@rubytech/create-maxy-code 0.1.504 → 0.1.506
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/package.json +1 -1
- package/payload/platform/lib/account-schema-regions/dist/index.d.ts +60 -0
- package/payload/platform/lib/account-schema-regions/dist/index.d.ts.map +1 -0
- package/payload/platform/lib/account-schema-regions/dist/index.js +101 -0
- package/payload/platform/lib/account-schema-regions/dist/index.js.map +1 -0
- package/payload/platform/lib/account-schema-regions/package.json +7 -0
- package/payload/platform/lib/account-schema-regions/src/index.ts +121 -0
- package/payload/platform/lib/account-schema-regions/tsconfig.json +9 -0
- package/payload/platform/lib/models/dist/index.d.ts +5 -5
- package/payload/platform/lib/models/dist/index.d.ts.map +1 -1
- package/payload/platform/lib/models/dist/index.js +7 -7
- package/payload/platform/lib/models/dist/index.js.map +1 -1
- package/payload/platform/lib/models/src/index.ts +7 -7
- package/payload/platform/package.json +3 -3
- package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +83 -28
- package/payload/platform/plugins/admin/skills/public-agent-manager/SKILL.md +5 -5
- package/payload/platform/plugins/admin/skills/whats-new/SKILL.md +12 -0
- package/payload/platform/plugins/docs/references/admin-session.md +1 -1
- package/payload/platform/plugins/docs/references/admin-ui.md +82 -27
- package/payload/platform/plugins/work/mcp/dist/__tests__/session-metering.test.js +2 -2
- package/payload/platform/plugins/work/mcp/dist/__tests__/session-metering.test.js.map +1 -1
- package/payload/platform/plugins/work/mcp/dist/index.js +1 -1
- package/payload/platform/plugins/work/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/work/mcp/dist/tools/session-metering.js +2 -2
- package/payload/platform/plugins/work/mcp/dist/tools/session-metering.js.map +1 -1
- package/payload/platform/scripts/check-no-esm-require.mjs +5 -0
- package/payload/platform/scripts/logs-read-jsonl.test.sh +1 -1
- package/payload/platform/services/claude-session-manager/dist/account-dir-schema-reconcile.d.ts +1 -1
- package/payload/platform/services/claude-session-manager/dist/account-dir-schema-reconcile.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/account-dir-schema-reconcile.js +50 -3
- package/payload/platform/services/claude-session-manager/dist/account-dir-schema-reconcile.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/http-server.js +2 -2
- package/payload/platform/services/claude-session-manager/dist/http-server.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/pricing.d.ts +19 -11
- package/payload/platform/services/claude-session-manager/dist/pricing.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/pricing.js +18 -15
- package/payload/platform/services/claude-session-manager/dist/pricing.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/rc-daemon.js +1 -1
- package/payload/platform/services/claude-session-manager/dist/rc-daemon.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/session-metering.js +3 -3
- package/payload/platform/services/claude-session-manager/dist/session-metering.js.map +1 -1
- package/payload/platform/templates/account.json +1 -1
- package/payload/platform/templates/specialists/agents/coding-assistant.md +1 -1
- package/payload/platform/templates/specialists/agents/content-producer.md +1 -1
- package/payload/platform/templates/specialists/agents/librarian.md +1 -1
- package/payload/platform/templates/specialists/agents/research-assistant.md +1 -1
- package/payload/server/{chunk-HN4HFTXE.js → chunk-5ADBNEJA.js} +1410 -1409
- package/payload/server/maxy-edge.js +1 -1
- package/payload/server/public/activity.html +5 -5
- package/payload/server/public/agents.html +4 -4
- package/payload/server/public/assets/{AdminLoginScreens-DWMR4KtI.js → AdminLoginScreens-D5KOQA8S.js} +1 -1
- package/payload/server/public/assets/AdminShell-C8wazpnz.js +2 -0
- package/payload/server/public/assets/{activity-DH3z4cv3.js → activity-CFqkDhTs.js} +1 -1
- package/payload/server/public/assets/admin-B-EGUWS4.js +1 -0
- package/payload/server/public/assets/agents-DPulfmrd.js +1 -0
- package/payload/server/public/assets/{browser-C_MJYN5k.js → browser-T_5xbnJh.js} +1 -1
- package/payload/server/public/assets/{calendar-DA0h7dqW.js → calendar-CKjuiG8c.js} +1 -1
- package/payload/server/public/assets/chat-DWLYAA70.js +1 -0
- package/payload/server/public/assets/chevron-left-DBMCTKlT.js +1 -0
- package/payload/server/public/assets/chevron-right-SBAr6zzc.js +1 -0
- package/payload/server/public/assets/clock-kkzt7Scf.js +1 -0
- package/payload/server/public/assets/data-CV8N9qcy.js +1 -0
- package/payload/server/public/assets/{file-text-RCoSeOpD.js → file-text-c6cA4Evd.js} +1 -1
- package/payload/server/public/assets/graph-DIk-o45J.js +51 -0
- package/payload/server/public/assets/{graph-labels-DJV0aIG5.js → graph-labels-5bjxhC_p.js} +1 -1
- package/payload/server/public/assets/{maximize-2-DcESsKbu.js → maximize-2-BCQkFb1_.js} +1 -1
- package/payload/server/public/assets/{operator-Dlkw1sXJ.js → operator-0UnNo2ms.js} +1 -1
- package/payload/server/public/assets/page-HVtUfub2.js +32 -0
- package/payload/server/public/assets/page-JJa2xdzf.js +1 -0
- package/payload/server/public/assets/{public-C-UHWk_S.js → public-CKEYyIPn.js} +1 -1
- package/payload/server/public/assets/{rotate-ccw-C1nRSAzP.js → rotate-ccw-dTpO5dhL.js} +1 -1
- package/payload/server/public/assets/{routines-qdAZ0sA4.js → routines-C6P1-Dto.js} +1 -1
- package/payload/server/public/assets/{skills-B78wr822.js → skills-ClrpVqlz.js} +1 -1
- package/payload/server/public/assets/tasks-C8SNhSFC.js +1 -0
- package/payload/server/public/assets/{time-entry-format-BhlltPP8.js → time-entry-format-CCO6N6XZ.js} +1 -1
- package/payload/server/public/assets/{triangle-alert-rEVGyIhi.js → triangle-alert-CHjdKpag.js} +1 -1
- package/payload/server/public/assets/{useCopyFeedback-DzpXjm9d.js → useCopyFeedback-BTUu3-l8.js} +1 -1
- package/payload/server/public/assets/{useSubAccountSwitcher-DVmWZxar.js → useSubAccountSwitcher-DSW9vDi2.js} +1 -1
- package/payload/server/public/assets/{useSubAccountSwitcher-wP8cOzPj.css → useSubAccountSwitcher-DyrH8DA8.css} +1 -1
- package/payload/server/public/assets/{useVoiceRecorder-CRRmPjYr.js → useVoiceRecorder-BeNqxmm2.js} +1 -1
- package/payload/server/public/assets/{wrench-oeLti270.js → wrench-CeNnc7oO.js} +1 -1
- package/payload/server/public/browser.html +4 -4
- package/payload/server/public/calendar.html +7 -7
- package/payload/server/public/chat.html +13 -13
- package/payload/server/public/data.html +11 -11
- package/payload/server/public/graph.html +9 -9
- package/payload/server/public/index.html +14 -14
- package/payload/server/public/operator.html +14 -14
- package/payload/server/public/public.html +13 -13
- package/payload/server/public/routines.html +6 -6
- package/payload/server/public/skills.html +5 -5
- package/payload/server/public/tasks.html +6 -6
- package/payload/server/server.js +1395 -812
- package/payload/server/public/assets/AdminShell-C8hBpL9K.js +0 -2
- package/payload/server/public/assets/admin-aaGhd2Yh.js +0 -1
- package/payload/server/public/assets/agents-SPu-clsf.js +0 -1
- package/payload/server/public/assets/chat-Bg7dlM0I.js +0 -1
- package/payload/server/public/assets/chevron-left-BoDA12H8.js +0 -1
- package/payload/server/public/assets/chevron-right-DXjrO6qA.js +0 -1
- package/payload/server/public/assets/clock-BceBgZP1.js +0 -1
- package/payload/server/public/assets/data-rNLaurgY.js +0 -1
- package/payload/server/public/assets/graph-Dm-YZeNP.js +0 -51
- package/payload/server/public/assets/page-Dl-mgQUu.js +0 -32
- package/payload/server/public/assets/page-DoyJrk8E.js +0 -1
- package/payload/server/public/assets/tasks-DbIsS-vW.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{B as t,F as n,K as r,O as i,P as a,S as o,T as s,U as c,_ as l,a as u,b as d,c as f,d as p,g as m,i as h,k as g,p as _,s as v,t as y,u as b,v as ee,x as te,y as x}from"./useSubAccountSwitcher-DSW9vDi2.js";import{C as ne,E as S,S as re,T as C,n as ie,r as w,s as ae}from"./useVoiceRecorder-BeNqxmm2.js";import{t as T}from"./chevron-left-DBMCTKlT.js";import{t as E}from"./file-text-c6cA4Evd.js";import{i as D,t as O}from"./graph-labels-5bjxhC_p.js";import{t as k}from"./triangle-alert-CHjdKpag.js";var oe=a(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),se=a(`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`}]]),ce=a(`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`}]]),le=a(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),ue=a(`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`}]]),de=a(`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`}]]),fe=a(`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`}]]),A=a(`send-horizontal`,[[`path`,{d:`M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z`,key:`117uat`}],[`path`,{d:`M6 12h16`,key:`s4cdu5`}]]),pe=a(`smile`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 14s1.5 2 4 2 4-2 4-2`,key:`1y1vjs`}],[`line`,{x1:`9`,x2:`9.01`,y1:`9`,y2:`9`,key:`yxxnd0`}],[`line`,{x1:`15`,x2:`15.01`,y1:`9`,y2:`9`,key:`1p4y9e`}]]),me=a(`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`}]]),j=a(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),M=e(r(),1);function he(){let[e,t]=(0,M.useState)([]),[n,r]=(0,M.useState)(!1),[i,a]=(0,M.useState)(null),o=(0,M.useRef)(null),s=(0,M.useCallback)(e=>{a(null);let n=e.find(e=>!w(e.type,S));if(n){a(`Unsupported file type: "${n.type}". Supported: images, PDF, plain text, markdown, CSV, calendar, zip, voice notes.`);return}let r=e.find(e=>e.size>C);if(r){a(`"${r.name}" exceeds the 50 MB limit.`);return}t(t=>[...t,...e].slice(0,5))},[]);return{pendingFiles:e,setPendingFiles:t,isDragOver:n,attachError:i,setAttachError:a,fileInputRef:o,addFiles:s,clearFiles:(0,M.useCallback)(()=>{t([]),a(null)},[]),removeFile:(0,M.useCallback)(e=>{t(t=>t.filter((t,n)=>n!==e))},[]),onDragOver:(0,M.useCallback)(e=>{e.preventDefault(),r(!0)},[]),onDragLeave:(0,M.useCallback)(()=>{r(!1)},[]),onDrop:(0,M.useCallback)(e=>{e.preventDefault(),r(!1),s([...e.dataTransfer.files])},[s])}}var N=[[128512],[128515],[128516],[128513],[128518],[128517],[128514],[129315],[128578],[128579],[128521],[128522],[128519],[128525],[128536],[128535],[128540],[128541],[129303],[129300],[128528],[128566],[128564],[128526],[129395],[128546],[128557],[128548],[128544],[128533],[128556],[129393],[128077],[128078],[128076],[128591],[128079],[128588],[128170],[128075],[129309],[10084,65039],[128293],[11088],[127881],[10024],[128175],[128064]].map(e=>String.fromCodePoint(...e));function ge(e,t,n,r){let i=e.length,a=Math.max(0,Math.min(n??i,i)),o=Math.max(a,Math.min(r??a,i));return{value:e.slice(0,a)+t+e.slice(o),caret:a+t.length}}var P=t();function F({onSelect:e}){return(0,P.jsx)(`div`,{className:`wa-emoji-popover`,role:`menu`,"aria-label":`Emoji picker`,children:N.map((t,n)=>(0,P.jsx)(`button`,{type:`button`,role:`menuitem`,className:`wa-emoji-item`,onClick:()=>e(t),children:t},n))})}function _e({sessionKey:e,onPick:t,onClose:n}){let[r,a]=(0,M.useState)(``),[o,s]=(0,M.useState)(null),[c,l]=(0,M.useState)(null),[u,d]=(0,M.useState)(!1),f=(0,M.useCallback)(t=>{d(!0),l(null),fetch(`/api/admin/files?path=${encodeURIComponent(t)}&session_key=${encodeURIComponent(e)}`).then(async e=>{let t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error??`Could not list files`);return t}).then(e=>{s(e),a(e.path===`.`?``:e.path)}).catch(e=>l(e instanceof Error?e.message:String(e))).finally(()=>d(!1))},[e]);(0,M.useEffect)(()=>{f(``)},[f]);let p=e=>f(r?`${r}/${e}`:e),h=()=>{let e=r.split(`/`).filter(Boolean);e.pop(),f(e.join(`/`))},g=e=>{let n=e.entryPath??e.name;t({path:r?`${r}/${n}`:n,name:e.displayName??e.name})};return(0,P.jsx)(`div`,{className:`wa-picker-backdrop`,role:`dialog`,"aria-label":`Choose a device file`,onClick:n,children:(0,P.jsxs)(`div`,{className:`wa-picker`,onClick:e=>e.stopPropagation(),children:[(0,P.jsxs)(`div`,{className:`wa-picker-head`,children:[r&&(0,P.jsx)(`button`,{type:`button`,className:`wa-picker-icon-btn`,onClick:h,"aria-label":`Up one folder`,children:(0,P.jsx)(T,{size:18})}),(0,P.jsx)(`span`,{className:`wa-picker-title`,children:r||`Device storage`}),(0,P.jsx)(`button`,{type:`button`,className:`wa-picker-icon-btn`,onClick:n,"aria-label":`Close file picker`,children:(0,P.jsx)(m,{size:18})})]}),c&&(0,P.jsx)(`p`,{className:`wa-picker-error`,role:`alert`,children:c}),u&&(0,P.jsx)(`p`,{className:`wa-picker-empty`,children:`Loading…`}),o&&!u&&(0,P.jsxs)(`ul`,{className:`wa-picker-list`,children:[o.entries.length===0&&(0,P.jsx)(`li`,{className:`wa-picker-empty`,children:`This folder is empty.`}),o.entries.map(e=>(0,P.jsx)(`li`,{children:e.kind===`directory`?(0,P.jsxs)(`button`,{type:`button`,className:`wa-picker-row`,onClick:()=>p(e.name),children:[(0,P.jsx)(i,{size:16,"aria-hidden":!0}),(0,P.jsx)(`span`,{className:`wa-picker-name`,children:e.displayName??e.name})]}):e.kind===`file`?(0,P.jsxs)(`button`,{type:`button`,className:`wa-picker-row`,onClick:()=>g(e),children:[(0,P.jsx)(E,{size:16,"aria-hidden":!0}),(0,P.jsx)(`span`,{className:`wa-picker-name`,children:e.displayName??e.name})]}):null},e.name))]})]})})}function ve(e){return`${Math.floor(e/60)}:${String(e%60).padStart(2,`0`)}`}function I({accountId:e,remoteJid:t,sessionKey:n,replyTo:r,onClearReply:i}){let[a,o]=(0,M.useState)(``),[s,c]=(0,M.useState)(!1),[u,d]=(0,M.useState)(null),[f,p]=(0,M.useState)(!1),[h,g]=(0,M.useState)(!1),[_,v]=(0,M.useState)(!1),[y,b]=(0,M.useState)([]),x=(0,M.useRef)(null),{pendingFiles:S,attachError:C,addFiles:w,removeFile:ae,clearFiles:T}=he(),{state:D,elapsedSeconds:O,errorMessage:k,start:oe,send:se,discard:ce}=ie(),ue=D===`recording`||D===`paused`,de=(0,M.useCallback)(()=>{console.info(`[operator-ui] op=voice-record state=start ms=0`),oe()},[oe]),fe=(0,M.useCallback)(async()=>{let e=O*1e3,t=await se();if(console.info(`[operator-ui] op=voice-record state=stop ms=${e}`),t){let e=t.type===`audio/ogg`?`.ogg`:t.type===`audio/mp4`?`.m4a`:`.webm`;w([new File([t],`voice-note${e}`,{type:t.type})])}},[O,se,w]),me=(0,M.useCallback)(()=>{console.info(`[operator-ui] op=voice-record state=cancel ms=${O*1e3}`),ce()},[O,ce]),j=(0,M.useRef)(!1),N=()=>Math.round((typeof window>`u`?900:window.innerHeight)/3),[I,L]=(0,M.useState)(null),[ye,be]=(0,M.useState)(null),xe=(0,M.useRef)(null),Se=(0,M.useRef)(44),R=(0,M.useCallback)(e=>{let t=xe.current;if(!t)return;t.moved=!0;let n=Math.min(N(),Math.max(44,t.startH+(t.startY-e.clientY)));Se.current=n,L(n)},[]),z=(0,M.useCallback)(()=>{let e=xe.current?.moved??!1;xe.current=null,window.removeEventListener(`pointermove`,R),window.removeEventListener(`pointerup`,z),e&&console.info(`[operator-ui] op=wa-composer-resize mode=drag h=${Se.current}`)},[R]),B=(0,M.useCallback)(e=>{xe.current={startY:e.clientY,startH:x.current?.offsetHeight??44,moved:!1},window.addEventListener(`pointermove`,R),window.addEventListener(`pointerup`,z),e.preventDefault()},[R,z]),Ce=(0,M.useCallback)(e=>{let t=I??x.current?.offsetHeight??44,n=null;e.key===`ArrowUp`?(e.preventDefault(),n=Math.min(N(),t+24)):e.key===`ArrowDown`&&(e.preventDefault(),n=Math.max(44,t-24)),n!==null&&(L(n),console.info(`[operator-ui] op=wa-composer-resize mode=key h=${n}`))},[I]),V=(0,M.useRef)(``);(0,M.useEffect)(()=>{let e=x.current;if(!e)return;let t=V.current!==``&&a===``;if(V.current=a,I!==null){t&&L(null);return}let n=e.style.height;e.style.height=`auto`;let r=Math.min(N(),Math.max(44,e.scrollHeight));e.style.height=n,be(r)},[a,I]);let we=(a.trim().length>0||S.length>0||y.length>0)&&!s,Te=(0,M.useCallback)(async()=>{if(!j.current&&!(a.trim().length===0&&S.length===0&&y.length===0)){j.current=!0,c(!0),d(null);try{let s=`/api/whatsapp-reader/reply?session_key=${encodeURIComponent(n)}`,c;if(S.length>0||y.length>0){let n=new FormData;n.append(`accountId`,e),n.append(`remoteJid`,t),a.trim()&&n.append(`text`,a);for(let e of S)n.append(`files`,e);for(let e of y)n.append(`fileRefs`,e.path);r&&n.append(`quotedId`,r.msgKeyId),c=await fetch(s,{method:`POST`,body:n})}else c=await fetch(s,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({accountId:e,remoteJid:t,text:a,...r?{quotedId:r.msgKeyId}:{}})});let l=await c.json().catch(()=>({}));if(!c.ok){d(l.error??`Send failed.`),console.info(`[operator-ui] op=reply-fail remoteJid=${t} error=${l.error??`unknown`}`);return}o(``),T(),b([]),i?.(),console.info(`[operator-ui] op=reply-sent remoteJid=${t} sent=${l.sent??0}`)}catch(e){d(`Could not reach the server. Try again.`),console.info(`[operator-ui] op=reply-fail remoteJid=${t} error=${String(e)}`)}finally{j.current=!1,c(!1)}}},[a,S,y,r,i,e,t,n,T]),Ee=(0,M.useCallback)(e=>{let t=x.current,{value:n,caret:r}=ge(a,e,t?t.selectionStart:null,t?t.selectionEnd:null);o(n),p(!1),requestAnimationFrame(()=>{let e=x.current;e&&(e.focus(),e.setSelectionRange(r,r))})},[a]),De=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),we&&Te())},Oe=e=>e.dataTransfer.types.includes(`Files`),ke=(0,M.useCallback)(e=>{Oe(e)&&(e.preventDefault(),v(!0))},[]),Ae=(0,M.useCallback)(()=>v(!1),[]),je=(0,M.useCallback)(e=>{if(!Oe(e))return;e.preventDefault(),v(!1);let t=[...e.dataTransfer.files];if(t.length===0)return;let n=Math.max(0,S.length+t.length-5);console.info(`[operator-ui] op=composer-drop count=${t.length} rejected=${n}`),w(t)},[S.length,w]),Me=e=>e.startsWith(`image/`)?(0,P.jsx)(le,{size:14}):e===`application/pdf`?(0,P.jsx)(E,{size:14}):(0,P.jsx)(ne,{size:14});return(0,P.jsxs)(`div`,{className:`wa-reply${_?` wa-reply-drag-over`:``}`,onDragOver:ke,onDragLeave:Ae,onDrop:je,children:[h&&(0,P.jsx)(_e,{sessionKey:n,onPick:e=>{b(t=>[...t,e].slice(0,5)),g(!1)},onClose:()=>g(!1)}),f&&(0,P.jsx)(F,{onSelect:Ee}),u&&(0,P.jsx)(`p`,{className:`wa-reply-error`,role:`alert`,children:u}),C&&(0,P.jsx)(`p`,{className:`wa-reply-error`,role:`alert`,children:C}),D===`error`&&k&&(0,P.jsx)(`p`,{className:`wa-reply-error`,role:`alert`,children:k}),(S.length>0||y.length>0)&&(0,P.jsxs)(`div`,{className:`wa-reply-attachments`,children:[S.map((e,t)=>(0,P.jsxs)(`div`,{className:`wa-reply-chip`,children:[Me(e.type),(0,P.jsx)(`span`,{className:`wa-reply-chip-name`,children:e.name}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>ae(t),"aria-label":`Remove ${e.name}`,children:(0,P.jsx)(m,{size:12})})]},`f-${t}`)),y.map((e,t)=>(0,P.jsxs)(`div`,{className:`wa-reply-chip wa-reply-chip-ref`,children:[(0,P.jsx)(E,{size:14}),(0,P.jsx)(`span`,{className:`wa-reply-chip-name`,children:e.name}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>b(e=>e.filter((e,n)=>n!==t)),"aria-label":`Remove ${e.name}`,children:(0,P.jsx)(m,{size:12})})]},`r-${t}`))]}),r&&(0,P.jsxs)(`div`,{className:`wa-reply-quote`,children:[(0,P.jsxs)(`div`,{className:`wa-reply-quote-body`,children:[(0,P.jsx)(`span`,{className:`wa-reply-quote-who`,children:r.fromMe?`You`:r.senderName??`Contact`}),(0,P.jsx)(`span`,{className:`wa-reply-quote-text`,children:r.body||`Message`})]}),(0,P.jsx)(`button`,{type:`button`,className:`wa-reply-quote-cancel`,onClick:()=>i?.(),"aria-label":`Cancel reply`,children:(0,P.jsx)(m,{size:14})})]}),!ue&&(0,P.jsx)(`div`,{className:`wa-reply-resize-handle`,role:`separator`,"aria-orientation":`horizontal`,"aria-label":`Resize input — drag up to enlarge`,tabIndex:0,onPointerDown:B,onKeyDown:Ce}),(0,P.jsx)(`div`,{className:`wa-reply-row`,children:ue?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`button`,{type:`button`,className:`wa-reply-attach`,onClick:me,"aria-label":`Cancel recording`,children:(0,P.jsx)(l,{size:20})}),(0,P.jsxs)(`span`,{className:`wa-rec-live`,role:`status`,children:[(0,P.jsx)(`span`,{className:`wa-rec-dot`,"aria-hidden":!0}),ve(O)]}),(0,P.jsx)(`button`,{type:`button`,className:`wa-reply-send`,onClick:()=>void fe(),"aria-label":`Stop recording`,children:(0,P.jsx)(ee,{size:20})})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`button`,{type:`button`,className:`wa-reply-emoji`,onClick:()=>p(e=>!e),disabled:s,"aria-label":`Emoji`,"aria-expanded":f,children:(0,P.jsx)(pe,{size:22})}),(0,P.jsx)(`button`,{type:`button`,className:`wa-reply-attach`,onClick:()=>g(!0),disabled:s,"aria-label":`Attach files`,children:(0,P.jsx)(te,{size:22})}),(0,P.jsx)(`textarea`,{ref:x,className:`wa-reply-input`,value:a,rows:1,style:{height:`${I??ye??44}px`},placeholder:`Type a message`,disabled:s,onChange:e=>o(e.target.value),onKeyDown:De}),(0,P.jsx)(`button`,{type:`button`,className:`wa-reply-mic`,onClick:()=>void de(),disabled:s,"aria-label":`Record voice note`,children:(0,P.jsx)(re,{size:22})}),(0,P.jsx)(`button`,{type:`button`,className:`wa-reply-send`,onClick:()=>void Te(),disabled:!we,"aria-label":`Send`,children:(0,P.jsx)(A,{size:20})})]})})]})}function L({accountId:e,remoteJid:t,contactName:n,sessionKey:r,onBack:i}){let a=f(t),o=t.split(`@`)[0],s=a?`Group`:n===`+${o}`?void 0:`+${o}`,[c,l]=(0,M.useState)(!1),[u,d]=(0,M.useState)(``),p=()=>{l(!1),d(``)},[h,g]=(0,M.useState)(null);return(0,P.jsxs)(`div`,{className:`wa-web`,children:[(0,P.jsxs)(`header`,{className:`wa-web-header`,children:[i&&(0,P.jsx)(`button`,{type:`button`,className:`wa-web-back`,onClick:i,"aria-label":`Back`,children:(0,P.jsx)(T,{size:20})}),(0,P.jsx)(`span`,{className:`wa-web-avatar`,"aria-hidden":!0,children:(0,P.jsx)(j,{size:20})}),c?(0,P.jsxs)(`div`,{className:`wa-web-search`,children:[(0,P.jsx)(D,{size:18,"aria-hidden":!0}),(0,P.jsx)(`input`,{className:`wa-web-search-input`,type:`text`,autoFocus:!0,placeholder:`Search messages`,"aria-label":`Search messages`,value:u,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Escape`&&p()}}),(0,P.jsx)(`button`,{type:`button`,className:`wa-web-search-close`,onClick:p,"aria-label":`Close search`,children:(0,P.jsx)(m,{size:18})})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`wa-web-titles`,children:[(0,P.jsx)(`span`,{className:`wa-web-name`,children:n}),s&&(0,P.jsx)(`span`,{className:`wa-web-subtitle`,children:s})]}),(0,P.jsx)(`button`,{type:`button`,className:`wa-web-search-toggle`,onClick:()=>l(!0),"aria-label":`Search messages`,children:(0,P.jsx)(D,{size:20})})]})]}),(0,P.jsx)(`div`,{className:`wa-web-body`,children:(0,P.jsx)(ae,{sessionId:``,projectDir:``,sessionKey:r,forceDeliveredOnly:!0,suppressDirectives:!0,store:{accountId:e,remoteJid:t},search:c?u:void 0,onReplyTo:a?void 0:g})}),a?(0,P.jsx)(`p`,{className:`wa-reply wa-reply-readonly`,children:`Group messages are read-only.`}):(0,P.jsx)(I,{accountId:e,remoteJid:t,sessionKey:r,replyTo:h,onClearReply:()=>g(null)})]})}function ye(e){let t=new Set,n=[];for(let r of e)for(let e of r.labels)e&&(t.has(e)||O.has(e)&&(t.add(e),n.push(e)));return n}function be(e,t,n=`data`){let r=`/api/admin/files/download?session_key=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`+(n===`data`?``:`&root=${encodeURIComponent(n)}`),i=document.createElement(`a`);i.href=r,i.rel=`noopener noreferrer`,document.body.appendChild(i),i.click(),i.remove()}function xe(e,t){let n=new URLSearchParams;n.set(`session_key`,e);for(let e of t)n.append(`path`,e);let r=document.createElement(`a`);r.href=`/api/admin/files/download-zip?${n.toString()}`,r.rel=`noopener noreferrer`,document.body.appendChild(r),r.click(),r.remove()}function Se(e,t,n=`data`){return`/api/admin/files/download?session_key=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}&disposition=inline`+(n===`data`?``:`&root=${encodeURIComponent(n)}`)}function R(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 z({conversations:e,sessionKey:t,onBack:n}){let[r,i]=(0,M.useState)(null),a=h(e);return r?r.source===`store`&&r.accountId&&r.remoteJid?(0,P.jsx)(L,{accountId:r.accountId,remoteJid:r.remoteJid,contactName:u(r),sessionKey:t,onBack:()=>i(null)},v(r)):(0,P.jsxs)(`div`,{className:`op-conv op-conv-reader`,children:[(0,P.jsxs)(`div`,{className:`op-conv-bar`,children:[(0,P.jsxs)(`button`,{type:`button`,className:`op-conv-back`,onClick:()=>i(null),"aria-label":`Back to conversations`,children:[(0,P.jsx)(T,{size:16}),` Back`]}),(0,P.jsx)(`span`,{className:`op-conv-title`,children:u(r)})]}),(0,P.jsx)(ae,{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},v(r))]}):(0,P.jsxs)(`div`,{className:`op-conv op-conv-list`,children:[(0,P.jsxs)(`div`,{className:`op-conv-bar`,children:[(0,P.jsxs)(`button`,{type:`button`,className:`op-conv-back`,onClick:n,"aria-label":`Back to chat`,children:[(0,P.jsx)(T,{size:16}),` Chat`]}),(0,P.jsx)(`span`,{className:`op-conv-title`,children:`Conversations`})]}),a.map(e=>(0,P.jsxs)(`div`,{className:`op-conv-group`,children:[(0,P.jsxs)(`div`,{className:`op-conv-group-head`,children:[(0,P.jsx)(b,{channel:e.channel,size:14}),e.label]}),e.rows.map(e=>(0,P.jsxs)(`button`,{type:`button`,className:`op-conv-row`,onClick:()=>{console.info(`[operator-ui] op=reader-open channel=${e.channel} key=${v(e)} readonly=true source=${e.source}`),i(e)},children:[(0,P.jsx)(`span`,{className:`op-conv-name`,children:u(e)}),e.modelGated&&(0,P.jsx)(`span`,{className:`op-conv-gated`,role:`img`,"aria-label":`Model unavailable`,children:(0,P.jsx)(k,{size:13})}),(0,P.jsx)(`span`,{className:`op-conv-when`,children:R(e.lastMessageAt)})]},v(e)))]},e.channel))]})}var B=/\.(png|jpe?g|gif|webp|svg)$/i;function Ce(e){return B.test(e)}function V(e){return e.entryPath??e.name}var we=`maxy-data-view`,Te=95*1024*1024,Ee=48*1024*1024;function De(){return typeof window>`u`?`list`:window.localStorage.getItem(we)===`grid`?`grid`:`list`}function Oe(){let[e,t]=(0,M.useState)(null),[r,i]=(0,M.useState)(!1);return(0,M.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!n){t(null),i(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(r=>{if(!e){if(r.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`;return}t(n),i(!0)}}).catch(()=>{e||(t(n),i(!0))}),()=>{e=!0}},[]),r?e?(0,P.jsx)(_,{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,P.jsx)(`div`,{className:`data-page data-page-full`,children:(0,P.jsx)(ke,{cacheKey:e})})}):(0,P.jsx)(`div`,{className:`data-page`,children:(0,P.jsxs)(`div`,{className:`data-empty`,children:[(0,P.jsx)(`p`,{children:`You are not signed in.`}),(0,P.jsxs)(`p`,{children:[`Open the `,(0,P.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,P.jsx)(n,{surface:`gate`})}function ke({cacheKey:e}){let{adminFetch:t,cacheKey:n,sessionRefetchNonce:r}=c({initialCacheKey:e,surface:`data`});return(0,P.jsx)(Le,{adminFetch:t,cacheKey:n,sessionRefetchNonce:r})}function Ae(){if(typeof window>`u`)return`@home`;let e=new URLSearchParams(window.location.hash.replace(/^#/,``)).get(`path`);return e&&e.length>0?e:`@home`}function je(e){if(typeof window>`u`)return;let t=new URL(window.location.href);t.hash=e===`.`||e===`@home`?``:`path=${encodeURIComponent(e)}`,window.history.replaceState(window.history.state,``,t.toString())}function Me(e){return new Promise((t,n)=>{let r=[],i=()=>e.readEntries(e=>{e.length===0?t(r):(r.push(...e),i())},n);i()})}function Ne(e){return new Promise((t,n)=>e.file(t,n))}async function Pe(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 Ne(r),relpath:e});else if(r.isDirectory){let t=await Me(r.createReader());n.push(...await Pe(t,e))}}return n}function Fe(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 Ie({adminFetch:e,cacheKey:t,sessionRefetchNonce:r}){let[a,c]=(0,M.useState)(``),u=(0,M.useRef)(null),[f,p]=(0,M.useState)(``),[h,_]=(0,M.useState)(null),[v,y]=(0,M.useState)(`hybrid`),[b,ee]=(0,M.useState)(!1),[te,ne]=(0,M.useState)(null),[S,re]=(0,M.useState)(null),[C,ie]=(0,M.useState)(0),[w,ae]=(0,M.useState)(!1),[T,O]=(0,M.useState)(()=>Ae()),[k,le]=(0,M.useState)(null),[A,pe]=(0,M.useState)(()=>De()),[j,he]=(0,M.useState)(null),[N,ge]=(0,M.useState)([]),[F,_e]=(0,M.useState)(null),[ve,I]=(0,M.useState)(0),L=N.slice(0,-1).map(e=>e.name).join(`/`),R=F?L:T,z=(0,M.useCallback)(e=>R===`.`||R===``?e:`${R}/${e}`,[R]),[B,Oe]=(0,M.useState)(!1),[ke,Me]=(0,M.useState)(!1),[Ne,Ie]=(0,M.useState)(null),[Le,Re]=(0,M.useState)(!1),[H,U]=(0,M.useState)(null),[Ve,We]=(0,M.useState)(null),[Ge,Ke]=(0,M.useState)(null),[qe,Je]=(0,M.useState)(!1),[Ye,Xe]=(0,M.useState)(null),Ze=(0,M.useRef)(null),[Qe,W]=(0,M.useState)(0),[$e,et]=(0,M.useState)(!1),[tt,nt]=(0,M.useState)(``),[rt,it]=(0,M.useState)(null),[at,ot]=(0,M.useState)(``),[st,ct]=(0,M.useState)(null),G=(()=>{let e=T===`.`?[]:T.split(`/`).filter(Boolean);return e.some(e=>e.startsWith(`@`))?!1:e.length>=2&&e[0]===`accounts`})(),[lt,ut]=(0,M.useState)(!1),dt=(0,M.useRef)(null),[ft,K]=(0,M.useState)(!1),pt=(0,M.useRef)(null);(0,M.useEffect)(()=>{let e=a.trim();if(!e){p(``),_(null),ne(null);return}ae(!1);let t=setTimeout(()=>p(e),300);return()=>clearTimeout(t)},[a]),(0,M.useEffect)(()=>{if(!f){ee(!1);return}let t=!1;return ee(!0),ne(null),e(`/api/admin/graph-search?q=${encodeURIComponent(f)}&labels=FileArtifact&limit=20${w?`&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||(_(e.results),y(e.mode??`hybrid`),ie(typeof e.suppressed==`number`?e.suppressed:0))}).catch(e=>{t||ne(e instanceof Error?e.message:String(e))}).finally(()=>{t||ee(!1)}),()=>{t=!0}},[f,e,r,w]);let mt=(0,M.useMemo)(()=>h?ye(h):[],[h]),q=S&&mt.includes(S)?S:null,ht=(0,M.useMemo)(()=>h?q?h.filter(e=>e.labels.includes(q)):h:null,[h,q]),gt=(0,M.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,M.useEffect)(()=>{if(!h)return;let e=h.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(`,`)}`)},[h]),(0,M.useEffect)(()=>{let t=!1;return Oe(!0),Ie(null),e(`/api/admin/files?path=${encodeURIComponent(T===`.`?``:T)}`).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||(le(e.entries),ge(e.displayPath??[]),_e(e.view??null),I(typeof e.systemCount==`number`?e.systemCount:0))}).catch(e=>{t||(le([]),ge([]),_e(null),I(0),Ie(e instanceof Error?e.message:String(e)))}).finally(()=>{t||(Oe(!1),Me(!0))}),()=>{t=!0}},[e,T,Qe,r]),(0,M.useEffect)(()=>{je(T)},[T]);let _t=(0,M.useCallback)(()=>{W(e=>e+1)},[]),J=(0,M.useCallback)(e=>{ut(!1),O(e)},[]),vt=(0,M.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}`),c(``),ne(null),re(null),J(r)},[J]),yt=(0,M.useCallback)(()=>{if(!T.split(`/`).some(e=>e.startsWith(`@`))){if(T===`.`||T===``)return;let e=T.split(`/`).filter(Boolean);e.pop(),O(e.length===0?`.`:e.join(`/`));return}N.length!==0&&O(N.length>=2?N.slice(0,N.length-1).map(e=>e.name).join(`/`):`.`)},[T,N]),bt=(0,M.useCallback)(e=>{be(t,z(V(e)))},[z,t]),[Y,xt]=(0,M.useState)(!1),[X,St]=(0,M.useState)(new Set),Ct=(0,M.useRef)(null),Z=(0,M.useRef)(!1),wt=typeof navigator<`u`&&typeof navigator.share==`function`&&typeof navigator.canShare==`function`,Tt=(0,M.useCallback)(e=>{xt(!0),St(new Set([e])),console.info(`[data-ui] op=select-enter count=1`)},[]),Q=(0,M.useCallback)(e=>{xt(!1),St(new Set),console.info(`[data-ui] op=select-exit reason=${e}`)},[]),Et=(0,M.useCallback)(e=>{St(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Dt=(0,M.useCallback)(e=>{Z.current=!1,Ct.current=setTimeout(()=>{Z.current=!0,Tt(e)},500)},[Tt]),$=(0,M.useCallback)(()=>{Ct.current&&=(clearTimeout(Ct.current),null)},[]),Ot=(0,M.useCallback)(e=>{if(Z.current){Z.current=!1;return}if(Y){Et(e.name);return}bt(e)},[Y,Et,bt]),kt=(0,M.useCallback)(e=>{pe(e),typeof window<`u`&&window.localStorage.setItem(we,e),console.info(`[data] op=view-mode mode=${e}`)},[]),At=(0,M.useCallback)(e=>{if(Z.current){Z.current=!1;return}if(Y){Et(e.name);return}he({src:Se(t,z(V(e))),alt:e.displayName??e.name})},[Y,Et,z,t]),jt=(0,M.useCallback)(()=>(k??[]).filter(e=>e.kind===`file`&&X.has(e.name)),[k,X]),Mt=(0,M.useCallback)(()=>{if(X.size!==1)return null;let e=(k??[]).find(e=>X.has(e.name));return e&&!e.entryPath?e:null},[k,X]),Nt=(0,M.useCallback)(()=>(k??[]).filter(e=>(e.kind===`file`||e.kind===`directory`)&&X.has(e.name)),[k,X]),Pt=(0,M.useCallback)(()=>{let e=Nt(),n=e.some(e=>e.kind===`directory`);e.length===1&&!n?bt(e[0]):e.length>=1&&xe(t,e.map(e=>z(V(e)))),Q(`action`)},[Nt,bt,z,t,Q]),Ft=(0,M.useCallback)(async()=>{let t=jt(),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=z(V(t));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))}}W(e=>e+1),Q(`action`)},[jt,z,e,Q]),It=(0,M.useCallback)(async()=>{let e=jt();if(console.info(`[data-ui] op=share supported=${wt} count=${e.length}`),wt)try{let n=await Promise.all(e.map(async e=>{let n=z(V(e)),r=`/api/admin/files/download?session_key=${encodeURIComponent(t)}&path=${encodeURIComponent(n)}`,i=await(await fetch(r)).blob();return new File([i],e.displayName??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)}`)}},[jt,wt,z,t]),Lt=(0,M.useCallback)(()=>{Ze.current?.click()},[]),Rt=(0,M.useCallback)((e,n={})=>{let r=(r,i,a)=>{let o=new URLSearchParams({session_key:t,path:T===`.`?``:T,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<=Te)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/Ee);return(async()=>{let t={status:0,data:{}};for(let o=0;o<a;o++){let s=o*Ee;if(t=await r(e.slice(s,Math.min(s+Ee,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,T]),zt=(0,M.useCallback)(async e=>{We(null),Re(!0),U({loaded:0,total:e.size});try{let{status:t,data:n}=await Rt(e,{onProgress:(e,t)=>U({loaded:e,total:t})});t>=200&&t<300&&n.path?(O(n.path.split(`/`).slice(0,-1).join(`/`)||`.`),W(e=>e+1)):We(t===0?`Network error during upload — the connection failed before the server responded.`:n.error??`Upload failed (HTTP ${t}).`)}finally{Re(!1),U(null),Ze.current&&(Ze.current.value=``)}},[Rt]),Bt=(0,M.useCallback)(e=>{G&&Array.from(e.dataTransfer.types).includes(`Files`)&&(e.preventDefault(),Je(!0))},[G]),Vt=(0,M.useCallback)(e=>{e.currentTarget.contains(e.relatedTarget)||Je(!1)},[]),Ht=(0,M.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(!G){console.info(`[data-ui] op=drop-rejected token=${t} reason=no-write`),We(`Open a folder inside your account to upload`);return}let r=n.map(e=>e.webkitGetAsEntry?.()).filter(e=>!!e);Re(!0),We(null),Ke(null);let i=performance.now();try{let e=await Pe(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}`),U({loaded:0,total:r.size});let{status:a,data:c}=await Rt(r,{relpath:i,token:t,onProgress:(e,t)=>U({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`:Fe(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(`, `)}`:``}`),W(e=>e+1)}catch(e){We(e instanceof Error?e.message:String(e))}finally{Re(!1),U(null)}},[G,Rt]),Ut=(0,M.useCallback)(async()=>{let t=tt.trim();if(t){ct(null);try{let n=await e(`/api/admin/files/folder`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:T===`.`?``:T,name:t})}),r=await n.json().catch(()=>({error:`HTTP ${n.status}`}));if(!n.ok)throw Error(r.error??`HTTP ${n.status}`);et(!1),nt(``),W(e=>e+1)}catch(e){ct(e instanceof Error?e.message:String(e))}}},[e,tt,T]),Wt=(0,M.useCallback)(async()=>{if(!rt)return;let t=at.trim();if(!t)return;ct(null);let n=z(rt);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}`);it(null),ot(``),Q(`action`),W(e=>e+1)}catch(e){ct(e instanceof Error?e.message:String(e))}},[e,at,rt,z,Q]);(0,M.useEffect)(()=>{if(!lt)return;let e=e=>{dt.current&&!dt.current.contains(e.target)&&ut(!1)},t=e=>{e.key===`Escape`&&ut(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[lt]),(0,M.useEffect)(()=>{if(!ft)return;let e=e=>{pt.current&&!pt.current.contains(e.target)&&K(!1)},t=e=>{e.key===`Escape`&&K(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[ft]);let Gt=(0,M.useCallback)(e=>N.slice(0,e+1).map(e=>e.name).join(`/`),[N]),Kt=N.length>=2,qt=Kt?[{name:`.`,label:`data`},...N.slice(0,N.length-2).map((e,t)=>({name:Gt(t),label:e.displayName??e.name}))]:[];return ke?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`data-toolbar`,children:[Y?(0,P.jsxs)(`button`,{type:`button`,className:`data-select-cancel`,onClick:()=>Q(`cancel`),"aria-label":`Cancel selection`,children:[(0,P.jsx)(m,{size:14}),` Cancel`]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`data-search-input`,children:[a===``&&(0,P.jsx)(D,{size:14}),(0,P.jsx)(`input`,{ref:u,type:`text`,value:a,onChange:e=>c(e.target.value),autoFocus:!0,autoComplete:`off`,spellCheck:!1}),b&&(0,P.jsx)(s,{size:14,className:`spin`}),a!==``&&(0,P.jsx)(`button`,{type:`button`,className:`data-search-inline-btn`,onClick:()=>{c(``),u.current?.focus()},title:`Clear search`,"aria-label":`Clear search`,children:(0,P.jsx)(m,{size:14})})]}),(0,P.jsxs)(`div`,{className:`data-toolbar-actions`,ref:pt,children:[(0,P.jsx)(`button`,{type:`button`,className:`data-action-overflow`,onClick:()=>K(e=>!e),"aria-haspopup":`menu`,"aria-expanded":ft,"aria-label":`File actions`,title:`File actions`,children:(0,P.jsx)(se,{size:16})}),(0,P.jsxs)(`div`,{className:`data-action-group`,role:`group`,"aria-label":`File actions`,"data-open":ft?`true`:void 0,children:[(0,P.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{_t(),K(!1)},disabled:B,title:`Refresh this folder`,"aria-label":`Refresh this folder`,children:[B?(0,P.jsx)(s,{size:16,className:`spin`}):(0,P.jsx)(d,{size:16}),(0,P.jsx)(`span`,{className:`data-action-label`,children:`Refresh`})]}),(0,P.jsxs)(`button`,{type:`button`,className:`data-action-btn admin-btn-cta`,onClick:()=>{Lt(),K(!1)},disabled:Le||!G,title:G?`Upload a file`:`Open a folder inside your account to upload`,"aria-label":`Upload a file`,children:[Le?H&&H.total>0?(0,P.jsxs)(`span`,{className:`data-upload-pct`,children:[Math.round(H.loaded/H.total*100),`%`]}):(0,P.jsx)(s,{size:16,className:`spin`}):(0,P.jsx)(me,{size:16}),(0,P.jsx)(`span`,{className:`data-action-label`,children:`Upload`})]}),(0,P.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{et(e=>!e),nt(``),ct(null),K(!1)},disabled:Le||!G,title:G?`New folder`:`Open a folder inside your account to create one`,"aria-label":`New folder`,children:[(0,P.jsx)(ce,{size:16}),(0,P.jsx)(`span`,{className:`data-action-label`,children:`New folder`})]}),(0,P.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{kt(A===`grid`?`list`:`grid`),K(!1)},title:A===`grid`?`List view`:`Grid view`,"aria-label":A===`grid`?`Switch to list view`:`Switch to grid view`,"aria-pressed":A===`grid`,children:[A===`grid`?(0,P.jsx)(de,{size:16}):(0,P.jsx)(ue,{size:16}),(0,P.jsx)(`span`,{className:`data-action-label`,children:A===`grid`?`List view`:`Grid view`})]})]})]})]}),(0,P.jsxs)(`div`,{className:`data-breadcrumbs`,children:[T!==`.`&&(0,P.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost data-back-btn`,onClick:yt,title:`Up one level`,"aria-label":`Up one level`,children:(0,P.jsx)(oe,{size:14})}),Kt?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`span`,{className:`data-crumb-wrap`,ref:dt,children:[(0,P.jsx)(`button`,{type:`button`,className:`data-crumb data-crumb-ellipsis`,onClick:()=>ut(e=>!e),"aria-haspopup":`menu`,"aria-expanded":lt,"aria-label":`Show parent folders`,title:`Show parent folders`,children:`…`}),lt&&(0,P.jsx)(`div`,{className:`data-crumb-menu`,role:`menu`,children:qt.map(e=>(0,P.jsx)(`button`,{type:`button`,role:`menuitem`,className:`data-crumb-menu-item`,onClick:()=>J(e.name),title:e.label,children:e.label},e.name))})]}),[N.length-2,N.length-1].map(e=>{let t=N[e];return(0,P.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,P.jsx)(`span`,{className:`data-crumb-sep`,children:`›`}),(0,P.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>J(Gt(e)),title:t.name,children:t.displayName??t.name})]},Gt(e))})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>J(`.`),children:`data`}),N.map((e,t)=>(0,P.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,P.jsx)(`span`,{className:`data-crumb-sep`,children:`›`}),(0,P.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>J(Gt(t)),title:e.name,children:e.displayName??e.name})]},Gt(t)))]})]}),$e&&(0,P.jsxs)(`div`,{className:`data-inline-form`,children:[(0,P.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`Folder name`,value:tt,autoFocus:!0,onChange:e=>nt(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Ut(),e.key===`Escape`&&et(!1)}}),(0,P.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:Ut,children:`Create`}),(0,P.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost`,onClick:()=>et(!1),children:`Cancel`})]}),rt&&(0,P.jsxs)(`div`,{className:`data-inline-form`,children:[(0,P.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`New name`,value:at,autoFocus:!0,onChange:e=>ot(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Wt(),e.key===`Escape`&&it(null)}}),(0,P.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:Wt,children:`Rename`}),(0,P.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost`,onClick:()=>it(null),children:`Cancel`})]}),st&&(0,P.jsx)(`div`,{className:`data-error`,children:st}),(0,P.jsx)(`input`,{type:`file`,ref:Ze,hidden:!0,onChange:e=>{let t=e.target.files?.[0];t&&zt(t)}})]}),(0,P.jsxs)(`div`,{className:`data-body`,"data-drag-active":qe?`true`:void 0,onDragEnter:Bt,onDragOver:Bt,onDragLeave:Vt,onDrop:Ht,children:[(te!==null||h!==null)&&(0,P.jsxs)(`section`,{className:`data-panel admin-card`,children:[te&&(0,P.jsxs)(`div`,{className:`data-error`,children:[`Search failed: `,te]}),mt.length>0&&(0,P.jsx)(`div`,{className:`data-chip-row`,role:`group`,"aria-label":`Filter by type`,children:mt.map(e=>{let t=e===q;return(0,P.jsx)(`button`,{type:`button`,className:`data-chip`,"data-active":t,onClick:()=>re(t?null:e),children:Be([e])??e},e)})}),h&&!b&&(0,P.jsxs)(`div`,{className:`data-results-meta`,children:[ht.length,` of `,h.length,` result`,h.length===1?``:`s`]}),h&&!b&&!q&&C>0&&!w&&(0,P.jsxs)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>ae(!0),children:[C,` low-confidence result`,C===1?``:`s`,` hidden — show all`]}),h&&!b&&!q&&w&&(0,P.jsx)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>ae(!1),children:`Showing all results — hide low-confidence`}),h&&h.length===0&&!b&&(0,P.jsx)(`div`,{className:`data-empty-results`,children:`No matches. Try a different keyword.`}),ht&&ht.length>0&&(0,P.jsx)(`ul`,{className:`data-results`,children:ht.map(e=>(0,P.jsx)(ze,{hit:e,mode:v,onDownload:gt,onLocate:vt},e.nodeId))})]}),(0,P.jsxs)(`section`,{className:`data-panel admin-card`,children:[H&&(0,P.jsxs)(`div`,{className:`data-upload-progress`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":H.total>0?Math.round(H.loaded/H.total*100):void 0,children:[(0,P.jsx)(`div`,{className:`data-upload-progress-track`,children:(0,P.jsx)(`div`,{className:`data-upload-progress-fill`,style:{width:`${H.total>0?Math.round(H.loaded/H.total*100):0}%`}})}),(0,P.jsxs)(`span`,{className:`data-upload-progress-label`,children:[`Uploading… `,H.total>0?`${Math.round(H.loaded/H.total*100)}%`:``]})]}),Ve&&(0,P.jsxs)(`div`,{className:`data-error`,children:[`Upload failed: `,Ve]}),Ge&&(0,P.jsx)(`div`,{className:`data-status`,children:Ge}),Ye&&(0,P.jsxs)(`div`,{className:`data-error`,children:[`Delete failed: `,Ye]}),Ne&&(0,P.jsx)(`div`,{className:`data-error`,children:Ne}),B&&(0,P.jsxs)(`div`,{className:`data-loading`,children:[(0,P.jsx)(s,{size:14,className:`spin`}),` Loading…`]}),!Y&&!B&&F!==`home`&&k&&k.length>0&&(0,P.jsxs)(`div`,{className:`data-select-hint`,children:[(0,P.jsx)(fe,{size:13}),(0,P.jsx)(`span`,{children:`Press and hold a file to select, rename, or delete it.`})]}),!B&&F!==`home`&&k&&k.length===0&&!Ne&&(0,P.jsx)(`div`,{className:`data-empty-results`,children:`Empty directory.`}),!B&&F===`home`&&k&&(0,P.jsxs)(`ul`,{className:`routine-list data-home-list`,children:[k.map(e=>(0,P.jsxs)(`li`,{className:`data-home-card`,children:[(0,P.jsxs)(`button`,{type:`button`,className:`data-home-card-head`,onClick:()=>J(z(e.name)),children:[(0,P.jsx)(`span`,{className:`data-home-card-title`,children:e.name}),(0,P.jsx)(`span`,{className:`data-home-card-count`,children:e.childCount===null||e.childCount===void 0?`—`:`${e.childCount} ${e.childCount===1?`item`:`items`}`})]}),(0,P.jsxs)(`ul`,{className:`data-home-card-children`,children:[e.childCount===null&&(0,P.jsx)(`li`,{className:`data-home-card-error`,children:`Could not read this folder.`}),e.childCount===0&&(0,P.jsx)(`li`,{className:`data-home-card-empty`,children:`Empty.`}),(e.children??[]).map(e=>(0,P.jsxs)(`li`,{className:`data-home-card-child`,children:[e.kind===`directory`?(0,P.jsx)(i,{size:12}):(0,P.jsx)(E,{size:12}),(0,P.jsx)(`span`,{className:`data-home-card-child-name`,children:e.name})]},e.name)),typeof e.childCount==`number`&&e.childCount>(e.children?.length??0)&&(0,P.jsxs)(`li`,{className:`data-home-card-more`,children:[`+`,e.childCount-(e.children?.length??0),` more`]})]})]},e.name)),(0,P.jsxs)(`li`,{className:`data-home-card`,children:[(0,P.jsxs)(`button`,{type:`button`,className:`data-home-card-head`,onClick:()=>J(z(`@system`)),children:[(0,P.jsx)(`span`,{className:`data-home-card-title`,children:`system`}),(0,P.jsxs)(`span`,{className:`data-home-card-count`,children:[ve,` `,ve===1?`item`:`items`]})]}),(0,P.jsx)(`ul`,{className:`data-home-card-children`,children:(0,P.jsx)(`li`,{className:`data-home-card-empty`,children:`Platform and plugin folders.`})})]})]}),!B&&F!==`home`&&k&&k.length>0&&A===`grid`&&(0,P.jsx)(`ul`,{className:`data-grid`,children:k.map(e=>{let n=e.displayName??e.name,r=Y&&X.has(e.name);if(e.kind===`directory`)return(0,P.jsx)(`li`,{className:`data-grid-cell`,"data-selected":r?`true`:void 0,children:(0,P.jsxs)(`button`,{type:`button`,className:`data-grid-tile`,onPointerDown:()=>Dt(e.name),onPointerUp:$,onPointerMove:$,onPointerLeave:$,onPointerCancel:$,onClick:()=>{if(Z.current){Z.current=!1;return}if(Y){Et(e.name);return}J(z(e.name))},children:[Y&&(0,P.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,P.jsx)(i,{size:28,className:`data-grid-glyph`}),(0,P.jsx)(`span`,{className:`data-grid-label`,title:e.name,children:n})]})},e.name);if(e.kind===`file`){let i=Ce(V(e)),a=z(V(e));return(0,P.jsx)(`li`,{className:`data-grid-cell`,"data-selected":r?`true`:void 0,children:(0,P.jsxs)(`button`,{type:`button`,className:`data-grid-tile${i?` data-grid-tile-image`:``}`,onPointerDown:()=>Dt(e.name),onPointerUp:$,onPointerMove:$,onPointerLeave:$,onPointerCancel:$,onClick:()=>i?At(e):Ot(e),title:Y?void 0:i?`Preview ${n}`:`Download ${n}`,children:[Y&&(0,P.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),i?(0,P.jsx)(`img`,{className:`data-grid-thumb`,src:Se(t,a),alt:n,loading:`lazy`,onError:()=>console.warn(`[data] op=thumb-error path=${a}`)}):(0,P.jsx)(E,{size:28,className:`data-grid-glyph`}),(0,P.jsx)(`span`,{className:`data-grid-label`,title:e.name,children:n}),!i&&(0,P.jsx)(`span`,{className:`data-grid-sub`,children:He(e.sizeBytes)})]})},e.name)}return(0,P.jsx)(`li`,{className:`data-grid-cell`,children:(0,P.jsxs)(`div`,{className:`data-grid-tile data-entry-disabled`,children:[(0,P.jsx)(E,{size:28,className:`data-grid-glyph`}),(0,P.jsx)(`span`,{className:`data-grid-label`,children:n}),(0,P.jsx)(`span`,{className:`data-grid-sub`,children:`special`})]})},e.name)})}),!B&&F!==`home`&&k&&k.length>0&&A===`list`&&(0,P.jsx)(`ul`,{className:`data-entries`,children:k.map(e=>{let t=e.displayName??e.name;if(e.kind===`directory`){let n=Y&&X.has(e.name);return(0,P.jsx)(`li`,{className:`data-entry`,"data-selected":n?`true`:void 0,children:(0,P.jsxs)(`button`,{type:`button`,className:`data-entry-btn`,onPointerDown:()=>Dt(e.name),onPointerUp:$,onPointerMove:$,onPointerLeave:$,onPointerCancel:$,onClick:()=>{if(Z.current){Z.current=!1;return}if(Y){Et(e.name);return}J(z(e.name))},children:[Y&&(0,P.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,P.jsx)(i,{size:14}),(0,P.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t})]})},e.name)}if(e.kind===`file`){let n=Y&&X.has(e.name);return(0,P.jsx)(`li`,{className:`data-entry`,"data-selected":n?`true`:void 0,children:(0,P.jsxs)(`button`,{type:`button`,className:`data-entry-btn data-entry-file`,onPointerDown:()=>Dt(e.name),onPointerUp:$,onPointerMove:$,onPointerLeave:$,onPointerCancel:$,onClick:()=>Ot(e),title:Y?void 0:`Download ${t}`,children:[Y&&(0,P.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,P.jsxs)(`span`,{className:`data-entry-text`,children:[(0,P.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t}),(0,P.jsxs)(`span`,{className:`data-entry-meta`,title:`Modified ${Ue(e.modifiedAt)}`,children:[He(e.sizeBytes),` · `,Ue(e.modifiedAt)]})]})]})},e.name)}return(0,P.jsx)(`li`,{className:`data-entry`,children:(0,P.jsx)(`div`,{className:`data-entry-btn data-entry-file data-entry-disabled`,children:(0,P.jsxs)(`span`,{className:`data-entry-text`,children:[(0,P.jsx)(`span`,{className:`data-entry-name`,children:t}),(0,P.jsx)(`span`,{className:`data-entry-meta`,children:`special`})]})})},e.name)})})]})]}),Y&&(0,P.jsx)(`div`,{className:`data-select-bar`,role:`toolbar`,"aria-label":`Selection actions`,children:(0,P.jsxs)(`div`,{className:`data-select-bar-inner`,children:[(0,P.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:It,disabled:!wt||X.size===0,title:wt?`Share selected files`:`Sharing is not supported on this device`,children:[(0,P.jsx)(x,{size:16}),` Share`]}),(0,P.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:Pt,disabled:X.size===0,children:[(0,P.jsx)(g,{size:16}),` Download`]}),(0,P.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:()=>{let e=Mt();e&&(it(e.name),ot(e.name))},disabled:!Mt(),children:[(0,P.jsx)(o,{size:16}),` Rename`]}),(0,P.jsxs)(`button`,{type:`button`,className:`data-select-action data-select-delete`,onClick:Ft,disabled:X.size===0,children:[(0,P.jsx)(l,{size:16}),` Delete`]})]})}),j&&(0,P.jsx)(`div`,{className:`chat-attachment-overlay`,role:`dialog`,"aria-label":j.alt,onClick:()=>he(null),children:(0,P.jsx)(`img`,{className:`chat-attachment-overlay-image`,src:j.src,alt:j.alt})})]}):(0,P.jsx)(n,{surface:`gate`})}function Le({adminFetch:e,cacheKey:t,sessionRefetchNonce:n}){(0,M.useEffect)(()=>{console.info(`[data-ui] op=mount header=operator home=absent`)},[]);let r=(0,M.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]),i=(0,M.useCallback)(e=>{e===`chat`&&(window.location.href=`/`)},[]),[a,o]=(0,M.useState)([]),[s,c]=(0,M.useState)(`files`),{subAccounts:l,activeAccountId:u,switching:d,switchAccount:f}=y(t);return(0,M.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,P.jsxs)(`main`,{className:`data-main`,children:[(0,P.jsx)(p,{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:u,switchingAccount:d,onSwitchAccount:f}),s===`conversations`?(0,P.jsx)(z,{conversations:a,sessionKey:t,onBack:()=>c(`files`)}):(0,P.jsx)(Ie,{adminFetch:e,cacheKey:t,sessionRefetchNonce:n})]})}function Re({cacheKey:e}){let{adminFetch:t,cacheKey:n,sessionRefetchNonce:r}=c({initialCacheKey:e,surface:`data`});return(0,P.jsx)(`div`,{className:`data-page`,children:(0,P.jsx)(`main`,{className:`data-main`,children:(0,P.jsx)(Ie,{adminFetch:t,cacheKey:n,sessionRefetchNonce:r})})})}function ze({hit:e,mode:t,onDownload:n,onLocate:r}){let a=H(e.properties),o=U(e.properties),s=Be(e.labels),c=Ve(e.properties),[l,u]=(0,M.useState)(!1),d=o&&o.length>280,f=l||!d?o:o?.slice(0,280)+`…`,p=t===`bm25`?`bm25 ${e.bm25Score.toFixed(2)}`:`vector ${e.vectorScore.toFixed(2)} · bm25 ${e.bm25Score.toFixed(2)} · combined ${e.score.toFixed(2)}`,m=e.properties.relativePath,h=typeof m==`string`&&m.length>0,g=h?m.lastIndexOf(`/`):-1,_=h?g===-1?`data`:m.slice(0,g):null;return(0,P.jsxs)(`li`,{className:`data-result`,children:[(0,P.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 ${a??s??`file`}`,children:[s&&(0,P.jsx)(`div`,{className:`data-result-header`,children:(0,P.jsx)(`span`,{className:`data-result-labels`,children:s})}),a&&(0,P.jsx)(`div`,{className:`data-result-title`,children:a}),o&&(0,P.jsx)(`pre`,{className:`data-result-body`,children:f}),(0,P.jsxs)(`div`,{className:`data-result-scores`,children:[c&&(0,P.jsxs)(`span`,{className:`data-result-updated`,children:[`Updated `,Ue(c),` · `]}),p]})]}),h&&(0,P.jsxs)(`button`,{type:`button`,className:`data-result-locate`,onClick:()=>r(e),title:`Locate in ${_}`,"aria-label":`Locate in ${_}`,children:[(0,P.jsx)(i,{size:12}),_]}),d&&(0,P.jsx)(`button`,{type:`button`,className:`data-result-toggle`,onClick:()=>u(e=>!e),children:l?`Show less`:`Show more`})]})}function Be(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 H(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 U(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 Ve(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 He(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 Ue(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{j as a,L as i,Re as n,be as r,Oe as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{B as t,
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{B as t,K as n,W as r}from"./useSubAccountSwitcher-DSW9vDi2.js";import"./useVoiceRecorder-BeNqxmm2.js";import{C as i}from"./AdminShell-C8wazpnz.js";import{a,c as o,i as s,o as c,r as l,s as u}from"./page-HVtUfub2.js";import"./useCopyFeedback-BTUu3-l8.js";var d=r(),f=e(n(),1),p=t();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{P as e}from"./useSubAccountSwitcher-
|
|
1
|
+
import{P as e}from"./useSubAccountSwitcher-DSW9vDi2.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{B as t,F as n,G as r,H as i,P as a,S as o,T as s,U as c,_ as l,g as u,p as d}from"./useSubAccountSwitcher-DVmWZxar.js";import{T as f,d as p,m,t as h}from"./AdminShell-C8hBpL9K.js";import{t as g}from"./clock-BceBgZP1.js";import{t as _}from"./wrench-oeLti270.js";var v=a(`history`,[[`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`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),y=c(),b=e(r(),1);function x(e){return/^\d+$/.test(e)?Number(e):null}function S(e){let t=e.trim().split(/\s+/);if(t.length!==5)return null;let[n,r,i,a,o]=t,s=x(n),c=x(r);if(s===null||c===null||s>59||c>23||a!==`*`)return null;if(i===`*`&&o===`*`)return{frequency:`daily`,minute:s,hour:c,weekdays:[],dayOfMonth:1};if(i===`*`&&o!==`*`){let e=o.split(`,`).map(x);return e.some(e=>e===null||e>6)?null:{frequency:`weekly`,minute:s,hour:c,weekdays:e,dayOfMonth:1}}if(o===`*`&&i!==`*`){let e=x(i);return e===null||e<1||e>31?null:{frequency:`monthly`,minute:s,hour:c,weekdays:[],dayOfMonth:e}}return null}function C(e){let t=String(e.minute),n=String(e.hour);return e.frequency===`daily`?`${t} ${n} * * *`:e.frequency===`weekly`?`${t} ${n} * * ${e.weekdays.length?[...e.weekdays].sort((e,t)=>e-t).join(`,`):`*`}`:`${t} ${n} ${e.dayOfMonth} * *`}var w=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function T(e,t){if(e===`*`)return{kind:`any`,value:0,rangeStart:null,rangeEnd:null,step:1};let n=e.match(/^(\*|\d+-\d+)\/(\d+)$/);if(n){let e=Number(n[2]);if(e<1)return null;if(n[1]===`*`)return{kind:`step`,value:0,rangeStart:null,rangeEnd:null,step:e};let[r,i]=n[1].split(`-`).map(Number);return r>t||i>t||r>i?null:{kind:`step`,value:0,rangeStart:r,rangeEnd:i,step:e}}let r=e.match(/^(\d+)-(\d+)$/);if(r){let e=Number(r[1]),n=Number(r[2]);return e>t||n>t||e>n?null:{kind:`step`,value:0,rangeStart:e,rangeEnd:n,step:1}}if(/^\d+$/.test(e)){let n=Number(e);return n>t?null:{kind:`fixed`,value:n,rangeStart:null,rangeEnd:null,step:1}}return null}function E(e){return String(e).padStart(2,`0`)}function D(e){if(e===`*`)return null;let t=e.match(/^(\d+)-(\d+)$/);if(t){let e=Number(t[1]),n=Number(t[2]);return e>7||n>7||e>n?`invalid`:`${w[e%7]} to ${w[n%7]}`}let n=e.split(`,`);return n.length>0&&n.every(e=>/^\d+$/.test(e)&&Number(e)<=7)?n.map(e=>w[Number(e)%7]).join(`, `):`invalid`}function O(e){let t=e.trim().split(/\s+/);if(t.length!==5)return e;let[n,r,i,a,o]=t;if(a!==`*`||i!==`*`&&!/^\d+$/.test(i))return e;let s=T(n,59),c=T(r,23);if(!s||!c)return e;let l=D(o);if(l===`invalid`||s.kind===`step`&&s.rangeStart!==null||(s.kind===`any`&&(s={kind:`step`,value:0,rangeStart:null,rangeEnd:null,step:1}),c.kind===`step`&&c.step===1&&c.rangeStart===null&&(c={kind:`any`,value:0,rangeStart:null,rangeEnd:null,step:1}),i!==`*`&&!(s.kind===`fixed`&&c.kind===`fixed`&&o===`*`))||s.kind===`step`&&c.kind===`step`&&c.step>1)return e;let u=l?`, ${l}`:``,d=e=>e.rangeStart+Math.floor((e.rangeEnd-e.rangeStart)/e.step)*e.step;if(s.kind===`step`){let e=s.step===1?`Every minute`:`Every ${s.step} minutes`;return c.kind===`any`?`${e}${u}`:c.kind===`fixed`?`${e}, ${E(c.value)}:00 to ${E(c.value)}:59${u}`:`${e}, ${E(c.rangeStart)}:00 to ${E(d(c))}:00${u}`}if(c.kind===`step`){let e=E(s.value),t=s.value===0?``:` at :${e}`;return c.rangeStart===null?`Every ${c.step} hours${t}${u}`:c.step===1?`Hourly, ${E(c.rangeStart)}:${e} to ${E(c.rangeEnd)}:${e}${u}`:`Every ${c.step} hours, ${E(c.rangeStart)}:${e} to ${E(d(c))}:${e}${u}`}if(c.kind===`any`)return`${s.value===0?`Every hour`:`Every hour at :${E(s.value)}`}${u}`;let f=`${E(c.value)}:${E(s.value)}`;return i===`*`?l?`${l} at ${f}`:`Daily at ${f}`:`Monthly on day ${Number(i)} at ${f}`}var k=t(),A=[{value:1,label:`Mon`},{value:2,label:`Tue`},{value:3,label:`Wed`},{value:4,label:`Thu`},{value:5,label:`Fri`},{value:6,label:`Sat`},{value:0,label:`Sun`}];function j(e){return`${String(e.hour).padStart(2,`0`)}:${String(e.minute).padStart(2,`0`)}`}var M={frequency:`daily`,minute:0,hour:9,weekdays:[1],dayOfMonth:1};function N({recurrence:e,onChange:t,disabled:n}){let r=e?S(e):M,[i,a]=(0,b.useState)(r??M),[o]=(0,b.useState)(e!=null&&r==null),[s,c]=(0,b.useState)(e??``);if(o)return(0,k.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,k.jsx)(`span`,{children:`Schedule (advanced)`}),(0,k.jsx)(`input`,{type:`text`,className:`routine-raw-cron`,value:s,disabled:n,onChange:e=>{c(e.target.value),t(e.target.value)},"aria-label":`Cron expression`}),(0,k.jsx)(`span`,{className:`routine-raw-note`,children:`This routine uses an advanced schedule, edited as a raw cron expression.`})]});let l=e=>{a(e),t(C(e))},u=e=>{let t=e===`weekly`&&i.weekdays.length===0?[1]:i.weekdays;l({...i,frequency:e,weekdays:t})},d=e=>{let[t,n]=e.split(`:`);l({...i,hour:Number(t)||0,minute:Number(n)||0})},f=e=>{let t=i.weekdays.includes(e);if(t&&i.weekdays.length===1)return;let n=t?i.weekdays.filter(t=>t!==e):[...i.weekdays,e];l({...i,weekdays:n})},p=e=>l({...i,dayOfMonth:Number(e)||1});return(0,k.jsxs)(`div`,{className:`routine-sched`,children:[(0,k.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,k.jsx)(`span`,{children:`Frequency`}),(0,k.jsxs)(`select`,{value:i.frequency,disabled:n,onChange:e=>u(e.target.value),children:[(0,k.jsx)(`option`,{value:`daily`,children:`Daily`}),(0,k.jsx)(`option`,{value:`weekly`,children:`Weekly`}),(0,k.jsx)(`option`,{value:`monthly`,children:`Monthly`})]})]}),(0,k.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,k.jsx)(`span`,{children:`Time of day`}),(0,k.jsx)(`input`,{type:`time`,value:j(i),disabled:n,onChange:e=>d(e.target.value)})]}),i.frequency===`weekly`&&(0,k.jsxs)(`div`,{className:`cal-modal-field`,children:[(0,k.jsx)(`span`,{children:`Days`}),(0,k.jsx)(`div`,{className:`routine-weekdays`,children:A.map(e=>(0,k.jsx)(`button`,{type:`button`,className:`routine-weekday${i.weekdays.includes(e.value)?` routine-weekday-on`:``}`,"aria-pressed":i.weekdays.includes(e.value),disabled:n,onClick:()=>f(e.value),children:e.label},e.value))})]}),i.frequency===`monthly`&&(0,k.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,k.jsx)(`span`,{children:`Day of month`}),(0,k.jsx)(`select`,{value:i.dayOfMonth,disabled:n,onChange:e=>p(e.target.value),children:Array.from({length:31},(e,t)=>t+1).map(e=>(0,k.jsx)(`option`,{value:e,children:e},e))})]})]})}function P(e){if(!e)return`—`;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function F({routine:e,adminFetch:t,onClose:n,onSaved:r,onDeleted:i}){let[a,c]=(0,b.useState)(!1),[d,f]=(0,b.useState)(!1),[h,y]=(0,b.useState)(null),[x,S]=(0,b.useState)(e),[C,w]=(0,b.useState)(!1),T=x.agentChannel!=null,[E,D]=(0,b.useState)(e.agentPrompt??``),[A,j]=(0,b.useState)(e.recurrence);(0,b.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!d&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[d,n]);let M=(0,b.useCallback)(()=>{let e={};return T&&E!==(x.agentPrompt??``)&&(e.agentPrompt=E),A!=null&&A!==(x.recurrence??null)&&(e.recurrence=A),e},[T,E,A,x]),F=(0,b.useCallback)(async()=>{let n=M();if(Object.keys(n).length===0){c(!1);return}f(!0),y(null);try{let i=await t(`/api/admin/routines/${encodeURIComponent(e.eventId)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(n)});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.error??`HTTP ${i.status}`)}let a=await i.json();S(a.routine),D(a.routine.agentPrompt??``),j(a.routine.recurrence),r(a.routine),c(!1)}catch(e){y(e instanceof Error?e.message:`Save failed`)}finally{f(!1)}},[t,M,e.eventId,r]),I=(0,b.useCallback)(async()=>{if(!d){if(!C){w(!0);return}f(!0),y(null);try{let n=await t(`/api/admin/routines/${encodeURIComponent(e.eventId)}`,{method:`DELETE`});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`HTTP ${n.status}`)}i(e.eventId)}catch(e){y(e instanceof Error?e.message:`Delete failed`),w(!1)}finally{f(!1)}}},[t,d,C,e.eventId,i]);return(0,k.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{d||n()},children:(0,k.jsxs)(`div`,{className:`cal-modal cal-modal-wide`,role:`dialog`,"aria-modal":`true`,"aria-label":a?`Edit routine`:`Routine detail`,onClick:e=>e.stopPropagation(),children:[(0,k.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,k.jsxs)(`span`,{className:`cal-modal-kind`,children:[(0,k.jsx)(p,{size:13}),` Routine`]}),(0,k.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:n,"aria-label":`Close`,autoFocus:!0,disabled:d,children:(0,k.jsx)(u,{size:16})})]}),!a&&(0,k.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,k.jsx)(`div`,{className:`cal-modal-title`,children:x.name??`Untitled routine`}),(0,k.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,k.jsx)(g,{size:14}),(0,k.jsx)(`span`,{children:x.recurrence?O(x.recurrence):`One-time`})]}),(0,k.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,k.jsxs)(`span`,{children:[`Status: `,x.eventStatus??`unknown`]})}),(0,k.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,k.jsxs)(`span`,{children:[`Next run: `,P(x.nextRun)]})}),(0,k.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,k.jsx)(v,{size:14}),(0,k.jsxs)(`span`,{children:[`Last run: `,P(x.lastTriggered),x.lastDispatchResult?` (${x.lastDispatchResult})`:``]})]}),T?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,k.jsx)(m,{size:14}),(0,k.jsxs)(`span`,{children:[x.agentChannel,` to `,x.agentDestination??`—`]})]}),(0,k.jsx)(`div`,{className:`cal-modal-row cal-modal-row-top routine-prose`,children:(0,k.jsx)(`span`,{children:x.agentPrompt??`No instruction set.`})})]}):x.actionPlugin?(0,k.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,k.jsx)(_,{size:14}),(0,k.jsxs)(`span`,{children:[x.actionPlugin,`.`,x.actionTool,x.actionArgs?` ${x.actionArgs}`:``]})]}):(0,k.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,k.jsx)(g,{size:14}),(0,k.jsx)(`span`,{children:`Scheduled trigger (no dispatch)`})]})]}),a&&(0,k.jsxs)(`div`,{className:`cal-modal-body`,children:[T&&(0,k.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,k.jsx)(`span`,{children:`Instruction`}),(0,k.jsx)(`textarea`,{className:`cal-modal-textarea`,value:E,onChange:e=>D(e.target.value),disabled:d,rows:16,placeholder:`What should the agent do when this routine fires?`})]}),(0,k.jsx)(N,{recurrence:x.recurrence,onChange:j,disabled:d})]}),h&&(0,k.jsx)(`div`,{className:`cal-modal-error`,children:h}),(0,k.jsxs)(`div`,{className:`cal-modal-actions`,children:[!a&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>{w(!1),c(!0)},disabled:d,children:[(0,k.jsx)(o,{size:14}),` Edit`]}),(0,k.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:I,disabled:d,children:[d&&C?(0,k.jsx)(s,{size:14,className:`spin`}):(0,k.jsx)(l,{size:14}),C?`Confirm delete`:`Delete`]})]}),a&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:F,disabled:d,children:[d?(0,k.jsx)(s,{size:14,className:`spin`}):null,` Save`]}),(0,k.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>{c(!1),y(null)},disabled:d,children:`Cancel`})]})]})]})})}var I=`maxy-admin-session-key`;function L(e){return e?O(e):`One-time`}function R(e){if(!e)return`—`;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function z(){let[e,t]=(0,b.useState)(null),[r,i]=(0,b.useState)(!1),[a,o]=(0,b.useState)(void 0),[s,c]=(0,b.useState)(null),[l,u]=(0,b.useState)(void 0),[p,m]=(0,b.useState)(null),[g,_]=(0,b.useState)(null);(0,b.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(I)}catch{}if(!n){i(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async r=>{if(!e){if(r.status===401){try{sessionStorage.removeItem(I)}catch{}window.location.href=`/`;return}if(r.ok)try{let e=await r.json();typeof e.businessName==`string`&&o(e.businessName),e.sessionId!==void 0&&c(e.sessionId??null),_(e.role??null),u(e.userName===void 0?null:e.userName),m(e.avatar??null)}catch{}t(n),i(!0)}}).catch(()=>{e||(t(n),i(!0))}),()=>{e=!0}},[]);let v=(0,b.useCallback)(()=>{try{sessionStorage.removeItem(I)}catch{}window.location.href=`/`},[]),[y,x]=(0,b.useState)(!1),S=(0,b.useCallback)(async()=>{x(!0);try{let e=await f();if(e){try{sessionStorage.removeItem(I)}catch{}window.location.href=`/`}return e}finally{x(!1)}},[]);return r?e?(0,k.jsx)(d,{cacheKey:e,surface:`routines`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=routines`);try{sessionStorage.removeItem(I)}catch{}window.location.href=`/`},children:(0,k.jsx)(h,{cacheKey:e,businessName:a,sessionId:s,onLogout:v,onDisconnect:S,disconnecting:y,userName:l,userAvatar:p,role:g,children:(0,k.jsx)(B,{cacheKey:e})})}):(0,k.jsx)(`div`,{className:`cal-page`,children:(0,k.jsxs)(`div`,{className:`cal-empty`,children:[(0,k.jsx)(`p`,{children:`You are not signed in.`}),(0,k.jsxs)(`p`,{children:[`Open the `,(0,k.jsx)(`a`,{href:`/`,className:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,k.jsx)(n,{surface:`gate`})}function B({cacheKey:e}){let{adminFetch:t,sessionRefetchNonce:r}=i({initialCacheKey:e,surface:`routines`}),[a,o]=(0,b.useState)([]),[c,l]=(0,b.useState)(!1),[u,d]=(0,b.useState)(!1),[f,h]=(0,b.useState)(null),[v,y]=(0,b.useState)(null),x=(0,b.useCallback)(()=>{let e=!1;return l(!0),h(null),t(`/api/admin/routines`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();o(Array.isArray(n.routines)?n.routines:[])}).catch(t=>{e||(h(t instanceof Error?t.message:`Failed to load`),o([]))}).finally(()=>{e||(l(!1),d(!0))}),()=>{e=!0}},[t]);(0,b.useEffect)(()=>x(),[x,r]);let S=(0,b.useCallback)(e=>{o(t=>t.map(t=>t.eventId===e.eventId?e:t)),y(e)},[]),C=(0,b.useCallback)(e=>{o(t=>t.filter(t=>t.eventId!==e)),y(null)},[]);return u?(0,k.jsxs)(`div`,{className:`cal-page`,children:[(0,k.jsx)(`header`,{className:`cal-header`,children:(0,k.jsxs)(`div`,{className:`cal-nav`,children:[(0,k.jsxs)(`span`,{className:`cal-range-label`,children:[(0,k.jsx)(p,{size:16}),` Routines`]}),c&&(0,k.jsx)(s,{size:16,className:`spin`})]})}),(0,k.jsxs)(`div`,{className:`cal-body`,children:[f&&(0,k.jsxs)(`div`,{className:`cal-error`,children:[`Could not load routines: `,f]}),!f&&!c&&a.length===0&&(0,k.jsx)(`div`,{className:`cal-empty`,children:(0,k.jsx)(`p`,{children:`No routines yet.`})}),(0,k.jsx)(`div`,{className:`routine-list`,children:a.map(e=>(0,k.jsxs)(`button`,{type:`button`,className:`routine-card`,onClick:()=>y(e),children:[(0,k.jsx)(`span`,{className:`routine-card-title`,children:e.name??`Untitled routine`}),(0,k.jsxs)(`span`,{className:`routine-card-sched`,children:[(0,k.jsx)(g,{size:13}),` `,L(e.recurrence)]}),(0,k.jsx)(`span`,{className:`routine-card-target`,children:e.agentChannel?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(m,{size:13}),` `,e.agentChannel,` to `,e.agentDestination??`—`]}):e.actionPlugin?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(_,{size:13}),` `,e.actionPlugin,`.`,e.actionTool]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(g,{size:13}),` Scheduled trigger`]})}),(0,k.jsxs)(`span`,{className:`routine-card-meta`,children:[`Next: `,R(e.nextRun),` · `,e.eventStatus??`unknown`]})]},e.eventId))})]}),v&&(0,k.jsx)(F,{routine:v,adminFetch:t,onClose:()=>y(null),onSaved:S,onDeleted:C})]}):(0,k.jsx)(n,{surface:`gate`})}(0,y.createRoot)(document.getElementById(`root`)).render((0,k.jsx)(z,{}));
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{B as t,F as n,K as r,P as i,S as a,T as o,U as s,W as c,_ as l,g as u,p as d}from"./useSubAccountSwitcher-DSW9vDi2.js";import{T as f,d as p,m,t as h}from"./AdminShell-C8wazpnz.js";import{t as g}from"./clock-kkzt7Scf.js";import{t as _}from"./wrench-CeNnc7oO.js";var v=i(`history`,[[`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`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),y=c(),b=e(r(),1);function x(e){return/^\d+$/.test(e)?Number(e):null}function S(e){let t=e.trim().split(/\s+/);if(t.length!==5)return null;let[n,r,i,a,o]=t,s=x(n),c=x(r);if(s===null||c===null||s>59||c>23||a!==`*`)return null;if(i===`*`&&o===`*`)return{frequency:`daily`,minute:s,hour:c,weekdays:[],dayOfMonth:1};if(i===`*`&&o!==`*`){let e=o.split(`,`).map(x);return e.some(e=>e===null||e>6)?null:{frequency:`weekly`,minute:s,hour:c,weekdays:e,dayOfMonth:1}}if(o===`*`&&i!==`*`){let e=x(i);return e===null||e<1||e>31?null:{frequency:`monthly`,minute:s,hour:c,weekdays:[],dayOfMonth:e}}return null}function C(e){let t=String(e.minute),n=String(e.hour);return e.frequency===`daily`?`${t} ${n} * * *`:e.frequency===`weekly`?`${t} ${n} * * ${e.weekdays.length?[...e.weekdays].sort((e,t)=>e-t).join(`,`):`*`}`:`${t} ${n} ${e.dayOfMonth} * *`}var w=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function T(e,t){if(e===`*`)return{kind:`any`,value:0,rangeStart:null,rangeEnd:null,step:1};let n=e.match(/^(\*|\d+-\d+)\/(\d+)$/);if(n){let e=Number(n[2]);if(e<1)return null;if(n[1]===`*`)return{kind:`step`,value:0,rangeStart:null,rangeEnd:null,step:e};let[r,i]=n[1].split(`-`).map(Number);return r>t||i>t||r>i?null:{kind:`step`,value:0,rangeStart:r,rangeEnd:i,step:e}}let r=e.match(/^(\d+)-(\d+)$/);if(r){let e=Number(r[1]),n=Number(r[2]);return e>t||n>t||e>n?null:{kind:`step`,value:0,rangeStart:e,rangeEnd:n,step:1}}if(/^\d+$/.test(e)){let n=Number(e);return n>t?null:{kind:`fixed`,value:n,rangeStart:null,rangeEnd:null,step:1}}return null}function E(e){return String(e).padStart(2,`0`)}function D(e){if(e===`*`)return null;let t=e.match(/^(\d+)-(\d+)$/);if(t){let e=Number(t[1]),n=Number(t[2]);return e>7||n>7||e>n?`invalid`:`${w[e%7]} to ${w[n%7]}`}let n=e.split(`,`);return n.length>0&&n.every(e=>/^\d+$/.test(e)&&Number(e)<=7)?n.map(e=>w[Number(e)%7]).join(`, `):`invalid`}function O(e){let t=e.trim().split(/\s+/);if(t.length!==5)return e;let[n,r,i,a,o]=t;if(a!==`*`||i!==`*`&&!/^\d+$/.test(i))return e;let s=T(n,59),c=T(r,23);if(!s||!c)return e;let l=D(o);if(l===`invalid`||s.kind===`step`&&s.rangeStart!==null||(s.kind===`any`&&(s={kind:`step`,value:0,rangeStart:null,rangeEnd:null,step:1}),c.kind===`step`&&c.step===1&&c.rangeStart===null&&(c={kind:`any`,value:0,rangeStart:null,rangeEnd:null,step:1}),i!==`*`&&!(s.kind===`fixed`&&c.kind===`fixed`&&o===`*`))||s.kind===`step`&&c.kind===`step`&&c.step>1)return e;let u=l?`, ${l}`:``,d=e=>e.rangeStart+Math.floor((e.rangeEnd-e.rangeStart)/e.step)*e.step;if(s.kind===`step`){let e=s.step===1?`Every minute`:`Every ${s.step} minutes`;return c.kind===`any`?`${e}${u}`:c.kind===`fixed`?`${e}, ${E(c.value)}:00 to ${E(c.value)}:59${u}`:`${e}, ${E(c.rangeStart)}:00 to ${E(d(c))}:00${u}`}if(c.kind===`step`){let e=E(s.value),t=s.value===0?``:` at :${e}`;return c.rangeStart===null?`Every ${c.step} hours${t}${u}`:c.step===1?`Hourly, ${E(c.rangeStart)}:${e} to ${E(c.rangeEnd)}:${e}${u}`:`Every ${c.step} hours, ${E(c.rangeStart)}:${e} to ${E(d(c))}:${e}${u}`}if(c.kind===`any`)return`${s.value===0?`Every hour`:`Every hour at :${E(s.value)}`}${u}`;let f=`${E(c.value)}:${E(s.value)}`;return i===`*`?l?`${l} at ${f}`:`Daily at ${f}`:`Monthly on day ${Number(i)} at ${f}`}var k=t(),A=[{value:1,label:`Mon`},{value:2,label:`Tue`},{value:3,label:`Wed`},{value:4,label:`Thu`},{value:5,label:`Fri`},{value:6,label:`Sat`},{value:0,label:`Sun`}];function j(e){return`${String(e.hour).padStart(2,`0`)}:${String(e.minute).padStart(2,`0`)}`}var M={frequency:`daily`,minute:0,hour:9,weekdays:[1],dayOfMonth:1};function N({recurrence:e,onChange:t,disabled:n}){let r=e?S(e):M,[i,a]=(0,b.useState)(r??M),[o]=(0,b.useState)(e!=null&&r==null),[s,c]=(0,b.useState)(e??``);if(o)return(0,k.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,k.jsx)(`span`,{children:`Schedule (advanced)`}),(0,k.jsx)(`input`,{type:`text`,className:`routine-raw-cron`,value:s,disabled:n,onChange:e=>{c(e.target.value),t(e.target.value)},"aria-label":`Cron expression`}),(0,k.jsx)(`span`,{className:`routine-raw-note`,children:`This routine uses an advanced schedule, edited as a raw cron expression.`})]});let l=e=>{a(e),t(C(e))},u=e=>{let t=e===`weekly`&&i.weekdays.length===0?[1]:i.weekdays;l({...i,frequency:e,weekdays:t})},d=e=>{let[t,n]=e.split(`:`);l({...i,hour:Number(t)||0,minute:Number(n)||0})},f=e=>{let t=i.weekdays.includes(e);if(t&&i.weekdays.length===1)return;let n=t?i.weekdays.filter(t=>t!==e):[...i.weekdays,e];l({...i,weekdays:n})},p=e=>l({...i,dayOfMonth:Number(e)||1});return(0,k.jsxs)(`div`,{className:`routine-sched`,children:[(0,k.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,k.jsx)(`span`,{children:`Frequency`}),(0,k.jsxs)(`select`,{value:i.frequency,disabled:n,onChange:e=>u(e.target.value),children:[(0,k.jsx)(`option`,{value:`daily`,children:`Daily`}),(0,k.jsx)(`option`,{value:`weekly`,children:`Weekly`}),(0,k.jsx)(`option`,{value:`monthly`,children:`Monthly`})]})]}),(0,k.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,k.jsx)(`span`,{children:`Time of day`}),(0,k.jsx)(`input`,{type:`time`,value:j(i),disabled:n,onChange:e=>d(e.target.value)})]}),i.frequency===`weekly`&&(0,k.jsxs)(`div`,{className:`cal-modal-field`,children:[(0,k.jsx)(`span`,{children:`Days`}),(0,k.jsx)(`div`,{className:`routine-weekdays`,children:A.map(e=>(0,k.jsx)(`button`,{type:`button`,className:`routine-weekday${i.weekdays.includes(e.value)?` routine-weekday-on`:``}`,"aria-pressed":i.weekdays.includes(e.value),disabled:n,onClick:()=>f(e.value),children:e.label},e.value))})]}),i.frequency===`monthly`&&(0,k.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,k.jsx)(`span`,{children:`Day of month`}),(0,k.jsx)(`select`,{value:i.dayOfMonth,disabled:n,onChange:e=>p(e.target.value),children:Array.from({length:31},(e,t)=>t+1).map(e=>(0,k.jsx)(`option`,{value:e,children:e},e))})]})]})}function P(e){if(!e)return`—`;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function F({routine:e,adminFetch:t,onClose:n,onSaved:r,onDeleted:i}){let[s,c]=(0,b.useState)(!1),[d,f]=(0,b.useState)(!1),[h,y]=(0,b.useState)(null),[x,S]=(0,b.useState)(e),[C,w]=(0,b.useState)(!1),T=x.agentChannel!=null,[E,D]=(0,b.useState)(e.agentPrompt??``),[A,j]=(0,b.useState)(e.recurrence);(0,b.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!d&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[d,n]);let M=(0,b.useCallback)(()=>{let e={};return T&&E!==(x.agentPrompt??``)&&(e.agentPrompt=E),A!=null&&A!==(x.recurrence??null)&&(e.recurrence=A),e},[T,E,A,x]),F=(0,b.useCallback)(async()=>{let n=M();if(Object.keys(n).length===0){c(!1);return}f(!0),y(null);try{let i=await t(`/api/admin/routines/${encodeURIComponent(e.eventId)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(n)});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.error??`HTTP ${i.status}`)}let a=await i.json();S(a.routine),D(a.routine.agentPrompt??``),j(a.routine.recurrence),r(a.routine),c(!1)}catch(e){y(e instanceof Error?e.message:`Save failed`)}finally{f(!1)}},[t,M,e.eventId,r]),I=(0,b.useCallback)(async()=>{if(!d){if(!C){w(!0);return}f(!0),y(null);try{let n=await t(`/api/admin/routines/${encodeURIComponent(e.eventId)}`,{method:`DELETE`});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`HTTP ${n.status}`)}i(e.eventId)}catch(e){y(e instanceof Error?e.message:`Delete failed`),w(!1)}finally{f(!1)}}},[t,d,C,e.eventId,i]);return(0,k.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{d||n()},children:(0,k.jsxs)(`div`,{className:`cal-modal cal-modal-wide`,role:`dialog`,"aria-modal":`true`,"aria-label":s?`Edit routine`:`Routine detail`,onClick:e=>e.stopPropagation(),children:[(0,k.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,k.jsxs)(`span`,{className:`cal-modal-kind`,children:[(0,k.jsx)(p,{size:13}),` Routine`]}),(0,k.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:n,"aria-label":`Close`,autoFocus:!0,disabled:d,children:(0,k.jsx)(u,{size:16})})]}),!s&&(0,k.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,k.jsx)(`div`,{className:`cal-modal-title`,children:x.name??`Untitled routine`}),(0,k.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,k.jsx)(g,{size:14}),(0,k.jsx)(`span`,{children:x.recurrence?O(x.recurrence):`One-time`})]}),(0,k.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,k.jsxs)(`span`,{children:[`Status: `,x.eventStatus??`unknown`]})}),(0,k.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,k.jsxs)(`span`,{children:[`Next run: `,P(x.nextRun)]})}),(0,k.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,k.jsx)(v,{size:14}),(0,k.jsxs)(`span`,{children:[`Last run: `,P(x.lastTriggered),x.lastDispatchResult?` (${x.lastDispatchResult})`:``]})]}),T?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,k.jsx)(m,{size:14}),(0,k.jsxs)(`span`,{children:[x.agentChannel,` to `,x.agentDestination??`—`]})]}),(0,k.jsx)(`div`,{className:`cal-modal-row cal-modal-row-top routine-prose`,children:(0,k.jsx)(`span`,{children:x.agentPrompt??`No instruction set.`})})]}):x.actionPlugin?(0,k.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,k.jsx)(_,{size:14}),(0,k.jsxs)(`span`,{children:[x.actionPlugin,`.`,x.actionTool,x.actionArgs?` ${x.actionArgs}`:``]})]}):(0,k.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,k.jsx)(g,{size:14}),(0,k.jsx)(`span`,{children:`Scheduled trigger (no dispatch)`})]})]}),s&&(0,k.jsxs)(`div`,{className:`cal-modal-body`,children:[T&&(0,k.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,k.jsx)(`span`,{children:`Instruction`}),(0,k.jsx)(`textarea`,{className:`cal-modal-textarea`,value:E,onChange:e=>D(e.target.value),disabled:d,rows:16,placeholder:`What should the agent do when this routine fires?`})]}),(0,k.jsx)(N,{recurrence:x.recurrence,onChange:j,disabled:d})]}),h&&(0,k.jsx)(`div`,{className:`cal-modal-error`,children:h}),(0,k.jsxs)(`div`,{className:`cal-modal-actions`,children:[!s&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>{w(!1),c(!0)},disabled:d,children:[(0,k.jsx)(a,{size:14}),` Edit`]}),(0,k.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:I,disabled:d,children:[d&&C?(0,k.jsx)(o,{size:14,className:`spin`}):(0,k.jsx)(l,{size:14}),C?`Confirm delete`:`Delete`]})]}),s&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:F,disabled:d,children:[d?(0,k.jsx)(o,{size:14,className:`spin`}):null,` Save`]}),(0,k.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>{c(!1),y(null)},disabled:d,children:`Cancel`})]})]})]})})}var I=`maxy-admin-session-key`;function L(e){return e?O(e):`One-time`}function R(e){if(!e)return`—`;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function z(){let[e,t]=(0,b.useState)(null),[r,i]=(0,b.useState)(!1),[a,o]=(0,b.useState)(void 0),[s,c]=(0,b.useState)(null),[l,u]=(0,b.useState)(void 0),[p,m]=(0,b.useState)(null),[g,_]=(0,b.useState)(null);(0,b.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(I)}catch{}if(!n){i(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async r=>{if(!e){if(r.status===401){try{sessionStorage.removeItem(I)}catch{}window.location.href=`/`;return}if(r.ok)try{let e=await r.json();typeof e.businessName==`string`&&o(e.businessName),e.sessionId!==void 0&&c(e.sessionId??null),_(e.role??null),u(e.userName===void 0?null:e.userName),m(e.avatar??null)}catch{}t(n),i(!0)}}).catch(()=>{e||(t(n),i(!0))}),()=>{e=!0}},[]);let v=(0,b.useCallback)(()=>{try{sessionStorage.removeItem(I)}catch{}window.location.href=`/`},[]),[y,x]=(0,b.useState)(!1),S=(0,b.useCallback)(async()=>{x(!0);try{let e=await f();if(e){try{sessionStorage.removeItem(I)}catch{}window.location.href=`/`}return e}finally{x(!1)}},[]);return r?e?(0,k.jsx)(d,{cacheKey:e,surface:`routines`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=routines`);try{sessionStorage.removeItem(I)}catch{}window.location.href=`/`},children:(0,k.jsx)(h,{cacheKey:e,businessName:a,sessionId:s,onLogout:v,onDisconnect:S,disconnecting:y,userName:l,userAvatar:p,role:g,children:(0,k.jsx)(B,{cacheKey:e})})}):(0,k.jsx)(`div`,{className:`cal-page`,children:(0,k.jsxs)(`div`,{className:`cal-empty`,children:[(0,k.jsx)(`p`,{children:`You are not signed in.`}),(0,k.jsxs)(`p`,{children:[`Open the `,(0,k.jsx)(`a`,{href:`/`,className:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,k.jsx)(n,{surface:`gate`})}function B({cacheKey:e}){let{adminFetch:t,sessionRefetchNonce:r}=s({initialCacheKey:e,surface:`routines`}),[i,a]=(0,b.useState)([]),[c,l]=(0,b.useState)(!1),[u,d]=(0,b.useState)(!1),[f,h]=(0,b.useState)(null),[v,y]=(0,b.useState)(null),x=(0,b.useCallback)(()=>{let e=!1;return l(!0),h(null),t(`/api/admin/routines`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();a(Array.isArray(n.routines)?n.routines:[])}).catch(t=>{e||(h(t instanceof Error?t.message:`Failed to load`),a([]))}).finally(()=>{e||(l(!1),d(!0))}),()=>{e=!0}},[t]);(0,b.useEffect)(()=>x(),[x,r]);let S=(0,b.useCallback)(e=>{a(t=>t.map(t=>t.eventId===e.eventId?e:t)),y(e)},[]),C=(0,b.useCallback)(e=>{a(t=>t.filter(t=>t.eventId!==e)),y(null)},[]);return u?(0,k.jsxs)(`div`,{className:`cal-page`,children:[(0,k.jsx)(`header`,{className:`cal-header`,children:(0,k.jsxs)(`div`,{className:`cal-nav`,children:[(0,k.jsxs)(`span`,{className:`cal-range-label`,children:[(0,k.jsx)(p,{size:16}),` Routines`]}),c&&(0,k.jsx)(o,{size:16,className:`spin`})]})}),(0,k.jsxs)(`div`,{className:`cal-body`,children:[f&&(0,k.jsxs)(`div`,{className:`cal-error`,children:[`Could not load routines: `,f]}),!f&&!c&&i.length===0&&(0,k.jsx)(`div`,{className:`cal-empty`,children:(0,k.jsx)(`p`,{children:`No routines yet.`})}),(0,k.jsx)(`div`,{className:`routine-list`,children:i.map(e=>(0,k.jsxs)(`button`,{type:`button`,className:`routine-card`,onClick:()=>y(e),children:[(0,k.jsx)(`span`,{className:`routine-card-title`,children:e.name??`Untitled routine`}),(0,k.jsxs)(`span`,{className:`routine-card-sched`,children:[(0,k.jsx)(g,{size:13}),` `,L(e.recurrence)]}),(0,k.jsx)(`span`,{className:`routine-card-target`,children:e.agentChannel?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(m,{size:13}),` `,e.agentChannel,` to `,e.agentDestination??`—`]}):e.actionPlugin?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(_,{size:13}),` `,e.actionPlugin,`.`,e.actionTool]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(g,{size:13}),` Scheduled trigger`]})}),(0,k.jsxs)(`span`,{className:`routine-card-meta`,children:[`Next: `,R(e.nextRun),` · `,e.eventStatus??`unknown`]})]},e.eventId))})]}),v&&(0,k.jsx)(F,{routine:v,adminFetch:t,onClose:()=>y(null),onSaved:S,onDeleted:C})]}):(0,k.jsx)(n,{surface:`gate`})}(0,y.createRoot)(document.getElementById(`root`)).render((0,k.jsx)(z,{}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{B as t,D as n,F as r,
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{B as t,D as n,F as r,K as i,T as a,U as o,W as s,_ as c,g as l,p as u}from"./useSubAccountSwitcher-DSW9vDi2.js";import{T as d,f,t as p}from"./AdminShell-C8wazpnz.js";import{t as m}from"./file-text-c6cA4Evd.js";var h=s(),g=e(i(),1),_=t();function v({summary:e,adminFetch:t,onClose:r,onDeleted:i}){let[o,s]=(0,g.useState)(null),[u,d]=(0,g.useState)(!0),[p,h]=(0,g.useState)(null),[v,y]=(0,g.useState)(!1),[b,x]=(0,g.useState)(!1);(0,g.useEffect)(()=>{let n=!1;return d(!0),h(null),t(`/api/admin/skills/${encodeURIComponent(e.plugin)}/${encodeURIComponent(e.skill)}`).then(async e=>{if(!n){if(!e.ok)throw Error(`HTTP ${e.status}`);s((await e.json()).skill)}}).catch(e=>{n||h(e instanceof Error?e.message:`Failed to load`)}).finally(()=>{n||d(!1)}),()=>{n=!0}},[t,e.plugin,e.skill]),(0,g.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!b&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[b,r]);let S=(0,g.useCallback)(async()=>{x(!0),h(null);try{let n=await t(`/api/admin/skills/${encodeURIComponent(e.plugin)}/${encodeURIComponent(e.skill)}`,{method:`DELETE`,headers:{"content-type":`application/json`}});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`HTTP ${n.status}`)}i(e)}catch(e){h(e instanceof Error?e.message:`Delete failed`),x(!1),y(!1)}},[t,e,i]);return(0,_.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{b||r()},children:(0,_.jsxs)(`div`,{className:`cal-modal cal-modal-wide`,role:`dialog`,"aria-modal":`true`,"aria-label":`Skill detail`,onClick:e=>e.stopPropagation(),children:[(0,_.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,_.jsxs)(`span`,{className:`cal-modal-kind`,children:[(0,_.jsx)(f,{size:13}),` Skill`]}),(0,_.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:r,"aria-label":`Close`,autoFocus:!0,disabled:b,children:(0,_.jsx)(l,{size:16})})]}),(0,_.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,_.jsx)(`div`,{className:`cal-modal-title`,children:e.skill}),(0,_.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,_.jsx)(m,{size:14}),(0,_.jsx)(`span`,{children:e.plugin})]}),u&&(0,_.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,_.jsx)(a,{size:14,className:`spin`}),(0,_.jsx)(`span`,{children:`Loading…`})]}),o&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,_.jsx)(`span`,{children:o.frontmatter.description||`No description.`})}),o.frontmatter.publicEmbed&&(0,_.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,_.jsx)(n,{size:14}),(0,_.jsx)(`span`,{children:`Public embed`})]}),(0,_.jsx)(`pre`,{className:`skill-body`,children:o.body.trim()||`No body content.`}),o.references.length>0&&(0,_.jsxs)(`div`,{className:`skill-refs`,children:[(0,_.jsx)(`span`,{className:`skill-refs-label`,children:`References`}),o.references.map(e=>(0,_.jsxs)(`span`,{className:`skill-ref`,children:[(0,_.jsx)(m,{size:13}),` `,e]},e))]})]})]}),p&&(0,_.jsx)(`div`,{className:`cal-modal-error`,children:p}),(0,_.jsxs)(`div`,{className:`cal-modal-actions`,children:[!v&&(0,_.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:()=>y(!0),disabled:b||u,children:[(0,_.jsx)(c,{size:14}),` Delete`]}),v&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Delete this skill?`}),(0,_.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:S,disabled:b,children:[b?(0,_.jsx)(a,{size:14,className:`spin`}):(0,_.jsx)(c,{size:14}),` Delete`]}),(0,_.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>y(!1),disabled:b,children:`Cancel`})]})]})]})})}var y=`maxy-admin-session-key`;function b(){let[e,t]=(0,g.useState)(null),[n,i]=(0,g.useState)(!1),[a,o]=(0,g.useState)(void 0),[s,c]=(0,g.useState)(null),[l,f]=(0,g.useState)(void 0),[m,h]=(0,g.useState)(null),[v,b]=(0,g.useState)(null);(0,g.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(y)}catch{}if(!n){i(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async r=>{if(!e){if(r.status===401){try{sessionStorage.removeItem(y)}catch{}window.location.href=`/`;return}if(r.ok)try{let e=await r.json();typeof e.businessName==`string`&&o(e.businessName),e.sessionId!==void 0&&c(e.sessionId??null),b(e.role??null),f(e.userName===void 0?null:e.userName),h(e.avatar??null)}catch{}t(n),i(!0)}}).catch(()=>{e||(t(n),i(!0))}),()=>{e=!0}},[]);let S=(0,g.useCallback)(()=>{try{sessionStorage.removeItem(y)}catch{}window.location.href=`/`},[]),[C,w]=(0,g.useState)(!1),T=(0,g.useCallback)(async()=>{w(!0);try{let e=await d();if(e){try{sessionStorage.removeItem(y)}catch{}window.location.href=`/`}return e}finally{w(!1)}},[]);return n?e?(0,_.jsx)(u,{cacheKey:e,surface:`skills`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=skills`);try{sessionStorage.removeItem(y)}catch{}window.location.href=`/`},children:(0,_.jsx)(p,{cacheKey:e,businessName:a,sessionId:s,onLogout:S,onDisconnect:T,disconnecting:C,userName:l,userAvatar:m,role:v,children:(0,_.jsx)(x,{cacheKey:e})})}):(0,_.jsx)(`div`,{className:`cal-page`,children:(0,_.jsxs)(`div`,{className:`cal-empty`,children:[(0,_.jsx)(`p`,{children:`You are not signed in.`}),(0,_.jsxs)(`p`,{children:[`Open the `,(0,_.jsx)(`a`,{href:`/`,className:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,_.jsx)(r,{surface:`gate`})}function x({cacheKey:e}){let{adminFetch:t,sessionRefetchNonce:n}=o({initialCacheKey:e,surface:`skills`}),[i,s]=(0,g.useState)([]),[c,l]=(0,g.useState)(!1),[u,d]=(0,g.useState)(!1),[p,h]=(0,g.useState)(null),[y,b]=(0,g.useState)(null),x=(0,g.useCallback)(()=>{let e=!1;return l(!0),h(null),t(`/api/admin/skills`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();s(Array.isArray(n.skills)?n.skills:[])}).catch(t=>{e||(h(t instanceof Error?t.message:`Failed to load`),s([]))}).finally(()=>{e||(l(!1),d(!0))}),()=>{e=!0}},[t]);(0,g.useEffect)(()=>x(),[x,n]);let S=(0,g.useCallback)(e=>{s(t=>t.filter(t=>!(t.plugin===e.plugin&&t.skill===e.skill))),b(null),x()},[x]);return u?(0,_.jsxs)(`div`,{className:`cal-page`,children:[(0,_.jsx)(`header`,{className:`cal-header`,children:(0,_.jsxs)(`div`,{className:`cal-nav`,children:[(0,_.jsxs)(`span`,{className:`cal-range-label`,children:[(0,_.jsx)(f,{size:16}),` Skills`]}),c&&(0,_.jsx)(a,{size:16,className:`spin`})]})}),(0,_.jsxs)(`div`,{className:`cal-body`,children:[p&&(0,_.jsxs)(`div`,{className:`cal-error`,children:[`Could not load skills: `,p]}),!p&&!c&&i.length===0&&(0,_.jsx)(`div`,{className:`cal-empty`,children:(0,_.jsx)(`p`,{children:`No skills yet. Ask in chat to create one.`})}),i.length>0&&(0,_.jsx)(`div`,{className:`routine-list`,children:i.map(e=>(0,_.jsxs)(`button`,{type:`button`,className:`routine-card`,onClick:()=>b(e),children:[(0,_.jsx)(`span`,{className:`routine-card-title`,children:e.skill}),(0,_.jsxs)(`span`,{className:`routine-card-sched`,children:[(0,_.jsx)(m,{size:13}),` `,e.plugin]}),(0,_.jsx)(`span`,{className:`skill-card-desc`,children:e.description||`No description.`}),(0,_.jsx)(`span`,{className:`routine-card-meta`,children:e.refCount===0?`No references`:`${e.refCount} reference${e.refCount===1?``:`s`}`})]},`${e.plugin}/${e.skill}`))})]}),y&&(0,_.jsx)(v,{summary:y,adminFetch:t,onClose:()=>b(null),onDeleted:S})]}):(0,_.jsx)(r,{surface:`gate`})}(0,h.createRoot)(document.getElementById(`root`)).render((0,_.jsx)(b,{}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{B as t,F as n,K as r,S as i,U as a,W as o,g as s,j as c,p as l,v as u}from"./useSubAccountSwitcher-DSW9vDi2.js";import{T as d,t as f}from"./AdminShell-C8wazpnz.js";import{n as p,t as m}from"./time-entry-format-CCO6N6XZ.js";import{t as h}from"./rotate-ccw-dTpO5dhL.js";var g=o(),_=e(r(),1);function v(e=3e4){let[t,n]=(0,_.useState)(()=>Date.now());return(0,_.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function y(e,t){let n=new Map,r=(e,t,r)=>{let i=n.get(e)??{openCount:0,totalSeconds:0};i.totalSeconds+=t,r&&(i.openCount+=1),n.set(e,i)};for(let t of e)t.clientName&&r(t.clientName,t.secondsLogged,!0);for(let e of t)e.clientName&&r(e.clientName,e.secondsLogged,!1);let i=[...n.entries()].map(([e,t])=>({name:e,openCount:t.openCount,totalSeconds:t.totalSeconds}));return i.sort((e,t)=>t.openCount-e.openCount||e.name.localeCompare(t.name)),b(e,i),i}function b(e,t){let n=t.reduce((e,t)=>e+t.openCount,0),r=e.filter(e=>!e.clientName).length,i=n+r===e.length;return i||console.warn(`[tasks-clients] reconcile-mismatch assigned=${n} unassigned=${r} openTotal=${e.length}`),i}var x=`__unassigned__`;function S(e,t){return e===`__unassigned__`?`Unassigned`:t||e.slice(0,8)}function C(e){return e===null||e===``?x:e}function w(e,t){let n=new Map,r=(e,t)=>{let r=C(e.assigneeUserId),i=n.get(r)??{name:null,openCount:0,totalCount:0};i.name===null&&e.assigneeName&&(i.name=e.assigneeName),i.totalCount+=1,t&&(i.openCount+=1),n.set(r,i)};for(let t of e)r(t,!0);for(let e of t)r(e,!1);let i=[...n.entries()].map(([e,t])=>({userId:e,label:S(e,t.name),openCount:t.openCount,totalCount:t.totalCount}));return i.sort((e,t)=>t.openCount-e.openCount||e.label.localeCompare(t.label)),i}function T(e,t){return t===null?!0:C(e.assigneeUserId)===t}var E=t();function D(e){let t=e.name??e.userId.slice(0,8);return e.kind===`owner`?`${t} (owner)`:t}var O=`maxy-admin-session-key`;function k(e){let t=[];return e.clientName&&t.push(e.clientName),e.propertyAddress&&t.push(e.propertyAddress),e.fee!=null&&t.push(`£${e.fee}`),t.join(` · `)}function A(e){if(!e)return``;let t=Date.parse(e);if(!Number.isFinite(t))return``;let n=new Date(t);return`${n.getUTCDate()} ${[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][n.getUTCMonth()]} ${n.getUTCFullYear()}`}function j(e){return e.assigneeName?e.assigneeName:e.assigneeUserId?e.assigneeUserId.slice(0,8):`Unassigned`}function M(e,t){return[t,A(e.createdAt),j(e)].filter(Boolean).join(` · `)}function N(e,t){if(e.running&&e.runningStartedAt){let n=Date.parse(e.runningStartedAt);if(Number.isFinite(n))return e.secondsLogged+Math.max(0,(t-n)/1e3)}return e.secondsLogged}function P({clients:e,onSelect:t}){return(0,E.jsxs)(`section`,{className:`admin-card tasks-card`,children:[(0,E.jsxs)(`div`,{className:`tasks-card-head`,children:[(0,E.jsx)(`span`,{className:`tasks-card-title`,children:`Clients`}),(0,E.jsxs)(`span`,{className:`tasks-card-count`,children:[e.length,` total`]})]}),e.length===0&&(0,E.jsx)(`div`,{className:`tasks-empty`,children:`No clients yet.`}),e.map(e=>(0,E.jsx)(`button`,{className:`tasks-row tasks-client-row`,onClick:()=>t(e.name),children:(0,E.jsxs)(`div`,{className:`tasks-row-main`,children:[(0,E.jsx)(`div`,{className:`tasks-row-name`,children:e.name}),(0,E.jsxs)(`div`,{className:`tasks-row-sub`,children:[e.openCount,` open · `,m(e.totalSeconds),` logged`]})]})},e.name))]})}function ee({task:e,roster:t,busy:n,onAssign:r,onClose:i}){return(0,_.useEffect)(()=>{let e=e=>{e.key===`Escape`&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]),(0,E.jsx)(`div`,{className:`tasks-detail-backdrop`,onClick:i,children:(0,E.jsxs)(`div`,{className:`tasks-detail`,role:`dialog`,"aria-modal":`true`,"aria-label":`Task detail`,onClick:e=>e.stopPropagation(),children:[(0,E.jsxs)(`div`,{className:`tasks-detail-head`,children:[(0,E.jsx)(`h2`,{className:`tasks-detail-title`,children:e?e.name:`Task no longer available`}),(0,E.jsx)(`button`,{className:`tasks-detail-close`,"aria-label":`Close`,onClick:i,children:(0,E.jsx)(s,{size:16})})]}),e===null?(0,E.jsx)(`p`,{className:`tasks-detail-gone`,children:`This task is no longer in the list. It may have been completed, cancelled or removed. Close this and reload to see the current list.`}):(0,E.jsxs)(`dl`,{className:`tasks-detail-fields`,children:[(0,E.jsx)(`dt`,{children:`Status`}),(0,E.jsx)(`dd`,{children:e.status}),(0,E.jsx)(`dt`,{children:`Logged`}),(0,E.jsx)(`dd`,{children:m(e.secondsLogged)}),(0,E.jsx)(`dt`,{children:`Created`}),(0,E.jsx)(`dd`,{children:A(e.createdAt)||`Not recorded`}),(0,E.jsx)(`dt`,{children:`Assignee`}),(0,E.jsx)(`dd`,{children:e.taskId===null?j(e):(0,E.jsxs)(`select`,{className:`tasks-assign-select`,"aria-label":`Assignee`,disabled:n,value:e.assigneeUserId??``,onChange:t=>r(e.taskId,t.target.value===``?null:t.target.value),children:[(0,E.jsx)(`option`,{value:``,children:`Unassigned`}),e.assigneeUserId&&!t.some(t=>t.userId===e.assigneeUserId)&&(0,E.jsxs)(`option`,{value:e.assigneeUserId,children:[j(e),` (not in roster)`]}),t.map(e=>(0,E.jsx)(`option`,{value:e.userId,children:D(e)},e.userId))]})}),e.clientName&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`dt`,{children:`Client`}),(0,E.jsx)(`dd`,{children:e.clientName})]}),e.propertyAddress&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`dt`,{children:`Property`}),(0,E.jsx)(`dd`,{children:e.propertyAddress})]}),e.fee!=null&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`dt`,{children:`Fee`}),(0,E.jsxs)(`dd`,{children:[`£`,e.fee]})]})]})]})})}function F({adminFetch:e}){let[t,r]=(0,_.useState)({open:[],completed:[]}),[a,o]=(0,_.useState)(!1),[l,d]=(0,_.useState)(!1),f=(0,_.useRef)(!1),g=(0,_.useRef)(``),b=v(1e3),[x,S]=(0,_.useState)(`open`),[C,D]=(0,_.useState)(null),[O,A]=(0,_.useState)(null),[j,F]=(0,_.useState)(null),[I,L]=(0,_.useState)(``),[R,z]=(0,_.useState)(null),[B,V]=(0,_.useState)(null),H=(0,_.useMemo)(()=>{if(R!==null)return[...t.open,...t.completed].find(e=>e.rowKey===R)??null},[t,R]);(0,_.useEffect)(()=>{R!==null&&H===null&&console.error(`[tasks-ui] op=detail-failed rowKey=${R} reason=not-in-list`)},[R,H]);let U=(0,_.useMemo)(()=>y(t.open,t.completed),[t]),W=(0,_.useMemo)(()=>C===null?{open:t.open,completed:t.completed}:{open:t.open.filter(e=>e.clientName===C),completed:t.completed.filter(e=>e.clientName===C)},[t,C]),G=(0,_.useMemo)(()=>w(W.open,W.completed),[W]),K=(0,_.useCallback)(e=>{D(e),S(`open`)},[]);(0,_.useEffect)(()=>{C&&!U.some(e=>e.name===C)&&D(null)},[U,C]),(0,_.useEffect)(()=>{O&&!G.some(e=>e.userId===O)&&A(null)},[G,O]),(0,_.useEffect)(()=>{V(null)},[x,C,O]);let q=t.open.filter(e=>e.running||(C===null||e.clientName===C)&&T(e,O)),J=(C?t.completed.filter(e=>e.clientName===C):t.completed).filter(e=>T(e,O)),[te,ne]=(0,_.useState)([]),Y=(0,_.useCallback)(async()=>{let t=await e(`/api/admin/tasks-list`);t.ok&&r(await t.json()),o(!0)},[e]);(0,_.useEffect)(()=>{Y()},[Y]),(0,_.useEffect)(()=>{(async()=>{let t=await e(`/api/admin/admin-users-list`);if(t.ok){let e=await t.json();e.ok&&Array.isArray(e.users)&&ne(e.users)}})()},[e]);let X=(0,_.useCallback)(async(t,n,r)=>{if(f.current)return!1;f.current=!0,d(!0);try{return await e(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({taskId:n,...r})}),await Y(),!0}finally{f.current=!1,d(!1)}},[e,Y]),re=(0,_.useCallback)(async e=>{await X(`/api/admin/task-complete`,e)&&console.log(`[tasks-ui] op=complete taskId=${e.slice(0,8)} confirmed=true`)},[X]),ie=(0,_.useCallback)((e,t)=>{let n=String(Math.round(e.secondsLogged/60));g.current=n,F(t),L(n)},[]),Z=(0,_.useCallback)(()=>{F(null),L(``)},[]),ae=(0,_.useCallback)(async e=>{let t=I.trim(),n=Number(t);if(!(t===``||!Number.isInteger(n)||n<0)){if(t===g.current){Z();return}F(null),L(``),await X(`/api/admin/task-time-adjust`,e,{newSeconds:n*60})}},[I,X,Z]),oe=(0,_.useCallback)(e=>{X(`/api/admin/task-time-adjust`,e,{newSeconds:0})},[X]),se=(0,_.useCallback)((e,t)=>{X(`/api/admin/task-assign`,e,{assigneeUserId:t})},[X]);if(!a)return(0,E.jsx)(n,{surface:`gate`});let Q=e=>e.taskId!==null&&j===e.taskId,$=(e,t)=>Q(e)?(0,E.jsxs)(`div`,{className:`tasks-edit`,children:[(0,E.jsx)(`input`,{className:`tasks-edit-input`,type:`number`,min:0,step:1,"aria-label":`Logged minutes`,value:I,onChange:e=>L(e.target.value)}),(0,E.jsx)(`span`,{className:`tasks-edit-unit`,children:`min`}),(0,E.jsxs)(`button`,{className:`admin-btn-cta tasks-btn-action`,disabled:l,onClick:()=>void ae(t),children:[(0,E.jsx)(c,{size:14}),` Save`]}),(0,E.jsxs)(`button`,{className:`tasks-btn-secondary tasks-btn-action`,onClick:Z,children:[(0,E.jsx)(s,{size:14}),` Cancel`]})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`button`,{className:`tasks-time-btn`,"aria-label":`Edit time`,disabled:l||e.running,title:e.running?`Stop the timer before editing time`:void 0,onClick:()=>ie(e,t),children:(0,E.jsx)(i,{size:14})}),(0,E.jsx)(`button`,{className:`tasks-time-btn`,"aria-label":`Reset time`,disabled:l||e.running,title:e.running?`Stop the timer before resetting time`:void 0,onClick:()=>oe(t),children:(0,E.jsx)(h,{size:14})})]});return(0,E.jsxs)(`div`,{className:`tasks-body`,children:[R!==null&&(0,E.jsx)(ee,{task:H??null,roster:te,busy:l,onAssign:se,onClose:()=>z(null)}),(0,E.jsxs)(`div`,{className:`tasks-tabs`,children:[(0,E.jsxs)(`button`,{className:`admin-chip ${x===`open`?`is-active`:``}`,onClick:()=>S(`open`),children:[`Open `,(0,E.jsx)(`span`,{className:`tasks-tab-badge`,children:t.open.length})]}),(0,E.jsxs)(`button`,{className:`admin-chip ${x===`completed`?`is-active`:``}`,onClick:()=>S(`completed`),children:[`Completed `,(0,E.jsx)(`span`,{className:`tasks-tab-badge`,children:t.completed.length})]}),(0,E.jsxs)(`button`,{className:`admin-chip ${x===`clients`?`is-active`:``}`,onClick:()=>S(`clients`),children:[`Clients `,(0,E.jsx)(`span`,{className:`tasks-tab-badge`,children:U.length})]})]}),x===`clients`?(0,E.jsx)(P,{clients:U,onSelect:K}):(0,E.jsxs)(E.Fragment,{children:[C&&(0,E.jsxs)(`div`,{className:`tasks-filter-banner`,children:[(0,E.jsxs)(`span`,{children:[`Showing `,C]}),(0,E.jsx)(`button`,{className:`tasks-filter-clear`,onClick:()=>D(null),children:`Clear`})]}),G.length>0&&(0,E.jsxs)(`div`,{className:`tasks-assignee-bar`,children:[(0,E.jsxs)(`button`,{className:`admin-chip ${O===null?`is-active`:``}`,"aria-pressed":O===null,onClick:()=>A(null),children:[`All `,(0,E.jsx)(`span`,{className:`tasks-assignee-count`,children:W.open.length})]}),G.map(e=>(0,E.jsxs)(`button`,{className:`admin-chip ${O===e.userId?`is-active`:``}`,"aria-pressed":O===e.userId,"aria-label":`Assignee ${e.label}`,title:e.userId===`__unassigned__`?`Tasks with no assigned admin`:`AdminUser ${e.userId}`,onClick:()=>A(O===e.userId?null:e.userId),children:[e.label,` `,(0,E.jsx)(`span`,{className:`tasks-assignee-count`,children:e.openCount})]},e.userId))]}),x===`open`?(0,E.jsxs)(`section`,{className:`admin-card tasks-card`,children:[(0,E.jsxs)(`div`,{className:`tasks-card-head`,children:[(0,E.jsx)(`span`,{className:`tasks-card-title`,children:`Open tasks`}),(0,E.jsxs)(`span`,{className:`tasks-card-count`,children:[q.length,` to do`]})]}),q.length===0&&(0,E.jsx)(`div`,{className:`tasks-empty`,children:`No open tasks.`}),q.map(e=>(0,E.jsxs)(`div`,{className:`tasks-row`,children:[(0,E.jsx)(`button`,{className:`tasks-row-open`,"aria-label":`Open task detail: ${e.name}`,onClick:()=>z(e.rowKey),children:(0,E.jsxs)(`div`,{className:`tasks-row-main`,children:[(0,E.jsx)(`div`,{className:`tasks-row-name`,children:e.name}),(0,E.jsx)(`div`,{className:`tasks-row-sub`,children:M(e,k(e))})]})}),(0,E.jsx)(`div`,{className:`tasks-row-elapsed ${e.running?`tasks-row-elapsed-running`:``}`,children:m(N(e,b))}),(0,E.jsx)(`div`,{className:`tasks-row-controls ${e.taskId!==null&&B===e.taskId?`is-confirming`:``}`,children:e.taskId!==null&&B===e.taskId?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`span`,{className:`tasks-confirm-label`,children:`Complete?`}),(0,E.jsxs)(`button`,{className:`admin-btn-cta tasks-btn-action`,disabled:l,onClick:()=>{V(null),re(e.taskId)},children:[(0,E.jsx)(c,{size:14}),` Confirm complete`]}),(0,E.jsxs)(`button`,{className:`tasks-btn-secondary tasks-btn-action`,onClick:()=>V(null),children:[(0,E.jsx)(s,{size:14}),` Keep open`]})]}):e.taskId===null?(0,E.jsx)(`span`,{className:`tasks-row-broken`,title:`This task has no id, so it cannot be started, edited or completed. Repair it by running platform/scripts/backfill-task-ids.sh on this install.`,children:`Needs repair`}):(0,E.jsxs)(E.Fragment,{children:[$(e,e.taskId),Q(e)?null:(0,E.jsxs)(`button`,{className:`tasks-btn-secondary tasks-btn-action`,"aria-label":`Complete task: ${e.name}`,disabled:l||e.running,title:e.running?`Stop the timer before completing`:void 0,onClick:()=>V(e.taskId),children:[(0,E.jsx)(c,{size:14}),` Complete`]}),Q(e)?null:e.running?(0,E.jsxs)(`button`,{className:`admin-btn-danger tasks-btn-action`,disabled:l,onClick:()=>void X(`/api/admin/task-timer-stop`,e.taskId),children:[(0,E.jsx)(u,{size:14}),` Stop`]}):(0,E.jsxs)(`button`,{className:`admin-btn-cta tasks-btn-action`,disabled:l,onClick:()=>void X(`/api/admin/task-timer-start`,e.taskId),children:[(0,E.jsx)(p,{size:14}),` Start`]})]})})]},e.rowKey))]}):(0,E.jsxs)(`section`,{className:`admin-card tasks-card`,children:[(0,E.jsxs)(`div`,{className:`tasks-card-head`,children:[(0,E.jsx)(`span`,{className:`tasks-card-title`,children:`Completed`}),(0,E.jsxs)(`span`,{className:`tasks-card-count`,children:[J.length,` done`]})]}),J.length===0&&(0,E.jsx)(`div`,{className:`tasks-empty`,children:`Nothing completed yet.`}),J.map(e=>(0,E.jsxs)(`div`,{className:`tasks-row tasks-row-done`,children:[(0,E.jsx)(`button`,{className:`tasks-row-open`,"aria-label":`Open task detail: ${e.name}`,onClick:()=>z(e.rowKey),children:(0,E.jsxs)(`div`,{className:`tasks-row-main`,children:[(0,E.jsx)(`div`,{className:`tasks-row-name`,children:e.name}),(0,E.jsx)(`div`,{className:`tasks-row-sub`,children:M(e,k(e))})]})}),(0,E.jsx)(`div`,{className:`tasks-row-elapsed`,children:m(e.secondsLogged)}),(0,E.jsx)(`div`,{className:`tasks-row-controls`,children:e.taskId===null?(0,E.jsx)(`span`,{className:`tasks-row-broken`,title:`This task has no id, so its logged time cannot be edited. Repair it by running platform/scripts/backfill-task-ids.sh on this install.`,children:`Needs repair`}):$(e,e.taskId)})]},e.rowKey))]})]})]})}function I({cacheKey:e}){let{adminFetch:t}=a({initialCacheKey:e,surface:`tasks`});return(0,E.jsx)(F,{adminFetch:t})}function L(){let[e,t]=(0,_.useState)(null),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(void 0),[s,c]=(0,_.useState)(null),[u,p]=(0,_.useState)(null),[m,h]=(0,_.useState)(null),[g,v]=(0,_.useState)(null);(0,_.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(O)}catch{}if(!n){t(null),i(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async r=>{if(!e){if(r.status===401){try{sessionStorage.removeItem(O)}catch{}window.location.href=`/`;return}if(r.ok)try{let e=await r.json();typeof e.businessName==`string`&&o(e.businessName),e.sessionId!==void 0&&c(e.sessionId??null),p(e.role??null),h(e.userName===void 0?null:e.userName),v(e.avatar??null)}catch{}t(n),i(!0)}}).catch(()=>{e||(t(n),i(!0))}),()=>{e=!0}},[]);let y=(0,_.useCallback)(()=>{try{sessionStorage.removeItem(O)}catch{}window.location.href=`/`},[]),[b,x]=(0,_.useState)(!1),S=(0,_.useCallback)(async()=>{x(!0);try{let e=await d();if(e){try{sessionStorage.removeItem(O)}catch{}window.location.href=`/`}return e}finally{x(!1)}},[]);return r?e?(0,E.jsx)(l,{cacheKey:e,surface:`tasks`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=tasks`);try{sessionStorage.removeItem(O)}catch{}window.location.href=`/`},children:(0,E.jsx)(f,{cacheKey:e,businessName:a,sessionId:s,onLogout:y,onDisconnect:S,disconnecting:b,userName:m,userAvatar:g,role:u,children:(0,E.jsx)(I,{cacheKey:e})})}):(0,E.jsx)(`div`,{className:`tasks-page`,children:(0,E.jsxs)(`div`,{className:`tasks-empty`,children:[(0,E.jsx)(`p`,{children:`You are not signed in.`}),(0,E.jsxs)(`p`,{children:[`Open the `,(0,E.jsx)(`a`,{href:`/`,className:`tasks-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,E.jsx)(n,{surface:`gate`})}(0,g.createRoot)(document.getElementById(`root`)).render((0,E.jsx)(L,{}));
|
package/payload/server/public/assets/{time-entry-format-BhlltPP8.js → time-entry-format-CCO6N6XZ.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{P as e}from"./useSubAccountSwitcher-
|
|
1
|
+
import{P as e}from"./useSubAccountSwitcher-DSW9vDi2.js";var t=e(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]);function n(e){let t=Math.max(0,Math.floor(e)),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n>0?`${n}:${String(r).padStart(2,`0`)}`:`${r}:${String(i).padStart(2,`0`)}`}export{t as n,n as t};
|
package/payload/server/public/assets/{triangle-alert-rEVGyIhi.js → triangle-alert-CHjdKpag.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{P as e}from"./useSubAccountSwitcher-
|
|
1
|
+
import{P as e}from"./useSubAccountSwitcher-DSW9vDi2.js";var t=e(`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`}]]);export{t};
|
package/payload/server/public/assets/{useCopyFeedback-DzpXjm9d.js → useCopyFeedback-BTUu3-l8.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{K as t,r as n}from"./useSubAccountSwitcher-DSW9vDi2.js";var r=e(t(),1);function i(e){let[t,i]=(0,r.useState)(`idle`),a=(0,r.useRef)(null),o=(0,r.useRef)(e?.onResult);return o.current=e?.onResult,(0,r.useEffect)(()=>()=>{a.current&&clearTimeout(a.current)},[]),{status:t,copy:(0,r.useCallback)(async e=>{let t=await n(e);i(t?`ok`:`fail`),o.current?.(t),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(`idle`),1500)},[])}}export{i as t};
|