@augmentd-labs/canvas-web 2.26.26 → 2.26.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{FiltersApplet-BJALOBRh.js → FiltersApplet-C-WD5XT9.js} +1 -1
- package/dist/assets/{HomeFab-Chvwu8rQ.js → HomeFab-CzKEIYDk.js} +1 -1
- package/dist/assets/{LensApplet-Ckl0M4Wi.js → LensApplet-BCJXNx84.js} +1 -1
- package/dist/assets/{NotesApplet-tNMaEcoj.js → NotesApplet-CvPyt7xB.js} +1 -1
- package/dist/assets/{_agentId_-sMYqsnQk.js → _agentId_-BXYnpAWp.js} +0 -0
- package/dist/assets/{_contextId_-DRvqFeiU.js → _contextId_-BEC7o1ya.js} +1 -1
- package/dist/assets/{_workspaceName_-DqFTMP44.js → _workspaceName_-5rSLTtJT.js} +1 -1
- package/dist/assets/{about-DbGpwqCH.js → about-DrgIxiPQ.js} +1 -1
- package/dist/assets/{add-DsH8MVg6.js → add-CPkuZwMW.js} +1 -1
- package/dist/assets/agents-jmTwCDAu.js +1 -0
- package/dist/assets/{appearance-CN8I4_GQ.js → appearance-DRBtL9nd.js} +1 -1
- package/dist/assets/{apps-CvInUZwB.js → apps-CqFFzo_Z.js} +1 -1
- package/dist/assets/{content-app-view-BGg1GOMt.js → content-app-view-y5TmcjuO.js} +1 -1
- package/dist/assets/{home-CFZRa_Mu.js → home-C6aXJsmf.js} +1 -1
- package/dist/assets/{index-BytAmMhU.js → index-CyEIU2rL.js} +6 -6
- package/dist/assets/{key-bindings-Dfa7ehDw.js → key-bindings-BDktmxOD.js} +1 -1
- package/dist/assets/{registry--2kt6I6T.js → registry-ZMLdscra.js} +2 -2
- package/dist/assets/{settings-DhVz_Osu.js → settings-Be_a2PGC.js} +1 -1
- package/dist/assets/{settings-FiiJ5QFa.js → settings-DJyvE-wf.js} +1 -1
- package/dist/assets/settings-TQmRYAGg.js +1 -0
- package/dist/assets/{settings-BOHindnt.js → settings-VF2v3Ya5.js} +3 -3
- package/dist/assets/{share-target-fpk-pz15.js → share-target-BDbVdgTo.js} +1 -1
- package/dist/assets/{shared-CCCuTYCU.js → shared-BbAavKdN.js} +1 -1
- package/dist/assets/{useAgentModels-CwNiA-Ak.js → useAgentModels-PQVPjrQu.js} +1 -1
- package/dist/assets/workspaces-BGbHBVHs.js +1 -0
- package/dist/index.html +2 -2
- package/dist/sw.js +1 -1
- package/package.json +2 -2
- package/dist/assets/agents-BBKnR8_O.js +0 -1
- package/dist/assets/settings-N3fbO22m.js +0 -1
- package/dist/assets/workspaces-By3jZzrz.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{_ as r,r as i,v as a}from"./chunk-62JRHF6Z-vspAGgtK.js";import{t as o}from"./utils-2pl1SbIp.js";import{Pt as s}from"./workspace-CrSpR4xf.js";import{p as c}from"./context-DQoZFMDQ.js";import{t as l}from"./registry
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{_ as r,r as i,v as a}from"./chunk-62JRHF6Z-vspAGgtK.js";import{t as o}from"./utils-2pl1SbIp.js";import{Pt as s}from"./workspace-CrSpR4xf.js";import{p as c}from"./context-DQoZFMDQ.js";import{t as l}from"./registry-ZMLdscra.js";import{t as u}from"./applet-target-C_gBgU-Z.js";var d=e(n(),1),f=t(),p=`universe`;function m(){let{appletId:e}=r(),[t,n]=a(),m=l.find(t=>t.id===e),h=t.get(`context`),g=t.get(`workspace`)||p,_=t.get(`path`)||`/`,v=t.get(`tree`)||`context`,y=t.get(`add`)===`1`,b=(0,d.useMemo)(()=>h?{mode:`context`,contextId:h}:{mode:`workspace`,workspaceName:g,path:_,treeName:v,treeType:v===`directory`?`directory`:`context`},[h,g,_,v]),[x,S]=(0,d.useState)([]),[C,w]=(0,d.useState)([]);(0,d.useEffect)(()=>{s().then(S).catch(()=>S([])),c().then(w).catch(()=>w([]))},[]);let[T,E]=(0,d.useState)(_),[D,O]=(0,d.useState)(_);D!==_&&(O(_),E(_));let k=e=>{let r=new URLSearchParams(t);r.delete(`add`);for(let[t,n]of Object.entries(e))n===null?r.delete(t):r.set(t,n);n(r,{replace:!0})};if(!m)return(0,f.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col items-center justify-center gap-3 surface-desk`,children:[(0,f.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Unknown app`,e?` "${e}"`:``,`.`]}),(0,f.jsx)(`div`,{className:`flex gap-2`,children:l.map(e=>(0,f.jsx)(i,{to:`/apps/${e.id}`,className:`rounded-md border border-border px-3 py-1.5 text-sm hover:bg-muted`,children:e.label},e.id))})]});let A=h?`context`:`path`;return(0,f.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col surface-desk p-shell gap-shell`,children:[(0,f.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 rounded-xl border bg-card px-3 py-2 shadow-elevation-2`,children:[(0,f.jsx)(m.icon,{className:`h-4 w-4 text-muted-foreground`}),(0,f.jsx)(`span`,{className:`text-sm font-semibold`,children:m.label}),(0,f.jsx)(`div`,{className:`ml-2 flex overflow-hidden rounded-md border border-border`,children:[`path`,`context`].map(e=>(0,f.jsx)(`button`,{type:`button`,onClick:()=>{e!==A&&k(e===`path`?{context:null}:{context:C[0]?.id??``,workspace:null,path:null,tree:null})},className:o(`px-2.5 py-1 text-xs capitalize transition-colors`,A===e?`bg-foreground text-background`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:e},e))}),A===`path`?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`select`,{value:g,onChange:e=>k({workspace:e.target.value,path:`/`}),className:`h-7 rounded-md border border-input bg-transparent px-1.5 text-xs`,"aria-label":`Workspace`,children:[!x.some(e=>e.name===g)&&(0,f.jsx)(`option`,{value:g,children:g}),x.map(e=>(0,f.jsx)(`option`,{value:e.name,children:e.label||e.name},e.id))]}),(0,f.jsx)(`input`,{value:T,onChange:e=>E(e.target.value),onBlur:()=>{let e=T.trim()||`/`;e!==_&&k({path:e})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()},spellCheck:!1,placeholder:`/`,className:`h-7 w-40 rounded-md border border-input bg-transparent px-2 text-xs outline-none focus-visible:ring-1 focus-visible:ring-ring`,"aria-label":`Path`})]}):(0,f.jsxs)(`select`,{value:h??``,onChange:e=>k({context:e.target.value}),className:`h-7 max-w-56 rounded-md border border-input bg-transparent px-1.5 text-xs`,"aria-label":`Context`,children:[!h&&(0,f.jsx)(`option`,{value:``,children:`Pick a context…`}),C.map(e=>(0,f.jsxs)(`option`,{value:e.id,children:[e.id,e.url?` (${e.url})`:``]},e.id))]}),(0,f.jsx)(`div`,{className:`grow`})]}),(0,f.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border bg-card shadow-elevation-2`,children:A===`context`&&!h?(0,f.jsxs)(`div`,{className:`flex h-full items-center justify-center p-6 text-center text-sm text-muted-foreground`,children:[`Pick a context above to bind `,m.label,` to it.`]}):(0,f.jsx)(u,{target:b,children:(0,f.jsx)(m.Component,{autoAdd:y},JSON.stringify(b))})})]})}export{m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{h as r}from"./chunk-62JRHF6Z-vspAGgtK.js";import{Br as i,Ct as a,G as o,It as s,L as c,Lt as l,Nt as u,St as d,Tr as f,Ut as p,X as m,Yr as h,ct as g,it as _,mn as v,mt as y,ti as b,tt as x,vn as S,yn as C}from"./ui-Byg1cZDr.js";import{t as w}from"./utils-2pl1SbIp.js";import{An as T,Vn as E,q as D}from"./workspace-CrSpR4xf.js";import{t as O}from"./TodosWidget-CxiqmDuJ.js";import{d as ee,o as te,u as ne}from"./ObjectPropertiesCard-BIBMvx_i.js";import{h as re,s as ie,t as ae,u as oe}from"./document-list-DKOU9Kcc.js";import{n as se,r as ce}from"./use-toolbox-Ck_cLGgf.js";import{t as le}from"./useToastHelpers-CRrpIIdY.js";import{n as k}from"./color-DFEH4BfK.js";import{t as ue}from"./DocumentIcon-x299QNu_.js";import{r as de}from"./workspace-BydSRtST.js";import{t as fe}from"./registry--2kt6I6T.js";import{t as A}from"./FileForm-CqJpRbXv.js";import{t as j}from"./applet-target-C_gBgU-Z.js";var M=e(n(),1);function pe(e){let{pathname:t}=r(),n=ce()?.setAgentView,i=JSON.stringify(e);(0,M.useEffect)(()=>(n?.({pathname:t,view:JSON.parse(i)}),()=>n?.(null)),[t,i,n])}function me(e,t,n,r){return structuredClone({...e,query:de(t,n,r),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone})}var N=t();function he({target:e,children:t}){let[n,r]=(0,M.useState)([]),i=(0,M.useRef)(!1),[a,o]=(0,M.useState)(!1),[s,c]=(0,M.useState)(!1),[l,u]=(0,M.useState)(null),{showErrorToast:d}=le();return(0,N.jsxs)(`div`,{className:`relative flex flex-col h-full min-h-0 bg-background ${a?`ring-2 ring-inset ring-primary`:``}`,onDragOverCapture:t=>{s||!e||!Array.from(t.dataTransfer.types).includes(`Files`)||(t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect=i.current?`none`:`copy`,o(!i.current))},onDragLeaveCapture:e=>{e.currentTarget.contains(e.relatedTarget)||o(!1)},onDropCapture:t=>{if(s||!e||!Array.from(t.dataTransfer.types).includes(`Files`))return;if(t.preventDefault(),t.stopPropagation(),o(!1),i.current){d(`Wait for the current upload to finish`);return}let n=Array.from(t.dataTransfer.files);if(!n.length){d(`Drop files rather than folders`);return}r(n),u(e),c(!0)},children:[t,a&&(0,N.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 z-30 flex items-center justify-center bg-background/80 text-sm font-medium`,children:[`Drop files to upload to `,e?.mode===`workspace`?e.path:`this context`]}),s&&(0,N.jsxs)(oe,{label:`Import files`,onClose:()=>{i.current||c(!1)},children:[(0,N.jsx)(`h2`,{className:`border-b px-4 py-3 text-sm font-medium`,children:`Import files`}),(0,N.jsx)(A,{target:l,initialFiles:n,onClose:()=>c(!1),onBusyChange:e=>{i.current=e}})]})]})}function ge({navigationTabs:e,navigationActions:t,onBack:n,accentColor:r,frameContent:i=!0,urlType:c,urlDisplay:u,contextPath:d,treeName:f,workspaceId:p,workspaceLabel:h,workspaceIcon:g,documentSchema:_,documents:v,isLoading:x,totalCount:S,currentPage:w,pageSize:T,onPageChange:E,onPageSizeChange:D,onRemoveDocument:O,onDeleteDocument:ie,onDestroyDocument:oe,onRemoveDocuments:ce,onDeleteDocuments:le,onDestroyDocuments:k,onCopyDocuments:ue,onCutDocuments:de,onPasteDocuments:fe,onImportDocuments:A,onSelectionChange:j,pastedDocumentIds:pe,onPurgeDocuments:me,disablePurgeDocuments:ge,canvasInfo:P,isCanvasPinned:F,onTogglePinCanvas:I,onSaveAsCanvas:L,onShareCanvas:R,onUnshareCanvas:z,onDeleteCanvas:B,isSharingCanvas:V,isDeletingCanvas:H,isCanvasShared:U,isCanvasLocked:W,backendSearchQueries:G,onBackendSearch:K,onRemoveBackendQuery:_e,serverSort:ve,onServerSortChange:ye,scope:be,onScopeChange:xe,canSaveChanges:Se,isSavingChanges:q,onSaveChanges:J,onBrowseWorkspaces:Ce,onBrowseTree:we,onNavigatePath:Te,linkTree:Ee,children:Y,contentBanner:De,folders:Oe,onOpenFolder:ke}){let Ae=c===`canvas`,X=re(),{state:je,toggleView:Me,hasActiveFilters:Ne,openAddPicker:Pe}=se(),Z=te(),[Fe,Q]=(0,M.useState)(``),$=JSON.stringify([p,f,d,_]),[Ie,Le]=(0,M.useState)($);Ie!==$&&(Le($),Q(``));let Re=(0,N.jsxs)(N.Fragment,{children:[t,L&&(0,N.jsx)(`button`,{type:`button`,onClick:L,title:`Save as canvas`,"aria-label":`Save as canvas`,className:`flex h-control-sm w-control-sm shrink-0 items-center justify-center rounded-md border text-muted-foreground hover:bg-accent touch-target`,children:(0,N.jsx)(b,{className:`h-4 w-4`})})]});return(0,N.jsxs)(he,{target:A&&p?{mode:`workspace`,workspaceName:p,path:d,treeName:f||`context`,treeType:f===`directory`?`directory`:`context`}:null,children:[e&&!X&&(0,N.jsx)(ee,{accentColor:r,children:e}),(0,N.jsxs)(`div`,{className:`canvas-surface-body${i&&!X?` is-framed`:``}`,children:[(0,N.jsx)(ne,{workspaceIcon:g,workspace:h||p||u.split(`://`)[0]||`Workspace`,actions:X&&e?(0,N.jsxs)(`details`,{className:`relative shrink-0`,"aria-label":`Canvas views`,children:[(0,N.jsx)(`summary`,{className:`cursor-pointer rounded-md border px-2 py-1 text-xs`,title:`Choose or manage content views`,children:`Views`}),(0,N.jsx)(`div`,{className:`absolute right-0 top-full z-30 mt-2 min-w-64 max-w-[80vw] rounded-md border bg-background p-2 shadow-lg`,children:e})]}):void 0,tree:f?`${f}${c.endsWith(`-layer`)?`:layer`:``}`:c.replace(`-layer`,``),path:d,accentColor:r,onBack:Z.location?Z.location.section===`view`?Z.close:()=>Z.update?.({section:`view`}):n,section:Z.location?`document/${Z.location.documentId}/${Z.location.section}`:void 0,onSection:Z.location?()=>Z.update?.({section:`view`}):void 0,onBrowseWorkspaces:Ce,onBrowseTree:we,onNavigatePath:Te,onFilter:()=>Me(`tools`),filtersActive:Ne,filtersOpen:je.t1Open&&je.t1View===`tools`,onAdd:e=>Pe({modal:e.shiftKey,fresh:!0}),search:K||!Y?{workspaceId:p,queries:G||[],onSearch:K??Q,localOnly:!K,onRemoveQuery:_e,scope:be,onScopeChange:xe}:void 0,onDraftChange:Y?void 0:Q}),Ae&&P?(0,N.jsx)(N.Fragment,{children:(0,N.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2.5 border-b bg-muted/20 shrink-0 min-w-0`,children:[P.color&&(0,N.jsx)(`div`,{className:`w-1 h-6 rounded-full shrink-0`,style:{backgroundColor:P.color}}),(0,N.jsx)(C,{className:`w-4 h-4 shrink-0 text-primary`}),(0,N.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,N.jsx)(`span`,{className:`text-lg font-semibold leading-tight truncate`,children:P.label||u.split(`://`)[1]||`Canvas`}),P.description&&(0,N.jsx)(`span`,{className:`text-xs text-muted-foreground truncate leading-tight`,children:P.description})]}),Se&&J&&(0,N.jsxs)(`button`,{type:`button`,onClick:J,disabled:q,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 text-xs border rounded-md hover:bg-accent transition-colors text-muted-foreground hover:text-foreground disabled:opacity-50`,title:`Save filters`,children:[(0,N.jsx)(a,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:q?`Saving...`:`Save filters`})]}),I&&(0,N.jsxs)(`button`,{type:`button`,onClick:I,"aria-pressed":!!F,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 text-xs border rounded-md hover:bg-accent transition-colors text-muted-foreground hover:text-foreground`,title:F?`Unpin from home`:`Pin to home`,children:[F?(0,N.jsx)(l,{className:`w-3 h-3`}):(0,N.jsx)(s,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:F?`Unpin`:`Pin`})]}),R&&(0,N.jsxs)(`button`,{type:`button`,onClick:R,disabled:V||H,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 text-xs border rounded-md hover:bg-accent transition-colors text-muted-foreground hover:text-foreground disabled:opacity-50`,title:U?`Copy public link`:`Share canvas`,children:[(0,N.jsx)(y,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:V?`Sharing...`:U?`Copy link`:`Share`})]}),U&&z&&(0,N.jsxs)(`button`,{type:`button`,onClick:z,disabled:V||H,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 text-xs border rounded-md hover:bg-destructive/10 transition-colors text-muted-foreground hover:text-destructive disabled:opacity-50`,children:[(0,N.jsx)(o,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:`Unshare`})]}),B&&(0,N.jsxs)(`button`,{type:`button`,onClick:B,disabled:H||W&&!U,title:W&&!U?`Unlock this canvas before deleting it`:`Delete canvas`,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 text-xs border rounded-md hover:bg-destructive/10 transition-colors text-muted-foreground hover:text-destructive disabled:opacity-50`,children:[(0,N.jsx)(m,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:H?`Deleting…`:`Delete`})]})]})}):null,Y&&(L||t)&&(0,N.jsx)(`div`,{className:`flex items-center gap-2 border-b px-3 py-1`,children:Re}),(0,N.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:[De,Y||(0,N.jsx)(ae,{readingPane:!0,externalSearchQuery:Fe,toolbarActions:Re,documents:_?v.filter(e=>e.schema===_):v,isLoading:x,folders:_?void 0:Oe,onOpenFolder:ke,contextPath:d,treeName:f,workspaceId:p,totalCount:S,viewMode:_?`card`:`table`,allowViewToggle:!0,currentPage:w,pageSize:T,onPageChange:E,onPageSizeChange:D,onRemoveDocument:O,onDeleteDocument:ie,onDestroyDocument:oe,onRemoveDocuments:ce,onDeleteDocuments:le,onDestroyDocuments:k,onCopyDocuments:ue,onCutDocuments:de,onPasteDocuments:fe,onImportDocuments:A,onSelectionChange:j,pastedDocumentIds:pe,onPurgeDocuments:_?void 0:me,disablePurgeDocuments:ge,backendSearchQueries:G,onBackendSearch:K,serverSort:ve,onServerSortChange:ye,onRemoveBackendQuery:_e,scope:be,onScopeChange:xe,canSaveChanges:!Ae&&Se,isSavingChanges:q,onSaveChanges:J,linkTree:Ee},_??`documents`)]})]})]})}var P=[{id:`todos`,label:`Todo list`},{id:`todo-app`,label:`Todo App`},{id:`notes`,label:`Notes list`},{id:`notes-app`,label:`Notes App`},{id:`sketch`,label:`Sketch`},{id:`terminal`,label:`Terminal`}];function F(e){return e?.kind===`app`&&e.app===`notes`?`data/schema/note`:void 0}var I={id:`default`,name:`All`,kind:`documents`};function L(){return[{id:`emails`,label:`Emails`,schemas:[`data/schema/message`]},{id:`todos`,label:`Todos`,schemas:[`data/schema/task`]},{id:`notes`,label:`Notes`,schemas:[`data/schema/note`]},{id:`links`,label:`Links`,schemas:[`data/schema/tab`,`data/schema/link`]},{id:`files`,label:`Files`,schemas:[`data/schema/file`]}]}function R(e){let t=e?.views;if(!Array.isArray(t))return[I];let n=t.filter(e=>{let t=e;return!t||typeof t.id!=`string`||typeof t.name!=`string`?!1:t.kind===`documents`||t.kind===`columns`||t.kind===`app`&&(P.some(e=>e.id===t.app)||t.app===`filters`||t.app===`lens`)});return n.length>0?n:[I]}var z={todos:v,"todo-app":v,notes:x,"notes-app":x,filters:g,sketch:_,Brush:h,terminal:_,lens:d};function B({views:e,activeId:t,onSelect:n,onSave:r,readOnly:i=!1,className:a,accentColor:o,onOpenToSide:s}){let[l,d]=(0,M.useState)(null),[m,h]=(0,M.useState)(``),[g,_]=(0,M.useState)(!1),[v,y]=(0,M.useState)(null),[b,x]=(0,M.useState)(null),C=(0,M.useRef)(null);(0,M.useEffect)(()=>{let e=C.current;if(!e)return;let t=t=>{if(t.ctrlKey||e.scrollWidth<=e.clientWidth)return;let n=Math.abs(t.deltaX)>Math.abs(t.deltaY)?t.deltaX:t.deltaY,r=t.deltaMode===1?16:t.deltaMode===2?e.clientWidth:1;t.preventDefault(),e.scrollLeft+=n*r};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]),(0,M.useEffect)(()=>{C.current?.querySelector(`[aria-pressed="true"], input`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[t,l]);let T=()=>{y(null),x(null)},E=()=>{if(v&&b&&v!==b.id){let t=e.find(e=>e.id===v),n=e.filter(e=>e.id!==v),i=n.findIndex(e=>e.id===b.id);t&&i>=0&&(n.splice(b.before?i:i+1,0,t),n.some((t,n)=>t.id!==e[n].id)&&r(n))}T()},D=()=>{if(!l)return;let t=m.trim();t&&r(e.map(e=>e.id===l?{...e,name:t}:e)),d(null)},O=(t,n)=>{_(!1);let i=`view-${Date.now().toString(36)}`,a=t===`columns`?`Board`:t===`app`?P.find(e=>e.id===n)?.label??`App`:`List`,o=t===`columns`?{id:i,name:a,kind:t,columns:L()}:t===`app`?{id:i,name:a,kind:t,app:n}:{id:i,name:a,kind:t};r([...e,o],i),d(i),h(a)},ee=n=>{let i=e.filter(e=>e.id!==n);r(i.length>0?i:[I],n===t?i[0]?.id??I.id:void 0)};return(0,N.jsxs)(`div`,{className:w(`relative flex h-full min-w-0 items-end`,a),children:[(0,N.jsx)(`div`,{ref:C,className:`flex min-w-0 items-end gap-0.5 overflow-x-auto overscroll-x-contain pt-1 [scrollbar-width:none]`,children:e.map(r=>{let a=r.id===t,u=r.kind===`columns`?f:r.kind===`app`&&r.app?z[r.app]:S;return l===r.id?(0,N.jsx)(`input`,{autoFocus:!0,"aria-label":`Tab name`,value:m,onChange:e=>h(e.target.value),onBlur:D,onKeyDown:e=>{e.key===`Enter`&&D(),e.key===`Escape`&&d(null)},className:w(`relative h-[2.3rem] w-28 shrink-0 rounded-t-[.5rem] border-0 px-3 pb-1 text-xs outline-none ring-0`,a?w(`z-[2] bg-background font-medium`,o?k(o):`text-foreground`):`bg-muted text-muted-foreground`),style:{backgroundColor:a?o:void 0}},r.id):(0,N.jsxs)(`button`,{type:`button`,"aria-pressed":a,onClick:()=>n(r.id),onDoubleClick:()=>{i||(d(r.id),h(r.name))},title:i?r.name:`${r.name}: double-click to rename, drag to reorder`,draggable:!i,onDragStart:e=>{e.dataTransfer.setData(`text/plain`,r.name),e.dataTransfer.effectAllowed=`move`,y(r.id)},onDragOver:e=>{if(!v||v===r.id)return;e.preventDefault(),e.dataTransfer.dropEffect=`move`;let t=e.currentTarget.getBoundingClientRect(),n=e.clientX<t.left+t.width/2;x(e=>e?.id===r.id&&e.before===n?e:{id:r.id,before:n})},onDrop:e=>{e.preventDefault(),E()},onDragEnd:T,className:w(`group relative flex h-[2.3rem] shrink-0 items-center gap-1.5 rounded-t-[.5rem] border-0 px-3 pb-1 text-xs transition-colors`,a?w(`z-[2] bg-background font-medium`,o?k(o):`text-foreground`):`bg-muted text-muted-foreground hover:bg-accent hover:text-foreground`,v===r.id&&`opacity-50`),style:{backgroundColor:a?o:void 0,boxShadow:b?.id===r.id?`inset ${b.before?`2px`:`-2px`} 0 0 var(--primary)`:void 0},children:[(0,N.jsx)(u,{className:`h-3 w-3 shrink-0`}),(0,N.jsx)(`span`,{className:`max-w-32 truncate`,children:r.name}),s&&(0,N.jsx)(p,{className:`h-3 w-3 shrink-0 opacity-0 transition-opacity hover:opacity-100 group-hover:opacity-60`,"aria-label":`Open to the side`,onClick:e=>{e.stopPropagation(),s(r.id)}}),!i&&e.length>1&&(0,N.jsx)(c,{className:w(`h-3 w-3 shrink-0 transition-opacity hover:text-destructive`,a?`opacity-60 hover:opacity-100`:`opacity-0 group-hover:opacity-100`),onClick:e=>{e.stopPropagation(),ee(r.id)}})]},r.id)})}),!i&&(g?(0,N.jsxs)(`span`,{className:`absolute left-0 top-full z-30 flex w-full min-w-64 flex-wrap items-center gap-2 rounded-b-xl border bg-card p-2 shadow-lg`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>O(`documents`),className:`flex h-10 items-center gap-1.5 rounded-md border px-2 text-xs text-muted-foreground hover:bg-accent/50 hover:text-foreground`,children:[(0,N.jsx)(S,{className:`h-3 w-3`}),` List`]}),(0,N.jsxs)(`button`,{type:`button`,onClick:()=>O(`columns`),className:`flex h-10 items-center gap-1.5 rounded-md border px-2 text-xs text-muted-foreground hover:bg-accent/50 hover:text-foreground`,children:[(0,N.jsx)(f,{className:`h-3 w-3`}),` Board`]}),P.map(e=>{let t=z[e.id];return(0,N.jsxs)(`button`,{type:`button`,onClick:()=>O(`app`,e.id),className:`flex h-10 items-center gap-1.5 rounded-md border px-2 text-xs text-muted-foreground hover:bg-accent/50 hover:text-foreground`,children:[(0,N.jsx)(t,{className:`h-3 w-3`}),` `,e.label]},e.id)}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>_(!1),className:`p-1 text-muted-foreground hover:text-foreground`,"aria-label":`Cancel`,children:(0,N.jsx)(c,{className:`h-3 w-3`})})]}):(0,N.jsx)(`button`,{type:`button`,onClick:()=>_(!0),title:`Add view`,"aria-label":`Add view`,className:`relative ml-1 flex h-[2.3rem] w-10 shrink-0 items-center justify-center rounded-md pb-1 text-muted-foreground hover:bg-accent/50 hover:text-foreground`,children:(0,N.jsx)(u,{className:`h-3.5 w-3.5`})}))]})}var V=[{id:`emails`,label:`Emails`,schemas:[`data/schema/message`]},{id:`todos`,label:`Todos`,schemas:[`data/schema/task`]},{id:`notes`,label:`Notes`,schemas:[`data/schema/note`]},{id:`links`,label:`Links`,schemas:[`data/schema/tab`,`data/schema/link`]},{id:`files`,label:`Files`,schemas:[`data/schema/file`]}];function H(e,t){return t.some(t=>e.schema===t||e.schema.startsWith(`${t}/`))}function U({documents:e,workspaceId:t,columns:n,onColumnsChange:r,readOnly:a=!1}){let[o,s]=(0,M.useState)(null),[l,d]=(0,M.useState)(!1),[f,p]=(0,M.useState)({}),[m,h]=(0,M.useState)({}),g=(0,M.useRef)(null),[_,v]=(0,M.useState)(!1),y=(0,M.useCallback)(()=>{let e=g.current;e&&v(e.scrollWidth-e.clientWidth-e.scrollLeft>8)},[]);(0,M.useEffect)(()=>{let e=g.current;if(!e)return;let t=new ResizeObserver(()=>y());return t.observe(e),()=>t.disconnect()},[y]);let b=(e,t)=>{e.preventDefault();let i=e.currentTarget.parentElement;if(!i)return;let a=e.clientX,o=i.getBoundingClientRect().width,s=o,c=e=>{s=Math.min(900,Math.max(220,o+e.clientX-a)),h(e=>({...e,[t]:s}))},l=()=>{window.removeEventListener(`pointermove`,c),window.removeEventListener(`pointerup`,l),r(n.map(e=>e.id===t?{...e,width:Math.round(s)}:e))};window.addEventListener(`pointermove`,c),window.addEventListener(`pointerup`,l)},x=e=>{h(t=>{let n={...t};return delete n[e],n}),r(n.map(t=>t.id===e?{...t,width:void 0}:t))},S=e=>{let t=f[e];if(t===void 0)return;let i=n.find(t=>t.id===e);i&&(i.filter||``)!==t&&r(n.map(n=>n.id===e?{...n,filter:t||void 0}:n))},C=V.filter(e=>!n.some(t=>t.id===e.id));return(0,N.jsxs)(`div`,{className:`relative h-full`,children:[(0,N.jsx)(`div`,{ref:g,onScroll:y,className:`flex h-full snap-x snap-mandatory gap-3 overflow-x-auto overscroll-x-contain p-2`,"data-testid":`schema-columns-board`,children:n.map(t=>{let i=(f[t.id]??t.filter??``).toLowerCase(),o=e.filter(e=>H(e,t.schemas)).filter(e=>{if(!i)return!0;let t=T(e);return`${t.title}\n${t.preview}\n${t.subtitle}`.toLowerCase().includes(i)}),l=m[t.id]??t.width;return(0,N.jsxs)(`div`,{className:`relative flex h-full min-h-0 min-w-0 shrink-0 grow-0 basis-full snap-start flex-col rounded-(--card-radius) border bg-muted/20 ${l?`sm:basis-[var(--col-w)]`:`sm:basis-[48%] lg:basis-[32%] xl:basis-[24%]`}`,style:l?{"--col-w":`${l}px`}:void 0,children:[!a&&(0,N.jsx)(`div`,{onPointerDown:e=>b(e,t.id),onDoubleClick:()=>x(t.id),title:`Drag to resize; double-click to reset`,className:`absolute right-0 inset-y-0 z-10 w-2 cursor-col-resize touch-none rounded-r-lg transition-colors hover:bg-primary/25 active:bg-primary/40 max-sm:hidden`}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2 px-3 pb-1 pt-2.5 max-sm:pr-10`,children:[(0,N.jsx)(`span`,{className:`truncate text-sm font-medium`,children:t.label}),(0,N.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:o.length}),(0,N.jsx)(`span`,{className:`flex-1`}),!a&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>r(n.filter(e=>e.id!==t.id)),title:`Remove column`,className:`rounded-sm p-0.5 text-muted-foreground hover:text-destructive`,children:(0,N.jsx)(c,{className:`h-3.5 w-3.5`})})]}),(0,N.jsx)(`div`,{className:`px-3 pb-2`,children:(0,N.jsx)(`input`,{value:f[t.id]??t.filter??``,onChange:e=>p(n=>({...n,[t.id]:e.target.value})),onBlur:()=>S(t.id),onKeyDown:e=>{e.key===`Enter`&&S(t.id)},placeholder:`Filter…`,readOnly:a,className:`h-7 w-full rounded-md border border-input bg-background px-2 text-xs placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`})}),(0,N.jsxs)(`div`,{className:`flex-1 space-y-1.5 overflow-y-auto px-2 pb-2`,children:[o.map(e=>{let t=T(e);return(0,N.jsxs)(`button`,{type:`button`,onClick:()=>s(e),className:`w-full min-w-0 rounded-md border bg-card px-2.5 py-2 text-left transition-colors hover:bg-accent/50`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,N.jsx)(ue,{document:e,size:3.5}),(0,N.jsx)(`span`,{className:`truncate text-xs font-medium`,title:t.title,children:t.title})]}),t.preview&&(0,N.jsx)(`p`,{className:`mt-1 line-clamp-2 break-words text-[11px] leading-snug text-muted-foreground`,children:t.preview}),(0,N.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground/70`,children:new Date(e.updatedAt||e.createdAt).toLocaleDateString()})]},e.id)}),o.length===0&&(0,N.jsx)(`p`,{className:`px-2 py-3 text-center text-xs text-muted-foreground/60`,children:`Empty`})]})]},t.id)})}),(!a&&C.length>0||_)&&(0,N.jsxs)(`div`,{className:`pointer-events-none absolute inset-y-0 right-0 z-20 flex w-7 flex-col items-end bg-gradient-to-l from-background via-background/60 to-transparent py-2`,children:[!a&&C.length>0&&(0,N.jsxs)(`div`,{className:`pointer-events-auto relative`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>d(e=>!e),title:`Add column`,"aria-label":`Add column`,className:`flex h-7 w-6 items-center justify-center rounded-l-md border border-r-0 bg-background text-muted-foreground shadow-elevation-1 hover:bg-accent hover:text-foreground`,children:(0,N.jsx)(u,{className:`h-3.5 w-3.5`})}),l&&(0,N.jsxs)(`div`,{className:`absolute right-0 top-8 w-44 rounded-lg border bg-background p-2 shadow-elevation-2`,children:[(0,N.jsx)(`p`,{className:`px-2 pb-1 text-[10px] uppercase tracking-wide text-muted-foreground`,children:`Add column`}),C.map(e=>(0,N.jsx)(`button`,{type:`button`,onClick:()=>{d(!1),r([...n,{...e}])},className:`w-full rounded-md px-2 py-1.5 text-left text-xs text-muted-foreground hover:bg-accent/50 hover:text-foreground`,children:e.label},e.id)),(0,N.jsx)(`button`,{type:`button`,onClick:()=>d(!1),className:`mt-1 w-full rounded-md px-2 py-1.5 text-left text-xs text-muted-foreground/60 hover:bg-accent/50`,children:`Cancel`})]})]}),_&&(0,N.jsx)(i,{className:`my-auto h-4 w-4 self-center text-muted-foreground/70`,"aria-label":`More columns`})]}),(0,N.jsx)(ie,{document:o,isOpen:o!==null,onClose:()=>s(null),workspaceId:t})]})}function W(e,t,n,r,i){let a=`${e}\0${t}\0${n}\0${r}\0${i??``}`,[o,s]=(0,M.useState)(0),[c,l]=(0,M.useState)(null);(0,M.useEffect)(()=>{let o=!1;return D(e,n,t,{limit:200,allOf:[r],...i?{sortBy:i,order:`asc`}:{}}).then(e=>{o||l({key:a,docs:e.payload||[]})}).catch(()=>{o||l({key:a,docs:[]})}),()=>{o=!0}},[a,o]);let u=c?.key===a?c.docs:[],d=c?.key!==a;return(0,M.useEffect)(()=>{let e=()=>s(e=>e+1);return window.addEventListener(`workspace:documents:refresh`,e),()=>window.removeEventListener(`workspace:documents:refresh`,e)},[]),{docs:u,isLoading:d,refresh:(0,M.useCallback)(()=>s(e=>e+1),[])}}function G({workspaceId:e,treeName:t,path:n}){let{docs:r,isLoading:i,refresh:a}=W(e,t,n,E,`tasks`),[o,s]=(0,M.useState)(!1),c=o?r.filter(e=>e.data?.status!==`completed`):r,l=r.filter(e=>{let t=e.data?.status;return t!==`completed`&&t!==`cancelled`}).length;return(0,N.jsxs)(`div`,{className:`mx-auto flex h-full w-full max-w-3xl flex-col p-4`,children:[(0,N.jsxs)(`div`,{className:`mb-2 flex shrink-0 items-center justify-between gap-2`,children:[(0,N.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[l,` open`]}),(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`hide done`]})]}),(0,N.jsx)(`div`,{className:`min-h-0 flex-1 space-y-1 overflow-y-auto`,children:i?(0,N.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`Loading…`}):c.length===0?(0,N.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No todos here.`}):c.map(t=>(0,N.jsx)(O,{doc:t,workspaceId:e,readOnly:!1,onChanged:a},t.id))})]})}function K({app:e,contextId:t,...n}){let r=t&&e!==`lens`?{mode:`context`,contextId:t}:{mode:`workspace`,workspaceName:n.workspaceId,treeName:n.treeName,path:n.path,treeType:n.treeName===`directory`||n.treeName===`backends`?`directory`:`context`},i=e===`todo-app`?`todo`:e===`notes-app`?`notes`:e,a=fe.find(e=>e.id===i);return(0,N.jsx)(j,{target:r,children:e===`todos`?(0,N.jsx)(G,{...n}):a?(0,N.jsx)(a.Component,{}):null})}export{F as a,me as c,I as i,pe as l,U as n,R as o,B as r,ge as s,K as t};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{h as r}from"./chunk-62JRHF6Z-vspAGgtK.js";import{Br as i,Ct as a,G as o,It as s,L as c,Lt as l,Nt as u,St as d,Tr as f,Ut as p,X as m,Yr as h,ct as g,it as _,mn as v,mt as y,ti as b,tt as x,vn as S,yn as C}from"./ui-Byg1cZDr.js";import{t as w}from"./utils-2pl1SbIp.js";import{An as T,Vn as E,q as D}from"./workspace-CrSpR4xf.js";import{t as O}from"./TodosWidget-CxiqmDuJ.js";import{d as ee,o as te,u as ne}from"./ObjectPropertiesCard-BIBMvx_i.js";import{h as re,s as ie,t as ae,u as oe}from"./document-list-DKOU9Kcc.js";import{n as se,r as ce}from"./use-toolbox-Ck_cLGgf.js";import{t as le}from"./useToastHelpers-CRrpIIdY.js";import{n as k}from"./color-DFEH4BfK.js";import{t as ue}from"./DocumentIcon-x299QNu_.js";import{r as de}from"./workspace-BydSRtST.js";import{t as fe}from"./registry-ZMLdscra.js";import{t as A}from"./FileForm-CqJpRbXv.js";import{t as j}from"./applet-target-C_gBgU-Z.js";var M=e(n(),1);function pe(e){let{pathname:t}=r(),n=ce()?.setAgentView,i=JSON.stringify(e);(0,M.useEffect)(()=>(n?.({pathname:t,view:JSON.parse(i)}),()=>n?.(null)),[t,i,n])}function me(e,t,n,r){return structuredClone({...e,query:de(t,n,r),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone})}var N=t();function he({target:e,children:t}){let[n,r]=(0,M.useState)([]),i=(0,M.useRef)(!1),[a,o]=(0,M.useState)(!1),[s,c]=(0,M.useState)(!1),[l,u]=(0,M.useState)(null),{showErrorToast:d}=le();return(0,N.jsxs)(`div`,{className:`relative flex flex-col h-full min-h-0 bg-background ${a?`ring-2 ring-inset ring-primary`:``}`,onDragOverCapture:t=>{s||!e||!Array.from(t.dataTransfer.types).includes(`Files`)||(t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect=i.current?`none`:`copy`,o(!i.current))},onDragLeaveCapture:e=>{e.currentTarget.contains(e.relatedTarget)||o(!1)},onDropCapture:t=>{if(s||!e||!Array.from(t.dataTransfer.types).includes(`Files`))return;if(t.preventDefault(),t.stopPropagation(),o(!1),i.current){d(`Wait for the current upload to finish`);return}let n=Array.from(t.dataTransfer.files);if(!n.length){d(`Drop files rather than folders`);return}r(n),u(e),c(!0)},children:[t,a&&(0,N.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 z-30 flex items-center justify-center bg-background/80 text-sm font-medium`,children:[`Drop files to upload to `,e?.mode===`workspace`?e.path:`this context`]}),s&&(0,N.jsxs)(oe,{label:`Import files`,onClose:()=>{i.current||c(!1)},children:[(0,N.jsx)(`h2`,{className:`border-b px-4 py-3 text-sm font-medium`,children:`Import files`}),(0,N.jsx)(A,{target:l,initialFiles:n,onClose:()=>c(!1),onBusyChange:e=>{i.current=e}})]})]})}function ge({navigationTabs:e,navigationActions:t,onBack:n,accentColor:r,frameContent:i=!0,urlType:c,urlDisplay:u,contextPath:d,treeName:f,workspaceId:p,workspaceLabel:h,workspaceIcon:g,documentSchema:_,documents:v,isLoading:x,totalCount:S,currentPage:w,pageSize:T,onPageChange:E,onPageSizeChange:D,onRemoveDocument:O,onDeleteDocument:ie,onDestroyDocument:oe,onRemoveDocuments:ce,onDeleteDocuments:le,onDestroyDocuments:k,onCopyDocuments:ue,onCutDocuments:de,onPasteDocuments:fe,onImportDocuments:A,onSelectionChange:j,pastedDocumentIds:pe,onPurgeDocuments:me,disablePurgeDocuments:ge,canvasInfo:P,isCanvasPinned:F,onTogglePinCanvas:I,onSaveAsCanvas:L,onShareCanvas:R,onUnshareCanvas:z,onDeleteCanvas:B,isSharingCanvas:V,isDeletingCanvas:H,isCanvasShared:U,isCanvasLocked:W,backendSearchQueries:G,onBackendSearch:K,onRemoveBackendQuery:_e,serverSort:ve,onServerSortChange:ye,scope:be,onScopeChange:xe,canSaveChanges:Se,isSavingChanges:q,onSaveChanges:J,onBrowseWorkspaces:Ce,onBrowseTree:we,onNavigatePath:Te,linkTree:Ee,children:Y,contentBanner:De,folders:Oe,onOpenFolder:ke}){let Ae=c===`canvas`,X=re(),{state:je,toggleView:Me,hasActiveFilters:Ne,openAddPicker:Pe}=se(),Z=te(),[Fe,Q]=(0,M.useState)(``),$=JSON.stringify([p,f,d,_]),[Ie,Le]=(0,M.useState)($);Ie!==$&&(Le($),Q(``));let Re=(0,N.jsxs)(N.Fragment,{children:[t,L&&(0,N.jsx)(`button`,{type:`button`,onClick:L,title:`Save as canvas`,"aria-label":`Save as canvas`,className:`flex h-control-sm w-control-sm shrink-0 items-center justify-center rounded-md border text-muted-foreground hover:bg-accent touch-target`,children:(0,N.jsx)(b,{className:`h-4 w-4`})})]});return(0,N.jsxs)(he,{target:A&&p?{mode:`workspace`,workspaceName:p,path:d,treeName:f||`context`,treeType:f===`directory`?`directory`:`context`}:null,children:[e&&!X&&(0,N.jsx)(ee,{accentColor:r,children:e}),(0,N.jsxs)(`div`,{className:`canvas-surface-body${i&&!X?` is-framed`:``}`,children:[(0,N.jsx)(ne,{workspaceIcon:g,workspace:h||p||u.split(`://`)[0]||`Workspace`,actions:X&&e?(0,N.jsxs)(`details`,{className:`relative shrink-0`,"aria-label":`Canvas views`,children:[(0,N.jsx)(`summary`,{className:`cursor-pointer rounded-md border px-2 py-1 text-xs`,title:`Choose or manage content views`,children:`Views`}),(0,N.jsx)(`div`,{className:`absolute right-0 top-full z-30 mt-2 min-w-64 max-w-[80vw] rounded-md border bg-background p-2 shadow-lg`,children:e})]}):void 0,tree:f?`${f}${c.endsWith(`-layer`)?`:layer`:``}`:c.replace(`-layer`,``),path:d,accentColor:r,onBack:Z.location?Z.location.section===`view`?Z.close:()=>Z.update?.({section:`view`}):n,section:Z.location?`document/${Z.location.documentId}/${Z.location.section}`:void 0,onSection:Z.location?()=>Z.update?.({section:`view`}):void 0,onBrowseWorkspaces:Ce,onBrowseTree:we,onNavigatePath:Te,onFilter:()=>Me(`tools`),filtersActive:Ne,filtersOpen:je.t1Open&&je.t1View===`tools`,onAdd:e=>Pe({modal:e.shiftKey,fresh:!0}),search:K||!Y?{workspaceId:p,queries:G||[],onSearch:K??Q,localOnly:!K,onRemoveQuery:_e,scope:be,onScopeChange:xe}:void 0,onDraftChange:Y?void 0:Q}),Ae&&P?(0,N.jsx)(N.Fragment,{children:(0,N.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2.5 border-b bg-muted/20 shrink-0 min-w-0`,children:[P.color&&(0,N.jsx)(`div`,{className:`w-1 h-6 rounded-full shrink-0`,style:{backgroundColor:P.color}}),(0,N.jsx)(C,{className:`w-4 h-4 shrink-0 text-primary`}),(0,N.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,N.jsx)(`span`,{className:`text-lg font-semibold leading-tight truncate`,children:P.label||u.split(`://`)[1]||`Canvas`}),P.description&&(0,N.jsx)(`span`,{className:`text-xs text-muted-foreground truncate leading-tight`,children:P.description})]}),Se&&J&&(0,N.jsxs)(`button`,{type:`button`,onClick:J,disabled:q,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 text-xs border rounded-md hover:bg-accent transition-colors text-muted-foreground hover:text-foreground disabled:opacity-50`,title:`Save filters`,children:[(0,N.jsx)(a,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:q?`Saving...`:`Save filters`})]}),I&&(0,N.jsxs)(`button`,{type:`button`,onClick:I,"aria-pressed":!!F,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 text-xs border rounded-md hover:bg-accent transition-colors text-muted-foreground hover:text-foreground`,title:F?`Unpin from home`:`Pin to home`,children:[F?(0,N.jsx)(l,{className:`w-3 h-3`}):(0,N.jsx)(s,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:F?`Unpin`:`Pin`})]}),R&&(0,N.jsxs)(`button`,{type:`button`,onClick:R,disabled:V||H,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 text-xs border rounded-md hover:bg-accent transition-colors text-muted-foreground hover:text-foreground disabled:opacity-50`,title:U?`Copy public link`:`Share canvas`,children:[(0,N.jsx)(y,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:V?`Sharing...`:U?`Copy link`:`Share`})]}),U&&z&&(0,N.jsxs)(`button`,{type:`button`,onClick:z,disabled:V||H,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 text-xs border rounded-md hover:bg-destructive/10 transition-colors text-muted-foreground hover:text-destructive disabled:opacity-50`,children:[(0,N.jsx)(o,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:`Unshare`})]}),B&&(0,N.jsxs)(`button`,{type:`button`,onClick:B,disabled:H||W&&!U,title:W&&!U?`Unlock this canvas before deleting it`:`Delete canvas`,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 text-xs border rounded-md hover:bg-destructive/10 transition-colors text-muted-foreground hover:text-destructive disabled:opacity-50`,children:[(0,N.jsx)(m,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:H?`Deleting…`:`Delete`})]})]})}):null,Y&&(L||t)&&(0,N.jsx)(`div`,{className:`flex items-center gap-2 border-b px-3 py-1`,children:Re}),(0,N.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:[De,Y||(0,N.jsx)(ae,{readingPane:!0,externalSearchQuery:Fe,toolbarActions:Re,documents:_?v.filter(e=>e.schema===_):v,isLoading:x,folders:_?void 0:Oe,onOpenFolder:ke,contextPath:d,treeName:f,workspaceId:p,totalCount:S,viewMode:_?`card`:`table`,allowViewToggle:!0,currentPage:w,pageSize:T,onPageChange:E,onPageSizeChange:D,onRemoveDocument:O,onDeleteDocument:ie,onDestroyDocument:oe,onRemoveDocuments:ce,onDeleteDocuments:le,onDestroyDocuments:k,onCopyDocuments:ue,onCutDocuments:de,onPasteDocuments:fe,onImportDocuments:A,onSelectionChange:j,pastedDocumentIds:pe,onPurgeDocuments:_?void 0:me,disablePurgeDocuments:ge,backendSearchQueries:G,onBackendSearch:K,serverSort:ve,onServerSortChange:ye,onRemoveBackendQuery:_e,scope:be,onScopeChange:xe,canSaveChanges:!Ae&&Se,isSavingChanges:q,onSaveChanges:J,linkTree:Ee},_??`documents`)]})]})]})}var P=[{id:`todos`,label:`Todo list`},{id:`todo-app`,label:`Todo App`},{id:`notes`,label:`Notes list`},{id:`notes-app`,label:`Notes App`},{id:`sketch`,label:`Sketch`},{id:`terminal`,label:`Terminal`}];function F(e){return e?.kind===`app`&&e.app===`notes`?`data/schema/note`:void 0}var I={id:`default`,name:`All`,kind:`documents`};function L(){return[{id:`emails`,label:`Emails`,schemas:[`data/schema/message`]},{id:`todos`,label:`Todos`,schemas:[`data/schema/task`]},{id:`notes`,label:`Notes`,schemas:[`data/schema/note`]},{id:`links`,label:`Links`,schemas:[`data/schema/tab`,`data/schema/link`]},{id:`files`,label:`Files`,schemas:[`data/schema/file`]}]}function R(e){let t=e?.views;if(!Array.isArray(t))return[I];let n=t.filter(e=>{let t=e;return!t||typeof t.id!=`string`||typeof t.name!=`string`?!1:t.kind===`documents`||t.kind===`columns`||t.kind===`app`&&(P.some(e=>e.id===t.app)||t.app===`filters`||t.app===`lens`)});return n.length>0?n:[I]}var z={todos:v,"todo-app":v,notes:x,"notes-app":x,filters:g,sketch:_,Brush:h,terminal:_,lens:d};function B({views:e,activeId:t,onSelect:n,onSave:r,readOnly:i=!1,className:a,accentColor:o,onOpenToSide:s}){let[l,d]=(0,M.useState)(null),[m,h]=(0,M.useState)(``),[g,_]=(0,M.useState)(!1),[v,y]=(0,M.useState)(null),[b,x]=(0,M.useState)(null),C=(0,M.useRef)(null);(0,M.useEffect)(()=>{let e=C.current;if(!e)return;let t=t=>{if(t.ctrlKey||e.scrollWidth<=e.clientWidth)return;let n=Math.abs(t.deltaX)>Math.abs(t.deltaY)?t.deltaX:t.deltaY,r=t.deltaMode===1?16:t.deltaMode===2?e.clientWidth:1;t.preventDefault(),e.scrollLeft+=n*r};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]),(0,M.useEffect)(()=>{C.current?.querySelector(`[aria-pressed="true"], input`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[t,l]);let T=()=>{y(null),x(null)},E=()=>{if(v&&b&&v!==b.id){let t=e.find(e=>e.id===v),n=e.filter(e=>e.id!==v),i=n.findIndex(e=>e.id===b.id);t&&i>=0&&(n.splice(b.before?i:i+1,0,t),n.some((t,n)=>t.id!==e[n].id)&&r(n))}T()},D=()=>{if(!l)return;let t=m.trim();t&&r(e.map(e=>e.id===l?{...e,name:t}:e)),d(null)},O=(t,n)=>{_(!1);let i=`view-${Date.now().toString(36)}`,a=t===`columns`?`Board`:t===`app`?P.find(e=>e.id===n)?.label??`App`:`List`,o=t===`columns`?{id:i,name:a,kind:t,columns:L()}:t===`app`?{id:i,name:a,kind:t,app:n}:{id:i,name:a,kind:t};r([...e,o],i),d(i),h(a)},ee=n=>{let i=e.filter(e=>e.id!==n);r(i.length>0?i:[I],n===t?i[0]?.id??I.id:void 0)};return(0,N.jsxs)(`div`,{className:w(`relative flex h-full min-w-0 items-end`,a),children:[(0,N.jsx)(`div`,{ref:C,className:`flex min-w-0 items-end gap-0.5 overflow-x-auto overscroll-x-contain pt-1 [scrollbar-width:none]`,children:e.map(r=>{let a=r.id===t,u=r.kind===`columns`?f:r.kind===`app`&&r.app?z[r.app]:S;return l===r.id?(0,N.jsx)(`input`,{autoFocus:!0,"aria-label":`Tab name`,value:m,onChange:e=>h(e.target.value),onBlur:D,onKeyDown:e=>{e.key===`Enter`&&D(),e.key===`Escape`&&d(null)},className:w(`relative h-[2.3rem] w-28 shrink-0 rounded-t-[.5rem] border-0 px-3 pb-1 text-xs outline-none ring-0`,a?w(`z-[2] bg-background font-medium`,o?k(o):`text-foreground`):`bg-muted text-muted-foreground`),style:{backgroundColor:a?o:void 0}},r.id):(0,N.jsxs)(`button`,{type:`button`,"aria-pressed":a,onClick:()=>n(r.id),onDoubleClick:()=>{i||(d(r.id),h(r.name))},title:i?r.name:`${r.name}: double-click to rename, drag to reorder`,draggable:!i,onDragStart:e=>{e.dataTransfer.setData(`text/plain`,r.name),e.dataTransfer.effectAllowed=`move`,y(r.id)},onDragOver:e=>{if(!v||v===r.id)return;e.preventDefault(),e.dataTransfer.dropEffect=`move`;let t=e.currentTarget.getBoundingClientRect(),n=e.clientX<t.left+t.width/2;x(e=>e?.id===r.id&&e.before===n?e:{id:r.id,before:n})},onDrop:e=>{e.preventDefault(),E()},onDragEnd:T,className:w(`group relative flex h-[2.3rem] shrink-0 items-center gap-1.5 rounded-t-[.5rem] border-0 px-3 pb-1 text-xs transition-colors`,a?w(`z-[2] bg-background font-medium`,o?k(o):`text-foreground`):`bg-muted text-muted-foreground hover:bg-accent hover:text-foreground`,v===r.id&&`opacity-50`),style:{backgroundColor:a?o:void 0,boxShadow:b?.id===r.id?`inset ${b.before?`2px`:`-2px`} 0 0 var(--primary)`:void 0},children:[(0,N.jsx)(u,{className:`h-3 w-3 shrink-0`}),(0,N.jsx)(`span`,{className:`max-w-32 truncate`,children:r.name}),s&&(0,N.jsx)(p,{className:`h-3 w-3 shrink-0 opacity-0 transition-opacity hover:opacity-100 group-hover:opacity-60`,"aria-label":`Open to the side`,onClick:e=>{e.stopPropagation(),s(r.id)}}),!i&&e.length>1&&(0,N.jsx)(c,{className:w(`h-3 w-3 shrink-0 transition-opacity hover:text-destructive`,a?`opacity-60 hover:opacity-100`:`opacity-0 group-hover:opacity-100`),onClick:e=>{e.stopPropagation(),ee(r.id)}})]},r.id)})}),!i&&(g?(0,N.jsxs)(`span`,{className:`absolute left-0 top-full z-30 flex w-full min-w-64 flex-wrap items-center gap-2 rounded-b-xl border bg-card p-2 shadow-lg`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>O(`documents`),className:`flex h-10 items-center gap-1.5 rounded-md border px-2 text-xs text-muted-foreground hover:bg-accent/50 hover:text-foreground`,children:[(0,N.jsx)(S,{className:`h-3 w-3`}),` List`]}),(0,N.jsxs)(`button`,{type:`button`,onClick:()=>O(`columns`),className:`flex h-10 items-center gap-1.5 rounded-md border px-2 text-xs text-muted-foreground hover:bg-accent/50 hover:text-foreground`,children:[(0,N.jsx)(f,{className:`h-3 w-3`}),` Board`]}),P.map(e=>{let t=z[e.id];return(0,N.jsxs)(`button`,{type:`button`,onClick:()=>O(`app`,e.id),className:`flex h-10 items-center gap-1.5 rounded-md border px-2 text-xs text-muted-foreground hover:bg-accent/50 hover:text-foreground`,children:[(0,N.jsx)(t,{className:`h-3 w-3`}),` `,e.label]},e.id)}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>_(!1),className:`p-1 text-muted-foreground hover:text-foreground`,"aria-label":`Cancel`,children:(0,N.jsx)(c,{className:`h-3 w-3`})})]}):(0,N.jsx)(`button`,{type:`button`,onClick:()=>_(!0),title:`Add view`,"aria-label":`Add view`,className:`relative ml-1 flex h-[2.3rem] w-10 shrink-0 items-center justify-center rounded-md pb-1 text-muted-foreground hover:bg-accent/50 hover:text-foreground`,children:(0,N.jsx)(u,{className:`h-3.5 w-3.5`})}))]})}var V=[{id:`emails`,label:`Emails`,schemas:[`data/schema/message`]},{id:`todos`,label:`Todos`,schemas:[`data/schema/task`]},{id:`notes`,label:`Notes`,schemas:[`data/schema/note`]},{id:`links`,label:`Links`,schemas:[`data/schema/tab`,`data/schema/link`]},{id:`files`,label:`Files`,schemas:[`data/schema/file`]}];function H(e,t){return t.some(t=>e.schema===t||e.schema.startsWith(`${t}/`))}function U({documents:e,workspaceId:t,columns:n,onColumnsChange:r,readOnly:a=!1}){let[o,s]=(0,M.useState)(null),[l,d]=(0,M.useState)(!1),[f,p]=(0,M.useState)({}),[m,h]=(0,M.useState)({}),g=(0,M.useRef)(null),[_,v]=(0,M.useState)(!1),y=(0,M.useCallback)(()=>{let e=g.current;e&&v(e.scrollWidth-e.clientWidth-e.scrollLeft>8)},[]);(0,M.useEffect)(()=>{let e=g.current;if(!e)return;let t=new ResizeObserver(()=>y());return t.observe(e),()=>t.disconnect()},[y]);let b=(e,t)=>{e.preventDefault();let i=e.currentTarget.parentElement;if(!i)return;let a=e.clientX,o=i.getBoundingClientRect().width,s=o,c=e=>{s=Math.min(900,Math.max(220,o+e.clientX-a)),h(e=>({...e,[t]:s}))},l=()=>{window.removeEventListener(`pointermove`,c),window.removeEventListener(`pointerup`,l),r(n.map(e=>e.id===t?{...e,width:Math.round(s)}:e))};window.addEventListener(`pointermove`,c),window.addEventListener(`pointerup`,l)},x=e=>{h(t=>{let n={...t};return delete n[e],n}),r(n.map(t=>t.id===e?{...t,width:void 0}:t))},S=e=>{let t=f[e];if(t===void 0)return;let i=n.find(t=>t.id===e);i&&(i.filter||``)!==t&&r(n.map(n=>n.id===e?{...n,filter:t||void 0}:n))},C=V.filter(e=>!n.some(t=>t.id===e.id));return(0,N.jsxs)(`div`,{className:`relative h-full`,children:[(0,N.jsx)(`div`,{ref:g,onScroll:y,className:`flex h-full snap-x snap-mandatory gap-3 overflow-x-auto overscroll-x-contain p-2`,"data-testid":`schema-columns-board`,children:n.map(t=>{let i=(f[t.id]??t.filter??``).toLowerCase(),o=e.filter(e=>H(e,t.schemas)).filter(e=>{if(!i)return!0;let t=T(e);return`${t.title}\n${t.preview}\n${t.subtitle}`.toLowerCase().includes(i)}),l=m[t.id]??t.width;return(0,N.jsxs)(`div`,{className:`relative flex h-full min-h-0 min-w-0 shrink-0 grow-0 basis-full snap-start flex-col rounded-(--card-radius) border bg-muted/20 ${l?`sm:basis-[var(--col-w)]`:`sm:basis-[48%] lg:basis-[32%] xl:basis-[24%]`}`,style:l?{"--col-w":`${l}px`}:void 0,children:[!a&&(0,N.jsx)(`div`,{onPointerDown:e=>b(e,t.id),onDoubleClick:()=>x(t.id),title:`Drag to resize; double-click to reset`,className:`absolute right-0 inset-y-0 z-10 w-2 cursor-col-resize touch-none rounded-r-lg transition-colors hover:bg-primary/25 active:bg-primary/40 max-sm:hidden`}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2 px-3 pb-1 pt-2.5 max-sm:pr-10`,children:[(0,N.jsx)(`span`,{className:`truncate text-sm font-medium`,children:t.label}),(0,N.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:o.length}),(0,N.jsx)(`span`,{className:`flex-1`}),!a&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>r(n.filter(e=>e.id!==t.id)),title:`Remove column`,className:`rounded-sm p-0.5 text-muted-foreground hover:text-destructive`,children:(0,N.jsx)(c,{className:`h-3.5 w-3.5`})})]}),(0,N.jsx)(`div`,{className:`px-3 pb-2`,children:(0,N.jsx)(`input`,{value:f[t.id]??t.filter??``,onChange:e=>p(n=>({...n,[t.id]:e.target.value})),onBlur:()=>S(t.id),onKeyDown:e=>{e.key===`Enter`&&S(t.id)},placeholder:`Filter…`,readOnly:a,className:`h-7 w-full rounded-md border border-input bg-background px-2 text-xs placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`})}),(0,N.jsxs)(`div`,{className:`flex-1 space-y-1.5 overflow-y-auto px-2 pb-2`,children:[o.map(e=>{let t=T(e);return(0,N.jsxs)(`button`,{type:`button`,onClick:()=>s(e),className:`w-full min-w-0 rounded-md border bg-card px-2.5 py-2 text-left transition-colors hover:bg-accent/50`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,N.jsx)(ue,{document:e,size:3.5}),(0,N.jsx)(`span`,{className:`truncate text-xs font-medium`,title:t.title,children:t.title})]}),t.preview&&(0,N.jsx)(`p`,{className:`mt-1 line-clamp-2 break-words text-[11px] leading-snug text-muted-foreground`,children:t.preview}),(0,N.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground/70`,children:new Date(e.updatedAt||e.createdAt).toLocaleDateString()})]},e.id)}),o.length===0&&(0,N.jsx)(`p`,{className:`px-2 py-3 text-center text-xs text-muted-foreground/60`,children:`Empty`})]})]},t.id)})}),(!a&&C.length>0||_)&&(0,N.jsxs)(`div`,{className:`pointer-events-none absolute inset-y-0 right-0 z-20 flex w-7 flex-col items-end bg-gradient-to-l from-background via-background/60 to-transparent py-2`,children:[!a&&C.length>0&&(0,N.jsxs)(`div`,{className:`pointer-events-auto relative`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>d(e=>!e),title:`Add column`,"aria-label":`Add column`,className:`flex h-7 w-6 items-center justify-center rounded-l-md border border-r-0 bg-background text-muted-foreground shadow-elevation-1 hover:bg-accent hover:text-foreground`,children:(0,N.jsx)(u,{className:`h-3.5 w-3.5`})}),l&&(0,N.jsxs)(`div`,{className:`absolute right-0 top-8 w-44 rounded-lg border bg-background p-2 shadow-elevation-2`,children:[(0,N.jsx)(`p`,{className:`px-2 pb-1 text-[10px] uppercase tracking-wide text-muted-foreground`,children:`Add column`}),C.map(e=>(0,N.jsx)(`button`,{type:`button`,onClick:()=>{d(!1),r([...n,{...e}])},className:`w-full rounded-md px-2 py-1.5 text-left text-xs text-muted-foreground hover:bg-accent/50 hover:text-foreground`,children:e.label},e.id)),(0,N.jsx)(`button`,{type:`button`,onClick:()=>d(!1),className:`mt-1 w-full rounded-md px-2 py-1.5 text-left text-xs text-muted-foreground/60 hover:bg-accent/50`,children:`Cancel`})]})]}),_&&(0,N.jsx)(i,{className:`my-auto h-4 w-4 self-center text-muted-foreground/70`,"aria-label":`More columns`})]}),(0,N.jsx)(ie,{document:o,isOpen:o!==null,onClose:()=>s(null),workspaceId:t})]})}function W(e,t,n,r,i){let a=`${e}\0${t}\0${n}\0${r}\0${i??``}`,[o,s]=(0,M.useState)(0),[c,l]=(0,M.useState)(null);(0,M.useEffect)(()=>{let o=!1;return D(e,n,t,{limit:200,allOf:[r],...i?{sortBy:i,order:`asc`}:{}}).then(e=>{o||l({key:a,docs:e.payload||[]})}).catch(()=>{o||l({key:a,docs:[]})}),()=>{o=!0}},[a,o]);let u=c?.key===a?c.docs:[],d=c?.key!==a;return(0,M.useEffect)(()=>{let e=()=>s(e=>e+1);return window.addEventListener(`workspace:documents:refresh`,e),()=>window.removeEventListener(`workspace:documents:refresh`,e)},[]),{docs:u,isLoading:d,refresh:(0,M.useCallback)(()=>s(e=>e+1),[])}}function G({workspaceId:e,treeName:t,path:n}){let{docs:r,isLoading:i,refresh:a}=W(e,t,n,E,`tasks`),[o,s]=(0,M.useState)(!1),c=o?r.filter(e=>e.data?.status!==`completed`):r,l=r.filter(e=>{let t=e.data?.status;return t!==`completed`&&t!==`cancelled`}).length;return(0,N.jsxs)(`div`,{className:`mx-auto flex h-full w-full max-w-3xl flex-col p-4`,children:[(0,N.jsxs)(`div`,{className:`mb-2 flex shrink-0 items-center justify-between gap-2`,children:[(0,N.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[l,` open`]}),(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`hide done`]})]}),(0,N.jsx)(`div`,{className:`min-h-0 flex-1 space-y-1 overflow-y-auto`,children:i?(0,N.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`Loading…`}):c.length===0?(0,N.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No todos here.`}):c.map(t=>(0,N.jsx)(O,{doc:t,workspaceId:e,readOnly:!1,onChanged:a},t.id))})]})}function K({app:e,contextId:t,...n}){let r=t&&e!==`lens`?{mode:`context`,contextId:t}:{mode:`workspace`,workspaceName:n.workspaceId,treeName:n.treeName,path:n.path,treeType:n.treeName===`directory`||n.treeName===`backends`?`directory`:`context`},i=e===`todo-app`?`todo`:e===`notes-app`?`notes`:e,a=fe.find(e=>e.id===i);return(0,N.jsx)(j,{target:r,children:e===`todos`?(0,N.jsx)(G,{...n}):a?(0,N.jsx)(a.Component,{}):null})}export{F as a,me as c,I as i,pe as l,U as n,R as o,B as r,ge as s,K as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{r}from"./chunk-62JRHF6Z-vspAGgtK.js";import{Lt as i,Vn as a,Xt as o,Zt as s,in as c,pr as l,yn as u}from"./ui-Byg1cZDr.js";import{H as d,ct as f}from"./workspace-CrSpR4xf.js";import{n as p,r as m}from"./use-canvas-pins-BvN6Gw6f.js";import{t as h}from"./useToastHelpers-CRrpIIdY.js";import{h as g}from"./index-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{r}from"./chunk-62JRHF6Z-vspAGgtK.js";import{Lt as i,Vn as a,Xt as o,Zt as s,in as c,pr as l,yn as u}from"./ui-Byg1cZDr.js";import{H as d,ct as f}from"./workspace-CrSpR4xf.js";import{n as p,r as m}from"./use-canvas-pins-BvN6Gw6f.js";import{t as h}from"./useToastHelpers-CRrpIIdY.js";import{h as g}from"./index-CyEIU2rL.js";import{t as _}from"./HomeFab-CzKEIYDk.js";var v=e(n(),1),y=t();function b(e){let t=`${e.workspaceName}\0${e.treeName}\0${e.path}`,[n,r]=(0,v.useState)(null);return(0,v.useEffect)(()=>{let n=!1;return f(e.workspaceName,e.treeName).then(i=>{n||r({key:t,node:d(i,e.path)})}).catch(()=>{n||r({key:t,node:null})}),()=>{n=!0}},[t,e.workspaceName,e.treeName,e.path]),!n||n.key!==t?{state:`loading`}:n.node?{state:`ready`,node:n.node}:{state:`missing`}}function x(e){let t=`/workspaces/${encodeURIComponent(e.workspaceName)}`,n=e.path.replace(/^\//,``);return e.treeName===`context`?`${t}/path/${n}`:`${t}/trees/${encodeURIComponent(e.treeName)}/path/${n}`}var S=`application/x-canvas-pin`;function C({pin:e,onUnpin:t,onMinimize:n,onDropPin:d}){let f=b(e),[p,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(null),C=!!d&&!p,w=e=>{let t=e.currentTarget.getBoundingClientRect();return e.clientX>t.left+t.width/2?`after`:`before`},T=C?{onDragOver:e=>{e.dataTransfer.types.includes(`application/x-canvas-pin`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,_(w(e)))},onDragLeave:()=>_(null),onDrop:t=>{let n=t.dataTransfer.getData(S);_(null),!(!n||n===e.id)&&(t.preventDefault(),d?.(n,w(t)===`after`))}}:{},E=f.state===`ready`?f.node:null,D=E?.label||e.label||e.path.split(`/`).filter(Boolean).pop()||`Canvas`,O=E?.color;return(0,v.useEffect)(()=>{if(!p)return;let e=e=>{e.key===`Escape`&&h(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[p]),(0,y.jsxs)(`section`,{...T,className:p?`fixed inset-0 z-picker flex flex-col bg-background`:`flex flex-col rounded-(--card-radius) border bg-background overflow-hidden min-h-0 min-w-0 ${g?`ring-2 ring-primary/60`:``}`,children:[(0,y.jsxs)(`header`,{draggable:C,onDragStart:C?t=>{t.dataTransfer.setData(S,e.id),t.dataTransfer.effectAllowed=`move`}:void 0,className:`flex items-center gap-2 px-3 py-2 border-b bg-muted/20 shrink-0 min-w-0 ${C?`cursor-grab active:cursor-grabbing`:``}`,children:[C&&(0,y.jsx)(a,{className:`w-3.5 h-3.5 shrink-0 text-muted-foreground/60`,"aria-hidden":!0}),O&&(0,y.jsx)(`div`,{className:`w-1 h-5 rounded-full shrink-0`,style:{backgroundColor:O}}),(0,y.jsx)(u,{className:`w-4 h-4 shrink-0 text-primary`}),(0,y.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,y.jsx)(`span`,{className:`text-sm font-semibold leading-tight truncate`,children:D}),(0,y.jsxs)(`span`,{className:`text-[11px] text-muted-foreground truncate leading-tight font-mono`,children:[e.workspaceName,`://`,e.path.replace(/^\//,``)]})]}),n&&(0,y.jsx)(`button`,{type:`button`,onClick:n,title:`Minimize to tab bar`,"aria-label":`Minimize to tab bar`,className:`shrink-0 flex items-center justify-center w-7 h-7 rounded-md text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,children:(0,y.jsx)(o,{className:`w-3.5 h-3.5`})}),(0,y.jsx)(`button`,{type:`button`,onClick:()=>h(e=>!e),"aria-pressed":p,title:p?`Restore tile (Esc)`:`Fill view area`,"aria-label":p?`Restore tile`:`Fill view area`,className:`shrink-0 flex items-center justify-center w-7 h-7 rounded-md text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,children:p?(0,y.jsx)(s,{className:`w-3.5 h-3.5`}):(0,y.jsx)(c,{className:`w-3.5 h-3.5`})}),(0,y.jsx)(r,{to:x(e),title:`Open in workspace`,"aria-label":`Open in workspace`,className:`shrink-0 flex items-center justify-center w-7 h-7 rounded-md text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,children:(0,y.jsx)(l,{className:`w-3.5 h-3.5`})}),(0,y.jsx)(`button`,{type:`button`,onClick:t,title:`Unpin from home`,"aria-label":`Unpin from home`,className:`shrink-0 flex items-center justify-center w-7 h-7 rounded-md text-muted-foreground hover:bg-destructive/10 hover:text-destructive transition-colors`,children:(0,y.jsx)(i,{className:`w-3.5 h-3.5`})})]}),(0,y.jsxs)(`div`,{className:`flex-1 min-h-0`,children:[f.state===`loading`&&(0,y.jsx)(`div`,{className:`flex items-center justify-center h-full text-xs text-muted-foreground`,children:`Loading…`}),f.state===`missing`&&(0,y.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-2 px-4 text-center`,children:[(0,y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This canvas is no longer available.`}),(0,y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`It may have been renamed, moved or deleted.`}),(0,y.jsx)(`button`,{type:`button`,onClick:t,className:`mt-1 px-2.5 py-1 text-xs border rounded-md hover:bg-accent`,children:`Remove pin`})]}),f.state===`ready`&&(0,y.jsx)(m,{workspaceId:e.workspaceName,treeName:e.treeName,path:e.path,layerId:f.node.id,querySpec:f.node.querySpec,metadata:f.node.metadata,readOnly:!0})]})]})}function w(e){return e.label||e.path.split(`/`).filter(Boolean).pop()||`Canvas`}function T({pins:e,onRestore:t}){let[n,r]=(0,v.useState)(!1),[i,a]=(0,v.useState)(e.length);return i!==e.length&&(a(e.length),e.length===0&&r(!1)),e.length===0?null:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`div`,{className:`pointer-events-none absolute bottom-0 left-0 right-0 z-40 max-md:hidden`,children:(0,y.jsx)(`div`,{className:`pointer-events-auto flex items-end gap-1 overflow-x-auto px-3 pr-28 pb-safe-bottom`,children:e.map(e=>(0,y.jsxs)(`button`,{type:`button`,onClick:()=>t(e.id),title:`Restore ${w(e)}`,className:`flex max-w-[180px] shrink-0 items-center gap-1.5 rounded-t-lg border border-b-0 bg-background px-3 py-1.5 text-xs shadow-elevation-1 hover:bg-accent`,children:[(0,y.jsx)(u,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,y.jsx)(`span`,{className:`truncate`,children:w(e)})]},e.id))})}),n&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`div`,{className:`fixed inset-0 z-drawer md:hidden`,onClick:()=>r(!1),"aria-hidden":!0}),(0,y.jsx)(`div`,{className:`fixed bottom-rail-stack left-2 z-rail w-60 max-w-[calc(100vw-1rem)] rounded-xl border bg-card p-1.5 shadow-elevation-5 animate-fade-in md:hidden touch-target`,children:e.map(e=>(0,y.jsxs)(`button`,{type:`button`,onClick:()=>t(e.id),className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-sm hover:bg-accent`,children:[(0,y.jsx)(u,{className:`h-4 w-4 shrink-0 text-primary`}),(0,y.jsx)(`span`,{className:`truncate`,children:w(e)})]},e.id))})]}),(0,y.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),"aria-label":n?`Close minimized canvases`:`Minimized canvases (${e.length})`,className:`fixed bottom-rail-inset left-16 z-nav flex h-12 w-12 items-center justify-center rounded-full bg-foreground text-background shadow-elevation-4 md:hidden`,children:[(0,y.jsx)(u,{className:`h-5 w-5`}),(0,y.jsx)(`span`,{className:`absolute -top-1 -right-1 flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1 text-[10px] font-semibold`,children:e.length})]})]})}function E(){let{pins:e,unpin:t,movePin:n,setMinimized:r,isLoading:i}=p(),{showErrorToast:a}=h(),[o,s]=(0,v.useState)(new Set),c=(0,v.useRef)(e);(0,v.useEffect)(()=>{c.current=e},[e]);let l=e=>{r(e,!0).catch(()=>a(`Could not save minimized state`))},u=t=>{s(e=>{let n=new Set(e);return n.delete(t),n}),e.find(e=>e.id===t)?.minimized&&r(t,!1).catch(()=>a(`Could not save restored state`))},d=(0,v.useCallback)(e=>{s(e?new Set(c.current.filter(e=>!e.minimized).map(e=>e.id)):new Set)},[]),f=e.filter(e=>!g(e,o)),m=e.filter(e=>g(e,o)),b=(t,r,i)=>{let a=e.findIndex(e=>e.id===r.id);if(a===-1)return;let o=i?e[a+1]?.id??null:r.id;n(t,o)};return(0,y.jsxs)(`div`,{className:`relative h-full`,children:[(0,y.jsx)(`div`,{className:`h-full overflow-y-auto`,children:i?(0,y.jsx)(`div`,{className:`flex items-center justify-center h-full text-xs text-muted-foreground`,children:`Loading…`}):(0,y.jsx)(`div`,{className:`grid gap-4 p-4 h-full grid-cols-[repeat(auto-fit,minmax(min(640px,100%),1fr))] auto-rows-fr ${m.length>0?`md:pb-12`:``}`,children:f.map(e=>(0,y.jsx)(C,{pin:e,onUnpin:()=>{t(e.id)},onMinimize:()=>l(e.id),onDropPin:(t,n)=>b(t,e,n)},e.id))})}),(0,y.jsx)(`div`,{className:`pointer-events-none absolute inset-0`,children:(0,y.jsx)(_,{onCardsOpenChange:d})}),(0,y.jsx)(T,{pins:m,onRestore:u})]})}export{E as default};
|