import{B as e,C as t,G as n,I as r,J as i,R as a,S as o,T as s,f as c,ht as l,n as u,pt as d,r as f,t as p,u as m,v as h,w as g,x as _}from"./folders.j8Vf02Wn.js";import{c as v}from"./style.BtGWTIRi.js";import{i as y,n as b,r as x}from"../options.C1oHSPEM.js";import{t as S}from"./LinkCard.BUwb4UH-.js";import{t as C}from"./Breadcrumbs.U9RvuAvq.js";var w={class:`organize-view p-4`},T={class:`mb-4 flex items-center justify-between`},E={key:0,class:`text-lg font-medium text-foreground`},D={key:1,class:`text-lg font-medium text-foreground`},O={class:`flex items-center gap-2`},k=[`title`],A={key:1,class:`py-12 text-center`},j={class:`text-sm text-muted-foreground`},M={__name:`OrganizeView`,setup(M){let N=b(),P=x(),F=u(),I=p(),L=v();f();let R=n([]),z=n(L.viewMode||c.LIST),B=n(``),V=n(null),H=_(()=>{let e=[];if(N.name===`search`&&N.query.q)B.value=N.query.q,e=F.searchLinks(N.query.q);else if(N.name===`starred`)e=F.starredLinks;else if(N.params.folderId){F.getLinksByFolder(N.params.folderId).value;let t=I.getAllDescendantIds(N.params.folderId);e=F.links.filter(e=>e.folderId===N.params.folderId||t.includes(e.folderId))}else e=F.links;if(V.value&&(e=e.filter(e=>e.tags?.includes(V.value))),B.value&&N.name!==`search`){let t=B.value.toLowerCase();e=e.filter(e=>e.title?.toLowerCase().includes(t)||e.url.includes(t))}let t=L.sortBy||m.DATE_ADDED_DESC;return[...e].sort((e,n)=>{switch(t){case m.DATE_ADDED_DESC:return n.createdAt-e.createdAt;case m.DATE_ADDED_ASC:return e.createdAt-n.createdAt;case m.TITLE_ASC:return e.title.localeCompare(n.title);case m.TITLE_DESC:return n.title.localeCompare(e.title);default:return n.createdAt-e.createdAt}})}),U=_(()=>N.params.folderId?I.getFolder(N.params.folderId):null);function W(e){R.value.includes(e)?R.value=R.value.filter(t=>t!==e):R.value=[...R.value,e]}function G(){R.value=[]}function K(){R.value=H.value.map(e=>e.id)}let q=_(()=>R.value.length),J=_(()=>R.value.length>0);function Y(e){window.open(e.url,`_blank`)}function X(e){F.starLink(e.id,!e.starred)}function Z(){z.value=z.value===c.LIST?c.GRID:c.LIST,L.update(`viewMode`,z.value)}function Q(){P.push(`/settings`)}return e(()=>N.fullPath,()=>{G()}),(e,n)=>(r(),s(`div`,w,[i(N).params.folderId?(r(),t(C,{key:0,"folder-id":i(N).params.folderId},null,8,[`folder-id`])):g(``,!0),o(`div`,T,[U.value?(r(),s(`h2`,E,l(U.value.name),1)):(r(),s(`div`,D,`All Links`)),o(`div`,O,[o(`button`,{onClick:Z,class:`btn btn-ghost btn-sm`,title:`Switch to ${z.value===`list`?`grid`:`list`} view`},l(z.value===i(c).LIST?`☰`:`⬜`),9,k),o(`button`,{onClick:Q,class:`btn btn-ghost btn-sm`},` ⚙️ `)])]),H.value.length===0?(r(),s(`div`,A,[n[1]||=o(`div`,{class:`text-4xl mb-2`},`📭`,-1),n[2]||=o(`h3`,{class:`text-lg font-medium text-foreground mb-1`},`No links here`,-1),o(`p`,j,l(i(N).name===`search`?`Try a different search term`:`Capture links from the Capture page`),1),o(`button`,{onClick:n[0]||=e=>i(P).push(`/capture`),class:`btn btn-secondary btn-sm mt-4`},` Go to Capture `)])):(r(),s(`div`,{key:2,class:d([`grid gap-2`,z.value===i(c).GRID?`grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4`:`grid-cols-1`])},[(r(!0),s(h,null,a(H.value,e=>(r(),t(S,{key:e.id,link:e,selected:R.value.includes(e.id),"view-mode":z.value,onToggleSelect:t=>W(e.id),onToggleStar:t=>X(e),onOpen:t=>Y(e)},null,8,[`link`,`selected`,`view-mode`,`onToggleSelect`,`onToggleStar`,`onOpen`]))),128))],2)),J.value?(r(),t(y,{key:3,count:q.value,"selected-ids":R.value,onClear:G,onSelectAll:K},null,8,[`count`,`selected-ids`])):g(``,!0)]))}};export{M as default};