@rubytech/create-maxy-code 0.1.85 → 0.1.87

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 (102) hide show
  1. package/package.json +1 -1
  2. package/payload/platform/config/brand.json +1 -1
  3. package/payload/platform/plugins/admin/hooks/__tests__/pre-tool-use-memory-write-passthrough.test.sh +118 -0
  4. package/payload/platform/plugins/admin/hooks/pre-tool-use.sh +0 -102
  5. package/payload/platform/plugins/cloudflare/PLUGIN.md +1 -1
  6. package/payload/platform/plugins/cloudflare/scripts/setup-tunnel.sh +33 -217
  7. package/payload/platform/plugins/cloudflare/skills/setup-tunnel/SKILL.md +9 -7
  8. package/payload/platform/plugins/docs/references/admin-session.md +1 -1
  9. package/payload/platform/plugins/docs/references/cloudflare.md +2 -2
  10. package/payload/platform/plugins/docs/references/deployment.md +1 -1
  11. package/payload/platform/plugins/docs/references/platform.md +1 -1
  12. package/payload/platform/plugins/docs/references/troubleshooting.md +1 -1
  13. package/payload/platform/plugins/memory/PLUGIN.md +2 -2
  14. package/payload/platform/services/claude-session-manager/dist/config.d.ts.map +1 -1
  15. package/payload/platform/services/claude-session-manager/dist/config.js +1 -8
  16. package/payload/platform/services/claude-session-manager/dist/config.js.map +1 -1
  17. package/payload/platform/services/claude-session-manager/dist/pty-spawner.d.ts.map +1 -1
  18. package/payload/platform/services/claude-session-manager/dist/pty-spawner.js +15 -15
  19. package/payload/platform/services/claude-session-manager/dist/pty-spawner.js.map +1 -1
  20. package/payload/platform/templates/agents/admin/IDENTITY.md +1 -1
  21. package/payload/server/public/assets/{brand-C_iHnsbT.css → ChatInput-CktRrxx1.css} +1 -1
  22. package/payload/server/public/assets/{brand-HqTMr1bV.js → ChatInput-D62NmYfJ.js} +5 -1
  23. package/payload/server/public/assets/Checkbox-D2XqbR29.js +1 -0
  24. package/payload/server/public/assets/admin-BK1F2LMD.js +217 -0
  25. package/payload/server/public/assets/{architectureDiagram-Q4EWVU46-DQMCKDU2.js → architectureDiagram-Q4EWVU46-9F6y6ESU.js} +1 -1
  26. package/payload/server/public/assets/{blockDiagram-DXYQGD6D-CqJNtiQY.js → blockDiagram-DXYQGD6D-LjGbzg0M.js} +1 -1
  27. package/payload/server/public/assets/{c4Diagram-AHTNJAMY-BVAa1YL3.js → c4Diagram-AHTNJAMY-Bxpn5T5R.js} +1 -1
  28. package/payload/server/public/assets/channel-CY_QocHj.js +1 -0
  29. package/payload/server/public/assets/{chunk-336JU56O-XIsdqKyD.js → chunk-336JU56O-Cc2kxWVN.js} +2 -2
  30. package/payload/server/public/assets/{chunk-426QAEUC-Dw4mcMYK.js → chunk-426QAEUC-DRzEhHvW.js} +1 -1
  31. package/payload/server/public/assets/{chunk-4TB4RGXK-BvrlG2FS.js → chunk-4TB4RGXK-C8zRzH9g.js} +1 -1
  32. package/payload/server/public/assets/{chunk-5FUZZQ4R-3-UZ9191.js → chunk-5FUZZQ4R-s8V7nzOd.js} +1 -1
  33. package/payload/server/public/assets/{chunk-5PVQY5BW-DOeY60Lp.js → chunk-5PVQY5BW-KNShBlaM.js} +1 -1
  34. package/payload/server/public/assets/{chunk-EDXVE4YY-BSbGSOxN.js → chunk-EDXVE4YY-C6GvGxn3.js} +1 -1
  35. package/payload/server/public/assets/{chunk-ENJZ2VHE-CszgAcWZ.js → chunk-ENJZ2VHE-XvXhU8ZS.js} +1 -1
  36. package/payload/server/public/assets/{chunk-ICPOFSXX-rgw1I6pt.js → chunk-ICPOFSXX-OSDYUb0H.js} +1 -1
  37. package/payload/server/public/assets/{chunk-OYMX7WX6-DL4v2Nx4.js → chunk-OYMX7WX6-km_4dA-E.js} +1 -1
  38. package/payload/server/public/assets/{chunk-U2HBQHQK-CwMCwyfq.js → chunk-U2HBQHQK-BGHqDvzJ.js} +1 -1
  39. package/payload/server/public/assets/{chunk-X2U36JSP-CvKfDVvq.js → chunk-X2U36JSP-BKKSYdFO.js} +1 -1
  40. package/payload/server/public/assets/{chunk-YZCP3GAM-D7vju2_U.js → chunk-YZCP3GAM-DT_yhfJM.js} +1 -1
  41. package/payload/server/public/assets/{chunk-ZZ45TVLE-sANOwJKn.js → chunk-ZZ45TVLE-CP2JuBPA.js} +1 -1
  42. package/payload/server/public/assets/classDiagram-6PBFFD2Q-BtwH3Rsu.js +1 -0
  43. package/payload/server/public/assets/classDiagram-v2-HSJHXN6E-tCRstAZ-.js +1 -0
  44. package/payload/server/public/assets/clone-Bc-lmwcQ.js +1 -0
  45. package/payload/server/public/assets/{dagre-CplqWwSs.js → dagre-CUhFHAG8.js} +1 -1
  46. package/payload/server/public/assets/{dagre-KV5264BT-DNbl5g9o.js → dagre-KV5264BT-Dk7osC4w.js} +1 -1
  47. package/payload/server/public/assets/data-B3WPMQdR.js +1 -0
  48. package/payload/server/public/assets/{diagram-5BDNPKRD-BCdMaYnY.js → diagram-5BDNPKRD-CdOEJbjg.js} +1 -1
  49. package/payload/server/public/assets/{diagram-G4DWMVQ6-8XhDBU0o.js → diagram-G4DWMVQ6-Dyx0MQk6.js} +1 -1
  50. package/payload/server/public/assets/{diagram-MMDJMWI5-M-RMQgtx.js → diagram-MMDJMWI5-Dw6sxLh8.js} +1 -1
  51. package/payload/server/public/assets/{diagram-TYMM5635-BBHPIBvQ.js → diagram-TYMM5635-Bm3GRH-1.js} +1 -1
  52. package/payload/server/public/assets/{erDiagram-SMLLAGMA-D6jOL-9s.js → erDiagram-SMLLAGMA-CAJ3Z9uD.js} +1 -1
  53. package/payload/server/public/assets/{flowDiagram-DWJPFMVM-CiyTYRlU.js → flowDiagram-DWJPFMVM-NrVUcQ2d.js} +1 -1
  54. package/payload/server/public/assets/{ganttDiagram-T4ZO3ILL-DHSIpjfS.js → ganttDiagram-T4ZO3ILL-28YyrNXj.js} +1 -1
  55. package/payload/server/public/assets/{gitGraphDiagram-UUTBAWPF-CEneVF3o.js → gitGraphDiagram-UUTBAWPF-D73FSDE8.js} +1 -1
  56. package/payload/server/public/assets/graph-B6c5nlBL.js +1 -0
  57. package/payload/server/public/assets/graph-labels-BMqBNCYc.js +1 -0
  58. package/payload/server/public/assets/{graphlib-CuF7rLfE.js → graphlib-n_bUAhub.js} +1 -1
  59. package/payload/server/public/assets/{infoDiagram-42DDH7IO-wGl-JoP7.js → infoDiagram-42DDH7IO-rFap2NoE.js} +1 -1
  60. package/payload/server/public/assets/{ishikawaDiagram-UXIWVN3A-B3TxFNi_.js → ishikawaDiagram-UXIWVN3A-KKAj626l.js} +1 -1
  61. package/payload/server/public/assets/{journeyDiagram-VCZTEJTY-B5n8No7p.js → journeyDiagram-VCZTEJTY-Do6hVThi.js} +1 -1
  62. package/payload/server/public/assets/{kanban-definition-6JOO6SKY-ByGF39_h.js → kanban-definition-6JOO6SKY-C38qlZwy.js} +1 -1
  63. package/payload/server/public/assets/lib-D-jcbjd4.js +29 -0
  64. package/payload/server/public/assets/{line-Br0FyyFW.js → line-DsDSEpXU.js} +1 -1
  65. package/payload/server/public/assets/{mermaid-parser.core-BUcTjodx.js → mermaid-parser.core-Cvzc7ePL.js} +1 -1
  66. package/payload/server/public/assets/{mermaid.core-BKzdtZgG.js → mermaid.core-BSZExB1C.js} +3 -3
  67. package/payload/server/public/assets/{mindmap-definition-QFDTVHPH-CobGMF9l.js → mindmap-definition-QFDTVHPH-CrS3b5u5.js} +1 -1
  68. package/payload/server/public/assets/page-C438DjPa.js +1 -0
  69. package/payload/server/public/assets/{page-Ba0BAfpu.js → page-fdrpcuv5.js} +2 -2
  70. package/payload/server/public/assets/{pieDiagram-DEJITSTG-DXFmGcNR.js → pieDiagram-DEJITSTG-Dk-6uOEj.js} +1 -1
  71. package/payload/server/public/assets/public-BK3eOHJs.js +8 -0
  72. package/payload/server/public/assets/{quadrantDiagram-34T5L4WZ-BnChStlO.js → quadrantDiagram-34T5L4WZ-CEMK5xQ0.js} +1 -1
  73. package/payload/server/public/assets/{requirementDiagram-MS252O5E-DdiBKsyO.js → requirementDiagram-MS252O5E-vTyRxQOY.js} +1 -1
  74. package/payload/server/public/assets/{sankeyDiagram-XADWPNL6-16-np_56.js → sankeyDiagram-XADWPNL6-s2z8dMpM.js} +1 -1
  75. package/payload/server/public/assets/{sequenceDiagram-FGHM5R23-D67SCRpA.js → sequenceDiagram-FGHM5R23-locoOgnm.js} +1 -1
  76. package/payload/server/public/assets/{stateDiagram-FHFEXIEX-CvNJX0YC.js → stateDiagram-FHFEXIEX-m1d4aD0M.js} +1 -1
  77. package/payload/server/public/assets/stateDiagram-v2-QKLJ7IA2-B7eWHz7x.js +1 -0
  78. package/payload/server/public/assets/{timeline-definition-GMOUNBTQ-BJE5YoBa.js → timeline-definition-GMOUNBTQ-HraDHuOp.js} +1 -1
  79. package/payload/server/public/assets/{vennDiagram-DHZGUBPP-DF17ddXt.js → vennDiagram-DHZGUBPP-DkyF2rFo.js} +1 -1
  80. package/payload/server/public/assets/{wardleyDiagram-NUSXRM2D-xn_2XUOo.js → wardleyDiagram-NUSXRM2D-BGScmzP0.js} +1 -1
  81. package/payload/server/public/assets/{xychartDiagram-5P7HB3ND-DVF8zf3f.js → xychartDiagram-5P7HB3ND-CPJ1JLj2.js} +1 -1
  82. package/payload/server/public/brand-constants.json +1 -1
  83. package/payload/server/public/data.html +5 -5
  84. package/payload/server/public/graph.html +6 -6
  85. package/payload/server/public/index.html +8 -8
  86. package/payload/server/public/public.html +5 -5
  87. package/payload/server/server.js +2 -2
  88. package/payload/platform/plugins/admin/hooks/__tests__/pre-tool-use-memory-write-revoke.test.sh +0 -248
  89. package/payload/platform/plugins/cloudflare/scripts/__tests__/setup-tunnel-display-precedence.test.sh +0 -194
  90. package/payload/server/public/assets/Checkbox-B34vplI7.js +0 -1
  91. package/payload/server/public/assets/admin-BkTlPuP0.js +0 -217
  92. package/payload/server/public/assets/channel-CZG4mVkt.js +0 -1
  93. package/payload/server/public/assets/classDiagram-6PBFFD2Q-BoqQ3pHg.js +0 -1
  94. package/payload/server/public/assets/classDiagram-v2-HSJHXN6E-FoKuBK7n.js +0 -1
  95. package/payload/server/public/assets/clone-CT8AM-bU.js +0 -1
  96. package/payload/server/public/assets/data-BIDM6J5V.js +0 -1
  97. package/payload/server/public/assets/device-url-actions-nxh9PmIH.js +0 -33
  98. package/payload/server/public/assets/graph-Cm-iWFqy.js +0 -1
  99. package/payload/server/public/assets/graph-labels-CFX6KkCz.js +0 -1
  100. package/payload/server/public/assets/page-B5NRnW0t.js +0 -1
  101. package/payload/server/public/assets/public-DWfBzf83.js +0 -8
  102. package/payload/server/public/assets/stateDiagram-v2-QKLJ7IA2-CFw2U4iL.js +0 -1
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-DD-I1_y5.js";import{a as t,f as n,h as r,o as i}from"./brand-HqTMr1bV.js";import{a,g as o,l as s,o as c,p as l,t as u,y as d}from"./graph-labels-CFX6KkCz.js";var f=n(`circle-arrow-up`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]]),p=n(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),m=n(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),h=n(`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`}]]),g=n(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]);function _(e){let t=new Set,n=[];for(let r of e)for(let e of r.labels)e&&(t.has(e)||u.has(e)&&(t.add(e),n.push(e)));return n}var v=80;function y(e){let t=b(e.properties)??e.labels[0]??``,n=t.length>v?t.slice(0,v):t;return`/graph?${new URLSearchParams({nodeId:e.nodeId,label:n}).toString()}`}function b(e){for(let t of[`title`,`name`,`summary`,`headline`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}var x=e(r(),1),S=t();function C(){let[e,t]=(0,x.useState)(null),[n,r]=(0,x.useState)(!1),[i,c]=(0,x.useState)(void 0),[l,u]=(0,x.useState)(null),[f,p]=(0,x.useState)(void 0),[m,h]=(0,x.useState)(null),[g,_]=(0,x.useState)(null);(0,x.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!n){t(null),r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&c(e.businessName),e.conversationId!==void 0&&u(e.conversationId??null),_(e.role??null),p(e.userName===void 0?null:e.userName),h(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let v=(0,x.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]);return n?e?(0,S.jsxs)(a,{cacheKey:e,businessName:i,conversationId:l,onLogout:v,userName:f,userAvatar:m,role:g,children:[(0,S.jsx)(s,{}),(0,S.jsxs)(`div`,{className:`data-page`,children:[(0,S.jsx)(`header`,{className:`data-header`,children:(0,S.jsxs)(`h1`,{className:`data-title`,children:[(0,S.jsx)(d,{size:18}),` Data`]})}),(0,S.jsx)(w,{cacheKey:e})]})]}):(0,S.jsxs)(`div`,{className:`data-page`,children:[(0,S.jsx)(`header`,{className:`data-header`,children:(0,S.jsxs)(`h1`,{className:`data-title`,children:[(0,S.jsx)(d,{size:18}),` Data`]})}),(0,S.jsxs)(`div`,{className:`data-empty`,children:[(0,S.jsx)(`p`,{children:`You are not signed in.`}),(0,S.jsxs)(`p`,{children:[`Open the `,(0,S.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})]}):(0,S.jsx)(`div`,{className:`data-page`,children:(0,S.jsxs)(`div`,{className:`data-loading`,children:[(0,S.jsx)(o,{size:18,className:`spin`}),` Loading…`]})})}function w({cacheKey:e,onOpenInGraph:t}){let{adminFetch:n,cacheKey:r,sessionRefetchNonce:i,banner:a,reloadToLogin:o}=c({initialCacheKey:e,surface:`data`});return(0,S.jsxs)(`main`,{className:`data-main`,children:[a&&(0,S.jsx)(`button`,{type:`button`,className:`data-session-banner`,onClick:o,"data-reason":a.reason,children:a.message}),(0,S.jsx)(T,{adminFetch:n,sessionRefetchNonce:i,onOpenInGraph:t}),(0,S.jsx)(A,{adminFetch:n,cacheKey:r,sessionRefetchNonce:i})]})}function T({adminFetch:e,sessionRefetchNonce:t,onOpenInGraph:n}){let[r,i]=(0,x.useState)(``),[a,s]=(0,x.useState)(``),[c,u]=(0,x.useState)(null),[d,f]=(0,x.useState)(`hybrid`),[p,m]=(0,x.useState)(!1),[h,g]=(0,x.useState)(null),[v,b]=(0,x.useState)(null),[C,w]=(0,x.useState)(0),[T,O]=(0,x.useState)(!1);(0,x.useEffect)(()=>{let e=r.trim();if(!e){s(``),u(null);return}O(!1);let t=setTimeout(()=>s(e),300);return()=>clearTimeout(t)},[r]),(0,x.useEffect)(()=>{if(!a)return;let t=!1;return m(!0),g(null),e(`/api/admin/graph-search?q=${encodeURIComponent(a)}&labels=*&limit=20${T?`&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||(u(e.results),f(e.mode??`hybrid`),w(typeof e.suppressed==`number`?e.suppressed:0))}).catch(e=>{t||g(e instanceof Error?e.message:String(e))}).finally(()=>{t||m(!1)}),()=>{t=!0}},[a,e,t,T]);let k=(0,x.useMemo)(()=>c?_(c):[],[c]),A=v&&k.includes(v)?v:null,j=(0,x.useMemo)(()=>c?A?c.filter(e=>e.labels.includes(A)):c:null,[c,A]),M=(0,x.useCallback)(e=>{if(n){n(e);return}window.location.href=y(e)},[n]);return(0,S.jsxs)(`section`,{className:`data-panel`,children:[(0,S.jsx)(`h2`,{className:`data-panel-title`,children:`Search`}),(0,S.jsx)(`p`,{className:`data-panel-subtitle`,children:`Find anything in your knowledge base by keyword.`}),(0,S.jsxs)(`div`,{className:`data-search-input`,children:[(0,S.jsx)(l,{size:14}),(0,S.jsx)(`input`,{type:`text`,placeholder:`Search your knowledge…`,value:r,onChange:e=>i(e.target.value),autoFocus:!0,autoComplete:`off`,spellCheck:!1}),p&&(0,S.jsx)(o,{size:14,className:`spin`})]}),h&&(0,S.jsxs)(`div`,{className:`data-error`,children:[`Search failed: `,h]}),k.length>0&&(0,S.jsx)(`div`,{className:`data-chip-row`,role:`group`,"aria-label":`Filter by type`,children:k.map(e=>{let t=e===A;return(0,S.jsx)(`button`,{type:`button`,className:`data-chip`,"data-active":t,onClick:()=>b(t?null:e),children:D([e])??e},e)})}),c&&!p&&(0,S.jsxs)(`div`,{className:`data-results-meta`,children:[j.length,` of `,c.length,` result`,c.length===1?``:`s`]}),c&&!p&&!A&&C>0&&!T&&(0,S.jsxs)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>O(!0),children:[C,` low-confidence result`,C===1?``:`s`,` hidden — show all`]}),c&&!p&&!A&&T&&(0,S.jsx)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>O(!1),children:`Showing all results — hide low-confidence`}),c&&c.length===0&&!p&&(0,S.jsx)(`div`,{className:`data-empty-results`,children:`No matches. Try a different keyword.`}),j&&j.length>0&&(0,S.jsx)(`ul`,{className:`data-results`,children:j.map(e=>(0,S.jsx)(E,{hit:e,mode:d,onOpenInGraph:M},e.nodeId))})]})}function E({hit:e,mode:t,onOpenInGraph:n}){let r=O(e.properties),i=k(e.properties),a=D(e.labels),[o,s]=(0,x.useState)(!1),c=i&&i.length>280,l=o||!c?i:i?.slice(0,280)+`…`,u=t===`bm25`?`bm25 ${e.bm25Score.toFixed(2)}`:`vector ${e.vectorScore.toFixed(2)} · bm25 ${e.bm25Score.toFixed(2)} · combined ${e.score.toFixed(2)}`;return(0,S.jsxs)(`li`,{className:`data-result`,children:[(0,S.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":`Open ${r??a??`node`} in graph`,children:[a&&(0,S.jsx)(`div`,{className:`data-result-header`,children:(0,S.jsx)(`span`,{className:`data-result-labels`,children:a})}),r&&(0,S.jsx)(`div`,{className:`data-result-title`,children:r}),i&&(0,S.jsx)(`pre`,{className:`data-result-body`,children:l}),(0,S.jsx)(`div`,{className:`data-result-scores`,children:u})]}),c&&(0,S.jsx)(`button`,{type:`button`,className:`data-result-toggle`,onClick:()=>s(e=>!e),children:o?`Show less`:`Show more`})]})}function D(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 O(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 k(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 A({adminFetch:e,cacheKey:t,sessionRefetchNonce:n}){let[r,a]=(0,x.useState)(`.`),[s,c]=(0,x.useState)(null),[l,u]=(0,x.useState)([]),[d,_]=(0,x.useState)(!1),[v,y]=(0,x.useState)(null),[b,C]=(0,x.useState)(!1),[w,T]=(0,x.useState)(null),[E,D]=(0,x.useState)(null),[O,k]=(0,x.useState)(null),[A,N]=(0,x.useState)(null),P=(0,x.useRef)(null),[F,I]=(0,x.useState)(0);(0,x.useEffect)(()=>{let t=!1;return _(!0),y(null),e(`/api/admin/files?path=${encodeURIComponent(r===`.`?``:r)}`).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||(c(e.entries),u(e.displayPath??[]))}).catch(e=>{t||(c([]),u([]),y(e instanceof Error?e.message:String(e)))}).finally(()=>{t||_(!1)}),()=>{t=!0}},[e,r,F,n]);let L=(0,x.useCallback)(e=>{a(e)},[]),R=(0,x.useCallback)(()=>{if(r===`.`||r===``)return;let e=r.split(`/`).filter(Boolean);e.pop(),a(e.length===0?`.`:e.join(`/`))},[r]),z=(0,x.useCallback)(e=>{let n=r===`.`?e.name:`${r}/${e.name}`,i=`/api/admin/files/download?session_key=${encodeURIComponent(t)}&path=${encodeURIComponent(n)}`,a=document.createElement(`a`);a.href=i,a.rel=`noopener noreferrer`,document.body.appendChild(a),a.click(),a.remove()},[r,t]),B=(0,x.useCallback)(()=>{P.current?.click()},[]),V=(0,x.useCallback)(e=>{D(null),N(e.name)},[]),H=(0,x.useCallback)(()=>{N(null)},[]),U=(0,x.useCallback)(async t=>{let n=r===`.`?t.name:`${r}/${t.name}`;D(null),N(null),k(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}`);I(e=>e+1)}catch(e){D(e instanceof Error?e.message:String(e))}finally{k(null)}},[r,e]);(0,x.useEffect)(()=>{if(!A)return;let e=e=>{e.key===`Escape`&&N(null)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[A]);let W=(0,x.useCallback)(async e=>{T(null),C(!0);try{let n=new FormData;n.append(`session_key`,t),n.append(`file`,e);let r=await fetch(`/api/admin/files/upload`,{method:`POST`,body:n}),i=await r.json().catch(()=>({error:`HTTP ${r.status}`}));if(!r.ok)throw Error(i.error??`HTTP ${r.status}`);a(i.path.split(`/`).slice(0,-1).join(`/`)||`.`),I(e=>e+1)}catch(e){T(e instanceof Error?e.message:String(e))}finally{C(!1),P.current&&(P.current.value=``)}},[t]);return(0,S.jsxs)(`section`,{className:`data-panel`,children:[(0,S.jsxs)(`div`,{className:`data-panel-heading`,children:[(0,S.jsx)(`h2`,{className:`data-panel-title`,children:`Files`}),(0,S.jsxs)(`div`,{className:`data-file-actions`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`data-btn`,onClick:B,disabled:b,children:[b?(0,S.jsx)(o,{size:14,className:`spin`}):(0,S.jsx)(g,{size:14}),` Upload`]}),(0,S.jsx)(`input`,{type:`file`,ref:P,hidden:!0,onChange:e=>{let t=e.target.files?.[0];t&&W(t)}})]})]}),(0,S.jsxs)(`p`,{className:`data-panel-subtitle`,children:[`Everything under your install's `,(0,S.jsx)(`code`,{children:`data/`}),` directory. Click a folder to open it, a file to download it. Uploads go to `,(0,S.jsx)(`code`,{children:`data/uploads/`}),`.`]}),(0,S.jsxs)(`div`,{className:`data-breadcrumbs`,children:[(0,S.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>L(`.`),children:`data`}),l.map((e,t)=>{let n=l.slice(0,t+1).map(e=>e.name).join(`/`);return(0,S.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,S.jsx)(`span`,{className:`data-crumb-sep`,children:`/`}),(0,S.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>L(n),title:e.name,children:e.displayName??e.name})]},n)}),r!==`.`&&(0,S.jsxs)(`button`,{type:`button`,className:`data-btn data-btn-ghost data-up-btn`,onClick:R,children:[(0,S.jsx)(f,{size:14}),` Up`]})]}),w&&(0,S.jsxs)(`div`,{className:`data-error`,children:[`Upload failed: `,w]}),E&&(0,S.jsxs)(`div`,{className:`data-error`,children:[`Delete failed: `,E]}),v&&(0,S.jsx)(`div`,{className:`data-error`,children:v}),d&&(0,S.jsxs)(`div`,{className:`data-loading`,children:[(0,S.jsx)(o,{size:14,className:`spin`}),` Loading…`]}),!d&&s&&s.length===0&&!v&&(0,S.jsx)(`div`,{className:`data-empty-results`,children:`Empty directory.`}),!d&&s&&s.length>0&&(0,S.jsx)(`ul`,{className:`data-entries`,children:s.map(e=>{let t=e.displayName??e.name,n=O===e.name,a=A===e.name;return(0,S.jsx)(`li`,{className:`data-entry`,children:e.kind===`directory`?(0,S.jsxs)(`button`,{type:`button`,className:`data-entry-btn`,onClick:()=>L(r===`.`?e.name:`${r}/${e.name}`),children:[(0,S.jsx)(h,{size:14}),(0,S.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t})]}):e.kind===`file`?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`button`,{type:`button`,className:`data-entry-btn`,onClick:()=>z(e),title:`Download ${t}`,disabled:a,children:[(0,S.jsx)(m,{size:14}),(0,S.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t}),(0,S.jsxs)(`span`,{className:`data-entry-meta`,title:`Modified ${M(e.modifiedAt)}`,children:[j(e.sizeBytes),` · `,M(e.modifiedAt)]}),(0,S.jsx)(p,{size:12,className:`data-entry-download-icon`})]}),a?(0,S.jsxs)(`div`,{className:`data-entry-confirm`,role:`group`,"aria-label":`Confirm delete ${t}`,children:[(0,S.jsx)(`span`,{className:`data-entry-confirm-label`,children:`Delete?`}),(0,S.jsx)(`button`,{type:`button`,className:`data-entry-confirm-yes`,onClick:()=>U(e),autoFocus:!0,children:`Yes`}),(0,S.jsx)(`button`,{type:`button`,className:`data-entry-confirm-no`,onClick:H,children:`No`})]}):(0,S.jsx)(`button`,{type:`button`,className:`data-entry-delete`,onClick:()=>V(e),disabled:n,title:`Delete ${t}`,"aria-label":`Delete ${t}`,children:n?(0,S.jsx)(o,{size:14,className:`spin`}):(0,S.jsx)(i,{size:14})})]}):(0,S.jsxs)(`div`,{className:`data-entry-btn data-entry-disabled`,children:[(0,S.jsx)(m,{size:14}),(0,S.jsx)(`span`,{className:`data-entry-name`,children:t}),(0,S.jsx)(`span`,{className:`data-entry-meta`,children:`special`})]})},e.name)})})]})}function j(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 M(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{p as i,w as n,b as r,C as t};
@@ -1,8 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-BKzdtZgG.js","assets/dist-Bd4S37oi.js","assets/chunk-DD-I1_y5.js","assets/chunk-U2HBQHQK-CwMCwyfq.js","assets/src-B6XdH6xq.js","assets/chunk-5PVQY5BW-DOeY60Lp.js","assets/chunk-ICPOFSXX-rgw1I6pt.js","assets/_baseFor-BHtDrjIo.js","assets/isEmpty-BWl67LAZ.js","assets/chunk-336JU56O-XIsdqKyD.js","assets/chunk-5FUZZQ4R-3-UZ9191.js","assets/chunk-X2U36JSP-CvKfDVvq.js","assets/chunk-ZZ45TVLE-sANOwJKn.js","assets/rough.esm-DKRO8IF-.js","assets/chunk-ENJZ2VHE-CszgAcWZ.js","assets/line-Br0FyyFW.js","assets/path-B0Ik7Tu9.js","assets/array-DetWRiSa.js","assets/chunk-BSJP7CBP-DP7LTBll.js","assets/chunk-426QAEUC-Dw4mcMYK.js","assets/chunk-XPW4576I-m1Y_r88I.js"])))=>i.map(i=>d[i]);
2
- import{o as e}from"./chunk-DD-I1_y5.js";import{a as t,c as n,d as r,f as i,h as a,l as o,n as s,o as c,p as l,r as u,s as d,t as f,u as p}from"./brand-HqTMr1bV.js";import{a as m,i as h,n as g,o as _,r as v,s as y,t as b}from"./device-url-actions-nxh9PmIH.js";import{t as x}from"./Checkbox-B34vplI7.js";var S=i(`file-code`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]),C=i(`mic`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]),w=i(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),T=i(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),E=i(`square-check-big`,[[`path`,{d:`M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344`,key:`2acyp4`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),D=i(`square-plus`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]]),O=i(`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`}]]),k=l(),A=e(a(),1),j=`image/jpeg,image/png,image/gif,image/webp,application/pdf,text/plain,text/markdown,text/csv,text/html,text/calendar,audio/ogg,audio/opus,audio/mp4,audio/mpeg,audio/webm,audio/wav,.opus,.ogg,.m4a,.mp3,.wav,.webm`,M=new Set(j.split(`,`).filter(e=>!e.startsWith(`.`))),N=50*1024*1024,P=typeof window<`u`&&/^(localhost|127\.0\.0\.1|[a-z0-9-]+\.local)(:|$)/.test(window.location.hostname);function ee(){let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=[...e].map(e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function F(){let e=window.location.pathname;if(e.startsWith(`/g/`))return;let t=e.match(/^\/([a-z][a-z0-9-]{2,49})$/);return t?t[1]:void 0}function I(){let e=window.location.pathname.match(/^\/g\/([a-z0-9][a-z0-9-]{0,49})$/);return e?e[1]:void 0}function L(e){return[{key:`length`,label:`At least 8 characters`,met:e.length>=8},{key:`number`,label:`Contains a number`,met:/\d/.test(e)},{key:`special`,label:`Contains a special character`,met:/[^A-Za-z0-9]/.test(e)},{key:`whitespace`,label:`No spaces`,met:e.length>0&&!/\s/.test(e)}]}function R(e,t){if(t===`phone`)return e.length>4?e.slice(0,e.length-4).replace(/\d/g,`•`)+` `+e.slice(-4):e;let n=e.indexOf(`@`);return n<=2?e:e.slice(0,2)+`•••`+e.slice(n)}function z(e){let[t,n]=(0,A.useState)(null),[r,i]=(0,A.useState)(null),[a,o]=(0,A.useState)(`loading`),[s,c]=(0,A.useState)(``),[l,u]=(0,A.useState)(null),[d,f]=(0,A.useState)(null),[p,m]=(0,A.useState)(!1),[h,g]=(0,A.useState)(null),_=(0,A.useMemo)(()=>F(),[]),v=(0,A.useMemo)(()=>I(),[]),[y,b]=(0,A.useState)(null),x=(0,A.useRef)(_||``),S=(0,A.useRef)(null),C=(0,A.useRef)(null),w=(0,A.useRef)(!1),T=(0,A.useRef)(null),[E,D]=(0,A.useState)(`sign-in`),[O,k]=(0,A.useState)(null),j=(0,A.useRef)(null),M=(0,A.useRef)(null);(0,A.useEffect)(()=>{try{let e=sessionStorage.getItem(`maxy_session`);e&&(M.current=e)}catch{}},[]);let N=(0,A.useCallback)(t=>{S.current=t,n(t);try{sessionStorage.setItem(`maxy_session`,t)}catch{}o(`chat`),e(t)},[e]),L=(0,A.useCallback)(()=>{S.current=null;try{sessionStorage.removeItem(`maxy_session`)}catch{}n(null),o(`auth-required`),D(`sign-in`)},[]),R=(0,A.useCallback)(async e=>{try{let t=x.current,n=await fetch(`/api/access/verify-token`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:e,agentSlug:t})}),r=await n.json();n.ok?(j.current=r.session_key,k(r.grant),D(`set-password`),window.history.replaceState({},``,window.location.pathname)):D(`link-expired`)}catch{D(`sign-in`)}},[]),z=(0,A.useCallback)(async()=>{if(S.current)return S.current;if(C.current)return C.current;let e=(async()=>{try{let e=M.current,t=await fetch(`/api/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({session_id:ee(),..._?{agent:_}:{},...v?{group_slug:v}:{},...e?{session_key:e}:{}})});if(!t.ok){let e=await t.json().catch(()=>({error:``}));return P&&console.error(`[session] POST /api/session failed: ${t.status} ${t.statusText}`,e),t.status===404?i(e.error||`Agent not found`):t.status===503&&i(e.error||`Service unavailable`),null}let r=await t.json();if(r.auth_required){r.agent_id&&(x.current=r.agent_id),c(r.displayName||``),r.agentImage&&u(r.agentImage),r.agentImageShape&&f(r.agentImageShape),r.showAgentName&&m(r.showAgentName),r.branding&&g(r.branding),o(`auth-required`);let e=new URLSearchParams(window.location.search).get(`token`);return e?R(e):D(`sign-in`),null}S.current=r.session_key,n(r.session_key),r.displayName&&c(r.displayName),r.agentImage&&u(r.agentImage),r.agentImageShape&&f(r.agentImageShape),r.showAgentName&&m(r.showAgentName),r.branding&&g(r.branding),o(`chat`),r.resumed&&r.messages&&(w.current=!0,T.current=r.messages),r.group&&b({groupSlug:r.groupSlug,groupName:r.groupName,participants:r.participants??[]});try{sessionStorage.setItem(`maxy_session`,r.session_key)}catch{}return r.session_key}catch(e){return P&&console.error(`[session] fetch /api/session threw:`,e),i(`Unable to connect. Please check your connection and try again.`),null}finally{C.current=null}})();return C.current=e,e},[_,v,R]);return{sessionId:t,cacheKeyRef:S,sessionError:r,pageState:a,setPageState:o,agentDisplayName:s,agentImage:l,agentImageShape:d,showAgentName:p,agentSlug:_,branding:h,resolvedSlugRef:x,ensureSession:z,startNewSession:(0,A.useCallback)(async()=>{S.current=null,C.current=null,M.current=null,w.current=!1,T.current=null,n(null),i(null);try{sessionStorage.removeItem(`maxy_session`)}catch{}let t=await z();t&&e(t)},[z,e]),enterChat:N,enterGate:L,resumedRef:w,resumeMessagesRef:T,gateState:E,setGateState:D,grantInfo:O,setGrantInfo:k,gateCacheKeyRef:j,groupContext:y,groupSlug:v}}async function*B(e){let t=e.body?.getReader();if(!t)throw Error(`No response stream`);let n=new TextDecoder,r=``;try{for(;;){let{done:e,value:i}=await t.read();if(e)break;r+=n.decode(i,{stream:!0});let a=r.split(`
3
- `);r=a.pop();for(let e of a){if(!e.startsWith(`data: `))continue;let t=e.slice(6);if(t===`[DONE]`)continue;let n;try{n=JSON.parse(t)}catch{continue}yield n}}}finally{t.cancel()}}function te({cacheKeyRef:e,ensureSession:t,sessionError:n,pageState:r,inputRef:i}){let[a,o]=(0,A.useState)([]),[s,c]=(0,A.useState)(!1),l=(0,A.useRef)(!1),u=e=>{l.current=e,c(e)},d=(0,A.useCallback)(async a=>{if(!l.current){u(!0),o([{role:`maxy`,content:``,timestamp:Date.now()}]);try{let n=await fetch(`/api/chat`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({greeting:!0,session_key:a})});if(n.status===401){e.current=null;try{sessionStorage.removeItem(`maxy_session`)}catch{}P&&console.warn(`[greeting] stale session, retrying with fresh session`);let r=await t();if(!r)return;n=await fetch(`/api/chat`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({greeting:!0,session_key:r})})}if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`Something went wrong`)}let r=``,i=``,s=()=>{i&&(r+=i,i=``,o(e=>{let t=[...e];return t[0]={...t[0],content:r},t}))},c=setInterval(s,60);try{for await(let e of B(n)){if(e.error)throw Object.assign(Error(e.error),{fromSSE:!0});e.text&&(i+=e.text),e.type===`component`&&(s(),o(t=>{let n=[...t],r={...n[0]},i=[...r.components||[]];return i.push({name:e.name,data:e.data,submitted:!1}),n[0]={...r,components:i},n}))}}finally{clearInterval(c),s()}}catch(e){if(P&&console.error(`[chat] greeting failed:`,e),r===`auth-required`)return;let t=e instanceof Error?e.message:String(e);o([{role:`maxy`,content:e instanceof Error&&e.fromSSE?t:n??`I'm having trouble connecting right now. Try refreshing the page.`,timestamp:Date.now()}])}finally{u(!1),r===`chat`&&i.current?.focus()}}},[e,t,n,r,i]),f=(0,A.useCallback)(async(a,s)=>{let c=s?.hidden??!1,d=s?.files??[];if(!a&&d.length===0||l.current)return;u(!0);let f=d.map(e=>({filename:e.name,mimeType:e.type})),p={role:`visitor`,content:a,attachments:f.length>0?f:void 0,timestamp:Date.now(),hidden:c},m;o(e=>{let t=[...e,p,{role:`maxy`,content:``,timestamp:Date.now()}];return m=t.length-1,t});try{let n=await t();if(!n)throw Error(`session`);let r=e=>{if(d.length>0){let t=new FormData;t.append(`message`,a),t.append(`session_key`,e);for(let e of d)t.append(`attachments`,e);return{body:t,headers:{}}}return{body:JSON.stringify({message:a,session_key:e}),headers:{"Content-Type":`application/json`}}},{body:i,headers:s}=r(n),c=await fetch(`/api/chat`,{method:`POST`,headers:s,body:i});if(c.status===401){e.current=null;try{sessionStorage.removeItem(`maxy_session`)}catch{}P&&console.warn(`[session-expired] stale key cleared, retrying with fresh session`);let n=await t();if(!n)throw Error(`session`);({body:i,headers:s}=r(n)),c=await fetch(`/api/chat`,{method:`POST`,headers:s,body:i})}if(!c.ok){let e=await c.json().catch(()=>({}));throw Error(e.error||`Something went wrong`)}let l=``,u=``,f=()=>{u&&(l+=u,u=``,o(e=>{let t=[...e];return t[m]={...t[m],content:l},t}))},p=setInterval(f,60);try{for await(let e of B(c)){if(e.error)throw Object.assign(Error(e.error),{fromSSE:!0});e.text&&(u+=e.text),e.type===`component`&&(f(),o(t=>{let n=[...t],r={...n[m]},i=[...r.components||[]];return i.push({name:e.name,data:e.data,submitted:!1}),n[m]={...r,components:i},n}))}}finally{clearInterval(p),f()}}catch(e){if(P&&console.error(`[chat] sendMessage failed:`,e),r===`auth-required`)return;let t=e instanceof Error?e.message:String(e),i=e instanceof Error&&e.fromSSE;o(e=>{let r=[...e];return r[m]={...r[m],content:i?t:t===`session`?n??`I'm having trouble connecting right now. Try refreshing the page.`:`Sorry, I hit a snag. Try again in a moment.`},r})}finally{u(!1),r===`chat`&&i.current?.focus()}},[e,t,n,r,i]);return{messages:a,setMessages:o,isStreaming:s,sendMessage:f,sendGreeting:d,handleComponentSubmit:(0,A.useCallback)((e,t,n)=>{o(n=>{let r=[...n],i={...r[e]},a=[...i.components||[]];return a[t]={...a[t],submitted:!0},r[e]={...i,components:a},r}),f(n,{hidden:!0})},[f])}}function ne({cacheKeyRef:e,groupSlug:t,isStreaming:n,setMessages:r}){let i=(0,A.useRef)(new Date().toISOString()),a=(0,A.useRef)(!0);(0,A.useEffect)(()=>{let e=()=>{a.current=document.visibilityState===`visible`};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]);let o=(0,A.useCallback)(async()=>{let n=e.current;if(!(!n||!t))try{let e=await fetch(`/api/group/messages?session_key=${encodeURIComponent(n)}&since=${encodeURIComponent(i.current)}`);if(!e.ok)return;let t=await e.json();if(!t.messages||t.messages.length===0)return;let a=t.messages[t.messages.length-1];a.timestamp&&(i.current=new Date(a.timestamp).toISOString()),r(e=>{let n=new Set(e.filter(e=>e.messageId).map(e=>e.messageId)),r=t.messages.filter(e=>!n.has(e.messageId)).map(e=>({role:e.role,content:e.content,timestamp:e.timestamp,senderName:e.senderName??void 0,senderVisitorId:e.senderVisitorId??void 0,messageId:e.messageId}));if(r.length===0)return e;let i=[...e,...r];return i.sort((e,t)=>e.timestamp-t.timestamp),i})}catch(e){console.error(`[group-poll] failed: ${e instanceof Error?e.message:String(e)}`)}},[e,t,r]);(0,A.useEffect)(()=>{if(!t)return;let e,r=!1;function i(){if(r)return;let t=a.current?3e3:3e4;e=setTimeout(async()=>{n||await o(),i()},t)}return i(),()=>{r=!0,clearTimeout(e)}},[t,n,o])}var V=t();function re({value:e,onChange:t,onComplete:n,disabled:r}){let i=(0,A.useRef)([]);function a(n,r){r.key===`Backspace`?(r.preventDefault(),e[n]?t(e.slice(0,n)+e.slice(n+1)):n>0&&(t(e.slice(0,n-1)+e.slice(n)),i.current[n-1]?.focus())):r.key===`ArrowLeft`&&n>0?i.current[n-1]?.focus():r.key===`ArrowRight`&&n<5&&i.current[n+1]?.focus()}function o(r,a){let o=a.nativeEvent.data;if(!o||!/^\d$/.test(o))return;let s=e.split(``);for(s[r]=o;s.length<r;)s.push(``);let c=s.join(``).replace(/\D/g,``).slice(0,6);t(c),c.length===6?n(c):r<5&&i.current[r+1]?.focus()}function s(e){e.preventDefault();let r=e.clipboardData.getData(`text`).replace(/\D/g,``).slice(0,6);r&&(t(r),r.length===6?n(r):i.current[r.length]?.focus())}return(0,V.jsx)(`div`,{className:`gate-otp-field`,children:Array.from({length:6}).map((t,n)=>(0,V.jsx)(`input`,{ref:e=>{i.current[n]=e},type:`text`,inputMode:`numeric`,className:`pin-box${e[n]?` pin-box-filled`:``}`,value:e[n]||``,onKeyDown:e=>a(n,e),onInput:e=>o(n,e),onPaste:s,onFocus:e=>e.target.select(),autoFocus:n===0,autoComplete:`off`,maxLength:1,disabled:r,"aria-label":`Code digit ${n+1}`},n))})}function ie({gateState:e,setGateState:t,grantInfo:n,setGrantInfo:r,gateCacheKeyRef:i,resolvedSlugRef:a,onAuthenticated:o}){let[s,c]=(0,A.useState)(``),[l,u]=(0,A.useState)(``),[d,f]=(0,A.useState)(``),[p,m]=(0,A.useState)(!1),[h,g]=(0,A.useState)(``),[v,y]=(0,A.useState)(``),[b,S]=(0,A.useState)(!1),[C,w]=(0,A.useState)(null),[T,E]=(0,A.useState)(null),[D,O]=(0,A.useState)(!1);async function k(e){if(e.preventDefault(),!D){w(null),O(!0);try{let e=a.current,n=await fetch(`/api/access/login`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({contact:s,password:l,agentSlug:e})}),i=await n.json();n.ok?o(i.session_key):n.status===401?i.error?.includes(`setup not complete`)||i.error?.includes(`invitation link`)?(t(`private-agent`),w(null)):w(i.error||`Invalid credentials`):n.status===403?(t(`access-expired`),i.expiresAt&&r(e=>e?{...e,expiresAt:i.expiresAt}:{displayName:null,contactValue:s,contactMethod:`email`,expiresAt:i.expiresAt,status:`expired`})):n.status===429?w(i.error||`Too many attempts. Please try again later.`):w(i.error||`Something went wrong`)}catch{w(`Unable to connect. Please try again.`)}finally{O(!1)}}}async function j(e){if(!D){w(null),O(!0);try{let n=a.current,o=await fetch(`/api/access/verify-otp`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({phone:v,code:e,agentSlug:n})}),s=await o.json();o.ok?(i.current=s.session_key,r(s.grant),t(`set-password`)):o.status===429?t(`otp-failed`):(w(s.error||`Invalid code`),g(``))}catch{w(`Unable to connect. Please try again.`)}finally{O(!1)}}}async function M(e){if(e.preventDefault(),!D){if(w(null),l!==d){w(`Passwords do not match`);return}if(!L(l).every(e=>e.met)){w(`Password does not meet requirements`);return}O(!0);try{let e=i.current;if(!e){w(`Session expired. Please use your invitation link again.`);return}let t=await fetch(`/api/access/create-credentials`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({session_key:e,password:l})}),n=await t.json();t.ok?o(n.session_key):t.status===400&&n.requirements?w(n.requirements.filter(e=>!e.met).map(e=>e.label).join(`, `)):w(n.error||`Something went wrong`)}catch{w(`Unable to connect. Please try again.`)}finally{O(!1)}}}async function N(e){if(e.preventDefault(),!(D||!s)){w(null),O(!0);try{let e=a.current,t=await fetch(`/api/access/forgot-password`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({contact:s,agentSlug:e})});t.status===429?w((await t.json()).error||`Too many attempts. Please try again later.`):(E(`If an account exists, a reset link has been sent.`),setTimeout(()=>{S(!1),E(null)},4e3))}catch{w(`Unable to connect. Please try again.`)}finally{O(!1)}}}switch(e){case`set-password`:{let e=L(l),t=e.every(e=>e.met),r=l===d,i=t&&r&&d.length>0;return(0,V.jsx)(`div`,{className:`gate-wrap`,children:(0,V.jsxs)(`div`,{className:`gate-card`,children:[n?.expiresAt&&(0,V.jsxs)(`div`,{className:`gate-expiry-badge`,children:[`Access until `,new Date(n.expiresAt).toLocaleDateString(`en-GB`,{day:`numeric`,month:`short`,year:`numeric`})]}),(0,V.jsxs)(`h2`,{className:`gate-title`,children:[`Welcome, `,n?.displayName||`there`]}),(0,V.jsx)(`p`,{className:`gate-subtitle`,children:`Create a password to access this agent in the future.`}),(0,V.jsxs)(`form`,{className:`gate-form`,onSubmit:M,children:[(0,V.jsxs)(`div`,{className:`gate-field`,children:[(0,V.jsx)(`label`,{htmlFor:`gate-display-name`,children:`Display name`}),(0,V.jsx)(`input`,{id:`gate-display-name`,type:`text`,value:n?.displayName||``,disabled:!0})]}),(0,V.jsxs)(`div`,{className:`gate-field gate-pw-row`,children:[(0,V.jsx)(`label`,{htmlFor:`gate-pw`,children:`Password`}),(0,V.jsx)(`div`,{className:`gate-pw-toggle`,children:(0,V.jsx)(x,{checked:p,onChange:m,label:`Show`})}),(0,V.jsx)(`input`,{id:`gate-pw`,type:p?`text`:`password`,value:l,onChange:e=>u(e.target.value),placeholder:`Your password`,autoFocus:!0,autoComplete:`new-password`}),l.length>0&&(0,V.jsx)(`div`,{className:`gate-strength`,children:e.map(e=>(0,V.jsxs)(`span`,{className:`gate-strength-item${e.met?` met`:``}`,children:[e.met?`✓`:`○`,` `,e.label]},e.key))})]}),(0,V.jsxs)(`div`,{className:`gate-field`,children:[(0,V.jsx)(`label`,{htmlFor:`gate-pw-confirm`,children:`Confirm password`}),(0,V.jsx)(`input`,{id:`gate-pw-confirm`,type:p?`text`:`password`,value:d,onChange:e=>f(e.target.value),placeholder:`Confirm your password`,autoComplete:`new-password`}),d.length>0&&!r&&(0,V.jsx)(`div`,{className:`gate-error`,children:`Passwords do not match`})]}),C&&(0,V.jsx)(`div`,{className:`gate-error`,children:C}),(0,V.jsx)(`div`,{className:`gate-submit`,children:(0,V.jsx)(_,{variant:`primary`,type:`submit`,fullWidth:!0,disabled:!i||D,loading:D,children:`Create account & enter chat`})})]})]})})}case`enter-otp`:return(0,V.jsx)(`div`,{className:`gate-wrap`,children:(0,V.jsxs)(`div`,{className:`gate-card`,children:[(0,V.jsx)(`h2`,{className:`gate-title`,children:`Enter your code`}),(0,V.jsxs)(`p`,{className:`gate-subtitle`,children:[`Enter the 6-digit code sent to `,R(v,`phone`)]}),(0,V.jsx)(re,{value:h,onChange:g,onComplete:j,disabled:D}),C&&(0,V.jsx)(`div`,{className:`gate-error`,children:C}),D&&(0,V.jsxs)(`div`,{className:`gate-loading`,children:[(0,V.jsx)(`span`,{className:`spinner`}),`Verifying...`]}),(0,V.jsx)(`div`,{className:`gate-resend`,children:(0,V.jsx)(`button`,{type:`button`,className:`gate-link`,onClick:()=>{t(`sign-in`),g(``),w(null)},children:`Use a different number`})})]})});case`sign-in`:case`private-agent`:return(0,V.jsx)(`div`,{className:`gate-wrap`,children:(0,V.jsxs)(`div`,{className:`gate-card`,children:[(0,V.jsx)(`h2`,{className:`gate-title`,children:e===`private-agent`?`Private Agent`:`Welcome back`}),(0,V.jsx)(`p`,{className:`gate-subtitle`,children:e===`private-agent`?`This agent is invitation-only. If you have an account, sign in below.`:`Sign in to continue your conversation.`}),b?(0,V.jsxs)(`form`,{className:`gate-form`,onSubmit:N,children:[(0,V.jsxs)(`div`,{className:`gate-field`,children:[(0,V.jsx)(`label`,{htmlFor:`gate-forgot-contact`,children:`Email or phone`}),(0,V.jsx)(`input`,{id:`gate-forgot-contact`,type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:`you@example.com`,autoFocus:!0,autoComplete:`email`})]}),C&&(0,V.jsx)(`div`,{className:`gate-error`,children:C}),T&&(0,V.jsx)(`div`,{className:`gate-success`,children:T}),(0,V.jsx)(`div`,{className:`gate-submit`,children:(0,V.jsx)(_,{variant:`primary`,type:`submit`,fullWidth:!0,disabled:!s.trim()||D,loading:D,children:`Send reset link`})}),(0,V.jsx)(`div`,{className:`gate-actions`,children:(0,V.jsx)(`button`,{type:`button`,className:`gate-link`,onClick:()=>{S(!1),w(null),E(null)},children:`Back to sign in`})})]}):(0,V.jsxs)(`form`,{className:`gate-form`,onSubmit:k,children:[(0,V.jsxs)(`div`,{className:`gate-field`,children:[(0,V.jsx)(`label`,{htmlFor:`gate-contact`,children:`Email or phone`}),(0,V.jsx)(`input`,{id:`gate-contact`,type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:`you@example.com`,autoFocus:!0,autoComplete:`email`})]}),(0,V.jsxs)(`div`,{className:`gate-field gate-pw-row`,children:[(0,V.jsx)(`label`,{htmlFor:`gate-login-pw`,children:`Password`}),(0,V.jsx)(`div`,{className:`gate-pw-toggle`,children:(0,V.jsx)(x,{checked:p,onChange:m,label:`Show`})}),(0,V.jsx)(`input`,{id:`gate-login-pw`,type:p?`text`:`password`,value:l,onChange:e=>u(e.target.value),placeholder:`Your password`,autoComplete:`current-password`})]}),C&&(0,V.jsx)(`div`,{className:`gate-error`,children:C}),(0,V.jsx)(`div`,{className:`gate-submit`,children:(0,V.jsx)(_,{variant:`primary`,type:`submit`,fullWidth:!0,disabled:!s.trim()||!l||D,loading:D,children:`Sign in`})}),(0,V.jsx)(`div`,{className:`gate-actions`,children:(0,V.jsx)(`button`,{type:`button`,className:`gate-link`,onClick:()=>{S(!0),w(null)},children:`Forgot password?`})})]}),e===`private-agent`&&(0,V.jsx)(`p`,{className:`gate-hint`,children:`No account? You need an invitation from the agent owner.`})]})});case`access-expired`:return(0,V.jsx)(`div`,{className:`gate-wrap`,children:(0,V.jsxs)(`div`,{className:`gate-card`,children:[(0,V.jsx)(`div`,{className:`gate-icon`,children:`⏰`}),(0,V.jsx)(`h2`,{className:`gate-title`,children:`Access expired`}),(0,V.jsxs)(`p`,{className:`gate-subtitle`,children:[n?.expiresAt?`Your access expired on ${new Date(n.expiresAt).toLocaleDateString(`en-GB`,{day:`numeric`,month:`long`,year:`numeric`})}.`:`Your access to this agent has expired.`,` `,`Contact the agent owner to renew.`]}),(0,V.jsx)(`div`,{className:`gate-actions`,children:(0,V.jsx)(_,{variant:`secondary`,onClick:()=>{t(`sign-in`),w(null),u(``)},children:`Sign in with a different account`})})]})});case`link-expired`:return(0,V.jsx)(`div`,{className:`gate-wrap`,children:(0,V.jsxs)(`div`,{className:`gate-card`,children:[(0,V.jsx)(`div`,{className:`gate-icon`,children:`⚠️`}),(0,V.jsx)(`h2`,{className:`gate-title`,children:`Link expired`}),(0,V.jsx)(`p`,{className:`gate-subtitle`,children:`This invitation link has expired or has already been used. If you already set your password, sign in below. Otherwise, ask the agent owner to send a new invitation.`}),(0,V.jsx)(`div`,{className:`gate-actions`,children:(0,V.jsx)(_,{variant:`primary`,onClick:()=>{t(`sign-in`),w(null)},children:`Go to sign in`})})]})});case`otp-failed`:return(0,V.jsx)(`div`,{className:`gate-wrap`,children:(0,V.jsxs)(`div`,{className:`gate-card`,children:[(0,V.jsx)(`div`,{className:`gate-icon`,children:`⛔`}),(0,V.jsx)(`h2`,{className:`gate-title`,children:`Too many attempts`}),(0,V.jsx)(`p`,{className:`gate-subtitle`,children:`You've entered the wrong code too many times. Ask the agent owner to send a new code.`}),(0,V.jsx)(`div`,{className:`gate-actions`,children:(0,V.jsx)(_,{variant:`secondary`,onClick:()=>{t(`sign-in`),w(null),g(``)},children:`Back to sign in`})})]})})}}var H=100;function U(e){let t;try{t=JSON.parse(e)}catch(e){return{ok:!1,reason:`invalid JSON: ${e instanceof Error?e.message:String(e)}`}}if(typeof t!=`object`||!t||Array.isArray(t))return{ok:!1,reason:`payload is not a JSON object`};let n=t;if(typeof n.url!=`string`||n.url.length===0)return{ok:!1,reason:`url is required`};let r;try{r=new URL(n.url)}catch{return{ok:!1,reason:`url is not a valid URL`}}if(r.protocol!==`http:`&&r.protocol!==`https:`)return{ok:!1,reason:`url scheme ${r.protocol} is not permitted (http/https only)`};if(typeof n.intent!=`string`||n.intent.length===0)return{ok:!1,reason:`intent is required`};if(n.intent.length>H)return{ok:!1,reason:`intent exceeds ${H} chars`};let i;if(n.hostname!==void 0){if(typeof n.hostname!=`string`)return{ok:!1,reason:`hostname must be a string when provided`};i=n.hostname}return{ok:!0,payload:i?{url:n.url,intent:n.intent,hostname:i}:{url:n.url,intent:n.intent}}}var W={ok:`succeeded`,timeout:`navigation timed out`,"cdp-unreachable":`device browser is not responding`,error:`navigation error`};async function G(e,t){try{await fetch(`/api/admin/events`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({event:e,fields:t})})}catch(t){console.error(`[device-url:event] failed to post event`,e,t)}}function K({raw:e,reason:t}){return(0,A.useEffect)(()=>{G(`device-url:malformed`,{reason:t.slice(0,200),length:e.length})},[e,t]),(0,V.jsx)(`pre`,{className:`md-pre md-device-url-malformed`,children:(0,V.jsxs)(`code`,{className:`md-code`,children:[(0,V.jsxs)(`span`,{className:`md-device-url-malformed-label`,children:[(0,V.jsx)(O,{size:12}),` device-URL block is malformed: `,t]}),`
4
- `,e]})})}function q({payload:e,reason:t}){let[n,i]=(0,A.useState)(`idle`);(0,A.useEffect)(()=>{G(`device-url:fallback-shown`,{intent:e.intent,reason:t,hostname:e.hostname??``})},[e.intent,e.hostname,t]);let a=async()=>{if(await h(e.url)){i(`copied`),window.setTimeout(()=>i(`idle`),2e3);return}i(`failed`),G(`device-url:fallback-shown`,{intent:e.intent,reason:`clipboard-write-failed`,hostname:e.hostname??``})},o=e.hostname?` on the device (${e.hostname})`:` on the device`;return(0,V.jsxs)(`div`,{className:`md-device-url md-device-url-fallback`,role:`group`,children:[(0,V.jsxs)(`div`,{className:`md-device-url-fallback-message`,children:[(0,V.jsx)(O,{size:14}),(0,V.jsxs)(`span`,{children:[`Could not open `,(0,V.jsx)(`strong`,{children:e.intent}),o,` automatically (`,t,`). Copy the URL and open it in a browser on the device:`]})]}),(0,V.jsxs)(`div`,{className:`md-device-url-fallback-url`,children:[(0,V.jsx)(`code`,{children:e.url}),(0,V.jsxs)(`button`,{type:`button`,className:`md-device-url-fallback-copy`,onClick:a,"aria-label":`Copy URL`,children:[n===`copied`?(0,V.jsx)(r,{size:14}):(0,V.jsx)(y,{size:14}),n===`copied`?`Copied`:n===`failed`?`Copy failed`:`Copy`]})]}),n===`failed`&&(0,V.jsx)(`div`,{className:`md-device-url-fallback-copy-failed`,children:`Your browser blocked the copy action. Select the URL text above manually to copy it.`})]})}function J({payload:e}){let t=b(),[r,i]=(0,A.useState)({phase:`idle`});(0,A.useEffect)(()=>{G(`device-url:render`,{intent:e.intent,url:e.url,hostname:e.hostname??``,origin:`tool`})},[e.intent,e.url,e.hostname]);let a=async()=>{if(r.phase!==`navigating`){i({phase:`navigating`});try{let n=await fetch(`/api/admin/device-browser/navigate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),r=await n.json().catch(()=>({}));if(n.ok&&r.ok){i({phase:`succeeded`}),t&&(t.onShowVnc(),G(`device-url:vnc-surface-shown`,{intent:e.intent})),window.setTimeout(()=>i({phase:`idle`}),2500);return}i({phase:`fallback`,reason:r.navigateResult?W[r.navigateResult]:r.detail?r.detail.slice(0,80):`navigation failed`})}catch(e){i({phase:`fallback`,reason:(e instanceof Error?e.message:String(e)).slice(0,80)})}}},o=r.phase===`navigating`,s=r.phase===`succeeded`;return(0,V.jsxs)(`div`,{className:`md-device-url`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`md-device-url-button`,onClick:a,disabled:o,"aria-label":`Open ${e.intent} on the device's browser`,title:e.hostname?`Opens on device: ${e.hostname}`:`Opens on the device running Maxy`,children:[(0,V.jsx)(n,{size:16,className:`md-device-url-icon`}),(0,V.jsx)(`span`,{className:`md-device-url-label`,children:o?`Opening…`:s?`Opened on device`:`Open ${e.intent} on device`})]}),r.phase===`fallback`&&(0,V.jsx)(q,{payload:e,reason:r.reason})]})}function Y({source:e}){let t=U(e.trim());return t.ok?(0,V.jsx)(J,{payload:t.payload}):(0,V.jsx)(K,{raw:e,reason:t.reason})}var X=`modulepreload`,ae=function(e){return`/`+e},Z={},Q=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=ae(t,n),t in Z)return;Z[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:X,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},$=null;function oe(){return $||=Q(async()=>{let{default:e}=await import(`./mermaid.core-BKzdtZgG.js`);return{default:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20])).then(({default:e})=>(e.initialize({startOnLoad:!1,theme:`neutral`}),e)),$}function se({source:e}){let t=(0,A.useRef)(null),[n,r]=(0,A.useState)(null);return(0,A.useEffect)(()=>{let n=!1,i=`mermaid-${Math.random().toString(36).slice(2,9)}`;return oe().then(t=>t.render(i,e)).then(({svg:e})=>{!n&&t.current&&(t.current.innerHTML=e)}).catch(t=>{n||(console.error(`[MermaidBlock] render failed:`,e,t),r(t instanceof Error?t.message:`Diagram render failed`))}),()=>{n=!0}},[e]),n?(0,V.jsxs)(`div`,{className:`md-mermaid md-mermaid-error`,children:[(0,V.jsx)(`div`,{className:`md-mermaid-error-label`,children:`Diagram render error`}),(0,V.jsx)(`pre`,{className:`md-pre`,children:(0,V.jsx)(`code`,{className:`md-code`,children:e})})]}):(0,V.jsx)(`div`,{className:`md-mermaid`,ref:t})}var ce=/\.(mp4|webm|mov)(\?.*)?$/i,le=/(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/,ue=/vimeo\.com\/(\d+)/;function de(e){return!!e&&ce.test(e)}function fe(e){if(!e)return null;let t=e.match(le);return t?t[1]:null}function pe(e){if(!e)return null;let t=e.match(ue);return t?t[1]:null}function me({src:e}){return(0,V.jsx)(`video`,{className:`md-video`,controls:!0,playsInline:!0,preload:`metadata`,children:(0,V.jsx)(`source`,{src:e})})}function he({videoId:e}){return(0,V.jsx)(`div`,{className:`md-video-iframe`,children:(0,V.jsx)(`iframe`,{src:`https://www.youtube-nocookie.com/embed/${e}`,allow:`accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture`,allowFullScreen:!0,loading:`lazy`})})}function ge({videoId:e}){return(0,V.jsx)(`div`,{className:`md-video-iframe`,children:(0,V.jsx)(`iframe`,{src:`https://player.vimeo.com/video/${e}`,allow:`autoplay; fullscreen; picture-in-picture`,allowFullScreen:!0,loading:`lazy`})})}function _e(e){if(de(e))return(0,V.jsx)(me,{src:e});let t=fe(e);if(t)return(0,V.jsx)(he,{videoId:t});let n=pe(e);return n?(0,V.jsx)(ge,{videoId:n}):null}var ve={p:({children:e})=>(0,V.jsx)(`p`,{className:`md-p`,children:e}),h1:({children:e})=>(0,V.jsx)(`h1`,{className:`md-heading`,children:e}),h2:({children:e})=>(0,V.jsx)(`h2`,{className:`md-heading`,children:e}),h3:({children:e})=>(0,V.jsx)(`h3`,{className:`md-heading`,children:e}),code:({children:e,className:t})=>t===`language-mermaid`?(0,V.jsx)(se,{source:String(e).replace(/\n$/,``)}):t===`language-maxy-device-url`?(0,V.jsx)(Y,{source:String(e).replace(/\n$/,``)}):(0,V.jsx)(`code`,{className:`md-code ${t||``}`.trim(),children:e}),pre:({children:e,node:t})=>{let n=t?.children?.[0];if(n?.type===`element`&&n.tagName===`code`){let t=n.properties?.className??[];if(t.includes(`language-mermaid`)||t.includes(`language-maxy-device-url`))return(0,V.jsx)(V.Fragment,{children:e})}return(0,V.jsx)(`pre`,{className:`md-pre`,children:e})},ul:({children:e})=>(0,V.jsx)(`ul`,{className:`md-list`,children:e}),ol:({children:e})=>(0,V.jsx)(`ol`,{className:`md-list md-list-ordered`,children:e}),li:({children:e})=>(0,V.jsx)(`li`,{className:`md-list-item`,children:e}),hr:()=>(0,V.jsx)(`hr`,{className:`md-hr`}),strong:({children:e})=>(0,V.jsx)(`strong`,{className:`md-strong`,children:e}),img:({src:e,alt:t})=>_e(e)||(0,V.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,children:(0,V.jsx)(`img`,{className:`md-img`,src:e,alt:t||``,loading:`lazy`})}),a:({href:e,children:t})=>_e(e)||(0,V.jsx)(`a`,{href:e,className:`md-link`,target:`_blank`,rel:`noopener noreferrer`,children:t}),table:({children:e})=>(0,V.jsx)(`table`,{className:`md-table`,children:e}),thead:({children:e})=>(0,V.jsx)(`thead`,{className:`md-thead`,children:e}),tbody:({children:e})=>(0,V.jsx)(`tbody`,{children:e}),tr:({children:e})=>(0,V.jsx)(`tr`,{className:`md-tr`,children:e}),th:({children:e})=>(0,V.jsx)(`th`,{className:`md-th`,children:e}),td:({children:e})=>(0,V.jsx)(`td`,{className:`md-td`,children:e})};function ye({content:e,elapsedSeconds:t,timestamp:n}){return(0,V.jsxs)(`div`,{className:`markdown-message`,children:[(0,V.jsx)(v,{remarkPlugins:[g],components:ve,children:e}),t!==void 0&&(0,V.jsxs)(`div`,{className:`message-meta`,children:[t,`s`]}),n&&(0,V.jsx)(`span`,{className:`message-timestamp`,children:n})]})}function be({submitted:e,submittedLabel:t=`Submitted`,actions:n,children:r}){return(0,V.jsxs)(`div`,{className:`component-card${e?` component-card--submitted`:``}`,children:[r,(0,V.jsx)(`div`,{className:`component-card__actions`,children:e?(0,V.jsx)(`span`,{className:`component-card__done-label`,children:t}):n.map((e,t)=>(0,V.jsx)(_,{variant:e.variant,size:`sm`,disabled:e.disabled,onClick:e.onClick,children:e.label},t))})]})}function xe({data:e,onSubmit:t,submitted:n}){let r=e,i=Array.isArray(r?.options)?r.options:[],[a,o]=(0,A.useState)(null),[s,c]=(0,A.useState)(`Submitted`);if(i.length===0)return null;let l=e=>{n||o(e)},u=()=>{if(!a||n)return;let e=i.find(e=>e.value===a);c(e?.label??`Submitted`),t((r?.submitMessage??`Selected: {{value}}`).replace(`{{value}}`,a).replace(`{{label}}`,e?.label??a))},d=()=>{n||(c(r?.backLabel??`Back`),t(r?.backMessage??``))},f=(e,t)=>{if(!n)if(e.key===`ArrowDown`||e.key===`ArrowRight`){e.preventDefault();let n=(t+1)%i.length;l(i[n].value),(e.currentTarget.parentElement?.children[n])?.focus()}else if(e.key===`ArrowUp`||e.key===`ArrowLeft`){e.preventDefault();let n=(t-1+i.length)%i.length;l(i[n].value),(e.currentTarget.parentElement?.children[n])?.focus()}else (e.key===` `||e.key===`Enter`)&&(e.preventDefault(),l(i[t].value))};return(0,V.jsx)(be,{submitted:n,submittedLabel:s,actions:[...r?.backLabel&&r?.backMessage?[{label:r.backLabel,variant:`ghost`,onClick:d}]:[],{label:r?.submitLabel??`Confirm`,variant:`primary`,disabled:!a,onClick:u}],children:(0,V.jsxs)(`div`,{className:`single-select`,role:`radiogroup`,"aria-label":r?.title??`Select one`,children:[r?.title&&(0,V.jsx)(`div`,{className:`single-select__title`,children:r.title}),i.map((e,t)=>(0,V.jsxs)(`div`,{className:`single-select__row${a===e.value?` single-select__row--selected`:``}`,role:`radio`,"aria-checked":a===e.value,tabIndex:a===e.value||!a&&t===0?0:-1,onClick:()=>l(e.value),onKeyDown:e=>f(e,t),children:[(0,V.jsx)(`span`,{className:`single-select__radio${a===e.value?` single-select__radio--checked`:``}`}),(0,V.jsxs)(`div`,{className:`single-select__info`,children:[(0,V.jsxs)(`span`,{className:`single-select__label`,children:[e.icon&&(0,V.jsx)(`span`,{className:`single-select__icon`,children:e.icon}),e.label]}),e.description&&(0,V.jsx)(`span`,{className:`single-select__desc`,children:e.description})]})]},e.value))]})})}function Se({data:e,onSubmit:t,submitted:n}){let r=e,i=Array.isArray(r?.options)?r.options:[],[a,o]=(0,A.useState)(i.map(e=>!!e.locked||!!e.defaultSelected)),[s,c]=(0,A.useState)(`Submitted`);if(i.length===0)return null;let l=i.some(e=>e.locked),u=i.every((e,t)=>e.locked||a[t]),d=e=>{n||i[e].locked||o(t=>t.map((t,n)=>n===e?!t:t))},f=()=>{n||o(i.map((e,t)=>e.locked?a[t]:!u))},p=i.filter((e,t)=>!e.locked&&a[t]).map(e=>e.value),m=p.length>0||l,h=()=>{if(!(!m||n)){if(c(`Submitted`),p.length===0){t(`No optional plugins selected`);return}t((r?.submitMessage??`Selected: {{values}}`).replace(`{{values}}`,p.join(`, `)))}},g=()=>{n||(c(`Skipped`),t(r?.skipMessage??`Skipped`))},_=()=>{n||(c(r?.backLabel??`Back`),t(r?.backMessage??``))},v=[];return r?.backLabel&&r?.backMessage&&v.push({label:r.backLabel,variant:`ghost`,onClick:_}),r?.skipLabel&&v.push({label:r.skipLabel,variant:`ghost`,onClick:g}),v.push({label:r?.submitLabel??`Confirm`,variant:`primary`,disabled:!m,onClick:h}),(0,V.jsx)(be,{submitted:n,submittedLabel:s,actions:v,children:(0,V.jsxs)(`div`,{className:`multi-select`,children:[r?.title&&(0,V.jsx)(`div`,{className:`multi-select__title`,children:r.title}),r?.selectAll&&(0,V.jsx)(`div`,{className:`multi-select__header`,children:(0,V.jsx)(x,{checked:u,onChange:f,label:`Select all`,disabled:n})}),(0,V.jsx)(`div`,{className:`multi-select__list`,role:`group`,"aria-label":r?.title??`Select options`,children:i.map((e,t)=>{let r=e.group&&(t===0||e.group!==i[t-1].group),o=!!e.locked;return(0,V.jsxs)(A.Fragment,{children:[r&&(0,V.jsx)(`div`,{className:`multi-select__group-header`,children:e.group}),(0,V.jsxs)(`div`,{className:`multi-select__row${o?` multi-select__row--locked`:``}`,role:`checkbox`,"aria-checked":a[t],"aria-disabled":o||void 0,tabIndex:o?-1:0,onClick:()=>d(t),onKeyDown:e=>{n||o||(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),d(t))},children:[(0,V.jsx)(x,{checked:a[t],onChange:()=>d(t),disabled:n||o}),(0,V.jsxs)(`div`,{className:`multi-select__info`,children:[(0,V.jsxs)(`span`,{className:`multi-select__label`,children:[e.label,e.badge&&(0,V.jsx)(`span`,{className:`multi-select__badge`,children:e.badge})]}),e.description&&(0,V.jsx)(`span`,{className:`multi-select__desc`,children:e.description})]})]})]},e.value)})})]})})}function Ce({data:e,onSubmit:t,submitted:n}){let r=e,i=Array.isArray(r?.buttons)?r.buttons:[],[a,o]=(0,A.useState)(`Submitted`);if(i.length===0)return null;let s=e=>{n||(o(e.label),t(e.value))};return(0,V.jsx)(be,{submitted:n,submittedLabel:a,actions:i.map(e=>({label:e.label,variant:`primary`,onClick:()=>s(e)})),children:(0,V.jsx)(V.Fragment,{})})}var we={"single-select":xe,"multi-select":Se,"action-buttons":Ce};function Te({name:e,data:t,onSubmit:n,submitted:r}){let i=we[e];return i?(0,V.jsx)(i,{data:t,onSubmit:n,submitted:r}):(console.warn(`[PublicComponentRenderer] Unknown component: "${e}". Registered: ${Object.keys(we).join(`, `)}`),(0,V.jsx)(`div`,{className:`component-card component-card--error`,children:(0,V.jsxs)(`p`,{style:{fontFamily:`var(--font-body)`,fontSize:12,color:`var(--text-secondary)`},children:[`Component “`,e,`” is not available. This may require a platform update.`]})}))}function Ee(e){let t=new Date(e),n=new Date,r=String(t.getHours()).padStart(2,`0`),i=String(t.getMinutes()).padStart(2,`0`),a=String(t.getSeconds()).padStart(2,`0`);return t.toDateString()===n.toDateString()?`${r}:${i}:${a}`:`${String(t.getDate()).padStart(2,`0`)}-${String(t.getMonth()+1).padStart(2,`0`)}-${t.getFullYear()} ${r}:${i}:${a}`}function De({messages:e,isStreaming:t,sessionError:n,selectionMode:r,selectedItems:i,toggleSelectItem:a,onComponentSubmit:s,remainingSuggestions:c,onSuggestionClick:l,isAtBottom:u,setIsAtBottom:d,isGroup:f,sessionId:m}){let[h,g]=(0,A.useState)(new Set),[v,y]=(0,A.useState)(new Set),b=(0,A.useRef)(null),C=(0,A.useRef)(null),w=(0,A.useRef)(null),T=(0,A.useRef)(!1),E=(0,A.useRef)(!1),D=(0,A.useRef)(!1),O=(0,A.useRef)(0),k=(0,A.useRef)(!1),j=(0,A.useRef)(new Map);k.current=t,(0,A.useEffect)(()=>{t&&!T.current&&u&&(E.current=!0)},[t,u]),(0,A.useEffect)(()=>{if(!E.current&&!u){T.current=t,D.current=!1;return}if(T.current&&!t&&w.current&&C.current){let e=w.current;if(e.offsetHeight>C.current.clientHeight){E.current=!1,D.current=!0,e.scrollIntoView({behavior:`smooth`,block:`start`}),T.current=t;return}}(u||E.current)&&!D.current&&b.current?.scrollIntoView({behavior:`smooth`}),T.current&&!t&&(E.current=!1),T.current=t},[e,u,t]),(0,A.useEffect)(()=>{let e=C.current;if(!e)return;let t=()=>{let t=e.scrollTop;k.current&&t<O.current&&(E.current=!1),O.current=t,d(e.scrollHeight-e.scrollTop-e.clientHeight<80)};return e.addEventListener(`scroll`,t,{passive:!0}),t(),()=>e.removeEventListener(`scroll`,t)},[d]),(0,A.useEffect)(()=>{function e(){y(e=>{let t=new Set;return j.current.forEach((n,r)=>{n.isConnected&&(h.has(r)?e.has(r)&&t.add(r):n.scrollHeight>n.clientHeight+2&&t.add(r))}),e.size===t.size&&[...e].every(e=>t.has(e))?e:t})}e();let t=new ResizeObserver(e);return j.current.forEach(e=>t.observe(e)),()=>t.disconnect()},[e.length,h]);let M=[...e].sort((e,t)=>e.timestamp-t.timestamp);(0,A.useEffect)(()=>{r&&console.log(`[selection] entered`,{conversationId:m??`unknown`,order:M.map(e=>({ts:e.timestamp,role:e.role,id:e.messageId}))})},[r]);let N=M.reduce((e,t,n)=>t.role===`maxy`&&!t.hidden?n:e,-1);return(0,V.jsxs)(`div`,{className:`chat-messages-wrap`,children:[r&&(0,V.jsx)(`div`,{className:`selection-overlay-band`}),(0,V.jsxs)(`div`,{className:`chat-messages`,ref:C,children:[n&&e.length===0&&(0,V.jsx)(`div`,{className:`session-error`,children:(0,V.jsx)(`p`,{children:n})}),M.map((e,n)=>{if(e.hidden)return null;let c=t&&n===M.length-1,l=`${e.timestamp}_${e.role}`,u=i.has(l);return(0,V.jsxs)(`div`,{ref:n===N?w:void 0,className:`message ${e.role}${u?` selected`:``}`,children:[r&&!c&&(0,V.jsx)(`div`,{className:`message-select-check`,children:(0,V.jsx)(x,{checked:u,onChange:()=>a(l)})}),(0,V.jsxs)(`div`,{className:`bubble`,children:[f&&e.role===`visitor`&&e.senderName&&(0,V.jsx)(`span`,{className:`bubble-sender`,children:e.senderName}),e.role===`visitor`&&e.content?(()=>{let t=h.has(n),r=v.has(n);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{ref:e=>{e?j.current.set(n,e):j.current.delete(n)},className:t?`bubble-content`:`bubble-content clamped${r?` overflowing`:``}`,children:e.content}),r&&(0,V.jsx)(`div`,{className:`bubble-expand`,children:(0,V.jsx)(_,{variant:`icon`,className:t?`expanded`:``,onClick:()=>g(e=>{let t=new Set(e);return t.has(n)?t.delete(n):t.add(n),t}),"aria-label":t?`Collapse message`:`Expand message`,children:(0,V.jsx)(p,{size:14})})})]})})():e.content?(0,V.jsx)(ye,{content:e.content,timestamp:Ee(e.timestamp)}):(0,V.jsxs)(`span`,{className:`typing-indicator`,children:[(0,V.jsx)(`span`,{className:`typing-dot`}),(0,V.jsx)(`span`,{className:`typing-dot`}),(0,V.jsx)(`span`,{className:`typing-dot`})]}),e.attachments&&e.attachments.length>0&&(0,V.jsx)(`div`,{className:`message-attachments`,children:e.attachments.map((e,t)=>(0,V.jsxs)(`span`,{className:`message-attachment-chip no-action`,children:[e.mimeType===`application/pdf`?(0,V.jsx)(o,{size:12}):e.mimeType.startsWith(`text/`)?(0,V.jsx)(S,{size:12}):null,(0,V.jsx)(`span`,{children:e.filename})]},t))}),e.role===`visitor`&&(0,V.jsx)(`span`,{className:`message-timestamp`,children:Ee(e.timestamp)})]}),e.role===`maxy`&&e.components&&e.components.length>0&&(0,V.jsx)(`div`,{className:`public-components`,children:e.components.map((e,t)=>(0,V.jsx)(`div`,{className:`public-component-enter`,children:(0,V.jsx)(Te,{name:e.name,data:e.data,onSubmit:e=>s(n,t,e),submitted:e.submitted})},t))})]},n)}),!t&&c.length>0&&(0,V.jsx)(`div`,{className:`chat-suggestions`,children:c.map(e=>(0,V.jsx)(_,{variant:`suggestion`,onClick:()=>l(e),children:e},e))}),(0,V.jsx)(`div`,{ref:b})]}),!u&&(0,V.jsx)(`button`,{className:`scroll-to-bottom`,onClick:()=>b.current?.scrollIntoView({behavior:`smooth`}),"aria-label":`Scroll to bottom`,children:(0,V.jsx)(p,{size:18})})]})}function Oe({selectedItems:e,messages:t,isStreaming:n,copySelected:r,selectAll:i,exitSelection:a,showCopyToast:o}){let[s,c]=(0,A.useState)(!1),l=(0,A.useRef)(null),u=(0,A.useRef)(!1);function d(e){let n=e.lastIndexOf(`_`),r=e.slice(0,n),i=e.slice(n+1),a=parseInt(r,10);return t.find(e=>e.timestamp===a&&e.role===i)?.content??``}function f(e,t){return parseInt(e.slice(0,e.lastIndexOf(`_`)),10)-parseInt(t.slice(0,t.lastIndexOf(`_`)),10)}function p(){let e=[...t].sort((e,t)=>e.timestamp-t.timestamp),n=[];for(let t of e){if(t.hidden||!t.content)continue;let e=t.role===`visitor`?`Visitor`:`Maxy`;n.push(`${e}:\n${t.content}`)}return n.join(`
5
-
6
- ---
7
-
8
- `)}A.useEffect(()=>{if(!s)return;let e=e=>{e.target.closest(`.selection-copy-wrap`)||c(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[s]);function m(){l.current!==null&&(clearTimeout(l.current),l.current=null)}let g=[...t].sort((e,t)=>e.timestamp-t.timestamp),_=g.reduce((e,t,r)=>(t.hidden||n&&r===g.length-1||e.push(`${t.timestamp}_${t.role}`),e),[]),v=_.length>0&&_.every(t=>e.has(t));return(0,V.jsx)(`div`,{className:`chat-input-area`,children:(0,V.jsxs)(`div`,{className:`selection-bar`,children:[(0,V.jsxs)(`div`,{className:`selection-bar-left`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`selection-select-all`,onClick:()=>i(_),disabled:_.length===0,"aria-label":v?`Deselect all`:`Select all`,title:v?`Deselect all`:`Select all`,children:[(0,V.jsx)(E,{size:16}),(0,V.jsx)(`span`,{children:v?`Deselect all`:`Select all`})]}),(0,V.jsxs)(`span`,{className:`selection-count`,children:[e.size,` Selected`]})]}),(0,V.jsxs)(`div`,{className:`selection-copy-wrap`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`selection-copy`,onPointerDown:()=>{if(s){c(!1);return}u.current=!1,l.current=setTimeout(()=>{u.current=!0,c(!0),l.current=null},500)},onPointerUp:m,onPointerLeave:m,onPointerCancel:m,onClick:async()=>{u.current||await r(d,f)},children:[(0,V.jsx)(y,{size:18}),(0,V.jsx)(`span`,{children:`Copy`})]}),s&&(0,V.jsx)(`div`,{className:`copy-menu`,children:(0,V.jsx)(`button`,{type:`button`,className:`copy-menu-item`,onClick:async()=>{let e=p();e&&o(await h(e)),a()},children:`Copy all`})})]}),(0,V.jsx)(`button`,{type:`button`,className:`selection-cancel`,onClick:a,children:`Cancel`})]})})}var ke=44,Ae=(0,A.forwardRef)(function({value:e,onChange:t,placeholder:n,disabled:r},i){let a=(0,A.useRef)(null),o=(0,A.useRef)(!1),s=(0,A.useCallback)((e,t)=>{let n=e.closest(`.chat-form`);n&&(n.dataset.expanded=t>ke?`true`:``)},[]),c=(0,A.useCallback)(e=>{if(o.current)return;let t=window.innerHeight*.75;e.style.height=`auto`;let n=Math.min(e.scrollHeight,t);e.style.height=`${n}px`,e.style.overflowY=e.scrollHeight>t?`auto`:`hidden`,s(e,n)},[s]);return(0,A.useImperativeHandle)(i,()=>({focus(){a.current?.focus()},resetHeight(){if(!a.current)return;o.current=!1,a.current.style.height=``,a.current.style.overflowY=``;let e=a.current.closest(`.chat-form`);e&&(e.dataset.expanded=``)},getOffsetHeight(){return a.current?.offsetHeight??36},setHeight(e){a.current&&(o.current=!0,a.current.style.height=`${e}px`,s(a.current,e))}})),(0,V.jsx)(`textarea`,{ref:a,className:`chat-input`,rows:1,value:e,onChange:e=>{t(e.target.value),c(e.target)},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),e.currentTarget.closest(`form`)?.requestSubmit())},placeholder:n,disabled:r,"aria-label":n||`Type a message...`})});function je({inputRef:e}){let t=(0,A.useRef)(null);function n(n){e.current&&(n.preventDefault(),n.target.setPointerCapture(n.pointerId),t.current={startY:n.clientY,startH:e.current.getOffsetHeight()})}function r(n){if(!t.current||!e.current)return;let r=t.current.startY-n.clientY,i=window.innerHeight*.75,a=Math.max(36,Math.min(i,t.current.startH+r));e.current.setHeight(a)}function i(){t.current=null}return(0,V.jsx)(`div`,{className:`chat-resize-handle`,onPointerDown:n,onPointerMove:r,onPointerUp:i,"aria-label":`Resize input`,children:(0,V.jsx)(`div`,{className:`chat-resize-handle-bar`})})}function Me(e){return`${Math.floor(e/60)}:${(e%60).toString().padStart(2,`0`)}`}function Ne({data:e,active:t}){let n=[];if(e&&e.length>0&&t){let t=Math.floor(e.length/24);for(let r=0;r<24;r++){let i=e[r*t]??128,a=Math.abs(i-128)/128;n.push(Math.max(.15,a))}}else for(let e=0;e<24;e++)n.push(.15);return(0,V.jsx)(`div`,{className:`voice-waveform`,"aria-hidden":`true`,children:n.map((e,t)=>(0,V.jsx)(`div`,{className:`voice-waveform-bar`,style:{height:`${Math.round(e*100)}%`}},t))})}function Pe({state:e,elapsedSeconds:t,waveform:n,onTogglePause:r,onDiscard:i,onSend:a}){if(e===`idle`||e===`error`)return null;let o=e===`recording`,s=e===`paused`,l=e===`sending`;return(0,V.jsxs)(`div`,{className:`voice-recorder`,role:`region`,"aria-label":`Voice recording`,"aria-live":`polite`,children:[(0,V.jsx)(`button`,{type:`button`,className:`voice-trash`,onClick:i,disabled:l,"aria-label":`Discard recording`,children:(0,V.jsx)(c,{size:16})}),(0,V.jsx)(`span`,{className:`voice-timer`,"aria-live":`polite`,"aria-atomic":`true`,children:Me(t)}),(0,V.jsx)(Ne,{data:n,active:o}),(0,V.jsx)(`button`,{type:`button`,className:`voice-pause`,onClick:r,disabled:l,"aria-label":s?`Resume recording`:`Pause recording`,children:s?(0,V.jsx)(d,{size:14}):(0,V.jsx)(T,{size:14})}),(0,V.jsx)(_,{variant:`send`,type:`button`,onClick:a,disabled:l,loading:l,"aria-label":`Send voice note`,children:(0,V.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,V.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,V.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]})}var Fe=[`audio/ogg;codecs=opus`,`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`];function Ie(){for(let e of Fe)if(MediaRecorder.isTypeSupported(e))return e;return``}function Le(e){return e.split(`;`)[0]}function Re(){let[e,t]=(0,A.useState)(`idle`),[n,r]=(0,A.useState)(0),[i,a]=(0,A.useState)(null),[o,s]=(0,A.useState)(null),c=(0,A.useRef)(null),l=(0,A.useRef)(null),u=(0,A.useRef)([]),d=(0,A.useRef)(``),f=(0,A.useRef)(null),p=(0,A.useRef)(0),m=(0,A.useRef)(0),h=(0,A.useRef)(null),g=(0,A.useRef)(null),_=(0,A.useRef)(0),v=(0,A.useCallback)(()=>{if(f.current&&=(clearInterval(f.current),null),_.current&&=(cancelAnimationFrame(_.current),0),c.current&&c.current.state!==`inactive`)try{c.current.stop()}catch{}c.current=null,u.current=[],l.current&&=(l.current.getTracks().forEach(e=>e.stop()),null),h.current&&(h.current.close().catch(()=>{}),h.current=null,g.current=null),m.current=0,p.current=0},[]);(0,A.useEffect)(()=>v,[v]);let y=(0,A.useCallback)(()=>{p.current=Date.now(),f.current=setInterval(()=>{let e=Date.now()-p.current,t=m.current+e;r(Math.floor(t/1e3))},200)},[]),b=(0,A.useCallback)(()=>{f.current&&=(clearInterval(f.current),null);let e=Date.now()-p.current;m.current+=e},[]),x=(0,A.useCallback)(()=>{let e=g.current;if(!e)return;let t=new Uint8Array(e.frequencyBinCount),n=()=>{e.getByteTimeDomainData(t),a(new Uint8Array(t)),_.current=requestAnimationFrame(n)};n()},[]),S=(0,A.useCallback)(()=>{_.current&&=(cancelAnimationFrame(_.current),0)},[]),C=(0,A.useCallback)(async()=>{if(!(e!==`idle`&&e!==`error`)){if(s(null),typeof window<`u`&&!window.isSecureContext){t(`error`),s(`Voice recording requires a secure connection (HTTPS). Use your tunnel URL for voice notes.`);return}if(typeof navigator>`u`||!navigator.mediaDevices?.getUserMedia){t(`error`),s(`Voice recording is not supported in this browser.`);return}if(typeof MediaRecorder>`u`){t(`error`),s(`Voice recording is not supported in this browser.`);return}try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});l.current=e;let n=new AudioContext;h.current=n;let i=n.createMediaStreamSource(e),o=n.createAnalyser();o.fftSize=256,i.connect(o),g.current=o;let s=Ie();d.current=s;let f=new MediaRecorder(e,s?{mimeType:s}:void 0);c.current=f,u.current=[],f.ondataavailable=e=>{e.data.size>0&&u.current.push(e.data)},e.getAudioTracks()[0]?.addEventListener(`ended`,()=>{v(),t(`idle`),r(0),a(null)}),f.start(1e3),t(`recording`),r(0),y(),x()}catch(e){v(),t(`error`),e instanceof DOMException?e.name===`NotAllowedError`?s(`Microphone access was denied. Check your browser permissions to enable voice recording.`):e.name===`NotFoundError`?s(`No microphone found. Connect a microphone to use voice recording.`):s(`Microphone error: ${e.message}`):s(`Could not start recording.`)}}},[e,v,y,x]),w=(0,A.useCallback)(()=>{let n=c.current;n&&(e===`recording`&&n.state===`recording`?(n.pause(),b(),S(),t(`paused`)):e===`paused`&&n.state===`paused`&&(n.resume(),y(),x(),t(`recording`)))},[e,b,y,x,S]),T=(0,A.useCallback)(()=>{e!==`recording`&&e!==`paused`||(v(),t(`idle`),r(0),a(null))},[e,v]),E=(0,A.useCallback)(async()=>{if(e!==`recording`&&e!==`paused`)return null;let n=c.current;if(!n)return null;let i=e===`recording`?Date.now()-p.current:0;return m.current+i<1e3?(T(),null):(t(`sending`),b(),S(),new Promise(e=>{n.onstop=()=>{let i=d.current||n.mimeType||`audio/webm`,o=new Blob(u.current,{type:Le(i)});v(),t(`idle`),r(0),a(null),e(o.size>0?o:null)},n.stop()}))},[e,T,b,S,v]);return(0,A.useEffect)(()=>{if(e!==`error`)return;let n=setTimeout(()=>{t(`idle`),s(null)},8e3);return()=>clearTimeout(n)},[e]),{state:e,elapsedSeconds:n,waveform:i,errorMessage:o,start:C,togglePause:w,discard:T,send:E}}function ze(e,t){let n=e.split(`;`)[0].trim().toLowerCase();return t.has(n)}function Be({input:e,setInput:t,isStreaming:n,pendingFiles:r,setPendingFiles:i,attachError:a,setAttachError:s,isDragOver:c,setIsDragOver:l,inputRef:u,onSubmit:d,onSendVoiceNote:f}){let p=(0,A.useRef)(null),m=Re(),h=m.state===`recording`||m.state===`paused`||m.state===`sending`,g=!h&&!n&&!e.trim()&&r.length===0;async function v(){let e=await m.send();if(!e)return;let t=e.type===`audio/ogg`?`.ogg`:e.type===`audio/mp4`?`.m4a`:`.webm`;f(new File([e],`voice-note${t}`,{type:e.type}))}function y(e){s(null);let t=e.find(e=>!ze(e.type,M));if(t){s(`Unsupported file type: "${t.type}". Supported: images, PDF, plain text, markdown, CSV, calendar, voice notes.`);return}let n=e.find(e=>e.size>N);if(n){s(`"${n.name}" exceeds the 50 MB limit.`);return}i(t=>[...t,...e].slice(0,5))}function b(e){e.preventDefault(),l(!0)}function x(){l(!1)}function T(e){e.preventDefault(),l(!1),y([...e.dataTransfer.files])}return(0,V.jsxs)(`div`,{className:`chat-input-area`,children:[(0,V.jsx)(`input`,{ref:p,type:`file`,multiple:!0,accept:j,style:{display:`none`},onChange:e=>{e.target.files&&y([...e.target.files]),e.target.value=``}}),r.length>0&&(0,V.jsx)(`div`,{className:`attachment-strip`,children:r.map((e,t)=>(0,V.jsxs)(`div`,{className:`attachment-chip`,children:[e.type.startsWith(`image/`)?(0,V.jsx)(`img`,{src:URL.createObjectURL(e),alt:e.name,className:`attachment-chip-thumb`}):e.type.startsWith(`audio/`)?(0,V.jsx)(C,{size:14}):e.type===`application/pdf`?(0,V.jsx)(o,{size:14}):(0,V.jsx)(S,{size:14}),(0,V.jsx)(`span`,{className:`attachment-chip-name`,children:e.name}),(0,V.jsx)(`button`,{type:`button`,className:`attachment-chip-remove`,onClick:()=>i(e=>e.filter((e,n)=>n!==t)),"aria-label":`Remove ${e.name}`,children:`×`})]},t))}),a&&(0,V.jsx)(`p`,{className:`attach-error`,children:a}),m.state===`error`&&m.errorMessage&&(0,V.jsxs)(`p`,{className:`voice-error`,role:`alert`,children:[(0,V.jsx)(C,{size:14}),m.errorMessage]}),(0,V.jsx)(je,{inputRef:u}),h?(0,V.jsx)(`div`,{className:`chat-form voice-active`,children:(0,V.jsx)(Pe,{state:m.state,elapsedSeconds:m.elapsedSeconds,waveform:m.waveform,onTogglePause:m.togglePause,onDiscard:m.discard,onSend:v})}):(0,V.jsxs)(`form`,{className:`chat-form${c?` drag-over`:``}`,onSubmit:d,onDragOver:b,onDragLeave:x,onDrop:T,onPaste:e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e of t){if(e.kind!==`file`)continue;let t=e.getAsFile();if(!t)continue;let r=t.type.split(`/`)[1]?.replace(`jpeg`,`jpg`)||`png`;n.push(new File([t],`pasted-image-${Date.now()}.${r}`,{type:t.type}))}n.length>0&&y(n)},children:[(0,V.jsx)(_,{variant:`icon`,type:`button`,onClick:()=>p.current?.click(),disabled:n,"aria-label":`Attach file`,children:(0,V.jsx)(w,{size:14})}),(0,V.jsx)(Ae,{ref:u,value:e,onChange:t}),g?(0,V.jsx)(_,{variant:`send`,type:`button`,onClick:m.start,disabled:n,"aria-label":`Record voice note`,children:(0,V.jsx)(C,{size:14})}):(0,V.jsx)(_,{variant:`send`,type:`submit`,disabled:n||!e.trim()&&r.length===0,"aria-label":`Send message`,children:(0,V.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,V.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,V.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]})]})}var Ve=[];function He(){let[e,t]=(0,A.useState)(``),[n,r]=(0,A.useState)([]),[i,a]=(0,A.useState)(!1),[o,c]=(0,A.useState)(null),[l,d]=(0,A.useState)(Ve),[p,h]=(0,A.useState)(!0),g=(0,A.useRef)(null),{selectionMode:_,selectedItems:v,copyToast:y,exitSelection:b,enterSelection:x,toggleSelectItem:S,selectAll:C,copySelected:w,showCopyToast:T}=m(),O=(0,A.useRef)(()=>{}),k=z((0,A.useCallback)(e=>{O.current(e)},[])),{sessionId:j,cacheKeyRef:M,sessionError:N,pageState:P,agentDisplayName:ee,agentImage:F,agentImageShape:I,showAgentName:L,branding:R,ensureSession:B,startNewSession:re,resumedRef:H,resumeMessagesRef:U,groupContext:W,groupSlug:G}=k,{messages:K,setMessages:q,isStreaming:J,sendMessage:Y,sendGreeting:X,handleComponentSubmit:ae}=te({cacheKeyRef:M,ensureSession:B,sessionError:N,pageState:P,inputRef:g});(0,A.useEffect)(()=>{O.current=X},[X]),ne({cacheKeyRef:M,groupSlug:G,isStreaming:J,setMessages:q}),(0,A.useEffect)(()=>{let e=!1;return(async()=>{let t=await B();if(!e&&t){if(H.current&&U.current&&U.current.length>0){let e=U.current.map(e=>({role:e.role,content:e.content,timestamp:e.timestamp}));e.sort((e,t)=>e.timestamp-t.timestamp),q(e),U.current=null;return}X(t)}})(),()=>{e=!0}},[]),(0,A.useEffect)(()=>{P===`chat`&&g.current?.focus()},[P]),(0,A.useEffect)(()=>{if(P!==`chat`)return;history.pushState({maxyChat:!0},``);function e(){history.pushState({maxyChat:!0},``)}return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[P]),(0,A.useEffect)(()=>{if(!R)return;let e=document.documentElement;if(R.primaryColor&&(e.style.setProperty(`--sage`,R.primaryColor),e.style.setProperty(`--sage-hover`,R.primaryColor),e.style.setProperty(`--sage-subtle`,R.primaryColor+`14`),e.style.setProperty(`--sage-glow`,R.primaryColor+`26`)),R.accentColor&&e.style.setProperty(`--visitor-bubble`,R.accentColor),R.backgroundColor&&e.style.setProperty(`--bg`,R.backgroundColor),document.title=R.name,R.primaryColor){let e=document.querySelector(`meta[name="theme-color"]`);e||(e=document.createElement(`meta`),e.name=`theme-color`,document.head.appendChild(e)),e.content=R.primaryColor}if(R.faviconUrl){let e=document.querySelector(`link[rel="icon"]`);e||(e=document.createElement(`link`),e.rel=`icon`,document.head.appendChild(e)),e.href=R.faviconUrl}},[R]),(0,A.useEffect)(()=>{function e(e){e.key===`Escape`&&_&&b()}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[_,b]);function Z(){J||(q([]),d(Ve),re())}function Q(e){if(!e&&n.length===0||J)return;q(e=>e.map(e=>e.components?.some(e=>!e.submitted)?{...e,components:e.components.map(e=>e.submitted?e:{...e,submitted:!0})}:e)),d(t=>t.filter(t=>t!==e)),h(!0);let i=[...n];t(``),r([]),c(null),Y(e,{files:i})}function $(t){t.preventDefault(),Q(e.trim()),g.current?.resetHeight()}return(0,V.jsxs)(`div`,{className:`chat-page`,children:[(0,V.jsxs)(`header`,{className:`chat-header`,children:[(0,V.jsx)(`img`,{src:F||R?.logoUrl||u,alt:R?.name||f.productName,className:`chat-logo${F&&I===`circle`?` chat-logo--circle`:``}${F&&I===`rounded`?` chat-logo--rounded`:``}`,onError:e=>{e.target.src=R?.logoUrl||u}}),(0,V.jsxs)(`div`,{className:`chat-header-text`,children:[L!==`none`&&(0,V.jsx)(`h1`,{className:`chat-tagline`,children:W?.groupName||L&&ee||R?.name||f.productName}),(0,V.jsx)(`p`,{className:`chat-intro`,children:W?`${W.participants.length} participants`:R?.tagline||``}),(0,V.jsx)(`p`,{className:`chat-ai-indicator`,children:`AI assistant`})]}),P===`chat`&&!_&&(0,V.jsxs)(`div`,{className:`chat-header-actions`,children:[(0,V.jsx)(`button`,{className:`chat-header-action`,onClick:Z,disabled:J,title:`New conversation`,"aria-label":`New conversation`,children:(0,V.jsx)(D,{size:16})}),(0,V.jsx)(`button`,{className:`chat-header-action`,onClick:x,title:`Select messages`,"aria-label":`Select messages`,children:(0,V.jsx)(E,{size:16})})]})]}),P===`loading`&&(0,V.jsx)(`div`,{className:`gate-wrap`,children:(0,V.jsx)(`div`,{className:`gate-loading`,children:(0,V.jsx)(`span`,{className:`spinner`})})}),P===`auth-required`&&(0,V.jsx)(ie,{gateState:k.gateState,setGateState:k.setGateState,grantInfo:k.grantInfo,setGrantInfo:k.setGrantInfo,gateCacheKeyRef:k.gateCacheKeyRef,resolvedSlugRef:k.resolvedSlugRef,onAuthenticated:k.enterChat}),P===`chat`&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(De,{messages:K,isStreaming:J,sessionError:N,selectionMode:_,selectedItems:v,toggleSelectItem:S,onComponentSubmit:ae,remainingSuggestions:l,onSuggestionClick:Q,isAtBottom:p,setIsAtBottom:h,isGroup:!!W,sessionId:j}),_?(0,V.jsx)(Oe,{selectedItems:v,messages:K,isStreaming:J,copySelected:w,selectAll:C,exitSelection:b,showCopyToast:T}):(0,V.jsx)(Be,{input:e,setInput:t,isStreaming:J,pendingFiles:n,setPendingFiles:r,attachError:o,setAttachError:c,isDragOver:i,setIsDragOver:a,inputRef:g,onSubmit:$,onSendVoiceNote:e=>{t(``),r([]),c(null),Y(`[Voice note]`,{files:[e]})}})]}),y&&(0,V.jsx)(`span`,{className:`copy-toast${y===`failed`?` copy-toast-failed`:``}`,children:y===`copied`?`Copied`:`Copy failed`}),(0,V.jsxs)(`footer`,{className:`chat-footer`,children:[(0,V.jsxs)(`a`,{href:s,children:[f.domain,` `,`↗`]}),j&&(0,V.jsxs)(`span`,{style:{opacity:.35,fontSize:`10px`,fontFamily:`monospace`,marginLeft:`1rem`},children:[`Conversation · `,j.slice(0,8)]})]})]})}(0,k.createRoot)(document.getElementById(`root`)).render((0,V.jsx)(He,{}));export{Q as t};
@@ -1 +0,0 @@
1
- import{h as e}from"./src-B6XdH6xq.js";import"./chunk-ICPOFSXX-rgw1I6pt.js";import"./dist-Bd4S37oi.js";import"./chunk-5PVQY5BW-DOeY60Lp.js";import"./chunk-U2HBQHQK-CwMCwyfq.js";import"./chunk-BSJP7CBP-DP7LTBll.js";import"./chunk-ZZ45TVLE-sANOwJKn.js";import"./chunk-55IACEB6-BRJOZLpU.js";import"./chunk-EDXVE4YY-BSbGSOxN.js";import"./chunk-X2U36JSP-CvKfDVvq.js";import"./chunk-5FUZZQ4R-3-UZ9191.js";import"./chunk-ENJZ2VHE-CszgAcWZ.js";import"./chunk-336JU56O-XIsdqKyD.js";import{i as t,n,r,t as i}from"./chunk-OYMX7WX6-DL4v2Nx4.js";var a={parser:n,get db(){return new i(2)},renderer:r,styles:t,init:e(e=>{e.state||={},e.state.arrowMarkerAbsolute=e.arrowMarkerAbsolute},`init`)};export{a as diagram};