@rubytech/create-maxy-code 0.1.87 → 0.1.90

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 (130) hide show
  1. package/dist/__tests__/entitlement-flag.test.js +43 -0
  2. package/dist/__tests__/tier-flag.test.js +53 -0
  3. package/dist/index.js +68 -0
  4. package/dist/tier-flag.js +85 -0
  5. package/package.json +1 -1
  6. package/payload/platform/lib/admin-conversation-purge/dist/index.d.ts +54 -0
  7. package/payload/platform/lib/admin-conversation-purge/dist/index.d.ts.map +1 -0
  8. package/payload/platform/lib/admin-conversation-purge/dist/index.js +84 -0
  9. package/payload/platform/lib/admin-conversation-purge/dist/index.js.map +1 -0
  10. package/payload/platform/lib/admin-conversation-purge/src/index.ts +120 -0
  11. package/payload/platform/lib/admin-conversation-purge/tsconfig.json +8 -0
  12. package/payload/platform/lib/graph-trash/dist/index.d.ts +12 -1
  13. package/payload/platform/lib/graph-trash/dist/index.d.ts.map +1 -1
  14. package/payload/platform/lib/graph-trash/dist/index.js +8 -1
  15. package/payload/platform/lib/graph-trash/dist/index.js.map +1 -1
  16. package/payload/platform/lib/graph-trash/src/index.ts +20 -2
  17. package/payload/platform/package.json +2 -2
  18. package/payload/platform/plugins/.claude-plugin/marketplace.json +5 -0
  19. package/payload/platform/plugins/admin/PLUGIN.md +1 -0
  20. package/payload/platform/plugins/admin/hooks/__tests__/askuserquestion-investigate-gate.test.sh +176 -0
  21. package/payload/platform/plugins/admin/hooks/askuserquestion-investigate-gate.sh +257 -0
  22. package/payload/platform/plugins/admin/skills/admin-user-management/SKILL.md +2 -0
  23. package/payload/platform/plugins/docs/references/admin-session.md +5 -1
  24. package/payload/platform/plugins/docs/references/linkedin-extension.md +49 -0
  25. package/payload/platform/plugins/linkedin-extension/.claude-plugin/plugin.json +8 -0
  26. package/payload/platform/plugins/linkedin-extension/PLUGIN.md +58 -0
  27. package/payload/platform/plugins/linkedin-extension/extension/README.md +44 -0
  28. package/payload/platform/plugins/linkedin-extension/extension/__tests__/fixtures/profile.html +34 -0
  29. package/payload/platform/plugins/linkedin-extension/extension/__tests__/fixtures/thread.html +36 -0
  30. package/payload/platform/plugins/linkedin-extension/extension/assets/pill.css +52 -0
  31. package/payload/platform/plugins/linkedin-extension/extension/background/sw.js +60 -0
  32. package/payload/platform/plugins/linkedin-extension/extension/content/extractors.js +127 -0
  33. package/payload/platform/plugins/linkedin-extension/extension/content/profile.js +82 -0
  34. package/payload/platform/plugins/linkedin-extension/extension/content/thread.js +84 -0
  35. package/payload/platform/plugins/linkedin-extension/extension/manifest.json +32 -0
  36. package/payload/platform/plugins/linkedin-extension/extension/options/options.html +33 -0
  37. package/payload/platform/plugins/linkedin-extension/extension/options/options.js +30 -0
  38. package/payload/platform/plugins/linkedin-extension/skills/linkedin-extension/SKILL.md +91 -0
  39. package/payload/platform/plugins/memory/mcp/dist/lib/neo4j.d.ts +14 -0
  40. package/payload/platform/plugins/memory/mcp/dist/lib/neo4j.d.ts.map +1 -1
  41. package/payload/platform/plugins/memory/mcp/dist/lib/neo4j.js +28 -0
  42. package/payload/platform/plugins/memory/mcp/dist/lib/neo4j.js.map +1 -1
  43. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-empty-trash-admin-conversation.test.d.ts +2 -0
  44. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-empty-trash-admin-conversation.test.d.ts.map +1 -0
  45. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-empty-trash-admin-conversation.test.js +168 -0
  46. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-empty-trash-admin-conversation.test.js.map +1 -0
  47. package/payload/platform/plugins/memory/mcp/dist/tools/memory-empty-trash.d.ts +22 -3
  48. package/payload/platform/plugins/memory/mcp/dist/tools/memory-empty-trash.d.ts.map +1 -1
  49. package/payload/platform/plugins/memory/mcp/dist/tools/memory-empty-trash.js +61 -13
  50. package/payload/platform/plugins/memory/mcp/dist/tools/memory-empty-trash.js.map +1 -1
  51. package/payload/platform/scripts/seed-neo4j.sh +12 -0
  52. package/payload/platform/services/claude-session-manager/dist/pty-spawner.d.ts.map +1 -1
  53. package/payload/platform/services/claude-session-manager/dist/pty-spawner.js +27 -17
  54. package/payload/platform/services/claude-session-manager/dist/pty-spawner.js.map +1 -1
  55. package/payload/platform/templates/agents/admin/IDENTITY.md +3 -1
  56. package/payload/platform/templates/specialists/agents/database-operator.md +6 -2
  57. package/payload/server/public/assets/{ChatInput-CktRrxx1.css → ChatInput-dLWJ0Q8I.css} +1 -1
  58. package/payload/server/public/assets/{Checkbox-D2XqbR29.js → Checkbox-Bx8mRHQ3.js} +1 -1
  59. package/payload/server/public/assets/{admin-BK1F2LMD.js → admin-C57bDUgs.js} +6 -6
  60. package/payload/server/public/assets/{architectureDiagram-Q4EWVU46-9F6y6ESU.js → architectureDiagram-Q4EWVU46-BEW_bD50.js} +1 -1
  61. package/payload/server/public/assets/{blockDiagram-DXYQGD6D-LjGbzg0M.js → blockDiagram-DXYQGD6D-DFLT98C3.js} +1 -1
  62. package/payload/server/public/assets/{c4Diagram-AHTNJAMY-Bxpn5T5R.js → c4Diagram-AHTNJAMY-BemKtROA.js} +1 -1
  63. package/payload/server/public/assets/channel-CfpByn-m.js +1 -0
  64. package/payload/server/public/assets/{chunk-336JU56O-Cc2kxWVN.js → chunk-336JU56O-BL8fGJ7_.js} +2 -2
  65. package/payload/server/public/assets/{chunk-426QAEUC-DRzEhHvW.js → chunk-426QAEUC-BD6by0MP.js} +1 -1
  66. package/payload/server/public/assets/{chunk-4TB4RGXK-C8zRzH9g.js → chunk-4TB4RGXK-DX-cb6Nd.js} +1 -1
  67. package/payload/server/public/assets/{chunk-5FUZZQ4R-s8V7nzOd.js → chunk-5FUZZQ4R-B2QqtIZS.js} +1 -1
  68. package/payload/server/public/assets/{chunk-5PVQY5BW-KNShBlaM.js → chunk-5PVQY5BW-CzJWmsmd.js} +1 -1
  69. package/payload/server/public/assets/{chunk-EDXVE4YY-C6GvGxn3.js → chunk-EDXVE4YY-DP9vcvEU.js} +1 -1
  70. package/payload/server/public/assets/{chunk-ENJZ2VHE-XvXhU8ZS.js → chunk-ENJZ2VHE-D5xWEjF0.js} +1 -1
  71. package/payload/server/public/assets/{chunk-ICPOFSXX-OSDYUb0H.js → chunk-ICPOFSXX-AKduf9o4.js} +1 -1
  72. package/payload/server/public/assets/{chunk-OYMX7WX6-km_4dA-E.js → chunk-OYMX7WX6-D6jsVNyQ.js} +1 -1
  73. package/payload/server/public/assets/{chunk-U2HBQHQK-BGHqDvzJ.js → chunk-U2HBQHQK-BNAnTYh8.js} +1 -1
  74. package/payload/server/public/assets/{chunk-X2U36JSP-BKKSYdFO.js → chunk-X2U36JSP-UdQhYDnh.js} +1 -1
  75. package/payload/server/public/assets/{chunk-YZCP3GAM-DT_yhfJM.js → chunk-YZCP3GAM-DSSmSGmS.js} +1 -1
  76. package/payload/server/public/assets/{chunk-ZZ45TVLE-CP2JuBPA.js → chunk-ZZ45TVLE-Czm7IDMC.js} +1 -1
  77. package/payload/server/public/assets/classDiagram-6PBFFD2Q-DNc9R1IX.js +1 -0
  78. package/payload/server/public/assets/classDiagram-v2-HSJHXN6E-DM1DQh8N.js +1 -0
  79. package/payload/server/public/assets/clone-BSrNdvLW.js +1 -0
  80. package/payload/server/public/assets/{dagre-KV5264BT-Dk7osC4w.js → dagre-KV5264BT-CBuRCJE7.js} +1 -1
  81. package/payload/server/public/assets/{dagre-CUhFHAG8.js → dagre-hSIMHJcO.js} +1 -1
  82. package/payload/server/public/assets/data-3n20lir5.js +1 -0
  83. package/payload/server/public/assets/{diagram-5BDNPKRD-CdOEJbjg.js → diagram-5BDNPKRD-dbMrH0le.js} +1 -1
  84. package/payload/server/public/assets/{diagram-G4DWMVQ6-Dyx0MQk6.js → diagram-G4DWMVQ6-DBc6hs9a.js} +1 -1
  85. package/payload/server/public/assets/{diagram-MMDJMWI5-Dw6sxLh8.js → diagram-MMDJMWI5-ubSGybUk.js} +1 -1
  86. package/payload/server/public/assets/{diagram-TYMM5635-Bm3GRH-1.js → diagram-TYMM5635-WxL3cv-9.js} +1 -1
  87. package/payload/server/public/assets/{erDiagram-SMLLAGMA-CAJ3Z9uD.js → erDiagram-SMLLAGMA-CrBBOAN8.js} +1 -1
  88. package/payload/server/public/assets/{flowDiagram-DWJPFMVM-NrVUcQ2d.js → flowDiagram-DWJPFMVM-CXUq5Hzt.js} +1 -1
  89. package/payload/server/public/assets/{ganttDiagram-T4ZO3ILL-28YyrNXj.js → ganttDiagram-T4ZO3ILL-vTCBnYVS.js} +1 -1
  90. package/payload/server/public/assets/{gitGraphDiagram-UUTBAWPF-D73FSDE8.js → gitGraphDiagram-UUTBAWPF-BHrj_bRa.js} +1 -1
  91. package/payload/server/public/assets/graph-ChwMpxn_.js +1 -0
  92. package/payload/server/public/assets/graph-labels-CUgJgIwl.js +1 -0
  93. package/payload/server/public/assets/{graphlib-n_bUAhub.js → graphlib-CDO75l2X.js} +1 -1
  94. package/payload/server/public/assets/{infoDiagram-42DDH7IO-rFap2NoE.js → infoDiagram-42DDH7IO-CcQdaOhi.js} +1 -1
  95. package/payload/server/public/assets/{ishikawaDiagram-UXIWVN3A-KKAj626l.js → ishikawaDiagram-UXIWVN3A-3KvltFgV.js} +1 -1
  96. package/payload/server/public/assets/{journeyDiagram-VCZTEJTY-Do6hVThi.js → journeyDiagram-VCZTEJTY-DZCXaGFE.js} +1 -1
  97. package/payload/server/public/assets/{kanban-definition-6JOO6SKY-C38qlZwy.js → kanban-definition-6JOO6SKY-DAIAKy1-.js} +1 -1
  98. package/payload/server/public/assets/{lib-D-jcbjd4.js → lib-CCLURO3E.js} +1 -1
  99. package/payload/server/public/assets/{line-DsDSEpXU.js → line-C8iCE2Wx.js} +1 -1
  100. package/payload/server/public/assets/{mermaid-parser.core-Cvzc7ePL.js → mermaid-parser.core-ElvUhnV9.js} +1 -1
  101. package/payload/server/public/assets/{mermaid.core-BSZExB1C.js → mermaid.core-7dSH31Ao.js} +3 -3
  102. package/payload/server/public/assets/{mindmap-definition-QFDTVHPH-CrS3b5u5.js → mindmap-definition-QFDTVHPH-FZ0rcfac.js} +1 -1
  103. package/payload/server/public/assets/{page-C438DjPa.js → page-D3bFmqF4.js} +1 -1
  104. package/payload/server/public/assets/{page-fdrpcuv5.js → page-DNjUtT5q.js} +18 -17
  105. package/payload/server/public/assets/{pieDiagram-DEJITSTG-Dk-6uOEj.js → pieDiagram-DEJITSTG-CDuvMZbO.js} +1 -1
  106. package/payload/server/public/assets/{public-BK3eOHJs.js → public-g_2skbnY.js} +3 -3
  107. package/payload/server/public/assets/{quadrantDiagram-34T5L4WZ-CEMK5xQ0.js → quadrantDiagram-34T5L4WZ-xDjhkqNc.js} +1 -1
  108. package/payload/server/public/assets/{requirementDiagram-MS252O5E-vTyRxQOY.js → requirementDiagram-MS252O5E-BPKpyT0n.js} +1 -1
  109. package/payload/server/public/assets/{sankeyDiagram-XADWPNL6-s2z8dMpM.js → sankeyDiagram-XADWPNL6-BvFIrihC.js} +1 -1
  110. package/payload/server/public/assets/{sequenceDiagram-FGHM5R23-locoOgnm.js → sequenceDiagram-FGHM5R23-C6G1oAE0.js} +1 -1
  111. package/payload/server/public/assets/{stateDiagram-FHFEXIEX-m1d4aD0M.js → stateDiagram-FHFEXIEX-DbOJT_Xh.js} +1 -1
  112. package/payload/server/public/assets/stateDiagram-v2-QKLJ7IA2-Ce4GFk-H.js +1 -0
  113. package/payload/server/public/assets/{timeline-definition-GMOUNBTQ-HraDHuOp.js → timeline-definition-GMOUNBTQ-D1DSxHh6.js} +1 -1
  114. package/payload/server/public/assets/{vennDiagram-DHZGUBPP-DkyF2rFo.js → vennDiagram-DHZGUBPP-BYoSeMdo.js} +1 -1
  115. package/payload/server/public/assets/{wardleyDiagram-NUSXRM2D-BGScmzP0.js → wardleyDiagram-NUSXRM2D-DH3kZdea.js} +1 -1
  116. package/payload/server/public/assets/{xychartDiagram-5P7HB3ND-CPJ1JLj2.js → xychartDiagram-5P7HB3ND-C6MROMLG.js} +1 -1
  117. package/payload/server/public/data.html +5 -5
  118. package/payload/server/public/graph.html +6 -6
  119. package/payload/server/public/index.html +8 -8
  120. package/payload/server/public/public.html +5 -5
  121. package/payload/server/server.js +531 -118
  122. package/payload/server/public/assets/channel-CY_QocHj.js +0 -1
  123. package/payload/server/public/assets/classDiagram-6PBFFD2Q-BtwH3Rsu.js +0 -1
  124. package/payload/server/public/assets/classDiagram-v2-HSJHXN6E-tCRstAZ-.js +0 -1
  125. package/payload/server/public/assets/clone-Bc-lmwcQ.js +0 -1
  126. package/payload/server/public/assets/data-B3WPMQdR.js +0 -1
  127. package/payload/server/public/assets/graph-B6c5nlBL.js +0 -1
  128. package/payload/server/public/assets/graph-labels-BMqBNCYc.js +0 -1
  129. package/payload/server/public/assets/stateDiagram-v2-QKLJ7IA2-B7eWHz7x.js +0 -1
  130. /package/payload/server/public/assets/{ChatInput-D62NmYfJ.js → ChatInput-DoS80kaC.js} +0 -0
@@ -1 +1 @@
1
- import{o as e}from"./chunk-DD-I1_y5.js";import{d as t,f as n,v as r,x as i}from"./ChatInput-D62NmYfJ.js";import{C as a,a as o,b as s,f as c,g as l,l as u,t as d}from"./graph-labels-BMqBNCYc.js";var f=r(`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=r(`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=r(`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=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`}]]),g=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`}]]);function _(e){let t=new Set,n=[];for(let r of e)for(let e of r.labels)e&&(t.has(e)||d.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(i(),1),S=t();function C(){let[e,t]=(0,x.useState)(null),[n,r]=(0,x.useState)(!1),[i,l]=(0,x.useState)(void 0),[u,d]=(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`&&l(e.businessName),e.conversationId!==void 0&&d(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)(o,{cacheKey:e,businessName:i,conversationId:u,onLogout:v,userName:f,userAvatar:m,role:g,children:[(0,S.jsx)(c,{}),(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)(a,{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)(a,{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)(s,{size:18,className:`spin`}),` Loading…`]})})}function w({cacheKey:e,onOpenInGraph:t}){let{adminFetch:n,cacheKey:r,sessionRefetchNonce:i,banner:a,reloadToLogin:o}=u({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,o]=(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){o(``),u(null);return}O(!1);let t=setTimeout(()=>o(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)(s,{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:r}){let[i,a]=(0,x.useState)(`.`),[o,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(i===`.`?``:i)}`).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,i,F,r]);let L=(0,x.useCallback)(e=>{a(e)},[]),R=(0,x.useCallback)(()=>{if(i===`.`||i===``)return;let e=i.split(`/`).filter(Boolean);e.pop(),a(e.length===0?`.`:e.join(`/`))},[i]),z=(0,x.useCallback)(e=>{let n=i===`.`?e.name:`${i}/${e.name}`,r=`/api/admin/files/download?session_key=${encodeURIComponent(t)}&path=${encodeURIComponent(n)}`,a=document.createElement(`a`);a.href=r,a.rel=`noopener noreferrer`,document.body.appendChild(a),a.click(),a.remove()},[i,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=i===`.`?t.name:`${i}/${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)}},[i,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)(s,{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)}),i!==`.`&&(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)(s,{size:14,className:`spin`}),` Loading…`]}),!d&&o&&o.length===0&&!v&&(0,S.jsx)(`div`,{className:`data-empty-results`,children:`Empty directory.`}),!d&&o&&o.length>0&&(0,S.jsx)(`ul`,{className:`data-entries`,children:o.map(e=>{let t=e.displayName??e.name,r=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(i===`.`?e.name:`${i}/${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:r,title:`Delete ${t}`,"aria-label":`Delete ${t}`,children:r?(0,S.jsx)(s,{size:14,className:`spin`}):(0,S.jsx)(n,{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
+ import{o as e}from"./chunk-DD-I1_y5.js";import{d as t,f as n,v as r,x as i}from"./ChatInput-DoS80kaC.js";import{S as a,a as o,b as s,f as c,g as l,l as u,t as d}from"./graph-labels-CUgJgIwl.js";var f=r(`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=r(`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=r(`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=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`}]]),g=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`}]]);function _(e){let t=new Set,n=[];for(let r of e)for(let e of r.labels)e&&(t.has(e)||d.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(i(),1),S=t();function C(){let[e,t]=(0,x.useState)(null),[n,r]=(0,x.useState)(!1),[i,l]=(0,x.useState)(void 0),[u,d]=(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`&&l(e.businessName),e.conversationId!==void 0&&d(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)(o,{cacheKey:e,businessName:i,conversationId:u,onLogout:v,userName:f,userAvatar:m,role:g,children:[(0,S.jsx)(c,{}),(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)(a,{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)(a,{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)(s,{size:18,className:`spin`}),` Loading…`]})})}function w({cacheKey:e,onOpenInGraph:t}){let{adminFetch:n,cacheKey:r,sessionRefetchNonce:i,banner:a,reloadToLogin:o}=u({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,o]=(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){o(``),u(null);return}O(!1);let t=setTimeout(()=>o(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)(s,{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:r}){let[i,a]=(0,x.useState)(`.`),[o,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(i===`.`?``:i)}`).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,i,F,r]);let L=(0,x.useCallback)(e=>{a(e)},[]),R=(0,x.useCallback)(()=>{if(i===`.`||i===``)return;let e=i.split(`/`).filter(Boolean);e.pop(),a(e.length===0?`.`:e.join(`/`))},[i]),z=(0,x.useCallback)(e=>{let n=i===`.`?e.name:`${i}/${e.name}`,r=`/api/admin/files/download?session_key=${encodeURIComponent(t)}&path=${encodeURIComponent(n)}`,a=document.createElement(`a`);a.href=r,a.rel=`noopener noreferrer`,document.body.appendChild(a),a.click(),a.remove()},[i,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=i===`.`?t.name:`${i}/${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)}},[i,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)(s,{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)}),i!==`.`&&(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)(s,{size:14,className:`spin`}),` Loading…`]}),!d&&o&&o.length===0&&!v&&(0,S.jsx)(`div`,{className:`data-empty-results`,children:`Empty directory.`}),!d&&o&&o.length>0&&(0,S.jsx)(`ul`,{className:`data-entries`,children:o.map(e=>{let t=e.displayName??e.name,r=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(i===`.`?e.name:`${i}/${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:r,title:`Delete ${t}`,"aria-label":`Delete ${t}`,children:r?(0,S.jsx)(s,{size:14,className:`spin`}):(0,S.jsx)(n,{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};