@augmentd-labs/canvas-web 2.26.30 → 2.26.31

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 (35) hide show
  1. package/dist/assets/{CalendarApplet-B-KQB9MF.js → CalendarApplet-1-_9Pqfs.js} +1 -1
  2. package/dist/assets/{FiltersApplet-BQ-yLETb.js → FiltersApplet-bF_7ntZU.js} +1 -1
  3. package/dist/assets/{HomeFab-xOFNqlcV.js → HomeFab-B_AndThd.js} +1 -1
  4. package/dist/assets/{LensApplet-DNR6LHP1.js → LensApplet-FoQc4ieR.js} +1 -1
  5. package/dist/assets/{NotesApplet-DyJobkzg.js → NotesApplet-DfagszMP.js} +1 -1
  6. package/dist/assets/{_agentId_-28SRDtL_.js → _agentId_-GsPtoz9i.js} +0 -0
  7. package/dist/assets/{_contextId_-DmyCWpLx.js → _contextId_-xoan5Zgw.js} +1 -1
  8. package/dist/assets/{_workspaceName_-BVxMj4S4.js → _workspaceName_-DfNeZ188.js} +1 -1
  9. package/dist/assets/{about-BSl71l_q.js → about-DWl4-RY1.js} +1 -1
  10. package/dist/assets/{add-fc-96N3K.js → add-AHQUHZBr.js} +1 -1
  11. package/dist/assets/{agents-Dp0UlFhw.js → agents-DT1XtFUN.js} +1 -1
  12. package/dist/assets/{appearance-MxLwJvKV.js → appearance-C8m9uEmD.js} +1 -1
  13. package/dist/assets/{apps-W1ZPkVTB.js → apps-DbYkQgyL.js} +1 -1
  14. package/dist/assets/backend-sync-progress-BJsLP7o5.js +7 -0
  15. package/dist/assets/{content-app-view-Cvqs06e8.js → content-app-view-B4ada874.js} +1 -1
  16. package/dist/assets/{document-list-Cq4rdquK.js → document-list-CwStaizB.js} +1 -1
  17. package/dist/assets/{home-B5H1Bpql.js → home-BWAoF6jL.js} +1 -1
  18. package/dist/assets/{index-Pdg5xeG3.js → index-D-y76fV7.js} +3 -3
  19. package/dist/assets/{key-bindings-CtvDqQLt.js → key-bindings-C3rMnRos.js} +1 -1
  20. package/dist/assets/{query-debug-B3pFyO8g.js → query-debug-CZacGe0M.js} +1 -1
  21. package/dist/assets/{registry-DxI6UTog.js → registry-BEyieXxp.js} +2 -2
  22. package/dist/assets/{settings-DihHqno3.js → settings-BZsdOcHy.js} +1 -1
  23. package/dist/assets/{settings-CC0TLN6V.js → settings-CFbSvlXK.js} +1 -1
  24. package/dist/assets/{settings-CG6tAbxu.js → settings-DD2zxZ8C.js} +1 -1
  25. package/dist/assets/{settings-CRzyZEHb.js → settings-QL_HG2aL.js} +1 -1
  26. package/dist/assets/{share-target-virrjHzV.js → share-target-pA9r0Obg.js} +1 -1
  27. package/dist/assets/{shared-Db_2ZVQH.js → shared-ZTRGU8MK.js} +1 -1
  28. package/dist/assets/{use-canvas-pins-BZMaPpb7.js → use-canvas-pins-D-zi5fqQ.js} +1 -1
  29. package/dist/assets/{useAgentModels-DPu0MHiH.js → useAgentModels-fXPBeHX2.js} +1 -1
  30. package/dist/assets/{workspace-area-menu-COdiU0Xn.js → workspace-area-menu-DtsodEXC.js} +1 -1
  31. package/dist/assets/{workspaces-CNtUJTgB.js → workspaces-BZ395Y1p.js} +1 -1
  32. package/dist/index.html +6 -6
  33. package/dist/sw.js +1 -1
  34. package/package.json +2 -2
  35. package/dist/assets/backend-sync-progress-DyvV8N9D.js +0 -7
@@ -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{dt as r,ft as i,ut as a}from"./index-Pdg5xeG3.js";import{n as o}from"./page-header-BoCaZiqu.js";import{t as s}from"./use-settings-back-DE0SPb7h.js";var c=e(n(),1),l=t();function u(){let[e,t]=(0,c.useState)(r),[n,u]=(0,c.useState)(``),d=e=>{if(e.previousTree&&e.previousTree===e.nextTree){u(`Choose a different shortcut: that combination is already assigned.`);return}try{i(e),t(e),u(`Saved on this device.`)}catch{u(`Could not save shortcuts in this browser.`)}};return(0,l.jsxs)(`div`,{className:`mx-auto max-w-4xl`,children:[(0,l.jsx)(o,{className:`mb-6`,title:`Key bindings`,onBack:s(),description:`Web UI shortcuts, saved on this device and available offline.`}),(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`font-medium`,children:`Tree navigation`}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Cycle the open workspace menu’s tabs in their displayed order, including Pins and Layers. Swipe left for next or right for previous over the tab bar. Shortcuts pause while typing or using a dialog.`}),[`previousTree`,`nextTree`].map(t=>(0,l.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,l.jsx)(`label`,{htmlFor:t,className:`min-w-32 text-sm`,children:t===`previousTree`?`Previous tree`:`Next tree`}),(0,l.jsxs)(`select`,{id:t,className:`rounded-md border bg-background p-2 text-sm`,value:e[t].split(`+`).slice(0,-1).join(`+`),onChange:n=>d({...e,[t]:n.target.value?`${n.target.value}+${e[t].slice(-1)||a[t].slice(-1)}`:``}),children:[(0,l.jsx)(`option`,{value:``,children:`Disabled`}),[`Alt`,`Alt+Shift`,`Ctrl+Shift`,`Meta+Shift`].map(e=>(0,l.jsx)(`option`,{value:e,children:e},e))]}),(0,l.jsx)(`select`,{"aria-label":`${t===`previousTree`?`Previous`:`Next`} tree key`,disabled:!e[t],className:`rounded-md border bg-background p-2 text-sm disabled:opacity-50`,value:e[t].slice(-1)||a[t].slice(-1),onChange:n=>d({...e,[t]:`${e[t].split(`+`).slice(0,-1).join(`+`)}+${n.target.value}`}),children:`ABCDEFGHIJKLMNOPQRSTUVWXYZ`.split(``).map(e=>(0,l.jsx)(`option`,{value:e,children:e},e))})]},t)),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Browsers and operating systems may reserve combinations. Choose another if a shortcut does not reach Canvas. Letters refer to physical keyboard positions (Q/W on a US keyboard); Meta is Command on Mac.`}),(0,l.jsx)(`button`,{type:`button`,className:`rounded-md border px-3 py-2 text-sm hover:bg-accent`,onClick:()=>d({...a}),children:`Restore defaults`}),(0,l.jsx)(`p`,{role:`status`,className:`text-sm`,children:n})]})]})}export{u 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{dt as r,ft as i,ut as a}from"./index-D-y76fV7.js";import{n as o}from"./page-header-BoCaZiqu.js";import{t as s}from"./use-settings-back-DE0SPb7h.js";var c=e(n(),1),l=t();function u(){let[e,t]=(0,c.useState)(r),[n,u]=(0,c.useState)(``),d=e=>{if(e.previousTree&&e.previousTree===e.nextTree){u(`Choose a different shortcut: that combination is already assigned.`);return}try{i(e),t(e),u(`Saved on this device.`)}catch{u(`Could not save shortcuts in this browser.`)}};return(0,l.jsxs)(`div`,{className:`mx-auto max-w-4xl`,children:[(0,l.jsx)(o,{className:`mb-6`,title:`Key bindings`,onBack:s(),description:`Web UI shortcuts, saved on this device and available offline.`}),(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`font-medium`,children:`Tree navigation`}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Cycle the open workspace menu’s tabs in their displayed order, including Pins and Layers. Swipe left for next or right for previous over the tab bar. Shortcuts pause while typing or using a dialog.`}),[`previousTree`,`nextTree`].map(t=>(0,l.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,l.jsx)(`label`,{htmlFor:t,className:`min-w-32 text-sm`,children:t===`previousTree`?`Previous tree`:`Next tree`}),(0,l.jsxs)(`select`,{id:t,className:`rounded-md border bg-background p-2 text-sm`,value:e[t].split(`+`).slice(0,-1).join(`+`),onChange:n=>d({...e,[t]:n.target.value?`${n.target.value}+${e[t].slice(-1)||a[t].slice(-1)}`:``}),children:[(0,l.jsx)(`option`,{value:``,children:`Disabled`}),[`Alt`,`Alt+Shift`,`Ctrl+Shift`,`Meta+Shift`].map(e=>(0,l.jsx)(`option`,{value:e,children:e},e))]}),(0,l.jsx)(`select`,{"aria-label":`${t===`previousTree`?`Previous`:`Next`} tree key`,disabled:!e[t],className:`rounded-md border bg-background p-2 text-sm disabled:opacity-50`,value:e[t].slice(-1)||a[t].slice(-1),onChange:n=>d({...e,[t]:`${e[t].split(`+`).slice(0,-1).join(`+`)}+${n.target.value}`}),children:`ABCDEFGHIJKLMNOPQRSTUVWXYZ`.split(``).map(e=>(0,l.jsx)(`option`,{value:e,children:e},e))})]},t)),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Browsers and operating systems may reserve combinations. Choose another if a shortcut does not reach Canvas. Letters refer to physical keyboard positions (Q/W on a US keyboard); Meta is Command on Mac.`}),(0,l.jsx)(`button`,{type:`button`,className:`rounded-md border px-3 py-2 text-sm hover:bg-accent`,onClick:()=>d({...a}),children:`Restore defaults`}),(0,l.jsx)(`p`,{role:`status`,className:`text-sm`,children:n})]})]})}export{u 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{Kn as r,Tt as i,X as a,ar as o,gr as s,kt as c}from"./ui-76Hw0NU_.js";import{t as l}from"./button-Bum-POPT.js";import{t as u}from"./input-BOtCd4HP.js";import{t as d}from"./api-CA6WiiYM.js";import{n as f}from"./use-toast-BlLDqSUO.js";import{h as p,o as m,s as h}from"./LinkToCard-VXpoeMDH.js";import{$t as g,An as _,F as v,Q as y,gn as b,ht as x,xt as S,yt as C}from"./workspace-46EFyEKZ.js";import{a as w,c as T,l as E,n as D,o as O,r as k,u as A}from"./backend-sync-progress-DyvV8N9D.js";import{t as j}from"./workspace-access-C9nZlBBZ.js";var M=e(n(),1),N={membership:`keep`,propagation:`never`,targets:[],acceptPropagatedDeletions:!1},P=e=>`/workspaces/${encodeURIComponent(e)}/trash/operations`,F=(e,t)=>d.get(`${P(e)}?${new URLSearchParams(Object.entries(t).map(([e,t])=>[e,String(t)]))}`),I=(e,t,n,r={})=>d.post(`${P(e)}/${n}`,{ids:t,...r}),L=(e,t,n,r)=>d.patch(`/workspaces/${encodeURIComponent(e)}/backends/imap/${encodeURIComponent(t)}/containers/${encodeURIComponent(n)}`,{removalPolicy:r}),R=t();function z(e){let t=T(`backends`,e.path)?.backend;return(0,R.jsx)(B,{...e},JSON.stringify([e.workspace,t]))}function B({workspace:e,path:t,onNavigate:n}){let l=T(`backends`,t),u=l.backend,d=l.prefix,[f,g]=(0,M.useState)(null),[_,v]=(0,M.useState)(null),y=(0,M.useRef)(!1),[b,x]=(0,M.useState)(null),[S,j]=(0,M.useState)(null),[N,P]=(0,M.useState)(0),[F,I]=(0,M.useState)(new Set),[L,z]=(0,M.useState)(null),B=(0,M.useCallback)(()=>P(e=>e+1),[]),[V,H]=(0,M.useState)(t);V!==t&&(H(t),I(new Set),z(null),j(null),x(null));let U=f?.revision!==N,W=U?[]:f.items,G=U?[]:f.backends,K=f?.days;(0,M.useEffect)(()=>{let t=!1;return(u?w(e,u).then(e=>({...e,backends:[]})):C(e).then(e=>({items:[],days:null,backends:e.filter(e=>e.driver===`file`&&e.enabled!==!1)}))).then(e=>{t||g({...e,revision:N,error:null})}).catch(e=>{t||g({revision:N,items:[],backends:[],days:null,error:e instanceof Error?e.message:String(e)})}),()=>{t=!0}},[e,u,N]),(0,M.useEffect)(()=>{let t=null,n=n=>{let r=n.detail;r?.workspaceName&&r.workspaceName!==e||r?.treeName&&r.treeName!==`backends`||(t||=setTimeout(()=>{t=null,B()},500))};return window.addEventListener(`workspace:trash:refresh`,n),window.addEventListener(`workspace:tree:refresh`,n),()=>{window.removeEventListener(`workspace:trash:refresh`,n),window.removeEventListener(`workspace:tree:refresh`,n),t&&clearTimeout(t)}},[e,B]);let q=A(W,d),J=async(t,n)=>{if(!(!u||y.current||U||!n.length)&&!(t===`discard`&&!D(u,n))){y.current=!0,v(t),x(null),j(null),z(null);try{let r=await(t===`restore`?O:k)(e,u,[...n].sort((e,t)=>t.deletedAt-e.deletedAt).map(e=>e.id)),i=r.filter(e=>!e.ok);j(`${r.length-i.length} item(s) ${t===`restore`?`restored to their original paths`:`permanently deleted`}.`),i.length&&x(`${i.length} item(s) remain in Trash. ${i.slice(0,3).map(e=>`${e.key||`Item`}: ${e.reason===`precondition-failed`||e.reason===`target-exists`?`original path is occupied`:e.message||e.reason}`).join(`; `)}`),I(new Set)}catch(e){x(e instanceof Error?e.message:String(e))}finally{y.current=!1,v(null),B()}}},Y=(e,t,n)=>z({x:e,y:t,row:n});return(0,R.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-background`,"aria-label":`Backend Trash`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 border-b px-4 py-3`,children:[(0,R.jsx)(a,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,R.jsx)(h,{items:m(t,e).map((e,t)=>t===2&&u?{...e,label:u}:e),onNavigate:n,className:`basis-48`}),(0,R.jsxs)(`div`,{className:`ml-auto flex max-w-full flex-wrap items-center gap-2`,children:[F.size>0&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`button`,{className:`flex items-center gap-1 rounded border px-2 py-1 text-sm disabled:opacity-50`,disabled:!!_||U,onClick:()=>void J(`restore`,q.filter(e=>F.has(e.id)).flatMap(e=>e.items)),children:[(0,R.jsx)(i,{className:`h-3.5 w-3.5`}),`Restore selected`]}),(0,R.jsxs)(`button`,{className:`flex items-center gap-1 rounded border px-2 py-1 text-sm text-destructive disabled:opacity-50`,disabled:!!_||U,onClick:()=>void J(`discard`,q.filter(e=>F.has(e.id)).flatMap(e=>e.items)),children:[(0,R.jsx)(a,{className:`h-3.5 w-3.5`}),`Delete selected`]})]}),u&&q.length>0&&(0,R.jsxs)(`button`,{className:`flex items-center gap-1 rounded border px-2 py-1 text-sm text-destructive disabled:opacity-50`,disabled:!!_||U,onClick:()=>void J(`discard`,q.flatMap(e=>e.items)),children:[(0,R.jsx)(a,{className:`h-3.5 w-3.5`}),d?`Empty this folder`:`Empty Trash`]}),(0,R.jsx)(`button`,{title:`Refresh Trash`,"aria-label":`Refresh Trash`,className:`rounded p-2 hover:bg-accent`,disabled:!!_||U,onClick:B,children:(0,R.jsx)(c,{className:`h-4 w-4 ${U?`animate-spin`:``}`})})]})]}),(0,R.jsxs)(`div`,{className:`border-b px-4 py-2 text-xs text-muted-foreground`,children:[`Restore files and folders to their original paths. Existing files are kept.`,K?` Deleted items are kept for ${K} days.`:``]}),S&&(0,R.jsx)(`p`,{role:`status`,className:`px-4 py-2 text-sm`,children:S}),(b||f?.error)&&(0,R.jsx)(`p`,{role:`alert`,className:`px-4 py-2 text-sm text-destructive`,children:b||f?.error}),_&&(0,R.jsx)(`p`,{role:`status`,className:`px-4 py-2 text-sm`,children:_===`restore`?`Restoring…`:`Deleting permanently…`}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:U?(0,R.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading Trash…`}):u?q.length===0?(0,R.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`This Trash folder is empty.`}):(0,R.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,R.jsx)(`thead`,{className:`border-b text-xs text-muted-foreground`,children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{className:`w-8 p-2`,children:(0,R.jsx)(`input`,{type:`checkbox`,"aria-label":`Select all visible items`,checked:q.length>0&&q.every(e=>F.has(e.id)),onChange:e=>I(e.target.checked?new Set(q.map(e=>e.id)):new Set)})}),(0,R.jsx)(`th`,{className:`p-2`,children:`Name`}),(0,R.jsx)(`th`,{className:`p-2 max-sm:hidden`,children:`Original path`}),(0,R.jsx)(`th`,{className:`p-2 max-md:hidden`,children:`Deleted`}),(0,R.jsx)(`th`,{className:`p-2`,children:(0,R.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]})}),(0,R.jsx)(`tbody`,{children:q.map(e=>(0,R.jsxs)(`tr`,{className:`border-b border-border/50 hover:bg-accent/50`,onContextMenu:t=>{t.preventDefault(),Y(t.clientX,t.clientY,e)},onDoubleClick:()=>e.navigable&&n(E(u,e.key)),children:[(0,R.jsx)(`td`,{className:`p-2`,children:(0,R.jsx)(`input`,{type:`checkbox`,"aria-label":`Select ${e.name}`,checked:F.has(e.id),disabled:!!_,onChange:t=>I(n=>{let r=new Set(n);return t.target.checked?r.add(e.id):r.delete(e.id),r})})}),(0,R.jsx)(`td`,{className:`p-2`,children:(0,R.jsxs)(`button`,{className:`flex items-center gap-2 text-left`,onClick:()=>e.navigable&&n(E(u,e.key)),children:[e.directory?(0,R.jsx)(r,{className:`h-4 w-4 shrink-0`}):(0,R.jsx)(o,{className:`h-4 w-4 shrink-0`}),(0,R.jsxs)(`span`,{children:[e.name,e.navigable&&(0,R.jsxs)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:[e.items.length,` items`]})]})]})}),(0,R.jsx)(`td`,{className:`p-2 text-xs text-muted-foreground max-sm:hidden`,children:e.key}),(0,R.jsx)(`td`,{className:`p-2 text-xs text-muted-foreground max-md:hidden`,children:new Date(e.items.reduce((e,t)=>Math.max(e,t.deletedAt),0)).toLocaleString()}),(0,R.jsx)(`td`,{className:`p-2 text-right`,children:(0,R.jsx)(`button`,{title:`Actions for ${e.name}`,"aria-label":`Actions for ${e.name}`,disabled:!!_,className:`rounded p-2 hover:bg-accent`,onClick:t=>Y(t.clientX,t.clientY,e),children:(0,R.jsx)(s,{className:`h-4 w-4`})})})]},e.id))})]}):(0,R.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-3`,children:[G.map(e=>(0,R.jsxs)(`button`,{onClick:()=>n(E(e.address)),className:`flex items-center gap-3 rounded-lg border p-4 text-left hover:bg-accent`,children:[(0,R.jsx)(a,{className:`h-6 w-6 text-muted-foreground`}),(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`span`,{className:`block text-sm font-medium`,children:e.label||e.address}),(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.address})]})]},e.address)),!G.length&&(0,R.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`No file backends are available.`})]})}),L&&(0,R.jsxs)(p,{x:L.x,y:L.y,onClose:()=>z(null),className:`min-w-44 rounded-md border bg-popover p-1 shadow-elevation-3`,children:[L.row.navigable&&(0,R.jsxs)(`button`,{className:`flex w-full items-center gap-2 rounded px-3 py-2 text-sm hover:bg-accent`,onClick:()=>{n(E(u,L.row.key)),z(null)},children:[(0,R.jsx)(r,{className:`h-4 w-4`}),`Open folder`]}),(0,R.jsxs)(`button`,{disabled:!!_,className:`flex w-full items-center gap-2 rounded px-3 py-2 text-sm hover:bg-accent disabled:opacity-50`,onClick:()=>void J(`restore`,L.row.items),children:[(0,R.jsx)(i,{className:`h-4 w-4`}),`Restore `,L.row.directory?`folder`:`file`]}),(0,R.jsxs)(`button`,{disabled:!!_||U,className:`flex w-full items-center gap-2 rounded px-3 py-2 text-sm text-destructive hover:bg-destructive/10 disabled:opacity-50`,onClick:()=>void J(`discard`,L.row.items),children:[(0,R.jsx)(a,{className:`h-4 w-4`}),`Delete permanently`]})]})]})}function V({value:e,backends:t,source:n,onSave:r,destination:i=!0}){let[a,o]=(0,M.useState)({...N,...e}),[s,c]=(0,M.useState)(!1),[u,d]=(0,M.useState)(``),f=`rounded border bg-background px-2 py-1.5 text-xs w-full`,p=async()=>{c(!0),d(``);try{await r(a),d(`Removal policy saved.`)}catch(e){d(e instanceof Error?e.message:`Could not save policy`)}finally{c(!1)}};return(0,R.jsxs)(`details`,{className:`border-t pt-3 text-xs`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer font-medium`,children:`Source removals and Trash`}),(0,R.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:`A completed scan removes missing locations from the backend tree. Items with no remaining locations go to Trash until you purge them.`}),(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`label`,{className:`space-y-1 block`,children:[`When an item disappears from this source`,(0,R.jsxs)(`select`,{className:f,value:a.membership,disabled:s,onChange:e=>o({...a,membership:e.target.value}),children:[(0,R.jsx)(`option`,{value:`keep`,children:`Keep in managed trees`}),(0,R.jsx)(`option`,{value:`review`,children:`Review removal in Trash`}),(0,R.jsx)(`option`,{value:`trash`,children:`Move to Trash automatically`})]})]}),(0,R.jsxs)(`label`,{className:`space-y-1 block`,children:[`Remove tracked copies from other backends`,(0,R.jsxs)(`select`,{className:f,value:a.propagation,disabled:s,onChange:e=>o({...a,propagation:e.target.value}),children:[(0,R.jsx)(`option`,{value:`never`,children:`Never`}),(0,R.jsx)(`option`,{value:`review`,children:`Review in Trash`}),(0,R.jsx)(`option`,{value:`automatic`,children:`Automatically, retaining recovery copies`})]})]})]}),a.propagation!==`never`&&(0,R.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,R.jsx)(`legend`,{className:`mb-1 font-medium`,children:`Destinations`}),(0,R.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:a.targets===`all`,disabled:s,onChange:e=>o({...a,targets:e.target.checked?`all`:[]})}),`All eligible backends`]}),a.targets!==`all`&&t.filter(e=>e.address!==n&&e.kind===`storage`).map(e=>(0,R.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`checkbox`,disabled:s||e.config?.propagatedRemovalSupported!==!0,checked:a.targets.includes(e.address),onChange:t=>o({...a,targets:t.target.checked?[...a.targets,e.address]:a.targets.filter(t=>t!==e.address)})}),String(e.config?.label||e.address),e.config?.propagatedRemovalSupported===!0?!e.config?.removalPolicy?.acceptPropagatedDeletions&&` · protected`:` · recovery removal unavailable`]},e.address)),(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:`Only tracked, Canvas-owned copies are eligible. Protected destinations refuse propagated deletion. Recovery removal currently supports filesystem and workspace blob storage; remote destinations remain protected.`})]}),i&&(0,R.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`checkbox`,disabled:s,checked:a.acceptPropagatedDeletions,onChange:e=>o({...a,acceptPropagatedDeletions:e.target.checked})}),`Accept propagated deletions on this backend`]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(l,{size:`sm`,variant:`outline`,disabled:s,onClick:()=>void p(),children:s?`Saving…`:`Save removal policy`}),(0,R.jsx)(`span`,{role:`status`,children:u})]})]})]})}function H({workspaceName:e,canWrite:t}){let{showToast:n}=f(),[r,o]=(0,M.useState)([]),[s,u]=(0,M.useState)(!1),[d,p]=(0,M.useState)([]),[m,h]=(0,M.useState)(!1),y=(0,M.useCallback)(async()=>{u(!0);try{o(await S(e))}catch(e){n({title:`Error`,description:e instanceof Error?e.message:`Failed to load the trash`,variant:`destructive`})}finally{u(!1)}},[e]);(0,M.useEffect)(()=>{y()},[y]);let b=(0,M.useCallback)(e=>d.includes(e),[d]),x=async(e,t)=>{p(t=>[...t,...e]);try{await t()}finally{p(t=>t.filter(t=>!e.includes(t)))}},C=t=>x([t.id],async()=>{try{let r=await g(e,[t.id]);r.failed?.length?n({title:`Not restored`,description:r.failed[0]?.error||`No restore target recorded`,variant:`destructive`}):(n({title:`Restored`,description:`Document put back where it was.`}),o(e=>e.filter(e=>e.id!==t.id)))}catch(e){n({title:`Error`,description:e instanceof Error?e.message:`Failed to restore`,variant:`destructive`})}}),w=t=>x([t.id],async()=>{try{let r=await v(e,[t.id]);if(r.failed?.length)throw Error(`The item could not be purged. Refresh and retry.`);n({title:`Cleared from Trash`,description:r.preserved?.length?`Existing backend copies remain indexed.`:`Document permanently deleted.`}),o(e=>e.filter(e=>e.id!==t.id))}catch(e){n({title:`Error`,description:e instanceof Error?e.message:`Failed to delete`,variant:`destructive`})}}),T=async()=>{if(!m){h(!0);return}h(!1);try{let t=await v(e);n({title:`Trash emptied`,description:`${t.destroyed?.length??0} document(s) purged. ${t.preserved?.length??0} item(s) cleared with backend copies preserved.`}),await y()}catch(e){n({title:`Error`,description:e instanceof Error?e.message:`Failed to empty the trash`,variant:`destructive`})}},E=(0,M.useMemo)(()=>r.map(e=>{let t=_(e),n=(e.trashed?.placements??[]).flatMap(e=>e.paths.map(t=>`${e.tree}:${t}`));return{document:e,title:t.title,origin:n,trashedAt:e.trashed?.trashedAt||null}}),[r]);return(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between sm:gap-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h2`,{className:`text-sm font-medium`,children:`Managed-tree items`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1 max-w-2xl`,children:`Restore managed-tree placements or permanently purge these items. Pending removals require separate approval. Backend copies are managed below.`})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 max-sm:flex-wrap`,children:[(0,R.jsxs)(l,{variant:`outline`,size:`sm`,onClick:()=>y(),disabled:s,children:[(0,R.jsx)(c,{className:`mr-2 h-3.5 w-3.5 ${s?`animate-spin`:``}`}),`Refresh`]}),(0,R.jsxs)(l,{variant:m?`destructive`:`outline`,size:`sm`,onClick:T,onBlur:()=>h(!1),disabled:!t||r.length===0,children:[(0,R.jsx)(a,{className:`mr-2 h-3.5 w-3.5`}),m?`Click again to delete everything`:`Empty trash`]})]})]}),s&&r.length===0&&(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading…`}),!s&&r.length===0&&(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The trash is empty.`}),E.length>0&&(0,R.jsx)(`div`,{className:`border rounded-md divide-y`,children:E.map(({document:e,title:n,origin:r,trashedAt:o})=>(0,R.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`div`,{className:`truncate text-sm`,children:n}),(0,R.jsxs)(`div`,{className:`truncate text-xs text-muted-foreground`,children:[r.length>0?`from ${r.join(`, `)}`:`no recorded origin`,o?` · ${new Date(o).toLocaleString()}`:``]})]}),(0,R.jsxs)(l,{variant:`outline`,size:`sm`,onClick:()=>C(e),disabled:!t||b(e.id)||r.length===0,title:r.length===0?`Nothing recorded to restore to`:`Put it back where it was`,children:[(0,R.jsx)(i,{className:`mr-2 h-3.5 w-3.5`}),`Restore placements`]}),(0,R.jsx)(l,{variant:`ghost`,size:`sm`,onClick:()=>w(e),disabled:!t||b(e.id),title:`Delete permanently`,children:(0,R.jsx)(a,{className:`h-3.5 w-3.5`})})]},e.id))})]})}function U({workspaceName:e}){return(0,R.jsx)(W,{workspaceName:e},e)}function W({workspaceName:e}){let[t,n]=(0,M.useState)(`pending`),[r,i]=(0,M.useState)(``),[a,o]=(0,M.useState)(``),[s,d]=(0,M.useState)(0),[f,p]=(0,M.useState)(0),[m,h]=(0,M.useState)(null),[g,_]=(0,M.useState)(``),[v,S]=(0,M.useState)(!1),[w,T]=(0,M.useState)(new Set),[E,D]=(0,M.useState)({}),[O,k]=(0,M.useState)(`/Trash`),[A,P]=(0,M.useState)([]),[B,U]=(0,M.useState)({write:!1,admin:!1});(0,M.useEffect)(()=>{let t=!0;return y(e).then(e=>{let n=e.remote?.permissions||e.access?.permissions||(typeof e.sharedVia==`object`?e.sharedVia?.permissions:[])||[],r=j(e);t&&U({admin:r,write:r||n.includes(`write`)})}).catch(()=>{}),()=>{t=!1}},[e]);let[W,G]=(0,M.useState)(null);(0,M.useEffect)(()=>{let t=!0;return C(e).then(e=>{t&&P(e)}).catch(()=>{}),()=>{t=!1}},[e]),(0,M.useEffect)(()=>{let n=!1,i=()=>F(e,{view:t,search:r,...a?{backend:a}:{},offset:s}).then(e=>{n||(h(e),_(``))}).catch(e=>{n||_(e instanceof Error?e.message:`Could not load Trash`)});i();let o=setInterval(()=>{v||i()},5e3);return()=>{n=!0,clearInterval(o)}},[e,t,r,a,s,f,v]);let K=m?.operations||[],q=()=>{T(new Set),p(e=>e+1)},J=()=>{x(e),window.dispatchEvent(new CustomEvent(`workspace:tree:refresh`,{detail:{workspaceName:e}})),window.dispatchEvent(new CustomEvent(`workspace:trash:refresh`,{detail:{workspaceName:e}}))},Y=async(t,n=[...w])=>{if(!(!n.length||v)&&!(t===`purge`&&!window.confirm(`Permanently delete retained recovery copies for ${n.length} operation(s)?`))){S(!0),_(``);try{let r=(t===`approve`?(await Promise.all(n.map(n=>I(e,[n],t,E[n])))).flatMap(e=>e.results):(await I(e,n,t)).results).filter(e=>!e.ok||e.operation?.state===`failed`);r.length&&_(r.map(e=>e.error||e.operation?.error||`A destination could not be changed. Expand the item for details.`).join(` `)),J(),q()}catch(e){_(e instanceof Error?e.message:`Trash action failed`)}finally{S(!1)}}},X=e=>{n(e),d(0),h(null),T(new Set),D({})};return(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h2`,{className:`text-base font-semibold`,children:`Workspace Trash`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Review source removals, recover items, and see what automatic policies changed.`})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,role:`tablist`,"aria-label":`Trash views`,children:[[[`pending`,`Pending removal`],[`trashed`,`In Trash`],[`activity`,`Activity`]].map(([e,n])=>(0,R.jsx)(l,{role:`tab`,"aria-selected":t===e,size:`sm`,variant:t===e?`default`:`outline`,onClick:()=>X(e),children:n},e)),(0,R.jsxs)(l,{size:`sm`,variant:`ghost`,className:`ml-auto`,onClick:q,disabled:v,children:[(0,R.jsx)(c,{className:`mr-2 h-3.5 w-3.5`}),`Refresh`]})]}),t===`trashed`&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(H,{workspaceName:e,canWrite:B.write},f),(0,R.jsxs)(`details`,{className:`rounded border p-3`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:`Browse backend recovery copies`}),(0,R.jsx)(`div`,{className:`mt-3 min-h-48`,children:(0,R.jsx)(z,{workspace:e,path:O,onNavigate:k})})]})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,R.jsx)(u,{"aria-label":`Filter Trash items`,placeholder:`Filter by item or path…`,className:`max-w-xs`,value:r,onChange:e=>{i(e.target.value),h(null),d(0),T(new Set)}}),(0,R.jsx)(u,{"aria-label":`Filter by backend`,placeholder:`Backend name…`,className:`max-w-56`,value:a,onChange:e=>{o(e.target.value),h(null),d(0),T(new Set)}}),w.size>0&&(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,R.jsxs)(`span`,{children:[w.size,` selected`]}),t===`pending`&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(l,{size:`sm`,disabled:v,onClick:()=>void Y(`approve`),children:`Approve selected`}),(0,R.jsx)(l,{size:`sm`,variant:`outline`,disabled:v,onClick:()=>void Y(`keep`),children:`Keep selected`}),(0,R.jsx)(l,{size:`sm`,variant:`outline`,disabled:v,onClick:()=>void Y(`retry`),children:`Retry`})]}),t===`trashed`&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(l,{size:`sm`,variant:`outline`,disabled:v,onClick:()=>void Y(`restore`),children:`Restore copies`}),(0,R.jsx)(l,{size:`sm`,variant:`destructive`,disabled:v,onClick:()=>void Y(`purge`),children:`Purge copies`})]})]})]}),W&&(0,R.jsxs)(`div`,{className:`rounded border p-3 space-y-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsxs)(`p`,{className:`text-sm font-medium`,children:[`Removal policy · `,W.source.account||W.source.backend,W.source.folder?` / ${W.source.folder}`:``]}),(0,R.jsx)(l,{size:`sm`,variant:`ghost`,onClick:()=>G(null),children:`Close`})]}),(0,R.jsx)(V,{source:W.source.backend,backends:A,destination:!1,value:{...N,...A.find(e=>e.address===W.source.backend)?.config?.removalPolicy,membership:E[W.id]?.membership??W.membership!==`keep`?`review`:`keep`,propagation:W.targets.length?`review`:`never`,targets:[...new Set(W.targets.filter(e=>!E[W.id]||E[W.id].targets.includes(JSON.stringify([e.backend,e.key]))).map(e=>e.backend))]},onSave:async t=>{W.source.driver===`imap`?await L(e,W.source.account,W.source.folder,t):await b(e,W.source.driver,W.source.backend,{removalPolicy:t}),P(await C(e))}},W.id)]}),g&&(0,R.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:g}),(0,R.jsxs)(`div`,{className:`overflow-x-auto rounded border`,children:[(0,R.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,R.jsx)(`thead`,{className:`bg-muted`,children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{className:`p-3 w-8`,children:(0,R.jsx)(`input`,{type:`checkbox`,"aria-label":`Select visible operations`,disabled:!B.write||v||!K.length||t===`activity`,checked:K.length>0&&K.every(e=>w.has(e.id)),onChange:e=>T(e.target.checked?new Set(K.map(e=>e.id)):new Set)})}),(0,R.jsx)(`th`,{className:`p-3`,children:`Item and affected copies`}),(0,R.jsx)(`th`,{className:`p-3`,children:`Source`}),(0,R.jsx)(`th`,{className:`p-3`,children:`Status`}),(0,R.jsx)(`th`,{className:`p-3`,children:`Detected`})]})}),(0,R.jsx)(`tbody`,{children:K.map(e=>{let n=E[e.id]||{targets:e.targets.filter(e=>e.state!==`kept`).map(e=>JSON.stringify([e.backend,e.key])),membership:e.membership!==`keep`};return(0,R.jsxs)(`tr`,{className:`border-t align-top`,children:[(0,R.jsx)(`td`,{className:`p-3`,children:(0,R.jsx)(`input`,{type:`checkbox`,"aria-label":`Select ${e.title}`,disabled:!B.write||v||t===`activity`,checked:w.has(e.id),onChange:t=>T(n=>{let r=new Set(n);return t.target.checked?r.add(e.id):r.delete(e.id),r})})}),(0,R.jsx)(`td`,{className:`p-3 min-w-64`,children:(0,R.jsxs)(`details`,{children:[(0,R.jsx)(`summary`,{className:`cursor-pointer font-medium`,children:e.title}),(0,R.jsxs)(`div`,{className:`mt-2 space-y-2 text-muted-foreground`,children:[(0,R.jsx)(`p`,{children:e.orphan?`No remaining byte locations. Restore placements only unless recovery bytes are available.`:`${e.remainingLocations.length} remaining location(s) when detected.`}),e.placements.map(e=>(0,R.jsxs)(`p`,{children:[e.tree,`: `,e.paths.join(`, `)]},e.tree)),e.membership!==`keep`&&(0,R.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:n.membership,disabled:v||t!==`pending`||e.membershipApplied,onChange:t=>D({...E,[e.id]:{...n,membership:t.target.checked}})}),e.membershipApplied?`Managed placements moved to Trash`:`Move managed placements to Trash`]}),e.targets.map(r=>{let i=JSON.stringify([r.backend,r.key]);return(0,R.jsxs)(`label`,{className:`flex items-start gap-2`,children:[(0,R.jsx)(`input`,{type:`checkbox`,disabled:v||t!==`pending`||!!r.trashId,checked:n.targets.includes(i),onChange:t=>D({...E,[e.id]:{...n,targets:t.target.checked?[...n.targets,i]:n.targets.filter(e=>e!==i)}})}),(0,R.jsxs)(`span`,{className:`break-all`,children:[r.backend,`:`,r.key,` · `,r.state,r.error&&(0,R.jsx)(`span`,{className:`block text-destructive`,children:r.error})]})]},i)}),(0,R.jsx)(l,{size:`sm`,variant:`outline`,disabled:!B.admin,onClick:()=>G(e),children:`Use these choices as a source policy`}),e.remainingLocations.map(e=>(0,R.jsx)(`p`,{className:`break-all`,children:e.url},e.url))]})]})}),(0,R.jsxs)(`td`,{className:`p-3 break-all`,children:[e.source.account||e.source.backend,e.source.folder&&(0,R.jsx)(`span`,{className:`block text-muted-foreground`,children:e.source.folder})]}),(0,R.jsxs)(`td`,{className:`p-3`,children:[e.state,e.error&&(0,R.jsx)(`p`,{className:`mt-1 max-w-xs text-destructive`,children:e.error})]}),(0,R.jsx)(`td`,{className:`p-3 whitespace-nowrap text-muted-foreground`,children:new Date(e.createdAt).toLocaleString()})]},e.id)})})]}),!K.length&&(0,R.jsx)(`p`,{className:`p-5 text-center text-sm text-muted-foreground`,children:m?`No matching operations.`:`Loading…`})]}),(0,R.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,R.jsxs)(`span`,{children:[m?.total??0,` operation(s)`]}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(l,{size:`sm`,variant:`outline`,disabled:!s||v,onClick:()=>{d(Math.max(0,s-200)),T(new Set)},children:`Previous`}),(0,R.jsx)(l,{size:`sm`,variant:`outline`,disabled:s+K.length>=(m?.total??0)||v,onClick:()=>{d(s+200),T(new Set)},children:`Next`})]})]})]})}var G=`canvas:query-debug`,K=`canvas:query-debug-changed`;function q(){try{return localStorage.getItem(G)===`1`}catch{return!1}}function J(e){try{e?localStorage.setItem(G,`1`):localStorage.removeItem(G)}catch{}window.dispatchEvent(new CustomEvent(K,{detail:e}))}function Y(){let[e,t]=(0,M.useState)(q);return(0,M.useEffect)(()=>{let e=()=>t(q());return window.addEventListener(K,e),window.addEventListener(`storage`,e),()=>{window.removeEventListener(K,e),window.removeEventListener(`storage`,e)}},[]),e}export{V as a,U as i,J as n,z as o,Y as r,L as s,q 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{Kn as r,Tt as i,X as a,ar as o,gr as s,kt as c}from"./ui-76Hw0NU_.js";import{t as l}from"./button-Bum-POPT.js";import{t as u}from"./input-BOtCd4HP.js";import{t as d}from"./api-CA6WiiYM.js";import{n as f}from"./use-toast-BlLDqSUO.js";import{h as p,o as m,s as h}from"./LinkToCard-VXpoeMDH.js";import{$t as g,An as _,F as v,Q as y,gn as b,ht as x,xt as S,yt as C}from"./workspace-46EFyEKZ.js";import{a as w,c as T,l as E,n as D,o as O,r as k,u as A}from"./backend-sync-progress-BJsLP7o5.js";import{t as j}from"./workspace-access-C9nZlBBZ.js";var M=e(n(),1),N={membership:`keep`,propagation:`never`,targets:[],acceptPropagatedDeletions:!1},P=e=>`/workspaces/${encodeURIComponent(e)}/trash/operations`,F=(e,t)=>d.get(`${P(e)}?${new URLSearchParams(Object.entries(t).map(([e,t])=>[e,String(t)]))}`),I=(e,t,n,r={})=>d.post(`${P(e)}/${n}`,{ids:t,...r}),L=(e,t,n,r)=>d.patch(`/workspaces/${encodeURIComponent(e)}/backends/imap/${encodeURIComponent(t)}/containers/${encodeURIComponent(n)}`,{removalPolicy:r}),R=t();function z(e){let t=T(`backends`,e.path)?.backend;return(0,R.jsx)(B,{...e},JSON.stringify([e.workspace,t]))}function B({workspace:e,path:t,onNavigate:n}){let l=T(`backends`,t),u=l.backend,d=l.prefix,[f,g]=(0,M.useState)(null),[_,v]=(0,M.useState)(null),y=(0,M.useRef)(!1),[b,x]=(0,M.useState)(null),[S,j]=(0,M.useState)(null),[N,P]=(0,M.useState)(0),[F,I]=(0,M.useState)(new Set),[L,z]=(0,M.useState)(null),B=(0,M.useCallback)(()=>P(e=>e+1),[]),[V,H]=(0,M.useState)(t);V!==t&&(H(t),I(new Set),z(null),j(null),x(null));let U=f?.revision!==N,W=U?[]:f.items,G=U?[]:f.backends,K=f?.days;(0,M.useEffect)(()=>{let t=!1;return(u?w(e,u).then(e=>({...e,backends:[]})):C(e).then(e=>({items:[],days:null,backends:e.filter(e=>e.driver===`file`&&e.enabled!==!1)}))).then(e=>{t||g({...e,revision:N,error:null})}).catch(e=>{t||g({revision:N,items:[],backends:[],days:null,error:e instanceof Error?e.message:String(e)})}),()=>{t=!0}},[e,u,N]),(0,M.useEffect)(()=>{let t=null,n=n=>{let r=n.detail;r?.workspaceName&&r.workspaceName!==e||r?.treeName&&r.treeName!==`backends`||(t||=setTimeout(()=>{t=null,B()},500))};return window.addEventListener(`workspace:trash:refresh`,n),window.addEventListener(`workspace:tree:refresh`,n),()=>{window.removeEventListener(`workspace:trash:refresh`,n),window.removeEventListener(`workspace:tree:refresh`,n),t&&clearTimeout(t)}},[e,B]);let q=A(W,d),J=async(t,n)=>{if(!(!u||y.current||U||!n.length)&&!(t===`discard`&&!D(u,n))){y.current=!0,v(t),x(null),j(null),z(null);try{let r=await(t===`restore`?O:k)(e,u,[...n].sort((e,t)=>t.deletedAt-e.deletedAt).map(e=>e.id)),i=r.filter(e=>!e.ok);j(`${r.length-i.length} item(s) ${t===`restore`?`restored to their original paths`:`permanently deleted`}.`),i.length&&x(`${i.length} item(s) remain in Trash. ${i.slice(0,3).map(e=>`${e.key||`Item`}: ${e.reason===`precondition-failed`||e.reason===`target-exists`?`original path is occupied`:e.message||e.reason}`).join(`; `)}`),I(new Set)}catch(e){x(e instanceof Error?e.message:String(e))}finally{y.current=!1,v(null),B()}}},Y=(e,t,n)=>z({x:e,y:t,row:n});return(0,R.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-background`,"aria-label":`Backend Trash`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 border-b px-4 py-3`,children:[(0,R.jsx)(a,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,R.jsx)(h,{items:m(t,e).map((e,t)=>t===2&&u?{...e,label:u}:e),onNavigate:n,className:`basis-48`}),(0,R.jsxs)(`div`,{className:`ml-auto flex max-w-full flex-wrap items-center gap-2`,children:[F.size>0&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`button`,{className:`flex items-center gap-1 rounded border px-2 py-1 text-sm disabled:opacity-50`,disabled:!!_||U,onClick:()=>void J(`restore`,q.filter(e=>F.has(e.id)).flatMap(e=>e.items)),children:[(0,R.jsx)(i,{className:`h-3.5 w-3.5`}),`Restore selected`]}),(0,R.jsxs)(`button`,{className:`flex items-center gap-1 rounded border px-2 py-1 text-sm text-destructive disabled:opacity-50`,disabled:!!_||U,onClick:()=>void J(`discard`,q.filter(e=>F.has(e.id)).flatMap(e=>e.items)),children:[(0,R.jsx)(a,{className:`h-3.5 w-3.5`}),`Delete selected`]})]}),u&&q.length>0&&(0,R.jsxs)(`button`,{className:`flex items-center gap-1 rounded border px-2 py-1 text-sm text-destructive disabled:opacity-50`,disabled:!!_||U,onClick:()=>void J(`discard`,q.flatMap(e=>e.items)),children:[(0,R.jsx)(a,{className:`h-3.5 w-3.5`}),d?`Empty this folder`:`Empty Trash`]}),(0,R.jsx)(`button`,{title:`Refresh Trash`,"aria-label":`Refresh Trash`,className:`rounded p-2 hover:bg-accent`,disabled:!!_||U,onClick:B,children:(0,R.jsx)(c,{className:`h-4 w-4 ${U?`animate-spin`:``}`})})]})]}),(0,R.jsxs)(`div`,{className:`border-b px-4 py-2 text-xs text-muted-foreground`,children:[`Restore files and folders to their original paths. Existing files are kept.`,K?` Deleted items are kept for ${K} days.`:``]}),S&&(0,R.jsx)(`p`,{role:`status`,className:`px-4 py-2 text-sm`,children:S}),(b||f?.error)&&(0,R.jsx)(`p`,{role:`alert`,className:`px-4 py-2 text-sm text-destructive`,children:b||f?.error}),_&&(0,R.jsx)(`p`,{role:`status`,className:`px-4 py-2 text-sm`,children:_===`restore`?`Restoring…`:`Deleting permanently…`}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:U?(0,R.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading Trash…`}):u?q.length===0?(0,R.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`This Trash folder is empty.`}):(0,R.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,R.jsx)(`thead`,{className:`border-b text-xs text-muted-foreground`,children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{className:`w-8 p-2`,children:(0,R.jsx)(`input`,{type:`checkbox`,"aria-label":`Select all visible items`,checked:q.length>0&&q.every(e=>F.has(e.id)),onChange:e=>I(e.target.checked?new Set(q.map(e=>e.id)):new Set)})}),(0,R.jsx)(`th`,{className:`p-2`,children:`Name`}),(0,R.jsx)(`th`,{className:`p-2 max-sm:hidden`,children:`Original path`}),(0,R.jsx)(`th`,{className:`p-2 max-md:hidden`,children:`Deleted`}),(0,R.jsx)(`th`,{className:`p-2`,children:(0,R.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]})}),(0,R.jsx)(`tbody`,{children:q.map(e=>(0,R.jsxs)(`tr`,{className:`border-b border-border/50 hover:bg-accent/50`,onContextMenu:t=>{t.preventDefault(),Y(t.clientX,t.clientY,e)},onDoubleClick:()=>e.navigable&&n(E(u,e.key)),children:[(0,R.jsx)(`td`,{className:`p-2`,children:(0,R.jsx)(`input`,{type:`checkbox`,"aria-label":`Select ${e.name}`,checked:F.has(e.id),disabled:!!_,onChange:t=>I(n=>{let r=new Set(n);return t.target.checked?r.add(e.id):r.delete(e.id),r})})}),(0,R.jsx)(`td`,{className:`p-2`,children:(0,R.jsxs)(`button`,{className:`flex items-center gap-2 text-left`,onClick:()=>e.navigable&&n(E(u,e.key)),children:[e.directory?(0,R.jsx)(r,{className:`h-4 w-4 shrink-0`}):(0,R.jsx)(o,{className:`h-4 w-4 shrink-0`}),(0,R.jsxs)(`span`,{children:[e.name,e.navigable&&(0,R.jsxs)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:[e.items.length,` items`]})]})]})}),(0,R.jsx)(`td`,{className:`p-2 text-xs text-muted-foreground max-sm:hidden`,children:e.key}),(0,R.jsx)(`td`,{className:`p-2 text-xs text-muted-foreground max-md:hidden`,children:new Date(e.items.reduce((e,t)=>Math.max(e,t.deletedAt),0)).toLocaleString()}),(0,R.jsx)(`td`,{className:`p-2 text-right`,children:(0,R.jsx)(`button`,{title:`Actions for ${e.name}`,"aria-label":`Actions for ${e.name}`,disabled:!!_,className:`rounded p-2 hover:bg-accent`,onClick:t=>Y(t.clientX,t.clientY,e),children:(0,R.jsx)(s,{className:`h-4 w-4`})})})]},e.id))})]}):(0,R.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-3`,children:[G.map(e=>(0,R.jsxs)(`button`,{onClick:()=>n(E(e.address)),className:`flex items-center gap-3 rounded-lg border p-4 text-left hover:bg-accent`,children:[(0,R.jsx)(a,{className:`h-6 w-6 text-muted-foreground`}),(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`span`,{className:`block text-sm font-medium`,children:e.label||e.address}),(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.address})]})]},e.address)),!G.length&&(0,R.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`No file backends are available.`})]})}),L&&(0,R.jsxs)(p,{x:L.x,y:L.y,onClose:()=>z(null),className:`min-w-44 rounded-md border bg-popover p-1 shadow-elevation-3`,children:[L.row.navigable&&(0,R.jsxs)(`button`,{className:`flex w-full items-center gap-2 rounded px-3 py-2 text-sm hover:bg-accent`,onClick:()=>{n(E(u,L.row.key)),z(null)},children:[(0,R.jsx)(r,{className:`h-4 w-4`}),`Open folder`]}),(0,R.jsxs)(`button`,{disabled:!!_,className:`flex w-full items-center gap-2 rounded px-3 py-2 text-sm hover:bg-accent disabled:opacity-50`,onClick:()=>void J(`restore`,L.row.items),children:[(0,R.jsx)(i,{className:`h-4 w-4`}),`Restore `,L.row.directory?`folder`:`file`]}),(0,R.jsxs)(`button`,{disabled:!!_||U,className:`flex w-full items-center gap-2 rounded px-3 py-2 text-sm text-destructive hover:bg-destructive/10 disabled:opacity-50`,onClick:()=>void J(`discard`,L.row.items),children:[(0,R.jsx)(a,{className:`h-4 w-4`}),`Delete permanently`]})]})]})}function V({value:e,backends:t,source:n,onSave:r,destination:i=!0}){let[a,o]=(0,M.useState)({...N,...e}),[s,c]=(0,M.useState)(!1),[u,d]=(0,M.useState)(``),f=`rounded border bg-background px-2 py-1.5 text-xs w-full`,p=async()=>{c(!0),d(``);try{await r(a),d(`Removal policy saved.`)}catch(e){d(e instanceof Error?e.message:`Could not save policy`)}finally{c(!1)}};return(0,R.jsxs)(`details`,{className:`border-t pt-3 text-xs`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer font-medium`,children:`Source removals and Trash`}),(0,R.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:`A completed scan removes missing locations from the backend tree. Items with no remaining locations go to Trash until you purge them.`}),(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`label`,{className:`space-y-1 block`,children:[`When an item disappears from this source`,(0,R.jsxs)(`select`,{className:f,value:a.membership,disabled:s,onChange:e=>o({...a,membership:e.target.value}),children:[(0,R.jsx)(`option`,{value:`keep`,children:`Keep in managed trees`}),(0,R.jsx)(`option`,{value:`review`,children:`Review removal in Trash`}),(0,R.jsx)(`option`,{value:`trash`,children:`Move to Trash automatically`})]})]}),(0,R.jsxs)(`label`,{className:`space-y-1 block`,children:[`Remove tracked copies from other backends`,(0,R.jsxs)(`select`,{className:f,value:a.propagation,disabled:s,onChange:e=>o({...a,propagation:e.target.value}),children:[(0,R.jsx)(`option`,{value:`never`,children:`Never`}),(0,R.jsx)(`option`,{value:`review`,children:`Review in Trash`}),(0,R.jsx)(`option`,{value:`automatic`,children:`Automatically, retaining recovery copies`})]})]})]}),a.propagation!==`never`&&(0,R.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,R.jsx)(`legend`,{className:`mb-1 font-medium`,children:`Destinations`}),(0,R.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:a.targets===`all`,disabled:s,onChange:e=>o({...a,targets:e.target.checked?`all`:[]})}),`All eligible backends`]}),a.targets!==`all`&&t.filter(e=>e.address!==n&&e.kind===`storage`).map(e=>(0,R.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`checkbox`,disabled:s||e.config?.propagatedRemovalSupported!==!0,checked:a.targets.includes(e.address),onChange:t=>o({...a,targets:t.target.checked?[...a.targets,e.address]:a.targets.filter(t=>t!==e.address)})}),String(e.config?.label||e.address),e.config?.propagatedRemovalSupported===!0?!e.config?.removalPolicy?.acceptPropagatedDeletions&&` · protected`:` · recovery removal unavailable`]},e.address)),(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:`Only tracked, Canvas-owned copies are eligible. Protected destinations refuse propagated deletion. Recovery removal currently supports filesystem and workspace blob storage; remote destinations remain protected.`})]}),i&&(0,R.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`checkbox`,disabled:s,checked:a.acceptPropagatedDeletions,onChange:e=>o({...a,acceptPropagatedDeletions:e.target.checked})}),`Accept propagated deletions on this backend`]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(l,{size:`sm`,variant:`outline`,disabled:s,onClick:()=>void p(),children:s?`Saving…`:`Save removal policy`}),(0,R.jsx)(`span`,{role:`status`,children:u})]})]})]})}function H({workspaceName:e,canWrite:t}){let{showToast:n}=f(),[r,o]=(0,M.useState)([]),[s,u]=(0,M.useState)(!1),[d,p]=(0,M.useState)([]),[m,h]=(0,M.useState)(!1),y=(0,M.useCallback)(async()=>{u(!0);try{o(await S(e))}catch(e){n({title:`Error`,description:e instanceof Error?e.message:`Failed to load the trash`,variant:`destructive`})}finally{u(!1)}},[e]);(0,M.useEffect)(()=>{y()},[y]);let b=(0,M.useCallback)(e=>d.includes(e),[d]),x=async(e,t)=>{p(t=>[...t,...e]);try{await t()}finally{p(t=>t.filter(t=>!e.includes(t)))}},C=t=>x([t.id],async()=>{try{let r=await g(e,[t.id]);r.failed?.length?n({title:`Not restored`,description:r.failed[0]?.error||`No restore target recorded`,variant:`destructive`}):(n({title:`Restored`,description:`Document put back where it was.`}),o(e=>e.filter(e=>e.id!==t.id)))}catch(e){n({title:`Error`,description:e instanceof Error?e.message:`Failed to restore`,variant:`destructive`})}}),w=t=>x([t.id],async()=>{try{let r=await v(e,[t.id]);if(r.failed?.length)throw Error(`The item could not be purged. Refresh and retry.`);n({title:`Cleared from Trash`,description:r.preserved?.length?`Existing backend copies remain indexed.`:`Document permanently deleted.`}),o(e=>e.filter(e=>e.id!==t.id))}catch(e){n({title:`Error`,description:e instanceof Error?e.message:`Failed to delete`,variant:`destructive`})}}),T=async()=>{if(!m){h(!0);return}h(!1);try{let t=await v(e);n({title:`Trash emptied`,description:`${t.destroyed?.length??0} document(s) purged. ${t.preserved?.length??0} item(s) cleared with backend copies preserved.`}),await y()}catch(e){n({title:`Error`,description:e instanceof Error?e.message:`Failed to empty the trash`,variant:`destructive`})}},E=(0,M.useMemo)(()=>r.map(e=>{let t=_(e),n=(e.trashed?.placements??[]).flatMap(e=>e.paths.map(t=>`${e.tree}:${t}`));return{document:e,title:t.title,origin:n,trashedAt:e.trashed?.trashedAt||null}}),[r]);return(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between sm:gap-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h2`,{className:`text-sm font-medium`,children:`Managed-tree items`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1 max-w-2xl`,children:`Restore managed-tree placements or permanently purge these items. Pending removals require separate approval. Backend copies are managed below.`})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 max-sm:flex-wrap`,children:[(0,R.jsxs)(l,{variant:`outline`,size:`sm`,onClick:()=>y(),disabled:s,children:[(0,R.jsx)(c,{className:`mr-2 h-3.5 w-3.5 ${s?`animate-spin`:``}`}),`Refresh`]}),(0,R.jsxs)(l,{variant:m?`destructive`:`outline`,size:`sm`,onClick:T,onBlur:()=>h(!1),disabled:!t||r.length===0,children:[(0,R.jsx)(a,{className:`mr-2 h-3.5 w-3.5`}),m?`Click again to delete everything`:`Empty trash`]})]})]}),s&&r.length===0&&(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading…`}),!s&&r.length===0&&(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The trash is empty.`}),E.length>0&&(0,R.jsx)(`div`,{className:`border rounded-md divide-y`,children:E.map(({document:e,title:n,origin:r,trashedAt:o})=>(0,R.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`div`,{className:`truncate text-sm`,children:n}),(0,R.jsxs)(`div`,{className:`truncate text-xs text-muted-foreground`,children:[r.length>0?`from ${r.join(`, `)}`:`no recorded origin`,o?` · ${new Date(o).toLocaleString()}`:``]})]}),(0,R.jsxs)(l,{variant:`outline`,size:`sm`,onClick:()=>C(e),disabled:!t||b(e.id)||r.length===0,title:r.length===0?`Nothing recorded to restore to`:`Put it back where it was`,children:[(0,R.jsx)(i,{className:`mr-2 h-3.5 w-3.5`}),`Restore placements`]}),(0,R.jsx)(l,{variant:`ghost`,size:`sm`,onClick:()=>w(e),disabled:!t||b(e.id),title:`Delete permanently`,children:(0,R.jsx)(a,{className:`h-3.5 w-3.5`})})]},e.id))})]})}function U({workspaceName:e}){return(0,R.jsx)(W,{workspaceName:e},e)}function W({workspaceName:e}){let[t,n]=(0,M.useState)(`pending`),[r,i]=(0,M.useState)(``),[a,o]=(0,M.useState)(``),[s,d]=(0,M.useState)(0),[f,p]=(0,M.useState)(0),[m,h]=(0,M.useState)(null),[g,_]=(0,M.useState)(``),[v,S]=(0,M.useState)(!1),[w,T]=(0,M.useState)(new Set),[E,D]=(0,M.useState)({}),[O,k]=(0,M.useState)(`/Trash`),[A,P]=(0,M.useState)([]),[B,U]=(0,M.useState)({write:!1,admin:!1});(0,M.useEffect)(()=>{let t=!0;return y(e).then(e=>{let n=e.remote?.permissions||e.access?.permissions||(typeof e.sharedVia==`object`?e.sharedVia?.permissions:[])||[],r=j(e);t&&U({admin:r,write:r||n.includes(`write`)})}).catch(()=>{}),()=>{t=!1}},[e]);let[W,G]=(0,M.useState)(null);(0,M.useEffect)(()=>{let t=!0;return C(e).then(e=>{t&&P(e)}).catch(()=>{}),()=>{t=!1}},[e]),(0,M.useEffect)(()=>{let n=!1,i=()=>F(e,{view:t,search:r,...a?{backend:a}:{},offset:s}).then(e=>{n||(h(e),_(``))}).catch(e=>{n||_(e instanceof Error?e.message:`Could not load Trash`)});i();let o=setInterval(()=>{v||i()},5e3);return()=>{n=!0,clearInterval(o)}},[e,t,r,a,s,f,v]);let K=m?.operations||[],q=()=>{T(new Set),p(e=>e+1)},J=()=>{x(e),window.dispatchEvent(new CustomEvent(`workspace:tree:refresh`,{detail:{workspaceName:e}})),window.dispatchEvent(new CustomEvent(`workspace:trash:refresh`,{detail:{workspaceName:e}}))},Y=async(t,n=[...w])=>{if(!(!n.length||v)&&!(t===`purge`&&!window.confirm(`Permanently delete retained recovery copies for ${n.length} operation(s)?`))){S(!0),_(``);try{let r=(t===`approve`?(await Promise.all(n.map(n=>I(e,[n],t,E[n])))).flatMap(e=>e.results):(await I(e,n,t)).results).filter(e=>!e.ok||e.operation?.state===`failed`);r.length&&_(r.map(e=>e.error||e.operation?.error||`A destination could not be changed. Expand the item for details.`).join(` `)),J(),q()}catch(e){_(e instanceof Error?e.message:`Trash action failed`)}finally{S(!1)}}},X=e=>{n(e),d(0),h(null),T(new Set),D({})};return(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h2`,{className:`text-base font-semibold`,children:`Workspace Trash`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Review source removals, recover items, and see what automatic policies changed.`})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,role:`tablist`,"aria-label":`Trash views`,children:[[[`pending`,`Pending removal`],[`trashed`,`In Trash`],[`activity`,`Activity`]].map(([e,n])=>(0,R.jsx)(l,{role:`tab`,"aria-selected":t===e,size:`sm`,variant:t===e?`default`:`outline`,onClick:()=>X(e),children:n},e)),(0,R.jsxs)(l,{size:`sm`,variant:`ghost`,className:`ml-auto`,onClick:q,disabled:v,children:[(0,R.jsx)(c,{className:`mr-2 h-3.5 w-3.5`}),`Refresh`]})]}),t===`trashed`&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(H,{workspaceName:e,canWrite:B.write},f),(0,R.jsxs)(`details`,{className:`rounded border p-3`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:`Browse backend recovery copies`}),(0,R.jsx)(`div`,{className:`mt-3 min-h-48`,children:(0,R.jsx)(z,{workspace:e,path:O,onNavigate:k})})]})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,R.jsx)(u,{"aria-label":`Filter Trash items`,placeholder:`Filter by item or path…`,className:`max-w-xs`,value:r,onChange:e=>{i(e.target.value),h(null),d(0),T(new Set)}}),(0,R.jsx)(u,{"aria-label":`Filter by backend`,placeholder:`Backend name…`,className:`max-w-56`,value:a,onChange:e=>{o(e.target.value),h(null),d(0),T(new Set)}}),w.size>0&&(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,R.jsxs)(`span`,{children:[w.size,` selected`]}),t===`pending`&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(l,{size:`sm`,disabled:v,onClick:()=>void Y(`approve`),children:`Approve selected`}),(0,R.jsx)(l,{size:`sm`,variant:`outline`,disabled:v,onClick:()=>void Y(`keep`),children:`Keep selected`}),(0,R.jsx)(l,{size:`sm`,variant:`outline`,disabled:v,onClick:()=>void Y(`retry`),children:`Retry`})]}),t===`trashed`&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(l,{size:`sm`,variant:`outline`,disabled:v,onClick:()=>void Y(`restore`),children:`Restore copies`}),(0,R.jsx)(l,{size:`sm`,variant:`destructive`,disabled:v,onClick:()=>void Y(`purge`),children:`Purge copies`})]})]})]}),W&&(0,R.jsxs)(`div`,{className:`rounded border p-3 space-y-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsxs)(`p`,{className:`text-sm font-medium`,children:[`Removal policy · `,W.source.account||W.source.backend,W.source.folder?` / ${W.source.folder}`:``]}),(0,R.jsx)(l,{size:`sm`,variant:`ghost`,onClick:()=>G(null),children:`Close`})]}),(0,R.jsx)(V,{source:W.source.backend,backends:A,destination:!1,value:{...N,...A.find(e=>e.address===W.source.backend)?.config?.removalPolicy,membership:E[W.id]?.membership??W.membership!==`keep`?`review`:`keep`,propagation:W.targets.length?`review`:`never`,targets:[...new Set(W.targets.filter(e=>!E[W.id]||E[W.id].targets.includes(JSON.stringify([e.backend,e.key]))).map(e=>e.backend))]},onSave:async t=>{W.source.driver===`imap`?await L(e,W.source.account,W.source.folder,t):await b(e,W.source.driver,W.source.backend,{removalPolicy:t}),P(await C(e))}},W.id)]}),g&&(0,R.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:g}),(0,R.jsxs)(`div`,{className:`overflow-x-auto rounded border`,children:[(0,R.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,R.jsx)(`thead`,{className:`bg-muted`,children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{className:`p-3 w-8`,children:(0,R.jsx)(`input`,{type:`checkbox`,"aria-label":`Select visible operations`,disabled:!B.write||v||!K.length||t===`activity`,checked:K.length>0&&K.every(e=>w.has(e.id)),onChange:e=>T(e.target.checked?new Set(K.map(e=>e.id)):new Set)})}),(0,R.jsx)(`th`,{className:`p-3`,children:`Item and affected copies`}),(0,R.jsx)(`th`,{className:`p-3`,children:`Source`}),(0,R.jsx)(`th`,{className:`p-3`,children:`Status`}),(0,R.jsx)(`th`,{className:`p-3`,children:`Detected`})]})}),(0,R.jsx)(`tbody`,{children:K.map(e=>{let n=E[e.id]||{targets:e.targets.filter(e=>e.state!==`kept`).map(e=>JSON.stringify([e.backend,e.key])),membership:e.membership!==`keep`};return(0,R.jsxs)(`tr`,{className:`border-t align-top`,children:[(0,R.jsx)(`td`,{className:`p-3`,children:(0,R.jsx)(`input`,{type:`checkbox`,"aria-label":`Select ${e.title}`,disabled:!B.write||v||t===`activity`,checked:w.has(e.id),onChange:t=>T(n=>{let r=new Set(n);return t.target.checked?r.add(e.id):r.delete(e.id),r})})}),(0,R.jsx)(`td`,{className:`p-3 min-w-64`,children:(0,R.jsxs)(`details`,{children:[(0,R.jsx)(`summary`,{className:`cursor-pointer font-medium`,children:e.title}),(0,R.jsxs)(`div`,{className:`mt-2 space-y-2 text-muted-foreground`,children:[(0,R.jsx)(`p`,{children:e.orphan?`No remaining byte locations. Restore placements only unless recovery bytes are available.`:`${e.remainingLocations.length} remaining location(s) when detected.`}),e.placements.map(e=>(0,R.jsxs)(`p`,{children:[e.tree,`: `,e.paths.join(`, `)]},e.tree)),e.membership!==`keep`&&(0,R.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:n.membership,disabled:v||t!==`pending`||e.membershipApplied,onChange:t=>D({...E,[e.id]:{...n,membership:t.target.checked}})}),e.membershipApplied?`Managed placements moved to Trash`:`Move managed placements to Trash`]}),e.targets.map(r=>{let i=JSON.stringify([r.backend,r.key]);return(0,R.jsxs)(`label`,{className:`flex items-start gap-2`,children:[(0,R.jsx)(`input`,{type:`checkbox`,disabled:v||t!==`pending`||!!r.trashId,checked:n.targets.includes(i),onChange:t=>D({...E,[e.id]:{...n,targets:t.target.checked?[...n.targets,i]:n.targets.filter(e=>e!==i)}})}),(0,R.jsxs)(`span`,{className:`break-all`,children:[r.backend,`:`,r.key,` · `,r.state,r.error&&(0,R.jsx)(`span`,{className:`block text-destructive`,children:r.error})]})]},i)}),(0,R.jsx)(l,{size:`sm`,variant:`outline`,disabled:!B.admin,onClick:()=>G(e),children:`Use these choices as a source policy`}),e.remainingLocations.map(e=>(0,R.jsx)(`p`,{className:`break-all`,children:e.url},e.url))]})]})}),(0,R.jsxs)(`td`,{className:`p-3 break-all`,children:[e.source.account||e.source.backend,e.source.folder&&(0,R.jsx)(`span`,{className:`block text-muted-foreground`,children:e.source.folder})]}),(0,R.jsxs)(`td`,{className:`p-3`,children:[e.state,e.error&&(0,R.jsx)(`p`,{className:`mt-1 max-w-xs text-destructive`,children:e.error})]}),(0,R.jsx)(`td`,{className:`p-3 whitespace-nowrap text-muted-foreground`,children:new Date(e.createdAt).toLocaleString()})]},e.id)})})]}),!K.length&&(0,R.jsx)(`p`,{className:`p-5 text-center text-sm text-muted-foreground`,children:m?`No matching operations.`:`Loading…`})]}),(0,R.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,R.jsxs)(`span`,{children:[m?.total??0,` operation(s)`]}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(l,{size:`sm`,variant:`outline`,disabled:!s||v,onClick:()=>{d(Math.max(0,s-200)),T(new Set)},children:`Previous`}),(0,R.jsx)(l,{size:`sm`,variant:`outline`,disabled:s+K.length>=(m?.total??0)||v,onClick:()=>{d(s+200),T(new Set)},children:`Next`})]})]})]})}var G=`canvas:query-debug`,K=`canvas:query-debug-changed`;function q(){try{return localStorage.getItem(G)===`1`}catch{return!1}}function J(e){try{e?localStorage.setItem(G,`1`):localStorage.removeItem(G)}catch{}window.dispatchEvent(new CustomEvent(K,{detail:e}))}function Y(){let[e,t]=(0,M.useState)(q);return(0,M.useEffect)(()=>{let e=()=>t(q());return window.addEventListener(K,e),window.addEventListener(`storage`,e),()=>{window.removeEventListener(K,e),window.removeEventListener(`storage`,e)}},[]),e}export{V as a,U as i,J as n,z as o,Y as r,L as s,q as t};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalApplet-Djk4l1Jm.js","assets/rolldown-runtime-C0FnF6B9.js","assets/code-editor-BOIngd5F.js","assets/ui-76Hw0NU_.js","assets/react-BHzhHVTZ.js","assets/use-applet-target-DmIdCxa_.js","assets/workspace-46EFyEKZ.js","assets/button-Bum-POPT.js","assets/utils-BxVxyehK.js","assets/utils-2pl1SbIp.js","assets/input-BOtCd4HP.js","assets/api-CA6WiiYM.js","assets/alert-dialog-CShuAcnP.js","assets/use-toolbox-Ck_cLGgf.js","assets/TerminalApplet-BrP-ENHg.css","assets/NotesApplet-DyJobkzg.js","assets/useAddTarget-D4ra50Am.js","assets/context-BGgz0Y_q.js","assets/note-save-status-DPz4VzL6.js","assets/useEditNoteFields-CKYMBf8V.js","assets/tags-YamdPoBK.js","assets/index-Pdg5xeG3.js","assets/preload-helper-Czpn1I53.js","assets/chunk-62JRHF6Z-vspAGgtK.js","assets/label-DJc8-3CQ.js","assets/socket-hM4c-ZSl.js","assets/socket-CtH3EU9m.js","assets/auth-Bx9fAZmz.js","assets/use-toast-BlLDqSUO.js","assets/LinkToCard-VXpoeMDH.js","assets/useEscapeClose-DR_xKT_k.js","assets/useToastHelpers-CRrpIIdY.js","assets/layer-style-Byl5LNFR.js","assets/color-DFEH4BfK.js","assets/DocumentIcon-ByDAILhm.js","assets/use-canvas-pins-BZMaPpb7.js","assets/TodosWidget-CX4lgk-9.js","assets/ObjectPropertiesCard-CFZ_LqzX.js","assets/use-mobile-Db-vWu9Y.js","assets/IdentityFields-CEDxU-Hd.js","assets/date-time-picker-Bzu8H_Oa.js","assets/relation-events-CKio19hE.js","assets/map-BxCwdK0d.js","assets/map-BcsP_QXj.css","assets/public-share-D2S8DEsv.js","assets/text-documents-CFW8MWES.js","assets/blobs-WiXP9QRi.js","assets/useDocumentThumbnail-Bs2Ju0eb.js","assets/markdown-view-BBBZtNSR.js","assets/sanitize-DrVcFY1Q.js","assets/MessageComposerDialog-BKGlI7jO.js","assets/markdown-it-DRESbtwK.js","assets/punycode.es6-ZbLrB_Dn.js","assets/lazy-editor-Bdm5JEXv.js","assets/LinkToSidePanel-eCy3nW4R.js","assets/DocumentBodyEditor-DRFQgBNB.js","assets/use-document-modal-PG8bQyIB.js","assets/sketch-lazy-BOFTGGTA.js","assets/geo-CZfs0E-x.js","assets/ObjectPropertiesCard-JArcZXXv.css","assets/document-list-Cq4rdquK.js","assets/document-open-mode-DoImW-xs.js","assets/PickDocumentsCard-B72XNYh3.js","assets/backend-sync-progress-DyvV8N9D.js","assets/PathPickerField-B58yeJGw.js","assets/backend-sync-progress-DU-e9TWi.css","assets/workspace-access-C9nZlBBZ.js","assets/search-COMZIxA7.js","assets/use-sortable-data-W2inLcb5.js","assets/workspace-BydSRtST.js","assets/document-list-DAYdk5vh.css","assets/url-params-n7kU_WZ-.js","assets/use-canvas-pins-C57Vbkrq.css","assets/use-menu-CaiLyPdw.js","assets/last-path-BbXWC3b3.js","assets/workspace-area-menu-COdiU0Xn.js","assets/workspace-content-gate-CGZmT2kw.js","assets/UploadProgressList-CHQ-Kn-e.js","assets/sha256-65KIjGvZ.js","assets/FileForm-B6eFRKG-.js","assets/use-theme-DaxpiICf.js","assets/index-XDD8pFI_.css","assets/shared-C-uHNNY8.js","assets/use-applet-docs-DBshA7yq.js","assets/TodosApplet-DZVcRHmh.js","assets/LensApplet-DNR6LHP1.js","assets/FiltersApplet-BQ-yLETb.js","assets/SketchApplet-BHee4eKG.js","assets/CalendarApplet-B-KQB9MF.js"])))=>i.map(i=>d[i]);
2
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{t as r}from"./preload-helper-Czpn1I53.js";import{St as i,Xr as a,ct as o,hn as s,it as c,qr as l,tt as u}from"./ui-76Hw0NU_.js";var d=e(n(),1),f=t();function p(e){let t=(0,d.lazy)(e);return function(e){return(0,f.jsx)(d.Suspense,{fallback:(0,f.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,role:`status`,children:`Opening app…`}),children:(0,f.jsx)(t,{...e})})}}var m=p(()=>r(()=>import(`./TerminalApplet-Djk4l1Jm.js`).then(e=>({default:e.TerminalApplet})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))),h=p(()=>r(()=>import(`./NotesApplet-DyJobkzg.js`).then(e=>({default:e.NotesApplet})),__vite__mapDeps([15,1,2,3,4,9,8,6,7,10,11,12,16,13,17,18,19,20,5,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83]))),g=p(()=>r(()=>import(`./TodosApplet-DZVcRHmh.js`).then(e=>({default:e.TodosApplet})),__vite__mapDeps([84,1,2,3,4,9,8,6,7,10,11,12,16,13,17,40,20,41,5,82,29,30,31,28,32,33,34,54,83]))),_=p(()=>r(()=>import(`./LensApplet-DNR6LHP1.js`).then(e=>({default:e.LensApplet})),__vite__mapDeps([85,1,2,3,4,9,8,6,7,10,11,12,47,44,34,56,5,13,21,22,23,24,25,26,27,28,29,30,31,32,33,35,36,37,38,39,20,16,17,40,41,42,43,45,46,48,49,50,51,52,53,54,18,19,55,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81]))),v=p(()=>r(()=>import(`./FiltersApplet-BQ-yLETb.js`).then(e=>({default:e.FiltersApplet})),__vite__mapDeps([86,1,2,26,11,25,13,5,6,4,7,3,8,9,10,12,21,22,23,24,27,28,29,30,31,32,33,34,35,36,37,38,39,20,16,17,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,18,19,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81]))),y=p(()=>r(()=>import(`./SketchApplet-BHee4eKG.js`).then(e=>({default:e.SketchApplet})),__vite__mapDeps([87,1,2,3,4,7,8,9,6,10,11,12,47,44,31,28,57,22,5,13,83,17]))),b=p(()=>r(()=>import(`./CalendarApplet-B-KQB9MF.js`).then(e=>({default:e.CalendarApplet})),__vite__mapDeps([88,1,2,23,22,3,4,9,8,6,7,10,11,12,16,13,17,40,20,41,5,21,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,42,43,44,45,46,47,48,49,50,51,52,53,54,18,19,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82]))),x=[{id:`terminal`,category:`utilities`,label:`Terminal`,icon:c,modes:[`context`],description:`Shell sessions for this context`,Component:m},{id:`filters`,category:`utilities`,label:`Filters`,icon:o,modes:[`context`,`global`],description:`Search and filter a workspace or a live context`,Component:v},{id:`notes`,category:`productivity`,label:`Notes`,icon:u,modes:[`context`],description:`All notes in the current context, editable in place`,Component:h},{id:`todo`,category:`productivity`,label:`Todos`,icon:s,modes:[`context`],description:`Todos in the current context, done items hidden by default`,Component:g},{id:`calendar`,category:`productivity`,label:`Calendar`,icon:l,modes:[`context`],description:`Day, week, month, year and schedule views of the events and due tasks in the current context`,Component:b},{id:`sketch`,category:`creative`,label:`Sketch`,icon:a,modes:[`context`],description:`Quick-sketch into the current context; tap a sketch to keep editing`,Component:y},{id:`lens`,category:`media`,label:`Lens`,icon:i,modes:[`context`],description:`Point a camera at things; matching documents surface live`,Component:_}];function S(e){return x.filter(t=>t.modes.includes(e))}export{S as n,x as t};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalApplet-Djk4l1Jm.js","assets/rolldown-runtime-C0FnF6B9.js","assets/code-editor-BOIngd5F.js","assets/ui-76Hw0NU_.js","assets/react-BHzhHVTZ.js","assets/use-applet-target-DmIdCxa_.js","assets/workspace-46EFyEKZ.js","assets/button-Bum-POPT.js","assets/utils-BxVxyehK.js","assets/utils-2pl1SbIp.js","assets/input-BOtCd4HP.js","assets/api-CA6WiiYM.js","assets/alert-dialog-CShuAcnP.js","assets/use-toolbox-Ck_cLGgf.js","assets/TerminalApplet-BrP-ENHg.css","assets/NotesApplet-DfagszMP.js","assets/useAddTarget-D4ra50Am.js","assets/context-BGgz0Y_q.js","assets/note-save-status-DPz4VzL6.js","assets/useEditNoteFields-CKYMBf8V.js","assets/tags-YamdPoBK.js","assets/index-D-y76fV7.js","assets/preload-helper-Czpn1I53.js","assets/chunk-62JRHF6Z-vspAGgtK.js","assets/label-DJc8-3CQ.js","assets/socket-hM4c-ZSl.js","assets/socket-CtH3EU9m.js","assets/auth-Bx9fAZmz.js","assets/use-toast-BlLDqSUO.js","assets/LinkToCard-VXpoeMDH.js","assets/useEscapeClose-DR_xKT_k.js","assets/useToastHelpers-CRrpIIdY.js","assets/layer-style-Byl5LNFR.js","assets/color-DFEH4BfK.js","assets/DocumentIcon-ByDAILhm.js","assets/use-canvas-pins-D-zi5fqQ.js","assets/TodosWidget-CX4lgk-9.js","assets/ObjectPropertiesCard-CFZ_LqzX.js","assets/use-mobile-Db-vWu9Y.js","assets/IdentityFields-CEDxU-Hd.js","assets/date-time-picker-Bzu8H_Oa.js","assets/relation-events-CKio19hE.js","assets/map-BxCwdK0d.js","assets/map-BcsP_QXj.css","assets/public-share-D2S8DEsv.js","assets/text-documents-CFW8MWES.js","assets/blobs-WiXP9QRi.js","assets/useDocumentThumbnail-Bs2Ju0eb.js","assets/markdown-view-BBBZtNSR.js","assets/sanitize-DrVcFY1Q.js","assets/MessageComposerDialog-BKGlI7jO.js","assets/markdown-it-DRESbtwK.js","assets/punycode.es6-ZbLrB_Dn.js","assets/lazy-editor-Bdm5JEXv.js","assets/LinkToSidePanel-eCy3nW4R.js","assets/DocumentBodyEditor-DRFQgBNB.js","assets/use-document-modal-PG8bQyIB.js","assets/sketch-lazy-BOFTGGTA.js","assets/geo-CZfs0E-x.js","assets/ObjectPropertiesCard-JArcZXXv.css","assets/document-list-CwStaizB.js","assets/document-open-mode-DoImW-xs.js","assets/PickDocumentsCard-B72XNYh3.js","assets/backend-sync-progress-BJsLP7o5.js","assets/PathPickerField-B58yeJGw.js","assets/backend-sync-progress-DU-e9TWi.css","assets/workspace-access-C9nZlBBZ.js","assets/search-COMZIxA7.js","assets/use-sortable-data-W2inLcb5.js","assets/workspace-BydSRtST.js","assets/document-list-DAYdk5vh.css","assets/url-params-n7kU_WZ-.js","assets/use-canvas-pins-C57Vbkrq.css","assets/use-menu-CaiLyPdw.js","assets/last-path-BbXWC3b3.js","assets/workspace-area-menu-DtsodEXC.js","assets/workspace-content-gate-CGZmT2kw.js","assets/UploadProgressList-CHQ-Kn-e.js","assets/sha256-65KIjGvZ.js","assets/FileForm-B6eFRKG-.js","assets/use-theme-DaxpiICf.js","assets/index-XDD8pFI_.css","assets/shared-C-uHNNY8.js","assets/use-applet-docs-DBshA7yq.js","assets/TodosApplet-DZVcRHmh.js","assets/LensApplet-FoQc4ieR.js","assets/FiltersApplet-bF_7ntZU.js","assets/SketchApplet-BHee4eKG.js","assets/CalendarApplet-1-_9Pqfs.js"])))=>i.map(i=>d[i]);
2
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{t as r}from"./preload-helper-Czpn1I53.js";import{St as i,Xr as a,ct as o,hn as s,it as c,qr as l,tt as u}from"./ui-76Hw0NU_.js";var d=e(n(),1),f=t();function p(e){let t=(0,d.lazy)(e);return function(e){return(0,f.jsx)(d.Suspense,{fallback:(0,f.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,role:`status`,children:`Opening app…`}),children:(0,f.jsx)(t,{...e})})}}var m=p(()=>r(()=>import(`./TerminalApplet-Djk4l1Jm.js`).then(e=>({default:e.TerminalApplet})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))),h=p(()=>r(()=>import(`./NotesApplet-DfagszMP.js`).then(e=>({default:e.NotesApplet})),__vite__mapDeps([15,1,2,3,4,9,8,6,7,10,11,12,16,13,17,18,19,20,5,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83]))),g=p(()=>r(()=>import(`./TodosApplet-DZVcRHmh.js`).then(e=>({default:e.TodosApplet})),__vite__mapDeps([84,1,2,3,4,9,8,6,7,10,11,12,16,13,17,40,20,41,5,82,29,30,31,28,32,33,34,54,83]))),_=p(()=>r(()=>import(`./LensApplet-FoQc4ieR.js`).then(e=>({default:e.LensApplet})),__vite__mapDeps([85,1,2,3,4,9,8,6,7,10,11,12,47,44,34,56,5,13,21,22,23,24,25,26,27,28,29,30,31,32,33,35,36,37,38,39,20,16,17,40,41,42,43,45,46,48,49,50,51,52,53,54,18,19,55,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81]))),v=p(()=>r(()=>import(`./FiltersApplet-bF_7ntZU.js`).then(e=>({default:e.FiltersApplet})),__vite__mapDeps([86,1,2,26,11,25,13,5,6,4,7,3,8,9,10,12,21,22,23,24,27,28,29,30,31,32,33,34,35,36,37,38,39,20,16,17,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,18,19,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81]))),y=p(()=>r(()=>import(`./SketchApplet-BHee4eKG.js`).then(e=>({default:e.SketchApplet})),__vite__mapDeps([87,1,2,3,4,7,8,9,6,10,11,12,47,44,31,28,57,22,5,13,83,17]))),b=p(()=>r(()=>import(`./CalendarApplet-1-_9Pqfs.js`).then(e=>({default:e.CalendarApplet})),__vite__mapDeps([88,1,2,23,22,3,4,9,8,6,7,10,11,12,16,13,17,40,20,41,5,21,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,42,43,44,45,46,47,48,49,50,51,52,53,54,18,19,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82]))),x=[{id:`terminal`,category:`utilities`,label:`Terminal`,icon:c,modes:[`context`],description:`Shell sessions for this context`,Component:m},{id:`filters`,category:`utilities`,label:`Filters`,icon:o,modes:[`context`,`global`],description:`Search and filter a workspace or a live context`,Component:v},{id:`notes`,category:`productivity`,label:`Notes`,icon:u,modes:[`context`],description:`All notes in the current context, editable in place`,Component:h},{id:`todo`,category:`productivity`,label:`Todos`,icon:s,modes:[`context`],description:`Todos in the current context, done items hidden by default`,Component:g},{id:`calendar`,category:`productivity`,label:`Calendar`,icon:l,modes:[`context`],description:`Day, week, month, year and schedule views of the events and due tasks in the current context`,Component:b},{id:`sketch`,category:`creative`,label:`Sketch`,icon:a,modes:[`context`],description:`Quick-sketch into the current context; tap a sketch to keep editing`,Component:y},{id:`lens`,category:`media`,label:`Lens`,icon:i,modes:[`context`],description:`Point a camera at things; matching documents surface live`,Component:_}];function S(e){return x.filter(t=>t.modes.includes(e))}export{S as n,x 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{_ as r,g as ee}from"./chunk-62JRHF6Z-vspAGgtK.js";import{X as i}from"./ui-76Hw0NU_.js";import{t as a}from"./button-Bum-POPT.js";import{t as o}from"./input-BOtCd4HP.js";import{n as te}from"./use-toast-BlLDqSUO.js";import{Nt as ne}from"./workspace-46EFyEKZ.js";import{t as re}from"./use-mobile-Db-vWu9Y.js";import{p as ie}from"./context-BGgz0Y_q.js";import{t as s}from"./color-DFEH4BfK.js";import{i as ae}from"./use-menu-CaiLyPdw.js";import{$ as oe,G as se,H as ce,K as le,Q as ue,R as de,V as fe,X as pe,Y as me,Z as he,_t as ge,mt as _e,nt as ve,q as ye}from"./index-Pdg5xeG3.js";import{n as be}from"./page-header-BoCaZiqu.js";import{n as xe,r as Se,t as Ce}from"./useAgentModels-DPu0MHiH.js";var c=e(n(),1),l=t(),we={anthropic:`claude-3-5-sonnet-20241022`,openai:`gpt-4o`,ollama:`qwen2.5-coder:latest`,"lm-studio":``,vllm:``,custom:``},u={anthropic:`https://api.anthropic.com`,openai:`https://api.openai.com/v1`,ollama:`http://localhost:11434/v1`,"lm-studio":`http://localhost:1234/v1`,vllm:`http://localhost:8000/v1`,custom:``};function d(e){return u[e]||``}function f({label:e,hint:t,children:n}){return(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:`text-sm font-medium`,children:e}),t&&(0,l.jsx)(`p`,{className:`mb-1 mt-0.5 text-xs text-muted-foreground`,children:t}),(0,l.jsx)(`div`,{className:t?void 0:`mt-1`,children:n})]})}var p=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring resize-y`,m=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring`;function h(){let{agentId:e,tab:t}=r(),n=ee(),{showToast:u}=te(),{selectEntity:h,goBack:Te}=ae(),Ee=re(),g=ge(t);(0,c.useEffect)(()=>{t!==g&&e&&n(`/agents/${encodeURIComponent(e)}/settings/${g}`,{replace:!0})},[t,g,e,n]);let[_,v]=(0,c.useState)(null),[De,Oe]=(0,c.useState)(!0),[ke,Ae]=(0,c.useState)(null),[je,Me]=(0,c.useState)(!1),[Ne,Pe]=(0,c.useState)(!1),[Fe,Ie]=(0,c.useState)(``),[Le,Re]=(0,c.useState)(``),[ze,Be]=(0,c.useState)(``),[Ve,y]=(0,c.useState)(s()),[b,He]=(0,c.useState)(``),[x,Ue]=(0,c.useState)(``),[S,We]=(0,c.useState)(``),[C,Ge]=(0,c.useState)(``),[w,Ke]=(0,c.useState)(`anthropic`),[T,qe]=(0,c.useState)(``),[E,D]=(0,c.useState)(``),[O,k]=(0,c.useState)(``),[Je,Ye]=(0,c.useState)(.7),[Xe,A]=(0,c.useState)(4096),[Ze,Qe]=(0,c.useState)(1),$e=Ce(w,T,E,_?.id),et=$e.models.find(e=>e.id===O),[tt,j]=(0,c.useState)([]),[M,N]=(0,c.useState)(``),[nt,P]=(0,c.useState)(``),[F,I]=(0,c.useState)(``),[L,R]=(0,c.useState)(``),[rt,it]=(0,c.useState)(!1),[at,ot]=(0,c.useState)(null),[z,B]=(0,c.useState)(null),[st,ct]=(0,c.useState)(null),[V,H]=(0,c.useState)(!1),[U,W]=(0,c.useState)(null),[G,K]=(0,c.useState)(``),[q,J]=(0,c.useState)(!1),[Y,lt]=(0,c.useState)(`context`),[X,ut]=(0,c.useState)(``),[dt,ft]=(0,c.useState)(`/`),[Z,pt]=(0,c.useState)(``),[mt,ht]=(0,c.useState)(!0),[Q,gt]=(0,c.useState)(!1),[_t,vt]=(0,c.useState)([]),[yt,bt]=(0,c.useState)([]),[$,xt]=(0,c.useState)(null),[St,Ct]=(0,c.useState)(`{}`),[wt,Tt]=(0,c.useState)(null),[Et,Dt]=(0,c.useState)(e);Et!==e&&(Dt(e),Oe(!0),v(null)),(0,c.useEffect)(()=>{if(!e)return;let t=!1;return fe(e).then(async e=>{if(t)return;let n=e.config?.identity||{};v(e),h(e.id),Ie(e.name||``),Re(e.label||``),Be(e.description||``),y(e.color||s()),He(n.role||``),Ue(n.identity||``),We(n.instructions||``),Ge(e.config?.prompts?.system||``),Ke(e.llmProvider||`anthropic`),qe(e.config?.apiKey||``),D(e.config?.baseUrl||d(e.llmProvider)),k(e.model||we[e.llmProvider]||``);let r=e.config?.connectors?.[e.llmProvider];r&&(Ye(r.temperature??.7),A(r.maxTokens??4096),Qe(r.topP??1)),Ct(JSON.stringify(e.config?.tools??{},null,2)),Tt(null),Ae(null);try{j(await ye(e.id))}catch{j([])}}).catch(e=>{t||Ae(e instanceof Error?e.message:`Failed to load agent`)}).finally(()=>{t||Oe(!1)}),()=>{t=!0}},[e,h]),(0,c.useEffect)(()=>{if(g!==`access`&&g!==`tools`||!_?.id)return;let e=_.id,t=!1;return Promise.all([ce(_.id).catch(()=>null),ne().catch(()=>[]),ie().catch(()=>[]),se(_.id).catch(()=>null)]).then(([n,r,ee,i])=>{t||(B(n),vt(r),bt(ee),xt(i?i.tools:[]),ct(e))}),()=>{t=!0}},[g,_?.id]);let Ot=()=>{let e=Se(b,x,S),t;try{let e=JSON.parse(St);e&&typeof e==`object`&&!Array.isArray(e)&&(t=e)}catch{}return{...t===void 0?{}:{tools:t},name:Fe.trim(),label:Le.trim(),description:ze.trim()||void 0,color:Ve,llmProvider:w,model:O,apiKey:T.trim()||(w===_?.llmProvider?void 0:``),baseUrl:E||void 0,config:{type:w,model:O,identity:{role:b.trim()||void 0,identity:x.trim()||void 0,instructions:S.trim()||void 0},prompts:C.trim()||e?{system:C.trim()||e}:void 0,connectors:{[w]:{...w===`anthropic`?{}:{temperature:Je},maxTokens:Xe,topP:Ze}}}}},kt=async e=>{if(e.preventDefault(),_){Me(!0);try{let e=await ve(_.id,Ot());v(e),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Saved`,description:`Agent updated`}),e.name&&e.name!==_.name&&n(`/agents/${encodeURIComponent(e.name)}/settings/${g}`,{replace:!0})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Save failed`,variant:`destructive`})}finally{Me(!1)}}},At=async()=>{if(_&&window.confirm(`Delete agent "${_.label||_.name}"? This cannot be undone.`)){Pe(!0);try{await de(_.id),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Deleted`,description:`Agent removed`}),n(`/agents`)}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Delete failed`,variant:`destructive`})}finally{Pe(!1)}}},jt=()=>{N(``),P(``),I(``),R(``)},Mt=async()=>{if(!(!_||!L.trim()&&!F.trim())){it(!0);try{let e=await le(_.id,L.trim()?{source:L.trim()}:{name:M,description:nt,content:F});j(e),jt(),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Installed`,description:`Skill saved`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Skill install failed`,variant:`destructive`})}finally{it(!1)}}},Nt=async e=>{if(_){ot(e);try{let t=await me(_.id,e);j(t),(M===e||L===e)&&jt(),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Removed`,description:`Skill "${e}" removed`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Skill remove failed`,variant:`destructive`})}finally{ot(null)}}},Pt=()=>Y===`global`?{type:`global`}:Y===`context`?Z?{type:`context`,context:Z}:null:X?Y===`path`?{type:`path`,workspace:X,path:dt.trim()||`/`}:{type:`workspace`,workspace:X}:null,Ft=async()=>{if(!_||V)return;let e=Pt(),t=[];if(mt&&t.push(`read`),Q&&t.push(`write`),!e||!/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$/.test(G.trim())||t.length===0||!q&&z?.grants.some(e=>e.id===G.trim())){u({title:`Invalid binding`,description:`Choose a unique connection name (letters, numbers, hyphens or underscores), scope and permissions`,variant:`destructive`});return}if(!(e.type===`global`&&!window.confirm(`Global scope lets this agent ${Q?`read and write`:`read`} ALL your workspaces. Continue?`))){H(!0);try{let n=await oe(_.id,G.trim(),{label:z?.grants.find(e=>e.id===G.trim())?.label||G.trim(),binding:e,permissions:t});B(n.access),W(n.tokens[0]?.token??null),K(``),J(!1),u({title:`Connection saved`,description:`Other connections and their tokens are unchanged`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Bind failed`,variant:`destructive`})}finally{H(!1)}}},It=async e=>{if(!(!_||V)){H(!0);try{let t=await ue(_.id,e);B(t.access),W(t.tokens[0]?.token??null),u({title:`Rotated`,description:`New token minted — the previous one no longer works`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Rotate failed`,variant:`destructive`})}finally{H(!1)}}},Lt=e=>{K(e.id),J(!0),lt(e.binding.type),ut(e.binding.workspace||``),ft(e.binding.path||`/`),pt(e.binding.context||``),ht(e.permissions.includes(`read`)),gt(e.permissions.includes(`write`))},Rt=async e=>{if(!(!_||V)){H(!0);try{let t=await he(_.id,e);B(t.access),W(null),G===e&&(K(``),J(!1))}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Revoke failed`,variant:`destructive`})}finally{H(!1)}}},zt=async()=>{if(!(!_||V)&&window.confirm(`Revoke this agent's canvas access? All its connection tokens stop working immediately.`)){H(!0);try{await pe(_.id),B(null),W(null),u({title:`Revoked`,description:`Agent access removed`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Revoke failed`,variant:`destructive`})}finally{H(!1)}}},Bt=e=>{if(e.type===`global`)return`Global — all workspaces`;if(e.type===`context`){let t=yt.find(t=>t.id===e.context);return`Context ${t?`${t.id} (${t.url})`:e.context} — follows the context live`}let t=e.workspaceName||e.workspace;return e.type===`path`?`Workspace ${t}, path ${e.path||`/`}`:`Workspace ${t} (whole tree)`};if(De)return(0,l.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:`Loading...`});if(!_||ke)return(0,l.jsx)(`div`,{className:`p-6 text-sm text-destructive`,children:ke||`Agent not found`});let Vt=_e.find(e=>e.id===g),Ht=encodeURIComponent(_.name||_.id),Ut=g===`identity`||g===`provider`||g===`models`||g===`tools`;return(0,l.jsx)(`div`,{className:`h-full min-h-0 overflow-y-auto`,children:(0,l.jsxs)(`div`,{className:`mx-auto max-w-5xl p-6 pb-12 max-md:px-4 max-md:pb-rail-stack`,children:[(0,l.jsx)(be,{compact:!0,className:`mb-6 border-b pb-4`,title:`${Vt.label} - ${_.label||_.name}`,description:Vt.description,backTo:`/agents/${Ht}`,onBack:Ee?Te:void 0}),(0,l.jsxs)(`form`,{onSubmit:kt,className:`space-y-6`,children:[g===`identity`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,l.jsx)(f,{label:`Name`,hint:`ID: ${_.id}`,children:(0,l.jsx)(o,{value:Fe,onChange:e=>Ie(e.target.value),placeholder:`lucy`})}),(0,l.jsx)(f,{label:`Label`,children:(0,l.jsx)(o,{value:Le,onChange:e=>Re(e.target.value),placeholder:`Display name`})})]}),(0,l.jsx)(f,{label:`Description`,children:(0,l.jsx)(o,{value:ze,onChange:e=>Be(e.target.value),placeholder:`Short description`})}),(0,l.jsx)(f,{label:`Color`,children:(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(o,{type:`color`,value:Ve,onChange:e=>y(e.target.value),className:`h-10 w-16 p-1`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>y(s()),children:`Randomize`})]})})]}),(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Persona`}),(0,l.jsx)(f,{label:`Role`,children:(0,l.jsx)(o,{value:b,onChange:e=>He(e.target.value),placeholder:`e.g. Software Engineer`})}),(0,l.jsx)(f,{label:`Identity`,children:(0,l.jsx)(`textarea`,{value:x,onChange:e=>Ue(e.target.value),placeholder:`Who this agent is…`,className:`${p} min-h-[80px]`})}),(0,l.jsx)(f,{label:`Instructions`,children:(0,l.jsx)(`textarea`,{value:S,onChange:e=>We(e.target.value),placeholder:`Behavioral instructions…`,className:`${p} min-h-[80px]`})}),(0,l.jsx)(f,{label:`System Prompt`,hint:`Compiled from Role + Identity + Instructions. Override manually.`,children:(0,l.jsx)(`textarea`,{value:C,onChange:e=>Ge(e.target.value),placeholder:`System prompt sent to the LLM…`,className:`${p} min-h-[140px] font-mono text-xs`})})]}),(0,l.jsxs)(`section`,{className:`rounded-lg border border-destructive/30 p-4`,children:[(0,l.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-destructive`,children:`Danger Zone`}),(0,l.jsxs)(a,{type:`button`,variant:`destructive`,disabled:Ne,onClick:At,children:[(0,l.jsx)(i,{className:`mr-2 h-4 w-4`}),Ne?`Deleting...`:`Delete Agent`]})]})]}),g===`provider`&&(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(f,{label:`Provider`,children:(0,l.jsxs)(`select`,{value:w,onChange:e=>{let t=e.target.value;Ke(t),qe(``),k(we[t]||``),D(d(t))},className:`w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring`,children:[(0,l.jsx)(`option`,{value:`anthropic`,children:`Anthropic Claude`}),(0,l.jsx)(`option`,{value:`openai`,children:`OpenAI GPT`}),(0,l.jsx)(`option`,{value:`ollama`,children:`Ollama (Local)`}),(0,l.jsx)(`option`,{value:`lm-studio`,children:`LM Studio (Local)`}),(0,l.jsx)(`option`,{value:`vllm`,children:`vLLM (Local)`}),(0,l.jsx)(`option`,{value:`custom`,children:`Custom`})]})}),(0,l.jsx)(f,{label:`API Key`,hint:[`ollama`,`lm-studio`,`vllm`].includes(w)?`Any value works for local providers.`:void 0,children:(0,l.jsx)(o,{type:`password`,value:T,onChange:e=>qe(e.target.value),placeholder:w===`ollama`?`ollama`:w===`lm-studio`?`lm-studio`:`sk-…`})}),(0,l.jsx)(f,{label:`Host / Base URL`,children:(0,l.jsx)(o,{value:E,onChange:e=>D(e.target.value),placeholder:d(w)||`https://api.example.com`})})]}),g===`models`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Main Model`}),(0,l.jsx)(f,{label:`Model`,children:(0,l.jsx)(xe,{value:O,onChange:(e,t)=>{k(e),t?.maxTokens&&A(t.maxTokens)},...$e})}),(0,l.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[w!==`anthropic`&&(0,l.jsx)(f,{label:`Temperature`,children:(0,l.jsx)(o,{type:`number`,min:0,max:2,step:.1,value:Je,onChange:e=>Ye(Number.isNaN(e.target.valueAsNumber)?.7:e.target.valueAsNumber)})}),(0,l.jsx)(f,{label:`Max Output Tokens`,children:(0,l.jsx)(o,{type:`number`,min:1,max:et?.maxTokens,value:Xe,onChange:e=>A(parseInt(e.target.value)||4096)})}),(0,l.jsx)(f,{label:`Top P`,children:(0,l.jsx)(o,{type:`number`,min:0,max:1,step:.1,value:Ze,onChange:e=>Qe(Number.isNaN(e.target.valueAsNumber)?1:e.target.valueAsNumber)})})]})]}),[`Governance`,`Memory Management`,`Subagent / Tool Use`].map(e=>(0,l.jsxs)(`section`,{className:`rounded-lg border border-dashed p-4`,children:[(0,l.jsxs)(`h2`,{className:`text-sm font-semibold text-muted-foreground`,children:[e,` Model`]}),(0,l.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Coming soon`})]},e))]}),g===`tools`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Runtime Tools`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Injected at start (pi defineTool): coding tools plus canvas tools scoped by the token binding (Access / ACL). Definitions live in the runtime — read-only here until the agent-runtime workspace lands.`})]}),$===null?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`Loading…`}):$.length===0?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`No tools resolved.`}):(0,l.jsx)(`div`,{className:`space-y-1.5`,children:$.map(e=>(0,l.jsxs)(`details`,{className:`rounded-md border px-3 py-2`,children:[(0,l.jsxs)(`summary`,{className:`cursor-pointer text-sm`,children:[(0,l.jsx)(`code`,{className:`font-mono text-xs font-medium`,children:e.name}),(0,l.jsx)(`span`,{className:`ml-2 rounded bg-muted px-1.5 py-0.5 text-[10px] uppercase text-muted-foreground`,children:e.source})]}),e.description&&(0,l.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-xs text-muted-foreground`,children:e.description}),e.parameters!=null&&(0,l.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded bg-muted p-2 font-mono text-[11px]`,children:JSON.stringify(e.parameters,null,2)})]},e.name))}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:z?z.grants.map(e=>`${e.label}: ${Bt(e.binding)}`).join(`; `):`Unbound — no canvas tools are injected. Bind under Access / ACL.`})]}),(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Tools Config`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`config.tools JSON, merged server-side — e.g. {"canvas": {"enabled": false}} gates the canvas tools. Saved with Save Changes.`})]}),(0,l.jsx)(`textarea`,{value:St,onChange:e=>{Ct(e.target.value);try{JSON.parse(e.target.value),Tt(null)}catch(e){Tt(e instanceof Error?e.message:`Invalid JSON`)}},className:`${p} min-h-[120px] font-mono text-xs`}),wt&&(0,l.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`Invalid JSON (not saved): `,wt]})]}),(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Skills`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Installed skills are saved immediately, independent of Save Changes.`})]}),tt.length===0?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`No skills installed.`}):tt.map(e=>(0,l.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border p-3`,children:[(0,l.jsxs)(`div`,{className:`min-w-0`,children:[(0,l.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.name}),(0,l.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.package?e.source:e.description||`No description`})]}),(0,l.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{N(e.name),P(e.description||``),I(e.content||``),R(e.source||``)},children:`Edit`}),(0,l.jsx)(a,{type:`button`,variant:`destructive`,size:`sm`,disabled:at===(e.source||e.name),onClick:()=>Nt(e.source||e.name),children:at===(e.source||e.name)?`Removing…`:`Remove`})]})]},e.name)),(0,l.jsxs)(`div`,{className:`space-y-4 rounded-md border p-4`,children:[(0,l.jsx)(f,{label:`Package Source`,hint:`Use this for whole pi packages. Leave empty to save inline SKILL.md content.`,children:(0,l.jsx)(o,{value:L,onChange:e=>R(e.target.value),placeholder:`npm:@foo/pi-tools or git:github.com/badlogic/pi-doom`})}),(0,l.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,l.jsx)(f,{label:`Name`,children:(0,l.jsx)(o,{value:M,onChange:e=>N(e.target.value),placeholder:`skill-name, or read from frontmatter`,disabled:!!L.trim()})}),(0,l.jsx)(f,{label:`Description`,children:(0,l.jsx)(o,{value:nt,onChange:e=>P(e.target.value),placeholder:`What this skill helps with`,disabled:!!L.trim()})})]}),(0,l.jsx)(f,{label:`SKILL.md Content`,children:(0,l.jsx)(`textarea`,{value:F,onChange:e=>I(e.target.value),placeholder:`# Skill instructions…`,disabled:!!L.trim(),className:`${p} min-h-[160px] font-mono text-xs`})}),(0,l.jsxs)(`div`,{className:`flex gap-2`,children:[(0,l.jsx)(a,{type:`button`,disabled:rt||!L.trim()&&!F.trim(),onClick:Mt,children:rt?`Saving…`:`Install / Update Skill`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,onClick:jt,children:`Clear`})]})]})]}),(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`MCP Servers`}),(_.config?.mcp?.servers||[]).length===0?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`No MCP servers configured.`}):(_.config?.mcp?.servers||[]).map((e,t)=>(0,l.jsxs)(`div`,{className:`rounded-md border p-3`,children:[(0,l.jsx)(`div`,{className:`text-sm font-medium`,children:e.name}),(0,l.jsxs)(`div`,{className:`font-mono text-xs text-muted-foreground`,children:[e.command,` `,(e.args||[]).join(` `)]})]},t))]})]}),g===`access`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Canvas Access`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Add named connections to workspaces, paths or contexts, with permissions for each. Every connection has its own scoped token. Overlapping grants are additive: a whole-workspace grant is not restricted by a context on that workspace.`})]}),st===_.id?z?(0,l.jsxs)(`div`,{className:`space-y-2`,children:[z.grants.map(e=>(0,l.jsxs)(`div`,{className:`space-y-2 rounded-md border p-3`,children:[(0,l.jsx)(`div`,{className:`text-sm font-medium`,children:e.label||e.id}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:Bt(e.binding)}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Permissions: `,e.permissions.join(`, `)]}),(0,l.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,disabled:V,onClick:()=>Lt(e),children:`Edit`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,disabled:V,onClick:()=>It(e.id),children:`Rotate Token`}),(0,l.jsx)(a,{type:`button`,variant:`destructive`,size:`sm`,disabled:V,onClick:()=>Rt(e.id),children:`Remove`})]})]},e.id)),(0,l.jsx)(a,{type:`button`,variant:`destructive`,size:`sm`,disabled:V,onClick:zt,children:`Revoke All Access`})]}):(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`Unbound — this agent has no canvas access.`}):(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`Loading…`}),U&&(0,l.jsxs)(`div`,{className:`space-y-2 rounded-md border border-warning/50 bg-warning/10 p-3`,children:[(0,l.jsx)(`div`,{className:`text-xs font-medium`,children:`Agent token — shown once, store it now`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`code`,{className:`flex-1 truncate rounded bg-background px-2 py-1 font-mono text-xs`,children:U}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>navigator.clipboard?.writeText(U),children:`Copy`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>W(null),children:`Dismiss`})]}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Managed agents receive their connections automatically. External runtimes use the CANVAS_CONNECTIONS JSON array.`})]})]}),(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:q?`Edit Connection`:`Add Connection`}),(0,l.jsx)(f,{label:`Connection name`,hint:`Agents use this name to select the scope for each tool call.`,children:(0,l.jsx)(o,{value:G,disabled:q,onChange:e=>K(e.target.value),placeholder:`bar, baz, baf`})}),(0,l.jsx)(f,{label:`Scope`,hint:`Context bindings follow the context live; global spans all workspaces.`,children:(0,l.jsxs)(`select`,{value:Y,onChange:e=>lt(e.target.value),className:m,children:[(0,l.jsx)(`option`,{value:`context`,children:`Context (follows live)`}),(0,l.jsx)(`option`,{value:`workspace`,children:`Workspace`}),(0,l.jsx)(`option`,{value:`path`,children:`Workspace path`}),(0,l.jsx)(`option`,{value:`global`,children:`Global (all workspaces)`})]})}),Y===`context`&&(0,l.jsx)(f,{label:`Context`,children:(0,l.jsxs)(`select`,{value:Z,onChange:e=>pt(e.target.value),className:m,children:[(0,l.jsx)(`option`,{value:``,children:`Select a context…`}),yt.map(e=>(0,l.jsxs)(`option`,{value:e.id,children:[e.id,` — `,e.url]},e.id))]})}),(Y===`workspace`||Y===`path`)&&(0,l.jsx)(f,{label:`Workspace`,children:(0,l.jsxs)(`select`,{value:X,onChange:e=>ut(e.target.value),className:m,children:[(0,l.jsx)(`option`,{value:``,children:`Select a workspace…`}),_t.map(e=>(0,l.jsx)(`option`,{value:e.name||e.id,children:e.label||e.name},e.id))]})}),Y===`path`&&(0,l.jsx)(f,{label:`Base path`,hint:`The agent is clamped to this subtree.`,children:(0,l.jsx)(o,{value:dt,onChange:e=>ft(e.target.value),placeholder:`/work/projects/foo`})}),(0,l.jsx)(f,{label:`Permissions`,children:(0,l.jsxs)(`div`,{className:`flex gap-4 text-sm`,children:[(0,l.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:mt,onChange:e=>ht(e.target.checked)}),` read`]}),(0,l.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:Q,onChange:e=>gt(e.target.checked)}),` write`]})]})}),(0,l.jsx)(a,{type:`button`,disabled:V,onClick:Ft,children:V?`Working…`:q?`Save Connection`:`Add Connection`}),q&&(0,l.jsx)(a,{type:`button`,variant:`outline`,onClick:()=>{K(``),J(!1)},children:`Cancel Edit`})]})]}),g===`memory`&&(0,l.jsxs)(`section`,{className:`rounded-lg border border-dashed p-6 text-center`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground`,children:`Memory Engine`}),(0,l.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Loop-based memory management. Settings coming soon.`})]}),g===`integrations`&&(0,l.jsxs)(`section`,{className:`rounded-lg border border-dashed p-6 text-center`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground`,children:`Integrations`}),(0,l.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`IMAP, chat, SQL and REST API accounts. Coming soon.`})]}),Ut&&(0,l.jsx)(a,{type:`submit`,disabled:je,children:je?`Saving…`:`Save Changes`})]})]})})}export{h as default};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{_ as r,g as ee}from"./chunk-62JRHF6Z-vspAGgtK.js";import{X as i}from"./ui-76Hw0NU_.js";import{t as a}from"./button-Bum-POPT.js";import{t as o}from"./input-BOtCd4HP.js";import{n as te}from"./use-toast-BlLDqSUO.js";import{Nt as ne}from"./workspace-46EFyEKZ.js";import{t as re}from"./use-mobile-Db-vWu9Y.js";import{p as ie}from"./context-BGgz0Y_q.js";import{t as s}from"./color-DFEH4BfK.js";import{i as ae}from"./use-menu-CaiLyPdw.js";import{$ as oe,G as se,H as ce,K as le,Q as ue,R as de,V as fe,X as pe,Y as me,Z as he,_t as ge,mt as _e,nt as ve,q as ye}from"./index-D-y76fV7.js";import{n as be}from"./page-header-BoCaZiqu.js";import{n as xe,r as Se,t as Ce}from"./useAgentModels-fXPBeHX2.js";var c=e(n(),1),l=t(),we={anthropic:`claude-3-5-sonnet-20241022`,openai:`gpt-4o`,ollama:`qwen2.5-coder:latest`,"lm-studio":``,vllm:``,custom:``},u={anthropic:`https://api.anthropic.com`,openai:`https://api.openai.com/v1`,ollama:`http://localhost:11434/v1`,"lm-studio":`http://localhost:1234/v1`,vllm:`http://localhost:8000/v1`,custom:``};function d(e){return u[e]||``}function f({label:e,hint:t,children:n}){return(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:`text-sm font-medium`,children:e}),t&&(0,l.jsx)(`p`,{className:`mb-1 mt-0.5 text-xs text-muted-foreground`,children:t}),(0,l.jsx)(`div`,{className:t?void 0:`mt-1`,children:n})]})}var p=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring resize-y`,m=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring`;function h(){let{agentId:e,tab:t}=r(),n=ee(),{showToast:u}=te(),{selectEntity:h,goBack:Te}=ae(),Ee=re(),g=ge(t);(0,c.useEffect)(()=>{t!==g&&e&&n(`/agents/${encodeURIComponent(e)}/settings/${g}`,{replace:!0})},[t,g,e,n]);let[_,v]=(0,c.useState)(null),[De,Oe]=(0,c.useState)(!0),[ke,Ae]=(0,c.useState)(null),[je,Me]=(0,c.useState)(!1),[Ne,Pe]=(0,c.useState)(!1),[Fe,Ie]=(0,c.useState)(``),[Le,Re]=(0,c.useState)(``),[ze,Be]=(0,c.useState)(``),[Ve,y]=(0,c.useState)(s()),[b,He]=(0,c.useState)(``),[x,Ue]=(0,c.useState)(``),[S,We]=(0,c.useState)(``),[C,Ge]=(0,c.useState)(``),[w,Ke]=(0,c.useState)(`anthropic`),[T,qe]=(0,c.useState)(``),[E,D]=(0,c.useState)(``),[O,k]=(0,c.useState)(``),[Je,Ye]=(0,c.useState)(.7),[Xe,A]=(0,c.useState)(4096),[Ze,Qe]=(0,c.useState)(1),$e=Ce(w,T,E,_?.id),et=$e.models.find(e=>e.id===O),[tt,j]=(0,c.useState)([]),[M,N]=(0,c.useState)(``),[nt,P]=(0,c.useState)(``),[F,I]=(0,c.useState)(``),[L,R]=(0,c.useState)(``),[rt,it]=(0,c.useState)(!1),[at,ot]=(0,c.useState)(null),[z,B]=(0,c.useState)(null),[st,ct]=(0,c.useState)(null),[V,H]=(0,c.useState)(!1),[U,W]=(0,c.useState)(null),[G,K]=(0,c.useState)(``),[q,J]=(0,c.useState)(!1),[Y,lt]=(0,c.useState)(`context`),[X,ut]=(0,c.useState)(``),[dt,ft]=(0,c.useState)(`/`),[Z,pt]=(0,c.useState)(``),[mt,ht]=(0,c.useState)(!0),[Q,gt]=(0,c.useState)(!1),[_t,vt]=(0,c.useState)([]),[yt,bt]=(0,c.useState)([]),[$,xt]=(0,c.useState)(null),[St,Ct]=(0,c.useState)(`{}`),[wt,Tt]=(0,c.useState)(null),[Et,Dt]=(0,c.useState)(e);Et!==e&&(Dt(e),Oe(!0),v(null)),(0,c.useEffect)(()=>{if(!e)return;let t=!1;return fe(e).then(async e=>{if(t)return;let n=e.config?.identity||{};v(e),h(e.id),Ie(e.name||``),Re(e.label||``),Be(e.description||``),y(e.color||s()),He(n.role||``),Ue(n.identity||``),We(n.instructions||``),Ge(e.config?.prompts?.system||``),Ke(e.llmProvider||`anthropic`),qe(e.config?.apiKey||``),D(e.config?.baseUrl||d(e.llmProvider)),k(e.model||we[e.llmProvider]||``);let r=e.config?.connectors?.[e.llmProvider];r&&(Ye(r.temperature??.7),A(r.maxTokens??4096),Qe(r.topP??1)),Ct(JSON.stringify(e.config?.tools??{},null,2)),Tt(null),Ae(null);try{j(await ye(e.id))}catch{j([])}}).catch(e=>{t||Ae(e instanceof Error?e.message:`Failed to load agent`)}).finally(()=>{t||Oe(!1)}),()=>{t=!0}},[e,h]),(0,c.useEffect)(()=>{if(g!==`access`&&g!==`tools`||!_?.id)return;let e=_.id,t=!1;return Promise.all([ce(_.id).catch(()=>null),ne().catch(()=>[]),ie().catch(()=>[]),se(_.id).catch(()=>null)]).then(([n,r,ee,i])=>{t||(B(n),vt(r),bt(ee),xt(i?i.tools:[]),ct(e))}),()=>{t=!0}},[g,_?.id]);let Ot=()=>{let e=Se(b,x,S),t;try{let e=JSON.parse(St);e&&typeof e==`object`&&!Array.isArray(e)&&(t=e)}catch{}return{...t===void 0?{}:{tools:t},name:Fe.trim(),label:Le.trim(),description:ze.trim()||void 0,color:Ve,llmProvider:w,model:O,apiKey:T.trim()||(w===_?.llmProvider?void 0:``),baseUrl:E||void 0,config:{type:w,model:O,identity:{role:b.trim()||void 0,identity:x.trim()||void 0,instructions:S.trim()||void 0},prompts:C.trim()||e?{system:C.trim()||e}:void 0,connectors:{[w]:{...w===`anthropic`?{}:{temperature:Je},maxTokens:Xe,topP:Ze}}}}},kt=async e=>{if(e.preventDefault(),_){Me(!0);try{let e=await ve(_.id,Ot());v(e),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Saved`,description:`Agent updated`}),e.name&&e.name!==_.name&&n(`/agents/${encodeURIComponent(e.name)}/settings/${g}`,{replace:!0})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Save failed`,variant:`destructive`})}finally{Me(!1)}}},At=async()=>{if(_&&window.confirm(`Delete agent "${_.label||_.name}"? This cannot be undone.`)){Pe(!0);try{await de(_.id),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Deleted`,description:`Agent removed`}),n(`/agents`)}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Delete failed`,variant:`destructive`})}finally{Pe(!1)}}},jt=()=>{N(``),P(``),I(``),R(``)},Mt=async()=>{if(!(!_||!L.trim()&&!F.trim())){it(!0);try{let e=await le(_.id,L.trim()?{source:L.trim()}:{name:M,description:nt,content:F});j(e),jt(),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Installed`,description:`Skill saved`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Skill install failed`,variant:`destructive`})}finally{it(!1)}}},Nt=async e=>{if(_){ot(e);try{let t=await me(_.id,e);j(t),(M===e||L===e)&&jt(),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Removed`,description:`Skill "${e}" removed`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Skill remove failed`,variant:`destructive`})}finally{ot(null)}}},Pt=()=>Y===`global`?{type:`global`}:Y===`context`?Z?{type:`context`,context:Z}:null:X?Y===`path`?{type:`path`,workspace:X,path:dt.trim()||`/`}:{type:`workspace`,workspace:X}:null,Ft=async()=>{if(!_||V)return;let e=Pt(),t=[];if(mt&&t.push(`read`),Q&&t.push(`write`),!e||!/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$/.test(G.trim())||t.length===0||!q&&z?.grants.some(e=>e.id===G.trim())){u({title:`Invalid binding`,description:`Choose a unique connection name (letters, numbers, hyphens or underscores), scope and permissions`,variant:`destructive`});return}if(!(e.type===`global`&&!window.confirm(`Global scope lets this agent ${Q?`read and write`:`read`} ALL your workspaces. Continue?`))){H(!0);try{let n=await oe(_.id,G.trim(),{label:z?.grants.find(e=>e.id===G.trim())?.label||G.trim(),binding:e,permissions:t});B(n.access),W(n.tokens[0]?.token??null),K(``),J(!1),u({title:`Connection saved`,description:`Other connections and their tokens are unchanged`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Bind failed`,variant:`destructive`})}finally{H(!1)}}},It=async e=>{if(!(!_||V)){H(!0);try{let t=await ue(_.id,e);B(t.access),W(t.tokens[0]?.token??null),u({title:`Rotated`,description:`New token minted — the previous one no longer works`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Rotate failed`,variant:`destructive`})}finally{H(!1)}}},Lt=e=>{K(e.id),J(!0),lt(e.binding.type),ut(e.binding.workspace||``),ft(e.binding.path||`/`),pt(e.binding.context||``),ht(e.permissions.includes(`read`)),gt(e.permissions.includes(`write`))},Rt=async e=>{if(!(!_||V)){H(!0);try{let t=await he(_.id,e);B(t.access),W(null),G===e&&(K(``),J(!1))}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Revoke failed`,variant:`destructive`})}finally{H(!1)}}},zt=async()=>{if(!(!_||V)&&window.confirm(`Revoke this agent's canvas access? All its connection tokens stop working immediately.`)){H(!0);try{await pe(_.id),B(null),W(null),u({title:`Revoked`,description:`Agent access removed`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Revoke failed`,variant:`destructive`})}finally{H(!1)}}},Bt=e=>{if(e.type===`global`)return`Global — all workspaces`;if(e.type===`context`){let t=yt.find(t=>t.id===e.context);return`Context ${t?`${t.id} (${t.url})`:e.context} — follows the context live`}let t=e.workspaceName||e.workspace;return e.type===`path`?`Workspace ${t}, path ${e.path||`/`}`:`Workspace ${t} (whole tree)`};if(De)return(0,l.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:`Loading...`});if(!_||ke)return(0,l.jsx)(`div`,{className:`p-6 text-sm text-destructive`,children:ke||`Agent not found`});let Vt=_e.find(e=>e.id===g),Ht=encodeURIComponent(_.name||_.id),Ut=g===`identity`||g===`provider`||g===`models`||g===`tools`;return(0,l.jsx)(`div`,{className:`h-full min-h-0 overflow-y-auto`,children:(0,l.jsxs)(`div`,{className:`mx-auto max-w-5xl p-6 pb-12 max-md:px-4 max-md:pb-rail-stack`,children:[(0,l.jsx)(be,{compact:!0,className:`mb-6 border-b pb-4`,title:`${Vt.label} - ${_.label||_.name}`,description:Vt.description,backTo:`/agents/${Ht}`,onBack:Ee?Te:void 0}),(0,l.jsxs)(`form`,{onSubmit:kt,className:`space-y-6`,children:[g===`identity`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,l.jsx)(f,{label:`Name`,hint:`ID: ${_.id}`,children:(0,l.jsx)(o,{value:Fe,onChange:e=>Ie(e.target.value),placeholder:`lucy`})}),(0,l.jsx)(f,{label:`Label`,children:(0,l.jsx)(o,{value:Le,onChange:e=>Re(e.target.value),placeholder:`Display name`})})]}),(0,l.jsx)(f,{label:`Description`,children:(0,l.jsx)(o,{value:ze,onChange:e=>Be(e.target.value),placeholder:`Short description`})}),(0,l.jsx)(f,{label:`Color`,children:(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(o,{type:`color`,value:Ve,onChange:e=>y(e.target.value),className:`h-10 w-16 p-1`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>y(s()),children:`Randomize`})]})})]}),(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Persona`}),(0,l.jsx)(f,{label:`Role`,children:(0,l.jsx)(o,{value:b,onChange:e=>He(e.target.value),placeholder:`e.g. Software Engineer`})}),(0,l.jsx)(f,{label:`Identity`,children:(0,l.jsx)(`textarea`,{value:x,onChange:e=>Ue(e.target.value),placeholder:`Who this agent is…`,className:`${p} min-h-[80px]`})}),(0,l.jsx)(f,{label:`Instructions`,children:(0,l.jsx)(`textarea`,{value:S,onChange:e=>We(e.target.value),placeholder:`Behavioral instructions…`,className:`${p} min-h-[80px]`})}),(0,l.jsx)(f,{label:`System Prompt`,hint:`Compiled from Role + Identity + Instructions. Override manually.`,children:(0,l.jsx)(`textarea`,{value:C,onChange:e=>Ge(e.target.value),placeholder:`System prompt sent to the LLM…`,className:`${p} min-h-[140px] font-mono text-xs`})})]}),(0,l.jsxs)(`section`,{className:`rounded-lg border border-destructive/30 p-4`,children:[(0,l.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-destructive`,children:`Danger Zone`}),(0,l.jsxs)(a,{type:`button`,variant:`destructive`,disabled:Ne,onClick:At,children:[(0,l.jsx)(i,{className:`mr-2 h-4 w-4`}),Ne?`Deleting...`:`Delete Agent`]})]})]}),g===`provider`&&(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(f,{label:`Provider`,children:(0,l.jsxs)(`select`,{value:w,onChange:e=>{let t=e.target.value;Ke(t),qe(``),k(we[t]||``),D(d(t))},className:`w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring`,children:[(0,l.jsx)(`option`,{value:`anthropic`,children:`Anthropic Claude`}),(0,l.jsx)(`option`,{value:`openai`,children:`OpenAI GPT`}),(0,l.jsx)(`option`,{value:`ollama`,children:`Ollama (Local)`}),(0,l.jsx)(`option`,{value:`lm-studio`,children:`LM Studio (Local)`}),(0,l.jsx)(`option`,{value:`vllm`,children:`vLLM (Local)`}),(0,l.jsx)(`option`,{value:`custom`,children:`Custom`})]})}),(0,l.jsx)(f,{label:`API Key`,hint:[`ollama`,`lm-studio`,`vllm`].includes(w)?`Any value works for local providers.`:void 0,children:(0,l.jsx)(o,{type:`password`,value:T,onChange:e=>qe(e.target.value),placeholder:w===`ollama`?`ollama`:w===`lm-studio`?`lm-studio`:`sk-…`})}),(0,l.jsx)(f,{label:`Host / Base URL`,children:(0,l.jsx)(o,{value:E,onChange:e=>D(e.target.value),placeholder:d(w)||`https://api.example.com`})})]}),g===`models`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Main Model`}),(0,l.jsx)(f,{label:`Model`,children:(0,l.jsx)(xe,{value:O,onChange:(e,t)=>{k(e),t?.maxTokens&&A(t.maxTokens)},...$e})}),(0,l.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[w!==`anthropic`&&(0,l.jsx)(f,{label:`Temperature`,children:(0,l.jsx)(o,{type:`number`,min:0,max:2,step:.1,value:Je,onChange:e=>Ye(Number.isNaN(e.target.valueAsNumber)?.7:e.target.valueAsNumber)})}),(0,l.jsx)(f,{label:`Max Output Tokens`,children:(0,l.jsx)(o,{type:`number`,min:1,max:et?.maxTokens,value:Xe,onChange:e=>A(parseInt(e.target.value)||4096)})}),(0,l.jsx)(f,{label:`Top P`,children:(0,l.jsx)(o,{type:`number`,min:0,max:1,step:.1,value:Ze,onChange:e=>Qe(Number.isNaN(e.target.valueAsNumber)?1:e.target.valueAsNumber)})})]})]}),[`Governance`,`Memory Management`,`Subagent / Tool Use`].map(e=>(0,l.jsxs)(`section`,{className:`rounded-lg border border-dashed p-4`,children:[(0,l.jsxs)(`h2`,{className:`text-sm font-semibold text-muted-foreground`,children:[e,` Model`]}),(0,l.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Coming soon`})]},e))]}),g===`tools`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Runtime Tools`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Injected at start (pi defineTool): coding tools plus canvas tools scoped by the token binding (Access / ACL). Definitions live in the runtime — read-only here until the agent-runtime workspace lands.`})]}),$===null?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`Loading…`}):$.length===0?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`No tools resolved.`}):(0,l.jsx)(`div`,{className:`space-y-1.5`,children:$.map(e=>(0,l.jsxs)(`details`,{className:`rounded-md border px-3 py-2`,children:[(0,l.jsxs)(`summary`,{className:`cursor-pointer text-sm`,children:[(0,l.jsx)(`code`,{className:`font-mono text-xs font-medium`,children:e.name}),(0,l.jsx)(`span`,{className:`ml-2 rounded bg-muted px-1.5 py-0.5 text-[10px] uppercase text-muted-foreground`,children:e.source})]}),e.description&&(0,l.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-xs text-muted-foreground`,children:e.description}),e.parameters!=null&&(0,l.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded bg-muted p-2 font-mono text-[11px]`,children:JSON.stringify(e.parameters,null,2)})]},e.name))}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:z?z.grants.map(e=>`${e.label}: ${Bt(e.binding)}`).join(`; `):`Unbound — no canvas tools are injected. Bind under Access / ACL.`})]}),(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Tools Config`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`config.tools JSON, merged server-side — e.g. {"canvas": {"enabled": false}} gates the canvas tools. Saved with Save Changes.`})]}),(0,l.jsx)(`textarea`,{value:St,onChange:e=>{Ct(e.target.value);try{JSON.parse(e.target.value),Tt(null)}catch(e){Tt(e instanceof Error?e.message:`Invalid JSON`)}},className:`${p} min-h-[120px] font-mono text-xs`}),wt&&(0,l.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`Invalid JSON (not saved): `,wt]})]}),(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Skills`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Installed skills are saved immediately, independent of Save Changes.`})]}),tt.length===0?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`No skills installed.`}):tt.map(e=>(0,l.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border p-3`,children:[(0,l.jsxs)(`div`,{className:`min-w-0`,children:[(0,l.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.name}),(0,l.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.package?e.source:e.description||`No description`})]}),(0,l.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{N(e.name),P(e.description||``),I(e.content||``),R(e.source||``)},children:`Edit`}),(0,l.jsx)(a,{type:`button`,variant:`destructive`,size:`sm`,disabled:at===(e.source||e.name),onClick:()=>Nt(e.source||e.name),children:at===(e.source||e.name)?`Removing…`:`Remove`})]})]},e.name)),(0,l.jsxs)(`div`,{className:`space-y-4 rounded-md border p-4`,children:[(0,l.jsx)(f,{label:`Package Source`,hint:`Use this for whole pi packages. Leave empty to save inline SKILL.md content.`,children:(0,l.jsx)(o,{value:L,onChange:e=>R(e.target.value),placeholder:`npm:@foo/pi-tools or git:github.com/badlogic/pi-doom`})}),(0,l.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,l.jsx)(f,{label:`Name`,children:(0,l.jsx)(o,{value:M,onChange:e=>N(e.target.value),placeholder:`skill-name, or read from frontmatter`,disabled:!!L.trim()})}),(0,l.jsx)(f,{label:`Description`,children:(0,l.jsx)(o,{value:nt,onChange:e=>P(e.target.value),placeholder:`What this skill helps with`,disabled:!!L.trim()})})]}),(0,l.jsx)(f,{label:`SKILL.md Content`,children:(0,l.jsx)(`textarea`,{value:F,onChange:e=>I(e.target.value),placeholder:`# Skill instructions…`,disabled:!!L.trim(),className:`${p} min-h-[160px] font-mono text-xs`})}),(0,l.jsxs)(`div`,{className:`flex gap-2`,children:[(0,l.jsx)(a,{type:`button`,disabled:rt||!L.trim()&&!F.trim(),onClick:Mt,children:rt?`Saving…`:`Install / Update Skill`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,onClick:jt,children:`Clear`})]})]})]}),(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`MCP Servers`}),(_.config?.mcp?.servers||[]).length===0?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`No MCP servers configured.`}):(_.config?.mcp?.servers||[]).map((e,t)=>(0,l.jsxs)(`div`,{className:`rounded-md border p-3`,children:[(0,l.jsx)(`div`,{className:`text-sm font-medium`,children:e.name}),(0,l.jsxs)(`div`,{className:`font-mono text-xs text-muted-foreground`,children:[e.command,` `,(e.args||[]).join(` `)]})]},t))]})]}),g===`access`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Canvas Access`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Add named connections to workspaces, paths or contexts, with permissions for each. Every connection has its own scoped token. Overlapping grants are additive: a whole-workspace grant is not restricted by a context on that workspace.`})]}),st===_.id?z?(0,l.jsxs)(`div`,{className:`space-y-2`,children:[z.grants.map(e=>(0,l.jsxs)(`div`,{className:`space-y-2 rounded-md border p-3`,children:[(0,l.jsx)(`div`,{className:`text-sm font-medium`,children:e.label||e.id}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:Bt(e.binding)}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Permissions: `,e.permissions.join(`, `)]}),(0,l.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,disabled:V,onClick:()=>Lt(e),children:`Edit`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,disabled:V,onClick:()=>It(e.id),children:`Rotate Token`}),(0,l.jsx)(a,{type:`button`,variant:`destructive`,size:`sm`,disabled:V,onClick:()=>Rt(e.id),children:`Remove`})]})]},e.id)),(0,l.jsx)(a,{type:`button`,variant:`destructive`,size:`sm`,disabled:V,onClick:zt,children:`Revoke All Access`})]}):(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`Unbound — this agent has no canvas access.`}):(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`Loading…`}),U&&(0,l.jsxs)(`div`,{className:`space-y-2 rounded-md border border-warning/50 bg-warning/10 p-3`,children:[(0,l.jsx)(`div`,{className:`text-xs font-medium`,children:`Agent token — shown once, store it now`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`code`,{className:`flex-1 truncate rounded bg-background px-2 py-1 font-mono text-xs`,children:U}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>navigator.clipboard?.writeText(U),children:`Copy`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>W(null),children:`Dismiss`})]}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Managed agents receive their connections automatically. External runtimes use the CANVAS_CONNECTIONS JSON array.`})]})]}),(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:q?`Edit Connection`:`Add Connection`}),(0,l.jsx)(f,{label:`Connection name`,hint:`Agents use this name to select the scope for each tool call.`,children:(0,l.jsx)(o,{value:G,disabled:q,onChange:e=>K(e.target.value),placeholder:`bar, baz, baf`})}),(0,l.jsx)(f,{label:`Scope`,hint:`Context bindings follow the context live; global spans all workspaces.`,children:(0,l.jsxs)(`select`,{value:Y,onChange:e=>lt(e.target.value),className:m,children:[(0,l.jsx)(`option`,{value:`context`,children:`Context (follows live)`}),(0,l.jsx)(`option`,{value:`workspace`,children:`Workspace`}),(0,l.jsx)(`option`,{value:`path`,children:`Workspace path`}),(0,l.jsx)(`option`,{value:`global`,children:`Global (all workspaces)`})]})}),Y===`context`&&(0,l.jsx)(f,{label:`Context`,children:(0,l.jsxs)(`select`,{value:Z,onChange:e=>pt(e.target.value),className:m,children:[(0,l.jsx)(`option`,{value:``,children:`Select a context…`}),yt.map(e=>(0,l.jsxs)(`option`,{value:e.id,children:[e.id,` — `,e.url]},e.id))]})}),(Y===`workspace`||Y===`path`)&&(0,l.jsx)(f,{label:`Workspace`,children:(0,l.jsxs)(`select`,{value:X,onChange:e=>ut(e.target.value),className:m,children:[(0,l.jsx)(`option`,{value:``,children:`Select a workspace…`}),_t.map(e=>(0,l.jsx)(`option`,{value:e.name||e.id,children:e.label||e.name},e.id))]})}),Y===`path`&&(0,l.jsx)(f,{label:`Base path`,hint:`The agent is clamped to this subtree.`,children:(0,l.jsx)(o,{value:dt,onChange:e=>ft(e.target.value),placeholder:`/work/projects/foo`})}),(0,l.jsx)(f,{label:`Permissions`,children:(0,l.jsxs)(`div`,{className:`flex gap-4 text-sm`,children:[(0,l.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:mt,onChange:e=>ht(e.target.checked)}),` read`]}),(0,l.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:Q,onChange:e=>gt(e.target.checked)}),` write`]})]})}),(0,l.jsx)(a,{type:`button`,disabled:V,onClick:Ft,children:V?`Working…`:q?`Save Connection`:`Add Connection`}),q&&(0,l.jsx)(a,{type:`button`,variant:`outline`,onClick:()=>{K(``),J(!1)},children:`Cancel Edit`})]})]}),g===`memory`&&(0,l.jsxs)(`section`,{className:`rounded-lg border border-dashed p-6 text-center`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground`,children:`Memory Engine`}),(0,l.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Loop-based memory management. Settings coming soon.`})]}),g===`integrations`&&(0,l.jsxs)(`section`,{className:`rounded-lg border border-dashed p-6 text-center`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground`,children:`Integrations`}),(0,l.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`IMAP, chat, SQL and REST API accounts. Coming soon.`})]}),Ut&&(0,l.jsx)(a,{type:`submit`,disabled:je,children:je?`Saving…`:`Save Changes`})]})]})})}export{h as default};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{r}from"./chunk-62JRHF6Z-vspAGgtK.js";import{ui as i}from"./ui-76Hw0NU_.js";import{t as a}from"./input-BOtCd4HP.js";import{Nt as o}from"./workspace-46EFyEKZ.js";import{p as s}from"./context-BGgz0Y_q.js";import{i as c,m as l,p as u}from"./use-menu-CaiLyPdw.js";import{J as d,gt as f,ht as p,mt as m}from"./index-Pdg5xeG3.js";import{n as h}from"./page-header-BoCaZiqu.js";var g=e(n(),1),_=t(),v=[{id:`workspace`,label:`Workspace`,path:`workspaces`,description:`Files, search, devices and sharing for one workspace. These settings override account defaults.`,sections:f,load:async()=>(await o()).map(e=>({id:e.name,label:e.label||e.name}))},{id:`context`,label:`Context`,path:`contexts`,description:`Choose the tree and path a context opens, and who can access that view. File storage belongs to its workspace.`,sections:p,load:async()=>(await s()).map(e=>({id:e.id,label:e.name||e.id}))},{id:`agent`,label:`Agent`,path:`agents`,description:`Configure one assistant: its instructions, chat model, tools and access to Canvas.`,sections:m,load:async()=>(await d()).map(e=>({id:e.id,label:e.label||e.name}))}];function y({to:e,label:t,description:n,icon:a}){return(0,_.jsxs)(r,{to:e,className:`group flex items-start gap-3 rounded-lg border bg-card p-4 transition-colors hover:border-primary/50 hover:bg-accent/30 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary`,children:[(0,_.jsx)(a,{className:`mt-0.5 h-5 w-5 shrink-0 text-muted-foreground`}),(0,_.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,_.jsx)(`span`,{className:`block text-sm font-semibold`,children:t}),(0,_.jsx)(`span`,{className:`mt-1 block text-sm leading-relaxed text-muted-foreground`,children:n})]}),(0,_.jsx)(i,{className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground group-hover:text-primary`})]})}function b({group:e,query:t}){let[n,r]=(0,g.useState)([]),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)(`loading`),[c,u]=(0,g.useState)(0);(0,g.useEffect)(()=>{let t=!1;return e.load().then(e=>{t||(r(e),s(`ready`))}).catch(()=>{t||s(`error`)}),()=>{t=!0}},[e,c]);let d=e.sections.filter(n=>l(t,e.label,n.label,n.description));return d.length?(0,_.jsxs)(`section`,{id:e.id,className:`scroll-mt-6 space-y-3`,children:[(0,_.jsx)(`h2`,{className:`text-lg font-semibold`,children:e.label}),(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description}),(0,_.jsxs)(`label`,{className:`block max-w-md text-sm font-medium`,children:[`Choose a `,e.label.toLowerCase(),(0,_.jsxs)(`select`,{className:`mt-2 h-10 w-full rounded-md border bg-background px-3 text-sm`,value:i,disabled:o!==`ready`||!n.length,onChange:e=>a(e.target.value),children:[(0,_.jsx)(`option`,{value:``,children:o===`loading`?`Loading…`:o===`error`?`Unable to load list`:n.length?`Select ${e.label.toLowerCase()}…`:`No ${e.path} available`}),n.map(e=>(0,_.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]}),o===`error`&&(0,_.jsxs)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:[`The list could not be loaded. `,(0,_.jsx)(`button`,{type:`button`,className:`underline`,onClick:()=>{s(`loading`),u(e=>e+1)},children:`Retry`})]}),(0,_.jsxs)(`details`,{open:!!(i||t.trim()),children:[(0,_.jsx)(`summary`,{className:`cursor-pointer py-2 text-sm text-muted-foreground`,children:i?`Settings for ${n.find(e=>e.id===i)?.label||i}`:`What you can configure (${d.length})`}),(0,_.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,16rem),1fr))] gap-3`,children:d.map(t=>i?(0,_.jsx)(y,{to:`/${e.path}/${encodeURIComponent(i)}/settings/${t.id}`,...t},t.id):(0,_.jsxs)(`div`,{className:`rounded-lg border border-dashed p-4`,children:[(0,_.jsx)(`p`,{className:`text-sm font-medium`,children:t.label}),(0,_.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:t.description})]},t.id))})]})]}):null}function x(){let{state:e}=c(),[t,n]=(0,g.useState)(``),r=u.filter(t=>t.id!==`server`||e.user?.userType===`admin`).map(e=>({...e,items:e.items.filter(n=>l(t,e.label,n.label,n.description))})).filter(e=>e.items.length),i=v.some(e=>e.sections.some(n=>l(t,e.label,n.label,n.description)));return(0,_.jsxs)(`div`,{className:`mx-auto max-w-6xl space-y-8 pb-8 max-md:pb-rail-stack`,children:[(0,_.jsx)(h,{title:`Settings`,description:`Start with what you want to change. Each section explains where your changes apply.`}),(0,_.jsx)(a,{type:`search`,className:`max-w-xl`,"aria-label":`Search all settings`,placeholder:`Find a setting: offline, folders, models, sharing…`,value:t,onChange:e=>n(e.target.value)}),r.filter(e=>e.id===`device`||e.id===`account`).map(e=>(0,_.jsxs)(`section`,{className:`space-y-3`,children:[(0,_.jsx)(`h2`,{className:`text-lg font-semibold`,children:e.label}),(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description}),(0,_.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,16rem),1fr))] gap-3`,children:e.items.map(e=>(0,_.jsx)(y,{to:e.path,...e},e.path))})]},e.id)),v.map(e=>(0,_.jsx)(b,{group:e,query:t},e.id)),r.filter(e=>e.id===`server`||e.id===`information`).map(e=>(0,_.jsxs)(`section`,{className:`space-y-3`,children:[(0,_.jsx)(`h2`,{className:`text-lg font-semibold`,children:e.label}),(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description}),(0,_.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,16rem),1fr))] gap-3`,children:e.items.map(e=>(0,_.jsx)(y,{to:e.path,...e},e.path))})]},e.id)),!r.length&&!i&&(0,_.jsxs)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:[`No settings match “`,t,`”. Try a shorter phrase or clear the search.`]})]})}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{r}from"./chunk-62JRHF6Z-vspAGgtK.js";import{ui as i}from"./ui-76Hw0NU_.js";import{t as a}from"./input-BOtCd4HP.js";import{Nt as o}from"./workspace-46EFyEKZ.js";import{p as s}from"./context-BGgz0Y_q.js";import{i as c,m as l,p as u}from"./use-menu-CaiLyPdw.js";import{J as d,gt as f,ht as p,mt as m}from"./index-D-y76fV7.js";import{n as h}from"./page-header-BoCaZiqu.js";var g=e(n(),1),_=t(),v=[{id:`workspace`,label:`Workspace`,path:`workspaces`,description:`Files, search, devices and sharing for one workspace. These settings override account defaults.`,sections:f,load:async()=>(await o()).map(e=>({id:e.name,label:e.label||e.name}))},{id:`context`,label:`Context`,path:`contexts`,description:`Choose the tree and path a context opens, and who can access that view. File storage belongs to its workspace.`,sections:p,load:async()=>(await s()).map(e=>({id:e.id,label:e.name||e.id}))},{id:`agent`,label:`Agent`,path:`agents`,description:`Configure one assistant: its instructions, chat model, tools and access to Canvas.`,sections:m,load:async()=>(await d()).map(e=>({id:e.id,label:e.label||e.name}))}];function y({to:e,label:t,description:n,icon:a}){return(0,_.jsxs)(r,{to:e,className:`group flex items-start gap-3 rounded-lg border bg-card p-4 transition-colors hover:border-primary/50 hover:bg-accent/30 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary`,children:[(0,_.jsx)(a,{className:`mt-0.5 h-5 w-5 shrink-0 text-muted-foreground`}),(0,_.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,_.jsx)(`span`,{className:`block text-sm font-semibold`,children:t}),(0,_.jsx)(`span`,{className:`mt-1 block text-sm leading-relaxed text-muted-foreground`,children:n})]}),(0,_.jsx)(i,{className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground group-hover:text-primary`})]})}function b({group:e,query:t}){let[n,r]=(0,g.useState)([]),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)(`loading`),[c,u]=(0,g.useState)(0);(0,g.useEffect)(()=>{let t=!1;return e.load().then(e=>{t||(r(e),s(`ready`))}).catch(()=>{t||s(`error`)}),()=>{t=!0}},[e,c]);let d=e.sections.filter(n=>l(t,e.label,n.label,n.description));return d.length?(0,_.jsxs)(`section`,{id:e.id,className:`scroll-mt-6 space-y-3`,children:[(0,_.jsx)(`h2`,{className:`text-lg font-semibold`,children:e.label}),(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description}),(0,_.jsxs)(`label`,{className:`block max-w-md text-sm font-medium`,children:[`Choose a `,e.label.toLowerCase(),(0,_.jsxs)(`select`,{className:`mt-2 h-10 w-full rounded-md border bg-background px-3 text-sm`,value:i,disabled:o!==`ready`||!n.length,onChange:e=>a(e.target.value),children:[(0,_.jsx)(`option`,{value:``,children:o===`loading`?`Loading…`:o===`error`?`Unable to load list`:n.length?`Select ${e.label.toLowerCase()}…`:`No ${e.path} available`}),n.map(e=>(0,_.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]}),o===`error`&&(0,_.jsxs)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:[`The list could not be loaded. `,(0,_.jsx)(`button`,{type:`button`,className:`underline`,onClick:()=>{s(`loading`),u(e=>e+1)},children:`Retry`})]}),(0,_.jsxs)(`details`,{open:!!(i||t.trim()),children:[(0,_.jsx)(`summary`,{className:`cursor-pointer py-2 text-sm text-muted-foreground`,children:i?`Settings for ${n.find(e=>e.id===i)?.label||i}`:`What you can configure (${d.length})`}),(0,_.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,16rem),1fr))] gap-3`,children:d.map(t=>i?(0,_.jsx)(y,{to:`/${e.path}/${encodeURIComponent(i)}/settings/${t.id}`,...t},t.id):(0,_.jsxs)(`div`,{className:`rounded-lg border border-dashed p-4`,children:[(0,_.jsx)(`p`,{className:`text-sm font-medium`,children:t.label}),(0,_.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:t.description})]},t.id))})]})]}):null}function x(){let{state:e}=c(),[t,n]=(0,g.useState)(``),r=u.filter(t=>t.id!==`server`||e.user?.userType===`admin`).map(e=>({...e,items:e.items.filter(n=>l(t,e.label,n.label,n.description))})).filter(e=>e.items.length),i=v.some(e=>e.sections.some(n=>l(t,e.label,n.label,n.description)));return(0,_.jsxs)(`div`,{className:`mx-auto max-w-6xl space-y-8 pb-8 max-md:pb-rail-stack`,children:[(0,_.jsx)(h,{title:`Settings`,description:`Start with what you want to change. Each section explains where your changes apply.`}),(0,_.jsx)(a,{type:`search`,className:`max-w-xl`,"aria-label":`Search all settings`,placeholder:`Find a setting: offline, folders, models, sharing…`,value:t,onChange:e=>n(e.target.value)}),r.filter(e=>e.id===`device`||e.id===`account`).map(e=>(0,_.jsxs)(`section`,{className:`space-y-3`,children:[(0,_.jsx)(`h2`,{className:`text-lg font-semibold`,children:e.label}),(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description}),(0,_.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,16rem),1fr))] gap-3`,children:e.items.map(e=>(0,_.jsx)(y,{to:e.path,...e},e.path))})]},e.id)),v.map(e=>(0,_.jsx)(b,{group:e,query:t},e.id)),r.filter(e=>e.id===`server`||e.id===`information`).map(e=>(0,_.jsxs)(`section`,{className:`space-y-3`,children:[(0,_.jsx)(`h2`,{className:`text-lg font-semibold`,children:e.label}),(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description}),(0,_.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,16rem),1fr))] gap-3`,children:e.items.map(e=>(0,_.jsx)(y,{to:e.path,...e},e.path))})]},e.id)),!r.length&&!i&&(0,_.jsxs)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:[`No settings match “`,t,`”. Try a shorter phrase or clear the search.`]})]})}export{x as default};