@rubytech/create-maxy-code 0.1.358 → 0.1.360

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 (79) hide show
  1. package/dist/__tests__/neo4j-pidfile-scrub.test.js +103 -0
  2. package/dist/index.js +42 -7
  3. package/dist/neo4j-pidfile-scrub.js +90 -0
  4. package/package.json +1 -1
  5. package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +3 -1
  6. package/payload/platform/plugins/browser/PLUGIN.md +1 -1
  7. package/payload/platform/plugins/docs/references/admin-ui.md +2 -0
  8. package/payload/platform/plugins/email/mcp/dist/__tests__/email-status.test.d.ts +2 -0
  9. package/payload/platform/plugins/email/mcp/dist/__tests__/email-status.test.d.ts.map +1 -0
  10. package/payload/platform/plugins/email/mcp/dist/__tests__/email-status.test.js +58 -0
  11. package/payload/platform/plugins/email/mcp/dist/__tests__/email-status.test.js.map +1 -0
  12. package/payload/platform/plugins/email/mcp/dist/__tests__/imap-probe.test.js +109 -1
  13. package/payload/platform/plugins/email/mcp/dist/__tests__/imap-probe.test.js.map +1 -1
  14. package/payload/platform/plugins/email/mcp/dist/__tests__/source-fetch-efficiency.test.d.ts +2 -0
  15. package/payload/platform/plugins/email/mcp/dist/__tests__/source-fetch-efficiency.test.d.ts.map +1 -0
  16. package/payload/platform/plugins/email/mcp/dist/__tests__/source-fetch-efficiency.test.js +142 -0
  17. package/payload/platform/plugins/email/mcp/dist/__tests__/source-fetch-efficiency.test.js.map +1 -0
  18. package/payload/platform/plugins/email/mcp/dist/lib/credentials.d.ts +13 -0
  19. package/payload/platform/plugins/email/mcp/dist/lib/credentials.d.ts.map +1 -1
  20. package/payload/platform/plugins/email/mcp/dist/lib/credentials.js +35 -0
  21. package/payload/platform/plugins/email/mcp/dist/lib/credentials.js.map +1 -1
  22. package/payload/platform/plugins/email/mcp/dist/lib/imap.d.ts +18 -5
  23. package/payload/platform/plugins/email/mcp/dist/lib/imap.d.ts.map +1 -1
  24. package/payload/platform/plugins/email/mcp/dist/lib/imap.js +199 -114
  25. package/payload/platform/plugins/email/mcp/dist/lib/imap.js.map +1 -1
  26. package/payload/platform/plugins/email/mcp/dist/lib/setup-probe.d.ts +19 -0
  27. package/payload/platform/plugins/email/mcp/dist/lib/setup-probe.d.ts.map +1 -1
  28. package/payload/platform/plugins/email/mcp/dist/lib/setup-probe.js +33 -0
  29. package/payload/platform/plugins/email/mcp/dist/lib/setup-probe.js.map +1 -1
  30. package/payload/platform/plugins/email/mcp/dist/tools/email-setup.d.ts.map +1 -1
  31. package/payload/platform/plugins/email/mcp/dist/tools/email-setup.js +11 -1
  32. package/payload/platform/plugins/email/mcp/dist/tools/email-setup.js.map +1 -1
  33. package/payload/platform/plugins/email/mcp/dist/tools/email-status.d.ts.map +1 -1
  34. package/payload/platform/plugins/email/mcp/dist/tools/email-status.js +24 -1
  35. package/payload/platform/plugins/email/mcp/dist/tools/email-status.js.map +1 -1
  36. package/payload/platform/plugins/email/references/email-reference.md +9 -2
  37. package/payload/platform/scripts/__tests__/vnc-cdp-liveness.test.sh +222 -0
  38. package/payload/platform/scripts/rss-sampler.sh +16 -0
  39. package/payload/platform/scripts/vnc.sh +117 -3
  40. package/payload/platform/services/claude-session-manager/dist/rc-daemon.d.ts +11 -4
  41. package/payload/platform/services/claude-session-manager/dist/rc-daemon.d.ts.map +1 -1
  42. package/payload/platform/services/claude-session-manager/dist/rc-daemon.js +22 -7
  43. package/payload/platform/services/claude-session-manager/dist/rc-daemon.js.map +1 -1
  44. package/payload/platform/services/claude-session-manager/dist/systemd-scope.d.ts +0 -4
  45. package/payload/platform/services/claude-session-manager/dist/systemd-scope.d.ts.map +1 -1
  46. package/payload/platform/services/claude-session-manager/dist/systemd-scope.js +0 -15
  47. package/payload/platform/services/claude-session-manager/dist/systemd-scope.js.map +1 -1
  48. package/payload/server/public/assets/{AdminLoginScreens-Ro_RUTDh.js → AdminLoginScreens-FufN0KIm.js} +1 -1
  49. package/payload/server/public/assets/AdminShell-CmFCbj38.js +1 -0
  50. package/payload/server/public/assets/{Checkbox-dYLaMEdh.js → Checkbox-njajXf-b.js} +1 -1
  51. package/payload/server/public/assets/OperatorConversations-B9Vx84BF.js +9 -0
  52. package/payload/server/public/assets/{OperatorConversations-2zJh7qnO.css → OperatorConversations-BqudLZH5.css} +1 -1
  53. package/payload/server/public/assets/admin-DYOYaRcc.js +1 -0
  54. package/payload/server/public/assets/{browser-DrXZ4wpy.js → browser-CUwGN38H.js} +1 -1
  55. package/payload/server/public/assets/calendar-HonT_eBL.js +1 -0
  56. package/payload/server/public/assets/chat-B-sCk0kO.js +1 -0
  57. package/payload/server/public/assets/data-vEYM-aPa.js +1 -0
  58. package/payload/server/public/assets/{graph-l_3_j3I9.js → graph-BLUtXXda.js} +3 -3
  59. package/payload/server/public/assets/{graph-labels-CJj55nHk.js → graph-labels-tUzvK8mv.js} +1 -1
  60. package/payload/server/public/assets/operator-BLEBOkrQ.js +1 -0
  61. package/payload/server/public/assets/page-CcnJY-yB.js +32 -0
  62. package/payload/server/public/assets/{public-smrhkkxD.js → public-B8GW-fZg.js} +1 -1
  63. package/payload/server/public/assets/{rotate-ccw-Dd8aAvU7.js → rotate-ccw-BA0MN5YR.js} +1 -1
  64. package/payload/server/public/browser.html +4 -4
  65. package/payload/server/public/calendar.html +4 -4
  66. package/payload/server/public/chat.html +6 -6
  67. package/payload/server/public/data.html +4 -4
  68. package/payload/server/public/graph.html +7 -7
  69. package/payload/server/public/index.html +6 -6
  70. package/payload/server/public/operator.html +8 -8
  71. package/payload/server/public/public.html +6 -6
  72. package/payload/server/public/assets/AdminShell-CmqhpAPU.js +0 -1
  73. package/payload/server/public/assets/OperatorConversations-Cei12sSK.js +0 -9
  74. package/payload/server/public/assets/admin-BldZQrJF.js +0 -1
  75. package/payload/server/public/assets/calendar-CQ4TCbO7.js +0 -1
  76. package/payload/server/public/assets/chat-D7w6_NE1.js +0 -1
  77. package/payload/server/public/assets/data-Dc5XNWgF.js +0 -1
  78. package/payload/server/public/assets/operator-CKmOgXNa.js +0 -1
  79. package/payload/server/public/assets/page-hG7xTrcO.js +0 -32
@@ -0,0 +1 @@
1
+ import{o as e}from"./chunk-CAM3fms7.js";import{H as t,W as n,i as r,v as i,w as a}from"./OperatorConversations-B9Vx84BF.js";import{n as o,t as s}from"./AdminLoginScreens-FufN0KIm.js";import"./admin-types-DJoj6VJv.js";import{r as c,t as l}from"./AdminShell-CmFCbj38.js";import"./Checkbox-njajXf-b.js";var u=t(),d=e(n(),1),f=a();function p({onOpen:e}){return(0,f.jsx)(`footer`,{className:`admin-footer`,children:(0,f.jsxs)(`div`,{className:`powered-by`,role:`button`,tabIndex:0,onClick:e,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e())},"aria-label":`Powered by Claude Code — show details`,children:[(0,f.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`powered-by-icon`}),(0,f.jsx)(`span`,{children:`Powered by Claude Code`})]})})}function m(){let e=o(),[t,n]=(0,d.useState)(!1);(0,d.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&n(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let a=(0,d.useCallback)(async()=>{let t=e.claudeInfo!=null;if(n(!0),t){console.info(`[admin-ui] claude-info-open cached=true ms=0`);return}let r=Date.now();try{let t=await fetch(`/api/admin/claude-info`);if(t.ok){let n=await t.json();e.setClaudeInfo(n)}console.info(`[admin-ui] claude-info-open cached=false ms=${Date.now()-r}`)}catch(e){console.error(`[admin-ui] claude-info-fetch-failed ms=${Date.now()-r} error="${e instanceof Error?e.message:String(e)}"`)}},[e]),u=(0,d.useCallback)(({code:t,path:n})=>{console.warn(`[admin-auth] outcome=chat-tab-logout-on-401 code=${t} path=${n}`),e.handleLogout()},[e]);return e.appState===`chat`?(0,f.jsx)(i,{cacheKey:e.cacheKey,onSessionExpired:u,surface:`chat`,children:(0,f.jsx)(l,{cacheKey:e.cacheKey,businessName:e.businessName,sessionId:e.sessionId,onLogout:e.handleLogout,onDisconnect:e.handleDisconnect,disconnecting:e.disconnecting,userName:e.userName,userAvatar:e.userAvatar,role:e.role,footer:(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(p,{onOpen:a}),(0,f.jsx)(c,{show:t,onClose:()=>n(!1),claudeInfo:e.claudeInfo,messages:[],sessionElapsed:0,sessionId:e.sessionId,cacheKey:e.cacheKey})]}),children:t=>(0,f.jsx)(f.Fragment,{children:t.selectedWhatsapp&&e.cacheKey?(0,f.jsx)(r,{sessionId:t.selectedWhatsapp.sessionId,projectDir:t.selectedWhatsapp.projectDir,sessionKey:e.cacheKey,cleanViewToggle:!0},t.selectedWhatsapp.sessionId):(0,f.jsx)(`main`,{})})})}):(0,f.jsx)(s,{auth:e})}(0,u.createRoot)(document.getElementById(`root`)).render((0,f.jsx)(m,{}));
@@ -1 +1 @@
1
- import{o as e}from"./chunk-CAM3fms7.js";import{A as t,C as n,N as r,R as i,U as a,V as o,b as s,j as c,v as l,y as u}from"./OperatorConversations-Cei12sSK.js";import{_ as d,t as f}from"./AdminShell-CmqhpAPU.js";var p=i(`monitor-play`,[[`path`,{d:`M15.033 9.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56V7.648a.645.645 0 0 1 .967-.56z`,key:`vbtd3f`}],[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}],[`rect`,{x:`2`,y:`3`,width:`20`,height:`14`,rx:`2`,key:`x3v2xh`}]]),m=o(),h=e(a(),1),g=n(),_=`maxy-vnc-popout`;function v(){let[e,n]=(0,h.useState)(null),[i,a]=(0,h.useState)(!1),[o,l]=(0,h.useState)(null),d=u(null);(0,h.useEffect)(()=>{let e=!1;return fetch(`/vnc-viewer.html`,{method:`HEAD`}).then(t=>{e||(console.info(`[browser-page] op=viewer-probe available=${t.ok}`),n(t.ok))}).catch(()=>{e||(console.info(`[browser-page] op=viewer-probe available=false`),n(!1))}),()=>{e=!0}},[]);let f=(0,h.useCallback)(()=>{window.open(`/vnc-popout.html?title=${encodeURIComponent(s.productName)}`,_,`width=1024,height=768`)},[]),m=(0,h.useCallback)(async()=>{a(!0),l(null);try{let e=await d(`/api/admin/browser/launch`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||`Launch failed (${e.status})`)}}catch(e){l(e instanceof Error?e.message:String(e))}finally{a(!1)}},[d]);return e===null?(0,g.jsx)(`div`,{className:`vnc-surface`,children:(0,g.jsxs)(`div`,{className:`data-loading`,children:[(0,g.jsx)(t,{size:18,className:`spin`}),` Checking viewer…`]})}):e?(0,g.jsxs)(`div`,{className:`vnc-surface`,children:[(0,g.jsxs)(`div`,{className:`vnc-surface__toolbar`,children:[(0,g.jsxs)(`button`,{type:`button`,className:`vnc-surface__btn`,onClick:m,disabled:i,children:[i?(0,g.jsx)(t,{size:14,className:`spin`}):(0,g.jsx)(c,{size:14}),` Launch browser`]}),(0,g.jsxs)(`button`,{type:`button`,className:`vnc-surface__btn`,onClick:f,children:[(0,g.jsx)(r,{size:14}),` Pop out`]}),o&&(0,g.jsx)(`span`,{className:`vnc-surface__error`,children:o})]}),(0,g.jsx)(`iframe`,{className:`vnc-surface__iframe`,src:`/vnc-viewer.html`,title:`VNC viewer`})]}):(0,g.jsx)(`div`,{className:`vnc-surface`,children:(0,g.jsxs)(`div`,{className:`vnc-surface__unavailable`,children:[(0,g.jsx)(p,{size:20}),(0,g.jsx)(`p`,{children:`VNC surface not available on this platform.`})]})})}function y(){let[e,n]=(0,h.useState)(null),[r,i]=(0,h.useState)(!1),[a,o]=(0,h.useState)(void 0),[s,u]=(0,h.useState)(null),[p,m]=(0,h.useState)(void 0),[_,y]=(0,h.useState)(null),[b,x]=(0,h.useState)(null);(0,h.useEffect)(()=>{let e=!1,t=null;try{t=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!t){n(null),i(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(t)}`).then(async r=>{if(!e){if(r.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`;return}if(r.ok)try{let e=await r.json();typeof e.businessName==`string`&&o(e.businessName),e.sessionId!==void 0&&u(e.sessionId??null),x(e.role??null),m(e.userName===void 0?null:e.userName),y(e.avatar??null)}catch{}n(t),i(!0)}}).catch(()=>{e||(n(t),i(!0))}),()=>{e=!0}},[]);let S=(0,h.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]),[C,w]=(0,h.useState)(!1),T=(0,h.useCallback)(async()=>{w(!0);try{let e=await d();if(e){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`}return e}finally{w(!1)}},[]);return r?e?(0,g.jsx)(l,{cacheKey:e,surface:`browser`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=browser`);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},children:(0,g.jsx)(f,{cacheKey:e,businessName:a,sessionId:s,onLogout:S,onDisconnect:T,disconnecting:C,userName:p,userAvatar:_,role:b,children:(0,g.jsxs)(`div`,{className:`data-page`,children:[(0,g.jsx)(`header`,{className:`data-header`,children:(0,g.jsxs)(`h1`,{className:`data-title`,children:[(0,g.jsx)(c,{size:18}),` Browser`]})}),(0,g.jsx)(v,{})]})})}):(0,g.jsxs)(`div`,{className:`data-page`,children:[(0,g.jsx)(`header`,{className:`data-header`,children:(0,g.jsxs)(`h1`,{className:`data-title`,children:[(0,g.jsx)(c,{size:18}),` Browser`]})}),(0,g.jsxs)(`div`,{className:`data-empty`,children:[(0,g.jsx)(`p`,{children:`You are not signed in.`}),(0,g.jsxs)(`p`,{children:[`Open the `,(0,g.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})]}):(0,g.jsx)(`div`,{className:`data-page`,children:(0,g.jsxs)(`div`,{className:`data-loading`,children:[(0,g.jsx)(t,{size:18,className:`spin`}),` Loading…`]})})}(0,m.createRoot)(document.getElementById(`root`)).render((0,g.jsx)(y,{}));
1
+ import{o as e}from"./chunk-CAM3fms7.js";import{H as t,M as n,P as r,W as i,b as a,j as o,v as s,w as c,y as l,z as u}from"./OperatorConversations-B9Vx84BF.js";import{t as d,y as f}from"./AdminShell-CmFCbj38.js";var p=u(`monitor-play`,[[`path`,{d:`M15.033 9.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56V7.648a.645.645 0 0 1 .967-.56z`,key:`vbtd3f`}],[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}],[`rect`,{x:`2`,y:`3`,width:`20`,height:`14`,rx:`2`,key:`x3v2xh`}]]),m=t(),h=e(i(),1),g=c(),_=`maxy-vnc-popout`;function v(){let[e,t]=(0,h.useState)(null),[i,s]=(0,h.useState)(!1),[c,u]=(0,h.useState)(null),d=l(null);(0,h.useEffect)(()=>{let e=!1;return fetch(`/vnc-viewer.html`,{method:`HEAD`}).then(n=>{e||(console.info(`[browser-page] op=viewer-probe available=${n.ok}`),t(n.ok))}).catch(()=>{e||(console.info(`[browser-page] op=viewer-probe available=false`),t(!1))}),()=>{e=!0}},[]);let f=(0,h.useCallback)(()=>{window.open(`/vnc-popout.html?title=${encodeURIComponent(a.productName)}`,_,`width=1024,height=768`)},[]),m=(0,h.useCallback)(async()=>{s(!0),u(null);try{let e=await d(`/api/admin/browser/launch`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||`Launch failed (${e.status})`)}}catch(e){u(e instanceof Error?e.message:String(e))}finally{s(!1)}},[d]);return e===null?(0,g.jsx)(`div`,{className:`vnc-surface`,children:(0,g.jsxs)(`div`,{className:`data-loading`,children:[(0,g.jsx)(o,{size:18,className:`spin`}),` Checking viewer…`]})}):e?(0,g.jsxs)(`div`,{className:`vnc-surface`,children:[(0,g.jsxs)(`div`,{className:`vnc-surface__toolbar`,children:[(0,g.jsxs)(`button`,{type:`button`,className:`vnc-surface__btn`,onClick:m,disabled:i,children:[i?(0,g.jsx)(o,{size:14,className:`spin`}):(0,g.jsx)(n,{size:14}),` Launch browser`]}),(0,g.jsxs)(`button`,{type:`button`,className:`vnc-surface__btn`,onClick:f,children:[(0,g.jsx)(r,{size:14}),` Pop out`]}),c&&(0,g.jsx)(`span`,{className:`vnc-surface__error`,children:c})]}),(0,g.jsx)(`iframe`,{className:`vnc-surface__iframe`,src:`/vnc-viewer.html`,title:`VNC viewer`})]}):(0,g.jsx)(`div`,{className:`vnc-surface`,children:(0,g.jsxs)(`div`,{className:`vnc-surface__unavailable`,children:[(0,g.jsx)(p,{size:20}),(0,g.jsx)(`p`,{children:`VNC surface not available on this platform.`})]})})}function y(){let[e,t]=(0,h.useState)(null),[r,i]=(0,h.useState)(!1),[a,c]=(0,h.useState)(void 0),[l,u]=(0,h.useState)(null),[p,m]=(0,h.useState)(void 0),[_,y]=(0,h.useState)(null),[b,x]=(0,h.useState)(null);(0,h.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!n){t(null),i(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async r=>{if(!e){if(r.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`;return}if(r.ok)try{let e=await r.json();typeof e.businessName==`string`&&c(e.businessName),e.sessionId!==void 0&&u(e.sessionId??null),x(e.role??null),m(e.userName===void 0?null:e.userName),y(e.avatar??null)}catch{}t(n),i(!0)}}).catch(()=>{e||(t(n),i(!0))}),()=>{e=!0}},[]);let S=(0,h.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]),[C,w]=(0,h.useState)(!1),T=(0,h.useCallback)(async()=>{w(!0);try{let e=await f();if(e){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`}return e}finally{w(!1)}},[]);return r?e?(0,g.jsx)(s,{cacheKey:e,surface:`browser`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=browser`);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},children:(0,g.jsx)(d,{cacheKey:e,businessName:a,sessionId:l,onLogout:S,onDisconnect:T,disconnecting:C,userName:p,userAvatar:_,role:b,children:(0,g.jsxs)(`div`,{className:`data-page`,children:[(0,g.jsx)(`header`,{className:`data-header`,children:(0,g.jsxs)(`h1`,{className:`data-title`,children:[(0,g.jsx)(n,{size:18}),` Browser`]})}),(0,g.jsx)(v,{})]})})}):(0,g.jsxs)(`div`,{className:`data-page`,children:[(0,g.jsx)(`header`,{className:`data-header`,children:(0,g.jsxs)(`h1`,{className:`data-title`,children:[(0,g.jsx)(n,{size:18}),` Browser`]})}),(0,g.jsxs)(`div`,{className:`data-empty`,children:[(0,g.jsx)(`p`,{children:`You are not signed in.`}),(0,g.jsxs)(`p`,{children:[`Open the `,(0,g.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})]}):(0,g.jsx)(`div`,{className:`data-page`,children:(0,g.jsxs)(`div`,{className:`data-loading`,children:[(0,g.jsx)(o,{size:18,className:`spin`}),` Loading…`]})})}(0,m.createRoot)(document.getElementById(`root`)).render((0,g.jsx)(y,{}));
@@ -0,0 +1 @@
1
+ import{o as e}from"./chunk-CAM3fms7.js";import{E as t,H as n,I as r,L as i,P as a,T as o,V as s,W as c,j as l,k as u,v as d,w as f,z as p}from"./OperatorConversations-B9Vx84BF.js";import{d as m,t as h,y as g}from"./AdminShell-CmFCbj38.js";var _=p(`calendar`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}]]),v=p(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),y=p(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),b=p(`map-pin`,[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]),x=p(`sticky-note`,[[`path`,{d:`M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z`,key:`1dfntj`}],[`path`,{d:`M15 3v5a1 1 0 0 0 1 1h5`,key:`6s6qgf`}]]),ee=p(`user-plus`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`19`,x2:`19`,y1:`8`,y2:`14`,key:`1bvyxn`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]),S=n(),C=e(c(),1);function w(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function T(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}function E(e){let t=w(e),n=t.getDay();return T(t,n===0?-6:1-n)}function D(e){let t=E(e);return Array.from({length:7},(e,n)=>T(t,n))}function O(e){let t=E(new Date(e.getFullYear(),e.getMonth(),1));return Array.from({length:42},(e,n)=>T(t,n))}function k(){return Array.from({length:24},(e,t)=>t)}function A(e){let t=e.getFullYear();return Array.from({length:12},(e,n)=>new Date(t,n,1))}function j(e,t){switch(e){case`day`:{let e=w(t);return{from:e,to:T(e,1)}}case`week`:{let e=E(t);return{from:e,to:T(e,7)}}case`month`:{let e=E(new Date(t.getFullYear(),t.getMonth(),1));return{from:e,to:T(e,42)}}case`year`:return{from:new Date(t.getFullYear(),0,1),to:new Date(t.getFullYear()+1,0,1)}}}function M(e,t,n){switch(e){case`day`:return T(t,n);case`week`:return T(t,n*7);case`month`:return new Date(t.getFullYear(),t.getMonth()+n,1);case`year`:return new Date(t.getFullYear()+n,t.getMonth(),1)}}function N(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function P(e,t){return{role:`button`,tabIndex:0,onClick:()=>t(e),onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t(e))}}}var F=f(),I=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],L=3;function R(e){return e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function z({anchor:e,meetings:t,onSelect:n}){let r=O(e),i=e.getMonth(),a=new Date;return(0,F.jsxs)(`div`,{className:`cal-month`,children:[(0,F.jsx)(`div`,{className:`cal-weekday-row`,children:I.map(e=>(0,F.jsx)(`div`,{className:`cal-weekday`,children:e},e))}),(0,F.jsx)(`div`,{className:`cal-month-grid`,children:r.map(e=>{let r=t.filter(t=>N(new Date(t.startsAt),e)).sort((e,t)=>e.startsAt.localeCompare(t.startsAt)),o=e.getMonth()!==i,s=N(e,a);return(0,F.jsxs)(`div`,{className:`cal-cell${o?` cal-cell-out`:``}${s?` cal-cell-today`:``}`,children:[(0,F.jsx)(`div`,{className:`cal-cell-num`,children:e.getDate()}),r.slice(0,L).map(e=>(0,F.jsxs)(`div`,{className:`cal-chip`,title:e.title??`Untitled`,...P(e,n),children:[!e.isAllDay&&(0,F.jsx)(`span`,{className:`cal-chip-time`,children:R(new Date(e.startsAt))}),e.title??`Untitled`]},e.meetingId)),r.length>L&&(0,F.jsxs)(`div`,{className:`cal-more`,children:[`+`,r.length-L,` more`]})]},e.toISOString())})})]})}var B=1440,V=1.8;function H(e){return e.getHours()*60+e.getMinutes()}function U(e){return e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function W({day:e,meetings:t,hourHeight:n,onSelect:r}){let i=n*24,a=t.filter(t=>!t.isAllDay&&N(new Date(t.startsAt),e));return(0,F.jsx)(`div`,{className:`cal-day-col`,children:(0,F.jsxs)(`div`,{className:`cal-hours`,style:{height:`${i}px`},children:[Array.from({length:24},(e,t)=>(0,F.jsx)(`div`,{className:`cal-hour-line`,style:{top:`${t*n}px`}},t)),a.map(t=>{let n=new Date(t.startsAt),i=t.endsAt?new Date(t.endsAt):new Date(n.getTime()+30*6e4),a=H(n),o=N(i,e)?H(i):B,s=a/B*100,c=Math.max((o-a)/B*100,V);return(0,F.jsxs)(`div`,{className:`cal-event`,style:{top:`${s}%`,height:`${c}%`},title:t.title??`Untitled`,...P(t,r),children:[(0,F.jsx)(`span`,{className:`cal-event-time`,children:U(n)}),(0,F.jsx)(`span`,{className:`cal-event-title`,children:t.title??`Untitled`})]},t.meetingId)})]})})}var G=44;function te(e){let t=new Date;return t.setHours(e,0,0,0),t.toLocaleTimeString([],{hour:`numeric`})}function ne({anchor:e,meetings:t,onSelect:n}){let r=D(e),i=new Date;return(0,F.jsxs)(`div`,{className:`cal-timed`,children:[(0,F.jsxs)(`div`,{className:`cal-day-headrow`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`}),r.map(e=>(0,F.jsxs)(`div`,{className:`cal-day-head${N(e,i)?` cal-day-head-today`:``}`,children:[(0,F.jsx)(`span`,{className:`cal-day-head-name`,children:e.toLocaleDateString([],{weekday:`short`})}),(0,F.jsx)(`span`,{className:`cal-day-head-num`,children:e.getDate()})]},e.toISOString()))]}),(0,F.jsxs)(`div`,{className:`cal-allday-band`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`,children:`All-day`}),r.map(e=>(0,F.jsx)(`div`,{className:`cal-allday-cell`,children:t.filter(t=>t.isAllDay&&N(new Date(t.startsAt),e)).map(e=>(0,F.jsx)(`div`,{className:`cal-allday-chip`,title:e.title??`Untitled`,...P(e,n),children:e.title??`Untitled`},e.meetingId))},e.toISOString()))]}),(0,F.jsxs)(`div`,{className:`cal-timed-cols`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`,children:k().map(e=>(0,F.jsx)(`div`,{className:`cal-hour-label`,style:{height:`${G}px`},children:e===0?``:te(e)},e))}),r.map(e=>(0,F.jsx)(W,{day:e,meetings:t,hourHeight:G,onSelect:n},e.toISOString()))]})]})}var K=52;function q(e){let t=new Date;return t.setHours(e,0,0,0),t.toLocaleTimeString([],{hour:`numeric`})}function J({anchor:e,meetings:t,onSelect:n}){let r=t.filter(t=>t.isAllDay&&N(new Date(t.startsAt),e));return(0,F.jsxs)(`div`,{className:`cal-timed cal-timed-single`,children:[(0,F.jsxs)(`div`,{className:`cal-allday-band`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`,children:`All-day`}),(0,F.jsx)(`div`,{className:`cal-allday-cell`,children:r.map(e=>(0,F.jsx)(`div`,{className:`cal-allday-chip`,title:e.title??`Untitled`,...P(e,n),children:e.title??`Untitled`},e.meetingId))})]}),(0,F.jsxs)(`div`,{className:`cal-timed-cols`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`,children:k().map(e=>(0,F.jsx)(`div`,{className:`cal-hour-label`,style:{height:`${K}px`},children:e===0?``:q(e)},e))}),(0,F.jsx)(W,{day:e,meetings:t,hourHeight:K,onSelect:n})]})]})}var Y=[`M`,`T`,`W`,`T`,`F`,`S`,`S`];function X(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function re({anchor:e,meetings:t,onPickMonth:n}){let r=new Date,i=new Set(t.map(e=>X(new Date(e.startsAt))));return(0,F.jsx)(`div`,{className:`cal-year`,children:(0,F.jsx)(`div`,{className:`cal-year-grid`,children:A(e).map(e=>{let t=O(e),a=e.getMonth();return(0,F.jsxs)(`button`,{type:`button`,className:`cal-mini`,onClick:()=>n(e),title:e.toLocaleDateString([],{month:`long`,year:`numeric`}),children:[(0,F.jsx)(`div`,{className:`cal-mini-title`,children:e.toLocaleDateString([],{month:`long`})}),(0,F.jsx)(`div`,{className:`cal-mini-weekrow`,children:Y.map((e,t)=>(0,F.jsx)(`span`,{className:`cal-mini-weekday`,children:e},t))}),(0,F.jsx)(`div`,{className:`cal-mini-grid`,children:t.map(e=>{let t=e.getMonth()!==a,n=N(e,r),o=!t&&i.has(X(e));return(0,F.jsxs)(`span`,{className:`cal-mini-day${t?` cal-mini-day-out`:``}${n?` cal-mini-day-today`:``}`,children:[e.getDate(),o&&(0,F.jsx)(`span`,{className:`cal-mini-dot`})]},e.toISOString())})})]},a)})})})}var ie={meeting:`Meeting`,event:`Event`,task:`Task`};function ae(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function oe(e){return new Date(e).toISOString()}function Z(e){return Math.floor(new Date(e).getTime()/6e4)}function se(e){let t=new Date(e.startsAt);if(e.isAllDay)return t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`});let n=t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`}),r=t.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`});return e.endsAt?`${n} · ${r} – ${new Date(e.endsAt).toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}`:`${n} · ${r}`}function ce(e){if(!e)return null;let t=e.match(/filename="([^"]+)"/);return t?t[1]:null}function le(e,t){return e.email??`${e.name??`unknown`}-${t}`}function Q({a:e}){let t=e.name||e.email||`Unknown`,n=e.name&&e.email?e.email:null;return(0,F.jsxs)(`span`,{className:`cal-attendee-lines`,children:[(0,F.jsx)(`span`,{className:`cal-attendee-name`,children:t}),n&&(0,F.jsx)(`span`,{className:`cal-attendee-email`,children:n})]})}function ue({meeting:e,adminFetch:n,onClose:i,onSaved:a,onDeleted:s}){let c=e.kind===`meeting`,[d,f]=(0,C.useState)(!1),[p,h]=(0,C.useState)(!1),[g,v]=(0,C.useState)(!1),[S,w]=(0,C.useState)(!1),[T,E]=(0,C.useState)(null),[D,O]=(0,C.useState)(e),[k,A]=(0,C.useState)(e.title??``),[j,M]=(0,C.useState)(ae(e.startsAt)),[N,P]=(0,C.useState)(e.endsAt?ae(e.endsAt):``),[I,L]=(0,C.useState)(e.location??``),[R,z]=(0,C.useState)(e.privateNote??``),[B,V]=(0,C.useState)(``),[H,U]=(0,C.useState)(``);(0,C.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!S&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[S,i]);let W=(0,C.useCallback)(()=>{let e={},t=k.trim();t!==(D.title??``)&&(e.title=t);let n=oe(j);Z(n)!==Z(D.startsAt)&&(e.startsAt=n);let r=N?oe(N):null;(r===null?D.endsAt!==null:D.endsAt===null||Z(r)!==Z(D.endsAt))&&(e.endsAt=r);let i=I.trim()||null;i!==(D.location??null)&&(e.location=i);let a=R.trim()||null;return a!==(D.privateNote??null)&&(e.privateNote=a),e},[k,j,N,I,R,D]),G=(0,C.useCallback)(async()=>{let t=W();if(Object.keys(t).length===0){f(!1);return}w(!0),E(null);try{let r=await n(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(!r.ok)throw Error(`HTTP ${r.status}`);let i=await r.json();O(i.meeting),a(i.meeting),f(!1)}catch(e){E(e instanceof Error?e.message:`Save failed`)}finally{w(!1)}},[n,W,e.meetingId,a]),te=(0,C.useCallback)(async()=>{let t=B.trim(),r=H.trim();if(!(!t&&!r)){w(!0),E(null);try{let i=await n(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/attendees`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:t||void 0,email:r||void 0})});if(!i.ok)throw Error(`HTTP ${i.status}`);let o=await i.json();O(o.meeting),a(o.meeting),V(``),U(``)}catch(e){E(e instanceof Error?e.message:`Add failed`)}finally{w(!1)}}},[n,B,H,e.meetingId,a]),ne=(0,C.useCallback)(async t=>{let r=t.email?{email:t.email}:{name:t.name};w(!0),E(null);try{let t=await n(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/attendees`,{method:`DELETE`,headers:{"content-type":`application/json`},body:JSON.stringify(r)});if(!t.ok)throw Error(`HTTP ${t.status}`);let i=await t.json();O(i.meeting),a(i.meeting)}catch(e){E(e instanceof Error?e.message:`Remove failed`)}finally{w(!1)}},[n,e.meetingId,a]),K=(0,C.useCallback)(async()=>{w(!0),E(null);try{let t=await n(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}`,{method:`DELETE`});if(!t.ok)throw Error(`HTTP ${t.status}`);s(e.meetingId)}catch(e){E(e instanceof Error?e.message:`Delete failed`),w(!1)}},[n,e.meetingId,s]),q=(0,C.useCallback)(async t=>{v(!1),w(!0),E(null);try{let r=await n(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/ics?attendees=${t?`1`:`0`}`);if(!r.ok)throw Error(`HTTP ${r.status}`);let i=await r.blob(),a=ce(r.headers.get(`content-disposition`))??`meeting.ics`,o=URL.createObjectURL(i),s=document.createElement(`a`);s.href=o,s.download=a,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(o)}catch(e){E(e instanceof Error?e.message:`Download failed`)}finally{w(!1)}},[n,e.meetingId]),J=ie[e.kind??`meeting`],Y=B.trim().length>0||H.trim().length>0;return(0,F.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{S||i()},children:(0,F.jsxs)(`div`,{className:`cal-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":d?`Edit meeting`:`Meeting detail`,onClick:e=>e.stopPropagation(),children:[(0,F.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,F.jsx)(`span`,{className:`cal-modal-kind`,children:J}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:i,"aria-label":`Close`,autoFocus:!0,disabled:S,children:(0,F.jsx)(o,{size:16})})]}),!d&&(0,F.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,F.jsx)(`div`,{className:`cal-modal-title`,children:D.title??`Untitled`}),(0,F.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,F.jsx)(y,{size:14}),(0,F.jsx)(`span`,{children:se(D)})]}),D.location&&(0,F.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,F.jsx)(b,{size:14}),(0,F.jsx)(`span`,{children:D.location})]}),D.attendees.length>0&&(0,F.jsxs)(`div`,{className:`cal-modal-row cal-modal-row-top`,children:[(0,F.jsx)(m,{size:14}),(0,F.jsx)(`div`,{className:`cal-modal-attendees`,children:D.attendees.map((e,t)=>(0,F.jsx)(`div`,{className:`cal-attendee-row`,children:(0,F.jsx)(Q,{a:e})},le(e,t)))})]}),D.privateNote&&(0,F.jsxs)(`div`,{className:`cal-modal-row cal-modal-row-top`,children:[(0,F.jsx)(x,{size:14}),(0,F.jsx)(`span`,{className:`cal-modal-note`,children:D.privateNote})]}),(0,F.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,F.jsx)(_,{size:14}),(0,F.jsx)(`span`,{children:J})]})]}),d&&(0,F.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Title`}),(0,F.jsx)(`input`,{type:`text`,value:k,onChange:e=>A(e.target.value),disabled:S})]}),(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Start`}),(0,F.jsx)(`input`,{type:`datetime-local`,value:j,onChange:e=>M(e.target.value),disabled:S})]}),(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`End`}),(0,F.jsx)(`input`,{type:`datetime-local`,value:N,onChange:e=>P(e.target.value),disabled:S})]}),(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Location`}),(0,F.jsx)(`input`,{type:`text`,value:I,onChange:e=>L(e.target.value),disabled:S})]}),(0,F.jsxs)(`div`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Attendees`}),(0,F.jsxs)(`div`,{className:`cal-modal-attendees cal-modal-attendees-edit`,children:[D.attendees.length===0&&(0,F.jsx)(`div`,{className:`cal-attendee-empty`,children:`No attendees yet.`}),D.attendees.map((e,t)=>(0,F.jsxs)(`div`,{className:`cal-attendee-row cal-attendee-row-edit`,children:[(0,F.jsx)(Q,{a:e}),(0,F.jsx)(`button`,{type:`button`,className:`cal-attendee-remove`,onClick:()=>ne(e),disabled:S,"aria-label":`Remove ${e.name||e.email||`attendee`}`,children:(0,F.jsx)(o,{size:13})})]},le(e,t)))]}),(0,F.jsxs)(`div`,{className:`cal-attendee-add`,children:[(0,F.jsx)(`input`,{type:`text`,placeholder:`Name`,value:B,onChange:e=>V(e.target.value),disabled:S,"aria-label":`Attendee name`}),(0,F.jsx)(`input`,{type:`email`,placeholder:`Email`,value:H,onChange:e=>U(e.target.value),disabled:S,"aria-label":`Attendee email`}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn cal-attendee-add-btn`,onClick:te,disabled:S||!Y,"aria-label":`Add attendee`,children:S?(0,F.jsx)(l,{size:13,className:`spin`}):(0,F.jsx)(ee,{size:13})})]})]}),(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Private note`}),(0,F.jsx)(`textarea`,{className:`cal-modal-textarea`,value:R,onChange:e=>z(e.target.value),disabled:S,rows:3,placeholder:`Only you and your team can see this.`})]})]}),T&&(0,F.jsx)(`div`,{className:`cal-modal-error`,children:T}),c&&(0,F.jsxs)(`div`,{className:`cal-modal-actions`,children:[!d&&!p&&!g&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>f(!0),disabled:S,children:[(0,F.jsx)(u,{size:14}),` Edit`]}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:()=>h(!0),disabled:S,children:[(0,F.jsx)(t,{size:14}),` Delete`]}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-download`,onClick:()=>{D.attendees.length>0?v(!0):q(!1)},disabled:S,children:[S?(0,F.jsx)(l,{size:14,className:`spin`}):(0,F.jsx)(r,{size:14}),` Download`]})]}),g&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Include attendees in the file?`}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:()=>q(!0),disabled:S,children:[S?(0,F.jsx)(l,{size:14,className:`spin`}):null,` Yes`]}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>q(!1),disabled:S,children:`No`}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>v(!1),disabled:S,children:`Cancel`})]}),d&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:G,disabled:S,children:[S?(0,F.jsx)(l,{size:14,className:`spin`}):null,` Save`]}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>{f(!1),E(null)},disabled:S,children:`Cancel`})]}),p&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Delete this meeting?`}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:K,disabled:S,children:[S?(0,F.jsx)(l,{size:14,className:`spin`}):null,` Delete`]}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>h(!1),disabled:S,children:`Cancel`})]})]})]})})}var $=`maxy-admin-session-key`,de=[`day`,`week`,`month`,`year`];function fe(e,t){switch(e){case`day`:return t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`});case`week`:{let{from:e,to:n}=j(`week`,t),r=new Date(n.getTime()-1);return`${e.toLocaleDateString([],{day:`numeric`,month:`short`})} – ${r.toLocaleDateString([],{day:`numeric`,month:`short`,year:`numeric`})}`}case`month`:return t.toLocaleDateString([],{month:`long`,year:`numeric`});case`year`:return String(t.getFullYear())}}function pe(){let[e,t]=(0,C.useState)(null),[n,r]=(0,C.useState)(!1),[i,a]=(0,C.useState)(void 0),[o,s]=(0,C.useState)(null),[c,u]=(0,C.useState)(void 0),[f,p]=(0,C.useState)(null),[m,_]=(0,C.useState)(null);(0,C.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem($)}catch{}if(!n){r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&a(e.businessName),e.sessionId!==void 0&&s(e.sessionId??null),_(e.role??null),u(e.userName===void 0?null:e.userName),p(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let v=(0,C.useCallback)(()=>{try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},[]),[y,b]=(0,C.useState)(!1),x=(0,C.useCallback)(async()=>{b(!0);try{let e=await g();if(e){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`}return e}finally{b(!1)}},[]);return n?e?(0,F.jsx)(d,{cacheKey:e,surface:`calendar`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=calendar`);try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},children:(0,F.jsx)(h,{cacheKey:e,businessName:i,sessionId:o,onLogout:v,onDisconnect:x,disconnecting:y,userName:c,userAvatar:f,role:m,children:(0,F.jsx)(me,{cacheKey:e})})}):(0,F.jsx)(`div`,{className:`cal-page`,children:(0,F.jsxs)(`div`,{className:`cal-empty`,children:[(0,F.jsx)(`p`,{children:`You are not signed in.`}),(0,F.jsxs)(`p`,{children:[`Open the `,(0,F.jsx)(`a`,{href:`/`,className:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,F.jsx)(`div`,{className:`cal-page`,children:(0,F.jsxs)(`div`,{className:`cal-loading`,children:[(0,F.jsx)(l,{size:18,className:`spin`}),` Loading…`]})})}function me({cacheKey:e}){let{adminFetch:t,sessionRefetchNonce:n}=s({initialCacheKey:e,surface:`calendar`}),[r,o]=(0,C.useState)(`month`),[c,u]=(0,C.useState)(()=>new Date),[d,f]=(0,C.useState)([]),[p,m]=(0,C.useState)(!1),[h,g]=(0,C.useState)(null),[y,b]=(0,C.useState)(null),[x,ee]=(0,C.useState)(null);(0,C.useEffect)(()=>{let e=!1;return t(`/api/admin/calendar/booking-link`).then(async t=>{if(e||!t.ok)return;let n=await t.json();typeof n.bookingDomain==`string`&&n.bookingDomain&&ee(n.bookingDomain)}).catch(()=>{}),()=>{e=!0}},[t]),(0,C.useEffect)(()=>{let e=!1,{from:n,to:i}=j(r,c);return m(!0),g(null),t(`/api/admin/calendar/meetings?from=${encodeURIComponent(n.toISOString())}&to=${encodeURIComponent(i.toISOString())}`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();f(Array.isArray(n.meetings)?n.meetings:[])}).catch(t=>{e||(g(t instanceof Error?t.message:`Failed to load`),f([]))}).finally(()=>{e||m(!1)}),()=>{e=!0}},[r,c,n,t]);let S=(0,C.useCallback)(()=>u(new Date),[]),w=(0,C.useCallback)(()=>u(e=>M(r,e,-1)),[r]),T=(0,C.useCallback)(()=>u(e=>M(r,e,1)),[r]),E=(0,C.useCallback)(e=>{u(e),o(`month`)},[]);(0,C.useEffect)(()=>{b(null)},[r,c]);let D=(0,C.useCallback)(e=>{f(t=>t.map(t=>t.meetingId===e.meetingId?e:t)),b(e)},[]),O=(0,C.useCallback)(e=>{f(t=>t.filter(t=>t.meetingId!==e)),b(null)},[]);return(0,F.jsxs)(`div`,{className:`cal-page`,children:[(0,F.jsxs)(`header`,{className:`cal-header`,children:[(0,F.jsxs)(`div`,{className:`cal-title`,children:[(0,F.jsx)(_,{size:20}),` Calendar`]}),(0,F.jsxs)(`div`,{className:`cal-nav`,children:[(0,F.jsx)(`button`,{type:`button`,className:`cal-today-btn`,onClick:S,children:`Today`}),(0,F.jsx)(`button`,{type:`button`,className:`cal-nav-btn`,onClick:w,"aria-label":`Previous`,children:(0,F.jsx)(i,{size:18})}),(0,F.jsx)(`button`,{type:`button`,className:`cal-nav-btn`,onClick:T,"aria-label":`Next`,children:(0,F.jsx)(v,{size:18})}),(0,F.jsx)(`span`,{className:`cal-range-label`,children:fe(r,c)}),p&&(0,F.jsx)(l,{size:16,className:`spin`})]}),(0,F.jsx)(`div`,{className:`cal-views`,children:de.map(e=>(0,F.jsx)(`button`,{type:`button`,className:`cal-view-btn${e===r?` cal-view-btn-active`:``}`,onClick:()=>o(e),children:e.charAt(0).toUpperCase()+e.slice(1)},e))}),x&&(0,F.jsxs)(`a`,{className:`cal-booking-link`,href:`https://${x}`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,F.jsx)(a,{size:14}),` Booking page`]})]}),(0,F.jsxs)(`div`,{className:`cal-body`,children:[h&&(0,F.jsxs)(`div`,{className:`cal-error`,children:[`Could not load the calendar: `,h]}),r===`day`&&(0,F.jsx)(J,{anchor:c,meetings:d,onSelect:b}),r===`week`&&(0,F.jsx)(ne,{anchor:c,meetings:d,onSelect:b}),r===`month`&&(0,F.jsx)(z,{anchor:c,meetings:d,onSelect:b}),r===`year`&&(0,F.jsx)(re,{anchor:c,meetings:d,onPickMonth:E})]}),y&&(0,F.jsx)(ue,{meeting:y,adminFetch:t,onClose:()=>b(null),onSaved:D,onDeleted:O})]})}(0,S.createRoot)(document.getElementById(`root`)).render((0,F.jsx)(pe,{}));
@@ -0,0 +1 @@
1
+ import{H as e,w as t}from"./OperatorConversations-B9Vx84BF.js";import"./admin-types-DJoj6VJv.js";import"./AdminShell-CmFCbj38.js";import{n}from"./page-CcnJY-yB.js";var r=e(),i=t();(0,r.createRoot)(document.getElementById(`root`)).render((0,i.jsx)(n,{}));
@@ -0,0 +1 @@
1
+ import{o as e}from"./chunk-CAM3fms7.js";import{D as t,E as n,F as r,H as i,I as a,N as o,O as s,T as c,V as l,W as u,_ as ee,d as te,f as d,j as f,k as ne,p,t as re,v as m,w as ie,z as h}from"./OperatorConversations-B9Vx84BF.js";import{i as ae,t as oe}from"./graph-labels-tUzvK8mv.js";var se=h(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),ce=h(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),le=h(`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`}]]),ue=h(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),de=h(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),fe=h(`mouse-pointer-click`,[[`path`,{d:`M14 4.1 12 6`,key:`ita8i4`}],[`path`,{d:`m5.1 8-2.9-.8`,key:`1go3kf`}],[`path`,{d:`m6 12-1.9 2`,key:`mnht97`}],[`path`,{d:`M7.2 2.2 8 5.1`,key:`1cfko1`}],[`path`,{d:`M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z`,key:`s0h3yz`}]]),pe=h(`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`}]]),g=i(),_=e(u(),1);function me(e){let t=new Set,n=[];for(let r of e)for(let e of r.labels)e&&(t.has(e)||oe.has(e)&&(t.add(e),n.push(e)));return n}var v=ie(),he=/\.(png|jpe?g|gif|webp|svg)$/i;function ge(e){return he.test(e)}var _e=`maxy-data-view`,ve=95*1024*1024,ye=48*1024*1024;function be(){return typeof window>`u`?`list`:window.localStorage.getItem(_e)===`grid`?`grid`:`list`}function xe(){let[e,t]=(0,_.useState)(null),[n,r]=(0,_.useState)(!1);return(0,_.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!n){t(null),r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`;return}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]),n?e?(0,v.jsx)(m,{cacheKey:e,surface:`data`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=data`);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},children:(0,v.jsx)(`div`,{className:`data-page data-page-full`,children:(0,v.jsx)(Se,{cacheKey:e})})}):(0,v.jsx)(`div`,{className:`data-page`,children:(0,v.jsxs)(`div`,{className:`data-empty`,children:[(0,v.jsx)(`p`,{children:`You are not signed in.`}),(0,v.jsxs)(`p`,{children:[`Open the `,(0,v.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,v.jsx)(`div`,{className:`data-page`,children:(0,v.jsxs)(`div`,{className:`data-loading`,children:[(0,v.jsx)(f,{size:18,className:`spin`}),` Loading…`]})})}function Se({cacheKey:e}){let{adminFetch:t,cacheKey:n,sessionRefetchNonce:r}=l({initialCacheKey:e,surface:`data`});return(0,v.jsx)(x,{adminFetch:t,cacheKey:n,sessionRefetchNonce:r})}function Ce(){if(typeof window>`u`)return`.`;let e=new URLSearchParams(window.location.hash.replace(/^#/,``)).get(`path`);return e&&e.length>0?e:`.`}function we(e){if(typeof window>`u`)return;let t=new URL(window.location.href);t.hash=e===`.`?``:`path=${encodeURIComponent(e)}`,window.history.replaceState(window.history.state,``,t.toString())}function y(e){return new Promise((t,n)=>{let r=[],i=()=>e.readEntries(e=>{e.length===0?t(r):(r.push(...e),i())},n);i()})}function b(e){return new Promise((t,n)=>e.file(t,n))}async function Te(e,t=``){let n=[];for(let r of e){if(!r)continue;let e=t?`${t}/${r.name}`:r.name;if(r.isFile)n.push({file:await b(r),relpath:e});else if(r.isDirectory){let t=await y(r.createReader());n.push(...await Te(t,e))}}return n}function Ee(e,t){if(e===422&&typeof t==`string`){if(/exceeds the .* limit/i.test(t))return`size`;if(/unsupported file type/i.test(t))return`mime`}return`http=${e}`}function x({adminFetch:e,cacheKey:i,sessionRefetchNonce:l}){let[u,m]=(0,_.useState)(``),ie=(0,_.useRef)(null),[h,oe]=(0,_.useState)(``),[g,he]=(0,_.useState)(null),[xe,Se]=(0,_.useState)(`hybrid`),[y,b]=(0,_.useState)(!1),[x,S]=(0,_.useState)(null),[C,ke]=(0,_.useState)(null),[Me,Ne]=(0,_.useState)(0),[w,Pe]=(0,_.useState)(!1),[T,Fe]=(0,_.useState)(()=>Ce()),[E,Ie]=(0,_.useState)(null),[D,Le]=(0,_.useState)(()=>be()),[O,Re]=(0,_.useState)(null),[k,ze]=(0,_.useState)([]),[A,Be]=(0,_.useState)(!1),[Ve,He]=(0,_.useState)(null),[Ue,j]=(0,_.useState)(!1),[M,N]=(0,_.useState)(null),[We,P]=(0,_.useState)(null),[Ge,Ke]=(0,_.useState)(null),[qe,Je]=(0,_.useState)(!1),[Ye,Xe]=(0,_.useState)(null),F=(0,_.useRef)(null),[Ze,I]=(0,_.useState)(0),[Qe,L]=(0,_.useState)(!1),[$e,et]=(0,_.useState)(``),[R,z]=(0,_.useState)(null),[tt,nt]=(0,_.useState)(``),[rt,B]=(0,_.useState)(null),V=(()=>{let e=T===`.`?[]:T.split(`/`).filter(Boolean);return e.length>=2&&e[0]===`accounts`})();(0,_.useEffect)(()=>{console.info(`[data-ui] op=mount header=operator home=absent`)},[]);let it=(0,_.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]),at=(0,_.useCallback)(e=>{e===`chat`&&(window.location.href=`/`)},[]),[H,ot]=(0,_.useState)([]),[st,ct]=(0,_.useState)(`files`);(0,_.useEffect)(()=>{if(!i)return;let e=!1;return fetch(`/api/whatsapp-reader/conversations?session_key=${encodeURIComponent(i)}`).then(e=>e.ok?e.json():{conversations:[]}).then(t=>{e||ot(t.conversations??[])}).catch(()=>{}),()=>{e=!0}},[i]);let lt=(0,_.useMemo)(()=>[...new Set(H.map(e=>e.channel))],[H]),[ut,dt]=(0,_.useState)(!1),ft=(0,_.useRef)(null),[pt,U]=(0,_.useState)(!1),mt=(0,_.useRef)(null);(0,_.useEffect)(()=>{let e=u.trim();if(!e){oe(``),he(null),S(null);return}Pe(!1);let t=setTimeout(()=>oe(e),300);return()=>clearTimeout(t)},[u]),(0,_.useEffect)(()=>{if(!h){b(!1);return}let t=!1;return b(!0),S(null),e(`/api/admin/graph-search?q=${encodeURIComponent(h)}&labels=FileArtifact&limit=20${w?`&threshold=0`:``}`).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{t||(he(e.results),Se(e.mode??`hybrid`),Ne(typeof e.suppressed==`number`?e.suppressed:0))}).catch(e=>{t||S(e instanceof Error?e.message:String(e))}).finally(()=>{t||b(!1)}),()=>{t=!0}},[h,e,l,w]);let ht=(0,_.useMemo)(()=>g?me(g):[],[g]),W=C&&ht.includes(C)?C:null,gt=(0,_.useMemo)(()=>g?W?g.filter(e=>e.labels.includes(W)):g:null,[g,W]),_t=(0,_.useCallback)(e=>{let t=e.properties.relativePath;if(typeof t!=`string`||t.length===0)return;let n=`/api/admin/files/download?session_key=${encodeURIComponent(i)}&path=${encodeURIComponent(t)}`,r=document.createElement(`a`);r.href=n,r.rel=`noopener noreferrer`,document.body.appendChild(r),r.click(),r.remove()},[i]);(0,_.useEffect)(()=>{if(!g)return;let e=g.filter(e=>{let t=e.properties.relativePath;return typeof t!=`string`||t.length===0});e.length>0&&console.warn(`[data-search] op=locate-link-missing nodeId=${e.map(e=>e.nodeId).join(`,`)}`)},[g]),(0,_.useEffect)(()=>{let t=!1;return Be(!0),He(null),e(`/api/admin/files?path=${encodeURIComponent(T===`.`?``:T)}`).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{t||(Ie(e.entries),ze(e.displayPath??[]))}).catch(e=>{t||(Ie([]),ze([]),He(e instanceof Error?e.message:String(e)))}).finally(()=>{t||Be(!1)}),()=>{t=!0}},[e,T,Ze,l]),(0,_.useEffect)(()=>{we(T)},[T]);let vt=(0,_.useCallback)(()=>{I(e=>e+1)},[]),G=(0,_.useCallback)(e=>{dt(!1),Fe(e)},[]),yt=(0,_.useCallback)(e=>{let t=e.properties.relativePath;if(typeof t!=`string`||t.length===0)return;let n=t.lastIndexOf(`/`),r=n===-1?`.`:t.slice(0,n);console.log(`[data-search] op=locate nodeId=${e.nodeId} folder=${r}`),m(``),S(null),ke(null),G(r)},[G]),bt=(0,_.useCallback)(()=>{if(T===`.`||T===``)return;let e=T.split(`/`).filter(Boolean);e.pop(),Fe(e.length===0?`.`:e.join(`/`))},[T]),xt=(0,_.useCallback)(e=>{d(i,T===`.`?e.name:`${T}/${e.name}`)},[T,i]),[K,St]=(0,_.useState)(!1),[q,Ct]=(0,_.useState)(new Set),wt=(0,_.useRef)(null),J=(0,_.useRef)(!1),Y=typeof navigator<`u`&&typeof navigator.share==`function`&&typeof navigator.canShare==`function`,Tt=(0,_.useCallback)(e=>{St(!0),Ct(new Set([e])),console.info(`[data-ui] op=select-enter count=1`)},[]),X=(0,_.useCallback)(e=>{St(!1),Ct(new Set),console.info(`[data-ui] op=select-exit reason=${e}`)},[]),Z=(0,_.useCallback)(e=>{Ct(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Et=(0,_.useCallback)(e=>{J.current=!1,wt.current=setTimeout(()=>{J.current=!0,Tt(e)},500)},[Tt]),Q=(0,_.useCallback)(()=>{wt.current&&=(clearTimeout(wt.current),null)},[]),Dt=(0,_.useCallback)(e=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}xt(e)},[K,Z,xt]),Ot=(0,_.useCallback)(e=>{Le(e),typeof window<`u`&&window.localStorage.setItem(_e,e),console.info(`[data] op=view-mode mode=${e}`)},[]),kt=(0,_.useCallback)(e=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}Re({src:te(i,T===`.`?e.name:`${T}/${e.name}`),alt:e.displayName??e.name})},[K,Z,T,i]),At=(0,_.useCallback)(()=>(E??[]).filter(e=>e.kind===`file`&&q.has(e.name)),[E,q]),jt=(0,_.useCallback)(()=>(E??[]).filter(e=>(e.kind===`file`||e.kind===`directory`)&&q.has(e.name)),[E,q]),Mt=(0,_.useCallback)(()=>{let e=jt(),t=e.some(e=>e.kind===`directory`);e.length===1&&!t?xt(e[0]):e.length>=1&&p(i,e.map(e=>T===`.`?e.name:`${T}/${e.name}`)),X(`action`)},[jt,xt,T,i,X]),Nt=(0,_.useCallback)(async()=>{let t=At(),n=t.filter(e=>!e.protected),r=t.length-n.length;Xe(r>0?`${r} protected file(s) kept`:null);for(let t of n){let n=T===`.`?t.name:`${T}/${t.name}`;try{let t=await e(`/api/admin/files?path=${encodeURIComponent(n)}`,{method:`DELETE`}),r=await t.json().catch(()=>({error:`HTTP ${t.status}`}));if(!t.ok)throw Error(r.error??`HTTP ${t.status}`)}catch(e){Xe(e instanceof Error?e.message:String(e))}}I(e=>e+1),X(`action`)},[At,T,e,X]),Pt=(0,_.useCallback)(async()=>{let e=At();if(console.info(`[data-ui] op=share supported=${Y} count=${e.length}`),Y)try{let t=await Promise.all(e.map(async e=>{let t=T===`.`?e.name:`${T}/${e.name}`,n=`/api/admin/files/download?session_key=${encodeURIComponent(i)}&path=${encodeURIComponent(t)}`,r=await(await fetch(n)).blob();return new File([r],e.name,{type:r.type||`application/octet-stream`})}));navigator.canShare({files:t})&&await navigator.share({files:t})}catch(e){console.warn(`[data-ui] op=share-failed err=${e instanceof Error?e.message:String(e)}`)}},[At,Y,T,i]),Ft=(0,_.useCallback)(()=>{F.current?.click()},[]),It=(0,_.useCallback)((e,t={})=>{let n=(n,r,a)=>{let o=new URLSearchParams({session_key:i,path:T===`.`?``:T,filename:e.name});t.relpath&&o.set(`relpath`,t.relpath),t.token&&o.set(`token`,t.token);for(let[e,t]of Object.entries(r))o.set(e,t);return new Promise(t=>{let r=new XMLHttpRequest;r.open(`POST`,`/api/admin/files/upload?${o.toString()}`),r.setRequestHeader(`Content-Type`,e.type||`application/octet-stream`),a&&(r.upload.onprogress=e=>{e.lengthComputable&&a(e.loaded)}),r.onload=()=>{let e={};try{e=JSON.parse(r.responseText)}catch{}t({status:r.status,data:e})},r.onerror=()=>t({status:0,data:{}}),r.onabort=()=>t({status:0,data:{error:`aborted`}}),r.send(n)})};if(e.size<=ve)return n(e,{},n=>t.onProgress?.(n,e.size));let r=`${Date.now().toString(36)}-${Math.random().toString(16).slice(2,10)}`,a=Math.ceil(e.size/ye);return(async()=>{let i={status:0,data:{}};for(let o=0;o<a;o++){let s=o*ye;if(i=await n(e.slice(s,Math.min(s+ye,e.size)),{uploadId:r,seq:String(o),total:String(a)},n=>t.onProgress?.(s+n,e.size)),!(i.status>=200&&i.status<300))return i}return i})()},[i,T]),Lt=(0,_.useCallback)(async e=>{P(null),j(!0),N({loaded:0,total:e.size});try{let{status:t,data:n}=await It(e,{onProgress:(e,t)=>N({loaded:e,total:t})});t>=200&&t<300&&n.path?(Fe(n.path.split(`/`).slice(0,-1).join(`/`)||`.`),I(e=>e+1)):P(t===0?`Network error during upload — the connection failed before the server responded.`:n.error??`Upload failed (HTTP ${t}).`)}finally{j(!1),N(null),F.current&&(F.current.value=``)}},[It]),Rt=(0,_.useCallback)(e=>{V&&Array.from(e.dataTransfer.types).includes(`Files`)&&(e.preventDefault(),Je(!0))},[V]),zt=(0,_.useCallback)(e=>{e.currentTarget.contains(e.relatedTarget)||Je(!1)},[]),Bt=(0,_.useCallback)(async e=>{e.preventDefault(),Je(!1);let t=Math.random().toString(16).slice(2,10),n=Array.from(e.dataTransfer.items);if(console.info(`[data-ui] op=drop-received token=${t} items=${n.length}`),n.length===0)return;if(!V){console.info(`[data-ui] op=drop-rejected token=${t} reason=no-write`),P(`Open a folder inside your account to upload`);return}let r=n.map(e=>e.webkitGetAsEntry?.()).filter(e=>!!e);j(!0),P(null),Ke(null);let i=performance.now();try{let e=await Te(r),n=e.reduce((e,t)=>e+t.file.size,0),a=new Set(e.map(e=>e.relpath.split(`/`).slice(0,-1).join(`/`)).filter(Boolean)).size;console.info(`[data-ui] op=drop-walk token=${t} files=${e.length} dirs=${a} bytes=${n}`);let o=0,s=[];for(let n=0;n<e.length;n++){let{file:r,relpath:i}=e[n];console.info(`[data-ui] op=drop-file token=${t} rel="${i}" i=${n+1}/${e.length}`),N({loaded:0,total:r.size});let{status:a,data:c}=await It(r,{relpath:i,token:t,onProgress:(e,t)=>N({loaded:e,total:t})});if(a>=200&&a<300)o++,console.info(`[data-ui] op=drop-file-ok token=${t} rel="${i}"`);else{let e=a===0?`http=0`:Ee(a,c.error);s.push(`${i} (${e})`),console.info(`[data-ui] op=drop-file-skip token=${t} rel="${i}" reason=${e}`)}}let c=Math.round(performance.now()-i);console.info(`[data-ui] op=drop-done token=${t} uploaded=${o} skipped=${s.length} ms=${c}`),Ke(`Uploaded ${o}, skipped ${s.length}${s.length?`: ${s.join(`, `)}`:``}`),I(e=>e+1)}catch(e){P(e instanceof Error?e.message:String(e))}finally{j(!1),N(null)}},[V,It]),Vt=(0,_.useCallback)(async()=>{let t=$e.trim();if(t){B(null);try{let n=await e(`/api/admin/files/folder`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:T===`.`?``:T,name:t})}),r=await n.json().catch(()=>({error:`HTTP ${n.status}`}));if(!n.ok)throw Error(r.error??`HTTP ${n.status}`);L(!1),et(``),I(e=>e+1)}catch(e){B(e instanceof Error?e.message:String(e))}}},[e,$e,T]),Ht=(0,_.useCallback)(async()=>{if(!R)return;let t=tt.trim();if(!t)return;B(null);let n=T===`.`?R:`${T}/${R}`;try{let r=await e(`/api/admin/files/rename`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:n,newName:t})}),i=await r.json().catch(()=>({error:`HTTP ${r.status}`}));if(!r.ok)throw Error(i.error??`HTTP ${r.status}`);z(null),nt(``),X(`action`),I(e=>e+1)}catch(e){B(e instanceof Error?e.message:String(e))}},[e,tt,R,T,X]);(0,_.useEffect)(()=>{if(!ut)return;let e=e=>{ft.current&&!ft.current.contains(e.target)&&dt(!1)},t=e=>{e.key===`Escape`&&dt(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[ut]),(0,_.useEffect)(()=>{if(!pt)return;let e=e=>{mt.current&&!mt.current.contains(e.target)&&U(!1)},t=e=>{e.key===`Escape`&&U(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[pt]);let $=(0,_.useCallback)(e=>k.slice(0,e+1).map(e=>e.name).join(`/`),[k]),Ut=k.length>=2,Wt=Ut?[{name:`.`,label:`data`},...k.slice(0,k.length-2).map((e,t)=>({name:$(t),label:e.displayName??e.name}))]:[];return(0,v.jsxs)(`main`,{className:`data-main`,children:[(0,v.jsx)(ee,{variant:`operator`,onNavigate:at,conversationsCount:H.length,conversationsChannels:lt,onOpenConversations:()=>ct(`conversations`),onToggleSidebar:()=>{},sidebarOpen:!1,onLogout:it,onDisconnect:async()=>!0,disconnecting:!1}),st===`conversations`?(0,v.jsx)(re,{conversations:H,sessionKey:i,onBack:()=>ct(`files`)}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`div`,{className:`data-toolbar`,children:[K?(0,v.jsxs)(`button`,{type:`button`,className:`data-select-cancel`,onClick:()=>X(`cancel`),"aria-label":`Cancel selection`,children:[(0,v.jsx)(c,{size:14}),` Cancel`]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`div`,{className:`data-search-input`,children:[u===``&&(0,v.jsx)(ae,{size:14}),(0,v.jsx)(`input`,{ref:ie,type:`text`,value:u,onChange:e=>m(e.target.value),autoFocus:!0,autoComplete:`off`,spellCheck:!1}),y&&(0,v.jsx)(f,{size:14,className:`spin`}),u!==``&&(0,v.jsx)(`button`,{type:`button`,className:`data-search-inline-btn`,onClick:()=>{m(``),ie.current?.focus()},title:`Clear search`,"aria-label":`Clear search`,children:(0,v.jsx)(c,{size:14})})]}),(0,v.jsxs)(`div`,{className:`data-toolbar-actions`,ref:mt,children:[(0,v.jsx)(`button`,{type:`button`,className:`data-action-overflow`,onClick:()=>U(e=>!e),"aria-haspopup":`menu`,"aria-expanded":pt,"aria-label":`File actions`,title:`File actions`,children:(0,v.jsx)(r,{size:16})}),(0,v.jsxs)(`div`,{className:`data-action-group`,role:`group`,"aria-label":`File actions`,"data-open":pt?`true`:void 0,children:[(0,v.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{vt(),U(!1)},disabled:A,title:`Refresh this folder`,"aria-label":`Refresh this folder`,children:[A?(0,v.jsx)(f,{size:16,className:`spin`}):(0,v.jsx)(s,{size:16}),(0,v.jsx)(`span`,{className:`data-action-label`,children:`Refresh`})]}),(0,v.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{Ft(),U(!1)},disabled:Ue||!V,title:V?`Upload a file`:`Open a folder inside your account to upload`,"aria-label":`Upload a file`,children:[Ue?M&&M.total>0?(0,v.jsxs)(`span`,{className:`data-upload-pct`,children:[Math.round(M.loaded/M.total*100),`%`]}):(0,v.jsx)(f,{size:16,className:`spin`}):(0,v.jsx)(pe,{size:16}),(0,v.jsx)(`span`,{className:`data-action-label`,children:`Upload`})]}),(0,v.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{L(e=>!e),et(``),B(null),U(!1)},disabled:Ue||!V,title:V?`New folder`:`Open a folder inside your account to create one`,"aria-label":`New folder`,children:[(0,v.jsx)(ce,{size:16}),(0,v.jsx)(`span`,{className:`data-action-label`,children:`New folder`})]}),(0,v.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{Ot(D===`grid`?`list`:`grid`),U(!1)},title:D===`grid`?`List view`:`Grid view`,"aria-label":D===`grid`?`Switch to list view`:`Switch to grid view`,"aria-pressed":D===`grid`,children:[D===`grid`?(0,v.jsx)(de,{size:16}):(0,v.jsx)(ue,{size:16}),(0,v.jsx)(`span`,{className:`data-action-label`,children:D===`grid`?`List view`:`Grid view`})]})]})]})]}),(0,v.jsxs)(`div`,{className:`data-breadcrumbs`,children:[T!==`.`&&(0,v.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost data-back-btn`,onClick:bt,title:`Up one level`,"aria-label":`Up one level`,children:(0,v.jsx)(se,{size:14})}),Ut?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`span`,{className:`data-crumb-wrap`,ref:ft,children:[(0,v.jsx)(`button`,{type:`button`,className:`data-crumb data-crumb-ellipsis`,onClick:()=>dt(e=>!e),"aria-haspopup":`menu`,"aria-expanded":ut,"aria-label":`Show parent folders`,title:`Show parent folders`,children:`…`}),ut&&(0,v.jsx)(`div`,{className:`data-crumb-menu`,role:`menu`,children:Wt.map(e=>(0,v.jsx)(`button`,{type:`button`,role:`menuitem`,className:`data-crumb-menu-item`,onClick:()=>G(e.name),title:e.label,children:e.label},e.name))})]}),[k.length-2,k.length-1].map(e=>{let t=k[e];return(0,v.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,v.jsx)(`span`,{className:`data-crumb-sep`,children:`/`}),(0,v.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>G($(e)),title:t.name,children:t.displayName??t.name})]},$(e))})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>G(`.`),children:`data`}),k.map((e,t)=>(0,v.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,v.jsx)(`span`,{className:`data-crumb-sep`,children:`/`}),(0,v.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>G($(t)),title:e.name,children:e.displayName??e.name})]},$(t)))]})]}),Qe&&(0,v.jsxs)(`div`,{className:`data-inline-form`,children:[(0,v.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`Folder name`,value:$e,autoFocus:!0,onChange:e=>et(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Vt(),e.key===`Escape`&&L(!1)}}),(0,v.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:Vt,children:`Create`}),(0,v.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost`,onClick:()=>L(!1),children:`Cancel`})]}),R&&(0,v.jsxs)(`div`,{className:`data-inline-form`,children:[(0,v.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`New name`,value:tt,autoFocus:!0,onChange:e=>nt(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Ht(),e.key===`Escape`&&z(null)}}),(0,v.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:Ht,children:`Rename`}),(0,v.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost`,onClick:()=>z(null),children:`Cancel`})]}),rt&&(0,v.jsx)(`div`,{className:`data-error`,children:rt}),(0,v.jsx)(`input`,{type:`file`,ref:F,hidden:!0,onChange:e=>{let t=e.target.files?.[0];t&&Lt(t)}})]}),(0,v.jsxs)(`div`,{className:`data-body`,"data-drag-active":qe?`true`:void 0,onDragEnter:Rt,onDragOver:Rt,onDragLeave:zt,onDrop:Bt,children:[(x!==null||g!==null)&&(0,v.jsxs)(`section`,{className:`data-panel`,children:[x&&(0,v.jsxs)(`div`,{className:`data-error`,children:[`Search failed: `,x]}),ht.length>0&&(0,v.jsx)(`div`,{className:`data-chip-row`,role:`group`,"aria-label":`Filter by type`,children:ht.map(e=>{let t=e===W;return(0,v.jsx)(`button`,{type:`button`,className:`data-chip`,"data-active":t,onClick:()=>ke(t?null:e),children:Oe([e])??e},e)})}),g&&!y&&(0,v.jsxs)(`div`,{className:`data-results-meta`,children:[gt.length,` of `,g.length,` result`,g.length===1?``:`s`]}),g&&!y&&!W&&Me>0&&!w&&(0,v.jsxs)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>Pe(!0),children:[Me,` low-confidence result`,Me===1?``:`s`,` hidden — show all`]}),g&&!y&&!W&&w&&(0,v.jsx)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>Pe(!1),children:`Showing all results — hide low-confidence`}),g&&g.length===0&&!y&&(0,v.jsx)(`div`,{className:`data-empty-results`,children:`No matches. Try a different keyword.`}),gt&&gt.length>0&&(0,v.jsx)(`ul`,{className:`data-results`,children:gt.map(e=>(0,v.jsx)(De,{hit:e,mode:xe,onDownload:_t,onLocate:yt},e.nodeId))})]}),(0,v.jsxs)(`section`,{className:`data-panel`,children:[M&&(0,v.jsxs)(`div`,{className:`data-upload-progress`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":M.total>0?Math.round(M.loaded/M.total*100):void 0,children:[(0,v.jsx)(`div`,{className:`data-upload-progress-track`,children:(0,v.jsx)(`div`,{className:`data-upload-progress-fill`,style:{width:`${M.total>0?Math.round(M.loaded/M.total*100):0}%`}})}),(0,v.jsxs)(`span`,{className:`data-upload-progress-label`,children:[`Uploading… `,M.total>0?`${Math.round(M.loaded/M.total*100)}%`:``]})]}),We&&(0,v.jsxs)(`div`,{className:`data-error`,children:[`Upload failed: `,We]}),Ge&&(0,v.jsx)(`div`,{className:`data-status`,children:Ge}),Ye&&(0,v.jsxs)(`div`,{className:`data-error`,children:[`Delete failed: `,Ye]}),Ve&&(0,v.jsx)(`div`,{className:`data-error`,children:Ve}),A&&(0,v.jsxs)(`div`,{className:`data-loading`,children:[(0,v.jsx)(f,{size:14,className:`spin`}),` Loading…`]}),!K&&!A&&E&&E.length>0&&(0,v.jsxs)(`div`,{className:`data-select-hint`,children:[(0,v.jsx)(fe,{size:13}),(0,v.jsx)(`span`,{children:`Press and hold a file to select, rename, or delete it.`})]}),!A&&E&&E.length===0&&!Ve&&(0,v.jsx)(`div`,{className:`data-empty-results`,children:`Empty directory.`}),!A&&E&&E.length>0&&D===`grid`&&(0,v.jsx)(`ul`,{className:`data-grid`,children:E.map(e=>{let t=e.displayName??e.name,n=K&&q.has(e.name);if(e.kind===`directory`)return(0,v.jsx)(`li`,{className:`data-grid-cell`,"data-selected":n?`true`:void 0,children:(0,v.jsxs)(`button`,{type:`button`,className:`data-grid-tile`,onPointerDown:()=>Et(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}G(T===`.`?e.name:`${T}/${e.name}`)},children:[K&&(0,v.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,v.jsx)(le,{size:28,className:`data-grid-glyph`}),(0,v.jsx)(`span`,{className:`data-grid-label`,title:e.name,children:t})]})},e.name);if(e.kind===`file`){let r=ge(e.name),a=T===`.`?e.name:`${T}/${e.name}`;return(0,v.jsx)(`li`,{className:`data-grid-cell`,"data-selected":n?`true`:void 0,children:(0,v.jsxs)(`button`,{type:`button`,className:`data-grid-tile${r?` data-grid-tile-image`:``}`,onPointerDown:()=>Et(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>r?kt(e):Dt(e),title:K?void 0:r?`Preview ${t}`:`Download ${t}`,children:[K&&(0,v.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),r?(0,v.jsx)(`img`,{className:`data-grid-thumb`,src:te(i,a),alt:t,loading:`lazy`,onError:()=>console.warn(`[data] op=thumb-error path=${a}`)}):(0,v.jsx)(o,{size:28,className:`data-grid-glyph`}),(0,v.jsx)(`span`,{className:`data-grid-label`,title:e.name,children:t}),!r&&(0,v.jsx)(`span`,{className:`data-grid-sub`,children:Ae(e.sizeBytes)})]})},e.name)}return(0,v.jsx)(`li`,{className:`data-grid-cell`,children:(0,v.jsxs)(`div`,{className:`data-grid-tile data-entry-disabled`,children:[(0,v.jsx)(o,{size:28,className:`data-grid-glyph`}),(0,v.jsx)(`span`,{className:`data-grid-label`,children:t}),(0,v.jsx)(`span`,{className:`data-grid-sub`,children:`special`})]})},e.name)})}),!A&&E&&E.length>0&&D===`list`&&(0,v.jsx)(`ul`,{className:`data-entries`,children:E.map(e=>{let t=e.displayName??e.name;if(e.kind===`directory`){let n=K&&q.has(e.name);return(0,v.jsx)(`li`,{className:`data-entry`,"data-selected":n?`true`:void 0,children:(0,v.jsxs)(`button`,{type:`button`,className:`data-entry-btn`,onPointerDown:()=>Et(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}G(T===`.`?e.name:`${T}/${e.name}`)},children:[K&&(0,v.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,v.jsx)(le,{size:14}),(0,v.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t})]})},e.name)}if(e.kind===`file`){let n=K&&q.has(e.name);return(0,v.jsx)(`li`,{className:`data-entry`,"data-selected":n?`true`:void 0,children:(0,v.jsxs)(`button`,{type:`button`,className:`data-entry-btn data-entry-file`,onPointerDown:()=>Et(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>Dt(e),title:K?void 0:`Download ${t}`,children:[K&&(0,v.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,v.jsxs)(`span`,{className:`data-entry-text`,children:[(0,v.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t}),(0,v.jsxs)(`span`,{className:`data-entry-meta`,title:`Modified ${je(e.modifiedAt)}`,children:[Ae(e.sizeBytes),` · `,je(e.modifiedAt)]})]})]})},e.name)}return(0,v.jsx)(`li`,{className:`data-entry`,children:(0,v.jsx)(`div`,{className:`data-entry-btn data-entry-file data-entry-disabled`,children:(0,v.jsxs)(`span`,{className:`data-entry-text`,children:[(0,v.jsx)(`span`,{className:`data-entry-name`,children:t}),(0,v.jsx)(`span`,{className:`data-entry-meta`,children:`special`})]})})},e.name)})})]})]}),K&&(0,v.jsx)(`div`,{className:`data-select-bar`,role:`toolbar`,"aria-label":`Selection actions`,children:(0,v.jsxs)(`div`,{className:`data-select-bar-inner`,children:[(0,v.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:Pt,disabled:!Y||q.size===0,title:Y?`Share selected files`:`Sharing is not supported on this device`,children:[(0,v.jsx)(t,{size:16}),` Share`]}),(0,v.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:Mt,disabled:q.size===0,children:[(0,v.jsx)(a,{size:16}),` Download`]}),(0,v.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:()=>{let e=[...q][0];e&&(z(e),nt(e))},disabled:q.size!==1,children:[(0,v.jsx)(ne,{size:16}),` Rename`]}),(0,v.jsxs)(`button`,{type:`button`,className:`data-select-action data-select-delete`,onClick:Nt,disabled:q.size===0,children:[(0,v.jsx)(n,{size:16}),` Delete`]})]})})]}),O&&(0,v.jsx)(`div`,{className:`chat-attachment-overlay`,role:`dialog`,"aria-label":O.alt,onClick:()=>Re(null),children:(0,v.jsx)(`img`,{className:`chat-attachment-overlay-image`,src:O.src,alt:O.alt})})]})}function De({hit:e,mode:t,onDownload:n,onLocate:r}){let i=S(e.properties),a=C(e.properties),o=Oe(e.labels),s=ke(e.properties),[c,l]=(0,_.useState)(!1),u=a&&a.length>280,ee=c||!u?a:a?.slice(0,280)+`…`,te=t===`bm25`?`bm25 ${e.bm25Score.toFixed(2)}`:`vector ${e.vectorScore.toFixed(2)} · bm25 ${e.bm25Score.toFixed(2)} · combined ${e.score.toFixed(2)}`,d=e.properties.relativePath,f=typeof d==`string`&&d.length>0,ne=f?d.lastIndexOf(`/`):-1,p=f?ne===-1?`data`:d.slice(0,ne):null;return(0,v.jsxs)(`li`,{className:`data-result`,children:[(0,v.jsxs)(`div`,{role:`button`,tabIndex:0,className:`data-result-open`,onClick:()=>n(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n(e))},"aria-label":`Download ${i??o??`file`}`,children:[o&&(0,v.jsx)(`div`,{className:`data-result-header`,children:(0,v.jsx)(`span`,{className:`data-result-labels`,children:o})}),i&&(0,v.jsx)(`div`,{className:`data-result-title`,children:i}),a&&(0,v.jsx)(`pre`,{className:`data-result-body`,children:ee}),(0,v.jsxs)(`div`,{className:`data-result-scores`,children:[s&&(0,v.jsxs)(`span`,{className:`data-result-updated`,children:[`Updated `,je(s),` · `]}),te]})]}),f&&(0,v.jsxs)(`button`,{type:`button`,className:`data-result-locate`,onClick:()=>r(e),title:`Locate in ${p}`,"aria-label":`Locate in ${p}`,children:[(0,v.jsx)(le,{size:12}),p]}),u&&(0,v.jsx)(`button`,{type:`button`,className:`data-result-toggle`,onClick:()=>l(e=>!e),children:c?`Show less`:`Show more`})]})}function Oe(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 S(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 C(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 ke(e){for(let t of[`updatedAt`,`modifiedAt`,`fetchedAt`,`createdAt`,`lastModified`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}function Ae(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 je(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`—`}}(0,g.createRoot)(document.getElementById(`root`)).render((0,v.jsx)(xe,{}));