@augmentd-labs/canvas-web 2.26.45 → 2.27.0
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/{CalendarApplet-CsyUmI2B.js → CalendarApplet-Be25FsQH.js} +1 -1
- package/dist/assets/{FiltersApplet-CVnCAs-P.js → FiltersApplet-CuBp34Ll.js} +1 -1
- package/dist/assets/{HomeFab-iC5BF7LV.js → HomeFab-BVC6GyBo.js} +1 -1
- package/dist/assets/{LensApplet-DA0ZWS1k.js → LensApplet-cH9mu9Ek.js} +1 -1
- package/dist/assets/{NotesApplet-BSJ-9RKl.js → NotesApplet-D7vrAU-F.js} +1 -1
- package/dist/assets/{_agentId_-BrzFDu8r.js → _agentId_-D7FMIU0U.js} +0 -0
- package/dist/assets/{_contextId_-DS6b9Uml.js → _contextId_-nHWeEqjb.js} +1 -1
- package/dist/assets/{_workspaceName_-XRqfa4c6.js → _workspaceName_-Ca7l8D3u.js} +1 -1
- package/dist/assets/{about-hcdKJNm5.js → about-DPQIKA4h.js} +1 -1
- package/dist/assets/{add-CEBusWuu.js → add-C4IXcB8E.js} +1 -1
- package/dist/assets/{agents-wFp7Vh3p.js → agents-Cq1aDFAt.js} +1 -1
- package/dist/assets/{appearance-D5BUjZm8.js → appearance-DTH3zH0p.js} +1 -1
- package/dist/assets/{apps-65YXCnzH.js → apps-DGG9ruBT.js} +1 -1
- package/dist/assets/{home-vr8b8oR-.js → home-BK8Bp4d-.js} +1 -1
- package/dist/assets/index-NOhHv2VY.js +16 -0
- package/dist/assets/{key-bindings-DmqvYSaF.js → key-bindings-Cbh1Fiav.js} +1 -1
- package/dist/assets/{registry-g1SKt_fD.js → registry-D7HyG001.js} +2 -2
- package/dist/assets/{settings-CbMkpipO.js → settings-6UW5qG-V.js} +1 -1
- package/dist/assets/{settings-XMhqrvTu.js → settings-BbqSg6FH.js} +1 -1
- package/dist/assets/{settings-BWCMmkjr.js → settings-CkBpWcHX.js} +1 -1
- package/dist/assets/{settings-BIoSwdXv.js → settings-Ckel628s.js} +1 -1
- package/dist/assets/{share-target-hDXdgW6o.js → share-target-CuBCWHxv.js} +1 -1
- package/dist/assets/{shared-DVlDThVA.js → shared-CqqMgsnU.js} +1 -1
- package/dist/assets/{tree-folders-IDoobsGN.js → tree-folders-dKwIsl1U.js} +1 -1
- package/dist/assets/{useAgentModels-CI9XT6yc.js → useAgentModels-DTZNaSRA.js} +1 -1
- package/dist/assets/{workspaces-ByYQ6L3I.js → workspaces-CXhffn_p.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/sw.js +1 -1
- package/package.json +2 -2
- package/dist/assets/index-CTvqbEB8.js +0 -16
|
@@ -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{g as r,v as i}from"./chunk-62JRHF6Z-vspAGgtK.js";import{n as a,t as o}from"./HomeFab-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{g as r,v as i}from"./chunk-62JRHF6Z-vspAGgtK.js";import{n as a,t as o}from"./HomeFab-BVC6GyBo.js";var s=e(n(),1),c=`share-target-inbox`,l=t(),u={"too-large":`Android shares are limited to 100 MiB in total for temporary device storage. Nothing was uploaded. Use Add File to upload larger files directly.`,"stash-failed":`Canvas couldn't hold on to the shared file — device storage may be full. Try again, or upload it from the app.`,"empty-share":`Canvas received no files or text from the sharing app. Try again, or use Add File to select the photo directly.`,"empty-file":`The sharing app delivered an empty file. Try again, or use Add File to select the original directly.`,expired:`Nothing shared, or the share expired.`};async function d(e){let t=await caches.open(c),n=null,r=Date.now()+3e5;for(;Date.now()<r;){let r=await t.match(`/share-target-inbox/${e}/meta`);if(!r)return null;if(n=await r.json(),n?.status===`error`)throw Error(n.error||`stash-failed`);if(n?.status!==`receiving`)break;await new Promise(e=>setTimeout(e,300))}if(!n||n.status===`receiving`)throw Error(`stash-failed`);let i=[];for(let r=0;r<n.fileNames.length;r++){let a=await t.match(`/share-target-inbox/${e}/file-${r}`);if(!a)throw Error(`stash-failed`);let o=await a.blob();i.push(new File([o],n.fileNames[r],{type:o.type}))}let o=i.length?await a(i):null;if(await Promise.all(n.fileNames.map((n,r)=>t.delete(`/share-target-inbox/${e}/file-${r}`))),await t.delete(`/share-target-inbox/${e}/meta`),o)return{kind:o.kind,data:{files:o.files}};if(![n.title,n.text,n.url].some(e=>e.trim()))throw Error(`empty-share`);let s=n.text.trim(),l=n.url||(m(s)?s:``);return l?{kind:`link`,data:{url:l,title:n.title}}:{kind:`note`,data:{title:n.title,content:n.text}}}var f=new Map;function p(e){let t=f.get(e);return t||(t=d(e),f.set(e,t),t.finally(()=>setTimeout(()=>f.delete(e),6e4)).catch(()=>{})),t}function m(e){if(!e||/\s/.test(e))return!1;try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function h(){let[e]=i(),t=r(),[n,a]=(0,s.useState)(null),[c,d]=(0,s.useState)(null);(0,s.useEffect)(()=>{let t=!1;async function n(){let n=e.get(`error`);if(n){d(n);return}let r=e.get(`token`),i=r?await p(r):null;t||(i?a(i):d(`expired`))}return n().catch(e=>{t||d(e instanceof Error?e.message:`stash-failed`)}),()=>{t=!0}},[e]);let f=()=>t(`/home`,{replace:!0});return c?(0,l.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center`,children:[(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:u[c]??u.expired}),(0,l.jsx)(`button`,{type:`button`,onClick:()=>t(`/apps/add/file`,{replace:!0}),className:`text-sm font-medium text-primary underline underline-offset-4`,children:`Add File`}),(0,l.jsx)(`button`,{type:`button`,onClick:f,className:`text-sm font-medium text-primary underline underline-offset-4`,children:`Go to Canvas`})]}):n?(0,l.jsx)(o,{initialKind:n.kind,initialData:n.data,onInitialCardClose:f}):(0,l.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Receiving shared content on this device… No upload has started.`})}export{h 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{t as i}from"./button--VYZekMF.js";import{t as a}from"./input-BOtCd4HP.js";import{t as o}from"./api-CA6WiiYM.js";import{n as s}from"./use-toast-BlLDqSUO.js";import{Pt as c}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{h as r}from"./chunk-62JRHF6Z-vspAGgtK.js";import{t as i}from"./button--VYZekMF.js";import{t as a}from"./input-BOtCd4HP.js";import{t as o}from"./api-CA6WiiYM.js";import{n as s}from"./use-toast-BlLDqSUO.js";import{Pt as c}from"./index-NOhHv2VY.js";import{n as l}from"./page-header-NyYSXjfY.js";import{t as u}from"./use-settings-back-D_MM9diy.js";var d=e(n(),1),f=t();function p(){let e=r(),{showToast:t}=s(),n=new URLSearchParams(e.search),p=e=>{try{let t=new URL(e);return t.pathname.includes(`/rest/v2/workspaces/`)&&!t.pathname.includes(`/rest/v2/pub/`)?t.pathname=t.pathname.replace(`/rest/v2/workspaces/`,`/rest/v2/pub/workspaces/`):t.pathname.includes(`/rest/v2/contexts/`)&&!t.pathname.includes(`/rest/v2/pub/`)&&(t.pathname=t.pathname.replace(`/rest/v2/contexts/`,`/rest/v2/pub/contexts/`)),t.toString()}catch{return e}},m=p(n.get(`url`)||``),h=sessionStorage.getItem(`sharedToken:last`)||``,[g,_]=(0,d.useState)(m),[v,y]=(0,d.useState)(h),[b,x]=(0,d.useState)(null),[S,C]=(0,d.useState)([]),[w,T]=(0,d.useState)(!1),E=(0,d.useMemo)(()=>{try{let e=new URL(g);return e.pathname.includes(`/pub/workspaces/`)?`workspace`:e.pathname.includes(`/pub/contexts/`)?`context`:`unknown`}catch{return`unknown`}},[g]),D=()=>({Authorization:`Bearer ${v.trim()}`}),O=async()=>{if(!(!g||!v)){T(!0);try{let e=p(g),t=await o.get(e,{skipAuth:!0,headers:D()});x(t);let n=await o.get(`${e}/documents`,{skipAuth:!0,headers:D()}),r=Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[];C(Array.isArray(r)?r:[])}catch(e){let n=g.includes(`/rest/v2/workspaces/`)?`Ensure the URL uses /rest/v2/pub/workspaces/<workspace-id> and the token matches that workspace.`:g.includes(`/rest/v2/contexts/`)?`Ensure the URL uses /rest/v2/pub/contexts/<context-id>.`:void 0;t({title:`Error`,description:`${e instanceof Error?e.message:`Failed to load shared resource`}${n?`: ${n}`:``}`,variant:`destructive`}),x(null),C([])}finally{T(!1)}}},k=(0,d.useRef)(O);return(0,d.useEffect)(()=>{k.current()},[]),(0,f.jsxs)(`div`,{className:`space-y-4`,children:[(0,f.jsx)(l,{onBack:u(),title:`Shared Resource Viewer`,description:`Open a resource someone shared with you.`}),(0,f.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-3`,children:[(0,f.jsx)(a,{value:g,onChange:e=>_(e.target.value),placeholder:`Full pub URL`}),(0,f.jsx)(a,{value:v,onChange:e=>y(e.target.value),placeholder:`Access token (canvas-...)`}),(0,f.jsx)(i,{onClick:O,disabled:w||!g||!v,children:`Load`})]}),(0,f.jsxs)(`div`,{className:`text-sm text-muted-foreground`,children:[`Type: `,E]}),w?(0,f.jsx)(`div`,{className:`text-center py-8 text-muted-foreground`,children:`Loading...`}):(0,f.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,f.jsxs)(`div`,{className:`border rounded p-3`,children:[(0,f.jsx)(`h2`,{className:`font-semibold mb-2`,children:`Metadata`}),(0,f.jsx)(`pre`,{className:`text-xs overflow-auto max-h-80`,children:JSON.stringify(b,null,2)})]}),(0,f.jsxs)(`div`,{className:`border rounded p-3`,children:[(0,f.jsxs)(`h2`,{className:`font-semibold mb-2`,children:[`Documents (`,S.length,`)`]}),S.length===0?(0,f.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`No documents`}):(0,f.jsx)(`ul`,{className:`space-y-2 text-sm`,children:S.slice(0,100).map((e,t)=>(0,f.jsxs)(`li`,{className:`border rounded p-2`,children:[(0,f.jsx)(`div`,{className:`font-mono text-xs`,children:e.id}),(0,f.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.schema})]},t))})]})]}),(0,f.jsx)(c,{className:`mt-8`})]})}export{p 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{$r as i,Ct as a,Dr as o,G as s,L as c,Lt as l,Pt as u,Rt as d,St as f,Ur as p,Wt as m,X as h,Xr as g,ai as _,bn as v,ct as y,hn as b,it as x,mt as S,tt as C,xn as w,yn as T}from"./ui-DEgHnkQu.js";import{t as E}from"./utils-2pl1SbIp.js";import{Bn as D,G as O,Ln as k,On as A,xn as ee}from"./workspace-4hWrSEku.js";import{t as te}from"./TodosWidget-DGftEAbs.js";import{d as ne,o as re,u as ie}from"./ObjectPropertiesCard-DesXRw-_.js";import{S as ae,j as oe,p as se,t as ce,w as j}from"./document-list-Bbbx-pTZ.js";import{n as le,r as ue}from"./use-toolbox-Ck_cLGgf.js";import{t as de}from"./useToastHelpers-CRrpIIdY.js";import{n as M}from"./color-DFEH4BfK.js";import{t as fe}from"./DocumentIcon-0ya9gycp.js";import{r as pe}from"./workspace-BydSRtST.js";import{t as me}from"./registry-g1SKt_fD.js";import{t as he}from"./applet-target-LvhUEvE5.js";var N=e(n(),1);function P(e){let{pathname:t}=r(),n=ue()?.setAgentView,i=JSON.stringify(e);(0,N.useEffect)(()=>(n?.({pathname:t,view:JSON.parse(i)}),()=>n?.(null)),[t,i,n])}function F(e,t,n,r){return structuredClone({...e,query:pe(t,n,r),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone})}var I=t();function ge({target:e,children:t}){let[n,r]=(0,N.useState)(null),{showErrorToast:i}=de(),a=e=>e.target.closest?.(`[data-drop-folder]`)?.dataset.dropFolder||null;return(0,I.jsxs)(`div`,{className:`relative flex flex-col h-full min-h-0 bg-background ${n?`ring-2 ring-inset ring-primary`:``}`,onDragOverCapture:t=>{!e||!j(t.dataTransfer)||(t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect=`copy`,r(a(t)??e.path))},onDragLeaveCapture:e=>{e.currentTarget.contains(e.relatedTarget)||r(null)},onDropCapture:t=>{if(!e||!j(t.dataTransfer))return;t.preventDefault(),t.stopPropagation(),r(null);let n=a(t);ae(t.dataTransfer,n?{...e,path:n}:e).then(e=>{e||i(`Nothing to upload in this drop`)}).catch(e=>i(e instanceof Error?e.message:`Could not read the dropped files`))},children:[t,n&&(0,I.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-4 z-30 flex justify-center`,children:(0,I.jsxs)(`span`,{className:`rounded-md border bg-popover px-3 py-1.5 text-sm font-medium shadow-elevation-3`,children:[`Drop to upload to `,n]})})]})}function L({navigationTabs:e,navigationActions:t,onBack:n,accentColor:r,frameContent:i=!0,urlType:o,urlDisplay:c,contextPath:u,treeName:f,workspaceId:p,workspaceLabel:m,workspaceIcon:g,documentSchema:y,documents:b,isLoading:x,totalCount:C,currentPage:w,pageSize:T,onPageChange:E,onPageSizeChange:D,onRemoveDocument:O,onDeleteDocument:k,onDestroyDocument:A,onRemoveDocuments:te,onDeleteDocuments:ae,onDestroyDocuments:se,onCopyDocuments:j,onCutDocuments:ue,onPasteDocuments:de,onImportDocuments:M,onSelectionChange:fe,pastedDocumentIds:pe,onPurgeDocuments:me,disablePurgeDocuments:he,canvasInfo:P,isCanvasPinned:F,onTogglePinCanvas:L,onSaveAsCanvas:R,onShareCanvas:z,onUnshareCanvas:B,onDeleteCanvas:V,isSharingCanvas:H,isDeletingCanvas:U,isCanvasShared:W,isCanvasLocked:G,backendSearchQueries:_e,onBackendSearch:K,onRemoveBackendQuery:q,serverSort:ve,onServerSortChange:ye,scope:J,onScopeChange:be,canSaveChanges:Y,isSavingChanges:X,onSaveChanges:Z,onBrowseWorkspaces:xe,onBrowseTree:Se,onNavigatePath:Ce,linkTree:we,children:Q,contentBanner:Te,folders:Ee,onOpenFolder:De}){let Oe=o===`canvas`,ke=oe(),{state:Ae,toggleView:je,hasActiveFilters:Me,openAddPicker:Ne}=le(),$=re(),[Pe,Fe]=(0,N.useState)(``),Ie=JSON.stringify([p,f,u,y]),[Le,Re]=(0,N.useState)(Ie);Le!==Ie&&(Re(Ie),Fe(``));let ze=(0,I.jsxs)(I.Fragment,{children:[t,R&&(0,I.jsx)(`button`,{type:`button`,onClick:R,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,I.jsx)(_,{className:`h-4 w-4`})})]});return(0,I.jsxs)(ge,{target:p&&(M||f===`backends`)?{mode:`workspace`,workspaceName:p,path:u,treeName:f||`context`,treeType:ee(f)}:null,children:[e&&!ke&&(0,I.jsx)(ne,{accentColor:r,children:e}),(0,I.jsxs)(`div`,{className:`canvas-surface-body${i&&!ke?` is-framed`:``}`,children:[(0,I.jsx)(ie,{workspaceIcon:g,workspace:m||p||c.split(`://`)[0]||`Workspace`,actions:ke&&e?(0,I.jsxs)(`details`,{className:`relative shrink-0`,"aria-label":`Canvas views`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer rounded-md border px-2 py-1 text-xs`,title:`Choose or manage content views`,children:`Views`}),(0,I.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}${o.endsWith(`-layer`)?`:layer`:``}`:o.replace(`-layer`,``),path:u,accentColor:r,onBack:$.location?$.location.section===`view`?$.close:()=>$.update?.({section:`view`}):n,section:$.location?`document/${$.location.documentId}/${$.location.section}`:void 0,onSection:$.location?()=>$.update?.({section:`view`}):void 0,onBrowseWorkspaces:xe,onBrowseTree:Se,onNavigatePath:Ce,onFilter:()=>je(`tools`),filtersActive:Me,filtersOpen:Ae.t1Open&&Ae.t1View===`tools`,onAdd:e=>Ne({modal:e.shiftKey,fresh:!0}),search:K||!Q?{workspaceId:p,queries:_e||[],onSearch:K??Fe,localOnly:!K,onRemoveQuery:q,scope:J,onScopeChange:be}:void 0,onDraftChange:Q?void 0:Fe}),Oe&&P?(0,I.jsx)(I.Fragment,{children:(0,I.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,I.jsx)(`div`,{className:`w-1 h-6 rounded-full shrink-0`,style:{backgroundColor:P.color}}),(0,I.jsx)(v,{className:`w-4 h-4 shrink-0 text-primary`}),(0,I.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,I.jsx)(`span`,{className:`text-lg font-semibold leading-tight truncate`,children:P.label||c.split(`://`)[1]||`Canvas`}),P.description&&(0,I.jsx)(`span`,{className:`text-xs text-muted-foreground truncate leading-tight`,children:P.description})]}),Y&&Z&&(0,I.jsxs)(`button`,{type:`button`,onClick:Z,disabled:X,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,I.jsx)(a,{className:`w-3 h-3`}),(0,I.jsx)(`span`,{className:`hidden sm:inline`,children:X?`Saving...`:`Save filters`})]}),L&&(0,I.jsxs)(`button`,{type:`button`,onClick:L,"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,I.jsx)(d,{className:`w-3 h-3`}):(0,I.jsx)(l,{className:`w-3 h-3`}),(0,I.jsx)(`span`,{className:`hidden sm:inline`,children:F?`Unpin`:`Pin`})]}),z&&(0,I.jsxs)(`button`,{type:`button`,onClick:z,disabled:H||U,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:W?`Copy public link`:`Share canvas`,children:[(0,I.jsx)(S,{className:`w-3 h-3`}),(0,I.jsx)(`span`,{className:`hidden sm:inline`,children:H?`Sharing...`:W?`Copy link`:`Share`})]}),W&&B&&(0,I.jsxs)(`button`,{type:`button`,onClick:B,disabled:H||U,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,I.jsx)(s,{className:`w-3 h-3`}),(0,I.jsx)(`span`,{className:`hidden sm:inline`,children:`Unshare`})]}),V&&(0,I.jsxs)(`button`,{type:`button`,onClick:V,disabled:U||G&&!W,title:G&&!W?`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,I.jsx)(h,{className:`w-3 h-3`}),(0,I.jsx)(`span`,{className:`hidden sm:inline`,children:U?`Deleting…`:`Delete`})]})]})}):null,Q&&(R||t)&&(0,I.jsx)(`div`,{className:`flex items-center gap-2 border-b px-3 py-1`,children:ze}),(0,I.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto${Q?``:` flex flex-col`}`,children:[Te,Q||(0,I.jsx)(ce,{readingPane:!0,externalSearchQuery:Pe,toolbarActions:ze,documents:y?b.filter(e=>e.schema===y):b,isLoading:x,folders:y?void 0:Ee,onOpenFolder:De,contextPath:u,treeName:f,workspaceId:p,totalCount:C,viewMode:y?`card`:`table`,allowViewToggle:!0,currentPage:w,pageSize:T,onPageChange:E,onPageSizeChange:D,onRemoveDocument:O,onDeleteDocument:k,onDestroyDocument:A,onRemoveDocuments:te,onDeleteDocuments:ae,onDestroyDocuments:se,onCopyDocuments:j,onCutDocuments:ue,onPasteDocuments:de,onImportDocuments:M,onSelectionChange:fe,pastedDocumentIds:pe,onPurgeDocuments:y?void 0:me,disablePurgeDocuments:he,backendSearchQueries:_e,onBackendSearch:K,serverSort:ve,onServerSortChange:ye,onRemoveBackendQuery:q,scope:J,onScopeChange:be,canSaveChanges:!Oe&&Y,isSavingChanges:X,onSaveChanges:Z,linkTree:we},y??`documents`)]})]})]})}var R=[{id:`todos`,label:`Todo list`},{id:`todo-app`,label:`Todo App`},{id:`notes`,label:`Notes list`},{id:`notes-app`,label:`Notes App`},{id:`calendar`,label:`Calendar`},{id:`apps`,label:`Apps`},{id:`sketch`,label:`Sketch`},{id:`terminal`,label:`Terminal`}];function z(e){return e?.kind===`app`&&e.app===`notes`?`data/schema/note`:void 0}var B={id:`default`,name:`All`,kind:`documents`};function V(){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 H(e){let t=e?.views;if(!Array.isArray(t))return[B];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`&&(R.some(e=>e.id===t.app)||t.app===`filters`||t.app===`lens`)});return n.length>0?n:[B]}var U={todos:b,"todo-app":b,notes:C,"notes-app":C,calendar:g,filters:y,sketch:i,terminal:x,lens:f,apps:w};function W({views:e,activeId:t,onSelect:n,onSave:r,readOnly:i=!1,className:a,accentColor:s,onOpenToSide:l}){let[d,f]=(0,N.useState)(null),[p,h]=(0,N.useState)(``),[g,_]=(0,N.useState)(!1),[v,y]=(0,N.useState)(null),[b,x]=(0,N.useState)(null),S=(0,N.useRef)(null);(0,N.useEffect)(()=>{let e=S.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,N.useEffect)(()=>{S.current?.querySelector(`[aria-pressed="true"], input`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[t,d]);let C=()=>{y(null),x(null)},w=()=>{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))}C()},D=()=>{if(!d)return;let t=p.trim();t&&r(e.map(e=>e.id===d?{...e,name:t}:e)),f(null)},O=(t,n)=>{_(!1);let i=`view-${Date.now().toString(36)}`,a=t===`columns`?`Board`:t===`app`?R.find(e=>e.id===n)?.label??`App`:`List`,o=t===`columns`?{id:i,name:a,kind:t,columns:V()}:t===`app`?{id:i,name:a,kind:t,app:n}:{id:i,name:a,kind:t};r([...e,o],i),f(i),h(a)},k=n=>{let i=e.filter(e=>e.id!==n);r(i.length>0?i:[B],n===t?i[0]?.id??B.id:void 0)};return(0,I.jsxs)(`div`,{className:E(`relative flex h-full min-w-0 items-end`,a),children:[(0,I.jsx)(`div`,{ref:S,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`?o:r.kind===`app`&&r.app?U[r.app]:T;return d===r.id?(0,I.jsx)(`input`,{autoFocus:!0,"aria-label":`Tab name`,value:p,onChange:e=>h(e.target.value),onBlur:D,onKeyDown:e=>{e.key===`Enter`&&D(),e.key===`Escape`&&f(null)},className:E(`relative h-[2.3rem] w-28 shrink-0 rounded-t-[.5rem] border-0 px-3 pb-1 text-xs outline-none ring-0`,a?E(`z-[2] bg-background font-medium`,s?M(s):`text-foreground`):`bg-muted text-muted-foreground`),style:{backgroundColor:a?s:void 0}},r.id):(0,I.jsxs)(`button`,{type:`button`,"aria-pressed":a,onClick:()=>n(r.id),onDoubleClick:()=>{i||(f(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(),w()},onDragEnd:C,className:E(`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?E(`z-[2] bg-background font-medium`,s?M(s):`text-foreground`):`bg-muted text-muted-foreground hover:bg-accent hover:text-foreground`,v===r.id&&`opacity-50`),style:{backgroundColor:a?s:void 0,boxShadow:b?.id===r.id?`inset ${b.before?`2px`:`-2px`} 0 0 var(--primary)`:void 0},children:[(0,I.jsx)(u,{className:`h-3 w-3 shrink-0`}),(0,I.jsx)(`span`,{className:`max-w-32 truncate`,children:r.name}),l&&(0,I.jsx)(m,{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(),l(r.id)}}),!i&&e.length>1&&(0,I.jsx)(c,{className:E(`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(),k(r.id)}})]},r.id)})}),!i&&(g?(0,I.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,I.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,I.jsx)(T,{className:`h-3 w-3`}),` List`]}),(0,I.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,I.jsx)(o,{className:`h-3 w-3`}),` Board`]}),R.map(e=>{let t=U[e.id];return(0,I.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,I.jsx)(t,{className:`h-3 w-3`}),` `,e.label]},e.id)}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>_(!1),className:`p-1 text-muted-foreground hover:text-foreground`,"aria-label":`Cancel`,children:(0,I.jsx)(c,{className:`h-3 w-3`})})]}):(0,I.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,I.jsx)(u,{className:`h-3.5 w-3.5`})}))]})}var G=[{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 _e(e,t){return t.some(t=>e.schema===t||e.schema.startsWith(`${t}/`))}function K({documents:e,workspaceId:t,columns:n,onColumnsChange:r,readOnly:i=!1}){let[a,o]=(0,N.useState)(null),[s,l]=(0,N.useState)(!1),[d,f]=(0,N.useState)({}),[m,h]=(0,N.useState)({}),g=(0,N.useRef)(null),[_,v]=(0,N.useState)(!1),y=(0,N.useCallback)(()=>{let e=g.current;e&&v(e.scrollWidth-e.clientWidth-e.scrollLeft>8)},[]);(0,N.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=d[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=G.filter(e=>!n.some(t=>t.id===e.id));return(0,I.jsxs)(`div`,{className:`relative h-full`,children:[(0,I.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 a=(d[t.id]??t.filter??``).toLowerCase(),s=e.filter(e=>_e(e,t.schemas)).filter(e=>{if(!a)return!0;let t=A(e);return`${t.title}\n${t.preview}\n${t.subtitle}`.toLowerCase().includes(a)}),l=m[t.id]??t.width;return(0,I.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:[!i&&(0,I.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,I.jsxs)(`div`,{className:`flex items-center gap-2 px-3 pb-1 pt-2.5 max-sm:pr-10`,children:[(0,I.jsx)(`span`,{className:`truncate text-sm font-medium`,children:t.label}),(0,I.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:s.length}),(0,I.jsx)(`span`,{className:`flex-1`}),!i&&(0,I.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,I.jsx)(c,{className:`h-3.5 w-3.5`})})]}),(0,I.jsx)(`div`,{className:`px-3 pb-2`,children:(0,I.jsx)(`input`,{value:d[t.id]??t.filter??``,onChange:e=>f(n=>({...n,[t.id]:e.target.value})),onBlur:()=>S(t.id),onKeyDown:e=>{e.key===`Enter`&&S(t.id)},placeholder:`Filter…`,readOnly:i,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,I.jsxs)(`div`,{className:`flex-1 space-y-1.5 overflow-y-auto px-2 pb-2`,children:[s.map(e=>{let t=A(e);return(0,I.jsxs)(`button`,{type:`button`,onClick:()=>o(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,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(fe,{document:e,size:3.5}),(0,I.jsx)(`span`,{className:`truncate text-xs font-medium`,title:t.title,children:t.title})]}),t.preview&&(0,I.jsx)(`p`,{className:`mt-1 line-clamp-2 break-words text-[11px] leading-snug text-muted-foreground`,children:t.preview}),(0,I.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground/70`,children:new Date(e.updatedAt||e.createdAt).toLocaleDateString()})]},e.id)}),s.length===0&&(0,I.jsx)(`p`,{className:`px-2 py-3 text-center text-xs text-muted-foreground/60`,children:`Empty`})]})]},t.id)})}),(!i&&C.length>0||_)&&(0,I.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:[!i&&C.length>0&&(0,I.jsxs)(`div`,{className:`pointer-events-auto relative`,children:[(0,I.jsx)(`button`,{type:`button`,onClick:()=>l(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,I.jsx)(u,{className:`h-3.5 w-3.5`})}),s&&(0,I.jsxs)(`div`,{className:`absolute right-0 top-8 w-44 rounded-lg border bg-background p-2 shadow-elevation-2`,children:[(0,I.jsx)(`p`,{className:`px-2 pb-1 text-[10px] uppercase tracking-wide text-muted-foreground`,children:`Add column`}),C.map(e=>(0,I.jsx)(`button`,{type:`button`,onClick:()=>{l(!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,I.jsx)(`button`,{type:`button`,onClick:()=>l(!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,I.jsx)(p,{className:`my-auto h-4 w-4 self-center text-muted-foreground/70`,"aria-label":`More columns`})]}),(0,I.jsx)(se,{document:a,isOpen:a!==null,onClose:()=>o(null),workspaceId:t})]})}function q(e,t,n,r,i){let a=`${e}\0${t}\0${n}\0${r.join(`,`)}\0${i??``}`,[o,s]=(0,N.useState)(0),[c,l]=(0,N.useState)(null);(0,N.useEffect)(()=>{let o=!1;return O(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,N.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,N.useCallback)(()=>s(e=>e+1),[])}}function ve({workspaceId:e,treeName:t,path:n}){let{docs:r,isLoading:i,refresh:a}=q(e,t,n,[D],`tasks`),[o,s]=(0,N.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,I.jsxs)(`div`,{className:`mx-auto flex h-full w-full max-w-3xl flex-col p-4`,children:[(0,I.jsxs)(`div`,{className:`mb-2 flex shrink-0 items-center justify-between gap-2`,children:[(0,I.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[l,` open`]}),(0,I.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`hide done`]})]}),(0,I.jsx)(`div`,{className:`min-h-0 flex-1 space-y-1 overflow-y-auto`,children:i?(0,I.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`Loading…`}):c.length===0?(0,I.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No todos here.`}):c.map(t=>(0,I.jsx)(te,{doc:t,workspaceId:e,readOnly:!1,onChanged:a},t.id))})]})}var ye=[k,`data/type/webapp`],J=`Other`;function be({workspaceId:e,treeName:t,path:n}){let{docs:r,isLoading:i}=q(e,t,n,ye),a=(0,N.useMemo)(()=>{let e=new Map;for(let t of r){let n=String(t.data?.category??``).trim(),r=n?n.toLowerCase():``,i=e.get(r)??[];i.push(t),e.set(r,i)}return[...e.entries()].map(([e,t])=>({key:e,label:e?String(t[0].data.category).trim():J,items:t.sort((e,t)=>X(e).localeCompare(X(t)))})).sort((e,t)=>!e.key-+!t.key||e.label.localeCompare(t.label))},[r]);return(0,I.jsx)(`div`,{className:`mx-auto h-full w-full max-w-5xl overflow-y-auto p-4`,children:i?(0,I.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`Loading…`}):a.length===0?(0,I.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No web apps here. Add a link and tick “Web app”.`}):a.map(e=>(0,I.jsxs)(`section`,{className:`mb-6`,children:[(0,I.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:e.label}),(0,I.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(7rem,1fr))] gap-3`,children:e.items.map(e=>(0,I.jsx)(Z,{doc:e},e.id))})]},e.key||J))})}function Y(e){return String(e.data?.uri??``)}function X(e){let t=String(e.data?.label??``).trim();if(t)return t;try{return new URL(Y(e)).hostname.replace(/^www\./,``)}catch{return Y(e)}}function Z({doc:e}){let t=X(e);return(0,I.jsxs)(`a`,{href:Y(e),target:`_blank`,rel:`noopener noreferrer`,title:Y(e),className:`flex flex-col items-center gap-2 rounded-lg border border-border bg-card p-3 text-center outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,I.jsx)(`span`,{className:`flex h-10 w-10 items-center justify-center rounded-md bg-primary/10 text-lg font-semibold text-primary`,children:t.charAt(0).toUpperCase()}),(0,I.jsx)(`span`,{className:`w-full truncate text-xs text-foreground`,children:t})]})}function xe({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:ee(n.treeName)},i=e===`todo-app`?`todo`:e===`notes-app`?`notes`:e,a=me.find(e=>e.id===i);return(0,I.jsx)(he,{target:r,children:e===`todos`?(0,I.jsx)(ve,{...n}):e===`apps`?(0,I.jsx)(be,{...n}):a?(0,I.jsx)(a.Component,{}):null})}function Se(e,t){if(!e)return[];let n=t.split(`/`).filter(Boolean),r=e;for(let e of n)if(r=r?.children?.find(t=>t.name===e)??null,!r)return[];let i=n.length?`/${n.join(`/`)}`:``,a=(r.children??[]).filter(e=>e.type!==`canvas`).map(e=>({name:e.name,path:`${i}/${e.name}`,label:e.label,color:e.color,childCount:e.children?.length??0})).sort((e,t)=>(e.label||e.name).localeCompare(t.label||t.name,void 0,{numeric:!0,sensitivity:`base`}));return n.length>0&&a.unshift({name:`..`,path:n.length>1?`/${n.slice(0,-1).join(`/`)}`:`/`,isParent:!0}),a}export{B as a,L as c,W as i,F as l,xe as n,z as o,K as r,H as s,Se as t,P as u};
|
|
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{$r as i,Ct as a,Dr as o,G as s,L as c,Lt as l,Pt as u,Rt as d,St as f,Ur as p,Wt as m,X as h,Xr as g,ai as _,bn as v,ct as y,hn as b,it as x,mt as S,tt as C,xn as w,yn as T}from"./ui-DEgHnkQu.js";import{t as E}from"./utils-2pl1SbIp.js";import{Bn as D,G as O,Ln as k,On as A,xn as ee}from"./workspace-4hWrSEku.js";import{t as te}from"./TodosWidget-DGftEAbs.js";import{d as ne,o as re,u as ie}from"./ObjectPropertiesCard-DesXRw-_.js";import{S as ae,j as oe,p as se,t as ce,w as j}from"./document-list-Bbbx-pTZ.js";import{n as le,r as ue}from"./use-toolbox-Ck_cLGgf.js";import{t as de}from"./useToastHelpers-CRrpIIdY.js";import{n as M}from"./color-DFEH4BfK.js";import{t as fe}from"./DocumentIcon-0ya9gycp.js";import{r as pe}from"./workspace-BydSRtST.js";import{t as me}from"./registry-D7HyG001.js";import{t as he}from"./applet-target-LvhUEvE5.js";var N=e(n(),1);function P(e){let{pathname:t}=r(),n=ue()?.setAgentView,i=JSON.stringify(e);(0,N.useEffect)(()=>(n?.({pathname:t,view:JSON.parse(i)}),()=>n?.(null)),[t,i,n])}function F(e,t,n,r){return structuredClone({...e,query:pe(t,n,r),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone})}var I=t();function ge({target:e,children:t}){let[n,r]=(0,N.useState)(null),{showErrorToast:i}=de(),a=e=>e.target.closest?.(`[data-drop-folder]`)?.dataset.dropFolder||null;return(0,I.jsxs)(`div`,{className:`relative flex flex-col h-full min-h-0 bg-background ${n?`ring-2 ring-inset ring-primary`:``}`,onDragOverCapture:t=>{!e||!j(t.dataTransfer)||(t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect=`copy`,r(a(t)??e.path))},onDragLeaveCapture:e=>{e.currentTarget.contains(e.relatedTarget)||r(null)},onDropCapture:t=>{if(!e||!j(t.dataTransfer))return;t.preventDefault(),t.stopPropagation(),r(null);let n=a(t);ae(t.dataTransfer,n?{...e,path:n}:e).then(e=>{e||i(`Nothing to upload in this drop`)}).catch(e=>i(e instanceof Error?e.message:`Could not read the dropped files`))},children:[t,n&&(0,I.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-4 z-30 flex justify-center`,children:(0,I.jsxs)(`span`,{className:`rounded-md border bg-popover px-3 py-1.5 text-sm font-medium shadow-elevation-3`,children:[`Drop to upload to `,n]})})]})}function L({navigationTabs:e,navigationActions:t,onBack:n,accentColor:r,frameContent:i=!0,urlType:o,urlDisplay:c,contextPath:u,treeName:f,workspaceId:p,workspaceLabel:m,workspaceIcon:g,documentSchema:y,documents:b,isLoading:x,totalCount:C,currentPage:w,pageSize:T,onPageChange:E,onPageSizeChange:D,onRemoveDocument:O,onDeleteDocument:k,onDestroyDocument:A,onRemoveDocuments:te,onDeleteDocuments:ae,onDestroyDocuments:se,onCopyDocuments:j,onCutDocuments:ue,onPasteDocuments:de,onImportDocuments:M,onSelectionChange:fe,pastedDocumentIds:pe,onPurgeDocuments:me,disablePurgeDocuments:he,canvasInfo:P,isCanvasPinned:F,onTogglePinCanvas:L,onSaveAsCanvas:R,onShareCanvas:z,onUnshareCanvas:B,onDeleteCanvas:V,isSharingCanvas:H,isDeletingCanvas:U,isCanvasShared:W,isCanvasLocked:G,backendSearchQueries:_e,onBackendSearch:K,onRemoveBackendQuery:q,serverSort:ve,onServerSortChange:ye,scope:J,onScopeChange:be,canSaveChanges:Y,isSavingChanges:X,onSaveChanges:Z,onBrowseWorkspaces:xe,onBrowseTree:Se,onNavigatePath:Ce,linkTree:we,children:Q,contentBanner:Te,folders:Ee,onOpenFolder:De}){let Oe=o===`canvas`,ke=oe(),{state:Ae,toggleView:je,hasActiveFilters:Me,openAddPicker:Ne}=le(),$=re(),[Pe,Fe]=(0,N.useState)(``),Ie=JSON.stringify([p,f,u,y]),[Le,Re]=(0,N.useState)(Ie);Le!==Ie&&(Re(Ie),Fe(``));let ze=(0,I.jsxs)(I.Fragment,{children:[t,R&&(0,I.jsx)(`button`,{type:`button`,onClick:R,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,I.jsx)(_,{className:`h-4 w-4`})})]});return(0,I.jsxs)(ge,{target:p&&(M||f===`backends`)?{mode:`workspace`,workspaceName:p,path:u,treeName:f||`context`,treeType:ee(f)}:null,children:[e&&!ke&&(0,I.jsx)(ne,{accentColor:r,children:e}),(0,I.jsxs)(`div`,{className:`canvas-surface-body${i&&!ke?` is-framed`:``}`,children:[(0,I.jsx)(ie,{workspaceIcon:g,workspace:m||p||c.split(`://`)[0]||`Workspace`,actions:ke&&e?(0,I.jsxs)(`details`,{className:`relative shrink-0`,"aria-label":`Canvas views`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer rounded-md border px-2 py-1 text-xs`,title:`Choose or manage content views`,children:`Views`}),(0,I.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}${o.endsWith(`-layer`)?`:layer`:``}`:o.replace(`-layer`,``),path:u,accentColor:r,onBack:$.location?$.location.section===`view`?$.close:()=>$.update?.({section:`view`}):n,section:$.location?`document/${$.location.documentId}/${$.location.section}`:void 0,onSection:$.location?()=>$.update?.({section:`view`}):void 0,onBrowseWorkspaces:xe,onBrowseTree:Se,onNavigatePath:Ce,onFilter:()=>je(`tools`),filtersActive:Me,filtersOpen:Ae.t1Open&&Ae.t1View===`tools`,onAdd:e=>Ne({modal:e.shiftKey,fresh:!0}),search:K||!Q?{workspaceId:p,queries:_e||[],onSearch:K??Fe,localOnly:!K,onRemoveQuery:q,scope:J,onScopeChange:be}:void 0,onDraftChange:Q?void 0:Fe}),Oe&&P?(0,I.jsx)(I.Fragment,{children:(0,I.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,I.jsx)(`div`,{className:`w-1 h-6 rounded-full shrink-0`,style:{backgroundColor:P.color}}),(0,I.jsx)(v,{className:`w-4 h-4 shrink-0 text-primary`}),(0,I.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,I.jsx)(`span`,{className:`text-lg font-semibold leading-tight truncate`,children:P.label||c.split(`://`)[1]||`Canvas`}),P.description&&(0,I.jsx)(`span`,{className:`text-xs text-muted-foreground truncate leading-tight`,children:P.description})]}),Y&&Z&&(0,I.jsxs)(`button`,{type:`button`,onClick:Z,disabled:X,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,I.jsx)(a,{className:`w-3 h-3`}),(0,I.jsx)(`span`,{className:`hidden sm:inline`,children:X?`Saving...`:`Save filters`})]}),L&&(0,I.jsxs)(`button`,{type:`button`,onClick:L,"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,I.jsx)(d,{className:`w-3 h-3`}):(0,I.jsx)(l,{className:`w-3 h-3`}),(0,I.jsx)(`span`,{className:`hidden sm:inline`,children:F?`Unpin`:`Pin`})]}),z&&(0,I.jsxs)(`button`,{type:`button`,onClick:z,disabled:H||U,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:W?`Copy public link`:`Share canvas`,children:[(0,I.jsx)(S,{className:`w-3 h-3`}),(0,I.jsx)(`span`,{className:`hidden sm:inline`,children:H?`Sharing...`:W?`Copy link`:`Share`})]}),W&&B&&(0,I.jsxs)(`button`,{type:`button`,onClick:B,disabled:H||U,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,I.jsx)(s,{className:`w-3 h-3`}),(0,I.jsx)(`span`,{className:`hidden sm:inline`,children:`Unshare`})]}),V&&(0,I.jsxs)(`button`,{type:`button`,onClick:V,disabled:U||G&&!W,title:G&&!W?`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,I.jsx)(h,{className:`w-3 h-3`}),(0,I.jsx)(`span`,{className:`hidden sm:inline`,children:U?`Deleting…`:`Delete`})]})]})}):null,Q&&(R||t)&&(0,I.jsx)(`div`,{className:`flex items-center gap-2 border-b px-3 py-1`,children:ze}),(0,I.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto${Q?``:` flex flex-col`}`,children:[Te,Q||(0,I.jsx)(ce,{readingPane:!0,externalSearchQuery:Pe,toolbarActions:ze,documents:y?b.filter(e=>e.schema===y):b,isLoading:x,folders:y?void 0:Ee,onOpenFolder:De,contextPath:u,treeName:f,workspaceId:p,totalCount:C,viewMode:y?`card`:`table`,allowViewToggle:!0,currentPage:w,pageSize:T,onPageChange:E,onPageSizeChange:D,onRemoveDocument:O,onDeleteDocument:k,onDestroyDocument:A,onRemoveDocuments:te,onDeleteDocuments:ae,onDestroyDocuments:se,onCopyDocuments:j,onCutDocuments:ue,onPasteDocuments:de,onImportDocuments:M,onSelectionChange:fe,pastedDocumentIds:pe,onPurgeDocuments:y?void 0:me,disablePurgeDocuments:he,backendSearchQueries:_e,onBackendSearch:K,serverSort:ve,onServerSortChange:ye,onRemoveBackendQuery:q,scope:J,onScopeChange:be,canSaveChanges:!Oe&&Y,isSavingChanges:X,onSaveChanges:Z,linkTree:we},y??`documents`)]})]})]})}var R=[{id:`todos`,label:`Todo list`},{id:`todo-app`,label:`Todo App`},{id:`notes`,label:`Notes list`},{id:`notes-app`,label:`Notes App`},{id:`calendar`,label:`Calendar`},{id:`apps`,label:`Apps`},{id:`sketch`,label:`Sketch`},{id:`terminal`,label:`Terminal`}];function z(e){return e?.kind===`app`&&e.app===`notes`?`data/schema/note`:void 0}var B={id:`default`,name:`All`,kind:`documents`};function V(){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 H(e){let t=e?.views;if(!Array.isArray(t))return[B];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`&&(R.some(e=>e.id===t.app)||t.app===`filters`||t.app===`lens`)});return n.length>0?n:[B]}var U={todos:b,"todo-app":b,notes:C,"notes-app":C,calendar:g,filters:y,sketch:i,terminal:x,lens:f,apps:w};function W({views:e,activeId:t,onSelect:n,onSave:r,readOnly:i=!1,className:a,accentColor:s,onOpenToSide:l}){let[d,f]=(0,N.useState)(null),[p,h]=(0,N.useState)(``),[g,_]=(0,N.useState)(!1),[v,y]=(0,N.useState)(null),[b,x]=(0,N.useState)(null),S=(0,N.useRef)(null);(0,N.useEffect)(()=>{let e=S.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,N.useEffect)(()=>{S.current?.querySelector(`[aria-pressed="true"], input`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[t,d]);let C=()=>{y(null),x(null)},w=()=>{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))}C()},D=()=>{if(!d)return;let t=p.trim();t&&r(e.map(e=>e.id===d?{...e,name:t}:e)),f(null)},O=(t,n)=>{_(!1);let i=`view-${Date.now().toString(36)}`,a=t===`columns`?`Board`:t===`app`?R.find(e=>e.id===n)?.label??`App`:`List`,o=t===`columns`?{id:i,name:a,kind:t,columns:V()}:t===`app`?{id:i,name:a,kind:t,app:n}:{id:i,name:a,kind:t};r([...e,o],i),f(i),h(a)},k=n=>{let i=e.filter(e=>e.id!==n);r(i.length>0?i:[B],n===t?i[0]?.id??B.id:void 0)};return(0,I.jsxs)(`div`,{className:E(`relative flex h-full min-w-0 items-end`,a),children:[(0,I.jsx)(`div`,{ref:S,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`?o:r.kind===`app`&&r.app?U[r.app]:T;return d===r.id?(0,I.jsx)(`input`,{autoFocus:!0,"aria-label":`Tab name`,value:p,onChange:e=>h(e.target.value),onBlur:D,onKeyDown:e=>{e.key===`Enter`&&D(),e.key===`Escape`&&f(null)},className:E(`relative h-[2.3rem] w-28 shrink-0 rounded-t-[.5rem] border-0 px-3 pb-1 text-xs outline-none ring-0`,a?E(`z-[2] bg-background font-medium`,s?M(s):`text-foreground`):`bg-muted text-muted-foreground`),style:{backgroundColor:a?s:void 0}},r.id):(0,I.jsxs)(`button`,{type:`button`,"aria-pressed":a,onClick:()=>n(r.id),onDoubleClick:()=>{i||(f(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(),w()},onDragEnd:C,className:E(`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?E(`z-[2] bg-background font-medium`,s?M(s):`text-foreground`):`bg-muted text-muted-foreground hover:bg-accent hover:text-foreground`,v===r.id&&`opacity-50`),style:{backgroundColor:a?s:void 0,boxShadow:b?.id===r.id?`inset ${b.before?`2px`:`-2px`} 0 0 var(--primary)`:void 0},children:[(0,I.jsx)(u,{className:`h-3 w-3 shrink-0`}),(0,I.jsx)(`span`,{className:`max-w-32 truncate`,children:r.name}),l&&(0,I.jsx)(m,{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(),l(r.id)}}),!i&&e.length>1&&(0,I.jsx)(c,{className:E(`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(),k(r.id)}})]},r.id)})}),!i&&(g?(0,I.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,I.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,I.jsx)(T,{className:`h-3 w-3`}),` List`]}),(0,I.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,I.jsx)(o,{className:`h-3 w-3`}),` Board`]}),R.map(e=>{let t=U[e.id];return(0,I.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,I.jsx)(t,{className:`h-3 w-3`}),` `,e.label]},e.id)}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>_(!1),className:`p-1 text-muted-foreground hover:text-foreground`,"aria-label":`Cancel`,children:(0,I.jsx)(c,{className:`h-3 w-3`})})]}):(0,I.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,I.jsx)(u,{className:`h-3.5 w-3.5`})}))]})}var G=[{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 _e(e,t){return t.some(t=>e.schema===t||e.schema.startsWith(`${t}/`))}function K({documents:e,workspaceId:t,columns:n,onColumnsChange:r,readOnly:i=!1}){let[a,o]=(0,N.useState)(null),[s,l]=(0,N.useState)(!1),[d,f]=(0,N.useState)({}),[m,h]=(0,N.useState)({}),g=(0,N.useRef)(null),[_,v]=(0,N.useState)(!1),y=(0,N.useCallback)(()=>{let e=g.current;e&&v(e.scrollWidth-e.clientWidth-e.scrollLeft>8)},[]);(0,N.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=d[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=G.filter(e=>!n.some(t=>t.id===e.id));return(0,I.jsxs)(`div`,{className:`relative h-full`,children:[(0,I.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 a=(d[t.id]??t.filter??``).toLowerCase(),s=e.filter(e=>_e(e,t.schemas)).filter(e=>{if(!a)return!0;let t=A(e);return`${t.title}\n${t.preview}\n${t.subtitle}`.toLowerCase().includes(a)}),l=m[t.id]??t.width;return(0,I.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:[!i&&(0,I.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,I.jsxs)(`div`,{className:`flex items-center gap-2 px-3 pb-1 pt-2.5 max-sm:pr-10`,children:[(0,I.jsx)(`span`,{className:`truncate text-sm font-medium`,children:t.label}),(0,I.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:s.length}),(0,I.jsx)(`span`,{className:`flex-1`}),!i&&(0,I.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,I.jsx)(c,{className:`h-3.5 w-3.5`})})]}),(0,I.jsx)(`div`,{className:`px-3 pb-2`,children:(0,I.jsx)(`input`,{value:d[t.id]??t.filter??``,onChange:e=>f(n=>({...n,[t.id]:e.target.value})),onBlur:()=>S(t.id),onKeyDown:e=>{e.key===`Enter`&&S(t.id)},placeholder:`Filter…`,readOnly:i,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,I.jsxs)(`div`,{className:`flex-1 space-y-1.5 overflow-y-auto px-2 pb-2`,children:[s.map(e=>{let t=A(e);return(0,I.jsxs)(`button`,{type:`button`,onClick:()=>o(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,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(fe,{document:e,size:3.5}),(0,I.jsx)(`span`,{className:`truncate text-xs font-medium`,title:t.title,children:t.title})]}),t.preview&&(0,I.jsx)(`p`,{className:`mt-1 line-clamp-2 break-words text-[11px] leading-snug text-muted-foreground`,children:t.preview}),(0,I.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground/70`,children:new Date(e.updatedAt||e.createdAt).toLocaleDateString()})]},e.id)}),s.length===0&&(0,I.jsx)(`p`,{className:`px-2 py-3 text-center text-xs text-muted-foreground/60`,children:`Empty`})]})]},t.id)})}),(!i&&C.length>0||_)&&(0,I.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:[!i&&C.length>0&&(0,I.jsxs)(`div`,{className:`pointer-events-auto relative`,children:[(0,I.jsx)(`button`,{type:`button`,onClick:()=>l(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,I.jsx)(u,{className:`h-3.5 w-3.5`})}),s&&(0,I.jsxs)(`div`,{className:`absolute right-0 top-8 w-44 rounded-lg border bg-background p-2 shadow-elevation-2`,children:[(0,I.jsx)(`p`,{className:`px-2 pb-1 text-[10px] uppercase tracking-wide text-muted-foreground`,children:`Add column`}),C.map(e=>(0,I.jsx)(`button`,{type:`button`,onClick:()=>{l(!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,I.jsx)(`button`,{type:`button`,onClick:()=>l(!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,I.jsx)(p,{className:`my-auto h-4 w-4 self-center text-muted-foreground/70`,"aria-label":`More columns`})]}),(0,I.jsx)(se,{document:a,isOpen:a!==null,onClose:()=>o(null),workspaceId:t})]})}function q(e,t,n,r,i){let a=`${e}\0${t}\0${n}\0${r.join(`,`)}\0${i??``}`,[o,s]=(0,N.useState)(0),[c,l]=(0,N.useState)(null);(0,N.useEffect)(()=>{let o=!1;return O(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,N.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,N.useCallback)(()=>s(e=>e+1),[])}}function ve({workspaceId:e,treeName:t,path:n}){let{docs:r,isLoading:i,refresh:a}=q(e,t,n,[D],`tasks`),[o,s]=(0,N.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,I.jsxs)(`div`,{className:`mx-auto flex h-full w-full max-w-3xl flex-col p-4`,children:[(0,I.jsxs)(`div`,{className:`mb-2 flex shrink-0 items-center justify-between gap-2`,children:[(0,I.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[l,` open`]}),(0,I.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`hide done`]})]}),(0,I.jsx)(`div`,{className:`min-h-0 flex-1 space-y-1 overflow-y-auto`,children:i?(0,I.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`Loading…`}):c.length===0?(0,I.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No todos here.`}):c.map(t=>(0,I.jsx)(te,{doc:t,workspaceId:e,readOnly:!1,onChanged:a},t.id))})]})}var ye=[k,`data/type/webapp`],J=`Other`;function be({workspaceId:e,treeName:t,path:n}){let{docs:r,isLoading:i}=q(e,t,n,ye),a=(0,N.useMemo)(()=>{let e=new Map;for(let t of r){let n=String(t.data?.category??``).trim(),r=n?n.toLowerCase():``,i=e.get(r)??[];i.push(t),e.set(r,i)}return[...e.entries()].map(([e,t])=>({key:e,label:e?String(t[0].data.category).trim():J,items:t.sort((e,t)=>X(e).localeCompare(X(t)))})).sort((e,t)=>!e.key-+!t.key||e.label.localeCompare(t.label))},[r]);return(0,I.jsx)(`div`,{className:`mx-auto h-full w-full max-w-5xl overflow-y-auto p-4`,children:i?(0,I.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`Loading…`}):a.length===0?(0,I.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No web apps here. Add a link and tick “Web app”.`}):a.map(e=>(0,I.jsxs)(`section`,{className:`mb-6`,children:[(0,I.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:e.label}),(0,I.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(7rem,1fr))] gap-3`,children:e.items.map(e=>(0,I.jsx)(Z,{doc:e},e.id))})]},e.key||J))})}function Y(e){return String(e.data?.uri??``)}function X(e){let t=String(e.data?.label??``).trim();if(t)return t;try{return new URL(Y(e)).hostname.replace(/^www\./,``)}catch{return Y(e)}}function Z({doc:e}){let t=X(e);return(0,I.jsxs)(`a`,{href:Y(e),target:`_blank`,rel:`noopener noreferrer`,title:Y(e),className:`flex flex-col items-center gap-2 rounded-lg border border-border bg-card p-3 text-center outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,I.jsx)(`span`,{className:`flex h-10 w-10 items-center justify-center rounded-md bg-primary/10 text-lg font-semibold text-primary`,children:t.charAt(0).toUpperCase()}),(0,I.jsx)(`span`,{className:`w-full truncate text-xs text-foreground`,children:t})]})}function xe({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:ee(n.treeName)},i=e===`todo-app`?`todo`:e===`notes-app`?`notes`:e,a=me.find(e=>e.id===i);return(0,I.jsx)(he,{target:r,children:e===`todos`?(0,I.jsx)(ve,{...n}):e===`apps`?(0,I.jsx)(be,{...n}):a?(0,I.jsx)(a.Component,{}):null})}function Se(e,t){if(!e)return[];let n=t.split(`/`).filter(Boolean),r=e;for(let e of n)if(r=r?.children?.find(t=>t.name===e)??null,!r)return[];let i=n.length?`/${n.join(`/`)}`:``,a=(r.children??[]).filter(e=>e.type!==`canvas`).map(e=>({name:e.name,path:`${i}/${e.name}`,label:e.label,color:e.color,childCount:e.children?.length??0})).sort((e,t)=>(e.label||e.name).localeCompare(t.label||t.name,void 0,{numeric:!0,sensitivity:`base`}));return n.length>0&&a.unshift({name:`..`,path:n.length>1?`/${n.slice(0,-1).join(`/`)}`:`/`,isParent:!0}),a}export{B as a,L as c,W as i,F as l,xe as n,z as o,K as r,H as s,Se as t,P as u};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{t as r}from"./button--VYZekMF.js";import{t as i}from"./input-BOtCd4HP.js";import{W as a}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{t as r}from"./button--VYZekMF.js";import{t as i}from"./input-BOtCd4HP.js";import{W as a}from"./index-NOhHv2VY.js";function o(e,t,n){return[e.trim()?`## Role\n${e.trim()}`:``,t.trim()?`## Identity\n${t.trim()}`:``,n.trim()?`## Instructions\n${n.trim()}`:``].filter(Boolean).join(`
|
|
2
2
|
|
|
3
3
|
`)}var s=e(n(),1),c=t();function l({value:e,onChange:t,models:n,loading:a,error:o,refresh:l,disabled:u,id:d}){let f=(0,s.useId)(),p=n.find(t=>t.id===e);return(0,c.jsxs)(`div`,{className:`space-y-2`,children:[(0,c.jsxs)(`div`,{className:`flex gap-2`,children:[(0,c.jsx)(i,{id:d,"aria-label":`Model`,list:f,value:e,onChange:e=>t(e.target.value,n.find(t=>t.id===e.target.value)),placeholder:`Choose or enter a model ID`,disabled:u}),(0,c.jsx)(r,{type:`button`,variant:`outline`,disabled:u||a,onClick:l,children:`Refresh models`})]}),(0,c.jsx)(`datalist`,{id:f,children:n.map(e=>(0,c.jsx)(`option`,{value:e.id,children:e.name},e.id))}),(0,c.jsx)(`p`,{className:`text-xs text-muted-foreground`,role:`status`,children:a?`Loading models…`:o||(n.length?`${n.length} models available`:`Enter provider credentials to load available models. You can also enter a model ID.`)}),p&&(0,c.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Context: `,p.contextWindow?.toLocaleString()??`not reported`,` · Max output: `,p.maxTokens?.toLocaleString()??`not reported`,` tokens`,p.limitsSource===`runtime`?` (runtime catalogue)`:p.limitsSource===`provider`?` (provider)`:``]})]})}function u(e,t,n,r){let[i,o]=(0,s.useState)(0),c=JSON.stringify([e,t,n,r,i]),[l,u]=(0,s.useState)({key:``,models:[],loading:!1,error:``}),d=!!t.trim()||!!r||[`ollama`,`lm-studio`,`vllm`,`custom`].includes(e);return(0,s.useEffect)(()=>{if(!d)return;let i=new AbortController,o=setTimeout(()=>{u({key:c,models:[],loading:!0,error:``}),a({provider:e,apiKey:t.trim()||void 0,baseUrl:n.trim()||void 0,agentIdentifier:r},i.signal).then(e=>{i.signal.aborted||u({key:c,models:e,loading:!1,error:``})}).catch(e=>{i.signal.aborted||u({key:c,models:[],loading:!1,error:e instanceof Error?e.message:`Unable to load models`})})},700);return()=>{clearTimeout(o),i.abort()}},[c,d,e,t,n,r]),{...l.key===c?l:{models:[],loading:d,error:``},refresh:()=>o(e=>e+1)}}export{l as n,o as r,u 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{_t as r}from"./react-BHzhHVTZ.js";import{g as i}from"./chunk-62JRHF6Z-vspAGgtK.js";import{Bn as a,Hn as o,It as s,Pt as c,X as l,at as u,br as d,ht as f,qn as p,rt as m}from"./ui-DEgHnkQu.js";import{t as h}from"./button--VYZekMF.js";import{t as g}from"./input-BOtCd4HP.js";import{t as _}from"./api-CA6WiiYM.js";import{n as v}from"./use-toast-BlLDqSUO.js";import{Ut as y,Wt as b,ft as x,i as S,in as C,jt as w,mn as T,rn as E,t as D,v as O,yt as k}from"./workspace-4hWrSEku.js";import{a as A,c as j,i as M,l as N,n as P,o as F,r as I,s as L,t as R}from"./alert-dialog-BKtaX1_a.js";import{t as ee}from"./use-mobile-Db-vWu9Y.js";import"./layer-style-Byl5LNFR.js";import{i as z,r as te,t as B}from"./color-DFEH4BfK.js";import{t as V}from"./workspace-access-C9nZlBBZ.js";import{i as ne}from"./use-menu-CKSpS96u.js";import{r as re}from"./last-path-BbXWC3b3.js";import{At as ie,Ft as H,It as U,Lt as ae,Mt as oe,Nt as se,Ot as ce,Rt as le,jt as W,kt as ue,vt as G,zt as K}from"./index-CTvqbEB8.js";import{n as de}from"./page-header-NyYSXjfY.js";import{t as q}from"./form-panel-CEbNKttr.js";import{t as fe}from"./use-create-panel-DhSNIGtr.js";import{n as pe,t as me}from"./useSocketSubscription-ifW-vnlb.js";import{a as he,i as ge,n as _e,r as ve,t as ye}from"./workspace-import-form-CWs9ZTts.js";var J=e(n(),1),Y=t();function be({workspace:e,onStart:t,onStop:n,onEnter:r,onEdit:i,onSettings:a,onDestroy:o}){let[c,p]=(0,J.useState)(!1),g=e.status===`active`,_=e.type===`universe`||e.name===`universe`,v=e.status===`error`,y=e.status===`not_found`,b=e.isShared===!0||e.type===`shared`,x=e.ownerEmail||e.owner,S=typeof e.sharedVia==`object`&&e.sharedVia?e.sharedVia:null,C=S?.permissions||[],w=C.includes(`admin`)?`admin`:C.includes(`write`)?`read/write`:`read-only`,T=S?.type===`group`?`via group ${S.principal}`:S?.type===`user`?`shared with you`:``,E=e.origin===`remote`,D=e.status===`offline`,O=z(e.color),k=O?``:`border-border`,ee=O?{borderLeftColor:O,borderLeftWidth:`4px`}:{borderLeftWidth:`4px`};return(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsxs)(H,{className:`relative ${k}`,style:ee,children:[(0,Y.jsx)(le,{children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1 basis-40`,children:[(0,Y.jsx)(K,{className:`truncate`,children:e.label||e.name}),(0,Y.jsx)(ae,{children:b?`Shared from ${x}`:e.description||``})]}),(0,Y.jsxs)(`div`,{className:`flex w-full shrink-0 flex-wrap items-center gap-2 sm:w-auto`,children:[g?(0,Y.jsx)(h,{variant:`outline`,size:`icon`,onClick:()=>n(G(e)),title:`Stop Workspace`,disabled:v||y,children:(0,Y.jsx)(m,{className:`h-4 w-4`})}):(0,Y.jsx)(h,{variant:`outline`,size:`icon`,onClick:()=>t(G(e)),title:D?`Remote unreachable${e.statusMessage?`: ${e.statusMessage}`:``}`:`Start Workspace`,disabled:v||y||D,children:(0,Y.jsx)(s,{className:`h-4 w-4`})}),g&&(0,Y.jsx)(h,{variant:`outline`,size:`icon`,onClick:()=>r(G(e)),title:`Enter Workspace`,disabled:v||y,children:(0,Y.jsx)(d,{className:`h-4 w-4`})}),a&&(0,Y.jsx)(h,{variant:`outline`,size:`icon`,onClick:()=>a(e),title:V(e)?`Workspace settings`:`Workspace settings require admin access`,"aria-label":`Workspace settings`,disabled:y||!V(e),children:(0,Y.jsx)(f,{className:`h-4 w-4`})}),i&&!_&&!b&&(0,Y.jsx)(h,{variant:`outline`,size:`icon`,onClick:()=>i(e),title:`Edit Workspace`,disabled:v||y,children:(0,Y.jsx)(u,{className:`h-4 w-4`})}),o&&!_&&!b&&(0,Y.jsxs)(R,{open:c,onOpenChange:p,children:[(0,Y.jsx)(N,{asChild:!0,children:(0,Y.jsx)(h,{variant:`outline`,size:`icon`,title:E?`Remove remote workspace reference`:`Delete Workspace`,disabled:g&&!E,className:`text-destructive hover:text-destructive hover:bg-destructive/10`,children:(0,Y.jsx)(l,{className:`h-4 w-4`})})}),(0,Y.jsxs)(M,{children:[(0,Y.jsxs)(L,{children:[(0,Y.jsx)(j,{children:E?`Remove remote workspace`:`Delete Workspace`}),(0,Y.jsx)(A,{children:E?(0,Y.jsxs)(Y.Fragment,{children:[`Remove the reference to "`,e.label||e.name,`" from this server?`,(0,Y.jsx)(`br`,{}),(0,Y.jsx)(`br`,{}),`The workspace itself stays untouched on `,e.remote?.url||e.host,`; only the stored share token and the local cache entry are dropped.`]}):(0,Y.jsxs)(Y.Fragment,{children:[`Are you sure you want to delete the workspace "`,e.label||e.name,`"?`,(0,Y.jsx)(`br`,{}),(0,Y.jsx)(`br`,{}),(0,Y.jsx)(`strong`,{children:`This action cannot be undone.`}),` All data associated with this workspace, including documents, contexts, and configurations will be permanently removed.`]})})]}),(0,Y.jsxs)(F,{children:[(0,Y.jsx)(I,{children:`Cancel`}),(0,Y.jsx)(P,{onClick:()=>{o(e),p(!1)},className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:E?`Remove reference`:`Delete Workspace`})]})]})]})]})]})}),(0,Y.jsx)(U,{children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`div`,{className:`h-3 w-3 rounded-full ${(()=>{switch(e.status){case`active`:return`bg-success`;case`inactive`:case`available`:return`bg-muted-foreground`;case`error`:case`offline`:return`bg-destructive`;case`not_found`:return`bg-muted-foreground`;default:return`bg-accent`}})()}`}),(0,Y.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:(()=>{switch(e.status){case`active`:return`Active`;case`inactive`:return`Inactive`;case`error`:return`Error`;case`not_found`:return`Not Found`;case`available`:return`Available`;case`removed`:return`Removed`;case`destroyed`:return`Destroyed`;case`offline`:return`Offline`;default:return e.status}})()}),_&&(0,Y.jsx)(`span`,{className:`ml-2 rounded-full bg-primary/10 px-2 py-1 text-xs text-primary`,children:`Universe`}),E&&(0,Y.jsxs)(`span`,{className:`ml-2 rounded-full bg-info/10 px-2 py-1 text-xs text-info`,title:e.remote?.url?`${e.remote.url} (${(e.remote.permissions||[]).join(`, `)||`no permissions`})`:void 0,children:[`Remote · `,e.host]}),b&&(0,Y.jsxs)(`span`,{className:`ml-2 rounded-full bg-info/10 px-2 py-1 text-xs text-info`,title:[T,`${w} access`].filter(Boolean).join(` · `),children:[`Shared · `,w]})]})})]})})}var X=[{value:`full`,icon:p,title:`Standard`,blurb:`Everything in one folder: your files in home/, alongside db/, data/, git/.`,tree:[`workspace.json`,`home/ ← your files`,`db/ data/ cache/ Git/`]},{value:`home`,icon:a,title:`Roaming home`,blurb:`The workspace folder IS your drive. Mount it over WebDAV and it looks like a plain home directory. Canvas keeps its files in a hidden .workspace/.`,tree:[`your files, at the top level`,`.workspace/ ← hidden, ignored`]}];function xe({value:e,onChange:t,disabled:n=!1,idPrefix:r=`workspace-layout`,compact:i=!1}){return(0,Y.jsx)(`div`,{className:i?`space-y-1.5`:`grid gap-2 sm:grid-cols-2`,children:X.map(i=>{let a=e===i.value,o=i.icon;return(0,Y.jsxs)(`button`,{id:`${r}-${i.value}`,type:`button`,role:`radio`,"aria-checked":a,disabled:n,onClick:()=>t(i.value),className:`flex w-full gap-2 rounded-md border p-2.5 text-left transition-colors disabled:opacity-50 ${a?`border-primary bg-accent/40`:`hover:bg-accent/20`}`,children:[(0,Y.jsx)(o,{className:`mt-0.5 h-4 w-4 shrink-0 ${a?`text-primary`:`text-muted-foreground`}`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`block text-xs font-medium`,children:i.title}),(0,Y.jsx)(`span`,{className:`mt-0.5 block text-[11px] leading-snug text-muted-foreground`,children:i.blurb}),(0,Y.jsx)(`span`,{className:`mt-1 block font-mono text-[10px] leading-relaxed text-muted-foreground/80`,children:i.tree.map(e=>(0,Y.jsx)(`span`,{className:`block truncate`,children:e},e))})]})]},i.value)})})}function Se(){let[e,t]=(0,J.useState)(`full`),[n,r]=(0,J.useState)(!1);return(0,J.useEffect)(()=>{let e=!0;return _.get(`/ping`,{skipAuth:!0}).then(r=>{let i=r?.defaults?.workspaceLayout;e&&!n&&(i===`home`||i===`full`)&&t(i)}).catch(()=>{}),()=>{e=!1}},[]),[e,e=>{r(!0),t(e)}]}function Ce(){let[e,t]=(0,J.useState)([]),[n,a]=(0,J.useState)(!0),[s,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(``),[m,_]=(0,J.useState)(B()),[y,x]=(0,J.useState)(null),[S,D]=(0,J.useState)(``),[k,A]=Se(),[j,M]=(0,J.useState)(null),[N,P]=(0,J.useState)(null),[F,I]=(0,J.useState)(!1),L=se(),[R,V]=fe(),H=he(),[U,ae]=(0,J.useState)(!1),[le,K]=(0,J.useState)(!1),[_e,X]=(0,J.useState)(!1),[Ce,De]=(0,J.useState)(!1),[Z,Q]=(0,J.useState)(null),{showToast:$}=v(),Oe=i(),ke=ee(),{openM2Drawer:Ae}=ne(),je=pe();me(je,`workspace`,{"workspace:status:changed":e=>t(t=>t.map(t=>t.id===e.workspaceId?{...t,status:e.status}:t)),"workspace:created":e=>t(t=>[...t,e.workspace]),"workspace:deleted":e=>t(t=>t.filter(t=>t.id!==e.workspaceId)),"workspaces.scanned":({report:e})=>{!e.discovered.length&&!e.adopted.length&&!e.updated.length&&!e.missing.length||w().then(e=>t(W(e))).catch(()=>{})}}),(0,J.useEffect)(()=>{let e=async()=>{try{a(!0);let e=await w();t(W(e)),l(null)}catch(e){console.error(`Workspace fetch error:`,e);let t=`Failed to fetch workspaces`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;t=n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||`Failed to fetch workspaces`}l(t),$({title:`Error`,description:t,variant:`destructive`})}finally{a(!1)}};e();let n=()=>{e()};return window.addEventListener(`workspaces:refresh`,n),()=>{window.removeEventListener(`workspaces:refresh`,n)}},[je,$]);let Me=async e=>{if(e.preventDefault(),u.trim()){I(!0);try{let e=await O({name:u,description:f||void 0,color:m,icon:y,label:S||u,layout:k});if(t(t=>[...t,e]),window.dispatchEvent(new CustomEvent(`workspaces:refresh`)),H.selected.size>0){try{await E(e.name);let{ok:t,failed:n}=await ge(e.name,Array.from(H.selected),H.tree);n&&$({title:`Folders`,description:`${t} folder(s) created, ${n} failed`,variant:`destructive`})}catch(e){console.error(`Default folder creation failed:`,e),$({title:`Folders`,description:`Workspace created, but default folders failed`,variant:`destructive`})}H.setSelected(new Set)}d(``),p(``),_(B()),x(null),D(``),$({title:`Success`,description:`Workspace '${e.label||e.name}' created.`}),V(!1)}catch(e){console.error(`Workspace creation error:`,e);let t=`Failed to create workspace`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;t=n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||`Failed to create workspace`}$({title:`Error`,description:t,variant:`destructive`})}finally{I(!1)}}},Ne=async e=>{if(e.preventDefault(),Z)try{let e={label:Z.label,description:Z.description,color:Z.color,icon:Z.icon??null};await T(Z.name,e),t(t=>t.map(t=>t.id===Z.id?{...t,...e}:t)),window.dispatchEvent(new CustomEvent(`workspaces:refresh`)),$({title:`Success`,description:`Workspace '${Z.label}' details updated.`}),Q(null)}catch(e){let t=e instanceof Error?e.message:`Failed to update workspace`;$({title:`Error`,description:t,variant:`destructive`})}},Pe=e=>{Q(e)},Fe=async e=>{try{await b(e.name),t(t=>t.filter(t=>t.id!==e.id)),$({title:`Success`,description:`Workspace '${e.label||e.name}' has been destroyed.`})}catch(e){let t=e instanceof Error?e.message:`Failed to destroy workspace`;$({title:`Error`,description:t,variant:`destructive`})}},Ie=async e=>{try{let n=await E(e);t(e=>e.map(e=>e.id===n.id?{...e,...n}:e)),$({title:`Success`,description:`Workspace '${n.label||n.name}' started.`}),window.dispatchEvent(new CustomEvent(`workspaces:refresh`))}catch(e){console.error(`Workspace start error:`,e);let t=`Failed to start workspace`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;t=n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||`Failed to start workspace`}$({title:`Error`,description:t,variant:`destructive`})}},Le=async e=>{try{let n=await C(e);t(e=>e.map(e=>e.id===n.id?{...e,...n}:e)),$({title:`Success`,description:`Workspace '${n.label||n.name}' stopped.`}),window.dispatchEvent(new CustomEvent(`workspaces:refresh`))}catch(e){console.error(`Workspace stop error:`,e);let t=`Failed to stop workspace`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;t=n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||`Failed to stop workspace`}$({title:`Error`,description:t,variant:`destructive`})}},Re=e=>{Oe(re(e))},{rowProps:ze,handleProps:Be,draggingIndex:Ve,insertLineClass:He}=oe((n,r)=>{let i=ue(e,n,r);t(i),ie(i,(e,t)=>T(G(e),{order:t})).then(({failed:e})=>{window.dispatchEvent(new CustomEvent(`workspaces:refresh`)),e&&$({title:`Partial reorder`,description:`${e} workspace(s) could not be reordered`,variant:`destructive`})})});return(0,Y.jsxs)(`div`,{className:`space-y-6`,children:[(0,Y.jsx)(de,{title:`Workspaces`,description:`Divide your Universe into self-contained workspaces`,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(h,{variant:`outline`,onClick:()=>ae(e=>!e),className:`max-sm:hidden`,children:`Open shared Workspace (local)…`}),(0,Y.jsx)(h,{variant:`outline`,onClick:()=>X(e=>!e),children:`Import workspace`}),(0,Y.jsx)(h,{variant:`outline`,onClick:()=>K(e=>!e),className:`max-sm:hidden`,children:`Import remote…`}),(0,Y.jsx)(h,{variant:`outline`,onClick:()=>De(e=>!e),className:`max-sm:hidden`,children:`Open remote…`}),!L.local&&!R&&(0,Y.jsxs)(h,{onClick:()=>V(!0),className:`max-sm:h-9 max-sm:w-9 max-sm:p-0`,"aria-label":`Create workspace`,title:`Create workspace`,children:[(0,Y.jsx)(c,{className:`h-4 w-4 sm:mr-2`}),(0,Y.jsx)(`span`,{className:`max-sm:hidden`,children:`Create Workspace`})]})]})}),!L.local&&R&&(0,Y.jsx)(q,{title:`Create New Workspace`,onClose:()=>V(!1),children:(0,Y.jsxs)(`form`,{onSubmit:Me,className:`space-y-4`,children:[(0,Y.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,Y.jsx)(g,{value:u,onChange:e=>d(e.target.value),placeholder:`Workspace Name (e.g., 'my-project')`,disabled:F}),(0,Y.jsx)(g,{value:S,onChange:e=>D(e.target.value),placeholder:`Workspace Label (display name, optional)`,disabled:F})]}),(0,Y.jsx)(g,{value:f,onChange:e=>p(e.target.value),placeholder:`Description (optional)`,disabled:F}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`label`,{htmlFor:`workspace-color`,className:`text-sm font-medium`,children:`Icon & Color`}),(0,Y.jsx)(`button`,{type:`button`,title:`Pick icon & color`,disabled:F,onClick:e=>M({x:Math.min(e.clientX,window.innerWidth-290),y:Math.min(e.clientY,window.innerHeight-360)}),className:`flex h-10 w-10 items-center justify-center rounded-md border hover:bg-accent`,children:(0,Y.jsx)(r,{icon:y||`ph:stack-fill`,width:22,height:22,color:z(m)})}),(0,Y.jsx)(g,{id:`workspace-color`,type:`color`,value:m,onChange:e=>_(e.target.value),className:`h-10 w-16 p-1`,disabled:F}),(0,Y.jsx)(h,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>_(B()),disabled:F,children:`Randomize`})]}),j&&(0,Y.jsx)(ce,{x:j.x,y:j.y,current:{icon:y??void 0,color:m},onChange:e=>{`icon`in e&&x(e.icon??null),`color`in e&&e.color&&_(e.color)},onClose:()=>M(null)}),(0,Y.jsxs)(`div`,{className:`rounded-lg border p-3`,children:[(0,Y.jsx)(`p`,{className:`text-sm font-medium`,children:`Folder structure`}),(0,Y.jsx)(`p`,{className:`mb-3 mt-0.5 text-xs text-muted-foreground`,children:`How the workspace directory is laid out on disk. Fixed once created.`}),(0,Y.jsx)(xe,{value:k,onChange:A,disabled:F,idPrefix:`create-workspace-layout`})]}),(0,Y.jsxs)(`div`,{className:`rounded-lg border p-3`,children:[(0,Y.jsxs)(`p`,{className:`text-sm font-medium`,children:[`Default folders `,(0,Y.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:`(optional)`})]}),(0,Y.jsx)(`p`,{className:`mb-3 mt-0.5 text-xs text-muted-foreground`,children:`Ticked folders are created right after the workspace, with matching icons and colors.`}),(0,Y.jsx)(ve,{selected:H.selected,onToggle:H.toggle,tree:H.tree,onTreeChange:H.setTree,disabled:F,idPrefix:`create-default-folders`})]}),(0,Y.jsxs)(h,{type:`submit`,disabled:F||!u.trim(),children:[(0,Y.jsx)(c,{className:`mr-2 h-4 w-4`}),`Create Workspace`]})]})}),U&&(0,Y.jsx)(Te,{}),Ce&&(0,Y.jsx)(Ee,{onClose:()=>De(!1),onChanged:async()=>{try{t(W(await w()))}catch{}window.dispatchEvent(new CustomEvent(`workspaces:refresh`))}}),_e&&(0,Y.jsx)(q,{title:`Import workspace`,onClose:()=>X(!1),children:(0,Y.jsx)(ye,{onImported:()=>X(!1)})}),le&&(0,Y.jsx)(we,{onImported:e=>{t(t=>t.some(t=>t.id===e.id)?t:[...t,e]),window.dispatchEvent(new CustomEvent(`workspaces:refresh`)),K(!1)},onClose:()=>K(!1)}),(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(`h2`,{className:`text-xl font-semibold`,children:`Your Workspaces`}),n&&(0,Y.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`Loading workspaces...`}),s&&(0,Y.jsx)(`div`,{className:`text-center text-destructive`,children:(0,Y.jsx)(`p`,{children:s})}),!n&&!s&&e.length===0&&(0,Y.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`No workspaces found`}),e.length>0&&(0,Y.jsx)(`div`,{className:`grid gap-4`,children:e.map((t,n)=>{let r={...t,createdAt:t.createdAt,updatedAt:t.updatedAt,color:t.color===null?void 0:t.color},i=z(t.color);return(0,Y.jsxs)(`div`,{...ze(n),className:`flex items-stretch rounded-lg ${He(n,e.length)||``} ${Ve===n?`opacity-60`:``}`,children:[(0,Y.jsx)(`button`,{type:`button`,...Be(n),title:`Drag to reorder`,"aria-label":`Drag to reorder`,className:`hidden w-5 shrink-0 cursor-grab items-center justify-center rounded-l-lg active:cursor-grabbing md:flex ${i?``:`bg-muted`}`,style:i?{backgroundColor:i}:void 0,children:(0,Y.jsx)(o,{className:`h-4 w-4 ${te(i)}`})}),(0,Y.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Y.jsx)(be,{workspace:r,onStart:Ie,onStop:Le,onEnter:Re,onEdit:Pe,onSettings:e=>{ke?Ae(`workspaces`,`settings`,G(e)):Oe(`/workspaces/${G(e)}/settings/general`)},onDestroy:Fe})})]},t.id)})})]}),Z&&(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsxs)(`h2`,{className:`text-xl font-semibold`,children:[`Edit Workspace: `,Z.label]}),(0,Y.jsxs)(`form`,{onSubmit:Ne,className:`space-y-4`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{htmlFor:`edit-label`,className:`text-sm font-medium`,children:`Label`}),(0,Y.jsx)(g,{id:`edit-label`,value:Z.label,onChange:e=>Q(t=>t?{...t,label:e.target.value}:null),placeholder:`Workspace Label`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{htmlFor:`edit-description`,className:`text-sm font-medium`,children:`Description`}),(0,Y.jsx)(g,{id:`edit-description`,value:Z.description||``,onChange:e=>Q(t=>t?{...t,description:e.target.value}:null),placeholder:`Description (optional)`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{htmlFor:`edit-color`,className:`text-sm font-medium`,children:`Icon & Color`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`button`,{type:`button`,title:`Pick icon & color`,onClick:e=>P({x:Math.min(e.clientX,window.innerWidth-290),y:Math.min(e.clientY,window.innerHeight-360)}),className:`flex h-10 w-10 items-center justify-center rounded-md border hover:bg-accent`,children:(0,Y.jsx)(r,{icon:Z.icon||`ph:stack-fill`,width:22,height:22,color:z(Z.color)})}),(0,Y.jsx)(g,{id:`edit-workspace-color`,type:`color`,value:Z.color||`#FFFFFF`,onChange:e=>Q(t=>t?{...t,color:e.target.value}:null),className:`h-10 w-16 p-1`}),(0,Y.jsx)(h,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>Q(e=>e?{...e,color:B()}:null),children:`Randomize Color`})]})]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(h,{type:`submit`,disabled:!Z.label?.trim(),children:`Save Changes`}),(0,Y.jsx)(h,{type:`button`,variant:`outline`,onClick:()=>Q(null),children:`Cancel`})]})]}),N&&(0,Y.jsx)(ce,{x:N.x,y:N.y,current:{icon:Z.icon??void 0,color:Z.color??void 0},onChange:e=>{Q(t=>{if(!t)return null;let n={...t};return`icon`in e&&(n.icon=e.icon??null),`color`in e&&e.color&&(n.color=e.color),n})},onClose:()=>P(null)})]})]})}function we({onImported:e,onClose:t}){let{showToast:n}=v(),[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(``),[d,f]=(0,J.useState)(!1),[p,m]=(0,J.useState)(``);return(0,Y.jsx)(q,{title:`Import (pull) a remote Workspace`,onClose:t,children:(0,Y.jsxs)(`form`,{onSubmit:async t=>{t.preventDefault();let i;try{i=new URL(r.trim()).origin}catch{n({title:`Error`,description:`Invalid server URL`,variant:`destructive`});return}if(!a.trim().startsWith(`canvas-`)){n({title:`Error`,description:`Invalid access token (expected canvas-...)`,variant:`destructive`});return}f(!0),m(`Starting…`);try{let t=await x(i,a.trim(),e=>{m(D[e.phase]||e.phase)},{name:s.trim(),label:l.trim()});n({title:`Success`,description:`Workspace '${t.label||t.name}' imported from ${i}.`}),e(t)}catch(e){let t=e,r=t?.message||t?.payload?.message||`Failed to import remote workspace`;n({title:`Error`,description:r,variant:`destructive`})}finally{f(!1),m(``)}},className:`space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-3`,children:[(0,Y.jsx)(g,{placeholder:`Server URL (e.g., https://my.canvas-server.tld)`,value:r,onChange:e=>i(e.target.value),disabled:d}),(0,Y.jsx)(g,{placeholder:`Workspace share token (canvas-...)`,value:a,onChange:e=>o(e.target.value),disabled:d}),(0,Y.jsx)(h,{type:`submit`,disabled:d||!r.trim()||!a.trim()||!s.trim()||!l.trim(),children:d?`Importing…`:`Import Workspace`})]}),(0,Y.jsx)(_e,{name:s,label:l,setName:c,setLabel:u,disabled:d}),d&&p&&(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:p}),(0,Y.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Pulls a full `,(0,Y.jsx)(`strong`,{children:`copy`}),` of the workspace from the remote canvas-server into this one, where it then lives independently. The remote workspace is stopped while it is packed, and large workspaces can take several minutes — progress is shown above.`]})]})})}function Te(){let{showToast:e}=v(),[t,n]=(0,J.useState)(``),[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(!1),s=e=>{try{return new URL(e)}catch{return null}};return(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsx)(`h2`,{className:`text-xl font-semibold`,children:`Open shared Workspace (local)`}),(0,Y.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-3`,children:[(0,Y.jsx)(g,{placeholder:`Shared URL (e.g., https://host/rest/v2/pub/workspaces/ID)`,value:t,onChange:e=>n(e.target.value)}),(0,Y.jsx)(g,{placeholder:`Access token (canvas-...)`,value:r,onChange:e=>i(e.target.value)}),(0,Y.jsx)(h,{onClick:async()=>{if(!s(t.trim())){e({title:`Error`,description:`Invalid URL`,variant:`destructive`});return}if(!r.trim().startsWith(`canvas-`)){e({title:`Error`,description:`Invalid access token`,variant:`destructive`});return}o(!0);try{sessionStorage.setItem(`sharedToken:last`,r.trim());let e=new URLSearchParams({url:t.trim()}).toString();window.location.href=`/shared?${e}`}catch(t){e({title:`Error`,description:t instanceof Error?t.message:`Failed to open shared resource`,variant:`destructive`})}finally{o(!1)}},disabled:a||!t.trim()||!r.trim(),children:`Open`})]}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`We use your provided URL and token to fetch via the remote's public API.`})]})}function Ee({onClose:e,onChanged:t}){let{showToast:n}=v(),r=i(),[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)([]),p=(0,J.useCallback)(async()=>{try{f(await k())}catch{f([])}},[]);(0,J.useEffect)(()=>{p()},[p]);let m=async e=>{e.preventDefault();let r;try{r=new URL(a.trim()).origin}catch{n({title:`Error`,description:`Invalid server URL`,variant:`destructive`});return}u(!0);try{let e=await S(r,s.trim());n({title:`Remote workspace added`,description:`'${e.label}' is available as ${e.address}.`}),o(``),c(``),await p(),t?.()}catch(e){let t=e;n({title:`Error`,description:t?.message||t?.payload?.message||`Failed to add remote workspace`,variant:`destructive`})}finally{u(!1)}},_=async e=>{try{await y(e.id),await p(),t?.()}catch(e){n({title:`Error`,description:e instanceof Error?e.message:`Failed to remove remote workspace`,variant:`destructive`})}};return(0,Y.jsxs)(q,{title:`Open a remote Workspace`,onClose:e,children:[(0,Y.jsxs)(`form`,{onSubmit:m,className:`space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-3`,children:[(0,Y.jsx)(g,{placeholder:`Server URL (e.g., https://my.canvas-server.tld)`,value:a,onChange:e=>o(e.target.value),disabled:l}),(0,Y.jsx)(g,{placeholder:`Workspace share token (canvas-...)`,value:s,onChange:e=>c(e.target.value),disabled:l}),(0,Y.jsx)(h,{type:`submit`,disabled:l||!a.trim()||!s.trim(),children:l?`Checking…`:`Add Remote`})]}),(0,Y.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Keeps the workspace on its own server and registers it here as`,` `,(0,Y.jsx)(`code`,{className:`font-mono text-xs`,children:`name@host`}),` — nothing is copied. Every call you make to it is forwarded to the remote with the share token (its permissions apply); document content and thumbnails are cached locally so they stay readable when the remote is offline. Use “Import remote…” if you want an independent local copy instead.`]})]}),d.length>0&&(0,Y.jsx)(`ul`,{className:`mt-4 space-y-2 border-t pt-3`,children:d.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-col gap-2 rounded-md border p-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`truncate text-sm font-medium`,children:[e.label,(0,Y.jsx)(`span`,{className:`ml-2 rounded bg-muted px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:`remote`})]}),(0,Y.jsxs)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-muted-foreground`,children:[e.address,` · `,e.remote.url]})]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Y.jsx)(h,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r(`/workspaces/${e.address}`),children:`Open`}),(0,Y.jsx)(h,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>_(e),className:`text-destructive hover:text-destructive`,children:`Remove`})]})]},e.id))})]})}export{Ce as default};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{_t as r}from"./react-BHzhHVTZ.js";import{g as i}from"./chunk-62JRHF6Z-vspAGgtK.js";import{Bn as a,Hn as o,It as s,Pt as c,X as l,at as u,br as d,ht as f,qn as p,rt as m}from"./ui-DEgHnkQu.js";import{t as h}from"./button--VYZekMF.js";import{t as g}from"./input-BOtCd4HP.js";import{t as _}from"./api-CA6WiiYM.js";import{n as v}from"./use-toast-BlLDqSUO.js";import{Ut as y,Wt as b,ft as x,i as S,in as C,jt as w,mn as T,rn as E,t as D,v as O,yt as k}from"./workspace-4hWrSEku.js";import{a as A,c as j,i as M,l as N,n as P,o as F,r as I,s as L,t as R}from"./alert-dialog-BKtaX1_a.js";import{t as ee}from"./use-mobile-Db-vWu9Y.js";import"./layer-style-Byl5LNFR.js";import{i as z,r as te,t as B}from"./color-DFEH4BfK.js";import{t as V}from"./workspace-access-C9nZlBBZ.js";import{i as ne}from"./use-menu-CKSpS96u.js";import{r as re}from"./last-path-BbXWC3b3.js";import{At as ie,Ft as H,It as U,Lt as ae,Mt as oe,Nt as se,Ot as ce,Rt as le,jt as W,kt as ue,vt as G,zt as K}from"./index-NOhHv2VY.js";import{n as de}from"./page-header-NyYSXjfY.js";import{t as q}from"./form-panel-CEbNKttr.js";import{t as fe}from"./use-create-panel-DhSNIGtr.js";import{n as pe,t as me}from"./useSocketSubscription-ifW-vnlb.js";import{a as he,i as ge,n as _e,r as ve,t as ye}from"./workspace-import-form-CWs9ZTts.js";var J=e(n(),1),Y=t();function be({workspace:e,onStart:t,onStop:n,onEnter:r,onEdit:i,onSettings:a,onDestroy:o}){let[c,p]=(0,J.useState)(!1),g=e.status===`active`,_=e.type===`universe`||e.name===`universe`,v=e.status===`error`,y=e.status===`not_found`,b=e.isShared===!0||e.type===`shared`,x=e.ownerEmail||e.owner,S=typeof e.sharedVia==`object`&&e.sharedVia?e.sharedVia:null,C=S?.permissions||[],w=C.includes(`admin`)?`admin`:C.includes(`write`)?`read/write`:`read-only`,T=S?.type===`group`?`via group ${S.principal}`:S?.type===`user`?`shared with you`:``,E=e.origin===`remote`,D=e.status===`offline`,O=z(e.color),k=O?``:`border-border`,ee=O?{borderLeftColor:O,borderLeftWidth:`4px`}:{borderLeftWidth:`4px`};return(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsxs)(H,{className:`relative ${k}`,style:ee,children:[(0,Y.jsx)(le,{children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1 basis-40`,children:[(0,Y.jsx)(K,{className:`truncate`,children:e.label||e.name}),(0,Y.jsx)(ae,{children:b?`Shared from ${x}`:e.description||``})]}),(0,Y.jsxs)(`div`,{className:`flex w-full shrink-0 flex-wrap items-center gap-2 sm:w-auto`,children:[g?(0,Y.jsx)(h,{variant:`outline`,size:`icon`,onClick:()=>n(G(e)),title:`Stop Workspace`,disabled:v||y,children:(0,Y.jsx)(m,{className:`h-4 w-4`})}):(0,Y.jsx)(h,{variant:`outline`,size:`icon`,onClick:()=>t(G(e)),title:D?`Remote unreachable${e.statusMessage?`: ${e.statusMessage}`:``}`:`Start Workspace`,disabled:v||y||D,children:(0,Y.jsx)(s,{className:`h-4 w-4`})}),g&&(0,Y.jsx)(h,{variant:`outline`,size:`icon`,onClick:()=>r(G(e)),title:`Enter Workspace`,disabled:v||y,children:(0,Y.jsx)(d,{className:`h-4 w-4`})}),a&&(0,Y.jsx)(h,{variant:`outline`,size:`icon`,onClick:()=>a(e),title:V(e)?`Workspace settings`:`Workspace settings require admin access`,"aria-label":`Workspace settings`,disabled:y||!V(e),children:(0,Y.jsx)(f,{className:`h-4 w-4`})}),i&&!_&&!b&&(0,Y.jsx)(h,{variant:`outline`,size:`icon`,onClick:()=>i(e),title:`Edit Workspace`,disabled:v||y,children:(0,Y.jsx)(u,{className:`h-4 w-4`})}),o&&!_&&!b&&(0,Y.jsxs)(R,{open:c,onOpenChange:p,children:[(0,Y.jsx)(N,{asChild:!0,children:(0,Y.jsx)(h,{variant:`outline`,size:`icon`,title:E?`Remove remote workspace reference`:`Delete Workspace`,disabled:g&&!E,className:`text-destructive hover:text-destructive hover:bg-destructive/10`,children:(0,Y.jsx)(l,{className:`h-4 w-4`})})}),(0,Y.jsxs)(M,{children:[(0,Y.jsxs)(L,{children:[(0,Y.jsx)(j,{children:E?`Remove remote workspace`:`Delete Workspace`}),(0,Y.jsx)(A,{children:E?(0,Y.jsxs)(Y.Fragment,{children:[`Remove the reference to "`,e.label||e.name,`" from this server?`,(0,Y.jsx)(`br`,{}),(0,Y.jsx)(`br`,{}),`The workspace itself stays untouched on `,e.remote?.url||e.host,`; only the stored share token and the local cache entry are dropped.`]}):(0,Y.jsxs)(Y.Fragment,{children:[`Are you sure you want to delete the workspace "`,e.label||e.name,`"?`,(0,Y.jsx)(`br`,{}),(0,Y.jsx)(`br`,{}),(0,Y.jsx)(`strong`,{children:`This action cannot be undone.`}),` All data associated with this workspace, including documents, contexts, and configurations will be permanently removed.`]})})]}),(0,Y.jsxs)(F,{children:[(0,Y.jsx)(I,{children:`Cancel`}),(0,Y.jsx)(P,{onClick:()=>{o(e),p(!1)},className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:E?`Remove reference`:`Delete Workspace`})]})]})]})]})]})}),(0,Y.jsx)(U,{children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`div`,{className:`h-3 w-3 rounded-full ${(()=>{switch(e.status){case`active`:return`bg-success`;case`inactive`:case`available`:return`bg-muted-foreground`;case`error`:case`offline`:return`bg-destructive`;case`not_found`:return`bg-muted-foreground`;default:return`bg-accent`}})()}`}),(0,Y.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:(()=>{switch(e.status){case`active`:return`Active`;case`inactive`:return`Inactive`;case`error`:return`Error`;case`not_found`:return`Not Found`;case`available`:return`Available`;case`removed`:return`Removed`;case`destroyed`:return`Destroyed`;case`offline`:return`Offline`;default:return e.status}})()}),_&&(0,Y.jsx)(`span`,{className:`ml-2 rounded-full bg-primary/10 px-2 py-1 text-xs text-primary`,children:`Universe`}),E&&(0,Y.jsxs)(`span`,{className:`ml-2 rounded-full bg-info/10 px-2 py-1 text-xs text-info`,title:e.remote?.url?`${e.remote.url} (${(e.remote.permissions||[]).join(`, `)||`no permissions`})`:void 0,children:[`Remote · `,e.host]}),b&&(0,Y.jsxs)(`span`,{className:`ml-2 rounded-full bg-info/10 px-2 py-1 text-xs text-info`,title:[T,`${w} access`].filter(Boolean).join(` · `),children:[`Shared · `,w]})]})})]})})}var X=[{value:`full`,icon:p,title:`Standard`,blurb:`Everything in one folder: your files in home/, alongside db/, data/, git/.`,tree:[`workspace.json`,`home/ ← your files`,`db/ data/ cache/ Git/`]},{value:`home`,icon:a,title:`Roaming home`,blurb:`The workspace folder IS your drive. Mount it over WebDAV and it looks like a plain home directory. Canvas keeps its files in a hidden .workspace/.`,tree:[`your files, at the top level`,`.workspace/ ← hidden, ignored`]}];function xe({value:e,onChange:t,disabled:n=!1,idPrefix:r=`workspace-layout`,compact:i=!1}){return(0,Y.jsx)(`div`,{className:i?`space-y-1.5`:`grid gap-2 sm:grid-cols-2`,children:X.map(i=>{let a=e===i.value,o=i.icon;return(0,Y.jsxs)(`button`,{id:`${r}-${i.value}`,type:`button`,role:`radio`,"aria-checked":a,disabled:n,onClick:()=>t(i.value),className:`flex w-full gap-2 rounded-md border p-2.5 text-left transition-colors disabled:opacity-50 ${a?`border-primary bg-accent/40`:`hover:bg-accent/20`}`,children:[(0,Y.jsx)(o,{className:`mt-0.5 h-4 w-4 shrink-0 ${a?`text-primary`:`text-muted-foreground`}`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`block text-xs font-medium`,children:i.title}),(0,Y.jsx)(`span`,{className:`mt-0.5 block text-[11px] leading-snug text-muted-foreground`,children:i.blurb}),(0,Y.jsx)(`span`,{className:`mt-1 block font-mono text-[10px] leading-relaxed text-muted-foreground/80`,children:i.tree.map(e=>(0,Y.jsx)(`span`,{className:`block truncate`,children:e},e))})]})]},i.value)})})}function Se(){let[e,t]=(0,J.useState)(`full`),[n,r]=(0,J.useState)(!1);return(0,J.useEffect)(()=>{let e=!0;return _.get(`/ping`,{skipAuth:!0}).then(r=>{let i=r?.defaults?.workspaceLayout;e&&!n&&(i===`home`||i===`full`)&&t(i)}).catch(()=>{}),()=>{e=!1}},[]),[e,e=>{r(!0),t(e)}]}function Ce(){let[e,t]=(0,J.useState)([]),[n,a]=(0,J.useState)(!0),[s,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(``),[m,_]=(0,J.useState)(B()),[y,x]=(0,J.useState)(null),[S,D]=(0,J.useState)(``),[k,A]=Se(),[j,M]=(0,J.useState)(null),[N,P]=(0,J.useState)(null),[F,I]=(0,J.useState)(!1),L=se(),[R,V]=fe(),H=he(),[U,ae]=(0,J.useState)(!1),[le,K]=(0,J.useState)(!1),[_e,X]=(0,J.useState)(!1),[Ce,De]=(0,J.useState)(!1),[Z,Q]=(0,J.useState)(null),{showToast:$}=v(),Oe=i(),ke=ee(),{openM2Drawer:Ae}=ne(),je=pe();me(je,`workspace`,{"workspace:status:changed":e=>t(t=>t.map(t=>t.id===e.workspaceId?{...t,status:e.status}:t)),"workspace:created":e=>t(t=>[...t,e.workspace]),"workspace:deleted":e=>t(t=>t.filter(t=>t.id!==e.workspaceId)),"workspaces.scanned":({report:e})=>{!e.discovered.length&&!e.adopted.length&&!e.updated.length&&!e.missing.length||w().then(e=>t(W(e))).catch(()=>{})}}),(0,J.useEffect)(()=>{let e=async()=>{try{a(!0);let e=await w();t(W(e)),l(null)}catch(e){console.error(`Workspace fetch error:`,e);let t=`Failed to fetch workspaces`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;t=n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||`Failed to fetch workspaces`}l(t),$({title:`Error`,description:t,variant:`destructive`})}finally{a(!1)}};e();let n=()=>{e()};return window.addEventListener(`workspaces:refresh`,n),()=>{window.removeEventListener(`workspaces:refresh`,n)}},[je,$]);let Me=async e=>{if(e.preventDefault(),u.trim()){I(!0);try{let e=await O({name:u,description:f||void 0,color:m,icon:y,label:S||u,layout:k});if(t(t=>[...t,e]),window.dispatchEvent(new CustomEvent(`workspaces:refresh`)),H.selected.size>0){try{await E(e.name);let{ok:t,failed:n}=await ge(e.name,Array.from(H.selected),H.tree);n&&$({title:`Folders`,description:`${t} folder(s) created, ${n} failed`,variant:`destructive`})}catch(e){console.error(`Default folder creation failed:`,e),$({title:`Folders`,description:`Workspace created, but default folders failed`,variant:`destructive`})}H.setSelected(new Set)}d(``),p(``),_(B()),x(null),D(``),$({title:`Success`,description:`Workspace '${e.label||e.name}' created.`}),V(!1)}catch(e){console.error(`Workspace creation error:`,e);let t=`Failed to create workspace`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;t=n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||`Failed to create workspace`}$({title:`Error`,description:t,variant:`destructive`})}finally{I(!1)}}},Ne=async e=>{if(e.preventDefault(),Z)try{let e={label:Z.label,description:Z.description,color:Z.color,icon:Z.icon??null};await T(Z.name,e),t(t=>t.map(t=>t.id===Z.id?{...t,...e}:t)),window.dispatchEvent(new CustomEvent(`workspaces:refresh`)),$({title:`Success`,description:`Workspace '${Z.label}' details updated.`}),Q(null)}catch(e){let t=e instanceof Error?e.message:`Failed to update workspace`;$({title:`Error`,description:t,variant:`destructive`})}},Pe=e=>{Q(e)},Fe=async e=>{try{await b(e.name),t(t=>t.filter(t=>t.id!==e.id)),$({title:`Success`,description:`Workspace '${e.label||e.name}' has been destroyed.`})}catch(e){let t=e instanceof Error?e.message:`Failed to destroy workspace`;$({title:`Error`,description:t,variant:`destructive`})}},Ie=async e=>{try{let n=await E(e);t(e=>e.map(e=>e.id===n.id?{...e,...n}:e)),$({title:`Success`,description:`Workspace '${n.label||n.name}' started.`}),window.dispatchEvent(new CustomEvent(`workspaces:refresh`))}catch(e){console.error(`Workspace start error:`,e);let t=`Failed to start workspace`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;t=n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||`Failed to start workspace`}$({title:`Error`,description:t,variant:`destructive`})}},Le=async e=>{try{let n=await C(e);t(e=>e.map(e=>e.id===n.id?{...e,...n}:e)),$({title:`Success`,description:`Workspace '${n.label||n.name}' stopped.`}),window.dispatchEvent(new CustomEvent(`workspaces:refresh`))}catch(e){console.error(`Workspace stop error:`,e);let t=`Failed to stop workspace`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;t=n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||`Failed to stop workspace`}$({title:`Error`,description:t,variant:`destructive`})}},Re=e=>{Oe(re(e))},{rowProps:ze,handleProps:Be,draggingIndex:Ve,insertLineClass:He}=oe((n,r)=>{let i=ue(e,n,r);t(i),ie(i,(e,t)=>T(G(e),{order:t})).then(({failed:e})=>{window.dispatchEvent(new CustomEvent(`workspaces:refresh`)),e&&$({title:`Partial reorder`,description:`${e} workspace(s) could not be reordered`,variant:`destructive`})})});return(0,Y.jsxs)(`div`,{className:`space-y-6`,children:[(0,Y.jsx)(de,{title:`Workspaces`,description:`Divide your Universe into self-contained workspaces`,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(h,{variant:`outline`,onClick:()=>ae(e=>!e),className:`max-sm:hidden`,children:`Open shared Workspace (local)…`}),(0,Y.jsx)(h,{variant:`outline`,onClick:()=>X(e=>!e),children:`Import workspace`}),(0,Y.jsx)(h,{variant:`outline`,onClick:()=>K(e=>!e),className:`max-sm:hidden`,children:`Import remote…`}),(0,Y.jsx)(h,{variant:`outline`,onClick:()=>De(e=>!e),className:`max-sm:hidden`,children:`Open remote…`}),!L.local&&!R&&(0,Y.jsxs)(h,{onClick:()=>V(!0),className:`max-sm:h-9 max-sm:w-9 max-sm:p-0`,"aria-label":`Create workspace`,title:`Create workspace`,children:[(0,Y.jsx)(c,{className:`h-4 w-4 sm:mr-2`}),(0,Y.jsx)(`span`,{className:`max-sm:hidden`,children:`Create Workspace`})]})]})}),!L.local&&R&&(0,Y.jsx)(q,{title:`Create New Workspace`,onClose:()=>V(!1),children:(0,Y.jsxs)(`form`,{onSubmit:Me,className:`space-y-4`,children:[(0,Y.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,Y.jsx)(g,{value:u,onChange:e=>d(e.target.value),placeholder:`Workspace Name (e.g., 'my-project')`,disabled:F}),(0,Y.jsx)(g,{value:S,onChange:e=>D(e.target.value),placeholder:`Workspace Label (display name, optional)`,disabled:F})]}),(0,Y.jsx)(g,{value:f,onChange:e=>p(e.target.value),placeholder:`Description (optional)`,disabled:F}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`label`,{htmlFor:`workspace-color`,className:`text-sm font-medium`,children:`Icon & Color`}),(0,Y.jsx)(`button`,{type:`button`,title:`Pick icon & color`,disabled:F,onClick:e=>M({x:Math.min(e.clientX,window.innerWidth-290),y:Math.min(e.clientY,window.innerHeight-360)}),className:`flex h-10 w-10 items-center justify-center rounded-md border hover:bg-accent`,children:(0,Y.jsx)(r,{icon:y||`ph:stack-fill`,width:22,height:22,color:z(m)})}),(0,Y.jsx)(g,{id:`workspace-color`,type:`color`,value:m,onChange:e=>_(e.target.value),className:`h-10 w-16 p-1`,disabled:F}),(0,Y.jsx)(h,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>_(B()),disabled:F,children:`Randomize`})]}),j&&(0,Y.jsx)(ce,{x:j.x,y:j.y,current:{icon:y??void 0,color:m},onChange:e=>{`icon`in e&&x(e.icon??null),`color`in e&&e.color&&_(e.color)},onClose:()=>M(null)}),(0,Y.jsxs)(`div`,{className:`rounded-lg border p-3`,children:[(0,Y.jsx)(`p`,{className:`text-sm font-medium`,children:`Folder structure`}),(0,Y.jsx)(`p`,{className:`mb-3 mt-0.5 text-xs text-muted-foreground`,children:`How the workspace directory is laid out on disk. Fixed once created.`}),(0,Y.jsx)(xe,{value:k,onChange:A,disabled:F,idPrefix:`create-workspace-layout`})]}),(0,Y.jsxs)(`div`,{className:`rounded-lg border p-3`,children:[(0,Y.jsxs)(`p`,{className:`text-sm font-medium`,children:[`Default folders `,(0,Y.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:`(optional)`})]}),(0,Y.jsx)(`p`,{className:`mb-3 mt-0.5 text-xs text-muted-foreground`,children:`Ticked folders are created right after the workspace, with matching icons and colors.`}),(0,Y.jsx)(ve,{selected:H.selected,onToggle:H.toggle,tree:H.tree,onTreeChange:H.setTree,disabled:F,idPrefix:`create-default-folders`})]}),(0,Y.jsxs)(h,{type:`submit`,disabled:F||!u.trim(),children:[(0,Y.jsx)(c,{className:`mr-2 h-4 w-4`}),`Create Workspace`]})]})}),U&&(0,Y.jsx)(Te,{}),Ce&&(0,Y.jsx)(Ee,{onClose:()=>De(!1),onChanged:async()=>{try{t(W(await w()))}catch{}window.dispatchEvent(new CustomEvent(`workspaces:refresh`))}}),_e&&(0,Y.jsx)(q,{title:`Import workspace`,onClose:()=>X(!1),children:(0,Y.jsx)(ye,{onImported:()=>X(!1)})}),le&&(0,Y.jsx)(we,{onImported:e=>{t(t=>t.some(t=>t.id===e.id)?t:[...t,e]),window.dispatchEvent(new CustomEvent(`workspaces:refresh`)),K(!1)},onClose:()=>K(!1)}),(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(`h2`,{className:`text-xl font-semibold`,children:`Your Workspaces`}),n&&(0,Y.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`Loading workspaces...`}),s&&(0,Y.jsx)(`div`,{className:`text-center text-destructive`,children:(0,Y.jsx)(`p`,{children:s})}),!n&&!s&&e.length===0&&(0,Y.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`No workspaces found`}),e.length>0&&(0,Y.jsx)(`div`,{className:`grid gap-4`,children:e.map((t,n)=>{let r={...t,createdAt:t.createdAt,updatedAt:t.updatedAt,color:t.color===null?void 0:t.color},i=z(t.color);return(0,Y.jsxs)(`div`,{...ze(n),className:`flex items-stretch rounded-lg ${He(n,e.length)||``} ${Ve===n?`opacity-60`:``}`,children:[(0,Y.jsx)(`button`,{type:`button`,...Be(n),title:`Drag to reorder`,"aria-label":`Drag to reorder`,className:`hidden w-5 shrink-0 cursor-grab items-center justify-center rounded-l-lg active:cursor-grabbing md:flex ${i?``:`bg-muted`}`,style:i?{backgroundColor:i}:void 0,children:(0,Y.jsx)(o,{className:`h-4 w-4 ${te(i)}`})}),(0,Y.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Y.jsx)(be,{workspace:r,onStart:Ie,onStop:Le,onEnter:Re,onEdit:Pe,onSettings:e=>{ke?Ae(`workspaces`,`settings`,G(e)):Oe(`/workspaces/${G(e)}/settings/general`)},onDestroy:Fe})})]},t.id)})})]}),Z&&(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsxs)(`h2`,{className:`text-xl font-semibold`,children:[`Edit Workspace: `,Z.label]}),(0,Y.jsxs)(`form`,{onSubmit:Ne,className:`space-y-4`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{htmlFor:`edit-label`,className:`text-sm font-medium`,children:`Label`}),(0,Y.jsx)(g,{id:`edit-label`,value:Z.label,onChange:e=>Q(t=>t?{...t,label:e.target.value}:null),placeholder:`Workspace Label`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{htmlFor:`edit-description`,className:`text-sm font-medium`,children:`Description`}),(0,Y.jsx)(g,{id:`edit-description`,value:Z.description||``,onChange:e=>Q(t=>t?{...t,description:e.target.value}:null),placeholder:`Description (optional)`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{htmlFor:`edit-color`,className:`text-sm font-medium`,children:`Icon & Color`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`button`,{type:`button`,title:`Pick icon & color`,onClick:e=>P({x:Math.min(e.clientX,window.innerWidth-290),y:Math.min(e.clientY,window.innerHeight-360)}),className:`flex h-10 w-10 items-center justify-center rounded-md border hover:bg-accent`,children:(0,Y.jsx)(r,{icon:Z.icon||`ph:stack-fill`,width:22,height:22,color:z(Z.color)})}),(0,Y.jsx)(g,{id:`edit-workspace-color`,type:`color`,value:Z.color||`#FFFFFF`,onChange:e=>Q(t=>t?{...t,color:e.target.value}:null),className:`h-10 w-16 p-1`}),(0,Y.jsx)(h,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>Q(e=>e?{...e,color:B()}:null),children:`Randomize Color`})]})]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(h,{type:`submit`,disabled:!Z.label?.trim(),children:`Save Changes`}),(0,Y.jsx)(h,{type:`button`,variant:`outline`,onClick:()=>Q(null),children:`Cancel`})]})]}),N&&(0,Y.jsx)(ce,{x:N.x,y:N.y,current:{icon:Z.icon??void 0,color:Z.color??void 0},onChange:e=>{Q(t=>{if(!t)return null;let n={...t};return`icon`in e&&(n.icon=e.icon??null),`color`in e&&e.color&&(n.color=e.color),n})},onClose:()=>P(null)})]})]})}function we({onImported:e,onClose:t}){let{showToast:n}=v(),[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(``),[d,f]=(0,J.useState)(!1),[p,m]=(0,J.useState)(``);return(0,Y.jsx)(q,{title:`Import (pull) a remote Workspace`,onClose:t,children:(0,Y.jsxs)(`form`,{onSubmit:async t=>{t.preventDefault();let i;try{i=new URL(r.trim()).origin}catch{n({title:`Error`,description:`Invalid server URL`,variant:`destructive`});return}if(!a.trim().startsWith(`canvas-`)){n({title:`Error`,description:`Invalid access token (expected canvas-...)`,variant:`destructive`});return}f(!0),m(`Starting…`);try{let t=await x(i,a.trim(),e=>{m(D[e.phase]||e.phase)},{name:s.trim(),label:l.trim()});n({title:`Success`,description:`Workspace '${t.label||t.name}' imported from ${i}.`}),e(t)}catch(e){let t=e,r=t?.message||t?.payload?.message||`Failed to import remote workspace`;n({title:`Error`,description:r,variant:`destructive`})}finally{f(!1),m(``)}},className:`space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-3`,children:[(0,Y.jsx)(g,{placeholder:`Server URL (e.g., https://my.canvas-server.tld)`,value:r,onChange:e=>i(e.target.value),disabled:d}),(0,Y.jsx)(g,{placeholder:`Workspace share token (canvas-...)`,value:a,onChange:e=>o(e.target.value),disabled:d}),(0,Y.jsx)(h,{type:`submit`,disabled:d||!r.trim()||!a.trim()||!s.trim()||!l.trim(),children:d?`Importing…`:`Import Workspace`})]}),(0,Y.jsx)(_e,{name:s,label:l,setName:c,setLabel:u,disabled:d}),d&&p&&(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:p}),(0,Y.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Pulls a full `,(0,Y.jsx)(`strong`,{children:`copy`}),` of the workspace from the remote canvas-server into this one, where it then lives independently. The remote workspace is stopped while it is packed, and large workspaces can take several minutes — progress is shown above.`]})]})})}function Te(){let{showToast:e}=v(),[t,n]=(0,J.useState)(``),[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(!1),s=e=>{try{return new URL(e)}catch{return null}};return(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsx)(`h2`,{className:`text-xl font-semibold`,children:`Open shared Workspace (local)`}),(0,Y.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-3`,children:[(0,Y.jsx)(g,{placeholder:`Shared URL (e.g., https://host/rest/v2/pub/workspaces/ID)`,value:t,onChange:e=>n(e.target.value)}),(0,Y.jsx)(g,{placeholder:`Access token (canvas-...)`,value:r,onChange:e=>i(e.target.value)}),(0,Y.jsx)(h,{onClick:async()=>{if(!s(t.trim())){e({title:`Error`,description:`Invalid URL`,variant:`destructive`});return}if(!r.trim().startsWith(`canvas-`)){e({title:`Error`,description:`Invalid access token`,variant:`destructive`});return}o(!0);try{sessionStorage.setItem(`sharedToken:last`,r.trim());let e=new URLSearchParams({url:t.trim()}).toString();window.location.href=`/shared?${e}`}catch(t){e({title:`Error`,description:t instanceof Error?t.message:`Failed to open shared resource`,variant:`destructive`})}finally{o(!1)}},disabled:a||!t.trim()||!r.trim(),children:`Open`})]}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`We use your provided URL and token to fetch via the remote's public API.`})]})}function Ee({onClose:e,onChanged:t}){let{showToast:n}=v(),r=i(),[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)([]),p=(0,J.useCallback)(async()=>{try{f(await k())}catch{f([])}},[]);(0,J.useEffect)(()=>{p()},[p]);let m=async e=>{e.preventDefault();let r;try{r=new URL(a.trim()).origin}catch{n({title:`Error`,description:`Invalid server URL`,variant:`destructive`});return}u(!0);try{let e=await S(r,s.trim());n({title:`Remote workspace added`,description:`'${e.label}' is available as ${e.address}.`}),o(``),c(``),await p(),t?.()}catch(e){let t=e;n({title:`Error`,description:t?.message||t?.payload?.message||`Failed to add remote workspace`,variant:`destructive`})}finally{u(!1)}},_=async e=>{try{await y(e.id),await p(),t?.()}catch(e){n({title:`Error`,description:e instanceof Error?e.message:`Failed to remove remote workspace`,variant:`destructive`})}};return(0,Y.jsxs)(q,{title:`Open a remote Workspace`,onClose:e,children:[(0,Y.jsxs)(`form`,{onSubmit:m,className:`space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-3`,children:[(0,Y.jsx)(g,{placeholder:`Server URL (e.g., https://my.canvas-server.tld)`,value:a,onChange:e=>o(e.target.value),disabled:l}),(0,Y.jsx)(g,{placeholder:`Workspace share token (canvas-...)`,value:s,onChange:e=>c(e.target.value),disabled:l}),(0,Y.jsx)(h,{type:`submit`,disabled:l||!a.trim()||!s.trim(),children:l?`Checking…`:`Add Remote`})]}),(0,Y.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Keeps the workspace on its own server and registers it here as`,` `,(0,Y.jsx)(`code`,{className:`font-mono text-xs`,children:`name@host`}),` — nothing is copied. Every call you make to it is forwarded to the remote with the share token (its permissions apply); document content and thumbnails are cached locally so they stay readable when the remote is offline. Use “Import remote…” if you want an independent local copy instead.`]})]}),d.length>0&&(0,Y.jsx)(`ul`,{className:`mt-4 space-y-2 border-t pt-3`,children:d.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-col gap-2 rounded-md border p-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`truncate text-sm font-medium`,children:[e.label,(0,Y.jsx)(`span`,{className:`ml-2 rounded bg-muted px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:`remote`})]}),(0,Y.jsxs)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-muted-foreground`,children:[e.address,` · `,e.remote.url]})]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Y.jsx)(h,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r(`/workspaces/${e.address}`),children:`Open`}),(0,Y.jsx)(h,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>_(e),className:`text-destructive hover:text-destructive`,children:`Remove`})]})]},e.id))})]})}export{Ce as default};
|
package/dist/index.html
CHANGED
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
}
|
|
47
47
|
})()
|
|
48
48
|
</script>
|
|
49
|
-
<script type="module" crossorigin src="/assets/index-
|
|
49
|
+
<script type="module" crossorigin src="/assets/index-NOhHv2VY.js"></script>
|
|
50
50
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-C0FnF6B9.js">
|
|
51
51
|
<link rel="modulepreload" crossorigin href="/assets/code-editor-BOIngd5F.js">
|
|
52
52
|
<link rel="modulepreload" crossorigin href="/assets/react-BHzhHVTZ.js">
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
<link rel="modulepreload" crossorigin href="/assets/url-params-n7kU_WZ-.js">
|
|
113
113
|
<link rel="modulepreload" crossorigin href="/assets/use-canvas-pins-q5Tncavk.js">
|
|
114
114
|
<link rel="modulepreload" crossorigin href="/assets/use-menu-CKSpS96u.js">
|
|
115
|
-
<link rel="modulepreload" crossorigin href="/assets/registry-
|
|
115
|
+
<link rel="modulepreload" crossorigin href="/assets/registry-D7HyG001.js">
|
|
116
116
|
<link rel="modulepreload" crossorigin href="/assets/use-applet-target-BlpVWlnA.js">
|
|
117
117
|
<link rel="modulepreload" crossorigin href="/assets/last-path-BbXWC3b3.js">
|
|
118
118
|
<link rel="modulepreload" crossorigin href="/assets/document-paste-BuTC6S7_.js">
|