@rubytech/create-maxy-code 0.1.429 → 0.1.431

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/package.json +1 -1
  2. package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +69 -3
  3. package/payload/platform/plugins/docs/PLUGIN.md +1 -0
  4. package/payload/platform/plugins/docs/references/internals.md +2 -2
  5. package/payload/platform/plugins/docs/references/workflows.md +61 -0
  6. package/payload/platform/plugins/whatsapp/mcp/dist/resolve-read-account.d.ts +8 -1
  7. package/payload/platform/plugins/whatsapp/mcp/dist/resolve-read-account.d.ts.map +1 -1
  8. package/payload/platform/plugins/whatsapp/mcp/dist/resolve-read-account.js +8 -1
  9. package/payload/platform/plugins/whatsapp/mcp/dist/resolve-read-account.js.map +1 -1
  10. package/payload/platform/plugins/workflows/PLUGIN.md +29 -9
  11. package/payload/platform/plugins/workflows/mcp/dist/index.js +34 -0
  12. package/payload/platform/plugins/workflows/mcp/dist/index.js.map +1 -1
  13. package/payload/platform/plugins/workflows/mcp/dist/lib/step-resolver.d.ts +2 -2
  14. package/payload/platform/plugins/workflows/mcp/dist/lib/step-resolver.d.ts.map +1 -1
  15. package/payload/platform/plugins/workflows/mcp/dist/lib/step-resolver.js.map +1 -1
  16. package/payload/platform/plugins/workflows/mcp/dist/tools/workflow-create.d.ts +25 -0
  17. package/payload/platform/plugins/workflows/mcp/dist/tools/workflow-create.d.ts.map +1 -1
  18. package/payload/platform/plugins/workflows/mcp/dist/tools/workflow-create.js +14 -1
  19. package/payload/platform/plugins/workflows/mcp/dist/tools/workflow-create.js.map +1 -1
  20. package/payload/platform/plugins/workflows/mcp/dist/tools/workflow-execute.d.ts +25 -1
  21. package/payload/platform/plugins/workflows/mcp/dist/tools/workflow-execute.d.ts.map +1 -1
  22. package/payload/platform/plugins/workflows/mcp/dist/tools/workflow-execute.js +79 -15
  23. package/payload/platform/plugins/workflows/mcp/dist/tools/workflow-execute.js.map +1 -1
  24. package/payload/platform/plugins/workflows/mcp/dist/tools/workflow-get.d.ts +2 -0
  25. package/payload/platform/plugins/workflows/mcp/dist/tools/workflow-get.d.ts.map +1 -1
  26. package/payload/platform/plugins/workflows/mcp/dist/tools/workflow-get.js +4 -0
  27. package/payload/platform/plugins/workflows/mcp/dist/tools/workflow-get.js.map +1 -1
  28. package/payload/platform/plugins/workflows/mcp/dist/tools/workflow-update.d.ts +3 -1
  29. package/payload/platform/plugins/workflows/mcp/dist/tools/workflow-update.d.ts.map +1 -1
  30. package/payload/platform/plugins/workflows/mcp/dist/tools/workflow-update.js +8 -1
  31. package/payload/platform/plugins/workflows/mcp/dist/tools/workflow-update.js.map +1 -1
  32. package/payload/platform/plugins/workflows/skills/workflow-manager/SKILL.md +24 -3
  33. package/payload/platform/services/telegram-channel/dist/instructions.js +1 -1
  34. package/payload/platform/services/telegram-channel/dist/instructions.js.map +1 -1
  35. package/payload/platform/services/telegram-channel/dist/notification.d.ts +10 -5
  36. package/payload/platform/services/telegram-channel/dist/notification.d.ts.map +1 -1
  37. package/payload/platform/services/telegram-channel/dist/notification.js +9 -6
  38. package/payload/platform/services/telegram-channel/dist/notification.js.map +1 -1
  39. package/payload/platform/services/telegram-channel/dist/server.d.ts.map +1 -1
  40. package/payload/platform/services/telegram-channel/dist/server.js +15 -5
  41. package/payload/platform/services/telegram-channel/dist/server.js.map +1 -1
  42. package/payload/platform/services/webchat-channel/dist/instructions.js +1 -1
  43. package/payload/platform/services/webchat-channel/dist/instructions.js.map +1 -1
  44. package/payload/platform/services/webchat-channel/dist/notification.d.ts +12 -10
  45. package/payload/platform/services/webchat-channel/dist/notification.d.ts.map +1 -1
  46. package/payload/platform/services/webchat-channel/dist/notification.js +12 -11
  47. package/payload/platform/services/webchat-channel/dist/notification.js.map +1 -1
  48. package/payload/platform/services/webchat-channel/dist/server.d.ts.map +1 -1
  49. package/payload/platform/services/webchat-channel/dist/server.js +12 -1
  50. package/payload/platform/services/webchat-channel/dist/server.js.map +1 -1
  51. package/payload/platform/services/whatsapp-channel/dist/notification.d.ts +11 -6
  52. package/payload/platform/services/whatsapp-channel/dist/notification.d.ts.map +1 -1
  53. package/payload/platform/services/whatsapp-channel/dist/notification.js +11 -8
  54. package/payload/platform/services/whatsapp-channel/dist/notification.js.map +1 -1
  55. package/payload/platform/services/whatsapp-channel/dist/server.d.ts.map +1 -1
  56. package/payload/platform/services/whatsapp-channel/dist/server.js +39 -14
  57. package/payload/platform/services/whatsapp-channel/dist/server.js.map +1 -1
  58. package/payload/platform/services/whatsapp-channel/dist/targets.d.ts +17 -2
  59. package/payload/platform/services/whatsapp-channel/dist/targets.d.ts.map +1 -1
  60. package/payload/platform/services/whatsapp-channel/dist/targets.js +37 -2
  61. package/payload/platform/services/whatsapp-channel/dist/targets.js.map +1 -1
  62. package/payload/server/public/assets/{AdminLoginScreens-C4AZT7cQ.js → AdminLoginScreens-CcW3pAAZ.js} +1 -1
  63. package/payload/server/public/assets/{admin-SaF1F4e-.js → admin-Co3hOTNp.js} +1 -1
  64. package/payload/server/public/assets/{audio-attachment-mime-BBW07eyG.js → audio-attachment-mime-CwYrV1pg.js} +1 -1
  65. package/payload/server/public/assets/{chat-B9Qjt7C9.js → chat-rxbGimwf.js} +1 -1
  66. package/payload/server/public/assets/data-D0YFYP1i.js +1 -0
  67. package/payload/server/public/assets/{operator-CTJjI8te.js → operator-Djv3MdcL.js} +1 -1
  68. package/payload/server/public/assets/{page-JzxyFGle.js → page-Ci27UrJz.js} +5 -5
  69. package/payload/server/public/assets/{page-CbI1wtef.js → page-D1EAVC_9.js} +1 -1
  70. package/payload/server/public/assets/{public-DzeW3_eM.js → public-C6k-fPfx.js} +1 -1
  71. package/payload/server/public/chat.html +3 -3
  72. package/payload/server/public/data.html +3 -3
  73. package/payload/server/public/index.html +4 -4
  74. package/payload/server/public/operator.html +4 -4
  75. package/payload/server/public/public.html +3 -3
  76. package/payload/server/server.js +95 -25
  77. package/payload/server/public/assets/data-BKE6Sa-g.js +0 -1
@@ -1 +1 @@
1
- import{o as e}from"./chunk-Ck5AOu5v.js";import{a as t,l as n,m as r,n as i,o as a,r as o,s,t as c,w as l,x as u,y as d}from"./useSubAccountSwitcher-DyjTbzQR.js";import{S as f,a as p,b as m,t as h,v as g,x as _,y as v}from"./audio-attachment-mime-BBW07eyG.js";import{t as y}from"./chevron-left-CLPxfjDV.js";import{a as b,c as x,d as ee,f as te,h as ne,i as re,m as ie,n as ae,p as oe,r as se,s as S,t as ce,u as le}from"./file-download-B2B2DTar.js";import{i as ue,t as C}from"./graph-labels-DxqDdO7G.js";var de=r(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),fe=r(`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`}]]),pe=r(`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`}]]),me=r(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),he=r(`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`}]]),ge=r(`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`}]]),_e=r(`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`}]]),ve=r(`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`}]]),w=r(`phone`,[[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]),ye=r(`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`}]]),T=r(`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`}]]),be=r(`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`}]]),xe=r(`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`}]]),E=r(`video`,[[`path`,{d:`m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5`,key:`ftymec`}],[`rect`,{x:`2`,y:`6`,width:`14`,height:`12`,rx:`2`,key:`158x01`}]]),D=e(l(),1);function Se(){let[e,t]=(0,D.useState)([]),[n,r]=(0,D.useState)(!1),[i,a]=(0,D.useState)(null),o=(0,D.useRef)(null),s=(0,D.useCallback)(e=>{a(null);let n=e.find(e=>!h(e.type,f));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>_);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,D.useCallback)(()=>{t([]),a(null)},[]),removeFile:(0,D.useCallback)(e=>{t(t=>t.filter((t,n)=>n!==e))},[]),onDragOver:(0,D.useCallback)(e=>{e.preventDefault(),r(!0)},[]),onDragLeave:(0,D.useCallback)(()=>{r(!1)},[]),onDrop:(0,D.useCallback)(e=>{e.preventDefault(),r(!1),s([...e.dataTransfer.files])},[s])}}var O=d();function k({accountId:e,remoteJid:n,sessionKey:r}){let[i,a]=(0,D.useState)(``),[o,s]=(0,D.useState)(!1),[c,l]=(0,D.useState)(null),{pendingFiles:u,attachError:d,fileInputRef:f,addFiles:p,removeFile:h,clearFiles:_}=Se(),v=(0,D.useRef)(!1),y=(i.trim().length>0||u.length>0)&&!o,b=(0,D.useCallback)(async()=>{if(!v.current&&!(i.trim().length===0&&u.length===0)){v.current=!0,s(!0),l(null);try{let t=`/api/whatsapp-reader/reply?session_key=${encodeURIComponent(r)}`,o;if(u.length>0){let r=new FormData;r.append(`accountId`,e),r.append(`remoteJid`,n),i.trim()&&r.append(`text`,i);for(let e of u)r.append(`files`,e);o=await fetch(t,{method:`POST`,body:r})}else o=await fetch(t,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({accountId:e,remoteJid:n,text:i})});let s=await o.json().catch(()=>({}));if(!o.ok){l(s.error??`Send failed.`),console.info(`[operator-ui] op=reply-fail remoteJid=${n} error=${s.error??`unknown`}`);return}a(``),_(),console.info(`[operator-ui] op=reply-sent remoteJid=${n} sent=${s.sent??0}`)}catch(e){l(`Could not reach the server. Try again.`),console.info(`[operator-ui] op=reply-fail remoteJid=${n} error=${String(e)}`)}finally{v.current=!1,s(!1)}}},[i,u,e,n,r,_]),x=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),y&&b())},ee=e=>e.startsWith(`image/`)?(0,O.jsx)(he,{size:14}):e===`application/pdf`?(0,O.jsx)(ie,{size:14}):(0,O.jsx)(g,{size:14});return(0,O.jsxs)(`div`,{className:`wa-reply`,children:[c&&(0,O.jsx)(`p`,{className:`wa-reply-error`,role:`alert`,children:c}),d&&(0,O.jsx)(`p`,{className:`wa-reply-error`,role:`alert`,children:d}),u.length>0&&(0,O.jsx)(`div`,{className:`wa-reply-attachments`,children:u.map((e,n)=>(0,O.jsxs)(`div`,{className:`wa-reply-chip`,children:[ee(e.type),(0,O.jsx)(`span`,{className:`wa-reply-chip-name`,children:e.name}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>h(n),"aria-label":`Remove ${e.name}`,children:(0,O.jsx)(t,{size:12})})]},n))}),(0,O.jsxs)(`div`,{className:`wa-reply-row`,children:[(0,O.jsx)(`input`,{ref:f,type:`file`,multiple:!0,accept:m,style:{display:`none`},onChange:e=>{e.target.files&&p([...e.target.files]),e.target.value=``}}),(0,O.jsx)(`button`,{type:`button`,className:`wa-reply-attach`,onClick:()=>f.current?.click(),disabled:o,"aria-label":`Attach files`,children:(0,O.jsx)(te,{size:22})}),(0,O.jsx)(`textarea`,{className:`wa-reply-input`,value:i,rows:1,placeholder:`Type a message`,disabled:o,onChange:e=>a(e.target.value),onKeyDown:x}),(0,O.jsx)(`button`,{type:`button`,className:`wa-reply-send`,onClick:()=>void b(),disabled:!y,"aria-label":`Send`,children:(0,O.jsx)(ye,{size:20})})]})]})}function A({accountId:e,remoteJid:t,contactName:n,sessionKey:r,onBack:i}){let a=x(t),o=t.split(`@`)[0],s=a?`Group`:n===`+${o}`?void 0:`+${o}`;return(0,O.jsxs)(`div`,{className:`wa-web`,children:[(0,O.jsxs)(`header`,{className:`wa-web-header`,children:[i&&(0,O.jsx)(`button`,{type:`button`,className:`wa-web-back`,onClick:i,"aria-label":`Back`,children:(0,O.jsx)(y,{size:20})}),(0,O.jsx)(`span`,{className:`wa-web-avatar`,"aria-hidden":!0,children:(0,O.jsx)(xe,{size:20})}),(0,O.jsxs)(`div`,{className:`wa-web-titles`,children:[(0,O.jsx)(`span`,{className:`wa-web-name`,children:n}),s&&(0,O.jsx)(`span`,{className:`wa-web-subtitle`,children:s})]}),(0,O.jsxs)(`div`,{className:`wa-web-actions`,"aria-hidden":!0,children:[(0,O.jsx)(E,{size:20}),(0,O.jsx)(w,{size:20}),(0,O.jsx)(ue,{size:20}),(0,O.jsx)(v,{size:20})]})]}),(0,O.jsx)(`div`,{className:`wa-web-body`,children:(0,O.jsx)(p,{sessionId:``,projectDir:``,sessionKey:r,forceDeliveredOnly:!0,suppressDirectives:!0,store:{accountId:e,remoteJid:t}})}),a?(0,O.jsx)(`p`,{className:`wa-reply wa-reply-readonly`,children:`Group messages are read-only.`}):(0,O.jsx)(k,{accountId:e,remoteJid:t,sessionKey:r})]})}function Ce(e){let t=new Set,n=[];for(let r of e)for(let e of r.labels)e&&(t.has(e)||C.has(e)&&(t.add(e),n.push(e)));return n}function j(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 we({conversations:e,sessionKey:t,onBack:n}){let[r,i]=(0,D.useState)(null),a=re(e);return r?r.source===`store`&&r.accountId&&r.remoteJid?(0,O.jsx)(A,{accountId:r.accountId,remoteJid:r.remoteJid,contactName:b(r),sessionKey:t,onBack:()=>i(null)},S(r)):(0,O.jsxs)(`div`,{className:`op-conv op-conv-reader`,children:[(0,O.jsxs)(`div`,{className:`op-conv-bar`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`op-conv-back`,onClick:()=>i(null),"aria-label":`Back to conversations`,children:[(0,O.jsx)(y,{size:16}),` Back`]}),(0,O.jsx)(`span`,{className:`op-conv-title`,children:b(r)})]}),(0,O.jsx)(p,{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},S(r))]}):(0,O.jsxs)(`div`,{className:`op-conv op-conv-list`,children:[(0,O.jsxs)(`div`,{className:`op-conv-bar`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`op-conv-back`,onClick:n,"aria-label":`Back to chat`,children:[(0,O.jsx)(y,{size:16}),` Chat`]}),(0,O.jsx)(`span`,{className:`op-conv-title`,children:`Conversations`})]}),a.map(e=>(0,O.jsxs)(`div`,{className:`op-conv-group`,children:[(0,O.jsxs)(`div`,{className:`op-conv-group-head`,children:[(0,O.jsx)(le,{channel:e.channel,size:14}),e.label]}),e.rows.map(e=>(0,O.jsxs)(`button`,{type:`button`,className:`op-conv-row`,onClick:()=>{console.info(`[operator-ui] op=reader-open channel=${e.channel} key=${S(e)} readonly=true source=${e.source}`),i(e)},children:[(0,O.jsx)(`span`,{className:`op-conv-name`,children:b(e)}),e.modelGated&&(0,O.jsx)(`span`,{className:`op-conv-gated`,role:`img`,"aria-label":`Model unavailable`,children:(0,O.jsx)(T,{size:13})}),(0,O.jsx)(`span`,{className:`op-conv-when`,children:j(e.lastMessageAt)})]},S(e)))]},e.channel))]})}var Te=/\.(png|jpe?g|gif|webp|svg)$/i;function Ee(e){return Te.test(e)}var De=`maxy-data-view`,Oe=95*1024*1024,ke=48*1024*1024;function Ae(){return typeof window>`u`?`list`:window.localStorage.getItem(De)===`grid`?`grid`:`list`}function je(){let[e,t]=(0,D.useState)(null),[r,i]=(0,D.useState)(!1);return(0,D.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,O.jsx)(o,{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,O.jsx)(`div`,{className:`data-page data-page-full`,children:(0,O.jsx)(Me,{cacheKey:e})})}):(0,O.jsx)(`div`,{className:`data-page`,children:(0,O.jsxs)(`div`,{className:`data-empty`,children:[(0,O.jsx)(`p`,{children:`You are not signed in.`}),(0,O.jsxs)(`p`,{children:[`Open the `,(0,O.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,O.jsx)(`div`,{className:`data-page`,children:(0,O.jsxs)(`div`,{className:`data-loading`,children:[(0,O.jsx)(n,{size:18,className:`spin`}),` Loading…`]})})}function Me({cacheKey:e}){let{adminFetch:t,cacheKey:n,sessionRefetchNonce:r}=u({initialCacheKey:e,surface:`data`});return(0,O.jsx)(Le,{adminFetch:t,cacheKey:n,sessionRefetchNonce:r})}function Ne(){if(typeof window>`u`)return`.`;let e=new URLSearchParams(window.location.hash.replace(/^#/,``)).get(`path`);return e&&e.length>0?e:`.`}function Pe(e){if(typeof window>`u`)return;let t=new URL(window.location.href);t.hash=e===`.`?``:`path=${encodeURIComponent(e)}`,window.history.replaceState(window.history.state,``,t.toString())}function M(e){return new Promise((t,n)=>{let r=[],i=()=>e.readEntries(e=>{e.length===0?t(r):(r.push(...e),i())},n);i()})}function N(e){return new Promise((t,n)=>e.file(t,n))}async function Fe(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 N(r),relpath:e});else if(r.isDirectory){let t=await M(r.createReader());n.push(...await Fe(t,e))}}return n}function Ie(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 P({adminFetch:e,cacheKey:r,sessionRefetchNonce:i}){let[o,c]=(0,D.useState)(``),l=(0,D.useRef)(null),[u,d]=(0,D.useState)(``),[f,p]=(0,D.useState)(null),[m,h]=(0,D.useState)(`hybrid`),[g,_]=(0,D.useState)(!1),[v,y]=(0,D.useState)(null),[b,x]=(0,D.useState)(null),[te,re]=(0,D.useState)(0),[S,le]=(0,D.useState)(!1),[C,he]=(0,D.useState)(()=>Ne()),[w,ye]=(0,D.useState)(null),[T,xe]=(0,D.useState)(()=>Ae()),[E,Se]=(0,D.useState)(null),[k,A]=(0,D.useState)([]),[j,we]=(0,D.useState)(!1),[Te,je]=(0,D.useState)(null),[Me,M]=(0,D.useState)(!1),[N,P]=(0,D.useState)(null),[Le,F]=(0,D.useState)(null),[Be,Ve]=(0,D.useState)(null),[He,Ge]=(0,D.useState)(!1),[Ke,qe]=(0,D.useState)(null),I=(0,D.useRef)(null),[Je,L]=(0,D.useState)(0),[Ye,R]=(0,D.useState)(!1),[Xe,Ze]=(0,D.useState)(``),[z,B]=(0,D.useState)(null),[Qe,$e]=(0,D.useState)(``),[et,V]=(0,D.useState)(null),H=(()=>{let e=C===`.`?[]:C.split(`/`).filter(Boolean);return e.length>=2&&e[0]===`accounts`})(),[tt,nt]=(0,D.useState)(!1),rt=(0,D.useRef)(null),[it,U]=(0,D.useState)(!1),at=(0,D.useRef)(null);(0,D.useEffect)(()=>{let e=o.trim();if(!e){d(``),p(null),y(null);return}le(!1);let t=setTimeout(()=>d(e),300);return()=>clearTimeout(t)},[o]),(0,D.useEffect)(()=>{if(!u){_(!1);return}let t=!1;return _(!0),y(null),e(`/api/admin/graph-search?q=${encodeURIComponent(u)}&labels=FileArtifact&limit=20${S?`&threshold=0`:``}`).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{t||(p(e.results),h(e.mode??`hybrid`),re(typeof e.suppressed==`number`?e.suppressed:0))}).catch(e=>{t||y(e instanceof Error?e.message:String(e))}).finally(()=>{t||_(!1)}),()=>{t=!0}},[u,e,i,S]);let ot=(0,D.useMemo)(()=>f?Ce(f):[],[f]),W=b&&ot.includes(b)?b:null,st=(0,D.useMemo)(()=>f?W?f.filter(e=>e.labels.includes(W)):f:null,[f,W]),ct=(0,D.useCallback)(e=>{let t=e.properties.relativePath;if(typeof t!=`string`||t.length===0)return;let n=`/api/admin/files/download?session_key=${encodeURIComponent(r)}&path=${encodeURIComponent(t)}`,i=document.createElement(`a`);i.href=n,i.rel=`noopener noreferrer`,document.body.appendChild(i),i.click(),i.remove()},[r]);(0,D.useEffect)(()=>{if(!f)return;let e=f.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(`,`)}`)},[f]),(0,D.useEffect)(()=>{let t=!1;return we(!0),je(null),e(`/api/admin/files?path=${encodeURIComponent(C===`.`?``:C)}`).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{t||(ye(e.entries),A(e.displayPath??[]))}).catch(e=>{t||(ye([]),A([]),je(e instanceof Error?e.message:String(e)))}).finally(()=>{t||we(!1)}),()=>{t=!0}},[e,C,Je,i]),(0,D.useEffect)(()=>{Pe(C)},[C]);let lt=(0,D.useCallback)(()=>{L(e=>e+1)},[]),G=(0,D.useCallback)(e=>{nt(!1),he(e)},[]),ut=(0,D.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(``),y(null),x(null),G(r)},[G]),dt=(0,D.useCallback)(()=>{if(C===`.`||C===``)return;let e=C.split(`/`).filter(Boolean);e.pop(),he(e.length===0?`.`:e.join(`/`))},[C]),ft=(0,D.useCallback)(e=>{ae(r,C===`.`?e.name:`${C}/${e.name}`)},[C,r]),[K,pt]=(0,D.useState)(!1),[q,mt]=(0,D.useState)(new Set),ht=(0,D.useRef)(null),J=(0,D.useRef)(!1),Y=typeof navigator<`u`&&typeof navigator.share==`function`&&typeof navigator.canShare==`function`,gt=(0,D.useCallback)(e=>{pt(!0),mt(new Set([e])),console.info(`[data-ui] op=select-enter count=1`)},[]),X=(0,D.useCallback)(e=>{pt(!1),mt(new Set),console.info(`[data-ui] op=select-exit reason=${e}`)},[]),Z=(0,D.useCallback)(e=>{mt(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),_t=(0,D.useCallback)(e=>{J.current=!1,ht.current=setTimeout(()=>{J.current=!0,gt(e)},500)},[gt]),Q=(0,D.useCallback)(()=>{ht.current&&=(clearTimeout(ht.current),null)},[]),vt=(0,D.useCallback)(e=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}ft(e)},[K,Z,ft]),yt=(0,D.useCallback)(e=>{xe(e),typeof window<`u`&&window.localStorage.setItem(De,e),console.info(`[data] op=view-mode mode=${e}`)},[]),bt=(0,D.useCallback)(e=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}Se({src:ce(r,C===`.`?e.name:`${C}/${e.name}`),alt:e.displayName??e.name})},[K,Z,C,r]),xt=(0,D.useCallback)(()=>(w??[]).filter(e=>e.kind===`file`&&q.has(e.name)),[w,q]),St=(0,D.useCallback)(()=>(w??[]).filter(e=>(e.kind===`file`||e.kind===`directory`)&&q.has(e.name)),[w,q]),Ct=(0,D.useCallback)(()=>{let e=St(),t=e.some(e=>e.kind===`directory`);e.length===1&&!t?ft(e[0]):e.length>=1&&se(r,e.map(e=>C===`.`?e.name:`${C}/${e.name}`)),X(`action`)},[St,ft,C,r,X]),wt=(0,D.useCallback)(async()=>{let t=xt(),n=t.filter(e=>!e.protected),r=t.length-n.length;qe(r>0?`${r} protected file(s) kept`:null);for(let t of n){let n=C===`.`?t.name:`${C}/${t.name}`;try{let t=await e(`/api/admin/files?path=${encodeURIComponent(n)}`,{method:`DELETE`}),r=await t.json().catch(()=>({error:`HTTP ${t.status}`}));if(!t.ok)throw Error(r.error??`HTTP ${t.status}`)}catch(e){qe(e instanceof Error?e.message:String(e))}}L(e=>e+1),X(`action`)},[xt,C,e,X]),Tt=(0,D.useCallback)(async()=>{let e=xt();if(console.info(`[data-ui] op=share supported=${Y} count=${e.length}`),Y)try{let t=await Promise.all(e.map(async e=>{let t=C===`.`?e.name:`${C}/${e.name}`,n=`/api/admin/files/download?session_key=${encodeURIComponent(r)}&path=${encodeURIComponent(t)}`,i=await(await fetch(n)).blob();return new File([i],e.name,{type:i.type||`application/octet-stream`})}));navigator.canShare({files:t})&&await navigator.share({files:t})}catch(e){console.warn(`[data-ui] op=share-failed err=${e instanceof Error?e.message:String(e)}`)}},[xt,Y,C,r]),Et=(0,D.useCallback)(()=>{I.current?.click()},[]),Dt=(0,D.useCallback)((e,t={})=>{let n=(n,i,a)=>{let o=new URLSearchParams({session_key:r,path:C===`.`?``:C,filename:e.name});t.relpath&&o.set(`relpath`,t.relpath),t.token&&o.set(`token`,t.token);for(let[e,t]of Object.entries(i))o.set(e,t);return new Promise(t=>{let r=new XMLHttpRequest;r.open(`POST`,`/api/admin/files/upload?${o.toString()}`),r.setRequestHeader(`Content-Type`,e.type||`application/octet-stream`),a&&(r.upload.onprogress=e=>{e.lengthComputable&&a(e.loaded)}),r.onload=()=>{let e={};try{e=JSON.parse(r.responseText)}catch{}t({status:r.status,data:e})},r.onerror=()=>t({status:0,data:{}}),r.onabort=()=>t({status:0,data:{error:`aborted`}}),r.send(n)})};if(e.size<=Oe)return n(e,{},n=>t.onProgress?.(n,e.size));let i=`${Date.now().toString(36)}-${Math.random().toString(16).slice(2,10)}`,a=Math.ceil(e.size/ke);return(async()=>{let r={status:0,data:{}};for(let o=0;o<a;o++){let s=o*ke;if(r=await n(e.slice(s,Math.min(s+ke,e.size)),{uploadId:i,seq:String(o),total:String(a)},n=>t.onProgress?.(s+n,e.size)),!(r.status>=200&&r.status<300))return r}return r})()},[r,C]),Ot=(0,D.useCallback)(async e=>{F(null),M(!0),P({loaded:0,total:e.size});try{let{status:t,data:n}=await Dt(e,{onProgress:(e,t)=>P({loaded:e,total:t})});t>=200&&t<300&&n.path?(he(n.path.split(`/`).slice(0,-1).join(`/`)||`.`),L(e=>e+1)):F(t===0?`Network error during upload — the connection failed before the server responded.`:n.error??`Upload failed (HTTP ${t}).`)}finally{M(!1),P(null),I.current&&(I.current.value=``)}},[Dt]),kt=(0,D.useCallback)(e=>{H&&Array.from(e.dataTransfer.types).includes(`Files`)&&(e.preventDefault(),Ge(!0))},[H]),At=(0,D.useCallback)(e=>{e.currentTarget.contains(e.relatedTarget)||Ge(!1)},[]),jt=(0,D.useCallback)(async e=>{e.preventDefault(),Ge(!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(!H){console.info(`[data-ui] op=drop-rejected token=${t} reason=no-write`),F(`Open a folder inside your account to upload`);return}let r=n.map(e=>e.webkitGetAsEntry?.()).filter(e=>!!e);M(!0),F(null),Ve(null);let i=performance.now();try{let e=await Fe(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}`),P({loaded:0,total:r.size});let{status:a,data:c}=await Dt(r,{relpath:i,token:t,onProgress:(e,t)=>P({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`:Ie(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}`),Ve(`Uploaded ${o}, skipped ${s.length}${s.length?`: ${s.join(`, `)}`:``}`),L(e=>e+1)}catch(e){F(e instanceof Error?e.message:String(e))}finally{M(!1),P(null)}},[H,Dt]),Mt=(0,D.useCallback)(async()=>{let t=Xe.trim();if(t){V(null);try{let n=await e(`/api/admin/files/folder`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:C===`.`?``:C,name:t})}),r=await n.json().catch(()=>({error:`HTTP ${n.status}`}));if(!n.ok)throw Error(r.error??`HTTP ${n.status}`);R(!1),Ze(``),L(e=>e+1)}catch(e){V(e instanceof Error?e.message:String(e))}}},[e,Xe,C]),Nt=(0,D.useCallback)(async()=>{if(!z)return;let t=Qe.trim();if(!t)return;V(null);let n=C===`.`?z:`${C}/${z}`;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}`);B(null),$e(``),X(`action`),L(e=>e+1)}catch(e){V(e instanceof Error?e.message:String(e))}},[e,Qe,z,C,X]);(0,D.useEffect)(()=>{if(!tt)return;let e=e=>{rt.current&&!rt.current.contains(e.target)&&nt(!1)},t=e=>{e.key===`Escape`&&nt(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[tt]),(0,D.useEffect)(()=>{if(!it)return;let e=e=>{at.current&&!at.current.contains(e.target)&&U(!1)},t=e=>{e.key===`Escape`&&U(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[it]);let $=(0,D.useCallback)(e=>k.slice(0,e+1).map(e=>e.name).join(`/`),[k]),Pt=k.length>=2,Ft=Pt?[{name:`.`,label:`data`},...k.slice(0,k.length-2).map((e,t)=>({name:$(t),label:e.displayName??e.name}))]:[];return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`data-toolbar`,children:[K?(0,O.jsxs)(`button`,{type:`button`,className:`data-select-cancel`,onClick:()=>X(`cancel`),"aria-label":`Cancel selection`,children:[(0,O.jsx)(t,{size:14}),` Cancel`]}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`data-search-input`,children:[o===``&&(0,O.jsx)(ue,{size:14}),(0,O.jsx)(`input`,{ref:l,type:`text`,value:o,onChange:e=>c(e.target.value),autoFocus:!0,autoComplete:`off`,spellCheck:!1}),g&&(0,O.jsx)(n,{size:14,className:`spin`}),o!==``&&(0,O.jsx)(`button`,{type:`button`,className:`data-search-inline-btn`,onClick:()=>{c(``),l.current?.focus()},title:`Clear search`,"aria-label":`Clear search`,children:(0,O.jsx)(t,{size:14})})]}),(0,O.jsxs)(`div`,{className:`data-toolbar-actions`,ref:at,children:[(0,O.jsx)(`button`,{type:`button`,className:`data-action-overflow`,onClick:()=>U(e=>!e),"aria-haspopup":`menu`,"aria-expanded":it,"aria-label":`File actions`,title:`File actions`,children:(0,O.jsx)(fe,{size:16})}),(0,O.jsxs)(`div`,{className:`data-action-group`,role:`group`,"aria-label":`File actions`,"data-open":it?`true`:void 0,children:[(0,O.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{lt(),U(!1)},disabled:j,title:`Refresh this folder`,"aria-label":`Refresh this folder`,children:[j?(0,O.jsx)(n,{size:16,className:`spin`}):(0,O.jsx)(ee,{size:16}),(0,O.jsx)(`span`,{className:`data-action-label`,children:`Refresh`})]}),(0,O.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{Et(),U(!1)},disabled:Me||!H,title:H?`Upload a file`:`Open a folder inside your account to upload`,"aria-label":`Upload a file`,children:[Me?N&&N.total>0?(0,O.jsxs)(`span`,{className:`data-upload-pct`,children:[Math.round(N.loaded/N.total*100),`%`]}):(0,O.jsx)(n,{size:16,className:`spin`}):(0,O.jsx)(be,{size:16}),(0,O.jsx)(`span`,{className:`data-action-label`,children:`Upload`})]}),(0,O.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{R(e=>!e),Ze(``),V(null),U(!1)},disabled:Me||!H,title:H?`New folder`:`Open a folder inside your account to create one`,"aria-label":`New folder`,children:[(0,O.jsx)(pe,{size:16}),(0,O.jsx)(`span`,{className:`data-action-label`,children:`New folder`})]}),(0,O.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{yt(T===`grid`?`list`:`grid`),U(!1)},title:T===`grid`?`List view`:`Grid view`,"aria-label":T===`grid`?`Switch to list view`:`Switch to grid view`,"aria-pressed":T===`grid`,children:[T===`grid`?(0,O.jsx)(_e,{size:16}):(0,O.jsx)(ge,{size:16}),(0,O.jsx)(`span`,{className:`data-action-label`,children:T===`grid`?`List view`:`Grid view`})]})]})]})]}),(0,O.jsxs)(`div`,{className:`data-breadcrumbs`,children:[C!==`.`&&(0,O.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost data-back-btn`,onClick:dt,title:`Up one level`,"aria-label":`Up one level`,children:(0,O.jsx)(de,{size:14})}),Pt?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`span`,{className:`data-crumb-wrap`,ref:rt,children:[(0,O.jsx)(`button`,{type:`button`,className:`data-crumb data-crumb-ellipsis`,onClick:()=>nt(e=>!e),"aria-haspopup":`menu`,"aria-expanded":tt,"aria-label":`Show parent folders`,title:`Show parent folders`,children:`…`}),tt&&(0,O.jsx)(`div`,{className:`data-crumb-menu`,role:`menu`,children:Ft.map(e=>(0,O.jsx)(`button`,{type:`button`,role:`menuitem`,className:`data-crumb-menu-item`,onClick:()=>G(e.name),title:e.label,children:e.label},e.name))})]}),[k.length-2,k.length-1].map(e=>{let t=k[e];return(0,O.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,O.jsx)(`span`,{className:`data-crumb-sep`,children:`/`}),(0,O.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>G($(e)),title:t.name,children:t.displayName??t.name})]},$(e))})]}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>G(`.`),children:`data`}),k.map((e,t)=>(0,O.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,O.jsx)(`span`,{className:`data-crumb-sep`,children:`/`}),(0,O.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>G($(t)),title:e.name,children:e.displayName??e.name})]},$(t)))]})]}),Ye&&(0,O.jsxs)(`div`,{className:`data-inline-form`,children:[(0,O.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`Folder name`,value:Xe,autoFocus:!0,onChange:e=>Ze(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Mt(),e.key===`Escape`&&R(!1)}}),(0,O.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:Mt,children:`Create`}),(0,O.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost`,onClick:()=>R(!1),children:`Cancel`})]}),z&&(0,O.jsxs)(`div`,{className:`data-inline-form`,children:[(0,O.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`New name`,value:Qe,autoFocus:!0,onChange:e=>$e(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Nt(),e.key===`Escape`&&B(null)}}),(0,O.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:Nt,children:`Rename`}),(0,O.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost`,onClick:()=>B(null),children:`Cancel`})]}),et&&(0,O.jsx)(`div`,{className:`data-error`,children:et}),(0,O.jsx)(`input`,{type:`file`,ref:I,hidden:!0,onChange:e=>{let t=e.target.files?.[0];t&&Ot(t)}})]}),(0,O.jsxs)(`div`,{className:`data-body`,"data-drag-active":He?`true`:void 0,onDragEnter:kt,onDragOver:kt,onDragLeave:At,onDrop:jt,children:[(v!==null||f!==null)&&(0,O.jsxs)(`section`,{className:`data-panel`,children:[v&&(0,O.jsxs)(`div`,{className:`data-error`,children:[`Search failed: `,v]}),ot.length>0&&(0,O.jsx)(`div`,{className:`data-chip-row`,role:`group`,"aria-label":`Filter by type`,children:ot.map(e=>{let t=e===W;return(0,O.jsx)(`button`,{type:`button`,className:`data-chip`,"data-active":t,onClick:()=>x(t?null:e),children:ze([e])??e},e)})}),f&&!g&&(0,O.jsxs)(`div`,{className:`data-results-meta`,children:[st.length,` of `,f.length,` result`,f.length===1?``:`s`]}),f&&!g&&!W&&te>0&&!S&&(0,O.jsxs)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>le(!0),children:[te,` low-confidence result`,te===1?``:`s`,` hidden — show all`]}),f&&!g&&!W&&S&&(0,O.jsx)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>le(!1),children:`Showing all results — hide low-confidence`}),f&&f.length===0&&!g&&(0,O.jsx)(`div`,{className:`data-empty-results`,children:`No matches. Try a different keyword.`}),st&&st.length>0&&(0,O.jsx)(`ul`,{className:`data-results`,children:st.map(e=>(0,O.jsx)(Re,{hit:e,mode:m,onDownload:ct,onLocate:ut},e.nodeId))})]}),(0,O.jsxs)(`section`,{className:`data-panel`,children:[N&&(0,O.jsxs)(`div`,{className:`data-upload-progress`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":N.total>0?Math.round(N.loaded/N.total*100):void 0,children:[(0,O.jsx)(`div`,{className:`data-upload-progress-track`,children:(0,O.jsx)(`div`,{className:`data-upload-progress-fill`,style:{width:`${N.total>0?Math.round(N.loaded/N.total*100):0}%`}})}),(0,O.jsxs)(`span`,{className:`data-upload-progress-label`,children:[`Uploading… `,N.total>0?`${Math.round(N.loaded/N.total*100)}%`:``]})]}),Le&&(0,O.jsxs)(`div`,{className:`data-error`,children:[`Upload failed: `,Le]}),Be&&(0,O.jsx)(`div`,{className:`data-status`,children:Be}),Ke&&(0,O.jsxs)(`div`,{className:`data-error`,children:[`Delete failed: `,Ke]}),Te&&(0,O.jsx)(`div`,{className:`data-error`,children:Te}),j&&(0,O.jsxs)(`div`,{className:`data-loading`,children:[(0,O.jsx)(n,{size:14,className:`spin`}),` Loading…`]}),!K&&!j&&w&&w.length>0&&(0,O.jsxs)(`div`,{className:`data-select-hint`,children:[(0,O.jsx)(ve,{size:13}),(0,O.jsx)(`span`,{children:`Press and hold a file to select, rename, or delete it.`})]}),!j&&w&&w.length===0&&!Te&&(0,O.jsx)(`div`,{className:`data-empty-results`,children:`Empty directory.`}),!j&&w&&w.length>0&&T===`grid`&&(0,O.jsx)(`ul`,{className:`data-grid`,children:w.map(e=>{let t=e.displayName??e.name,n=K&&q.has(e.name);if(e.kind===`directory`)return(0,O.jsx)(`li`,{className:`data-grid-cell`,"data-selected":n?`true`:void 0,children:(0,O.jsxs)(`button`,{type:`button`,className:`data-grid-tile`,onPointerDown:()=>_t(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}G(C===`.`?e.name:`${C}/${e.name}`)},children:[K&&(0,O.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,O.jsx)(me,{size:28,className:`data-grid-glyph`}),(0,O.jsx)(`span`,{className:`data-grid-label`,title:e.name,children:t})]})},e.name);if(e.kind===`file`){let i=Ee(e.name),a=C===`.`?e.name:`${C}/${e.name}`;return(0,O.jsx)(`li`,{className:`data-grid-cell`,"data-selected":n?`true`:void 0,children:(0,O.jsxs)(`button`,{type:`button`,className:`data-grid-tile${i?` data-grid-tile-image`:``}`,onPointerDown:()=>_t(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>i?bt(e):vt(e),title:K?void 0:i?`Preview ${t}`:`Download ${t}`,children:[K&&(0,O.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),i?(0,O.jsx)(`img`,{className:`data-grid-thumb`,src:ce(r,a),alt:t,loading:`lazy`,onError:()=>console.warn(`[data] op=thumb-error path=${a}`)}):(0,O.jsx)(ie,{size:28,className:`data-grid-glyph`}),(0,O.jsx)(`span`,{className:`data-grid-label`,title:e.name,children:t}),!i&&(0,O.jsx)(`span`,{className:`data-grid-sub`,children:Ue(e.sizeBytes)})]})},e.name)}return(0,O.jsx)(`li`,{className:`data-grid-cell`,children:(0,O.jsxs)(`div`,{className:`data-grid-tile data-entry-disabled`,children:[(0,O.jsx)(ie,{size:28,className:`data-grid-glyph`}),(0,O.jsx)(`span`,{className:`data-grid-label`,children:t}),(0,O.jsx)(`span`,{className:`data-grid-sub`,children:`special`})]})},e.name)})}),!j&&w&&w.length>0&&T===`list`&&(0,O.jsx)(`ul`,{className:`data-entries`,children:w.map(e=>{let t=e.displayName??e.name;if(e.kind===`directory`){let n=K&&q.has(e.name);return(0,O.jsx)(`li`,{className:`data-entry`,"data-selected":n?`true`:void 0,children:(0,O.jsxs)(`button`,{type:`button`,className:`data-entry-btn`,onPointerDown:()=>_t(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}G(C===`.`?e.name:`${C}/${e.name}`)},children:[K&&(0,O.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,O.jsx)(me,{size:14}),(0,O.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t})]})},e.name)}if(e.kind===`file`){let n=K&&q.has(e.name);return(0,O.jsx)(`li`,{className:`data-entry`,"data-selected":n?`true`:void 0,children:(0,O.jsxs)(`button`,{type:`button`,className:`data-entry-btn data-entry-file`,onPointerDown:()=>_t(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>vt(e),title:K?void 0:`Download ${t}`,children:[K&&(0,O.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,O.jsxs)(`span`,{className:`data-entry-text`,children:[(0,O.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t}),(0,O.jsxs)(`span`,{className:`data-entry-meta`,title:`Modified ${We(e.modifiedAt)}`,children:[Ue(e.sizeBytes),` · `,We(e.modifiedAt)]})]})]})},e.name)}return(0,O.jsx)(`li`,{className:`data-entry`,children:(0,O.jsx)(`div`,{className:`data-entry-btn data-entry-file data-entry-disabled`,children:(0,O.jsxs)(`span`,{className:`data-entry-text`,children:[(0,O.jsx)(`span`,{className:`data-entry-name`,children:t}),(0,O.jsx)(`span`,{className:`data-entry-meta`,children:`special`})]})})},e.name)})})]})]}),K&&(0,O.jsx)(`div`,{className:`data-select-bar`,role:`toolbar`,"aria-label":`Selection actions`,children:(0,O.jsxs)(`div`,{className:`data-select-bar-inner`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:Tt,disabled:!Y||q.size===0,title:Y?`Share selected files`:`Sharing is not supported on this device`,children:[(0,O.jsx)(s,{size:16}),` Share`]}),(0,O.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:Ct,disabled:q.size===0,children:[(0,O.jsx)(ne,{size:16}),` Download`]}),(0,O.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:()=>{let e=[...q][0];e&&(B(e),$e(e))},disabled:q.size!==1,children:[(0,O.jsx)(oe,{size:16}),` Rename`]}),(0,O.jsxs)(`button`,{type:`button`,className:`data-select-action data-select-delete`,onClick:wt,disabled:q.size===0,children:[(0,O.jsx)(a,{size:16}),` Delete`]})]})}),E&&(0,O.jsx)(`div`,{className:`chat-attachment-overlay`,role:`dialog`,"aria-label":E.alt,onClick:()=>Se(null),children:(0,O.jsx)(`img`,{className:`chat-attachment-overlay-image`,src:E.src,alt:E.alt})})]})}function Le({adminFetch:e,cacheKey:t,sessionRefetchNonce:n}){(0,D.useEffect)(()=>{console.info(`[data-ui] op=mount header=operator home=absent`)},[]);let r=(0,D.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]),a=(0,D.useCallback)(e=>{e===`chat`&&(window.location.href=`/`)},[]),[o,s]=(0,D.useState)([]),[l,u]=(0,D.useState)(`files`),{subAccounts:d,activeAccountId:f,switching:p,switchAccount:m}=c(t);return(0,D.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||s(t.conversations??[])}).catch(()=>{}),()=>{e=!0}},[t]),(0,O.jsxs)(`main`,{className:`data-main`,children:[(0,O.jsx)(i,{variant:`operator`,onNavigate:a,onOpenConversations:o.length>0?()=>u(`conversations`):void 0,onToggleSidebar:()=>{},sidebarOpen:!1,onLogout:r,onDisconnect:async()=>!0,disconnecting:!1,subAccounts:d,activeAccountId:f,switchingAccount:p,onSwitchAccount:m}),l===`conversations`?(0,O.jsx)(we,{conversations:o,sessionKey:t,onBack:()=>u(`files`)}):(0,O.jsx)(P,{adminFetch:e,cacheKey:t,sessionRefetchNonce:n})]})}function F({cacheKey:e}){let{adminFetch:t,cacheKey:n,sessionRefetchNonce:r}=u({initialCacheKey:e,surface:`data`});return(0,O.jsx)(`div`,{className:`data-page`,children:(0,O.jsx)(`main`,{className:`data-main`,children:(0,O.jsx)(P,{adminFetch:t,cacheKey:n,sessionRefetchNonce:r})})})}function Re({hit:e,mode:t,onDownload:n,onLocate:r}){let i=Be(e.properties),a=Ve(e.properties),o=ze(e.labels),s=He(e.properties),[c,l]=(0,D.useState)(!1),u=a&&a.length>280,d=c||!u?a:a?.slice(0,280)+`…`,f=t===`bm25`?`bm25 ${e.bm25Score.toFixed(2)}`:`vector ${e.vectorScore.toFixed(2)} · bm25 ${e.bm25Score.toFixed(2)} · combined ${e.score.toFixed(2)}`,p=e.properties.relativePath,m=typeof p==`string`&&p.length>0,h=m?p.lastIndexOf(`/`):-1,g=m?h===-1?`data`:p.slice(0,h):null;return(0,O.jsxs)(`li`,{className:`data-result`,children:[(0,O.jsxs)(`div`,{role:`button`,tabIndex:0,className:`data-result-open`,onClick:()=>n(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n(e))},"aria-label":`Download ${i??o??`file`}`,children:[o&&(0,O.jsx)(`div`,{className:`data-result-header`,children:(0,O.jsx)(`span`,{className:`data-result-labels`,children:o})}),i&&(0,O.jsx)(`div`,{className:`data-result-title`,children:i}),a&&(0,O.jsx)(`pre`,{className:`data-result-body`,children:d}),(0,O.jsxs)(`div`,{className:`data-result-scores`,children:[s&&(0,O.jsxs)(`span`,{className:`data-result-updated`,children:[`Updated `,We(s),` · `]}),f]})]}),m&&(0,O.jsxs)(`button`,{type:`button`,className:`data-result-locate`,onClick:()=>r(e),title:`Locate in ${g}`,"aria-label":`Locate in ${g}`,children:[(0,O.jsx)(me,{size:12}),g]}),u&&(0,O.jsx)(`button`,{type:`button`,className:`data-result-toggle`,onClick:()=>l(e=>!e),children:c?`Show less`:`Show more`})]})}function ze(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 Be(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 Ve(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 He(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 Ue(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 We(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{F as n,A as r,je as t};
1
+ import{o as e}from"./chunk-Ck5AOu5v.js";import{a as t,l as n,m as r,n as i,o as a,r as o,s,t as c,w as l,x as u,y as d}from"./useSubAccountSwitcher-DyjTbzQR.js";import{S as f,a as p,b as m,t as h,v as g,x as _,y as v}from"./audio-attachment-mime-CwYrV1pg.js";import{t as y}from"./chevron-left-CLPxfjDV.js";import{a as b,c as x,d as ee,f as te,h as ne,i as re,m as ie,n as ae,p as oe,r as se,s as S,t as ce,u as le}from"./file-download-B2B2DTar.js";import{i as ue,t as C}from"./graph-labels-DxqDdO7G.js";var de=r(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),fe=r(`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`}]]),pe=r(`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`}]]),me=r(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),he=r(`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`}]]),ge=r(`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`}]]),_e=r(`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`}]]),ve=r(`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`}]]),w=r(`phone`,[[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]),ye=r(`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`}]]),T=r(`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`}]]),be=r(`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`}]]),xe=r(`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`}]]),E=r(`video`,[[`path`,{d:`m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5`,key:`ftymec`}],[`rect`,{x:`2`,y:`6`,width:`14`,height:`12`,rx:`2`,key:`158x01`}]]),D=e(l(),1);function Se(){let[e,t]=(0,D.useState)([]),[n,r]=(0,D.useState)(!1),[i,a]=(0,D.useState)(null),o=(0,D.useRef)(null),s=(0,D.useCallback)(e=>{a(null);let n=e.find(e=>!h(e.type,f));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>_);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,D.useCallback)(()=>{t([]),a(null)},[]),removeFile:(0,D.useCallback)(e=>{t(t=>t.filter((t,n)=>n!==e))},[]),onDragOver:(0,D.useCallback)(e=>{e.preventDefault(),r(!0)},[]),onDragLeave:(0,D.useCallback)(()=>{r(!1)},[]),onDrop:(0,D.useCallback)(e=>{e.preventDefault(),r(!1),s([...e.dataTransfer.files])},[s])}}var O=d();function k({accountId:e,remoteJid:n,sessionKey:r}){let[i,a]=(0,D.useState)(``),[o,s]=(0,D.useState)(!1),[c,l]=(0,D.useState)(null),{pendingFiles:u,attachError:d,fileInputRef:f,addFiles:p,removeFile:h,clearFiles:_}=Se(),v=(0,D.useRef)(!1),y=(i.trim().length>0||u.length>0)&&!o,b=(0,D.useCallback)(async()=>{if(!v.current&&!(i.trim().length===0&&u.length===0)){v.current=!0,s(!0),l(null);try{let t=`/api/whatsapp-reader/reply?session_key=${encodeURIComponent(r)}`,o;if(u.length>0){let r=new FormData;r.append(`accountId`,e),r.append(`remoteJid`,n),i.trim()&&r.append(`text`,i);for(let e of u)r.append(`files`,e);o=await fetch(t,{method:`POST`,body:r})}else o=await fetch(t,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({accountId:e,remoteJid:n,text:i})});let s=await o.json().catch(()=>({}));if(!o.ok){l(s.error??`Send failed.`),console.info(`[operator-ui] op=reply-fail remoteJid=${n} error=${s.error??`unknown`}`);return}a(``),_(),console.info(`[operator-ui] op=reply-sent remoteJid=${n} sent=${s.sent??0}`)}catch(e){l(`Could not reach the server. Try again.`),console.info(`[operator-ui] op=reply-fail remoteJid=${n} error=${String(e)}`)}finally{v.current=!1,s(!1)}}},[i,u,e,n,r,_]),x=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),y&&b())},ee=e=>e.startsWith(`image/`)?(0,O.jsx)(he,{size:14}):e===`application/pdf`?(0,O.jsx)(ie,{size:14}):(0,O.jsx)(g,{size:14});return(0,O.jsxs)(`div`,{className:`wa-reply`,children:[c&&(0,O.jsx)(`p`,{className:`wa-reply-error`,role:`alert`,children:c}),d&&(0,O.jsx)(`p`,{className:`wa-reply-error`,role:`alert`,children:d}),u.length>0&&(0,O.jsx)(`div`,{className:`wa-reply-attachments`,children:u.map((e,n)=>(0,O.jsxs)(`div`,{className:`wa-reply-chip`,children:[ee(e.type),(0,O.jsx)(`span`,{className:`wa-reply-chip-name`,children:e.name}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>h(n),"aria-label":`Remove ${e.name}`,children:(0,O.jsx)(t,{size:12})})]},n))}),(0,O.jsxs)(`div`,{className:`wa-reply-row`,children:[(0,O.jsx)(`input`,{ref:f,type:`file`,multiple:!0,accept:m,style:{display:`none`},onChange:e=>{e.target.files&&p([...e.target.files]),e.target.value=``}}),(0,O.jsx)(`button`,{type:`button`,className:`wa-reply-attach`,onClick:()=>f.current?.click(),disabled:o,"aria-label":`Attach files`,children:(0,O.jsx)(te,{size:22})}),(0,O.jsx)(`textarea`,{className:`wa-reply-input`,value:i,rows:1,placeholder:`Type a message`,disabled:o,onChange:e=>a(e.target.value),onKeyDown:x}),(0,O.jsx)(`button`,{type:`button`,className:`wa-reply-send`,onClick:()=>void b(),disabled:!y,"aria-label":`Send`,children:(0,O.jsx)(ye,{size:20})})]})]})}function A({accountId:e,remoteJid:t,contactName:n,sessionKey:r,onBack:i}){let a=x(t),o=t.split(`@`)[0],s=a?`Group`:n===`+${o}`?void 0:`+${o}`;return(0,O.jsxs)(`div`,{className:`wa-web`,children:[(0,O.jsxs)(`header`,{className:`wa-web-header`,children:[i&&(0,O.jsx)(`button`,{type:`button`,className:`wa-web-back`,onClick:i,"aria-label":`Back`,children:(0,O.jsx)(y,{size:20})}),(0,O.jsx)(`span`,{className:`wa-web-avatar`,"aria-hidden":!0,children:(0,O.jsx)(xe,{size:20})}),(0,O.jsxs)(`div`,{className:`wa-web-titles`,children:[(0,O.jsx)(`span`,{className:`wa-web-name`,children:n}),s&&(0,O.jsx)(`span`,{className:`wa-web-subtitle`,children:s})]}),(0,O.jsxs)(`div`,{className:`wa-web-actions`,"aria-hidden":!0,children:[(0,O.jsx)(E,{size:20}),(0,O.jsx)(w,{size:20}),(0,O.jsx)(ue,{size:20}),(0,O.jsx)(v,{size:20})]})]}),(0,O.jsx)(`div`,{className:`wa-web-body`,children:(0,O.jsx)(p,{sessionId:``,projectDir:``,sessionKey:r,forceDeliveredOnly:!0,suppressDirectives:!0,store:{accountId:e,remoteJid:t}})}),a?(0,O.jsx)(`p`,{className:`wa-reply wa-reply-readonly`,children:`Group messages are read-only.`}):(0,O.jsx)(k,{accountId:e,remoteJid:t,sessionKey:r})]})}function Ce(e){let t=new Set,n=[];for(let r of e)for(let e of r.labels)e&&(t.has(e)||C.has(e)&&(t.add(e),n.push(e)));return n}function j(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 we({conversations:e,sessionKey:t,onBack:n}){let[r,i]=(0,D.useState)(null),a=re(e);return r?r.source===`store`&&r.accountId&&r.remoteJid?(0,O.jsx)(A,{accountId:r.accountId,remoteJid:r.remoteJid,contactName:b(r),sessionKey:t,onBack:()=>i(null)},S(r)):(0,O.jsxs)(`div`,{className:`op-conv op-conv-reader`,children:[(0,O.jsxs)(`div`,{className:`op-conv-bar`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`op-conv-back`,onClick:()=>i(null),"aria-label":`Back to conversations`,children:[(0,O.jsx)(y,{size:16}),` Back`]}),(0,O.jsx)(`span`,{className:`op-conv-title`,children:b(r)})]}),(0,O.jsx)(p,{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},S(r))]}):(0,O.jsxs)(`div`,{className:`op-conv op-conv-list`,children:[(0,O.jsxs)(`div`,{className:`op-conv-bar`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`op-conv-back`,onClick:n,"aria-label":`Back to chat`,children:[(0,O.jsx)(y,{size:16}),` Chat`]}),(0,O.jsx)(`span`,{className:`op-conv-title`,children:`Conversations`})]}),a.map(e=>(0,O.jsxs)(`div`,{className:`op-conv-group`,children:[(0,O.jsxs)(`div`,{className:`op-conv-group-head`,children:[(0,O.jsx)(le,{channel:e.channel,size:14}),e.label]}),e.rows.map(e=>(0,O.jsxs)(`button`,{type:`button`,className:`op-conv-row`,onClick:()=>{console.info(`[operator-ui] op=reader-open channel=${e.channel} key=${S(e)} readonly=true source=${e.source}`),i(e)},children:[(0,O.jsx)(`span`,{className:`op-conv-name`,children:b(e)}),e.modelGated&&(0,O.jsx)(`span`,{className:`op-conv-gated`,role:`img`,"aria-label":`Model unavailable`,children:(0,O.jsx)(T,{size:13})}),(0,O.jsx)(`span`,{className:`op-conv-when`,children:j(e.lastMessageAt)})]},S(e)))]},e.channel))]})}var Te=/\.(png|jpe?g|gif|webp|svg)$/i;function Ee(e){return Te.test(e)}var De=`maxy-data-view`,Oe=95*1024*1024,ke=48*1024*1024;function Ae(){return typeof window>`u`?`list`:window.localStorage.getItem(De)===`grid`?`grid`:`list`}function je(){let[e,t]=(0,D.useState)(null),[r,i]=(0,D.useState)(!1);return(0,D.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,O.jsx)(o,{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,O.jsx)(`div`,{className:`data-page data-page-full`,children:(0,O.jsx)(Me,{cacheKey:e})})}):(0,O.jsx)(`div`,{className:`data-page`,children:(0,O.jsxs)(`div`,{className:`data-empty`,children:[(0,O.jsx)(`p`,{children:`You are not signed in.`}),(0,O.jsxs)(`p`,{children:[`Open the `,(0,O.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,O.jsx)(`div`,{className:`data-page`,children:(0,O.jsxs)(`div`,{className:`data-loading`,children:[(0,O.jsx)(n,{size:18,className:`spin`}),` Loading…`]})})}function Me({cacheKey:e}){let{adminFetch:t,cacheKey:n,sessionRefetchNonce:r}=u({initialCacheKey:e,surface:`data`});return(0,O.jsx)(Le,{adminFetch:t,cacheKey:n,sessionRefetchNonce:r})}function Ne(){if(typeof window>`u`)return`.`;let e=new URLSearchParams(window.location.hash.replace(/^#/,``)).get(`path`);return e&&e.length>0?e:`.`}function Pe(e){if(typeof window>`u`)return;let t=new URL(window.location.href);t.hash=e===`.`?``:`path=${encodeURIComponent(e)}`,window.history.replaceState(window.history.state,``,t.toString())}function M(e){return new Promise((t,n)=>{let r=[],i=()=>e.readEntries(e=>{e.length===0?t(r):(r.push(...e),i())},n);i()})}function N(e){return new Promise((t,n)=>e.file(t,n))}async function Fe(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 N(r),relpath:e});else if(r.isDirectory){let t=await M(r.createReader());n.push(...await Fe(t,e))}}return n}function Ie(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 P({adminFetch:e,cacheKey:r,sessionRefetchNonce:i}){let[o,c]=(0,D.useState)(``),l=(0,D.useRef)(null),[u,d]=(0,D.useState)(``),[f,p]=(0,D.useState)(null),[m,h]=(0,D.useState)(`hybrid`),[g,_]=(0,D.useState)(!1),[v,y]=(0,D.useState)(null),[b,x]=(0,D.useState)(null),[te,re]=(0,D.useState)(0),[S,le]=(0,D.useState)(!1),[C,he]=(0,D.useState)(()=>Ne()),[w,ye]=(0,D.useState)(null),[T,xe]=(0,D.useState)(()=>Ae()),[E,Se]=(0,D.useState)(null),[k,A]=(0,D.useState)([]),[j,we]=(0,D.useState)(!1),[Te,je]=(0,D.useState)(null),[Me,M]=(0,D.useState)(!1),[N,P]=(0,D.useState)(null),[Le,F]=(0,D.useState)(null),[Be,Ve]=(0,D.useState)(null),[He,Ge]=(0,D.useState)(!1),[Ke,qe]=(0,D.useState)(null),I=(0,D.useRef)(null),[Je,L]=(0,D.useState)(0),[Ye,R]=(0,D.useState)(!1),[Xe,Ze]=(0,D.useState)(``),[z,B]=(0,D.useState)(null),[Qe,$e]=(0,D.useState)(``),[et,V]=(0,D.useState)(null),H=(()=>{let e=C===`.`?[]:C.split(`/`).filter(Boolean);return e.length>=2&&e[0]===`accounts`})(),[tt,nt]=(0,D.useState)(!1),rt=(0,D.useRef)(null),[it,U]=(0,D.useState)(!1),at=(0,D.useRef)(null);(0,D.useEffect)(()=>{let e=o.trim();if(!e){d(``),p(null),y(null);return}le(!1);let t=setTimeout(()=>d(e),300);return()=>clearTimeout(t)},[o]),(0,D.useEffect)(()=>{if(!u){_(!1);return}let t=!1;return _(!0),y(null),e(`/api/admin/graph-search?q=${encodeURIComponent(u)}&labels=FileArtifact&limit=20${S?`&threshold=0`:``}`).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{t||(p(e.results),h(e.mode??`hybrid`),re(typeof e.suppressed==`number`?e.suppressed:0))}).catch(e=>{t||y(e instanceof Error?e.message:String(e))}).finally(()=>{t||_(!1)}),()=>{t=!0}},[u,e,i,S]);let ot=(0,D.useMemo)(()=>f?Ce(f):[],[f]),W=b&&ot.includes(b)?b:null,st=(0,D.useMemo)(()=>f?W?f.filter(e=>e.labels.includes(W)):f:null,[f,W]),ct=(0,D.useCallback)(e=>{let t=e.properties.relativePath;if(typeof t!=`string`||t.length===0)return;let n=`/api/admin/files/download?session_key=${encodeURIComponent(r)}&path=${encodeURIComponent(t)}`,i=document.createElement(`a`);i.href=n,i.rel=`noopener noreferrer`,document.body.appendChild(i),i.click(),i.remove()},[r]);(0,D.useEffect)(()=>{if(!f)return;let e=f.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(`,`)}`)},[f]),(0,D.useEffect)(()=>{let t=!1;return we(!0),je(null),e(`/api/admin/files?path=${encodeURIComponent(C===`.`?``:C)}`).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{t||(ye(e.entries),A(e.displayPath??[]))}).catch(e=>{t||(ye([]),A([]),je(e instanceof Error?e.message:String(e)))}).finally(()=>{t||we(!1)}),()=>{t=!0}},[e,C,Je,i]),(0,D.useEffect)(()=>{Pe(C)},[C]);let lt=(0,D.useCallback)(()=>{L(e=>e+1)},[]),G=(0,D.useCallback)(e=>{nt(!1),he(e)},[]),ut=(0,D.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(``),y(null),x(null),G(r)},[G]),dt=(0,D.useCallback)(()=>{if(C===`.`||C===``)return;let e=C.split(`/`).filter(Boolean);e.pop(),he(e.length===0?`.`:e.join(`/`))},[C]),ft=(0,D.useCallback)(e=>{ae(r,C===`.`?e.name:`${C}/${e.name}`)},[C,r]),[K,pt]=(0,D.useState)(!1),[q,mt]=(0,D.useState)(new Set),ht=(0,D.useRef)(null),J=(0,D.useRef)(!1),Y=typeof navigator<`u`&&typeof navigator.share==`function`&&typeof navigator.canShare==`function`,gt=(0,D.useCallback)(e=>{pt(!0),mt(new Set([e])),console.info(`[data-ui] op=select-enter count=1`)},[]),X=(0,D.useCallback)(e=>{pt(!1),mt(new Set),console.info(`[data-ui] op=select-exit reason=${e}`)},[]),Z=(0,D.useCallback)(e=>{mt(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),_t=(0,D.useCallback)(e=>{J.current=!1,ht.current=setTimeout(()=>{J.current=!0,gt(e)},500)},[gt]),Q=(0,D.useCallback)(()=>{ht.current&&=(clearTimeout(ht.current),null)},[]),vt=(0,D.useCallback)(e=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}ft(e)},[K,Z,ft]),yt=(0,D.useCallback)(e=>{xe(e),typeof window<`u`&&window.localStorage.setItem(De,e),console.info(`[data] op=view-mode mode=${e}`)},[]),bt=(0,D.useCallback)(e=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}Se({src:ce(r,C===`.`?e.name:`${C}/${e.name}`),alt:e.displayName??e.name})},[K,Z,C,r]),xt=(0,D.useCallback)(()=>(w??[]).filter(e=>e.kind===`file`&&q.has(e.name)),[w,q]),St=(0,D.useCallback)(()=>(w??[]).filter(e=>(e.kind===`file`||e.kind===`directory`)&&q.has(e.name)),[w,q]),Ct=(0,D.useCallback)(()=>{let e=St(),t=e.some(e=>e.kind===`directory`);e.length===1&&!t?ft(e[0]):e.length>=1&&se(r,e.map(e=>C===`.`?e.name:`${C}/${e.name}`)),X(`action`)},[St,ft,C,r,X]),wt=(0,D.useCallback)(async()=>{let t=xt(),n=t.filter(e=>!e.protected),r=t.length-n.length;qe(r>0?`${r} protected file(s) kept`:null);for(let t of n){let n=C===`.`?t.name:`${C}/${t.name}`;try{let t=await e(`/api/admin/files?path=${encodeURIComponent(n)}`,{method:`DELETE`}),r=await t.json().catch(()=>({error:`HTTP ${t.status}`}));if(!t.ok)throw Error(r.error??`HTTP ${t.status}`)}catch(e){qe(e instanceof Error?e.message:String(e))}}L(e=>e+1),X(`action`)},[xt,C,e,X]),Tt=(0,D.useCallback)(async()=>{let e=xt();if(console.info(`[data-ui] op=share supported=${Y} count=${e.length}`),Y)try{let t=await Promise.all(e.map(async e=>{let t=C===`.`?e.name:`${C}/${e.name}`,n=`/api/admin/files/download?session_key=${encodeURIComponent(r)}&path=${encodeURIComponent(t)}`,i=await(await fetch(n)).blob();return new File([i],e.name,{type:i.type||`application/octet-stream`})}));navigator.canShare({files:t})&&await navigator.share({files:t})}catch(e){console.warn(`[data-ui] op=share-failed err=${e instanceof Error?e.message:String(e)}`)}},[xt,Y,C,r]),Et=(0,D.useCallback)(()=>{I.current?.click()},[]),Dt=(0,D.useCallback)((e,t={})=>{let n=(n,i,a)=>{let o=new URLSearchParams({session_key:r,path:C===`.`?``:C,filename:e.name});t.relpath&&o.set(`relpath`,t.relpath),t.token&&o.set(`token`,t.token);for(let[e,t]of Object.entries(i))o.set(e,t);return new Promise(t=>{let r=new XMLHttpRequest;r.open(`POST`,`/api/admin/files/upload?${o.toString()}`),r.setRequestHeader(`Content-Type`,e.type||`application/octet-stream`),a&&(r.upload.onprogress=e=>{e.lengthComputable&&a(e.loaded)}),r.onload=()=>{let e={};try{e=JSON.parse(r.responseText)}catch{}t({status:r.status,data:e})},r.onerror=()=>t({status:0,data:{}}),r.onabort=()=>t({status:0,data:{error:`aborted`}}),r.send(n)})};if(e.size<=Oe)return n(e,{},n=>t.onProgress?.(n,e.size));let i=`${Date.now().toString(36)}-${Math.random().toString(16).slice(2,10)}`,a=Math.ceil(e.size/ke);return(async()=>{let r={status:0,data:{}};for(let o=0;o<a;o++){let s=o*ke;if(r=await n(e.slice(s,Math.min(s+ke,e.size)),{uploadId:i,seq:String(o),total:String(a)},n=>t.onProgress?.(s+n,e.size)),!(r.status>=200&&r.status<300))return r}return r})()},[r,C]),Ot=(0,D.useCallback)(async e=>{F(null),M(!0),P({loaded:0,total:e.size});try{let{status:t,data:n}=await Dt(e,{onProgress:(e,t)=>P({loaded:e,total:t})});t>=200&&t<300&&n.path?(he(n.path.split(`/`).slice(0,-1).join(`/`)||`.`),L(e=>e+1)):F(t===0?`Network error during upload — the connection failed before the server responded.`:n.error??`Upload failed (HTTP ${t}).`)}finally{M(!1),P(null),I.current&&(I.current.value=``)}},[Dt]),kt=(0,D.useCallback)(e=>{H&&Array.from(e.dataTransfer.types).includes(`Files`)&&(e.preventDefault(),Ge(!0))},[H]),At=(0,D.useCallback)(e=>{e.currentTarget.contains(e.relatedTarget)||Ge(!1)},[]),jt=(0,D.useCallback)(async e=>{e.preventDefault(),Ge(!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(!H){console.info(`[data-ui] op=drop-rejected token=${t} reason=no-write`),F(`Open a folder inside your account to upload`);return}let r=n.map(e=>e.webkitGetAsEntry?.()).filter(e=>!!e);M(!0),F(null),Ve(null);let i=performance.now();try{let e=await Fe(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}`),P({loaded:0,total:r.size});let{status:a,data:c}=await Dt(r,{relpath:i,token:t,onProgress:(e,t)=>P({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`:Ie(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}`),Ve(`Uploaded ${o}, skipped ${s.length}${s.length?`: ${s.join(`, `)}`:``}`),L(e=>e+1)}catch(e){F(e instanceof Error?e.message:String(e))}finally{M(!1),P(null)}},[H,Dt]),Mt=(0,D.useCallback)(async()=>{let t=Xe.trim();if(t){V(null);try{let n=await e(`/api/admin/files/folder`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:C===`.`?``:C,name:t})}),r=await n.json().catch(()=>({error:`HTTP ${n.status}`}));if(!n.ok)throw Error(r.error??`HTTP ${n.status}`);R(!1),Ze(``),L(e=>e+1)}catch(e){V(e instanceof Error?e.message:String(e))}}},[e,Xe,C]),Nt=(0,D.useCallback)(async()=>{if(!z)return;let t=Qe.trim();if(!t)return;V(null);let n=C===`.`?z:`${C}/${z}`;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}`);B(null),$e(``),X(`action`),L(e=>e+1)}catch(e){V(e instanceof Error?e.message:String(e))}},[e,Qe,z,C,X]);(0,D.useEffect)(()=>{if(!tt)return;let e=e=>{rt.current&&!rt.current.contains(e.target)&&nt(!1)},t=e=>{e.key===`Escape`&&nt(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[tt]),(0,D.useEffect)(()=>{if(!it)return;let e=e=>{at.current&&!at.current.contains(e.target)&&U(!1)},t=e=>{e.key===`Escape`&&U(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[it]);let $=(0,D.useCallback)(e=>k.slice(0,e+1).map(e=>e.name).join(`/`),[k]),Pt=k.length>=2,Ft=Pt?[{name:`.`,label:`data`},...k.slice(0,k.length-2).map((e,t)=>({name:$(t),label:e.displayName??e.name}))]:[];return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`data-toolbar`,children:[K?(0,O.jsxs)(`button`,{type:`button`,className:`data-select-cancel`,onClick:()=>X(`cancel`),"aria-label":`Cancel selection`,children:[(0,O.jsx)(t,{size:14}),` Cancel`]}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`data-search-input`,children:[o===``&&(0,O.jsx)(ue,{size:14}),(0,O.jsx)(`input`,{ref:l,type:`text`,value:o,onChange:e=>c(e.target.value),autoFocus:!0,autoComplete:`off`,spellCheck:!1}),g&&(0,O.jsx)(n,{size:14,className:`spin`}),o!==``&&(0,O.jsx)(`button`,{type:`button`,className:`data-search-inline-btn`,onClick:()=>{c(``),l.current?.focus()},title:`Clear search`,"aria-label":`Clear search`,children:(0,O.jsx)(t,{size:14})})]}),(0,O.jsxs)(`div`,{className:`data-toolbar-actions`,ref:at,children:[(0,O.jsx)(`button`,{type:`button`,className:`data-action-overflow`,onClick:()=>U(e=>!e),"aria-haspopup":`menu`,"aria-expanded":it,"aria-label":`File actions`,title:`File actions`,children:(0,O.jsx)(fe,{size:16})}),(0,O.jsxs)(`div`,{className:`data-action-group`,role:`group`,"aria-label":`File actions`,"data-open":it?`true`:void 0,children:[(0,O.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{lt(),U(!1)},disabled:j,title:`Refresh this folder`,"aria-label":`Refresh this folder`,children:[j?(0,O.jsx)(n,{size:16,className:`spin`}):(0,O.jsx)(ee,{size:16}),(0,O.jsx)(`span`,{className:`data-action-label`,children:`Refresh`})]}),(0,O.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{Et(),U(!1)},disabled:Me||!H,title:H?`Upload a file`:`Open a folder inside your account to upload`,"aria-label":`Upload a file`,children:[Me?N&&N.total>0?(0,O.jsxs)(`span`,{className:`data-upload-pct`,children:[Math.round(N.loaded/N.total*100),`%`]}):(0,O.jsx)(n,{size:16,className:`spin`}):(0,O.jsx)(be,{size:16}),(0,O.jsx)(`span`,{className:`data-action-label`,children:`Upload`})]}),(0,O.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{R(e=>!e),Ze(``),V(null),U(!1)},disabled:Me||!H,title:H?`New folder`:`Open a folder inside your account to create one`,"aria-label":`New folder`,children:[(0,O.jsx)(pe,{size:16}),(0,O.jsx)(`span`,{className:`data-action-label`,children:`New folder`})]}),(0,O.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{yt(T===`grid`?`list`:`grid`),U(!1)},title:T===`grid`?`List view`:`Grid view`,"aria-label":T===`grid`?`Switch to list view`:`Switch to grid view`,"aria-pressed":T===`grid`,children:[T===`grid`?(0,O.jsx)(_e,{size:16}):(0,O.jsx)(ge,{size:16}),(0,O.jsx)(`span`,{className:`data-action-label`,children:T===`grid`?`List view`:`Grid view`})]})]})]})]}),(0,O.jsxs)(`div`,{className:`data-breadcrumbs`,children:[C!==`.`&&(0,O.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost data-back-btn`,onClick:dt,title:`Up one level`,"aria-label":`Up one level`,children:(0,O.jsx)(de,{size:14})}),Pt?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`span`,{className:`data-crumb-wrap`,ref:rt,children:[(0,O.jsx)(`button`,{type:`button`,className:`data-crumb data-crumb-ellipsis`,onClick:()=>nt(e=>!e),"aria-haspopup":`menu`,"aria-expanded":tt,"aria-label":`Show parent folders`,title:`Show parent folders`,children:`…`}),tt&&(0,O.jsx)(`div`,{className:`data-crumb-menu`,role:`menu`,children:Ft.map(e=>(0,O.jsx)(`button`,{type:`button`,role:`menuitem`,className:`data-crumb-menu-item`,onClick:()=>G(e.name),title:e.label,children:e.label},e.name))})]}),[k.length-2,k.length-1].map(e=>{let t=k[e];return(0,O.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,O.jsx)(`span`,{className:`data-crumb-sep`,children:`/`}),(0,O.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>G($(e)),title:t.name,children:t.displayName??t.name})]},$(e))})]}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>G(`.`),children:`data`}),k.map((e,t)=>(0,O.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,O.jsx)(`span`,{className:`data-crumb-sep`,children:`/`}),(0,O.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>G($(t)),title:e.name,children:e.displayName??e.name})]},$(t)))]})]}),Ye&&(0,O.jsxs)(`div`,{className:`data-inline-form`,children:[(0,O.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`Folder name`,value:Xe,autoFocus:!0,onChange:e=>Ze(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Mt(),e.key===`Escape`&&R(!1)}}),(0,O.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:Mt,children:`Create`}),(0,O.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost`,onClick:()=>R(!1),children:`Cancel`})]}),z&&(0,O.jsxs)(`div`,{className:`data-inline-form`,children:[(0,O.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`New name`,value:Qe,autoFocus:!0,onChange:e=>$e(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Nt(),e.key===`Escape`&&B(null)}}),(0,O.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:Nt,children:`Rename`}),(0,O.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost`,onClick:()=>B(null),children:`Cancel`})]}),et&&(0,O.jsx)(`div`,{className:`data-error`,children:et}),(0,O.jsx)(`input`,{type:`file`,ref:I,hidden:!0,onChange:e=>{let t=e.target.files?.[0];t&&Ot(t)}})]}),(0,O.jsxs)(`div`,{className:`data-body`,"data-drag-active":He?`true`:void 0,onDragEnter:kt,onDragOver:kt,onDragLeave:At,onDrop:jt,children:[(v!==null||f!==null)&&(0,O.jsxs)(`section`,{className:`data-panel`,children:[v&&(0,O.jsxs)(`div`,{className:`data-error`,children:[`Search failed: `,v]}),ot.length>0&&(0,O.jsx)(`div`,{className:`data-chip-row`,role:`group`,"aria-label":`Filter by type`,children:ot.map(e=>{let t=e===W;return(0,O.jsx)(`button`,{type:`button`,className:`data-chip`,"data-active":t,onClick:()=>x(t?null:e),children:ze([e])??e},e)})}),f&&!g&&(0,O.jsxs)(`div`,{className:`data-results-meta`,children:[st.length,` of `,f.length,` result`,f.length===1?``:`s`]}),f&&!g&&!W&&te>0&&!S&&(0,O.jsxs)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>le(!0),children:[te,` low-confidence result`,te===1?``:`s`,` hidden — show all`]}),f&&!g&&!W&&S&&(0,O.jsx)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>le(!1),children:`Showing all results — hide low-confidence`}),f&&f.length===0&&!g&&(0,O.jsx)(`div`,{className:`data-empty-results`,children:`No matches. Try a different keyword.`}),st&&st.length>0&&(0,O.jsx)(`ul`,{className:`data-results`,children:st.map(e=>(0,O.jsx)(Re,{hit:e,mode:m,onDownload:ct,onLocate:ut},e.nodeId))})]}),(0,O.jsxs)(`section`,{className:`data-panel`,children:[N&&(0,O.jsxs)(`div`,{className:`data-upload-progress`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":N.total>0?Math.round(N.loaded/N.total*100):void 0,children:[(0,O.jsx)(`div`,{className:`data-upload-progress-track`,children:(0,O.jsx)(`div`,{className:`data-upload-progress-fill`,style:{width:`${N.total>0?Math.round(N.loaded/N.total*100):0}%`}})}),(0,O.jsxs)(`span`,{className:`data-upload-progress-label`,children:[`Uploading… `,N.total>0?`${Math.round(N.loaded/N.total*100)}%`:``]})]}),Le&&(0,O.jsxs)(`div`,{className:`data-error`,children:[`Upload failed: `,Le]}),Be&&(0,O.jsx)(`div`,{className:`data-status`,children:Be}),Ke&&(0,O.jsxs)(`div`,{className:`data-error`,children:[`Delete failed: `,Ke]}),Te&&(0,O.jsx)(`div`,{className:`data-error`,children:Te}),j&&(0,O.jsxs)(`div`,{className:`data-loading`,children:[(0,O.jsx)(n,{size:14,className:`spin`}),` Loading…`]}),!K&&!j&&w&&w.length>0&&(0,O.jsxs)(`div`,{className:`data-select-hint`,children:[(0,O.jsx)(ve,{size:13}),(0,O.jsx)(`span`,{children:`Press and hold a file to select, rename, or delete it.`})]}),!j&&w&&w.length===0&&!Te&&(0,O.jsx)(`div`,{className:`data-empty-results`,children:`Empty directory.`}),!j&&w&&w.length>0&&T===`grid`&&(0,O.jsx)(`ul`,{className:`data-grid`,children:w.map(e=>{let t=e.displayName??e.name,n=K&&q.has(e.name);if(e.kind===`directory`)return(0,O.jsx)(`li`,{className:`data-grid-cell`,"data-selected":n?`true`:void 0,children:(0,O.jsxs)(`button`,{type:`button`,className:`data-grid-tile`,onPointerDown:()=>_t(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}G(C===`.`?e.name:`${C}/${e.name}`)},children:[K&&(0,O.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,O.jsx)(me,{size:28,className:`data-grid-glyph`}),(0,O.jsx)(`span`,{className:`data-grid-label`,title:e.name,children:t})]})},e.name);if(e.kind===`file`){let i=Ee(e.name),a=C===`.`?e.name:`${C}/${e.name}`;return(0,O.jsx)(`li`,{className:`data-grid-cell`,"data-selected":n?`true`:void 0,children:(0,O.jsxs)(`button`,{type:`button`,className:`data-grid-tile${i?` data-grid-tile-image`:``}`,onPointerDown:()=>_t(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>i?bt(e):vt(e),title:K?void 0:i?`Preview ${t}`:`Download ${t}`,children:[K&&(0,O.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),i?(0,O.jsx)(`img`,{className:`data-grid-thumb`,src:ce(r,a),alt:t,loading:`lazy`,onError:()=>console.warn(`[data] op=thumb-error path=${a}`)}):(0,O.jsx)(ie,{size:28,className:`data-grid-glyph`}),(0,O.jsx)(`span`,{className:`data-grid-label`,title:e.name,children:t}),!i&&(0,O.jsx)(`span`,{className:`data-grid-sub`,children:Ue(e.sizeBytes)})]})},e.name)}return(0,O.jsx)(`li`,{className:`data-grid-cell`,children:(0,O.jsxs)(`div`,{className:`data-grid-tile data-entry-disabled`,children:[(0,O.jsx)(ie,{size:28,className:`data-grid-glyph`}),(0,O.jsx)(`span`,{className:`data-grid-label`,children:t}),(0,O.jsx)(`span`,{className:`data-grid-sub`,children:`special`})]})},e.name)})}),!j&&w&&w.length>0&&T===`list`&&(0,O.jsx)(`ul`,{className:`data-entries`,children:w.map(e=>{let t=e.displayName??e.name;if(e.kind===`directory`){let n=K&&q.has(e.name);return(0,O.jsx)(`li`,{className:`data-entry`,"data-selected":n?`true`:void 0,children:(0,O.jsxs)(`button`,{type:`button`,className:`data-entry-btn`,onPointerDown:()=>_t(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}G(C===`.`?e.name:`${C}/${e.name}`)},children:[K&&(0,O.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,O.jsx)(me,{size:14}),(0,O.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t})]})},e.name)}if(e.kind===`file`){let n=K&&q.has(e.name);return(0,O.jsx)(`li`,{className:`data-entry`,"data-selected":n?`true`:void 0,children:(0,O.jsxs)(`button`,{type:`button`,className:`data-entry-btn data-entry-file`,onPointerDown:()=>_t(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>vt(e),title:K?void 0:`Download ${t}`,children:[K&&(0,O.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,O.jsxs)(`span`,{className:`data-entry-text`,children:[(0,O.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t}),(0,O.jsxs)(`span`,{className:`data-entry-meta`,title:`Modified ${We(e.modifiedAt)}`,children:[Ue(e.sizeBytes),` · `,We(e.modifiedAt)]})]})]})},e.name)}return(0,O.jsx)(`li`,{className:`data-entry`,children:(0,O.jsx)(`div`,{className:`data-entry-btn data-entry-file data-entry-disabled`,children:(0,O.jsxs)(`span`,{className:`data-entry-text`,children:[(0,O.jsx)(`span`,{className:`data-entry-name`,children:t}),(0,O.jsx)(`span`,{className:`data-entry-meta`,children:`special`})]})})},e.name)})})]})]}),K&&(0,O.jsx)(`div`,{className:`data-select-bar`,role:`toolbar`,"aria-label":`Selection actions`,children:(0,O.jsxs)(`div`,{className:`data-select-bar-inner`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:Tt,disabled:!Y||q.size===0,title:Y?`Share selected files`:`Sharing is not supported on this device`,children:[(0,O.jsx)(s,{size:16}),` Share`]}),(0,O.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:Ct,disabled:q.size===0,children:[(0,O.jsx)(ne,{size:16}),` Download`]}),(0,O.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:()=>{let e=[...q][0];e&&(B(e),$e(e))},disabled:q.size!==1,children:[(0,O.jsx)(oe,{size:16}),` Rename`]}),(0,O.jsxs)(`button`,{type:`button`,className:`data-select-action data-select-delete`,onClick:wt,disabled:q.size===0,children:[(0,O.jsx)(a,{size:16}),` Delete`]})]})}),E&&(0,O.jsx)(`div`,{className:`chat-attachment-overlay`,role:`dialog`,"aria-label":E.alt,onClick:()=>Se(null),children:(0,O.jsx)(`img`,{className:`chat-attachment-overlay-image`,src:E.src,alt:E.alt})})]})}function Le({adminFetch:e,cacheKey:t,sessionRefetchNonce:n}){(0,D.useEffect)(()=>{console.info(`[data-ui] op=mount header=operator home=absent`)},[]);let r=(0,D.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]),a=(0,D.useCallback)(e=>{e===`chat`&&(window.location.href=`/`)},[]),[o,s]=(0,D.useState)([]),[l,u]=(0,D.useState)(`files`),{subAccounts:d,activeAccountId:f,switching:p,switchAccount:m}=c(t);return(0,D.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||s(t.conversations??[])}).catch(()=>{}),()=>{e=!0}},[t]),(0,O.jsxs)(`main`,{className:`data-main`,children:[(0,O.jsx)(i,{variant:`operator`,onNavigate:a,onOpenConversations:o.length>0?()=>u(`conversations`):void 0,onToggleSidebar:()=>{},sidebarOpen:!1,onLogout:r,onDisconnect:async()=>!0,disconnecting:!1,subAccounts:d,activeAccountId:f,switchingAccount:p,onSwitchAccount:m}),l===`conversations`?(0,O.jsx)(we,{conversations:o,sessionKey:t,onBack:()=>u(`files`)}):(0,O.jsx)(P,{adminFetch:e,cacheKey:t,sessionRefetchNonce:n})]})}function F({cacheKey:e}){let{adminFetch:t,cacheKey:n,sessionRefetchNonce:r}=u({initialCacheKey:e,surface:`data`});return(0,O.jsx)(`div`,{className:`data-page`,children:(0,O.jsx)(`main`,{className:`data-main`,children:(0,O.jsx)(P,{adminFetch:t,cacheKey:n,sessionRefetchNonce:r})})})}function Re({hit:e,mode:t,onDownload:n,onLocate:r}){let i=Be(e.properties),a=Ve(e.properties),o=ze(e.labels),s=He(e.properties),[c,l]=(0,D.useState)(!1),u=a&&a.length>280,d=c||!u?a:a?.slice(0,280)+`…`,f=t===`bm25`?`bm25 ${e.bm25Score.toFixed(2)}`:`vector ${e.vectorScore.toFixed(2)} · bm25 ${e.bm25Score.toFixed(2)} · combined ${e.score.toFixed(2)}`,p=e.properties.relativePath,m=typeof p==`string`&&p.length>0,h=m?p.lastIndexOf(`/`):-1,g=m?h===-1?`data`:p.slice(0,h):null;return(0,O.jsxs)(`li`,{className:`data-result`,children:[(0,O.jsxs)(`div`,{role:`button`,tabIndex:0,className:`data-result-open`,onClick:()=>n(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n(e))},"aria-label":`Download ${i??o??`file`}`,children:[o&&(0,O.jsx)(`div`,{className:`data-result-header`,children:(0,O.jsx)(`span`,{className:`data-result-labels`,children:o})}),i&&(0,O.jsx)(`div`,{className:`data-result-title`,children:i}),a&&(0,O.jsx)(`pre`,{className:`data-result-body`,children:d}),(0,O.jsxs)(`div`,{className:`data-result-scores`,children:[s&&(0,O.jsxs)(`span`,{className:`data-result-updated`,children:[`Updated `,We(s),` · `]}),f]})]}),m&&(0,O.jsxs)(`button`,{type:`button`,className:`data-result-locate`,onClick:()=>r(e),title:`Locate in ${g}`,"aria-label":`Locate in ${g}`,children:[(0,O.jsx)(me,{size:12}),g]}),u&&(0,O.jsx)(`button`,{type:`button`,className:`data-result-toggle`,onClick:()=>l(e=>!e),children:c?`Show less`:`Show more`})]})}function ze(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 Be(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 Ve(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 He(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 Ue(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 We(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{F as n,A as r,je as t};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-Ck5AOu5v.js";import{S as t,w as n,y as r}from"./useSubAccountSwitcher-DyjTbzQR.js";import"./audio-attachment-mime-BBW07eyG.js";import{y as i}from"./AdminShell-BfLQQ27Z.js";import{a,c as o,i as s,o as c,r as l,s as u}from"./page-JzxyFGle.js";import"./useCopyFeedback-CPEOUSGU.js";import"./file-download-B2B2DTar.js";var d=t(),f=e(n(),1),p=r();function m({gateState:e,setGateState:t,grantInfo:n,resolvedSlugRef:r}){let[a,o]=(0,f.useState)(``),[s,c]=(0,f.useState)(!1),[l,u]=(0,f.useState)(null);async function d(e){e.preventDefault();let n=a.trim().toLowerCase();if(!n){u(`Enter the email you were invited on.`);return}c(!0),u(null);try{let e=await fetch(`/api/access/request-magic-link`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({contactValue:n,agentSlug:r.current})});if(e.status===429){u((await e.json().catch(()=>({})))?.error||`Too many requests. Try again later.`);return}t(`request-sent`)}catch{u(`Could not reach the server. Check your connection and try again.`)}finally{c(!1)}}return(0,p.jsxs)(`div`,{className:`access-gate`,children:[e===`verifying`&&(0,p.jsxs)(`div`,{className:`access-gate-message`,children:[(0,p.jsx)(`h2`,{children:`Verifying your link…`}),(0,p.jsx)(`p`,{children:`This takes a moment.`})]}),e===`verify-failed`&&(0,p.jsxs)(`div`,{className:`access-gate-message`,children:[(0,p.jsx)(`h2`,{children:`That link did not work`}),(0,p.jsx)(`p`,{children:`It may have expired, already been used, or been for a different agent. You can request a fresh one below.`}),(0,p.jsx)(i,{onClick:()=>{t(`request-link`),u(null)},children:`Request a new link`})]}),e===`request-link`&&(0,p.jsxs)(`form`,{className:`access-gate-form`,onSubmit:d,children:[(0,p.jsx)(`h2`,{children:n?.displayName?`Welcome back, ${n.displayName}`:`Sign in`}),(0,p.jsx)(`p`,{children:`Enter the email you were invited on and we will send you a fresh link.`}),(0,p.jsx)(`label`,{htmlFor:`access-email`,children:`Email`}),(0,p.jsx)(`input`,{id:`access-email`,type:`email`,inputMode:`email`,autoComplete:`email`,value:a,onChange:e=>o(e.target.value),disabled:s}),l&&(0,p.jsx)(`p`,{className:`access-gate-error`,children:l}),(0,p.jsx)(i,{type:`submit`,disabled:s||!a.trim(),children:s?`Sending…`:`Send me a link`})]}),e===`request-sent`&&(0,p.jsxs)(`div`,{className:`access-gate-message`,children:[(0,p.jsx)(`h2`,{children:`Check your email`}),(0,p.jsx)(`p`,{children:`If that address is on the invite list, a fresh link is on the way. It expires in 15 minutes.`}),(0,p.jsx)(i,{onClick:()=>{t(`request-link`),o(``),u(null)},children:`Try a different email`})]})]})}function h(){let[e,t]=(0,f.useState)(null),[n,r]=(0,f.useState)(null),[i,l]=(0,f.useState)(`loading`),[d,p]=(0,f.useState)(``),[m,h]=(0,f.useState)(null),[g,_]=(0,f.useState)(null),[v,y]=(0,f.useState)(!1),[b,x]=(0,f.useState)(null),S=(0,f.useMemo)(()=>a(),[]),C=(0,f.useRef)(S||``),w=(0,f.useRef)(null),T=(0,f.useRef)(null),E=(0,f.useRef)(!1),D=(0,f.useRef)(null),[O,k]=(0,f.useState)(`request-link`),[A,j]=(0,f.useState)(null),M=(0,f.useRef)(null),N=(0,f.useRef)(null);(0,f.useEffect)(()=>{try{let e=sessionStorage.getItem(`maxy_session`);e&&(N.current=e)}catch{}},[]),(0,f.useEffect)(()=>{try{let e=c();e&&(sessionStorage.setItem(s,e),o&&console.info(`[public-webchat] op=seed-persisted len=${e.length} head=${e.slice(0,40)}`))}catch{}},[]);let P=(0,f.useCallback)(e=>{w.current=e,t(e);try{sessionStorage.setItem(`maxy_session`,e)}catch{}l(`chat`)},[]),F=(0,f.useCallback)(()=>{w.current=null;try{sessionStorage.removeItem(`maxy_session`)}catch{}t(null),l(`auth-required`),k(`request-link`)},[]),I=(0,f.useCallback)(async e=>{k(`verifying`);try{let t=C.current,n=await fetch(`/api/access/verify-token`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:e,agentSlug:t})});if(window.history.replaceState({},``,window.location.pathname),n.ok){let e=await n.json().catch(()=>({}));return e?.displayName&&j({displayName:e.displayName,contactValue:``,expiresAt:null,status:`active`}),!0}return k(`verify-failed`),!1}catch{return k(`verify-failed`),!1}},[]),L=(0,f.useCallback)(async()=>{if(w.current)return w.current;if(T.current)return T.current;let e=(async()=>{try{let e=N.current,n=await fetch(`/api/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({session_id:u(),...S?{agent:S}:{},...e?{session_key:e}:{}})});if(!n.ok){let e=await n.json().catch(()=>({error:``}));return o&&console.error(`[session] POST /api/session failed: ${n.status} ${n.statusText}`,e),n.status===404?r(e.error||`Agent not found`):n.status===503&&r(e.error||`Service unavailable`),null}let i=await n.json();if(i.auth_required){i.agent_id&&(C.current=i.agent_id),p(i.displayName||``),i.agentImage&&h(i.agentImage),i.agentImageShape&&_(i.agentImageShape),i.showAgentName&&y(i.showAgentName),i.branding&&x(i.branding),l(`auth-required`);let e=new URLSearchParams(window.location.search).get(`token`);return e?await I(e)&&window.location.reload():k(`request-link`),null}w.current=i.session_key,t(i.session_key),i.displayName&&p(i.displayName),i.agentImage&&h(i.agentImage),i.agentImageShape&&_(i.agentImageShape),i.showAgentName&&y(i.showAgentName),i.branding&&x(i.branding),l(`chat`),i.resumed&&i.messages&&(E.current=!0,D.current=i.messages);try{sessionStorage.setItem(`maxy_session`,i.session_key)}catch{}return i.session_key}catch(e){return o&&console.error(`[session] fetch /api/session threw:`,e),r(`Unable to connect. Please check your connection and try again.`),null}finally{T.current=null}})();return T.current=e,e},[S,I]);return{sessionId:e,cacheKeyRef:w,sessionError:n,pageState:i,setPageState:l,agentDisplayName:d,agentImage:m,agentImageShape:g,showAgentName:v,agentSlug:S,branding:b,resolvedSlugRef:C,ensureSession:L,startNewSession:(0,f.useCallback)(async()=>{w.current=null,T.current=null,N.current=null,E.current=!1,D.current=null,t(null),r(null);try{sessionStorage.removeItem(`maxy_session`)}catch{}await L()},[L]),enterChat:P,enterGate:F,resumedRef:E,resumeMessagesRef:D,gateState:O,setGateState:k,grantInfo:A,setGrantInfo:j,gateCacheKeyRef:M}}function g(){let{ensureSession:e,pageState:t,gateState:n,setGateState:r,grantInfo:i,resolvedSlugRef:a}=h();return(0,f.useEffect)(()=>{e()},[e]),t===`loading`?(0,p.jsx)(`div`,{className:`public-loading`,children:`Loading…`}):t===`auth-required`?(0,p.jsx)(m,{gateState:n,setGateState:r,grantInfo:i,resolvedSlugRef:a}):(0,p.jsx)(`div`,{className:`public-shell`,children:(0,p.jsx)(l,{cacheKey:``,variant:`public`})})}(0,d.createRoot)(document.getElementById(`root`)).render((0,p.jsx)(g,{}));
1
+ import{o as e}from"./chunk-Ck5AOu5v.js";import{S as t,w as n,y as r}from"./useSubAccountSwitcher-DyjTbzQR.js";import"./audio-attachment-mime-CwYrV1pg.js";import{y as i}from"./AdminShell-BfLQQ27Z.js";import{a,c as o,i as s,o as c,r as l,s as u}from"./page-Ci27UrJz.js";import"./useCopyFeedback-CPEOUSGU.js";import"./file-download-B2B2DTar.js";var d=t(),f=e(n(),1),p=r();function m({gateState:e,setGateState:t,grantInfo:n,resolvedSlugRef:r}){let[a,o]=(0,f.useState)(``),[s,c]=(0,f.useState)(!1),[l,u]=(0,f.useState)(null);async function d(e){e.preventDefault();let n=a.trim().toLowerCase();if(!n){u(`Enter the email you were invited on.`);return}c(!0),u(null);try{let e=await fetch(`/api/access/request-magic-link`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({contactValue:n,agentSlug:r.current})});if(e.status===429){u((await e.json().catch(()=>({})))?.error||`Too many requests. Try again later.`);return}t(`request-sent`)}catch{u(`Could not reach the server. Check your connection and try again.`)}finally{c(!1)}}return(0,p.jsxs)(`div`,{className:`access-gate`,children:[e===`verifying`&&(0,p.jsxs)(`div`,{className:`access-gate-message`,children:[(0,p.jsx)(`h2`,{children:`Verifying your link…`}),(0,p.jsx)(`p`,{children:`This takes a moment.`})]}),e===`verify-failed`&&(0,p.jsxs)(`div`,{className:`access-gate-message`,children:[(0,p.jsx)(`h2`,{children:`That link did not work`}),(0,p.jsx)(`p`,{children:`It may have expired, already been used, or been for a different agent. You can request a fresh one below.`}),(0,p.jsx)(i,{onClick:()=>{t(`request-link`),u(null)},children:`Request a new link`})]}),e===`request-link`&&(0,p.jsxs)(`form`,{className:`access-gate-form`,onSubmit:d,children:[(0,p.jsx)(`h2`,{children:n?.displayName?`Welcome back, ${n.displayName}`:`Sign in`}),(0,p.jsx)(`p`,{children:`Enter the email you were invited on and we will send you a fresh link.`}),(0,p.jsx)(`label`,{htmlFor:`access-email`,children:`Email`}),(0,p.jsx)(`input`,{id:`access-email`,type:`email`,inputMode:`email`,autoComplete:`email`,value:a,onChange:e=>o(e.target.value),disabled:s}),l&&(0,p.jsx)(`p`,{className:`access-gate-error`,children:l}),(0,p.jsx)(i,{type:`submit`,disabled:s||!a.trim(),children:s?`Sending…`:`Send me a link`})]}),e===`request-sent`&&(0,p.jsxs)(`div`,{className:`access-gate-message`,children:[(0,p.jsx)(`h2`,{children:`Check your email`}),(0,p.jsx)(`p`,{children:`If that address is on the invite list, a fresh link is on the way. It expires in 15 minutes.`}),(0,p.jsx)(i,{onClick:()=>{t(`request-link`),o(``),u(null)},children:`Try a different email`})]})]})}function h(){let[e,t]=(0,f.useState)(null),[n,r]=(0,f.useState)(null),[i,l]=(0,f.useState)(`loading`),[d,p]=(0,f.useState)(``),[m,h]=(0,f.useState)(null),[g,_]=(0,f.useState)(null),[v,y]=(0,f.useState)(!1),[b,x]=(0,f.useState)(null),S=(0,f.useMemo)(()=>a(),[]),C=(0,f.useRef)(S||``),w=(0,f.useRef)(null),T=(0,f.useRef)(null),E=(0,f.useRef)(!1),D=(0,f.useRef)(null),[O,k]=(0,f.useState)(`request-link`),[A,j]=(0,f.useState)(null),M=(0,f.useRef)(null),N=(0,f.useRef)(null);(0,f.useEffect)(()=>{try{let e=sessionStorage.getItem(`maxy_session`);e&&(N.current=e)}catch{}},[]),(0,f.useEffect)(()=>{try{let e=c();e&&(sessionStorage.setItem(s,e),o&&console.info(`[public-webchat] op=seed-persisted len=${e.length} head=${e.slice(0,40)}`))}catch{}},[]);let P=(0,f.useCallback)(e=>{w.current=e,t(e);try{sessionStorage.setItem(`maxy_session`,e)}catch{}l(`chat`)},[]),F=(0,f.useCallback)(()=>{w.current=null;try{sessionStorage.removeItem(`maxy_session`)}catch{}t(null),l(`auth-required`),k(`request-link`)},[]),I=(0,f.useCallback)(async e=>{k(`verifying`);try{let t=C.current,n=await fetch(`/api/access/verify-token`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:e,agentSlug:t})});if(window.history.replaceState({},``,window.location.pathname),n.ok){let e=await n.json().catch(()=>({}));return e?.displayName&&j({displayName:e.displayName,contactValue:``,expiresAt:null,status:`active`}),!0}return k(`verify-failed`),!1}catch{return k(`verify-failed`),!1}},[]),L=(0,f.useCallback)(async()=>{if(w.current)return w.current;if(T.current)return T.current;let e=(async()=>{try{let e=N.current,n=await fetch(`/api/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({session_id:u(),...S?{agent:S}:{},...e?{session_key:e}:{}})});if(!n.ok){let e=await n.json().catch(()=>({error:``}));return o&&console.error(`[session] POST /api/session failed: ${n.status} ${n.statusText}`,e),n.status===404?r(e.error||`Agent not found`):n.status===503&&r(e.error||`Service unavailable`),null}let i=await n.json();if(i.auth_required){i.agent_id&&(C.current=i.agent_id),p(i.displayName||``),i.agentImage&&h(i.agentImage),i.agentImageShape&&_(i.agentImageShape),i.showAgentName&&y(i.showAgentName),i.branding&&x(i.branding),l(`auth-required`);let e=new URLSearchParams(window.location.search).get(`token`);return e?await I(e)&&window.location.reload():k(`request-link`),null}w.current=i.session_key,t(i.session_key),i.displayName&&p(i.displayName),i.agentImage&&h(i.agentImage),i.agentImageShape&&_(i.agentImageShape),i.showAgentName&&y(i.showAgentName),i.branding&&x(i.branding),l(`chat`),i.resumed&&i.messages&&(E.current=!0,D.current=i.messages);try{sessionStorage.setItem(`maxy_session`,i.session_key)}catch{}return i.session_key}catch(e){return o&&console.error(`[session] fetch /api/session threw:`,e),r(`Unable to connect. Please check your connection and try again.`),null}finally{T.current=null}})();return T.current=e,e},[S,I]);return{sessionId:e,cacheKeyRef:w,sessionError:n,pageState:i,setPageState:l,agentDisplayName:d,agentImage:m,agentImageShape:g,showAgentName:v,agentSlug:S,branding:b,resolvedSlugRef:C,ensureSession:L,startNewSession:(0,f.useCallback)(async()=>{w.current=null,T.current=null,N.current=null,E.current=!1,D.current=null,t(null),r(null);try{sessionStorage.removeItem(`maxy_session`)}catch{}await L()},[L]),enterChat:P,enterGate:F,resumedRef:E,resumeMessagesRef:D,gateState:O,setGateState:k,grantInfo:A,setGrantInfo:j,gateCacheKeyRef:M}}function g(){let{ensureSession:e,pageState:t,gateState:n,setGateState:r,grantInfo:i,resolvedSlugRef:a}=h();return(0,f.useEffect)(()=>{e()},[e]),t===`loading`?(0,p.jsx)(`div`,{className:`public-loading`,children:`Loading…`}):t===`auth-required`?(0,p.jsx)(m,{gateState:n,setGateState:r,grantInfo:i,resolvedSlugRef:a}):(0,p.jsx)(`div`,{className:`public-shell`,children:(0,p.jsx)(l,{cacheKey:``,variant:`public`})})}(0,d.createRoot)(document.getElementById(`root`)).render((0,p.jsx)(g,{}));
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Chat — Maxy</title>
7
7
  <link rel="icon" href="/favicon.ico">
8
- <script type="module" crossorigin src="/assets/chat-B9Qjt7C9.js"></script>
8
+ <script type="module" crossorigin src="/assets/chat-rxbGimwf.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/chunk-Ck5AOu5v.js">
10
10
  <link rel="modulepreload" crossorigin href="/assets/useSubAccountSwitcher-DyjTbzQR.js">
11
11
  <link rel="modulepreload" crossorigin href="/assets/file-download-B2B2DTar.js">
@@ -13,11 +13,11 @@
13
13
  <link rel="modulepreload" crossorigin href="/assets/AdminShell-BfLQQ27Z.js">
14
14
  <link rel="modulepreload" crossorigin href="/assets/preload-helper-ClBMtM1g.js">
15
15
  <link rel="modulepreload" crossorigin href="/assets/maximize-2-DKx6OBKv.js">
16
- <link rel="modulepreload" crossorigin href="/assets/audio-attachment-mime-BBW07eyG.js">
16
+ <link rel="modulepreload" crossorigin href="/assets/audio-attachment-mime-CwYrV1pg.js">
17
17
  <link rel="modulepreload" crossorigin href="/assets/useCopyFeedback-CPEOUSGU.js">
18
18
  <link rel="modulepreload" crossorigin href="/assets/chevron-left-CLPxfjDV.js">
19
19
  <link rel="modulepreload" crossorigin href="/assets/play-DHttF4fl.js">
20
- <link rel="modulepreload" crossorigin href="/assets/page-JzxyFGle.js">
20
+ <link rel="modulepreload" crossorigin href="/assets/page-Ci27UrJz.js">
21
21
  <link rel="stylesheet" crossorigin href="/assets/useSubAccountSwitcher-CdS1CorH.css">
22
22
  <link rel="stylesheet" href="/brand-defaults.css">
23
23
  </head>
@@ -5,16 +5,16 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Data — Maxy</title>
7
7
  <link rel="icon" href="/favicon.ico">
8
- <script type="module" crossorigin src="/assets/data-BKE6Sa-g.js"></script>
8
+ <script type="module" crossorigin src="/assets/data-D0YFYP1i.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/chunk-Ck5AOu5v.js">
10
10
  <link rel="modulepreload" crossorigin href="/assets/useSubAccountSwitcher-DyjTbzQR.js">
11
11
  <link rel="modulepreload" crossorigin href="/assets/graph-labels-DxqDdO7G.js">
12
12
  <link rel="modulepreload" crossorigin href="/assets/preload-helper-ClBMtM1g.js">
13
13
  <link rel="modulepreload" crossorigin href="/assets/file-download-B2B2DTar.js">
14
14
  <link rel="modulepreload" crossorigin href="/assets/maximize-2-DKx6OBKv.js">
15
- <link rel="modulepreload" crossorigin href="/assets/audio-attachment-mime-BBW07eyG.js">
15
+ <link rel="modulepreload" crossorigin href="/assets/audio-attachment-mime-CwYrV1pg.js">
16
16
  <link rel="modulepreload" crossorigin href="/assets/chevron-left-CLPxfjDV.js">
17
- <link rel="modulepreload" crossorigin href="/assets/page-CbI1wtef.js">
17
+ <link rel="modulepreload" crossorigin href="/assets/page-D1EAVC_9.js">
18
18
  <link rel="stylesheet" crossorigin href="/assets/useSubAccountSwitcher-CdS1CorH.css">
19
19
  <link rel="stylesheet" href="/brand-defaults.css">
20
20
  </head>
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Maxy</title>
7
7
  <link rel="icon" href="/favicon.ico">
8
- <script type="module" crossorigin src="/assets/admin-SaF1F4e-.js"></script>
8
+ <script type="module" crossorigin src="/assets/admin-Co3hOTNp.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/chunk-Ck5AOu5v.js">
10
10
  <link rel="modulepreload" crossorigin href="/assets/useSubAccountSwitcher-DyjTbzQR.js">
11
11
  <link rel="modulepreload" crossorigin href="/assets/graph-labels-DxqDdO7G.js">
@@ -14,11 +14,11 @@
14
14
  <link rel="modulepreload" crossorigin href="/assets/AdminShell-BfLQQ27Z.js">
15
15
  <link rel="modulepreload" crossorigin href="/assets/preload-helper-ClBMtM1g.js">
16
16
  <link rel="modulepreload" crossorigin href="/assets/maximize-2-DKx6OBKv.js">
17
- <link rel="modulepreload" crossorigin href="/assets/audio-attachment-mime-BBW07eyG.js">
17
+ <link rel="modulepreload" crossorigin href="/assets/audio-attachment-mime-CwYrV1pg.js">
18
18
  <link rel="modulepreload" crossorigin href="/assets/Checkbox-BC0c_gbn.js">
19
- <link rel="modulepreload" crossorigin href="/assets/AdminLoginScreens-C4AZT7cQ.js">
19
+ <link rel="modulepreload" crossorigin href="/assets/AdminLoginScreens-CcW3pAAZ.js">
20
20
  <link rel="modulepreload" crossorigin href="/assets/chevron-left-CLPxfjDV.js">
21
- <link rel="modulepreload" crossorigin href="/assets/page-CbI1wtef.js">
21
+ <link rel="modulepreload" crossorigin href="/assets/page-D1EAVC_9.js">
22
22
  <link rel="stylesheet" crossorigin href="/assets/useSubAccountSwitcher-CdS1CorH.css">
23
23
  <link rel="stylesheet" crossorigin href="/assets/AdminLoginScreens-CWMpccrR.css">
24
24
  <link rel="stylesheet" href="/brand-defaults.css">
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Operator — Maxy</title>
7
7
  <link rel="icon" href="/favicon.ico">
8
- <script type="module" crossorigin src="/assets/operator-CTJjI8te.js"></script>
8
+ <script type="module" crossorigin src="/assets/operator-Djv3MdcL.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/chunk-Ck5AOu5v.js">
10
10
  <link rel="modulepreload" crossorigin href="/assets/useSubAccountSwitcher-DyjTbzQR.js">
11
11
  <link rel="modulepreload" crossorigin href="/assets/file-download-B2B2DTar.js">
@@ -13,13 +13,13 @@
13
13
  <link rel="modulepreload" crossorigin href="/assets/AdminShell-BfLQQ27Z.js">
14
14
  <link rel="modulepreload" crossorigin href="/assets/preload-helper-ClBMtM1g.js">
15
15
  <link rel="modulepreload" crossorigin href="/assets/maximize-2-DKx6OBKv.js">
16
- <link rel="modulepreload" crossorigin href="/assets/audio-attachment-mime-BBW07eyG.js">
16
+ <link rel="modulepreload" crossorigin href="/assets/audio-attachment-mime-CwYrV1pg.js">
17
17
  <link rel="modulepreload" crossorigin href="/assets/Checkbox-BC0c_gbn.js">
18
- <link rel="modulepreload" crossorigin href="/assets/AdminLoginScreens-C4AZT7cQ.js">
18
+ <link rel="modulepreload" crossorigin href="/assets/AdminLoginScreens-CcW3pAAZ.js">
19
19
  <link rel="modulepreload" crossorigin href="/assets/useCopyFeedback-CPEOUSGU.js">
20
20
  <link rel="modulepreload" crossorigin href="/assets/chevron-left-CLPxfjDV.js">
21
21
  <link rel="modulepreload" crossorigin href="/assets/play-DHttF4fl.js">
22
- <link rel="modulepreload" crossorigin href="/assets/page-JzxyFGle.js">
22
+ <link rel="modulepreload" crossorigin href="/assets/page-Ci27UrJz.js">
23
23
  <link rel="stylesheet" crossorigin href="/assets/useSubAccountSwitcher-CdS1CorH.css">
24
24
  <link rel="stylesheet" crossorigin href="/assets/AdminLoginScreens-CWMpccrR.css">
25
25
  <link rel="stylesheet" href="/brand-defaults.css">
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Maxy</title>
7
7
  <link rel="icon" href="/favicon.ico">
8
- <script type="module" crossorigin src="/assets/public-DzeW3_eM.js"></script>
8
+ <script type="module" crossorigin src="/assets/public-C6k-fPfx.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/chunk-Ck5AOu5v.js">
10
10
  <link rel="modulepreload" crossorigin href="/assets/useSubAccountSwitcher-DyjTbzQR.js">
11
11
  <link rel="modulepreload" crossorigin href="/assets/file-download-B2B2DTar.js">
@@ -13,11 +13,11 @@
13
13
  <link rel="modulepreload" crossorigin href="/assets/AdminShell-BfLQQ27Z.js">
14
14
  <link rel="modulepreload" crossorigin href="/assets/preload-helper-ClBMtM1g.js">
15
15
  <link rel="modulepreload" crossorigin href="/assets/maximize-2-DKx6OBKv.js">
16
- <link rel="modulepreload" crossorigin href="/assets/audio-attachment-mime-BBW07eyG.js">
16
+ <link rel="modulepreload" crossorigin href="/assets/audio-attachment-mime-CwYrV1pg.js">
17
17
  <link rel="modulepreload" crossorigin href="/assets/useCopyFeedback-CPEOUSGU.js">
18
18
  <link rel="modulepreload" crossorigin href="/assets/chevron-left-CLPxfjDV.js">
19
19
  <link rel="modulepreload" crossorigin href="/assets/play-DHttF4fl.js">
20
- <link rel="modulepreload" crossorigin href="/assets/page-JzxyFGle.js">
20
+ <link rel="modulepreload" crossorigin href="/assets/page-Ci27UrJz.js">
21
21
  <link rel="stylesheet" crossorigin href="/assets/useSubAccountSwitcher-CdS1CorH.css">
22
22
  <link rel="stylesheet" href="/brand-defaults.css">
23
23
  </head>