@rubytech/create-maxy-code 0.1.389 → 0.1.392
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/__tests__/claude-bin.test.js +51 -0
- package/dist/__tests__/claude-upgrade-privilege.test.js +17 -0
- package/dist/__tests__/launchd-plist.test.js +36 -1
- package/dist/__tests__/macos-darwin-branch.test.js +18 -0
- package/dist/__tests__/neo4j-datadir.test.js +14 -0
- package/dist/claude-bin.js +78 -0
- package/dist/claude-upgrade-privilege.js +21 -0
- package/dist/index.js +241 -34
- package/dist/launchd-plist.js +25 -9
- package/dist/neo4j-datadir.js +15 -0
- package/package.json +1 -1
- package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +4 -4
- package/payload/platform/scripts/smoke-boot-services.sh +35 -10
- package/payload/platform/services/claude-session-manager/dist/claude-host-creds.d.ts +11 -0
- package/payload/platform/services/claude-session-manager/dist/claude-host-creds.d.ts.map +1 -0
- package/payload/platform/services/claude-session-manager/dist/claude-host-creds.js +37 -0
- package/payload/platform/services/claude-session-manager/dist/claude-host-creds.js.map +1 -0
- package/payload/platform/services/claude-session-manager/dist/index.js +8 -8
- package/payload/platform/services/claude-session-manager/dist/index.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.js +7 -0
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/rc-daemon.d.ts +1 -1
- package/payload/platform/services/claude-session-manager/dist/rc-daemon.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/rc-daemon.js +5 -1
- package/payload/platform/services/claude-session-manager/dist/rc-daemon.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/systemd-scope.d.ts +28 -0
- package/payload/platform/services/claude-session-manager/dist/systemd-scope.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/systemd-scope.js +54 -0
- package/payload/platform/services/claude-session-manager/dist/systemd-scope.js.map +1 -1
- package/payload/server/public/assets/{AdminLoginScreens-CerrEc_m.js → AdminLoginScreens-CL27ZV86.js} +1 -1
- package/payload/server/public/assets/{AdminShell-cRTvNRbo.js → AdminShell-CBcSh9Yd.js} +1 -1
- package/payload/server/public/assets/{Checkbox-Dh2pLMFN.js → Checkbox-DRIcYN9r.js} +1 -1
- package/payload/server/public/assets/{Transcript-B_GVJujB.js → Transcript-CRc72hkG.js} +1 -1
- package/payload/server/public/assets/{admin-BXaYelnR.js → admin-iKYYnv3w.js} +1 -1
- package/payload/server/public/assets/{browser-fhjGE7fH.js → browser--8gzAe-E.js} +1 -1
- package/payload/server/public/assets/{calendar-PnZudAtc.js → calendar-7xAT81N_.js} +1 -1
- package/payload/server/public/assets/chat-B8Z9W42Z.js +1 -0
- package/payload/server/public/assets/chevron-left-DDselYau.js +1 -0
- package/payload/server/public/assets/data-Ece320dZ.js +1 -0
- package/payload/server/public/assets/{graph-CycO3tkW.js → graph-B3haz2DN.js} +1 -1
- package/payload/server/public/assets/{graph-labels-DlSsSpBV.js → graph-labels-Ba_fyw6I.js} +1 -1
- package/payload/server/public/assets/{operator-L4kBC-zS.js → operator-BYL1IFz9.js} +1 -1
- package/payload/server/public/assets/page-Bj6lB07z.js +32 -0
- package/payload/server/public/assets/{page-D5E-Ng4D.js → page-CLKVCquw.js} +1 -1
- package/payload/server/public/assets/{public-BmnajF3K.js → public-BKJUKC76.js} +1 -1
- package/payload/server/public/assets/{rotate-ccw-W5HhvAbo.js → rotate-ccw-BypBbSI4.js} +1 -1
- package/payload/server/public/assets/{useSubAccountSwitcher-D1TI1xvd.css → useSubAccountSwitcher-4qilMyPX.css} +1 -1
- package/payload/server/public/browser.html +4 -4
- package/payload/server/public/calendar.html +5 -5
- package/payload/server/public/chat.html +8 -8
- package/payload/server/public/data.html +7 -7
- package/payload/server/public/graph.html +8 -8
- package/payload/server/public/index.html +10 -10
- package/payload/server/public/operator.html +10 -10
- package/payload/server/public/public.html +8 -8
- package/payload/server/server.js +157 -12
- package/payload/server/public/assets/chat-Dy_zrjKS.js +0 -1
- package/payload/server/public/assets/chevron-left-IB6TmMZ_.js +0 -1
- package/payload/server/public/assets/data-B2IcjAj6.js +0 -1
- package/payload/server/public/assets/page-M8sD9LOi.js +0 -32
- /package/payload/server/public/assets/{useSubAccountSwitcher-UqZbmzYy.js → useSubAccountSwitcher-CsRv6MEd.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CAM3fms7.js";import{D as t,L as n,M as r,P as i,S as a,_ as o,a as s,b as c,c as l,d as u,f as d,g as ee,h as f,i as te,m as ne,n as p,o as m,r as re,t as ie,u as ae,v as oe,w as se}from"./useSubAccountSwitcher-UqZbmzYy.js";import{t as h}from"./chevron-left-IB6TmMZ_.js";import{i as g}from"./Transcript-B_GVJujB.js";import{i as ce,t as le}from"./graph-labels-DlSsSpBV.js";var ue=t(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),de=t(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),fe=t(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),pe=t(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),me=t(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),he=t(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),ge=t(`mouse-pointer-click`,[[`path`,{d:`M14 4.1 12 6`,key:`ita8i4`}],[`path`,{d:`m5.1 8-2.9-.8`,key:`1go3kf`}],[`path`,{d:`m6 12-1.9 2`,key:`mnht97`}],[`path`,{d:`M7.2 2.2 8 5.1`,key:`1cfko1`}],[`path`,{d:`M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z`,key:`s0h3yz`}]]),_=t(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),_e=t(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]);function ve(e){let t=new Set,n=[];for(let r of e)for(let e of r.labels)e&&(t.has(e)||le.has(e)&&(t.add(e),n.push(e)));return n}var v=e(n(),1),y=r();function b(e){if(!e)return``;let t=new Date(e).getTime();return Number.isFinite(t)?new Date(t).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):``}function ye({conversations:e,sessionKey:t,onBack:n}){let[r,i]=(0,v.useState)(null),a=s(e);return r?(0,y.jsxs)(`div`,{className:`op-conv op-conv-reader`,children:[(0,y.jsxs)(`div`,{className:`op-conv-bar`,children:[(0,y.jsxs)(`button`,{type:`button`,className:`op-conv-back`,onClick:()=>i(null),"aria-label":`Back to conversations`,children:[(0,y.jsx)(h,{size:16}),` Back`]}),(0,y.jsx)(`span`,{className:`op-conv-title`,children:m(r)})]}),(0,y.jsx)(g,{sessionId:r.sessionId,projectDir:r.projectDir,sessionKey:t,forceDeliveredOnly:!0,suppressDirectives:r.source===`store`,store:r.source===`store`?{accountId:r.accountId,remoteJid:r.remoteJid}:void 0},l(r))]}):(0,y.jsxs)(`div`,{className:`op-conv op-conv-list`,children:[(0,y.jsxs)(`div`,{className:`op-conv-bar`,children:[(0,y.jsxs)(`button`,{type:`button`,className:`op-conv-back`,onClick:n,"aria-label":`Back to chat`,children:[(0,y.jsx)(h,{size:16}),` Chat`]}),(0,y.jsx)(`span`,{className:`op-conv-title`,children:`Conversations`})]}),a.map(e=>(0,y.jsxs)(`div`,{className:`op-conv-group`,children:[(0,y.jsxs)(`div`,{className:`op-conv-group-head`,children:[(0,y.jsx)(ae,{channel:e.channel,size:14}),e.label]}),e.rows.map(e=>(0,y.jsxs)(`button`,{type:`button`,className:`op-conv-row`,onClick:()=>{console.info(`[operator-ui] op=reader-open channel=${e.channel} key=${l(e)} readonly=true source=${e.source}`),i(e)},children:[(0,y.jsx)(`span`,{className:`op-conv-name`,children:m(e)}),e.modelGated&&(0,y.jsx)(`span`,{className:`op-conv-gated`,role:`img`,"aria-label":`Model unavailable`,children:(0,y.jsx)(_,{size:13})}),(0,y.jsx)(`span`,{className:`op-conv-when`,children:b(e.lastMessageAt)})]},l(e)))]},e.channel))]})}var x=/\.(png|jpe?g|gif|webp|svg)$/i;function be(e){return x.test(e)}var xe=`maxy-data-view`,Se=95*1024*1024,Ce=48*1024*1024;function we(){return typeof window>`u`?`list`:window.localStorage.getItem(xe)===`grid`?`grid`:`list`}function Te(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!n){t(null),r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`;return}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]),n?e?(0,y.jsx)(d,{cacheKey:e,surface:`data`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=data`);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},children:(0,y.jsx)(`div`,{className:`data-page data-page-full`,children:(0,y.jsx)(S,{cacheKey:e})})}):(0,y.jsx)(`div`,{className:`data-page`,children:(0,y.jsxs)(`div`,{className:`data-empty`,children:[(0,y.jsx)(`p`,{children:`You are not signed in.`}),(0,y.jsxs)(`p`,{children:[`Open the `,(0,y.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,y.jsx)(`div`,{className:`data-page`,children:(0,y.jsxs)(`div`,{className:`data-loading`,children:[(0,y.jsx)(c,{size:18,className:`spin`}),` Loading…`]})})}function S({cacheKey:e}){let{adminFetch:t,cacheKey:n,sessionRefetchNonce:r}=i({initialCacheKey:e,surface:`data`});return(0,y.jsx)(T,{adminFetch:t,cacheKey:n,sessionRefetchNonce:r})}function Ee(){if(typeof window>`u`)return`.`;let e=new URLSearchParams(window.location.hash.replace(/^#/,``)).get(`path`);return e&&e.length>0?e:`.`}function De(e){if(typeof window>`u`)return;let t=new URL(window.location.href);t.hash=e===`.`?``:`path=${encodeURIComponent(e)}`,window.history.replaceState(window.history.state,``,t.toString())}function Oe(e){return new Promise((t,n)=>{let r=[],i=()=>e.readEntries(e=>{e.length===0?t(r):(r.push(...e),i())},n);i()})}function C(e){return new Promise((t,n)=>e.file(t,n))}async function ke(e,t=``){let n=[];for(let r of e){if(!r)continue;let e=t?`${t}/${r.name}`:r.name;if(r.isFile)n.push({file:await C(r),relpath:e});else if(r.isDirectory){let t=await Oe(r.createReader());n.push(...await ke(t,e))}}return n}function Ae(e,t){if(e===422&&typeof t==`string`){if(/exceeds the .* limit/i.test(t))return`size`;if(/unsupported file type/i.test(t))return`mime`}return`http=${e}`}function w({adminFetch:e,cacheKey:t,sessionRefetchNonce:n}){let[r,i]=(0,v.useState)(``),s=(0,v.useRef)(null),[l,u]=(0,v.useState)(``),[d,m]=(0,v.useState)(null),[ie,ae]=(0,v.useState)(`hybrid`),[h,g]=(0,v.useState)(!1),[le,_]=(0,v.useState)(null),[b,ye]=(0,v.useState)(null),[x,Te]=(0,v.useState)(0),[S,Oe]=(0,v.useState)(!1),[C,w]=(0,v.useState)(()=>Ee()),[T,je]=(0,v.useState)(null),[E,Pe]=(0,v.useState)(()=>we()),[D,Le]=(0,v.useState)(null),[O,Re]=(0,v.useState)([]),[k,ze]=(0,v.useState)(!1),[Be,Ve]=(0,v.useState)(null),[He,Ue]=(0,v.useState)(!1),[A,j]=(0,v.useState)(null),[We,M]=(0,v.useState)(null),[Ge,Ke]=(0,v.useState)(null),[qe,Je]=(0,v.useState)(!1),[Ye,Xe]=(0,v.useState)(null),N=(0,v.useRef)(null),[Ze,P]=(0,v.useState)(0),[Qe,$e]=(0,v.useState)(!1),[et,tt]=(0,v.useState)(``),[F,nt]=(0,v.useState)(null),[rt,it]=(0,v.useState)(``),[at,I]=(0,v.useState)(null),L=(()=>{let e=C===`.`?[]:C.split(`/`).filter(Boolean);return e.length>=2&&e[0]===`accounts`})(),[R,z]=(0,v.useState)(!1),ot=(0,v.useRef)(null),[B,V]=(0,v.useState)(!1),st=(0,v.useRef)(null);(0,v.useEffect)(()=>{let e=r.trim();if(!e){u(``),m(null),_(null);return}Oe(!1);let t=setTimeout(()=>u(e),300);return()=>clearTimeout(t)},[r]),(0,v.useEffect)(()=>{if(!l){g(!1);return}let t=!1;return g(!0),_(null),e(`/api/admin/graph-search?q=${encodeURIComponent(l)}&labels=FileArtifact&limit=20${S?`&threshold=0`:``}`).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{t||(m(e.results),ae(e.mode??`hybrid`),Te(typeof e.suppressed==`number`?e.suppressed:0))}).catch(e=>{t||_(e instanceof Error?e.message:String(e))}).finally(()=>{t||g(!1)}),()=>{t=!0}},[l,e,n,S]);let ct=(0,v.useMemo)(()=>d?ve(d):[],[d]),H=b&&ct.includes(b)?b:null,U=(0,v.useMemo)(()=>d?H?d.filter(e=>e.labels.includes(H)):d:null,[d,H]),lt=(0,v.useCallback)(e=>{let n=e.properties.relativePath;if(typeof n!=`string`||n.length===0)return;let r=`/api/admin/files/download?session_key=${encodeURIComponent(t)}&path=${encodeURIComponent(n)}`,i=document.createElement(`a`);i.href=r,i.rel=`noopener noreferrer`,document.body.appendChild(i),i.click(),i.remove()},[t]);(0,v.useEffect)(()=>{if(!d)return;let e=d.filter(e=>{let t=e.properties.relativePath;return typeof t!=`string`||t.length===0});e.length>0&&console.warn(`[data-search] op=locate-link-missing nodeId=${e.map(e=>e.nodeId).join(`,`)}`)},[d]),(0,v.useEffect)(()=>{let t=!1;return ze(!0),Ve(null),e(`/api/admin/files?path=${encodeURIComponent(C===`.`?``:C)}`).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{t||(je(e.entries),Re(e.displayPath??[]))}).catch(e=>{t||(je([]),Re([]),Ve(e instanceof Error?e.message:String(e)))}).finally(()=>{t||ze(!1)}),()=>{t=!0}},[e,C,Ze,n]),(0,v.useEffect)(()=>{De(C)},[C]);let ut=(0,v.useCallback)(()=>{P(e=>e+1)},[]),W=(0,v.useCallback)(e=>{z(!1),w(e)},[]),dt=(0,v.useCallback)(e=>{let t=e.properties.relativePath;if(typeof t!=`string`||t.length===0)return;let n=t.lastIndexOf(`/`),r=n===-1?`.`:t.slice(0,n);console.log(`[data-search] op=locate nodeId=${e.nodeId} folder=${r}`),i(``),_(null),ye(null),W(r)},[W]),ft=(0,v.useCallback)(()=>{if(C===`.`||C===``)return;let e=C.split(`/`).filter(Boolean);e.pop(),w(e.length===0?`.`:e.join(`/`))},[C]),G=(0,v.useCallback)(e=>{re(t,C===`.`?e.name:`${C}/${e.name}`)},[C,t]),[K,pt]=(0,v.useState)(!1),[q,mt]=(0,v.useState)(new Set),ht=(0,v.useRef)(null),J=(0,v.useRef)(!1),Y=typeof navigator<`u`&&typeof navigator.share==`function`&&typeof navigator.canShare==`function`,gt=(0,v.useCallback)(e=>{pt(!0),mt(new Set([e])),console.info(`[data-ui] op=select-enter count=1`)},[]),X=(0,v.useCallback)(e=>{pt(!1),mt(new Set),console.info(`[data-ui] op=select-exit reason=${e}`)},[]),Z=(0,v.useCallback)(e=>{mt(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),_t=(0,v.useCallback)(e=>{J.current=!1,ht.current=setTimeout(()=>{J.current=!0,gt(e)},500)},[gt]),Q=(0,v.useCallback)(()=>{ht.current&&=(clearTimeout(ht.current),null)},[]),vt=(0,v.useCallback)(e=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}G(e)},[K,Z,G]),yt=(0,v.useCallback)(e=>{Pe(e),typeof window<`u`&&window.localStorage.setItem(xe,e),console.info(`[data] op=view-mode mode=${e}`)},[]),bt=(0,v.useCallback)(e=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}Le({src:p(t,C===`.`?e.name:`${C}/${e.name}`),alt:e.displayName??e.name})},[K,Z,C,t]),xt=(0,v.useCallback)(()=>(T??[]).filter(e=>e.kind===`file`&&q.has(e.name)),[T,q]),St=(0,v.useCallback)(()=>(T??[]).filter(e=>(e.kind===`file`||e.kind===`directory`)&&q.has(e.name)),[T,q]),Ct=(0,v.useCallback)(()=>{let e=St(),n=e.some(e=>e.kind===`directory`);e.length===1&&!n?G(e[0]):e.length>=1&&te(t,e.map(e=>C===`.`?e.name:`${C}/${e.name}`)),X(`action`)},[St,G,C,t,X]),wt=(0,v.useCallback)(async()=>{let t=xt(),n=t.filter(e=>!e.protected),r=t.length-n.length;Xe(r>0?`${r} protected file(s) kept`:null);for(let t of n){let n=C===`.`?t.name:`${C}/${t.name}`;try{let t=await e(`/api/admin/files?path=${encodeURIComponent(n)}`,{method:`DELETE`}),r=await t.json().catch(()=>({error:`HTTP ${t.status}`}));if(!t.ok)throw Error(r.error??`HTTP ${t.status}`)}catch(e){Xe(e instanceof Error?e.message:String(e))}}P(e=>e+1),X(`action`)},[xt,C,e,X]),Tt=(0,v.useCallback)(async()=>{let e=xt();if(console.info(`[data-ui] op=share supported=${Y} count=${e.length}`),Y)try{let n=await Promise.all(e.map(async e=>{let n=C===`.`?e.name:`${C}/${e.name}`,r=`/api/admin/files/download?session_key=${encodeURIComponent(t)}&path=${encodeURIComponent(n)}`,i=await(await fetch(r)).blob();return new File([i],e.name,{type:i.type||`application/octet-stream`})}));navigator.canShare({files:n})&&await navigator.share({files:n})}catch(e){console.warn(`[data-ui] op=share-failed err=${e instanceof Error?e.message:String(e)}`)}},[xt,Y,C,t]),Et=(0,v.useCallback)(()=>{N.current?.click()},[]),Dt=(0,v.useCallback)((e,n={})=>{let r=(r,i,a)=>{let o=new URLSearchParams({session_key:t,path:C===`.`?``:C,filename:e.name});n.relpath&&o.set(`relpath`,n.relpath),n.token&&o.set(`token`,n.token);for(let[e,t]of Object.entries(i))o.set(e,t);return new Promise(t=>{let n=new XMLHttpRequest;n.open(`POST`,`/api/admin/files/upload?${o.toString()}`),n.setRequestHeader(`Content-Type`,e.type||`application/octet-stream`),a&&(n.upload.onprogress=e=>{e.lengthComputable&&a(e.loaded)}),n.onload=()=>{let e={};try{e=JSON.parse(n.responseText)}catch{}t({status:n.status,data:e})},n.onerror=()=>t({status:0,data:{}}),n.onabort=()=>t({status:0,data:{error:`aborted`}}),n.send(r)})};if(e.size<=Se)return r(e,{},t=>n.onProgress?.(t,e.size));let i=`${Date.now().toString(36)}-${Math.random().toString(16).slice(2,10)}`,a=Math.ceil(e.size/Ce);return(async()=>{let t={status:0,data:{}};for(let o=0;o<a;o++){let s=o*Ce;if(t=await r(e.slice(s,Math.min(s+Ce,e.size)),{uploadId:i,seq:String(o),total:String(a)},t=>n.onProgress?.(s+t,e.size)),!(t.status>=200&&t.status<300))return t}return t})()},[t,C]),Ot=(0,v.useCallback)(async e=>{M(null),Ue(!0),j({loaded:0,total:e.size});try{let{status:t,data:n}=await Dt(e,{onProgress:(e,t)=>j({loaded:e,total:t})});t>=200&&t<300&&n.path?(w(n.path.split(`/`).slice(0,-1).join(`/`)||`.`),P(e=>e+1)):M(t===0?`Network error during upload — the connection failed before the server responded.`:n.error??`Upload failed (HTTP ${t}).`)}finally{Ue(!1),j(null),N.current&&(N.current.value=``)}},[Dt]),kt=(0,v.useCallback)(e=>{L&&Array.from(e.dataTransfer.types).includes(`Files`)&&(e.preventDefault(),Je(!0))},[L]),At=(0,v.useCallback)(e=>{e.currentTarget.contains(e.relatedTarget)||Je(!1)},[]),jt=(0,v.useCallback)(async e=>{e.preventDefault(),Je(!1);let t=Math.random().toString(16).slice(2,10),n=Array.from(e.dataTransfer.items);if(console.info(`[data-ui] op=drop-received token=${t} items=${n.length}`),n.length===0)return;if(!L){console.info(`[data-ui] op=drop-rejected token=${t} reason=no-write`),M(`Open a folder inside your account to upload`);return}let r=n.map(e=>e.webkitGetAsEntry?.()).filter(e=>!!e);Ue(!0),M(null),Ke(null);let i=performance.now();try{let e=await ke(r),n=e.reduce((e,t)=>e+t.file.size,0),a=new Set(e.map(e=>e.relpath.split(`/`).slice(0,-1).join(`/`)).filter(Boolean)).size;console.info(`[data-ui] op=drop-walk token=${t} files=${e.length} dirs=${a} bytes=${n}`);let o=0,s=[];for(let n=0;n<e.length;n++){let{file:r,relpath:i}=e[n];console.info(`[data-ui] op=drop-file token=${t} rel="${i}" i=${n+1}/${e.length}`),j({loaded:0,total:r.size});let{status:a,data:c}=await Dt(r,{relpath:i,token:t,onProgress:(e,t)=>j({loaded:e,total:t})});if(a>=200&&a<300)o++,console.info(`[data-ui] op=drop-file-ok token=${t} rel="${i}"`);else{let e=a===0?`http=0`:Ae(a,c.error);s.push(`${i} (${e})`),console.info(`[data-ui] op=drop-file-skip token=${t} rel="${i}" reason=${e}`)}}let c=Math.round(performance.now()-i);console.info(`[data-ui] op=drop-done token=${t} uploaded=${o} skipped=${s.length} ms=${c}`),Ke(`Uploaded ${o}, skipped ${s.length}${s.length?`: ${s.join(`, `)}`:``}`),P(e=>e+1)}catch(e){M(e instanceof Error?e.message:String(e))}finally{Ue(!1),j(null)}},[L,Dt]),Mt=(0,v.useCallback)(async()=>{let t=et.trim();if(t){I(null);try{let n=await e(`/api/admin/files/folder`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:C===`.`?``:C,name:t})}),r=await n.json().catch(()=>({error:`HTTP ${n.status}`}));if(!n.ok)throw Error(r.error??`HTTP ${n.status}`);$e(!1),tt(``),P(e=>e+1)}catch(e){I(e instanceof Error?e.message:String(e))}}},[e,et,C]),Nt=(0,v.useCallback)(async()=>{if(!F)return;let t=rt.trim();if(!t)return;I(null);let n=C===`.`?F:`${C}/${F}`;try{let r=await e(`/api/admin/files/rename`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:n,newName:t})}),i=await r.json().catch(()=>({error:`HTTP ${r.status}`}));if(!r.ok)throw Error(i.error??`HTTP ${r.status}`);nt(null),it(``),X(`action`),P(e=>e+1)}catch(e){I(e instanceof Error?e.message:String(e))}},[e,rt,F,C,X]);(0,v.useEffect)(()=>{if(!R)return;let e=e=>{ot.current&&!ot.current.contains(e.target)&&z(!1)},t=e=>{e.key===`Escape`&&z(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[R]),(0,v.useEffect)(()=>{if(!B)return;let e=e=>{st.current&&!st.current.contains(e.target)&&V(!1)},t=e=>{e.key===`Escape`&&V(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[B]);let $=(0,v.useCallback)(e=>O.slice(0,e+1).map(e=>e.name).join(`/`),[O]),Pt=O.length>=2,Ft=Pt?[{name:`.`,label:`data`},...O.slice(0,O.length-2).map((e,t)=>({name:$(t),label:e.displayName??e.name}))]:[];return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`data-toolbar`,children:[K?(0,y.jsxs)(`button`,{type:`button`,className:`data-select-cancel`,onClick:()=>X(`cancel`),"aria-label":`Cancel selection`,children:[(0,y.jsx)(ne,{size:14}),` Cancel`]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`data-search-input`,children:[r===``&&(0,y.jsx)(ce,{size:14}),(0,y.jsx)(`input`,{ref:s,type:`text`,value:r,onChange:e=>i(e.target.value),autoFocus:!0,autoComplete:`off`,spellCheck:!1}),h&&(0,y.jsx)(c,{size:14,className:`spin`}),r!==``&&(0,y.jsx)(`button`,{type:`button`,className:`data-search-inline-btn`,onClick:()=>{i(``),s.current?.focus()},title:`Clear search`,"aria-label":`Clear search`,children:(0,y.jsx)(ne,{size:14})})]}),(0,y.jsxs)(`div`,{className:`data-toolbar-actions`,ref:st,children:[(0,y.jsx)(`button`,{type:`button`,className:`data-action-overflow`,onClick:()=>V(e=>!e),"aria-haspopup":`menu`,"aria-expanded":B,"aria-label":`File actions`,title:`File actions`,children:(0,y.jsx)(de,{size:16})}),(0,y.jsxs)(`div`,{className:`data-action-group`,role:`group`,"aria-label":`File actions`,"data-open":B?`true`:void 0,children:[(0,y.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{ut(),V(!1)},disabled:k,title:`Refresh this folder`,"aria-label":`Refresh this folder`,children:[k?(0,y.jsx)(c,{size:16,className:`spin`}):(0,y.jsx)(o,{size:16}),(0,y.jsx)(`span`,{className:`data-action-label`,children:`Refresh`})]}),(0,y.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{Et(),V(!1)},disabled:He||!L,title:L?`Upload a file`:`Open a folder inside your account to upload`,"aria-label":`Upload a file`,children:[He?A&&A.total>0?(0,y.jsxs)(`span`,{className:`data-upload-pct`,children:[Math.round(A.loaded/A.total*100),`%`]}):(0,y.jsx)(c,{size:16,className:`spin`}):(0,y.jsx)(_e,{size:16}),(0,y.jsx)(`span`,{className:`data-action-label`,children:`Upload`})]}),(0,y.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{$e(e=>!e),tt(``),I(null),V(!1)},disabled:He||!L,title:L?`New folder`:`Open a folder inside your account to create one`,"aria-label":`New folder`,children:[(0,y.jsx)(fe,{size:16}),(0,y.jsx)(`span`,{className:`data-action-label`,children:`New folder`})]}),(0,y.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{yt(E===`grid`?`list`:`grid`),V(!1)},title:E===`grid`?`List view`:`Grid view`,"aria-label":E===`grid`?`Switch to list view`:`Switch to grid view`,"aria-pressed":E===`grid`,children:[E===`grid`?(0,y.jsx)(he,{size:16}):(0,y.jsx)(me,{size:16}),(0,y.jsx)(`span`,{className:`data-action-label`,children:E===`grid`?`List view`:`Grid view`})]})]})]})]}),(0,y.jsxs)(`div`,{className:`data-breadcrumbs`,children:[C!==`.`&&(0,y.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost data-back-btn`,onClick:ft,title:`Up one level`,"aria-label":`Up one level`,children:(0,y.jsx)(ue,{size:14})}),Pt?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`span`,{className:`data-crumb-wrap`,ref:ot,children:[(0,y.jsx)(`button`,{type:`button`,className:`data-crumb data-crumb-ellipsis`,onClick:()=>z(e=>!e),"aria-haspopup":`menu`,"aria-expanded":R,"aria-label":`Show parent folders`,title:`Show parent folders`,children:`…`}),R&&(0,y.jsx)(`div`,{className:`data-crumb-menu`,role:`menu`,children:Ft.map(e=>(0,y.jsx)(`button`,{type:`button`,role:`menuitem`,className:`data-crumb-menu-item`,onClick:()=>W(e.name),title:e.label,children:e.label},e.name))})]}),[O.length-2,O.length-1].map(e=>{let t=O[e];return(0,y.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,y.jsx)(`span`,{className:`data-crumb-sep`,children:`/`}),(0,y.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>W($(e)),title:t.name,children:t.displayName??t.name})]},$(e))})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>W(`.`),children:`data`}),O.map((e,t)=>(0,y.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,y.jsx)(`span`,{className:`data-crumb-sep`,children:`/`}),(0,y.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>W($(t)),title:e.name,children:e.displayName??e.name})]},$(t)))]})]}),Qe&&(0,y.jsxs)(`div`,{className:`data-inline-form`,children:[(0,y.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`Folder name`,value:et,autoFocus:!0,onChange:e=>tt(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Mt(),e.key===`Escape`&&$e(!1)}}),(0,y.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:Mt,children:`Create`}),(0,y.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost`,onClick:()=>$e(!1),children:`Cancel`})]}),F&&(0,y.jsxs)(`div`,{className:`data-inline-form`,children:[(0,y.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`New name`,value:rt,autoFocus:!0,onChange:e=>it(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Nt(),e.key===`Escape`&&nt(null)}}),(0,y.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:Nt,children:`Rename`}),(0,y.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost`,onClick:()=>nt(null),children:`Cancel`})]}),at&&(0,y.jsx)(`div`,{className:`data-error`,children:at}),(0,y.jsx)(`input`,{type:`file`,ref:N,hidden:!0,onChange:e=>{let t=e.target.files?.[0];t&&Ot(t)}})]}),(0,y.jsxs)(`div`,{className:`data-body`,"data-drag-active":qe?`true`:void 0,onDragEnter:kt,onDragOver:kt,onDragLeave:At,onDrop:jt,children:[(le!==null||d!==null)&&(0,y.jsxs)(`section`,{className:`data-panel`,children:[le&&(0,y.jsxs)(`div`,{className:`data-error`,children:[`Search failed: `,le]}),ct.length>0&&(0,y.jsx)(`div`,{className:`data-chip-row`,role:`group`,"aria-label":`Filter by type`,children:ct.map(e=>{let t=e===H;return(0,y.jsx)(`button`,{type:`button`,className:`data-chip`,"data-active":t,onClick:()=>ye(t?null:e),children:Ne([e])??e},e)})}),d&&!h&&(0,y.jsxs)(`div`,{className:`data-results-meta`,children:[U.length,` of `,d.length,` result`,d.length===1?``:`s`]}),d&&!h&&!H&&x>0&&!S&&(0,y.jsxs)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>Oe(!0),children:[x,` low-confidence result`,x===1?``:`s`,` hidden — show all`]}),d&&!h&&!H&&S&&(0,y.jsx)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>Oe(!1),children:`Showing all results — hide low-confidence`}),d&&d.length===0&&!h&&(0,y.jsx)(`div`,{className:`data-empty-results`,children:`No matches. Try a different keyword.`}),U&&U.length>0&&(0,y.jsx)(`ul`,{className:`data-results`,children:U.map(e=>(0,y.jsx)(Me,{hit:e,mode:ie,onDownload:lt,onLocate:dt},e.nodeId))})]}),(0,y.jsxs)(`section`,{className:`data-panel`,children:[A&&(0,y.jsxs)(`div`,{className:`data-upload-progress`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":A.total>0?Math.round(A.loaded/A.total*100):void 0,children:[(0,y.jsx)(`div`,{className:`data-upload-progress-track`,children:(0,y.jsx)(`div`,{className:`data-upload-progress-fill`,style:{width:`${A.total>0?Math.round(A.loaded/A.total*100):0}%`}})}),(0,y.jsxs)(`span`,{className:`data-upload-progress-label`,children:[`Uploading… `,A.total>0?`${Math.round(A.loaded/A.total*100)}%`:``]})]}),We&&(0,y.jsxs)(`div`,{className:`data-error`,children:[`Upload failed: `,We]}),Ge&&(0,y.jsx)(`div`,{className:`data-status`,children:Ge}),Ye&&(0,y.jsxs)(`div`,{className:`data-error`,children:[`Delete failed: `,Ye]}),Be&&(0,y.jsx)(`div`,{className:`data-error`,children:Be}),k&&(0,y.jsxs)(`div`,{className:`data-loading`,children:[(0,y.jsx)(c,{size:14,className:`spin`}),` Loading…`]}),!K&&!k&&T&&T.length>0&&(0,y.jsxs)(`div`,{className:`data-select-hint`,children:[(0,y.jsx)(ge,{size:13}),(0,y.jsx)(`span`,{children:`Press and hold a file to select, rename, or delete it.`})]}),!k&&T&&T.length===0&&!Be&&(0,y.jsx)(`div`,{className:`data-empty-results`,children:`Empty directory.`}),!k&&T&&T.length>0&&E===`grid`&&(0,y.jsx)(`ul`,{className:`data-grid`,children:T.map(e=>{let n=e.displayName??e.name,r=K&&q.has(e.name);if(e.kind===`directory`)return(0,y.jsx)(`li`,{className:`data-grid-cell`,"data-selected":r?`true`:void 0,children:(0,y.jsxs)(`button`,{type:`button`,className:`data-grid-tile`,onPointerDown:()=>_t(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}W(C===`.`?e.name:`${C}/${e.name}`)},children:[K&&(0,y.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,y.jsx)(pe,{size:28,className:`data-grid-glyph`}),(0,y.jsx)(`span`,{className:`data-grid-label`,title:e.name,children:n})]})},e.name);if(e.kind===`file`){let i=be(e.name),o=C===`.`?e.name:`${C}/${e.name}`;return(0,y.jsx)(`li`,{className:`data-grid-cell`,"data-selected":r?`true`:void 0,children:(0,y.jsxs)(`button`,{type:`button`,className:`data-grid-tile${i?` data-grid-tile-image`:``}`,onPointerDown:()=>_t(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>i?bt(e):vt(e),title:K?void 0:i?`Preview ${n}`:`Download ${n}`,children:[K&&(0,y.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),i?(0,y.jsx)(`img`,{className:`data-grid-thumb`,src:p(t,o),alt:n,loading:`lazy`,onError:()=>console.warn(`[data] op=thumb-error path=${o}`)}):(0,y.jsx)(a,{size:28,className:`data-grid-glyph`}),(0,y.jsx)(`span`,{className:`data-grid-label`,title:e.name,children:n}),!i&&(0,y.jsx)(`span`,{className:`data-grid-sub`,children:Fe(e.sizeBytes)})]})},e.name)}return(0,y.jsx)(`li`,{className:`data-grid-cell`,children:(0,y.jsxs)(`div`,{className:`data-grid-tile data-entry-disabled`,children:[(0,y.jsx)(a,{size:28,className:`data-grid-glyph`}),(0,y.jsx)(`span`,{className:`data-grid-label`,children:n}),(0,y.jsx)(`span`,{className:`data-grid-sub`,children:`special`})]})},e.name)})}),!k&&T&&T.length>0&&E===`list`&&(0,y.jsx)(`ul`,{className:`data-entries`,children:T.map(e=>{let t=e.displayName??e.name;if(e.kind===`directory`){let n=K&&q.has(e.name);return(0,y.jsx)(`li`,{className:`data-entry`,"data-selected":n?`true`:void 0,children:(0,y.jsxs)(`button`,{type:`button`,className:`data-entry-btn`,onPointerDown:()=>_t(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}W(C===`.`?e.name:`${C}/${e.name}`)},children:[K&&(0,y.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,y.jsx)(pe,{size:14}),(0,y.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t})]})},e.name)}if(e.kind===`file`){let n=K&&q.has(e.name);return(0,y.jsx)(`li`,{className:`data-entry`,"data-selected":n?`true`:void 0,children:(0,y.jsxs)(`button`,{type:`button`,className:`data-entry-btn data-entry-file`,onPointerDown:()=>_t(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>vt(e),title:K?void 0:`Download ${t}`,children:[K&&(0,y.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,y.jsxs)(`span`,{className:`data-entry-text`,children:[(0,y.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t}),(0,y.jsxs)(`span`,{className:`data-entry-meta`,title:`Modified ${Ie(e.modifiedAt)}`,children:[Fe(e.sizeBytes),` · `,Ie(e.modifiedAt)]})]})]})},e.name)}return(0,y.jsx)(`li`,{className:`data-entry`,children:(0,y.jsx)(`div`,{className:`data-entry-btn data-entry-file data-entry-disabled`,children:(0,y.jsxs)(`span`,{className:`data-entry-text`,children:[(0,y.jsx)(`span`,{className:`data-entry-name`,children:t}),(0,y.jsx)(`span`,{className:`data-entry-meta`,children:`special`})]})})},e.name)})})]})]}),K&&(0,y.jsx)(`div`,{className:`data-select-bar`,role:`toolbar`,"aria-label":`Selection actions`,children:(0,y.jsxs)(`div`,{className:`data-select-bar-inner`,children:[(0,y.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:Tt,disabled:!Y||q.size===0,title:Y?`Share selected files`:`Sharing is not supported on this device`,children:[(0,y.jsx)(ee,{size:16}),` Share`]}),(0,y.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:Ct,disabled:q.size===0,children:[(0,y.jsx)(se,{size:16}),` Download`]}),(0,y.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:()=>{let e=[...q][0];e&&(nt(e),it(e))},disabled:q.size!==1,children:[(0,y.jsx)(oe,{size:16}),` Rename`]}),(0,y.jsxs)(`button`,{type:`button`,className:`data-select-action data-select-delete`,onClick:wt,disabled:q.size===0,children:[(0,y.jsx)(f,{size:16}),` Delete`]})]})}),D&&(0,y.jsx)(`div`,{className:`chat-attachment-overlay`,role:`dialog`,"aria-label":D.alt,onClick:()=>Le(null),children:(0,y.jsx)(`img`,{className:`chat-attachment-overlay-image`,src:D.src,alt:D.alt})})]})}function T({adminFetch:e,cacheKey:t,sessionRefetchNonce:n}){(0,v.useEffect)(()=>{console.info(`[data-ui] op=mount header=operator home=absent`)},[]);let r=(0,v.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]),i=(0,v.useCallback)(e=>{e===`chat`&&(window.location.href=`/`)},[]),[a,o]=(0,v.useState)([]),[s,c]=(0,v.useState)(`files`),{subAccounts:l,activeAccountId:d,switching:ee,switchAccount:f}=ie(t);return(0,v.useEffect)(()=>{if(!t)return;let e=!1;return fetch(`/api/whatsapp-reader/conversations?session_key=${encodeURIComponent(t)}`).then(e=>e.ok?e.json():{conversations:[]}).then(t=>{e||o(t.conversations??[])}).catch(()=>{}),()=>{e=!0}},[t]),(0,y.jsxs)(`main`,{className:`data-main`,children:[(0,y.jsx)(u,{variant:`operator`,onNavigate:i,onOpenConversations:a.length>0?()=>c(`conversations`):void 0,onToggleSidebar:()=>{},sidebarOpen:!1,onLogout:r,onDisconnect:async()=>!0,disconnecting:!1,subAccounts:l,activeAccountId:d,switchingAccount:ee,onSwitchAccount:f}),s===`conversations`?(0,y.jsx)(ye,{conversations:a,sessionKey:t,onBack:()=>c(`files`)}):(0,y.jsx)(w,{adminFetch:e,cacheKey:t,sessionRefetchNonce:n})]})}function je({cacheKey:e}){let{adminFetch:t,cacheKey:n,sessionRefetchNonce:r}=i({initialCacheKey:e,surface:`data`});return(0,y.jsx)(`div`,{className:`data-page`,children:(0,y.jsx)(`main`,{className:`data-main`,children:(0,y.jsx)(w,{adminFetch:t,cacheKey:n,sessionRefetchNonce:r})})})}function Me({hit:e,mode:t,onDownload:n,onLocate:r}){let i=E(e.properties),a=Pe(e.properties),o=Ne(e.labels),s=D(e.properties),[c,l]=(0,v.useState)(!1),u=a&&a.length>280,d=c||!u?a:a?.slice(0,280)+`…`,ee=t===`bm25`?`bm25 ${e.bm25Score.toFixed(2)}`:`vector ${e.vectorScore.toFixed(2)} · bm25 ${e.bm25Score.toFixed(2)} · combined ${e.score.toFixed(2)}`,f=e.properties.relativePath,te=typeof f==`string`&&f.length>0,ne=te?f.lastIndexOf(`/`):-1,p=te?ne===-1?`data`:f.slice(0,ne):null;return(0,y.jsxs)(`li`,{className:`data-result`,children:[(0,y.jsxs)(`div`,{role:`button`,tabIndex:0,className:`data-result-open`,onClick:()=>n(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n(e))},"aria-label":`Download ${i??o??`file`}`,children:[o&&(0,y.jsx)(`div`,{className:`data-result-header`,children:(0,y.jsx)(`span`,{className:`data-result-labels`,children:o})}),i&&(0,y.jsx)(`div`,{className:`data-result-title`,children:i}),a&&(0,y.jsx)(`pre`,{className:`data-result-body`,children:d}),(0,y.jsxs)(`div`,{className:`data-result-scores`,children:[s&&(0,y.jsxs)(`span`,{className:`data-result-updated`,children:[`Updated `,Ie(s),` · `]}),ee]})]}),te&&(0,y.jsxs)(`button`,{type:`button`,className:`data-result-locate`,onClick:()=>r(e),title:`Locate in ${p}`,"aria-label":`Locate in ${p}`,children:[(0,y.jsx)(pe,{size:12}),p]}),u&&(0,y.jsx)(`button`,{type:`button`,className:`data-result-toggle`,onClick:()=>l(e=>!e),children:c?`Show less`:`Show more`})]})}function Ne(e){if(e.length===0)return null;let t=e[0].replace(/([a-z])([A-Z])/g,`$1 $2`);return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}function E(e){for(let t of[`title`,`name`,`summary`,`headline`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n.length>140?n.slice(0,140)+`…`:n}return null}function Pe(e){for(let t of[`content`,`summary`,`body`,`description`,`text`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}function D(e){for(let t of[`updatedAt`,`modifiedAt`,`fetchedAt`,`createdAt`,`lastModified`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}function Fe(e){return e==null?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${(e/1024/1024/1024).toFixed(1)} GB`}function Ie(e){try{let t=new Date(e);if(isNaN(t.getTime()))return`—`;let n=typeof navigator<`u`?navigator.languages&&navigator.languages.length>0?[...navigator.languages]:[navigator.language]:void 0;return t.toLocaleString(n,{dateStyle:`medium`,timeStyle:`short`})}catch{return`—`}}export{je as n,Te as t};
|
|
1
|
+
import{o as e}from"./chunk-CAM3fms7.js";import{D as t,L as n,M as r,P as i,S as a,_ as o,a as s,b as c,c as l,d as u,f as d,g as ee,h as f,i as te,m as ne,n as p,o as m,r as re,t as ie,u as ae,v as oe,w as se}from"./useSubAccountSwitcher-CsRv6MEd.js";import{t as h}from"./chevron-left-DDselYau.js";import{i as g}from"./Transcript-CRc72hkG.js";import{i as ce,t as le}from"./graph-labels-Ba_fyw6I.js";var ue=t(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),de=t(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),fe=t(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),pe=t(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),me=t(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),he=t(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),ge=t(`mouse-pointer-click`,[[`path`,{d:`M14 4.1 12 6`,key:`ita8i4`}],[`path`,{d:`m5.1 8-2.9-.8`,key:`1go3kf`}],[`path`,{d:`m6 12-1.9 2`,key:`mnht97`}],[`path`,{d:`M7.2 2.2 8 5.1`,key:`1cfko1`}],[`path`,{d:`M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z`,key:`s0h3yz`}]]),_=t(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),_e=t(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]);function ve(e){let t=new Set,n=[];for(let r of e)for(let e of r.labels)e&&(t.has(e)||le.has(e)&&(t.add(e),n.push(e)));return n}var v=e(n(),1),y=r();function b(e){if(!e)return``;let t=new Date(e).getTime();return Number.isFinite(t)?new Date(t).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):``}function ye({conversations:e,sessionKey:t,onBack:n}){let[r,i]=(0,v.useState)(null),a=s(e);return r?(0,y.jsxs)(`div`,{className:`op-conv op-conv-reader`,children:[(0,y.jsxs)(`div`,{className:`op-conv-bar`,children:[(0,y.jsxs)(`button`,{type:`button`,className:`op-conv-back`,onClick:()=>i(null),"aria-label":`Back to conversations`,children:[(0,y.jsx)(h,{size:16}),` Back`]}),(0,y.jsx)(`span`,{className:`op-conv-title`,children:m(r)})]}),(0,y.jsx)(g,{sessionId:r.sessionId,projectDir:r.projectDir,sessionKey:t,forceDeliveredOnly:!0,suppressDirectives:r.source===`store`,store:r.source===`store`?{accountId:r.accountId,remoteJid:r.remoteJid}:void 0},l(r))]}):(0,y.jsxs)(`div`,{className:`op-conv op-conv-list`,children:[(0,y.jsxs)(`div`,{className:`op-conv-bar`,children:[(0,y.jsxs)(`button`,{type:`button`,className:`op-conv-back`,onClick:n,"aria-label":`Back to chat`,children:[(0,y.jsx)(h,{size:16}),` Chat`]}),(0,y.jsx)(`span`,{className:`op-conv-title`,children:`Conversations`})]}),a.map(e=>(0,y.jsxs)(`div`,{className:`op-conv-group`,children:[(0,y.jsxs)(`div`,{className:`op-conv-group-head`,children:[(0,y.jsx)(ae,{channel:e.channel,size:14}),e.label]}),e.rows.map(e=>(0,y.jsxs)(`button`,{type:`button`,className:`op-conv-row`,onClick:()=>{console.info(`[operator-ui] op=reader-open channel=${e.channel} key=${l(e)} readonly=true source=${e.source}`),i(e)},children:[(0,y.jsx)(`span`,{className:`op-conv-name`,children:m(e)}),e.modelGated&&(0,y.jsx)(`span`,{className:`op-conv-gated`,role:`img`,"aria-label":`Model unavailable`,children:(0,y.jsx)(_,{size:13})}),(0,y.jsx)(`span`,{className:`op-conv-when`,children:b(e.lastMessageAt)})]},l(e)))]},e.channel))]})}var x=/\.(png|jpe?g|gif|webp|svg)$/i;function be(e){return x.test(e)}var xe=`maxy-data-view`,Se=95*1024*1024,Ce=48*1024*1024;function we(){return typeof window>`u`?`list`:window.localStorage.getItem(xe)===`grid`?`grid`:`list`}function Te(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!n){t(null),r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`;return}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]),n?e?(0,y.jsx)(d,{cacheKey:e,surface:`data`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=data`);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},children:(0,y.jsx)(`div`,{className:`data-page data-page-full`,children:(0,y.jsx)(S,{cacheKey:e})})}):(0,y.jsx)(`div`,{className:`data-page`,children:(0,y.jsxs)(`div`,{className:`data-empty`,children:[(0,y.jsx)(`p`,{children:`You are not signed in.`}),(0,y.jsxs)(`p`,{children:[`Open the `,(0,y.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,y.jsx)(`div`,{className:`data-page`,children:(0,y.jsxs)(`div`,{className:`data-loading`,children:[(0,y.jsx)(c,{size:18,className:`spin`}),` Loading…`]})})}function S({cacheKey:e}){let{adminFetch:t,cacheKey:n,sessionRefetchNonce:r}=i({initialCacheKey:e,surface:`data`});return(0,y.jsx)(T,{adminFetch:t,cacheKey:n,sessionRefetchNonce:r})}function Ee(){if(typeof window>`u`)return`.`;let e=new URLSearchParams(window.location.hash.replace(/^#/,``)).get(`path`);return e&&e.length>0?e:`.`}function De(e){if(typeof window>`u`)return;let t=new URL(window.location.href);t.hash=e===`.`?``:`path=${encodeURIComponent(e)}`,window.history.replaceState(window.history.state,``,t.toString())}function Oe(e){return new Promise((t,n)=>{let r=[],i=()=>e.readEntries(e=>{e.length===0?t(r):(r.push(...e),i())},n);i()})}function C(e){return new Promise((t,n)=>e.file(t,n))}async function ke(e,t=``){let n=[];for(let r of e){if(!r)continue;let e=t?`${t}/${r.name}`:r.name;if(r.isFile)n.push({file:await C(r),relpath:e});else if(r.isDirectory){let t=await Oe(r.createReader());n.push(...await ke(t,e))}}return n}function Ae(e,t){if(e===422&&typeof t==`string`){if(/exceeds the .* limit/i.test(t))return`size`;if(/unsupported file type/i.test(t))return`mime`}return`http=${e}`}function w({adminFetch:e,cacheKey:t,sessionRefetchNonce:n}){let[r,i]=(0,v.useState)(``),s=(0,v.useRef)(null),[l,u]=(0,v.useState)(``),[d,m]=(0,v.useState)(null),[ie,ae]=(0,v.useState)(`hybrid`),[h,g]=(0,v.useState)(!1),[le,_]=(0,v.useState)(null),[b,ye]=(0,v.useState)(null),[x,Te]=(0,v.useState)(0),[S,Oe]=(0,v.useState)(!1),[C,w]=(0,v.useState)(()=>Ee()),[T,je]=(0,v.useState)(null),[E,Pe]=(0,v.useState)(()=>we()),[D,Le]=(0,v.useState)(null),[O,Re]=(0,v.useState)([]),[k,ze]=(0,v.useState)(!1),[Be,Ve]=(0,v.useState)(null),[He,Ue]=(0,v.useState)(!1),[A,j]=(0,v.useState)(null),[We,M]=(0,v.useState)(null),[Ge,Ke]=(0,v.useState)(null),[qe,Je]=(0,v.useState)(!1),[Ye,Xe]=(0,v.useState)(null),N=(0,v.useRef)(null),[Ze,P]=(0,v.useState)(0),[Qe,$e]=(0,v.useState)(!1),[et,tt]=(0,v.useState)(``),[F,nt]=(0,v.useState)(null),[rt,it]=(0,v.useState)(``),[at,I]=(0,v.useState)(null),L=(()=>{let e=C===`.`?[]:C.split(`/`).filter(Boolean);return e.length>=2&&e[0]===`accounts`})(),[R,z]=(0,v.useState)(!1),ot=(0,v.useRef)(null),[B,V]=(0,v.useState)(!1),st=(0,v.useRef)(null);(0,v.useEffect)(()=>{let e=r.trim();if(!e){u(``),m(null),_(null);return}Oe(!1);let t=setTimeout(()=>u(e),300);return()=>clearTimeout(t)},[r]),(0,v.useEffect)(()=>{if(!l){g(!1);return}let t=!1;return g(!0),_(null),e(`/api/admin/graph-search?q=${encodeURIComponent(l)}&labels=FileArtifact&limit=20${S?`&threshold=0`:``}`).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{t||(m(e.results),ae(e.mode??`hybrid`),Te(typeof e.suppressed==`number`?e.suppressed:0))}).catch(e=>{t||_(e instanceof Error?e.message:String(e))}).finally(()=>{t||g(!1)}),()=>{t=!0}},[l,e,n,S]);let ct=(0,v.useMemo)(()=>d?ve(d):[],[d]),H=b&&ct.includes(b)?b:null,U=(0,v.useMemo)(()=>d?H?d.filter(e=>e.labels.includes(H)):d:null,[d,H]),lt=(0,v.useCallback)(e=>{let n=e.properties.relativePath;if(typeof n!=`string`||n.length===0)return;let r=`/api/admin/files/download?session_key=${encodeURIComponent(t)}&path=${encodeURIComponent(n)}`,i=document.createElement(`a`);i.href=r,i.rel=`noopener noreferrer`,document.body.appendChild(i),i.click(),i.remove()},[t]);(0,v.useEffect)(()=>{if(!d)return;let e=d.filter(e=>{let t=e.properties.relativePath;return typeof t!=`string`||t.length===0});e.length>0&&console.warn(`[data-search] op=locate-link-missing nodeId=${e.map(e=>e.nodeId).join(`,`)}`)},[d]),(0,v.useEffect)(()=>{let t=!1;return ze(!0),Ve(null),e(`/api/admin/files?path=${encodeURIComponent(C===`.`?``:C)}`).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{t||(je(e.entries),Re(e.displayPath??[]))}).catch(e=>{t||(je([]),Re([]),Ve(e instanceof Error?e.message:String(e)))}).finally(()=>{t||ze(!1)}),()=>{t=!0}},[e,C,Ze,n]),(0,v.useEffect)(()=>{De(C)},[C]);let ut=(0,v.useCallback)(()=>{P(e=>e+1)},[]),W=(0,v.useCallback)(e=>{z(!1),w(e)},[]),dt=(0,v.useCallback)(e=>{let t=e.properties.relativePath;if(typeof t!=`string`||t.length===0)return;let n=t.lastIndexOf(`/`),r=n===-1?`.`:t.slice(0,n);console.log(`[data-search] op=locate nodeId=${e.nodeId} folder=${r}`),i(``),_(null),ye(null),W(r)},[W]),ft=(0,v.useCallback)(()=>{if(C===`.`||C===``)return;let e=C.split(`/`).filter(Boolean);e.pop(),w(e.length===0?`.`:e.join(`/`))},[C]),G=(0,v.useCallback)(e=>{re(t,C===`.`?e.name:`${C}/${e.name}`)},[C,t]),[K,pt]=(0,v.useState)(!1),[q,mt]=(0,v.useState)(new Set),ht=(0,v.useRef)(null),J=(0,v.useRef)(!1),Y=typeof navigator<`u`&&typeof navigator.share==`function`&&typeof navigator.canShare==`function`,gt=(0,v.useCallback)(e=>{pt(!0),mt(new Set([e])),console.info(`[data-ui] op=select-enter count=1`)},[]),X=(0,v.useCallback)(e=>{pt(!1),mt(new Set),console.info(`[data-ui] op=select-exit reason=${e}`)},[]),Z=(0,v.useCallback)(e=>{mt(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),_t=(0,v.useCallback)(e=>{J.current=!1,ht.current=setTimeout(()=>{J.current=!0,gt(e)},500)},[gt]),Q=(0,v.useCallback)(()=>{ht.current&&=(clearTimeout(ht.current),null)},[]),vt=(0,v.useCallback)(e=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}G(e)},[K,Z,G]),yt=(0,v.useCallback)(e=>{Pe(e),typeof window<`u`&&window.localStorage.setItem(xe,e),console.info(`[data] op=view-mode mode=${e}`)},[]),bt=(0,v.useCallback)(e=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}Le({src:p(t,C===`.`?e.name:`${C}/${e.name}`),alt:e.displayName??e.name})},[K,Z,C,t]),xt=(0,v.useCallback)(()=>(T??[]).filter(e=>e.kind===`file`&&q.has(e.name)),[T,q]),St=(0,v.useCallback)(()=>(T??[]).filter(e=>(e.kind===`file`||e.kind===`directory`)&&q.has(e.name)),[T,q]),Ct=(0,v.useCallback)(()=>{let e=St(),n=e.some(e=>e.kind===`directory`);e.length===1&&!n?G(e[0]):e.length>=1&&te(t,e.map(e=>C===`.`?e.name:`${C}/${e.name}`)),X(`action`)},[St,G,C,t,X]),wt=(0,v.useCallback)(async()=>{let t=xt(),n=t.filter(e=>!e.protected),r=t.length-n.length;Xe(r>0?`${r} protected file(s) kept`:null);for(let t of n){let n=C===`.`?t.name:`${C}/${t.name}`;try{let t=await e(`/api/admin/files?path=${encodeURIComponent(n)}`,{method:`DELETE`}),r=await t.json().catch(()=>({error:`HTTP ${t.status}`}));if(!t.ok)throw Error(r.error??`HTTP ${t.status}`)}catch(e){Xe(e instanceof Error?e.message:String(e))}}P(e=>e+1),X(`action`)},[xt,C,e,X]),Tt=(0,v.useCallback)(async()=>{let e=xt();if(console.info(`[data-ui] op=share supported=${Y} count=${e.length}`),Y)try{let n=await Promise.all(e.map(async e=>{let n=C===`.`?e.name:`${C}/${e.name}`,r=`/api/admin/files/download?session_key=${encodeURIComponent(t)}&path=${encodeURIComponent(n)}`,i=await(await fetch(r)).blob();return new File([i],e.name,{type:i.type||`application/octet-stream`})}));navigator.canShare({files:n})&&await navigator.share({files:n})}catch(e){console.warn(`[data-ui] op=share-failed err=${e instanceof Error?e.message:String(e)}`)}},[xt,Y,C,t]),Et=(0,v.useCallback)(()=>{N.current?.click()},[]),Dt=(0,v.useCallback)((e,n={})=>{let r=(r,i,a)=>{let o=new URLSearchParams({session_key:t,path:C===`.`?``:C,filename:e.name});n.relpath&&o.set(`relpath`,n.relpath),n.token&&o.set(`token`,n.token);for(let[e,t]of Object.entries(i))o.set(e,t);return new Promise(t=>{let n=new XMLHttpRequest;n.open(`POST`,`/api/admin/files/upload?${o.toString()}`),n.setRequestHeader(`Content-Type`,e.type||`application/octet-stream`),a&&(n.upload.onprogress=e=>{e.lengthComputable&&a(e.loaded)}),n.onload=()=>{let e={};try{e=JSON.parse(n.responseText)}catch{}t({status:n.status,data:e})},n.onerror=()=>t({status:0,data:{}}),n.onabort=()=>t({status:0,data:{error:`aborted`}}),n.send(r)})};if(e.size<=Se)return r(e,{},t=>n.onProgress?.(t,e.size));let i=`${Date.now().toString(36)}-${Math.random().toString(16).slice(2,10)}`,a=Math.ceil(e.size/Ce);return(async()=>{let t={status:0,data:{}};for(let o=0;o<a;o++){let s=o*Ce;if(t=await r(e.slice(s,Math.min(s+Ce,e.size)),{uploadId:i,seq:String(o),total:String(a)},t=>n.onProgress?.(s+t,e.size)),!(t.status>=200&&t.status<300))return t}return t})()},[t,C]),Ot=(0,v.useCallback)(async e=>{M(null),Ue(!0),j({loaded:0,total:e.size});try{let{status:t,data:n}=await Dt(e,{onProgress:(e,t)=>j({loaded:e,total:t})});t>=200&&t<300&&n.path?(w(n.path.split(`/`).slice(0,-1).join(`/`)||`.`),P(e=>e+1)):M(t===0?`Network error during upload — the connection failed before the server responded.`:n.error??`Upload failed (HTTP ${t}).`)}finally{Ue(!1),j(null),N.current&&(N.current.value=``)}},[Dt]),kt=(0,v.useCallback)(e=>{L&&Array.from(e.dataTransfer.types).includes(`Files`)&&(e.preventDefault(),Je(!0))},[L]),At=(0,v.useCallback)(e=>{e.currentTarget.contains(e.relatedTarget)||Je(!1)},[]),jt=(0,v.useCallback)(async e=>{e.preventDefault(),Je(!1);let t=Math.random().toString(16).slice(2,10),n=Array.from(e.dataTransfer.items);if(console.info(`[data-ui] op=drop-received token=${t} items=${n.length}`),n.length===0)return;if(!L){console.info(`[data-ui] op=drop-rejected token=${t} reason=no-write`),M(`Open a folder inside your account to upload`);return}let r=n.map(e=>e.webkitGetAsEntry?.()).filter(e=>!!e);Ue(!0),M(null),Ke(null);let i=performance.now();try{let e=await ke(r),n=e.reduce((e,t)=>e+t.file.size,0),a=new Set(e.map(e=>e.relpath.split(`/`).slice(0,-1).join(`/`)).filter(Boolean)).size;console.info(`[data-ui] op=drop-walk token=${t} files=${e.length} dirs=${a} bytes=${n}`);let o=0,s=[];for(let n=0;n<e.length;n++){let{file:r,relpath:i}=e[n];console.info(`[data-ui] op=drop-file token=${t} rel="${i}" i=${n+1}/${e.length}`),j({loaded:0,total:r.size});let{status:a,data:c}=await Dt(r,{relpath:i,token:t,onProgress:(e,t)=>j({loaded:e,total:t})});if(a>=200&&a<300)o++,console.info(`[data-ui] op=drop-file-ok token=${t} rel="${i}"`);else{let e=a===0?`http=0`:Ae(a,c.error);s.push(`${i} (${e})`),console.info(`[data-ui] op=drop-file-skip token=${t} rel="${i}" reason=${e}`)}}let c=Math.round(performance.now()-i);console.info(`[data-ui] op=drop-done token=${t} uploaded=${o} skipped=${s.length} ms=${c}`),Ke(`Uploaded ${o}, skipped ${s.length}${s.length?`: ${s.join(`, `)}`:``}`),P(e=>e+1)}catch(e){M(e instanceof Error?e.message:String(e))}finally{Ue(!1),j(null)}},[L,Dt]),Mt=(0,v.useCallback)(async()=>{let t=et.trim();if(t){I(null);try{let n=await e(`/api/admin/files/folder`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:C===`.`?``:C,name:t})}),r=await n.json().catch(()=>({error:`HTTP ${n.status}`}));if(!n.ok)throw Error(r.error??`HTTP ${n.status}`);$e(!1),tt(``),P(e=>e+1)}catch(e){I(e instanceof Error?e.message:String(e))}}},[e,et,C]),Nt=(0,v.useCallback)(async()=>{if(!F)return;let t=rt.trim();if(!t)return;I(null);let n=C===`.`?F:`${C}/${F}`;try{let r=await e(`/api/admin/files/rename`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:n,newName:t})}),i=await r.json().catch(()=>({error:`HTTP ${r.status}`}));if(!r.ok)throw Error(i.error??`HTTP ${r.status}`);nt(null),it(``),X(`action`),P(e=>e+1)}catch(e){I(e instanceof Error?e.message:String(e))}},[e,rt,F,C,X]);(0,v.useEffect)(()=>{if(!R)return;let e=e=>{ot.current&&!ot.current.contains(e.target)&&z(!1)},t=e=>{e.key===`Escape`&&z(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[R]),(0,v.useEffect)(()=>{if(!B)return;let e=e=>{st.current&&!st.current.contains(e.target)&&V(!1)},t=e=>{e.key===`Escape`&&V(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[B]);let $=(0,v.useCallback)(e=>O.slice(0,e+1).map(e=>e.name).join(`/`),[O]),Pt=O.length>=2,Ft=Pt?[{name:`.`,label:`data`},...O.slice(0,O.length-2).map((e,t)=>({name:$(t),label:e.displayName??e.name}))]:[];return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`data-toolbar`,children:[K?(0,y.jsxs)(`button`,{type:`button`,className:`data-select-cancel`,onClick:()=>X(`cancel`),"aria-label":`Cancel selection`,children:[(0,y.jsx)(ne,{size:14}),` Cancel`]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`data-search-input`,children:[r===``&&(0,y.jsx)(ce,{size:14}),(0,y.jsx)(`input`,{ref:s,type:`text`,value:r,onChange:e=>i(e.target.value),autoFocus:!0,autoComplete:`off`,spellCheck:!1}),h&&(0,y.jsx)(c,{size:14,className:`spin`}),r!==``&&(0,y.jsx)(`button`,{type:`button`,className:`data-search-inline-btn`,onClick:()=>{i(``),s.current?.focus()},title:`Clear search`,"aria-label":`Clear search`,children:(0,y.jsx)(ne,{size:14})})]}),(0,y.jsxs)(`div`,{className:`data-toolbar-actions`,ref:st,children:[(0,y.jsx)(`button`,{type:`button`,className:`data-action-overflow`,onClick:()=>V(e=>!e),"aria-haspopup":`menu`,"aria-expanded":B,"aria-label":`File actions`,title:`File actions`,children:(0,y.jsx)(de,{size:16})}),(0,y.jsxs)(`div`,{className:`data-action-group`,role:`group`,"aria-label":`File actions`,"data-open":B?`true`:void 0,children:[(0,y.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{ut(),V(!1)},disabled:k,title:`Refresh this folder`,"aria-label":`Refresh this folder`,children:[k?(0,y.jsx)(c,{size:16,className:`spin`}):(0,y.jsx)(o,{size:16}),(0,y.jsx)(`span`,{className:`data-action-label`,children:`Refresh`})]}),(0,y.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{Et(),V(!1)},disabled:He||!L,title:L?`Upload a file`:`Open a folder inside your account to upload`,"aria-label":`Upload a file`,children:[He?A&&A.total>0?(0,y.jsxs)(`span`,{className:`data-upload-pct`,children:[Math.round(A.loaded/A.total*100),`%`]}):(0,y.jsx)(c,{size:16,className:`spin`}):(0,y.jsx)(_e,{size:16}),(0,y.jsx)(`span`,{className:`data-action-label`,children:`Upload`})]}),(0,y.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{$e(e=>!e),tt(``),I(null),V(!1)},disabled:He||!L,title:L?`New folder`:`Open a folder inside your account to create one`,"aria-label":`New folder`,children:[(0,y.jsx)(fe,{size:16}),(0,y.jsx)(`span`,{className:`data-action-label`,children:`New folder`})]}),(0,y.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{yt(E===`grid`?`list`:`grid`),V(!1)},title:E===`grid`?`List view`:`Grid view`,"aria-label":E===`grid`?`Switch to list view`:`Switch to grid view`,"aria-pressed":E===`grid`,children:[E===`grid`?(0,y.jsx)(he,{size:16}):(0,y.jsx)(me,{size:16}),(0,y.jsx)(`span`,{className:`data-action-label`,children:E===`grid`?`List view`:`Grid view`})]})]})]})]}),(0,y.jsxs)(`div`,{className:`data-breadcrumbs`,children:[C!==`.`&&(0,y.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost data-back-btn`,onClick:ft,title:`Up one level`,"aria-label":`Up one level`,children:(0,y.jsx)(ue,{size:14})}),Pt?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`span`,{className:`data-crumb-wrap`,ref:ot,children:[(0,y.jsx)(`button`,{type:`button`,className:`data-crumb data-crumb-ellipsis`,onClick:()=>z(e=>!e),"aria-haspopup":`menu`,"aria-expanded":R,"aria-label":`Show parent folders`,title:`Show parent folders`,children:`…`}),R&&(0,y.jsx)(`div`,{className:`data-crumb-menu`,role:`menu`,children:Ft.map(e=>(0,y.jsx)(`button`,{type:`button`,role:`menuitem`,className:`data-crumb-menu-item`,onClick:()=>W(e.name),title:e.label,children:e.label},e.name))})]}),[O.length-2,O.length-1].map(e=>{let t=O[e];return(0,y.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,y.jsx)(`span`,{className:`data-crumb-sep`,children:`/`}),(0,y.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>W($(e)),title:t.name,children:t.displayName??t.name})]},$(e))})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>W(`.`),children:`data`}),O.map((e,t)=>(0,y.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,y.jsx)(`span`,{className:`data-crumb-sep`,children:`/`}),(0,y.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>W($(t)),title:e.name,children:e.displayName??e.name})]},$(t)))]})]}),Qe&&(0,y.jsxs)(`div`,{className:`data-inline-form`,children:[(0,y.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`Folder name`,value:et,autoFocus:!0,onChange:e=>tt(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Mt(),e.key===`Escape`&&$e(!1)}}),(0,y.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:Mt,children:`Create`}),(0,y.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost`,onClick:()=>$e(!1),children:`Cancel`})]}),F&&(0,y.jsxs)(`div`,{className:`data-inline-form`,children:[(0,y.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`New name`,value:rt,autoFocus:!0,onChange:e=>it(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Nt(),e.key===`Escape`&&nt(null)}}),(0,y.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:Nt,children:`Rename`}),(0,y.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost`,onClick:()=>nt(null),children:`Cancel`})]}),at&&(0,y.jsx)(`div`,{className:`data-error`,children:at}),(0,y.jsx)(`input`,{type:`file`,ref:N,hidden:!0,onChange:e=>{let t=e.target.files?.[0];t&&Ot(t)}})]}),(0,y.jsxs)(`div`,{className:`data-body`,"data-drag-active":qe?`true`:void 0,onDragEnter:kt,onDragOver:kt,onDragLeave:At,onDrop:jt,children:[(le!==null||d!==null)&&(0,y.jsxs)(`section`,{className:`data-panel`,children:[le&&(0,y.jsxs)(`div`,{className:`data-error`,children:[`Search failed: `,le]}),ct.length>0&&(0,y.jsx)(`div`,{className:`data-chip-row`,role:`group`,"aria-label":`Filter by type`,children:ct.map(e=>{let t=e===H;return(0,y.jsx)(`button`,{type:`button`,className:`data-chip`,"data-active":t,onClick:()=>ye(t?null:e),children:Ne([e])??e},e)})}),d&&!h&&(0,y.jsxs)(`div`,{className:`data-results-meta`,children:[U.length,` of `,d.length,` result`,d.length===1?``:`s`]}),d&&!h&&!H&&x>0&&!S&&(0,y.jsxs)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>Oe(!0),children:[x,` low-confidence result`,x===1?``:`s`,` hidden — show all`]}),d&&!h&&!H&&S&&(0,y.jsx)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>Oe(!1),children:`Showing all results — hide low-confidence`}),d&&d.length===0&&!h&&(0,y.jsx)(`div`,{className:`data-empty-results`,children:`No matches. Try a different keyword.`}),U&&U.length>0&&(0,y.jsx)(`ul`,{className:`data-results`,children:U.map(e=>(0,y.jsx)(Me,{hit:e,mode:ie,onDownload:lt,onLocate:dt},e.nodeId))})]}),(0,y.jsxs)(`section`,{className:`data-panel`,children:[A&&(0,y.jsxs)(`div`,{className:`data-upload-progress`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":A.total>0?Math.round(A.loaded/A.total*100):void 0,children:[(0,y.jsx)(`div`,{className:`data-upload-progress-track`,children:(0,y.jsx)(`div`,{className:`data-upload-progress-fill`,style:{width:`${A.total>0?Math.round(A.loaded/A.total*100):0}%`}})}),(0,y.jsxs)(`span`,{className:`data-upload-progress-label`,children:[`Uploading… `,A.total>0?`${Math.round(A.loaded/A.total*100)}%`:``]})]}),We&&(0,y.jsxs)(`div`,{className:`data-error`,children:[`Upload failed: `,We]}),Ge&&(0,y.jsx)(`div`,{className:`data-status`,children:Ge}),Ye&&(0,y.jsxs)(`div`,{className:`data-error`,children:[`Delete failed: `,Ye]}),Be&&(0,y.jsx)(`div`,{className:`data-error`,children:Be}),k&&(0,y.jsxs)(`div`,{className:`data-loading`,children:[(0,y.jsx)(c,{size:14,className:`spin`}),` Loading…`]}),!K&&!k&&T&&T.length>0&&(0,y.jsxs)(`div`,{className:`data-select-hint`,children:[(0,y.jsx)(ge,{size:13}),(0,y.jsx)(`span`,{children:`Press and hold a file to select, rename, or delete it.`})]}),!k&&T&&T.length===0&&!Be&&(0,y.jsx)(`div`,{className:`data-empty-results`,children:`Empty directory.`}),!k&&T&&T.length>0&&E===`grid`&&(0,y.jsx)(`ul`,{className:`data-grid`,children:T.map(e=>{let n=e.displayName??e.name,r=K&&q.has(e.name);if(e.kind===`directory`)return(0,y.jsx)(`li`,{className:`data-grid-cell`,"data-selected":r?`true`:void 0,children:(0,y.jsxs)(`button`,{type:`button`,className:`data-grid-tile`,onPointerDown:()=>_t(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}W(C===`.`?e.name:`${C}/${e.name}`)},children:[K&&(0,y.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,y.jsx)(pe,{size:28,className:`data-grid-glyph`}),(0,y.jsx)(`span`,{className:`data-grid-label`,title:e.name,children:n})]})},e.name);if(e.kind===`file`){let i=be(e.name),o=C===`.`?e.name:`${C}/${e.name}`;return(0,y.jsx)(`li`,{className:`data-grid-cell`,"data-selected":r?`true`:void 0,children:(0,y.jsxs)(`button`,{type:`button`,className:`data-grid-tile${i?` data-grid-tile-image`:``}`,onPointerDown:()=>_t(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>i?bt(e):vt(e),title:K?void 0:i?`Preview ${n}`:`Download ${n}`,children:[K&&(0,y.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),i?(0,y.jsx)(`img`,{className:`data-grid-thumb`,src:p(t,o),alt:n,loading:`lazy`,onError:()=>console.warn(`[data] op=thumb-error path=${o}`)}):(0,y.jsx)(a,{size:28,className:`data-grid-glyph`}),(0,y.jsx)(`span`,{className:`data-grid-label`,title:e.name,children:n}),!i&&(0,y.jsx)(`span`,{className:`data-grid-sub`,children:Fe(e.sizeBytes)})]})},e.name)}return(0,y.jsx)(`li`,{className:`data-grid-cell`,children:(0,y.jsxs)(`div`,{className:`data-grid-tile data-entry-disabled`,children:[(0,y.jsx)(a,{size:28,className:`data-grid-glyph`}),(0,y.jsx)(`span`,{className:`data-grid-label`,children:n}),(0,y.jsx)(`span`,{className:`data-grid-sub`,children:`special`})]})},e.name)})}),!k&&T&&T.length>0&&E===`list`&&(0,y.jsx)(`ul`,{className:`data-entries`,children:T.map(e=>{let t=e.displayName??e.name;if(e.kind===`directory`){let n=K&&q.has(e.name);return(0,y.jsx)(`li`,{className:`data-entry`,"data-selected":n?`true`:void 0,children:(0,y.jsxs)(`button`,{type:`button`,className:`data-entry-btn`,onPointerDown:()=>_t(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}W(C===`.`?e.name:`${C}/${e.name}`)},children:[K&&(0,y.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,y.jsx)(pe,{size:14}),(0,y.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t})]})},e.name)}if(e.kind===`file`){let n=K&&q.has(e.name);return(0,y.jsx)(`li`,{className:`data-entry`,"data-selected":n?`true`:void 0,children:(0,y.jsxs)(`button`,{type:`button`,className:`data-entry-btn data-entry-file`,onPointerDown:()=>_t(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>vt(e),title:K?void 0:`Download ${t}`,children:[K&&(0,y.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,y.jsxs)(`span`,{className:`data-entry-text`,children:[(0,y.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t}),(0,y.jsxs)(`span`,{className:`data-entry-meta`,title:`Modified ${Ie(e.modifiedAt)}`,children:[Fe(e.sizeBytes),` · `,Ie(e.modifiedAt)]})]})]})},e.name)}return(0,y.jsx)(`li`,{className:`data-entry`,children:(0,y.jsx)(`div`,{className:`data-entry-btn data-entry-file data-entry-disabled`,children:(0,y.jsxs)(`span`,{className:`data-entry-text`,children:[(0,y.jsx)(`span`,{className:`data-entry-name`,children:t}),(0,y.jsx)(`span`,{className:`data-entry-meta`,children:`special`})]})})},e.name)})})]})]}),K&&(0,y.jsx)(`div`,{className:`data-select-bar`,role:`toolbar`,"aria-label":`Selection actions`,children:(0,y.jsxs)(`div`,{className:`data-select-bar-inner`,children:[(0,y.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:Tt,disabled:!Y||q.size===0,title:Y?`Share selected files`:`Sharing is not supported on this device`,children:[(0,y.jsx)(ee,{size:16}),` Share`]}),(0,y.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:Ct,disabled:q.size===0,children:[(0,y.jsx)(se,{size:16}),` Download`]}),(0,y.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:()=>{let e=[...q][0];e&&(nt(e),it(e))},disabled:q.size!==1,children:[(0,y.jsx)(oe,{size:16}),` Rename`]}),(0,y.jsxs)(`button`,{type:`button`,className:`data-select-action data-select-delete`,onClick:wt,disabled:q.size===0,children:[(0,y.jsx)(f,{size:16}),` Delete`]})]})}),D&&(0,y.jsx)(`div`,{className:`chat-attachment-overlay`,role:`dialog`,"aria-label":D.alt,onClick:()=>Le(null),children:(0,y.jsx)(`img`,{className:`chat-attachment-overlay-image`,src:D.src,alt:D.alt})})]})}function T({adminFetch:e,cacheKey:t,sessionRefetchNonce:n}){(0,v.useEffect)(()=>{console.info(`[data-ui] op=mount header=operator home=absent`)},[]);let r=(0,v.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]),i=(0,v.useCallback)(e=>{e===`chat`&&(window.location.href=`/`)},[]),[a,o]=(0,v.useState)([]),[s,c]=(0,v.useState)(`files`),{subAccounts:l,activeAccountId:d,switching:ee,switchAccount:f}=ie(t);return(0,v.useEffect)(()=>{if(!t)return;let e=!1;return fetch(`/api/whatsapp-reader/conversations?session_key=${encodeURIComponent(t)}`).then(e=>e.ok?e.json():{conversations:[]}).then(t=>{e||o(t.conversations??[])}).catch(()=>{}),()=>{e=!0}},[t]),(0,y.jsxs)(`main`,{className:`data-main`,children:[(0,y.jsx)(u,{variant:`operator`,onNavigate:i,onOpenConversations:a.length>0?()=>c(`conversations`):void 0,onToggleSidebar:()=>{},sidebarOpen:!1,onLogout:r,onDisconnect:async()=>!0,disconnecting:!1,subAccounts:l,activeAccountId:d,switchingAccount:ee,onSwitchAccount:f}),s===`conversations`?(0,y.jsx)(ye,{conversations:a,sessionKey:t,onBack:()=>c(`files`)}):(0,y.jsx)(w,{adminFetch:e,cacheKey:t,sessionRefetchNonce:n})]})}function je({cacheKey:e}){let{adminFetch:t,cacheKey:n,sessionRefetchNonce:r}=i({initialCacheKey:e,surface:`data`});return(0,y.jsx)(`div`,{className:`data-page`,children:(0,y.jsx)(`main`,{className:`data-main`,children:(0,y.jsx)(w,{adminFetch:t,cacheKey:n,sessionRefetchNonce:r})})})}function Me({hit:e,mode:t,onDownload:n,onLocate:r}){let i=E(e.properties),a=Pe(e.properties),o=Ne(e.labels),s=D(e.properties),[c,l]=(0,v.useState)(!1),u=a&&a.length>280,d=c||!u?a:a?.slice(0,280)+`…`,ee=t===`bm25`?`bm25 ${e.bm25Score.toFixed(2)}`:`vector ${e.vectorScore.toFixed(2)} · bm25 ${e.bm25Score.toFixed(2)} · combined ${e.score.toFixed(2)}`,f=e.properties.relativePath,te=typeof f==`string`&&f.length>0,ne=te?f.lastIndexOf(`/`):-1,p=te?ne===-1?`data`:f.slice(0,ne):null;return(0,y.jsxs)(`li`,{className:`data-result`,children:[(0,y.jsxs)(`div`,{role:`button`,tabIndex:0,className:`data-result-open`,onClick:()=>n(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n(e))},"aria-label":`Download ${i??o??`file`}`,children:[o&&(0,y.jsx)(`div`,{className:`data-result-header`,children:(0,y.jsx)(`span`,{className:`data-result-labels`,children:o})}),i&&(0,y.jsx)(`div`,{className:`data-result-title`,children:i}),a&&(0,y.jsx)(`pre`,{className:`data-result-body`,children:d}),(0,y.jsxs)(`div`,{className:`data-result-scores`,children:[s&&(0,y.jsxs)(`span`,{className:`data-result-updated`,children:[`Updated `,Ie(s),` · `]}),ee]})]}),te&&(0,y.jsxs)(`button`,{type:`button`,className:`data-result-locate`,onClick:()=>r(e),title:`Locate in ${p}`,"aria-label":`Locate in ${p}`,children:[(0,y.jsx)(pe,{size:12}),p]}),u&&(0,y.jsx)(`button`,{type:`button`,className:`data-result-toggle`,onClick:()=>l(e=>!e),children:c?`Show less`:`Show more`})]})}function Ne(e){if(e.length===0)return null;let t=e[0].replace(/([a-z])([A-Z])/g,`$1 $2`);return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}function E(e){for(let t of[`title`,`name`,`summary`,`headline`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n.length>140?n.slice(0,140)+`…`:n}return null}function Pe(e){for(let t of[`content`,`summary`,`body`,`description`,`text`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}function D(e){for(let t of[`updatedAt`,`modifiedAt`,`fetchedAt`,`createdAt`,`lastModified`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}function Fe(e){return e==null?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${(e/1024/1024/1024).toFixed(1)} GB`}function Ie(e){try{let t=new Date(e);if(isNaN(t.getTime()))return`—`;let n=typeof navigator<`u`?navigator.languages&&navigator.languages.length>0?[...navigator.languages]:[navigator.language]:void 0;return t.toLocaleString(n,{dateStyle:`medium`,timeStyle:`short`})}catch{return`—`}}export{je as n,Te as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CAM3fms7.js";import{F as t,L as n,M as r}from"./useSubAccountSwitcher-
|
|
1
|
+
import{o as e}from"./chunk-CAM3fms7.js";import{F as t,L as n,M as r}from"./useSubAccountSwitcher-CsRv6MEd.js";import"./admin-types-hioowVct.js";import{y as i}from"./AdminShell-CBcSh9Yd.js";import{a,c as o,i as s,o as c,r as l,s as u}from"./page-Bj6lB07z.js";import"./Transcript-CRc72hkG.js";var d=t(),f=e(n(),1),p=r();function m({gateState:e,setGateState:t,grantInfo:n,resolvedSlugRef:r}){let[a,o]=(0,f.useState)(``),[s,c]=(0,f.useState)(!1),[l,u]=(0,f.useState)(null);async function d(e){e.preventDefault();let n=a.trim().toLowerCase();if(!n){u(`Enter the email you were invited on.`);return}c(!0),u(null);try{let e=await fetch(`/api/access/request-magic-link`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({contactValue:n,agentSlug:r.current})});if(e.status===429){u((await e.json().catch(()=>({})))?.error||`Too many requests. Try again later.`);return}t(`request-sent`)}catch{u(`Could not reach the server. Check your connection and try again.`)}finally{c(!1)}}return(0,p.jsxs)(`div`,{className:`access-gate`,children:[e===`verifying`&&(0,p.jsxs)(`div`,{className:`access-gate-message`,children:[(0,p.jsx)(`h2`,{children:`Verifying your link…`}),(0,p.jsx)(`p`,{children:`This takes a moment.`})]}),e===`verify-failed`&&(0,p.jsxs)(`div`,{className:`access-gate-message`,children:[(0,p.jsx)(`h2`,{children:`That link did not work`}),(0,p.jsx)(`p`,{children:`It may have expired, already been used, or been for a different agent. You can request a fresh one below.`}),(0,p.jsx)(i,{onClick:()=>{t(`request-link`),u(null)},children:`Request a new link`})]}),e===`request-link`&&(0,p.jsxs)(`form`,{className:`access-gate-form`,onSubmit:d,children:[(0,p.jsx)(`h2`,{children:n?.displayName?`Welcome back, ${n.displayName}`:`Sign in`}),(0,p.jsx)(`p`,{children:`Enter the email you were invited on and we will send you a fresh link.`}),(0,p.jsx)(`label`,{htmlFor:`access-email`,children:`Email`}),(0,p.jsx)(`input`,{id:`access-email`,type:`email`,inputMode:`email`,autoComplete:`email`,value:a,onChange:e=>o(e.target.value),disabled:s}),l&&(0,p.jsx)(`p`,{className:`access-gate-error`,children:l}),(0,p.jsx)(i,{type:`submit`,disabled:s||!a.trim(),children:s?`Sending…`:`Send me a link`})]}),e===`request-sent`&&(0,p.jsxs)(`div`,{className:`access-gate-message`,children:[(0,p.jsx)(`h2`,{children:`Check your email`}),(0,p.jsx)(`p`,{children:`If that address is on the invite list, a fresh link is on the way. It expires in 15 minutes.`}),(0,p.jsx)(i,{onClick:()=>{t(`request-link`),o(``),u(null)},children:`Try a different email`})]})]})}function h(){let[e,t]=(0,f.useState)(null),[n,r]=(0,f.useState)(null),[i,l]=(0,f.useState)(`loading`),[d,p]=(0,f.useState)(``),[m,h]=(0,f.useState)(null),[g,_]=(0,f.useState)(null),[v,y]=(0,f.useState)(!1),[b,x]=(0,f.useState)(null),S=(0,f.useMemo)(()=>a(),[]),C=(0,f.useRef)(S||``),w=(0,f.useRef)(null),T=(0,f.useRef)(null),E=(0,f.useRef)(!1),D=(0,f.useRef)(null),[O,k]=(0,f.useState)(`request-link`),[A,j]=(0,f.useState)(null),M=(0,f.useRef)(null),N=(0,f.useRef)(null);(0,f.useEffect)(()=>{try{let e=sessionStorage.getItem(`maxy_session`);e&&(N.current=e)}catch{}},[]),(0,f.useEffect)(()=>{try{let e=c();e&&(sessionStorage.setItem(s,e),o&&console.info(`[public-webchat] op=seed-persisted len=${e.length} head=${e.slice(0,40)}`))}catch{}},[]);let P=(0,f.useCallback)(e=>{w.current=e,t(e);try{sessionStorage.setItem(`maxy_session`,e)}catch{}l(`chat`)},[]),F=(0,f.useCallback)(()=>{w.current=null;try{sessionStorage.removeItem(`maxy_session`)}catch{}t(null),l(`auth-required`),k(`request-link`)},[]),I=(0,f.useCallback)(async e=>{k(`verifying`);try{let t=C.current,n=await fetch(`/api/access/verify-token`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:e,agentSlug:t})});if(window.history.replaceState({},``,window.location.pathname),n.ok){let e=await n.json().catch(()=>({}));return e?.displayName&&j({displayName:e.displayName,contactValue:``,expiresAt:null,status:`active`}),!0}return k(`verify-failed`),!1}catch{return k(`verify-failed`),!1}},[]),L=(0,f.useCallback)(async()=>{if(w.current)return w.current;if(T.current)return T.current;let e=(async()=>{try{let e=N.current,n=await fetch(`/api/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({session_id:u(),...S?{agent:S}:{},...e?{session_key:e}:{}})});if(!n.ok){let e=await n.json().catch(()=>({error:``}));return o&&console.error(`[session] POST /api/session failed: ${n.status} ${n.statusText}`,e),n.status===404?r(e.error||`Agent not found`):n.status===503&&r(e.error||`Service unavailable`),null}let i=await n.json();if(i.auth_required){i.agent_id&&(C.current=i.agent_id),p(i.displayName||``),i.agentImage&&h(i.agentImage),i.agentImageShape&&_(i.agentImageShape),i.showAgentName&&y(i.showAgentName),i.branding&&x(i.branding),l(`auth-required`);let e=new URLSearchParams(window.location.search).get(`token`);return e?await I(e)&&window.location.reload():k(`request-link`),null}w.current=i.session_key,t(i.session_key),i.displayName&&p(i.displayName),i.agentImage&&h(i.agentImage),i.agentImageShape&&_(i.agentImageShape),i.showAgentName&&y(i.showAgentName),i.branding&&x(i.branding),l(`chat`),i.resumed&&i.messages&&(E.current=!0,D.current=i.messages);try{sessionStorage.setItem(`maxy_session`,i.session_key)}catch{}return i.session_key}catch(e){return o&&console.error(`[session] fetch /api/session threw:`,e),r(`Unable to connect. Please check your connection and try again.`),null}finally{T.current=null}})();return T.current=e,e},[S,I]);return{sessionId:e,cacheKeyRef:w,sessionError:n,pageState:i,setPageState:l,agentDisplayName:d,agentImage:m,agentImageShape:g,showAgentName:v,agentSlug:S,branding:b,resolvedSlugRef:C,ensureSession:L,startNewSession:(0,f.useCallback)(async()=>{w.current=null,T.current=null,N.current=null,E.current=!1,D.current=null,t(null),r(null);try{sessionStorage.removeItem(`maxy_session`)}catch{}await L()},[L]),enterChat:P,enterGate:F,resumedRef:E,resumeMessagesRef:D,gateState:O,setGateState:k,grantInfo:A,setGrantInfo:j,gateCacheKeyRef:M}}function g(){let{ensureSession:e,pageState:t,gateState:n,setGateState:r,grantInfo:i,resolvedSlugRef:a}=h();return(0,f.useEffect)(()=>{e()},[e]),t===`loading`?(0,p.jsx)(`div`,{className:`public-loading`,children:`Loading…`}):t===`auth-required`?(0,p.jsx)(m,{gateState:n,setGateState:r,grantInfo:i,resolvedSlugRef:a}):(0,p.jsx)(`div`,{className:`public-shell`,children:(0,p.jsx)(l,{cacheKey:``,variant:`public`})})}(0,d.createRoot)(document.getElementById(`root`)).render((0,p.jsx)(g,{}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{D as e}from"./useSubAccountSwitcher-
|
|
1
|
+
import{D as e}from"./useSubAccountSwitcher-CsRv6MEd.js";var t=e(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]);export{t};
|