@augmentd-labs/canvas-web 2.26.19 → 2.26.21

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 (155) hide show
  1. package/dist/assets/DocumentBodyEditor-CE2S2X6g.js +1 -0
  2. package/dist/assets/DocumentIcon-BS10SIP6.js +1 -0
  3. package/dist/assets/EditorOverlay-BUToR_av.js +1 -0
  4. package/dist/assets/FileForm-BxTixeDm.js +1 -0
  5. package/dist/assets/FiltersApplet-DNYAQP5F.js +1 -0
  6. package/dist/assets/HomeFab-CpTZdNyY.js +3 -0
  7. package/dist/assets/IdentityFields-C2MPM-Ab.js +1 -0
  8. package/dist/assets/LensApplet-CRa1j2WP.js +1 -0
  9. package/dist/assets/LinkToCard-BZwwE-Dv.js +1 -0
  10. package/dist/assets/LinkToSidePanel-eCy3nW4R.js +1 -0
  11. package/dist/assets/{LocationTab-BONJQfYM.js → LocationTab-DAtqAQ3l.js} +1 -1
  12. package/dist/assets/{MarkdownEditor-CkobBLtI.js → MarkdownEditor-7OqSDr7E.js} +1 -1
  13. package/dist/assets/MessageComposerDialog-DzLhkHyh.js +4 -0
  14. package/dist/assets/{NextShell-Byg6OtC2.js → NextShell-D9gvlKY2.js} +1 -1
  15. package/dist/assets/NotesApplet-CFK86JYj.js +1 -0
  16. package/dist/assets/ObjectPropertiesCard-C3jt40tM.css +1 -0
  17. package/dist/assets/ObjectPropertiesCard-DDcRLpsW.js +8 -0
  18. package/dist/assets/PathPickerField-cVs5sZuG.js +1 -0
  19. package/dist/assets/PickDocumentsCard-BlicxMqC.js +1 -0
  20. package/dist/assets/SketchApplet-D8mkYmK9.js +1 -0
  21. package/dist/assets/{SketchEditor-C9_lu3Ot.js → SketchEditor-zMrm1npg.js} +4 -4
  22. package/dist/assets/TerminalApplet-BO2HRp0z.js +20 -0
  23. package/dist/assets/TerminalApplet-BrP-ENHg.css +1 -0
  24. package/dist/assets/TextDocumentEditor-7V4aFL8i.js +1 -0
  25. package/dist/assets/TodosApplet-swdaBT-2.js +1 -0
  26. package/dist/assets/TodosWidget-BXF8fYer.js +1 -0
  27. package/dist/assets/UploadProgressList-B2xCVzFR.js +1 -0
  28. package/dist/assets/_agentId_-CHdTYJFu.js +0 -0
  29. package/dist/assets/_contextId_-m9zn5qav.js +1 -0
  30. package/dist/assets/_workspaceName_-D0z9E9Uy.js +1 -0
  31. package/dist/assets/about-pl0DXTEt.js +1 -0
  32. package/dist/assets/add-B30V-yHb.js +1 -0
  33. package/dist/assets/admin-Bhg9QBHL.js +5 -0
  34. package/dist/assets/agents-Bc7_wscP.js +1 -0
  35. package/dist/assets/agents-ClK3Y2x0.js +1 -0
  36. package/dist/assets/alert-dialog-DIA-tAP5.js +1 -0
  37. package/dist/assets/api-CA6WiiYM.js +1 -0
  38. package/dist/assets/api-tokens-O5iFESo0.js +1 -0
  39. package/dist/assets/appearance-DLo_2WH0.js +1 -0
  40. package/dist/assets/applet-target-DnTa2VAT.js +1 -0
  41. package/dist/assets/apps-DzFFo5D0.js +1 -0
  42. package/dist/assets/auth-Bx9fAZmz.js +1 -0
  43. package/dist/assets/auth-CUdpxbLV.js +1 -0
  44. package/dist/assets/backend-sync-progress-DU-e9TWi.css +1 -0
  45. package/dist/assets/backend-sync-progress-DWR42uQV.js +7 -0
  46. package/dist/assets/blobs-WiXP9QRi.js +1 -0
  47. package/dist/assets/button-Bv4zA1qr.js +1 -0
  48. package/dist/assets/chunk-62JRHF6Z-vspAGgtK.js +3 -0
  49. package/dist/assets/{chunk-K2UTITRG-zQFDOW3Q.js → chunk-K2UTITRG-BvHe9UPk.js} +3 -3
  50. package/dist/assets/code-editor-BOIngd5F.js +40 -0
  51. package/dist/assets/color-DFEH4BfK.js +1 -0
  52. package/dist/assets/content-app-view-BUi8HG1r.js +1 -0
  53. package/dist/assets/context-D_K4g9SQ.js +1 -0
  54. package/dist/assets/contexts-B6d6Axza.js +1 -0
  55. package/dist/assets/contexts-CgydYDn-2.js +1 -0
  56. package/dist/assets/date-time-picker-BZaA3M9_.js +1 -0
  57. package/dist/assets/desk-dI_FvLsK.js +1 -0
  58. package/dist/assets/devices-CAa1bRxk.js +1 -0
  59. package/dist/assets/devices-D3-_UWM0.js +1 -0
  60. package/dist/assets/document-BG_mODBn.js +1 -0
  61. package/dist/assets/document-list-BiogH4tf.js +2 -0
  62. package/dist/assets/document-list-DAYdk5vh.css +1 -0
  63. package/dist/assets/document-open-mode-DoImW-xs.js +1 -0
  64. package/dist/assets/embedding-Cjrxh6MN.js +1 -0
  65. package/dist/assets/embedding-m8SZH4oN.js +1 -0
  66. package/dist/assets/form-panel-Dz96K7Lv.js +1 -0
  67. package/dist/assets/geo-CZfs0E-x.js +1 -0
  68. package/dist/assets/home-C5IxNq_5.js +1 -0
  69. package/dist/assets/image-GAAHSSAO-CI-0hUck.js +1 -0
  70. package/dist/assets/index-D7EoeBID.css +2 -0
  71. package/dist/assets/index-DtZS4JJ4.js +16 -0
  72. package/dist/assets/inferd-config-editor-DagMmwW4.js +1 -0
  73. package/dist/assets/input-BOtCd4HP.js +1 -0
  74. package/dist/assets/key-bindings-DomR6ZNC.js +1 -0
  75. package/dist/assets/label-CNoJOoe0.js +1 -0
  76. package/dist/assets/last-path-BbXWC3b3.js +1 -0
  77. package/dist/assets/layer-style-Byl5LNFR.js +1 -0
  78. package/dist/assets/lazy-editor-Cbva8Pe2.js +2 -0
  79. package/dist/assets/logs-CdbfY8_H.js +1 -0
  80. package/dist/assets/{markdown-html-XoABNf32.js → markdown-html-CZMGihx6.js} +1 -1
  81. package/dist/assets/markdown-view-BBBZtNSR.js +2 -0
  82. package/dist/assets/note-save-status-DPz4VzL6.js +1 -0
  83. package/dist/assets/offline-BjMpUv3N.js +1 -0
  84. package/dist/assets/page-header-GtTr9Ff_.js +1 -0
  85. package/dist/assets/public-share-DT9Tgn_Y.js +1 -0
  86. package/dist/assets/query-debug-tVbB_8Z6.js +1 -0
  87. package/dist/assets/react-BHzhHVTZ.js +164 -0
  88. package/dist/assets/registry-BgnkvPjl.js +2 -0
  89. package/dist/assets/relation-events-CKio19hE.js +1 -0
  90. package/dist/assets/remotes-DR_iJClb.js +1 -0
  91. package/dist/assets/role-C5I0Plgn.js +1 -0
  92. package/dist/assets/roles-DERIgujv.js +2 -0
  93. package/dist/assets/roles-DswT1Lv0.js +2 -0
  94. package/dist/assets/settings-B4LC1yCH.js +1 -0
  95. package/dist/assets/settings-BXOyceZ3.js +1 -0
  96. package/dist/assets/settings-CUzf6xEQ.js +14 -0
  97. package/dist/assets/settings-DhoHM9AU.js +1 -0
  98. package/dist/assets/share-target-CpjVaYVl.js +1 -0
  99. package/dist/assets/shared-1dpCuibu.js +1 -0
  100. package/dist/assets/shared-B824Ibpc.js +1 -0
  101. package/dist/assets/sketch-lazy-Q58-vPF-.js +2 -0
  102. package/dist/assets/socket-CtH3EU9m.js +1 -0
  103. package/dist/assets/subtree-transfer-dialog-B7s4r78T.js +1 -0
  104. package/dist/assets/tags-YamdPoBK.js +1 -0
  105. package/dist/assets/text-documents-D_zDMyhB.js +2 -0
  106. package/dist/assets/{ui-BqHBdBU4.js → ui-BSqPn1LJ.js} +2 -2
  107. package/dist/assets/url-params-n7kU_WZ-.js +1 -0
  108. package/dist/assets/use-applet-docs-Cry2SFsG.js +1 -0
  109. package/dist/assets/use-applet-target-mkjQujx6.js +1 -0
  110. package/dist/assets/use-canvas-pins-C57Vbkrq.css +1 -0
  111. package/dist/assets/use-canvas-pins-CZBfEB5E.js +3 -0
  112. package/dist/assets/use-create-panel-DhSNIGtr.js +1 -0
  113. package/dist/assets/use-document-modal-PG8bQyIB.js +1 -0
  114. package/dist/assets/use-menu-BVkqNEIx.js +1 -0
  115. package/dist/assets/use-mobile-Db-vWu9Y.js +1 -0
  116. package/dist/assets/use-settings-back-Dk-DJEUO.js +1 -0
  117. package/dist/assets/use-sortable-data-DYIDDI8c.js +1 -0
  118. package/dist/assets/{use-theme-Bd8sb5Ox.js → use-theme-DaxpiICf.js} +1 -1
  119. package/dist/assets/use-toast-BlLDqSUO.js +1 -0
  120. package/dist/assets/use-toolbox-Ck_cLGgf.js +1 -0
  121. package/dist/assets/use-workspace-identity-BVpGHkZq.js +1 -0
  122. package/dist/assets/useAddTarget-CVRPElxz.js +1 -0
  123. package/dist/assets/useAgentModels-ndLotMWH.js +3 -0
  124. package/dist/assets/useDocumentThumbnail-C_rq2rXs.js +1 -0
  125. package/dist/assets/useEditNoteFields-Bigs9ZG8.js +1 -0
  126. package/dist/assets/useEscapeClose-DR_xKT_k.js +1 -0
  127. package/dist/assets/useSocketSubscription-ifW-vnlb.js +1 -0
  128. package/dist/assets/useToastHelpers-CRrpIIdY.js +1 -0
  129. package/dist/assets/users-C9N-O1QA.js +1 -0
  130. package/dist/assets/workspace-BydSRtST.js +1 -0
  131. package/dist/assets/workspace-CJ1PWQ29.js +1 -0
  132. package/dist/assets/workspace-access-C9nZlBBZ.js +1 -0
  133. package/dist/assets/workspace-area-menu-Ba_9bGKs.js +1 -0
  134. package/dist/assets/workspace-content-gate-D8bzGD9i.js +1 -0
  135. package/dist/assets/workspace-import-form-D5JA8gzx.js +1 -0
  136. package/dist/assets/workspaces-BBgdfAM_.js +1 -0
  137. package/dist/assets/workspaces-Dx5_N57M.js +1 -0
  138. package/dist/index.html +69 -14
  139. package/dist/sw.js +1 -1
  140. package/package.json +2 -2
  141. package/dist/assets/EditorOverlay-B384ALjA.js +0 -1
  142. package/dist/assets/TextDocumentEditor-DBVWuJaR.js +0 -1
  143. package/dist/assets/alert-dialog-BC58hyW-.js +0 -1
  144. package/dist/assets/blobs-CtDkR2hC.js +0 -1
  145. package/dist/assets/code-editor-BQnKd3jw.js +0 -40
  146. package/dist/assets/document-list-BmUv3zzK.js +0 -19
  147. package/dist/assets/document-list-r-TfV16D.css +0 -1
  148. package/dist/assets/image-GAAHSSAO-BoD-NvEF.js +0 -1
  149. package/dist/assets/index-BhcdilCi.css +0 -2
  150. package/dist/assets/index-DRji5GQn.js +0 -61
  151. package/dist/assets/react-BzqgEMSQ.js +0 -164
  152. package/dist/assets/subtree-transfer-dialog-DRz8kLqY.js +0 -1
  153. package/dist/assets/text-documents-BvR9-zf4.js +0 -3
  154. package/dist/assets/useAddTarget-CgZfKokT.js +0 -1
  155. package/dist/assets/workspace-BSXnX2Me.js +0 -1
@@ -0,0 +1 @@
1
+ import{l as e}from"./code-editor-BOIngd5F.js";import{t}from"./utils-2pl1SbIp.js";import{t as n}from"./lazy-editor-Cbva8Pe2.js";var r=e();function i({kind:e,value:i,onChange:a,placeholder:o,rows:s=16,fill:c=!1}){return e===`markdown`?(0,r.jsx)(n,{value:i,onChange:a,placeholder:o,fill:c}):(0,r.jsx)(`textarea`,{value:i,onChange:e=>a(e.target.value),rows:c?void 0:s,placeholder:o,spellCheck:!1,className:t(`flex w-full rounded-md border border-input bg-transparent px-3 py-2 font-mono text-xs leading-relaxed shadow-elevation-1 transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,c&&`h-full min-h-0 resize-none`)})}export{i 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{An as r,Gt as i,Jt as a,Qt as o,U as s,Vn as c,Wt as l,cr as u,gt as d,ir as f,lr as p,nr as m,on as h,ot as g,rr as _,tt as v}from"./ui-BSqPn1LJ.js";import{t as y}from"./utils-2pl1SbIp.js";var b=e(n(),1),x=[{color:`text-data-1`,chip:`bg-data-1/15`},{color:`text-data-2`,chip:`bg-data-2/15`},{color:`text-data-3`,chip:`bg-data-3/15`},{color:`text-data-4`,chip:`bg-data-4/15`},{color:`text-data-5`,chip:`bg-data-5/15`},{color:`text-data-6`,chip:`bg-data-6/15`},{color:`text-data-7`,chip:`bg-data-7/15`},{color:`text-data-8`,chip:`bg-data-8/15`},{color:`text-data-9`,chip:`bg-data-9/15`},{color:`text-data-10`,chip:`bg-data-10/15`},{color:`text-data-11`,chip:`bg-data-11/15`},{color:`text-data-12`,chip:`bg-data-12/15`}];function S(e,t){return{Icon:e,...x[t-1]}}var C={tab:S(c,7),link:S(c,7),email:S(h,3),note:S(v,3),task:S(g,5),message:S(o,6),identity:S(s,2),contact:S(s,2),device:S(a,10),application:S(l,11),dotfile:S(d,4),document:S(f,9)},w=[{test:/^image\//,spec:S(r,5)},{test:/^video\//,spec:S(m,11)},{test:/^audio\//,spec:S(i,10)},{test:/pdf$/,spec:S(f,1)},{test:/zip|tar|gzip|7z|rar|compressed/,spec:S(p,12)},{test:/json|javascript|typescript|xml|html|css|x-sh|python/,spec:S(u,6)},{test:/^text\//,spec:S(f,12)}],T=S(_,6),E=S(_,9);function D(e){let t=(e.schema||``).split(`/`).pop()||``;if(t===`file`){let t=String(e.metadata?.contentType||``).toLowerCase();return w.find(({test:e})=>e.test(t))?.spec||T}return C[t]||E}var O=t(),k={3.5:`h-3.5 w-3.5`,4:`h-4 w-4`,5:`h-5 w-5`,10:`h-10 w-10`};function A(e){let t=[],n=typeof e?.favIconUrl==`string`?e.favIconUrl:``;/^https?:\/\//i.test(n)&&t.push(n);let r=typeof e?.url==`string`?e.url:``;try{let e=new URL(r).origin;if(/^https?:/i.test(e)){let n=`${e}/favicon.ico`;t.includes(n)||t.push(n)}}catch{}return t}function j({document:e,size:t=4,chip:n=!1,className:r}){let i=D(e),a=e.schema===`data/schema/tab`?A(e.data):[],[o,s]=(0,b.useState)(0),c=a[o]??null,l=c?(0,O.jsx)(`img`,{src:c,alt:``,loading:`lazy`,onError:()=>s(e=>e+1),className:y(k[t],`rounded-xs object-contain`,!n&&`shrink-0`,!n&&r)}):(0,O.jsx)(i.Icon,{className:y(k[t],i.color,!n&&`shrink-0`,!n&&r)});return n?(0,O.jsx)(`span`,{className:y(`inline-flex shrink-0 items-center justify-center rounded-md`,t>=10?`p-3`:`p-1`,i.chip,r),children:l}):l}export{j 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{yt as r}from"./react-BHzhHVTZ.js";import{Dn as i,Xt as a,rn as o,ui as s}from"./ui-BSqPn1LJ.js";import{t as c}from"./utils-2pl1SbIp.js";import{t as l}from"./button-Bv4zA1qr.js";var u=e(n(),1),d=e(r(),1),f=t();function p({title:e,onClose:t,onDetails:n,actions:r,children:p}){let[m,h]=(0,u.useState)(!0);return(0,d.createPortal)((0,f.jsx)(`div`,{className:c(`fixed inset-0 z-fullscreen flex bg-scrim`,m?`p-0`:`p-4 md:p-10`),children:(0,f.jsxs)(`div`,{className:c(`flex min-h-0 w-full flex-col overflow-hidden bg-background surface-glass`,m?``:`rounded-lg border shadow-elevation-4`),children:[(0,f.jsxs)(`div`,{className:`flex h-12 shrink-0 items-center gap-2 border-b px-3`,children:[(0,f.jsx)(l,{variant:`ghost`,size:`sm`,onClick:t,"aria-label":`Back`,title:`Back`,children:(0,f.jsx)(s,{className:`h-4 w-4`})}),e,(0,f.jsx)(`div`,{className:`flex-1`}),n&&(0,f.jsxs)(l,{variant:`ghost`,size:`sm`,onClick:n,title:`Edit details (title, tags, comment)`,children:[(0,f.jsx)(i,{className:`mr-1.5 h-4 w-4`}),` Details`]}),(0,f.jsx)(l,{variant:`ghost`,size:`sm`,onClick:()=>h(e=>!e),title:m?`Restore`:`Maximize`,"aria-label":m?`Restore`:`Maximize`,children:m?(0,f.jsx)(a,{className:`h-4 w-4`}):(0,f.jsx)(o,{className:`h-4 w-4`})}),r]}),(0,f.jsx)(`div`,{className:`min-h-0 flex-1`,children:p})]})}),window.document.body)}export{p 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{L as r,Mt as i,Tt as a,W as o,ci as s,ui as c}from"./ui-BSqPn1LJ.js";import{t as l}from"./utils-2pl1SbIp.js";import{t as u}from"./button-Bv4zA1qr.js";import{t as d}from"./label-CNoJOoe0.js";import{g as f,t as p}from"./LinkToCard-BZwwE-Dv.js";import{Pn as m,_ as h,nt as g}from"./workspace-CJ1PWQ29.js";import{a as _,s as v,t as y}from"./useAddTarget-CVRPElxz.js";import{n as b}from"./use-toolbox-Ck_cLGgf.js";import{n as x}from"./relation-events-CKio19hE.js";import{t as S}from"./useToastHelpers-CRrpIIdY.js";import{t as C}from"./DocumentIcon-BS10SIP6.js";import{n as w}from"./LinkToSidePanel-eCy3nW4R.js";import{a as T,i as E,o as D,r as O,t as k}from"./UploadProgressList-B2xCVzFR.js";var A=e(n(),1),j=`references`;function M(e){return e?e.documents.map(e=>({predicate:j,direction:`out`,targetId:e.id,document:e})):[]}function N(e,t){let[n,r]=(0,A.useState)(()=>M(t)),i=e?.mode===`context`?e.contextId:null,[a,o]=(0,A.useState)(null);(0,A.useEffect)(()=>{if(!i)return;let e=!1;return _({mode:`context`,contextId:i}).then(t=>{e||o({contextId:i,workspaceName:t.workspaceName})}).catch(()=>{}),()=>{e=!0}},[i]);let s=e?.mode===`workspace`?e.workspaceName:i&&a?.contextId===i?a.workspaceName:t?.workspaceName??null,{predicates:c}=f(s);return{rows:n,predicates:c,workspaceName:s,add:(0,A.useCallback)(async(e,t,i)=>{let a=i.filter(r=>!n.some(n=>n.targetId===r&&n.predicate===e&&n.direction===t));if(a.length===0)return;let o=await Promise.all(a.map(e=>s?g(s,e).catch(()=>null):Promise.resolve(null)));r(n=>[...n,...a.map((n,r)=>({predicate:e,direction:t,targetId:n,document:o[r]??null}))])},[n,s]),update:(0,A.useCallback)((e,t)=>{r(n=>n.map((n,r)=>r===e?{...n,...t}:n))},[]),remove:(0,A.useCallback)(e=>{r(t=>t.filter((t,n)=>n!==e))},[]),write:(0,A.useCallback)(async e=>{if(n.length===0||e.length===0||!s)return 0;let t=new Map;for(let e of n){let n=`${e.direction}:${e.predicate}`,r=t.get(n)??{predicate:e.predicate,direction:e.direction,targets:[]};r.targets.push(e.targetId),t.set(n,r)}let r=0;for(let n of e)for(let e of t.values())try{await h(s,n,e.predicate,e.targets,e.direction)}catch(t){r+=1,console.error(`Failed to relate document`,n,e.predicate,t)}return r<e.length*t.size&&x(),r},[n,s]),hasRows:n.length>0}}var P=t();function F({f:e,idPrefix:t}){let[n,a]=(0,A.useState)(!1),[o,f]=(0,A.useState)(!1),h=!e.workspaceName;return(0,P.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,P.jsx)(d,{children:`Related documents`}),(0,P.jsxs)(u,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs`,disabled:h,onClick:()=>a(!0),title:h?`No workspace to relate within`:`Pick documents the new one relates to`,children:[(0,P.jsx)(i,{className:`mr-1 h-3 w-3`}),` Add`]})]}),e.rows.length===0?(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`None. Relations are written right after the document is created.`}):(0,P.jsx)(`ul`,{className:`space-y-1`,children:e.rows.map((n,i)=>{let a=n.document?m(n.document).title:`Document ${n.targetId}`,o=`${t}-relation-${i}`;return(0,P.jsxs)(`li`,{className:`flex items-center gap-1.5 rounded-md border border-input px-2 py-1.5 text-sm`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>e.update(i,{direction:n.direction===`out`?`in`:`out`}),className:`shrink-0 rounded p-0.5 text-muted-foreground hover:bg-accent hover:text-foreground`,title:n.direction===`out`?`The new document ${n.predicate} this one (click to flip)`:`This document ${n.predicate} the new one (click to flip)`,"aria-label":`Flip relation direction`,children:n.direction===`out`?(0,P.jsx)(s,{className:`h-3.5 w-3.5`}):(0,P.jsx)(c,{className:`h-3.5 w-3.5`})}),(0,P.jsx)(`label`,{htmlFor:o,className:`sr-only`,children:`Predicate`}),(0,P.jsx)(`select`,{id:o,value:n.predicate,onChange:t=>e.update(i,{predicate:t.target.value}),className:`w-[9.5rem] shrink-0 rounded-md border border-input bg-background px-1.5 py-1 font-mono text-[11px] focus:outline-none focus:ring-2 focus:ring-ring`,children:(e.predicates.includes(n.predicate)?e.predicates:[n.predicate,...e.predicates]).map(e=>(0,P.jsx)(`option`,{value:e,children:e},e))}),n.document?(0,P.jsx)(C,{document:n.document,size:3.5}):null,(0,P.jsx)(`span`,{className:l(`min-w-0 flex-1 truncate`,!n.document&&`italic text-muted-foreground`),title:a,children:a}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>e.remove(i),className:`shrink-0 rounded p-0.5 text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,title:`Remove`,"aria-label":`Remove relation`,children:(0,P.jsx)(r,{className:`h-3.5 w-3.5`})})]},`${n.direction}:${n.predicate}:${n.targetId}`)})}),n&&e.workspaceName&&(0,P.jsx)(w,{onClose:()=>{o||a(!1)},children:(0,P.jsx)(p,{sizeClassName:`h-full w-[380px] max-w-[90vw] max-md:w-full`,title:`Relate to…`,confirmLabel:`Add`,tabs:[`relations`],fixedWorkspaceName:e.workspaceName,documentCount:1,saving:o,relationPredicates:e.predicates,relationExcludeIds:new Set(e.rows.map(e=>e.targetId)),onClose:()=>a(!1),onConfirm:()=>{},onConfirmRelation:async({predicate:t,direction:n,targetIds:r})=>{f(!0);try{await e.add(t,n,r),a(!1)}finally{f(!1)}}})})]})}function I({capture:e=!1,target:t,initialFiles:n=[],onClose:r,onBusyChange:i}={}){let{closeAdd:s,state:c}=b(),d=v(),f=t===void 0?d:t,p=r??s,m=f?.mode===`workspace`&&f.treeName===`backends`,h=N(f,t===void 0?c.addRelateTo:null),{showSuccessToast:g,showErrorToast:x}=S(),C=(0,A.useRef)(null),[w,j]=(0,A.useState)(!1),M=O(n),{items:I,running:L}=M,R=(0,A.useRef)(!1),z=(0,A.useRef)(!1),[B,V]=(0,A.useState)(!1),[H,U]=(0,A.useState)(null);(0,A.useEffect)(()=>{if(f?.mode!==`context`)return;let e=!1;return _(f).then(t=>{e||U({contextId:f.contextId,workspaceName:t.workspaceName})}).catch(()=>{}),()=>{e=!0}},[f]);let W=f?.mode===`workspace`?f.workspaceName:f&&H?.contextId===f.contextId?H.workspaceName:null,G=D(W),K=e=>{e&&M.addFiles(Array.from(e))},q=e=>{e.preventDefault(),j(!1),K(e.dataTransfer.files)},J=I.filter(e=>e.status===`error`).length,Y=I.filter(e=>e.status===`done`).length,X=I.length-Y,Z=!!f&&!B&&X>0;return(0,P.jsxs)(`div`,{className:`flex flex-col gap-4 p-4`,children:[(0,P.jsxs)(`div`,{onDragOver:e=>{e.preventDefault(),j(!0)},onDragLeave:()=>j(!1),onDrop:q,onClick:()=>C.current?.click(),className:l(`flex cursor-pointer flex-col items-center justify-center gap-2 rounded-md border border-dashed px-4 py-8 text-center transition-colors`,w?`border-primary bg-primary/5`:`border-input hover:bg-muted/40`),children:[(0,P.jsx)(o,{className:`h-6 w-6 text-muted-foreground touch-target`}),(0,P.jsx)(`p`,{className:`text-sm`,children:e?`Take a photo or video`:`Drag & drop files here`}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e?`click to open the camera`:`or click to browse`}),(0,P.jsx)(`input`,{ref:C,type:`file`,multiple:!0,accept:e?`image/*,video/*`:void 0,capture:e?`environment`:void 0,className:`hidden`,onChange:e=>{K(e.target.files),e.target.value=``}})]}),(0,P.jsx)(k,{items:I,running:L,onRemove:M.removeItem}),!m&&(0,P.jsx)(E,{fields:G,idPrefix:`file`,multiple:I.length>1}),(0,P.jsx)(F,{f:h,idPrefix:`file`}),(0,P.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[y(f),m?`. Existing files are never overwritten.`:``]}),(0,P.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,P.jsx)(u,{variant:`outline`,size:`sm`,onClick:()=>{B?(z.current=!0,M.cancel()):p()},children:`Cancel`}),(0,P.jsx)(u,{size:`sm`,onClick:async()=>{if(!(!Z||!f||R.current)){R.current=!0,z.current=!1,V(!0),i?.(!0);try{let e=m?null:await G.geotag.capture();if(z.current)return;let t=await M.start(f,(t,n)=>T(t,n,{tags:G.tags,comment:G.comment,geo:e})),n=await h.write(t.docIds);if(t.failed===0){let e=t.resumed?` (${t.resumed} already uploaded)`:``,r=n?`; some relations failed`:``;g(`${t.done} file(s) uploaded${e}${r}`),p()}else x(`${t.failed} of ${t.total} file(s) failed — retry keeps what already made it`)}catch(e){x(e instanceof Error?e.message:`Failed to upload files`)}finally{R.current=!1,V(!1),i?.(!1)}}},disabled:!Z,children:B?`Uploading…`:J>0?(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(a,{className:`h-3.5 w-3.5`}),`Retry failed (`,J,`)`]}):`Add files`})]})]})}export{F as n,N as r,I 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{t as r}from"./socket-CtH3EU9m.js";import{r as i}from"./use-toolbox-Ck_cLGgf.js";import{n as a}from"./use-applet-target-mkjQujx6.js";import{S as o,j as s,v as c}from"./index-DtZS4JJ4.js";var l=e(n(),1),u=t();function d(){let e=a(),t=i()?.state,n=!!t&&(e?.mode===`context`?t.activeContextType===`context`&&t.activeContextId===e.contextId:e?.mode===`workspace`?t.activeContextType!==`context`&&t.activeWorkspaceName===e.workspaceName&&t.activeTreeName===e.treeName&&t.activeContextPath===e.path:!t.activeWorkspaceName&&!t.activeContextId),d=!n&&e?.mode===`context`?e.contextId:null;return(0,l.useEffect)(()=>{if(!d)return;let e=`context:${d}`,t=()=>r.emit(`subscribe`,{channel:e}),n=r.on(`connect`,t);return t(),()=>{n(),r.emit(`unsubscribe`,{channel:e})}},[d]),n?(0,u.jsx)(c,{}):(0,u.jsx)(s,{target:e,children:(0,u.jsx)(o,{children:(0,u.jsx)(c,{})})})}export{d as FiltersApplet};
@@ -0,0 +1,3 @@
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{yt as r}from"./react-BHzhHVTZ.js";import{g as i}from"./chunk-62JRHF6Z-vspAGgtK.js";import{L as a,Mt as o,U as s,Ur as c,W as l,hn as u,pn as d,rr as f,tt as p}from"./ui-BSqPn1LJ.js";import{t as m}from"./utils-2pl1SbIp.js";import{t as h}from"./input-BOtCd4HP.js";import{t as g}from"./label-CNoJOoe0.js";import{t as _}from"./LinkToCard-BZwwE-Dv.js";import{Vt as v}from"./workspace-CJ1PWQ29.js";import{t as y}from"./use-mobile-Db-vWu9Y.js";import{a as b,i as x,s as S,t as ee}from"./IdentityFields-C2MPM-Ab.js";import{n as C,r as te}from"./use-toolbox-Ck_cLGgf.js";import{c as ne}from"./date-time-picker-BZaA3M9_.js";import{n as w,t as re}from"./PickDocumentsCard-BlicxMqC.js";import{t as T}from"./useToastHelpers-CRrpIIdY.js";import{r as E,t as D}from"./note-save-status-DPz4VzL6.js";import{t as O}from"./DocumentBodyEditor-CE2S2X6g.js";import{a as k,i as A,n as j,o as M,r as N,s as P,t as F}from"./UploadProgressList-B2xCVzFR.js";import{A as I,D as L,O as R,k as z}from"./index-DtZS4JJ4.js";var B=e(r(),1),V=e(n(),1),H=t();function U({onClose:e,initialData:t,draftId:n}){let r=R(void 0,void 0,`home-card:${n}`);return(0,V.useEffect)(()=>{t?.title&&r.setTitle(t.title),t?.content&&r.setContent(t.content)},[]),(0,H.jsx)(w,{title:`New Note`,icon:p,onClose:e,onSave:async e=>{let t=await r.save({mode:`workspace`,...e});return r.finish(),t},canSave:r.canSave,saving:r.saving,successMessage:`Note created`,children:(0,H.jsxs)(`div`,{className:`flex h-full flex-col gap-4 p-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(g,{htmlFor:`qa-note-title`,children:`Title`}),(0,H.jsx)(h,{id:`qa-note-title`,value:r.title,onChange:e=>r.setTitle(e.target.value),placeholder:`Optional; defaults to today's date`})]}),(0,H.jsxs)(`div`,{className:`flex flex-1 flex-col gap-1.5`,children:[(0,H.jsx)(g,{children:`Body`}),(0,H.jsx)(`div`,{className:`flex-1`,children:(0,H.jsx)(O,{kind:`markdown`,value:r.content,onChange:r.setContent,placeholder:`Write your note…`})})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(g,{children:`Tags`}),(0,H.jsx)(S,{tags:r.tags,onChange:r.setTags})]}),(0,H.jsx)(D,{...r,onRetry:r.retry}),(0,H.jsx)(P,{geotag:r.geotag,idPrefix:`qa-note-geotag`})]})})}function W({onClose:e,initialData:t}){let n=L();return(0,V.useEffect)(()=>{t?.url&&n.setUrl(t.url),t?.title&&n.setTitle(t.title)},[]),(0,H.jsx)(w,{title:`New Link`,icon:u,onClose:e,onSave:e=>n.save({mode:`workspace`,...e}),canSave:n.canSave,saving:n.saving,successMessage:`Link created`,children:(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 p-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(g,{htmlFor:`qa-link-url`,children:`URL`}),(0,H.jsx)(h,{id:`qa-link-url`,value:n.url,onChange:e=>n.setUrl(e.target.value),placeholder:`https://example.com`,autoFocus:!0}),n.showUrlError&&(0,H.jsx)(`p`,{className:`text-xs text-destructive`,children:`Enter a valid URL, e.g. https://example.com`})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(g,{htmlFor:`qa-link-title`,children:`Title`}),(0,H.jsx)(h,{id:`qa-link-title`,value:n.title,onChange:e=>n.setTitle(e.target.value),placeholder:`Optional display title`})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(g,{children:`Tags`}),(0,H.jsx)(S,{tags:n.tags,onChange:n.setTags})]}),(0,H.jsx)(P,{geotag:n.geotag,idPrefix:`qa-link-geotag`})]})})}function G({onClose:e,initialData:t}){let n=ne();return(0,V.useEffect)(()=>{t?.title&&n.setTitle(t.title),t?.content&&n.setDescription(t.content)},[]),(0,H.jsx)(w,{title:`New Todo`,icon:d,onClose:e,onSave:e=>n.save({mode:`workspace`,...e}),canSave:n.canSave,saving:n.saving,successMessage:`Todo created`,children:(0,H.jsxs)(`div`,{className:`flex h-full flex-col gap-4 p-4`,children:[(0,H.jsx)(b,{...n,idPrefix:`qa-todo`}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(g,{children:`Tags`}),(0,H.jsx)(S,{tags:n.tags,onChange:n.setTags})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(g,{htmlFor:`qa-todo-comment`,children:`Comment`}),(0,H.jsx)(`textarea`,{id:`qa-todo-comment`,value:n.comment,onChange:e=>n.setComment(e.target.value),rows:3,placeholder:`Optional context`,className:`flex w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-elevation-1 transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`})]}),(0,H.jsx)(P,{geotag:n.geotag,idPrefix:`qa-todo-geotag`})]})})}function K({onClose:e,initialData:t}){let n=x();return(0,V.useEffect)(()=>{t?.title&&n.setDisplayName(t.title)},[]),(0,H.jsx)(w,{title:`New Identity`,icon:s,onClose:e,onSave:e=>n.save({mode:`workspace`,...e}),canSave:n.canSave,saving:n.saving,successMessage:`Identity created`,children:(0,H.jsxs)(`div`,{className:`flex h-full flex-col gap-4 p-4`,children:[(0,H.jsx)(ee,{idPrefix:`qa-identity`,...n,emailValid:n.emailValid}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(g,{children:`Tags`}),(0,H.jsx)(S,{tags:n.tags,onChange:n.setTags})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(g,{htmlFor:`qa-identity-comment`,children:`Comment`}),(0,H.jsx)(`textarea`,{id:`qa-identity-comment`,value:n.comment,onChange:e=>n.setComment(e.target.value),rows:3,placeholder:`How you know them, where they came from…`,className:`flex w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-elevation-1 transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`})]})]})})}var q={jpg:`image/jpeg`,jpeg:`image/jpeg`,png:`image/png`,gif:`image/gif`,webp:`image/webp`,avif:`image/avif`,heic:`image/heic`,heif:`image/heif`,bmp:`image/bmp`,tif:`image/tiff`,tiff:`image/tiff`,svg:`image/svg+xml`,mp4:`video/mp4`,mov:`video/quicktime`,webm:`video/webm`,"3gp":`video/3gpp`};function J(e){return/^(image|video)\//.test(e.type)}async function Y(e){let t=await Promise.all(e.map(async e=>{let t=new Uint8Array(await e.slice(0,64).arrayBuffer()),n=(e,n)=>String.fromCharCode(...t.slice(e,e+n)),r=``;if(t[0]===255&&t[1]===216&&t[2]===255)r=`image/jpeg`;else if(n(0,8)===`‰PNG\r
2
+ 
3
+ `)r=`image/png`;else if([`GIF87a`,`GIF89a`].includes(n(0,6)))r=`image/gif`;else if(n(0,4)===`RIFF`&&n(8,4)===`WEBP`)r=`image/webp`;else if(n(0,5)===`%PDF-`)r=`application/pdf`;else if(n(0,4)===`PK`)r=`application/zip`;else if(n(4,4)===`ftyp`){let e=[n(8,4)],i=new DataView(t.buffer).getUint32(0);for(let r=16;r+4<=Math.min(t.length,i);r+=4)e.push(n(r,4));e.some(e=>[`avif`,`avis`].includes(e))?r=`image/avif`:e.some(e=>[`heic`,`heix`,`hevc`,`hevx`].includes(e))?r=`image/heic`:e.some(e=>[`mif1`,`msf1`].includes(e))?r=`image/heif`:e.includes(`qt `)?r=`video/quicktime`:e.some(e=>[`isom`,`iso2`,`mp41`,`mp42`,`avc1`,`M4V `].includes(e))&&(r=`video/mp4`)}let i=e.type.toLowerCase().split(`;`)[0].trim(),a=!i||[`application/octet-stream`,`binary/octet-stream`,`*/*`].includes(i),o=e.name.split(`.`).pop()?.toLowerCase()??``,s=r||a&&q[o]||i;return s===e.type?e:new File([e],e.name,{type:s,lastModified:e.lastModified})}));return{kind:t.length>0&&t.every(J)?`photo`:`file`,files:t}}function X({file:e}){let t=(0,V.useRef)(null),[n,r]=(0,V.useState)(!1);return(0,V.useEffect)(()=>{let n=t.current;if(!n)return;let r=URL.createObjectURL(e);return n.src=r,()=>{n.removeAttribute(`src`),URL.revokeObjectURL(r)}},[e]),(0,H.jsx)(`div`,{className:`flex min-h-24 items-center justify-center overflow-hidden rounded-md border border-input bg-muted/30`,children:n?(0,H.jsxs)(`p`,{className:`p-4 text-center text-sm text-muted-foreground`,children:[`Preview unavailable for `,e.name,`. You can still save the original.`]}):e.type.startsWith(`video/`)?(0,H.jsx)(`video`,{ref:t,controls:!0,preload:`metadata`,"aria-label":e.name,onError:()=>r(!0),className:`max-h-64 max-w-full`}):(0,H.jsx)(`img`,{ref:t,alt:e.name,onError:()=>r(!0),className:`max-h-64 max-w-full object-contain`})})}function ie({onClose:e,initialData:t}){let n=(0,V.useRef)(null),r=N(t?.files),i=r.items.map(e=>e.file),[a,o]=(0,V.useState)(!1),[s,c]=(0,V.useState)(!1),{state:u}=C(),d=M(u.activeWorkspaceName),f=e=>{e&&(s||r.addFiles(Array.from(e)))},p=e=>{e.preventDefault(),o(!1),f(e.dataTransfer.files)},h=i.length>0;return(0,H.jsx)(w,{title:`Upload File`,icon:l,onClose:e,onSave:async e=>{c(!0);try{let t={mode:`workspace`,...e},n=await d.geotag.capture(),i=await r.start(t,(e,t)=>k(e,t,{tags:d.tags,comment:d.comment,geo:n}));if(i.failed)throw Error(`${i.failed} file(s) failed or cancelled. Retry keeps completed uploads.`);return i.docIds}finally{c(!1)}},navigateAfterSave:!0,canSave:h,saving:s,saveProgress:(0,H.jsx)(j,{items:r.items,running:r.running,onCancel:r.cancel}),successMessage:`File(s) uploaded`,children:(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 p-4`,children:[(0,H.jsxs)(`div`,{onDragOver:e=>{e.preventDefault(),o(!0)},onDragLeave:()=>o(!1),onDrop:p,onClick:()=>n.current?.click(),className:m(`flex cursor-pointer flex-col items-center justify-center gap-2 rounded-md border border-dashed px-4 py-8 text-center transition-colors`,a?`border-primary bg-primary/5`:`border-input hover:bg-muted/40`),children:[(0,H.jsx)(l,{className:`h-6 w-6 text-muted-foreground touch-target`}),(0,H.jsx)(`p`,{className:`text-sm`,children:`Drag & drop files here`}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`or click to browse`}),(0,H.jsx)(`input`,{ref:n,type:`file`,multiple:!0,disabled:s,className:`hidden`,onChange:e=>{f(e.target.files),e.target.value=``}})]}),r.items.filter(e=>J(e.file)).map(e=>(0,H.jsx)(X,{file:e.file},e.id)),(0,H.jsx)(F,{items:r.items,running:s,onRemove:r.removeItem}),(0,H.jsx)(A,{fields:d,idPrefix:`qa-file`,multiple:i.length>1})]})})}function ae({onClose:e,initialData:t}){let n=N(t?.files),r=(0,V.useRef)(null),i=n.items.length>0,[o,s]=(0,V.useState)(!1),{state:l}=C(),u=M(l.activeWorkspaceName),d=e=>{!o&&e&&n.addFiles([e])};return(0,H.jsx)(w,{title:`Photo/Video`,icon:c,onClose:e,onSave:async e=>{if(!i)return[];s(!0);try{let t=await u.geotag.capture(),r={mode:`workspace`,...e},i=await n.start(r,(e,n)=>k(e,n,{tags:u.tags,comment:u.comment,geo:t}));if(i.failed)throw Error(`Upload failed or cancelled. You can retry.`);return i.docIds}finally{s(!1)}},navigateAfterSave:!0,canSave:i,saving:o,saveProgress:(0,H.jsx)(j,{items:n.items,running:n.running,onCancel:n.cancel}),successMessage:`Upload saved`,children:(0,H.jsxs)(`div`,{className:m(`flex h-full flex-col gap-4 p-4`,!i&&`items-center justify-center`),children:[i?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`flex min-h-0 w-full flex-1 flex-col gap-3 overflow-y-auto`,children:n.items.map(({id:e,file:t,status:r})=>(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(X,{file:t}),(0,H.jsxs)(`div`,{className:`flex w-full items-center gap-2 rounded border border-input px-3 py-2 text-sm`,children:[(0,H.jsx)(f,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,H.jsx)(`span`,{className:`flex-1 truncate`,children:t.name}),(0,H.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:[(t.size/1024/1024).toFixed(1),` MB`]}),(0,H.jsx)(`button`,{type:`button`,disabled:o||r===`done`,onClick:()=>n.removeItem(e),"aria-label":`Remove ${t.name}`,className:`text-muted-foreground hover:text-foreground disabled:opacity-40`,children:(0,H.jsx)(a,{className:`h-3.5 w-3.5`})})]})]},e))}),(0,H.jsx)(`div`,{className:`w-full shrink-0 space-y-4`,children:(0,H.jsx)(A,{fields:u,idPrefix:`qa-photo`,multiple:n.items.length>1})})]}):(0,H.jsxs)(`button`,{type:`button`,onClick:()=>r.current?.click(),className:`flex flex-col items-center gap-2 rounded-md border border-dashed border-input px-6 py-10 text-center transition-colors hover:bg-muted/40`,children:[(0,H.jsx)(c,{className:`h-8 w-8 text-muted-foreground`}),(0,H.jsx)(`span`,{className:`text-sm`,children:`Open camera`})]}),(0,H.jsx)(`input`,{ref:r,type:`file`,accept:`image/*,video/*`,capture:`environment`,className:`hidden`,disabled:o,onChange:e=>{d(e.target.files?.[0]??null),e.target.value=``}})]})})}var Z=`shrink-0 h-viewport-card w-[min(380px,90vw)] max-md:fixed max-md:inset-2 max-md:z-40 max-md:h-auto max-md:w-auto max-md:shadow-elevation-5`;function oe({onClose:e}){let{showSuccessToast:t,showErrorToast:n}=T(),[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(!1);return r?(0,H.jsx)(_,{sizeClassName:Z,documentCount:r.length,saving:a,onClose:e,onConfirm:async(i,a)=>{o(!0);try{await Promise.all(i.map(e=>v(a.workspaceName,e,r,a.treeName,a.treeType))),t(`${r.length} document${r.length===1?``:`s`} linked`),e()}catch(e){n(e instanceof Error?e.message:`Failed to link documents`)}finally{o(!1)}}}):(0,H.jsx)(re,{sizeClassName:Z,onConfirm:e=>{e.length&&i(e)},onClose:e})}function Q(){let e=E(`new:home-card:`);try{return Object.keys(localStorage).filter(t=>t.startsWith(e)&&t.endsWith(`:home`)).filter(e=>{let t=JSON.parse(localStorage.getItem(e)||`null`)?.value;return t&&(t.title||t.content||t.comment||t.tags?.length)}).map(t=>t.slice(e.length,-5))}catch{return[]}}var $=0;function se(){return $+=1,`card-${$}`}function ce({initialKind:e,initialData:t,onInitialCardClose:n,onCardsOpenChange:r}){let[s,c]=(0,V.useState)(!1),l=y(),u=te(),d=!!(u?.state.t1Open||u?.state.addOpen),[f,p]=(0,V.useState)(()=>e?[{id:`initial`,kind:e,initialData:t,noteDraftId:crypto.randomUUID()}]:Q().map(e=>({id:e,kind:`note`,noteDraftId:e}))),h=f.length>0,g=(0,V.useRef)(r);(0,V.useEffect)(()=>{g.current=r},[r]),(0,V.useEffect)(()=>{g.current?.(h)},[h]),d&&s&&c(!1);let _=i(),v=e=>{if(e===`sketch`){c(!1),_(I.createUrl(null));return}let t=e===`note`?Q().find(e=>!f.some(t=>t.noteDraftId===e))||crypto.randomUUID():void 0;p(n=>[...n,{id:se(),kind:e,noteDraftId:t}]),c(!1)},b=e=>{p(t=>t.filter(t=>t.id!==e)),e===`initial`&&n?.()},x=(0,H.jsxs)(`div`,{className:m(`pointer-events-none fixed right-6 z-40 flex flex-col items-end gap-2`,`bottom-fab-inset md:bottom-[calc(var(--spacing-fab-inset)+5rem)]`,f.length>0&&`max-md:hidden`,d&&`hidden`),children:[(0,H.jsx)(`div`,{className:m(`flex flex-col items-end gap-2 transition-all duration-fast`,s?`pointer-events-auto opacity-100`:`pointer-events-none translate-y-2 opacity-0`),children:(0,H.jsx)(z,{variant:`stack`,omit:[`plaintext`,`folder`,`message`],onSelect:v})}),(0,H.jsx)(`div`,{className:`pointer-events-none flex w-16 justify-center`,children:(0,H.jsx)(`button`,{type:`button`,onClick:()=>c(e=>!e),"aria-label":s?`Close quick add`:`Quick add`,className:`pointer-events-auto flex h-11 w-11 items-center justify-center rounded-full bg-primary text-primary-foreground shadow-elevation-3 transition-transform hover:scale-105`,children:s?(0,H.jsx)(a,{className:`h-5 w-5`}):(0,H.jsx)(o,{className:`h-5 w-5`})})})]});return(0,H.jsxs)(`div`,{className:`relative flex h-full w-full flex-col`,children:[f.length>0&&(0,H.jsx)(`div`,{className:`pointer-events-auto flex flex-1 items-center gap-4 overflow-x-auto p-6 md:pr-28`,children:f.map(e=>{let t=()=>b(e.id);switch(e.kind){case`note`:return(0,H.jsx)(U,{draftId:e.noteDraftId,onClose:t,initialData:e.initialData},e.id);case`link`:return(0,H.jsx)(W,{onClose:t,initialData:e.initialData},e.id);case`todo`:return(0,H.jsx)(G,{onClose:t,initialData:e.initialData},e.id);case`identity`:return(0,H.jsx)(K,{onClose:t,initialData:e.initialData},e.id);case`file`:return(0,H.jsx)(ie,{onClose:t,initialData:e.initialData},e.id);case`photo`:return(0,H.jsx)(ae,{onClose:t,initialData:e.initialData},e.id);case`existing`:return(0,H.jsx)(oe,{onClose:t},e.id);case`sketch`:return null;case`folder`:case`message`:return null}})}),l?(0,B.createPortal)(x,document.body):x]})}export{Y as n,ce 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{yt as r}from"./react-BHzhHVTZ.js";import{Hr as i,L as a,Mt as o,X as s,an as c,dn as l,gn as u,nt as d,un as f,yr as p,yt as m}from"./ui-BSqPn1LJ.js";import{t as h}from"./utils-2pl1SbIp.js";import{t as g}from"./input-BOtCd4HP.js";import{t as _}from"./label-CNoJOoe0.js";import{Pn as v,Tt as y,Vn as b,_ as x,qn as S}from"./workspace-CJ1PWQ29.js";import{n as C}from"./tags-YamdPoBK.js";import{o as w}from"./useAddTarget-CVRPElxz.js";import{n as T,r as E,t as D}from"./date-time-picker-BZaA3M9_.js";import{t as O}from"./useEscapeClose-DR_xKT_k.js";import{n as k}from"./map-BxCwdK0d.js";var A=e(n(),1),j=(0,A.createContext)(null),M=t();function N({tags:e,onChange:t,placeholder:n=`Add tag, press Enter`,suggestions:r=[]}){let[i,o]=(0,A.useState)(``),[s,c]=(0,A.useState)(!1),l=i.trim().toLowerCase(),u=(l?r.filter(t=>t.toLowerCase().includes(l)&&!e.includes(t)):s?r.filter(t=>!e.includes(t)):[]).slice(0,8),d=()=>{let n=i.trim();n&&!e.includes(n)&&t([...e,n]),o(``)};return(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 rounded-md border border-input bg-transparent px-2 py-1.5 focus-within:ring-1 focus-within:ring-ring`,children:[e.map(n=>(0,M.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-muted px-1.5 py-0.5 text-xs`,children:[n,(0,M.jsx)(`button`,{type:`button`,onClick:()=>t(e.filter(e=>e!==n)),className:`text-muted-foreground hover:text-foreground`,"aria-label":`Remove ${n}`,children:(0,M.jsx)(a,{className:`h-3 w-3`})})]},n)),(0,M.jsxs)(`div`,{className:`relative flex-1 min-w-[8ch]`,children:[(0,M.jsx)(`input`,{value:i,onChange:e=>o(e.target.value),onKeyDown:n=>{n.key===`Enter`||n.key===`,`?(n.preventDefault(),d()):n.key===`Backspace`&&!i&&e.length&&t(e.slice(0,-1))},onFocus:()=>c(!0),onBlur:()=>{setTimeout(d,150),c(!1)},placeholder:e.length?``:n,className:`w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground`}),u.length>0&&(0,M.jsx)(`div`,{className:`absolute left-0 top-full z-50 mt-1 max-h-48 w-56 overflow-auto rounded-md border bg-popover p-1 text-sm shadow-elevation-2`,children:u.map(n=>(0,M.jsx)(`button`,{type:`button`,onMouseDown:r=>{r.preventDefault(),e.includes(n)||t([...e,n]),o(``)},className:`block w-full rounded px-2 py-1 text-left hover:bg-accent`,children:n},n))})]})]})}var ee=e(r(),1),P=e(k(),1),F=`#8b5cf6`,I=`https://nominatim.openstreetmap.org`,te=700,L=e=>Math.round(e*1e6)/1e6;function R(){let e=`<div style="display:flex;align-items:center;justify-content:center;width:28px;height:28px;border-radius:9999px 9999px 9999px 2px;transform:rotate(-45deg);background:${F};border:2px solid #fff;box-shadow:0 1px 4px rgba(0,0,0,.45)"><div style="width:8px;height:8px;border-radius:9999px;background:#fff"></div></div>`;return P.default.divIcon({html:e,className:`canvas-map-pick`,iconSize:[28,28],iconAnchor:[14,28]})}function z({initial:e,onPick:t,onClose:n}){let r=(0,A.useRef)(null),o=(0,A.useRef)(null),s=(0,A.useRef)(null),u=(0,A.useRef)(null);(0,A.useEffect)(()=>()=>u.current?.abort(),[]);let[d,g]=(0,A.useState)(e?{lat:e.lat,lon:e.lon}:null),[_,v]=(0,A.useState)(``),[y,b]=(0,A.useState)([]),[x,S]=(0,A.useState)(!1),[C,w]=(0,A.useState)(null),[T,E]=(0,A.useState)(!1),[D,k]=(0,A.useState)(!1),[j,N]=(0,A.useState)(!1);(0,A.useEffect)(()=>{let e=requestAnimationFrame(()=>N(!0));return()=>cancelAnimationFrame(e)},[]),O(n);let F=(0,A.useCallback)((e,t,n)=>{let r=o.current;if(!r)return;let i=P.default.latLng(e,t);s.current?s.current.setLatLng(i):(s.current=P.default.marker(i,{icon:R(),draggable:!0,autoPan:!0}).addTo(r),s.current.on(`dragend`,()=>{let e=s.current.getLatLng();g({lat:L(e.lat),lon:L(e.lng)})})),g({lat:L(e),lon:L(t),...n?{label:n}:{}})},[]);(0,A.useEffect)(()=>{let t=r.current;if(!t||o.current)return;let n=P.default.map(t,{center:e?[e.lat,e.lon]:[20,0],zoom:e?13:2,worldCopyJump:!0,zoomControl:!0});P.default.tileLayer(`https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png`,{attribution:`&copy; OpenStreetMap contributors`,maxZoom:19}).addTo(n),o.current=n,e&&F(e.lat,e.lon),n.on(`click`,e=>F(e.latlng.lat,e.latlng.lng));let i=new ResizeObserver(()=>n.invalidateSize());i.observe(t);let a=setTimeout(()=>n.invalidateSize(),260);return()=>{clearTimeout(a),i.disconnect(),n.remove(),o.current=null,s.current=null}},[]),(0,A.useEffect)(()=>{if(!d||d.label)return;let{lat:e,lon:t}=d,n=new AbortController,r=setTimeout(()=>{E(!0),fetch(`${I}/reverse?format=jsonv2&zoom=16&lat=${e}&lon=${t}`,{signal:n.signal,headers:{Accept:`application/json`}}).then(e=>e.ok?e.json():null).then(n=>{let r=n?.display_name;typeof r==`string`&&r&&g(n=>n&&n.lat===e&&n.lon===t?{...n,label:r}:n)}).catch(()=>{}).finally(()=>E(!1))},te);return()=>{clearTimeout(r),n.abort()}},[d]);let z=(0,A.useCallback)(async()=>{let e=_.trim();if(e.length<2)return;u.current?.abort();let t=new AbortController;u.current=t;let n=!1,r=window.setTimeout(()=>{n=!0,t.abort()},12e3);S(!0),b([]),w(null);try{let n=await fetch(`${I}/search?format=jsonv2&limit=6&q=${encodeURIComponent(e)}`,{signal:t.signal,headers:{Accept:`application/json`}});if(n.status===429)throw Error(`Place search is busy. Wait a moment and try again, or click the map`);if(!n.ok)throw Error(`Place search is unavailable (${n.status}). Try again, or click the map`);let r=await n.json();if(!Array.isArray(r))throw Error(`Place search returned an invalid response. Try again, or click the map`);if(t.signal.aborted||u.current!==t)return;b(r),r.length||w(`No match. Try a different spelling, or just click the map`)}catch(e){if(u.current!==t||t.signal.aborted&&!n)return;w(n?`Place search timed out. Try again, or click the map`:e instanceof TypeError?`Could not reach place search. Check your connection, or click the map`:e instanceof Error?e.message:`Search is unavailable right now. Click the map to place a pin`)}finally{window.clearTimeout(r),u.current===t&&(!t.signal.aborted||n)&&S(!1)}},[_]),B=(0,A.useCallback)(()=>{if(!navigator.geolocation){w(`This browser has no geolocation`);return}k(!0),w(null),navigator.geolocation.getCurrentPosition(e=>{k(!1),o.current?.setView([e.coords.latitude,e.coords.longitude],16),F(e.coords.latitude,e.coords.longitude)},()=>{k(!1),w(`Could not read your location. Search or click the map instead`)},{enableHighAccuracy:!0,timeout:1e4,maximumAge:6e4})},[F]),V=(0,A.useCallback)(e=>{let t=o.current,n=Number(e.lat),r=Number(e.lon);if(!t||!Number.isFinite(n)||!Number.isFinite(r))return;let i=e.boundingbox?.map(Number);i&&i.length===4&&i.every(Number.isFinite)?t.fitBounds(P.default.latLngBounds([i[0],i[2]],[i[1],i[3]]),{maxZoom:16}):t.setView([n,r],15),F(n,r,e.display_name),b([])},[F]);return(0,ee.createPortal)((0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`div`,{className:h(`fixed inset-0 z-[60] bg-scrim transition-opacity duration-normal`,j?`opacity-100`:`opacity-0`),onClick:n}),(0,M.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Pick a location on the map`,className:h(`fixed inset-y-0 right-0 z-[61] flex w-[min(560px,100vw)] flex-col overflow-hidden rounded-(--panel-radius) bg-background shadow-elevation-4 transition-transform duration-normal ease-out`,j?`translate-x-0`:`translate-x-full`),children:[(0,M.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b px-3 py-2`,children:[(0,M.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,M.jsx)(c,{className:`h-4 w-4 text-info`}),`Custom geotag`]}),(0,M.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close map`,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,M.jsx)(a,{className:`h-4 w-4`})})]}),(0,M.jsxs)(`div`,{className:`relative z-10 shrink-0 border-b px-3 py-2`,children:[(0,M.jsxs)(`div`,{className:`flex gap-2`,children:[(0,M.jsxs)(`div`,{className:`relative flex-1`,children:[(0,M.jsx)(m,{className:`pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,M.jsx)(`input`,{value:_,autoFocus:!0,onChange:e=>{u.current?.abort(),u.current=null,S(!1),b([]),v(e.target.value),w(null)},"aria-label":`Search for a place or address`,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),z())},placeholder:`Search a place, e.g. Slavkovský štít`,spellCheck:!1,className:`h-8 w-full rounded-md border border-input bg-transparent pl-7 pr-2 text-sm outline-none placeholder:text-muted-foreground focus-visible:ring-1 focus-visible:ring-ring`})]}),(0,M.jsx)(`button`,{type:`button`,onClick:B,disabled:D,title:`Use my current location`,"aria-label":`Use my current location`,className:`inline-flex h-8 w-8 items-center justify-center rounded-md border border-border text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50`,children:D?(0,M.jsx)(l,{className:`h-3.5 w-3.5 animate-spin`}):(0,M.jsx)(f,{className:`h-3.5 w-3.5`})}),(0,M.jsxs)(`button`,{type:`button`,onClick:z,disabled:x||_.trim().length<2,className:`inline-flex h-8 items-center gap-1.5 rounded-md bg-primary px-3 text-xs text-primary-foreground disabled:opacity-50`,children:[x?(0,M.jsx)(l,{className:`h-3.5 w-3.5 animate-spin`}):(0,M.jsx)(m,{className:`h-3.5 w-3.5`}),`Search`]})]}),C&&(0,M.jsx)(`p`,{role:`status`,className:`mt-1 text-xs text-warning`,children:C}),y.length>0&&(0,M.jsx)(`div`,{className:`absolute inset-x-3 top-full z-10 mt-1 max-h-64 overflow-y-auto rounded-md border bg-popover shadow-elevation-4`,children:y.map(e=>(0,M.jsx)(`button`,{type:`button`,onClick:()=>V(e),className:`block w-full border-b border-border/60 px-3 py-2 text-left text-xs last:border-0 hover:bg-muted`,children:e.display_name},`${e.lat},${e.lon},${e.display_name}`))})]}),(0,M.jsxs)(`div`,{className:`relative isolate z-0 min-h-0 flex-1`,children:[(0,M.jsx)(`div`,{ref:r,className:`h-full w-full`}),!d&&(0,M.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-3 z-[1000] flex justify-center`,children:(0,M.jsx)(`span`,{className:`rounded-full bg-background/90 px-3 py-1 text-xs text-muted-foreground shadow-elevation-2`,children:`Click the map to drop a pin, or drag it to fine-tune`})})]}),(0,M.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-t px-3 py-2`,children:[(0,M.jsx)(`div`,{className:`min-w-0 text-xs`,children:d?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-1.5 tabular-nums text-foreground`,children:[(0,M.jsx)(p,{className:`h-3 w-3 shrink-0 text-muted-foreground`}),d.lat.toFixed(5),`, `,d.lon.toFixed(5),T&&(0,M.jsx)(l,{className:`h-3 w-3 animate-spin text-muted-foreground`})]}),d.label&&(0,M.jsx)(`div`,{className:`truncate text-muted-foreground`,children:d.label})]}):(0,M.jsx)(`span`,{className:`text-muted-foreground`,children:`No point selected`})}),(0,M.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,M.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-md border border-border px-3 py-1.5 text-xs text-muted-foreground hover:bg-muted hover:text-foreground`,children:`Cancel`}),(0,M.jsxs)(`button`,{type:`button`,disabled:!d,onClick:()=>{d&&(t(d),n())},className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground disabled:opacity-50`,children:[(0,M.jsx)(i,{className:`h-3.5 w-3.5`}),`Use this point`]})]})]})]})]}),document.body)}var B={1:`1: Highest`,2:`2`,3:`3: High`,4:`4`,5:`5: Medium`,6:`6`,7:`7: Low`,8:`8`,9:`9: Lowest`},V=`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-elevation-1 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,H=`flex w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-elevation-1 transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`;function U({title:e,setTitle:t,description:n,setDescription:r,status:i,setStatus:a,priority:o,setPriority:s,due:c,setDue:l,idPrefix:u=`todo`}){return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(_,{htmlFor:`${u}-title`,children:`Title`}),(0,M.jsx)(g,{id:`${u}-title`,value:e,onChange:e=>t(e.target.value),placeholder:`What needs doing?`})]}),(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(_,{htmlFor:`${u}-desc`,children:`Description`}),(0,M.jsx)(`textarea`,{id:`${u}-desc`,value:n,onChange:e=>r(e.target.value),rows:3,placeholder:`Optional details…`,className:H})]}),(0,M.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(_,{htmlFor:`${u}-due`,children:`Due`}),(0,M.jsx)(D,{id:`${u}-due`,value:c,onChange:l,placeholder:`No due date`})]}),(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(_,{htmlFor:`${u}-priority`,children:`Priority`}),(0,M.jsxs)(`select`,{id:`${u}-priority`,value:o===``?``:String(o),onChange:e=>s(e.target.value===``?``:Number(e.target.value)),className:V,children:[(0,M.jsx)(`option`,{value:``,children:`None`}),[1,2,3,4,5,6,7,8,9].map(e=>(0,M.jsx)(`option`,{value:e,children:B[e]},e))]})]})]}),(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(_,{htmlFor:`${u}-status`,children:`Status`}),(0,M.jsx)(`select`,{id:`${u}-status`,value:i,onChange:e=>a(e.target.value),className:V,children:T.map(e=>(0,M.jsx)(`option`,{value:e,children:E[e]},e))})]})]})}var W=`3.0`,G=[`person`,`organization`,`service`,`bot`],K={person:`Person`,organization:`Organization`,service:`Service`,bot:`Bot`},q=[`email`,`phone`,`sms`,`chat`,`web`],J=[`email`,`github`,`slack`,`matrix`,`gpg`,`url`];function Y(e){let t=e.primaryEmail.trim().toLowerCase(),n=e.channels.map(e=>({...e,kind:e.kind.trim(),value:e.value.trim(),label:e.label?.trim()||void 0})).filter(e=>e.kind&&e.value);if(t&&!n.some(e=>e.kind===`email`&&e.value===t)){for(let e of n)e.kind===`email`&&(e.primary=!1);n.push({kind:`email`,value:t,label:void 0,primary:!0})}let r=e.given.trim(),i=e.family.trim();return{displayName:e.displayName.trim(),...t?{primaryEmail:t}:{},...r||i?{name:{...r?{given:r}:{},...i?{family:i}:{}}}:{},channels:n,identifiers:e.identifiers.map(e=>({...e,type:e.type.trim(),identifier:e.identifier.trim(),provider:e.provider?.trim()||void 0})).filter(e=>e.type&&e.identifier),organizations:e.organizations.map(({identityId:e,...t})=>({...t,name:t.name.trim(),role:t.role?.trim()||void 0,...e?{metadata:{identityId:e}}:{}})).filter(e=>e.name)}}function X(e){let t=e?.data??{},n=t.name&&typeof t.name==`object`?t.name:{},r=e=>Array.isArray(e)?e:[],i=S(String(e?.schema||``),b);return{displayName:String(t.displayName||``),type:G.includes(i)?i:`person`,primaryEmail:String(t.primaryEmail||``),given:String(n.given||``),family:String(n.family||``),channels:r(t.channels),identifiers:r(t.identifiers),organizations:r(t.organizations).map(e=>({name:String(e.name||``),role:e.role?String(e.role):void 0,identityId:Number(e.metadata?.identityId)||void 0}))}}async function Z(e,t,n){if(!t||!e||e.mode!==`workspace`)return;let r=n.filter(e=>e.identityId);for(let n of r)try{await x(e.workspaceName,t,`member-of`,[n.identityId])}catch(e){console.error(`Failed to link organization`,n.name,e)}}function ne(e){let[t,n]=(0,A.useState)(e?.displayName??``),[r,i]=(0,A.useState)(e?.type??`person`),[a,o]=(0,A.useState)(e?.primaryEmail??``),[s,c]=(0,A.useState)(e?.given??``),[l,u]=(0,A.useState)(e?.family??``),[d,f]=(0,A.useState)(e?.channels??[]),[p,m]=(0,A.useState)(e?.identifiers??[]),[h,g]=(0,A.useState)(e?.organizations??[]),[_,v]=(0,A.useState)([]),[y,x]=(0,A.useState)(``),[S,T]=(0,A.useState)(!1),E={displayName:t,type:r,primaryEmail:a,given:s,family:l,channels:d,identifiers:p,organizations:h},D=!a.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a.trim()),O=t.trim().length>0&&D&&!S;async function k(e){T(!0);try{let t=y.trim(),n={schema:`${b}/${E.type}`,schemaVersion:W,data:Y(E),...t?{comment:t}:{},metadata:{features:C(_)}},r=await w(e,[n]);return await Z(e,r[0],h),r}finally{T(!1)}}return{displayName:t,setDisplayName:n,type:r,setType:i,primaryEmail:a,setPrimaryEmail:o,given:s,setGiven:c,family:l,setFamily:u,channels:d,setChannels:f,identifiers:p,setIdentifiers:m,organizations:h,setOrganizations:g,tags:_,setTags:v,comment:y,setComment:x,values:E,saving:S,canSave:O,emailValid:D,save:k}}var Q=`h-9 shrink-0 rounded-md border border-input bg-transparent px-2 text-sm shadow-elevation-1 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`;function $({label:e,rows:t,onChange:n,blank:r,addLabel:i,children:a}){return(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,M.jsx)(_,{children:e}),(0,M.jsxs)(`button`,{type:`button`,onClick:()=>n([...t,r()]),className:`inline-flex items-center gap-1 rounded-md px-1.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:[(0,M.jsx)(o,{className:`h-3 w-3`}),` `,i]})]}),t.length===0?(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`None yet.`}):(0,M.jsx)(`div`,{className:`space-y-1.5`,children:t.map((r,i)=>(0,M.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[a(r,e=>n(t.map((t,n)=>n===i?{...t,...e}:t))),(0,M.jsx)(`button`,{type:`button`,onClick:()=>n(t.filter((e,t)=>t!==i)),className:`shrink-0 rounded p-1.5 text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,"aria-label":`Remove ${e.toLowerCase()} row`,children:(0,M.jsx)(s,{className:`h-3.5 w-3.5`})})]},i))})]})}function re(e,t){let n=e[t].kind,r=e[t].primary;return e.map((e,i)=>e.kind===n?{...e,primary:!r&&i===t}:e)}function ie(e){let[t,n]=(0,A.useState)([]);return(0,A.useEffect)(()=>{if(!e)return;let t=!1;async function r(){try{let r=await y(e,`organization`);t||n(r.map(e=>({id:e.id,name:v(e).title})))}catch{t||n([])}}return r(),()=>{t=!0}},[e]),t}function ae({idPrefix:e,workspaceName:t,displayName:n,setDisplayName:r,type:i,setType:a,primaryEmail:o,setPrimaryEmail:s,given:c,setGiven:l,family:f,setFamily:p,channels:m,setChannels:v,identifiers:y,setIdentifiers:b,organizations:x,setOrganizations:S,emailValid:C=!0}){let w=ie(t);return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(_,{htmlFor:`${e}-display-name`,children:`Display name`}),(0,M.jsx)(g,{id:`${e}-display-name`,value:n,onChange:e=>r(e.target.value),placeholder:`Jane Doe, Acme Ltd, build-bot…`,autoFocus:!0})]}),(0,M.jsxs)(`div`,{className:`flex gap-2`,children:[(0,M.jsxs)(`div`,{className:`w-40 space-y-1.5`,children:[(0,M.jsx)(_,{htmlFor:`${e}-type`,children:`Type`}),(0,M.jsx)(`select`,{id:`${e}-type`,value:i,onChange:e=>a(e.target.value),className:h(Q,`w-full`),children:G.map(e=>(0,M.jsx)(`option`,{value:e,children:K[e]},e))})]}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1.5`,children:[(0,M.jsx)(_,{htmlFor:`${e}-email`,children:`Primary email`}),(0,M.jsx)(g,{id:`${e}-email`,type:`email`,value:o,onChange:e=>s(e.target.value),placeholder:`jane@example.com`}),!C&&(0,M.jsx)(`p`,{className:`text-xs text-destructive`,children:`Enter a valid email address.`})]})]}),i===`person`&&(0,M.jsxs)(`div`,{className:`flex gap-2`,children:[(0,M.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1.5`,children:[(0,M.jsx)(_,{htmlFor:`${e}-given`,children:`Given name`}),(0,M.jsx)(g,{id:`${e}-given`,value:c,onChange:e=>l(e.target.value),placeholder:`Jane`})]}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1.5`,children:[(0,M.jsx)(_,{htmlFor:`${e}-family`,children:`Family name`}),(0,M.jsx)(g,{id:`${e}-family`,value:f,onChange:e=>p(e.target.value),placeholder:`Doe`})]})]}),(0,M.jsx)($,{label:`Channels`,rows:m,onChange:v,blank:()=>({kind:`email`,value:``}),addLabel:`Add channel`,children:(e,t)=>(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`select`,{value:e.kind,onChange:e=>t({kind:e.target.value}),className:h(Q,`w-24`),children:[q.map(e=>(0,M.jsx)(`option`,{value:e,children:e},e)),!q.includes(e.kind)&&(0,M.jsx)(`option`,{value:e.kind,children:e.kind})]}),(0,M.jsx)(g,{value:e.value,onChange:e=>t({value:e.target.value}),placeholder:e.kind===`phone`?`+421…`:`address or handle`,className:`min-w-0 flex-1`}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>v(re(m,m.indexOf(e))),className:h(`shrink-0 rounded p-1.5 transition-colors hover:bg-muted`,e.primary?`text-data-5`:`text-muted-foreground`),title:e.primary?`Primary for this kind`:`Make primary for this kind`,"aria-pressed":!!e.primary,children:(0,M.jsx)(d,{className:h(`h-3.5 w-3.5`,e.primary&&`fill-current`)})})]})}),(0,M.jsx)($,{label:`Identifiers`,rows:y,onChange:b,blank:()=>({type:`github`,identifier:``}),addLabel:`Add identifier`,children:(e,t)=>(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`select`,{value:e.type,onChange:e=>t({type:e.target.value}),className:h(Q,`w-24`),children:[J.map(e=>(0,M.jsx)(`option`,{value:e,children:e},e)),!J.includes(e.type)&&(0,M.jsx)(`option`,{value:e.type,children:e.type})]}),(0,M.jsx)(g,{value:e.identifier,onChange:e=>t({identifier:e.target.value}),placeholder:`octocat, U024BE7LH, 0xABCD…`,className:`min-w-0 flex-1 font-mono text-xs`})]})}),(0,M.jsx)($,{label:`Organizations`,rows:x,onChange:S,blank:()=>({name:``}),addLabel:`Add organization`,children:(e,t)=>(0,M.jsxs)(M.Fragment,{children:[w.length>0?(0,M.jsxs)(`select`,{value:e.identityId?String(e.identityId):``,onChange:e=>{let n=w.find(t=>String(t.id)===e.target.value);t(n?{identityId:n.id,name:n.name}:{identityId:void 0})},className:h(Q,`min-w-0 flex-1`),children:[(0,M.jsx)(`option`,{value:``,children:`Other… (type a name)`}),w.map(e=>(0,M.jsx)(`option`,{value:e.id,children:e.name},e.id))]}):null,!e.identityId&&(0,M.jsx)(g,{value:e.name,onChange:e=>t({name:e.target.value}),placeholder:`Acme Ltd`,className:`min-w-0 flex-1`}),e.identityId&&(0,M.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,title:`Linked — saving relates this identity to that organization`,children:(0,M.jsx)(u,{className:`h-3.5 w-3.5`})}),(0,M.jsx)(g,{value:e.role??``,onChange:e=>t({role:e.target.value}),placeholder:`Role`,className:`w-28 shrink-0`})]})})]})}export{U as a,j as c,ne as i,Y as n,z as o,X as r,N as s,ae 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{Jt as r,Ur as i,Zn as a,jr as o}from"./ui-BSqPn1LJ.js";import{t as s}from"./utils-2pl1SbIp.js";import{Ln as c,Pn as l}from"./workspace-CJ1PWQ29.js";import{t as u}from"./useDocumentThumbnail-C_rq2rXs.js";import{t as d}from"./DocumentIcon-BS10SIP6.js";import{n as f}from"./use-document-modal-PG8bQyIB.js";import{n as p}from"./use-applet-target-mkjQujx6.js";import{C as m,E as h,T as g,b as _,w as v,x as y,y as b}from"./index-DtZS4JJ4.js";var x=e(n(),1),S=t(),C=`h-8 rounded-md border border-input bg-transparent px-2 text-xs outline-none focus-visible:ring-2 focus-visible:ring-ring`,w=`h-8 rounded-md border border-input bg-transparent px-2 text-xs outline-none focus-visible:ring-1 focus-visible:ring-ring`;function T({workspaceRef:e,doc:t,distance:n,onOpen:r}){let i=c(t),{blobUrl:a}=u(e,t.id,256,{enabled:i}),o=l(t);return(0,S.jsxs)(`button`,{type:`button`,onClick:()=>r(t),title:`Open ${o.title}`,className:`rounded-(--card-radius) border border-border bg-card overflow-hidden flex flex-col text-left cursor-pointer transition-colors hover:border-foreground/30 hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,S.jsx)(`div`,{className:`aspect-square bg-muted/40 flex items-center justify-center overflow-hidden`,children:i&&a?(0,S.jsx)(`img`,{src:a,alt:o.title,className:`h-full w-full object-cover`}):(0,S.jsx)(d,{document:t,size:10})}),(0,S.jsxs)(`div`,{className:`p-2 min-w-0`,children:[(0,S.jsx)(`div`,{className:`text-xs font-medium truncate`,title:o.title,children:o.title}),(0,S.jsxs)(`div`,{className:`text-[10px] text-muted-foreground truncate`,children:[o.schemaLabel,n==null?``:` · d=${n.toFixed(3)}`]})]})]})}function E(){let e=p(),t=f(),n=g(),{rateMs:c,setRateMs:l,text:u,setText:d,maxDistance:E,setMaxDistance:D,latencyMs:O,error:k}=n,A=e?.mode===`workspace`?e.workspaceName:``,j=e?.mode===`workspace`&&e.path!==`/`?e.path:null,M=n.running&&n.consumer===`applet`,N=n.running&&n.consumer!==`applet`,P=M?n.hits:[];h(M);let F=M?n.snapshotSize??n.camera?.size:null,I=!!F&&F.height>F.width,L=e=>{A&&n.start(e,`applet`,{workspaceRef:A,contextPath:j})},{setContextPath:R}=n;return(0,x.useEffect)(()=>{M&&R(j)},[M,j,R]),e?.mode===`workspace`?(0,S.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-3 overflow-y-auto p-3`,children:[(0,S.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,S.jsx)(`select`,{className:C,value:c,onChange:e=>l(Number(e.target.value)),title:`Frame rate. High rates (10–30 fps) are experimental; the loop never overlaps requests, so the effective rate is capped by search latency.`,children:v.map(e=>(0,S.jsx)(`option`,{value:e.ms,children:e.label},e.ms))}),(0,S.jsx)(`input`,{className:s(w,`w-44`),placeholder:`Optional text (fused mode)`,value:u,onChange:e=>d(e.target.value)}),(0,S.jsx)(`input`,{className:s(w,`w-28`),placeholder:`max distance`,inputMode:`decimal`,value:E,onChange:e=>D(e.target.value),title:`Cosine-distance floor (0 = identical). Empty = top-K.`}),M?(0,S.jsxs)(`button`,{type:`button`,onClick:n.stop,className:`flex h-8 items-center gap-1 rounded-md bg-destructive px-3 text-xs font-medium text-destructive-foreground transition-colors hover:bg-destructive/90`,children:[(0,S.jsx)(o,{className:`h-3.5 w-3.5`}),` `,n.source===`photo`?`Close photo`:`Stop`]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`button`,{type:`button`,onClick:()=>L(`camera`),disabled:N,className:`flex h-8 items-center gap-1 rounded-md bg-foreground px-3 text-xs font-medium text-background transition-colors hover:bg-foreground/90 disabled:opacity-50`,children:[(0,S.jsx)(i,{className:`h-3.5 w-3.5`}),` Camera`]}),(0,S.jsxs)(`button`,{type:`button`,onClick:()=>L(`screen`),disabled:N,className:`flex h-8 items-center gap-1 rounded-md bg-foreground px-3 text-xs font-medium text-background transition-colors hover:bg-foreground/90 disabled:opacity-50`,children:[(0,S.jsx)(r,{className:`h-3.5 w-3.5`}),` Desktop`]})]}),(0,S.jsx)(_,{consumer:`applet`,workspaceRef:A,contextPath:j,disabled:N,className:`flex h-8 items-center gap-1 rounded-md bg-foreground px-3 text-xs font-medium text-background transition-colors hover:bg-foreground/90 disabled:opacity-50`})]}),(0,S.jsxs)(`div`,{className:s(`relative shrink-0 overflow-hidden rounded-xl border border-border bg-black/80`,I?`aspect-[3/4] max-h-[60vh]`:`aspect-video max-h-80`),children:[M&&(0,S.jsx)(m,{className:`h-full w-full`,interactive:!0}),M&&(0,S.jsx)(y,{}),!M&&(0,S.jsxs)(`div`,{className:`absolute inset-0 flex items-center justify-center text-sm text-muted-foreground`,children:[(0,S.jsx)(a,{className:`mr-2 h-4 w-4`}),` camera off · or pick a photo`]})]}),M&&(0,S.jsx)(b,{className:`shrink-0`}),(0,S.jsx)(`div`,{className:`shrink-0 text-xs text-muted-foreground`,children:k?(0,S.jsx)(`span`,{className:`text-destructive`,children:k}):M?(0,S.jsxs)(S.Fragment,{children:[n.snapshot?`snapshot`:`live`,` · `,O==null?`searching…`:`${O} ms/frame`,` · `,P.length,` match`,P.length===1?``:`es`,j?` · scoped to ${j}`:``]}):N?`The Lens filter is using the camera. Stop it there first.`:`Frames are ephemeral: embedded for the query, never stored or indexed.`}),P.length===0?(0,S.jsx)(`div`,{className:`flex min-h-24 flex-1 items-center justify-center rounded-xl border border-dashed border-border text-sm text-muted-foreground`,children:M?n.snapshot?`Nothing similar in the snapshot`:`Nothing matching in view`:`Matches appear here`}):(0,S.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4`,children:P.map(e=>(0,S.jsx)(T,{workspaceRef:A,doc:e.doc,distance:e.distance,onOpen:e=>t.open(e,A)},e.doc.id))})]}):(0,S.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-center text-sm text-muted-foreground`,children:`Lens searches a workspace. Bind it to a workspace path to start.`})}export{E as LensApplet};
@@ -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{_t as r,yt as i}from"./react-BHzhHVTZ.js";import{Ft as a,Gn as o,Hn as s,L as c,Rn as l,Sr as u,Vr as ee,Yn as d,gn as f,mt as p,yt as m,zr as h}from"./ui-BSqPn1LJ.js";import{t as g}from"./utils-2pl1SbIp.js";import{t as _}from"./button-Bv4zA1qr.js";import{K as v,Ot as y,Pn as b,Pt as x,Q as S,gt as C,ht as w,it as te,q as ne,t as re}from"./workspace-CJ1PWQ29.js";import{t as T}from"./useEscapeClose-DR_xKT_k.js";import{t as ie}from"./useToastHelpers-CRrpIIdY.js";import{s as E}from"./layer-style-Byl5LNFR.js";import{i as D}from"./color-DFEH4BfK.js";import{t as ae}from"./DocumentIcon-BS10SIP6.js";var O=e(n(),1),k=t();function A({className:e=`h-5 w-5`,...t}){return(0,k.jsxs)(`svg`,{className:`animate-spin ${e}`,xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,...t,children:[(0,k.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,k.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`})]})}var j=e(i(),1);function M(e){let[t,n]=(0,O.useState)(null);(0,O.useEffect)(()=>{if(!e)return;let t=!1;return S(e).then(r=>{t||n({workspaceId:e,predicates:r,error:!1})},()=>{t||n({workspaceId:e,predicates:[],error:!0})}),()=>{t=!0}},[e]);let r=t?.workspaceId===e?t:null;return{predicates:r?.predicates??[],error:r?.error??!1,loading:!!e&&!r}}function N({x:e,y:t,onClose:n,className:r,children:i}){let a=(0,O.useRef)(null),[o,s]=(0,O.useState)({x:e,y:t});return T(n),(0,O.useLayoutEffect)(()=>{let n=a.current;if(!n)return;let{width:r,height:i}=n.getBoundingClientRect();s({x:Math.max(8,Math.min(e,window.innerWidth-r-8)),y:Math.max(8,Math.min(t,window.innerHeight-i-8))})},[e,t]),(0,j.createPortal)((0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:`fixed inset-0 z-menu-scrim`,onClick:n,onContextMenu:e=>{e.preventDefault(),n()}}),(0,k.jsx)(`div`,{ref:a,style:{left:o.x,top:o.y},className:g(`fixed z-menu max-h-viewport-modal overflow-y-auto`,r,`bg-popover text-popover-foreground`),children:i})]}),document.body)}var P=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent),F={Delete:`Del`,Backspace:`⌫`,Enter:`↵`,ArrowUp:`↑`,ArrowDown:`↓`};function I(e){let t=e.split(`+`),n=t.pop()||``,r=F[n]||(n.length===1?n.toUpperCase():n);if(P){let e={Mod:`⌘`,Shift:`⇧`,Alt:`⌥`,Ctrl:`⌃`};return[...[`Ctrl`,`Alt`,`Shift`,`Mod`].filter(e=>t.includes(e)).map(t=>e[t]),r].join(``)}return[...t.map(e=>e===`Mod`?`Ctrl`:e),r].join(`+`)}function oe(e,t){let n=t.split(`+`),r=n.pop()||``;return(P?e.metaKey:e.ctrlKey)!==n.includes(`Mod`)||e.shiftKey!==n.includes(`Shift`)||e.altKey!==n.includes(`Alt`)||P&&e.ctrlKey!==n.includes(`Ctrl`)?!1:r.length===1?e.key.toLowerCase()===r.toLowerCase():e.key===r}function L(e){if(e?.closest?.(`input, textarea, select, [contenteditable="true"], [role="dialog"], [role="menu"]`))return!0;let t=typeof window<`u`?window.getSelection():null;return!!t&&!t.isCollapsed&&t.toString().length>0}function R(e,t){if(e.defaultPrevented||e.nativeEvent.isComposing||L(e.target))return!1;let n=t.find(t=>t.shortcut&&!t.disabled&&oe(e,t.shortcut));return n?(e.preventDefault(),e.stopPropagation(),n.run({shiftKey:e.shiftKey}),!0):!1}function z(e){return e.key===`ContextMenu`||e.key===`F10`&&e.shiftKey}function se(){return typeof window<`u`&&window.matchMedia(`(max-width: 767px)`).matches}function B(e,t=`below`){let n=e.getBoundingClientRect();return t===`below`?{x:n.left,y:n.bottom+4}:{x:n.left+Math.min(24,n.width/2),y:n.top+Math.min(24,n.height/2)}}function V(e){let t=[];for(let n of e){let e=t[t.length-1];e&&(e[0].group??``)===(n.group??``)?e.push(n):t.push([n])}return t}function ce(e,t,n){t(),setTimeout(()=>{e.run({shiftKey:n})},0)}function le({anchor:e,items:t,onClose:n,label:r}){let i=(0,O.useRef)(null);return(0,O.useEffect)(()=>{let e=document.activeElement;return i.current?.querySelector(`[role="menuitem"]:not([aria-disabled="true"])`)?.focus(),()=>{e?.isConnected&&e.focus({preventScroll:!0})}},[]),(0,k.jsx)(N,{x:e.x,y:e.y,onClose:n,className:`min-w-[200px] rounded-lg border bg-popover text-popover-foreground py-1 shadow-elevation-3`,children:(0,k.jsx)(`div`,{ref:i,role:`menu`,"aria-label":r,onKeyDown:e=>{let t=Array.from(i.current?.querySelectorAll(`[role="menuitem"]:not([aria-disabled="true"])`)??[]);if(t.length===0)return;let r=t.indexOf(document.activeElement),a=e=>t[(e+t.length)%t.length]?.focus();switch(e.key){case`ArrowDown`:e.preventDefault(),a(r+1);return;case`ArrowUp`:e.preventDefault(),a(r<0?-1:r-1);return;case`Home`:e.preventDefault(),a(0);return;case`End`:e.preventDefault(),a(-1);return;case`Tab`:e.preventDefault(),n();return}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){let n=e.key.toLowerCase(),i=[...t.slice(r+1),...t.slice(0,r+1)].find(e=>e.textContent?.trim().toLowerCase().startsWith(n));i&&(e.preventDefault(),i.focus())}},onContextMenu:e=>e.preventDefault(),children:V(t).map((e,t)=>(0,k.jsxs)(O.Fragment,{children:[t>0&&(0,k.jsx)(`div`,{role:`separator`,className:`my-1 h-px bg-border`}),e[0].groupLabel&&(0,k.jsx)(`div`,{className:`px-3 py-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:e[0].groupLabel}),e.map(e=>{let t=e.icon;return(0,k.jsxs)(`button`,{type:`button`,role:`menuitem`,tabIndex:-1,"aria-disabled":e.disabled||void 0,title:e.hint,onClick:t=>{e.disabled||ce(e,n,t.shiftKey)},className:g(`flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm outline-none`,e.disabled?`cursor-default opacity-50`:e.destructive?`text-destructive hover:bg-destructive hover:text-destructive-foreground focus:bg-destructive focus:text-destructive-foreground`:`hover:bg-muted focus:bg-muted`),children:[t?(0,k.jsx)(t,{className:`h-3.5 w-3.5 shrink-0`}):(0,k.jsx)(`span`,{className:`w-3.5 shrink-0`}),(0,k.jsx)(`span`,{className:`flex-1 truncate`,children:e.label}),e.shortcut&&(0,k.jsx)(`kbd`,{className:`ml-4 shrink-0 font-sans text-[11px] text-muted-foreground`,children:I(e.shortcut)})]},e.id)})]},`${e[0].group??``}:${t}`))})})}function H({items:e,onClose:t,header:n}){T(t);let r=`flex w-full items-center gap-3 rounded-xl border bg-card px-4 py-3.5 text-base font-medium transition-transform active:scale-[.98]`;return(0,j.createPortal)((0,k.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,className:`fixed inset-0 z-fullscreen flex flex-col bg-popover text-popover-foreground animate-in slide-in-from-bottom-10 fade-in duration-normal`,onClick:t,onContextMenu:e=>e.preventDefault(),children:[(0,k.jsxs)(`div`,{className:`flex shrink-0 items-start gap-3 border-b p-4`,onClick:e=>e.stopPropagation(),children:[(0,k.jsx)(`div`,{className:`min-w-0 flex-1`,children:n}),(0,k.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-sm p-2 hover:bg-muted`,title:`Close`,"aria-label":`Close`,children:(0,k.jsx)(c,{className:`h-5 w-5`})})]}),(0,k.jsx)(`div`,{className:`min-h-4 flex-1`}),(0,k.jsxs)(`div`,{className:`max-h-[75vh] shrink-0 space-y-2 overflow-y-auto px-4 pt-2`,style:{paddingBottom:`calc(var(--safe-bottom) + 1.25rem)`},onClick:e=>e.stopPropagation(),children:[V(e).map((e,n)=>(0,k.jsxs)(`div`,{className:g(`space-y-2`,n>0&&`pt-2`),children:[e[0].groupLabel&&(0,k.jsx)(`div`,{className:`px-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:e[0].groupLabel}),e.map(e=>{let n=e.icon;return(0,k.jsxs)(`button`,{type:`button`,disabled:e.disabled,onClick:n=>ce(e,t,n.shiftKey),className:g(r,e.destructive&&`border-destructive/30 text-destructive`,e.disabled&&`opacity-50`),children:[n&&(0,k.jsx)(n,{className:g(`h-5 w-5 shrink-0`,!e.destructive&&`text-muted-foreground`)}),e.label]},e.id)})]},`${e[0].group??``}:${n}`)),(0,k.jsx)(`button`,{type:`button`,onClick:t,className:`${r} justify-center bg-muted`,children:`Cancel`})]})]}),window.document.body)}function ue({anchor:e,items:t,onClose:n,label:r,header:i}){return t.length===0?null:se()?(0,k.jsx)(H,{items:t,onClose:n,header:i??(r&&(0,k.jsx)(`div`,{className:`truncate text-base font-semibold`,children:r}))}):(0,k.jsx)(le,{anchor:e,items:t,onClose:n,label:r})}function de({items:e,onNavigate:t,disabled:n,className:r,label:i=`Tree path`}){let a=(0,O.useRef)(null),o=e[e.length-1]?.path;return(0,O.useEffect)(()=>{let e=a.current;e&&(e.scrollLeft=e.scrollWidth)},[o]),(0,k.jsx)(`nav`,{"aria-label":i,className:g(`min-w-0 flex-1`,r),children:(0,k.jsx)(`ol`,{ref:a,className:`flex min-w-0 items-center gap-1 overflow-x-auto py-0.5 text-sm`,children:e.map((r,i)=>{let a=i===e.length-1,o=g(`block max-w-56 truncate rounded px-1.5 py-1`,a?`font-medium text-foreground`:`text-muted-foreground`);return(0,k.jsxs)(`li`,{className:`flex shrink-0 items-center gap-1`,children:[i>0&&(0,k.jsx)(`span`,{"aria-hidden":`true`,className:`text-muted-foreground/60`,children:`/`}),t&&!a?(0,k.jsx)(`button`,{type:`button`,title:r.path===`/`?`${r.label} (root)`:r.path,disabled:n,onClick:()=>t(r.path),className:g(o,`hover:bg-accent hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50`),children:r.label}):(0,k.jsx)(`span`,{title:r.path===`/`?r.label:r.path,"aria-current":a?`location`:void 0,className:o,children:r.label})]},r.path)})})})}function U(e,t){let n=e.split(`/`).filter(Boolean);return[{label:t,path:`/`},...n.map((e,t)=>({label:e,path:`/${n.slice(0,t+1).join(`/`)}`}))]}var fe={context:(0,k.jsx)(s,{className:`h-3.5 w-3.5`}),directory:(0,k.jsx)(o,{className:`h-3.5 w-3.5`}),backends:(0,k.jsx)(l,{className:`h-3.5 w-3.5`}),relations:(0,k.jsx)(p,{className:`h-3.5 w-3.5`})},pe={context:`Context tree`,directory:`Directory tree`,backends:`Backends tree`,relations:`Relations`};function W(e,t){return e===`/`?`/${t}`:`${e}/${t}`}function me(e,t){let n=(0,O.useRef)(null),r=(0,O.useRef)(!1),i=()=>{n.current&&=(clearTimeout(n.current),null)},a=e=>t=>{if(r.current){r.current=!1;return}t.detail>1||e()};return t?{guardClick:a,handlers:{onContextMenu:n=>{n.preventDefault(),n.stopPropagation(),t({clientX:n.clientX,clientY:n.clientY,path:e})},onPointerDown:a=>{if(a.pointerType!==`touch`)return;let{clientX:o,clientY:s}=a;i(),n.current=setTimeout(()=>{r.current=!0,t({clientX:o,clientY:s,path:e})},500)},onPointerUp:i,onPointerLeave:i,onPointerMove:i}}:{handlers:{},guardClick:a}}function he(e,t,n){let r=W(t,e.name);return r.toLowerCase().includes(n)||(e.label||``).toLowerCase().includes(n)?!0:e.children?.some(e=>he(e,r,n))??!1}var G=200;function ge({onConfirm:e,onCancel:t,busy:n}){let[r,i]=(0,O.useState)(``);return(0,k.jsxs)(`div`,{className:`flex min-h-11 items-center gap-2 rounded-(--card-radius) bg-card px-3 py-2.5 text-sm shadow-elevation-1`,children:[(0,k.jsx)(u,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,k.jsx)(`input`,{type:`text`,value:r,onChange:e=>i(e.target.value),onKeyDown:n=>{n.key===`Enter`&&r.trim()&&e(r.trim()),n.key===`Escape`&&t()},onBlur:()=>{n||t()},placeholder:`New folder name…`,autoFocus:!0,disabled:n,className:`w-full flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground`}),n&&(0,k.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`Creating…`})]})}function _e({node:e,parentPath:t,query:n,selected:i,onToggle:a,onActivate:o,onRowMenu:s,createParent:c,onCreateConfirm:l,onCreateCancel:u,creating:d}){let f=W(t,e.name),p=!!e.children?.length,[m,_]=(0,O.useState)(!1),{handlers:v,guardClick:y}=me(f,s);if(n&&!he(e,t,n))return null;let b=c===f,x=m||n.length>0||b,S=i.has(f),C=e.type===`canvas`,w=E(e);return(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:g(`group relative flex min-h-11 items-center gap-2 rounded-md px-3 py-2.5 cursor-pointer transition-all select-none text-sm shadow-elevation-1 hover:shadow`,`before:absolute before:left-0 before:top-0 before:bottom-0 before:w-1.5 before:transition-colors`,S?`bg-primary/[0.08] hover:bg-primary/[0.12] before:bg-primary`:`bg-card hover:bg-primary/[0.04] before:bg-transparent`),onClick:y(()=>a(f)),onDoubleClick:e=>{e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||e.target.closest(`button,input,textarea,select,a,[contenteditable="true"]`)||(e.preventDefault(),e.stopPropagation(),p?_(e=>!e):o?.(f))},title:f,...v,children:[(0,k.jsx)(`button`,{type:`button`,"aria-label":`${x?`Collapse`:`Expand`} ${e.label||e.name}`,"aria-expanded":p?x:void 0,disabled:!p,className:g(`shrink-0 text-muted-foreground hover:text-foreground`,!p&&`invisible`),onClick:e=>{e.stopPropagation(),e.detail<=1&&_(e=>!e)},children:x?(0,k.jsx)(ee,{className:`w-4 h-4`}):(0,k.jsx)(h,{className:`w-4 h-4`})}),(0,k.jsx)(r,{icon:w.icon||(C?`ph:squares-four-fill`:`ph:folder-fill`),width:16,height:16,color:D(w.color),className:g(`shrink-0`,!D(w.color)&&(C?`text-primary`:`text-muted-foreground`))}),(0,k.jsx)(`span`,{className:`flex-1 truncate font-medium`,title:e.description||void 0,children:e.label||e.name})]}),x&&p||b?(0,k.jsxs)(`div`,{className:`ml-[22px] mt-1.5 space-y-1.5`,children:[b&&l&&u&&(0,k.jsx)(ge,{busy:d,onConfirm:e=>{_(!0),l(f,e)},onCancel:u}),x&&e.children?.map(e=>(0,k.jsx)(_e,{node:e,parentPath:f,query:n,selected:i,onToggle:a,onActivate:o,onRowMenu:s,createParent:c,onCreateConfirm:l,onCreateCancel:u,creating:d},e.id||e.name))]}):null]})}function ve({workspaces:e,loading:t,onPick:n}){return t&&e.length===0?(0,k.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground`,children:`Loading…`}):e.length===0?(0,k.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground`,children:`No workspaces found`}):(0,k.jsx)(`div`,{className:`space-y-1.5`,children:e.map(e=>{let t=D(e.color);return(0,k.jsxs)(`div`,{onClick:()=>n(e.name),className:`group relative flex cursor-pointer items-center gap-2 rounded-(--card-radius) bg-card px-3 py-2.5 shadow-elevation-1 transition-all hover:bg-accent/50 hover:shadow`,style:{borderRight:`6px solid ${t||`transparent`}`},children:[(0,k.jsx)(r,{icon:e.icon||`ph:stack-fill`,width:18,height:18,color:t,className:g(`shrink-0`,!t&&`text-muted-foreground`)}),(0,k.jsx)(`span`,{className:`flex-1 truncate text-sm font-medium`,children:e.label||e.name}),(0,k.jsx)(h,{className:`h-4 w-4 shrink-0 text-muted-foreground`})]},e.id||e.name)})})}function ye({workspaceName:e,treeTab:t,onTreeTabChange:n,selectedDocIds:r,onToggleDoc:i,onNavigate:a,excludeDocumentIds:o}){let[s,l]=(0,O.useState)(`folder`),[u,d]=(0,O.useState)(``),f=u.trim().toLowerCase(),[p,_]=(0,O.useState)(`/`),[y,x]=(0,O.useState)(null),[S,C]=(0,O.useState)(!1),[w,T]=(0,O.useState)([]),[ie,E]=(0,O.useState)(!1),[D,A]=(0,O.useState)(``),[j,M]=(0,O.useState)(``),[N,P]=(0,O.useState)(t),F=n?t:N,I=e=>{_(`/`),l(`folder`),A(``),M(``),a?.(`/`),n?n(e):P(e)},[oe,L]=(0,O.useState)(F);F!==oe&&(L(F),_(`/`),l(`folder`)),(0,O.useEffect)(()=>{let e=setTimeout(()=>M(D.trim()),300);return()=>clearTimeout(e)},[D]),(0,O.useEffect)(()=>{let t=!1;async function n(){C(!0);try{let n=await v(e,F);t||x(n)}catch{t||x(null)}finally{t||C(!1)}}return n(),()=>{t=!0}},[e,F]),(0,O.useEffect)(()=>{if(s!==`documents`)return;let t=!1,n=F===`directory`?`directory`:re,r=F===`context`?`context`:`directory`;async function i(){E(!0);try{let i=j?await te(e,p,[],{treeName:n,treeType:r,q:j,limit:G}):await ne(e,p,n,{limit:G});t||T(i.payload||[])}catch{t||T([])}finally{t||E(!1)}}return i(),()=>{t=!0}},[e,F,p,s,j]);let R=e=>{_(e),a?.(e)},z=o?.size?w.filter(e=>!o.has(e.id)):w;return s===`folder`?(0,k.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,k.jsxs)(`div`,{className:`shrink-0 space-y-2 border-b bg-muted/30 px-3 py-2`,children:[!n&&(0,k.jsx)(`div`,{className:`flex items-center gap-1 rounded-md border border-input p-0.5`,children:[`context`,`directory`].map(e=>(0,k.jsxs)(`button`,{type:`button`,onClick:()=>I(e),className:g(`flex flex-1 items-center justify-center gap-1.5 rounded px-2 py-1 text-xs transition-colors`,F===e?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground`),title:`Browse the ${pe[e].toLowerCase()}`,children:[fe[e],(0,k.jsx)(`span`,{className:`font-mono`,children:e===`directory`?`dir://`:`ctx://`})]},e))}),(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,k.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Step 1 of 2 · Pick a folder`}),(0,k.jsxs)(`button`,{type:`button`,onClick:()=>l(`documents`),className:`inline-flex items-center gap-1 rounded-md bg-primary px-2.5 py-1 text-xs font-medium text-primary-foreground transition-opacity hover:opacity-90`,children:[`Next `,(0,k.jsx)(h,{className:`h-3.5 w-3.5`})]})]}),(0,k.jsx)(de,{items:U(p,e),onNavigate:R,label:`Folder path`}),(0,k.jsxs)(`div`,{className:`relative`,children:[(0,k.jsx)(m,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,k.jsx)(`input`,{type:`text`,placeholder:`Filter folders…`,value:u,onChange:e=>d(e.target.value),className:`w-full rounded-md border border-input bg-background py-1.5 pl-8 pr-3 text-xs placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring`})]})]}),(0,k.jsx)(`div`,{className:`min-h-0 flex-1 space-y-1.5 overflow-y-auto p-3`,children:S?(0,k.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground`,children:`Loading…`}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:g(`group relative flex min-h-11 items-center gap-2 rounded-md px-3 py-2.5 cursor-pointer transition-all select-none text-sm shadow-elevation-1 hover:shadow`,`before:absolute before:left-0 before:top-0 before:bottom-0 before:w-1.5 before:transition-colors`,p===`/`?`bg-primary/[0.08] hover:bg-primary/[0.12] before:bg-primary`:`bg-card hover:bg-primary/[0.04] before:bg-transparent`),onClick:()=>R(`/`),onDoubleClick:()=>{R(`/`),l(`documents`)},title:`/`,children:[(0,k.jsx)(ee,{className:`w-4 h-4 shrink-0 text-muted-foreground`}),(0,k.jsx)(`span`,{className:`flex-1 truncate font-medium`,children:`/`})]}),(0,k.jsx)(`div`,{className:`ml-[22px] space-y-1.5`,children:y?.children?.length?y.children.map(e=>(0,k.jsx)(_e,{node:e,parentPath:`/`,query:f,selected:new Set([p]),onToggle:R,onActivate:e=>{R(e),l(`documents`)}},e.id||e.name)):(0,k.jsx)(`p`,{className:`px-2 py-1.5 text-xs text-muted-foreground`,children:`Empty tree`})})]})})]}):(0,k.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,k.jsxs)(`div`,{className:`shrink-0 space-y-2 border-b bg-muted/30 px-3 py-2`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:()=>l(`folder`),className:`inline-flex min-w-0 items-center gap-1 rounded-md px-1.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,title:`Back to folders`,children:[(0,k.jsx)(h,{className:`h-3.5 w-3.5 shrink-0 rotate-180`}),(0,k.jsx)(`span`,{children:`Folders`})]}),(0,k.jsx)(`span`,{className:`ml-auto shrink-0 text-xs text-muted-foreground`,children:`Step 2 of 2 · Pick a document`})]}),(0,k.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,k.jsxs)(`span`,{className:`shrink-0 font-mono text-xs text-muted-foreground`,children:[`[`,F,`]`]}),(0,k.jsx)(de,{items:U(p,e),onNavigate:R,label:`Document folder path`})]}),(0,k.jsxs)(`div`,{className:`relative`,children:[(0,k.jsx)(m,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,k.jsx)(`input`,{type:`text`,placeholder:`Search documents in this folder…`,value:D,onChange:e=>A(e.target.value),className:`w-full rounded-md border border-input bg-background py-1.5 pl-8 pr-7 text-xs placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring`}),D&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>A(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,"aria-label":`Clear document search`,children:(0,k.jsx)(c,{className:`h-3.5 w-3.5`})})]})]}),(0,k.jsx)(`div`,{className:`min-h-0 flex-1 space-y-1 overflow-y-auto p-3`,children:ie?(0,k.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground`,children:`Loading documents…`}):z.length===0?(0,k.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground`,children:j?`No documents match “${j}” here.`:`No documents in this folder.`}):z.map(e=>{let t=b(e),n=r.has(e.id);return(0,k.jsxs)(`div`,{onClick:()=>i(e.id),className:g(`flex min-h-9 items-center gap-2 rounded-md px-3 py-1.5 cursor-pointer transition-all select-none text-sm`,n?`bg-primary/[0.08] hover:bg-primary/[0.12]`:`hover:bg-primary/[0.04]`),children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>i(e.id),className:`shrink-0`,onClick:e=>e.stopPropagation()}),(0,k.jsx)(ae,{document:e,size:3.5}),(0,k.jsx)(`span`,{className:`flex-1 truncate`,children:t.title})]},e.id)})})]})}function be({onClose:e,onConfirm:t,documentCount:n,fixedWorkspaceName:r,excludeWorkspace:i,multiple:o=!0,saving:s=!1,savingContent:l,sizeClassName:u,tabs:p=[`context`,`directory`],initialTab:b,title:S,confirmLabel:te,backendFolderCreation:ne,onConfirmRelation:E,relationWorkspaceName:D,relationPredicates:ae,relationExcludeIds:j}){let[N,P]=(0,O.useState)(r?`tree`:`workspace`),[F,I]=(0,O.useState)([]),[oe,L]=(0,O.useState)(!r),[R,z]=(0,O.useState)(r??null),se=b&&p.includes(b)?b:p.includes(`context`)||p.includes(`directory`)?`pins`:p[0]??`context`,[B,V]=(0,O.useState)(se),ce=M(p.includes(`relations`)&&!ae?D??R:null),H=ae??ce.predicates,[ue,de]=(0,O.useState)(``),U=H.includes(ue)?ue:H[0]??``,[W,he]=(0,O.useState)(`out`),[G,be]=(0,O.useState)(new Set),[xe,Se]=(0,O.useState)(null),[K,Ce]=(0,O.useState)(`context`),[we,Te]=(0,O.useState)(!1),Ee=B===`pins`?K:B;(0,O.useEffect)(()=>{if(!R)return;let e=!1;return y(R).then(t=>{e||Se(t)}).catch(()=>{e||Te(!0)}),()=>{e=!0}},[R]);let q=B===`relations`,[De,Oe]=(0,O.useState)(null),[ke,Ae]=(0,O.useState)(!1),[J,Y]=(0,O.useState)(new Set),[je,Me]=(0,O.useState)(``),Ne=je.trim().toLowerCase(),{showErrorToast:Pe}=ie(),[X,Fe]=(0,O.useState)(null),[Ie,Z]=(0,O.useState)(null),[Q,Le]=(0,O.useState)(!1);T(e,!s&&!Q);let Re=me(`/`,e=>Fe(e)),ze=e=>!s&&(B===`backends`?ne?.canCreate(e)===!0:B!==`pins`&&B!==`relations`),Be=async(e,t)=>{let n=t.trim().replace(/^\/+|\/+$/g,``);if(!(!n||!R||Q||!ze(e))){Le(!0);try{let t=`${e===`/`?``:e}/${n}`,r=B===`context`?re:B;B===`backends`?await ne.create(e,n):await w(R,t,!0,r),C(R,r),window.dispatchEvent(new CustomEvent(`workspace:tree:refresh`,{detail:{workspaceName:R,treeName:r,cacheInvalidated:!0}}));let i=await v(R,B);Oe(i),Y(e=>o?new Set([...e,t]):new Set([t])),Me(``),Z(null)}catch(e){Pe(e instanceof Error?e.message:`Failed to create folder`)}finally{Le(!1)}}},[Ve,He]=(0,O.useState)(r);r!==Ve&&(He(r),r||L(!0)),(0,O.useEffect)(()=>{r||x().then(e=>I(e.filter(e=>e.id!==i&&e.name!==i))).catch(()=>I([])).finally(()=>L(!1))},[r,i]),(0,O.useEffect)(()=>{if(!R||B===`relations`||B===`pins`)return;let e=!1,t=0;async function n(n=!1){let r=++t;n||Ae(!0);try{let n=await v(R,B);!e&&r===t&&Oe(n)}catch{!e&&r===t&&!n&&Oe(null)}finally{!e&&r===t&&Ae(!1)}}let r=e=>{let t=e.detail;t?.workspaceName&&t.workspaceName!==R||t?.treeName&&t.treeName!==B||(t?.cacheInvalidated||C(R,B),n(!0))};return window.addEventListener(`workspace:tree:refresh`,r),n(),()=>{e=!0,window.removeEventListener(`workspace:tree:refresh`,r)}},[R,B]);let Ue=e=>{e!==R&&(Se(null),Te(!1)),V(se),z(e),Y(new Set),be(new Set),P(`tree`)},We=e=>{be(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Ge=e=>{if(!o){Y(new Set([e]));return}Y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Ke=q?!!U&&G.size>0&&!!E:J.size>0,qe=async()=>{if(!(!R||s||!Ke)){if(q){await E?.({predicate:U,direction:W,targetIds:Array.from(G)},{workspaceName:D??R});return}await t(Array.from(J),{workspaceName:R,treeName:Ee===`context`?re:Ee,treeType:Ee===`context`?`context`:`directory`})}},$=n??1;return s&&l?(0,k.jsx)(`div`,{className:g(`flex flex-col overflow-hidden rounded-(--panel-radius) border bg-card shadow-elevation-4`,u||`h-viewport-card max-h-full w-[min(380px,90vw)] max-md:h-full max-md:w-full max-md:shadow-elevation-5`),children:l}):(0,k.jsxs)(`div`,{className:g(`flex flex-col overflow-hidden rounded-(--panel-radius) border bg-card shadow-elevation-4`,u||`h-viewport-card max-h-full w-[min(380px,90vw)] max-md:h-full max-md:w-full max-md:shadow-elevation-5`),children:[(0,k.jsxs)(`div`,{className:`flex h-12 shrink-0 items-center justify-between border-b px-4`,children:[(0,k.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,k.jsx)(f,{className:`h-4 w-4`}),S??(N===`workspace`?`Link to…`:q?`Relate ${$} document${$===1?``:`s`} to…`:`Link ${$} document${$===1?``:`s`} to…`)]}),(0,k.jsx)(`button`,{type:`button`,onClick:e,disabled:s||Q,className:`text-muted-foreground transition-colors hover:text-foreground disabled:opacity-40`,"aria-label":`Close`,children:(0,k.jsx)(c,{className:`h-4 w-4`})})]}),(0,k.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:(0,k.jsxs)(`div`,{className:`grid h-full w-[200%] grid-cols-2 transition-transform duration-normal`,style:{transform:N===`workspace`?`translateX(0)`:`translateX(-50%)`},children:[(0,k.jsx)(`div`,{className:`flex min-w-0 flex-col overflow-y-auto p-2`,children:(0,k.jsx)(ve,{workspaces:F,loading:oe,onPick:Ue})}),(0,k.jsxs)(`div`,{className:`flex min-w-0 flex-col overflow-hidden`,children:[(0,k.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 overflow-x-auto border-b px-2 pt-2`,children:[!r&&(0,k.jsx)(`button`,{type:`button`,disabled:Q,onClick:()=>P(`workspace`),className:`mr-1 rounded p-1.5 text-muted-foreground hover:bg-muted hover:text-foreground touch-target`,"aria-label":`Back to workspaces`,children:(0,k.jsx)(h,{className:`h-4 w-4 rotate-180`})}),(p.includes(`context`)||p.includes(`directory`))&&(0,k.jsxs)(`button`,{type:`button`,disabled:Q,onClick:()=>{V(`pins`),Y(new Set),Z(null)},className:g(`flex shrink-0 items-center gap-1.5 border-b-2 px-3 py-2 text-xs`,B===`pins`?`border-primary`:`border-transparent text-muted-foreground`),children:[(0,k.jsx)(a,{className:`h-3.5 w-3.5`}),`Pins`]}),p.map(e=>(0,k.jsxs)(`button`,{type:`button`,disabled:Q,onClick:()=>{V(e),Y(new Set),Z(null)},className:g(`flex shrink-0 items-center gap-1.5 rounded-t-md border-b-2 px-3 py-2 text-xs font-medium transition-colors`,B===e?`border-primary text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:[fe[e],pe[e]]},e))]}),!q&&(0,k.jsx)(`div`,{className:`shrink-0 border-b p-2`,children:(0,k.jsxs)(`div`,{className:`relative`,children:[(0,k.jsx)(m,{className:`pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`}),(0,k.jsx)(`input`,{type:`text`,placeholder:`Search paths…`,value:je,onChange:e=>Me(e.target.value),className:`w-full rounded-md border border-input bg-background py-2 pl-9 pr-3 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring`})]})}),q&&(0,k.jsxs)(`div`,{className:`shrink-0 space-y-2 border-b bg-primary/[0.04] px-3 py-2`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(`label`,{htmlFor:`relation-predicate`,className:`shrink-0 text-xs text-muted-foreground`,children:`Predicate`}),(0,k.jsx)(`select`,{id:`relation-predicate`,value:U,onChange:e=>de(e.target.value),className:`min-w-0 flex-1 rounded-md border border-input bg-background px-2 py-1.5 text-xs focus:outline-none focus:ring-2 focus:ring-ring`,children:H.map(e=>(0,k.jsx)(`option`,{value:e,children:e},e))})]}),(0,k.jsx)(`div`,{className:`flex items-center gap-1`,children:[{dir:`out`,label:`This → picked`,hint:`the ${$===1?`document`:`documents`} you started from ${U} the picked one(s)`},{dir:`in`,label:`Picked → this`,hint:`the picked document(s) ${U} the ${$===1?`one`:`ones`} you started from`}].map(({dir:e,label:t,hint:n})=>(0,k.jsx)(`button`,{type:`button`,title:n,onClick:()=>he(e),className:g(`flex-1 rounded-md border px-2 py-1.5 text-xs transition-colors`,W===e?`border-primary bg-primary text-primary-foreground`:`border-input hover:bg-accent`),children:t},e))})]}),!q&&o&&(0,k.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center gap-1.5 overflow-x-auto border-b bg-primary/[0.04] px-3`,children:[!J.size&&(0,k.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Selected folders appear here`}),Array.from(J).map(e=>(0,k.jsxs)(`span`,{className:`inline-flex max-w-full shrink-0 items-center gap-1 rounded-full bg-primary px-2 py-0.5 text-xs text-primary-foreground`,children:[(0,k.jsx)(`span`,{className:`truncate`,title:e,children:e}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>Ge(e),className:`shrink-0 rounded-full hover:bg-primary-foreground/20`,"aria-label":`Remove ${e}`,children:(0,k.jsx)(c,{className:`h-3 w-3`})})]},e))]}),q&&(D??R)&&(0,k.jsx)(ye,{workspaceName:D??R,treeTab:`context`,selectedDocIds:G,onToggleDoc:We,excludeDocumentIds:j}),B===`pins`&&(0,k.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3 space-y-2`,children:[!xe&&!we&&(0,k.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading pins…`}),we&&(0,k.jsx)(`p`,{className:`text-xs text-destructive`,children:`Could not load pins. You can still browse the trees.`}),!we&&xe?.length===0&&(0,k.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No pinned paths yet. Choose a path from a tree.`}),xe?.filter(e=>e.resolvable!==!1&&p.includes(e.tree===`context`?`context`:e.tree)&&`${e.label??e.name??``} ${e.path}`.toLowerCase().includes(Ne)).map(e=>{let t=e.tree===`context`?`context`:e.tree;return(0,k.jsxs)(`button`,{type:`button`,"aria-pressed":K===t&&J.has(e.path),className:g(`w-full rounded-md border p-3 text-left text-sm hover:bg-muted`,K===t&&J.has(e.path)&&`border-primary bg-primary/10`),onClick:()=>{K===t?Ge(e.path):(Ce(t),Y(new Set([e.path])))},children:[(0,k.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(a,{className:`h-3.5 w-3.5`}),e.label||e.name||e.path]}),(0,k.jsxs)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:[t,` · `,e.path]})]},e.id)})]}),(0,k.jsx)(`div`,{className:g(`min-h-0 flex-1 space-y-1.5 overflow-y-auto p-3`,(q||B===`pins`)&&`hidden`),children:ke?(0,k.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground`,children:`Loading…`}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:g(`group relative flex min-h-11 items-center gap-2 rounded-md px-3 py-2.5 cursor-pointer transition-all select-none text-sm shadow-elevation-1 hover:shadow`,`before:absolute before:left-0 before:top-0 before:bottom-0 before:w-1.5 before:transition-colors`,J.has(`/`)?`bg-primary/[0.08] hover:bg-primary/[0.12] before:bg-primary`:`bg-card hover:bg-primary/[0.04] before:bg-transparent`),onClick:Re.guardClick(()=>Ge(`/`)),title:`/`,...ze(`/`)?Re.handlers:{},children:[(0,k.jsx)(ee,{className:`w-4 h-4 shrink-0 text-muted-foreground`}),(0,k.jsx)(`span`,{className:`flex-1 truncate font-medium`,children:`/`})]}),(0,k.jsxs)(`div`,{className:`ml-[22px] space-y-1.5`,children:[Ie===`/`&&(0,k.jsx)(ge,{busy:Q,onConfirm:e=>Be(`/`,e),onCancel:()=>Z(null)}),De?.children?.length?De.children.map(e=>(0,k.jsx)(_e,{node:e,parentPath:`/`,query:Ne,selected:J,onToggle:Ge,onRowMenu:e=>{ze(e.path)&&Fe(e)},createParent:Ie,onCreateConfirm:Be,onCreateCancel:()=>Z(null),creating:Q},e.id||e.name)):Ie===`/`?null:(0,k.jsx)(`p`,{className:`px-2 py-1.5 text-xs text-muted-foreground`,children:`Empty tree`})]})]})})]})]})}),N===`tree`&&(0,k.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-t px-4 py-3`,children:[(0,k.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:q?`${G.size} document${G.size===1?``:`s`} selected`:`${J.size} path${J.size===1?``:`s`} selected`}),(0,k.jsx)(_,{size:`sm`,onClick:qe,disabled:!Ke||s||Q,children:s?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(A,{className:`mr-1.5 h-3.5 w-3.5`}),q?`Relating…`:`Linking…`]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f,{className:`mr-1 h-3.5 w-3.5`}),q?`Relate`:te??`Link`]})})]}),X&&(0,k.jsx)(le,{anchor:{x:X.clientX,y:X.clientY},onClose:()=>Fe(null),items:[{id:`new-folder`,label:`New folder in ${X.path}`,icon:d,run:()=>Z(X.path)}]})]})}export{A as _,pe as a,ue as c,I as d,z as f,M as g,N as h,fe as i,B as l,oe as m,ye as n,U as o,L as p,ve as r,de as s,be as t,R as u};
@@ -0,0 +1 @@
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t}from"./code-editor-BOIngd5F.js";import{yt as n}from"./react-BHzhHVTZ.js";var r=e(n(),1),i=t(),a=`h-full w-[380px] max-w-[90vw] max-md:w-full`;function o({onClose:e,children:t}){return(0,r.createPortal)((0,i.jsx)(`div`,{className:`fixed inset-0 z-picker flex items-stretch justify-end bg-scrim animate-fade-in`,onClick:e,children:(0,i.jsx)(`div`,{className:`h-full p-2 max-md:w-full max-md:p-1`,onClick:e=>e.stopPropagation(),children:t})}),window.document.body)}export{o as n,a as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BQnKd3jw.js";import{n as r}from"./map-BxCwdK0d.js";var i=e(n(),1),a=e(r(),1),o=t();function s({lat:e,lon:t}){let n=(0,i.useRef)(null);return(0,i.useEffect)(()=>{if(!n.current)return;let r=a.default.map(n.current).setView([e,t],14);a.default.tileLayer(`https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png`,{attribution:`&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors`,maxZoom:19}).addTo(r),a.default.circleMarker([e,t],{radius:8,color:`#ffffff`,weight:2,fillColor:`#8b5cf6`,fillOpacity:1}).addTo(r);let i=new ResizeObserver(()=>r.invalidateSize());return i.observe(n.current),()=>{i.disconnect(),r.remove()}},[e,t]),(0,o.jsxs)(`div`,{className:`flex h-full min-h-80 flex-col gap-3`,children:[(0,o.jsxs)(`p`,{className:`text-sm tabular-nums`,children:[e.toFixed(5),`, `,t.toFixed(5)]}),(0,o.jsx)(`div`,{ref:n,role:`region`,"aria-label":`Document location map`,className:`relative z-0 min-h-64 flex-1 overflow-hidden rounded-md border`})]})}export{s 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{n as r}from"./map-BxCwdK0d.js";var i=e(n(),1),a=e(r(),1),o=t();function s({lat:e,lon:t}){let n=(0,i.useRef)(null);return(0,i.useEffect)(()=>{if(!n.current)return;let r=a.default.map(n.current).setView([e,t],14);a.default.tileLayer(`https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png`,{attribution:`&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors`,maxZoom:19}).addTo(r),a.default.circleMarker([e,t],{radius:8,color:`#ffffff`,weight:2,fillColor:`#8b5cf6`,fillOpacity:1}).addTo(r);let i=new ResizeObserver(()=>r.invalidateSize());return i.observe(n.current),()=>{i.disconnect(),r.remove()}},[e,t]),(0,o.jsxs)(`div`,{className:`flex h-full min-h-80 flex-col gap-3`,children:[(0,o.jsxs)(`p`,{className:`text-sm tabular-nums`,children:[e.toFixed(5),`, `,t.toFixed(5)]}),(0,o.jsx)(`div`,{ref:n,role:`region`,"aria-label":`Document location map`,className:`relative z-0 min-h-64 flex-1 overflow-hidden rounded-md border`})]})}export{s as default};
@@ -1,4 +1,4 @@
1
- import{o as e,r as t,t as n}from"./rolldown-runtime-C0FnF6B9.js";import{l as r,u as i}from"./code-editor-BQnKd3jw.js";import{$ as a,A as o,B as s,C as c,D as l,E as u,F as d,G as f,H as p,I as m,J as h,K as g,L as _,M as v,N as y,O as b,P as ee,Q as x,R as S,S as te,T as ne,U as C,V as re,W as ie,X as w,Y as T,Z as ae,_ as oe,at as se,b as ce,c as le,d as E,et as ue,f as de,g as fe,h as pe,it as me,j as he,k as ge,l as _e,m as D,nt as ve,ot as O,p as k,q as ye,rt as A,tt as be,v as xe,w as Se,x as Ce,y as we,z as Te}from"./react-BzqgEMSQ.js";import{Fn as Ee,In as De,Tn as Oe,Tr as ke,et as Ae,fn as je,hn as Me,mn as Ne,qt as Pe,ti as Fe}from"./ui-BqHBdBU4.js";import{t as Ie}from"./utils-2pl1SbIp.js";import{a as Le,i as Re,n as ze,o as Be,r as Ve,t as He}from"./punycode.es6-ZbLrB_Dn.js";import{t as Ue}from"./use-theme-Bd8sb5Ox.js";var We=(e,t)=>{if(e===`slot`)return 0;if(e instanceof Function)return e(t);let{children:n,...r}=t??{};if(e===`svg`)throw Error(`SVG elements are not supported in the JSX syntax, use the array syntax instead`);return[e,r,n]},Ge=e(i(),1),Ke=(e,t)=>{let{state:n}=e,{selection:r}=n;if(!r.empty)return!1;let{$from:i}=r;if(i.parentOffset!==0)return!1;let a=i.depth-1;if(a<0)return!1;let o=i.node(a),s=i.index(a);if(s===0)return!1;if(o.type===t)return e.commands.lift(t.name);let c=o.child(s-1);if(c.type!==t||!c.lastChild?.isTextblock)return!1;let l=i.before()-1-1;return e.commands.command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=i.parent.content,r=new O(n,0,0);return e.replace(l,i.after(),r),e.setSelection(x.create(e.doc,l+n.size)),e.scrollIntoView(),t(e),!0})},qe=/^\s*>\s$/,Je=D.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return We(`blockquote`,{...S(this.options.HTMLAttributes,e),children:We(`slot`,{})})},parseMarkdown:(e,t)=>{let n=t.parseBlockChildren??t.parseChildren;return t.createNode(`blockquote`,void 0,n(e.tokens||[]))},renderMarkdown:(e,t)=>{if(!e.content)return``;let n=[];return e.content.forEach((e,r)=>{let i=(t.renderChild?.call(t,e,r)??t.renderChildren([e])).split(`
1
+ import{o as e,r as t,t as n}from"./rolldown-runtime-C0FnF6B9.js";import{l as r,u as i}from"./code-editor-BOIngd5F.js";import{$ as a,A as o,B as s,C as c,D as l,E as u,F as d,G as f,H as p,I as m,J as h,K as g,L as _,M as v,N as y,O as b,P as ee,Q as x,R as S,S as te,T as ne,U as C,V as re,W as ie,X as w,Y as T,Z as ae,_ as oe,at as se,b as ce,c as le,d as E,et as ue,f as de,g as fe,h as pe,it as me,j as he,k as ge,l as _e,m as D,nt as ve,ot as O,p as k,q as ye,rt as A,tt as be,v as xe,w as Se,x as Ce,y as we,z as Te}from"./react-BHzhHVTZ.js";import{Fn as Ee,In as De,Tn as Oe,Tr as ke,et as Ae,fn as je,hn as Me,mn as Ne,qt as Pe,ti as Fe}from"./ui-BSqPn1LJ.js";import{t as Ie}from"./utils-2pl1SbIp.js";import{a as Le,i as Re,n as ze,o as Be,r as Ve,t as He}from"./punycode.es6-ZbLrB_Dn.js";import{t as Ue}from"./use-theme-DaxpiICf.js";var We=(e,t)=>{if(e===`slot`)return 0;if(e instanceof Function)return e(t);let{children:n,...r}=t??{};if(e===`svg`)throw Error(`SVG elements are not supported in the JSX syntax, use the array syntax instead`);return[e,r,n]},Ge=e(i(),1),Ke=(e,t)=>{let{state:n}=e,{selection:r}=n;if(!r.empty)return!1;let{$from:i}=r;if(i.parentOffset!==0)return!1;let a=i.depth-1;if(a<0)return!1;let o=i.node(a),s=i.index(a);if(s===0)return!1;if(o.type===t)return e.commands.lift(t.name);let c=o.child(s-1);if(c.type!==t||!c.lastChild?.isTextblock)return!1;let l=i.before()-1-1;return e.commands.command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=i.parent.content,r=new O(n,0,0);return e.replace(l,i.after(),r),e.setSelection(x.create(e.doc,l+n.size)),e.scrollIntoView(),t(e),!0})},qe=/^\s*>\s$/,Je=D.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return We(`blockquote`,{...S(this.options.HTMLAttributes,e),children:We(`slot`,{})})},parseMarkdown:(e,t)=>{let n=t.parseBlockChildren??t.parseChildren;return t.createNode(`blockquote`,void 0,n(e.tokens||[]))},renderMarkdown:(e,t)=>{if(!e.content)return``;let n=[];return e.content.forEach((e,r)=>{let i=(t.renderChild?.call(t,e,r)??t.renderChildren([e])).split(`
2
2
  `).map(e=>e.trim()===``?`>`:`> ${e}`);n.push(i.join(`
3
3
  `))}),n.join(`
4
4
  >
@@ -0,0 +1,4 @@
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{t as r}from"./button-Bv4zA1qr.js";import{t as i}from"./input-BOtCd4HP.js";import{c as a,t as o}from"./api-CA6WiiYM.js";import{t as s}from"./markdown-it-DRESbtwK.js";import{t as c}from"./lazy-editor-Cbva8Pe2.js";var l=t();function u({tabs:e,active:t,onChange:n,className:r=``,iconOnly:i=!1}){return(0,l.jsx)(`div`,{className:`flex gap-1 border-b overflow-x-auto ${r}`,children:e.map(e=>{let r=e.icon;return(0,l.jsxs)(`button`,{onClick:()=>n(e.id),title:e.label,className:`${i&&r?`px-3`:`px-4`} py-2 text-sm font-medium border-b-2 transition-colors whitespace-nowrap inline-flex items-center gap-1.5 ${t===e.id?`border-primary text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:[r&&(0,l.jsx)(r,{className:`h-3.5 w-3.5`}),(!i||!r)&&e.label]},e.id)})})}var d=e(n(),1),f=e=>`${a.workspaces}/${encodeURIComponent(e)}/messages`,p=e=>o.get(`${f(e)}/accounts`),m=(e,t)=>o.get(`${f(e)}/reply-target/${t}`),h=(e,t)=>o.post(`${f(e)}/send`,t),g=(e,t)=>o.get(`${f(e)}/whatsapp/${encodeURIComponent(t)}/connection`),_=(e,t)=>o.get(`${f(e)}/outbox/${encodeURIComponent(t)}`),v=(e,t)=>o.delete(`${f(e)}/whatsapp/${encodeURIComponent(t)}/connection`),y=(e,t)=>o.get(`${f(e)}/thread/${t}`),b=new s({html:!1});function x(e){let t=e=>{let n=[];return e.map(e=>{if(e.children)return t(e.children);switch(e.type){case`strong_open`:case`strong_close`:return`*`;case`em_open`:case`em_close`:return`_`;case`s_open`:case`s_close`:return`~`;case`code_inline`:return`\`${e.content}\``;case`fence`:case`code_block`:return`\`\`\`\n${e.content}\`\`\`\n`;case`text`:return e.content;case`softbreak`:case`hardbreak`:return`
2
+ `;case`paragraph_close`:case`heading_close`:return`
3
+
4
+ `;case`list_item_open`:return`- `;case`link_open`:return n.push(String(e.attrGet(`href`)||``)),``;case`link_close`:return` (${n.pop()||``})`;case`image`:return e.content;default:return``}}).join(``)};return t(b.parse(e,{})).trim()}function S(e,t,n=!1){let r=2166136261;try{for(let e of localStorage.getItem(`authToken`)||``)r=Math.imul(r^e.charCodeAt(0),16777619)}catch{}return`canvas:message-draft:${r>>>0}:${e}:${t||`new`}${n?`:fwd`:``}`}var C={reply:`Reply`,replyAll:`Reply all`,forward:`Forward`};function w({workspaceId:e,replyToDocumentId:t,mode:n=`reply`,originalSubject:a,initialAccount:o,testEmail:s=!1,onClose:u}){let f=!!t&&n===`forward`,g=s?`${S(e)}:smtp-test:${o?.address}`:S(e,t,f),v=()=>({requestId:crypto.randomUUID(),text:s?`This is a test email sent from Canvas to check the SMTP configuration.`:``,replyToDocumentId:t,...o,...s?{subject:`Canvas SMTP test`}:{},...f?{forward:!0}:t?{replyAll:n===`replyAll`,quote:!0}:{}}),[y,b]=(0,d.useState)(()=>{try{let e=localStorage.getItem(g);if(e){let r=JSON.parse(e),i=r.draft||r;if(f||!t||r.attempted)return i;let a=n===`replyAll`;return{...i,replyAll:a,...!!i.replyAll===a?{}:{to:void 0,cc:void 0}}}}catch{}return v()}),[w,T]=(0,d.useState)(null),[E,D]=(0,d.useState)([]),[O,k]=(0,d.useState)(navigator.onLine);(0,d.useEffect)(()=>{let e=()=>k(navigator.onLine);return window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}},[]);let A=(0,d.useRef)(!1),[j,M]=(0,d.useState)(!1),[N,P]=(0,d.useState)(!1),[F,I]=(0,d.useState)(()=>{try{return JSON.parse(localStorage.getItem(g)||`{}`).attempted===!0}catch{return!1}}),[L,R]=(0,d.useState)(``),[z,B]=(0,d.useState)(null);(0,d.useEffect)(()=>{let n=!0;return Promise.all([p(e),t?m(e,t):Promise.resolve(null)]).then(([e,r])=>{n&&(T(r),D(e.filter(e=>e.canSend&&(!r||e.driver===r.driver&&e.address===r.address))),t&&!r&&R(`This message has no supported reply account.`),r&&b(e=>{let t=e.replyAll?r.allRecipients:r.recipients;return{...e,driver:r.driver,address:r.address,...!f&&t&&!F?{to:e.to?.some(e=>e.trim())?e.to:t.to,cc:e.cc?.some(e=>e.trim())?e.cc:t.cc}:{}}}))}).catch(e=>{n&&R(e.message)}),()=>{n=!1}},[e,t,f,F]),(0,d.useEffect)(()=>{try{z?.status===`accepted`?localStorage.removeItem(g):localStorage.setItem(g,JSON.stringify({draft:y,attempted:F}))}catch{}},[g,y,F,z]);let V=E.find(e=>e.driver===y.driver&&e.address===y.address),H=V?.driver===`imap`,U=V?.driver===`whatsapp`,W=!!y.images?.length,G=!!y.text.trim(),K=e=>b(t=>({...t,...e})),q=async()=>{P(!0),R(``),I(!0);let t=H?G?y:{...y,html:void 0}:{...y,text:U?x(y.text):y.text,html:void 0,quote:void 0,forward:void 0};try{let n=F?await _(e,y.requestId).catch(n=>{if(n.statusCode===404)return h(e,t);throw n}):await h(e,t);if(B(n),n.status===`accepted`){try{localStorage.removeItem(g)}catch{}window.dispatchEvent(new CustomEvent(`workspace:documents:refresh`,{detail:{workspaceName:e}}))}}catch(e){let t=e;R(t.message),!F&&t.statusCode&&t.statusCode>=400&&t.statusCode<500&&t.statusCode!==409&&I(!1)}finally{P(!1)}},J=async e=>{if(X||A.current)return;let t=e.filter(e=>[`image/png`,`image/jpeg`,`image/webp`,`image/gif`].includes(e.type));if(t.length){if((y.images?.length||0)+t.length>(U?1:8)){R(U?`One picture per WhatsApp reply.`:`Up to 8 pictures per email.`);return}if((y.images||[]).reduce((e,t)=>e+t.base64.length*3/4,0)+t.reduce((e,t)=>e+t.size,0)>8388608){R(`Pictures must total at most 8 MB.`);return}A.current=!0,M(!0);try{let e=await Promise.all(t.map(e=>new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(Error(`Could not read picture`)),r.onload=()=>t({name:e.name,mimeType:e.type,base64:String(r.result).split(`,`)[1]}),r.readAsDataURL(e)})));b(t=>({...t,images:[...t.images||[],...e]})),R(``)}catch(e){R(e instanceof Error?e.message:`Could not read picture`)}finally{A.current=!1,M(!1)}}},Y=y.replyAll?w?.allRecipients:w?.recipients,X=N||F||j,Z=s?`Send test email`:t?f?C.forward:C[y.replyAll?`replyAll`:`reply`]:`New message`,Q=t&&a?`${f?`Fwd`:`Re`}: ${a.replace(f?/^(fwd?|fw):\s*/i:/^re:\s*/i,``)}`:``;return(0,l.jsxs)(`section`,{onPasteCapture:e=>{if(!(H||U))return;let t=Array.from(e.clipboardData.files);t.some(e=>e.type.startsWith(`image/`))&&(e.preventDefault(),e.stopPropagation(),J(t))},className:`max-h-[70dvh] overflow-y-auto rounded-md border bg-card p-3 space-y-3`,"aria-label":t?`${Z} to message`:`New message`,children:[(0,l.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,l.jsx)(`strong`,{className:`text-sm`,children:Z}),(0,l.jsx)(r,{size:`sm`,variant:`ghost`,onClick:u,children:`Close`})]}),(0,l.jsxs)(`label`,{className:`block text-xs`,children:[`Send from`,(0,l.jsxs)(`select`,{"aria-label":`Sending account`,className:`w-full rounded border bg-background p-2`,value:V?`${V.driver}:${V.address}`:``,disabled:X||!!t||!!o,onChange:e=>{let t=E.find(t=>`${t.driver}:${t.address}`===e.target.value);t&&K({driver:t.driver,address:t.address,to:[],cc:[],bcc:[],subject:void 0,target:void 0,images:void 0,replyAll:!1})},children:[(0,l.jsx)(`option`,{value:``,children:`Select an enabled sending account`}),E.map(e=>(0,l.jsxs)(`option`,{value:`${e.driver}:${e.address}`,children:[e.driver,` · `,e.from||e.address]},`${e.driver}:${e.address}`))]})]}),s&&(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Uses the saved SMTP settings. Enter a recipient you control, then click Send. This sends a real email; provider acceptance does not guarantee inbox delivery.`}),!E.length&&(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Enable sending in the account’s workspace settings. Your draft stays on this device.`}),H?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`label`,{className:`block text-xs`,children:[`To `,t&&!f?`(leave blank to reply to the sender)`:``,(0,l.jsx)(i,{"aria-label":`To`,disabled:X,value:y.to?.join(`, `)||``,onChange:e=>K({to:[e.target.value]})})]}),t&&!f&&!y.to?.some(e=>e.trim())&&Y&&(0,l.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Reply to: `,Y.to.join(`, `),Y.cc.length?` · Cc: ${Y.cc.join(`, `)}`:``]}),[`cc`,`bcc`].map(e=>(0,l.jsxs)(`label`,{className:`block text-xs`,children:[e===`cc`?`Cc`:`Bcc`,(0,l.jsx)(i,{"aria-label":e===`cc`?`Cc`:`Bcc`,disabled:X,value:y[e]?.join(`, `)||``,onChange:t=>K({[e]:[t.target.value]})})]},e)),(0,l.jsxs)(`label`,{className:`block text-xs`,children:[`Subject`,(0,l.jsx)(i,{"aria-label":`Subject`,disabled:X,value:y.subject||``,placeholder:Q,onChange:e=>K({subject:e.target.value||void 0})})]}),t&&!f&&(0,l.jsxs)(`div`,{className:`flex flex-wrap gap-4 text-xs`,children:[(0,l.jsxs)(`label`,{className:`flex gap-2`,children:[(0,l.jsx)(`input`,{type:`checkbox`,disabled:X,checked:y.replyAll||!1,onChange:e=>{let t=e.target.checked?w?.allRecipients:w?.recipients;K({replyAll:e.target.checked,...t?{to:t.to,cc:t.cc}:{}})}}),`Reply all`]}),(0,l.jsxs)(`label`,{className:`flex gap-2`,children:[(0,l.jsx)(`input`,{type:`checkbox`,disabled:X,checked:y.quote||!1,onChange:e=>K({quote:e.target.checked})}),`Quote original message`]})]}),f&&(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The original message and its attachments are included below your note.`}),(0,l.jsx)(c,{format:`html`,editable:!X,value:y.html||``,placeholder:f?`Add a note (optional)…`:`Write a message…`,onChange:(e,t)=>K({html:e,text:t.slice(0,32e3)})})]}):(0,l.jsxs)(l.Fragment,{children:[!t&&(0,l.jsxs)(`label`,{className:`block text-xs`,children:[`Conversation (configured channel name or ID)`,(0,l.jsx)(i,{"aria-label":`Conversation`,disabled:X,value:y.target||``,onChange:e=>K({target:e.target.value})})]}),U?(0,l.jsx)(c,{format:`markdown`,editable:!X,value:y.text,placeholder:`Write a message…`,onChange:e=>K({text:e.slice(0,32e3)})}):(0,l.jsx)(`textarea`,{"aria-label":`Message text`,className:`w-full rounded border bg-background p-2 text-sm`,rows:5,maxLength:32e3,disabled:X,value:y.text,onChange:e=>K({text:e.target.value}),placeholder:`Write a message…`})]}),(H||U)&&(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsxs)(`label`,{className:`block text-xs`,children:[`Paste a picture into the reply, or attach one`,(0,l.jsx)(`input`,{"aria-label":`Attach pictures`,className:`block`,type:`file`,accept:`image/png,image/jpeg,image/webp,image/gif`,multiple:!U,disabled:X,onChange:e=>{J(Array.from(e.target.files||[])),e.target.value=``}})]}),y.images?.map((e,t)=>(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`img`,{className:`h-20 w-20 rounded object-contain`,src:`data:${e.mimeType};base64,${e.base64}`,alt:e.name}),(0,l.jsx)(`span`,{className:`text-xs`,children:e.name}),(0,l.jsx)(r,{size:`sm`,variant:`ghost`,disabled:X,onClick:()=>K({images:y.images?.filter((e,n)=>n!==t)}),children:`Remove picture`})]},t)),U&&(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Bold, italic, strikethrough and code are supported. Your reply becomes the picture caption.`})]}),L&&(0,l.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:L}),z&&(0,l.jsxs)(`p`,{role:`status`,className:`text-sm`,children:[z.status===`accepted`?`Accepted by the provider.`:z.message,` `,z.warnings?.join(` `),` `,z.rejected?.length?`Not accepted for: ${z.rejected.join(`, `)}`:``]}),z?.status!==`accepted`&&(0,l.jsx)(r,{size:`sm`,disabled:N||j||!F&&(!V||!G&&!W&&!(H&&f)||f&&!y.to?.some(e=>e.trim()))||!O,onClick:()=>void q(),children:N?`Sending…`:F?`Check send status`:`Send`}),(0,l.jsx)(r,{size:`sm`,variant:`ghost`,disabled:N,onClick:()=>{window.confirm(F?`This message may already have been sent. Discard this draft only after checking the conversation.`:`Discard this draft?`)&&(b({...v(),driver:y.driver,address:y.address}),I(!1),B(null),R(``))},children:`Discard draft`}),F&&z?.status!==`accepted`&&(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Do not start another send until you have checked the conversation. The same request will not be delivered twice by Canvas.`})]})}function T(e){let t=(0,d.useRef)(null),n=(0,d.useRef)(e.onClose);return(0,d.useEffect)(()=>{n.current=e.onClose}),(0,d.useEffect)(()=>{let e=t.current;if(!e)return;let n=document.activeElement;return e.showModal(),()=>{e.close(),n?.focus()}},[]),(0,l.jsx)(`dialog`,{ref:t,"aria-label":e.replyToDocumentId?`${e.mode===`forward`?`Forward`:e.mode===`replyAll`?`Reply all`:`Reply`} message`:`Send test email`,className:`m-auto w-[calc(100%-2rem)] max-w-3xl max-h-[90dvh] overflow-y-auto rounded-(--panel-radius) border bg-card p-0 text-foreground shadow-elevation-4 backdrop:bg-black/40`,onKeyDown:e=>e.stopPropagation(),onCancel:e=>{e.preventDefault(),e.stopPropagation(),n.current()},children:(0,l.jsx)(w,{...e})})}export{g as a,p as i,w as n,v as o,y as r,u as s,T as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BQnKd3jw.js";import{Ft as r}from"./workspace-BSXnX2Me.js";var i=e(n(),1),a=t(),o=[`Inbox sweep`,`Canvas edge notes`,`Release 2.7`];function s(){let[e,t]=(0,i.useState)(`none`),[n,s]=(0,i.useState)(null);(0,i.useEffect)(()=>{e===`workspaces`&&n===null&&r().then(s).catch(()=>s([]))},[e,n]);let c=e=>t(t=>t===e?`none`:e);return(0,a.jsxs)(`div`,{className:`next-shell`,children:[(0,a.jsx)(`div`,{className:`next-wallpaper`,"aria-hidden":!0,children:(0,a.jsx)(`i`,{})}),(0,a.jsxs)(`div`,{className:`relative flex h-full flex-col items-center justify-center gap-3 select-none`,children:[(0,a.jsx)(`p`,{className:`text-2xl font-light tracking-wide text-white/80`,children:`Canvas`}),(0,a.jsx)(`p`,{className:`text-sm text-white/40`,children:`say something, or tap the orb. Swipe up for canvases (soon)`})]}),e===`tasks`&&(0,a.jsxs)(`div`,{className:`next-glass absolute bottom-24 left-6 w-64 rounded-2xl p-3`,children:[(0,a.jsx)(`p`,{className:`px-2 pb-2 text-[11px] uppercase tracking-widest text-white/40`,children:`Pinned`}),(0,a.jsx)(`div`,{className:`flex flex-col gap-1`,children:o.map(e=>(0,a.jsx)(`button`,{type:`button`,className:`rounded-xl px-3 py-2 text-left text-sm text-white/85 transition-colors hover:bg-white/10`,children:e},e))})]}),e===`workspaces`&&(0,a.jsxs)(`div`,{className:`next-glass absolute bottom-24 right-6 w-72 rounded-2xl p-3`,children:[(0,a.jsx)(`p`,{className:`px-2 pb-2 text-[11px] uppercase tracking-widest text-white/40`,children:`Workspaces`}),(0,a.jsxs)(`div`,{className:`flex max-h-80 flex-col gap-1 overflow-y-auto`,children:[n===null&&(0,a.jsx)(`p`,{className:`px-3 py-2 text-sm text-white/50`,children:`Loading…`}),n?.map(e=>(0,a.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2.5 rounded-xl px-3 py-2 text-left text-sm text-white/85 transition-colors hover:bg-white/10`,children:[(0,a.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-full`,style:{backgroundColor:e.color||`rgb(255 255 255 / 0.35)`}}),(0,a.jsx)(`span`,{className:`truncate`,children:e.label||e.name})]},e.id)),n?.length===0&&(0,a.jsx)(`p`,{className:`px-3 py-2 text-sm text-white/50`,children:`No workspaces`})]})]}),(0,a.jsxs)(`div`,{className:`absolute bottom-6 right-6 flex items-center gap-3`,children:[e!==`none`&&(0,a.jsx)(`button`,{type:`button`,onClick:()=>c(e===`tasks`?`workspaces`:`tasks`),className:`next-glass rounded-full px-4 py-2 text-xs text-white/70`,children:e===`tasks`?`workspaces`:`pinned`}),(0,a.jsx)(`button`,{type:`button`,onClick:()=>c(`tasks`),"aria-label":`Toolbox`,className:`next-orb flex h-14 w-14 items-center justify-center rounded-full`,children:(0,a.jsx)(`span`,{className:`h-3 w-3 rounded-full bg-white/85`})})]})]})}export{s 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{Pt as r}from"./workspace-CJ1PWQ29.js";var i=e(n(),1),a=t(),o=[`Inbox sweep`,`Canvas edge notes`,`Release 2.7`];function s(){let[e,t]=(0,i.useState)(`none`),[n,s]=(0,i.useState)(null);(0,i.useEffect)(()=>{e===`workspaces`&&n===null&&r().then(s).catch(()=>s([]))},[e,n]);let c=e=>t(t=>t===e?`none`:e);return(0,a.jsxs)(`div`,{className:`next-shell`,children:[(0,a.jsx)(`div`,{className:`next-wallpaper`,"aria-hidden":!0,children:(0,a.jsx)(`i`,{})}),(0,a.jsxs)(`div`,{className:`relative flex h-full flex-col items-center justify-center gap-3 select-none`,children:[(0,a.jsx)(`p`,{className:`text-2xl font-light tracking-wide text-white/80`,children:`Canvas`}),(0,a.jsx)(`p`,{className:`text-sm text-white/40`,children:`say something, or tap the orb. Swipe up for canvases (soon)`})]}),e===`tasks`&&(0,a.jsxs)(`div`,{className:`next-glass absolute bottom-24 left-6 w-64 rounded-2xl p-3`,children:[(0,a.jsx)(`p`,{className:`px-2 pb-2 text-[11px] uppercase tracking-widest text-white/40`,children:`Pinned`}),(0,a.jsx)(`div`,{className:`flex flex-col gap-1`,children:o.map(e=>(0,a.jsx)(`button`,{type:`button`,className:`rounded-xl px-3 py-2 text-left text-sm text-white/85 transition-colors hover:bg-white/10`,children:e},e))})]}),e===`workspaces`&&(0,a.jsxs)(`div`,{className:`next-glass absolute bottom-24 right-6 w-72 rounded-2xl p-3`,children:[(0,a.jsx)(`p`,{className:`px-2 pb-2 text-[11px] uppercase tracking-widest text-white/40`,children:`Workspaces`}),(0,a.jsxs)(`div`,{className:`flex max-h-80 flex-col gap-1 overflow-y-auto`,children:[n===null&&(0,a.jsx)(`p`,{className:`px-3 py-2 text-sm text-white/50`,children:`Loading…`}),n?.map(e=>(0,a.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2.5 rounded-xl px-3 py-2 text-left text-sm text-white/85 transition-colors hover:bg-white/10`,children:[(0,a.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-full`,style:{backgroundColor:e.color||`rgb(255 255 255 / 0.35)`}}),(0,a.jsx)(`span`,{className:`truncate`,children:e.label||e.name})]},e.id)),n?.length===0&&(0,a.jsx)(`p`,{className:`px-3 py-2 text-sm text-white/50`,children:`No workspaces`})]})]}),(0,a.jsxs)(`div`,{className:`absolute bottom-6 right-6 flex items-center gap-3`,children:[e!==`none`&&(0,a.jsx)(`button`,{type:`button`,onClick:()=>c(e===`tasks`?`workspaces`:`tasks`),className:`next-glass rounded-full px-4 py-2 text-xs text-white/70`,children:e===`tasks`?`workspaces`:`pinned`}),(0,a.jsx)(`button`,{type:`button`,onClick:()=>c(`tasks`),"aria-label":`Toolbox`,className:`next-orb flex h-14 w-14 items-center justify-center rounded-full`,children:(0,a.jsx)(`span`,{className:`h-3 w-3 rounded-full bg-white/85`})})]})]})}export{s 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{L as r,Mt as i,dn as a,fi as o,oi as s,yt as c}from"./ui-BSqPn1LJ.js";import{t as l}from"./utils-2pl1SbIp.js";import{Un as u}from"./workspace-CJ1PWQ29.js";import{t as d}from"./useAddTarget-CVRPElxz.js";import{t as f}from"./note-save-status-DPz4VzL6.js";import{t as p}from"./useEditNoteFields-Bigs9ZG8.js";import{n as m}from"./use-applet-target-mkjQujx6.js";import{O as h}from"./index-DtZS4JJ4.js";import{n as g,r as _,t as v}from"./shared-1dpCuibu.js";import{n as y,r as b}from"./use-applet-docs-Cry2SFsG.js";var x=e(n(),1),S=t();function C({doc:e,updateWorkspace:t,registerEl:n,registerBody:r,highlighted:i,onLinkTo:a,onDelete:o}){let s=p(e,t||``,!!t),{title:c,content:u,setTitle:d,setContent:m}=s,h=()=>{s.save().catch(()=>{})};return(0,S.jsxs)(`div`,{ref:t=>n(e.id,t),className:l(`group border-t border-border/60 px-4 py-3 transition-colors`,i&&`bg-primary/5`),children:[(0,S.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between gap-2`,children:[(0,S.jsxs)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground/70`,children:[y(e.createdAt),` · #`,e.id]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground/70`,children:[(0,S.jsx)(f,{...s,onRetry:s.save}),(0,S.jsx)(g,{onLinkTo:a,onDelete:o})]})]}),(0,S.jsx)(`input`,{value:c,onChange:e=>d(e.target.value),onBlur:h,placeholder:`Untitled`,spellCheck:!1,className:`mb-1 w-full border-0 bg-transparent p-0 text-sm font-semibold text-foreground outline-none placeholder:text-muted-foreground/50`}),(0,S.jsx)(v,{value:u,onChange:m,onBlur:h,innerRef:t=>r(e.id,t)})]})}function w({target:e,onCreated:t,onCancel:n}){let i=h(e,void 0,`applet`),{title:a,content:o,setTitle:s,setContent:c,saving:l}=i,[u,d]=(0,x.useState)(null),p=async()=>{try{await i.save(e),i.finish(),t()}catch(e){d(e instanceof Error?e.message:`Failed to save note`)}};return(0,S.jsxs)(`div`,{className:`border-t border-border/60 bg-muted/30 px-4 py-3`,children:[(0,S.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between`,children:[(0,S.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground/70`,children:`New note`}),(0,S.jsx)(`button`,{type:`button`,onClick:n,className:`text-muted-foreground hover:text-foreground`,"aria-label":`Close note`,children:(0,S.jsx)(r,{className:`h-3 w-3`})})]}),(0,S.jsx)(`input`,{value:a,onChange:e=>s(e.target.value),placeholder:`Untitled`,autoFocus:!0,spellCheck:!1,className:`mb-1 w-full border-0 bg-transparent p-0 text-sm font-semibold text-foreground outline-none placeholder:text-muted-foreground/50`}),(0,S.jsx)(v,{value:o,onChange:c,placeholder:`Write your note…`}),(0,S.jsx)(f,{...i,onRetry:i.retry}),u&&(0,S.jsx)(`p`,{className:`mt-1 text-xs text-destructive`,children:u}),(0,S.jsx)(`div`,{className:`mt-2 flex justify-end`,children:(0,S.jsx)(`button`,{type:`button`,onClick:p,disabled:!o.trim()||l,className:`rounded-md bg-primary px-2.5 py-1 text-xs text-primary-foreground disabled:opacity-50`,children:l?`Saving…`:`Done`})})]})}function T({autoAdd:e=!1}){let t=m(),{docs:n,loading:r,error:l,scope:f,reload:p,removeDoc:h}=b(t,u),[g,v]=(0,x.useState)(``),[y,T]=(0,x.useState)(0),[E,D]=(0,x.useState)(`desc`),[O,k]=(0,x.useState)(e),[A,j]=(0,x.useState)(null),M=(0,x.useRef)(new Map),N=(0,x.useRef)(new Map),P=(0,x.useCallback)((e,t)=>{t?M.current.set(e,t):M.current.delete(e)},[]),F=(0,x.useCallback)((e,t)=>{t?N.current.set(e,t):N.current.delete(e)},[]),I=(0,x.useCallback)(async e=>{let t=e.data?.title?`"${e.data.title}"`:`#${e.id}`;if(window.confirm(`Delete note ${t}?\n\nIt is removed from this path and moves to the workspace trash if nothing else links it.`))try{await h(e.id)}catch{}},[h]),L=(0,x.useMemo)(()=>{let e=[...n];return e.sort((e,t)=>{let n=new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime();return E===`asc`?n:-n}),e},[n,E]),R=(0,x.useMemo)(()=>{let e=g.trim().toLowerCase();if(!e)return[];let t=[];for(let n of L){let r=String(n.data?.content??``),i=String(n.data?.title??``),a=r.toLowerCase().indexOf(e);a>=0?t.push({docId:n.id,offset:a}):i.toLowerCase().includes(e)&&t.push({docId:n.id,offset:-1})}return t},[g,L]),z=R.length?R[Math.min(y,R.length-1)]:null;(0,x.useEffect)(()=>{z&&M.current.get(z.docId)?.scrollIntoView({block:`center`,behavior:`smooth`})},[z]);let B=(0,x.useCallback)(e=>{if(!R.length)return;let t=e?(y+1)%R.length:y;e&&T(t);let n=R[t],r=N.current.get(n.docId);r&&n.offset>=0&&(r.focus(),r.setSelectionRange(n.offset,n.offset+g.trim().length)),M.current.get(n.docId)?.scrollIntoView({block:`center`,behavior:`smooth`})},[R,y,g]);return t?(0,S.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,S.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border px-3 py-2`,children:[(0,S.jsxs)(`div`,{className:`relative flex-1`,children:[(0,S.jsx)(c,{className:`pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,S.jsx)(`input`,{value:g,onChange:e=>{v(e.target.value),T(0)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),B(!0))},placeholder:`Search notes…`,spellCheck:!1,className:`w-full rounded-md border border-input bg-transparent py-1 pl-7 pr-14 text-xs outline-none placeholder:text-muted-foreground focus-visible:ring-1 focus-visible:ring-ring`}),g.trim()&&(0,S.jsx)(`span`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-[10px] tabular-nums text-muted-foreground`,children:R.length?`${Math.min(y+1,R.length)}/${R.length}`:`0/0`})]}),(0,S.jsx)(`button`,{type:`button`,onClick:()=>D(e=>e===`desc`?`asc`:`desc`),className:`rounded-md border border-border p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,title:E===`desc`?`Newest first (click for oldest first)`:`Oldest first (click for newest first)`,"aria-label":`Toggle sort order`,children:E===`desc`?(0,S.jsx)(o,{className:`h-3.5 w-3.5`}):(0,S.jsx)(s,{className:`h-3.5 w-3.5`})}),(0,S.jsxs)(`button`,{type:`button`,onClick:()=>k(!0),className:`flex items-center gap-1 rounded-md bg-primary px-2 py-1.5 text-xs text-primary-foreground`,title:`Add a note`,children:[(0,S.jsx)(i,{className:`h-3.5 w-3.5`}),`Note`]})]}),(0,S.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[O&&(0,S.jsx)(w,{target:t,onCreated:()=>{k(!1),p()},onCancel:()=>k(!1)},JSON.stringify(t)),r&&!n.length&&(0,S.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,S.jsx)(a,{className:`h-5 w-5 animate-spin text-muted-foreground`})}),l&&(0,S.jsx)(`p`,{className:`px-4 py-6 text-center text-sm text-destructive`,children:l}),!r&&!l&&!L.length&&!O&&(0,S.jsx)(`p`,{className:`px-4 py-10 text-center text-sm text-muted-foreground`,children:`No notes here yet - add the first one.`}),L.map(e=>(0,S.jsx)(C,{doc:e,updateWorkspace:f?.workspaceName??null,registerEl:P,registerBody:F,highlighted:z?.docId===e.id,onLinkTo:()=>j(e.id),onDelete:()=>I(e)},e.id))]}),A!==null&&(0,S.jsx)(_,{documentId:A,workspaceName:f?.workspaceName,onClose:()=>j(null)})]}):(0,S.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-center text-sm text-muted-foreground`,children:d(t)})}export{T as NotesApplet};
@@ -0,0 +1 @@
1
+ .canvas-navigation{border-top:2px solid var(--border);border-bottom:1px solid var(--border);background:var(--background);flex-shrink:0;min-width:0}.canvas-navigation.has-tabs{border-top:0}.canvas-navigation-tabs{background:var(--background);flex-direction:column;flex-shrink:0;justify-content:flex-end;height:3rem;padding:0 8px;display:flex;position:relative}.canvas-tab-divider{z-index:1;inset-inline:0;background:var(--border);pointer-events:none;height:4px;position:absolute;bottom:0}.canvas-surface-body{background:var(--background);flex-direction:column;flex:1;min-width:0;min-height:0;display:flex;overflow:hidden}.canvas-surface-body>.canvas-navigation{border-top:0}@media (width>=640px){.canvas-surface-body.is-framed{border:1px solid var(--border);border-radius:var(--sheet-radius);margin:8px}}.canvas-address-row{align-items:center;gap:4px;min-width:0;padding:6px;display:flex}.canvas-nav-button{width:44px;height:44px;color:var(--muted-foreground);cursor:pointer;border-radius:10px;flex:0 0 44px;justify-content:center;align-items:center;display:inline-flex;position:relative}.canvas-nav-button:hover{background:var(--accent);color:var(--foreground)}.canvas-nav-button:focus-visible,.canvas-address-crumbs:focus-visible,.canvas-address-crumbs button:focus-visible{outline:2px solid var(--ring);outline-offset:-2px}.canvas-nav-button:disabled{opacity:.35;cursor:default}.canvas-address-field{border:1px solid var(--border);background:var(--muted);border-radius:12px;flex:1;min-width:0;display:flex}.canvas-address-field:focus-within{border-color:var(--ring)}.canvas-address-crumbs{scrollbar-width:none;white-space:nowrap;overscroll-behavior-x:contain;flex:1;align-items:center;min-width:0;padding-left:8px;font-size:13px;display:flex;overflow-x:auto}.canvas-address-crumbs::-webkit-scrollbar{display:none}.canvas-address-crumbs button,.canvas-address-label{cursor:pointer;border-radius:4px;flex-shrink:0;min-height:44px;padding:0 4px}.canvas-address-crumbs button:hover{color:var(--foreground);text-underline-offset:4px;text-decoration:underline}.canvas-address-label{align-items:center;display:inline-flex}.canvas-address-workspace{white-space:nowrap;cursor:pointer;flex:none;align-items:center;gap:6px;max-width:120px;min-height:44px;padding:0 4px 0 10px;font-size:13px;font-weight:600;display:inline-flex}.canvas-address-workspace:hover{text-decoration:underline}.canvas-address-crumbs.is-scrolled{-webkit-mask-image:linear-gradient(90deg,#0000,#000 12px);mask-image:linear-gradient(90deg,#0000,#000 12px)}@media (width<=639px){.canvas-address-workspace{max-width:90px}}.canvas-address-tree,.canvas-address-root{color:var(--muted-foreground);font-family:monospace}.canvas-address-segment{flex-shrink:0;align-items:center;gap:2px;display:flex}.canvas-address-segment>span{color:var(--muted-foreground)}.canvas-address-segment button{text-overflow:ellipsis;max-width:160px;overflow:hidden}.canvas-address-section{color:var(--primary)}.canvas-address-search{border-radius:0 11px 11px 0}.canvas-add-button{color:var(--primary-foreground);border-radius:50%}.canvas-add-button:before{content:"";background:var(--primary);border-radius:50%;position:absolute;inset:6px}.canvas-add-button>svg{width:18px;height:18px;position:relative}.canvas-add-button:hover{color:var(--primary-foreground);background:0 0}.canvas-add-button:hover:before{opacity:.85}.canvas-filter-button[data-active=true]{background:var(--accent);color:var(--foreground)}.canvas-nav-dot{background:var(--primary);border-radius:50%;width:5px;height:5px;position:absolute;top:7px;right:7px}.canvas-search-input{flex:1;align-items:center;min-width:0;display:flex;position:relative}.canvas-search-input input{background:0 0;outline:none;flex:1;width:100%;min-width:0;height:44px;padding:0 10px;font-size:16px}.canvas-search-dropdown{padding:0 12px 10px}.canvas-search-heading{color:var(--muted-foreground);justify-content:space-between;align-items:center;gap:8px;font-size:11px;display:flex}.canvas-search-heading .canvas-nav-button{height:36px}.canvas-search-options{flex-direction:column;gap:8px;display:flex}.canvas-search-scopes{flex-wrap:wrap;align-items:center;gap:6px;font-size:12px;display:flex}.canvas-search-scopes>span{color:var(--muted-foreground);margin-right:3px}.canvas-search-scopes button{border:1px solid var(--border);cursor:pointer;border-radius:8px;min-height:40px;padding:0 12px}.canvas-search-scopes button[aria-pressed=true]{background:var(--foreground);color:var(--background);border-color:var(--foreground)}.canvas-search-queries{flex-wrap:wrap;gap:6px;display:flex}.canvas-search-query{border:1px solid var(--border);background:var(--muted);border-radius:8px;align-items:center;gap:6px;max-width:100%;padding-left:8px;font-size:12px;display:inline-flex}.canvas-search-query>span{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.canvas-search-query button{cursor:pointer;justify-content:center;align-items:center;min-width:40px;min-height:40px;display:flex}.canvas-search-clear{padding:8px;font-size:12px;text-decoration:underline}@media (width>=640px){.canvas-address-row{gap:6px;padding:8px 10px}}