@augmentd-labs/canvas-web 2.26.44 → 2.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/dist/assets/CalendarApplet-Be25FsQH.js +2 -0
  2. package/dist/assets/{DocumentBodyEditor-CVO5KPCs.js → DocumentBodyEditor-C8AEpqX3.js} +1 -1
  3. package/dist/assets/{DocumentIcon-9i1uCMQa.js → DocumentIcon-0ya9gycp.js} +1 -1
  4. package/dist/assets/{EditorOverlay-D5t3xg4w.js → EditorOverlay-DglJkHo3.js} +1 -1
  5. package/dist/assets/{FiltersApplet-BT3fR4Fu.js → FiltersApplet-CuBp34Ll.js} +1 -1
  6. package/dist/assets/HomeFab-BVC6GyBo.js +3 -0
  7. package/dist/assets/{IdentityFields-D-NCTUaE.js → IdentityFields-CB3Ap0bl.js} +1 -1
  8. package/dist/assets/{LensApplet-CVUc1-vK.js → LensApplet-cH9mu9Ek.js} +1 -1
  9. package/dist/assets/LinkToCard-oi3wGP0a.js +1 -0
  10. package/dist/assets/{MarkdownEditor-DbpRWbO6.js → MarkdownEditor-bDoyR7l2.js} +2 -2
  11. package/dist/assets/{MessageComposerDialog-CdPp-3GR.js → MessageComposerDialog-CLrwtB76.js} +1 -1
  12. package/dist/assets/{NextShell-ull6WmMg.js → NextShell-DCWxD5TR.js} +1 -1
  13. package/dist/assets/{NotesApplet-Bbd61mrH.js → NotesApplet-D7vrAU-F.js} +1 -1
  14. package/dist/assets/ObjectPropertiesCard-DesXRw-_.js +8 -0
  15. package/dist/assets/{PathPickerField-CW2yG2Yg.js → PathPickerField-CSIa7jSl.js} +1 -1
  16. package/dist/assets/PickDocumentsCard-DVdBxx3s.js +1 -0
  17. package/dist/assets/{SketchApplet-BKnhzTBA.js → SketchApplet--3uyqpmo.js} +1 -1
  18. package/dist/assets/{SketchEditor-DmGMcbU0.js → SketchEditor-CSA7dTyq.js} +2 -2
  19. package/dist/assets/{TerminalApplet-D7YxftqM.js → TerminalApplet-BZJx2ztD.js} +1 -1
  20. package/dist/assets/{TextDocumentEditor-BQnVD0dd.js → TextDocumentEditor-VYIF2XCX.js} +1 -1
  21. package/dist/assets/{TodosApplet-DU5VWc5i.js → TodosApplet-DY7JzeZS.js} +1 -1
  22. package/dist/assets/{TodosWidget-CNnfNk4L.js → TodosWidget-DGftEAbs.js} +1 -1
  23. package/dist/assets/{_agentId_-CrBQ54X2.js → _agentId_-D7FMIU0U.js} +0 -0
  24. package/dist/assets/{_contextId_-CEcdj7Ec.js → _contextId_-nHWeEqjb.js} +1 -1
  25. package/dist/assets/_workspaceName_-Ca7l8D3u.js +1 -0
  26. package/dist/assets/{about-CdAN00wx.js → about-DPQIKA4h.js} +1 -1
  27. package/dist/assets/{add-COjQRnFC.js → add-C4IXcB8E.js} +1 -1
  28. package/dist/assets/{agents-DxqAi3vk.js → agents-BfSFdg41.js} +1 -1
  29. package/dist/assets/{agents-D_t6cQMW.js → agents-Cq1aDFAt.js} +1 -1
  30. package/dist/assets/{alert-dialog-CFeuDt0T.js → alert-dialog-BKtaX1_a.js} +1 -1
  31. package/dist/assets/{api-tokens-drrVuCYc.js → api-tokens-Biqt5TnG.js} +1 -1
  32. package/dist/assets/{appearance-BnUcoqpz.js → appearance-DTH3zH0p.js} +1 -1
  33. package/dist/assets/{applet-target-pLdP-R76.js → applet-target-LvhUEvE5.js} +1 -1
  34. package/dist/assets/{apps-CCC-xyI2.js → apps-DGG9ruBT.js} +1 -1
  35. package/dist/assets/{auth-PqttD05H.js → auth-BwxT5xRB.js} +1 -1
  36. package/dist/assets/{button-SeUZ_Pvi.js → button--VYZekMF.js} +1 -1
  37. package/dist/assets/{context-t3rdtGUB.js → context-DY40EDc6.js} +1 -1
  38. package/dist/assets/{contexts-DDJagU4j.js → contexts-BPO_Wb9W.js} +1 -1
  39. package/dist/assets/{contexts-Bq8LHUTK2.js → contexts-DBJ0_-AO2.js} +1 -1
  40. package/dist/assets/{date-time-picker-DCikruos.js → date-time-picker-p3vy4nst.js} +1 -1
  41. package/dist/assets/{devices-BwU9M8-W.js → devices-DZbbaWYU.js} +1 -1
  42. package/dist/assets/{document-Cr7GhnVd.js → document-Dv8NCUoM.js} +1 -1
  43. package/dist/assets/document-list-Bbbx-pTZ.js +3 -0
  44. package/dist/assets/document-paste-BuTC6S7_.js +1 -0
  45. package/dist/assets/{embedding-D-I_ygUZ.js → embedding-B9vSy_a9.js} +1 -1
  46. package/dist/assets/{embedding-BvXcVfij.js → embedding-M2hUmnk0.js} +1 -1
  47. package/dist/assets/{form-panel-3p-ncEVK.js → form-panel-CEbNKttr.js} +1 -1
  48. package/dist/assets/{home-DrRSXywO.js → home-BK8Bp4d-.js} +1 -1
  49. package/dist/assets/index-CoVFQpP3.css +2 -0
  50. package/dist/assets/index-NOhHv2VY.js +16 -0
  51. package/dist/assets/{inferd-config-editor-B8x_XPOt.js → inferd-config-editor-Dpdj90iN.js} +1 -1
  52. package/dist/assets/{key-bindings-6SHAlZR8.js → key-bindings-Cbh1Fiav.js} +1 -1
  53. package/dist/assets/{label-BSTdjCWU.js → label-RuOXXC8t.js} +1 -1
  54. package/dist/assets/{lazy-editor-BUFAkTGl.js → lazy-editor-CShGeIep.js} +2 -2
  55. package/dist/assets/{logs-DjG8_wJ2.js → logs-7eSz9yjc.js} +1 -1
  56. package/dist/assets/{offline-ByoT6JJX.js → offline-C-Yvb6LA.js} +1 -1
  57. package/dist/assets/{page-header-DrDt1sQ2.js → page-header-NyYSXjfY.js} +1 -1
  58. package/dist/assets/{public-share-CXR25Q1X.js → public-share-0DqS7L2Q.js} +1 -1
  59. package/dist/assets/{query-debug-lD5vbJGi.js → query-debug-PEWbZsOP.js} +1 -1
  60. package/dist/assets/registry-D7HyG001.js +2 -0
  61. package/dist/assets/{remotes-RPGcw6fH.js → remotes-DqCLds8Q.js} +1 -1
  62. package/dist/assets/{roles-sb8vgjV_.js → roles-BwVDE1aQ.js} +1 -1
  63. package/dist/assets/{roles-p2cRajz-.js → roles-W7oJ5WMg.js} +1 -1
  64. package/dist/assets/rule-builder-CziPqpNe.js +6 -0
  65. package/dist/assets/{settings-r7slYioS.js → settings-6UW5qG-V.js} +1 -1
  66. package/dist/assets/settings-BbqSg6FH.js +1 -0
  67. package/dist/assets/{settings-CGncOyKY.js → settings-CkBpWcHX.js} +1 -1
  68. package/dist/assets/settings-Ckel628s.js +16 -0
  69. package/dist/assets/{share-target-CoDDhZI5.js → share-target-CuBCWHxv.js} +1 -1
  70. package/dist/assets/{shared-BLOuO2Is.js → shared-CLjTxih0.js} +1 -1
  71. package/dist/assets/{shared-bYen6pjw.js → shared-CqqMgsnU.js} +1 -1
  72. package/dist/assets/sketch-lazy-CtjOUfVz.js +2 -0
  73. package/dist/assets/{subtree-transfer-dialog-DQM5zfx2.js → subtree-transfer-dialog-DtE6JSUr.js} +1 -1
  74. package/dist/assets/{text-documents-Cdb3U63i.js → text-documents-wu6fzOuw.js} +2 -2
  75. package/dist/assets/tree-folders-dKwIsl1U.js +1 -0
  76. package/dist/assets/ui-DEgHnkQu.js +41 -0
  77. package/dist/assets/{use-applet-docs-rimRHjID.js → use-applet-docs-C08GAUm3.js} +1 -1
  78. package/dist/assets/{use-applet-target-BygCSj5n.js → use-applet-target-BlpVWlnA.js} +1 -1
  79. package/dist/assets/{use-canvas-pins-BPCW4twY.js → use-canvas-pins-q5Tncavk.js} +2 -2
  80. package/dist/assets/{use-menu-DIP1zh7I.js → use-menu-CKSpS96u.js} +1 -1
  81. package/dist/assets/use-settings-back-D_MM9diy.js +1 -0
  82. package/dist/assets/{use-sortable-data-BBKmqs79.js → use-sortable-data-D7zS2qCC.js} +1 -1
  83. package/dist/assets/{use-workspace-identity-CSkRwVyo.js → use-workspace-identity-XSv3dATQ.js} +1 -1
  84. package/dist/assets/{useAddTarget-DeRZWtGg.js → useAddTarget-BvuFR5pN.js} +1 -1
  85. package/dist/assets/{useAgentModels-BufYelEA.js → useAgentModels-DTZNaSRA.js} +1 -1
  86. package/dist/assets/{useDocumentThumbnail-Cj4UYyhC.js → useDocumentThumbnail-CZIaXkIi.js} +1 -1
  87. package/dist/assets/{useEditNoteFields-BT1ASu_q.js → useEditNoteFields-DsVKIHWm.js} +1 -1
  88. package/dist/assets/{users-DuVk-TEd.js → users-DzlbKZp6.js} +1 -1
  89. package/dist/assets/workspace-4hWrSEku.js +1 -0
  90. package/dist/assets/{workspace-content-gate-C54J9Man.js → workspace-content-gate-BlFdbi67.js} +1 -1
  91. package/dist/assets/{workspace-import-form-DTvV9jYt.js → workspace-import-form-CWs9ZTts.js} +1 -1
  92. package/dist/assets/{workspaces-CqHYstZv.js → workspaces-67v2hWrl.js} +1 -1
  93. package/dist/assets/workspaces-CXhffn_p.js +1 -0
  94. package/dist/index.html +36 -38
  95. package/dist/sw.js +1 -1
  96. package/package.json +2 -2
  97. package/dist/assets/CalendarApplet-BNT0vegP.js +0 -2
  98. package/dist/assets/FileForm-CDiVKvxq.js +0 -1
  99. package/dist/assets/HomeFab-B17r3232.js +0 -3
  100. package/dist/assets/LinkToCard-CKVi4Nrg.js +0 -1
  101. package/dist/assets/ObjectPropertiesCard-D2lrTQqT.js +0 -8
  102. package/dist/assets/PickDocumentsCard-BWgc-A02.js +0 -1
  103. package/dist/assets/UploadProgressList-D2wEpa7t.js +0 -1
  104. package/dist/assets/_workspaceName_-BhZWt9RG.js +0 -1
  105. package/dist/assets/backend-sync-progress-B3lZB9Ha.js +0 -6
  106. package/dist/assets/document-list-rzRLzfkF.js +0 -3
  107. package/dist/assets/index-DOXi2QgX.css +0 -2
  108. package/dist/assets/index-G_67YwLB.js +0 -16
  109. package/dist/assets/registry-FfNYUpRF.js +0 -2
  110. package/dist/assets/settings-CCr9Jr0Q.js +0 -1
  111. package/dist/assets/settings-Cv6jdSA0.js +0 -16
  112. package/dist/assets/sketch-lazy-BY_ka1hw.js +0 -2
  113. package/dist/assets/tree-folders-Q5iu5vpu.js +0 -1
  114. package/dist/assets/ui-CDoK3F3U.js +0 -41
  115. package/dist/assets/use-settings-back-DGmLAD63.js +0 -1
  116. package/dist/assets/workspace-C5V-ZCOE.js +0 -1
  117. package/dist/assets/workspace-area-menu-BN5ysUpx.js +0 -1
  118. package/dist/assets/workspaces-Dj9dNIWZ.js +0 -1
  119. /package/dist/assets/{backend-sync-progress-DU-e9TWi.css → rule-builder-DU-e9TWi.css} +0 -0
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{_ as r,r as i,v as a}from"./chunk-62JRHF6Z-vspAGgtK.js";import{t as o}from"./utils-2pl1SbIp.js";import{bn as s,jt as c}from"./workspace-C5V-ZCOE.js";import{p as l}from"./context-t3rdtGUB.js";import{t as u}from"./registry-FfNYUpRF.js";import{t as d}from"./applet-target-pLdP-R76.js";var f=e(n(),1),p=t(),m=`universe`;function h(){let{appletId:e}=r(),[t,n]=a(),h=u.find(t=>t.id===e),g=t.get(`context`),_=t.get(`workspace`)||m,v=t.get(`path`)||`/`,y=t.get(`tree`)||`context`,b=t.get(`add`)===`1`,x=(0,f.useMemo)(()=>g?{mode:`context`,contextId:g}:{mode:`workspace`,workspaceName:_,path:v,treeName:y,treeType:s(y)},[g,_,v,y]),[S,C]=(0,f.useState)([]),[w,T]=(0,f.useState)([]);(0,f.useEffect)(()=>{c().then(C).catch(()=>C([])),l().then(T).catch(()=>T([]))},[]);let[E,D]=(0,f.useState)(v),[O,k]=(0,f.useState)(v);O!==v&&(k(v),D(v));let A=e=>{let r=new URLSearchParams(t);r.delete(`add`);for(let[t,n]of Object.entries(e))n===null?r.delete(t):r.set(t,n);n(r,{replace:!0})};if(!h)return(0,p.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col items-center justify-center gap-3 surface-desk`,children:[(0,p.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Unknown app`,e?` "${e}"`:``,`.`]}),(0,p.jsx)(`div`,{className:`flex gap-2`,children:u.map(e=>(0,p.jsx)(i,{to:`/apps/${e.id}`,className:`rounded-md border border-border px-3 py-1.5 text-sm hover:bg-muted`,children:e.label},e.id))})]});let j=g?`context`:`path`;return(0,p.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col surface-desk p-shell gap-shell`,children:[(0,p.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 rounded-xl border bg-card px-3 py-2 shadow-elevation-2`,children:[(0,p.jsx)(h.icon,{className:`h-4 w-4 text-muted-foreground`}),(0,p.jsx)(`span`,{className:`text-sm font-semibold`,children:h.label}),(0,p.jsx)(`div`,{className:`ml-2 flex overflow-hidden rounded-md border border-border`,children:[`path`,`context`].map(e=>(0,p.jsx)(`button`,{type:`button`,onClick:()=>{e!==j&&A(e===`path`?{context:null}:{context:w[0]?.id??``,workspace:null,path:null,tree:null})},className:o(`px-2.5 py-1 text-xs capitalize transition-colors`,j===e?`bg-foreground text-background`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:e},e))}),j===`path`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`select`,{value:_,onChange:e=>A({workspace:e.target.value,path:`/`}),className:`h-7 rounded-md border border-input bg-transparent px-1.5 text-xs`,"aria-label":`Workspace`,children:[!S.some(e=>e.name===_)&&(0,p.jsx)(`option`,{value:_,children:_}),S.map(e=>(0,p.jsx)(`option`,{value:e.name,children:e.label||e.name},e.id))]}),(0,p.jsx)(`input`,{value:E,onChange:e=>D(e.target.value),onBlur:()=>{let e=E.trim()||`/`;e!==v&&A({path:e})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()},spellCheck:!1,placeholder:`/`,className:`h-7 w-40 rounded-md border border-input bg-transparent px-2 text-xs outline-none focus-visible:ring-1 focus-visible:ring-ring`,"aria-label":`Path`})]}):(0,p.jsxs)(`select`,{value:g??``,onChange:e=>A({context:e.target.value}),className:`h-7 max-w-56 rounded-md border border-input bg-transparent px-1.5 text-xs`,"aria-label":`Context`,children:[!g&&(0,p.jsx)(`option`,{value:``,children:`Pick a context…`}),w.map(e=>(0,p.jsxs)(`option`,{value:e.id,children:[e.id,e.url?` (${e.url})`:``]},e.id))]}),(0,p.jsx)(`div`,{className:`grow`})]}),(0,p.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border bg-card shadow-elevation-2`,children:j===`context`&&!g?(0,p.jsxs)(`div`,{className:`flex h-full items-center justify-center p-6 text-center text-sm text-muted-foreground`,children:[`Pick a context above to bind `,h.label,` to it.`]}):(0,p.jsx)(d,{target:x,children:(0,p.jsx)(h.Component,{autoAdd:b},JSON.stringify(x))})})]})}export{h as default};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{_ as r,r as i,v as a}from"./chunk-62JRHF6Z-vspAGgtK.js";import{t as o}from"./utils-2pl1SbIp.js";import{jt as s,xn as c}from"./workspace-4hWrSEku.js";import{p as l}from"./context-DY40EDc6.js";import{t as u}from"./registry-D7HyG001.js";import{t as d}from"./applet-target-LvhUEvE5.js";var f=e(n(),1),p=t(),m=`universe`;function h(){let{appletId:e}=r(),[t,n]=a(),h=u.find(t=>t.id===e),g=t.get(`context`),_=t.get(`workspace`)||m,v=t.get(`path`)||`/`,y=t.get(`tree`)||`context`,b=t.get(`add`)===`1`,x=(0,f.useMemo)(()=>g?{mode:`context`,contextId:g}:{mode:`workspace`,workspaceName:_,path:v,treeName:y,treeType:c(y)},[g,_,v,y]),[S,C]=(0,f.useState)([]),[w,T]=(0,f.useState)([]);(0,f.useEffect)(()=>{s().then(C).catch(()=>C([])),l().then(T).catch(()=>T([]))},[]);let[E,D]=(0,f.useState)(v),[O,k]=(0,f.useState)(v);O!==v&&(k(v),D(v));let A=e=>{let r=new URLSearchParams(t);r.delete(`add`);for(let[t,n]of Object.entries(e))n===null?r.delete(t):r.set(t,n);n(r,{replace:!0})};if(!h)return(0,p.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col items-center justify-center gap-3 surface-desk`,children:[(0,p.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Unknown app`,e?` "${e}"`:``,`.`]}),(0,p.jsx)(`div`,{className:`flex gap-2`,children:u.map(e=>(0,p.jsx)(i,{to:`/apps/${e.id}`,className:`rounded-md border border-border px-3 py-1.5 text-sm hover:bg-muted`,children:e.label},e.id))})]});let j=g?`context`:`path`;return(0,p.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col surface-desk p-shell gap-shell`,children:[(0,p.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 rounded-xl border bg-card px-3 py-2 shadow-elevation-2`,children:[(0,p.jsx)(h.icon,{className:`h-4 w-4 text-muted-foreground`}),(0,p.jsx)(`span`,{className:`text-sm font-semibold`,children:h.label}),(0,p.jsx)(`div`,{className:`ml-2 flex overflow-hidden rounded-md border border-border`,children:[`path`,`context`].map(e=>(0,p.jsx)(`button`,{type:`button`,onClick:()=>{e!==j&&A(e===`path`?{context:null}:{context:w[0]?.id??``,workspace:null,path:null,tree:null})},className:o(`px-2.5 py-1 text-xs capitalize transition-colors`,j===e?`bg-foreground text-background`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:e},e))}),j===`path`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`select`,{value:_,onChange:e=>A({workspace:e.target.value,path:`/`}),className:`h-7 rounded-md border border-input bg-transparent px-1.5 text-xs`,"aria-label":`Workspace`,children:[!S.some(e=>e.name===_)&&(0,p.jsx)(`option`,{value:_,children:_}),S.map(e=>(0,p.jsx)(`option`,{value:e.name,children:e.label||e.name},e.id))]}),(0,p.jsx)(`input`,{value:E,onChange:e=>D(e.target.value),onBlur:()=>{let e=E.trim()||`/`;e!==v&&A({path:e})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()},spellCheck:!1,placeholder:`/`,className:`h-7 w-40 rounded-md border border-input bg-transparent px-2 text-xs outline-none focus-visible:ring-1 focus-visible:ring-ring`,"aria-label":`Path`})]}):(0,p.jsxs)(`select`,{value:g??``,onChange:e=>A({context:e.target.value}),className:`h-7 max-w-56 rounded-md border border-input bg-transparent px-1.5 text-xs`,"aria-label":`Context`,children:[!g&&(0,p.jsx)(`option`,{value:``,children:`Pick a context…`}),w.map(e=>(0,p.jsxs)(`option`,{value:e.id,children:[e.id,e.url?` (${e.url})`:``]},e.id))]}),(0,p.jsx)(`div`,{className:`grow`})]}),(0,p.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border bg-card shadow-elevation-2`,children:j===`context`&&!g?(0,p.jsxs)(`div`,{className:`flex h-full items-center justify-center p-6 text-center text-sm text-muted-foreground`,children:[`Pick a context above to bind `,h.label,` to it.`]}):(0,p.jsx)(d,{target:x,children:(0,p.jsx)(h.Component,{autoAdd:b},JSON.stringify(x))})})]})}export{h as default};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{Fr as r,Mr as i,Pt as a,X as o,kt as s,pn as c,pt as l}from"./ui-CDoK3F3U.js";import{t as u}from"./utils-2pl1SbIp.js";import{t as d}from"./button-SeUZ_Pvi.js";import{t as f}from"./input-BOtCd4HP.js";import{c as p,l as m,t as h}from"./api-CA6WiiYM.js";import{i as g}from"./auth-Bx9fAZmz.js";import{n as _}from"./use-toast-BlLDqSUO.js";import{n as v}from"./page-header-DrDt1sQ2.js";import{t as y}from"./use-settings-back-DGmLAD63.js";var b=e(n(),1);function x(){return h.get(p.admin.authConfig)}function S(e){return h.put(p.admin.authConfig,e)}function C(e,t,n){return h.post(`${p.admin.authConfig}/test`,{strategy:`ldap`,name:e,server:t,email:n})}function w(e,t,n){return h.post(`${p.admin.authConfig}/test`,{strategy:`imap`,domain:e,email:t,password:n})}var T=t(),E=0,D=()=>`row-${++E}`;function O(e){let{servers:t,...n}=e.strategies.ldap,{domains:r,...i}=e.strategies.imap;return{allowUserRegistrations:e.allowUserRegistrations,local:e.strategies.local,ldap:{...n,servers:Object.entries(t).map(([e,t])=>({...t,id:D(),name:e,originalName:e}))},imap:{...i,domains:Object.entries(r).map(([e,t])=>({...t,id:D(),domain:e}))},google:e.strategies.google??{enabled:!1,defaultUserType:`user`,defaultStatus:`active`,clientId:``,clientSecretSet:!1,allowedDomains:[],autoCreateUsers:!0,webOrigins:[]}}}function k(e){let{id:t,name:n,originalName:r,...i}=e;return{...i,...r&&r!==e.name?{previousName:r}:{}}}function A(e){return{allowUserRegistrations:e.allowUserRegistrations,strategies:{local:e.local,ldap:{enabled:e.ldap.enabled,defaultUserType:e.ldap.defaultUserType,defaultStatus:e.ldap.defaultStatus,servers:Object.fromEntries(e.ldap.servers.map(e=>[e.name.trim(),k(e)]))},imap:{enabled:e.imap.enabled,defaultUserType:e.imap.defaultUserType,defaultStatus:e.imap.defaultStatus,domains:Object.fromEntries(e.imap.domains.map(({id:e,domain:t,...n})=>[t.trim().toLowerCase(),n]))},google:e.google}}}function j({value:e,onChange:t,placeholder:n,disabled:r}){let i=e.join(`, `),[a,o]=(0,b.useState)(i),[s,c]=(0,b.useState)(i);return i!==s&&(c(i),a.split(/[\s,]+/).filter(Boolean).join(`, `)!==i&&o(i)),(0,T.jsx)(f,{className:`h-8 text-sm`,value:a,placeholder:n,disabled:r,onChange:e=>{o(e.target.value),t(e.target.value.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean))}})}var M={originalName:null,url:`ldap://`,bindDN:``,bindPasswordSet:!1,bindPassword:void 0,searchBase:``,searchFilter:`(mail={{email}})`,attributes:[`mail`,`cn`,`displayName`,`memberOf`],groupAttribute:`memberOf`,tls:!1},N={domain:``,name:``,host:``,port:993,secure:!0,startTLS:!1,requireAppPassword:!1},P=`h-8 rounded-md border border-input bg-transparent px-2 text-sm outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:opacity-50`;function F({label:e,hint:t,children:n,className:r}){return(0,T.jsxs)(`label`,{className:u(`flex min-w-0 flex-col gap-1`,r),children:[(0,T.jsx)(`span`,{className:`text-xs font-medium`,children:e}),n,t&&(0,T.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t})]})}function I({checked:e,onChange:t,disabled:n,label:r,hint:i}){return(0,T.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,T.jsx)(`input`,{type:`checkbox`,className:`mt-0.5`,checked:e,disabled:n,onChange:e=>t(e.target.checked)}),(0,T.jsxs)(`span`,{children:[r,i&&(0,T.jsx)(`span`,{className:`block text-[11px] text-muted-foreground`,children:i})]})]})}function L({title:e,description:t,enabled:n,onToggle:r,disabled:i,children:a}){return(0,T.jsxs)(`section`,{className:`rounded-lg border p-4`,children:[(0,T.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsx)(`h3`,{className:`text-sm font-semibold`,children:e}),(0,T.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:t})]}),r&&(0,T.jsxs)(`label`,{className:`flex shrink-0 items-center gap-2 text-xs font-medium`,children:[(0,T.jsx)(`input`,{type:`checkbox`,checked:!!n,disabled:i,onChange:e=>r(e.target.checked)}),n?`Enabled`:`Disabled`]})]}),(0,T.jsx)(`div`,{className:u(`mt-4 space-y-4`,r&&!n&&`opacity-60`),children:a})]})}function R({result:e}){return e?(0,T.jsxs)(`div`,{className:u(`flex items-start gap-2 rounded-md border p-2 text-xs`,e.ok?`border-emerald-500/40 bg-emerald-500/5`:`border-destructive/40 bg-destructive/5`),children:[e.ok?(0,T.jsx)(r,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-emerald-600`}):(0,T.jsx)(i,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-destructive`}),(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsx)(`p`,{children:e.message}),e.user&&e.user.groups.length>0&&(0,T.jsxs)(`p`,{className:`mt-1 break-all text-muted-foreground`,children:[`Groups: `,e.user.groups.join(` · `)]})]})]}):null}function z({value:e,onChange:t,disabled:n}){return(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsxs)(`div`,{className:`flex flex-wrap gap-4`,children:[(0,T.jsx)(F,{label:`New accounts are`,children:(0,T.jsxs)(`select`,{className:P,value:e.defaultUserType,disabled:n,onChange:e=>t({defaultUserType:e.target.value}),children:[(0,T.jsx)(`option`,{value:`user`,children:`Users`}),(0,T.jsx)(`option`,{value:`admin`,children:`Admins`})]})}),(0,T.jsx)(F,{label:`Initial status`,children:(0,T.jsxs)(`select`,{className:P,value:e.defaultStatus,disabled:n,onChange:e=>t({defaultStatus:e.target.value}),children:[(0,T.jsx)(`option`,{value:`active`,children:`Active — can sign in right away`}),(0,T.jsx)(`option`,{value:`pending`,children:`Pending — an admin activates them`}),(0,T.jsx)(`option`,{value:`inactive`,children:`Inactive`})]})})]}),e.defaultUserType===`admin`&&(0,T.jsxs)(`p`,{className:`flex items-start gap-1.5 text-[11px] text-destructive`,children:[(0,T.jsx)(l,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),`Everyone who can sign in through this backend becomes a server admin on first login.`]})]})}function B({row:e,index:t,onChange:n,onRemove:r,disabled:i}){let[a,s]=(0,b.useState)(``),[l,u]=(0,b.useState)(!1),[p,m]=(0,b.useState)(null),h=async()=>{u(!0),m(null);try{m(await C(e.originalName??e.name,k(e),a.trim()||void 0))}catch(e){m({ok:!1,message:e instanceof Error?e.message:`Test failed`})}finally{u(!1)}},g=e.bindPassword===null?`cleared on save`:typeof e.bindPassword==`string`?`replaced on save`:e.bindPasswordSet?`stored — leave empty to keep it`:`none set`;return(0,T.jsxs)(`div`,{className:`space-y-3 rounded-md border p-3`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsxs)(`span`,{className:`shrink-0 text-[11px] text-muted-foreground`,children:[`#`,t+1]}),(0,T.jsx)(f,{className:`h-8 max-w-[14rem] font-mono text-sm`,value:e.name,disabled:i,onChange:e=>n({name:e.target.value}),placeholder:`primary`,"aria-label":`Server name`}),(0,T.jsx)(`div`,{className:`flex-1`}),(0,T.jsx)(d,{type:`button`,size:`sm`,variant:`ghost`,onClick:r,disabled:i,"aria-label":`Remove server`,children:(0,T.jsx)(o,{className:`h-3.5 w-3.5`})})]}),(0,T.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,T.jsx)(F,{label:`Server URL`,hint:`ldap:// or ldaps://host:port`,children:(0,T.jsx)(f,{className:`h-8 font-mono text-sm`,value:e.url,disabled:i,onChange:e=>n({url:e.target.value}),placeholder:`ldaps://dc1.example.com:636`})}),(0,T.jsx)(F,{label:`Search base`,children:(0,T.jsx)(f,{className:`h-8 font-mono text-sm`,value:e.searchBase,disabled:i,onChange:e=>n({searchBase:e.target.value}),placeholder:`ou=users,dc=example,dc=com`})}),(0,T.jsx)(F,{label:`Bind DN`,hint:`Service account used to look users up. Empty = anonymous search.`,children:(0,T.jsx)(f,{className:`h-8 font-mono text-sm`,value:e.bindDN,disabled:i,onChange:e=>n({bindDN:e.target.value}),placeholder:`cn=canvas,ou=services,dc=example,dc=com`})}),(0,T.jsx)(F,{label:`Bind password`,hint:(0,T.jsxs)(T.Fragment,{children:[`Currently: `,g,e.bindPasswordSet&&e.bindPassword!==null&&(0,T.jsxs)(T.Fragment,{children:[` · `,(0,T.jsx)(`button`,{type:`button`,className:`underline hover:text-foreground`,disabled:i,onClick:()=>n({bindPassword:null}),children:`clear`})]})]}),children:(0,T.jsx)(f,{className:`h-8 text-sm`,type:`password`,autoComplete:`new-password`,value:typeof e.bindPassword==`string`?e.bindPassword:``,disabled:i,onChange:e=>n({bindPassword:e.target.value===``?void 0:e.target.value}),placeholder:e.bindPasswordSet&&e.bindPassword!==null?`••••••••`:``})}),(0,T.jsx)(F,{label:`User search filter`,hint:(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`span`,{className:`font-mono`,children:`{{email}}`}),` is replaced by the address typed at sign-in.`]}),children:(0,T.jsx)(f,{className:`h-8 font-mono text-sm`,value:e.searchFilter,disabled:i,onChange:e=>n({searchFilter:e.target.value})})}),(0,T.jsx)(F,{label:`Group attribute`,hint:`Group memberships drive team workspace sharing.`,children:(0,T.jsx)(f,{className:`h-8 font-mono text-sm`,value:e.groupAttribute,disabled:i,onChange:e=>n({groupAttribute:e.target.value}),placeholder:`memberOf`})}),(0,T.jsx)(F,{label:`Attributes to read`,hint:`Comma-separated.`,className:`sm:col-span-2`,children:(0,T.jsx)(f,{className:`h-8 font-mono text-sm`,value:e.attributes.join(`, `),disabled:i,onChange:e=>n({attributes:e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)})})})]}),(0,T.jsx)(I,{checked:e.tls,disabled:i,onChange:e=>n({tls:e}),label:`Accept self-signed certificates`,hint:`Skips certificate verification for ldaps://. Only for directories with a private CA.`}),(0,T.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2 border-t pt-3`,children:[(0,T.jsx)(F,{label:`Test`,hint:`Binds with the settings above (unsaved edits included). Add an e-mail to also look that user up.`,className:`min-w-[14rem] flex-1`,children:(0,T.jsx)(f,{className:`h-8 text-sm`,type:`email`,value:a,onChange:e=>s(e.target.value),placeholder:`someone@example.com (optional)`})}),(0,T.jsxs)(d,{type:`button`,size:`sm`,variant:`outline`,onClick:h,disabled:l||i,className:`mb-5`,children:[l&&(0,T.jsx)(c,{className:`mr-2 h-3.5 w-3.5 animate-spin`}),`Test connection`]})]}),(0,T.jsx)(R,{result:p})]})}function V({row:e,onChange:t,onRemove:n,disabled:r}){let[i,a]=(0,b.useState)(``),[s,l]=(0,b.useState)(``),[u,p]=(0,b.useState)(!1),[m,h]=(0,b.useState)(null);return(0,T.jsxs)(`div`,{className:`space-y-3 rounded-md border p-3`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`@`}),(0,T.jsx)(f,{className:`h-8 max-w-[16rem] font-mono text-sm`,value:e.domain,disabled:r,onChange:e=>t({domain:e.target.value}),placeholder:`example.com`,"aria-label":`E-mail domain`}),(0,T.jsx)(`div`,{className:`flex-1`}),(0,T.jsx)(d,{type:`button`,size:`sm`,variant:`ghost`,onClick:n,disabled:r,"aria-label":`Remove domain`,children:(0,T.jsx)(o,{className:`h-3.5 w-3.5`})})]}),(0,T.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[1fr_6rem_1fr]`,children:[(0,T.jsx)(F,{label:`IMAP host`,children:(0,T.jsx)(f,{className:`h-8 font-mono text-sm`,value:e.host,disabled:r,onChange:e=>t({host:e.target.value}),placeholder:`imap.example.com`})}),(0,T.jsx)(F,{label:`Port`,children:(0,T.jsx)(f,{className:`h-8 text-sm`,type:`number`,min:1,max:65535,value:e.port,disabled:r,onChange:e=>t({port:Number(e.target.value)})})}),(0,T.jsx)(F,{label:`Label on the sign-in form`,hint:`Optional.`,children:(0,T.jsx)(f,{className:`h-8 text-sm`,value:e.name,disabled:r,onChange:e=>t({name:e.target.value}),placeholder:`Example Mail`})})]}),(0,T.jsxs)(`div`,{className:`flex flex-wrap gap-x-6 gap-y-2`,children:[(0,T.jsx)(I,{checked:e.secure,disabled:r,onChange:e=>t({secure:e,...e?{startTLS:!1}:{}}),label:`TLS from the start`,hint:`Usually port 993.`}),(0,T.jsx)(I,{checked:e.startTLS,disabled:r||e.secure,onChange:e=>t({startTLS:e}),label:`Require STARTTLS`,hint:`Plain port 143 upgraded to TLS.`}),(0,T.jsx)(I,{checked:e.requireAppPassword,disabled:r,onChange:e=>t({requireAppPassword:e}),label:`Needs an app password`,hint:`Shown as a hint on the sign-in form.`})]}),(0,T.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2 border-t pt-3`,children:[(0,T.jsx)(F,{label:`Test sign-in`,hint:`A real IMAP login with these credentials, logged straight out. Nothing is stored.`,className:`min-w-[12rem] flex-1`,children:(0,T.jsx)(f,{className:`h-8 text-sm`,type:`email`,value:i,onChange:e=>a(e.target.value),placeholder:`someone@${e.domain||`example.com`}`})}),(0,T.jsx)(F,{label:`Password`,className:`mb-5 min-w-[10rem] flex-1`,children:(0,T.jsx)(f,{className:`h-8 text-sm`,type:`password`,autoComplete:`off`,value:s,onChange:e=>l(e.target.value)})}),(0,T.jsxs)(d,{type:`button`,size:`sm`,variant:`outline`,onClick:async()=>{p(!0),h(null);try{let{id:t,domain:n,...r}=e;h(await w(r,i.trim(),s))}catch(e){h({ok:!1,message:e instanceof Error?e.message:`Test failed`})}finally{p(!1),l(``)}},disabled:u||r||!i||!s,className:`mb-5`,children:[u&&(0,T.jsx)(c,{className:`mr-2 h-3.5 w-3.5 animate-spin`}),`Test`]})]}),(0,T.jsx)(R,{result:m})]})}function H(){let e=y(),{showToast:t}=_(),n=g()?.userType===`admin`,[r,i]=(0,b.useState)(``),[o,u]=(0,b.useState)(null),[p,h]=(0,b.useState)(null),[C,w]=(0,b.useState)(!0),[E,k]=(0,b.useState)(!1),[P,R]=(0,b.useState)(null),[H,U]=(0,b.useState)(null),W=(0,b.useCallback)(()=>x().then(e=>{let t=O(e.config);i(e.configPath),u(t),h(t),R(null)}).catch(e=>R(e instanceof Error?e.message:`Failed to load auth configuration`)).finally(()=>w(!1)),[]);(0,b.useEffect)(()=>{n&&W()},[n,W]);let G=(0,b.useMemo)(()=>!!p&&!!o&&JSON.stringify(A(p))!==JSON.stringify(A(o)),[p,o]),K=e=>h(t=>t&&e(t)),q=(e,t)=>K(n=>({...n,ldap:{...n.ldap,servers:n.ldap.servers.map(n=>n.id===e?{...n,...t}:n)}})),J=(e,t)=>K(n=>({...n,imap:{...n.imap,domains:n.imap.domains.map(n=>n.id===e?{...n,...t}:n)}})),Y=async()=>{if(!p)return;let e=p.ldap.servers.map(e=>e.name.trim()),n=p.imap.domains.map(e=>e.domain.trim().toLowerCase());if(e.some(e=>!e)||new Set(e).size!==e.length){U(`Every LDAP server needs a unique name.`);return}if(n.some(e=>!e)||new Set(n).size!==n.length){U(`Every IMAP domain must be filled in and listed once.`);return}k(!0),U(null);try{let e=O((await S(A(p))).config);u(e),h(e),t({title:`Authentication settings saved`,description:`Applied immediately — the next sign-in uses them.`})}catch(e){U(e instanceof Error?e.message.replace(/^HTTP \d+:\s*/,``):`Failed to save`)}finally{k(!1)}},X=(0,T.jsx)(v,{onBack:e,compact:!0,className:`mb-6`,title:`Authentication`,description:`Entire server · Choose how people sign in: local passwords, your LDAP directory, or their mail server over IMAP.`,actions:n&&(0,T.jsxs)(d,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>{w(!0),W()},disabled:C||E,children:[(0,T.jsx)(s,{className:`mr-2 h-3.5 w-3.5`}),`Reload`]})});return n?(0,T.jsxs)(`div`,{className:`mx-auto max-w-4xl p-6 pb-24`,children:[X,C&&!p?(0,T.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,T.jsx)(s,{className:`h-4 w-4 animate-spin`}),`Loading…`]}):P||!p?(0,T.jsxs)(`div`,{className:`space-y-3`,children:[(0,T.jsxs)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/5 p-4 text-sm`,children:[(0,T.jsx)(`p`,{className:`font-medium text-destructive`,children:`Authentication settings unavailable`}),(0,T.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:P||`No config returned.`})]}),(0,T.jsx)(d,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>{w(!0),W()},children:`Retry`})]}):(0,T.jsxs)(`div`,{className:`space-y-4`,children:[(0,T.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[`Config file: `,(0,T.jsx)(`span`,{className:`font-mono`,children:r}),` · Sign-in picks the backend from the account: existing users keep the method they were created with; a new address tries LDAP first (when enabled), then IMAP for a listed domain, then local.`]}),(0,T.jsxs)(L,{title:`Sign-up & local passwords`,description:`Accounts whose password is stored on this server.`,children:[(0,T.jsx)(I,{checked:p.allowUserRegistrations,onChange:e=>K(t=>({...t,allowUserRegistrations:e})),label:`Allow self-registration`,hint:`Off = only admins create accounts (and LDAP/IMAP users on first sign-in).`}),(0,T.jsx)(I,{checked:p.local.enabled,onChange:e=>K(t=>({...t,local:{...t.local,enabled:e}})),label:`Local password accounts`,hint:`Off refuses new local registrations. Existing local accounts — admins included — can still sign in, so this cannot lock you out.`}),(0,T.jsx)(I,{checked:p.local.requireEmailVerification,onChange:e=>K(t=>({...t,local:{...t.local,requireEmailVerification:e}})),label:`Require e-mail verification`,hint:`Needs working SMTP (config/smtp.json).`}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`p`,{className:`mb-2 text-xs font-medium`,children:`Password policy`}),(0,T.jsxs)(`div`,{className:`flex flex-wrap items-start gap-4`,children:[(0,T.jsx)(F,{label:`Min length`,children:(0,T.jsx)(f,{className:`h-8 w-24 text-sm`,type:`number`,min:1,max:1024,value:p.local.passwordPolicy.minLength,onChange:e=>K(t=>({...t,local:{...t.local,passwordPolicy:{...t.local.passwordPolicy,minLength:Number(e.target.value)}}}))})}),(0,T.jsx)(F,{label:`Max length`,children:(0,T.jsx)(f,{className:`h-8 w-24 text-sm`,type:`number`,min:1,max:1024,value:p.local.passwordPolicy.maxLength,onChange:e=>K(t=>({...t,local:{...t.local,passwordPolicy:{...t.local.passwordPolicy,maxLength:Number(e.target.value)}}}))})}),(0,T.jsx)(`div`,{className:`grid grid-cols-2 gap-x-6 gap-y-1 pt-1`,children:[[`requireUppercase`,`Uppercase letter`],[`requireLowercase`,`Lowercase letter`],[`requireNumbers`,`Number`],[`requireSpecialChars`,`Special character`]].map(([e,t])=>(0,T.jsx)(I,{checked:p.local.passwordPolicy[e],label:t,onChange:t=>K(n=>({...n,local:{...n.local,passwordPolicy:{...n.local.passwordPolicy,[e]:t}}}))},e))})]})]})]}),(0,T.jsxs)(L,{title:`LDAP / Active Directory`,description:`Users sign in with their directory password. Servers are tried in order, so later ones act as fallbacks.`,enabled:p.ldap.enabled,onToggle:e=>K(t=>({...t,ldap:{...t.ldap,enabled:e}})),children:[(0,T.jsx)(z,{value:p.ldap,onChange:e=>K(t=>({...t,ldap:{...t.ldap,...e}}))}),p.ldap.servers.map((e,t)=>(0,T.jsx)(B,{row:e,index:t,onChange:t=>q(e.id,t),onRemove:()=>K(t=>({...t,ldap:{...t.ldap,servers:t.ldap.servers.filter(t=>t.id!==e.id)}}))},e.id)),(0,T.jsxs)(d,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>K(e=>({...e,ldap:{...e.ldap,servers:[...e.ldap.servers,{...M,id:D(),name:e.ldap.servers.length?`server${e.ldap.servers.length+1}`:`primary`}]}})),children:[(0,T.jsx)(a,{className:`mr-2 h-3.5 w-3.5`}),` Add LDAP server`]})]}),(0,T.jsxs)(L,{title:`IMAP (mail server sign-in)`,description:`Users of a listed e-mail domain sign in with their mailbox password — the server checks it by logging in to IMAP.`,enabled:p.imap.enabled,onToggle:e=>K(t=>({...t,imap:{...t.imap,enabled:e}})),children:[(0,T.jsx)(z,{value:p.imap,onChange:e=>K(t=>({...t,imap:{...t.imap,...e}}))}),p.imap.domains.map(e=>(0,T.jsx)(V,{row:e,onChange:t=>J(e.id,t),onRemove:()=>K(t=>({...t,imap:{...t.imap,domains:t.imap.domains.filter(t=>t.id!==e.id)}}))},e.id)),(0,T.jsxs)(d,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>K(e=>({...e,imap:{...e.imap,domains:[...e.imap.domains,{...N,id:D()}]}})),children:[(0,T.jsx)(a,{className:`mr-2 h-3.5 w-3.5`}),` Add mail domain`]})]}),(0,T.jsxs)(L,{title:`Google sign-in`,description:(0,T.jsxs)(T.Fragment,{children:[`One-click sign-in with a Google account via OAuth. Needs a Google Cloud OAuth client of type `,(0,T.jsx)(`em`,{children:`Web application`}),` whose authorized redirect URI is `,(0,T.jsx)(`code`,{className:`select-all`,children:`${m}/oauth/google/callback`}),`.`]}),enabled:p.google.enabled,onToggle:e=>K(t=>({...t,google:{...t.google,enabled:e}})),children:[(0,T.jsx)(z,{value:p.google,onChange:e=>K(t=>({...t,google:{...t.google,...e}}))}),(0,T.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,T.jsx)(F,{label:`OAuth client id`,children:(0,T.jsx)(f,{className:`h-8 font-mono text-sm`,value:p.google.clientId,autoComplete:`off`,onChange:e=>K(t=>({...t,google:{...t.google,clientId:e.target.value}}))})}),(0,T.jsx)(F,{label:`OAuth client secret`,hint:p.google.clientSecretSet&&p.google.clientSecret===void 0?`A secret is stored; leave blank to keep it.`:void 0,children:(0,T.jsx)(f,{className:`h-8 font-mono text-sm`,type:`password`,autoComplete:`off`,value:p.google.clientSecret??``,placeholder:p.google.clientSecretSet?`••••••••`:``,onChange:e=>K(t=>({...t,google:{...t.google,clientSecret:e.target.value===``?void 0:e.target.value}}))})}),(0,T.jsx)(F,{label:`Allowed e-mail domains`,hint:`Comma separated. Empty = any Google account may sign in.`,children:(0,T.jsx)(j,{value:p.google.allowedDomains,placeholder:`example.com, example.org`,onChange:e=>K(t=>({...t,google:{...t.google,allowedDomains:e}}))})}),(0,T.jsx)(F,{label:`Extra web origins`,hint:`Only when the web UI is served from another origin than the API (e.g. a Vite dev server).`,children:(0,T.jsx)(j,{value:p.google.webOrigins,placeholder:`http://localhost:5173`,onChange:e=>K(t=>({...t,google:{...t.google,webOrigins:e}}))})})]}),(0,T.jsx)(I,{checked:p.google.autoCreateUsers,label:`Create an account on first sign-in`,hint:`Off: only users that already exist (by e-mail) can sign in with Google.`,onChange:e=>K(t=>({...t,google:{...t.google,autoCreateUsers:e}}))})]}),(G||H)&&(0,T.jsxs)(`div`,{className:`sticky bottom-4 z-10 rounded-lg border bg-card p-3 shadow-elevation-4`,children:[H&&(0,T.jsx)(`ul`,{className:`mb-2 space-y-0.5 text-xs text-destructive`,children:H.split(`; `).map(e=>(0,T.jsx)(`li`,{children:e},e))}),(0,T.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,T.jsx)(`span`,{className:`mr-auto text-xs text-muted-foreground`,children:G?`Unsaved changes`:``}),(0,T.jsx)(d,{type:`button`,size:`sm`,variant:`ghost`,disabled:E,onClick:()=>{h(o),U(null)},children:`Discard`}),(0,T.jsxs)(d,{type:`button`,size:`sm`,disabled:E||!G,onClick:()=>void Y(),children:[E&&(0,T.jsx)(c,{className:`mr-2 h-3.5 w-3.5 animate-spin`}),`Save`]})]})]})]})]}):(0,T.jsxs)(`div`,{className:`mx-auto max-w-4xl p-6`,children:[X,(0,T.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border p-3 text-xs`,children:[(0,T.jsx)(l,{className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`}),(0,T.jsx)(`p`,{className:`text-muted-foreground`,children:`Authentication settings are only available to server admins.`})]})]})}export{H as default};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{Ir as r,Nr as i,Pt as a,X as o,kt as s,pn as c,pt as l}from"./ui-DEgHnkQu.js";import{t as u}from"./utils-2pl1SbIp.js";import{t as d}from"./button--VYZekMF.js";import{t as f}from"./input-BOtCd4HP.js";import{c as p,l as m,t as h}from"./api-CA6WiiYM.js";import{i as g}from"./auth-Bx9fAZmz.js";import{n as _}from"./use-toast-BlLDqSUO.js";import{n as v}from"./page-header-NyYSXjfY.js";import{t as y}from"./use-settings-back-D_MM9diy.js";var b=e(n(),1);function x(){return h.get(p.admin.authConfig)}function S(e){return h.put(p.admin.authConfig,e)}function C(e,t,n){return h.post(`${p.admin.authConfig}/test`,{strategy:`ldap`,name:e,server:t,email:n})}function w(e,t,n){return h.post(`${p.admin.authConfig}/test`,{strategy:`imap`,domain:e,email:t,password:n})}var T=t(),E=0,D=()=>`row-${++E}`;function O(e){let{servers:t,...n}=e.strategies.ldap,{domains:r,...i}=e.strategies.imap;return{allowUserRegistrations:e.allowUserRegistrations,local:e.strategies.local,ldap:{...n,servers:Object.entries(t).map(([e,t])=>({...t,id:D(),name:e,originalName:e}))},imap:{...i,domains:Object.entries(r).map(([e,t])=>({...t,id:D(),domain:e}))},google:e.strategies.google??{enabled:!1,defaultUserType:`user`,defaultStatus:`active`,clientId:``,clientSecretSet:!1,allowedDomains:[],autoCreateUsers:!0,webOrigins:[]}}}function k(e){let{id:t,name:n,originalName:r,...i}=e;return{...i,...r&&r!==e.name?{previousName:r}:{}}}function A(e){return{allowUserRegistrations:e.allowUserRegistrations,strategies:{local:e.local,ldap:{enabled:e.ldap.enabled,defaultUserType:e.ldap.defaultUserType,defaultStatus:e.ldap.defaultStatus,servers:Object.fromEntries(e.ldap.servers.map(e=>[e.name.trim(),k(e)]))},imap:{enabled:e.imap.enabled,defaultUserType:e.imap.defaultUserType,defaultStatus:e.imap.defaultStatus,domains:Object.fromEntries(e.imap.domains.map(({id:e,domain:t,...n})=>[t.trim().toLowerCase(),n]))},google:e.google}}}function j({value:e,onChange:t,placeholder:n,disabled:r}){let i=e.join(`, `),[a,o]=(0,b.useState)(i),[s,c]=(0,b.useState)(i);return i!==s&&(c(i),a.split(/[\s,]+/).filter(Boolean).join(`, `)!==i&&o(i)),(0,T.jsx)(f,{className:`h-8 text-sm`,value:a,placeholder:n,disabled:r,onChange:e=>{o(e.target.value),t(e.target.value.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean))}})}var M={originalName:null,url:`ldap://`,bindDN:``,bindPasswordSet:!1,bindPassword:void 0,searchBase:``,searchFilter:`(mail={{email}})`,attributes:[`mail`,`cn`,`displayName`,`memberOf`],groupAttribute:`memberOf`,tls:!1},N={domain:``,name:``,host:``,port:993,secure:!0,startTLS:!1,requireAppPassword:!1},P=`h-8 rounded-md border border-input bg-transparent px-2 text-sm outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:opacity-50`;function F({label:e,hint:t,children:n,className:r}){return(0,T.jsxs)(`label`,{className:u(`flex min-w-0 flex-col gap-1`,r),children:[(0,T.jsx)(`span`,{className:`text-xs font-medium`,children:e}),n,t&&(0,T.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t})]})}function I({checked:e,onChange:t,disabled:n,label:r,hint:i}){return(0,T.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,T.jsx)(`input`,{type:`checkbox`,className:`mt-0.5`,checked:e,disabled:n,onChange:e=>t(e.target.checked)}),(0,T.jsxs)(`span`,{children:[r,i&&(0,T.jsx)(`span`,{className:`block text-[11px] text-muted-foreground`,children:i})]})]})}function L({title:e,description:t,enabled:n,onToggle:r,disabled:i,children:a}){return(0,T.jsxs)(`section`,{className:`rounded-lg border p-4`,children:[(0,T.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsx)(`h3`,{className:`text-sm font-semibold`,children:e}),(0,T.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:t})]}),r&&(0,T.jsxs)(`label`,{className:`flex shrink-0 items-center gap-2 text-xs font-medium`,children:[(0,T.jsx)(`input`,{type:`checkbox`,checked:!!n,disabled:i,onChange:e=>r(e.target.checked)}),n?`Enabled`:`Disabled`]})]}),(0,T.jsx)(`div`,{className:u(`mt-4 space-y-4`,r&&!n&&`opacity-60`),children:a})]})}function R({result:e}){return e?(0,T.jsxs)(`div`,{className:u(`flex items-start gap-2 rounded-md border p-2 text-xs`,e.ok?`border-emerald-500/40 bg-emerald-500/5`:`border-destructive/40 bg-destructive/5`),children:[e.ok?(0,T.jsx)(r,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-emerald-600`}):(0,T.jsx)(i,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-destructive`}),(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsx)(`p`,{children:e.message}),e.user&&e.user.groups.length>0&&(0,T.jsxs)(`p`,{className:`mt-1 break-all text-muted-foreground`,children:[`Groups: `,e.user.groups.join(` · `)]})]})]}):null}function z({value:e,onChange:t,disabled:n}){return(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsxs)(`div`,{className:`flex flex-wrap gap-4`,children:[(0,T.jsx)(F,{label:`New accounts are`,children:(0,T.jsxs)(`select`,{className:P,value:e.defaultUserType,disabled:n,onChange:e=>t({defaultUserType:e.target.value}),children:[(0,T.jsx)(`option`,{value:`user`,children:`Users`}),(0,T.jsx)(`option`,{value:`admin`,children:`Admins`})]})}),(0,T.jsx)(F,{label:`Initial status`,children:(0,T.jsxs)(`select`,{className:P,value:e.defaultStatus,disabled:n,onChange:e=>t({defaultStatus:e.target.value}),children:[(0,T.jsx)(`option`,{value:`active`,children:`Active — can sign in right away`}),(0,T.jsx)(`option`,{value:`pending`,children:`Pending — an admin activates them`}),(0,T.jsx)(`option`,{value:`inactive`,children:`Inactive`})]})})]}),e.defaultUserType===`admin`&&(0,T.jsxs)(`p`,{className:`flex items-start gap-1.5 text-[11px] text-destructive`,children:[(0,T.jsx)(l,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),`Everyone who can sign in through this backend becomes a server admin on first login.`]})]})}function B({row:e,index:t,onChange:n,onRemove:r,disabled:i}){let[a,s]=(0,b.useState)(``),[l,u]=(0,b.useState)(!1),[p,m]=(0,b.useState)(null),h=async()=>{u(!0),m(null);try{m(await C(e.originalName??e.name,k(e),a.trim()||void 0))}catch(e){m({ok:!1,message:e instanceof Error?e.message:`Test failed`})}finally{u(!1)}},g=e.bindPassword===null?`cleared on save`:typeof e.bindPassword==`string`?`replaced on save`:e.bindPasswordSet?`stored — leave empty to keep it`:`none set`;return(0,T.jsxs)(`div`,{className:`space-y-3 rounded-md border p-3`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsxs)(`span`,{className:`shrink-0 text-[11px] text-muted-foreground`,children:[`#`,t+1]}),(0,T.jsx)(f,{className:`h-8 max-w-[14rem] font-mono text-sm`,value:e.name,disabled:i,onChange:e=>n({name:e.target.value}),placeholder:`primary`,"aria-label":`Server name`}),(0,T.jsx)(`div`,{className:`flex-1`}),(0,T.jsx)(d,{type:`button`,size:`sm`,variant:`ghost`,onClick:r,disabled:i,"aria-label":`Remove server`,children:(0,T.jsx)(o,{className:`h-3.5 w-3.5`})})]}),(0,T.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,T.jsx)(F,{label:`Server URL`,hint:`ldap:// or ldaps://host:port`,children:(0,T.jsx)(f,{className:`h-8 font-mono text-sm`,value:e.url,disabled:i,onChange:e=>n({url:e.target.value}),placeholder:`ldaps://dc1.example.com:636`})}),(0,T.jsx)(F,{label:`Search base`,children:(0,T.jsx)(f,{className:`h-8 font-mono text-sm`,value:e.searchBase,disabled:i,onChange:e=>n({searchBase:e.target.value}),placeholder:`ou=users,dc=example,dc=com`})}),(0,T.jsx)(F,{label:`Bind DN`,hint:`Service account used to look users up. Empty = anonymous search.`,children:(0,T.jsx)(f,{className:`h-8 font-mono text-sm`,value:e.bindDN,disabled:i,onChange:e=>n({bindDN:e.target.value}),placeholder:`cn=canvas,ou=services,dc=example,dc=com`})}),(0,T.jsx)(F,{label:`Bind password`,hint:(0,T.jsxs)(T.Fragment,{children:[`Currently: `,g,e.bindPasswordSet&&e.bindPassword!==null&&(0,T.jsxs)(T.Fragment,{children:[` · `,(0,T.jsx)(`button`,{type:`button`,className:`underline hover:text-foreground`,disabled:i,onClick:()=>n({bindPassword:null}),children:`clear`})]})]}),children:(0,T.jsx)(f,{className:`h-8 text-sm`,type:`password`,autoComplete:`new-password`,value:typeof e.bindPassword==`string`?e.bindPassword:``,disabled:i,onChange:e=>n({bindPassword:e.target.value===``?void 0:e.target.value}),placeholder:e.bindPasswordSet&&e.bindPassword!==null?`••••••••`:``})}),(0,T.jsx)(F,{label:`User search filter`,hint:(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`span`,{className:`font-mono`,children:`{{email}}`}),` is replaced by the address typed at sign-in.`]}),children:(0,T.jsx)(f,{className:`h-8 font-mono text-sm`,value:e.searchFilter,disabled:i,onChange:e=>n({searchFilter:e.target.value})})}),(0,T.jsx)(F,{label:`Group attribute`,hint:`Group memberships drive team workspace sharing.`,children:(0,T.jsx)(f,{className:`h-8 font-mono text-sm`,value:e.groupAttribute,disabled:i,onChange:e=>n({groupAttribute:e.target.value}),placeholder:`memberOf`})}),(0,T.jsx)(F,{label:`Attributes to read`,hint:`Comma-separated.`,className:`sm:col-span-2`,children:(0,T.jsx)(f,{className:`h-8 font-mono text-sm`,value:e.attributes.join(`, `),disabled:i,onChange:e=>n({attributes:e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)})})})]}),(0,T.jsx)(I,{checked:e.tls,disabled:i,onChange:e=>n({tls:e}),label:`Accept self-signed certificates`,hint:`Skips certificate verification for ldaps://. Only for directories with a private CA.`}),(0,T.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2 border-t pt-3`,children:[(0,T.jsx)(F,{label:`Test`,hint:`Binds with the settings above (unsaved edits included). Add an e-mail to also look that user up.`,className:`min-w-[14rem] flex-1`,children:(0,T.jsx)(f,{className:`h-8 text-sm`,type:`email`,value:a,onChange:e=>s(e.target.value),placeholder:`someone@example.com (optional)`})}),(0,T.jsxs)(d,{type:`button`,size:`sm`,variant:`outline`,onClick:h,disabled:l||i,className:`mb-5`,children:[l&&(0,T.jsx)(c,{className:`mr-2 h-3.5 w-3.5 animate-spin`}),`Test connection`]})]}),(0,T.jsx)(R,{result:p})]})}function V({row:e,onChange:t,onRemove:n,disabled:r}){let[i,a]=(0,b.useState)(``),[s,l]=(0,b.useState)(``),[u,p]=(0,b.useState)(!1),[m,h]=(0,b.useState)(null);return(0,T.jsxs)(`div`,{className:`space-y-3 rounded-md border p-3`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`@`}),(0,T.jsx)(f,{className:`h-8 max-w-[16rem] font-mono text-sm`,value:e.domain,disabled:r,onChange:e=>t({domain:e.target.value}),placeholder:`example.com`,"aria-label":`E-mail domain`}),(0,T.jsx)(`div`,{className:`flex-1`}),(0,T.jsx)(d,{type:`button`,size:`sm`,variant:`ghost`,onClick:n,disabled:r,"aria-label":`Remove domain`,children:(0,T.jsx)(o,{className:`h-3.5 w-3.5`})})]}),(0,T.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[1fr_6rem_1fr]`,children:[(0,T.jsx)(F,{label:`IMAP host`,children:(0,T.jsx)(f,{className:`h-8 font-mono text-sm`,value:e.host,disabled:r,onChange:e=>t({host:e.target.value}),placeholder:`imap.example.com`})}),(0,T.jsx)(F,{label:`Port`,children:(0,T.jsx)(f,{className:`h-8 text-sm`,type:`number`,min:1,max:65535,value:e.port,disabled:r,onChange:e=>t({port:Number(e.target.value)})})}),(0,T.jsx)(F,{label:`Label on the sign-in form`,hint:`Optional.`,children:(0,T.jsx)(f,{className:`h-8 text-sm`,value:e.name,disabled:r,onChange:e=>t({name:e.target.value}),placeholder:`Example Mail`})})]}),(0,T.jsxs)(`div`,{className:`flex flex-wrap gap-x-6 gap-y-2`,children:[(0,T.jsx)(I,{checked:e.secure,disabled:r,onChange:e=>t({secure:e,...e?{startTLS:!1}:{}}),label:`TLS from the start`,hint:`Usually port 993.`}),(0,T.jsx)(I,{checked:e.startTLS,disabled:r||e.secure,onChange:e=>t({startTLS:e}),label:`Require STARTTLS`,hint:`Plain port 143 upgraded to TLS.`}),(0,T.jsx)(I,{checked:e.requireAppPassword,disabled:r,onChange:e=>t({requireAppPassword:e}),label:`Needs an app password`,hint:`Shown as a hint on the sign-in form.`})]}),(0,T.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2 border-t pt-3`,children:[(0,T.jsx)(F,{label:`Test sign-in`,hint:`A real IMAP login with these credentials, logged straight out. Nothing is stored.`,className:`min-w-[12rem] flex-1`,children:(0,T.jsx)(f,{className:`h-8 text-sm`,type:`email`,value:i,onChange:e=>a(e.target.value),placeholder:`someone@${e.domain||`example.com`}`})}),(0,T.jsx)(F,{label:`Password`,className:`mb-5 min-w-[10rem] flex-1`,children:(0,T.jsx)(f,{className:`h-8 text-sm`,type:`password`,autoComplete:`off`,value:s,onChange:e=>l(e.target.value)})}),(0,T.jsxs)(d,{type:`button`,size:`sm`,variant:`outline`,onClick:async()=>{p(!0),h(null);try{let{id:t,domain:n,...r}=e;h(await w(r,i.trim(),s))}catch(e){h({ok:!1,message:e instanceof Error?e.message:`Test failed`})}finally{p(!1),l(``)}},disabled:u||r||!i||!s,className:`mb-5`,children:[u&&(0,T.jsx)(c,{className:`mr-2 h-3.5 w-3.5 animate-spin`}),`Test`]})]}),(0,T.jsx)(R,{result:m})]})}function H(){let e=y(),{showToast:t}=_(),n=g()?.userType===`admin`,[r,i]=(0,b.useState)(``),[o,u]=(0,b.useState)(null),[p,h]=(0,b.useState)(null),[C,w]=(0,b.useState)(!0),[E,k]=(0,b.useState)(!1),[P,R]=(0,b.useState)(null),[H,U]=(0,b.useState)(null),W=(0,b.useCallback)(()=>x().then(e=>{let t=O(e.config);i(e.configPath),u(t),h(t),R(null)}).catch(e=>R(e instanceof Error?e.message:`Failed to load auth configuration`)).finally(()=>w(!1)),[]);(0,b.useEffect)(()=>{n&&W()},[n,W]);let G=(0,b.useMemo)(()=>!!p&&!!o&&JSON.stringify(A(p))!==JSON.stringify(A(o)),[p,o]),K=e=>h(t=>t&&e(t)),q=(e,t)=>K(n=>({...n,ldap:{...n.ldap,servers:n.ldap.servers.map(n=>n.id===e?{...n,...t}:n)}})),J=(e,t)=>K(n=>({...n,imap:{...n.imap,domains:n.imap.domains.map(n=>n.id===e?{...n,...t}:n)}})),Y=async()=>{if(!p)return;let e=p.ldap.servers.map(e=>e.name.trim()),n=p.imap.domains.map(e=>e.domain.trim().toLowerCase());if(e.some(e=>!e)||new Set(e).size!==e.length){U(`Every LDAP server needs a unique name.`);return}if(n.some(e=>!e)||new Set(n).size!==n.length){U(`Every IMAP domain must be filled in and listed once.`);return}k(!0),U(null);try{let e=O((await S(A(p))).config);u(e),h(e),t({title:`Authentication settings saved`,description:`Applied immediately — the next sign-in uses them.`})}catch(e){U(e instanceof Error?e.message.replace(/^HTTP \d+:\s*/,``):`Failed to save`)}finally{k(!1)}},X=(0,T.jsx)(v,{onBack:e,compact:!0,className:`mb-6`,title:`Authentication`,description:`Entire server · Choose how people sign in: local passwords, your LDAP directory, or their mail server over IMAP.`,actions:n&&(0,T.jsxs)(d,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>{w(!0),W()},disabled:C||E,children:[(0,T.jsx)(s,{className:`mr-2 h-3.5 w-3.5`}),`Reload`]})});return n?(0,T.jsxs)(`div`,{className:`mx-auto max-w-4xl p-6 pb-24`,children:[X,C&&!p?(0,T.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,T.jsx)(s,{className:`h-4 w-4 animate-spin`}),`Loading…`]}):P||!p?(0,T.jsxs)(`div`,{className:`space-y-3`,children:[(0,T.jsxs)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/5 p-4 text-sm`,children:[(0,T.jsx)(`p`,{className:`font-medium text-destructive`,children:`Authentication settings unavailable`}),(0,T.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:P||`No config returned.`})]}),(0,T.jsx)(d,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>{w(!0),W()},children:`Retry`})]}):(0,T.jsxs)(`div`,{className:`space-y-4`,children:[(0,T.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[`Config file: `,(0,T.jsx)(`span`,{className:`font-mono`,children:r}),` · Sign-in picks the backend from the account: existing users keep the method they were created with; a new address tries LDAP first (when enabled), then IMAP for a listed domain, then local.`]}),(0,T.jsxs)(L,{title:`Sign-up & local passwords`,description:`Accounts whose password is stored on this server.`,children:[(0,T.jsx)(I,{checked:p.allowUserRegistrations,onChange:e=>K(t=>({...t,allowUserRegistrations:e})),label:`Allow self-registration`,hint:`Off = only admins create accounts (and LDAP/IMAP users on first sign-in).`}),(0,T.jsx)(I,{checked:p.local.enabled,onChange:e=>K(t=>({...t,local:{...t.local,enabled:e}})),label:`Local password accounts`,hint:`Off refuses new local registrations. Existing local accounts — admins included — can still sign in, so this cannot lock you out.`}),(0,T.jsx)(I,{checked:p.local.requireEmailVerification,onChange:e=>K(t=>({...t,local:{...t.local,requireEmailVerification:e}})),label:`Require e-mail verification`,hint:`Needs working SMTP (config/smtp.json).`}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`p`,{className:`mb-2 text-xs font-medium`,children:`Password policy`}),(0,T.jsxs)(`div`,{className:`flex flex-wrap items-start gap-4`,children:[(0,T.jsx)(F,{label:`Min length`,children:(0,T.jsx)(f,{className:`h-8 w-24 text-sm`,type:`number`,min:1,max:1024,value:p.local.passwordPolicy.minLength,onChange:e=>K(t=>({...t,local:{...t.local,passwordPolicy:{...t.local.passwordPolicy,minLength:Number(e.target.value)}}}))})}),(0,T.jsx)(F,{label:`Max length`,children:(0,T.jsx)(f,{className:`h-8 w-24 text-sm`,type:`number`,min:1,max:1024,value:p.local.passwordPolicy.maxLength,onChange:e=>K(t=>({...t,local:{...t.local,passwordPolicy:{...t.local.passwordPolicy,maxLength:Number(e.target.value)}}}))})}),(0,T.jsx)(`div`,{className:`grid grid-cols-2 gap-x-6 gap-y-1 pt-1`,children:[[`requireUppercase`,`Uppercase letter`],[`requireLowercase`,`Lowercase letter`],[`requireNumbers`,`Number`],[`requireSpecialChars`,`Special character`]].map(([e,t])=>(0,T.jsx)(I,{checked:p.local.passwordPolicy[e],label:t,onChange:t=>K(n=>({...n,local:{...n.local,passwordPolicy:{...n.local.passwordPolicy,[e]:t}}}))},e))})]})]})]}),(0,T.jsxs)(L,{title:`LDAP / Active Directory`,description:`Users sign in with their directory password. Servers are tried in order, so later ones act as fallbacks.`,enabled:p.ldap.enabled,onToggle:e=>K(t=>({...t,ldap:{...t.ldap,enabled:e}})),children:[(0,T.jsx)(z,{value:p.ldap,onChange:e=>K(t=>({...t,ldap:{...t.ldap,...e}}))}),p.ldap.servers.map((e,t)=>(0,T.jsx)(B,{row:e,index:t,onChange:t=>q(e.id,t),onRemove:()=>K(t=>({...t,ldap:{...t.ldap,servers:t.ldap.servers.filter(t=>t.id!==e.id)}}))},e.id)),(0,T.jsxs)(d,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>K(e=>({...e,ldap:{...e.ldap,servers:[...e.ldap.servers,{...M,id:D(),name:e.ldap.servers.length?`server${e.ldap.servers.length+1}`:`primary`}]}})),children:[(0,T.jsx)(a,{className:`mr-2 h-3.5 w-3.5`}),` Add LDAP server`]})]}),(0,T.jsxs)(L,{title:`IMAP (mail server sign-in)`,description:`Users of a listed e-mail domain sign in with their mailbox password — the server checks it by logging in to IMAP.`,enabled:p.imap.enabled,onToggle:e=>K(t=>({...t,imap:{...t.imap,enabled:e}})),children:[(0,T.jsx)(z,{value:p.imap,onChange:e=>K(t=>({...t,imap:{...t.imap,...e}}))}),p.imap.domains.map(e=>(0,T.jsx)(V,{row:e,onChange:t=>J(e.id,t),onRemove:()=>K(t=>({...t,imap:{...t.imap,domains:t.imap.domains.filter(t=>t.id!==e.id)}}))},e.id)),(0,T.jsxs)(d,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>K(e=>({...e,imap:{...e.imap,domains:[...e.imap.domains,{...N,id:D()}]}})),children:[(0,T.jsx)(a,{className:`mr-2 h-3.5 w-3.5`}),` Add mail domain`]})]}),(0,T.jsxs)(L,{title:`Google sign-in`,description:(0,T.jsxs)(T.Fragment,{children:[`One-click sign-in with a Google account via OAuth. Needs a Google Cloud OAuth client of type `,(0,T.jsx)(`em`,{children:`Web application`}),` whose authorized redirect URI is `,(0,T.jsx)(`code`,{className:`select-all`,children:`${m}/oauth/google/callback`}),`.`]}),enabled:p.google.enabled,onToggle:e=>K(t=>({...t,google:{...t.google,enabled:e}})),children:[(0,T.jsx)(z,{value:p.google,onChange:e=>K(t=>({...t,google:{...t.google,...e}}))}),(0,T.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,T.jsx)(F,{label:`OAuth client id`,children:(0,T.jsx)(f,{className:`h-8 font-mono text-sm`,value:p.google.clientId,autoComplete:`off`,onChange:e=>K(t=>({...t,google:{...t.google,clientId:e.target.value}}))})}),(0,T.jsx)(F,{label:`OAuth client secret`,hint:p.google.clientSecretSet&&p.google.clientSecret===void 0?`A secret is stored; leave blank to keep it.`:void 0,children:(0,T.jsx)(f,{className:`h-8 font-mono text-sm`,type:`password`,autoComplete:`off`,value:p.google.clientSecret??``,placeholder:p.google.clientSecretSet?`••••••••`:``,onChange:e=>K(t=>({...t,google:{...t.google,clientSecret:e.target.value===``?void 0:e.target.value}}))})}),(0,T.jsx)(F,{label:`Allowed e-mail domains`,hint:`Comma separated. Empty = any Google account may sign in.`,children:(0,T.jsx)(j,{value:p.google.allowedDomains,placeholder:`example.com, example.org`,onChange:e=>K(t=>({...t,google:{...t.google,allowedDomains:e}}))})}),(0,T.jsx)(F,{label:`Extra web origins`,hint:`Only when the web UI is served from another origin than the API (e.g. a Vite dev server).`,children:(0,T.jsx)(j,{value:p.google.webOrigins,placeholder:`http://localhost:5173`,onChange:e=>K(t=>({...t,google:{...t.google,webOrigins:e}}))})})]}),(0,T.jsx)(I,{checked:p.google.autoCreateUsers,label:`Create an account on first sign-in`,hint:`Off: only users that already exist (by e-mail) can sign in with Google.`,onChange:e=>K(t=>({...t,google:{...t.google,autoCreateUsers:e}}))})]}),(G||H)&&(0,T.jsxs)(`div`,{className:`sticky bottom-4 z-10 rounded-lg border bg-card p-3 shadow-elevation-4`,children:[H&&(0,T.jsx)(`ul`,{className:`mb-2 space-y-0.5 text-xs text-destructive`,children:H.split(`; `).map(e=>(0,T.jsx)(`li`,{children:e},e))}),(0,T.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,T.jsx)(`span`,{className:`mr-auto text-xs text-muted-foreground`,children:G?`Unsaved changes`:``}),(0,T.jsx)(d,{type:`button`,size:`sm`,variant:`ghost`,disabled:E,onClick:()=>{h(o),U(null)},children:`Discard`}),(0,T.jsxs)(d,{type:`button`,size:`sm`,disabled:E||!G,onClick:()=>void Y(),children:[E&&(0,T.jsx)(c,{className:`mr-2 h-3.5 w-3.5 animate-spin`}),`Save`]})]})]})]})]}):(0,T.jsxs)(`div`,{className:`mx-auto max-w-4xl p-6`,children:[X,(0,T.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border p-3 text-xs`,children:[(0,T.jsx)(l,{className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`}),(0,T.jsx)(`p`,{className:`text-muted-foreground`,children:`Authentication settings are only available to server admins.`})]})]})}export{H as default};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{Si as r}from"./ui-CDoK3F3U.js";import{i}from"./utils-BxVxyehK.js";import{t as a}from"./utils-2pl1SbIp.js";var o=e(n(),1),s=i([`inline-flex items-center justify-center gap-2 whitespace-nowrap`,`text-sm transition-colors`,`rounded-(--btn-radius) font-(number:--btn-font-weight)`,`focus-ring`,`disabled:pointer-events-none disabled:opacity-50`,`[&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`],{variants:{variant:{default:`bg-primary text-primary-foreground shadow-elevation-1 hover:bg-primary/90`,destructive:`bg-destructive text-destructive-foreground shadow-elevation-1 hover:bg-destructive/90`,outline:`border-(length:--btn-border-width) border-input bg-background shadow-elevation-1 hover:bg-accent hover:text-accent-foreground`,secondary:`bg-secondary text-secondary-foreground shadow-elevation-1 hover:bg-secondary/80`,ghost:`hover:bg-accent hover:text-accent-foreground`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-(--btn-height) px-(--btn-padding-x)`,sm:`h-control-sm rounded-(--btn-radius) px-3 text-xs`,lg:`h-control-lg rounded-(--btn-radius) px-8`,icon:`h-(--btn-height) w-(--btn-height)`}},defaultVariants:{variant:`default`,size:`default`}}),c=t(),l=o.forwardRef(({className:e,variant:t,size:n,asChild:i=!1,...o},l)=>(0,c.jsx)(i?r:`button`,{className:a(s({variant:t,size:n,className:e})),ref:l,...o}));l.displayName=`Button`;export{s as n,l as t};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{wi as r}from"./ui-DEgHnkQu.js";import{i}from"./utils-BxVxyehK.js";import{t as a}from"./utils-2pl1SbIp.js";var o=e(n(),1),s=i([`inline-flex items-center justify-center gap-2 whitespace-nowrap`,`text-sm transition-colors`,`rounded-(--btn-radius) font-(number:--btn-font-weight)`,`focus-ring`,`disabled:pointer-events-none disabled:opacity-50`,`[&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`],{variants:{variant:{default:`bg-primary text-primary-foreground shadow-elevation-1 hover:bg-primary/90`,destructive:`bg-destructive text-destructive-foreground shadow-elevation-1 hover:bg-destructive/90`,outline:`border-(length:--btn-border-width) border-input bg-background shadow-elevation-1 hover:bg-accent hover:text-accent-foreground`,secondary:`bg-secondary text-secondary-foreground shadow-elevation-1 hover:bg-secondary/80`,ghost:`hover:bg-accent hover:text-accent-foreground`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-(--btn-height) px-(--btn-padding-x)`,sm:`h-control-sm rounded-(--btn-radius) px-3 text-xs`,lg:`h-control-lg rounded-(--btn-radius) px-8`,icon:`h-(--btn-height) w-(--btn-height)`}},defaultVariants:{variant:`default`,size:`default`}}),c=t(),l=o.forwardRef(({className:e,variant:t,size:n,asChild:i=!1,...o},l)=>(0,c.jsx)(i?r:`button`,{className:a(s({variant:t,size:n,className:e})),ref:l,...o}));l.displayName=`Button`;export{s as n,l as t};
@@ -1 +1 @@
1
- import{c as e,t}from"./api-CA6WiiYM.js";import{Cn as n,wn as r}from"./workspace-C5V-ZCOE.js";var i=`contexts:deleted`;function a(e,t){return e.id===t.id?t.ownerId===void 0?e.isShared!==!0&&e.type!==`shared`:e.userId===t.ownerId:!1}async function o(){try{let n=await t.get(e.contexts);return Array.isArray(n)?n:(console.warn(`listContexts: response.payload is not an array:`,n),[])}catch(e){throw console.error(`Failed to list contexts:`,e),e}}function s(e,t){return t?`${e}${e.includes(`?`)?`&`:`?`}ownerId=${encodeURIComponent(t)}`:e}async function c(n,r){try{let i=s(`${e.contexts}/${n}`,r),a=await t.get(i);if(a&&a)return a;throw Error(`Context data not found in API response`)}catch(e){throw console.error(`Failed to get context ${n}:`,e),e}}async function l(n){try{let r=await t.post(e.contexts,n);if(r&&r&&r.context)return r.context;throw Error(`Created context data not found in API response`)}catch(e){throw console.error(`Failed to create context:`,e),e}}async function u(n,r,i){try{let a=s(`${e.contexts}/${n}`,i),o=await t.put(a,r);if(o?.context)return o.context;throw Error(`Updated context data not found in API response`)}catch(e){throw console.error(`Failed to patch context ${n}:`,e),e}}async function d(n,r,i){try{let a=s(`${e.contexts}/${n}`,i),o=await t.put(a,r);if(o?.context)return o.context;throw Error(`Updated context data not found in API response`)}catch(e){throw console.error(`Failed to update context ${n}:`,e),e}}async function f(n,r,i,a){try{let o=s(`${e.contexts}/${n}/url`,i),c=await t.post(o,{url:r,...a?{treeName:a}:{}});if(c&&c&&c.url)return{url:c.url,treeId:c.treeId};throw Error(`Updated context data not found in API response`)}catch(e){throw console.error(`Failed to update context URL for ${n}:`,e),e}}async function p(n,r){try{let a=s(`${e.contexts}/${n}`,r);await t.delete(a),window.dispatchEvent(new CustomEvent(i,{detail:{id:n,ownerId:r}}))}catch(e){throw console.error(`Failed to delete context ${n}:`,e),e}}async function m(i,a=[],o=[],s={},c){try{if(s.ids?.length===0)return Object.assign([],{count:0,totalCount:0});if(r(s.sortBy)){let e=await n(s,async e=>{let t=await m(i,a,o,{...s,...e,sortBy:void 0,order:`asc`},c);return{payload:t,count:t.count,totalCount:t.totalCount}});return Object.assign(e.payload,{count:e.count,totalCount:e.totalCount})}let l=new URLSearchParams;s.geoSelection&&(l.set(`geoSelection`,JSON.stringify(s.geoSelection)),l.set(`includeUnlocated`,String(s.includeUnlocated===!0))),s.ids?.forEach(e=>l.append(`ids`,String(e))),a.forEach(e=>l.append(`allOf`,e)),o.forEach(e=>l.append(`filters`,e)),(s.anyOf||[]).filter(Boolean).forEach(e=>l.append(`anyOf`,e)),(s.noneOf||[]).filter(Boolean).forEach(e=>l.append(`noneOf`,e)),s.sortBy&&l.append(`sortBy`,s.sortBy),s.order&&l.append(`order`,s.order),s.applyContextSpec===!1&&l.append(`applyContextSpec`,`false`),c&&l.append(`ownerId`,c),s.includeServerContext!==void 0&&l.append(`includeServerContext`,s.includeServerContext.toString()),s.includeClientContext!==void 0&&l.append(`includeClientContext`,s.includeClientContext.toString()),s.limit!==void 0&&l.append(`limit`,s.limit.toString()),s.offset!==void 0&&l.append(`offset`,s.offset.toString()),s.page!==void 0&&l.append(`page`,s.page.toString()),(s.queries&&s.queries.length?s.queries:s.q?[s.q]:[]).map(e=>e.trim()).filter(Boolean).forEach(e=>l.append(`q`,e));let u=`${e.contexts}/${i}/documents${l.toString()?`?`+l.toString():``}`,d=await t.getEnvelope(u,{signal:s.signal}),f=d.payload;if(Array.isArray(f)){let e=f;return e.count=d.count??void 0,e.totalCount=d.totalCount??void 0,e}return console.warn(`getContextDocuments: payload is not an array:`,f),[]}catch(e){throw console.error(`Failed to get context documents for ${i}:`,e),e}}async function h(n){let r=await t.get(`${e.contexts}/${n}/shares`);return Array.isArray(r)?r:[]}async function g(n,r,i){try{return{message:(await t.post(`${e.contexts}/${n}/shares`,{userEmail:r,accessLevel:i})).message||`Context access granted`}}catch(e){throw console.error(`Failed to grant context access:`,e),e}}async function _(n,r){try{return{message:(await t.delete(`${e.contexts}/${n}/shares/${encodeURIComponent(r)}`)).message||`Context access revoked`}}catch(e){throw console.error(`Failed to revoke context access:`,e),e}}async function v(n,r){try{let i=s(`${e.contexts}/${n}/tree`,r),a=await t.get(i);if(a)return a;throw Error(`Context tree data not found in API response`)}catch(e){throw console.error(`Failed to get context tree for ${n}:`,e),e}}async function y(n,r,i,a){try{let a=Array.isArray(r)?r:[r],o=new URLSearchParams,c=`${e.contexts}/${n}/documents/remove${o.toString()?`?${o.toString()}`:``}`;return{message:await t.delete(s(c,i),{body:JSON.stringify(a),headers:{"Content-Type":`application/json`}})||`Documents removed from context`}}catch(e){throw console.error(`Failed to remove documents from context ${n}:`,e),e}}async function b(n,r,i,a){try{let a=Array.isArray(r)?r:[r],o=new URLSearchParams,c=`${e.contexts}/${n}/documents${o.toString()?`?${o.toString()}`:``}`;return await t.delete(s(c,i),{body:JSON.stringify(a),headers:{"Content-Type":`application/json`}})}catch(e){throw console.error(`Failed to delete documents from context ${n}:`,e),e}}async function x(n,r,i,a){try{let o=Array.isArray(i)?i:[i];return await t.post(s(`${e.contexts}/${n}/documents`,a),{documentIds:o,context:r}),!0}catch(e){throw console.error(`Failed to paste documents to context path ${r}:`,e),e}}async function S(n,r,i=!0){return await t.post(`${e.contexts}/${n}/tree/paths`,{path:r,autoCreateLayers:i})??!0}async function C(n,r,i=!1){let a=new URLSearchParams({path:r,recursive:i.toString()});return await t.delete(`${e.contexts}/${n}/tree/paths?${a}`)??!0}async function w(n,r,i){return await t.patch(`${e.contexts}/${n}/tree/paths`,{path:r,...i})??!0}async function T(n,r,i,a=!1,o={}){return await t.post(`${e.contexts}/${n}/tree/paths/move`,{from:r,to:i,recursive:a,...o.mergeDown?{mergeDown:!0}:{}})??!0}async function E(n,r){return await t.post(`${e.contexts}/${n}/tree/paths/merge-down`,{path:r})}async function D(n,r){return await t.post(`${e.contexts}/${n}/tree/paths/subtract-down`,{path:r})}async function O(n,r,i,a=!1){return await t.post(`${e.contexts}/${n}/tree/paths/copy`,{from:r,to:i,recursive:a})??!0}async function k(n,r,i){return await t.post(`${e.contexts}/${n}/tree/layers/merge`,{layerId:r,targetLayers:i})}async function A(n,r,i){return await t.post(`${e.contexts}/${n}/tree/layers/subtract`,{layerId:r,targetLayers:i})}async function j(n,r,i){try{let a=Array.isArray(i)?i:[i];return await t.post(`${e.workspaces}/${n}/documents`,{documents:a,treeType:`context`,context:r}),!0}catch(e){throw console.error(`Failed to import documents to context path ${r}:`,e),e}}async function M(n,r,i=[]){try{let a=Array.isArray(r)?r:[r],o=await t.post(`${e.contexts}/${n}/documents`,{documents:a,features:i});return Array.isArray(o)?o:[]}catch(e){throw console.error(`Failed to insert documents into context ${n}:`,e),e}}export{D as C,i as D,f as E,a as O,A as S,w as T,x as _,c as a,y as b,g as c,M as d,h as f,T as g,E as h,b as i,j as l,k as m,l as n,m as o,o as p,p as r,v as s,O as t,S as u,u as v,d as w,_ as x,C as y};
1
+ import{c as e,t}from"./api-CA6WiiYM.js";import{Tn as n,wn as r}from"./workspace-4hWrSEku.js";var i=`contexts:deleted`;function a(e,t){return e.id===t.id?t.ownerId===void 0?e.isShared!==!0&&e.type!==`shared`:e.userId===t.ownerId:!1}async function o(){try{let n=await t.get(e.contexts);return Array.isArray(n)?n:(console.warn(`listContexts: response.payload is not an array:`,n),[])}catch(e){throw console.error(`Failed to list contexts:`,e),e}}function s(e,t){return t?`${e}${e.includes(`?`)?`&`:`?`}ownerId=${encodeURIComponent(t)}`:e}async function c(n,r){try{let i=s(`${e.contexts}/${n}`,r),a=await t.get(i);if(a&&a)return a;throw Error(`Context data not found in API response`)}catch(e){throw console.error(`Failed to get context ${n}:`,e),e}}async function l(n){try{let r=await t.post(e.contexts,n);if(r&&r&&r.context)return r.context;throw Error(`Created context data not found in API response`)}catch(e){throw console.error(`Failed to create context:`,e),e}}async function u(n,r,i){try{let a=s(`${e.contexts}/${n}`,i),o=await t.put(a,r);if(o?.context)return o.context;throw Error(`Updated context data not found in API response`)}catch(e){throw console.error(`Failed to patch context ${n}:`,e),e}}async function d(n,r,i){try{let a=s(`${e.contexts}/${n}`,i),o=await t.put(a,r);if(o?.context)return o.context;throw Error(`Updated context data not found in API response`)}catch(e){throw console.error(`Failed to update context ${n}:`,e),e}}async function f(n,r,i,a){try{let o=s(`${e.contexts}/${n}/url`,i),c=await t.post(o,{url:r,...a?{treeName:a}:{}});if(c&&c&&c.url)return{url:c.url,treeId:c.treeId};throw Error(`Updated context data not found in API response`)}catch(e){throw console.error(`Failed to update context URL for ${n}:`,e),e}}async function p(n,r){try{let a=s(`${e.contexts}/${n}`,r);await t.delete(a),window.dispatchEvent(new CustomEvent(i,{detail:{id:n,ownerId:r}}))}catch(e){throw console.error(`Failed to delete context ${n}:`,e),e}}async function m(i,a=[],o=[],s={},c){try{if(s.ids?.length===0)return Object.assign([],{count:0,totalCount:0});if(n(s.sortBy)){let e=await r(s,async e=>{let t=await m(i,a,o,{...s,...e,sortBy:void 0,order:`asc`},c);return{payload:t,count:t.count,totalCount:t.totalCount}});return Object.assign(e.payload,{count:e.count,totalCount:e.totalCount})}let l=new URLSearchParams;s.geoSelection&&(l.set(`geoSelection`,JSON.stringify(s.geoSelection)),l.set(`includeUnlocated`,String(s.includeUnlocated===!0))),s.ids?.forEach(e=>l.append(`ids`,String(e))),a.forEach(e=>l.append(`allOf`,e)),o.forEach(e=>l.append(`filters`,e)),(s.anyOf||[]).filter(Boolean).forEach(e=>l.append(`anyOf`,e)),(s.noneOf||[]).filter(Boolean).forEach(e=>l.append(`noneOf`,e)),s.sortBy&&l.append(`sortBy`,s.sortBy),s.order&&l.append(`order`,s.order),s.applyContextSpec===!1&&l.append(`applyContextSpec`,`false`),c&&l.append(`ownerId`,c),s.includeServerContext!==void 0&&l.append(`includeServerContext`,s.includeServerContext.toString()),s.includeClientContext!==void 0&&l.append(`includeClientContext`,s.includeClientContext.toString()),s.limit!==void 0&&l.append(`limit`,s.limit.toString()),s.offset!==void 0&&l.append(`offset`,s.offset.toString()),s.page!==void 0&&l.append(`page`,s.page.toString()),(s.queries&&s.queries.length?s.queries:s.q?[s.q]:[]).map(e=>e.trim()).filter(Boolean).forEach(e=>l.append(`q`,e));let u=`${e.contexts}/${i}/documents${l.toString()?`?`+l.toString():``}`,d=await t.getEnvelope(u,{signal:s.signal}),f=d.payload;if(Array.isArray(f)){let e=f;return e.count=d.count??void 0,e.totalCount=d.totalCount??void 0,e}return console.warn(`getContextDocuments: payload is not an array:`,f),[]}catch(e){throw console.error(`Failed to get context documents for ${i}:`,e),e}}async function h(n){let r=await t.get(`${e.contexts}/${n}/shares`);return Array.isArray(r)?r:[]}async function g(n,r,i){try{return{message:(await t.post(`${e.contexts}/${n}/shares`,{userEmail:r,accessLevel:i})).message||`Context access granted`}}catch(e){throw console.error(`Failed to grant context access:`,e),e}}async function _(n,r){try{return{message:(await t.delete(`${e.contexts}/${n}/shares/${encodeURIComponent(r)}`)).message||`Context access revoked`}}catch(e){throw console.error(`Failed to revoke context access:`,e),e}}async function v(n,r){try{let i=s(`${e.contexts}/${n}/tree`,r),a=await t.get(i);if(a)return a;throw Error(`Context tree data not found in API response`)}catch(e){throw console.error(`Failed to get context tree for ${n}:`,e),e}}async function y(n,r,i,a){try{let a=Array.isArray(r)?r:[r],o=new URLSearchParams,c=`${e.contexts}/${n}/documents/remove${o.toString()?`?${o.toString()}`:``}`;return{message:await t.delete(s(c,i),{body:JSON.stringify(a),headers:{"Content-Type":`application/json`}})||`Documents removed from context`}}catch(e){throw console.error(`Failed to remove documents from context ${n}:`,e),e}}async function b(n,r,i,a){try{let a=Array.isArray(r)?r:[r],o=new URLSearchParams,c=`${e.contexts}/${n}/documents${o.toString()?`?${o.toString()}`:``}`;return await t.delete(s(c,i),{body:JSON.stringify(a),headers:{"Content-Type":`application/json`}})}catch(e){throw console.error(`Failed to delete documents from context ${n}:`,e),e}}async function x(n,r,i,a){try{let o=Array.isArray(i)?i:[i];return await t.post(s(`${e.contexts}/${n}/documents`,a),{documentIds:o,context:r}),!0}catch(e){throw console.error(`Failed to paste documents to context path ${r}:`,e),e}}async function S(n,r,i=!0){return await t.post(`${e.contexts}/${n}/tree/paths`,{path:r,autoCreateLayers:i})??!0}async function C(n,r,i=!1){let a=new URLSearchParams({path:r,recursive:i.toString()});return await t.delete(`${e.contexts}/${n}/tree/paths?${a}`)??!0}async function w(n,r,i){return await t.patch(`${e.contexts}/${n}/tree/paths`,{path:r,...i})??!0}async function T(n,r,i,a=!1,o={}){return await t.post(`${e.contexts}/${n}/tree/paths/move`,{from:r,to:i,recursive:a,...o.mergeDown?{mergeDown:!0}:{}})??!0}async function E(n,r){return await t.post(`${e.contexts}/${n}/tree/paths/merge-down`,{path:r})}async function D(n,r){return await t.post(`${e.contexts}/${n}/tree/paths/subtract-down`,{path:r})}async function O(n,r,i,a=!1){return await t.post(`${e.contexts}/${n}/tree/paths/copy`,{from:r,to:i,recursive:a})??!0}async function k(n,r,i){return await t.post(`${e.contexts}/${n}/tree/layers/merge`,{layerId:r,targetLayers:i})}async function A(n,r,i){return await t.post(`${e.contexts}/${n}/tree/layers/subtract`,{layerId:r,targetLayers:i})}async function j(n,r,i){try{let a=Array.isArray(i)?i:[i];return await t.post(`${e.workspaces}/${n}/documents`,{documents:a,treeType:`context`,context:r}),!0}catch(e){throw console.error(`Failed to import documents to context path ${r}:`,e),e}}async function M(n,r,i=[]){try{let a=Array.isArray(r)?r:[r],o=await t.post(`${e.contexts}/${n}/documents`,{documents:a,features:i});return Array.isArray(o)?o:[]}catch(e){throw console.error(`Failed to insert documents into context ${n}:`,e),e}}export{D as C,i as D,f as E,a as O,A as S,w as T,x as _,c as a,y as b,g as c,M as d,h as f,T as g,E as h,b as i,j as l,k as m,l as n,m as o,o as p,p as r,v as s,O as t,S as u,u as v,d as w,_ as x,C as y};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{i as r}from"./auth-Bx9fAZmz.js";import{n as i}from"./page-header-DrDt1sQ2.js";var a=e(n(),1),o=t();function s(){let e=r()?.userType===`admin`;return(0,a.useEffect)(()=>{},[e]),e?(0,o.jsxs)(`div`,{className:`space-y-6`,children:[(0,o.jsx)(i,{title:`All Contexts`,description:`Manage all contexts across all users`}),(0,o.jsx)(`div`,{className:`flex flex-col items-center justify-center py-12 space-y-4`,children:(0,o.jsxs)(`div`,{className:`text-center`,children:[(0,o.jsx)(`h2`,{className:`text-2xl font-semibold mb-2`,children:`Coming Soon`}),(0,o.jsx)(`p`,{className:`text-muted-foreground max-w-md`,children:`Global context management is currently under development. Check back later for updates.`})]})})]}):(0,o.jsx)(`div`,{className:`text-center space-y-4`,children:(0,o.jsx)(`div`,{className:`text-destructive`,children:`Access denied. Admin privileges required.`})})}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{i as r}from"./auth-Bx9fAZmz.js";import{n as i}from"./page-header-NyYSXjfY.js";var a=e(n(),1),o=t();function s(){let e=r()?.userType===`admin`;return(0,a.useEffect)(()=>{},[e]),e?(0,o.jsxs)(`div`,{className:`space-y-6`,children:[(0,o.jsx)(i,{title:`All Contexts`,description:`Manage all contexts across all users`}),(0,o.jsx)(`div`,{className:`flex flex-col items-center justify-center py-12 space-y-4`,children:(0,o.jsxs)(`div`,{className:`text-center`,children:[(0,o.jsx)(`h2`,{className:`text-2xl font-semibold mb-2`,children:`Coming Soon`}),(0,o.jsx)(`p`,{className:`text-muted-foreground max-w-md`,children:`Global context management is currently under development. Check back later for updates.`})]})})]}):(0,o.jsx)(`div`,{className:`text-center space-y-4`,children:(0,o.jsx)(`div`,{className:`text-destructive`,children:`Access denied. Admin privileges required.`})})}export{s as default};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{g as r}from"./chunk-62JRHF6Z-vspAGgtK.js";import{Pt as i,Y as a,at as o,mt as s,yr as c}from"./ui-CDoK3F3U.js";import{t as l}from"./button-SeUZ_Pvi.js";import{t as u}from"./input-BOtCd4HP.js";import{t as d}from"./socket-CtH3EU9m.js";import{n as ee}from"./use-toast-BlLDqSUO.js";import{jt as te}from"./workspace-C5V-ZCOE.js";import{a as ne,c as re,i as f,n as ie,o as ae,r as oe,s as se,t as ce}from"./alert-dialog-CFeuDt0T.js";import{O as le,n as ue,p as de,r as p}from"./context-t3rdtGUB.js";import{t as m}from"./PathPickerField-CW2yG2Yg.js";import{a as h,c as g,i as fe,n as _,o as pe,r as me,s as he,t as ge}from"./use-sortable-data-BBKmqs79.js";import{n as _e}from"./page-header-DrDt1sQ2.js";import{t as ve}from"./form-panel-3p-ncEVK.js";import{t as ye}from"./use-create-panel-DhSNIGtr.js";var v=e(n(),1);function y(e,t=`An error occurred`){if(e instanceof Error)return e.message;if(typeof e==`object`&&e){let n=e;return n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||t}return t}function be(e,t,n=`An error occurred`){return console.error(t,e),y(e,n)}var b=t();function x(){let e=r(),[t,n]=(0,v.useState)([]),[y,x]=(0,v.useState)([]),[S,C]=(0,v.useState)(!0),[w,T]=(0,v.useState)(null),[E,D]=(0,v.useState)(``),[O,k]=(0,v.useState)(``),[A,j]=(0,v.useState)(`context`),[M,N]=(0,v.useState)(`/`),[P,F]=(0,v.useState)(``),[I,L]=(0,v.useState)(null),[R,z]=(0,v.useState)(`/`),[B,V]=(0,v.useState)(``),[H,U]=(0,v.useState)(!1),[W,G]=ye(),[K,q]=(0,v.useState)(null),[J,Y]=(0,v.useState)(null),{showToast:X}=ee();(0,v.useEffect)(()=>{d.isConnected()||(console.log(`Socket not connected, attempting to connect...`),d.reconnect())},[]);let Z=(0,v.useCallback)(async()=>{try{C(!0);let[e,t]=await Promise.all([de(),te()]),r=e?.filter(e=>e&&typeof e==`object`&&e.id&&e.userId)||[];n(r);let i=t||[];if(x(i),i.length>0){let e=i.some(e=>e.id===B);(!B||!e)&&V(i[0].id)}else V(``);T(null)}catch(e){console.error(`Data fetch error:`,e),n([]),x([]);let t=`Failed to fetch data`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;t=n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||`Failed to fetch data`}T(t),X({title:`Error`,description:t,variant:`destructive`})}finally{C(!1)}},[B,X]);(0,v.useEffect)(()=>{Z()},[Z]),(0,v.useEffect)(()=>{let e=()=>d.emit(`subscribe`,{channel:`context`}),t=()=>d.emit(`unsubscribe`,{channel:`context`}),r=d.on(`connect`,e);console.log(`Subscribing to context events`),e();let i=e=>{let t=e;if(console.log(`Received context created:`,t),!t||!t.id||!t.userId){console.error(`Invalid context data received in context:created event:`,t);return}n(e=>e.some(e=>e&&e.id===t.id&&e.userId===t.userId)?(console.log(`Context ${t.id} already exists, skipping duplicate add`),e):[...e,t])},a=e=>{let t=e;if(console.log(`Received context update:`,t),!t||!t.id||!t.userId){console.error(`Invalid context data received in context:updated event:`,t);return}n(e=>e.map(e=>e&&e.id===t.id&&e.userId===t.userId?{...e,...t}:e))},o=e=>{let t=e;console.log(`Received context deletion:`,t);let r=t?.contextId??t?.id;if(!r){console.error(`Invalid context deletion data received:`,t);return}n(e=>e.filter(e=>e&&e.id!==r))},s=e=>{let t=e;if(console.log(`Received context URL change:`,t),!t||!t.id||!t.userId){console.error(`Invalid context data received in context:url:changed event:`,t);return}n(e=>e.map(e=>e&&e.id===t.id&&e.userId===t.userId?{...e,...t}:e))},c=[[`context:created`,i],[`context.created`,i],[`context:updated`,a],[`context.updated`,a],[`context:deleted`,o],[`context.deleted`,o],[`context:url:changed`,s],[`context.url.set`,s],[`context:url:set`,s]];return c.forEach(([e,t])=>d.on(e,t)),()=>{console.log(`Unsubscribing from context events`),t(),r?.(),c.forEach(([e,t])=>d.off(e,t))}},[]);let xe=async t=>{if(t.preventDefault(),!M.trim()||!B||!E.trim()){X({title:`Missing Fields`,description:`Context ID, Context URL and Workspace are required.`,variant:`destructive`});return}U(!0);try{let t={id:E,name:O.trim()||void 0,url:M,description:P.trim()||void 0,metadata:{ui:{color:I}},workspaceId:B,baseUrl:R||void 0,treeType:A},n=await ue(t);D(``),k(``),N(`/`),F(``),L(null),z(`/`),await Z(),X({title:`Success`,description:`Context created successfully`}),G(!1),window.dispatchEvent(new CustomEvent(`contexts:refresh`)),e(`/contexts/${n.id}`)}catch(e){let t=be(e,`Context creation error:`,`Failed to create context`);X({title:`Error`,description:t,variant:`destructive`})}finally{U(!1)}},Se=async e=>{let n=t.find(t=>t.id===e);if(n&&n.url&&(n.url.endsWith(`/default`)||n.url.includes(`://default`))){X({title:`Error`,description:`Cannot delete the default context`,variant:`destructive`});return}Y(e)},Ce=async()=>{if(J)try{await p(J),n(e=>e.filter(e=>!le(e,{id:J}))),X({title:`Success`,description:`Context deleted successfully`})}catch(e){console.error(`Context deletion error:`,e);let t=`Failed to delete context`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;t=n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||`Failed to delete context`}X({title:`Error`,description:t,variant:`destructive`})}finally{Y(null)}},we=t=>{let n=t.isShared||t.type===`shared`;e(n?`/contexts/${t.id}?ownerId=${encodeURIComponent(t.userId)}`:`/contexts/${t.id}`)},Te=e=>{q(e)},Ee=async e=>{if(e.preventDefault(),K)try{n(e=>e.map(e=>e.id===K.id&&e.userId===K.userId?K:e)),X({title:`Success`,description:`Context updated successfully (mock update)`}),q(null)}catch(e){let t=e instanceof Error?e.message:`Failed to update context`;X({title:`Error`,description:t,variant:`destructive`})}},De=(0,v.useMemo)(()=>({type:e=>e.isShared||e.type===`shared`?`shared`:`owned`,id:e=>e.id??``,owner:e=>e.isShared||e.type===`shared`?e.ownerEmail||e.userId||``:`you`,url:e=>e.url??``,workspaceId:e=>e.workspaceId??``,baseUrl:e=>e.baseUrl??``,path:e=>e.path??``,locked:e=>+!!e.locked,created:e=>Date.parse(e.createdAt)||0,updated:e=>Date.parse(e.updatedAt)||0}),[]),{sorted:Oe,sort:Q,toggleSort:$}=ge(t.filter(e=>e!=null),De);return(0,b.jsxs)(`div`,{className:`space-y-6`,children:[(0,b.jsx)(_e,{title:`Contexts`,description:`Create and manage contexts in your workspaces. View contexts shared with you.`,actions:!W&&(0,b.jsxs)(l,{onClick:()=>G(!0),className:`max-sm:h-9 max-sm:w-9 max-sm:p-0`,"aria-label":`Create context`,title:`Create context`,children:[(0,b.jsx)(i,{className:`h-4 w-4 sm:mr-2`}),(0,b.jsx)(`span`,{className:`max-sm:hidden`,children:`Create Context`})]})}),W&&(0,b.jsx)(ve,{title:`Create New Context`,onClose:()=>G(!1),children:(0,b.jsxs)(`form`,{onSubmit:xe,className:`space-y-4`,children:[(0,b.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`workspace`,className:`block text-sm font-medium mb-1`,children:`Workspace`}),(0,b.jsxs)(`select`,{id:`workspace`,className:`w-full px-3 py-2 border border-border rounded-md shadow-elevation-1 focus:outline-none focus:ring-primary focus:border-primary`,value:B,onChange:e=>V(e.target.value),disabled:H||y.length===0,children:[y.length===0&&(0,b.jsx)(`option`,{value:``,children:`No workspaces available. Create one first.`}),y.map(e=>(0,b.jsx)(`option`,{value:e.id,children:e.label||e.name},`${e.owner}-${e.id}`))]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`newContextId`,className:`block text-sm font-medium mb-1`,children:`Context ID`}),(0,b.jsx)(u,{id:`newContextId`,value:E,onChange:e=>D(e.target.value),placeholder:`e.g., my-new-context`,disabled:H})]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`url`,className:`block text-sm font-medium mb-1`,children:`Context URL`}),(0,b.jsx)(m,{id:`url`,value:M,onChange:N,placeholder:`e.g., /project/path/resource`,disabled:H,pickerTitle:`Context URL path…`,onPickTarget:(e,t)=>{N(e),j(t.treeType);let n=y.find(e=>e.name===t.workspaceName||e.id===t.workspaceName);n&&V(n.id)}})]}),(0,b.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`baseUrl`,className:`block text-sm font-medium mb-1`,children:`Base URL (Optional)`}),(0,b.jsx)(m,{id:`baseUrl`,value:R,onChange:z,format:`path`,placeholder:`e.g., /base/path`,disabled:H,pickerTitle:`Base path…`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`description`,className:`block text-sm font-medium mb-1`,children:`Description (Optional)`}),(0,b.jsx)(u,{id:`description`,value:P,onChange:e=>F(e.target.value),placeholder:`Description`,disabled:H})]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`contextColor`,className:`block text-sm font-medium mb-1`,children:`Color (Optional)`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(u,{id:`contextColor`,type:`color`,value:I||`#808080`,onChange:e=>L(e.target.value),className:`h-10 w-16 p-1`,disabled:H}),(0,b.jsx)(l,{type:`button`,variant:`outline`,size:`sm`,disabled:H||I===null,onClick:()=>L(null),children:`Use inherited color`})]}),(0,b.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:I===null?`Uses the tree folder or workspace color.`:`Applies only to this context.`})]}),(0,b.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`contextName`,className:`block text-sm font-medium mb-1`,children:`Name (Optional)`}),(0,b.jsx)(u,{id:`contextName`,value:O,onChange:e=>k(e.target.value),placeholder:`My Context`,disabled:H})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`treeType`,className:`block text-sm font-medium mb-1`,children:`Tree`}),(0,b.jsxs)(`select`,{id:`treeType`,className:`w-full px-3 py-2 border border-border rounded-md shadow-elevation-1 focus:outline-none focus:ring-primary focus:border-primary`,value:A,onChange:e=>j(e.target.value),disabled:H,children:[(0,b.jsx)(`option`,{value:`context`,children:`Context tree`}),(0,b.jsx)(`option`,{value:`directory`,children:`Directory tree`})]}),(0,b.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Which workspace tree this context navigates.`})]})]}),(0,b.jsxs)(l,{type:`submit`,disabled:H||!M.trim()||!B||!E.trim(),children:[(0,b.jsx)(i,{className:`mr-2 h-4 w-4`}),`Create Context`]})]})}),(0,b.jsxs)(`div`,{className:`space-y-4`,children:[(0,b.jsx)(`h2`,{className:`text-xl font-semibold`,children:`Your Contexts & Shared Contexts`}),S&&(0,b.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`Loading contexts...`}),w&&(0,b.jsx)(`div`,{className:`text-center text-destructive`,children:(0,b.jsx)(`p`,{children:w})}),!S&&!w&&t.length===0&&(0,b.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`No contexts found. Create one above.`}),t.length>0&&(0,b.jsx)(`div`,{className:`border rounded-lg overflow-hidden`,children:(0,b.jsxs)(me,{children:[(0,b.jsx)(he,{children:(0,b.jsxs)(g,{children:[(0,b.jsx)(_,{label:`Type`,sortKey:`type`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`ID`,sortKey:`id`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`Owner`,sortKey:`owner`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`Context URL`,sortKey:`url`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`Workspace ID`,sortKey:`workspaceId`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`Base URL`,sortKey:`baseUrl`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`Path`,sortKey:`path`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`Locked`,sortKey:`locked`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`Created`,sortKey:`created`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`Updated`,sortKey:`updated`,sort:Q,onSort:$}),(0,b.jsx)(pe,{className:`text-right`,children:`Actions`})]})}),(0,b.jsx)(fe,{children:Oe.map(e=>{if(!e)return console.warn(`Found null/undefined context in contexts array, skipping`),null;let t=e.createdAt?new Date(e.createdAt).toLocaleDateString():`-`,n=e.updatedAt?new Date(e.updatedAt).toLocaleDateString():`-`,r=e.isShared||e.type===`shared`,i=r?e.ownerEmail||e.userId||`-`:`You`,u=r&&e.sharedVia?typeof e.sharedVia==`string`?e.sharedVia:e.sharedVia.accessLevel||`-`:`-`;return(0,b.jsxs)(g,{children:[(0,b.jsx)(h,{children:r?(0,b.jsxs)(`div`,{className:`flex items-center gap-1 text-info`,title:`Shared with you (${u})`,children:[(0,b.jsx)(s,{className:`h-4 w-4`}),(0,b.jsx)(`span`,{className:`text-xs`,children:`Shared`})]}):(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Owned`})}),(0,b.jsx)(h,{className:`font-mono text-sm`,children:e.id||`-`}),(0,b.jsx)(h,{className:`font-mono text-sm`,title:r?`Owned by: ${i}`:`You are the owner`,children:i}),(0,b.jsx)(h,{className:`font-mono text-sm max-w-xs truncate`,title:e.url||`-`,children:e.url||`-`}),(0,b.jsx)(h,{className:`font-mono text-sm`,children:e.workspaceId||`-`}),(0,b.jsx)(h,{className:`font-mono text-sm`,children:e.baseUrl||`-`}),(0,b.jsx)(h,{className:`font-mono text-sm`,children:e.path||`-`}),(0,b.jsx)(h,{children:e.locked?`Yes`:`No`}),(0,b.jsx)(h,{children:t}),(0,b.jsx)(h,{children:n}),(0,b.jsx)(h,{className:`text-right`,children:(0,b.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[!r&&(0,b.jsx)(l,{variant:`outline`,size:`sm`,onClick:()=>Te(e),title:`Edit Context`,children:(0,b.jsx)(o,{className:`h-4 w-4`})}),(0,b.jsx)(l,{variant:`outline`,size:`sm`,onClick:()=>we(e),title:r?`Open Shared Context`:`Open Context Details`,children:(0,b.jsx)(c,{className:`h-4 w-4`})}),!r&&(0,b.jsx)(l,{variant:`outline`,size:`sm`,onClick:()=>Se(e.id),disabled:!!(e.url&&(e.url.endsWith(`/default`)||e.url.includes(`://default`))),className:`text-destructive hover:bg-destructive/10 hover:text-destructive disabled:opacity-50 disabled:cursor-not-allowed`,title:e.url&&(e.url.endsWith(`/default`)||e.url.includes(`://default`))?`Cannot delete default context`:`Delete Context`,children:(0,b.jsx)(a,{className:`h-4 w-4`})})]})})]},`${e.userId}-${e.id}`)})})]})})]}),K&&(0,b.jsxs)(`div`,{className:`space-y-4`,children:[(0,b.jsx)(`h2`,{className:`text-xl font-semibold`,children:`Edit Context`}),(0,b.jsxs)(`form`,{onSubmit:Ee,className:`space-y-4`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`edit-context-id`,className:`block text-sm font-medium mb-1`,children:`Context ID (read-only)`}),(0,b.jsx)(u,{id:`edit-context-id`,value:K.id,disabled:!0,className:`bg-muted`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`edit-context-url`,className:`block text-sm font-medium mb-1`,children:`Context URL`}),(0,b.jsx)(m,{id:`edit-context-url`,value:K.url,onChange:e=>q(t=>t?{...t,url:e}:null),placeholder:`workspace://path or /path`,pickerTitle:`Context URL path…`}),(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Use format: workspace://path or /path for current workspace`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`edit-base-url`,className:`block text-sm font-medium mb-1`,children:`Base URL (optional)`}),(0,b.jsx)(m,{id:`edit-base-url`,value:K.baseUrl||``,onChange:e=>q(t=>t?{...t,baseUrl:e||null}:null),format:`path`,placeholder:`/base/path`,pickerTitle:`Base path…`}),(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Restricts context navigation to this base path`})]}),(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[(0,b.jsx)(l,{type:`submit`,children:`Save Changes`}),(0,b.jsx)(l,{type:`button`,variant:`outline`,onClick:()=>q(null),children:`Cancel`})]})]})]}),(0,b.jsx)(ce,{open:J!==null,onOpenChange:e=>!e&&Y(null),children:(0,b.jsxs)(f,{children:[(0,b.jsxs)(se,{children:[(0,b.jsx)(re,{children:`Delete Context`}),(0,b.jsx)(ne,{children:`Are you sure you want to delete this context? This action cannot be undone.`})]}),(0,b.jsxs)(ae,{children:[(0,b.jsx)(oe,{children:`Cancel`}),(0,b.jsx)(ie,{onClick:Ce,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`Delete`})]})]})})]})}export{x as default};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{g as r}from"./chunk-62JRHF6Z-vspAGgtK.js";import{Pt as i,Y as a,at as o,br as s,mt as c}from"./ui-DEgHnkQu.js";import{t as l}from"./button--VYZekMF.js";import{t as u}from"./input-BOtCd4HP.js";import{t as d}from"./socket-CtH3EU9m.js";import{n as ee}from"./use-toast-BlLDqSUO.js";import{jt as te}from"./workspace-4hWrSEku.js";import{a as ne,c as re,i as f,n as ie,o as ae,r as oe,s as se,t as ce}from"./alert-dialog-BKtaX1_a.js";import{O as le,n as ue,p as de,r as p}from"./context-DY40EDc6.js";import{t as m}from"./PathPickerField-CSIa7jSl.js";import{a as h,c as g,i as fe,n as _,o as pe,r as me,s as he,t as ge}from"./use-sortable-data-D7zS2qCC.js";import{n as _e}from"./page-header-NyYSXjfY.js";import{t as ve}from"./form-panel-CEbNKttr.js";import{t as ye}from"./use-create-panel-DhSNIGtr.js";var v=e(n(),1);function y(e,t=`An error occurred`){if(e instanceof Error)return e.message;if(typeof e==`object`&&e){let n=e;return n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||t}return t}function be(e,t,n=`An error occurred`){return console.error(t,e),y(e,n)}var b=t();function x(){let e=r(),[t,n]=(0,v.useState)([]),[y,x]=(0,v.useState)([]),[S,C]=(0,v.useState)(!0),[w,T]=(0,v.useState)(null),[E,D]=(0,v.useState)(``),[O,k]=(0,v.useState)(``),[A,j]=(0,v.useState)(`context`),[M,N]=(0,v.useState)(`/`),[P,F]=(0,v.useState)(``),[I,L]=(0,v.useState)(null),[R,z]=(0,v.useState)(`/`),[B,V]=(0,v.useState)(``),[H,U]=(0,v.useState)(!1),[W,G]=ye(),[K,q]=(0,v.useState)(null),[J,Y]=(0,v.useState)(null),{showToast:X}=ee();(0,v.useEffect)(()=>{d.isConnected()||(console.log(`Socket not connected, attempting to connect...`),d.reconnect())},[]);let Z=(0,v.useCallback)(async()=>{try{C(!0);let[e,t]=await Promise.all([de(),te()]),r=e?.filter(e=>e&&typeof e==`object`&&e.id&&e.userId)||[];n(r);let i=t||[];if(x(i),i.length>0){let e=i.some(e=>e.id===B);(!B||!e)&&V(i[0].id)}else V(``);T(null)}catch(e){console.error(`Data fetch error:`,e),n([]),x([]);let t=`Failed to fetch data`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;t=n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||`Failed to fetch data`}T(t),X({title:`Error`,description:t,variant:`destructive`})}finally{C(!1)}},[B,X]);(0,v.useEffect)(()=>{Z()},[Z]),(0,v.useEffect)(()=>{let e=()=>d.emit(`subscribe`,{channel:`context`}),t=()=>d.emit(`unsubscribe`,{channel:`context`}),r=d.on(`connect`,e);console.log(`Subscribing to context events`),e();let i=e=>{let t=e;if(console.log(`Received context created:`,t),!t||!t.id||!t.userId){console.error(`Invalid context data received in context:created event:`,t);return}n(e=>e.some(e=>e&&e.id===t.id&&e.userId===t.userId)?(console.log(`Context ${t.id} already exists, skipping duplicate add`),e):[...e,t])},a=e=>{let t=e;if(console.log(`Received context update:`,t),!t||!t.id||!t.userId){console.error(`Invalid context data received in context:updated event:`,t);return}n(e=>e.map(e=>e&&e.id===t.id&&e.userId===t.userId?{...e,...t}:e))},o=e=>{let t=e;console.log(`Received context deletion:`,t);let r=t?.contextId??t?.id;if(!r){console.error(`Invalid context deletion data received:`,t);return}n(e=>e.filter(e=>e&&e.id!==r))},s=e=>{let t=e;if(console.log(`Received context URL change:`,t),!t||!t.id||!t.userId){console.error(`Invalid context data received in context:url:changed event:`,t);return}n(e=>e.map(e=>e&&e.id===t.id&&e.userId===t.userId?{...e,...t}:e))},c=[[`context:created`,i],[`context.created`,i],[`context:updated`,a],[`context.updated`,a],[`context:deleted`,o],[`context.deleted`,o],[`context:url:changed`,s],[`context.url.set`,s],[`context:url:set`,s]];return c.forEach(([e,t])=>d.on(e,t)),()=>{console.log(`Unsubscribing from context events`),t(),r?.(),c.forEach(([e,t])=>d.off(e,t))}},[]);let xe=async t=>{if(t.preventDefault(),!M.trim()||!B||!E.trim()){X({title:`Missing Fields`,description:`Context ID, Context URL and Workspace are required.`,variant:`destructive`});return}U(!0);try{let t={id:E,name:O.trim()||void 0,url:M,description:P.trim()||void 0,metadata:{ui:{color:I}},workspaceId:B,baseUrl:R||void 0,treeType:A},n=await ue(t);D(``),k(``),N(`/`),F(``),L(null),z(`/`),await Z(),X({title:`Success`,description:`Context created successfully`}),G(!1),window.dispatchEvent(new CustomEvent(`contexts:refresh`)),e(`/contexts/${n.id}`)}catch(e){let t=be(e,`Context creation error:`,`Failed to create context`);X({title:`Error`,description:t,variant:`destructive`})}finally{U(!1)}},Se=async e=>{let n=t.find(t=>t.id===e);if(n&&n.url&&(n.url.endsWith(`/default`)||n.url.includes(`://default`))){X({title:`Error`,description:`Cannot delete the default context`,variant:`destructive`});return}Y(e)},Ce=async()=>{if(J)try{await p(J),n(e=>e.filter(e=>!le(e,{id:J}))),X({title:`Success`,description:`Context deleted successfully`})}catch(e){console.error(`Context deletion error:`,e);let t=`Failed to delete context`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;t=n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||`Failed to delete context`}X({title:`Error`,description:t,variant:`destructive`})}finally{Y(null)}},we=t=>{let n=t.isShared||t.type===`shared`;e(n?`/contexts/${t.id}?ownerId=${encodeURIComponent(t.userId)}`:`/contexts/${t.id}`)},Te=e=>{q(e)},Ee=async e=>{if(e.preventDefault(),K)try{n(e=>e.map(e=>e.id===K.id&&e.userId===K.userId?K:e)),X({title:`Success`,description:`Context updated successfully (mock update)`}),q(null)}catch(e){let t=e instanceof Error?e.message:`Failed to update context`;X({title:`Error`,description:t,variant:`destructive`})}},De=(0,v.useMemo)(()=>({type:e=>e.isShared||e.type===`shared`?`shared`:`owned`,id:e=>e.id??``,owner:e=>e.isShared||e.type===`shared`?e.ownerEmail||e.userId||``:`you`,url:e=>e.url??``,workspaceId:e=>e.workspaceId??``,baseUrl:e=>e.baseUrl??``,path:e=>e.path??``,locked:e=>+!!e.locked,created:e=>Date.parse(e.createdAt)||0,updated:e=>Date.parse(e.updatedAt)||0}),[]),{sorted:Oe,sort:Q,toggleSort:$}=ge(t.filter(e=>e!=null),De);return(0,b.jsxs)(`div`,{className:`space-y-6`,children:[(0,b.jsx)(_e,{title:`Contexts`,description:`Create and manage contexts in your workspaces. View contexts shared with you.`,actions:!W&&(0,b.jsxs)(l,{onClick:()=>G(!0),className:`max-sm:h-9 max-sm:w-9 max-sm:p-0`,"aria-label":`Create context`,title:`Create context`,children:[(0,b.jsx)(i,{className:`h-4 w-4 sm:mr-2`}),(0,b.jsx)(`span`,{className:`max-sm:hidden`,children:`Create Context`})]})}),W&&(0,b.jsx)(ve,{title:`Create New Context`,onClose:()=>G(!1),children:(0,b.jsxs)(`form`,{onSubmit:xe,className:`space-y-4`,children:[(0,b.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`workspace`,className:`block text-sm font-medium mb-1`,children:`Workspace`}),(0,b.jsxs)(`select`,{id:`workspace`,className:`w-full px-3 py-2 border border-border rounded-md shadow-elevation-1 focus:outline-none focus:ring-primary focus:border-primary`,value:B,onChange:e=>V(e.target.value),disabled:H||y.length===0,children:[y.length===0&&(0,b.jsx)(`option`,{value:``,children:`No workspaces available. Create one first.`}),y.map(e=>(0,b.jsx)(`option`,{value:e.id,children:e.label||e.name},`${e.owner}-${e.id}`))]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`newContextId`,className:`block text-sm font-medium mb-1`,children:`Context ID`}),(0,b.jsx)(u,{id:`newContextId`,value:E,onChange:e=>D(e.target.value),placeholder:`e.g., my-new-context`,disabled:H})]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`url`,className:`block text-sm font-medium mb-1`,children:`Context URL`}),(0,b.jsx)(m,{id:`url`,value:M,onChange:N,placeholder:`e.g., /project/path/resource`,disabled:H,pickerTitle:`Context URL path…`,onPickTarget:(e,t)=>{N(e),j(t.treeType);let n=y.find(e=>e.name===t.workspaceName||e.id===t.workspaceName);n&&V(n.id)}})]}),(0,b.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`baseUrl`,className:`block text-sm font-medium mb-1`,children:`Base URL (Optional)`}),(0,b.jsx)(m,{id:`baseUrl`,value:R,onChange:z,format:`path`,placeholder:`e.g., /base/path`,disabled:H,pickerTitle:`Base path…`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`description`,className:`block text-sm font-medium mb-1`,children:`Description (Optional)`}),(0,b.jsx)(u,{id:`description`,value:P,onChange:e=>F(e.target.value),placeholder:`Description`,disabled:H})]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`contextColor`,className:`block text-sm font-medium mb-1`,children:`Color (Optional)`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(u,{id:`contextColor`,type:`color`,value:I||`#808080`,onChange:e=>L(e.target.value),className:`h-10 w-16 p-1`,disabled:H}),(0,b.jsx)(l,{type:`button`,variant:`outline`,size:`sm`,disabled:H||I===null,onClick:()=>L(null),children:`Use inherited color`})]}),(0,b.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:I===null?`Uses the tree folder or workspace color.`:`Applies only to this context.`})]}),(0,b.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`contextName`,className:`block text-sm font-medium mb-1`,children:`Name (Optional)`}),(0,b.jsx)(u,{id:`contextName`,value:O,onChange:e=>k(e.target.value),placeholder:`My Context`,disabled:H})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`treeType`,className:`block text-sm font-medium mb-1`,children:`Tree`}),(0,b.jsxs)(`select`,{id:`treeType`,className:`w-full px-3 py-2 border border-border rounded-md shadow-elevation-1 focus:outline-none focus:ring-primary focus:border-primary`,value:A,onChange:e=>j(e.target.value),disabled:H,children:[(0,b.jsx)(`option`,{value:`context`,children:`Context tree`}),(0,b.jsx)(`option`,{value:`directory`,children:`Directory tree`})]}),(0,b.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Which workspace tree this context navigates.`})]})]}),(0,b.jsxs)(l,{type:`submit`,disabled:H||!M.trim()||!B||!E.trim(),children:[(0,b.jsx)(i,{className:`mr-2 h-4 w-4`}),`Create Context`]})]})}),(0,b.jsxs)(`div`,{className:`space-y-4`,children:[(0,b.jsx)(`h2`,{className:`text-xl font-semibold`,children:`Your Contexts & Shared Contexts`}),S&&(0,b.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`Loading contexts...`}),w&&(0,b.jsx)(`div`,{className:`text-center text-destructive`,children:(0,b.jsx)(`p`,{children:w})}),!S&&!w&&t.length===0&&(0,b.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`No contexts found. Create one above.`}),t.length>0&&(0,b.jsx)(`div`,{className:`border rounded-lg overflow-hidden`,children:(0,b.jsxs)(me,{children:[(0,b.jsx)(he,{children:(0,b.jsxs)(g,{children:[(0,b.jsx)(_,{label:`Type`,sortKey:`type`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`ID`,sortKey:`id`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`Owner`,sortKey:`owner`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`Context URL`,sortKey:`url`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`Workspace ID`,sortKey:`workspaceId`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`Base URL`,sortKey:`baseUrl`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`Path`,sortKey:`path`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`Locked`,sortKey:`locked`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`Created`,sortKey:`created`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`Updated`,sortKey:`updated`,sort:Q,onSort:$}),(0,b.jsx)(pe,{className:`text-right`,children:`Actions`})]})}),(0,b.jsx)(fe,{children:Oe.map(e=>{if(!e)return console.warn(`Found null/undefined context in contexts array, skipping`),null;let t=e.createdAt?new Date(e.createdAt).toLocaleDateString():`-`,n=e.updatedAt?new Date(e.updatedAt).toLocaleDateString():`-`,r=e.isShared||e.type===`shared`,i=r?e.ownerEmail||e.userId||`-`:`You`,u=r&&e.sharedVia?typeof e.sharedVia==`string`?e.sharedVia:e.sharedVia.accessLevel||`-`:`-`;return(0,b.jsxs)(g,{children:[(0,b.jsx)(h,{children:r?(0,b.jsxs)(`div`,{className:`flex items-center gap-1 text-info`,title:`Shared with you (${u})`,children:[(0,b.jsx)(c,{className:`h-4 w-4`}),(0,b.jsx)(`span`,{className:`text-xs`,children:`Shared`})]}):(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Owned`})}),(0,b.jsx)(h,{className:`font-mono text-sm`,children:e.id||`-`}),(0,b.jsx)(h,{className:`font-mono text-sm`,title:r?`Owned by: ${i}`:`You are the owner`,children:i}),(0,b.jsx)(h,{className:`font-mono text-sm max-w-xs truncate`,title:e.url||`-`,children:e.url||`-`}),(0,b.jsx)(h,{className:`font-mono text-sm`,children:e.workspaceId||`-`}),(0,b.jsx)(h,{className:`font-mono text-sm`,children:e.baseUrl||`-`}),(0,b.jsx)(h,{className:`font-mono text-sm`,children:e.path||`-`}),(0,b.jsx)(h,{children:e.locked?`Yes`:`No`}),(0,b.jsx)(h,{children:t}),(0,b.jsx)(h,{children:n}),(0,b.jsx)(h,{className:`text-right`,children:(0,b.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[!r&&(0,b.jsx)(l,{variant:`outline`,size:`sm`,onClick:()=>Te(e),title:`Edit Context`,children:(0,b.jsx)(o,{className:`h-4 w-4`})}),(0,b.jsx)(l,{variant:`outline`,size:`sm`,onClick:()=>we(e),title:r?`Open Shared Context`:`Open Context Details`,children:(0,b.jsx)(s,{className:`h-4 w-4`})}),!r&&(0,b.jsx)(l,{variant:`outline`,size:`sm`,onClick:()=>Se(e.id),disabled:!!(e.url&&(e.url.endsWith(`/default`)||e.url.includes(`://default`))),className:`text-destructive hover:bg-destructive/10 hover:text-destructive disabled:opacity-50 disabled:cursor-not-allowed`,title:e.url&&(e.url.endsWith(`/default`)||e.url.includes(`://default`))?`Cannot delete default context`:`Delete Context`,children:(0,b.jsx)(a,{className:`h-4 w-4`})})]})})]},`${e.userId}-${e.id}`)})})]})})]}),K&&(0,b.jsxs)(`div`,{className:`space-y-4`,children:[(0,b.jsx)(`h2`,{className:`text-xl font-semibold`,children:`Edit Context`}),(0,b.jsxs)(`form`,{onSubmit:Ee,className:`space-y-4`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`edit-context-id`,className:`block text-sm font-medium mb-1`,children:`Context ID (read-only)`}),(0,b.jsx)(u,{id:`edit-context-id`,value:K.id,disabled:!0,className:`bg-muted`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`edit-context-url`,className:`block text-sm font-medium mb-1`,children:`Context URL`}),(0,b.jsx)(m,{id:`edit-context-url`,value:K.url,onChange:e=>q(t=>t?{...t,url:e}:null),placeholder:`workspace://path or /path`,pickerTitle:`Context URL path…`}),(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Use format: workspace://path or /path for current workspace`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`edit-base-url`,className:`block text-sm font-medium mb-1`,children:`Base URL (optional)`}),(0,b.jsx)(m,{id:`edit-base-url`,value:K.baseUrl||``,onChange:e=>q(t=>t?{...t,baseUrl:e||null}:null),format:`path`,placeholder:`/base/path`,pickerTitle:`Base path…`}),(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Restricts context navigation to this base path`})]}),(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[(0,b.jsx)(l,{type:`submit`,children:`Save Changes`}),(0,b.jsx)(l,{type:`button`,variant:`outline`,onClick:()=>q(null),children:`Cancel`})]})]})]}),(0,b.jsx)(ce,{open:J!==null,onOpenChange:e=>!e&&Y(null),children:(0,b.jsxs)(f,{children:[(0,b.jsxs)(se,{children:[(0,b.jsx)(re,{children:`Delete Context`}),(0,b.jsx)(ne,{children:`Are you sure you want to delete this context? This action cannot be undone.`})]}),(0,b.jsxs)(ae,{children:[(0,b.jsx)(oe,{children:`Cancel`}),(0,b.jsx)(ie,{onClick:Ce,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`Delete`})]})]})})]})}export{x as default};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{yt as r}from"./react-BHzhHVTZ.js";import{Hr as i,Jr as a,L as o,Vr as s,Yr as c}from"./ui-CDoK3F3U.js";import{t as l}from"./utils-2pl1SbIp.js";import{zn as u}from"./workspace-C5V-ZCOE.js";import{n as d}from"./tags-YamdPoBK.js";import{o as f}from"./useAddTarget-DeRZWtGg.js";import{r as p}from"./relation-events-CKio19hE.js";var m=e(n(),1),h=`2.1`,g=[`pending`,`in-progress`,`completed`,`cancelled`],_={pending:`Pending`,"in-progress":`In progress`,completed:`Completed`,cancelled:`Cancelled`};function v(e){return String(e).padStart(2,`0`)}function y(e){return`${e.getFullYear()}-${v(e.getMonth()+1)}-${v(e.getDate())}T${v(e.getHours())}:${v(e.getMinutes())}`}function b(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:y(t)}function x(e){if(!e)return;let t=new Date(e);return Number.isNaN(t.getTime())?void 0:t.toISOString()}function S(){let e=new Date;return e.setHours(23,59,0,0),y(e)}function C(e){let t=x(e.due);return{title:e.title.trim(),...e.description.trim()?{description:e.description.trim()}:{},status:e.status,completed:e.status===`completed`,...t?{dueDate:t}:{},...e.priority===``?{}:{priority:Number(e.priority)}}}function w(){let[e,t]=(0,m.useState)(``),[n,r]=(0,m.useState)(``),[i,a]=(0,m.useState)(`pending`),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)(S()),[g,_]=(0,m.useState)([]),[v,y]=(0,m.useState)(``),[b,x]=(0,m.useState)(!1),w=p(),T=e.trim().length>0&&!b;async function E(t){x(!0);try{let r=await w.capture(),a=v.trim(),s={schema:u,schemaVersion:h,data:C({title:e,description:n,status:i,priority:o,due:c}),...a?{comment:a}:{},metadata:{features:d(g),...r?{geo:r}:{}}};return await f(t,[s])}finally{x(!1)}}return{title:e,setTitle:t,description:n,setDescription:r,status:i,setStatus:a,priority:o,setPriority:s,due:c,setDue:l,tags:g,setTags:_,comment:v,setComment:y,saving:b,canSave:T,save:E,geotag:w}}var T=e(r(),1),E=t(),D=15,O=[`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`,`Su`];function k(e){return String(e).padStart(2,`0`)}function A(e){let t=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})/.exec(e||``);return t?{date:`${t[1]}-${t[2]}-${t[3]}`,time:`${t[4]}:${t[5]}`}:null}function j(e){return`${e.getFullYear()}-${k(e.getMonth()+1)}-${k(e.getDate())}`}function M(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r)}function N(){let e=new Date;return e.setSeconds(0,0),e.setMinutes(Math.ceil(e.getMinutes()/D)*D),`${k(e.getHours())}:${k(e.getMinutes())}`}function P(){let e=[];for(let t=0;t<1440;t+=D)e.push(`${k(Math.floor(t/60))}:${k(t%60)}`);return e}var F=P();function I(e){let t=new Date(e.getFullYear(),e.getMonth(),1),n=(t.getDay()+6)%7,r=new Date(t);return r.setDate(t.getDate()-n),Array.from({length:42},(e,t)=>{let n=new Date(r);return n.setDate(r.getDate()+t),n})}function L(e){let[t,n]=e.split(`:`).map(Number);return new Date(2e3,0,1,t,n).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}function R(e){let t=A(e);if(!t)return``;let[n,r,i]=t.date.split(`-`).map(Number),[a,o]=t.time.split(`:`).map(Number);return new Date(n,r-1,i,a,o).toLocaleString(void 0,{weekday:`short`,day:`numeric`,month:`short`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})}function z({value:e,onChange:t,id:n,placeholder:r=`Pick a date & time`,clearable:i=!0,disabled:a=!1,compact:s=!1,className:u=``}){let[d,f]=(0,m.useState)(!1),p=(0,m.useRef)(null),h=A(e),g=h?R(e):``;return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`button`,{ref:p,id:n,type:`button`,disabled:a,onClick:()=>f(e=>!e),"aria-haspopup":`dialog`,"aria-expanded":d,className:l(`inline-flex w-full items-center gap-2 rounded-md border border-input bg-transparent text-left shadow-elevation-1 transition-colors`,`focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50`,s?`h-6 px-1.5 text-[11px]`:`h-9 px-3 py-1 text-sm`,!h&&`text-muted-foreground`,u),children:[(0,E.jsx)(c,{className:l(`shrink-0 text-muted-foreground`,s?`h-3 w-3`:`h-4 w-4`)}),(0,E.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:g||r}),i&&h&&(0,E.jsx)(`span`,{role:`button`,tabIndex:-1,"aria-label":`Clear date`,title:`Clear`,onClick:e=>{e.stopPropagation(),t(``)},className:`shrink-0 rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,E.jsx)(o,{className:s?`h-2.5 w-2.5`:`h-3.5 w-3.5`})})]}),d&&(0,E.jsx)(V,{anchorRef:p,value:e,onChange:t,onClose:()=>f(!1)})]})}function B({value:e,onChange:t,id:n,placeholder:r=`Pick a date`,min:i,disabled:o=!1,className:s=``}){let[c,u]=(0,m.useState)(!1),d=(0,m.useRef)(null),f=/^\d{4}-\d{2}-\d{2}$/.test(e),p=f?M(e).toLocaleDateString(void 0,{weekday:`short`,day:`numeric`,month:`short`,year:`numeric`}):``;return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`button`,{ref:d,id:n,type:`button`,disabled:o,onClick:()=>u(e=>!e),"aria-haspopup":`dialog`,"aria-expanded":c,className:l(`inline-flex h-8 w-full items-center gap-2 rounded-md border border-input bg-transparent px-2 text-left text-sm transition-colors`,`focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50`,!f&&`text-muted-foreground`,s),children:[(0,E.jsx)(a,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,E.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:p||r})]}),c&&(0,E.jsx)(V,{anchorRef:d,value:f?`${e}T00:00`:``,min:i,dateOnly:!0,onChange:e=>{t(e.slice(0,10)),u(!1)},onClose:()=>u(!1)})]})}function V({anchorRef:e,value:t,min:n,dateOnly:r=!1,onChange:a,onClose:o}){let c=A(t),u=c?.date??j(new Date),d=c?.time??null,[f,p]=(0,m.useState)(()=>{let e=M(u);return new Date(e.getFullYear(),e.getMonth(),1)}),h=(0,m.useRef)(null),g=(0,m.useRef)(null),[_,v]=(0,m.useState)(null);(0,m.useLayoutEffect)(()=>{let t=h.current,n=e.current;if(!t||!n)return;let r=()=>{let e=n.getBoundingClientRect(),{width:r,height:i}=t.getBoundingClientRect(),a=e.bottom+4,o=a+i+8<=window.innerHeight,s=e.top-i-4>=8,c=o?a:s?e.top-i-4:Math.max(8,window.innerHeight-i-8),l=Math.max(8,Math.min(e.left,window.innerWidth-r-8));v({x:l,y:c})};r();let i=new ResizeObserver(r);return i.observe(t),window.addEventListener(`resize`,r),window.addEventListener(`scroll`,r,!0),()=>{i.disconnect(),window.removeEventListener(`resize`,r),window.removeEventListener(`scroll`,r,!0)}},[e]),(0,m.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.stopPropagation(),o())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[o]);let y=(0,m.useMemo)(()=>!d||F.includes(d)?F:[...F,d].sort(),[d]);(0,m.useEffect)(()=>{let e=g.current,t=e?.querySelector(`[data-selected="true"]`);e&&t&&(e.scrollTop=t.offsetTop-e.clientHeight/2+t.clientHeight/2)},[]);let b=(e,t)=>a(`${e}T${t}`),x=e=>{let t=r?`00:00`:d??N();b(j(e),t),e.getMonth()!==f.getMonth()&&p(new Date(e.getFullYear(),e.getMonth(),1))},S=e=>{b(u,e),o()},C=e=>{let t=new Date;t.setDate(t.getDate()+e);let n=r?`00:00`:d??N();b(j(t),n),p(new Date(t.getFullYear(),t.getMonth(),1))},w=j(new Date),D=I(f);return(0,T.createPortal)((0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:o}),(0,E.jsxs)(`div`,{ref:h,role:`dialog`,"aria-label":`Choose date and time`,className:`fixed z-50 flex max-w-[95vw] gap-2 rounded-md border bg-popover p-2 text-popover-foreground shadow-elevation-4`,style:{left:_?.x??-9999,top:_?.y??-9999,visibility:_?`visible`:`hidden`},children:[(0,E.jsxs)(`div`,{className:`w-[236px]`,children:[(0,E.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,E.jsx)(`button`,{type:`button`,onClick:()=>p(new Date(f.getFullYear(),f.getMonth()-1,1)),"aria-label":`Previous month`,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,E.jsx)(i,{className:`h-4 w-4`})}),(0,E.jsx)(`span`,{className:`text-xs font-medium`,children:f.toLocaleDateString(void 0,{month:`long`,year:`numeric`})}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>p(new Date(f.getFullYear(),f.getMonth()+1,1)),"aria-label":`Next month`,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,E.jsx)(s,{className:`h-4 w-4`})})]}),(0,E.jsx)(`div`,{className:`grid grid-cols-7 gap-0.5 px-0.5 pb-1 text-center text-[10px] uppercase tracking-wide text-muted-foreground/70`,children:O.map(e=>(0,E.jsx)(`span`,{children:e},e))}),(0,E.jsx)(`div`,{className:`grid grid-cols-7 gap-0.5`,children:D.map(e=>{let t=j(e),r=e.getMonth()!==f.getMonth(),i=t===u&&!!c;return(0,E.jsx)(`button`,{type:`button`,disabled:!!n&&t<n,onClick:()=>x(e),"aria-pressed":i,className:l(`h-7 rounded text-xs tabular-nums transition-colors disabled:cursor-not-allowed disabled:opacity-30`,r?`text-muted-foreground/40`:`text-foreground`,i?`bg-primary text-primary-foreground`:`hover:bg-muted`,!i&&t===w&&`font-semibold ring-1 ring-inset ring-border`),children:e.getDate()},t)})}),(0,E.jsx)(`div`,{className:`mt-1.5 flex gap-1`,children:[[`Today`,0],[`Tomorrow`,1],[`Next week`,7]].map(([e,t])=>(0,E.jsx)(`button`,{type:`button`,onClick:()=>C(t),className:`flex-1 rounded border border-border px-1.5 py-1 text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:e},e))})]}),!r&&(0,E.jsxs)(`div`,{className:`flex w-[104px] flex-col`,children:[(0,E.jsx)(`input`,{type:`time`,step:900,value:d??``,onChange:e=>{e.target.value&&b(u,e.target.value.slice(0,5))},"aria-label":`Time`,className:`mb-1 h-7 w-full rounded border border-input bg-transparent px-1.5 text-xs tabular-nums focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`}),(0,E.jsx)(`div`,{ref:g,className:`max-h-[236px] flex-1 overflow-y-auto pr-0.5`,children:y.map(e=>{let t=e===d;return(0,E.jsx)(`button`,{type:`button`,"data-selected":t,onClick:()=>S(e),"aria-pressed":t,className:l(`block w-full rounded px-2 py-1 text-left text-xs tabular-nums transition-colors`,t?`bg-primary text-primary-foreground`:`hover:bg-muted`),children:L(e)},e)})})]})]})]}),document.body)}export{C as a,S as c,_ as i,w as l,z as n,b as o,g as r,x as s,B as t};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{yt as r}from"./react-BHzhHVTZ.js";import{L as i,Ur as a,Wr as o,Xr as s,Zr as c}from"./ui-DEgHnkQu.js";import{t as l}from"./utils-2pl1SbIp.js";import{Bn as u}from"./workspace-4hWrSEku.js";import{n as d}from"./tags-YamdPoBK.js";import{o as f}from"./useAddTarget-BvuFR5pN.js";import{r as p}from"./relation-events-CKio19hE.js";var m=e(n(),1),h=`2.1`,g=[`pending`,`in-progress`,`completed`,`cancelled`],_={pending:`Pending`,"in-progress":`In progress`,completed:`Completed`,cancelled:`Cancelled`};function v(e){return String(e).padStart(2,`0`)}function y(e){return`${e.getFullYear()}-${v(e.getMonth()+1)}-${v(e.getDate())}T${v(e.getHours())}:${v(e.getMinutes())}`}function b(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:y(t)}function x(e){if(!e)return;let t=new Date(e);return Number.isNaN(t.getTime())?void 0:t.toISOString()}function S(){let e=new Date;return e.setHours(23,59,0,0),y(e)}function C(e){let t=x(e.due);return{title:e.title.trim(),...e.description.trim()?{description:e.description.trim()}:{},status:e.status,completed:e.status===`completed`,...t?{dueDate:t}:{},...e.priority===``?{}:{priority:Number(e.priority)}}}function w(){let[e,t]=(0,m.useState)(``),[n,r]=(0,m.useState)(``),[i,a]=(0,m.useState)(`pending`),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)(S()),[g,_]=(0,m.useState)([]),[v,y]=(0,m.useState)(``),[b,x]=(0,m.useState)(!1),w=p(),T=e.trim().length>0&&!b;async function E(t){x(!0);try{let r=await w.capture(),a=v.trim(),s={schema:u,schemaVersion:h,data:C({title:e,description:n,status:i,priority:o,due:c}),...a?{comment:a}:{},metadata:{features:d(g),...r?{geo:r}:{}}};return await f(t,[s])}finally{x(!1)}}return{title:e,setTitle:t,description:n,setDescription:r,status:i,setStatus:a,priority:o,setPriority:s,due:c,setDue:l,tags:g,setTags:_,comment:v,setComment:y,saving:b,canSave:T,save:E,geotag:w}}var T=e(r(),1),E=t(),D=15,O=[`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`,`Su`];function k(e){return String(e).padStart(2,`0`)}function A(e){let t=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})/.exec(e||``);return t?{date:`${t[1]}-${t[2]}-${t[3]}`,time:`${t[4]}:${t[5]}`}:null}function j(e){return`${e.getFullYear()}-${k(e.getMonth()+1)}-${k(e.getDate())}`}function M(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r)}function N(){let e=new Date;return e.setSeconds(0,0),e.setMinutes(Math.ceil(e.getMinutes()/D)*D),`${k(e.getHours())}:${k(e.getMinutes())}`}function P(){let e=[];for(let t=0;t<1440;t+=D)e.push(`${k(Math.floor(t/60))}:${k(t%60)}`);return e}var F=P();function I(e){let t=new Date(e.getFullYear(),e.getMonth(),1),n=(t.getDay()+6)%7,r=new Date(t);return r.setDate(t.getDate()-n),Array.from({length:42},(e,t)=>{let n=new Date(r);return n.setDate(r.getDate()+t),n})}function L(e){let[t,n]=e.split(`:`).map(Number);return new Date(2e3,0,1,t,n).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}function R(e){let t=A(e);if(!t)return``;let[n,r,i]=t.date.split(`-`).map(Number),[a,o]=t.time.split(`:`).map(Number);return new Date(n,r-1,i,a,o).toLocaleString(void 0,{weekday:`short`,day:`numeric`,month:`short`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})}function z({value:e,onChange:t,id:n,placeholder:r=`Pick a date & time`,clearable:a=!0,disabled:o=!1,compact:s=!1,className:u=``}){let[d,f]=(0,m.useState)(!1),p=(0,m.useRef)(null),h=A(e),g=h?R(e):``;return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`button`,{ref:p,id:n,type:`button`,disabled:o,onClick:()=>f(e=>!e),"aria-haspopup":`dialog`,"aria-expanded":d,className:l(`inline-flex w-full items-center gap-2 rounded-md border border-input bg-transparent text-left shadow-elevation-1 transition-colors`,`focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50`,s?`h-6 px-1.5 text-[11px]`:`h-9 px-3 py-1 text-sm`,!h&&`text-muted-foreground`,u),children:[(0,E.jsx)(c,{className:l(`shrink-0 text-muted-foreground`,s?`h-3 w-3`:`h-4 w-4`)}),(0,E.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:g||r}),a&&h&&(0,E.jsx)(`span`,{role:`button`,tabIndex:-1,"aria-label":`Clear date`,title:`Clear`,onClick:e=>{e.stopPropagation(),t(``)},className:`shrink-0 rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,E.jsx)(i,{className:s?`h-2.5 w-2.5`:`h-3.5 w-3.5`})})]}),d&&(0,E.jsx)(V,{anchorRef:p,value:e,onChange:t,onClose:()=>f(!1)})]})}function B({value:e,onChange:t,id:n,placeholder:r=`Pick a date`,min:i,disabled:a=!1,className:o=``}){let[c,u]=(0,m.useState)(!1),d=(0,m.useRef)(null),f=/^\d{4}-\d{2}-\d{2}$/.test(e),p=f?M(e).toLocaleDateString(void 0,{weekday:`short`,day:`numeric`,month:`short`,year:`numeric`}):``;return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`button`,{ref:d,id:n,type:`button`,disabled:a,onClick:()=>u(e=>!e),"aria-haspopup":`dialog`,"aria-expanded":c,className:l(`inline-flex h-8 w-full items-center gap-2 rounded-md border border-input bg-transparent px-2 text-left text-sm transition-colors`,`focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50`,!f&&`text-muted-foreground`,o),children:[(0,E.jsx)(s,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,E.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:p||r})]}),c&&(0,E.jsx)(V,{anchorRef:d,value:f?`${e}T00:00`:``,min:i,dateOnly:!0,onChange:e=>{t(e.slice(0,10)),u(!1)},onClose:()=>u(!1)})]})}function V({anchorRef:e,value:t,min:n,dateOnly:r=!1,onChange:i,onClose:s}){let c=A(t),u=c?.date??j(new Date),d=c?.time??null,[f,p]=(0,m.useState)(()=>{let e=M(u);return new Date(e.getFullYear(),e.getMonth(),1)}),h=(0,m.useRef)(null),g=(0,m.useRef)(null),[_,v]=(0,m.useState)(null);(0,m.useLayoutEffect)(()=>{let t=h.current,n=e.current;if(!t||!n)return;let r=()=>{let e=n.getBoundingClientRect(),{width:r,height:i}=t.getBoundingClientRect(),a=e.bottom+4,o=a+i+8<=window.innerHeight,s=e.top-i-4>=8,c=o?a:s?e.top-i-4:Math.max(8,window.innerHeight-i-8),l=Math.max(8,Math.min(e.left,window.innerWidth-r-8));v({x:l,y:c})};r();let i=new ResizeObserver(r);return i.observe(t),window.addEventListener(`resize`,r),window.addEventListener(`scroll`,r,!0),()=>{i.disconnect(),window.removeEventListener(`resize`,r),window.removeEventListener(`scroll`,r,!0)}},[e]),(0,m.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.stopPropagation(),s())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[s]);let y=(0,m.useMemo)(()=>!d||F.includes(d)?F:[...F,d].sort(),[d]);(0,m.useEffect)(()=>{let e=g.current,t=e?.querySelector(`[data-selected="true"]`);e&&t&&(e.scrollTop=t.offsetTop-e.clientHeight/2+t.clientHeight/2)},[]);let b=(e,t)=>i(`${e}T${t}`),x=e=>{let t=r?`00:00`:d??N();b(j(e),t),e.getMonth()!==f.getMonth()&&p(new Date(e.getFullYear(),e.getMonth(),1))},S=e=>{b(u,e),s()},C=e=>{let t=new Date;t.setDate(t.getDate()+e);let n=r?`00:00`:d??N();b(j(t),n),p(new Date(t.getFullYear(),t.getMonth(),1))},w=j(new Date),D=I(f);return(0,T.createPortal)((0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:s}),(0,E.jsxs)(`div`,{ref:h,role:`dialog`,"aria-label":`Choose date and time`,className:`fixed z-50 flex max-w-[95vw] gap-2 rounded-md border bg-popover p-2 text-popover-foreground shadow-elevation-4`,style:{left:_?.x??-9999,top:_?.y??-9999,visibility:_?`visible`:`hidden`},children:[(0,E.jsxs)(`div`,{className:`w-[236px]`,children:[(0,E.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,E.jsx)(`button`,{type:`button`,onClick:()=>p(new Date(f.getFullYear(),f.getMonth()-1,1)),"aria-label":`Previous month`,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,E.jsx)(o,{className:`h-4 w-4`})}),(0,E.jsx)(`span`,{className:`text-xs font-medium`,children:f.toLocaleDateString(void 0,{month:`long`,year:`numeric`})}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>p(new Date(f.getFullYear(),f.getMonth()+1,1)),"aria-label":`Next month`,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,E.jsx)(a,{className:`h-4 w-4`})})]}),(0,E.jsx)(`div`,{className:`grid grid-cols-7 gap-0.5 px-0.5 pb-1 text-center text-[10px] uppercase tracking-wide text-muted-foreground/70`,children:O.map(e=>(0,E.jsx)(`span`,{children:e},e))}),(0,E.jsx)(`div`,{className:`grid grid-cols-7 gap-0.5`,children:D.map(e=>{let t=j(e),r=e.getMonth()!==f.getMonth(),i=t===u&&!!c;return(0,E.jsx)(`button`,{type:`button`,disabled:!!n&&t<n,onClick:()=>x(e),"aria-pressed":i,className:l(`h-7 rounded text-xs tabular-nums transition-colors disabled:cursor-not-allowed disabled:opacity-30`,r?`text-muted-foreground/40`:`text-foreground`,i?`bg-primary text-primary-foreground`:`hover:bg-muted`,!i&&t===w&&`font-semibold ring-1 ring-inset ring-border`),children:e.getDate()},t)})}),(0,E.jsx)(`div`,{className:`mt-1.5 flex gap-1`,children:[[`Today`,0],[`Tomorrow`,1],[`Next week`,7]].map(([e,t])=>(0,E.jsx)(`button`,{type:`button`,onClick:()=>C(t),className:`flex-1 rounded border border-border px-1.5 py-1 text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:e},e))})]}),!r&&(0,E.jsxs)(`div`,{className:`flex w-[104px] flex-col`,children:[(0,E.jsx)(`input`,{type:`time`,step:900,value:d??``,onChange:e=>{e.target.value&&b(u,e.target.value.slice(0,5))},"aria-label":`Time`,className:`mb-1 h-7 w-full rounded border border-input bg-transparent px-1.5 text-xs tabular-nums focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`}),(0,E.jsx)(`div`,{ref:g,className:`max-h-[236px] flex-1 overflow-y-auto pr-0.5`,children:y.map(e=>{let t=e===d;return(0,E.jsx)(`button`,{type:`button`,"data-selected":t,onClick:()=>S(e),"aria-pressed":t,className:l(`block w-full rounded px-2 py-1 text-left text-xs tabular-nums transition-colors`,t?`bg-primary text-primary-foreground`:`hover:bg-muted`),children:L(e)},e)})})]})]})]}),document.body)}export{C as a,S as c,_ as i,w as l,z as n,b as o,g as r,x as s,B as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{Bt as r,L as i,Wr as a,Xt as o,dt as s,kt as c,vn as l}from"./ui-CDoK3F3U.js";import{t as u}from"./button-SeUZ_Pvi.js";import{t as d}from"./input-BOtCd4HP.js";import{n as f}from"./use-toast-BlLDqSUO.js";import{n as p}from"./page-header-DrDt1sQ2.js";import{t as m}from"./use-settings-back-DGmLAD63.js";import{i as h,n as g,o as _}from"./devices-CAa1bRxk.js";var v=e(n(),1),y=t();function b({device:e,onUpdated:t,onRemoved:n}){let[c,l]=(0,v.useState)(!1),[p,m]=(0,v.useState)(e.name),[g,b]=(0,v.useState)(e.description??``),[x,S]=(0,v.useState)(!1),[C,w]=(0,v.useState)(!1),[T,E]=(0,v.useState)(!1),{showToast:D}=f(),O=async()=>{E(!0);try{await h(e.deviceId),n(e.deviceId),D({title:`Revoked`,description:`${e.name} can no longer sign in; a running mirror stops on its next request.`})}catch(e){D({title:`Error`,description:e instanceof Error?e.message:`Failed to revoke device`,variant:`destructive`}),w(!1)}finally{E(!1)}},k=async()=>{let n=p.trim();if(n){if(n===e.name&&g.trim()===(e.description??``)){l(!1);return}S(!0);try{let r=await _(e.deviceId,{name:n,description:g.trim()||void 0});t({...e,...r}),l(!1),D({title:`Saved`,description:`Device updated`})}catch(e){D({title:`Error`,description:e instanceof Error?e.message:`Failed to update device`,variant:`destructive`})}finally{S(!1)}}},A=()=>{m(e.name),b(e.description??``),l(!1)},j=e=>e?new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):`—`;return(0,y.jsx)(`div`,{className:`rounded-lg border p-4`,children:(0,y.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,y.jsxs)(`div`,{className:`flex items-start gap-3 min-w-0`,children:[(0,y.jsx)(o,{className:`h-4 w-4 text-muted-foreground mt-0.5 shrink-0`}),(0,y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[c?(0,y.jsxs)(`div`,{className:`space-y-2 mb-2`,children:[(0,y.jsx)(d,{value:p,onChange:e=>m(e.target.value),className:`h-7 text-sm`,placeholder:`Device name`,autoFocus:!0,disabled:x,onKeyDown:e=>{e.key===`Enter`&&k(),e.key===`Escape`&&A()}}),(0,y.jsx)(d,{value:g,onChange:e=>b(e.target.value),className:`h-7 text-xs`,placeholder:`Description (optional)`,disabled:x,onKeyDown:e=>{e.key===`Enter`&&k(),e.key===`Escape`&&A()}})]}):(0,y.jsxs)(`div`,{className:`mb-1`,children:[(0,y.jsx)(`span`,{className:`text-sm font-medium`,children:e.name}),e.description&&(0,y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e.description})]}),(0,y.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-0.5 text-[11px] font-mono text-muted-foreground`,children:[(0,y.jsx)(`span`,{title:`Device ID`,children:e.deviceId}),e.platform&&(0,y.jsx)(`span`,{children:e.platform}),e.arch&&(0,y.jsx)(`span`,{children:e.arch}),e.type&&(0,y.jsx)(`span`,{className:`capitalize`,children:e.type})]}),(0,y.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-x-4 text-[11px] text-muted-foreground`,children:[e.createdAt&&(0,y.jsxs)(`span`,{children:[`registered `,j(e.createdAt)]}),e.updatedAt&&e.updatedAt!==e.createdAt&&(0,y.jsxs)(`span`,{children:[`updated `,j(e.updatedAt)]}),e.lastSeen&&(0,y.jsxs)(`span`,{children:[`seen `,j(e.lastSeen)]})]})]})]}),(0,y.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:C?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(u,{type:`button`,variant:`destructive`,size:`sm`,onClick:O,disabled:T,children:T?`Revoking…`:`Confirm revoke`}),(0,y.jsx)(u,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>w(!1),disabled:T,children:(0,y.jsx)(i,{className:`h-3.5 w-3.5`})})]}):c?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(u,{type:`button`,variant:`outline`,size:`sm`,onClick:k,disabled:x||!p.trim(),children:(0,y.jsx)(a,{className:`h-3.5 w-3.5`})}),(0,y.jsx)(u,{type:`button`,variant:`ghost`,size:`sm`,onClick:A,disabled:x,children:(0,y.jsx)(i,{className:`h-3.5 w-3.5`})})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(u,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>l(!0),title:`Edit name / description`,children:(0,y.jsx)(r,{className:`h-3.5 w-3.5`})}),(0,y.jsx)(u,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>w(!0),title:`Revoke this device: its tokens stop working and its mirrors stop syncing`,children:(0,y.jsx)(s,{className:`h-3.5 w-3.5`})})]})})]})})}function x(){let[e,t]=(0,v.useState)([]),[n,r]=(0,v.useState)(!0),{showToast:i}=f(),a=async()=>{r(!0);try{t(await g())}catch(e){i({title:`Error`,description:e instanceof Error?e.message:`Failed to load devices`,variant:`destructive`})}finally{r(!1)}};(0,v.useEffect)(()=>{(async()=>{try{t(await g())}catch(e){i({title:`Error`,description:e instanceof Error?e.message:`Failed to load devices`,variant:`destructive`})}finally{r(!1)}})()},[i]);let s=e=>t(t=>t.map(t=>t.deviceId===e.deviceId?e:t)),d=e=>t(t=>t.filter(t=>t.deviceId!==e));return(0,y.jsx)(`div`,{className:`h-full min-h-0 overflow-y-auto`,children:(0,y.jsxs)(`div`,{className:`mx-auto max-w-3xl p-6 pb-12 space-y-6`,children:[(0,y.jsx)(p,{compact:!0,title:`Devices`,onBack:m(),description:`All devices registered to your account. Link them to individual workspaces in Workspace › Settings › Devices.`,actions:(0,y.jsxs)(u,{type:`button`,variant:`outline`,size:`sm`,onClick:a,disabled:n,children:[(0,y.jsx)(c,{className:`mr-2 h-3.5 w-3.5 ${n?`animate-spin`:``}`}),`Refresh`]})}),n?(0,y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,y.jsx)(c,{className:`h-4 w-4 animate-spin`}),`Loading…`]}):e.length===0?(0,y.jsxs)(`div`,{className:`rounded-lg border p-6 text-center text-sm text-muted-foreground space-y-2`,children:[(0,y.jsx)(o,{className:`h-8 w-8 mx-auto text-muted-foreground/40`}),(0,y.jsx)(`p`,{children:`No devices registered yet.`}),(0,y.jsxs)(`p`,{className:`text-xs`,children:[`Devices register themselves automatically on first connection via`,` `,(0,y.jsx)(`span`,{className:`font-mono`,children:`POST /auth/devices/register`}),`.`]})]}):(0,y.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,y.jsx)(b,{device:e,onUpdated:s,onRemoved:d},e.deviceId))}),e.length>0&&(0,y.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-dashed p-3 text-xs text-muted-foreground`,children:[(0,y.jsx)(l,{className:`h-3.5 w-3.5 shrink-0`}),`To link a device to a workspace, go to Workspace › Settings › Devices.`]})]})})}export{x 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{Bt as r,Kr as i,L as a,Xt as o,dt as s,kt as c,vn as l}from"./ui-DEgHnkQu.js";import{t as u}from"./button--VYZekMF.js";import{t as d}from"./input-BOtCd4HP.js";import{n as f}from"./use-toast-BlLDqSUO.js";import{n as p}from"./page-header-NyYSXjfY.js";import{t as m}from"./use-settings-back-D_MM9diy.js";import{i as h,n as g,o as _}from"./devices-CAa1bRxk.js";var v=e(n(),1),y=t();function b({device:e,onUpdated:t,onRemoved:n}){let[c,l]=(0,v.useState)(!1),[p,m]=(0,v.useState)(e.name),[g,b]=(0,v.useState)(e.description??``),[x,S]=(0,v.useState)(!1),[C,w]=(0,v.useState)(!1),[T,E]=(0,v.useState)(!1),{showToast:D}=f(),O=async()=>{E(!0);try{await h(e.deviceId),n(e.deviceId),D({title:`Revoked`,description:`${e.name} can no longer sign in; a running mirror stops on its next request.`})}catch(e){D({title:`Error`,description:e instanceof Error?e.message:`Failed to revoke device`,variant:`destructive`}),w(!1)}finally{E(!1)}},k=async()=>{let n=p.trim();if(n){if(n===e.name&&g.trim()===(e.description??``)){l(!1);return}S(!0);try{let r=await _(e.deviceId,{name:n,description:g.trim()||void 0});t({...e,...r}),l(!1),D({title:`Saved`,description:`Device updated`})}catch(e){D({title:`Error`,description:e instanceof Error?e.message:`Failed to update device`,variant:`destructive`})}finally{S(!1)}}},A=()=>{m(e.name),b(e.description??``),l(!1)},j=e=>e?new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):`—`;return(0,y.jsx)(`div`,{className:`rounded-lg border p-4`,children:(0,y.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,y.jsxs)(`div`,{className:`flex items-start gap-3 min-w-0`,children:[(0,y.jsx)(o,{className:`h-4 w-4 text-muted-foreground mt-0.5 shrink-0`}),(0,y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[c?(0,y.jsxs)(`div`,{className:`space-y-2 mb-2`,children:[(0,y.jsx)(d,{value:p,onChange:e=>m(e.target.value),className:`h-7 text-sm`,placeholder:`Device name`,autoFocus:!0,disabled:x,onKeyDown:e=>{e.key===`Enter`&&k(),e.key===`Escape`&&A()}}),(0,y.jsx)(d,{value:g,onChange:e=>b(e.target.value),className:`h-7 text-xs`,placeholder:`Description (optional)`,disabled:x,onKeyDown:e=>{e.key===`Enter`&&k(),e.key===`Escape`&&A()}})]}):(0,y.jsxs)(`div`,{className:`mb-1`,children:[(0,y.jsx)(`span`,{className:`text-sm font-medium`,children:e.name}),e.description&&(0,y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e.description})]}),(0,y.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-0.5 text-[11px] font-mono text-muted-foreground`,children:[(0,y.jsx)(`span`,{title:`Device ID`,children:e.deviceId}),e.platform&&(0,y.jsx)(`span`,{children:e.platform}),e.arch&&(0,y.jsx)(`span`,{children:e.arch}),e.type&&(0,y.jsx)(`span`,{className:`capitalize`,children:e.type})]}),(0,y.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-x-4 text-[11px] text-muted-foreground`,children:[e.createdAt&&(0,y.jsxs)(`span`,{children:[`registered `,j(e.createdAt)]}),e.updatedAt&&e.updatedAt!==e.createdAt&&(0,y.jsxs)(`span`,{children:[`updated `,j(e.updatedAt)]}),e.lastSeen&&(0,y.jsxs)(`span`,{children:[`seen `,j(e.lastSeen)]})]})]})]}),(0,y.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:C?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(u,{type:`button`,variant:`destructive`,size:`sm`,onClick:O,disabled:T,children:T?`Revoking…`:`Confirm revoke`}),(0,y.jsx)(u,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>w(!1),disabled:T,children:(0,y.jsx)(a,{className:`h-3.5 w-3.5`})})]}):c?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(u,{type:`button`,variant:`outline`,size:`sm`,onClick:k,disabled:x||!p.trim(),children:(0,y.jsx)(i,{className:`h-3.5 w-3.5`})}),(0,y.jsx)(u,{type:`button`,variant:`ghost`,size:`sm`,onClick:A,disabled:x,children:(0,y.jsx)(a,{className:`h-3.5 w-3.5`})})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(u,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>l(!0),title:`Edit name / description`,children:(0,y.jsx)(r,{className:`h-3.5 w-3.5`})}),(0,y.jsx)(u,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>w(!0),title:`Revoke this device: its tokens stop working and its mirrors stop syncing`,children:(0,y.jsx)(s,{className:`h-3.5 w-3.5`})})]})})]})})}function x(){let[e,t]=(0,v.useState)([]),[n,r]=(0,v.useState)(!0),{showToast:i}=f(),a=async()=>{r(!0);try{t(await g())}catch(e){i({title:`Error`,description:e instanceof Error?e.message:`Failed to load devices`,variant:`destructive`})}finally{r(!1)}};(0,v.useEffect)(()=>{(async()=>{try{t(await g())}catch(e){i({title:`Error`,description:e instanceof Error?e.message:`Failed to load devices`,variant:`destructive`})}finally{r(!1)}})()},[i]);let s=e=>t(t=>t.map(t=>t.deviceId===e.deviceId?e:t)),d=e=>t(t=>t.filter(t=>t.deviceId!==e));return(0,y.jsx)(`div`,{className:`h-full min-h-0 overflow-y-auto`,children:(0,y.jsxs)(`div`,{className:`mx-auto max-w-3xl p-6 pb-12 space-y-6`,children:[(0,y.jsx)(p,{compact:!0,title:`Devices`,onBack:m(),description:`All devices registered to your account. Link them to individual workspaces in Workspace › Settings › Devices.`,actions:(0,y.jsxs)(u,{type:`button`,variant:`outline`,size:`sm`,onClick:a,disabled:n,children:[(0,y.jsx)(c,{className:`mr-2 h-3.5 w-3.5 ${n?`animate-spin`:``}`}),`Refresh`]})}),n?(0,y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,y.jsx)(c,{className:`h-4 w-4 animate-spin`}),`Loading…`]}):e.length===0?(0,y.jsxs)(`div`,{className:`rounded-lg border p-6 text-center text-sm text-muted-foreground space-y-2`,children:[(0,y.jsx)(o,{className:`h-8 w-8 mx-auto text-muted-foreground/40`}),(0,y.jsx)(`p`,{children:`No devices registered yet.`}),(0,y.jsxs)(`p`,{className:`text-xs`,children:[`Devices register themselves automatically on first connection via`,` `,(0,y.jsx)(`span`,{className:`font-mono`,children:`POST /auth/devices/register`}),`.`]})]}):(0,y.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,y.jsx)(b,{device:e,onUpdated:s,onRemoved:d},e.deviceId))}),e.length>0&&(0,y.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-dashed p-3 text-xs text-muted-foreground`,children:[(0,y.jsx)(l,{className:`h-3.5 w-3.5 shrink-0`}),`To link a device to a workspace, go to Workspace › Settings › Devices.`]})]})})}export{x as default};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{_ as r,g as i,h as a}from"./chunk-62JRHF6Z-vspAGgtK.js";import{t as o}from"./button-SeUZ_Pvi.js";import{Dn as s,et as c,tt as l}from"./workspace-C5V-ZCOE.js";import{t as u,u as d}from"./ObjectPropertiesCard-D2lrTQqT.js";import{t as f}from"./url-params-n7kU_WZ-.js";import{i as p}from"./use-menu-DIP1zh7I.js";import{t as m}from"./workspace-content-gate-C54J9Man.js";import{t as h}from"./use-workspace-identity-CSkRwVyo.js";var g=e(n(),1),_=t();function v(){let{workspaceName:e}=r();return e?(0,_.jsx)(m,{workspaceName:e,children:(0,_.jsx)(y,{})}):(0,_.jsx)(`p`,{role:`alert`,className:`p-6`,children:`Workspace not specified.`})}function y(){let{workspaceName:e=``,documentId:t=``,algo:n=``,checksum:m=``}=r(),v=i(),y=a(),{goBack:b,openM1Drawer:x,openM2Drawer:S}=p(),C=h(e),w=!!n&&!!m,T=w?`${n}/${m}`:t,E=JSON.stringify([e,t,n,m]),D=Number(t),O=/^\d+$/.test(t)&&Number.isSafeInteger(D)&&D>0,k=w||O,[A,j]=(0,g.useState)(0),[M,N]=(0,g.useState)(null),P=M?.identity===E?M:null,F=k&&(!P||P.revision!==A);(0,g.useEffect)(()=>{let t=!1;if(k)return(w?l(e,n,m):c(e,D)).then(e=>{t||N({identity:E,revision:A,document:e||null,missing:!e,error:``})}).catch(e=>{t||N({identity:E,revision:A,document:null,missing:e?.statusCode===404,error:e instanceof Error?e.message:`Unable to retrieve this document.`})}),()=>{t=!0}},[e,D,E,A,k,w,n,m]);let I={workspace:C?.label||e,workspaceIcon:C?.icon,path:`/`,tree:`context`,document:P?.document?s(P.document).title:`Document ${T}`,onBack:b,onBrowseWorkspaces:()=>x(`workspaces`),onBrowseTree:()=>S(`workspaces`,`detail`,e),onNavigatePath:t=>v(f(e,t,`context`))},L=y.hash.slice(1),R=[`view`,`location`,`metadata`,`json`,`synapses`,`backends`].includes(L)?L:`view`;return(0,_.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[!P?.document&&(0,_.jsx)(d,{...I}),P?.document?(0,_.jsx)(u,{document:P.document,workspaceId:e,onChanged:()=>j(e=>e+1),navigation:I,initialTab:R,onTabChange:e=>v(`${y.pathname}${y.search}#${e}`,{replace:!0}),tabActions:(0,_.jsx)(o,{variant:`ghost`,disabled:F,onClick:()=>j(e=>e+1),children:`Refresh`})},E):F?(0,_.jsx)(`p`,{role:`status`,className:`p-6 text-sm text-muted-foreground`,children:`Loading document…`}):(0,_.jsxs)(`div`,{role:`alert`,className:`space-y-2 p-6 text-sm`,children:[(0,_.jsx)(`p`,{className:`font-medium`,children:P?.missing?`Document ${T} not found`:`Unable to load document`}),k&&(0,_.jsx)(o,{variant:`outline`,onClick:()=>j(e=>e+1),children:`Retry`}),(0,_.jsx)(`p`,{className:`text-muted-foreground`,children:k?P?.missing?`This record is no longer available in this workspace. Subtree exports skip missing records and report their IDs.`:P?.error:`Document ID must be a positive integer.`})]})]})}export{v as default};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{_ as r,g as i,h as a}from"./chunk-62JRHF6Z-vspAGgtK.js";import{t as o}from"./button--VYZekMF.js";import{On as s,et as c,tt as l}from"./workspace-4hWrSEku.js";import{t as u,u as d}from"./ObjectPropertiesCard-DesXRw-_.js";import{t as f}from"./url-params-n7kU_WZ-.js";import{i as p}from"./use-menu-CKSpS96u.js";import{t as m}from"./workspace-content-gate-BlFdbi67.js";import{t as h}from"./use-workspace-identity-XSv3dATQ.js";var g=e(n(),1),_=t();function v(){let{workspaceName:e}=r();return e?(0,_.jsx)(m,{workspaceName:e,children:(0,_.jsx)(y,{})}):(0,_.jsx)(`p`,{role:`alert`,className:`p-6`,children:`Workspace not specified.`})}function y(){let{workspaceName:e=``,documentId:t=``,algo:n=``,checksum:m=``}=r(),v=i(),y=a(),{goBack:b,openM1Drawer:x,openM2Drawer:S}=p(),C=h(e),w=!!n&&!!m,T=w?`${n}/${m}`:t,E=JSON.stringify([e,t,n,m]),D=Number(t),O=/^\d+$/.test(t)&&Number.isSafeInteger(D)&&D>0,k=w||O,[A,j]=(0,g.useState)(0),[M,N]=(0,g.useState)(null),P=M?.identity===E?M:null,F=k&&(!P||P.revision!==A);(0,g.useEffect)(()=>{let t=!1;if(k)return(w?l(e,n,m):c(e,D)).then(e=>{t||N({identity:E,revision:A,document:e||null,missing:!e,error:``})}).catch(e=>{t||N({identity:E,revision:A,document:null,missing:e?.statusCode===404,error:e instanceof Error?e.message:`Unable to retrieve this document.`})}),()=>{t=!0}},[e,D,E,A,k,w,n,m]);let I={workspace:C?.label||e,workspaceIcon:C?.icon,path:`/`,tree:`context`,document:P?.document?s(P.document).title:`Document ${T}`,onBack:b,onBrowseWorkspaces:()=>x(`workspaces`),onBrowseTree:()=>S(`workspaces`,`detail`,e),onNavigatePath:t=>v(f(e,t,`context`))},L=y.hash.slice(1),R=[`view`,`location`,`metadata`,`json`,`synapses`,`backends`].includes(L)?L:`view`;return(0,_.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[!P?.document&&(0,_.jsx)(d,{...I}),P?.document?(0,_.jsx)(u,{document:P.document,workspaceId:e,onChanged:()=>j(e=>e+1),navigation:I,initialTab:R,onTabChange:e=>v(`${y.pathname}${y.search}#${e}`,{replace:!0}),tabActions:(0,_.jsx)(o,{variant:`ghost`,disabled:F,onClick:()=>j(e=>e+1),children:`Refresh`})},E):F?(0,_.jsx)(`p`,{role:`status`,className:`p-6 text-sm text-muted-foreground`,children:`Loading document…`}):(0,_.jsxs)(`div`,{role:`alert`,className:`space-y-2 p-6 text-sm`,children:[(0,_.jsx)(`p`,{className:`font-medium`,children:P?.missing?`Document ${T} not found`:`Unable to load document`}),k&&(0,_.jsx)(o,{variant:`outline`,onClick:()=>j(e=>e+1),children:`Retry`}),(0,_.jsx)(`p`,{className:`text-muted-foreground`,children:k?P?.missing?`This record is no longer available in this workspace. Subtree exports skip missing records and report their IDs.`:P?.error:`Document ID must be a positive integer.`})]})]})}export{v as default};