@augmentd-labs/canvas-web 2.26.25 → 2.26.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{FiltersApplet--yXjHZqs.js → FiltersApplet-BJALOBRh.js} +1 -1
- package/dist/assets/{HomeFab-3cymOU3P.js → HomeFab-Chvwu8rQ.js} +1 -1
- package/dist/assets/{LensApplet-5NHmz9TL.js → LensApplet-Ckl0M4Wi.js} +1 -1
- package/dist/assets/{NotesApplet-bIqcBzpg.js → NotesApplet-tNMaEcoj.js} +1 -1
- package/dist/assets/{_agentId_-BpZvdICK.js → _agentId_-sMYqsnQk.js} +0 -0
- package/dist/assets/{_contextId_-tiUa7oY9.js → _contextId_-DRvqFeiU.js} +1 -1
- package/dist/assets/{_workspaceName_-BJ7uXLLN.js → _workspaceName_-DqFTMP44.js} +1 -1
- package/dist/assets/{about-Dn6r3v8E.js → about-DbGpwqCH.js} +1 -1
- package/dist/assets/{add-BTCF4qRT.js → add-DsH8MVg6.js} +1 -1
- package/dist/assets/{agents-CO1AV00y.js → agents-BBKnR8_O.js} +1 -1
- package/dist/assets/{appearance-BoZKRJ6u.js → appearance-CN8I4_GQ.js} +1 -1
- package/dist/assets/{apps-B9-IBy2A.js → apps-CvInUZwB.js} +1 -1
- package/dist/assets/{content-app-view-acLgdhQ9.js → content-app-view-BGg1GOMt.js} +1 -1
- package/dist/assets/document-list-DKOU9Kcc.js +2 -0
- package/dist/assets/{home-BZ2OLB0t.js → home-CFZRa_Mu.js} +1 -1
- package/dist/assets/index-B-PM5mzp.css +2 -0
- package/dist/assets/{index-4M1qLU_S.js → index-BytAmMhU.js} +2 -2
- package/dist/assets/{key-bindings-CwUENuYh.js → key-bindings-Dfa7ehDw.js} +1 -1
- package/dist/assets/{registry-Ct1xWTs8.js → registry--2kt6I6T.js} +2 -2
- package/dist/assets/{settings-CDsVas7f.js → settings-BOHindnt.js} +3 -3
- package/dist/assets/{settings-Df2eiuZ1.js → settings-DhVz_Osu.js} +1 -1
- package/dist/assets/{settings-CuK0olLh.js → settings-FiiJ5QFa.js} +1 -1
- package/dist/assets/{settings-udxCpn5y.js → settings-N3fbO22m.js} +1 -1
- package/dist/assets/{share-target-DEadau7S.js → share-target-fpk-pz15.js} +1 -1
- package/dist/assets/{shared-De1-Pxac.js → shared-CCCuTYCU.js} +1 -1
- package/dist/assets/{use-canvas-pins-CbAxLLTU.js → use-canvas-pins-BvN6Gw6f.js} +1 -1
- package/dist/assets/{useAgentModels-CUwa_SHA.js → useAgentModels-CwNiA-Ak.js} +1 -1
- package/dist/assets/{workspace-area-menu-CP5OWZNX.js → workspace-area-menu-C0-X-FpD.js} +1 -1
- package/dist/assets/{workspaces-DyWI__ok.js → workspaces-By3jZzrz.js} +1 -1
- package/dist/index.html +6 -6
- package/dist/sw.js +1 -1
- package/package.json +2 -2
- package/dist/assets/document-list-Dsf1DVEx.js +0 -2
- package/dist/assets/index-D7EoeBID.css +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/apps-
|
|
2
|
-
import{o as e,r as t}from"./rolldown-runtime-C0FnF6B9.js";import{l as n,u as r}from"./code-editor-BOIngd5F.js";import{_t as i,st as a,vt as o,yt as s}from"./react-BHzhHVTZ.js";import{t as c}from"./preload-helper-Czpn1I53.js";import{_ as l,a as u,c as d,d as f,f as p,g as m,h,i as g,l as _,m as v,n as y,o as b,p as x,r as S,s as C,t as w,u as T,v as E}from"./chunk-62JRHF6Z-vspAGgtK.js";import{$n as D,B as O,Br as k,Bt as A,C as j,Ct as M,Dn as N,F as P,Fn as F,Ft as ee,H as te,Hn as ne,Hr as re,Ht as ie,I as ae,Ir as I,It as L,J as R,Jn as oe,Kn as se,Kr as ce,L as z,Lt as B,Mn as le,Mr as V,Nt as ue,Or as de,Ot as fe,P as pe,Pr as me,Pt as H,Q as he,Qr as ge,Qt as _e,R as ve,Rr as U,S as ye,Tn as be,Tt as xe,U as W,Un as Se,Ur as Ce,V as we,Vn as Te,Vr as Ee,Vt as De,W as Oe,Wr as ke,Wt as Ae,X as je,Xn as Me,Xr as Ne,Yr as Pe,Yt as Fe,Zn as Ie,Zt as Le,_ as Re,_i as ze,_n as Be,_r as Ve,_t as He,ar as Ue,b as We,bn as Ge,br as Ke,ci as qe,cn as Je,ct as Ye,d as Xe,di as Ze,dn as Qe,dr as $e,er as et,f as tt,fn as nt,g as rt,gi as it,gn as at,gt as ot,h as st,hi as ct,hr as lt,ht as ut,in as dt,jn as ft,kr as pt,ln as mt,lt as ht,m as gt,mi as _t,mn as vt,mr as yt,mt as bt,on as xt,p as St,pr as Ct,qn as wt,ri as Tt,rn as Et,rt as Dt,sn as Ot,sr as kt,tn as At,tt as jt,u as Mt,un as Nt,ut as Pt,v as Ft,vt as It,w as Lt,wr as Rt,x as zt,xn as Bt,xr as Vt,xt as Ht,y as Ut,yn as Wt,yr as Gt,yt as Kt,z as qt,zn as Jt,zr as Yt,zt as Xt}from"./ui-Byg1cZDr.js";import{i as Zt,r as Qt}from"./utils-BxVxyehK.js";import{n as $t,t as G}from"./utils-2pl1SbIp.js";import{t as K}from"./button-SgR3GVvV.js";import{t as en}from"./input-BOtCd4HP.js";import{t as q}from"./label-Dn4gCMcc.js";import{a as tn,c as nn,i as rn,l as J,n as an,o as on,r as sn,s as cn,t as Y,u as ln}from"./api-CA6WiiYM.js";import{t as un}from"./socket-hM4c-ZSl.js";import{t as X}from"./socket-CtH3EU9m.js";import{a as dn,c as fn,d as pn,i as mn,l as hn,n as gn,o as _n,r as vn,s as yn,t as bn}from"./auth-Bx9fAZmz.js";import{n as xn,t as Sn}from"./use-toast-BlLDqSUO.js";import{_ as Cn,h as wn,m as Tn,p as En,t as Dn}from"./LinkToCard-5dg0jvSY.js";import{$ as On,An as kn,Bt as An,C as jn,Cn as Mn,Ct as Nn,D as Pn,Dn as Fn,Et as In,Ft as Ln,H as Rn,K as zn,Mt as Bn,On as Vn,Ot as Hn,Pn as Un,Pt as Wn,Qt as Gn,Rt as Kn,Sn as qn,V as Jn,Vt as Yn,Zt as Xn,_n as Zn,_t as Qn,bn as $n,bt as er,cn as tr,g as nr,gn as rr,gt as ir,ht as ar,i as or,k as sr,l as cr,nt as lr,sn as ur,t as dr,ut as fr,v as pr,w as mr,x as hr,yn as gr}from"./workspace-CrSpR4xf.js";import{r as _r,t as vr}from"./use-canvas-pins-CbAxLLTU.js";import{a as yr,i as br,n as xr,o as Sr,r as Cr}from"./ObjectPropertiesCard-BIBMvx_i.js";import{c as wr,d as Tr,f as Er,i as Dr,m as Or,n as kr,p as Ar,s as jr,u as Mr}from"./document-list-Dsf1DVEx.js";import{n as Nr,t as Pr}from"./use-mobile-Db-vWu9Y.js";import{a as Fr,i as Ir,s as Lr,t as Rr}from"./IdentityFields-Bti7ojF3.js";import{n as zr,t as Br}from"./public-share-g_wBd6BW.js";import{t as Vr}from"./markdown-view-BBBZtNSR.js";import{n as Hr,t as Ur}from"./tags-YamdPoBK.js";import{a as Wr,c as Gr,i as Kr,l as qr,n as Jr,o as Yr,r as Xr,s as Zr,t as Qr,u as $r}from"./useAddTarget-CqnDU0Om.js";import{n as ei,r as ti,t as ni}from"./use-toolbox-Ck_cLGgf.js";import{D as ri,E as ii,O as ai,a as oi,p as si,s as ci,v as li,w as ui}from"./context-DQoZFMDQ.js";import{r as di}from"./relation-events-CKio19hE.js";import{c as fi}from"./date-time-picker-DebNUTx3.js";import{t as pi}from"./PickDocumentsCard-DamtV7fN.js";import{t as mi}from"./useEscapeClose-DR_xKT_k.js";import{t as hi}from"./useToastHelpers-CRrpIIdY.js";import{a as gi,c as _i,d as vi,l as yi,s as bi}from"./layer-style-Byl5LNFR.js";import{i as xi,r as Si}from"./color-DFEH4BfK.js";import{n as Ci}from"./MessageComposerDialog-gbD0Gu_b.js";import{n as wi,t as Ti}from"./LinkToSidePanel-eCy3nW4R.js";import{n as Ei,r as Di,t as Oi}from"./note-save-status-DPz4VzL6.js";import{t as ki}from"./useEditNoteFields-BehI0vog.js";import{t as Ai}from"./DocumentBodyEditor-8DNmOBS0.js";import{n as ji,t as Mi}from"./map-BxCwdK0d.js";import{o as Ni}from"./blobs-WiXP9QRi.js";import{n as Pi,t as Fi}from"./use-document-modal-PG8bQyIB.js";import{n as Ii,r as Li}from"./geo-CZfs0E-x.js";import{C as Ri,W as zi,_ as Bi,c as Vi,g as Hi,i as Ui,s as Wi,y as Gi,z as Ki}from"./backend-sync-progress-pZrhQPk3.js";import{t as qi}from"./workspace-access-C9nZlBBZ.js";import{t as Ji}from"./PathPickerField-fZazwxCN.js";import{a as Yi,c as Xi,i as Zi,o as Qi,r as $i,s as ea,t as ta}from"./workspace-BydSRtST.js";import{n as na,t as ra}from"./url-params-n7kU_WZ-.js";import{a as ia,c as aa,d as oa,f as sa,i as ca,m as la,n as ua,p as da,r as fa,t as pa}from"./use-menu-BiJ8N7sS.js";import{n as ma,t as ha}from"./registry-Ct1xWTs8.js";import{n as ga}from"./use-applet-target-gXPvZGgx.js";import{r as _a,t as va}from"./last-path-BbXWC3b3.js";import{t as ya}from"./workspace-area-menu-CP5OWZNX.js";import{t as ba}from"./workspace-content-gate-9okuA7J7.js";import{c as xa,s as Sa}from"./UploadProgressList-DRJzjy6A.js";import{n as Ca,r as wa,t as Ta}from"./FileForm-CqJpRbXv.js";import{n as Ea}from"./use-theme-DaxpiICf.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Z=e(r(),1),Da=o(),Q=n(),Oa=Z.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(`div`,{ref:n,className:G(`rounded-(--card-radius) border bg-card text-card-foreground shadow-elevation-1`,e),...t}));Oa.displayName=`Card`;var ka=Z.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(`div`,{ref:n,className:G(`flex flex-col space-y-1.5 p-6`,e),...t}));ka.displayName=`CardHeader`;var Aa=Z.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(`h3`,{ref:n,className:G(`text-2xl font-semibold leading-none tracking-tight`,e),...t}));Aa.displayName=`CardTitle`;var ja=Z.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(`p`,{ref:n,className:G(`text-sm text-muted-foreground`,e),...t}));ja.displayName=`CardDescription`;var Ma=Z.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(`div`,{ref:n,className:G(`p-6 pt-0`,e),...t}));Ma.displayName=`CardContent`;var Na=Z.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(`div`,{ref:n,className:G(`flex items-center p-6 pt-0`,e),...t}));Na.displayName=`CardFooter`;var Pa=`2.26.25`,Fa=e=>{window.particlesJS.load(e,`/js/particles.config.json`,()=>{console.log(`particles.js config loaded for`,e)})};function Ia(e){(0,Z.useEffect)(()=>{if(window.particlesJS!==void 0)Fa(e);else{if(document.getElementById(`particles-js-script`))return;let t=document.createElement(`script`);t.id=`particles-js-script`,t.src=`/js/particles.min.js`,t.onload=()=>{console.log(`particles.js loaded`),Fa(e)},document.head.appendChild(t)}return()=>{window.pJS&&window.pJS[e]?.destroy&&window.pJS[e].destroy()}},[e])}function La(){let[e,t]=(0,Z.useState)(null),[n,r]=(0,Z.useState)(!0),[i,a]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{let e=!0;async function n(){try{r(!0),a(null);let n=await Y.get(`/ping`,{skipAuth:!0});e&&(n?.version?t(n.version):a(`Invalid server response`))}catch(t){e&&(console.error(`Failed to fetch server version:`,t),a(`Unable to connect to server`))}finally{e&&r(!1)}}n();let i=setInterval(n,3e4);return()=>{e=!1,clearInterval(i)}},[]),{serverVersion:e,isLoading:n,error:i}}var Ra=`https://github.com/canvas-ui/canvas-server`,za=null;function Ba(){return za||=Y.get(`/ping`,{skipAuth:!0}).then(e=>{let t=e??{};return{sourceUrl:t.sourceUrl||Ra,version:t.version??null,commit:t.commit??null,license:t.license??null}}).catch(e=>(console.error(`Failed to fetch server source info:`,e),za=null,{sourceUrl:Ra,version:null,commit:null,license:null})),za}function Va(){let[e,t]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{let e=!0;return Ba().then(n=>{e&&t(n)}),()=>{e=!1}},[]),e}function Ha({className:e=``}){let t=Va();if(!t)return null;let n=[t.version?`v${t.version}`:null,t.commit?.slice(0,7)].filter(Boolean).join(` `);return(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground ${e}`,children:[`Powered by`,` `,(0,Q.jsx)(`a`,{href:t.sourceUrl,target:`_blank`,rel:`noreferrer`,className:`underline underline-offset-2 hover:text-foreground`,children:`Canvas`}),n?` ${n}`:``,t.license?`, ${t.license}`:``,`.`,` `,(0,Q.jsx)(`a`,{href:t.sourceUrl,target:`_blank`,rel:`noreferrer`,className:`underline underline-offset-2 hover:text-foreground`,children:`Get the source code`}),`.`]})}function Ua({children:e}){Ia(`particle-js`);let{serverVersion:t,isLoading:n,error:r}=La();return(0,Q.jsx)(`div`,{className:`flex min-h-viewport w-full items-center justify-center p-4 flex-col`,children:(0,Q.jsxs)(Oa,{className:`flex w-[95vw] h-viewport-modal overflow-hidden`,children:[(0,Q.jsxs)(`div`,{className:`hidden md:block w-1/2 relative bg-background`,"data-scheme":`dark`,id:`particle-js`,children:[(0,Q.jsxs)(S,{className:`absolute top-8 left-8 font-bold text-foreground flex items-center z-raised`,to:`/`,children:[(0,Q.jsx)(`img`,{src:`/images/logo-wr_128x128.png`,alt:`Canvas Logo`,className:`mr-2 h-6 w-6 touch-target`}),(0,Q.jsx)(`span`,{className:`text-2xl font-bold text-foreground`,children:`Canvas`})]}),(0,Q.jsxs)(`div`,{className:`absolute bottom-8 left-8 text-sm text-foreground max-w-[80%] z-raised`,children:[`Web UI: v`,Pa,`, Server: `,n?`Loading...`:r?`Unavailable`:t?`v${t}`:`Unknown`]})]}),(0,Q.jsx)(`div`,{className:`flex w-full md:w-1/2 flex-col justify-center px-4 py-12 sm:px-6 lg:px-8`,children:(0,Q.jsxs)(`div`,{className:`mx-auto w-full max-w-sm`,children:[e,(0,Q.jsxs)(`div`,{className:`mt-8 border-t pt-6`,children:[(0,Q.jsxs)(`a`,{href:`https://github.com/canvas-ui`,target:`_blank`,className:`text-muted-foreground hover:text-foreground justify-center flex items-center space-x-2`,rel:`noopener noreferrer`,children:[(0,Q.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`24`,height:`24`,stroke:`currentColor`,fill:`none`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`w-6 h-6`,children:(0,Q.jsx)(`path`,{d:`M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22`})}),(0,Q.jsx)(`span`,{children:`View on GitHub`})]}),(0,Q.jsx)(Ha,{className:`mt-4 text-center`})]})]})})]})})}var Wa=e=>e?.strategies?.local?.enabled!==!1,Ga=e=>e?.allowUserRegistrations!==!1;function Ka(){let e=m(),[t,n]=Z.useState(!1),[r,a]=Z.useState(``),[o,s]=Z.useState(``),[c,l]=Z.useState(!1),[u,d]=Z.useState({}),[f,p]=Z.useState(null),[h,g]=Z.useState({email:``,password:``,strategy:`auto`});Z.useEffect(()=>{dn()&&e(`/workspaces`),fetch(`${J}/runtime/capabilities`).then(e=>e.ok?e.json():null).then(e=>n(e?.payload?.local===!0)).catch(()=>{}),gn().then(e=>{p(e)}).catch(e=>{console.error(`Failed to load auth config:`,e)})},[e]);let _=()=>{let e={};return h.email?/\S+@\S+\.\S+/.test(h.email)||(e.email=`Email is invalid`):e.email=`Email is required`,h.password||(e.password=`Password is required`),d(e),Object.keys(e).length===0},v=e=>{let{name:t,value:n}=e.target;g(e=>({...e,[t]:n}))};async function y(t){if(t.preventDefault(),_()){l(!0);try{console.log(`Attempting login with:`,h.email,`strategy:`,h.strategy);let t=await fn(h.email,h.password,h.strategy);console.log(`Login successful, received token:`,`token`in t?!!t.token:!!t.payload?.token),d({}),e(`/home`)}catch(e){console.error(`Login error:`,e);let t=`Login failed`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;n.message?t=n.message:n.error?t=n.error:n.payload?.message&&(t=n.payload.message)}d({password:t})}finally{l(!1)}}}return t?(0,Q.jsx)(Ua,{children:(0,Q.jsxs)(`form`,{className:`grid gap-4`,onSubmit:async t=>{t.preventDefault(),l(!0),s(``);try{if(Y.setAuthToken(r.trim()),!await vn())throw Error(`The local token was not accepted`);e(`/workspaces`)}catch(e){Y.clearAuthToken(),s(e instanceof Error?e.message:`Authentication failed`)}finally{l(!1)}},children:[(0,Q.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Connect to your local runtime`}),(0,Q.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Enter the token shown by `,(0,Q.jsx)(`code`,{children:`canvas runtime token`}),` in the runtime folder.`]}),(0,Q.jsx)(q,{htmlFor:`local-token`,children:`Local access token`}),(0,Q.jsx)(en,{id:`local-token`,type:`password`,autoComplete:`off`,value:r,onChange:e=>a(e.target.value),required:!0}),o&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:o}),(0,Q.jsx)(K,{disabled:c,children:c?`Connecting…`:`Connect`})]})}):(0,Q.jsx)(Ua,{children:(0,Q.jsxs)(`div`,{className:`flex flex-col space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col space-y-2 text-center`,children:[(0,Q.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Welcome back`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Enter your credentials to access your account`})]}),(0,Q.jsx)(`form`,{onSubmit:y,children:(0,Q.jsxs)(`div`,{className:`grid gap-4`,children:[f?.strategies?.imap?.enabled&&f.strategies.imap.domains.length>0&&(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(q,{htmlFor:`strategy`,children:`Authentication Method`}),(0,Q.jsxs)(`select`,{id:`strategy`,name:`strategy`,value:h.strategy,onChange:v,disabled:c,className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,Q.jsx)(`option`,{value:`auto`,children:`Auto-detect`}),(0,Q.jsx)(`option`,{value:`local`,children:`Local Account`}),(0,Q.jsx)(`option`,{value:`imap`,children:`Email Server (IMAP)`})]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(q,{htmlFor:`email`,children:`Email`}),(0,Q.jsx)(en,{id:`email`,name:`email`,placeholder:`name@example.com`,type:`email`,autoCapitalize:`none`,autoComplete:`email`,autoCorrect:`off`,disabled:c,value:h.email,onChange:v}),u.email&&(0,Q.jsx)(`p`,{className:`text-sm text-destructive`,children:u.email})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(q,{htmlFor:`password`,children:`Password`}),(0,Q.jsx)(en,{id:`password`,name:`password`,type:`password`,disabled:c,value:h.password,onChange:v}),u.password&&(0,Q.jsx)(`p`,{className:`text-sm text-destructive`,children:u.password})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col space-y-4`,children:[(0,Q.jsx)(K,{type:`submit`,disabled:c,children:c?`Signing in...`:`Sign In`}),f?.strategies?.google?.enabled&&(0,Q.jsxs)(K,{type:`button`,variant:`outline`,disabled:c,onClick:()=>pn(),children:[(0,Q.jsx)(i,{icon:`logos:google-icon`,width:16,height:16,className:`mr-2`}),`Sign in with Google`]}),Wa(f)&&Ga(f)&&(0,Q.jsx)(K,{variant:`outline`,type:`button`,disabled:c,onClick:()=>e(`/register`),children:`Don't have an account? Sign up`})]})]})})]})})}function qa(){let e=m(),{showToast:t}=xn(),[n,r]=Z.useState(!1),[i,a]=Z.useState({}),[o,s]=Z.useState({name:``,email:``,password:``}),[c,l]=Z.useState(!1),[u,d]=Z.useState(!1),[f,p]=Z.useState(null);Z.useEffect(()=>{(async()=>{let t=await gn(),n=t?.strategies?.local;if(t?.allowUserRegistrations===!1||n?.enabled===!1){e(`/login`,{replace:!0});return}n?.passwordPolicy&&p(n.passwordPolicy),d(!!n?.requireEmailVerification)})()},[e]);let h=Z.useMemo(()=>{if(!f)return null;let e=o.password||``;return{minLength:!f.minLength||e.length>=f.minLength,maxLength:!f.maxLength||e.length<=f.maxLength,uppercase:!f.requireUppercase||/[A-Z]/.test(e),lowercase:!f.requireLowercase||/[a-z]/.test(e),number:!f.requireNumbers||/[0-9]/.test(e),special:!f.requireSpecialChars||/[^A-Za-z0-9]/.test(e)}},[f,o.password]),g=()=>{let e={};if(!o.name)e.name=`Username is required`;else if(o.name.trim().length===0)e.name=`Username cannot be empty`;else{let t=o.name.toLowerCase().trim();t.length<3?e.name=`Username must be at least 3 characters long`:t.length>39?e.name=`Username cannot be longer than 39 characters`:/^[a-z0-9_-]+$/.test(t)?[`admin`,`administrator`,`root`,`system`,`support`,`help`,`api`,`www`,`mail`,`ftp`,`localhost`,`test`,`demo`,`canvas`,`universe`,`workspace`,`context`,`user`,`users`].includes(t)&&(e.name=`Username '${t}' is reserved and cannot be used`):e.name=`Username can only contain lowercase letters, numbers, underscores, and hyphens`}if(o.email?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.email)||(e.email=`Please enter a valid email address`):e.email=`Email is required`,!o.password)e.password=`Password is required`;else if(f){let t=o.password,n=[];f.minLength&&t.length<f.minLength&&n.push(`at least ${f.minLength} characters`),f.maxLength&&t.length>f.maxLength&&n.push(`no more than ${f.maxLength} characters`),f.requireUppercase&&!/[A-Z]/.test(t)&&n.push(`an uppercase letter`),f.requireLowercase&&!/[a-z]/.test(t)&&n.push(`a lowercase letter`),f.requireNumbers&&!/[0-9]/.test(t)&&n.push(`a number`),f.requireSpecialChars&&!/[^A-Za-z0-9]/.test(t)&&n.push(`a special character`),n.length&&(e.password=`Password must contain ${n.join(`, `).replace(/, ([^,]*)$/,` and $1`)}.`)}else o.password.length<8&&(e.password=`Password must be at least 8 characters long`);return a(e),Object.keys(e).length===0},_=e=>{let t={...o,[e.target.id]:e.target.value};s(t),(e.target.id===`name`||e.target.id===`email`||e.target.id===`password`)&&g()};return c?(0,Q.jsxs)(Ua,{children:[(0,Q.jsxs)(`div`,{className:`flex flex-col space-y-2 text-center`,children:[(0,Q.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Registration Successful!`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:u?`Check your email for a verification link to activate your account.`:`Your account has been created.`})]}),(0,Q.jsx)(`div`,{className:`space-y-6 text-center pt-6`,children:!u&&(0,Q.jsx)(K,{asChild:!0,className:`w-full`,children:(0,Q.jsx)(S,{to:`/login`,children:`Go to Login`})})})]}):(0,Q.jsxs)(Ua,{children:[(0,Q.jsxs)(`div`,{className:`flex flex-col space-y-2 text-center`,children:[(0,Q.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Create an account`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Enter your email below to create your account`})]}),(0,Q.jsxs)(`form`,{onSubmit:async e=>{if(e.preventDefault(),g()){r(!0);try{let e=await hn(o.name,o.email,o.password);console.log(`Registration successful:`,e),t({title:`Registration Successful`,description:u?`Check your email for a verification link before logging in.`:`You can now log in with your credentials.`,variant:`default`}),l(!0),s({name:``,email:``,password:``}),a({})}catch(e){console.error(`Registration failed:`,e);let n=e?.message||`Registration failed`;n.toLowerCase().includes(`password`)?a({...i,password:n}):a({...i,email:n}),t({title:`Registration Failed`,description:n,variant:`destructive`})}finally{r(!1)}}},className:`space-y-4 pt-6`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(q,{htmlFor:`name`,children:`Username`}),(0,Q.jsx)(en,{id:`name`,type:`text`,placeholder:`Enter your username (e.g., john_doe)`,value:o.name,onChange:_,disabled:n,className:i.name?`border-destructive`:``}),i.name&&(0,Q.jsx)(`p`,{className:`text-sm text-destructive`,children:i.name}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`3-39 characters, lowercase letters, numbers, underscores, and hyphens only`})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(q,{htmlFor:`email`,children:`Email`}),(0,Q.jsx)(en,{id:`email`,type:`email`,placeholder:`name@example.com`,value:o.email,onChange:_,disabled:n,className:i.email?`border-destructive`:``}),i.email&&(0,Q.jsx)(`p`,{className:`text-sm text-destructive`,children:i.email})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(q,{htmlFor:`password`,children:`Password`}),(0,Q.jsx)(en,{id:`password`,type:`password`,placeholder:`Enter your password`,value:o.password,onChange:_,disabled:n,className:i.password?`border-destructive`:``}),i.password&&(0,Q.jsx)(`p`,{className:`text-sm text-destructive`,children:i.password}),f&&h&&(0,Q.jsxs)(`ul`,{className:`text-xs list-disc pl-4 space-y-1`,children:[(0,Q.jsxs)(`li`,{className:h.minLength?`text-success`:`text-muted-foreground`,children:[`At least `,f.minLength,` characters`]}),f.requireUppercase&&(0,Q.jsx)(`li`,{className:h.uppercase?`text-success`:`text-muted-foreground`,children:`At least one uppercase letter`}),f.requireLowercase&&(0,Q.jsx)(`li`,{className:h.lowercase?`text-success`:`text-muted-foreground`,children:`At least one lowercase letter`}),f.requireNumbers&&(0,Q.jsx)(`li`,{className:h.number?`text-success`:`text-muted-foreground`,children:`At least one number`}),f.requireSpecialChars&&(0,Q.jsx)(`li`,{className:h.special?`text-success`:`text-muted-foreground`,children:`At least one special character`}),f.maxLength&&(0,Q.jsxs)(`li`,{className:h.maxLength?`text-success`:`text-muted-foreground`,children:[`No more than `,f.maxLength,` characters`]})]})]}),(0,Q.jsx)(K,{type:`submit`,className:`w-full`,disabled:n,children:n?`Creating Account...`:`Create Account`})]}),(0,Q.jsxs)(`div`,{className:`mt-4 text-center text-sm`,children:[`Already have an account?`,` `,(0,Q.jsx)(S,{to:`/login`,className:`underline`,children:`Sign in`})]}),(0,Q.jsxs)(`div`,{className:`px-8 py-4 text-center text-sm text-muted-foreground border-t mt-6`,children:[`By clicking continue, you agree to our`,` `,(0,Q.jsx)(S,{to:`/terms`,className:`underline underline-offset-4 hover:text-primary`,children:`Terms of Service`}),` `,`and`,` `,(0,Q.jsx)(S,{to:`/privacy`,className:`underline underline-offset-4 hover:text-primary`,children:`Privacy Policy`}),`.`]})]})}function Ja(){let e=m(),[t]=E(),[n,r]=Z.useState(t.get(`error`)),i=Z.useRef(!1);return Z.useEffect(()=>{let n=t.get(`code`);!n||i.current||(i.current=!0,bn(n).then(()=>e(`/home`,{replace:!0})).catch(e=>r(e instanceof Error?e.message:`Google sign-in failed`)))},[t,e]),(0,Q.jsx)(Ua,{children:(0,Q.jsx)(`div`,{className:`flex flex-col space-y-4 text-center`,children:n?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Google sign-in failed`}),(0,Q.jsx)(`p`,{className:`text-sm text-destructive`,children:n}),(0,Q.jsx)(K,{type:`button`,variant:`outline`,onClick:()=>e(`/login`,{replace:!0}),children:`Back to sign in`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Signing you in…`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Completing Google sign-in.`})]})})})}function Ya({children:e}){let[t,n]=(0,Z.useState)(`loading`);return(0,Z.useEffect)(()=>{(async()=>{try{if(!_n()){console.log(`No authentication token found, redirecting to login`),n(`unauthenticated`);return}let e=await vn();e?(console.log(`User authenticated:`,e.email),n(`authenticated`)):(console.log(`User not authenticated or token expired`),n(`unauthenticated`))}catch(e){if(console.error(`Authentication check failed:`,e),yn(e)){if(dn()){n(`authenticated`);return}Y.clearAuthToken(),n(`unauthenticated`);return}e instanceof Error&&e.message.includes(`Authentication required`)&&(console.log(`Clearing invalid token from ProtectedRoute`),Y.clearAuthToken()),n(`unauthenticated`)}})()},[]),t===`loading`?(0,Q.jsx)(`div`,{className:`flex h-screen items-center justify-center`,children:(0,Q.jsx)(Cn,{className:`h-8 w-8`})}):t===`unauthenticated`?(0,Q.jsx)(u,{to:`/login`,replace:!0}):(0,Q.jsx)(Q.Fragment,{children:e})}function Xa({children:e}){let[t,n]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{(async()=>{try{await Y.get(`/auth/me`),n(!0)}catch(e){e instanceof Error&&e.message.includes(`Authentication required`)&&(console.log(`Clearing invalid token from PublicRoute`),Y.clearAuthToken()),n(!1)}})()},[]),t===null?null:t?(0,Q.jsx)(u,{to:`/workspaces`,replace:!0}):(0,Q.jsx)(Q.Fragment,{children:e})}var Za=`data/schema/file`;function Qa(e){return String(e.locations?.[0]?.url||``).trim()}function $a(e){let t=Qa(e);if(!t)return``;let n=t.split(/[?#]/)[0].split(`/`).filter(Boolean).pop()||``;try{return decodeURIComponent(n)}catch{return n}}function eo(e){return e.schema===Za&&String(e.metadata?.contentType||``).startsWith(`image/`)}function to(e){let t=Number(e);return!Number.isFinite(t)||t<0?``:t<1024?`${t} B`:t<1048576?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`}function no(e){if(e.schema!==Za)return kn(e);let t=$a(e),n=String(e.metadata?.contentType||``).trim(),r=to(e.metadata?.size);return{...kn(e),title:t||`File ${e.id}`,preview:[n,r].filter(Boolean).join(` · `),subtitle:Qa(e),schemaLabel:`file`}}function ro(e){return/^https?:\/\/[^\s]+$/i.test(e)}function io(e,t){if(e.schema===`data/schema/tab`){let t=String(e.data?.url||``).trim();return ro(t)?t:null}return t.isExternal&&ro(t.subtitle)?t.subtitle:ro(t.title)?t.title:null}function ao(e,t,n=!1){return zr(e,t,{download:n})}function oo(e){return e.split(/(https?:\/\/[^\s]+)/gi).map((e,t)=>ro(e)?(0,Q.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`underline decoration-muted-foreground underline-offset-2 hover:text-primary`,children:e},`${e}-${t}`):e)}function so(e){return e?new Date(e).toLocaleString():``}function co(){let{code:e=``}=l(),[t,n]=(0,Z.useState)(null),[r,i]=(0,Z.useState)(!0),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(``),f=(0,Z.useMemo)(()=>t?.documents?Array.isArray(t.documents)?t.documents:t.documents.data||[]:[],[t]),p=(0,Z.useMemo)(()=>{let e=u.trim().toLowerCase();return e?f.filter(t=>{let n=no(t);return[t.schema,n.title,n.preview,n.subtitle,$a(t),t.metadata?.contentType].join(` `).toLowerCase().includes(e)}):f},[f,u]),m=(0,Z.useCallback)(async()=>{if(e){i(!0);try{let t=await Y.get(`${J}/pub/c/${encodeURIComponent(e)}`,{skipAuth:!0});n(t),o(null)}catch(e){n(null),o(e instanceof Error?e.message:`Failed to load public canvas`)}finally{i(!1)}}},[e]);(0,Z.useEffect)(()=>{m()},[m]),(0,Z.useEffect)(()=>{if(!e)return;let t=un(`${ln}/pub`,{transports:[`websocket`],auth:{code:e},reconnection:!0,reconnectionAttempts:10,reconnectionDelay:1500});return t.on(`connect`,()=>c(!0)),t.on(`disconnect`,()=>c(!1)),t.on(`connect_error`,()=>c(!1)),t.on(`canvas:changed`,()=>m()),()=>{t?.disconnect(),t=null}},[e,m]);let h=(0,Z.useCallback)(e=>{e?.preventDefault(),d(u.trim())},[u]),g=(0,Z.useCallback)(()=>{d(``)},[]),_=(0,Z.useCallback)(async e=>({payload:Fn(e?.sortBy)?Vn(f,e.sortBy,e?.order):f,totalCount:t?.stats.documentCount??f.length}),[f,t]);if(r&&!t)return(0,Q.jsx)(`main`,{className:`min-h-screen bg-muted flex items-center justify-center p-6`,children:(0,Q.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Loading canvas...`})});if(a||!t)return(0,Q.jsxs)(`main`,{className:`min-h-screen bg-muted flex flex-col items-center justify-center p-6`,children:[(0,Q.jsxs)(Oa,{className:`max-w-md bg-card`,children:[(0,Q.jsx)(ka,{children:(0,Q.jsx)(Aa,{children:`Canvas unavailable`})}),(0,Q.jsx)(Ma,{className:`text-sm text-muted-foreground`,children:a||`This public canvas does not exist.`})]}),(0,Q.jsx)(Ha,{className:`mt-6 text-center`})]});let v=t.canvas.metadata?.ui??{},y=!!v.widgets&&Object.keys(v.widgets).length>0;return(0,Q.jsx)(Br.Provider,{value:e,children:(0,Q.jsx)(`main`,{className:`min-h-screen bg-muted p-2 text-foreground sm:p-4 md:p-10`,children:(0,Q.jsxs)(`div`,{className:`mx-auto max-w-6xl`,children:[(0,Q.jsxs)(Oa,{className:`bg-card shadow-elevation-3`,children:[(0,Q.jsx)(ka,{className:`border-b p-3 sm:p-6`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between md:gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 gap-3 sm:gap-4`,children:[(0,Q.jsx)(`div`,{className:`mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-accent text-primary sm:mt-1 sm:h-12 sm:w-12 sm:rounded-2xl`,style:t.canvas.color?{borderLeft:`4px solid ${t.canvas.color}`}:void 0,children:(0,Q.jsx)(Wt,{className:`h-5 w-5 sm:h-6 sm:w-6`})}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-xs uppercase tracking-wide text-muted-foreground`,children:t.workspace.label||t.workspace.name}),(0,Q.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] text-muted-foreground md:hidden`,children:[s?(0,Q.jsx)(qt,{className:`h-3 w-3 text-success`}):(0,Q.jsx)(O,{className:`h-3 w-3 text-muted-foreground`}),s?`Live`:`Offline`]})]}),(0,Q.jsx)(Aa,{className:`mt-0.5 truncate text-2xl sm:mt-1 sm:text-3xl md:text-5xl`,children:t.canvas.label||t.canvas.name||`Canvas`}),t.canvas.description&&(0,Q.jsx)(`p`,{className:`mt-1.5 max-w-3xl text-sm text-muted-foreground sm:mt-3 sm:text-base`,children:t.canvas.description})]})]}),(0,Q.jsxs)(`div`,{className:`hidden shrink-0 items-center gap-2 rounded-full border px-3 py-1 text-xs text-muted-foreground md:flex`,children:[s?(0,Q.jsx)(qt,{className:`h-3.5 w-3.5 text-success`}):(0,Q.jsx)(O,{className:`h-3.5 w-3.5 text-muted-foreground`}),s?`Live`:`Offline`]})]})}),(0,Q.jsxs)(Ma,{className:`space-y-4 p-3 sm:space-y-6 sm:p-6 md:p-8`,children:[(0,Q.jsxs)(`section`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-1 text-xs text-muted-foreground md:hidden`,children:[(0,Q.jsx)(`span`,{className:`w-full truncate font-mono text-foreground`,children:t.share.path}),(0,Q.jsxs)(`span`,{className:`tabular-nums`,children:[t.stats.documentCount,` docs`]}),p.length!==t.stats.documentCount&&(0,Q.jsxs)(`span`,{className:`tabular-nums`,children:[`· `,p.length,` shown`]}),(0,Q.jsxs)(`span`,{className:`truncate`,children:[`· `,so(t.stats.refreshedAt)]})]}),(0,Q.jsxs)(`section`,{className:`hidden gap-3 md:grid md:grid-cols-4`,children:[(0,Q.jsx)(lo,{label:`Path`,value:t.share.path,mono:!0}),(0,Q.jsx)(lo,{label:`Documents`,value:String(t.stats.documentCount)}),(0,Q.jsx)(lo,{label:`Shown`,value:String(p.length)}),(0,Q.jsx)(lo,{label:`Refreshed`,value:so(t.stats.refreshedAt)})]}),y&&(0,Q.jsx)(`section`,{id:`content-area`,className:`flex w-full flex-col overflow-hidden rounded-2xl border h-viewport-card min-h-[420px] md:h-viewport-pane`,children:(0,Q.jsx)(_r,{workspaceId:t.workspace.name,treeName:t.share.treeName,path:t.share.path,layerId:t.canvas.id,querySpec:t.canvas.querySpec,metadata:t.canvas.metadata,readOnly:!0,interactive:!1,fetchDocuments:_},JSON.stringify(v))}),!y&&(0,Q.jsxs)(`section`,{className:`rounded-2xl border`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 border-b px-4 py-3 md:flex-row md:items-center md:justify-between`,children:[(0,Q.jsx)(`h2`,{className:`font-semibold`,children:`Content`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 md:flex-row md:items-center`,children:[(0,Q.jsxs)(`form`,{onSubmit:h,className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,Q.jsx)(Kt,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`}),(0,Q.jsx)(`input`,{type:`search`,value:u,onChange:e=>d(e.target.value),placeholder:`Search loaded documents...`,className:`w-full rounded-md border py-1.5 pl-9 pr-8 text-sm md:w-72`}),u&&(0,Q.jsx)(`button`,{type:`button`,onClick:g,className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,"aria-label":`Clear search`,children:(0,Q.jsx)(z,{className:`h-4 w-4`})})]}),(0,Q.jsx)(`button`,{type:`submit`,className:`rounded-md border px-3 py-1.5 text-xs hover:bg-muted`,children:`Search`})]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:m,className:`inline-flex items-center justify-center gap-2 rounded-md border px-3 py-1.5 text-xs hover:bg-muted`,children:[(0,Q.jsx)(fe,{className:`h-3.5 w-3.5 ${r?`animate-spin`:``}`}),`Refresh`]})]})]}),u.trim()&&(0,Q.jsxs)(`div`,{className:`border-b bg-muted px-4 py-2 text-xs text-muted-foreground`,children:[`Local search: `,(0,Q.jsxs)(`span`,{className:`font-mono`,children:[`"`,u.trim(),`"`]})]}),(0,Q.jsx)(`div`,{className:`divide-y`,children:p.length===0?(0,Q.jsx)(`div`,{className:`p-8 text-center text-sm text-muted-foreground`,children:u.trim()?`No loaded documents match your search.`:`No documents yet.`}):p.map(t=>{let n=no(t),r=io(t,n),i=t.schema===Za,a=i?ao(e,t.id):null,o=a||r;return(0,Q.jsxs)(`article`,{className:`p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 md:flex-row md:items-start md:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h3`,{className:`truncate font-medium`,children:o?(0,Q.jsx)(`a`,{href:o,target:`_blank`,rel:`noreferrer`,className:`hover:text-primary hover:underline`,children:n.title}):n.title}),(0,Q.jsx)(`div`,{className:`mt-1 font-mono text-xs text-muted-foreground`,children:n.schemaLabel})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3`,children:[i&&(0,Q.jsxs)(`a`,{href:ao(e,t.id,!0),download:n.title,className:`inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs text-muted-foreground hover:bg-muted hover:text-foreground`,children:[(0,Q.jsx)(Ve,{className:`h-3.5 w-3.5`}),`Download`]}),(0,Q.jsx)(`time`,{className:`text-xs text-muted-foreground`,children:so(t.updatedAt||t.createdAt)})]})]}),n.preview&&(0,Q.jsx)(`p`,{className:`mt-3 line-clamp-3 text-sm leading-6 text-foreground`,children:oo(n.preview)}),eo(t)&&(0,Q.jsx)(`a`,{href:a||void 0,target:`_blank`,rel:`noreferrer`,className:`mt-3 block w-fit`,children:(0,Q.jsx)(`img`,{src:a||void 0,alt:n.title,loading:`lazy`,className:`max-h-64 max-w-full rounded border bg-muted object-contain transition-opacity hover:opacity-90`})})]},t.id)})})]})]})]}),(0,Q.jsx)(Ha,{className:`mt-6 text-center`})]})})})}function lo({label:e,value:t,mono:n=!1}){return(0,Q.jsxs)(`div`,{className:`min-w-0 rounded-xl border bg-muted p-4`,children:[(0,Q.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-muted-foreground`,children:e}),(0,Q.jsx)(`div`,{className:`mt-2 truncate text-lg font-semibold ${n?`font-mono text-sm`:``}`,children:t||`-`})]})}var uo=`false`,fo=`false`,po=uo===`true`,mo=fo===`true`;function ho(e={}){let{immediate:t=!1,onNeedReload:n,onNeedRefresh:r,onOfflineReady:i,onRegistered:a,onRegisteredSW:o,onRegisterError:s}=e,l,u,d,f=async(e=!0)=>{await u,po||d?.()};async function p(){if(`serviceWorker`in navigator){if(l=await c(async()=>{let{Workbox:e}=await import(`./workbox-window.prod.es5-Bd17z0YL.js`);return{Workbox:e}},[]).then(({Workbox:e})=>new e(`/sw.js`,{scope:`/`,type:`classic`})).catch(e=>{s?.(e)}),!l)return;if(d=()=>{l?.messageSkipWaiting()},!mo){if(po)l.addEventListener(`activated`,e=>{(e.isUpdate||e.isExternal)&&(n?n():window.location.reload())}),l.addEventListener(`installed`,e=>{e.isUpdate||i?.()});else{let e=!1,t=()=>{e=!0,l?.addEventListener(`controlling`,e=>{e.isUpdate&&(n?n():window.location.reload())}),r?.()};l.addEventListener(`installed`,n=>{n.isUpdate===void 0?n.isExternal===void 0?!e&&i?.():n.isExternal?t():!e&&i?.():n.isUpdate||i?.()}),l.addEventListener(`waiting`,t)}}l.register({immediate:t}).then(e=>{o?o(`/sw.js`,e):a?.(e)}).catch(e=>{s?.(e)})}}return u=p(),f}var go=new Set,_o=!1,vo=ho({immediate:!0,onRegisteredSW(e,t){t&&setInterval(()=>{t.update()},36e5)},onNeedRefresh(){_o=!0,go.forEach(e=>e())}});function yo(e){return go.add(e),_o&&e(),()=>{go.delete(e)}}function bo(){vo(!0)}function xo(){let[e,t]=(0,Z.useState)(!1),[n,r]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>yo(()=>t(!0)),[]),!e||n?null:(0,Q.jsx)(`div`,{className:`fixed bottom-4 left-1/2 z-50 -translate-x-1/2`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-full border border-border bg-card px-4 py-2 shadow-elevation-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm`,children:`A new version of Canvas is ready`}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>bo(),className:`flex items-center gap-1 rounded-full bg-foreground px-3 py-1 text-xs font-medium text-background hover:bg-foreground/90`,children:[(0,Q.jsx)(fe,{className:`h-3 w-3`}),` Reload`]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>r(!0),"aria-label":`Not now`,className:`rounded-full p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,Q.jsx)(z,{className:`h-3.5 w-3.5`})})]})})}var So=(0,Z.lazy)(()=>c(()=>import(`./apps-B9-IBy2A.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]))),Co=(0,Z.lazy)(()=>c(()=>Promise.resolve().then(()=>Is).then(e=>({default:e.AppsMenu})),void 0)),wo=(0,Z.lazy)(()=>c(()=>import(`./workspaces-DyWI__ok.js`),__vite__mapDeps([19,1,2,8,3,4,10,9,6,5,11,12,20,7,13,21,22,23,24,25,26,27,28,29,30,31,32,33]))),To=(0,Z.lazy)(()=>c(()=>import(`./_workspaceName_-BJ7uXLLN.js`),__vite__mapDeps([34,1,2,3,4,10,8,5,6,9,12,35,32,20,7,11,13,36,37,38,39,40,22,23,41,42,43,44,21,45,46,47,18,14,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,24,76,77,78,79,27,80,25,26,81,82,29,83,15,84,85,86,16,17,87]))),Eo=(0,Z.lazy)(()=>c(()=>import(`./document-DOp6AbOi.js`),__vite__mapDeps([88,1,2,3,4,9,10,8,6,5,7,11,12,13,43,44,38,39,40,20,22,23,41,21,45,46,47,18,14,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,27,25,82,35,32,24,89]))),Do=(0,Z.lazy)(()=>c(()=>import(`./home-BZ2OLB0t.js`),__vite__mapDeps([90,1,2,3,4,10,8,7,9,6,5,11,12,13,36,35,32,37,38,39,40,20,22,23,41,42,43,44,21,45,46,47,18,14,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,24,76,77,78,79,27,80,91,85,86]))),Oo=(0,Z.lazy)(()=>c(()=>import(`./desk-dI_FvLsK.js`),__vite__mapDeps([92,2,1]))),ko=(0,Z.lazy)(()=>c(()=>import(`./share-target-DEadau7S.js`),__vite__mapDeps([93,1,2,3,4,91,8,10,5,6,11,44,38,9,7,12,13,39,40,20,22,23,41,21,45,46,47,18,14,48,49,50,51,72,63,65,61,85,54,86]))),Ao=(0,Z.lazy)(()=>c(()=>import(`./contexts-CvMtPd1N2.js`),__vite__mapDeps([94,1,2,3,4,10,8,9,6,5,11,35,12,32,20,7,13,14,74,38,39,40,22,23,41,62,77,28,29,30]))),jo=(0,Z.lazy)(()=>c(()=>import(`./_contextId_-tiUa7oY9.js`),__vite__mapDeps([95,1,2,3,4,35,12,32,20,38,8,10,5,6,9,7,11,13,39,40,22,23,41,70,43,44,21,45,46,47,18,14,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,71,72,73,74,75,24,76,77,78,79,25,83,42,15,84,85,86,16,17,89]))),Mo=(0,Z.lazy)(()=>c(()=>import(`./api-tokens-DDH7LMJ7.js`),__vite__mapDeps([96,1,2,10,8,9,6,5,11,12,20,28,3,4,97,25,21]))),No=(0,Z.lazy)(()=>c(()=>import(`./devices-C3gLuNDv.js`),__vite__mapDeps([98,1,2,10,8,9,6,5,11,20,28,3,4,97,25,21,99,12]))),Po=(0,Z.lazy)(()=>c(()=>import(`./settings-Df2eiuZ1.js`),__vite__mapDeps([100,1,2,3,4,10,8,11,5,6,7,9,12,13,14,25,21,28]))),Fo=(0,Z.lazy)(()=>c(()=>import(`./appearance-BoZKRJ6u.js`),__vite__mapDeps([101,1,2,10,8,5,6,71,25,3,4,21,102,28,97]))),Io=(0,Z.lazy)(()=>c(()=>import(`./key-bindings-CwUENuYh.js`),__vite__mapDeps([103,1,2,28,3,4,10,8,5,6,97,25,21]))),Lo=(0,Z.lazy)(()=>c(()=>import(`./offline-COOUcZsG.js`),__vite__mapDeps([104,1,2,10,8,5,6,9,12,38,7,11,13,39,40,20,22,23,41,62,28,3,4,97,25,21]))),Ro=(0,Z.lazy)(()=>c(()=>import(`./about-Dn6r3v8E.js`),__vite__mapDeps([105,1,2,12,28,3,4,10,8,5,6,97,25,21]))),zo=(0,Z.lazy)(()=>c(()=>import(`./embedding-B5JiUA9X.js`),__vite__mapDeps([106,1,2,10,8,9,6,5,20,28,3,4,97,25,21,107,11,12]))),Bo=(0,Z.lazy)(()=>c(()=>import(`./shared-De1-Pxac.js`),__vite__mapDeps([108,1,2,3,4,9,10,8,6,5,11,12,20,28,97,25,21]))),Vo=(0,Z.lazy)(()=>c(()=>import(`./workspaces-Da_hUIj3.js`),__vite__mapDeps([109,1,2,10,8,9,6,5,11,44,37,12,35,32,20,39,28,3,4,110]))),Ho=(0,Z.lazy)(()=>c(()=>import(`./contexts-Ef3fHwv6.js`),__vite__mapDeps([111,1,2,37,6,12,35,32,28,3,4,10,8,5]))),Uo=(0,Z.lazy)(()=>c(()=>import(`./agents-DlLq0q2s.js`),__vite__mapDeps([112,1,2,37,6,12,35,32,28,3,4,10,8,5]))),Wo=(0,Z.lazy)(()=>c(()=>import(`./logs-Czn2sPeP.js`),__vite__mapDeps([113,1,2,10,8,9,6,5,11,44,37,12,35,32,20,28,3,4,97,25,21,110]))),Go=(0,Z.lazy)(()=>c(()=>import(`./roles-BpVWTMmp.js`),__vite__mapDeps([114,1,2,10,8,9,6,5,11,44,37,12,35,32,20,39,28,3,4,97,25,21,115]))),Ko=(0,Z.lazy)(()=>c(()=>import(`./users-CKz9kOoR.js`),__vite__mapDeps([116,1,2,10,8,9,6,5,11,44,37,12,35,32,20,39,28,3,4,97,25,21,110]))),qo=(0,Z.lazy)(()=>c(()=>import(`./embedding-B7cWrpy0.js`),__vite__mapDeps([117,1,2,10,8,9,6,5,11,37,12,35,32,20,28,3,4,97,25,21,107]))),Jo=(0,Z.lazy)(()=>c(()=>import(`./auth-HZNJB4wv.js`),__vite__mapDeps([118,1,2,10,8,5,6,9,11,12,37,35,32,20,28,3,4,97,25,21]))),Yo=(0,Z.lazy)(()=>c(()=>import(`./agents-CO1AV00y.js`),__vite__mapDeps([119,1,2,3,4,10,8,9,6,5,11,20,23,28,120,29,30,31,12,32]))),Xo=(0,Z.lazy)(()=>c(()=>import(`./_agentId_-BpZvdICK.js`),__vite__mapDeps([121,1,2,3,4,10,8,5,6,9,12,32,20,56,25,21,28]))),Zo=(0,Z.lazy)(()=>c(()=>import(`./settings-udxCpn5y.js`),__vite__mapDeps([122,1,2,3,4,10,8,9,6,5,11,20,7,12,13,21,14,23,25,28,120]))),Qo=(0,Z.lazy)(()=>c(()=>import(`./settings-CDsVas7f.js`),__vite__mapDeps([123,1,2,8,3,4,10,5,6,9,11,44,12,35,32,20,38,7,13,39,40,22,23,41,21,58,59,60,61,62,66,73,74,75,24,25,102,28,107,31,99,87,33]))),$o=(0,Z.lazy)(()=>c(()=>import(`./settings-CuK0olLh.js`),__vite__mapDeps([124,1,2,3,4,10,8,5,6,9,11,20,21,14,12,7,13,74,38,39,40,22,23,41,62,25,28]))),es=(0,Z.lazy)(()=>c(()=>import(`./roles-Bo9GZdOk.js`),__vite__mapDeps([125,1,2,10,8,9,6,5,11,37,12,35,32,20,7,13,39,28,3,4,115,29,30]))),ts=(0,Z.lazy)(()=>c(()=>import(`./remotes-CdEU1Y5l.js`),__vite__mapDeps([126,2,1,28,3,4,10,8,5,6]))),ns=(0,Z.lazy)(()=>c(()=>import(`./add-BTCF4qRT.js`),__vite__mapDeps([127,2,1,3,4,91,8,10,5,6,11,44,38,9,7,12,13,39,40,20,22,23,41,21,45,46,47,18,14,48,49,50,51,72,63,65,61,85,54,86])));function $(e){return(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`flex h-full items-center justify-center p-4 text-sm text-muted-foreground`,role:`status`,children:`Opening…`}),children:(0,Q.jsx)(e,{})})}var rs=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(d,{index:!0,element:$(Oo)},`r1`),(0,Q.jsx)(d,{path:`home`,element:$(Do)},`r2`),(0,Q.jsx)(d,{path:`share-target`,element:$(ko)},`r3`),(0,Q.jsx)(d,{path:`apps`,element:$(Co)},`apps-index`),(0,Q.jsx)(d,{path:`apps/:appletId`,element:$(So)},`apps-host`),(0,Q.jsx)(d,{path:`apps/add/:kind`,element:$(ns)},`r4`),(0,Q.jsx)(d,{path:`workspaces`,element:$(wo)},`r5`),(0,Q.jsx)(d,{path:`workspaces/:workspaceName`,element:$(To)},`r6`),(0,Q.jsx)(d,{path:`workspaces/:workspaceName/documents/by-id/:documentId`,element:$(Eo)},`workspace-document-by-id`),(0,Q.jsx)(d,{path:`workspaces/:workspaceName/documents/:documentId`,element:$(Eo)},`workspace-document`),(0,Q.jsx)(d,{path:`workspaces/:workspaceName/documents/by-hash/:algo/:checksum`,element:$(Eo)},`workspace-document-by-hash`),(0,Q.jsx)(d,{path:`workspaces/:workspaceName/documents/by-checksum/:algo/:checksum`,element:$(Eo)},`workspace-document-by-checksum`),(0,Q.jsx)(d,{path:`workspaces/:workspaceName/settings`,element:$(Qo)},`r7`),(0,Q.jsx)(d,{path:`workspaces/:workspaceName/settings/:tab`,element:$(Qo)},`r8`),(0,Q.jsx)(d,{path:`workspaces/:workspaceName/path/*`,element:$(To)},`r9`),(0,Q.jsx)(d,{path:`workspaces/:workspaceName/trees/:treeName`,element:$(To)},`r10`),(0,Q.jsx)(d,{path:`workspaces/:workspaceName/trees/:treeName/path/*`,element:$(To)},`r11`),(0,Q.jsx)(d,{path:`contexts`,element:$(Ao)},`r12`),(0,Q.jsx)(d,{path:`contexts/:contextId`,element:$(jo)},`r13`),(0,Q.jsx)(d,{path:`contexts/:contextId/settings`,element:$($o)},`r14`),(0,Q.jsx)(d,{path:`contexts/:contextId/settings/:tab`,element:$($o)},`r15`),(0,Q.jsx)(d,{path:`agents`,element:$(Yo)},`r16`),(0,Q.jsx)(d,{path:`agents/:agentId`,element:$(Xo)},`r17`),(0,Q.jsx)(d,{path:`agents/:agentId/:sessionId`,element:$(Xo)},`r18`),(0,Q.jsx)(d,{path:`agents/:agentId/settings`,element:$(Zo)},`r19`),(0,Q.jsx)(d,{path:`agents/:agentId/settings/:tab`,element:$(Zo)},`r20`),(0,Q.jsx)(d,{path:`roles`,element:$(es)},`r21`),(0,Q.jsx)(d,{path:`remotes`,element:$(ts)},`r22`),(0,Q.jsx)(d,{path:`settings`,element:$(Po)},`settings`),(0,Q.jsx)(d,{path:`appearance`,element:$(Fo)},`r23`),(0,Q.jsx)(d,{path:`key-bindings`,element:$(Io)},`key-bindings`),(0,Q.jsx)(d,{path:`offline`,element:$(Lo)},`r24`),(0,Q.jsx)(d,{path:`about`,element:$(Ro)},`r25`),(0,Q.jsx)(d,{path:`api-tokens`,element:$(Mo)},`r26`),(0,Q.jsx)(d,{path:`devices`,element:$(No)},`r27`),(0,Q.jsx)(d,{path:`embedding`,element:$(zo)},`r28`),(0,Q.jsx)(d,{path:`shared`,element:$(Bo)},`r29`),(0,Q.jsx)(d,{path:`admin/users`,element:$(Ko)},`r30`),(0,Q.jsx)(d,{path:`admin/contexts`,element:$(Ho)},`r31`),(0,Q.jsx)(d,{path:`admin/workspaces`,element:$(Vo)},`r32`),(0,Q.jsx)(d,{path:`admin/agents`,element:$(Uo)},`r33`),(0,Q.jsx)(d,{path:`admin/logs`,element:$(Wo)},`r34`),(0,Q.jsx)(d,{path:`admin/roles`,element:$(Go)},`r35`),(0,Q.jsx)(d,{path:`admin/embedding`,element:$(qo)},`r36`),(0,Q.jsx)(d,{path:`admin/auth`,element:$(Jo)},`r37`)]});function is(e){if(typeof e!=`string`||!e.startsWith(`/`)||e.startsWith(`//`)||/[\\\u0000-\u0020]/.test(e))return null;let t=new URL(e,`https://canvas.invalid`);return t.origin!==`https://canvas.invalid`||/^\/(?:login|register|pub|share-target|apps|next)(?:\/|$)/.test(t.pathname)||t.pathname===`/`||[...t.searchParams.keys()].some(e=>/token|password|secret|code/i.test(e))?null:t.pathname+t.search+t.hash}function as(e){let t=2166136261;for(let n of e)t=Math.imul(t^n.charCodeAt(0),16777619);return`canvas:last-screen:${t>>>0}`}var os=p(rs),ss=e=>{let t=is(e);return t&&x(os,t)?t:null};function cs(){let e=h(),[t]=(0,Z.useState)(()=>{if(e.pathname!==`/`||e.search||e.hash)return null;try{let t=localStorage.getItem(`authToken`);return t?{key:e.key,path:ss(localStorage.getItem(as(t)))||`/home`}:null}catch{return{key:e.key,path:`/home`}}}),n=t&&e.key===t.key&&e.pathname===`/`;return(0,Z.useEffect)(()=>{if(n)return;let t=ss(e.pathname+e.search+e.hash);if(t)try{let e=localStorage.getItem(`authToken`);e&&localStorage.setItem(as(e),t)}catch{}},[e.pathname,e.search,e.hash,n]),n?(0,Q.jsx)(u,{to:t.path,replace:!0}):null}var ls={activeSection:null,m0Open:!1,m1Open:!1,m2Open:!1,m2View:null,selectedEntityId:null,user:null};function us(e,t){switch(t.type){case`RESTORE_MENU`:return{...e,...t.menu,user:e.user};case`SET_SECTION`:return{...e,activeSection:t.section,m1Open:t.section!==null,m2Open:!1,m2View:null,selectedEntityId:null};case`TOGGLE_SECTION`:return e.activeSection===t.section&&e.m1Open?{...e,activeSection:null,m1Open:!1,m2Open:!1,m2View:null}:{...e,activeSection:t.section,m1Open:!0,m2Open:!1,m2View:null,selectedEntityId:null};case`TOGGLE_M0`:return e.m0Open?{...e,m0Open:!1,activeSection:null,m1Open:!1,m2Open:!1,m2View:null}:{...e,m0Open:!0};case`CLOSE_M0`:return{...e,m0Open:!1};case`CLOSE_M1`:return{...e,activeSection:null,m1Open:!1,m2Open:!1,m2View:null};case`OPEN_M2`:return{...e,m2Open:!0,m2View:t.view,selectedEntityId:t.entityId===void 0?e.selectedEntityId:t.entityId};case`OPEN_M2_DRAWER`:return{...e,m0Open:!0,activeSection:t.section,m1Open:!0,m2Open:!0,m2View:t.view,selectedEntityId:t.entityId};case`OPEN_M1_DRAWER`:return{...e,m0Open:!0,activeSection:t.section,m1Open:!0,m2Open:!1,m2View:null,selectedEntityId:null};case`CLOSE_M2`:return{...e,m2Open:!1,m2View:null};case`SELECT_ENTITY`:return{...e,selectedEntityId:t.entityId};case`SYNC_FROM_URL`:{let n=!t.mobile&&!e.m2Open&&e.m2View===null&&t.section===e.activeSection&&t.entityId===e.selectedEntityId;return t.section===e.activeSection&&t.entityId===e.selectedEntityId&&t.m2View===e.m2View&&!(t.mobile&&(e.m1Open||e.m0Open))?e:{...e,activeSection:t.section,m0Open:!t.mobile&&e.m0Open,m1Open:!t.mobile&&t.section!==null,selectedEntityId:t.entityId,m2Open:!n&&t.m2View!==null,m2View:n?null:t.m2View}}case`SET_USER`:return{...e,user:t.user};default:return e}}function ds({children:e}){let[t,n]=(0,Z.useReducer)(us,ls),r=h(),i=m(),a=(0,Z.useRef)(t);(0,Z.useLayoutEffect)(()=>{a.current=t},[t]),ia(t,n);let o=(0,Z.useCallback)((e,t=!1,o=!1)=>{let s=us(a.current,e);if(a.current=s,n(e),!ua())return;let{activeSection:c,m0Open:l,m1Open:u,m2Open:d,m2View:f,selectedEntityId:p}=s;i({pathname:r.pathname,search:r.search,hash:r.hash},{replace:t,state:{...r.state,canvasMenu:{activeSection:c,m0Open:l,m1Open:u,m2Open:d,m2View:f,selectedEntityId:p},canvasMenuBack:o}})},[r,i]),s=(0,Z.useCallback)(e=>{if(ua()&&a.current.m1Open){let{activeSection:t,m0Open:n,m1Open:o,m2Open:s,m2View:c,selectedEntityId:l}=a.current;i(e,{replace:!0,state:{...r.state,canvasMenu:{activeSection:t,m0Open:n,m1Open:o,m2Open:s,m2View:c,selectedEntityId:l},canvasMenuBack:!1}})}i(e)},[r.state,i]),c=(0,Z.useCallback)(()=>{if(window.history.state?.idx>0){i(-1);return}let e=a.current;if(e.m1Open&&e.m2Open)o({type:`CLOSE_M2`},!0,!0);else if(e.m1Open)o({type:`CLOSE_M1`},!0,!0);else if(e.m0Open)o({type:`CLOSE_M0`},!0,!0);else{let{section:e,entityId:t,m2View:n}=fa(r.pathname);if(!ua()){i(e?`/${e}`:`/`);return}o(e&&t?{type:`OPEN_M2_DRAWER`,section:e,view:n,entityId:t}:{type:`TOGGLE_M0`},!0,!0)}},[o,r.pathname,i]);(0,Z.useEffect)(()=>{let e=mn();if(e){n({type:`SET_USER`,user:e});return}let t=!1;return vn().then(e=>{!t&&e&&n({type:`SET_USER`,user:e})}).catch(()=>{}),()=>{t=!0}},[]);let l={state:t,dispatch:n,setSection:(0,Z.useCallback)(e=>{o({type:`SET_SECTION`,section:e})},[o]),toggleSection:(0,Z.useCallback)(e=>{o({type:`TOGGLE_SECTION`,section:e})},[o]),toggleM0:(0,Z.useCallback)(()=>{o({type:`TOGGLE_M0`},a.current.m0Open)},[o]),closeM0:(0,Z.useCallback)(()=>{o({type:`CLOSE_M0`},!0)},[o]),closeM1:(0,Z.useCallback)(()=>{o({type:`CLOSE_M1`},!0)},[o]),openM2:(0,Z.useCallback)((e,t)=>{o({type:`OPEN_M2`,view:e,entityId:t})},[o]),openM2Drawer:(0,Z.useCallback)((e,t,n)=>{o({type:`OPEN_M2_DRAWER`,section:e,view:t,entityId:n})},[o]),openM1Drawer:(0,Z.useCallback)(e=>{o({type:`OPEN_M1_DRAWER`,section:e})},[o]),closeM2:(0,Z.useCallback)(()=>{ua()&&a.current.m1Open&&a.current.m2Open?c():n({type:`CLOSE_M2`})},[c]),selectEntity:(0,Z.useCallback)(e=>{n({type:`SELECT_ENTITY`,entityId:e})},[]),goBack:c,navigateFromMenu:s};return(0,Q.jsx)(pa.Provider,{value:l,children:e})}var fs;function ps(){let[e,t]=(0,Z.useState)({local:!1});return(0,Z.useEffect)(()=>{fs??=fetch(`${J}/runtime/capabilities`).then(async e=>e.ok?(await e.json()).payload:{local:!1}).catch(()=>({local:!1}));let e=!0;return fs.then(n=>{e&&t(n)}),()=>{e=!1}},[]),e}function ms(){return(0,Z.useSyncExternalStore)(rn,sn,()=>!1)}function hs(e,t){let n=null,r=!1,i,a;function o(){clearTimeout(i),!r&&sn()&&(i=setTimeout(()=>{s()},3e4))}function s(s=!1){if(n)return n;if(r)return Promise.resolve(!1);clearTimeout(i),a=new AbortController;let c=setTimeout(()=>a?.abort(),5e3);return n=(async()=>{try{let n=await fetch(e,{cache:`no-store`,credentials:`omit`,signal:a.signal});if(!n.ok||n.headers.get(`x-canvas-offline`)===`fallback`)throw Error(`Unavailable`);if((await n.json()).status!==`success`)throw Error(`Not a Canvas response`);if(r)return!1;let i=sn();return on(),(i||s)&&t(),!0}catch{return r||tn(),!1}finally{clearTimeout(c),n=null,o()}})(),n}let c=rn(o),l=()=>{s()};return window.addEventListener(`online`,l),o(),{retry:s,stop(){r=!0,clearTimeout(i),a?.abort(),c(),window.removeEventListener(`online`,l)}}}var gs;function _s(){gs=hs(`${J}/ping`,()=>X.retryNow());let e=()=>{gs?.retry()},t=X.on(`connect_error`,e),n=X.on(`disconnect`,e);return()=>{t(),n(),gs?.stop(),gs=void 0}}function vs(){return gs?.retry(!0)??Promise.resolve(!1)}function ys(){let e=ms(),[t,n]=(0,Z.useState)(!1);return e?(0,Q.jsxs)(`details`,{className:`relative`,children:[(0,Q.jsx)(`summary`,{"aria-label":`Offline — connection options`,title:`Offline — cached content available`,className:`flex h-10 w-10 cursor-pointer list-none items-center justify-center rounded-lg text-amber-600 hover:bg-accent/50 [&::-webkit-details-marker]:hidden`,children:(0,Q.jsx)(O,{className:`h-5 w-5`})}),(0,Q.jsxs)(`div`,{className:`absolute bottom-0 left-full z-50 ml-2 w-60 max-w-[calc(100vw-5rem)] rounded-lg border bg-popover p-3 text-popover-foreground shadow-lg`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium`,role:`status`,children:`Offline`}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`You can browse cached documents. We’ll reconnect automatically when the server is available.`}),(0,Q.jsx)(`button`,{type:`button`,disabled:t,onClick:async()=>{n(!0);try{await vs()}finally{n(!1)}},className:`mt-3 rounded-md bg-secondary px-3 py-2 text-xs font-medium hover:bg-accent disabled:opacity-50`,children:t?`Checking…`:`Retry now`})]})]}):null}var bs=ye,xs=j,Ss=Lt,Cs=Z.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,Q.jsx)(zt,{children:(0,Q.jsx)(We,{ref:r,sideOffset:t,className:G(`z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in duration-fast fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]`,e),...n})}));Cs.displayName=We.displayName;var ws=Z.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(Re,{ref:n,className:G(`relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full`,e),...t}));ws.displayName=Re.displayName;var Ts=Z.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(Ut,{ref:n,className:G(`aspect-square h-full w-full`,e),...t}));Ts.displayName=Ut.displayName;var Es=Z.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(Ft,{ref:n,className:G(`flex h-full w-full items-center justify-center rounded-full bg-muted`,e),...t}));Es.displayName=Ft.displayName;function Ds({section:e,icon:t,label:n,disabled:r}){let{state:i,toggleSection:a}=ca(),o=i.activeSection===e;return(0,Q.jsxs)(xs,{children:[(0,Q.jsx)(Ss,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,disabled:r,"aria-label":n,onClick:()=>!r&&e&&a(e),className:G(`relative flex items-center justify-center w-10 h-10 rounded-lg transition-colors`,o?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`,r&&`opacity-30 cursor-not-allowed`),children:[o&&(0,Q.jsx)(`span`,{className:`absolute right-0 top-1/2 -translate-y-1/2 w-0.5 h-5 bg-foreground rounded-l`}),t]})}),(0,Q.jsx)(Cs,{side:`right`,sideOffset:8,children:n})]})}function Os({path:e,icon:t,label:n,section:r=`settings`}){let i=m(),{setSection:a}=ca();return(0,Q.jsxs)(xs,{children:[(0,Q.jsx)(Ss,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":n,onClick:()=>{a(r),i(e)},className:`flex items-center justify-center w-10 h-10 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors`,children:t})}),(0,Q.jsx)(Cs,{side:`right`,sideOffset:8,children:n})]})}function ks(){let{state:e,toggleM0:t}=ca(),n=ms();return(0,Q.jsxs)(`button`,{type:`button`,onClick:t,"aria-label":`${e.m0Open?`Close menu`:`Open menu`}${n?` — offline, connection options in menu`:``}`,"data-shell":`rail`,className:`fixed bottom-rail-inset left-2 z-nav flex h-rail w-rail items-center justify-center rounded-full bg-foreground text-background shadow-elevation-4 md:hidden`,children:[e.m0Open?(0,Q.jsx)(z,{className:`h-5 w-5`}):(0,Q.jsx)(Et,{className:`h-5 w-5`}),n&&(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`absolute right-0 top-0 h-3 w-3 rounded-full border-2 border-background bg-amber-500`})]})}function As(){let{state:e,closeM0:t,closeM1:n}=ca(),{state:r,setView:i,closeT1:a}=ei(),o=m(),{showToast:s}=xn(),c=e.user?.userType===`admin`,l=ps(),u=()=>{r.t1Open?a():i(`tools`),n(),t()},d=(0,Z.useCallback)(async()=>{try{await Y.post(`/auth/logout`),localStorage.removeItem(`authToken`),o(`/login`)}catch{s({title:`Error`,description:`Logout failed`,variant:`destructive`})}},[o,s]);return(0,Q.jsxs)(bs,{delayDuration:200,children:[e.m0Open&&(0,Q.jsx)(`div`,{className:`fixed inset-0 z-nav-scrim bg-scrim animate-fade-in md:hidden`,onClick:t,"aria-hidden":!0}),(0,Q.jsxs)(`div`,{"data-shell":`rail`,className:G(`flex flex-col items-center w-rail h-full rounded-(--panel-radius) bg-transparent shrink-0`,e.m0Open?`max-md:fixed max-md:left-2 max-md:top-2 max-md:bottom-rail-stack max-md:z-rail max-md:h-auto max-md:bg-card max-md:surface-glass max-md:shadow-elevation-5`:`max-md:hidden`),children:[(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-12 w-full shrink-0`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Canvas home`,onClick:()=>o(`/home`),className:`flex items-center justify-center w-10 h-10 rounded-lg hover:bg-accent/50 transition-colors`,children:(0,Q.jsx)(`img`,{src:`/images/logo-br_128x128.png`,alt:``,className:`w-6 h-6`})})}),(0,Q.jsxs)(`nav`,{className:`flex flex-col items-center gap-1 py-2 flex-1 min-h-0 overflow-y-auto`,children:[(!l.local||l.workspace!==!1)&&(0,Q.jsx)(Ds,{section:`contexts`,icon:(0,Q.jsx)(Bt,{className:`w-5 h-5`}),label:`Contexts`}),(!l.local||l.workspace!==!1)&&(0,Q.jsx)(Ds,{section:`workspaces`,icon:(0,Q.jsx)(Ge,{className:`w-5 h-5`}),label:`Workspaces`}),(!l.local||l.agent)&&(0,Q.jsx)(Ds,{section:`agents`,icon:(0,Q.jsx)(Ne,{className:`w-5 h-5`}),label:`Agents`}),(0,Q.jsx)(Ds,{section:`apps`,icon:(0,Q.jsx)(it,{className:`w-5 h-5`}),label:`Apps`}),(!l.local||l.workspace!==!1)&&(0,Q.jsx)(Os,{path:`/roles`,section:null,icon:(0,Q.jsx)(Pt,{className:`w-5 h-5`}),label:`Roles`}),c&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`w-6 h-px bg-border my-2`}),(0,Q.jsx)(Os,{path:`/admin/users`,icon:(0,Q.jsx)(te,{className:`w-5 h-5`}),label:`All Users`}),(0,Q.jsx)(Os,{path:`/admin/logs`,icon:(0,Q.jsx)(Ue,{className:`w-5 h-5`}),label:`Server Logs`}),(0,Q.jsx)(Os,{path:`/admin/workspaces`,icon:(0,Q.jsx)(Ie,{className:`w-5 h-5`}),label:`All Workspaces`}),(0,Q.jsx)(Os,{path:`/admin/agents`,icon:(0,Q.jsx)(Ne,{className:`w-5 h-5`}),label:`All Agents`}),(0,Q.jsx)(Os,{path:`/admin/roles`,icon:(0,Q.jsx)(Pt,{className:`w-5 h-5`}),label:`All Roles`})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-1 py-2 shrink-0`,children:[(0,Q.jsx)(`div`,{className:`w-6 h-px bg-border mb-2`}),(0,Q.jsx)(ys,{}),(0,Q.jsxs)(xs,{children:[(0,Q.jsx)(Ss,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,onClick:u,"aria-label":r.t1Open?`Close toolbox`:`Open toolbox`,className:G(`flex items-center justify-center w-10 h-10 rounded-lg transition-colors`,r.t1Open?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`),children:(0,Q.jsx)(ve,{className:`w-5 h-5`})})}),(0,Q.jsx)(Cs,{side:`right`,sideOffset:8,children:`Toolbox`})]}),!l.local&&(0,Q.jsx)(Os,{path:`/settings`,section:`settings`,icon:(0,Q.jsx)(ut,{className:`w-5 h-5`}),label:`Settings`}),(0,Q.jsxs)(xs,{children:[(0,Q.jsx)(Ss,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":e.user?.email?`Profile: ${e.user.email}`:`Profile`,onClick:()=>o(`/home`),className:`flex items-center justify-center w-10 h-10 rounded-lg hover:bg-accent/50 transition-colors`,children:(0,Q.jsx)(ws,{className:`h-7 w-7 touch-target`,children:(0,Q.jsx)(Es,{className:`text-[10px] bg-muted`,children:e.user?.email?(e=>e.split(`@`)[0].split(`.`).map(e=>e.charAt(0).toUpperCase()).join(``).slice(0,2))(e.user.email):`U`})})})}),(0,Q.jsx)(Cs,{side:`right`,sideOffset:8,children:e.user?.email?.split(`@`)[0]||`Profile`})]}),(0,Q.jsxs)(xs,{children:[(0,Q.jsx)(Ss,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Log out`,onClick:d,className:`flex items-center justify-center w-10 h-10 rounded-lg text-destructive hover:bg-destructive/10 transition-colors`,children:(0,Q.jsx)(Je,{className:`w-5 h-5`})})}),(0,Q.jsx)(Cs,{side:`right`,sideOffset:8,children:`Logout`})]})]})]})]})}function js(){let{goBack:e}=ca();return(0,Q.jsx)(`button`,{type:`button`,onClick:e,"aria-label":`Back to previous view`,title:`Back to previous view`,className:`-ml-2 mr-1 flex h-11 w-11 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-accent md:hidden`,children:(0,Q.jsx)(Ze,{className:`h-5 w-5`})})}var Ms=[{id:`productivity`,label:`Productivity`},{id:`creative`,label:`Creative`},{id:`media`,label:`Media & capture`},{id:`utilities`,label:`Utilities`}];function Ns(e,t){let n=t.trim().toLocaleLowerCase();return Ms.map(t=>({...t,apps:e.filter(e=>e.category===t.id&&`${e.name} ${e.description} ${e.kind} ${t.label}`.toLocaleLowerCase().includes(n)).sort((e,t)=>e.name.localeCompare(t.name)||e.id.localeCompare(t.id))})).filter(e=>e.apps.length)}function Ps(e){let t=new URL(e);if(![`http:`,`https:`].includes(t.protocol)||t.username||t.password)throw Error(`Enter an HTTP or HTTPS URL without embedded credentials.`);return t.href}function Fs({apps:e,query:t,activeId:n,onLaunch:r,onRemove:i}){let a=Ns(e,t);return(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto p-2`,children:[a.map(e=>(0,Q.jsxs)(`section`,{"aria-label":e.label,children:[(0,Q.jsx)(`h3`,{className:`px-2 py-2 text-xs font-semibold text-muted-foreground`,children:e.label}),e.apps.map(e=>{let t=e.kind===`web`?ne:e.kind===`desktop`?Fe:Bt;return(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>r(e),"aria-current":n===e.id?`page`:void 0,className:`flex min-w-0 flex-1 items-start gap-2 rounded-md p-2 text-left hover:bg-accent/50 ${n===e.id?`bg-accent`:``}`,children:[(0,Q.jsx)(t,{className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.name}),(0,Q.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.description}),(0,Q.jsx)(`span`,{className:`mt-1 block text-[10px] text-muted-foreground`,children:e.kind===`canvas`?`Canvas`:e.kind===`web`?`Web app · opens in browser`:`Desktop app`})]})]}),e.kind===`web`&&i&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>i(e),"aria-label":`Remove ${e.name}`,className:`rounded p-2 text-muted-foreground hover:bg-accent`,children:(0,Q.jsx)(je,{className:`h-3.5 w-3.5`})})]},e.id)})]},e.id)),!a.length&&(0,Q.jsx)(`p`,{role:`status`,className:`p-3 text-sm text-muted-foreground`,children:`No matching apps.`})]})}var Is=t({AppsMenu:()=>zs}),Ls=`canvas:webApps`;function Rs(){try{let e=JSON.parse(localStorage.getItem(Ls)||`[]`);return Array.isArray(e)?e.filter(e=>{if(!e||typeof e.id!=`string`||typeof e.name!=`string`||typeof e.description!=`string`||e.kind!==`web`||!Ms.some(t=>t.id===e.category))return!1;try{return typeof e.target==`string`&&!!Ps(e.target)}catch{return!1}}):[]}catch{return[]}}function zs(){let{navigateFromMenu:e}=ca(),t=h(),n=ga(),[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(Rs),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(``);(0,Z.useEffect)(()=>{let e=()=>o(Rs());return window.addEventListener(`storage`,e),window.addEventListener(`canvas:apps-changed`,e),()=>{window.removeEventListener(`storage`,e),window.removeEventListener(`canvas:apps-changed`,e)}},[]);let d=e=>{try{return localStorage.setItem(Ls,JSON.stringify(e)),o(e),window.dispatchEvent(new Event(`canvas:apps-changed`)),!0}catch{return u(`Unable to save web apps on this device.`),!1}},f=[...ha.map(e=>({id:`canvas:${e.id}`,name:e.label,description:e.description,category:e.category,kind:`canvas`,target:`/apps/${e.id}`})),...a];return(0,Q.jsxs)(`nav`,{"aria-label":`Apps`,className:`flex h-full min-h-0 flex-col`,children:[(0,Q.jsxs)(`div`,{className:`shrink-0 space-y-3 border-b p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(js,{}),(0,Q.jsx)(`h2`,{className:`flex-1 text-sm font-semibold`,children:`Apps`}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Add web app`,title:`Add web app`,onClick:()=>{c(!s),u(``)},className:`rounded p-1 hover:bg-accent`,children:(0,Q.jsx)(ue,{className:`h-4 w-4`})})]}),(0,Q.jsx)(`input`,{type:`search`,"aria-label":`Search apps`,placeholder:`Find an app…`,value:r,onChange:e=>i(e.target.value),className:`w-full rounded-md border bg-background px-2 py-1.5 text-sm`}),s&&(0,Q.jsxs)(`form`,{className:`space-y-2`,onSubmit:e=>{e.preventDefault();let t=new FormData(e.currentTarget);try{let e=String(t.get(`name`)||``).trim();if(!e)throw Error(`Enter an app name.`);let n={id:`web:${crypto.randomUUID()}`,name:e,description:``,category:t.get(`category`),kind:`web`,target:Ps(String(t.get(`url`)||``))};d([...Rs(),n])&&(c(!1),u(``))}catch(e){u(e instanceof Error?e.message:`Unable to add app.`)}},children:[(0,Q.jsx)(`input`,{name:`name`,required:!0,"aria-label":`App name`,placeholder:`App name`,className:`w-full rounded border bg-background p-1 text-sm`}),(0,Q.jsx)(`input`,{name:`url`,type:`url`,required:!0,"aria-label":`App URL`,placeholder:`https://…`,className:`w-full rounded border bg-background p-1 text-sm`}),(0,Q.jsx)(`select`,{name:`category`,"aria-label":`App category`,className:`w-full rounded border bg-background p-1 text-sm`,children:Ms.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.label},e.id))}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Saved on this device. Opens in your browser.`}),(0,Q.jsx)(`button`,{type:`submit`,className:`rounded border px-2 py-1 text-sm hover:bg-accent`,children:`Add app`})]}),l&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:l})]}),(0,Q.jsx)(Fs,{apps:f,query:r,activeId:f.find(e=>e.kind===`canvas`&&e.target===t.pathname)?.id,onLaunch:r=>{if(r.kind===`web`){window.open(Ps(r.target),`_blank`,`noopener,noreferrer`);return}let i=new URLSearchParams;if(t.pathname.startsWith(`/apps/`)){let e=new URLSearchParams(t.search);for(let t of[`context`,`workspace`,`path`,`tree`])e.has(t)&&i.set(t,e.get(t))}else n?.mode===`context`?i.set(`context`,n.contextId):n?.mode===`workspace`&&(i.set(`workspace`,n.workspaceName),i.set(`path`,n.path),i.set(`tree`,n.treeName));e(`${r.target}${i.size?`?${i}`:``}`)},onRemove:e=>{d(Rs().filter(t=>t.id!==e.id))}})]})}var Bs=220,Vs=560;function Hs({width:e,onResize:t,onDragging:n}){let r=(0,Z.useRef)(null),i=e=>t(Math.min(Vs,Math.max(Bs,e))),a=()=>{r.current=null,n?.(!1)};return(0,Q.jsx)(`div`,{role:`separator`,"aria-label":`Resize menu`,"aria-orientation":`vertical`,"aria-valuemin":Bs,"aria-valuemax":Vs,"aria-valuenow":e,tabIndex:0,title:`Drag to resize; use arrow keys to adjust; Home resets width`,className:`absolute inset-y-0 right-0 z-30 flex w-3 touch-none select-none cursor-col-resize items-center justify-center hover:bg-primary/10 focus-visible:bg-primary/10 focus-visible:outline-none [@media(pointer:coarse)]:w-6`,onPointerDown:t=>{t.button!==0||r.current||(t.preventDefault(),t.stopPropagation(),r.current={id:t.pointerId,x:t.clientX,width:e},t.currentTarget.setPointerCapture(t.pointerId),n?.(!0))},onPointerMove:e=>{r.current?.id===e.pointerId&&i(r.current.width+e.clientX-r.current.x)},onPointerUp:e=>{r.current?.id===e.pointerId&&(a(),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))},onPointerCancel:a,onLostPointerCapture:a,onDoubleClick:()=>i(280),onKeyDown:t=>{[`ArrowLeft`,`ArrowRight`,`Home`].includes(t.key)&&(t.preventDefault(),t.stopPropagation(),i(t.key===`Home`?280:e+(t.key===`ArrowRight`?1:-1)*(t.shiftKey?64:16)))},children:(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`h-10 w-1 rounded-full bg-border`})})}function Us(e,t,n,r=!0){let i=Pr(),a=h(),o=(0,Z.useRef)(null);(0,Z.useLayoutEffect)(()=>{let s=window.history.state?.idx??0,c=o.current,l=a.state?.canvasMenuBack||!!c&&(s<c.index||s===c.index&&c.backwards);if(o.current={active:t,viewKey:n,index:s,backwards:l},!r||!i||!t||!c||c.active&&c.viewKey===n)return;let u=e.current;if(!u||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let d=Number.parseFloat(getComputedStyle(u).getPropertyValue(`--motion-scale`)),f=Number.isFinite(d)?Math.max(0,d):1,p=u.animate([{transform:`translateX(${l?`-100%`:`100%`})`},{transform:`translateX(0)`}],{duration:70*f,easing:`cubic-bezier(0.2, 0, 0, 1)`});return()=>p.cancel()},[r,i,t,n,a.key,a.state,e])}function Ws(e){return[...e].sort((e,t)=>{let n=typeof e.order==`number`&&Number.isFinite(e.order)?e.order:2**53-1,r=typeof t.order==`number`&&Number.isFinite(t.order)?t.order:2**53-1;if(n!==r)return n-r;let i=e.createdAt??``,a=t.createdAt??``;return i===a?(e.name??``).localeCompare(t.name??``):i<a?-1:1})}function Gs(e,t,n){let r=[...e],[i]=r.splice(t,1);return r.splice(n,0,i),r}async function Ks(e,t){return{failed:(await Promise.allSettled(e.map((e,n)=>e.order===n?Promise.resolve():t(e,n)))).filter(e=>e.status===`rejected`).length}}function qs(e){let[t,n]=(0,Z.useState)(null),[r,i]=(0,Z.useState)(null);return{rowProps:e=>({"data-reorder-index":e}),handleProps:t=>({onPointerDown:r=>{if(r.pointerType===`mouse`&&r.button!==0)return;r.preventDefault(),r.stopPropagation();let a=r.currentTarget.closest(`[data-reorder-index]`);if(!a)return;let o=a.parentElement,s=(o?[...o.querySelectorAll(`:scope > [data-reorder-index]`)]:[a]).map(e=>({index:Number(e.dataset.reorderIndex),rect:e.getBoundingClientRect()})).filter(e=>Number.isFinite(e.index)).sort((e,t)=>e.index-t.index).map(e=>e.rect.top+e.rect.height/2),c=a.getBoundingClientRect(),l=a.cloneNode(!0);Object.assign(l.style,{position:`fixed`,left:`${c.left}px`,top:`${c.top}px`,width:`${c.width}px`,height:`${c.height}px`,margin:`0`,pointerEvents:`none`,zIndex:`100`,opacity:`0.92`,boxShadow:`0 12px 32px rgba(0,0,0,.28)`,willChange:`transform`}),document.body.appendChild(l);let u={x:r.clientX,y:r.clientY},d=t;n(t),i(t);let f={x:r.clientX,y:r.clientY},p=0,m=()=>{p=0,l.style.transform=`translate(${f.x-u.x}px, ${f.y-u.y}px) scale(1.02)`;let e=s.length;for(let t=0;t<s.length;t++)if(f.y<s[t]){e=t;break}e!==d&&(d=e,i(e))},h=e=>{f={x:e.clientX,y:e.clientY},p||=requestAnimationFrame(m)},g=()=>{window.removeEventListener(`pointermove`,h),window.removeEventListener(`pointerup`,g),window.removeEventListener(`pointercancel`,g),p&&cancelAnimationFrame(p),l.remove(),n(null),i(null),d!==t&&d!==t+1&&e(t,d>t?d-1:d)};window.addEventListener(`pointermove`,h),window.addEventListener(`pointerup`,g),window.addEventListener(`pointercancel`,g)},onClick:e=>{e.preventDefault(),e.stopPropagation()},style:{touchAction:`none`}}),insertIndex:r,draggingIndex:t,insertLineClass:(e,n)=>r===null||t===null?!1:r===e?`shadow-[0_-3px_0_0_var(--color-primary)]`:r===n&&e===n-1&&`shadow-[0_3px_0_0_var(--color-primary)]`}}function Js(e){let[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)(!1),a=(0,Z.useRef)(!1),o=(0,Z.useRef)(!1),s=(0,Z.useCallback)(async()=>{if(!o.current){o.current=!0,i(!0);try{let e=await si();n(e||[]),a.current=!0}catch(e){console.error(`Failed to fetch contexts:`,e)}finally{o.current=!1,i(!1)}}},[]),c=(0,Z.useRef)(s);(0,Z.useEffect)(()=>{c.current=s});let l=(0,Z.useCallback)(()=>{a.current=!1,s()},[s]);return(0,Z.useEffect)(()=>{e&&!a.current&&s()},[e,s]),(0,Z.useEffect)(()=>{if(!e)return;let t=()=>X.emit(`subscribe`,{channel:`context`}),r=()=>X.emit(`unsubscribe`,{channel:`context`}),i=X.on(`connect`,()=>{t(),s()});t();let o=e=>{let t=e;!t?.id||!t?.userId||n(e=>e.some(e=>e.id===t.id&&e.userId===t.userId)?e:[...e,t])},l=e=>{let t=e;!t?.id||!t?.userId||n(e=>e.map(e=>e.id===t.id&&e.userId===t.userId?{...e,...t}:e))},u=e=>{let t=e,r=t?.contextId??t?.id;r&&n(e=>e.filter(e=>e.id!==r))},d=e=>{let t=e;!t?.id||!t?.userId||n(e=>e.map(e=>e.id===t.id&&e.userId===t.userId?{...e,...t}:e))},f=()=>{a.current=!1,c.current()},p=[[`context:created`,o],[`context.created`,o],[`context:updated`,l],[`context.updated`,l],[`context:deleted`,u],[`context.deleted`,u],[`context:url:changed`,d],[`context.url.set`,d],[`context:url:set`,d],[`workspace:status:changed`,f],[`workspace.status.changed`,f]];return p.forEach(([e,t])=>X.on(e,t)),()=>{r(),i?.(),p.forEach(([e,t])=>X.off(e,t))}},[e,s]),(0,Z.useEffect)(()=>{let e=e=>{let t=e.detail;n(e=>e.filter(e=>!ai(e,t)))};return window.addEventListener(ri,e),()=>window.removeEventListener(ri,e)},[]),(0,Z.useEffect)(()=>{let e=()=>{a.current=!1,s()};return window.addEventListener(`contexts:refresh`,e),()=>window.removeEventListener(`contexts:refresh`,e)},[s]),{contexts:(0,Z.useMemo)(()=>Ws(t),[t]),isLoading:r,refresh:l}}function Ys(){let{state:e,selectEntity:t,openM2:n,closeM2:r}=ca(),a=Pr(),{contexts:o,isLoading:s}=Js(e.activeSection===`contexts`),{showToast:c}=xn(),l=m(),[u,d]=(0,Z.useState)(null),f=u&&u.base===o?u.order:o,p=e=>e.isShared===!0||e.type===`shared`,{rowProps:h,handleProps:g,draggingIndex:_,insertLineClass:v}=qs((e,t)=>{let n=Gs(f,e,t);d({base:o,order:n}),Ks(n,(e,t)=>p(e)?Promise.resolve():ui(e.id,{order:t})).then(({failed:e})=>{window.dispatchEvent(new CustomEvent(`contexts:refresh`)),e&&c({title:`Partial reorder`,description:`${e} context(s) could not be reordered`,variant:`destructive`})})}),y=e=>{t(e.id),l(`/contexts/${e.id}`)};return(0,Q.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-4 h-12 border-b border-border shrink-0`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center`,children:[(0,Q.jsx)(js,{}),(0,Q.jsx)(`span`,{className:`text-sm font-semibold`,children:`Contexts`})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{r(),l(`/contexts?create=1`)},title:`Create context`,"aria-label":`Create context`,className:`flex items-center justify-center w-6 h-6 rounded-full bg-foreground text-background hover:opacity-80 transition-opacity`,children:(0,Q.jsx)(ue,{className:`w-3.5 h-3.5`})})]}),(0,Q.jsx)(`div`,{className:`flex-1 overflow-y-auto py-2`,children:s&&o.length===0?(0,Q.jsx)(`div`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:`Loading...`}):o.length===0?(0,Q.jsx)(`div`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:`No contexts found`}):(0,Q.jsx)(`div`,{className:`space-y-1.5 px-2`,children:f.map((r,o)=>{let s=e.selectedEntityId===r.id,c=p(r),u=r.workspaceActive!==!1,d=xi(r.color);return(0,Q.jsxs)(`div`,{...h(o),"data-active":s||void 0,className:G(`group relative rounded-(--card-radius) py-2.5 pl-3 pr-7 transition-all shadow-elevation-1`,u?`cursor-pointer hover:shadow `+(s?`bg-accent shadow`:`bg-card hover:bg-accent/50`):`cursor-not-allowed opacity-50 bg-card`,v(o,f.length),_===o&&`opacity-60`),onClick:()=>u&&y(r),title:u?void 0:`Workspace "${r.workspaceName}" is not active`,children:[c?(0,Q.jsx)(`div`,{className:G(`absolute inset-y-0 right-0 w-4 rounded-r-(--card-radius)`,!d&&`bg-muted`),style:d?{backgroundColor:d}:void 0}):(0,Q.jsx)(`button`,{type:`button`,...g(o),title:`Drag to reorder`,"aria-label":`Drag to reorder`,className:G(`absolute inset-y-0 right-0 flex w-4 cursor-grab items-center justify-center rounded-r-(--card-radius) active:cursor-grabbing`,!d&&`bg-muted`),style:d?{backgroundColor:d}:void 0,children:(0,Q.jsx)(Te,{className:G(`h-3.5 w-3.5`,Si(d))})}),(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(i,{icon:r.icon||`ph:stack-fill`,width:16,height:16,color:d,className:G(`mt-0.5 shrink-0`,!d&&`text-muted-foreground`)}),(0,Q.jsx)(`span`,{className:`text-sm font-medium truncate flex-1`,children:r.name||r.id}),c&&(0,Q.jsx)(`span`,{className:`rounded-full bg-info/10 px-1.5 py-0.5 text-[9px] text-info shrink-0`,children:`Shared`}),u&&(0,Q.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),t(r.id),n(`detail`,r.id)},className:`reveal-on-hover shrink-0 mt-0.5`,title:`Switch context URL`,children:(0,Q.jsx)(Be,{className:`w-3.5 h-3.5 text-muted-foreground hover:text-foreground`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),t(r.id),a?n(`settings`,r.id):l(`/contexts/${r.id}/settings/general`)},className:`reveal-on-hover shrink-0 mt-0.5`,title:`Settings`,children:(0,Q.jsx)(ut,{className:`w-3.5 h-3.5 text-muted-foreground hover:text-foreground`})})]}),r.name&&(0,Q.jsx)(`div`,{className:`text-[10px] text-muted-foreground/60 truncate font-mono`,children:r.id}),(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground truncate mt-0.5`,children:r.url||`/`}),r.ownerEmail&&(0,Q.jsx)(`div`,{className:`text-[10px] text-muted-foreground truncate mt-0.5`,children:r.ownerEmail})]},`${r.userId||`u`}-${r.id}`)})})})]})}function Xs({title:e,onBack:t,action:n,className:r,icon:a,accentColor:o}){let{closeM1:s}=ca(),c=xi(o);return(0,Q.jsxs)(`div`,{className:G(`flex items-center h-12 px-2 border-b border-border shrink-0 gap-1`,r),style:{borderBottomWidth:4,...c?{borderBottomColor:c}:{}},children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center gap-0.5 h-8 rounded px-1 hover:bg-accent/50 text-muted-foreground hover:text-foreground transition-colors flex-1 min-w-0`,title:`Back`,"aria-label":`Back to previous view`,children:[(0,Q.jsx)(Ee,{className:`w-4 h-4 shrink-0`}),a&&(0,Q.jsx)(i,{icon:a,width:16,height:16,color:c,className:G(`mr-1 shrink-0`,!c&&`text-muted-foreground`)}),(0,Q.jsx)(`span`,{className:`text-sm font-semibold truncate`,children:e})]}),n&&(0,Q.jsx)(`div`,{className:`shrink-0`,children:n}),(0,Q.jsx)(`button`,{type:`button`,onClick:s,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground`,title:`Close menu`,"aria-label":`Close menu`,children:(0,Q.jsx)(z,{className:`w-4 h-4`})})]})}function Zs(e,t,n){let r=e.indexOf(n);if(r<0)return new Set;let i=t===null?-1:e.indexOf(t);return new Set(i<0?[n]:e.slice(Math.min(i,r),Math.max(i,r)+1))}function Qs(e){let t=[...e];return t.filter(e=>!t.some(t=>t!==e&&e.startsWith(`${t}/`)))}var $s=e(s(),1),ec=180;function tc({x:e,y:t,current:n,onChange:r,onClose:a}){mi(a);let[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)([]),[u,d]=(0,Z.useState)({q:``,list:[]}),[f,p]=(0,Z.useState)(!0),m=(0,Z.useRef)(null),h=(0,Z.useRef)({name:``,t:0}),g=(e,t)=>{r({icon:e}),h.current.name===e&&t-h.current.t<350&&a(),h.current={name:e,t}};(0,Z.useEffect)(()=>{m.current?.focus()},[]),(0,Z.useEffect)(()=>{let e=!0;return _i().then(t=>{e&&(l(t),p(!1))}),()=>{e=!1}},[]),(0,Z.useEffect)(()=>{let e=o.trim();if(!e)return;let t=setTimeout(()=>{vi(e).then(t=>{d({q:e,list:t})})},250);return()=>clearTimeout(t)},[o]);let _=o.trim(),v=u.q===_,y=_!==``&&!v,b=(0,Z.useMemo)(()=>(_?v?u.list:[]:c).slice(0,ec),[_,v,u.list,c]),x=(0,Z.useRef)(null),[S,C]=(0,Z.useState)({x:e,y:t});return(0,Z.useLayoutEffect)(()=>{let n=x.current;if(!n)return;let r=()=>{let{width:r,height:i}=n.getBoundingClientRect();C({x:Math.max(8,Math.min(e,window.innerWidth-r-8)),y:Math.max(8,Math.min(t,window.innerHeight-i-8))})};r();let i=new ResizeObserver(r);return i.observe(n),window.addEventListener(`resize`,r),()=>{i.disconnect(),window.removeEventListener(`resize`,r)}},[e,t]),(0,$s.createPortal)((0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:a}),(0,Q.jsxs)(`div`,{ref:x,className:`fixed z-50 w-[270px] max-w-[90vw] rounded-md border bg-popover p-2 shadow-elevation-4`,style:{left:S.x,top:S.y},children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-1 pb-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:`Icon & color`}),(0,Q.jsx)(`button`,{type:`button`,onClick:a,className:`text-muted-foreground hover:text-foreground`,children:(0,Q.jsx)(z,{className:`w-3.5 h-3.5`})})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 px-1 pb-2`,children:[gi.map(e=>(0,Q.jsx)(`button`,{type:`button`,title:e,onClick:()=>r({color:e}),className:G(`w-5 h-5 rounded-full border transition-transform hover:scale-110`,n.color===e?`ring-2 ring-offset-1 ring-foreground`:`border-border`),style:{backgroundColor:e}},e)),(0,Q.jsx)(`button`,{type:`button`,title:`No color`,onClick:()=>r({color:void 0}),className:G(`w-5 h-5 rounded-full border flex items-center justify-center text-muted-foreground hover:scale-110 transition-transform`,!n.color&&`ring-2 ring-offset-1 ring-foreground`),children:(0,Q.jsx)(z,{className:`w-3 h-3`})}),(0,Q.jsx)(`label`,{title:`Custom color`,className:G(`relative w-5 h-5 rounded-full border border-border cursor-pointer hover:scale-110 transition-transform overflow-hidden`,n.color&&!gi.includes(n.color)&&`ring-2 ring-offset-1 ring-foreground`),style:{background:n.color&&!gi.includes(n.color)?n.color:`conic-gradient(from 0deg, #ef4444, #eab308, #22c55e, #06b6d4, #6366f1, #ec4899, #ef4444)`},children:(0,Q.jsx)(`input`,{type:`color`,value:n.color??`#3b82f6`,onChange:e=>r({color:e.target.value}),className:`absolute inset-0 opacity-0 cursor-pointer`})})]}),(0,Q.jsx)(`input`,{ref:m,value:o,onChange:e=>s(e.target.value),placeholder:`Search icons…`,className:`w-full mb-2 rounded-sm border bg-background px-2 py-1 text-xs outline-none focus:ring-1 focus:ring-primary`}),f||y?(0,Q.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-8 text-xs text-muted-foreground`,children:[(0,Q.jsx)(nt,{className:`w-4 h-4 animate-spin`}),` `,y?`Searching…`:`Loading icons…`]}):(0,Q.jsxs)(`div`,{className:`grid grid-cols-7 gap-0.5 max-h-[200px] overflow-y-auto`,children:[(0,Q.jsx)(`button`,{type:`button`,title:`No icon`,onClick:()=>r({icon:void 0}),className:G(`aspect-square flex items-center justify-center rounded-sm hover:bg-accent text-muted-foreground`,!n.icon&&`bg-accent ring-1 ring-primary`),children:(0,Q.jsx)(z,{className:`w-4 h-4`})}),b.map(e=>(0,Q.jsx)(`button`,{type:`button`,title:e.replace(/^[^:]+:/,``).replace(`-fill`,``),onClick:t=>g(e,t.timeStamp),className:G(`aspect-square flex items-center justify-center rounded-sm hover:bg-accent`,n.icon===e&&`bg-accent ring-1 ring-primary`),children:(0,Q.jsx)(i,{icon:e,width:18,height:18,color:n.color})},e))]}),!f&&!y&&b.length===0&&(0,Q.jsxs)(`div`,{className:`px-1 py-3 text-center text-[11px] text-muted-foreground`,children:[`No icons match “`,o,`”`]})]})]}),document.body)}var nc=[{id:`cards`,name:`Cards`,description:`Nested cards with connector lines. Each level indents.`},{id:`accordion-mobile`,name:`Accordion on phones (beta)`,description:`Experimental. Full-width accordion rows on a phone, cards on wider screens.`},{id:`accordion`,name:`Accordion (beta)`,description:`Experimental. Full-width rows at every depth; a depth rail, tint and colour swatch replace the indent, and open parents stick to the top while you scroll.`}],rc=`canvas:treeStyle`;function ic(){try{let e=localStorage.getItem(rc);return e===`accordion`||e===`accordion-mobile`?e:`cards`}catch{return`cards`}}var ac=ic(),oc=new Set;function sc(){return ac}function cc(e){try{e===`cards`?localStorage.removeItem(rc):localStorage.setItem(rc,e)}catch{}ac=e;for(let e of oc)e()}function lc(e){oc.add(e);let t=t=>{(t.key===rc||t.key===null)&&(ac=ic(),e())};return window.addEventListener(`storage`,t),()=>{oc.delete(e),window.removeEventListener(`storage`,t)}}function uc(){return(0,Z.useSyncExternalStore)(lc,sc,()=>`cards`)}function dc(){let e=uc(),t=Pr();return e===`accordion`||e===`accordion-mobile`&&t}var fc=22,pc=44,mc=4;function hc(e,t){if(!t)return null;let n=String(e||``).split(`/`).filter(Boolean);return n[0]===`workspace`&&n[1]===`git`?null:n[0]===`workspace`&&n.length>=2?{address:`workspace:${n[1]}`,key:n.slice(2).join(`/`)}:n[0]===`device`&&n.length>=3?{address:n[2],key:n.slice(3).join(`/`)}:n[0]===`file`&&n.length>=2?{address:n[1],key:n.slice(2).join(`/`)}:null}function gc(e,t){return!t||fr(e)!==null}var _c=e=>Array.from(e.dataTransfer.types).includes(`application/json`);function vc(e,t){if(!t)return null;let n=String(e||``).split(`/`).filter(Boolean);return n[0]===`workspace`&&n[1]===`git`?n[2]||null:n[0]===`workspace`&&n.length>=2?`workspace:${n[1]}`:n[0]===`device`?n.length>=3?n[2]:null:n.length>=2?n[1]:null}function yc({x:e,y:t,node:n,path:r,isBackendsTree:i,isDirectoryTree:a,backends:o,onClose:s,onShowContent:c,onOpenToSide:l,sourceLayer:u,targetLayers:d,clipboard:f,onStartInlineCreate:p,onChangeIcon:m,onNewCanvas:h,onShareCanvas:g,onRemove:_,onRename:v,onExportSubtree:y,onImportSubtree:b,onImportDocuments:x,onExportDocuments:S,onLock:C,onUnlock:w,onDestroy:T,onMerge:E,onSubtract:D,onMergeDown:O,onSubtractDown:k,onResyncBackend:j,canResyncBackend:M,onAddRule:N,onAddStoreRule:P,onStoragePolicy:F,onRenameBackendFolder:ee,onDeleteBackendFolder:te,onRestoreTrash:ne,onDiscardTrash:re,onCopy:ie,onCut:ae,onPaste:I,pastedDocumentIds:R,onPasteDocuments:ce,isPinned:z,onTogglePin:le}){let V=u&&d.size>0&&u.path===r,de=!i&&(O||k)&&r!==`/`&&n.type!==`canvas`&&r.split(`/`).filter(Boolean).length>1,pe=u&&d.size>0&&(u.path===r||d.has(r)),me=async e=>{s();try{await e()}catch(e){alert(e instanceof Error?e.message:String(e))}},H=(e,t,n,r=!1)=>(0,Q.jsxs)(`button`,{type:`button`,className:G(`flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-accent rounded-sm text-left`,r&&`text-destructive hover:bg-destructive/10`),onClick:()=>me(n),children:[e,t]});return i&&n.metadata?.backendTrash?(0,Q.jsxs)(wn,{x:e,y:t,onClose:s,className:`min-w-44 rounded-md border bg-popover p-1 shadow-elevation-3`,children:[c&&H((0,Q.jsx)(je,{className:`h-3 w-3`}),`Open Trash`,async()=>c(r)),r!==`/Trash`&&ne&&H((0,Q.jsx)(xe,{className:`h-3 w-3`}),`Restore original paths`,()=>ne(r)),r!==`/Trash`&&re&&H((0,Q.jsx)(je,{className:`h-3 w-3`}),`Empty Trash`,()=>re(r),!0)]}):(0,Q.jsxs)(wn,{x:e,y:t,onClose:s,className:`min-w-[11rem] rounded-md border bg-popover p-1 shadow-elevation-3`,children:[c&&H((0,Q.jsx)($e,{className:`w-3 h-3`}),`Show layer content`,async()=>{c(r,n.id||void 0)}),l&&H((0,Q.jsx)($e,{className:`w-3 h-3`}),`Open to the side`,async()=>{l(r)}),(c||l)&&(0,Q.jsx)(`div`,{className:`my-1 h-px bg-border`}),n.type===`canvas`&&g&&H((0,Q.jsx)(bt,{className:`w-3 h-3`}),`Share canvas`,async()=>{await g(r)}),n.type===`canvas`&&g&&(0,Q.jsx)(`div`,{className:`my-1 h-px bg-border`}),j&&(M?.(r)??!!vc(r,i))&&(0,Q.jsxs)(Q.Fragment,{children:[H((0,Q.jsx)(fe,{className:`w-3 h-3`}),`Refresh backend`,async()=>{await j(r)}),(0,Q.jsx)(`div`,{className:`my-1 h-px bg-border`})]}),i&&vc(r,i)&&(N||P)&&(0,Q.jsxs)(Q.Fragment,{children:[N&&H((0,Q.jsx)(oe,{className:`w-3 h-3`}),`Auto-Link documents to…`,async()=>{N(r)}),P&&hc(r,i)&&H((0,Q.jsx)(Jt,{className:`w-3 h-3`}),`Create storage rule…`,async()=>{P(r)}),(0,Q.jsx)(`div`,{className:`my-1 h-px bg-border`})]}),!i&&(P||F)&&r!==`/`&&(0,Q.jsxs)(Q.Fragment,{children:[P&&H((0,Q.jsx)(Jt,{className:`w-3 h-3`}),`Create rule…`,async()=>{P(r)}),P&&H((0,Q.jsx)(Ve,{className:`w-3 h-3`}),`Create download rule…`,async()=>{P(r,`download`)}),F&&n.type!==`canvas`&&H((0,Q.jsx)(wt,{className:`w-3 h-3`}),`Storage policy…`,async()=>{F(r)}),(0,Q.jsx)(`div`,{className:`my-1 h-px bg-border`})]}),(!i||hc(r,i))&&(0,Q.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-accent rounded-sm text-left`,onClick:()=>{p(r),s()},children:[(0,Q.jsx)(ue,{className:`w-3 h-3`}),`New folder here`]}),ee&&hc(r,i)?.key&&H((0,Q.jsx)(A,{className:`w-3 h-3`}),`Rename folder`,async()=>{let e=r.split(`/`).pop()||``,t=prompt(`New folder name:`,e);!t||t===e||await ee(r,t)}),te&&i&&cr(r,o)&&H((0,Q.jsx)(je,{className:`w-3 h-3`}),`Delete from backend`,async()=>{confirm(`Delete folder "${r.split(`/`).pop()}" and its contents from the backend?`)&&await te(r)},!0),h&&!i&&(0,Q.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-accent rounded-sm text-left`,onClick:()=>{h(r),s()},children:[(0,Q.jsx)(Wt,{className:`w-3 h-3 text-primary`}),`New canvas here…`]}),r!==`/`&&le&&H(z?(0,Q.jsx)(B,{className:`w-3 h-3`}):(0,Q.jsx)(L,{className:`w-3 h-3`}),z?`Unpin`:`Pin`,async()=>{await le()}),r!==`/`&&m&&(0,Q.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-accent rounded-sm text-left`,onClick:()=>{m(),s()},children:[(0,Q.jsx)(Ae,{className:`w-3 h-3`}),`Change icon`]}),r!==`/`&&!n.locked&&v&&!i&&H((0,Q.jsx)(A,{className:`w-3 h-3`}),`Rename`,async()=>{let e=r.split(`/`).pop()||``,t=prompt(`New name:`,e);!t||t===e||await v(r,t)}),(0,Q.jsx)(`div`,{className:`my-1 h-px bg-border`}),H((0,Q.jsx)(Rt,{className:`w-3 h-3`}),`Copy`,async()=>ie(r)),!i&&H((0,Q.jsx)(Ht,{className:`w-3 h-3`}),`Cut`,async()=>ae(r)),f&&!i&&H((0,Q.jsx)(pt,{className:`w-3 h-3`}),`Paste (${f.mode})`,async()=>I(r)),R&&R.length>0&&ce&&gc(r,i)&&H((0,Q.jsx)(pt,{className:`w-3 h-3`}),i?`Move ${R.length} message(s) here`:`Paste ${R.length} document(s)`,async()=>{await ce(r,R)}),x&&H((0,Q.jsx)(se,{className:`w-3 h-3`}),`Import documents…`,()=>x(r)),S&&H((0,Q.jsx)(Ve,{className:`w-3 h-3`}),`Export documents…`,()=>S(r)),(y||b)&&(0,Q.jsx)(`div`,{className:`my-1 h-px bg-border`}),y&&n.type!==`canvas`&&H((0,Q.jsx)(Ve,{className:`w-3 h-3`}),`Export subtree…`,()=>y(r)),b&&!i&&n.type!==`canvas`&&H((0,Q.jsx)(se,{className:`w-3 h-3`}),`Import subtree here…`,()=>b(r)),!i&&r!==`/`&&!n.locked&&_&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`my-1 h-px bg-border`}),H((0,Q.jsx)(je,{className:`w-3 h-3`}),`Remove`,async()=>{confirm(`Remove "${r}"${a?` and all children`:``}?`)&&await _(r,a)},!0),!a&&H((0,Q.jsx)(je,{className:`w-3 h-3`}),`Remove recursive`,async()=>{confirm(`Remove "${r}" and all children?`)&&await _(r,!0)},!0)]}),!i&&(C||w||T)&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`my-1 h-px bg-border`}),n.locked?w&&H((0,Q.jsx)(Nt,{className:`w-3 h-3`}),`Unlock layer`,async()=>{await w(n.id)}):C&&H((0,Q.jsx)(mt,{className:`w-3 h-3`}),`Lock layer`,async()=>{await C(n.id)}),n.locked&&n.lockedBy&&n.lockedBy.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`px-3 pt-1 pb-0.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:`Locked by`}),n.lockedBy.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-1 text-xs`,children:[(0,Q.jsx)(`span`,{className:`truncate`,title:e,children:e}),w&&(0,Q.jsx)(`button`,{type:`button`,title:`Remove lock held by ${e}`,className:`shrink-0 text-muted-foreground hover:text-destructive`,onClick:()=>me(async()=>{await w(n.id,e)}),children:(0,Q.jsx)(Nt,{className:`w-3 h-3`})})]},e))]}),r!==`/`&&!n.locked&&T&&H((0,Q.jsx)(je,{className:`w-3 h-3`}),`Destroy layer`,async()=>{confirm(`Permanently destroy layer "${n.label||n.name}" and its bitmap?`)&&await T(n.id)},!0)]}),de&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`my-1 h-px bg-border`}),O&&H((0,Q.jsx)(_t,{className:`w-3 h-3`}),`Merge down (into ancestors)`,async()=>{confirm(`Merge "${n.label||n.name}" into every layer above it on\n${r}\n\nAfter this, ${r} lists its documents.`)&&await O(r)}),k&&H((0,Q.jsx)(qe,{className:`w-3 h-3`}),`Subtract from ancestors`,async()=>{confirm(`Remove "${n.label||n.name}"'s documents from every layer above it on\n${r}\n\nUndo of "Merge down". Documents an ancestor holds for other reasons are removed from it too.`)&&await k(r)})]}),V&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`my-1 h-px bg-border`}),E&&H((0,Q.jsx)(Bt,{className:`w-3 h-3`}),`Merge this layer into ${d.size} selected`,async()=>{confirm(`Merge "${r}" (source) INTO:\n${Array.from(d.keys()).join(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/apps-CvInUZwB.js","assets/rolldown-runtime-C0FnF6B9.js","assets/code-editor-BOIngd5F.js","assets/chunk-62JRHF6Z-vspAGgtK.js","assets/preload-helper-Czpn1I53.js","assets/utils-2pl1SbIp.js","assets/utils-BxVxyehK.js","assets/workspace-CrSpR4xf.js","assets/react-BHzhHVTZ.js","assets/button-SgR3GVvV.js","assets/ui-Byg1cZDr.js","assets/input-BOtCd4HP.js","assets/api-CA6WiiYM.js","assets/alert-dialog-izlVMXfa.js","assets/context-DQoZFMDQ.js","assets/registry--2kt6I6T.js","assets/applet-target-C_gBgU-Z.js","assets/use-applet-target-gXPvZGgx.js","assets/use-toolbox-Ck_cLGgf.js","assets/workspaces-By3jZzrz.js","assets/use-toast-BlLDqSUO.js","assets/use-mobile-Db-vWu9Y.js","assets/layer-style-Byl5LNFR.js","assets/color-DFEH4BfK.js","assets/workspace-access-C9nZlBBZ.js","assets/use-menu-BiJ8N7sS.js","assets/last-path-BbXWC3b3.js","assets/url-params-n7kU_WZ-.js","assets/page-header-DkOHw0g-.js","assets/form-panel-C34lByEH.js","assets/use-create-panel-DhSNIGtr.js","assets/useSocketSubscription-ifW-vnlb.js","assets/socket-hM4c-ZSl.js","assets/workspace-import-form-aR-DwHf6.js","assets/_workspaceName_-DqFTMP44.js","assets/socket-CtH3EU9m.js","assets/use-canvas-pins-BvN6Gw6f.js","assets/auth-Bx9fAZmz.js","assets/LinkToCard-5dg0jvSY.js","assets/useEscapeClose-DR_xKT_k.js","assets/useToastHelpers-CRrpIIdY.js","assets/DocumentIcon-x299QNu_.js","assets/TodosWidget-CxiqmDuJ.js","assets/ObjectPropertiesCard-BIBMvx_i.js","assets/label-Dn4gCMcc.js","assets/IdentityFields-Bti7ojF3.js","assets/tags-YamdPoBK.js","assets/useAddTarget-CqnDU0Om.js","assets/date-time-picker-DebNUTx3.js","assets/relation-events-CKio19hE.js","assets/map-BxCwdK0d.js","assets/map-BcsP_QXj.css","assets/public-share-g_wBd6BW.js","assets/text-documents-0P9jkIpu.js","assets/blobs-WiXP9QRi.js","assets/useDocumentThumbnail-DunxmU1A.js","assets/markdown-view-BBBZtNSR.js","assets/sanitize-DrVcFY1Q.js","assets/MessageComposerDialog-gbD0Gu_b.js","assets/markdown-it-DRESbtwK.js","assets/punycode.es6-ZbLrB_Dn.js","assets/lazy-editor-BSRnneOo.js","assets/LinkToSidePanel-eCy3nW4R.js","assets/note-save-status-DPz4VzL6.js","assets/useEditNoteFields-BehI0vog.js","assets/DocumentBodyEditor-8DNmOBS0.js","assets/use-document-modal-PG8bQyIB.js","assets/sketch-lazy-C4pjV1WK.js","assets/geo-CZfs0E-x.js","assets/ObjectPropertiesCard-JArcZXXv.css","assets/document-list-DKOU9Kcc.js","assets/document-open-mode-DoImW-xs.js","assets/PickDocumentsCard-DamtV7fN.js","assets/backend-sync-progress-pZrhQPk3.js","assets/PathPickerField-fZazwxCN.js","assets/backend-sync-progress-DU-e9TWi.css","assets/search-COMZIxA7.js","assets/use-sortable-data-BW_0sXBs.js","assets/workspace-BydSRtST.js","assets/document-list-DAYdk5vh.css","assets/use-canvas-pins-C57Vbkrq.css","assets/workspace-area-menu-C0-X-FpD.js","assets/workspace-content-gate-9okuA7J7.js","assets/content-app-view-BGg1GOMt.js","assets/FileForm-CqJpRbXv.js","assets/UploadProgressList-DRJzjy6A.js","assets/sha256-65KIjGvZ.js","assets/query-debug-CrPsUwT-.js","assets/document-DOp6AbOi.js","assets/use-workspace-identity-BCrrvfeE.js","assets/home-CFZRa_Mu.js","assets/HomeFab-Chvwu8rQ.js","assets/desk-dI_FvLsK.js","assets/share-target-fpk-pz15.js","assets/contexts-CvMtPd1N2.js","assets/_contextId_-DRvqFeiU.js","assets/api-tokens-DDH7LMJ7.js","assets/use-settings-back-CQauYjQ4.js","assets/devices-C3gLuNDv.js","assets/devices-CAa1bRxk.js","assets/settings-DhVz_Osu.js","assets/appearance-CN8I4_GQ.js","assets/use-theme-DaxpiICf.js","assets/key-bindings-Dfa7ehDw.js","assets/offline-COOUcZsG.js","assets/about-DbGpwqCH.js","assets/embedding-B5JiUA9X.js","assets/inferd-config-editor--MDmN_7w.js","assets/shared-CCCuTYCU.js","assets/workspaces-Da_hUIj3.js","assets/admin-Bhg9QBHL.js","assets/contexts-Ef3fHwv6.js","assets/agents-DlLq0q2s.js","assets/logs-Czn2sPeP.js","assets/roles-BpVWTMmp.js","assets/role-C5I0Plgn.js","assets/users-CKz9kOoR.js","assets/embedding-B7cWrpy0.js","assets/auth-HZNJB4wv.js","assets/agents-BBKnR8_O.js","assets/useAgentModels-CwNiA-Ak.js","assets/_agentId_-sMYqsnQk.js","assets/settings-N3fbO22m.js","assets/settings-BOHindnt.js","assets/settings-FiiJ5QFa.js","assets/roles-Bo9GZdOk.js","assets/remotes-CdEU1Y5l.js","assets/add-DsH8MVg6.js","assets/NextShell-UX4Efo0u.js","assets/NextShell-BT6-_CFY.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as e,r as t}from"./rolldown-runtime-C0FnF6B9.js";import{l as n,u as r}from"./code-editor-BOIngd5F.js";import{_t as i,st as a,vt as o,yt as s}from"./react-BHzhHVTZ.js";import{t as c}from"./preload-helper-Czpn1I53.js";import{_ as l,a as u,c as d,d as f,f as p,g as m,h,i as g,l as _,m as v,n as y,o as b,p as x,r as S,s as C,t as w,u as T,v as E}from"./chunk-62JRHF6Z-vspAGgtK.js";import{$n as D,B as O,Br as k,Bt as A,C as j,Ct as M,Dn as N,F as P,Fn as F,Ft as ee,H as te,Hn as ne,Hr as re,Ht as ie,I as ae,Ir as I,It as L,J as R,Jn as oe,Kn as se,Kr as ce,L as z,Lt as B,Mn as le,Mr as V,Nt as ue,Or as de,Ot as fe,P as pe,Pr as me,Pt as H,Q as he,Qr as ge,Qt as _e,R as ve,Rr as U,S as ye,Tn as be,Tt as xe,U as W,Un as Se,Ur as Ce,V as we,Vn as Te,Vr as Ee,Vt as De,W as Oe,Wr as ke,Wt as Ae,X as je,Xn as Me,Xr as Ne,Yr as Pe,Yt as Fe,Zn as Ie,Zt as Le,_ as Re,_i as ze,_n as Be,_r as Ve,_t as He,ar as Ue,b as We,bn as Ge,br as Ke,ci as qe,cn as Je,ct as Ye,d as Xe,di as Ze,dn as Qe,dr as $e,er as et,f as tt,fn as nt,g as rt,gi as it,gn as at,gt as ot,h as st,hi as ct,hr as lt,ht as ut,in as dt,jn as ft,kr as pt,ln as mt,lt as ht,m as gt,mi as _t,mn as vt,mr as yt,mt as bt,on as xt,p as St,pr as Ct,qn as wt,ri as Tt,rn as Et,rt as Dt,sn as Ot,sr as kt,tn as At,tt as jt,u as Mt,un as Nt,ut as Pt,v as Ft,vt as It,w as Lt,wr as Rt,x as zt,xn as Bt,xr as Vt,xt as Ht,y as Ut,yn as Wt,yr as Gt,yt as Kt,z as qt,zn as Jt,zr as Yt,zt as Xt}from"./ui-Byg1cZDr.js";import{i as Zt,r as Qt}from"./utils-BxVxyehK.js";import{n as $t,t as G}from"./utils-2pl1SbIp.js";import{t as K}from"./button-SgR3GVvV.js";import{t as en}from"./input-BOtCd4HP.js";import{t as q}from"./label-Dn4gCMcc.js";import{a as tn,c as nn,i as rn,l as J,n as an,o as on,r as sn,s as cn,t as Y,u as ln}from"./api-CA6WiiYM.js";import{t as un}from"./socket-hM4c-ZSl.js";import{t as X}from"./socket-CtH3EU9m.js";import{a as dn,c as fn,d as pn,i as mn,l as hn,n as gn,o as _n,r as vn,s as yn,t as bn}from"./auth-Bx9fAZmz.js";import{n as xn,t as Sn}from"./use-toast-BlLDqSUO.js";import{_ as Cn,h as wn,m as Tn,p as En,t as Dn}from"./LinkToCard-5dg0jvSY.js";import{$ as On,An as kn,Bt as An,C as jn,Cn as Mn,Ct as Nn,D as Pn,Dn as Fn,Et as In,Ft as Ln,H as Rn,K as zn,Mt as Bn,On as Vn,Ot as Hn,Pn as Un,Pt as Wn,Qt as Gn,Rt as Kn,Sn as qn,V as Jn,Vt as Yn,Zt as Xn,_n as Zn,_t as Qn,bn as $n,bt as er,cn as tr,g as nr,gn as rr,gt as ir,ht as ar,i as or,k as sr,l as cr,nt as lr,sn as ur,t as dr,ut as fr,v as pr,w as mr,x as hr,yn as gr}from"./workspace-CrSpR4xf.js";import{r as _r,t as vr}from"./use-canvas-pins-BvN6Gw6f.js";import{a as yr,i as br,n as xr,o as Sr,r as Cr}from"./ObjectPropertiesCard-BIBMvx_i.js";import{c as wr,d as Tr,f as Er,i as Dr,m as Or,n as kr,p as Ar,s as jr,u as Mr}from"./document-list-DKOU9Kcc.js";import{n as Nr,t as Pr}from"./use-mobile-Db-vWu9Y.js";import{a as Fr,i as Ir,s as Lr,t as Rr}from"./IdentityFields-Bti7ojF3.js";import{n as zr,t as Br}from"./public-share-g_wBd6BW.js";import{t as Vr}from"./markdown-view-BBBZtNSR.js";import{n as Hr,t as Ur}from"./tags-YamdPoBK.js";import{a as Wr,c as Gr,i as Kr,l as qr,n as Jr,o as Yr,r as Xr,s as Zr,t as Qr,u as $r}from"./useAddTarget-CqnDU0Om.js";import{n as ei,r as ti,t as ni}from"./use-toolbox-Ck_cLGgf.js";import{D as ri,E as ii,O as ai,a as oi,p as si,s as ci,v as li,w as ui}from"./context-DQoZFMDQ.js";import{r as di}from"./relation-events-CKio19hE.js";import{c as fi}from"./date-time-picker-DebNUTx3.js";import{t as pi}from"./PickDocumentsCard-DamtV7fN.js";import{t as mi}from"./useEscapeClose-DR_xKT_k.js";import{t as hi}from"./useToastHelpers-CRrpIIdY.js";import{a as gi,c as _i,d as vi,l as yi,s as bi}from"./layer-style-Byl5LNFR.js";import{i as xi,r as Si}from"./color-DFEH4BfK.js";import{n as Ci}from"./MessageComposerDialog-gbD0Gu_b.js";import{n as wi,t as Ti}from"./LinkToSidePanel-eCy3nW4R.js";import{n as Ei,r as Di,t as Oi}from"./note-save-status-DPz4VzL6.js";import{t as ki}from"./useEditNoteFields-BehI0vog.js";import{t as Ai}from"./DocumentBodyEditor-8DNmOBS0.js";import{n as ji,t as Mi}from"./map-BxCwdK0d.js";import{o as Ni}from"./blobs-WiXP9QRi.js";import{n as Pi,t as Fi}from"./use-document-modal-PG8bQyIB.js";import{n as Ii,r as Li}from"./geo-CZfs0E-x.js";import{C as Ri,W as zi,_ as Bi,c as Vi,g as Hi,i as Ui,s as Wi,y as Gi,z as Ki}from"./backend-sync-progress-pZrhQPk3.js";import{t as qi}from"./workspace-access-C9nZlBBZ.js";import{t as Ji}from"./PathPickerField-fZazwxCN.js";import{a as Yi,c as Xi,i as Zi,o as Qi,r as $i,s as ea,t as ta}from"./workspace-BydSRtST.js";import{n as na,t as ra}from"./url-params-n7kU_WZ-.js";import{a as ia,c as aa,d as oa,f as sa,i as ca,m as la,n as ua,p as da,r as fa,t as pa}from"./use-menu-BiJ8N7sS.js";import{n as ma,t as ha}from"./registry--2kt6I6T.js";import{n as ga}from"./use-applet-target-gXPvZGgx.js";import{r as _a,t as va}from"./last-path-BbXWC3b3.js";import{t as ya}from"./workspace-area-menu-C0-X-FpD.js";import{t as ba}from"./workspace-content-gate-9okuA7J7.js";import{c as xa,s as Sa}from"./UploadProgressList-DRJzjy6A.js";import{n as Ca,r as wa,t as Ta}from"./FileForm-CqJpRbXv.js";import{n as Ea}from"./use-theme-DaxpiICf.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Z=e(r(),1),Da=o(),Q=n(),Oa=Z.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(`div`,{ref:n,className:G(`rounded-(--card-radius) border bg-card text-card-foreground shadow-elevation-1`,e),...t}));Oa.displayName=`Card`;var ka=Z.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(`div`,{ref:n,className:G(`flex flex-col space-y-1.5 p-6`,e),...t}));ka.displayName=`CardHeader`;var Aa=Z.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(`h3`,{ref:n,className:G(`text-2xl font-semibold leading-none tracking-tight`,e),...t}));Aa.displayName=`CardTitle`;var ja=Z.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(`p`,{ref:n,className:G(`text-sm text-muted-foreground`,e),...t}));ja.displayName=`CardDescription`;var Ma=Z.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(`div`,{ref:n,className:G(`p-6 pt-0`,e),...t}));Ma.displayName=`CardContent`;var Na=Z.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(`div`,{ref:n,className:G(`flex items-center p-6 pt-0`,e),...t}));Na.displayName=`CardFooter`;var Pa=`2.26.26`,Fa=e=>{window.particlesJS.load(e,`/js/particles.config.json`,()=>{console.log(`particles.js config loaded for`,e)})};function Ia(e){(0,Z.useEffect)(()=>{if(window.particlesJS!==void 0)Fa(e);else{if(document.getElementById(`particles-js-script`))return;let t=document.createElement(`script`);t.id=`particles-js-script`,t.src=`/js/particles.min.js`,t.onload=()=>{console.log(`particles.js loaded`),Fa(e)},document.head.appendChild(t)}return()=>{window.pJS&&window.pJS[e]?.destroy&&window.pJS[e].destroy()}},[e])}function La(){let[e,t]=(0,Z.useState)(null),[n,r]=(0,Z.useState)(!0),[i,a]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{let e=!0;async function n(){try{r(!0),a(null);let n=await Y.get(`/ping`,{skipAuth:!0});e&&(n?.version?t(n.version):a(`Invalid server response`))}catch(t){e&&(console.error(`Failed to fetch server version:`,t),a(`Unable to connect to server`))}finally{e&&r(!1)}}n();let i=setInterval(n,3e4);return()=>{e=!1,clearInterval(i)}},[]),{serverVersion:e,isLoading:n,error:i}}var Ra=`https://github.com/canvas-ui/canvas-server`,za=null;function Ba(){return za||=Y.get(`/ping`,{skipAuth:!0}).then(e=>{let t=e??{};return{sourceUrl:t.sourceUrl||Ra,version:t.version??null,commit:t.commit??null,license:t.license??null}}).catch(e=>(console.error(`Failed to fetch server source info:`,e),za=null,{sourceUrl:Ra,version:null,commit:null,license:null})),za}function Va(){let[e,t]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{let e=!0;return Ba().then(n=>{e&&t(n)}),()=>{e=!1}},[]),e}function Ha({className:e=``}){let t=Va();if(!t)return null;let n=[t.version?`v${t.version}`:null,t.commit?.slice(0,7)].filter(Boolean).join(` `);return(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground ${e}`,children:[`Powered by`,` `,(0,Q.jsx)(`a`,{href:t.sourceUrl,target:`_blank`,rel:`noreferrer`,className:`underline underline-offset-2 hover:text-foreground`,children:`Canvas`}),n?` ${n}`:``,t.license?`, ${t.license}`:``,`.`,` `,(0,Q.jsx)(`a`,{href:t.sourceUrl,target:`_blank`,rel:`noreferrer`,className:`underline underline-offset-2 hover:text-foreground`,children:`Get the source code`}),`.`]})}function Ua({children:e}){Ia(`particle-js`);let{serverVersion:t,isLoading:n,error:r}=La();return(0,Q.jsx)(`div`,{className:`flex min-h-viewport w-full items-center justify-center p-4 flex-col`,children:(0,Q.jsxs)(Oa,{className:`flex w-[95vw] h-viewport-modal overflow-hidden`,children:[(0,Q.jsxs)(`div`,{className:`hidden md:block w-1/2 relative bg-background`,"data-scheme":`dark`,id:`particle-js`,children:[(0,Q.jsxs)(S,{className:`absolute top-8 left-8 font-bold text-foreground flex items-center z-raised`,to:`/`,children:[(0,Q.jsx)(`img`,{src:`/images/logo-wr_128x128.png`,alt:`Canvas Logo`,className:`mr-2 h-6 w-6 touch-target`}),(0,Q.jsx)(`span`,{className:`text-2xl font-bold text-foreground`,children:`Canvas`})]}),(0,Q.jsxs)(`div`,{className:`absolute bottom-8 left-8 text-sm text-foreground max-w-[80%] z-raised`,children:[`Web UI: v`,Pa,`, Server: `,n?`Loading...`:r?`Unavailable`:t?`v${t}`:`Unknown`]})]}),(0,Q.jsx)(`div`,{className:`flex w-full md:w-1/2 flex-col justify-center px-4 py-12 sm:px-6 lg:px-8`,children:(0,Q.jsxs)(`div`,{className:`mx-auto w-full max-w-sm`,children:[e,(0,Q.jsxs)(`div`,{className:`mt-8 border-t pt-6`,children:[(0,Q.jsxs)(`a`,{href:`https://github.com/canvas-ui`,target:`_blank`,className:`text-muted-foreground hover:text-foreground justify-center flex items-center space-x-2`,rel:`noopener noreferrer`,children:[(0,Q.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`24`,height:`24`,stroke:`currentColor`,fill:`none`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`w-6 h-6`,children:(0,Q.jsx)(`path`,{d:`M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22`})}),(0,Q.jsx)(`span`,{children:`View on GitHub`})]}),(0,Q.jsx)(Ha,{className:`mt-4 text-center`})]})]})})]})})}var Wa=e=>e?.strategies?.local?.enabled!==!1,Ga=e=>e?.allowUserRegistrations!==!1;function Ka(){let e=m(),[t,n]=Z.useState(!1),[r,a]=Z.useState(``),[o,s]=Z.useState(``),[c,l]=Z.useState(!1),[u,d]=Z.useState({}),[f,p]=Z.useState(null),[h,g]=Z.useState({email:``,password:``,strategy:`auto`});Z.useEffect(()=>{dn()&&e(`/workspaces`),fetch(`${J}/runtime/capabilities`).then(e=>e.ok?e.json():null).then(e=>n(e?.payload?.local===!0)).catch(()=>{}),gn().then(e=>{p(e)}).catch(e=>{console.error(`Failed to load auth config:`,e)})},[e]);let _=()=>{let e={};return h.email?/\S+@\S+\.\S+/.test(h.email)||(e.email=`Email is invalid`):e.email=`Email is required`,h.password||(e.password=`Password is required`),d(e),Object.keys(e).length===0},v=e=>{let{name:t,value:n}=e.target;g(e=>({...e,[t]:n}))};async function y(t){if(t.preventDefault(),_()){l(!0);try{console.log(`Attempting login with:`,h.email,`strategy:`,h.strategy);let t=await fn(h.email,h.password,h.strategy);console.log(`Login successful, received token:`,`token`in t?!!t.token:!!t.payload?.token),d({}),e(`/home`)}catch(e){console.error(`Login error:`,e);let t=`Login failed`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;n.message?t=n.message:n.error?t=n.error:n.payload?.message&&(t=n.payload.message)}d({password:t})}finally{l(!1)}}}return t?(0,Q.jsx)(Ua,{children:(0,Q.jsxs)(`form`,{className:`grid gap-4`,onSubmit:async t=>{t.preventDefault(),l(!0),s(``);try{if(Y.setAuthToken(r.trim()),!await vn())throw Error(`The local token was not accepted`);e(`/workspaces`)}catch(e){Y.clearAuthToken(),s(e instanceof Error?e.message:`Authentication failed`)}finally{l(!1)}},children:[(0,Q.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Connect to your local runtime`}),(0,Q.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Enter the token shown by `,(0,Q.jsx)(`code`,{children:`canvas runtime token`}),` in the runtime folder.`]}),(0,Q.jsx)(q,{htmlFor:`local-token`,children:`Local access token`}),(0,Q.jsx)(en,{id:`local-token`,type:`password`,autoComplete:`off`,value:r,onChange:e=>a(e.target.value),required:!0}),o&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:o}),(0,Q.jsx)(K,{disabled:c,children:c?`Connecting…`:`Connect`})]})}):(0,Q.jsx)(Ua,{children:(0,Q.jsxs)(`div`,{className:`flex flex-col space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col space-y-2 text-center`,children:[(0,Q.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Welcome back`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Enter your credentials to access your account`})]}),(0,Q.jsx)(`form`,{onSubmit:y,children:(0,Q.jsxs)(`div`,{className:`grid gap-4`,children:[f?.strategies?.imap?.enabled&&f.strategies.imap.domains.length>0&&(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(q,{htmlFor:`strategy`,children:`Authentication Method`}),(0,Q.jsxs)(`select`,{id:`strategy`,name:`strategy`,value:h.strategy,onChange:v,disabled:c,className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,Q.jsx)(`option`,{value:`auto`,children:`Auto-detect`}),(0,Q.jsx)(`option`,{value:`local`,children:`Local Account`}),(0,Q.jsx)(`option`,{value:`imap`,children:`Email Server (IMAP)`})]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(q,{htmlFor:`email`,children:`Email`}),(0,Q.jsx)(en,{id:`email`,name:`email`,placeholder:`name@example.com`,type:`email`,autoCapitalize:`none`,autoComplete:`email`,autoCorrect:`off`,disabled:c,value:h.email,onChange:v}),u.email&&(0,Q.jsx)(`p`,{className:`text-sm text-destructive`,children:u.email})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(q,{htmlFor:`password`,children:`Password`}),(0,Q.jsx)(en,{id:`password`,name:`password`,type:`password`,disabled:c,value:h.password,onChange:v}),u.password&&(0,Q.jsx)(`p`,{className:`text-sm text-destructive`,children:u.password})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col space-y-4`,children:[(0,Q.jsx)(K,{type:`submit`,disabled:c,children:c?`Signing in...`:`Sign In`}),f?.strategies?.google?.enabled&&(0,Q.jsxs)(K,{type:`button`,variant:`outline`,disabled:c,onClick:()=>pn(),children:[(0,Q.jsx)(i,{icon:`logos:google-icon`,width:16,height:16,className:`mr-2`}),`Sign in with Google`]}),Wa(f)&&Ga(f)&&(0,Q.jsx)(K,{variant:`outline`,type:`button`,disabled:c,onClick:()=>e(`/register`),children:`Don't have an account? Sign up`})]})]})})]})})}function qa(){let e=m(),{showToast:t}=xn(),[n,r]=Z.useState(!1),[i,a]=Z.useState({}),[o,s]=Z.useState({name:``,email:``,password:``}),[c,l]=Z.useState(!1),[u,d]=Z.useState(!1),[f,p]=Z.useState(null);Z.useEffect(()=>{(async()=>{let t=await gn(),n=t?.strategies?.local;if(t?.allowUserRegistrations===!1||n?.enabled===!1){e(`/login`,{replace:!0});return}n?.passwordPolicy&&p(n.passwordPolicy),d(!!n?.requireEmailVerification)})()},[e]);let h=Z.useMemo(()=>{if(!f)return null;let e=o.password||``;return{minLength:!f.minLength||e.length>=f.minLength,maxLength:!f.maxLength||e.length<=f.maxLength,uppercase:!f.requireUppercase||/[A-Z]/.test(e),lowercase:!f.requireLowercase||/[a-z]/.test(e),number:!f.requireNumbers||/[0-9]/.test(e),special:!f.requireSpecialChars||/[^A-Za-z0-9]/.test(e)}},[f,o.password]),g=()=>{let e={};if(!o.name)e.name=`Username is required`;else if(o.name.trim().length===0)e.name=`Username cannot be empty`;else{let t=o.name.toLowerCase().trim();t.length<3?e.name=`Username must be at least 3 characters long`:t.length>39?e.name=`Username cannot be longer than 39 characters`:/^[a-z0-9_-]+$/.test(t)?[`admin`,`administrator`,`root`,`system`,`support`,`help`,`api`,`www`,`mail`,`ftp`,`localhost`,`test`,`demo`,`canvas`,`universe`,`workspace`,`context`,`user`,`users`].includes(t)&&(e.name=`Username '${t}' is reserved and cannot be used`):e.name=`Username can only contain lowercase letters, numbers, underscores, and hyphens`}if(o.email?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.email)||(e.email=`Please enter a valid email address`):e.email=`Email is required`,!o.password)e.password=`Password is required`;else if(f){let t=o.password,n=[];f.minLength&&t.length<f.minLength&&n.push(`at least ${f.minLength} characters`),f.maxLength&&t.length>f.maxLength&&n.push(`no more than ${f.maxLength} characters`),f.requireUppercase&&!/[A-Z]/.test(t)&&n.push(`an uppercase letter`),f.requireLowercase&&!/[a-z]/.test(t)&&n.push(`a lowercase letter`),f.requireNumbers&&!/[0-9]/.test(t)&&n.push(`a number`),f.requireSpecialChars&&!/[^A-Za-z0-9]/.test(t)&&n.push(`a special character`),n.length&&(e.password=`Password must contain ${n.join(`, `).replace(/, ([^,]*)$/,` and $1`)}.`)}else o.password.length<8&&(e.password=`Password must be at least 8 characters long`);return a(e),Object.keys(e).length===0},_=e=>{let t={...o,[e.target.id]:e.target.value};s(t),(e.target.id===`name`||e.target.id===`email`||e.target.id===`password`)&&g()};return c?(0,Q.jsxs)(Ua,{children:[(0,Q.jsxs)(`div`,{className:`flex flex-col space-y-2 text-center`,children:[(0,Q.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Registration Successful!`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:u?`Check your email for a verification link to activate your account.`:`Your account has been created.`})]}),(0,Q.jsx)(`div`,{className:`space-y-6 text-center pt-6`,children:!u&&(0,Q.jsx)(K,{asChild:!0,className:`w-full`,children:(0,Q.jsx)(S,{to:`/login`,children:`Go to Login`})})})]}):(0,Q.jsxs)(Ua,{children:[(0,Q.jsxs)(`div`,{className:`flex flex-col space-y-2 text-center`,children:[(0,Q.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Create an account`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Enter your email below to create your account`})]}),(0,Q.jsxs)(`form`,{onSubmit:async e=>{if(e.preventDefault(),g()){r(!0);try{let e=await hn(o.name,o.email,o.password);console.log(`Registration successful:`,e),t({title:`Registration Successful`,description:u?`Check your email for a verification link before logging in.`:`You can now log in with your credentials.`,variant:`default`}),l(!0),s({name:``,email:``,password:``}),a({})}catch(e){console.error(`Registration failed:`,e);let n=e?.message||`Registration failed`;n.toLowerCase().includes(`password`)?a({...i,password:n}):a({...i,email:n}),t({title:`Registration Failed`,description:n,variant:`destructive`})}finally{r(!1)}}},className:`space-y-4 pt-6`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(q,{htmlFor:`name`,children:`Username`}),(0,Q.jsx)(en,{id:`name`,type:`text`,placeholder:`Enter your username (e.g., john_doe)`,value:o.name,onChange:_,disabled:n,className:i.name?`border-destructive`:``}),i.name&&(0,Q.jsx)(`p`,{className:`text-sm text-destructive`,children:i.name}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`3-39 characters, lowercase letters, numbers, underscores, and hyphens only`})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(q,{htmlFor:`email`,children:`Email`}),(0,Q.jsx)(en,{id:`email`,type:`email`,placeholder:`name@example.com`,value:o.email,onChange:_,disabled:n,className:i.email?`border-destructive`:``}),i.email&&(0,Q.jsx)(`p`,{className:`text-sm text-destructive`,children:i.email})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(q,{htmlFor:`password`,children:`Password`}),(0,Q.jsx)(en,{id:`password`,type:`password`,placeholder:`Enter your password`,value:o.password,onChange:_,disabled:n,className:i.password?`border-destructive`:``}),i.password&&(0,Q.jsx)(`p`,{className:`text-sm text-destructive`,children:i.password}),f&&h&&(0,Q.jsxs)(`ul`,{className:`text-xs list-disc pl-4 space-y-1`,children:[(0,Q.jsxs)(`li`,{className:h.minLength?`text-success`:`text-muted-foreground`,children:[`At least `,f.minLength,` characters`]}),f.requireUppercase&&(0,Q.jsx)(`li`,{className:h.uppercase?`text-success`:`text-muted-foreground`,children:`At least one uppercase letter`}),f.requireLowercase&&(0,Q.jsx)(`li`,{className:h.lowercase?`text-success`:`text-muted-foreground`,children:`At least one lowercase letter`}),f.requireNumbers&&(0,Q.jsx)(`li`,{className:h.number?`text-success`:`text-muted-foreground`,children:`At least one number`}),f.requireSpecialChars&&(0,Q.jsx)(`li`,{className:h.special?`text-success`:`text-muted-foreground`,children:`At least one special character`}),f.maxLength&&(0,Q.jsxs)(`li`,{className:h.maxLength?`text-success`:`text-muted-foreground`,children:[`No more than `,f.maxLength,` characters`]})]})]}),(0,Q.jsx)(K,{type:`submit`,className:`w-full`,disabled:n,children:n?`Creating Account...`:`Create Account`})]}),(0,Q.jsxs)(`div`,{className:`mt-4 text-center text-sm`,children:[`Already have an account?`,` `,(0,Q.jsx)(S,{to:`/login`,className:`underline`,children:`Sign in`})]}),(0,Q.jsxs)(`div`,{className:`px-8 py-4 text-center text-sm text-muted-foreground border-t mt-6`,children:[`By clicking continue, you agree to our`,` `,(0,Q.jsx)(S,{to:`/terms`,className:`underline underline-offset-4 hover:text-primary`,children:`Terms of Service`}),` `,`and`,` `,(0,Q.jsx)(S,{to:`/privacy`,className:`underline underline-offset-4 hover:text-primary`,children:`Privacy Policy`}),`.`]})]})}function Ja(){let e=m(),[t]=E(),[n,r]=Z.useState(t.get(`error`)),i=Z.useRef(!1);return Z.useEffect(()=>{let n=t.get(`code`);!n||i.current||(i.current=!0,bn(n).then(()=>e(`/home`,{replace:!0})).catch(e=>r(e instanceof Error?e.message:`Google sign-in failed`)))},[t,e]),(0,Q.jsx)(Ua,{children:(0,Q.jsx)(`div`,{className:`flex flex-col space-y-4 text-center`,children:n?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Google sign-in failed`}),(0,Q.jsx)(`p`,{className:`text-sm text-destructive`,children:n}),(0,Q.jsx)(K,{type:`button`,variant:`outline`,onClick:()=>e(`/login`,{replace:!0}),children:`Back to sign in`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Signing you in…`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Completing Google sign-in.`})]})})})}function Ya({children:e}){let[t,n]=(0,Z.useState)(`loading`);return(0,Z.useEffect)(()=>{(async()=>{try{if(!_n()){console.log(`No authentication token found, redirecting to login`),n(`unauthenticated`);return}let e=await vn();e?(console.log(`User authenticated:`,e.email),n(`authenticated`)):(console.log(`User not authenticated or token expired`),n(`unauthenticated`))}catch(e){if(console.error(`Authentication check failed:`,e),yn(e)){if(dn()){n(`authenticated`);return}Y.clearAuthToken(),n(`unauthenticated`);return}e instanceof Error&&e.message.includes(`Authentication required`)&&(console.log(`Clearing invalid token from ProtectedRoute`),Y.clearAuthToken()),n(`unauthenticated`)}})()},[]),t===`loading`?(0,Q.jsx)(`div`,{className:`flex h-screen items-center justify-center`,children:(0,Q.jsx)(Cn,{className:`h-8 w-8`})}):t===`unauthenticated`?(0,Q.jsx)(u,{to:`/login`,replace:!0}):(0,Q.jsx)(Q.Fragment,{children:e})}function Xa({children:e}){let[t,n]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{(async()=>{try{await Y.get(`/auth/me`),n(!0)}catch(e){e instanceof Error&&e.message.includes(`Authentication required`)&&(console.log(`Clearing invalid token from PublicRoute`),Y.clearAuthToken()),n(!1)}})()},[]),t===null?null:t?(0,Q.jsx)(u,{to:`/workspaces`,replace:!0}):(0,Q.jsx)(Q.Fragment,{children:e})}var Za=`data/schema/file`;function Qa(e){return String(e.locations?.[0]?.url||``).trim()}function $a(e){let t=Qa(e);if(!t)return``;let n=t.split(/[?#]/)[0].split(`/`).filter(Boolean).pop()||``;try{return decodeURIComponent(n)}catch{return n}}function eo(e){return e.schema===Za&&String(e.metadata?.contentType||``).startsWith(`image/`)}function to(e){let t=Number(e);return!Number.isFinite(t)||t<0?``:t<1024?`${t} B`:t<1048576?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`}function no(e){if(e.schema!==Za)return kn(e);let t=$a(e),n=String(e.metadata?.contentType||``).trim(),r=to(e.metadata?.size);return{...kn(e),title:t||`File ${e.id}`,preview:[n,r].filter(Boolean).join(` · `),subtitle:Qa(e),schemaLabel:`file`}}function ro(e){return/^https?:\/\/[^\s]+$/i.test(e)}function io(e,t){if(e.schema===`data/schema/tab`){let t=String(e.data?.url||``).trim();return ro(t)?t:null}return t.isExternal&&ro(t.subtitle)?t.subtitle:ro(t.title)?t.title:null}function ao(e,t,n=!1){return zr(e,t,{download:n})}function oo(e){return e.split(/(https?:\/\/[^\s]+)/gi).map((e,t)=>ro(e)?(0,Q.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`underline decoration-muted-foreground underline-offset-2 hover:text-primary`,children:e},`${e}-${t}`):e)}function so(e){return e?new Date(e).toLocaleString():``}function co(){let{code:e=``}=l(),[t,n]=(0,Z.useState)(null),[r,i]=(0,Z.useState)(!0),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(``),f=(0,Z.useMemo)(()=>t?.documents?Array.isArray(t.documents)?t.documents:t.documents.data||[]:[],[t]),p=(0,Z.useMemo)(()=>{let e=u.trim().toLowerCase();return e?f.filter(t=>{let n=no(t);return[t.schema,n.title,n.preview,n.subtitle,$a(t),t.metadata?.contentType].join(` `).toLowerCase().includes(e)}):f},[f,u]),m=(0,Z.useCallback)(async()=>{if(e){i(!0);try{let t=await Y.get(`${J}/pub/c/${encodeURIComponent(e)}`,{skipAuth:!0});n(t),o(null)}catch(e){n(null),o(e instanceof Error?e.message:`Failed to load public canvas`)}finally{i(!1)}}},[e]);(0,Z.useEffect)(()=>{m()},[m]),(0,Z.useEffect)(()=>{if(!e)return;let t=un(`${ln}/pub`,{transports:[`websocket`],auth:{code:e},reconnection:!0,reconnectionAttempts:10,reconnectionDelay:1500});return t.on(`connect`,()=>c(!0)),t.on(`disconnect`,()=>c(!1)),t.on(`connect_error`,()=>c(!1)),t.on(`canvas:changed`,()=>m()),()=>{t?.disconnect(),t=null}},[e,m]);let h=(0,Z.useCallback)(e=>{e?.preventDefault(),d(u.trim())},[u]),g=(0,Z.useCallback)(()=>{d(``)},[]),_=(0,Z.useCallback)(async e=>({payload:Fn(e?.sortBy)?Vn(f,e.sortBy,e?.order):f,totalCount:t?.stats.documentCount??f.length}),[f,t]);if(r&&!t)return(0,Q.jsx)(`main`,{className:`min-h-screen bg-muted flex items-center justify-center p-6`,children:(0,Q.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Loading canvas...`})});if(a||!t)return(0,Q.jsxs)(`main`,{className:`min-h-screen bg-muted flex flex-col items-center justify-center p-6`,children:[(0,Q.jsxs)(Oa,{className:`max-w-md bg-card`,children:[(0,Q.jsx)(ka,{children:(0,Q.jsx)(Aa,{children:`Canvas unavailable`})}),(0,Q.jsx)(Ma,{className:`text-sm text-muted-foreground`,children:a||`This public canvas does not exist.`})]}),(0,Q.jsx)(Ha,{className:`mt-6 text-center`})]});let v=t.canvas.metadata?.ui??{},y=!!v.widgets&&Object.keys(v.widgets).length>0;return(0,Q.jsx)(Br.Provider,{value:e,children:(0,Q.jsx)(`main`,{className:`min-h-screen bg-muted p-2 text-foreground sm:p-4 md:p-10`,children:(0,Q.jsxs)(`div`,{className:`mx-auto max-w-6xl`,children:[(0,Q.jsxs)(Oa,{className:`bg-card shadow-elevation-3`,children:[(0,Q.jsx)(ka,{className:`border-b p-3 sm:p-6`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between md:gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 gap-3 sm:gap-4`,children:[(0,Q.jsx)(`div`,{className:`mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-accent text-primary sm:mt-1 sm:h-12 sm:w-12 sm:rounded-2xl`,style:t.canvas.color?{borderLeft:`4px solid ${t.canvas.color}`}:void 0,children:(0,Q.jsx)(Wt,{className:`h-5 w-5 sm:h-6 sm:w-6`})}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-xs uppercase tracking-wide text-muted-foreground`,children:t.workspace.label||t.workspace.name}),(0,Q.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] text-muted-foreground md:hidden`,children:[s?(0,Q.jsx)(qt,{className:`h-3 w-3 text-success`}):(0,Q.jsx)(O,{className:`h-3 w-3 text-muted-foreground`}),s?`Live`:`Offline`]})]}),(0,Q.jsx)(Aa,{className:`mt-0.5 truncate text-2xl sm:mt-1 sm:text-3xl md:text-5xl`,children:t.canvas.label||t.canvas.name||`Canvas`}),t.canvas.description&&(0,Q.jsx)(`p`,{className:`mt-1.5 max-w-3xl text-sm text-muted-foreground sm:mt-3 sm:text-base`,children:t.canvas.description})]})]}),(0,Q.jsxs)(`div`,{className:`hidden shrink-0 items-center gap-2 rounded-full border px-3 py-1 text-xs text-muted-foreground md:flex`,children:[s?(0,Q.jsx)(qt,{className:`h-3.5 w-3.5 text-success`}):(0,Q.jsx)(O,{className:`h-3.5 w-3.5 text-muted-foreground`}),s?`Live`:`Offline`]})]})}),(0,Q.jsxs)(Ma,{className:`space-y-4 p-3 sm:space-y-6 sm:p-6 md:p-8`,children:[(0,Q.jsxs)(`section`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-1 text-xs text-muted-foreground md:hidden`,children:[(0,Q.jsx)(`span`,{className:`w-full truncate font-mono text-foreground`,children:t.share.path}),(0,Q.jsxs)(`span`,{className:`tabular-nums`,children:[t.stats.documentCount,` docs`]}),p.length!==t.stats.documentCount&&(0,Q.jsxs)(`span`,{className:`tabular-nums`,children:[`· `,p.length,` shown`]}),(0,Q.jsxs)(`span`,{className:`truncate`,children:[`· `,so(t.stats.refreshedAt)]})]}),(0,Q.jsxs)(`section`,{className:`hidden gap-3 md:grid md:grid-cols-4`,children:[(0,Q.jsx)(lo,{label:`Path`,value:t.share.path,mono:!0}),(0,Q.jsx)(lo,{label:`Documents`,value:String(t.stats.documentCount)}),(0,Q.jsx)(lo,{label:`Shown`,value:String(p.length)}),(0,Q.jsx)(lo,{label:`Refreshed`,value:so(t.stats.refreshedAt)})]}),y&&(0,Q.jsx)(`section`,{id:`content-area`,className:`flex w-full flex-col overflow-hidden rounded-2xl border h-viewport-card min-h-[420px] md:h-viewport-pane`,children:(0,Q.jsx)(_r,{workspaceId:t.workspace.name,treeName:t.share.treeName,path:t.share.path,layerId:t.canvas.id,querySpec:t.canvas.querySpec,metadata:t.canvas.metadata,readOnly:!0,interactive:!1,fetchDocuments:_},JSON.stringify(v))}),!y&&(0,Q.jsxs)(`section`,{className:`rounded-2xl border`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 border-b px-4 py-3 md:flex-row md:items-center md:justify-between`,children:[(0,Q.jsx)(`h2`,{className:`font-semibold`,children:`Content`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 md:flex-row md:items-center`,children:[(0,Q.jsxs)(`form`,{onSubmit:h,className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,Q.jsx)(Kt,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`}),(0,Q.jsx)(`input`,{type:`search`,value:u,onChange:e=>d(e.target.value),placeholder:`Search loaded documents...`,className:`w-full rounded-md border py-1.5 pl-9 pr-8 text-sm md:w-72`}),u&&(0,Q.jsx)(`button`,{type:`button`,onClick:g,className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,"aria-label":`Clear search`,children:(0,Q.jsx)(z,{className:`h-4 w-4`})})]}),(0,Q.jsx)(`button`,{type:`submit`,className:`rounded-md border px-3 py-1.5 text-xs hover:bg-muted`,children:`Search`})]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:m,className:`inline-flex items-center justify-center gap-2 rounded-md border px-3 py-1.5 text-xs hover:bg-muted`,children:[(0,Q.jsx)(fe,{className:`h-3.5 w-3.5 ${r?`animate-spin`:``}`}),`Refresh`]})]})]}),u.trim()&&(0,Q.jsxs)(`div`,{className:`border-b bg-muted px-4 py-2 text-xs text-muted-foreground`,children:[`Local search: `,(0,Q.jsxs)(`span`,{className:`font-mono`,children:[`"`,u.trim(),`"`]})]}),(0,Q.jsx)(`div`,{className:`divide-y`,children:p.length===0?(0,Q.jsx)(`div`,{className:`p-8 text-center text-sm text-muted-foreground`,children:u.trim()?`No loaded documents match your search.`:`No documents yet.`}):p.map(t=>{let n=no(t),r=io(t,n),i=t.schema===Za,a=i?ao(e,t.id):null,o=a||r;return(0,Q.jsxs)(`article`,{className:`p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 md:flex-row md:items-start md:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h3`,{className:`truncate font-medium`,children:o?(0,Q.jsx)(`a`,{href:o,target:`_blank`,rel:`noreferrer`,className:`hover:text-primary hover:underline`,children:n.title}):n.title}),(0,Q.jsx)(`div`,{className:`mt-1 font-mono text-xs text-muted-foreground`,children:n.schemaLabel})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3`,children:[i&&(0,Q.jsxs)(`a`,{href:ao(e,t.id,!0),download:n.title,className:`inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs text-muted-foreground hover:bg-muted hover:text-foreground`,children:[(0,Q.jsx)(Ve,{className:`h-3.5 w-3.5`}),`Download`]}),(0,Q.jsx)(`time`,{className:`text-xs text-muted-foreground`,children:so(t.updatedAt||t.createdAt)})]})]}),n.preview&&(0,Q.jsx)(`p`,{className:`mt-3 line-clamp-3 text-sm leading-6 text-foreground`,children:oo(n.preview)}),eo(t)&&(0,Q.jsx)(`a`,{href:a||void 0,target:`_blank`,rel:`noreferrer`,className:`mt-3 block w-fit`,children:(0,Q.jsx)(`img`,{src:a||void 0,alt:n.title,loading:`lazy`,className:`max-h-64 max-w-full rounded border bg-muted object-contain transition-opacity hover:opacity-90`})})]},t.id)})})]})]})]}),(0,Q.jsx)(Ha,{className:`mt-6 text-center`})]})})})}function lo({label:e,value:t,mono:n=!1}){return(0,Q.jsxs)(`div`,{className:`min-w-0 rounded-xl border bg-muted p-4`,children:[(0,Q.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-muted-foreground`,children:e}),(0,Q.jsx)(`div`,{className:`mt-2 truncate text-lg font-semibold ${n?`font-mono text-sm`:``}`,children:t||`-`})]})}var uo=`false`,fo=`false`,po=uo===`true`,mo=fo===`true`;function ho(e={}){let{immediate:t=!1,onNeedReload:n,onNeedRefresh:r,onOfflineReady:i,onRegistered:a,onRegisteredSW:o,onRegisterError:s}=e,l,u,d,f=async(e=!0)=>{await u,po||d?.()};async function p(){if(`serviceWorker`in navigator){if(l=await c(async()=>{let{Workbox:e}=await import(`./workbox-window.prod.es5-Bd17z0YL.js`);return{Workbox:e}},[]).then(({Workbox:e})=>new e(`/sw.js`,{scope:`/`,type:`classic`})).catch(e=>{s?.(e)}),!l)return;if(d=()=>{l?.messageSkipWaiting()},!mo){if(po)l.addEventListener(`activated`,e=>{(e.isUpdate||e.isExternal)&&(n?n():window.location.reload())}),l.addEventListener(`installed`,e=>{e.isUpdate||i?.()});else{let e=!1,t=()=>{e=!0,l?.addEventListener(`controlling`,e=>{e.isUpdate&&(n?n():window.location.reload())}),r?.()};l.addEventListener(`installed`,n=>{n.isUpdate===void 0?n.isExternal===void 0?!e&&i?.():n.isExternal?t():!e&&i?.():n.isUpdate||i?.()}),l.addEventListener(`waiting`,t)}}l.register({immediate:t}).then(e=>{o?o(`/sw.js`,e):a?.(e)}).catch(e=>{s?.(e)})}}return u=p(),f}var go=new Set,_o=!1,vo=ho({immediate:!0,onRegisteredSW(e,t){t&&setInterval(()=>{t.update()},36e5)},onNeedRefresh(){_o=!0,go.forEach(e=>e())}});function yo(e){return go.add(e),_o&&e(),()=>{go.delete(e)}}function bo(){vo(!0)}function xo(){let[e,t]=(0,Z.useState)(!1),[n,r]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>yo(()=>t(!0)),[]),!e||n?null:(0,Q.jsx)(`div`,{className:`fixed bottom-4 left-1/2 z-50 -translate-x-1/2`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-full border border-border bg-card px-4 py-2 shadow-elevation-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm`,children:`A new version of Canvas is ready`}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>bo(),className:`flex items-center gap-1 rounded-full bg-foreground px-3 py-1 text-xs font-medium text-background hover:bg-foreground/90`,children:[(0,Q.jsx)(fe,{className:`h-3 w-3`}),` Reload`]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>r(!0),"aria-label":`Not now`,className:`rounded-full p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,Q.jsx)(z,{className:`h-3.5 w-3.5`})})]})})}var So=(0,Z.lazy)(()=>c(()=>import(`./apps-CvInUZwB.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]))),Co=(0,Z.lazy)(()=>c(()=>Promise.resolve().then(()=>Is).then(e=>({default:e.AppsMenu})),void 0)),wo=(0,Z.lazy)(()=>c(()=>import(`./workspaces-By3jZzrz.js`),__vite__mapDeps([19,1,2,8,3,4,10,9,6,5,11,12,20,7,13,21,22,23,24,25,26,27,28,29,30,31,32,33]))),To=(0,Z.lazy)(()=>c(()=>import(`./_workspaceName_-DqFTMP44.js`),__vite__mapDeps([34,1,2,3,4,10,8,5,6,9,12,35,32,20,7,11,13,36,37,38,39,40,22,23,41,42,43,44,21,45,46,47,18,14,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,24,76,77,78,79,27,80,25,26,81,82,29,83,15,84,85,86,16,17,87]))),Eo=(0,Z.lazy)(()=>c(()=>import(`./document-DOp6AbOi.js`),__vite__mapDeps([88,1,2,3,4,9,10,8,6,5,7,11,12,13,43,44,38,39,40,20,22,23,41,21,45,46,47,18,14,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,27,25,82,35,32,24,89]))),Do=(0,Z.lazy)(()=>c(()=>import(`./home-CFZRa_Mu.js`),__vite__mapDeps([90,1,2,3,4,10,8,7,9,6,5,11,12,13,36,35,32,37,38,39,40,20,22,23,41,42,43,44,21,45,46,47,18,14,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,24,76,77,78,79,27,80,91,85,86]))),Oo=(0,Z.lazy)(()=>c(()=>import(`./desk-dI_FvLsK.js`),__vite__mapDeps([92,2,1]))),ko=(0,Z.lazy)(()=>c(()=>import(`./share-target-fpk-pz15.js`),__vite__mapDeps([93,1,2,3,4,91,8,10,5,6,11,44,38,9,7,12,13,39,40,20,22,23,41,21,45,46,47,18,14,48,49,50,51,72,63,65,61,85,54,86]))),Ao=(0,Z.lazy)(()=>c(()=>import(`./contexts-CvMtPd1N2.js`),__vite__mapDeps([94,1,2,3,4,10,8,9,6,5,11,35,12,32,20,7,13,14,74,38,39,40,22,23,41,62,77,28,29,30]))),jo=(0,Z.lazy)(()=>c(()=>import(`./_contextId_-DRvqFeiU.js`),__vite__mapDeps([95,1,2,3,4,35,12,32,20,38,8,10,5,6,9,7,11,13,39,40,22,23,41,70,43,44,21,45,46,47,18,14,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,71,72,73,74,75,24,76,77,78,79,25,83,42,15,84,85,86,16,17,89]))),Mo=(0,Z.lazy)(()=>c(()=>import(`./api-tokens-DDH7LMJ7.js`),__vite__mapDeps([96,1,2,10,8,9,6,5,11,12,20,28,3,4,97,25,21]))),No=(0,Z.lazy)(()=>c(()=>import(`./devices-C3gLuNDv.js`),__vite__mapDeps([98,1,2,10,8,9,6,5,11,20,28,3,4,97,25,21,99,12]))),Po=(0,Z.lazy)(()=>c(()=>import(`./settings-DhVz_Osu.js`),__vite__mapDeps([100,1,2,3,4,10,8,11,5,6,7,9,12,13,14,25,21,28]))),Fo=(0,Z.lazy)(()=>c(()=>import(`./appearance-CN8I4_GQ.js`),__vite__mapDeps([101,1,2,10,8,5,6,71,25,3,4,21,102,28,97]))),Io=(0,Z.lazy)(()=>c(()=>import(`./key-bindings-Dfa7ehDw.js`),__vite__mapDeps([103,1,2,28,3,4,10,8,5,6,97,25,21]))),Lo=(0,Z.lazy)(()=>c(()=>import(`./offline-COOUcZsG.js`),__vite__mapDeps([104,1,2,10,8,5,6,9,12,38,7,11,13,39,40,20,22,23,41,62,28,3,4,97,25,21]))),Ro=(0,Z.lazy)(()=>c(()=>import(`./about-DbGpwqCH.js`),__vite__mapDeps([105,1,2,12,28,3,4,10,8,5,6,97,25,21]))),zo=(0,Z.lazy)(()=>c(()=>import(`./embedding-B5JiUA9X.js`),__vite__mapDeps([106,1,2,10,8,9,6,5,20,28,3,4,97,25,21,107,11,12]))),Bo=(0,Z.lazy)(()=>c(()=>import(`./shared-CCCuTYCU.js`),__vite__mapDeps([108,1,2,3,4,9,10,8,6,5,11,12,20,28,97,25,21]))),Vo=(0,Z.lazy)(()=>c(()=>import(`./workspaces-Da_hUIj3.js`),__vite__mapDeps([109,1,2,10,8,9,6,5,11,44,37,12,35,32,20,39,28,3,4,110]))),Ho=(0,Z.lazy)(()=>c(()=>import(`./contexts-Ef3fHwv6.js`),__vite__mapDeps([111,1,2,37,6,12,35,32,28,3,4,10,8,5]))),Uo=(0,Z.lazy)(()=>c(()=>import(`./agents-DlLq0q2s.js`),__vite__mapDeps([112,1,2,37,6,12,35,32,28,3,4,10,8,5]))),Wo=(0,Z.lazy)(()=>c(()=>import(`./logs-Czn2sPeP.js`),__vite__mapDeps([113,1,2,10,8,9,6,5,11,44,37,12,35,32,20,28,3,4,97,25,21,110]))),Go=(0,Z.lazy)(()=>c(()=>import(`./roles-BpVWTMmp.js`),__vite__mapDeps([114,1,2,10,8,9,6,5,11,44,37,12,35,32,20,39,28,3,4,97,25,21,115]))),Ko=(0,Z.lazy)(()=>c(()=>import(`./users-CKz9kOoR.js`),__vite__mapDeps([116,1,2,10,8,9,6,5,11,44,37,12,35,32,20,39,28,3,4,97,25,21,110]))),qo=(0,Z.lazy)(()=>c(()=>import(`./embedding-B7cWrpy0.js`),__vite__mapDeps([117,1,2,10,8,9,6,5,11,37,12,35,32,20,28,3,4,97,25,21,107]))),Jo=(0,Z.lazy)(()=>c(()=>import(`./auth-HZNJB4wv.js`),__vite__mapDeps([118,1,2,10,8,5,6,9,11,12,37,35,32,20,28,3,4,97,25,21]))),Yo=(0,Z.lazy)(()=>c(()=>import(`./agents-BBKnR8_O.js`),__vite__mapDeps([119,1,2,3,4,10,8,9,6,5,11,20,23,28,120,29,30,31,12,32]))),Xo=(0,Z.lazy)(()=>c(()=>import(`./_agentId_-sMYqsnQk.js`),__vite__mapDeps([121,1,2,3,4,10,8,5,6,9,12,32,20,56,25,21,28]))),Zo=(0,Z.lazy)(()=>c(()=>import(`./settings-N3fbO22m.js`),__vite__mapDeps([122,1,2,3,4,10,8,9,6,5,11,20,7,12,13,21,14,23,25,28,120]))),Qo=(0,Z.lazy)(()=>c(()=>import(`./settings-BOHindnt.js`),__vite__mapDeps([123,1,2,8,3,4,10,5,6,9,11,44,12,35,32,20,38,7,13,39,40,22,23,41,21,58,59,60,61,62,66,73,74,75,24,25,102,28,107,31,99,87,33]))),$o=(0,Z.lazy)(()=>c(()=>import(`./settings-FiiJ5QFa.js`),__vite__mapDeps([124,1,2,3,4,10,8,5,6,9,11,20,21,14,12,7,13,74,38,39,40,22,23,41,62,25,28]))),es=(0,Z.lazy)(()=>c(()=>import(`./roles-Bo9GZdOk.js`),__vite__mapDeps([125,1,2,10,8,9,6,5,11,37,12,35,32,20,7,13,39,28,3,4,115,29,30]))),ts=(0,Z.lazy)(()=>c(()=>import(`./remotes-CdEU1Y5l.js`),__vite__mapDeps([126,2,1,28,3,4,10,8,5,6]))),ns=(0,Z.lazy)(()=>c(()=>import(`./add-DsH8MVg6.js`),__vite__mapDeps([127,2,1,3,4,91,8,10,5,6,11,44,38,9,7,12,13,39,40,20,22,23,41,21,45,46,47,18,14,48,49,50,51,72,63,65,61,85,54,86])));function $(e){return(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`flex h-full items-center justify-center p-4 text-sm text-muted-foreground`,role:`status`,children:`Opening…`}),children:(0,Q.jsx)(e,{})})}var rs=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(d,{index:!0,element:$(Oo)},`r1`),(0,Q.jsx)(d,{path:`home`,element:$(Do)},`r2`),(0,Q.jsx)(d,{path:`share-target`,element:$(ko)},`r3`),(0,Q.jsx)(d,{path:`apps`,element:$(Co)},`apps-index`),(0,Q.jsx)(d,{path:`apps/:appletId`,element:$(So)},`apps-host`),(0,Q.jsx)(d,{path:`apps/add/:kind`,element:$(ns)},`r4`),(0,Q.jsx)(d,{path:`workspaces`,element:$(wo)},`r5`),(0,Q.jsx)(d,{path:`workspaces/:workspaceName`,element:$(To)},`r6`),(0,Q.jsx)(d,{path:`workspaces/:workspaceName/documents/by-id/:documentId`,element:$(Eo)},`workspace-document-by-id`),(0,Q.jsx)(d,{path:`workspaces/:workspaceName/documents/:documentId`,element:$(Eo)},`workspace-document`),(0,Q.jsx)(d,{path:`workspaces/:workspaceName/documents/by-hash/:algo/:checksum`,element:$(Eo)},`workspace-document-by-hash`),(0,Q.jsx)(d,{path:`workspaces/:workspaceName/documents/by-checksum/:algo/:checksum`,element:$(Eo)},`workspace-document-by-checksum`),(0,Q.jsx)(d,{path:`workspaces/:workspaceName/settings`,element:$(Qo)},`r7`),(0,Q.jsx)(d,{path:`workspaces/:workspaceName/settings/:tab`,element:$(Qo)},`r8`),(0,Q.jsx)(d,{path:`workspaces/:workspaceName/path/*`,element:$(To)},`r9`),(0,Q.jsx)(d,{path:`workspaces/:workspaceName/trees/:treeName`,element:$(To)},`r10`),(0,Q.jsx)(d,{path:`workspaces/:workspaceName/trees/:treeName/path/*`,element:$(To)},`r11`),(0,Q.jsx)(d,{path:`contexts`,element:$(Ao)},`r12`),(0,Q.jsx)(d,{path:`contexts/:contextId`,element:$(jo)},`r13`),(0,Q.jsx)(d,{path:`contexts/:contextId/settings`,element:$($o)},`r14`),(0,Q.jsx)(d,{path:`contexts/:contextId/settings/:tab`,element:$($o)},`r15`),(0,Q.jsx)(d,{path:`agents`,element:$(Yo)},`r16`),(0,Q.jsx)(d,{path:`agents/:agentId`,element:$(Xo)},`r17`),(0,Q.jsx)(d,{path:`agents/:agentId/:sessionId`,element:$(Xo)},`r18`),(0,Q.jsx)(d,{path:`agents/:agentId/settings`,element:$(Zo)},`r19`),(0,Q.jsx)(d,{path:`agents/:agentId/settings/:tab`,element:$(Zo)},`r20`),(0,Q.jsx)(d,{path:`roles`,element:$(es)},`r21`),(0,Q.jsx)(d,{path:`remotes`,element:$(ts)},`r22`),(0,Q.jsx)(d,{path:`settings`,element:$(Po)},`settings`),(0,Q.jsx)(d,{path:`appearance`,element:$(Fo)},`r23`),(0,Q.jsx)(d,{path:`key-bindings`,element:$(Io)},`key-bindings`),(0,Q.jsx)(d,{path:`offline`,element:$(Lo)},`r24`),(0,Q.jsx)(d,{path:`about`,element:$(Ro)},`r25`),(0,Q.jsx)(d,{path:`api-tokens`,element:$(Mo)},`r26`),(0,Q.jsx)(d,{path:`devices`,element:$(No)},`r27`),(0,Q.jsx)(d,{path:`embedding`,element:$(zo)},`r28`),(0,Q.jsx)(d,{path:`shared`,element:$(Bo)},`r29`),(0,Q.jsx)(d,{path:`admin/users`,element:$(Ko)},`r30`),(0,Q.jsx)(d,{path:`admin/contexts`,element:$(Ho)},`r31`),(0,Q.jsx)(d,{path:`admin/workspaces`,element:$(Vo)},`r32`),(0,Q.jsx)(d,{path:`admin/agents`,element:$(Uo)},`r33`),(0,Q.jsx)(d,{path:`admin/logs`,element:$(Wo)},`r34`),(0,Q.jsx)(d,{path:`admin/roles`,element:$(Go)},`r35`),(0,Q.jsx)(d,{path:`admin/embedding`,element:$(qo)},`r36`),(0,Q.jsx)(d,{path:`admin/auth`,element:$(Jo)},`r37`)]});function is(e){if(typeof e!=`string`||!e.startsWith(`/`)||e.startsWith(`//`)||/[\\\u0000-\u0020]/.test(e))return null;let t=new URL(e,`https://canvas.invalid`);return t.origin!==`https://canvas.invalid`||/^\/(?:login|register|pub|share-target|apps|next)(?:\/|$)/.test(t.pathname)||t.pathname===`/`||[...t.searchParams.keys()].some(e=>/token|password|secret|code/i.test(e))?null:t.pathname+t.search+t.hash}function as(e){let t=2166136261;for(let n of e)t=Math.imul(t^n.charCodeAt(0),16777619);return`canvas:last-screen:${t>>>0}`}var os=p(rs),ss=e=>{let t=is(e);return t&&x(os,t)?t:null};function cs(){let e=h(),[t]=(0,Z.useState)(()=>{if(e.pathname!==`/`||e.search||e.hash)return null;try{let t=localStorage.getItem(`authToken`);return t?{key:e.key,path:ss(localStorage.getItem(as(t)))||`/home`}:null}catch{return{key:e.key,path:`/home`}}}),n=t&&e.key===t.key&&e.pathname===`/`;return(0,Z.useEffect)(()=>{if(n)return;let t=ss(e.pathname+e.search+e.hash);if(t)try{let e=localStorage.getItem(`authToken`);e&&localStorage.setItem(as(e),t)}catch{}},[e.pathname,e.search,e.hash,n]),n?(0,Q.jsx)(u,{to:t.path,replace:!0}):null}var ls={activeSection:null,m0Open:!1,m1Open:!1,m2Open:!1,m2View:null,selectedEntityId:null,user:null};function us(e,t){switch(t.type){case`RESTORE_MENU`:return{...e,...t.menu,user:e.user};case`SET_SECTION`:return{...e,activeSection:t.section,m1Open:t.section!==null,m2Open:!1,m2View:null,selectedEntityId:null};case`TOGGLE_SECTION`:return e.activeSection===t.section&&e.m1Open?{...e,activeSection:null,m1Open:!1,m2Open:!1,m2View:null}:{...e,activeSection:t.section,m1Open:!0,m2Open:!1,m2View:null,selectedEntityId:null};case`TOGGLE_M0`:return e.m0Open?{...e,m0Open:!1,activeSection:null,m1Open:!1,m2Open:!1,m2View:null}:{...e,m0Open:!0};case`CLOSE_M0`:return{...e,m0Open:!1};case`CLOSE_M1`:return{...e,activeSection:null,m1Open:!1,m2Open:!1,m2View:null};case`OPEN_M2`:return{...e,m2Open:!0,m2View:t.view,selectedEntityId:t.entityId===void 0?e.selectedEntityId:t.entityId};case`OPEN_M2_DRAWER`:return{...e,m0Open:!0,activeSection:t.section,m1Open:!0,m2Open:!0,m2View:t.view,selectedEntityId:t.entityId};case`OPEN_M1_DRAWER`:return{...e,m0Open:!0,activeSection:t.section,m1Open:!0,m2Open:!1,m2View:null,selectedEntityId:null};case`CLOSE_M2`:return{...e,m2Open:!1,m2View:null};case`SELECT_ENTITY`:return{...e,selectedEntityId:t.entityId};case`SYNC_FROM_URL`:{let n=!t.mobile&&!e.m2Open&&e.m2View===null&&t.section===e.activeSection&&t.entityId===e.selectedEntityId;return t.section===e.activeSection&&t.entityId===e.selectedEntityId&&t.m2View===e.m2View&&!(t.mobile&&(e.m1Open||e.m0Open))?e:{...e,activeSection:t.section,m0Open:!t.mobile&&e.m0Open,m1Open:!t.mobile&&t.section!==null,selectedEntityId:t.entityId,m2Open:!n&&t.m2View!==null,m2View:n?null:t.m2View}}case`SET_USER`:return{...e,user:t.user};default:return e}}function ds({children:e}){let[t,n]=(0,Z.useReducer)(us,ls),r=h(),i=m(),a=(0,Z.useRef)(t);(0,Z.useLayoutEffect)(()=>{a.current=t},[t]),ia(t,n);let o=(0,Z.useCallback)((e,t=!1,o=!1)=>{let s=us(a.current,e);if(a.current=s,n(e),!ua())return;let{activeSection:c,m0Open:l,m1Open:u,m2Open:d,m2View:f,selectedEntityId:p}=s;i({pathname:r.pathname,search:r.search,hash:r.hash},{replace:t,state:{...r.state,canvasMenu:{activeSection:c,m0Open:l,m1Open:u,m2Open:d,m2View:f,selectedEntityId:p},canvasMenuBack:o}})},[r,i]),s=(0,Z.useCallback)(e=>{if(ua()&&a.current.m1Open){let{activeSection:t,m0Open:n,m1Open:o,m2Open:s,m2View:c,selectedEntityId:l}=a.current;i(e,{replace:!0,state:{...r.state,canvasMenu:{activeSection:t,m0Open:n,m1Open:o,m2Open:s,m2View:c,selectedEntityId:l},canvasMenuBack:!1}})}i(e)},[r.state,i]),c=(0,Z.useCallback)(()=>{if(window.history.state?.idx>0){i(-1);return}let e=a.current;if(e.m1Open&&e.m2Open)o({type:`CLOSE_M2`},!0,!0);else if(e.m1Open)o({type:`CLOSE_M1`},!0,!0);else if(e.m0Open)o({type:`CLOSE_M0`},!0,!0);else{let{section:e,entityId:t,m2View:n}=fa(r.pathname);if(!ua()){i(e?`/${e}`:`/`);return}o(e&&t?{type:`OPEN_M2_DRAWER`,section:e,view:n,entityId:t}:{type:`TOGGLE_M0`},!0,!0)}},[o,r.pathname,i]);(0,Z.useEffect)(()=>{let e=mn();if(e){n({type:`SET_USER`,user:e});return}let t=!1;return vn().then(e=>{!t&&e&&n({type:`SET_USER`,user:e})}).catch(()=>{}),()=>{t=!0}},[]);let l={state:t,dispatch:n,setSection:(0,Z.useCallback)(e=>{o({type:`SET_SECTION`,section:e})},[o]),toggleSection:(0,Z.useCallback)(e=>{o({type:`TOGGLE_SECTION`,section:e})},[o]),toggleM0:(0,Z.useCallback)(()=>{o({type:`TOGGLE_M0`},a.current.m0Open)},[o]),closeM0:(0,Z.useCallback)(()=>{o({type:`CLOSE_M0`},!0)},[o]),closeM1:(0,Z.useCallback)(()=>{o({type:`CLOSE_M1`},!0)},[o]),openM2:(0,Z.useCallback)((e,t)=>{o({type:`OPEN_M2`,view:e,entityId:t})},[o]),openM2Drawer:(0,Z.useCallback)((e,t,n)=>{o({type:`OPEN_M2_DRAWER`,section:e,view:t,entityId:n})},[o]),openM1Drawer:(0,Z.useCallback)(e=>{o({type:`OPEN_M1_DRAWER`,section:e})},[o]),closeM2:(0,Z.useCallback)(()=>{ua()&&a.current.m1Open&&a.current.m2Open?c():n({type:`CLOSE_M2`})},[c]),selectEntity:(0,Z.useCallback)(e=>{n({type:`SELECT_ENTITY`,entityId:e})},[]),goBack:c,navigateFromMenu:s};return(0,Q.jsx)(pa.Provider,{value:l,children:e})}var fs;function ps(){let[e,t]=(0,Z.useState)({local:!1});return(0,Z.useEffect)(()=>{fs??=fetch(`${J}/runtime/capabilities`).then(async e=>e.ok?(await e.json()).payload:{local:!1}).catch(()=>({local:!1}));let e=!0;return fs.then(n=>{e&&t(n)}),()=>{e=!1}},[]),e}function ms(){return(0,Z.useSyncExternalStore)(rn,sn,()=>!1)}function hs(e,t){let n=null,r=!1,i,a;function o(){clearTimeout(i),!r&&sn()&&(i=setTimeout(()=>{s()},3e4))}function s(s=!1){if(n)return n;if(r)return Promise.resolve(!1);clearTimeout(i),a=new AbortController;let c=setTimeout(()=>a?.abort(),5e3);return n=(async()=>{try{let n=await fetch(e,{cache:`no-store`,credentials:`omit`,signal:a.signal});if(!n.ok||n.headers.get(`x-canvas-offline`)===`fallback`)throw Error(`Unavailable`);if((await n.json()).status!==`success`)throw Error(`Not a Canvas response`);if(r)return!1;let i=sn();return on(),(i||s)&&t(),!0}catch{return r||tn(),!1}finally{clearTimeout(c),n=null,o()}})(),n}let c=rn(o),l=()=>{s()};return window.addEventListener(`online`,l),o(),{retry:s,stop(){r=!0,clearTimeout(i),a?.abort(),c(),window.removeEventListener(`online`,l)}}}var gs;function _s(){gs=hs(`${J}/ping`,()=>X.retryNow());let e=()=>{gs?.retry()},t=X.on(`connect_error`,e),n=X.on(`disconnect`,e);return()=>{t(),n(),gs?.stop(),gs=void 0}}function vs(){return gs?.retry(!0)??Promise.resolve(!1)}function ys(){let e=ms(),[t,n]=(0,Z.useState)(!1);return e?(0,Q.jsxs)(`details`,{className:`relative`,children:[(0,Q.jsx)(`summary`,{"aria-label":`Offline — connection options`,title:`Offline — cached content available`,className:`flex h-10 w-10 cursor-pointer list-none items-center justify-center rounded-lg text-amber-600 hover:bg-accent/50 [&::-webkit-details-marker]:hidden`,children:(0,Q.jsx)(O,{className:`h-5 w-5`})}),(0,Q.jsxs)(`div`,{className:`absolute bottom-0 left-full z-50 ml-2 w-60 max-w-[calc(100vw-5rem)] rounded-lg border bg-popover p-3 text-popover-foreground shadow-lg`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium`,role:`status`,children:`Offline`}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`You can browse cached documents. We’ll reconnect automatically when the server is available.`}),(0,Q.jsx)(`button`,{type:`button`,disabled:t,onClick:async()=>{n(!0);try{await vs()}finally{n(!1)}},className:`mt-3 rounded-md bg-secondary px-3 py-2 text-xs font-medium hover:bg-accent disabled:opacity-50`,children:t?`Checking…`:`Retry now`})]})]}):null}var bs=ye,xs=j,Ss=Lt,Cs=Z.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,Q.jsx)(zt,{children:(0,Q.jsx)(We,{ref:r,sideOffset:t,className:G(`z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in duration-fast fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]`,e),...n})}));Cs.displayName=We.displayName;var ws=Z.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(Re,{ref:n,className:G(`relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full`,e),...t}));ws.displayName=Re.displayName;var Ts=Z.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(Ut,{ref:n,className:G(`aspect-square h-full w-full`,e),...t}));Ts.displayName=Ut.displayName;var Es=Z.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(Ft,{ref:n,className:G(`flex h-full w-full items-center justify-center rounded-full bg-muted`,e),...t}));Es.displayName=Ft.displayName;function Ds({section:e,icon:t,label:n,disabled:r}){let{state:i,toggleSection:a}=ca(),o=i.activeSection===e;return(0,Q.jsxs)(xs,{children:[(0,Q.jsx)(Ss,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,disabled:r,"aria-label":n,onClick:()=>!r&&e&&a(e),className:G(`relative flex items-center justify-center w-10 h-10 rounded-lg transition-colors`,o?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`,r&&`opacity-30 cursor-not-allowed`),children:[o&&(0,Q.jsx)(`span`,{className:`absolute right-0 top-1/2 -translate-y-1/2 w-0.5 h-5 bg-foreground rounded-l`}),t]})}),(0,Q.jsx)(Cs,{side:`right`,sideOffset:8,children:n})]})}function Os({path:e,icon:t,label:n,section:r=`settings`}){let i=m(),{setSection:a}=ca();return(0,Q.jsxs)(xs,{children:[(0,Q.jsx)(Ss,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":n,onClick:()=>{a(r),i(e)},className:`flex items-center justify-center w-10 h-10 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors`,children:t})}),(0,Q.jsx)(Cs,{side:`right`,sideOffset:8,children:n})]})}function ks(){let{state:e,toggleM0:t}=ca(),n=ms();return(0,Q.jsxs)(`button`,{type:`button`,onClick:t,"aria-label":`${e.m0Open?`Close menu`:`Open menu`}${n?` — offline, connection options in menu`:``}`,"data-shell":`rail`,className:`fixed bottom-rail-inset left-2 z-nav flex h-rail w-rail items-center justify-center rounded-full bg-foreground text-background shadow-elevation-4 md:hidden`,children:[e.m0Open?(0,Q.jsx)(z,{className:`h-5 w-5`}):(0,Q.jsx)(Et,{className:`h-5 w-5`}),n&&(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`absolute right-0 top-0 h-3 w-3 rounded-full border-2 border-background bg-amber-500`})]})}function As(){let{state:e,closeM0:t,closeM1:n}=ca(),{state:r,setView:i,closeT1:a}=ei(),o=m(),{showToast:s}=xn(),c=e.user?.userType===`admin`,l=ps(),u=()=>{r.t1Open?a():i(`tools`),n(),t()},d=(0,Z.useCallback)(async()=>{try{await Y.post(`/auth/logout`),localStorage.removeItem(`authToken`),o(`/login`)}catch{s({title:`Error`,description:`Logout failed`,variant:`destructive`})}},[o,s]);return(0,Q.jsxs)(bs,{delayDuration:200,children:[e.m0Open&&(0,Q.jsx)(`div`,{className:`fixed inset-0 z-nav-scrim bg-scrim animate-fade-in md:hidden`,onClick:t,"aria-hidden":!0}),(0,Q.jsxs)(`div`,{"data-shell":`rail`,className:G(`flex flex-col items-center w-rail h-full rounded-(--panel-radius) bg-transparent shrink-0`,e.m0Open?`max-md:fixed max-md:left-2 max-md:top-2 max-md:bottom-rail-stack max-md:z-rail max-md:h-auto max-md:bg-card max-md:surface-glass max-md:shadow-elevation-5`:`max-md:hidden`),children:[(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-12 w-full shrink-0`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Canvas home`,onClick:()=>o(`/home`),className:`flex items-center justify-center w-10 h-10 rounded-lg hover:bg-accent/50 transition-colors`,children:(0,Q.jsx)(`img`,{src:`/images/logo-br_128x128.png`,alt:``,className:`w-6 h-6`})})}),(0,Q.jsxs)(`nav`,{className:`flex flex-col items-center gap-1 py-2 flex-1 min-h-0 overflow-y-auto`,children:[(!l.local||l.workspace!==!1)&&(0,Q.jsx)(Ds,{section:`contexts`,icon:(0,Q.jsx)(Bt,{className:`w-5 h-5`}),label:`Contexts`}),(!l.local||l.workspace!==!1)&&(0,Q.jsx)(Ds,{section:`workspaces`,icon:(0,Q.jsx)(Ge,{className:`w-5 h-5`}),label:`Workspaces`}),(!l.local||l.agent)&&(0,Q.jsx)(Ds,{section:`agents`,icon:(0,Q.jsx)(Ne,{className:`w-5 h-5`}),label:`Agents`}),(0,Q.jsx)(Ds,{section:`apps`,icon:(0,Q.jsx)(it,{className:`w-5 h-5`}),label:`Apps`}),(!l.local||l.workspace!==!1)&&(0,Q.jsx)(Os,{path:`/roles`,section:null,icon:(0,Q.jsx)(Pt,{className:`w-5 h-5`}),label:`Roles`}),c&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`w-6 h-px bg-border my-2`}),(0,Q.jsx)(Os,{path:`/admin/users`,icon:(0,Q.jsx)(te,{className:`w-5 h-5`}),label:`All Users`}),(0,Q.jsx)(Os,{path:`/admin/logs`,icon:(0,Q.jsx)(Ue,{className:`w-5 h-5`}),label:`Server Logs`}),(0,Q.jsx)(Os,{path:`/admin/workspaces`,icon:(0,Q.jsx)(Ie,{className:`w-5 h-5`}),label:`All Workspaces`}),(0,Q.jsx)(Os,{path:`/admin/agents`,icon:(0,Q.jsx)(Ne,{className:`w-5 h-5`}),label:`All Agents`}),(0,Q.jsx)(Os,{path:`/admin/roles`,icon:(0,Q.jsx)(Pt,{className:`w-5 h-5`}),label:`All Roles`})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-1 py-2 shrink-0`,children:[(0,Q.jsx)(`div`,{className:`w-6 h-px bg-border mb-2`}),(0,Q.jsx)(ys,{}),(0,Q.jsxs)(xs,{children:[(0,Q.jsx)(Ss,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,onClick:u,"aria-label":r.t1Open?`Close toolbox`:`Open toolbox`,className:G(`flex items-center justify-center w-10 h-10 rounded-lg transition-colors`,r.t1Open?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`),children:(0,Q.jsx)(ve,{className:`w-5 h-5`})})}),(0,Q.jsx)(Cs,{side:`right`,sideOffset:8,children:`Toolbox`})]}),!l.local&&(0,Q.jsx)(Os,{path:`/settings`,section:`settings`,icon:(0,Q.jsx)(ut,{className:`w-5 h-5`}),label:`Settings`}),(0,Q.jsxs)(xs,{children:[(0,Q.jsx)(Ss,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":e.user?.email?`Profile: ${e.user.email}`:`Profile`,onClick:()=>o(`/home`),className:`flex items-center justify-center w-10 h-10 rounded-lg hover:bg-accent/50 transition-colors`,children:(0,Q.jsx)(ws,{className:`h-7 w-7 touch-target`,children:(0,Q.jsx)(Es,{className:`text-[10px] bg-muted`,children:e.user?.email?(e=>e.split(`@`)[0].split(`.`).map(e=>e.charAt(0).toUpperCase()).join(``).slice(0,2))(e.user.email):`U`})})})}),(0,Q.jsx)(Cs,{side:`right`,sideOffset:8,children:e.user?.email?.split(`@`)[0]||`Profile`})]}),(0,Q.jsxs)(xs,{children:[(0,Q.jsx)(Ss,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Log out`,onClick:d,className:`flex items-center justify-center w-10 h-10 rounded-lg text-destructive hover:bg-destructive/10 transition-colors`,children:(0,Q.jsx)(Je,{className:`w-5 h-5`})})}),(0,Q.jsx)(Cs,{side:`right`,sideOffset:8,children:`Logout`})]})]})]})]})}function js(){let{goBack:e}=ca();return(0,Q.jsx)(`button`,{type:`button`,onClick:e,"aria-label":`Back to previous view`,title:`Back to previous view`,className:`-ml-2 mr-1 flex h-11 w-11 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-accent md:hidden`,children:(0,Q.jsx)(Ze,{className:`h-5 w-5`})})}var Ms=[{id:`productivity`,label:`Productivity`},{id:`creative`,label:`Creative`},{id:`media`,label:`Media & capture`},{id:`utilities`,label:`Utilities`}];function Ns(e,t){let n=t.trim().toLocaleLowerCase();return Ms.map(t=>({...t,apps:e.filter(e=>e.category===t.id&&`${e.name} ${e.description} ${e.kind} ${t.label}`.toLocaleLowerCase().includes(n)).sort((e,t)=>e.name.localeCompare(t.name)||e.id.localeCompare(t.id))})).filter(e=>e.apps.length)}function Ps(e){let t=new URL(e);if(![`http:`,`https:`].includes(t.protocol)||t.username||t.password)throw Error(`Enter an HTTP or HTTPS URL without embedded credentials.`);return t.href}function Fs({apps:e,query:t,activeId:n,onLaunch:r,onRemove:i}){let a=Ns(e,t);return(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto p-2`,children:[a.map(e=>(0,Q.jsxs)(`section`,{"aria-label":e.label,children:[(0,Q.jsx)(`h3`,{className:`px-2 py-2 text-xs font-semibold text-muted-foreground`,children:e.label}),e.apps.map(e=>{let t=e.kind===`web`?ne:e.kind===`desktop`?Fe:Bt;return(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>r(e),"aria-current":n===e.id?`page`:void 0,className:`flex min-w-0 flex-1 items-start gap-2 rounded-md p-2 text-left hover:bg-accent/50 ${n===e.id?`bg-accent`:``}`,children:[(0,Q.jsx)(t,{className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.name}),(0,Q.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.description}),(0,Q.jsx)(`span`,{className:`mt-1 block text-[10px] text-muted-foreground`,children:e.kind===`canvas`?`Canvas`:e.kind===`web`?`Web app · opens in browser`:`Desktop app`})]})]}),e.kind===`web`&&i&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>i(e),"aria-label":`Remove ${e.name}`,className:`rounded p-2 text-muted-foreground hover:bg-accent`,children:(0,Q.jsx)(je,{className:`h-3.5 w-3.5`})})]},e.id)})]},e.id)),!a.length&&(0,Q.jsx)(`p`,{role:`status`,className:`p-3 text-sm text-muted-foreground`,children:`No matching apps.`})]})}var Is=t({AppsMenu:()=>zs}),Ls=`canvas:webApps`;function Rs(){try{let e=JSON.parse(localStorage.getItem(Ls)||`[]`);return Array.isArray(e)?e.filter(e=>{if(!e||typeof e.id!=`string`||typeof e.name!=`string`||typeof e.description!=`string`||e.kind!==`web`||!Ms.some(t=>t.id===e.category))return!1;try{return typeof e.target==`string`&&!!Ps(e.target)}catch{return!1}}):[]}catch{return[]}}function zs(){let{navigateFromMenu:e}=ca(),t=h(),n=ga(),[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(Rs),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(``);(0,Z.useEffect)(()=>{let e=()=>o(Rs());return window.addEventListener(`storage`,e),window.addEventListener(`canvas:apps-changed`,e),()=>{window.removeEventListener(`storage`,e),window.removeEventListener(`canvas:apps-changed`,e)}},[]);let d=e=>{try{return localStorage.setItem(Ls,JSON.stringify(e)),o(e),window.dispatchEvent(new Event(`canvas:apps-changed`)),!0}catch{return u(`Unable to save web apps on this device.`),!1}},f=[...ha.map(e=>({id:`canvas:${e.id}`,name:e.label,description:e.description,category:e.category,kind:`canvas`,target:`/apps/${e.id}`})),...a];return(0,Q.jsxs)(`nav`,{"aria-label":`Apps`,className:`flex h-full min-h-0 flex-col`,children:[(0,Q.jsxs)(`div`,{className:`shrink-0 space-y-3 border-b p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(js,{}),(0,Q.jsx)(`h2`,{className:`flex-1 text-sm font-semibold`,children:`Apps`}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Add web app`,title:`Add web app`,onClick:()=>{c(!s),u(``)},className:`rounded p-1 hover:bg-accent`,children:(0,Q.jsx)(ue,{className:`h-4 w-4`})})]}),(0,Q.jsx)(`input`,{type:`search`,"aria-label":`Search apps`,placeholder:`Find an app…`,value:r,onChange:e=>i(e.target.value),className:`w-full rounded-md border bg-background px-2 py-1.5 text-sm`}),s&&(0,Q.jsxs)(`form`,{className:`space-y-2`,onSubmit:e=>{e.preventDefault();let t=new FormData(e.currentTarget);try{let e=String(t.get(`name`)||``).trim();if(!e)throw Error(`Enter an app name.`);let n={id:`web:${crypto.randomUUID()}`,name:e,description:``,category:t.get(`category`),kind:`web`,target:Ps(String(t.get(`url`)||``))};d([...Rs(),n])&&(c(!1),u(``))}catch(e){u(e instanceof Error?e.message:`Unable to add app.`)}},children:[(0,Q.jsx)(`input`,{name:`name`,required:!0,"aria-label":`App name`,placeholder:`App name`,className:`w-full rounded border bg-background p-1 text-sm`}),(0,Q.jsx)(`input`,{name:`url`,type:`url`,required:!0,"aria-label":`App URL`,placeholder:`https://…`,className:`w-full rounded border bg-background p-1 text-sm`}),(0,Q.jsx)(`select`,{name:`category`,"aria-label":`App category`,className:`w-full rounded border bg-background p-1 text-sm`,children:Ms.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.label},e.id))}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Saved on this device. Opens in your browser.`}),(0,Q.jsx)(`button`,{type:`submit`,className:`rounded border px-2 py-1 text-sm hover:bg-accent`,children:`Add app`})]}),l&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:l})]}),(0,Q.jsx)(Fs,{apps:f,query:r,activeId:f.find(e=>e.kind===`canvas`&&e.target===t.pathname)?.id,onLaunch:r=>{if(r.kind===`web`){window.open(Ps(r.target),`_blank`,`noopener,noreferrer`);return}let i=new URLSearchParams;if(t.pathname.startsWith(`/apps/`)){let e=new URLSearchParams(t.search);for(let t of[`context`,`workspace`,`path`,`tree`])e.has(t)&&i.set(t,e.get(t))}else n?.mode===`context`?i.set(`context`,n.contextId):n?.mode===`workspace`&&(i.set(`workspace`,n.workspaceName),i.set(`path`,n.path),i.set(`tree`,n.treeName));e(`${r.target}${i.size?`?${i}`:``}`)},onRemove:e=>{d(Rs().filter(t=>t.id!==e.id))}})]})}var Bs=220,Vs=560;function Hs({width:e,onResize:t,onDragging:n}){let r=(0,Z.useRef)(null),i=e=>t(Math.min(Vs,Math.max(Bs,e))),a=()=>{r.current=null,n?.(!1)};return(0,Q.jsx)(`div`,{role:`separator`,"aria-label":`Resize menu`,"aria-orientation":`vertical`,"aria-valuemin":Bs,"aria-valuemax":Vs,"aria-valuenow":e,tabIndex:0,title:`Drag to resize; use arrow keys to adjust; Home resets width`,className:`absolute inset-y-0 right-0 z-30 flex w-3 touch-none select-none cursor-col-resize items-center justify-center hover:bg-primary/10 focus-visible:bg-primary/10 focus-visible:outline-none [@media(pointer:coarse)]:w-6`,onPointerDown:t=>{t.button!==0||r.current||(t.preventDefault(),t.stopPropagation(),r.current={id:t.pointerId,x:t.clientX,width:e},t.currentTarget.setPointerCapture(t.pointerId),n?.(!0))},onPointerMove:e=>{r.current?.id===e.pointerId&&i(r.current.width+e.clientX-r.current.x)},onPointerUp:e=>{r.current?.id===e.pointerId&&(a(),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))},onPointerCancel:a,onLostPointerCapture:a,onDoubleClick:()=>i(280),onKeyDown:t=>{[`ArrowLeft`,`ArrowRight`,`Home`].includes(t.key)&&(t.preventDefault(),t.stopPropagation(),i(t.key===`Home`?280:e+(t.key===`ArrowRight`?1:-1)*(t.shiftKey?64:16)))},children:(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`h-10 w-1 rounded-full bg-border`})})}function Us(e,t,n,r=!0){let i=Pr(),a=h(),o=(0,Z.useRef)(null);(0,Z.useLayoutEffect)(()=>{let s=window.history.state?.idx??0,c=o.current,l=a.state?.canvasMenuBack||!!c&&(s<c.index||s===c.index&&c.backwards);if(o.current={active:t,viewKey:n,index:s,backwards:l},!r||!i||!t||!c||c.active&&c.viewKey===n)return;let u=e.current;if(!u||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let d=Number.parseFloat(getComputedStyle(u).getPropertyValue(`--motion-scale`)),f=Number.isFinite(d)?Math.max(0,d):1,p=u.animate([{transform:`translateX(${l?`-100%`:`100%`})`},{transform:`translateX(0)`}],{duration:70*f,easing:`cubic-bezier(0.2, 0, 0, 1)`});return()=>p.cancel()},[r,i,t,n,a.key,a.state,e])}function Ws(e){return[...e].sort((e,t)=>{let n=typeof e.order==`number`&&Number.isFinite(e.order)?e.order:2**53-1,r=typeof t.order==`number`&&Number.isFinite(t.order)?t.order:2**53-1;if(n!==r)return n-r;let i=e.createdAt??``,a=t.createdAt??``;return i===a?(e.name??``).localeCompare(t.name??``):i<a?-1:1})}function Gs(e,t,n){let r=[...e],[i]=r.splice(t,1);return r.splice(n,0,i),r}async function Ks(e,t){return{failed:(await Promise.allSettled(e.map((e,n)=>e.order===n?Promise.resolve():t(e,n)))).filter(e=>e.status===`rejected`).length}}function qs(e){let[t,n]=(0,Z.useState)(null),[r,i]=(0,Z.useState)(null);return{rowProps:e=>({"data-reorder-index":e}),handleProps:t=>({onPointerDown:r=>{if(r.pointerType===`mouse`&&r.button!==0)return;r.preventDefault(),r.stopPropagation();let a=r.currentTarget.closest(`[data-reorder-index]`);if(!a)return;let o=a.parentElement,s=(o?[...o.querySelectorAll(`:scope > [data-reorder-index]`)]:[a]).map(e=>({index:Number(e.dataset.reorderIndex),rect:e.getBoundingClientRect()})).filter(e=>Number.isFinite(e.index)).sort((e,t)=>e.index-t.index).map(e=>e.rect.top+e.rect.height/2),c=a.getBoundingClientRect(),l=a.cloneNode(!0);Object.assign(l.style,{position:`fixed`,left:`${c.left}px`,top:`${c.top}px`,width:`${c.width}px`,height:`${c.height}px`,margin:`0`,pointerEvents:`none`,zIndex:`100`,opacity:`0.92`,boxShadow:`0 12px 32px rgba(0,0,0,.28)`,willChange:`transform`}),document.body.appendChild(l);let u={x:r.clientX,y:r.clientY},d=t;n(t),i(t);let f={x:r.clientX,y:r.clientY},p=0,m=()=>{p=0,l.style.transform=`translate(${f.x-u.x}px, ${f.y-u.y}px) scale(1.02)`;let e=s.length;for(let t=0;t<s.length;t++)if(f.y<s[t]){e=t;break}e!==d&&(d=e,i(e))},h=e=>{f={x:e.clientX,y:e.clientY},p||=requestAnimationFrame(m)},g=()=>{window.removeEventListener(`pointermove`,h),window.removeEventListener(`pointerup`,g),window.removeEventListener(`pointercancel`,g),p&&cancelAnimationFrame(p),l.remove(),n(null),i(null),d!==t&&d!==t+1&&e(t,d>t?d-1:d)};window.addEventListener(`pointermove`,h),window.addEventListener(`pointerup`,g),window.addEventListener(`pointercancel`,g)},onClick:e=>{e.preventDefault(),e.stopPropagation()},style:{touchAction:`none`}}),insertIndex:r,draggingIndex:t,insertLineClass:(e,n)=>r===null||t===null?!1:r===e?`shadow-[0_-3px_0_0_var(--color-primary)]`:r===n&&e===n-1&&`shadow-[0_3px_0_0_var(--color-primary)]`}}function Js(e){let[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)(!1),a=(0,Z.useRef)(!1),o=(0,Z.useRef)(!1),s=(0,Z.useCallback)(async()=>{if(!o.current){o.current=!0,i(!0);try{let e=await si();n(e||[]),a.current=!0}catch(e){console.error(`Failed to fetch contexts:`,e)}finally{o.current=!1,i(!1)}}},[]),c=(0,Z.useRef)(s);(0,Z.useEffect)(()=>{c.current=s});let l=(0,Z.useCallback)(()=>{a.current=!1,s()},[s]);return(0,Z.useEffect)(()=>{e&&!a.current&&s()},[e,s]),(0,Z.useEffect)(()=>{if(!e)return;let t=()=>X.emit(`subscribe`,{channel:`context`}),r=()=>X.emit(`unsubscribe`,{channel:`context`}),i=X.on(`connect`,()=>{t(),s()});t();let o=e=>{let t=e;!t?.id||!t?.userId||n(e=>e.some(e=>e.id===t.id&&e.userId===t.userId)?e:[...e,t])},l=e=>{let t=e;!t?.id||!t?.userId||n(e=>e.map(e=>e.id===t.id&&e.userId===t.userId?{...e,...t}:e))},u=e=>{let t=e,r=t?.contextId??t?.id;r&&n(e=>e.filter(e=>e.id!==r))},d=e=>{let t=e;!t?.id||!t?.userId||n(e=>e.map(e=>e.id===t.id&&e.userId===t.userId?{...e,...t}:e))},f=()=>{a.current=!1,c.current()},p=[[`context:created`,o],[`context.created`,o],[`context:updated`,l],[`context.updated`,l],[`context:deleted`,u],[`context.deleted`,u],[`context:url:changed`,d],[`context.url.set`,d],[`context:url:set`,d],[`workspace:status:changed`,f],[`workspace.status.changed`,f]];return p.forEach(([e,t])=>X.on(e,t)),()=>{r(),i?.(),p.forEach(([e,t])=>X.off(e,t))}},[e,s]),(0,Z.useEffect)(()=>{let e=e=>{let t=e.detail;n(e=>e.filter(e=>!ai(e,t)))};return window.addEventListener(ri,e),()=>window.removeEventListener(ri,e)},[]),(0,Z.useEffect)(()=>{let e=()=>{a.current=!1,s()};return window.addEventListener(`contexts:refresh`,e),()=>window.removeEventListener(`contexts:refresh`,e)},[s]),{contexts:(0,Z.useMemo)(()=>Ws(t),[t]),isLoading:r,refresh:l}}function Ys(){let{state:e,selectEntity:t,openM2:n,closeM2:r}=ca(),a=Pr(),{contexts:o,isLoading:s}=Js(e.activeSection===`contexts`),{showToast:c}=xn(),l=m(),[u,d]=(0,Z.useState)(null),f=u&&u.base===o?u.order:o,p=e=>e.isShared===!0||e.type===`shared`,{rowProps:h,handleProps:g,draggingIndex:_,insertLineClass:v}=qs((e,t)=>{let n=Gs(f,e,t);d({base:o,order:n}),Ks(n,(e,t)=>p(e)?Promise.resolve():ui(e.id,{order:t})).then(({failed:e})=>{window.dispatchEvent(new CustomEvent(`contexts:refresh`)),e&&c({title:`Partial reorder`,description:`${e} context(s) could not be reordered`,variant:`destructive`})})}),y=e=>{t(e.id),l(`/contexts/${e.id}`)};return(0,Q.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-4 h-12 border-b border-border shrink-0`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center`,children:[(0,Q.jsx)(js,{}),(0,Q.jsx)(`span`,{className:`text-sm font-semibold`,children:`Contexts`})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{r(),l(`/contexts?create=1`)},title:`Create context`,"aria-label":`Create context`,className:`flex items-center justify-center w-6 h-6 rounded-full bg-foreground text-background hover:opacity-80 transition-opacity`,children:(0,Q.jsx)(ue,{className:`w-3.5 h-3.5`})})]}),(0,Q.jsx)(`div`,{className:`flex-1 overflow-y-auto py-2`,children:s&&o.length===0?(0,Q.jsx)(`div`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:`Loading...`}):o.length===0?(0,Q.jsx)(`div`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:`No contexts found`}):(0,Q.jsx)(`div`,{className:`space-y-1.5 px-2`,children:f.map((r,o)=>{let s=e.selectedEntityId===r.id,c=p(r),u=r.workspaceActive!==!1,d=xi(r.color);return(0,Q.jsxs)(`div`,{...h(o),"data-active":s||void 0,className:G(`group relative rounded-(--card-radius) py-2.5 pl-3 pr-7 transition-all shadow-elevation-1`,u?`cursor-pointer hover:shadow `+(s?`bg-accent shadow`:`bg-card hover:bg-accent/50`):`cursor-not-allowed opacity-50 bg-card`,v(o,f.length),_===o&&`opacity-60`),onClick:()=>u&&y(r),title:u?void 0:`Workspace "${r.workspaceName}" is not active`,children:[c?(0,Q.jsx)(`div`,{className:G(`absolute inset-y-0 right-0 w-4 rounded-r-(--card-radius)`,!d&&`bg-muted`),style:d?{backgroundColor:d}:void 0}):(0,Q.jsx)(`button`,{type:`button`,...g(o),title:`Drag to reorder`,"aria-label":`Drag to reorder`,className:G(`absolute inset-y-0 right-0 flex w-4 cursor-grab items-center justify-center rounded-r-(--card-radius) active:cursor-grabbing`,!d&&`bg-muted`),style:d?{backgroundColor:d}:void 0,children:(0,Q.jsx)(Te,{className:G(`h-3.5 w-3.5`,Si(d))})}),(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(i,{icon:r.icon||`ph:stack-fill`,width:16,height:16,color:d,className:G(`mt-0.5 shrink-0`,!d&&`text-muted-foreground`)}),(0,Q.jsx)(`span`,{className:`text-sm font-medium truncate flex-1`,children:r.name||r.id}),c&&(0,Q.jsx)(`span`,{className:`rounded-full bg-info/10 px-1.5 py-0.5 text-[9px] text-info shrink-0`,children:`Shared`}),u&&(0,Q.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),t(r.id),n(`detail`,r.id)},className:`reveal-on-hover shrink-0 mt-0.5`,title:`Switch context URL`,children:(0,Q.jsx)(Be,{className:`w-3.5 h-3.5 text-muted-foreground hover:text-foreground`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),t(r.id),a?n(`settings`,r.id):l(`/contexts/${r.id}/settings/general`)},className:`reveal-on-hover shrink-0 mt-0.5`,title:`Settings`,children:(0,Q.jsx)(ut,{className:`w-3.5 h-3.5 text-muted-foreground hover:text-foreground`})})]}),r.name&&(0,Q.jsx)(`div`,{className:`text-[10px] text-muted-foreground/60 truncate font-mono`,children:r.id}),(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground truncate mt-0.5`,children:r.url||`/`}),r.ownerEmail&&(0,Q.jsx)(`div`,{className:`text-[10px] text-muted-foreground truncate mt-0.5`,children:r.ownerEmail})]},`${r.userId||`u`}-${r.id}`)})})})]})}function Xs({title:e,onBack:t,action:n,className:r,icon:a,accentColor:o}){let{closeM1:s}=ca(),c=xi(o);return(0,Q.jsxs)(`div`,{className:G(`flex items-center h-12 px-2 border-b border-border shrink-0 gap-1`,r),style:{borderBottomWidth:4,...c?{borderBottomColor:c}:{}},children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center gap-0.5 h-8 rounded px-1 hover:bg-accent/50 text-muted-foreground hover:text-foreground transition-colors flex-1 min-w-0`,title:`Back`,"aria-label":`Back to previous view`,children:[(0,Q.jsx)(Ee,{className:`w-4 h-4 shrink-0`}),a&&(0,Q.jsx)(i,{icon:a,width:16,height:16,color:c,className:G(`mr-1 shrink-0`,!c&&`text-muted-foreground`)}),(0,Q.jsx)(`span`,{className:`text-sm font-semibold truncate`,children:e})]}),n&&(0,Q.jsx)(`div`,{className:`shrink-0`,children:n}),(0,Q.jsx)(`button`,{type:`button`,onClick:s,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground`,title:`Close menu`,"aria-label":`Close menu`,children:(0,Q.jsx)(z,{className:`w-4 h-4`})})]})}function Zs(e,t,n){let r=e.indexOf(n);if(r<0)return new Set;let i=t===null?-1:e.indexOf(t);return new Set(i<0?[n]:e.slice(Math.min(i,r),Math.max(i,r)+1))}function Qs(e){let t=[...e];return t.filter(e=>!t.some(t=>t!==e&&e.startsWith(`${t}/`)))}var $s=e(s(),1),ec=180;function tc({x:e,y:t,current:n,onChange:r,onClose:a}){mi(a);let[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)([]),[u,d]=(0,Z.useState)({q:``,list:[]}),[f,p]=(0,Z.useState)(!0),m=(0,Z.useRef)(null),h=(0,Z.useRef)({name:``,t:0}),g=(e,t)=>{r({icon:e}),h.current.name===e&&t-h.current.t<350&&a(),h.current={name:e,t}};(0,Z.useEffect)(()=>{m.current?.focus()},[]),(0,Z.useEffect)(()=>{let e=!0;return _i().then(t=>{e&&(l(t),p(!1))}),()=>{e=!1}},[]),(0,Z.useEffect)(()=>{let e=o.trim();if(!e)return;let t=setTimeout(()=>{vi(e).then(t=>{d({q:e,list:t})})},250);return()=>clearTimeout(t)},[o]);let _=o.trim(),v=u.q===_,y=_!==``&&!v,b=(0,Z.useMemo)(()=>(_?v?u.list:[]:c).slice(0,ec),[_,v,u.list,c]),x=(0,Z.useRef)(null),[S,C]=(0,Z.useState)({x:e,y:t});return(0,Z.useLayoutEffect)(()=>{let n=x.current;if(!n)return;let r=()=>{let{width:r,height:i}=n.getBoundingClientRect();C({x:Math.max(8,Math.min(e,window.innerWidth-r-8)),y:Math.max(8,Math.min(t,window.innerHeight-i-8))})};r();let i=new ResizeObserver(r);return i.observe(n),window.addEventListener(`resize`,r),()=>{i.disconnect(),window.removeEventListener(`resize`,r)}},[e,t]),(0,$s.createPortal)((0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:a}),(0,Q.jsxs)(`div`,{ref:x,className:`fixed z-50 w-[270px] max-w-[90vw] rounded-md border bg-popover p-2 shadow-elevation-4`,style:{left:S.x,top:S.y},children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-1 pb-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:`Icon & color`}),(0,Q.jsx)(`button`,{type:`button`,onClick:a,className:`text-muted-foreground hover:text-foreground`,children:(0,Q.jsx)(z,{className:`w-3.5 h-3.5`})})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 px-1 pb-2`,children:[gi.map(e=>(0,Q.jsx)(`button`,{type:`button`,title:e,onClick:()=>r({color:e}),className:G(`w-5 h-5 rounded-full border transition-transform hover:scale-110`,n.color===e?`ring-2 ring-offset-1 ring-foreground`:`border-border`),style:{backgroundColor:e}},e)),(0,Q.jsx)(`button`,{type:`button`,title:`No color`,onClick:()=>r({color:void 0}),className:G(`w-5 h-5 rounded-full border flex items-center justify-center text-muted-foreground hover:scale-110 transition-transform`,!n.color&&`ring-2 ring-offset-1 ring-foreground`),children:(0,Q.jsx)(z,{className:`w-3 h-3`})}),(0,Q.jsx)(`label`,{title:`Custom color`,className:G(`relative w-5 h-5 rounded-full border border-border cursor-pointer hover:scale-110 transition-transform overflow-hidden`,n.color&&!gi.includes(n.color)&&`ring-2 ring-offset-1 ring-foreground`),style:{background:n.color&&!gi.includes(n.color)?n.color:`conic-gradient(from 0deg, #ef4444, #eab308, #22c55e, #06b6d4, #6366f1, #ec4899, #ef4444)`},children:(0,Q.jsx)(`input`,{type:`color`,value:n.color??`#3b82f6`,onChange:e=>r({color:e.target.value}),className:`absolute inset-0 opacity-0 cursor-pointer`})})]}),(0,Q.jsx)(`input`,{ref:m,value:o,onChange:e=>s(e.target.value),placeholder:`Search icons…`,className:`w-full mb-2 rounded-sm border bg-background px-2 py-1 text-xs outline-none focus:ring-1 focus:ring-primary`}),f||y?(0,Q.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-8 text-xs text-muted-foreground`,children:[(0,Q.jsx)(nt,{className:`w-4 h-4 animate-spin`}),` `,y?`Searching…`:`Loading icons…`]}):(0,Q.jsxs)(`div`,{className:`grid grid-cols-7 gap-0.5 max-h-[200px] overflow-y-auto`,children:[(0,Q.jsx)(`button`,{type:`button`,title:`No icon`,onClick:()=>r({icon:void 0}),className:G(`aspect-square flex items-center justify-center rounded-sm hover:bg-accent text-muted-foreground`,!n.icon&&`bg-accent ring-1 ring-primary`),children:(0,Q.jsx)(z,{className:`w-4 h-4`})}),b.map(e=>(0,Q.jsx)(`button`,{type:`button`,title:e.replace(/^[^:]+:/,``).replace(`-fill`,``),onClick:t=>g(e,t.timeStamp),className:G(`aspect-square flex items-center justify-center rounded-sm hover:bg-accent`,n.icon===e&&`bg-accent ring-1 ring-primary`),children:(0,Q.jsx)(i,{icon:e,width:18,height:18,color:n.color})},e))]}),!f&&!y&&b.length===0&&(0,Q.jsxs)(`div`,{className:`px-1 py-3 text-center text-[11px] text-muted-foreground`,children:[`No icons match “`,o,`”`]})]})]}),document.body)}var nc=[{id:`cards`,name:`Cards`,description:`Nested cards with connector lines. Each level indents.`},{id:`accordion-mobile`,name:`Accordion on phones (beta)`,description:`Experimental. Full-width accordion rows on a phone, cards on wider screens.`},{id:`accordion`,name:`Accordion (beta)`,description:`Experimental. Full-width rows at every depth; a depth rail, tint and colour swatch replace the indent, and open parents stick to the top while you scroll.`}],rc=`canvas:treeStyle`;function ic(){try{let e=localStorage.getItem(rc);return e===`accordion`||e===`accordion-mobile`?e:`cards`}catch{return`cards`}}var ac=ic(),oc=new Set;function sc(){return ac}function cc(e){try{e===`cards`?localStorage.removeItem(rc):localStorage.setItem(rc,e)}catch{}ac=e;for(let e of oc)e()}function lc(e){oc.add(e);let t=t=>{(t.key===rc||t.key===null)&&(ac=ic(),e())};return window.addEventListener(`storage`,t),()=>{oc.delete(e),window.removeEventListener(`storage`,t)}}function uc(){return(0,Z.useSyncExternalStore)(lc,sc,()=>`cards`)}function dc(){let e=uc(),t=Pr();return e===`accordion`||e===`accordion-mobile`&&t}var fc=22,pc=44,mc=4;function hc(e,t){if(!t)return null;let n=String(e||``).split(`/`).filter(Boolean);return n[0]===`workspace`&&n[1]===`git`?null:n[0]===`workspace`&&n.length>=2?{address:`workspace:${n[1]}`,key:n.slice(2).join(`/`)}:n[0]===`device`&&n.length>=3?{address:n[2],key:n.slice(3).join(`/`)}:n[0]===`file`&&n.length>=2?{address:n[1],key:n.slice(2).join(`/`)}:null}function gc(e,t){return!t||fr(e)!==null}var _c=e=>Array.from(e.dataTransfer.types).includes(`application/json`);function vc(e,t){if(!t)return null;let n=String(e||``).split(`/`).filter(Boolean);return n[0]===`workspace`&&n[1]===`git`?n[2]||null:n[0]===`workspace`&&n.length>=2?`workspace:${n[1]}`:n[0]===`device`?n.length>=3?n[2]:null:n.length>=2?n[1]:null}function yc({x:e,y:t,node:n,path:r,isBackendsTree:i,isDirectoryTree:a,backends:o,onClose:s,onShowContent:c,onOpenToSide:l,sourceLayer:u,targetLayers:d,clipboard:f,onStartInlineCreate:p,onChangeIcon:m,onNewCanvas:h,onShareCanvas:g,onRemove:_,onRename:v,onExportSubtree:y,onImportSubtree:b,onImportDocuments:x,onExportDocuments:S,onLock:C,onUnlock:w,onDestroy:T,onMerge:E,onSubtract:D,onMergeDown:O,onSubtractDown:k,onResyncBackend:j,canResyncBackend:M,onAddRule:N,onAddStoreRule:P,onStoragePolicy:F,onRenameBackendFolder:ee,onDeleteBackendFolder:te,onRestoreTrash:ne,onDiscardTrash:re,onCopy:ie,onCut:ae,onPaste:I,pastedDocumentIds:R,onPasteDocuments:ce,isPinned:z,onTogglePin:le}){let V=u&&d.size>0&&u.path===r,de=!i&&(O||k)&&r!==`/`&&n.type!==`canvas`&&r.split(`/`).filter(Boolean).length>1,pe=u&&d.size>0&&(u.path===r||d.has(r)),me=async e=>{s();try{await e()}catch(e){alert(e instanceof Error?e.message:String(e))}},H=(e,t,n,r=!1)=>(0,Q.jsxs)(`button`,{type:`button`,className:G(`flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-accent rounded-sm text-left`,r&&`text-destructive hover:bg-destructive/10`),onClick:()=>me(n),children:[e,t]});return i&&n.metadata?.backendTrash?(0,Q.jsxs)(wn,{x:e,y:t,onClose:s,className:`min-w-44 rounded-md border bg-popover p-1 shadow-elevation-3`,children:[c&&H((0,Q.jsx)(je,{className:`h-3 w-3`}),`Open Trash`,async()=>c(r)),r!==`/Trash`&&ne&&H((0,Q.jsx)(xe,{className:`h-3 w-3`}),`Restore original paths`,()=>ne(r)),r!==`/Trash`&&re&&H((0,Q.jsx)(je,{className:`h-3 w-3`}),`Empty Trash`,()=>re(r),!0)]}):(0,Q.jsxs)(wn,{x:e,y:t,onClose:s,className:`min-w-[11rem] rounded-md border bg-popover p-1 shadow-elevation-3`,children:[c&&H((0,Q.jsx)($e,{className:`w-3 h-3`}),`Show layer content`,async()=>{c(r,n.id||void 0)}),l&&H((0,Q.jsx)($e,{className:`w-3 h-3`}),`Open to the side`,async()=>{l(r)}),(c||l)&&(0,Q.jsx)(`div`,{className:`my-1 h-px bg-border`}),n.type===`canvas`&&g&&H((0,Q.jsx)(bt,{className:`w-3 h-3`}),`Share canvas`,async()=>{await g(r)}),n.type===`canvas`&&g&&(0,Q.jsx)(`div`,{className:`my-1 h-px bg-border`}),j&&(M?.(r)??!!vc(r,i))&&(0,Q.jsxs)(Q.Fragment,{children:[H((0,Q.jsx)(fe,{className:`w-3 h-3`}),`Refresh backend`,async()=>{await j(r)}),(0,Q.jsx)(`div`,{className:`my-1 h-px bg-border`})]}),i&&vc(r,i)&&(N||P)&&(0,Q.jsxs)(Q.Fragment,{children:[N&&H((0,Q.jsx)(oe,{className:`w-3 h-3`}),`Auto-Link documents to…`,async()=>{N(r)}),P&&hc(r,i)&&H((0,Q.jsx)(Jt,{className:`w-3 h-3`}),`Create storage rule…`,async()=>{P(r)}),(0,Q.jsx)(`div`,{className:`my-1 h-px bg-border`})]}),!i&&(P||F)&&r!==`/`&&(0,Q.jsxs)(Q.Fragment,{children:[P&&H((0,Q.jsx)(Jt,{className:`w-3 h-3`}),`Create rule…`,async()=>{P(r)}),P&&H((0,Q.jsx)(Ve,{className:`w-3 h-3`}),`Create download rule…`,async()=>{P(r,`download`)}),F&&n.type!==`canvas`&&H((0,Q.jsx)(wt,{className:`w-3 h-3`}),`Storage policy…`,async()=>{F(r)}),(0,Q.jsx)(`div`,{className:`my-1 h-px bg-border`})]}),(!i||hc(r,i))&&(0,Q.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-accent rounded-sm text-left`,onClick:()=>{p(r),s()},children:[(0,Q.jsx)(ue,{className:`w-3 h-3`}),`New folder here`]}),ee&&hc(r,i)?.key&&H((0,Q.jsx)(A,{className:`w-3 h-3`}),`Rename folder`,async()=>{let e=r.split(`/`).pop()||``,t=prompt(`New folder name:`,e);!t||t===e||await ee(r,t)}),te&&i&&cr(r,o)&&H((0,Q.jsx)(je,{className:`w-3 h-3`}),`Delete from backend`,async()=>{confirm(`Delete folder "${r.split(`/`).pop()}" and its contents from the backend?`)&&await te(r)},!0),h&&!i&&(0,Q.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-accent rounded-sm text-left`,onClick:()=>{h(r),s()},children:[(0,Q.jsx)(Wt,{className:`w-3 h-3 text-primary`}),`New canvas here…`]}),r!==`/`&&le&&H(z?(0,Q.jsx)(B,{className:`w-3 h-3`}):(0,Q.jsx)(L,{className:`w-3 h-3`}),z?`Unpin`:`Pin`,async()=>{await le()}),r!==`/`&&m&&(0,Q.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-accent rounded-sm text-left`,onClick:()=>{m(),s()},children:[(0,Q.jsx)(Ae,{className:`w-3 h-3`}),`Change icon`]}),r!==`/`&&!n.locked&&v&&!i&&H((0,Q.jsx)(A,{className:`w-3 h-3`}),`Rename`,async()=>{let e=r.split(`/`).pop()||``,t=prompt(`New name:`,e);!t||t===e||await v(r,t)}),(0,Q.jsx)(`div`,{className:`my-1 h-px bg-border`}),H((0,Q.jsx)(Rt,{className:`w-3 h-3`}),`Copy`,async()=>ie(r)),!i&&H((0,Q.jsx)(Ht,{className:`w-3 h-3`}),`Cut`,async()=>ae(r)),f&&!i&&H((0,Q.jsx)(pt,{className:`w-3 h-3`}),`Paste (${f.mode})`,async()=>I(r)),R&&R.length>0&&ce&&gc(r,i)&&H((0,Q.jsx)(pt,{className:`w-3 h-3`}),i?`Move ${R.length} message(s) here`:`Paste ${R.length} document(s)`,async()=>{await ce(r,R)}),x&&H((0,Q.jsx)(se,{className:`w-3 h-3`}),`Import documents…`,()=>x(r)),S&&H((0,Q.jsx)(Ve,{className:`w-3 h-3`}),`Export documents…`,()=>S(r)),(y||b)&&(0,Q.jsx)(`div`,{className:`my-1 h-px bg-border`}),y&&n.type!==`canvas`&&H((0,Q.jsx)(Ve,{className:`w-3 h-3`}),`Export subtree…`,()=>y(r)),b&&!i&&n.type!==`canvas`&&H((0,Q.jsx)(se,{className:`w-3 h-3`}),`Import subtree here…`,()=>b(r)),!i&&r!==`/`&&!n.locked&&_&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`my-1 h-px bg-border`}),H((0,Q.jsx)(je,{className:`w-3 h-3`}),`Remove`,async()=>{confirm(`Remove "${r}"${a?` and all children`:``}?`)&&await _(r,a)},!0),!a&&H((0,Q.jsx)(je,{className:`w-3 h-3`}),`Remove recursive`,async()=>{confirm(`Remove "${r}" and all children?`)&&await _(r,!0)},!0)]}),!i&&(C||w||T)&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`my-1 h-px bg-border`}),n.locked?w&&H((0,Q.jsx)(Nt,{className:`w-3 h-3`}),`Unlock layer`,async()=>{await w(n.id)}):C&&H((0,Q.jsx)(mt,{className:`w-3 h-3`}),`Lock layer`,async()=>{await C(n.id)}),n.locked&&n.lockedBy&&n.lockedBy.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`px-3 pt-1 pb-0.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:`Locked by`}),n.lockedBy.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-1 text-xs`,children:[(0,Q.jsx)(`span`,{className:`truncate`,title:e,children:e}),w&&(0,Q.jsx)(`button`,{type:`button`,title:`Remove lock held by ${e}`,className:`shrink-0 text-muted-foreground hover:text-destructive`,onClick:()=>me(async()=>{await w(n.id,e)}),children:(0,Q.jsx)(Nt,{className:`w-3 h-3`})})]},e))]}),r!==`/`&&!n.locked&&T&&H((0,Q.jsx)(je,{className:`w-3 h-3`}),`Destroy layer`,async()=>{confirm(`Permanently destroy layer "${n.label||n.name}" and its bitmap?`)&&await T(n.id)},!0)]}),de&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`my-1 h-px bg-border`}),O&&H((0,Q.jsx)(_t,{className:`w-3 h-3`}),`Merge down (into ancestors)`,async()=>{confirm(`Merge "${n.label||n.name}" into every layer above it on\n${r}\n\nAfter this, ${r} lists its documents.`)&&await O(r)}),k&&H((0,Q.jsx)(qe,{className:`w-3 h-3`}),`Subtract from ancestors`,async()=>{confirm(`Remove "${n.label||n.name}"'s documents from every layer above it on\n${r}\n\nUndo of "Merge down". Documents an ancestor holds for other reasons are removed from it too.`)&&await k(r)})]}),V&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`my-1 h-px bg-border`}),E&&H((0,Q.jsx)(Bt,{className:`w-3 h-3`}),`Merge this layer into ${d.size} selected`,async()=>{confirm(`Merge "${r}" (source) INTO:\n${Array.from(d.keys()).join(`
|
|
3
3
|
`)}\n\nThe selected layers gain this layer's documents. This layer is unchanged.`)&&await E(n.id,Array.from(d.values()))}),D&&H((0,Q.jsx)(Bt,{className:`w-3 h-3`}),`Subtract this layer from ${d.size} selected`,async()=>{confirm(`Subtract "${r}" (source) FROM:\n${Array.from(d.keys()).join(`
|
|
4
4
|
`)}\n\nThe selected layers lose this layer's documents. This layer is unchanged.`)&&await D(n.id,Array.from(d.values()))})]}),pe&&!V&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`my-1 h-px bg-border`}),(0,Q.jsxs)(`div`,{className:`px-3 py-1.5 text-[10px] text-muted-foreground italic`,children:[`This is a target. Right-click the source (`,u?.path,`) to merge/subtract`]})]})]})}function bc({onConfirm:e,onCancel:t,placeholder:n=`folder name…`}){let r=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{r.current?.focus()},[]);let i=()=>{let n=r.current?.value.trim()??``;n?e(n):t()};return(0,Q.jsxs)(`div`,{className:`flex min-h-11 items-center gap-2 rounded-(--card-radius) px-3 py-2.5 bg-card ring-1 ring-primary/50 shadow-elevation-3 text-sm font-medium`,children:[(0,Q.jsx)(k,{className:`w-4 h-4 opacity-0 shrink-0`}),(0,Q.jsx)(`input`,{ref:r,className:`flex-1 bg-transparent outline-none min-w-0 text-sm font-medium placeholder:font-normal placeholder:text-muted-foreground`,placeholder:n,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),i()),e.key===`Escape`&&t()},onBlur:i})]})}function xc(e,t){return e===`/`?`/${t}`:`${e}/${t}`}function Sc(e,t,n){let r=xc(t,e.name);return r.toLowerCase().includes(n)||(e.label||``).toLowerCase().includes(n)?!0:e.children?.some(e=>Sc(e,r,n))??!1}function Cc({expansionState:e,node:t,parentPath:n,depth:r,isLast:a,selectedPath:o,pendingPath:s,contentPath:c,readOnly:l,sourceLayer:u,targetLayers:d,clipboard:f,searchQuery:p,inlineCreateParent:m,onSelect:h,onAltSelect:g,selectedPaths:_,onRangeSelect:v,onShowContent:y,onCtrl:b,onCtxMenu:x,onConfirmCreate:S,onCancelCreate:C,onOpenPicker:w,styleOverrides:T,dragOverPath:E,isCopyDrag:D,onDragStart:O,onDragEnter:A,onDragOver:j,onDragLeave:M,onDragEnd:N,onDrop:P,resyncingPaths:F,policyBadgeFor:ee,removingPaths:te,accordion:ne=!1,trail:ie=[]}){let ae=Tr(),I=xc(n,t.name),L=ee?.(I)??null,R=T.get(I)??bi(t),[oe,se]=(0,Z.useState)(()=>e?.get(t.id||I)??(o!==`/`&&(o===I||o.startsWith(I+`/`)))),[ce,z]=(0,Z.useState)(o);if(ce!==o&&(z(o),o!==`/`&&o.startsWith(I+`/`)&&se(!0)),(0,Z.useEffect)(()=>{e?.set(t.id||I,oe)},[e,t.id,I,oe]),p&&!Sc(t,n,p))return null;let B=oe||m===I||p.length>0,le=t.children&&t.children.length>0,V=o===I||_.has(I),ue=s===I,de=u?.path===I,pe=d.has(I),me=t.type===`canvas`,H=e=>{if(e.shiftKey){v(I,e);return}if(e.ctrlKey||e.metaKey){b(I,t.id);return}if(e.altKey&&g){g(I);return}h(I)},he=e=>{!le||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||e.target.closest(`button, input, textarea, select, a, [contenteditable="true"]`)||(e.preventDefault(),e.stopPropagation(),se(e=>!e))},ge=[...ie].reverse().find(Boolean)??null,_e=R.color||ge,ve=ne?[...ie,_e]:ie,U=o!==`/`&&o.startsWith(I+`/`),ye=!de&&!pe,be=ye&&V,xe=(e,t)=>`color-mix(in oklab, ${e} ${t}%, var(--card))`,W=e=>`color-mix(in oklab, currentColor ${e}%, transparent)`,Se=Math.min(r,5),Ce=B&&!!le,we=ye&&!be&&!t.locked&&Ce,Te=Math.min(3+Se*2+(U?4:0)+(ue?3:0),18),Ee=be?`var(--primary)`:de?xe(`var(--info)`,12):pe?xe(`var(--warning)`,12):we?`var(--accent)`:xe(`var(--muted-foreground)`,Te),De=be?`text-primary-foreground`:we?`text-accent-foreground`:`text-foreground`,Oe=ne&&B&&le&&r<mc,ke=(0,Q.jsxs)(`div`,{"data-tree-path":I,"data-selected":_.has(I)||void 0,"data-active":V||void 0,className:G(`group relative flex cursor-pointer select-none items-stretch overflow-hidden text-sm`,`after:pointer-events-none after:absolute after:inset-0 after:bg-foreground/0 after:transition-colors hover:after:bg-foreground/[0.07]`,De,de&&`ring-1 ring-inset ring-info/40`,pe&&!de&&`ring-1 ring-inset ring-warning/40`,E===I&&!l&&!D&&`ring-2 ring-inset ring-info`,E===I&&!l&&D&&`ring-2 ring-inset ring-success`),style:{height:pc,background:Ee,borderBottom:`1px solid var(--border)`,...Oe?{position:`sticky`,top:r*pc,zIndex:20-r}:{}},draggable:!l&&!t.metadata?.backendTrash,onClick:H,onDoubleClick:he,...l?{}:ae,onContextMenu:e=>{l||(e.preventDefault(),x(e,I,t))},onDragStart:e=>{l||O(I,e)},onDragEnter:e=>{l||A(I,e)},onDragOver:e=>{l||j(I,e)},onDragLeave:e=>M(I,e),onDragEnd:()=>N(),onDrop:e=>{l||P(I,e)},children:[ie.length>0&&(0,Q.jsx)(`span`,{className:`flex shrink-0 gap-px`,"aria-hidden":!0,children:ie.map((e,t)=>(0,Q.jsx)(`span`,{className:`w-[3px]`,style:{background:e?`color-mix(in oklab, ${e} 35%, var(--border))`:`var(--border)`}},t))}),(()=>{let e=R.color?{background:R.color}:ge?{background:`color-mix(in oklab, ${ge} 45%, transparent)`}:{background:W(10)},n=(0,Q.jsx)(i,{icon:R.icon||(me?`ph:squares-four-fill`:`ph:folder-fill`),width:18,height:18,className:G(`shrink-0`,R.color?Si(R.color):be?`text-primary-foreground`:we?`text-current`:`text-foreground/80`)}),r=`flex w-10 shrink-0 items-center justify-center`;return w?(0,Q.jsx)(`button`,{type:`button`,className:r,style:e,title:`Change icon`,onClick:e=>{$t()||(e.stopPropagation(),w(e,I,t))},onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),w(e,I,t)},children:n}):(0,Q.jsx)(`span`,{className:r,style:e,children:n})})(),(0,Q.jsx)(`span`,{className:G(`min-w-0 flex-1 self-center truncate px-2.5`,V||U||Ce?`font-semibold`:`font-medium`),title:t.description||void 0,children:t.label||t.name}),te.has(I)&&(0,Q.jsx)(fe,{className:`mr-1 h-3.5 w-3.5 shrink-0 animate-spin self-center`,"aria-label":te.get(I)}),F?.has(I)&&(0,Q.jsx)(fe,{className:`mr-1 h-3.5 w-3.5 shrink-0 animate-spin self-center opacity-70`,"aria-label":`Indexing`}),L&&(0,Q.jsx)(wt,{className:`mr-1 h-3 w-3 shrink-0 self-center text-muted-foreground`,"aria-label":L,children:(0,Q.jsx)(`title`,{children:L})}),!l&&(0,Q.jsx)(`button`,{type:`button`,className:`reveal-on-hover shrink-0 self-center rounded p-1 hover:bg-foreground/10`,onClick:e=>{e.stopPropagation(),x(e,I,t)},children:(0,Q.jsx)(lt,{className:`h-4 w-4`})}),(0,Q.jsx)(`button`,{type:`button`,className:G(`relative z-[1] flex w-12 shrink-0 cursor-pointer items-center justify-center transition-colors`,`bg-[color-mix(in_oklab,currentColor_9%,transparent)] hover:bg-[color-mix(in_oklab,currentColor_24%,transparent)] active:bg-[color-mix(in_oklab,currentColor_32%,transparent)]`,!le&&m!==I&&`invisible`),style:{borderLeft:`1px solid ${W(16)}`},"aria-label":B?`Collapse`:`Expand`,"aria-expanded":B,title:B?`Collapse`:`Expand`,onClick:e=>{e.stopPropagation(),se(e=>!e)},children:B?(0,Q.jsx)(re,{className:`h-5 w-5`,strokeWidth:2.25}):(0,Q.jsx)(k,{className:`h-5 w-5`,strokeWidth:2.25})})]});return(0,Q.jsxs)(`div`,{className:`relative`,children:[ne?ke:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`pointer-events-none absolute top-0 w-px bg-border`,style:{left:`-${fc/2}px`,...a?{height:`1.375rem`}:{bottom:0}}}),(0,Q.jsx)(`div`,{className:`pointer-events-none absolute top-[1.375rem] h-px bg-border`,style:{left:`-${fc/2}px`,width:`${fc/2}px`}}),(0,Q.jsxs)(`div`,{"data-tree-path":I,"data-selected":_.has(I)||void 0,"data-active":V||void 0,className:G(`group relative flex min-h-11 items-center gap-2 rounded-(--card-radius) px-3 py-2.5 cursor-pointer transition-all select-none overflow-hidden`,`shadow-elevation-3 hover:shadow-elevation-4 text-sm`,`before:absolute before:left-0 before:top-0 before:bottom-0 before:w-1.5 before:transition-colors`,de&&`ring-1 ring-info/40 bg-info/10 before:bg-info`,pe&&!de&&`ring-1 ring-warning/40 bg-warning/10 before:bg-warning`,!de&&!pe&&V&&!t.locked&&`bg-primary/[0.08] hover:bg-primary/[0.12] before:bg-primary`,!de&&!pe&&V&&t.locked&&`bg-warning/15 hover:bg-warning/20 before:bg-primary`,!de&&!pe&&!V&&ue&&`bg-primary/[0.03] before:bg-transparent`,!de&&!pe&&!V&&!ue&&!t.locked&&`bg-card hover:bg-primary/[0.04] before:bg-transparent`,!de&&!pe&&!V&&t.locked&&`bg-warning/15 hover:bg-warning/20 before:bg-warning`,E===I&&!l&&!D&&`ring-2 ring-info bg-info-subtle/50`,E===I&&!l&&D&&`ring-2 ring-success bg-success-subtle/50`),style:{borderRight:R.color?`4px solid ${R.color}`:`4px solid transparent`},draggable:!l&&!t.metadata?.backendTrash,onClick:H,onDoubleClick:he,...l?{}:ae,onContextMenu:e=>{l||(e.preventDefault(),x(e,I,t))},onDragStart:e=>{l||O(I,e)},onDragEnter:e=>{l||A(I,e)},onDragOver:e=>{l||j(I,e)},onDragLeave:e=>M(I,e),onDragEnd:()=>N(),onDrop:e=>{l||P(I,e)},children:[(0,Q.jsx)(`button`,{type:`button`,className:G(`shrink-0 text-muted-foreground hover:text-foreground`,!le&&m!==I&&`invisible`),"aria-label":B?`Collapse`:`Expand`,"aria-expanded":B,onClick:e=>{e.stopPropagation(),se(e=>!e)},children:B?(0,Q.jsx)(re,{className:`w-4 h-4`}):(0,Q.jsx)(k,{className:`w-4 h-4`})}),(()=>{let e=(0,Q.jsx)(i,{icon:R.icon||(me?`ph:squares-four-fill`:`ph:folder-fill`),width:16,height:16,color:R.color||void 0,className:G(`shrink-0`,!R.color&&(me?`text-primary`:`text-muted-foreground`))});return w?(0,Q.jsx)(`button`,{type:`button`,className:`shrink-0 rounded p-0.5 -m-0.5 hover:bg-muted-foreground/10 touch-target`,title:`Change icon`,onClick:e=>{$t()||(e.stopPropagation(),w(e,I,t))},onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),w(e,I,t)},children:e}):e})(),(0,Q.jsx)(`span`,{className:`flex-1 truncate font-medium`,title:t.description||void 0,children:t.label||t.name}),te.has(I)&&(0,Q.jsx)(fe,{className:`h-3.5 w-3.5 shrink-0 animate-spin`,"aria-label":te.get(I)}),F?.has(I)&&(0,Q.jsx)(fe,{className:`w-3.5 h-3.5 shrink-0 animate-spin text-muted-foreground`,"aria-label":`Indexing`}),L&&(0,Q.jsx)(wt,{className:`w-3 h-3 shrink-0 text-muted-foreground`,"aria-label":L,children:(0,Q.jsx)(`title`,{children:L})}),!l&&(0,Q.jsx)(`button`,{type:`button`,className:`shrink-0 reveal-on-hover p-1 rounded hover:bg-muted-foreground/10 text-muted-foreground`,onClick:e=>{e.stopPropagation(),x(e,I,t)},children:(0,Q.jsx)(lt,{className:`w-4 h-4`})})]})]}),B&&(le||m===I)&&(0,Q.jsxs)(`div`,{className:ne?void 0:`ml-[22px] mt-2 mb-1 space-y-1.5`,children:[m===I&&(0,Q.jsx)(bc,{onConfirm:e=>S(I,e),onCancel:C}),t.children?.map((n,i)=>(0,Q.jsx)(Cc,{node:n,expansionState:e,parentPath:I,depth:r+1,isLast:i===(t.children?.length??0)-1,selectedPath:o,pendingPath:s,contentPath:c,readOnly:l,sourceLayer:u,targetLayers:d,clipboard:f,searchQuery:p,inlineCreateParent:m,onSelect:h,onAltSelect:g,selectedPaths:_,onRangeSelect:v,onShowContent:y,onCtrl:b,onCtxMenu:x,onConfirmCreate:S,onCancelCreate:C,onOpenPicker:w,styleOverrides:T,dragOverPath:E,isCopyDrag:D,onDragStart:O,onDragEnter:A,onDragOver:j,onDragLeave:M,onDragEnd:N,onDrop:P,resyncingPaths:F,policyBadgeFor:ee,removingPaths:te,accordion:ne,trail:ve},n.id||n.name))]})]})}function wc({root:e,expansionState:t,workspaceId:n,treeName:r=`context`,isBackendsTree:i=!1,onRestoreTrash:a,onDiscardTrash:o,selectedPath:s,pendingPath:c,onSelect:l,isLoading:u=!1,readOnly:d=!1,onAddRule:f,onAddStoreRule:p,onStoragePolicy:m,policyBadgeFor:h,rootLabel:g,contentPath:_,onShowContent:v,onOpenToSide:y,onAltSelect:b,onInsertPath:x,onNewCanvas:S,onShareCanvas:C,onRemovePath:w,onRenamePath:T,onMovePath:E,onCopyPath:D,onExportSubtree:O,onImportSubtree:k,onImportDocuments:A,onExportDocuments:j,pastedDocumentIds:M,onPasteDocuments:N,onLockLayer:P,onUnlockLayer:F,onDestroyLayer:ee,onMergeLayer:te,onSubtractLayer:ne,onMergeDown:ie,onSubtractDown:ae,onResyncBackend:I,canResyncBackend:L,onCreateBackendFolder:R,onRenameBackendFolder:oe,onDeleteBackendFolder:se,onUpdateNode:ce,isPathPinned:z,onTogglePin:B,searchQuery:le=``,resyncingPaths:V,backends:ue}){let de=dc(),[pe,me]=(0,Z.useState)(new Set),H=(0,Z.useRef)(null),he=e=>{H.current=e,me(new Set),l(e)},ge=(e,t)=>{t.preventDefault();let n=t.currentTarget.closest(`[data-menu-tree]`)?.querySelectorAll(`[data-tree-path]`),r=Array.from(n||[],e=>e.dataset.treePath),i=H.current||s;me(Zs(r,i,e)),H.current=r.includes(i)?i:e},[_e,ve]=(0,Z.useState)(null),[U,ye]=(0,Z.useState)(null),[be,xe]=(0,Z.useState)(new Map),[W,Se]=(0,Z.useState)(null),[Ce,we]=(0,Z.useState)(new Map),Te=(0,Z.useRef)(new Set),Ee=(0,Z.useCallback)(async(e,t=!1,n=!1,a=!1)=>{if(!(i?se:w)||[...Te.current].some(t=>t===e||t.startsWith(e+`/`)||e.startsWith(t+`/`)))return!1;Te.current.add(e);let o=i?`Deleting from backend…`:a?`Removing documents and backend files…`:n?`Removing and purging documents…`:`Removing folder…`;we(t=>new Map(t).set(e,o));try{return i?await se(e):await w(e,r===`directory`||t,n,a)}finally{Te.current.delete(e),we(t=>{let n=new Map(t);return n.delete(e),n})}},[w,se,i,r]),[De,Oe]=(0,Z.useState)(null),[ke,Ae]=(0,Z.useState)(new Map),[je,Me]=(0,Z.useState)(e),Ne=(0,Z.useRef)(new Map),Pe=(0,Z.useRef)(null),[Fe,Ie]=(0,Z.useState)(null);if(e!==je){Me(e);let t=Fe;Ae(t?new Map([[t.path,t.style]]):new Map)}let[Le,Re]=(0,Z.useState)(null),[ze,Be]=(0,Z.useState)(null),[Ve,He]=(0,Z.useState)(!1),[Ue,We]=(0,Z.useState)(!1),[Ge,Ke]=(0,Z.useState)(!0),qe=(0,Z.useRef)(!0),Je=(0,Z.useRef)(null),Ye=(0,Z.useRef)(r),Xe=(0,Z.useRef)(!1),Ze=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{let e=e=>{ve(e.detail??null)};return window.addEventListener(`tree:path-clipboard`,e),()=>window.removeEventListener(`tree:path-clipboard`,e)},[]),(0,Z.useEffect)(()=>{let e=e=>{let t=e.ctrlKey||e.altKey||Ze.current;Xe.current=t,He(t)};return window.addEventListener(`keydown`,e),window.addEventListener(`keyup`,e),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`keyup`,e)}},[]);let Qe=(0,Z.useCallback)((e,t,n)=>{if(Vi(Ye.current,e)||Vi(r,t))return!1;if(Ye.current!==r)return!0;let i=e.endsWith(`/`)?e.slice(0,-1):e,a=t.endsWith(`/`)?t.slice(0,-1):t,o=i.substring(0,i.lastIndexOf(`/`))||`/`;return!(a.startsWith(i+`/`)||i===a||!n&&a===o)},[r]),$e=(0,Z.useCallback)((e,t)=>{if(Vi(r,e)){t.preventDefault();return}Je.current=e,Ye.current=r,t.dataTransfer.setData(`text/plain`,e),t.dataTransfer.setData(`application/x-canvas-tree-path`,JSON.stringify({path:e,treeName:r})),t.dataTransfer.effectAllowed=`copyMove`},[r]),et=e=>e.ctrlKey||e.altKey||Ze.current,tt=(0,Z.useCallback)((e,t)=>{if(Vi(r,e))return;let n=Je.current,a=et(t);if(a!==Xe.current&&(Xe.current=a,He(a)),n){if(!Qe(n,e,a))return}else if(_c(t)&&!gc(e,i))return;t.preventDefault(),Be(e)},[Qe,r,i]),nt=(0,Z.useCallback)((e,t)=>{if(Vi(r,e)){t.dataTransfer.dropEffect=`none`;return}let n=et(t);n!==Xe.current&&(Xe.current=n,He(n));let a=Je.current;if(a){if(!Qe(a,e,n)){t.dataTransfer.dropEffect=`none`;return}}else if(_c(t)&&!gc(e,i)){t.dataTransfer.dropEffect=`none`;return}t.preventDefault(),t.dataTransfer.dropEffect=n&&!i?`copy`:`move`},[Qe,r,i]),rt=(0,Z.useCallback)((e,t)=>{t.currentTarget.contains(t.relatedTarget)||Be(t=>t===e?null:t)},[]),it=(0,Z.useCallback)(()=>{Je.current=null,Ye.current=r,Xe.current=!1,He(!1),Be(null)},[r]),at=(0,Z.useCallback)(async(e,t)=>{if(t.preventDefault(),t.stopPropagation(),Vi(r,e))return;let a=(()=>{try{return JSON.parse(t.dataTransfer.getData(`application/json`))}catch{return null}})();if(a?.type===`document`&&Array.isArray(a.documentIds)&&a.documentIds.length){if(Je.current=null,Xe.current=!1,He(!1),Be(null),wr(a,n,r,e))return;if(N&&gc(e,i))try{await N(e,a.documentIds)}catch(e){alert(e instanceof Error?e.message:String(e))}return}let o=(()=>{try{return JSON.parse(t.dataTransfer.getData(`application/x-canvas-tree-path`))}catch{return null}})(),s=o?.path||t.dataTransfer.getData(`text/plain`),c=o?.treeName||Ye.current||r;if(Vi(c,s))return;let l=et(t)||Xe.current;if(Je.current=null,Ye.current=r,Xe.current=!1,He(!1),Be(null),!s)return;let u=t.shiftKey,d=c!==r;if(!(!d&&s===e)&&!(!d&&!Qe(s,e,l)))try{if(l&&D)await D(s,e,u,c,r);else if(!l&&E){let t=qe.current&&!i&&!!ie;await E(s,e,u,c,r,t?{mergeDown:t}:void 0)}}catch(e){alert(e instanceof Error?e.message:String(e))}},[Qe,D,E,N,n,r,i,ie]),ot=le.toLowerCase().trim(),st=(0,Z.useCallback)((e,t,n)=>{e.stopPropagation(),Se({x:e.clientX,y:e.clientY,path:t,node:n})},[]),ct=(0,Z.useCallback)((e,t,n)=>{e.stopPropagation(),!n.metadata?.backendTrash&&(Pe.current=null,Ie(null),Oe({x:e.clientX,y:e.clientY,path:t,node:n}))},[]),ut=(0,Z.useCallback)(e=>{if(!De||!ce)return;let t=De.path,n={...ke.get(t)??(Pe.current?.path===t?Pe.current.style:bi(De.node)),...e};Pe.current={path:t,style:n},Ie({path:t,style:n}),Ae(e=>new Map(e).set(t,n));let r=yi(De.node.metadata,n),i=Ne.current,a=i.get(t);a&&clearTimeout(a),i.set(t,setTimeout(()=>{i.delete(t),ce(t,{metadata:r}).catch(e=>alert(e instanceof Error?e.message:String(e)))},350))},[De,ce,ke]),dt=(0,Z.useCallback)((e,t)=>{U?e===U.path?(ye(null),xe(new Map)):xe(n=>{let r=new Map(n);return r.has(e)?r.delete(e):r.set(e,t),r}):(ye({path:e,id:t}),xe(new Map))},[U]),ft=(0,Z.useCallback)(async e=>{if(!(!_e||!E||!D)&&!(_e.treeName===r&&(e===_e.path||e.startsWith(_e.path+`/`)))){if(_e.mode===`cut`){let t=qe.current&&!i&&!!ie;await E(_e.path,e,!1,_e.treeName,r,t?{mergeDown:t}:void 0),ve(null),window.dispatchEvent(new CustomEvent(`tree:path-clipboard`,{detail:null}))}else await D(_e.path,e,!0,_e.treeName,r)}},[_e,E,D,r,i,ie]);(0,Z.useEffect)(()=>{if(d)return;let e=e=>{let t=e.target;if(t?.tagName===`INPUT`||t?.tagName===`TEXTAREA`||e.key!==`F6`)return;if(e.preventDefault(),_e?.mode===`cut`){ft(s);return}let n={mode:`cut`,path:s,treeName:r};ve(n),window.dispatchEvent(new CustomEvent(`tree:path-clipboard`,{detail:n}))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[_e,ft,d,s,r]);let pt=(0,Z.useCallback)(async(e,t)=>{Re(null);let n=e===`/`?`/${t}`:`${e}/${t}`;try{hc(e,i)&&R?await R(e,t)&&l(n):x&&await x(n,!0)&&l(n)}catch(e){alert(e instanceof Error?e.message:String(e))}},[x,R,l,i]),mt=(0,Z.useCallback)(()=>{Re(null)},[]),ht=(0,Z.useCallback)((e,t)=>{let n={mode:t,path:e,treeName:r};ve(n),window.dispatchEvent(new CustomEvent(`tree:path-clipboard`,{detail:n}))},[r]),gt=(0,Z.useCallback)(t=>{if(d||En(t.target)||s&&Vi(r,s))return;if(Tn(t,`Mod+V`)){M?.length&&N&&s&&gc(s,i)?(t.preventDefault(),N(s,M).catch(()=>{})):_e&&s&&(t.preventDefault(),ft(s).catch(e=>alert(e instanceof Error?e.message:String(e))));return}if(s&&s!==`/`&&(Tn(t,`Mod+C`)||!i&&Tn(t,`Mod+X`))){t.preventDefault(),ht(s,t.key.toLowerCase()===`x`?`cut`:`copy`);return}if((i?!se||!cr(s||``,ue):!w)||t.key!==`Delete`&&t.key!==`Backspace`||!s||s===`/`)return;t.preventDefault();let n=Rn(e,s);if(!i&&n?.locked){alert(`"${s}" is locked`);return}confirm(i?`Delete "${s}" and its contents from this backend?`:`Remove "${s}"${r===`directory`?` and all children`:``}?`)&&Ee(s,!1).catch(e=>alert(e instanceof Error?e.message:String(e)))},[d,w,se,Ee,s,e,M,N,_e,ft,i,ht,r,ue]),_t=(0,Z.useCallback)(()=>{We(e=>{let t=!e;return Ze.current=t,Xe.current=t,He(t),t})},[]);if(u)return(0,Q.jsx)(`div`,{className:`px-3 py-3 text-xs text-muted-foreground`,children:`Loading tree…`});if(!e)return(0,Q.jsx)(`div`,{className:`px-3 py-3 text-xs text-muted-foreground`,children:`No tree available`});let vt=U||be.size>0,yt={expansionState:t,accordion:de,selectedPath:s,pendingPath:c,contentPath:_,readOnly:d,sourceLayer:U,targetLayers:be,clipboard:_e,searchQuery:ot,inlineCreateParent:Le,onSelect:he,onAltSelect:b,selectedPaths:pe,onRangeSelect:ge,onShowContent:v,onCtrl:dt,onCtxMenu:st,onConfirmCreate:pt,onCancelCreate:mt,onOpenPicker:ce?ct:void 0,styleOverrides:ke,dragOverPath:ze,isCopyDrag:Ve,onDragStart:$e,onDragEnter:tt,onDragOver:nt,onDragLeave:rt,onDragEnd:it,onDrop:at,resyncingPaths:V,backends:ue,policyBadgeFor:i?void 0:h,removingPaths:Ce};return(0,Q.jsxs)(`div`,{"data-menu-tree":!0,className:`px-3 py-2 space-y-1.5 outline-none min-h-full`,tabIndex:0,onKeyDown:gt,onContextMenu:t=>{t.defaultPrevented||d||(t.preventDefault(),st(t,`/`,e))},children:[Ce.size>0&&(0,Q.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`space-y-1 rounded-md border bg-muted/50 p-2 text-xs`,children:[...Ce].map(([e,t])=>(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(fe,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 animate-spin`,"aria-hidden":`true`}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block`,children:t}),(0,Q.jsx)(`span`,{className:`block truncate text-muted-foreground`,title:e,children:e})]})]},e))}),!d&&(0,Q.jsxs)(`div`,{className:`flex items-center justify-end px-1 pb-0.5 text-[10px]`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:_t,title:`Toggle drag-drop mode (or hold Ctrl / Alt while dragging)`,className:G(`px-2 py-0.5 rounded-full border transition-colors select-none`,Ue?`border-success bg-success/15 text-success dark:text-success`:`border-border text-muted-foreground hover:bg-muted`),children:Ue?`Drag → Copy`:`Drag → Move`}),ie&&!i&&!Ue&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>Ke(e=>(qe.current=!e,!e)),title:`When moving a layer, also merge it into its new ancestors so the new path lists its documents`,className:G(`ml-1 px-2 py-0.5 rounded-full border transition-colors select-none`,Ge?`border-info bg-info/15 text-info dark:text-info`:`border-border text-muted-foreground hover:bg-muted`),children:Ge?`+ merge down`:`merge down: off`})]}),vt&&(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-1 pb-1 text-[10px] text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:U?`Source: ${U.path} · ${be.size} target(s)`:`Select source with ⌃-click`}),(0,Q.jsx)(`button`,{type:`button`,className:`hover:text-foreground underline`,onClick:()=>{ye(null),xe(new Map)},children:`clear`})]}),(0,Q.jsxs)(`div`,{"data-active":s===`/`&&!_||void 0,className:G(`group relative flex min-h-11 items-center gap-2 rounded-(--card-radius) px-3 py-2.5 cursor-pointer transition-all select-none`,`shadow-elevation-3 hover:shadow-elevation-4 text-sm`,s===`/`&&!_?`bg-primary/[0.06]`:`bg-card hover:bg-primary/[0.04]`,ze===`/`&&!d&&!Ve&&`ring-2 ring-info bg-info-subtle/50`,ze===`/`&&!d&&Ve&&`ring-2 ring-success bg-success-subtle/50`),style:{borderRight:`4px solid transparent`},onClick:()=>he(`/`),onDragEnter:e=>{d||tt(`/`,e)},onDragOver:e=>{d||nt(`/`,e)},onDragLeave:e=>rt(`/`,e),onDrop:e=>{d||at(`/`,e)},onContextMenu:e=>{!d&&x&&(e.preventDefault(),Se({x:e.clientX,y:e.clientY,path:`/`,node:{id:``,name:`/`,label:`/`,type:`root`,description:``,color:null,locked:!1,children:[]}}))},children:[(0,Q.jsx)(re,{className:`w-4 h-4 shrink-0 text-muted-foreground`}),(0,Q.jsxs)(`span`,{className:`flex-1 font-medium truncate`,children:[`/ `,g&&(0,Q.jsxs)(`span`,{className:`text-muted-foreground font-normal`,children:[`[`,g,`]`]})]}),!d&&x&&(0,Q.jsx)(`button`,{type:`button`,className:`shrink-0 reveal-on-hover p-1 rounded hover:bg-muted-foreground/10 text-muted-foreground`,onClick:e=>{e.stopPropagation(),Se({x:e.clientX,y:e.clientY,path:`/`,node:{id:``,name:`/`,label:`/`,type:`root`,description:``,color:null,locked:!1,children:[]}})},children:(0,Q.jsx)(lt,{className:`w-4 h-4`})})]}),(0,Q.jsxs)(`div`,{className:de?`mt-1.5 border-t border-border/60`:`ml-[22px] mt-1.5 space-y-1.5`,children:[Le===`/`&&(0,Q.jsx)(bc,{onConfirm:e=>pt(`/`,e),onCancel:mt}),e.children?.map((t,n)=>(0,Q.jsx)(Cc,{node:t,parentPath:`/`,depth:0,isLast:n===(e.children?.length??0)-1,...yt},t.id||t.name)),!e.children?.length&&Le!==`/`&&(0,Q.jsx)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground`,children:`Empty tree`})]}),W&&pe.size>1&&pe.has(W.path)?(0,Q.jsxs)(wn,{x:W.x,y:W.y,onClose:()=>Se(null),className:`min-w-44 rounded-md border bg-popover p-1 shadow-elevation-3`,children:[(0,Q.jsxs)(`div`,{className:`px-3 py-1.5 text-xs text-muted-foreground`,children:[pe.size,` folders selected`]}),(0,Q.jsx)(`button`,{type:`button`,className:`block w-full px-3 py-1.5 text-left text-xs hover:bg-accent`,onClick:()=>{navigator.clipboard?.writeText([...pe].join(`
|
|
5
5
|
`)),Se(null)},children:`Copy paths`}),!d&&!i&&w&&(0,Q.jsx)(`button`,{type:`button`,className:`block w-full px-3 py-1.5 text-left text-xs text-destructive hover:bg-accent`,onClick:()=>{Se(null);let e=Qs(pe);confirm(`Remove ${pe.size} selected folders and their children?\n${e.join(`
|
|
@@ -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{ct as r,lt as i,ut as a}from"./index-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{ct as r,lt as i,ut as a}from"./index-BytAmMhU.js";import{n as o}from"./page-header-DkOHw0g-.js";import{t as s}from"./use-settings-back-CQauYjQ4.js";var c=e(n(),1),l=t();function u(){let[e,t]=(0,c.useState)(i),[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{a(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)||r[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)||r[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({...r}),children:`Restore defaults`}),(0,l.jsx)(`p`,{role:`status`,className:`text-sm`,children:n})]})]})}export{u as default};
|