@augmentd-labs/canvas-web 2.26.44 → 2.26.45

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.
Files changed (119) hide show
  1. package/dist/assets/CalendarApplet-CsyUmI2B.js +2 -0
  2. package/dist/assets/{DocumentBodyEditor-CVO5KPCs.js → DocumentBodyEditor-C8AEpqX3.js} +1 -1
  3. package/dist/assets/{DocumentIcon-9i1uCMQa.js → DocumentIcon-0ya9gycp.js} +1 -1
  4. package/dist/assets/{EditorOverlay-D5t3xg4w.js → EditorOverlay-DglJkHo3.js} +1 -1
  5. package/dist/assets/{FiltersApplet-BT3fR4Fu.js → FiltersApplet-CVnCAs-P.js} +1 -1
  6. package/dist/assets/HomeFab-iC5BF7LV.js +3 -0
  7. package/dist/assets/{IdentityFields-D-NCTUaE.js → IdentityFields-CB3Ap0bl.js} +1 -1
  8. package/dist/assets/{LensApplet-CVUc1-vK.js → LensApplet-DA0ZWS1k.js} +1 -1
  9. package/dist/assets/LinkToCard-oi3wGP0a.js +1 -0
  10. package/dist/assets/{MarkdownEditor-DbpRWbO6.js → MarkdownEditor-bDoyR7l2.js} +2 -2
  11. package/dist/assets/{MessageComposerDialog-CdPp-3GR.js → MessageComposerDialog-CLrwtB76.js} +1 -1
  12. package/dist/assets/{NextShell-ull6WmMg.js → NextShell-DCWxD5TR.js} +1 -1
  13. package/dist/assets/{NotesApplet-Bbd61mrH.js → NotesApplet-BSJ-9RKl.js} +1 -1
  14. package/dist/assets/ObjectPropertiesCard-DesXRw-_.js +8 -0
  15. package/dist/assets/{PathPickerField-CW2yG2Yg.js → PathPickerField-CSIa7jSl.js} +1 -1
  16. package/dist/assets/PickDocumentsCard-DVdBxx3s.js +1 -0
  17. package/dist/assets/{SketchApplet-BKnhzTBA.js → SketchApplet--3uyqpmo.js} +1 -1
  18. package/dist/assets/{SketchEditor-DmGMcbU0.js → SketchEditor-CSA7dTyq.js} +2 -2
  19. package/dist/assets/{TerminalApplet-D7YxftqM.js → TerminalApplet-BZJx2ztD.js} +1 -1
  20. package/dist/assets/{TextDocumentEditor-BQnVD0dd.js → TextDocumentEditor-VYIF2XCX.js} +1 -1
  21. package/dist/assets/{TodosApplet-DU5VWc5i.js → TodosApplet-DY7JzeZS.js} +1 -1
  22. package/dist/assets/{TodosWidget-CNnfNk4L.js → TodosWidget-DGftEAbs.js} +1 -1
  23. package/dist/assets/{_agentId_-CrBQ54X2.js → _agentId_-BrzFDu8r.js} +0 -0
  24. package/dist/assets/{_contextId_-CEcdj7Ec.js → _contextId_-DS6b9Uml.js} +1 -1
  25. package/dist/assets/_workspaceName_-XRqfa4c6.js +1 -0
  26. package/dist/assets/{about-CdAN00wx.js → about-hcdKJNm5.js} +1 -1
  27. package/dist/assets/{add-COjQRnFC.js → add-CEBusWuu.js} +1 -1
  28. package/dist/assets/{agents-DxqAi3vk.js → agents-BfSFdg41.js} +1 -1
  29. package/dist/assets/{agents-D_t6cQMW.js → agents-wFp7Vh3p.js} +1 -1
  30. package/dist/assets/{alert-dialog-CFeuDt0T.js → alert-dialog-BKtaX1_a.js} +1 -1
  31. package/dist/assets/{api-tokens-drrVuCYc.js → api-tokens-Biqt5TnG.js} +1 -1
  32. package/dist/assets/{appearance-BnUcoqpz.js → appearance-D5BUjZm8.js} +1 -1
  33. package/dist/assets/{applet-target-pLdP-R76.js → applet-target-LvhUEvE5.js} +1 -1
  34. package/dist/assets/{apps-CCC-xyI2.js → apps-65YXCnzH.js} +1 -1
  35. package/dist/assets/{auth-PqttD05H.js → auth-BwxT5xRB.js} +1 -1
  36. package/dist/assets/{button-SeUZ_Pvi.js → button--VYZekMF.js} +1 -1
  37. package/dist/assets/{context-t3rdtGUB.js → context-DY40EDc6.js} +1 -1
  38. package/dist/assets/{contexts-DDJagU4j.js → contexts-BPO_Wb9W.js} +1 -1
  39. package/dist/assets/{contexts-Bq8LHUTK2.js → contexts-DBJ0_-AO2.js} +1 -1
  40. package/dist/assets/{date-time-picker-DCikruos.js → date-time-picker-p3vy4nst.js} +1 -1
  41. package/dist/assets/{devices-BwU9M8-W.js → devices-DZbbaWYU.js} +1 -1
  42. package/dist/assets/{document-Cr7GhnVd.js → document-Dv8NCUoM.js} +1 -1
  43. package/dist/assets/document-list-Bbbx-pTZ.js +3 -0
  44. package/dist/assets/document-paste-BuTC6S7_.js +1 -0
  45. package/dist/assets/{embedding-D-I_ygUZ.js → embedding-B9vSy_a9.js} +1 -1
  46. package/dist/assets/{embedding-BvXcVfij.js → embedding-M2hUmnk0.js} +1 -1
  47. package/dist/assets/{form-panel-3p-ncEVK.js → form-panel-CEbNKttr.js} +1 -1
  48. package/dist/assets/{home-DrRSXywO.js → home-vr8b8oR-.js} +1 -1
  49. package/dist/assets/index-CTvqbEB8.js +16 -0
  50. package/dist/assets/index-CoVFQpP3.css +2 -0
  51. package/dist/assets/{inferd-config-editor-B8x_XPOt.js → inferd-config-editor-Dpdj90iN.js} +1 -1
  52. package/dist/assets/{key-bindings-6SHAlZR8.js → key-bindings-DmqvYSaF.js} +1 -1
  53. package/dist/assets/{label-BSTdjCWU.js → label-RuOXXC8t.js} +1 -1
  54. package/dist/assets/{lazy-editor-BUFAkTGl.js → lazy-editor-CShGeIep.js} +2 -2
  55. package/dist/assets/{logs-DjG8_wJ2.js → logs-7eSz9yjc.js} +1 -1
  56. package/dist/assets/{offline-ByoT6JJX.js → offline-C-Yvb6LA.js} +1 -1
  57. package/dist/assets/{page-header-DrDt1sQ2.js → page-header-NyYSXjfY.js} +1 -1
  58. package/dist/assets/{public-share-CXR25Q1X.js → public-share-0DqS7L2Q.js} +1 -1
  59. package/dist/assets/{query-debug-lD5vbJGi.js → query-debug-PEWbZsOP.js} +1 -1
  60. package/dist/assets/registry-g1SKt_fD.js +2 -0
  61. package/dist/assets/{remotes-RPGcw6fH.js → remotes-DqCLds8Q.js} +1 -1
  62. package/dist/assets/{roles-sb8vgjV_.js → roles-BwVDE1aQ.js} +1 -1
  63. package/dist/assets/{roles-p2cRajz-.js → roles-W7oJ5WMg.js} +1 -1
  64. package/dist/assets/rule-builder-CziPqpNe.js +6 -0
  65. package/dist/assets/settings-BIoSwdXv.js +16 -0
  66. package/dist/assets/{settings-CGncOyKY.js → settings-BWCMmkjr.js} +1 -1
  67. package/dist/assets/{settings-r7slYioS.js → settings-CbMkpipO.js} +1 -1
  68. package/dist/assets/settings-XMhqrvTu.js +1 -0
  69. package/dist/assets/{share-target-CoDDhZI5.js → share-target-hDXdgW6o.js} +1 -1
  70. package/dist/assets/{shared-BLOuO2Is.js → shared-CLjTxih0.js} +1 -1
  71. package/dist/assets/{shared-bYen6pjw.js → shared-DVlDThVA.js} +1 -1
  72. package/dist/assets/sketch-lazy-CtjOUfVz.js +2 -0
  73. package/dist/assets/{subtree-transfer-dialog-DQM5zfx2.js → subtree-transfer-dialog-DtE6JSUr.js} +1 -1
  74. package/dist/assets/{text-documents-Cdb3U63i.js → text-documents-wu6fzOuw.js} +2 -2
  75. package/dist/assets/tree-folders-IDoobsGN.js +1 -0
  76. package/dist/assets/ui-DEgHnkQu.js +41 -0
  77. package/dist/assets/{use-applet-docs-rimRHjID.js → use-applet-docs-C08GAUm3.js} +1 -1
  78. package/dist/assets/{use-applet-target-BygCSj5n.js → use-applet-target-BlpVWlnA.js} +1 -1
  79. package/dist/assets/{use-canvas-pins-BPCW4twY.js → use-canvas-pins-q5Tncavk.js} +2 -2
  80. package/dist/assets/{use-menu-DIP1zh7I.js → use-menu-CKSpS96u.js} +1 -1
  81. package/dist/assets/use-settings-back-D_MM9diy.js +1 -0
  82. package/dist/assets/{use-sortable-data-BBKmqs79.js → use-sortable-data-D7zS2qCC.js} +1 -1
  83. package/dist/assets/{use-workspace-identity-CSkRwVyo.js → use-workspace-identity-XSv3dATQ.js} +1 -1
  84. package/dist/assets/{useAddTarget-DeRZWtGg.js → useAddTarget-BvuFR5pN.js} +1 -1
  85. package/dist/assets/{useAgentModels-BufYelEA.js → useAgentModels-CI9XT6yc.js} +1 -1
  86. package/dist/assets/{useDocumentThumbnail-Cj4UYyhC.js → useDocumentThumbnail-CZIaXkIi.js} +1 -1
  87. package/dist/assets/{useEditNoteFields-BT1ASu_q.js → useEditNoteFields-DsVKIHWm.js} +1 -1
  88. package/dist/assets/{users-DuVk-TEd.js → users-DzlbKZp6.js} +1 -1
  89. package/dist/assets/workspace-4hWrSEku.js +1 -0
  90. package/dist/assets/{workspace-content-gate-C54J9Man.js → workspace-content-gate-BlFdbi67.js} +1 -1
  91. package/dist/assets/{workspace-import-form-DTvV9jYt.js → workspace-import-form-CWs9ZTts.js} +1 -1
  92. package/dist/assets/{workspaces-CqHYstZv.js → workspaces-67v2hWrl.js} +1 -1
  93. package/dist/assets/workspaces-ByYQ6L3I.js +1 -0
  94. package/dist/index.html +36 -38
  95. package/dist/sw.js +1 -1
  96. package/package.json +2 -2
  97. package/dist/assets/CalendarApplet-BNT0vegP.js +0 -2
  98. package/dist/assets/FileForm-CDiVKvxq.js +0 -1
  99. package/dist/assets/HomeFab-B17r3232.js +0 -3
  100. package/dist/assets/LinkToCard-CKVi4Nrg.js +0 -1
  101. package/dist/assets/ObjectPropertiesCard-D2lrTQqT.js +0 -8
  102. package/dist/assets/PickDocumentsCard-BWgc-A02.js +0 -1
  103. package/dist/assets/UploadProgressList-D2wEpa7t.js +0 -1
  104. package/dist/assets/_workspaceName_-BhZWt9RG.js +0 -1
  105. package/dist/assets/backend-sync-progress-B3lZB9Ha.js +0 -6
  106. package/dist/assets/document-list-rzRLzfkF.js +0 -3
  107. package/dist/assets/index-DOXi2QgX.css +0 -2
  108. package/dist/assets/index-G_67YwLB.js +0 -16
  109. package/dist/assets/registry-FfNYUpRF.js +0 -2
  110. package/dist/assets/settings-CCr9Jr0Q.js +0 -1
  111. package/dist/assets/settings-Cv6jdSA0.js +0 -16
  112. package/dist/assets/sketch-lazy-BY_ka1hw.js +0 -2
  113. package/dist/assets/tree-folders-Q5iu5vpu.js +0 -1
  114. package/dist/assets/ui-CDoK3F3U.js +0 -41
  115. package/dist/assets/use-settings-back-DGmLAD63.js +0 -1
  116. package/dist/assets/workspace-C5V-ZCOE.js +0 -1
  117. package/dist/assets/workspace-area-menu-BN5ysUpx.js +0 -1
  118. package/dist/assets/workspaces-Dj9dNIWZ.js +0 -1
  119. /package/dist/assets/{backend-sync-progress-DU-e9TWi.css → rule-builder-DU-e9TWi.css} +0 -0
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{_ as ee,g as r,v as i}from"./chunk-62JRHF6Z-vspAGgtK.js";import{G as te,X as a,kt as o}from"./ui-CDoK3F3U.js";import{t as s}from"./utils-2pl1SbIp.js";import{t as c}from"./button-SeUZ_Pvi.js";import{t as l}from"./input-BOtCd4HP.js";import{n as ne}from"./use-toast-BlLDqSUO.js";import{t as re}from"./use-mobile-Db-vWu9Y.js";import{E as ie,a as ae,c as oe,f as u,r as d,v as se,w as ce,x as le}from"./context-t3rdtGUB.js";import{t as f}from"./PathPickerField-CW2yG2Yg.js";import{i as ue}from"./use-menu-DIP1zh7I.js";import{gt as p,yt as de}from"./index-G_67YwLB.js";import{n as fe}from"./page-header-DrDt1sQ2.js";var m=e(n(),1),h=t(),g=[{value:`documentRead`,label:`Read`},{value:`documentWrite`,label:`Write`},{value:`documentReadWrite`,label:`Read & write`}];function _(){let{contextId:e,tab:t}=ee(),[n]=i(),_=n.get(`ownerId`)||void 0,v=r(),{showToast:y}=ne(),{selectEntity:b,goBack:x,closeM2:S}=ue(),C=re(),w=de(t),T=_?`?ownerId=${encodeURIComponent(_)}`:``;(0,m.useEffect)(()=>{t!==w&&e&&v(`/contexts/${e}/settings/${w}${T}`,{replace:!0})},[t,w,e,T,v]);let[E,D]=(0,m.useState)(null),[pe,me]=(0,m.useState)(!0),[O,k]=(0,m.useState)(!1),[A,j]=(0,m.useState)(!1),[M,N]=(0,m.useState)(``),[P,F]=(0,m.useState)(``),[I,L]=(0,m.useState)(null),[R,z]=(0,m.useState)(``),[B,V]=(0,m.useState)(``),[H,he]=(0,m.useState)(),[U,W]=(0,m.useState)([]),[G,K]=(0,m.useState)(!1),[q,J]=(0,m.useState)(``),[Y,ge]=(0,m.useState)(g[0].value),[X,Z]=(0,m.useState)(null);(0,m.useEffect)(()=>{if(!e)return;let t=!1;return ae(e,_).then(e=>{t||(D(e),b(e.id),N(e.name||``),F(e.description||``),L(typeof e.metadata?.ui?.color==`string`?e.metadata.ui.color:null),z(e.url||``),V(e.baseUrl||``))}).catch(()=>{t||y({title:`Error`,description:`Failed to load context`,variant:`destructive`})}).finally(()=>{t||me(!1)}),()=>{t=!0}},[e,_,b,y]);let Q=(t=e)=>{t&&(K(!0),u(t).then(W).catch(()=>W([])).finally(()=>K(!1)))};(0,m.useEffect)(()=>{if(w!==`shares`||!e)return;let t=!1;return u(e).then(e=>{t||W(e)}).catch(()=>{t||W([])}),()=>{t=!0}},[w,e]);let _e=async t=>{if(t.preventDefault(),e){k(!0);try{let t=await se(e,{name:M.trim(),description:P.trim(),metadata:{...E?.metadata,ui:{...E?.metadata?.ui,color:I}}},_);D(t),window.dispatchEvent(new CustomEvent(`contexts:refresh`)),y({title:`Saved`,description:`Context updated`})}catch(e){y({title:`Error`,description:e instanceof Error?e.message:`Save failed`,variant:`destructive`})}finally{k(!1)}}},ve=async t=>{if(t.preventDefault(),e){k(!0);try{await Promise.all([ie(e,R.trim(),_,H),ce(e,{baseUrl:B.trim()||null},_)]),window.dispatchEvent(new CustomEvent(`contexts:refresh`)),y({title:`Saved`,description:`Context URL updated`})}catch(e){y({title:`Error`,description:e instanceof Error?e.message:`Save failed`,variant:`destructive`})}finally{k(!1)}}},ye=async()=>{if(e&&window.confirm(`Delete context "${e}"? This cannot be undone.`)){j(!0);try{await d(e,_),S(),b(null),y({title:`Deleted`,description:`Context "${e}" removed`}),v(`/contexts`,{replace:!0})}catch(e){y({title:`Error`,description:e instanceof Error?e.message:`Delete failed`,variant:`destructive`})}finally{j(!1)}}},be=async t=>{if(t.preventDefault(),!(!e||!q.trim())){Z(`grant`);try{await oe(e,q.trim(),Y),J(``),Q(),y({title:`Shared`,description:`Access granted to ${q.trim()}`})}catch(e){y({title:`Error`,description:e instanceof Error?e.message:`Failed to grant access`,variant:`destructive`})}finally{Z(null)}}},xe=async t=>{if(e&&window.confirm(`Revoke ${t.userEmail}'s access to "${e}"?`)){Z(t.userEmail);try{await le(e,t.userEmail),Q(),y({title:`Revoked`,description:`${t.userEmail} no longer has access`})}catch(e){y({title:`Error`,description:e instanceof Error?e.message:`Failed to revoke access`,variant:`destructive`})}finally{Z(null)}}};if(pe)return(0,h.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:`Loading...`});if(!E)return(0,h.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:`Context not found`});let $=p.find(e=>e.id===w),Se=`/contexts/${e}${T}`;return(0,h.jsx)(`div`,{className:`h-full min-h-0 overflow-y-auto`,children:(0,h.jsxs)(`div`,{className:`mx-auto max-w-3xl p-6 pb-12 max-md:px-4 max-md:pb-rail-stack`,children:[(0,h.jsx)(fe,{compact:!0,className:`mb-6 border-b pb-4`,title:`${$.label} - ${E.name||E.id}`,description:$.description,backTo:Se,onBack:C?x:void 0}),w===`general`&&(0,h.jsxs)(`div`,{className:`space-y-6`,children:[(0,h.jsxs)(`form`,{onSubmit:_e,className:`space-y-4 rounded-lg border p-4`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{className:`text-sm font-medium`,children:`Context ID`}),(0,h.jsx)(`div`,{className:`mt-1 flex h-10 items-center rounded-md bg-muted px-3 font-mono text-sm text-muted-foreground`,children:E.id})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`ctx-name`,className:`text-sm font-medium`,children:`Name`}),(0,h.jsx)(l,{id:`ctx-name`,value:M,onChange:e=>N(e.target.value),placeholder:`My Context`})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`ctx-description`,className:`text-sm font-medium`,children:`Description`}),(0,h.jsx)(l,{id:`ctx-description`,value:P,onChange:e=>F(e.target.value),placeholder:`Optional description`})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`ctx-color`,className:`text-sm font-medium`,children:`Color`}),(0,h.jsxs)(`div`,{className:`mt-1 flex items-center gap-2`,children:[(0,h.jsx)(l,{id:`ctx-color`,type:`color`,value:/^#[0-9a-f]{6}$/i.test(I||E.color||``)?I||E.color:`#808080`,onChange:e=>L(e.target.value),className:`h-10 w-16 p-1`,disabled:O}),(0,h.jsx)(c,{type:`button`,variant:`outline`,size:`sm`,disabled:O||I===null,onClick:()=>L(null),children:`Use inherited color`})]}),(0,h.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:I===null?`Using the tree folder or workspace color.`:`Applies only to this context.`})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{className:`text-sm font-medium`,children:`Workspace`}),(0,h.jsx)(`div`,{className:`mt-1 flex h-10 items-center rounded-md bg-muted px-3 text-sm text-muted-foreground`,children:E.workspaceName||E.workspaceId||E.workspace})]}),(0,h.jsx)(c,{type:`submit`,disabled:O,children:O?`Saving...`:`Save Changes`})]}),(0,h.jsxs)(`section`,{className:`rounded-lg border border-destructive/30 p-4`,children:[(0,h.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-destructive`,children:`Danger Zone`}),(0,h.jsxs)(c,{variant:`destructive`,disabled:A,onClick:ye,children:[(0,h.jsx)(a,{className:`mr-2 h-4 w-4`}),A?`Deleting...`:`Delete Context`]})]})]}),w===`location`&&(0,h.jsxs)(`form`,{onSubmit:ve,className:`space-y-4 rounded-lg border p-4`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`ctx-url`,className:`text-sm font-medium`,children:`URL`}),(0,h.jsx)(f,{id:`ctx-url`,value:R,onChange:z,fixedWorkspaceName:E.workspaceName,pickerTitle:`Switch context to…`,placeholder:`workspace://path`,onPickTarget:(e,t)=>{z(`${t.workspaceName}://${e.replace(/^\/+/,``)}`),he(t.treeName)}}),H&&(0,h.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Destination tree: `,H]})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`label`,{htmlFor:`ctx-base-url`,className:`text-sm font-medium`,children:[`Base URL `,(0,h.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:`(optional)`})]}),(0,h.jsx)(f,{id:`ctx-base-url`,value:B,onChange:V,fixedWorkspaceName:E.workspaceName,placeholder:`workspace://base/path`,pickerTitle:`Pick a base path…`})]}),(0,h.jsx)(c,{type:`submit`,disabled:O,children:O?`Saving...`:`Save Changes`})]}),w===`shares`&&(0,h.jsxs)(`div`,{className:`space-y-4`,children:[(0,h.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h2`,{className:`text-sm font-semibold`,children:`People with access`}),(0,h.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Only the context owner can see and change this list.`})]}),(0,h.jsxs)(c,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>Q(),disabled:G,children:[(0,h.jsx)(o,{className:s(`mr-2 h-3.5 w-3.5`,G&&`animate-spin`)}),`Refresh`]})]}),U.length===0?(0,h.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`Not shared with anyone.`}):U.map(e=>(0,h.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border p-3`,children:[(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.userEmail}),(0,h.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[g.find(t=>t.value===e.accessLevel)?.label||e.accessLevel||`unknown access`,e.sharedAt&&` - since ${new Date(e.sharedAt).toLocaleDateString()}`]})]}),(0,h.jsx)(c,{type:`button`,variant:`outline`,size:`sm`,className:`text-destructive hover:text-destructive`,disabled:X===e.userEmail,onClick:()=>xe(e),children:(0,h.jsx)(te,{className:`h-3.5 w-3.5`})})]},e.userEmail))]}),(0,h.jsxs)(`form`,{onSubmit:be,className:`space-y-4 rounded-lg border p-4`,children:[(0,h.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Grant access`}),(0,h.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`share-email`,className:`text-sm font-medium`,children:`User email`}),(0,h.jsx)(l,{id:`share-email`,type:`email`,value:q,onChange:e=>J(e.target.value),placeholder:`person@example.com`}),(0,h.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`The user must already have an account on this server.`})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`share-level`,className:`text-sm font-medium`,children:`Access level`}),(0,h.jsx)(`select`,{id:`share-level`,value:Y,onChange:e=>ge(e.target.value),className:`mt-1 w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring`,children:g.map(e=>(0,h.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]}),(0,h.jsx)(c,{type:`submit`,disabled:X===`grant`||!q.trim(),children:X===`grant`?`Sharing...`:`Share context`})]})]})]})})}export{_ 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{_ as ee,g as r,v as i}from"./chunk-62JRHF6Z-vspAGgtK.js";import{G as te,X as a,kt as o}from"./ui-DEgHnkQu.js";import{t as s}from"./utils-2pl1SbIp.js";import{t as c}from"./button--VYZekMF.js";import{t as l}from"./input-BOtCd4HP.js";import{n as ne}from"./use-toast-BlLDqSUO.js";import{t as re}from"./use-mobile-Db-vWu9Y.js";import{E as ie,a as ae,c as oe,f as u,r as d,v as se,w as ce,x as le}from"./context-DY40EDc6.js";import{t as f}from"./PathPickerField-CSIa7jSl.js";import{i as ue}from"./use-menu-CKSpS96u.js";import{Ct as p,bt as de}from"./index-CTvqbEB8.js";import{n as fe}from"./page-header-NyYSXjfY.js";var m=e(n(),1),h=t(),g=[{value:`documentRead`,label:`Read`},{value:`documentWrite`,label:`Write`},{value:`documentReadWrite`,label:`Read & write`}];function _(){let{contextId:e,tab:t}=ee(),[n]=i(),_=n.get(`ownerId`)||void 0,v=r(),{showToast:y}=ne(),{selectEntity:b,goBack:x,closeM2:S}=ue(),C=re(),w=p(t),T=_?`?ownerId=${encodeURIComponent(_)}`:``;(0,m.useEffect)(()=>{t!==w&&e&&v(`/contexts/${e}/settings/${w}${T}`,{replace:!0})},[t,w,e,T,v]);let[E,D]=(0,m.useState)(null),[pe,me]=(0,m.useState)(!0),[O,k]=(0,m.useState)(!1),[A,j]=(0,m.useState)(!1),[M,N]=(0,m.useState)(``),[P,F]=(0,m.useState)(``),[I,L]=(0,m.useState)(null),[R,z]=(0,m.useState)(``),[B,V]=(0,m.useState)(``),[H,he]=(0,m.useState)(),[U,W]=(0,m.useState)([]),[G,K]=(0,m.useState)(!1),[q,J]=(0,m.useState)(``),[Y,ge]=(0,m.useState)(g[0].value),[X,Z]=(0,m.useState)(null);(0,m.useEffect)(()=>{if(!e)return;let t=!1;return ae(e,_).then(e=>{t||(D(e),b(e.id),N(e.name||``),F(e.description||``),L(typeof e.metadata?.ui?.color==`string`?e.metadata.ui.color:null),z(e.url||``),V(e.baseUrl||``))}).catch(()=>{t||y({title:`Error`,description:`Failed to load context`,variant:`destructive`})}).finally(()=>{t||me(!1)}),()=>{t=!0}},[e,_,b,y]);let Q=(t=e)=>{t&&(K(!0),u(t).then(W).catch(()=>W([])).finally(()=>K(!1)))};(0,m.useEffect)(()=>{if(w!==`shares`||!e)return;let t=!1;return u(e).then(e=>{t||W(e)}).catch(()=>{t||W([])}),()=>{t=!0}},[w,e]);let _e=async t=>{if(t.preventDefault(),e){k(!0);try{let t=await se(e,{name:M.trim(),description:P.trim(),metadata:{...E?.metadata,ui:{...E?.metadata?.ui,color:I}}},_);D(t),window.dispatchEvent(new CustomEvent(`contexts:refresh`)),y({title:`Saved`,description:`Context updated`})}catch(e){y({title:`Error`,description:e instanceof Error?e.message:`Save failed`,variant:`destructive`})}finally{k(!1)}}},ve=async t=>{if(t.preventDefault(),e){k(!0);try{await Promise.all([ie(e,R.trim(),_,H),ce(e,{baseUrl:B.trim()||null},_)]),window.dispatchEvent(new CustomEvent(`contexts:refresh`)),y({title:`Saved`,description:`Context URL updated`})}catch(e){y({title:`Error`,description:e instanceof Error?e.message:`Save failed`,variant:`destructive`})}finally{k(!1)}}},ye=async()=>{if(e&&window.confirm(`Delete context "${e}"? This cannot be undone.`)){j(!0);try{await d(e,_),S(),b(null),y({title:`Deleted`,description:`Context "${e}" removed`}),v(`/contexts`,{replace:!0})}catch(e){y({title:`Error`,description:e instanceof Error?e.message:`Delete failed`,variant:`destructive`})}finally{j(!1)}}},be=async t=>{if(t.preventDefault(),!(!e||!q.trim())){Z(`grant`);try{await oe(e,q.trim(),Y),J(``),Q(),y({title:`Shared`,description:`Access granted to ${q.trim()}`})}catch(e){y({title:`Error`,description:e instanceof Error?e.message:`Failed to grant access`,variant:`destructive`})}finally{Z(null)}}},xe=async t=>{if(e&&window.confirm(`Revoke ${t.userEmail}'s access to "${e}"?`)){Z(t.userEmail);try{await le(e,t.userEmail),Q(),y({title:`Revoked`,description:`${t.userEmail} no longer has access`})}catch(e){y({title:`Error`,description:e instanceof Error?e.message:`Failed to revoke access`,variant:`destructive`})}finally{Z(null)}}};if(pe)return(0,h.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:`Loading...`});if(!E)return(0,h.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:`Context not found`});let $=de.find(e=>e.id===w),Se=`/contexts/${e}${T}`;return(0,h.jsx)(`div`,{className:`h-full min-h-0 overflow-y-auto`,children:(0,h.jsxs)(`div`,{className:`mx-auto max-w-3xl p-6 pb-12 max-md:px-4 max-md:pb-rail-stack`,children:[(0,h.jsx)(fe,{compact:!0,className:`mb-6 border-b pb-4`,title:`${$.label} - ${E.name||E.id}`,description:$.description,backTo:Se,onBack:C?x:void 0}),w===`general`&&(0,h.jsxs)(`div`,{className:`space-y-6`,children:[(0,h.jsxs)(`form`,{onSubmit:_e,className:`space-y-4 rounded-lg border p-4`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{className:`text-sm font-medium`,children:`Context ID`}),(0,h.jsx)(`div`,{className:`mt-1 flex h-10 items-center rounded-md bg-muted px-3 font-mono text-sm text-muted-foreground`,children:E.id})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`ctx-name`,className:`text-sm font-medium`,children:`Name`}),(0,h.jsx)(l,{id:`ctx-name`,value:M,onChange:e=>N(e.target.value),placeholder:`My Context`})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`ctx-description`,className:`text-sm font-medium`,children:`Description`}),(0,h.jsx)(l,{id:`ctx-description`,value:P,onChange:e=>F(e.target.value),placeholder:`Optional description`})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`ctx-color`,className:`text-sm font-medium`,children:`Color`}),(0,h.jsxs)(`div`,{className:`mt-1 flex items-center gap-2`,children:[(0,h.jsx)(l,{id:`ctx-color`,type:`color`,value:/^#[0-9a-f]{6}$/i.test(I||E.color||``)?I||E.color:`#808080`,onChange:e=>L(e.target.value),className:`h-10 w-16 p-1`,disabled:O}),(0,h.jsx)(c,{type:`button`,variant:`outline`,size:`sm`,disabled:O||I===null,onClick:()=>L(null),children:`Use inherited color`})]}),(0,h.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:I===null?`Using the tree folder or workspace color.`:`Applies only to this context.`})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{className:`text-sm font-medium`,children:`Workspace`}),(0,h.jsx)(`div`,{className:`mt-1 flex h-10 items-center rounded-md bg-muted px-3 text-sm text-muted-foreground`,children:E.workspaceName||E.workspaceId||E.workspace})]}),(0,h.jsx)(c,{type:`submit`,disabled:O,children:O?`Saving...`:`Save Changes`})]}),(0,h.jsxs)(`section`,{className:`rounded-lg border border-destructive/30 p-4`,children:[(0,h.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-destructive`,children:`Danger Zone`}),(0,h.jsxs)(c,{variant:`destructive`,disabled:A,onClick:ye,children:[(0,h.jsx)(a,{className:`mr-2 h-4 w-4`}),A?`Deleting...`:`Delete Context`]})]})]}),w===`location`&&(0,h.jsxs)(`form`,{onSubmit:ve,className:`space-y-4 rounded-lg border p-4`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`ctx-url`,className:`text-sm font-medium`,children:`URL`}),(0,h.jsx)(f,{id:`ctx-url`,value:R,onChange:z,fixedWorkspaceName:E.workspaceName,pickerTitle:`Switch context to…`,placeholder:`workspace://path`,onPickTarget:(e,t)=>{z(`${t.workspaceName}://${e.replace(/^\/+/,``)}`),he(t.treeName)}}),H&&(0,h.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Destination tree: `,H]})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`label`,{htmlFor:`ctx-base-url`,className:`text-sm font-medium`,children:[`Base URL `,(0,h.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:`(optional)`})]}),(0,h.jsx)(f,{id:`ctx-base-url`,value:B,onChange:V,fixedWorkspaceName:E.workspaceName,placeholder:`workspace://base/path`,pickerTitle:`Pick a base path…`})]}),(0,h.jsx)(c,{type:`submit`,disabled:O,children:O?`Saving...`:`Save Changes`})]}),w===`shares`&&(0,h.jsxs)(`div`,{className:`space-y-4`,children:[(0,h.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h2`,{className:`text-sm font-semibold`,children:`People with access`}),(0,h.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Only the context owner can see and change this list.`})]}),(0,h.jsxs)(c,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>Q(),disabled:G,children:[(0,h.jsx)(o,{className:s(`mr-2 h-3.5 w-3.5`,G&&`animate-spin`)}),`Refresh`]})]}),U.length===0?(0,h.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`Not shared with anyone.`}):U.map(e=>(0,h.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border p-3`,children:[(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.userEmail}),(0,h.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[g.find(t=>t.value===e.accessLevel)?.label||e.accessLevel||`unknown access`,e.sharedAt&&` - since ${new Date(e.sharedAt).toLocaleDateString()}`]})]}),(0,h.jsx)(c,{type:`button`,variant:`outline`,size:`sm`,className:`text-destructive hover:text-destructive`,disabled:X===e.userEmail,onClick:()=>xe(e),children:(0,h.jsx)(te,{className:`h-3.5 w-3.5`})})]},e.userEmail))]}),(0,h.jsxs)(`form`,{onSubmit:be,className:`space-y-4 rounded-lg border p-4`,children:[(0,h.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Grant access`}),(0,h.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`share-email`,className:`text-sm font-medium`,children:`User email`}),(0,h.jsx)(l,{id:`share-email`,type:`email`,value:q,onChange:e=>J(e.target.value),placeholder:`person@example.com`}),(0,h.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`The user must already have an account on this server.`})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`share-level`,className:`text-sm font-medium`,children:`Access level`}),(0,h.jsx)(`select`,{id:`share-level`,value:Y,onChange:e=>ge(e.target.value),className:`mt-1 w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring`,children:g.map(e=>(0,h.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]}),(0,h.jsx)(c,{type:`submit`,disabled:X===`grant`||!q.trim(),children:X===`grant`?`Sharing...`:`Share context`})]})]})]})})}export{_ as default};
@@ -0,0 +1 @@
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{_ as r,g as ee}from"./chunk-62JRHF6Z-vspAGgtK.js";import{X as i}from"./ui-DEgHnkQu.js";import{t as a}from"./button--VYZekMF.js";import{t as o}from"./input-BOtCd4HP.js";import{n as te}from"./use-toast-BlLDqSUO.js";import{jt as ne}from"./workspace-4hWrSEku.js";import{t as re}from"./use-mobile-Db-vWu9Y.js";import{p as ie}from"./context-DY40EDc6.js";import{t as s}from"./color-DFEH4BfK.js";import{i as ae}from"./use-menu-CKSpS96u.js";import{K as oe,Q as se,St as ce,U as le,X as ue,Z as de,et as fe,it as pe,nt as me,q as he,rt as ge,st as _e,tt as ve,yt as ye}from"./index-CTvqbEB8.js";import{n as be}from"./page-header-NyYSXjfY.js";import{n as xe,r as Se,t as Ce}from"./useAgentModels-CI9XT6yc.js";var c=e(n(),1),l=t(),we={anthropic:`claude-3-5-sonnet-20241022`,openai:`gpt-4o`,ollama:`qwen2.5-coder:latest`,"lm-studio":``,vllm:``,custom:``},u={anthropic:`https://api.anthropic.com`,openai:`https://api.openai.com/v1`,ollama:`http://localhost:11434/v1`,"lm-studio":`http://localhost:1234/v1`,vllm:`http://localhost:8000/v1`,custom:``};function d(e){return u[e]||``}function f({label:e,hint:t,children:n}){return(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:`text-sm font-medium`,children:e}),t&&(0,l.jsx)(`p`,{className:`mb-1 mt-0.5 text-xs text-muted-foreground`,children:t}),(0,l.jsx)(`div`,{className:t?void 0:`mt-1`,children:n})]})}var p=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring resize-y`,m=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring`;function h(){let{agentId:e,tab:t}=r(),n=ee(),{showToast:u}=te(),{selectEntity:h,goBack:Te}=ae(),Ee=re(),g=ce(t);(0,c.useEffect)(()=>{t!==g&&e&&n(`/agents/${encodeURIComponent(e)}/settings/${g}`,{replace:!0})},[t,g,e,n]);let[_,v]=(0,c.useState)(null),[De,Oe]=(0,c.useState)(!0),[ke,Ae]=(0,c.useState)(null),[je,Me]=(0,c.useState)(!1),[Ne,Pe]=(0,c.useState)(!1),[Fe,Ie]=(0,c.useState)(``),[Le,Re]=(0,c.useState)(``),[ze,Be]=(0,c.useState)(``),[Ve,y]=(0,c.useState)(s()),[b,He]=(0,c.useState)(``),[x,Ue]=(0,c.useState)(``),[S,We]=(0,c.useState)(``),[C,Ge]=(0,c.useState)(``),[w,Ke]=(0,c.useState)(`anthropic`),[T,qe]=(0,c.useState)(``),[E,D]=(0,c.useState)(``),[O,k]=(0,c.useState)(``),[Je,Ye]=(0,c.useState)(.7),[Xe,A]=(0,c.useState)(4096),[Ze,Qe]=(0,c.useState)(1),$e=Ce(w,T,E,_?.id),et=$e.models.find(e=>e.id===O),[tt,j]=(0,c.useState)([]),[M,N]=(0,c.useState)(``),[nt,P]=(0,c.useState)(``),[F,I]=(0,c.useState)(``),[L,R]=(0,c.useState)(``),[rt,it]=(0,c.useState)(!1),[at,ot]=(0,c.useState)(null),[z,B]=(0,c.useState)(null),[st,ct]=(0,c.useState)(null),[V,H]=(0,c.useState)(!1),[U,W]=(0,c.useState)(null),[G,K]=(0,c.useState)(``),[q,J]=(0,c.useState)(!1),[Y,lt]=(0,c.useState)(`context`),[X,ut]=(0,c.useState)(``),[dt,ft]=(0,c.useState)(`/`),[Z,pt]=(0,c.useState)(``),[mt,ht]=(0,c.useState)(!0),[Q,gt]=(0,c.useState)(!1),[_t,vt]=(0,c.useState)([]),[yt,bt]=(0,c.useState)([]),[$,xt]=(0,c.useState)(null),[St,Ct]=(0,c.useState)(`{}`),[wt,Tt]=(0,c.useState)(null),[Et,Dt]=(0,c.useState)(e);Et!==e&&(Dt(e),Oe(!0),v(null)),(0,c.useEffect)(()=>{if(!e)return;let t=!1;return oe(e).then(async e=>{if(t)return;let n=e.config?.identity||{};v(e),h(e.id),Ie(e.name||``),Re(e.label||``),Be(e.description||``),y(e.color||s()),He(n.role||``),Ue(n.identity||``),We(n.instructions||``),Ge(e.config?.prompts?.system||``),Ke(e.llmProvider||`anthropic`),qe(e.config?.apiKey||``),D(e.config?.baseUrl||d(e.llmProvider)),k(e.model||we[e.llmProvider]||``);let r=e.config?.connectors?.[e.llmProvider];r&&(Ye(r.temperature??.7),A(r.maxTokens??4096),Qe(r.topP??1)),Ct(JSON.stringify(e.config?.tools??{},null,2)),Tt(null),Ae(null);try{j(await se(e.id))}catch{j([])}}).catch(e=>{t||Ae(e instanceof Error?e.message:`Failed to load agent`)}).finally(()=>{t||Oe(!1)}),()=>{t=!0}},[e,h]),(0,c.useEffect)(()=>{if(g!==`access`&&g!==`tools`||!_?.id)return;let e=_.id,t=!1;return Promise.all([he(_.id).catch(()=>null),ne().catch(()=>[]),ie().catch(()=>[]),ue(_.id).catch(()=>null)]).then(([n,r,ee,i])=>{t||(B(n),vt(r),bt(ee),xt(i?i.tools:[]),ct(e))}),()=>{t=!0}},[g,_?.id]);let Ot=()=>{let e=Se(b,x,S),t;try{let e=JSON.parse(St);e&&typeof e==`object`&&!Array.isArray(e)&&(t=e)}catch{}return{...t===void 0?{}:{tools:t},name:Fe.trim(),label:Le.trim(),description:ze.trim()||void 0,color:Ve,llmProvider:w,model:O,apiKey:T.trim()||(w===_?.llmProvider?void 0:``),baseUrl:E||void 0,config:{type:w,model:O,identity:{role:b.trim()||void 0,identity:x.trim()||void 0,instructions:S.trim()||void 0},prompts:C.trim()||e?{system:C.trim()||e}:void 0,connectors:{[w]:{...w===`anthropic`?{}:{temperature:Je},maxTokens:Xe,topP:Ze}}}}},kt=async e=>{if(e.preventDefault(),_){Me(!0);try{let e=await _e(_.id,Ot());v(e),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Saved`,description:`Agent updated`}),e.name&&e.name!==_.name&&n(`/agents/${encodeURIComponent(e.name)}/settings/${g}`,{replace:!0})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Save failed`,variant:`destructive`})}finally{Me(!1)}}},At=async()=>{if(_&&window.confirm(`Delete agent "${_.label||_.name}"? This cannot be undone.`)){Pe(!0);try{await le(_.id),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Deleted`,description:`Agent removed`}),n(`/agents`)}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Delete failed`,variant:`destructive`})}finally{Pe(!1)}}},jt=()=>{N(``),P(``),I(``),R(``)},Mt=async()=>{if(!(!_||!L.trim()&&!F.trim())){it(!0);try{let e=await de(_.id,L.trim()?{source:L.trim()}:{name:M,description:nt,content:F});j(e),jt(),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Installed`,description:`Skill saved`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Skill install failed`,variant:`destructive`})}finally{it(!1)}}},Nt=async e=>{if(_){ot(e);try{let t=await fe(_.id,e);j(t),(M===e||L===e)&&jt(),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Removed`,description:`Skill "${e}" removed`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Skill remove failed`,variant:`destructive`})}finally{ot(null)}}},Pt=()=>Y===`global`?{type:`global`}:Y===`context`?Z?{type:`context`,context:Z}:null:X?Y===`path`?{type:`path`,workspace:X,path:dt.trim()||`/`}:{type:`workspace`,workspace:X}:null,Ft=async()=>{if(!_||V)return;let e=Pt(),t=[];if(mt&&t.push(`read`),Q&&t.push(`write`),!e||!/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$/.test(G.trim())||t.length===0||!q&&z?.grants.some(e=>e.id===G.trim())){u({title:`Invalid binding`,description:`Choose a unique connection name (letters, numbers, hyphens or underscores), scope and permissions`,variant:`destructive`});return}if(!(e.type===`global`&&!window.confirm(`Global scope lets this agent ${Q?`read and write`:`read`} ALL your workspaces. Continue?`))){H(!0);try{let n=await pe(_.id,G.trim(),{label:z?.grants.find(e=>e.id===G.trim())?.label||G.trim(),binding:e,permissions:t});B(n.access),W(n.tokens[0]?.token??null),K(``),J(!1),u({title:`Connection saved`,description:`Other connections and their tokens are unchanged`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Bind failed`,variant:`destructive`})}finally{H(!1)}}},It=async e=>{if(!(!_||V)){H(!0);try{let t=await ge(_.id,e);B(t.access),W(t.tokens[0]?.token??null),u({title:`Rotated`,description:`New token minted — the previous one no longer works`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Rotate failed`,variant:`destructive`})}finally{H(!1)}}},Lt=e=>{K(e.id),J(!0),lt(e.binding.type),ut(e.binding.workspace||``),ft(e.binding.path||`/`),pt(e.binding.context||``),ht(e.permissions.includes(`read`)),gt(e.permissions.includes(`write`))},Rt=async e=>{if(!(!_||V)){H(!0);try{let t=await me(_.id,e);B(t.access),W(null),G===e&&(K(``),J(!1))}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Revoke failed`,variant:`destructive`})}finally{H(!1)}}},zt=async()=>{if(!(!_||V)&&window.confirm(`Revoke this agent's canvas access? All its connection tokens stop working immediately.`)){H(!0);try{await ve(_.id),B(null),W(null),u({title:`Revoked`,description:`Agent access removed`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Revoke failed`,variant:`destructive`})}finally{H(!1)}}},Bt=e=>{if(e.type===`global`)return`Global — all workspaces`;if(e.type===`context`){let t=yt.find(t=>t.id===e.context);return`Context ${t?`${t.id} (${t.url})`:e.context} — follows the context live`}let t=e.workspaceName||e.workspace;return e.type===`path`?`Workspace ${t}, path ${e.path||`/`}`:`Workspace ${t} (whole tree)`};if(De)return(0,l.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:`Loading...`});if(!_||ke)return(0,l.jsx)(`div`,{className:`p-6 text-sm text-destructive`,children:ke||`Agent not found`});let Vt=ye.find(e=>e.id===g),Ht=encodeURIComponent(_.name||_.id),Ut=g===`identity`||g===`provider`||g===`models`||g===`tools`;return(0,l.jsx)(`div`,{className:`h-full min-h-0 overflow-y-auto`,children:(0,l.jsxs)(`div`,{className:`mx-auto max-w-5xl p-6 pb-12 max-md:px-4 max-md:pb-rail-stack`,children:[(0,l.jsx)(be,{compact:!0,className:`mb-6 border-b pb-4`,title:`${Vt.label} - ${_.label||_.name}`,description:Vt.description,backTo:`/agents/${Ht}`,onBack:Ee?Te:void 0}),(0,l.jsxs)(`form`,{onSubmit:kt,className:`space-y-6`,children:[g===`identity`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,l.jsx)(f,{label:`Name`,hint:`ID: ${_.id}`,children:(0,l.jsx)(o,{value:Fe,onChange:e=>Ie(e.target.value),placeholder:`lucy`})}),(0,l.jsx)(f,{label:`Label`,children:(0,l.jsx)(o,{value:Le,onChange:e=>Re(e.target.value),placeholder:`Display name`})})]}),(0,l.jsx)(f,{label:`Description`,children:(0,l.jsx)(o,{value:ze,onChange:e=>Be(e.target.value),placeholder:`Short description`})}),(0,l.jsx)(f,{label:`Color`,children:(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(o,{type:`color`,value:Ve,onChange:e=>y(e.target.value),className:`h-10 w-16 p-1`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>y(s()),children:`Randomize`})]})})]}),(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Persona`}),(0,l.jsx)(f,{label:`Role`,children:(0,l.jsx)(o,{value:b,onChange:e=>He(e.target.value),placeholder:`e.g. Software Engineer`})}),(0,l.jsx)(f,{label:`Identity`,children:(0,l.jsx)(`textarea`,{value:x,onChange:e=>Ue(e.target.value),placeholder:`Who this agent is…`,className:`${p} min-h-[80px]`})}),(0,l.jsx)(f,{label:`Instructions`,children:(0,l.jsx)(`textarea`,{value:S,onChange:e=>We(e.target.value),placeholder:`Behavioral instructions…`,className:`${p} min-h-[80px]`})}),(0,l.jsx)(f,{label:`System Prompt`,hint:`Compiled from Role + Identity + Instructions. Override manually.`,children:(0,l.jsx)(`textarea`,{value:C,onChange:e=>Ge(e.target.value),placeholder:`System prompt sent to the LLM…`,className:`${p} min-h-[140px] font-mono text-xs`})})]}),(0,l.jsxs)(`section`,{className:`rounded-lg border border-destructive/30 p-4`,children:[(0,l.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-destructive`,children:`Danger Zone`}),(0,l.jsxs)(a,{type:`button`,variant:`destructive`,disabled:Ne,onClick:At,children:[(0,l.jsx)(i,{className:`mr-2 h-4 w-4`}),Ne?`Deleting...`:`Delete Agent`]})]})]}),g===`provider`&&(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(f,{label:`Provider`,children:(0,l.jsxs)(`select`,{value:w,onChange:e=>{let t=e.target.value;Ke(t),qe(``),k(we[t]||``),D(d(t))},className:`w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring`,children:[(0,l.jsx)(`option`,{value:`anthropic`,children:`Anthropic Claude`}),(0,l.jsx)(`option`,{value:`openai`,children:`OpenAI GPT`}),(0,l.jsx)(`option`,{value:`ollama`,children:`Ollama (Local)`}),(0,l.jsx)(`option`,{value:`lm-studio`,children:`LM Studio (Local)`}),(0,l.jsx)(`option`,{value:`vllm`,children:`vLLM (Local)`}),(0,l.jsx)(`option`,{value:`custom`,children:`Custom`})]})}),(0,l.jsx)(f,{label:`API Key`,hint:[`ollama`,`lm-studio`,`vllm`].includes(w)?`Any value works for local providers.`:void 0,children:(0,l.jsx)(o,{type:`password`,value:T,onChange:e=>qe(e.target.value),placeholder:w===`ollama`?`ollama`:w===`lm-studio`?`lm-studio`:`sk-…`})}),(0,l.jsx)(f,{label:`Host / Base URL`,children:(0,l.jsx)(o,{value:E,onChange:e=>D(e.target.value),placeholder:d(w)||`https://api.example.com`})})]}),g===`models`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Main Model`}),(0,l.jsx)(f,{label:`Model`,children:(0,l.jsx)(xe,{value:O,onChange:(e,t)=>{k(e),t?.maxTokens&&A(t.maxTokens)},...$e})}),(0,l.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[w!==`anthropic`&&(0,l.jsx)(f,{label:`Temperature`,children:(0,l.jsx)(o,{type:`number`,min:0,max:2,step:.1,value:Je,onChange:e=>Ye(Number.isNaN(e.target.valueAsNumber)?.7:e.target.valueAsNumber)})}),(0,l.jsx)(f,{label:`Max Output Tokens`,children:(0,l.jsx)(o,{type:`number`,min:1,max:et?.maxTokens,value:Xe,onChange:e=>A(parseInt(e.target.value)||4096)})}),(0,l.jsx)(f,{label:`Top P`,children:(0,l.jsx)(o,{type:`number`,min:0,max:1,step:.1,value:Ze,onChange:e=>Qe(Number.isNaN(e.target.valueAsNumber)?1:e.target.valueAsNumber)})})]})]}),[`Governance`,`Memory Management`,`Subagent / Tool Use`].map(e=>(0,l.jsxs)(`section`,{className:`rounded-lg border border-dashed p-4`,children:[(0,l.jsxs)(`h2`,{className:`text-sm font-semibold text-muted-foreground`,children:[e,` Model`]}),(0,l.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Coming soon`})]},e))]}),g===`tools`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Runtime Tools`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Injected at start (pi defineTool): coding tools plus canvas tools scoped by the token binding (Access / ACL). Definitions live in the runtime — read-only here until the agent-runtime workspace lands.`})]}),$===null?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`Loading…`}):$.length===0?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`No tools resolved.`}):(0,l.jsx)(`div`,{className:`space-y-1.5`,children:$.map(e=>(0,l.jsxs)(`details`,{className:`rounded-md border px-3 py-2`,children:[(0,l.jsxs)(`summary`,{className:`cursor-pointer text-sm`,children:[(0,l.jsx)(`code`,{className:`font-mono text-xs font-medium`,children:e.name}),(0,l.jsx)(`span`,{className:`ml-2 rounded bg-muted px-1.5 py-0.5 text-[10px] uppercase text-muted-foreground`,children:e.source})]}),e.description&&(0,l.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-xs text-muted-foreground`,children:e.description}),e.parameters!=null&&(0,l.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded bg-muted p-2 font-mono text-[11px]`,children:JSON.stringify(e.parameters,null,2)})]},e.name))}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:z?z.grants.map(e=>`${e.label}: ${Bt(e.binding)}`).join(`; `):`Unbound — no canvas tools are injected. Bind under Access / ACL.`})]}),(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Tools Config`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`config.tools JSON, merged server-side — e.g. {"canvas": {"enabled": false}} gates the canvas tools. Saved with Save Changes.`})]}),(0,l.jsx)(`textarea`,{value:St,onChange:e=>{Ct(e.target.value);try{JSON.parse(e.target.value),Tt(null)}catch(e){Tt(e instanceof Error?e.message:`Invalid JSON`)}},className:`${p} min-h-[120px] font-mono text-xs`}),wt&&(0,l.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`Invalid JSON (not saved): `,wt]})]}),(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Skills`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Installed skills are saved immediately, independent of Save Changes.`})]}),tt.length===0?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`No skills installed.`}):tt.map(e=>(0,l.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border p-3`,children:[(0,l.jsxs)(`div`,{className:`min-w-0`,children:[(0,l.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.name}),(0,l.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.package?e.source:e.description||`No description`})]}),(0,l.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{N(e.name),P(e.description||``),I(e.content||``),R(e.source||``)},children:`Edit`}),(0,l.jsx)(a,{type:`button`,variant:`destructive`,size:`sm`,disabled:at===(e.source||e.name),onClick:()=>Nt(e.source||e.name),children:at===(e.source||e.name)?`Removing…`:`Remove`})]})]},e.name)),(0,l.jsxs)(`div`,{className:`space-y-4 rounded-md border p-4`,children:[(0,l.jsx)(f,{label:`Package Source`,hint:`Use this for whole pi packages. Leave empty to save inline SKILL.md content.`,children:(0,l.jsx)(o,{value:L,onChange:e=>R(e.target.value),placeholder:`npm:@foo/pi-tools or git:github.com/badlogic/pi-doom`})}),(0,l.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,l.jsx)(f,{label:`Name`,children:(0,l.jsx)(o,{value:M,onChange:e=>N(e.target.value),placeholder:`skill-name, or read from frontmatter`,disabled:!!L.trim()})}),(0,l.jsx)(f,{label:`Description`,children:(0,l.jsx)(o,{value:nt,onChange:e=>P(e.target.value),placeholder:`What this skill helps with`,disabled:!!L.trim()})})]}),(0,l.jsx)(f,{label:`SKILL.md Content`,children:(0,l.jsx)(`textarea`,{value:F,onChange:e=>I(e.target.value),placeholder:`# Skill instructions…`,disabled:!!L.trim(),className:`${p} min-h-[160px] font-mono text-xs`})}),(0,l.jsxs)(`div`,{className:`flex gap-2`,children:[(0,l.jsx)(a,{type:`button`,disabled:rt||!L.trim()&&!F.trim(),onClick:Mt,children:rt?`Saving…`:`Install / Update Skill`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,onClick:jt,children:`Clear`})]})]})]}),(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`MCP Servers`}),(_.config?.mcp?.servers||[]).length===0?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`No MCP servers configured.`}):(_.config?.mcp?.servers||[]).map((e,t)=>(0,l.jsxs)(`div`,{className:`rounded-md border p-3`,children:[(0,l.jsx)(`div`,{className:`text-sm font-medium`,children:e.name}),(0,l.jsxs)(`div`,{className:`font-mono text-xs text-muted-foreground`,children:[e.command,` `,(e.args||[]).join(` `)]})]},t))]})]}),g===`access`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Canvas Access`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Add named connections to workspaces, paths or contexts, with permissions for each. Every connection has its own scoped token. Overlapping grants are additive: a whole-workspace grant is not restricted by a context on that workspace.`})]}),st===_.id?z?(0,l.jsxs)(`div`,{className:`space-y-2`,children:[z.grants.map(e=>(0,l.jsxs)(`div`,{className:`space-y-2 rounded-md border p-3`,children:[(0,l.jsx)(`div`,{className:`text-sm font-medium`,children:e.label||e.id}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:Bt(e.binding)}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Permissions: `,e.permissions.join(`, `)]}),(0,l.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,disabled:V,onClick:()=>Lt(e),children:`Edit`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,disabled:V,onClick:()=>It(e.id),children:`Rotate Token`}),(0,l.jsx)(a,{type:`button`,variant:`destructive`,size:`sm`,disabled:V,onClick:()=>Rt(e.id),children:`Remove`})]})]},e.id)),(0,l.jsx)(a,{type:`button`,variant:`destructive`,size:`sm`,disabled:V,onClick:zt,children:`Revoke All Access`})]}):(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`Unbound — this agent has no canvas access.`}):(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`Loading…`}),U&&(0,l.jsxs)(`div`,{className:`space-y-2 rounded-md border border-warning/50 bg-warning/10 p-3`,children:[(0,l.jsx)(`div`,{className:`text-xs font-medium`,children:`Agent token — shown once, store it now`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`code`,{className:`flex-1 truncate rounded bg-background px-2 py-1 font-mono text-xs`,children:U}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>navigator.clipboard?.writeText(U),children:`Copy`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>W(null),children:`Dismiss`})]}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Managed agents receive their connections automatically. External runtimes use the CANVAS_CONNECTIONS JSON array.`})]})]}),(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:q?`Edit Connection`:`Add Connection`}),(0,l.jsx)(f,{label:`Connection name`,hint:`Agents use this name to select the scope for each tool call.`,children:(0,l.jsx)(o,{value:G,disabled:q,onChange:e=>K(e.target.value),placeholder:`bar, baz, baf`})}),(0,l.jsx)(f,{label:`Scope`,hint:`Context bindings follow the context live; global spans all workspaces.`,children:(0,l.jsxs)(`select`,{value:Y,onChange:e=>lt(e.target.value),className:m,children:[(0,l.jsx)(`option`,{value:`context`,children:`Context (follows live)`}),(0,l.jsx)(`option`,{value:`workspace`,children:`Workspace`}),(0,l.jsx)(`option`,{value:`path`,children:`Workspace path`}),(0,l.jsx)(`option`,{value:`global`,children:`Global (all workspaces)`})]})}),Y===`context`&&(0,l.jsx)(f,{label:`Context`,children:(0,l.jsxs)(`select`,{value:Z,onChange:e=>pt(e.target.value),className:m,children:[(0,l.jsx)(`option`,{value:``,children:`Select a context…`}),yt.map(e=>(0,l.jsxs)(`option`,{value:e.id,children:[e.id,` — `,e.url]},e.id))]})}),(Y===`workspace`||Y===`path`)&&(0,l.jsx)(f,{label:`Workspace`,children:(0,l.jsxs)(`select`,{value:X,onChange:e=>ut(e.target.value),className:m,children:[(0,l.jsx)(`option`,{value:``,children:`Select a workspace…`}),_t.map(e=>(0,l.jsx)(`option`,{value:e.name||e.id,children:e.label||e.name},e.id))]})}),Y===`path`&&(0,l.jsx)(f,{label:`Base path`,hint:`The agent is clamped to this subtree.`,children:(0,l.jsx)(o,{value:dt,onChange:e=>ft(e.target.value),placeholder:`/work/projects/foo`})}),(0,l.jsx)(f,{label:`Permissions`,children:(0,l.jsxs)(`div`,{className:`flex gap-4 text-sm`,children:[(0,l.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:mt,onChange:e=>ht(e.target.checked)}),` read`]}),(0,l.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:Q,onChange:e=>gt(e.target.checked)}),` write`]})]})}),(0,l.jsx)(a,{type:`button`,disabled:V,onClick:Ft,children:V?`Working…`:q?`Save Connection`:`Add Connection`}),q&&(0,l.jsx)(a,{type:`button`,variant:`outline`,onClick:()=>{K(``),J(!1)},children:`Cancel Edit`})]})]}),g===`memory`&&(0,l.jsxs)(`section`,{className:`rounded-lg border border-dashed p-6 text-center`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground`,children:`Memory Engine`}),(0,l.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Loop-based memory management. Settings coming soon.`})]}),g===`integrations`&&(0,l.jsxs)(`section`,{className:`rounded-lg border border-dashed p-6 text-center`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground`,children:`Integrations`}),(0,l.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`IMAP, chat, SQL and REST API accounts. Coming soon.`})]}),Ut&&(0,l.jsx)(a,{type:`submit`,disabled:je,children:je?`Saving…`:`Save Changes`})]})]})})}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{g as r,v as i}from"./chunk-62JRHF6Z-vspAGgtK.js";import{n as a,t as o}from"./HomeFab-B17r3232.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
+ 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-iC5BF7LV.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{X as r,vn as i}from"./ui-CDoK3F3U.js";import{t as a}from"./LinkToCard-CKVi4Nrg.js";import{Lt as o,g as s}from"./workspace-C5V-ZCOE.js";import{n as c}from"./relation-events-CKio19hE.js";import{t as l}from"./useToastHelpers-CRrpIIdY.js";import{n as u,t as d}from"./LinkToSidePanel-eCy3nW4R.js";var f=e(n(),1),p=t();function m({value:e,onChange:t,onBlur:n,placeholder:r,innerRef:i}){let a=(0,f.useRef)(null),o=(0,f.useCallback)(()=>{let e=a.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)},[]);return(0,f.useEffect)(()=>{o()},[e,o]),(0,p.jsx)(`textarea`,{ref:e=>{a.current=e,i?.(e)},value:e,onChange:e=>t(e.target.value),onBlur:n,placeholder:r,rows:1,spellCheck:!1,className:`w-full resize-none overflow-hidden border-0 bg-transparent p-0 text-sm leading-relaxed text-foreground outline-none placeholder:text-muted-foreground/60`})}function h({onLinkTo:e,onDelete:t}){return(0,p.jsxs)(`span`,{className:`reveal-on-hover flex items-center gap-0.5`,children:[(0,p.jsx)(`button`,{type:`button`,onClick:e,className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,"aria-label":`Link to…`,title:`Link to…`,children:(0,p.jsx)(i,{className:`h-3.5 w-3.5`})}),(0,p.jsx)(`button`,{type:`button`,onClick:t,className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-destructive`,"aria-label":`Delete`,title:`Delete (moves to trash)`,children:(0,p.jsx)(r,{className:`h-3.5 w-3.5`})})]})}function g({documentId:e,workspaceName:t,onClose:n}){let{showSuccessToast:r,showErrorToast:i}=l(),[m,h]=(0,f.useState)(!1);return(0,p.jsx)(u,{onClose:n,children:(0,p.jsx)(a,{onClose:n,onConfirm:async(t,a)=>{if(t.length){h(!0);try{for(let n of t)await o(a.workspaceName,n,[e],a.treeName,a.treeType);r(`Linked to ${t.length} path${t.length>1?`s`:``}`),n()}catch(e){i(e instanceof Error?e.message:`Failed to link document`),h(!1)}}},documentCount:1,saving:m,sizeClassName:d,tabs:t?[`context`,`directory`,`relations`]:[`context`,`directory`],relationWorkspaceName:t,relationExcludeIds:new Set([e]),onConfirmRelation:async({predicate:a,direction:o,targetIds:l})=>{if(!(!t||!l.length)){h(!0);try{await s(t,e,a,l,o),r(`Related to ${l.length} document${l.length===1?``:`s`}`),c(),n()}catch(e){i(e instanceof Error?e.message:`Failed to create relation`),h(!1)}}}})})}export{h as n,g as r,m as t};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{X as r,vn as i}from"./ui-DEgHnkQu.js";import{t as a}from"./LinkToCard-oi3wGP0a.js";import{Lt as o,g as s}from"./workspace-4hWrSEku.js";import{n as c}from"./relation-events-CKio19hE.js";import{t as l}from"./useToastHelpers-CRrpIIdY.js";import{n as u,t as d}from"./LinkToSidePanel-eCy3nW4R.js";var f=e(n(),1),p=t();function m({value:e,onChange:t,onBlur:n,placeholder:r,innerRef:i}){let a=(0,f.useRef)(null),o=(0,f.useCallback)(()=>{let e=a.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)},[]);return(0,f.useEffect)(()=>{o()},[e,o]),(0,p.jsx)(`textarea`,{ref:e=>{a.current=e,i?.(e)},value:e,onChange:e=>t(e.target.value),onBlur:n,placeholder:r,rows:1,spellCheck:!1,className:`w-full resize-none overflow-hidden border-0 bg-transparent p-0 text-sm leading-relaxed text-foreground outline-none placeholder:text-muted-foreground/60`})}function h({onLinkTo:e,onDelete:t}){return(0,p.jsxs)(`span`,{className:`reveal-on-hover flex items-center gap-0.5`,children:[(0,p.jsx)(`button`,{type:`button`,onClick:e,className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,"aria-label":`Link to…`,title:`Link to…`,children:(0,p.jsx)(i,{className:`h-3.5 w-3.5`})}),(0,p.jsx)(`button`,{type:`button`,onClick:t,className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-destructive`,"aria-label":`Delete`,title:`Delete (moves to trash)`,children:(0,p.jsx)(r,{className:`h-3.5 w-3.5`})})]})}function g({documentId:e,workspaceName:t,onClose:n}){let{showSuccessToast:r,showErrorToast:i}=l(),[m,h]=(0,f.useState)(!1);return(0,p.jsx)(u,{onClose:n,children:(0,p.jsx)(a,{onClose:n,onConfirm:async(t,a)=>{if(t.length){h(!0);try{for(let n of t)await o(a.workspaceName,n,[e],a.treeName,a.treeType);r(`Linked to ${t.length} path${t.length>1?`s`:``}`),n()}catch(e){i(e instanceof Error?e.message:`Failed to link document`),h(!1)}}},documentCount:1,saving:m,sizeClassName:d,tabs:t?[`context`,`directory`,`relations`]:[`context`,`directory`],relationWorkspaceName:t,relationExcludeIds:new Set([e]),onConfirmRelation:async({predicate:a,direction:o,targetIds:l})=>{if(!(!t||!l.length)){h(!0);try{await s(t,e,a,l,o),r(`Related to ${l.length} document${l.length===1?``:`s`}`),c(),n()}catch(e){i(e instanceof Error?e.message:`Failed to create relation`),h(!1)}}}})})}export{h as n,g as r,m 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{h as r}from"./chunk-62JRHF6Z-vspAGgtK.js";import{t as i}from"./button-SeUZ_Pvi.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{At as c}from"./index-G_67YwLB.js";import{n as l}from"./page-header-DrDt1sQ2.js";import{t as u}from"./use-settings-back-DGmLAD63.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
+ 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-CTvqbEB8.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};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SketchEditor-CSA7dTyq.js","assets/rolldown-runtime-C0FnF6B9.js","assets/code-editor-BOIngd5F.js","assets/react-BHzhHVTZ.js","assets/preload-helper-Czpn1I53.js","assets/ui-DEgHnkQu.js","assets/utils-BxVxyehK.js","assets/button--VYZekMF.js","assets/utils-2pl1SbIp.js","assets/input-BOtCd4HP.js","assets/workspace-4hWrSEku.js","assets/api-CA6WiiYM.js","assets/alert-dialog-BKtaX1_a.js","assets/useAddTarget-BvuFR5pN.js","assets/use-toolbox-Ck_cLGgf.js","assets/context-DY40EDc6.js","assets/useToastHelpers-CRrpIIdY.js","assets/use-toast-BlLDqSUO.js","assets/blobs-WiXP9QRi.js","assets/sha256-65KIjGvZ.js","assets/chunk-K2UTITRG-BvHe9UPk.js","assets/chunk-SRAX5OIU-Dhm3gOdh.js","assets/chunk-6U3AYISY-C6-Mtja1.js","assets/chunk-Z3N5DIM6-D9TMVU7m.js","assets/EditorOverlay-DglJkHo3.js","assets/SketchEditor-DtRVLazd.css"])))=>i.map(i=>d[i]);
2
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{u as t}from"./code-editor-BOIngd5F.js";import{t as n}from"./preload-helper-Czpn1I53.js";var r=e(t(),1);window.EXCALIDRAW_ASSET_PATH=`/excalidraw/`;var i=(0,r.lazy)(()=>n(()=>import(`./SketchEditor-CSA7dTyq.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25])));export{i 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{vt as r}from"./react-BHzhHVTZ.js";import{kt as i}from"./ui-CDoK3F3U.js";import{t as a}from"./button-SeUZ_Pvi.js";import{t as o}from"./input-BOtCd4HP.js";import{c as s,t as c}from"./api-CA6WiiYM.js";import{a as l,c as u,i as d,s as f,t as p}from"./alert-dialog-CFeuDt0T.js";var m=e(n(),1),h=r(),g=(e,t)=>`${s.workspaces}/${encodeURIComponent(e)}/trees/${encodeURIComponent(t)}/subtree`;function _(e,t,n,r){return c.post(`${g(e,t)}/export`,{path:n,dependencies:r})}function v(e,t,n,r,i){return c.post(`${g(e,t)}/import`,{parentPath:n,name:r,archive:i})}async function y(e,t,n,r){for(;;){let i=await c.get(`${g(e,t)}/jobs/${encodeURIComponent(n)}`,{cache:`no-store`});if(r(i),i.status===`failed`)throw Error(i.error?.message||`Subtree transfer failed`);if(i.status===`done`)return i;await new Promise(e=>setTimeout(e,750))}}var b=t();function x(e){let t=document.createElement(`div`);document.body.appendChild(t);let n=(0,h.createRoot)(t),r=()=>{n.unmount(),t.remove()};n.render((0,b.jsx)(S,{...e,onClose:r}))}function S({mode:e,workspaceId:t,treeName:n,path:r,onImported:s,onClose:c}){let[h,g]=(0,m.useState)(`related`),[x,S]=(0,m.useState)(null),[C,w]=(0,m.useState)(``),[T,E]=(0,m.useState)(!1),[D,O]=(0,m.useState)(``),[k,A]=(0,m.useState)(null),j=k?.status===`done`&&e===`import`?k.result:null,M=async e=>{if(e){E(!0),O(``),S(null),A(null);try{if(e.size>125829120)throw Error(`This export exceeds the 120 MB upload limit.`);let t=JSON.parse(await e.text());if(t.format!==`canvas-subtree`||t.version!==1||!Array.isArray(t.nodes)||!t.nodes[0]||!Array.isArray(t.documents))throw Error(`Choose a Canvas subtree export file.`);S(t),w(t.nodes[0].name===`/`?t.source.tree.name:t.nodes[0].name)}catch(e){O(e instanceof Error?e.message:`Could not read export`)}finally{E(!1)}}},N=async()=>{E(!0),O(``);try{let i=k?.status===`running`?k:e===`export`?await _(t,n,r,h):await v(t,n,r,C,x);A(i);let a=await y(t,n,i.id,A);e===`export`?S(a.result):s()}catch(t){O(t instanceof Error?t.message:`Subtree transfer failed`),e===`import`&&s()}finally{E(!1)}},P=()=>{if(!x)return;let e=URL.createObjectURL(new Blob([JSON.stringify(x)],{type:`application/json`})),t=document.createElement(`a`);t.href=e,t.download=`${(x.nodes[0].name===`/`?x.source.tree.name:x.nodes[0].name).replace(/[^\p{L}\p{N}._-]/gu,`_`)}.canvas-subtree.json`,t.click(),setTimeout(()=>URL.revokeObjectURL(e),1e3)},F=(0,m.useMemo)(()=>x?new Set(x.nodes.flatMap(e=>e.documentIds)).size:0,[x]);return(0,b.jsx)(p,{open:!0,onOpenChange:e=>{!e&&!T&&c()},children:(0,b.jsxs)(d,{children:[(0,b.jsxs)(f,{children:[(0,b.jsx)(u,{children:e===`export`?`Export subtree`:`Import subtree`}),(0,b.jsxs)(l,{children:[e===`export`?`${n}:${r}`:`Destination: ${n}:${r}`,`. Includes document records, folder structure, and relationships. Physical files are copied separately.`]})]}),e===`export`&&!x&&(0,b.jsxs)(`label`,{className:`grid gap-2 text-sm`,children:[`Include`,(0,b.jsxs)(`select`,{disabled:T||k?.status===`running`,value:h,onChange:e=>g(e.target.value),className:`rounded-md border bg-background p-2`,children:[(0,b.jsx)(`option`,{value:`related`,children:`Subtree + attachments and contacts`}),(0,b.jsx)(`option`,{value:`none`,children:`Subtree only`})]}),(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Supporting records keep their relationships. Their other folders, unrelated messages, and reply chains are excluded.`})]}),e===`import`&&!j&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(o,{type:`file`,accept:`.json,application/json`,disabled:T||k?.status===`running`,"aria-label":`Subtree export file`,onChange:e=>void M(e.target.files?.[0])}),x&&(0,b.jsxs)(`label`,{className:`grid gap-2 text-sm`,children:[`Folder name`,(0,b.jsx)(o,{value:C,disabled:T||k?.status===`running`,onChange:e=>w(e.target.value)})]}),x?.source.tree.type===`context`&&(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Existing context layers are reused by name. Documents are added to their shared membership; existing documents, layer settings, and saved views are kept.`})]}),x&&(0,b.jsxs)(`p`,{className:`text-sm`,children:[x.nodes.length,` folders, `,F,` subtree documents, and `,x.documents.length-F,` supporting records.`,x.summary?.externalRelations>0&&` ${x.summary.externalRelations} references point outside this export.`]}),!!x?.skippedDocuments?.length&&(0,b.jsxs)(`div`,{role:`status`,className:`space-y-2 rounded-md border p-3 text-sm`,children:[(0,b.jsxs)(`p`,{children:[x.skippedDocuments.length,` missing document`,x.skippedDocuments.length===1?` was`:`s were`,` skipped during export. Available records and folders are included.`]}),(0,b.jsx)(`ul`,{className:`max-h-32 overflow-y-auto text-xs`,children:x.skippedDocuments.map(n=>(0,b.jsxs)(`li`,{children:[e===`export`?(0,b.jsxs)(`a`,{className:`underline`,target:`_blank`,rel:`noopener noreferrer`,href:`/workspaces/${encodeURIComponent(t)}/documents/by-id/${n.id}`,children:[`Document `,n.id]}):`Source document ${n.id}`,`: `,n.reason===`not-found`?`record not found`:n.reason]},n.id))})]}),T&&(0,b.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 text-sm`,children:[(0,b.jsx)(i,{className:`h-4 w-4 animate-spin`}),(0,b.jsx)(`span`,{children:k?`${k.phase.charAt(0).toUpperCase()}${k.phase.slice(1)}${k.total?`: ${k.received} / ${k.total}`:`…`}`:`Starting…`})]}),j&&(0,b.jsxs)(`div`,{role:`status`,className:`space-y-2 text-sm`,children:[(0,b.jsxs)(`p`,{children:[`Imported `,j.documents,` documents into `,j.path,`. Reused `,j.reused,` matching records.`]}),!!j.reusedLayers&&(0,b.jsxs)(`p`,{children:[`Merged into `,j.reusedLayers,` existing layers, keeping their settings and documents.`]}),(0,b.jsx)(`p`,{children:`Copy the files into the destination backend and run its sync. Matching checksums reconnect the imported file records.`}),j.unresolvedRelations>0&&(0,b.jsxs)(`p`,{children:[j.unresolvedRelations,` external references were kept as migration metadata because their target records are not present.`]})]}),D&&(0,b.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:D}),(0,b.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,b.jsx)(a,{variant:`outline`,disabled:T,onClick:c,children:`Close`}),e===`export`&&x?(0,b.jsx)(a,{onClick:P,children:`Download export`}):!j&&(0,b.jsx)(a,{disabled:T||e===`import`&&(!x||!C.trim()||C.includes(`/`)),onClick:()=>void N(),children:D?`Retry`:e===`export`?`Create export`:`Import subtree`})]})]})})}export{x as showSubtreeTransfer};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{vt as r}from"./react-BHzhHVTZ.js";import{kt as i}from"./ui-DEgHnkQu.js";import{t as a}from"./button--VYZekMF.js";import{t as o}from"./input-BOtCd4HP.js";import{c as s,t as c}from"./api-CA6WiiYM.js";import{a as l,c as u,i as d,s as f,t as p}from"./alert-dialog-BKtaX1_a.js";var m=e(n(),1),h=r(),g=(e,t)=>`${s.workspaces}/${encodeURIComponent(e)}/trees/${encodeURIComponent(t)}/subtree`;function _(e,t,n,r){return c.post(`${g(e,t)}/export`,{path:n,dependencies:r})}function v(e,t,n,r,i){return c.post(`${g(e,t)}/import`,{parentPath:n,name:r,archive:i})}async function y(e,t,n,r){for(;;){let i=await c.get(`${g(e,t)}/jobs/${encodeURIComponent(n)}`,{cache:`no-store`});if(r(i),i.status===`failed`)throw Error(i.error?.message||`Subtree transfer failed`);if(i.status===`done`)return i;await new Promise(e=>setTimeout(e,750))}}var b=t();function x(e){let t=document.createElement(`div`);document.body.appendChild(t);let n=(0,h.createRoot)(t),r=()=>{n.unmount(),t.remove()};n.render((0,b.jsx)(S,{...e,onClose:r}))}function S({mode:e,workspaceId:t,treeName:n,path:r,onImported:s,onClose:c}){let[h,g]=(0,m.useState)(`related`),[x,S]=(0,m.useState)(null),[C,w]=(0,m.useState)(``),[T,E]=(0,m.useState)(!1),[D,O]=(0,m.useState)(``),[k,A]=(0,m.useState)(null),j=k?.status===`done`&&e===`import`?k.result:null,M=async e=>{if(e){E(!0),O(``),S(null),A(null);try{if(e.size>125829120)throw Error(`This export exceeds the 120 MB upload limit.`);let t=JSON.parse(await e.text());if(t.format!==`canvas-subtree`||t.version!==1||!Array.isArray(t.nodes)||!t.nodes[0]||!Array.isArray(t.documents))throw Error(`Choose a Canvas subtree export file.`);S(t),w(t.nodes[0].name===`/`?t.source.tree.name:t.nodes[0].name)}catch(e){O(e instanceof Error?e.message:`Could not read export`)}finally{E(!1)}}},N=async()=>{E(!0),O(``);try{let i=k?.status===`running`?k:e===`export`?await _(t,n,r,h):await v(t,n,r,C,x);A(i);let a=await y(t,n,i.id,A);e===`export`?S(a.result):s()}catch(t){O(t instanceof Error?t.message:`Subtree transfer failed`),e===`import`&&s()}finally{E(!1)}},P=()=>{if(!x)return;let e=URL.createObjectURL(new Blob([JSON.stringify(x)],{type:`application/json`})),t=document.createElement(`a`);t.href=e,t.download=`${(x.nodes[0].name===`/`?x.source.tree.name:x.nodes[0].name).replace(/[^\p{L}\p{N}._-]/gu,`_`)}.canvas-subtree.json`,t.click(),setTimeout(()=>URL.revokeObjectURL(e),1e3)},F=(0,m.useMemo)(()=>x?new Set(x.nodes.flatMap(e=>e.documentIds)).size:0,[x]);return(0,b.jsx)(p,{open:!0,onOpenChange:e=>{!e&&!T&&c()},children:(0,b.jsxs)(d,{children:[(0,b.jsxs)(f,{children:[(0,b.jsx)(u,{children:e===`export`?`Export subtree`:`Import subtree`}),(0,b.jsxs)(l,{children:[e===`export`?`${n}:${r}`:`Destination: ${n}:${r}`,`. Includes document records, folder structure, and relationships. Physical files are copied separately.`]})]}),e===`export`&&!x&&(0,b.jsxs)(`label`,{className:`grid gap-2 text-sm`,children:[`Include`,(0,b.jsxs)(`select`,{disabled:T||k?.status===`running`,value:h,onChange:e=>g(e.target.value),className:`rounded-md border bg-background p-2`,children:[(0,b.jsx)(`option`,{value:`related`,children:`Subtree + attachments and contacts`}),(0,b.jsx)(`option`,{value:`none`,children:`Subtree only`})]}),(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Supporting records keep their relationships. Their other folders, unrelated messages, and reply chains are excluded.`})]}),e===`import`&&!j&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(o,{type:`file`,accept:`.json,application/json`,disabled:T||k?.status===`running`,"aria-label":`Subtree export file`,onChange:e=>void M(e.target.files?.[0])}),x&&(0,b.jsxs)(`label`,{className:`grid gap-2 text-sm`,children:[`Folder name`,(0,b.jsx)(o,{value:C,disabled:T||k?.status===`running`,onChange:e=>w(e.target.value)})]}),x?.source.tree.type===`context`&&(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Existing context layers are reused by name. Documents are added to their shared membership; existing documents, layer settings, and saved views are kept.`})]}),x&&(0,b.jsxs)(`p`,{className:`text-sm`,children:[x.nodes.length,` folders, `,F,` subtree documents, and `,x.documents.length-F,` supporting records.`,x.summary?.externalRelations>0&&` ${x.summary.externalRelations} references point outside this export.`]}),!!x?.skippedDocuments?.length&&(0,b.jsxs)(`div`,{role:`status`,className:`space-y-2 rounded-md border p-3 text-sm`,children:[(0,b.jsxs)(`p`,{children:[x.skippedDocuments.length,` missing document`,x.skippedDocuments.length===1?` was`:`s were`,` skipped during export. Available records and folders are included.`]}),(0,b.jsx)(`ul`,{className:`max-h-32 overflow-y-auto text-xs`,children:x.skippedDocuments.map(n=>(0,b.jsxs)(`li`,{children:[e===`export`?(0,b.jsxs)(`a`,{className:`underline`,target:`_blank`,rel:`noopener noreferrer`,href:`/workspaces/${encodeURIComponent(t)}/documents/by-id/${n.id}`,children:[`Document `,n.id]}):`Source document ${n.id}`,`: `,n.reason===`not-found`?`record not found`:n.reason]},n.id))})]}),T&&(0,b.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 text-sm`,children:[(0,b.jsx)(i,{className:`h-4 w-4 animate-spin`}),(0,b.jsx)(`span`,{children:k?`${k.phase.charAt(0).toUpperCase()}${k.phase.slice(1)}${k.total?`: ${k.received} / ${k.total}`:`…`}`:`Starting…`})]}),j&&(0,b.jsxs)(`div`,{role:`status`,className:`space-y-2 text-sm`,children:[(0,b.jsxs)(`p`,{children:[`Imported `,j.documents,` documents into `,j.path,`. Reused `,j.reused,` matching records.`]}),!!j.reusedLayers&&(0,b.jsxs)(`p`,{children:[`Merged into `,j.reusedLayers,` existing layers, keeping their settings and documents.`]}),(0,b.jsx)(`p`,{children:`Copy the files into the destination backend and run its sync. Matching checksums reconnect the imported file records.`}),j.unresolvedRelations>0&&(0,b.jsxs)(`p`,{children:[j.unresolvedRelations,` external references were kept as migration metadata because their target records are not present.`]})]}),D&&(0,b.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:D}),(0,b.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,b.jsx)(a,{variant:`outline`,disabled:T,onClick:c,children:`Close`}),e===`export`&&x?(0,b.jsx)(a,{onClick:P,children:`Download export`}):!j&&(0,b.jsx)(a,{disabled:T||e===`import`&&(!x||!C.trim()||C.includes(`/`)),onClick:()=>void N(),children:D?`Retry`:e===`export`?`Create export`:`Import subtree`})]})]})})}export{x as showSubtreeTransfer};
@@ -1,2 +1,2 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{u as t}from"./code-editor-BOIngd5F.js";import{Bn as n,et as r,hn as i,kn as a}from"./workspace-C5V-ZCOE.js";import{r as o}from"./public-share-CXR25Q1X.js";import{i as s,o as c}from"./blobs-WiXP9QRi.js";var l=e(t(),1),u=e=>({blobUrl:null,blob:null,text:null,mime:null,error:null,loading:e});function d(e,t,{url:n,mode:r=`blob`,enabled:i=!0,maxTextLength:a=2e5,typeHint:s,version:c=null}={}){let{isPublic:d,fetchBlob:f}=o(e),p=`${d?`pub`:`ws`}:${e}:${t}:${n??``}:${r}:${i}:${s??``}:${c??``}`,[m,h]=(0,l.useState)(u(i)),[g,_]=(0,l.useState)(p);return p!==g&&(_(p),h(u(i))),(0,l.useEffect)(()=>{if(!i)return;let e=!1,o=null;return f(t,{...n?{url:n}:{},...c?{version:c}:{}}).then(async({blob:t,mime:n})=>{if(!e){if(r===`text`){let r=await t.text();e||h({blobUrl:null,blob:null,text:r.slice(0,a),mime:n,error:null,loading:!1})}else{let r=s&&(!t.type||t.type===`application/octet-stream`),i=r?t.slice(0,t.size,s):t;if(o=URL.createObjectURL(i),e){URL.revokeObjectURL(o),o=null;return}h({blobUrl:o,blob:i,text:null,mime:r?s:n,error:null,loading:!1})}}}).catch(t=>{e||h({blobUrl:null,blob:null,text:null,mime:null,error:String(t instanceof Error?t.message:t),loading:!1})}),()=>{e=!0,o&&URL.revokeObjectURL(o)}},[p]),m}function f(e,t,{url:n,enabled:r=!0}={}){let{isPublic:i,streamUrl:a,mintTicket:s}=o(e),c=`${i?`pub`:`ws`}:${e}:${t}:${n||``}:${r}`,[u,d]=(0,l.useState)({src:null,error:null,loading:!0}),[f,p]=(0,l.useState)(c);return c!==f&&(p(c),d({src:null,error:null,loading:!0})),(0,l.useEffect)(()=>{if(!r)return;let e=!1;return s(t).then(r=>{e||d(r?{src:a(t,{url:n}),error:null,loading:!1}:{src:null,error:`Could not authorize stream`,loading:!1})}).catch(t=>{e||d({src:null,error:t instanceof Error?t.message:String(t),loading:!1})}),()=>{e=!0}},[c]),u}var p=1e6;function m(e){if(e.schema===`data/schema/note`)return`markdown`;if(e.schema!==`data/schema/file`)return null;let t=n(String(e.metadata?.contentType??``),a(e));return t===`markdown`?`markdown`:t===`text`||t===`html`?`text`:null}function h(e){return e.schema===`data/schema/file`&&m(e)!=null}function g(e){let t=Number(e.metadata?.size??0);return Number.isFinite(t)&&t>1e6}var _=`workspace:data`;function v(e){for(let t of e.locations||[]){let e=/^stored:\/\/([^/]+)\/(.+)$/.exec(String(t?.url||``));if(!(!e||e[1]===_))return{backend:e[1],key:e[2]}}return null}async function y(e,t,n,o={}){let l=a(t)||`document-${t.id}.txt`,u=String(t.metadata?.contentType??``)||(m(t)===`markdown`?`text/markdown`:`text/plain`),d=n.endsWith(`
2
- `)?n:`${n}\n`,f=new Blob([d],{type:u}),p=v(t);if(p){let n=String(t.checksumArray?.[0]??``).replace(/^sha256\//,``),a=await c(e,{driver:`file`,address:p.backend,key:p.key},f,{ifMatch:n||void 0,contentType:u});return(o.comment!==void 0&&o.comment!==(t.comment??``)||o.metadata!==void 0)&&await i(e,{id:a.docId??t.id,schema:t.schema,schemaVersion:t.schemaVersion,...o.comment===void 0?{}:{comment:o.comment},...o.metadata===void 0?{}:{metadata:o.metadata}}),r(e,a.docId??t.id)}let h=await s(e,f);return await i(e,{id:t.id,schema:t.schema,schemaVersion:t.schemaVersion,...o.comment===void 0?{}:{comment:o.comment},checksumArray:[`sha256/${h.checksum}`],locations:[{url:h.url,metadata:{filename:l}}],metadata:{contentType:u,size:h.size,...o.metadata??{}}}),r(e,t.id)}export{g as a,h as i,p as n,d as o,m as r,f as s,y as t};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{u as t}from"./code-editor-BOIngd5F.js";import{An as n,Vn as r,et as i,hn as a}from"./workspace-4hWrSEku.js";import{r as o}from"./public-share-0DqS7L2Q.js";import{i as s,o as c}from"./blobs-WiXP9QRi.js";var l=e(t(),1),u=e=>({blobUrl:null,blob:null,text:null,mime:null,error:null,loading:e});function d(e,t,{url:n,mode:r=`blob`,enabled:i=!0,maxTextLength:a=2e5,typeHint:s,version:c=null}={}){let{isPublic:d,fetchBlob:f}=o(e),p=`${d?`pub`:`ws`}:${e}:${t}:${n??``}:${r}:${i}:${s??``}:${c??``}`,[m,h]=(0,l.useState)(u(i)),[g,_]=(0,l.useState)(p);return p!==g&&(_(p),h(u(i))),(0,l.useEffect)(()=>{if(!i)return;let e=!1,o=null;return f(t,{...n?{url:n}:{},...c?{version:c}:{}}).then(async({blob:t,mime:n})=>{if(!e){if(r===`text`){let r=await t.text();e||h({blobUrl:null,blob:null,text:r.slice(0,a),mime:n,error:null,loading:!1})}else{let r=s&&(!t.type||t.type===`application/octet-stream`),i=r?t.slice(0,t.size,s):t;if(o=URL.createObjectURL(i),e){URL.revokeObjectURL(o),o=null;return}h({blobUrl:o,blob:i,text:null,mime:r?s:n,error:null,loading:!1})}}}).catch(t=>{e||h({blobUrl:null,blob:null,text:null,mime:null,error:String(t instanceof Error?t.message:t),loading:!1})}),()=>{e=!0,o&&URL.revokeObjectURL(o)}},[p]),m}function f(e,t,{url:n,enabled:r=!0}={}){let{isPublic:i,streamUrl:a,mintTicket:s}=o(e),c=`${i?`pub`:`ws`}:${e}:${t}:${n||``}:${r}`,[u,d]=(0,l.useState)({src:null,error:null,loading:!0}),[f,p]=(0,l.useState)(c);return c!==f&&(p(c),d({src:null,error:null,loading:!0})),(0,l.useEffect)(()=>{if(!r)return;let e=!1;return s(t).then(r=>{e||d(r?{src:a(t,{url:n}),error:null,loading:!1}:{src:null,error:`Could not authorize stream`,loading:!1})}).catch(t=>{e||d({src:null,error:t instanceof Error?t.message:String(t),loading:!1})}),()=>{e=!0}},[c]),u}var p=1e6;function m(e){if(e.schema===`data/schema/note`)return`markdown`;if(e.schema!==`data/schema/file`)return null;let t=r(String(e.metadata?.contentType??``),n(e));return t===`markdown`?`markdown`:t===`text`||t===`html`?`text`:null}function h(e){return e.schema===`data/schema/file`&&m(e)!=null}function g(e){let t=Number(e.metadata?.size??0);return Number.isFinite(t)&&t>1e6}var _=`workspace:data`;function v(e){for(let t of e.locations||[]){let e=/^stored:\/\/([^/]+)\/(.+)$/.exec(String(t?.url||``));if(!(!e||e[1]===_))return{backend:e[1],key:e[2]}}return null}async function y(e,t,r,o={}){let l=n(t)||`document-${t.id}.txt`,u=String(t.metadata?.contentType??``)||(m(t)===`markdown`?`text/markdown`:`text/plain`),d=r.endsWith(`
2
+ `)?r:`${r}\n`,f=new Blob([d],{type:u}),p=v(t);if(p){let n=String(t.checksumArray?.[0]??``).replace(/^sha256\//,``),r=await c(e,{driver:`file`,address:p.backend,key:p.key},f,{ifMatch:n||void 0,contentType:u});return(o.comment!==void 0&&o.comment!==(t.comment??``)||o.metadata!==void 0)&&await a(e,{id:r.docId??t.id,schema:t.schema,schemaVersion:t.schemaVersion,...o.comment===void 0?{}:{comment:o.comment},...o.metadata===void 0?{}:{metadata:o.metadata}}),i(e,r.docId??t.id)}let h=await s(e,f);return await a(e,{id:t.id,schema:t.schema,schemaVersion:t.schemaVersion,...o.comment===void 0?{}:{comment:o.comment},checksumArray:[`sha256/${h.checksum}`],locations:[{url:h.url,metadata:{filename:l}}],metadata:{contentType:u,size:h.size,...o.metadata??{}}}),i(e,t.id)}export{g as a,h as i,p as n,d as o,m as r,f as s,y as t};
@@ -0,0 +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};