@rubytech/create-maxy-code 0.1.378 → 0.1.379

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 (40) hide show
  1. package/package.json +1 -1
  2. package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +3 -3
  3. package/payload/platform/plugins/docs/references/admin-ui.md +2 -2
  4. package/payload/platform/plugins/whatsapp/references/channels-whatsapp.md +13 -0
  5. package/payload/server/{chunk-AQO6KLIH.js → chunk-ZYS5V5QG.js} +0 -21
  6. package/payload/server/maxy-edge.js +1 -1
  7. package/payload/server/public/assets/{AdminLoginScreens-B9u1V35g.js → AdminLoginScreens-BHo8w_9J.js} +1 -1
  8. package/payload/server/public/assets/AdminShell-DbTijFVA.js +1 -0
  9. package/payload/server/public/assets/{Checkbox-B2g2SCpw.js → Checkbox-LmjNFccS.js} +1 -1
  10. package/payload/server/public/assets/admin-BBWILfl8.js +1 -0
  11. package/payload/server/public/assets/{browser-B8omhYsK.js → browser-DtLvD_ES.js} +1 -1
  12. package/payload/server/public/assets/calendar-D3i4IqOV.js +1 -0
  13. package/payload/server/public/assets/chat-DU-T6blN.js +1 -0
  14. package/payload/server/public/assets/data-B_vDxQrO.js +1 -0
  15. package/payload/server/public/assets/{graph-DJOKFr_s.js → graph-ClQeGEH4.js} +3 -3
  16. package/payload/server/public/assets/{graph-labels-DFdBydWC.js → graph-labels-OaIKHgMg.js} +1 -1
  17. package/payload/server/public/assets/operator-Dxqfta5U.js +1 -0
  18. package/payload/server/public/assets/{page-BMeSKYGZ.js → page-BkIb7CHh.js} +4 -4
  19. package/payload/server/public/assets/page-Dv_YEOUW.js +1 -0
  20. package/payload/server/public/assets/{public-CGl0i1f-.js → public-C_mM8sSZ.js} +1 -1
  21. package/payload/server/public/assets/{rotate-ccw-Cg_V4XIU.js → rotate-ccw-VF0b6NTt.js} +1 -1
  22. package/payload/server/public/assets/useSubAccountSwitcher-CQbgG-FH.js +9 -0
  23. package/payload/server/public/assets/{useSubAccountSwitcher-Ca1GJeBC.css → useSubAccountSwitcher-VzvzZC7h.css} +1 -1
  24. package/payload/server/public/browser.html +4 -4
  25. package/payload/server/public/calendar.html +4 -4
  26. package/payload/server/public/chat.html +6 -6
  27. package/payload/server/public/data.html +5 -5
  28. package/payload/server/public/graph.html +7 -7
  29. package/payload/server/public/index.html +8 -8
  30. package/payload/server/public/operator.html +8 -8
  31. package/payload/server/public/public.html +6 -6
  32. package/payload/server/server.js +247 -72
  33. package/payload/server/public/assets/AdminShell-C2UXTLSB.js +0 -1
  34. package/payload/server/public/assets/admin-CRBQgWsm.js +0 -1
  35. package/payload/server/public/assets/calendar-Blb-5arm.js +0 -1
  36. package/payload/server/public/assets/chat--1ajLxwi.js +0 -1
  37. package/payload/server/public/assets/data-BYUmu98z.js +0 -1
  38. package/payload/server/public/assets/operator-DUVqlubZ.js +0 -1
  39. package/payload/server/public/assets/page-DBkTNfei.js +0 -1
  40. package/payload/server/public/assets/useSubAccountSwitcher-DAgBUed_.js +0 -9
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-CAM3fms7.js";import{C as t,E as n,F as r,G as i,H as a,L as o,N as s,O as c,S as l,W as u,b as d,j as f,q as p}from"./useSubAccountSwitcher-DAgBUed_.js";import{t as m,u as h,y as g}from"./AdminShell-C2UXTLSB.js";var _=o(`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=o(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),y=o(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),b=o(`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=o(`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`}]]),S=o(`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`}]]),C=i(),w=e(p(),1);function T(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function E(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}function D(e){let t=T(e),n=t.getDay();return E(t,n===0?-6:1-n)}function O(e){let t=D(e);return Array.from({length:7},(e,n)=>E(t,n))}function k(e){let t=D(new Date(e.getFullYear(),e.getMonth(),1));return Array.from({length:42},(e,n)=>E(t,n))}function A(){return Array.from({length:24},(e,t)=>t)}function j(e){let t=e.getFullYear();return Array.from({length:12},(e,n)=>new Date(t,n,1))}function M(e,t){switch(e){case`day`:{let e=T(t);return{from:e,to:E(e,1)}}case`week`:{let e=D(t);return{from:e,to:E(e,7)}}case`month`:{let e=D(new Date(t.getFullYear(),t.getMonth(),1));return{from:e,to:E(e,42)}}case`year`:return{from:new Date(t.getFullYear(),0,1),to:new Date(t.getFullYear()+1,0,1)}}}function N(e,t,n){switch(e){case`day`:return E(t,n);case`week`:return E(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 P(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function F(e,t){return{role:`button`,tabIndex:0,onClick:()=>t(e),onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t(e))}}}var I=a(),L=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],R=3;function z(e){return e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function B({anchor:e,meetings:t,onSelect:n}){let r=k(e),i=e.getMonth(),a=new Date;return(0,I.jsxs)(`div`,{className:`cal-month`,children:[(0,I.jsx)(`div`,{className:`cal-weekday-row`,children:L.map(e=>(0,I.jsx)(`div`,{className:`cal-weekday`,children:e},e))}),(0,I.jsx)(`div`,{className:`cal-month-grid`,children:r.map(e=>{let r=t.filter(t=>P(new Date(t.startsAt),e)).sort((e,t)=>e.startsAt.localeCompare(t.startsAt)),o=e.getMonth()!==i,s=P(e,a);return(0,I.jsxs)(`div`,{className:`cal-cell${o?` cal-cell-out`:``}${s?` cal-cell-today`:``}`,children:[(0,I.jsx)(`div`,{className:`cal-cell-num`,children:e.getDate()}),r.slice(0,R).map(e=>(0,I.jsxs)(`div`,{className:`cal-chip`,title:e.title??`Untitled`,...F(e,n),children:[!e.isAllDay&&(0,I.jsx)(`span`,{className:`cal-chip-time`,children:z(new Date(e.startsAt))}),e.title??`Untitled`]},e.meetingId)),r.length>R&&(0,I.jsxs)(`div`,{className:`cal-more`,children:[`+`,r.length-R,` more`]})]},e.toISOString())})})]})}var V=1440,H=1.8;function U(e){return e.getHours()*60+e.getMinutes()}function W(e){return e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function G({day:e,meetings:t,hourHeight:n,onSelect:r}){let i=n*24,a=t.filter(t=>!t.isAllDay&&P(new Date(t.startsAt),e));return(0,I.jsx)(`div`,{className:`cal-day-col`,children:(0,I.jsxs)(`div`,{className:`cal-hours`,style:{height:`${i}px`},children:[Array.from({length:24},(e,t)=>(0,I.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=U(n),o=P(i,e)?U(i):V,s=a/V*100,c=Math.max((o-a)/V*100,H);return(0,I.jsxs)(`div`,{className:`cal-event`,style:{top:`${s}%`,height:`${c}%`},title:t.title??`Untitled`,...F(t,r),children:[(0,I.jsx)(`span`,{className:`cal-event-time`,children:W(n)}),(0,I.jsx)(`span`,{className:`cal-event-title`,children:t.title??`Untitled`})]},t.meetingId)})]})})}var K=44;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=O(e),i=new Date;return(0,I.jsxs)(`div`,{className:`cal-timed`,children:[(0,I.jsxs)(`div`,{className:`cal-day-headrow`,children:[(0,I.jsx)(`div`,{className:`cal-timed-gutter`}),r.map(e=>(0,I.jsxs)(`div`,{className:`cal-day-head${P(e,i)?` cal-day-head-today`:``}`,children:[(0,I.jsx)(`span`,{className:`cal-day-head-name`,children:e.toLocaleDateString([],{weekday:`short`})}),(0,I.jsx)(`span`,{className:`cal-day-head-num`,children:e.getDate()})]},e.toISOString()))]}),(0,I.jsxs)(`div`,{className:`cal-allday-band`,children:[(0,I.jsx)(`div`,{className:`cal-timed-gutter`,children:`All-day`}),r.map(e=>(0,I.jsx)(`div`,{className:`cal-allday-cell`,children:t.filter(t=>t.isAllDay&&P(new Date(t.startsAt),e)).map(e=>(0,I.jsx)(`div`,{className:`cal-allday-chip`,title:e.title??`Untitled`,...F(e,n),children:e.title??`Untitled`},e.meetingId))},e.toISOString()))]}),(0,I.jsxs)(`div`,{className:`cal-timed-cols`,children:[(0,I.jsx)(`div`,{className:`cal-timed-gutter`,children:A().map(e=>(0,I.jsx)(`div`,{className:`cal-hour-label`,style:{height:`${K}px`},children:e===0?``:q(e)},e))}),r.map(e=>(0,I.jsx)(G,{day:e,meetings:t,hourHeight:K,onSelect:n},e.toISOString()))]})]})}var Y=52;function X(e){let t=new Date;return t.setHours(e,0,0,0),t.toLocaleTimeString([],{hour:`numeric`})}function Z({anchor:e,meetings:t,onSelect:n}){let r=t.filter(t=>t.isAllDay&&P(new Date(t.startsAt),e));return(0,I.jsxs)(`div`,{className:`cal-timed cal-timed-single`,children:[(0,I.jsxs)(`div`,{className:`cal-allday-band`,children:[(0,I.jsx)(`div`,{className:`cal-timed-gutter`,children:`All-day`}),(0,I.jsx)(`div`,{className:`cal-allday-cell`,children:r.map(e=>(0,I.jsx)(`div`,{className:`cal-allday-chip`,title:e.title??`Untitled`,...F(e,n),children:e.title??`Untitled`},e.meetingId))})]}),(0,I.jsxs)(`div`,{className:`cal-timed-cols`,children:[(0,I.jsx)(`div`,{className:`cal-timed-gutter`,children:A().map(e=>(0,I.jsx)(`div`,{className:`cal-hour-label`,style:{height:`${Y}px`},children:e===0?``:X(e)},e))}),(0,I.jsx)(G,{day:e,meetings:t,hourHeight:Y,onSelect:n})]})]})}var ee=[`M`,`T`,`W`,`T`,`F`,`S`,`S`];function te(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function ne({anchor:e,meetings:t,onPickMonth:n}){let r=new Date,i=new Set(t.map(e=>te(new Date(e.startsAt))));return(0,I.jsx)(`div`,{className:`cal-year`,children:(0,I.jsx)(`div`,{className:`cal-year-grid`,children:j(e).map(e=>{let t=k(e),a=e.getMonth();return(0,I.jsxs)(`button`,{type:`button`,className:`cal-mini`,onClick:()=>n(e),title:e.toLocaleDateString([],{month:`long`,year:`numeric`}),children:[(0,I.jsx)(`div`,{className:`cal-mini-title`,children:e.toLocaleDateString([],{month:`long`})}),(0,I.jsx)(`div`,{className:`cal-mini-weekrow`,children:ee.map((e,t)=>(0,I.jsx)(`span`,{className:`cal-mini-weekday`,children:e},t))}),(0,I.jsx)(`div`,{className:`cal-mini-grid`,children:t.map(e=>{let t=e.getMonth()!==a,n=P(e,r),o=!t&&i.has(te(e));return(0,I.jsxs)(`span`,{className:`cal-mini-day${t?` cal-mini-day-out`:``}${n?` cal-mini-day-today`:``}`,children:[e.getDate(),o&&(0,I.jsx)(`span`,{className:`cal-mini-dot`})]},e.toISOString())})})]},a)})})})}var re={meeting:`Meeting`,event:`Event`,task:`Task`};function ie(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 ae(e){return new Date(e).toISOString()}function Q(e){return Math.floor(new Date(e).getTime()/6e4)}function oe(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 se(e){if(!e)return null;let t=e.match(/filename="([^"]+)"/);return t?t[1]:null}function ce(e,t){return e.email??`${e.name??`unknown`}-${t}`}function le({a:e}){let t=e.name||e.email||`Unknown`,n=e.name&&e.email?e.email:null;return(0,I.jsxs)(`span`,{className:`cal-attendee-lines`,children:[(0,I.jsx)(`span`,{className:`cal-attendee-name`,children:t}),n&&(0,I.jsx)(`span`,{className:`cal-attendee-email`,children:n})]})}function ue({meeting:e,adminFetch:r,onClose:i,onSaved:a,onDeleted:o}){let u=e.kind===`meeting`,[d,f]=(0,w.useState)(!1),[p,m]=(0,w.useState)(!1),[g,v]=(0,w.useState)(!1),[C,T]=(0,w.useState)(!1),[E,D]=(0,w.useState)(null),[O,k]=(0,w.useState)(e),[A,j]=(0,w.useState)(e.title??``),[M,N]=(0,w.useState)(ie(e.startsAt)),[P,F]=(0,w.useState)(e.endsAt?ie(e.endsAt):``),[L,R]=(0,w.useState)(e.location??``),[z,B]=(0,w.useState)(e.privateNote??``),[V,H]=(0,w.useState)(``),[U,W]=(0,w.useState)(``);(0,w.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!C&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[C,i]);let G=(0,w.useCallback)(()=>{let e={},t=A.trim();t!==(O.title??``)&&(e.title=t);let n=ae(M);Q(n)!==Q(O.startsAt)&&(e.startsAt=n);let r=P?ae(P):null;(r===null?O.endsAt!==null:O.endsAt===null||Q(r)!==Q(O.endsAt))&&(e.endsAt=r);let i=L.trim()||null;i!==(O.location??null)&&(e.location=i);let a=z.trim()||null;return a!==(O.privateNote??null)&&(e.privateNote=a),e},[A,M,P,L,z,O]),K=(0,w.useCallback)(async()=>{let t=G();if(Object.keys(t).length===0){f(!1);return}T(!0),D(null);try{let n=await r(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(!n.ok)throw Error(`HTTP ${n.status}`);let i=await n.json();k(i.meeting),a(i.meeting),f(!1)}catch(e){D(e instanceof Error?e.message:`Save failed`)}finally{T(!1)}},[r,G,e.meetingId,a]),q=(0,w.useCallback)(async()=>{let t=V.trim(),n=U.trim();if(!(!t&&!n)){T(!0),D(null);try{let i=await r(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/attendees`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:t||void 0,email:n||void 0})});if(!i.ok)throw Error(`HTTP ${i.status}`);let o=await i.json();k(o.meeting),a(o.meeting),H(``),W(``)}catch(e){D(e instanceof Error?e.message:`Add failed`)}finally{T(!1)}}},[r,V,U,e.meetingId,a]),J=(0,w.useCallback)(async t=>{let n=t.email?{email:t.email}:{name:t.name};T(!0),D(null);try{let t=await r(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/attendees`,{method:`DELETE`,headers:{"content-type":`application/json`},body:JSON.stringify(n)});if(!t.ok)throw Error(`HTTP ${t.status}`);let i=await t.json();k(i.meeting),a(i.meeting)}catch(e){D(e instanceof Error?e.message:`Remove failed`)}finally{T(!1)}},[r,e.meetingId,a]),Y=(0,w.useCallback)(async()=>{T(!0),D(null);try{let t=await r(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}`,{method:`DELETE`});if(!t.ok)throw Error(`HTTP ${t.status}`);o(e.meetingId)}catch(e){D(e instanceof Error?e.message:`Delete failed`),T(!1)}},[r,e.meetingId,o]),X=(0,w.useCallback)(async t=>{v(!1),T(!0),D(null);try{let n=await r(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/ics?attendees=${t?`1`:`0`}`);if(!n.ok)throw Error(`HTTP ${n.status}`);let i=await n.blob(),a=se(n.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){D(e instanceof Error?e.message:`Download failed`)}finally{T(!1)}},[r,e.meetingId]),Z=re[e.kind??`meeting`],ee=V.trim().length>0||U.trim().length>0;return(0,I.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{C||i()},children:(0,I.jsxs)(`div`,{className:`cal-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":d?`Edit meeting`:`Meeting detail`,onClick:e=>e.stopPropagation(),children:[(0,I.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,I.jsx)(`span`,{className:`cal-modal-kind`,children:Z}),(0,I.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:i,"aria-label":`Close`,autoFocus:!0,disabled:C,children:(0,I.jsx)(l,{size:16})})]}),!d&&(0,I.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,I.jsx)(`div`,{className:`cal-modal-title`,children:O.title??`Untitled`}),(0,I.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,I.jsx)(y,{size:14}),(0,I.jsx)(`span`,{children:oe(O)})]}),O.location&&(0,I.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,I.jsx)(b,{size:14}),(0,I.jsx)(`span`,{children:O.location})]}),O.attendees.length>0&&(0,I.jsxs)(`div`,{className:`cal-modal-row cal-modal-row-top`,children:[(0,I.jsx)(h,{size:14}),(0,I.jsx)(`div`,{className:`cal-modal-attendees`,children:O.attendees.map((e,t)=>(0,I.jsx)(`div`,{className:`cal-attendee-row`,children:(0,I.jsx)(le,{a:e})},ce(e,t)))})]}),O.privateNote&&(0,I.jsxs)(`div`,{className:`cal-modal-row cal-modal-row-top`,children:[(0,I.jsx)(x,{size:14}),(0,I.jsx)(`span`,{className:`cal-modal-note`,children:O.privateNote})]}),(0,I.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,I.jsx)(_,{size:14}),(0,I.jsx)(`span`,{children:Z})]})]}),d&&(0,I.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`Title`}),(0,I.jsx)(`input`,{type:`text`,value:A,onChange:e=>j(e.target.value),disabled:C})]}),(0,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`Start`}),(0,I.jsx)(`input`,{type:`datetime-local`,value:M,onChange:e=>N(e.target.value),disabled:C})]}),(0,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`End`}),(0,I.jsx)(`input`,{type:`datetime-local`,value:P,onChange:e=>F(e.target.value),disabled:C})]}),(0,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`Location`}),(0,I.jsx)(`input`,{type:`text`,value:L,onChange:e=>R(e.target.value),disabled:C})]}),(0,I.jsxs)(`div`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`Attendees`}),(0,I.jsxs)(`div`,{className:`cal-modal-attendees cal-modal-attendees-edit`,children:[O.attendees.length===0&&(0,I.jsx)(`div`,{className:`cal-attendee-empty`,children:`No attendees yet.`}),O.attendees.map((e,t)=>(0,I.jsxs)(`div`,{className:`cal-attendee-row cal-attendee-row-edit`,children:[(0,I.jsx)(le,{a:e}),(0,I.jsx)(`button`,{type:`button`,className:`cal-attendee-remove`,onClick:()=>J(e),disabled:C,"aria-label":`Remove ${e.name||e.email||`attendee`}`,children:(0,I.jsx)(l,{size:13})})]},ce(e,t)))]}),(0,I.jsxs)(`div`,{className:`cal-attendee-add`,children:[(0,I.jsx)(`input`,{type:`text`,placeholder:`Name`,value:V,onChange:e=>H(e.target.value),disabled:C,"aria-label":`Attendee name`}),(0,I.jsx)(`input`,{type:`email`,placeholder:`Email`,value:U,onChange:e=>W(e.target.value),disabled:C,"aria-label":`Attendee email`}),(0,I.jsx)(`button`,{type:`button`,className:`cal-modal-btn cal-attendee-add-btn`,onClick:q,disabled:C||!ee,"aria-label":`Add attendee`,children:C?(0,I.jsx)(c,{size:13,className:`spin`}):(0,I.jsx)(S,{size:13})})]})]}),(0,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`Private note`}),(0,I.jsx)(`textarea`,{className:`cal-modal-textarea`,value:z,onChange:e=>B(e.target.value),disabled:C,rows:3,placeholder:`Only you and your team can see this.`})]})]}),E&&(0,I.jsx)(`div`,{className:`cal-modal-error`,children:E}),u&&(0,I.jsxs)(`div`,{className:`cal-modal-actions`,children:[!d&&!p&&!g&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>f(!0),disabled:C,children:[(0,I.jsx)(n,{size:14}),` Edit`]}),(0,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:()=>m(!0),disabled:C,children:[(0,I.jsx)(t,{size:14}),` Delete`]}),(0,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-download`,onClick:()=>{O.attendees.length>0?v(!0):X(!1)},disabled:C,children:[C?(0,I.jsx)(c,{size:14,className:`spin`}):(0,I.jsx)(s,{size:14}),` Download`]})]}),g&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Include attendees in the file?`}),(0,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:()=>X(!0),disabled:C,children:[C?(0,I.jsx)(c,{size:14,className:`spin`}):null,` Yes`]}),(0,I.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>X(!1),disabled:C,children:`No`}),(0,I.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>v(!1),disabled:C,children:`Cancel`})]}),d&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:K,disabled:C,children:[C?(0,I.jsx)(c,{size:14,className:`spin`}):null,` Save`]}),(0,I.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>{f(!1),D(null)},disabled:C,children:`Cancel`})]}),p&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Delete this meeting?`}),(0,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:Y,disabled:C,children:[C?(0,I.jsx)(c,{size:14,className:`spin`}):null,` Delete`]}),(0,I.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>m(!1),disabled:C,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}=M(`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,w.useState)(null),[n,r]=(0,w.useState)(!1),[i,a]=(0,w.useState)(void 0),[o,s]=(0,w.useState)(null),[l,u]=(0,w.useState)(void 0),[f,p]=(0,w.useState)(null),[h,_]=(0,w.useState)(null);(0,w.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,w.useCallback)(()=>{try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},[]),[y,b]=(0,w.useState)(!1),x=(0,w.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,I.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,I.jsx)(m,{cacheKey:e,businessName:i,sessionId:o,onLogout:v,onDisconnect:x,disconnecting:y,userName:l,userAvatar:f,role:h,children:(0,I.jsx)(me,{cacheKey:e})})}):(0,I.jsx)(`div`,{className:`cal-page`,children:(0,I.jsxs)(`div`,{className:`cal-empty`,children:[(0,I.jsx)(`p`,{children:`You are not signed in.`}),(0,I.jsxs)(`p`,{children:[`Open the `,(0,I.jsx)(`a`,{href:`/`,className:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,I.jsx)(`div`,{className:`cal-page`,children:(0,I.jsxs)(`div`,{className:`cal-loading`,children:[(0,I.jsx)(c,{size:18,className:`spin`}),` Loading…`]})})}function me({cacheKey:e}){let{adminFetch:t,sessionRefetchNonce:n}=u({initialCacheKey:e,surface:`calendar`}),[i,a]=(0,w.useState)(`month`),[o,s]=(0,w.useState)(()=>new Date),[l,d]=(0,w.useState)([]),[p,m]=(0,w.useState)(!1),[h,g]=(0,w.useState)(null),[y,b]=(0,w.useState)(null),[x,S]=(0,w.useState)(null);(0,w.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&&S(n.bookingDomain)}).catch(()=>{}),()=>{e=!0}},[t]),(0,w.useEffect)(()=>{let e=!1,{from:n,to:r}=M(i,o);return m(!0),g(null),t(`/api/admin/calendar/meetings?from=${encodeURIComponent(n.toISOString())}&to=${encodeURIComponent(r.toISOString())}`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();d(Array.isArray(n.meetings)?n.meetings:[])}).catch(t=>{e||(g(t instanceof Error?t.message:`Failed to load`),d([]))}).finally(()=>{e||m(!1)}),()=>{e=!0}},[i,o,n,t]);let C=(0,w.useCallback)(()=>s(new Date),[]),T=(0,w.useCallback)(()=>s(e=>N(i,e,-1)),[i]),E=(0,w.useCallback)(()=>s(e=>N(i,e,1)),[i]),D=(0,w.useCallback)(e=>{s(e),a(`month`)},[]);(0,w.useEffect)(()=>{b(null)},[i,o]);let O=(0,w.useCallback)(e=>{d(t=>t.map(t=>t.meetingId===e.meetingId?e:t)),b(e)},[]),k=(0,w.useCallback)(e=>{d(t=>t.filter(t=>t.meetingId!==e)),b(null)},[]);return(0,I.jsxs)(`div`,{className:`cal-page`,children:[(0,I.jsxs)(`header`,{className:`cal-header`,children:[(0,I.jsxs)(`div`,{className:`cal-title`,children:[(0,I.jsx)(_,{size:20}),` Calendar`]}),(0,I.jsxs)(`div`,{className:`cal-nav`,children:[(0,I.jsx)(`button`,{type:`button`,className:`cal-today-btn`,onClick:C,children:`Today`}),(0,I.jsx)(`button`,{type:`button`,className:`cal-nav-btn`,onClick:T,"aria-label":`Previous`,children:(0,I.jsx)(r,{size:18})}),(0,I.jsx)(`button`,{type:`button`,className:`cal-nav-btn`,onClick:E,"aria-label":`Next`,children:(0,I.jsx)(v,{size:18})}),(0,I.jsx)(`span`,{className:`cal-range-label`,children:fe(i,o)}),p&&(0,I.jsx)(c,{size:16,className:`spin`})]}),(0,I.jsx)(`div`,{className:`cal-views`,children:de.map(e=>(0,I.jsx)(`button`,{type:`button`,className:`cal-view-btn${e===i?` cal-view-btn-active`:``}`,onClick:()=>a(e),children:e.charAt(0).toUpperCase()+e.slice(1)},e))}),x&&(0,I.jsxs)(`a`,{className:`cal-booking-link`,href:`https://${x}`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,I.jsx)(f,{size:14}),` Booking page`]})]}),(0,I.jsxs)(`div`,{className:`cal-body`,children:[h&&(0,I.jsxs)(`div`,{className:`cal-error`,children:[`Could not load the calendar: `,h]}),i===`day`&&(0,I.jsx)(Z,{anchor:o,meetings:l,onSelect:b}),i===`week`&&(0,I.jsx)(J,{anchor:o,meetings:l,onSelect:b}),i===`month`&&(0,I.jsx)(B,{anchor:o,meetings:l,onSelect:b}),i===`year`&&(0,I.jsx)(ne,{anchor:o,meetings:l,onPickMonth:D})]}),y&&(0,I.jsx)(ue,{meeting:y,adminFetch:t,onClose:()=>b(null),onSaved:O,onDeleted:k})]})}(0,C.createRoot)(document.getElementById(`root`)).render((0,I.jsx)(pe,{}));
@@ -1 +0,0 @@
1
- import{G as e,H as t}from"./useSubAccountSwitcher-DAgBUed_.js";import"./admin-types-DJoj6VJv.js";import"./AdminShell-C2UXTLSB.js";import{n}from"./page-BMeSKYGZ.js";var r=e(),i=t();(0,r.createRoot)(document.getElementById(`root`)).render((0,i.jsx)(n,{}));
@@ -1 +0,0 @@
1
- import{G as e,H as t}from"./useSubAccountSwitcher-DAgBUed_.js";import{t as n}from"./page-DBkTNfei.js";import"./graph-labels-DFdBydWC.js";var r=e(),i=t();(0,r.createRoot)(document.getElementById(`root`)).render((0,i.jsx)(n,{}));
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-CAM3fms7.js";import{G as t,H as n,q as r}from"./useSubAccountSwitcher-DAgBUed_.js";import{n as i,t as a}from"./AdminLoginScreens-B9u1V35g.js";import"./admin-types-DJoj6VJv.js";import"./AdminShell-C2UXTLSB.js";import"./Checkbox-B2g2SCpw.js";import{t as o}from"./page-BMeSKYGZ.js";var s=t(),c=e(r(),1),l=n();function u(){let e=i(`operator`),t=(0,c.useRef)(null);return(0,c.useEffect)(()=>{e.appState!==`chat`&&t.current!==e.appState&&(t.current=e.appState,console.info(`[operator-ui] op=auth-gate state=${e.appState}`))},[e.appState]),e.appState===`chat`?(0,l.jsx)(o,{variant:`operator`,forceCanonicalSession:window.location.pathname!==`/chat`}):(0,l.jsx)(a,{auth:e})}(0,s.createRoot)(document.getElementById(`root`)).render((0,l.jsx)(u,{}));
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-CAM3fms7.js";import{A as t,C as n,E as r,H as i,L as a,M as o,N as s,O as c,S as ee,T as l,W as u,b as d,h as f,m as te,n as p,p as m,q as h,t as ne,w as re,y as g}from"./useSubAccountSwitcher-DAgBUed_.js";import{i as ie,t as ae}from"./graph-labels-DFdBydWC.js";var oe=a(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),se=a(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),ce=a(`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`}]]),le=a(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),ue=a(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),de=a(`mouse-pointer-click`,[[`path`,{d:`M14 4.1 12 6`,key:`ita8i4`}],[`path`,{d:`m5.1 8-2.9-.8`,key:`1go3kf`}],[`path`,{d:`m6 12-1.9 2`,key:`mnht97`}],[`path`,{d:`M7.2 2.2 8 5.1`,key:`1cfko1`}],[`path`,{d:`M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z`,key:`s0h3yz`}]]),fe=a(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]);function pe(e){let t=new Set,n=[];for(let r of e)for(let e of r.labels)e&&(t.has(e)||ae.has(e)&&(t.add(e),n.push(e)));return n}var _=e(h(),1),v=i(),me=/\.(png|jpe?g|gif|webp|svg)$/i;function he(e){return me.test(e)}var ge=`maxy-data-view`,_e=95*1024*1024,ve=48*1024*1024;function ye(){return typeof window>`u`?`list`:window.localStorage.getItem(ge)===`grid`?`grid`:`list`}function be(){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)(d,{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)(y,{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)(c,{size:18,className:`spin`}),` Loading…`]})})}function y({cacheKey:e}){let{adminFetch:t,cacheKey:n,sessionRefetchNonce:r}=u({initialCacheKey:e,surface:`data`});return(0,v.jsx)(Te,{adminFetch:t,cacheKey:n,sessionRefetchNonce:r})}function xe(){if(typeof window>`u`)return`.`;let e=new URLSearchParams(window.location.hash.replace(/^#/,``)).get(`path`);return e&&e.length>0?e:`.`}function Se(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 b(e){return new Promise((t,n)=>{let r=[],i=()=>e.readEntries(e=>{e.length===0?t(r):(r.push(...e),i())},n);i()})}function x(e){return new Promise((t,n)=>e.file(t,n))}async function Ce(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 x(r),relpath:e});else if(r.isDirectory){let t=await b(r.createReader());n.push(...await Ce(t,e))}}return n}function we(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 S({adminFetch:e,cacheKey:i,sessionRefetchNonce:a}){let[u,d]=(0,_.useState)(``),p=(0,_.useRef)(null),[h,ne]=(0,_.useState)(``),[g,ae]=(0,_.useState)(null),[me,be]=(0,_.useState)(`hybrid`),[y,b]=(0,_.useState)(!1),[x,S]=(0,_.useState)(null),[Te,Ee]=(0,_.useState)(null),[ke,Ae]=(0,_.useState)(0),[C,Ne]=(0,_.useState)(!1),[w,Pe]=(0,_.useState)(()=>xe()),[T,Fe]=(0,_.useState)(null),[E,Ie]=(0,_.useState)(()=>ye()),[Le,Re]=(0,_.useState)(null),[D,ze]=(0,_.useState)([]),[O,Be]=(0,_.useState)(!1),[Ve,He]=(0,_.useState)(null),[Ue,We]=(0,_.useState)(!1),[k,A]=(0,_.useState)(null),[Ge,j]=(0,_.useState)(null),[Ke,qe]=(0,_.useState)(null),[Je,Ye]=(0,_.useState)(!1),[Xe,Ze]=(0,_.useState)(null),M=(0,_.useRef)(null),[Qe,N]=(0,_.useState)(0),[$e,P]=(0,_.useState)(!1),[et,tt]=(0,_.useState)(``),[F,I]=(0,_.useState)(null),[nt,rt]=(0,_.useState)(``),[it,L]=(0,_.useState)(null),R=(()=>{let e=w===`.`?[]:w.split(`/`).filter(Boolean);return e.length>=2&&e[0]===`accounts`})(),[z,B]=(0,_.useState)(!1),at=(0,_.useRef)(null),[V,H]=(0,_.useState)(!1),ot=(0,_.useRef)(null);(0,_.useEffect)(()=>{let e=u.trim();if(!e){ne(``),ae(null),S(null);return}Ne(!1);let t=setTimeout(()=>ne(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${C?`&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||(ae(e.results),be(e.mode??`hybrid`),Ae(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,a,C]);let st=(0,_.useMemo)(()=>g?pe(g):[],[g]),U=Te&&st.includes(Te)?Te:null,W=(0,_.useMemo)(()=>g?U?g.filter(e=>e.labels.includes(U)):g:null,[g,U]),ct=(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(w===`.`?``:w)}`).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||(Fe(e.entries),ze(e.displayPath??[]))}).catch(e=>{t||(Fe([]),ze([]),He(e instanceof Error?e.message:String(e)))}).finally(()=>{t||Be(!1)}),()=>{t=!0}},[e,w,Qe,a]),(0,_.useEffect)(()=>{Se(w)},[w]);let lt=(0,_.useCallback)(()=>{N(e=>e+1)},[]),G=(0,_.useCallback)(e=>{B(!1),Pe(e)},[]),ut=(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}`),d(``),S(null),Ee(null),G(r)},[G]),dt=(0,_.useCallback)(()=>{if(w===`.`||w===``)return;let e=w.split(`/`).filter(Boolean);e.pop(),Pe(e.length===0?`.`:e.join(`/`))},[w]),ft=(0,_.useCallback)(e=>{te(i,w===`.`?e.name:`${w}/${e.name}`)},[w,i]),[K,pt]=(0,_.useState)(!1),[q,mt]=(0,_.useState)(new Set),ht=(0,_.useRef)(null),J=(0,_.useRef)(!1),Y=typeof navigator<`u`&&typeof navigator.share==`function`&&typeof navigator.canShare==`function`,gt=(0,_.useCallback)(e=>{pt(!0),mt(new Set([e])),console.info(`[data-ui] op=select-enter count=1`)},[]),X=(0,_.useCallback)(e=>{pt(!1),mt(new Set),console.info(`[data-ui] op=select-exit reason=${e}`)},[]),Z=(0,_.useCallback)(e=>{mt(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),_t=(0,_.useCallback)(e=>{J.current=!1,ht.current=setTimeout(()=>{J.current=!0,gt(e)},500)},[gt]),Q=(0,_.useCallback)(()=>{ht.current&&=(clearTimeout(ht.current),null)},[]),vt=(0,_.useCallback)(e=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}ft(e)},[K,Z,ft]),yt=(0,_.useCallback)(e=>{Ie(e),typeof window<`u`&&window.localStorage.setItem(ge,e),console.info(`[data] op=view-mode mode=${e}`)},[]),bt=(0,_.useCallback)(e=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}Re({src:m(i,w===`.`?e.name:`${w}/${e.name}`),alt:e.displayName??e.name})},[K,Z,w,i]),xt=(0,_.useCallback)(()=>(T??[]).filter(e=>e.kind===`file`&&q.has(e.name)),[T,q]),St=(0,_.useCallback)(()=>(T??[]).filter(e=>(e.kind===`file`||e.kind===`directory`)&&q.has(e.name)),[T,q]),Ct=(0,_.useCallback)(()=>{let e=St(),t=e.some(e=>e.kind===`directory`);e.length===1&&!t?ft(e[0]):e.length>=1&&f(i,e.map(e=>w===`.`?e.name:`${w}/${e.name}`)),X(`action`)},[St,ft,w,i,X]),wt=(0,_.useCallback)(async()=>{let t=xt(),n=t.filter(e=>!e.protected),r=t.length-n.length;Ze(r>0?`${r} protected file(s) kept`:null);for(let t of n){let n=w===`.`?t.name:`${w}/${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){Ze(e instanceof Error?e.message:String(e))}}N(e=>e+1),X(`action`)},[xt,w,e,X]),Tt=(0,_.useCallback)(async()=>{let e=xt();if(console.info(`[data-ui] op=share supported=${Y} count=${e.length}`),Y)try{let t=await Promise.all(e.map(async e=>{let t=w===`.`?e.name:`${w}/${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)}`)}},[xt,Y,w,i]),Et=(0,_.useCallback)(()=>{M.current?.click()},[]),Dt=(0,_.useCallback)((e,t={})=>{let n=(n,r,a)=>{let o=new URLSearchParams({session_key:i,path:w===`.`?``:w,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<=_e)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/ve);return(async()=>{let i={status:0,data:{}};for(let o=0;o<a;o++){let s=o*ve;if(i=await n(e.slice(s,Math.min(s+ve,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,w]),Ot=(0,_.useCallback)(async e=>{j(null),We(!0),A({loaded:0,total:e.size});try{let{status:t,data:n}=await Dt(e,{onProgress:(e,t)=>A({loaded:e,total:t})});t>=200&&t<300&&n.path?(Pe(n.path.split(`/`).slice(0,-1).join(`/`)||`.`),N(e=>e+1)):j(t===0?`Network error during upload — the connection failed before the server responded.`:n.error??`Upload failed (HTTP ${t}).`)}finally{We(!1),A(null),M.current&&(M.current.value=``)}},[Dt]),kt=(0,_.useCallback)(e=>{R&&Array.from(e.dataTransfer.types).includes(`Files`)&&(e.preventDefault(),Ye(!0))},[R]),At=(0,_.useCallback)(e=>{e.currentTarget.contains(e.relatedTarget)||Ye(!1)},[]),jt=(0,_.useCallback)(async e=>{e.preventDefault(),Ye(!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(!R){console.info(`[data-ui] op=drop-rejected token=${t} reason=no-write`),j(`Open a folder inside your account to upload`);return}let r=n.map(e=>e.webkitGetAsEntry?.()).filter(e=>!!e);We(!0),j(null),qe(null);let i=performance.now();try{let e=await Ce(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}`),A({loaded:0,total:r.size});let{status:a,data:c}=await Dt(r,{relpath:i,token:t,onProgress:(e,t)=>A({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`:we(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}`),qe(`Uploaded ${o}, skipped ${s.length}${s.length?`: ${s.join(`, `)}`:``}`),N(e=>e+1)}catch(e){j(e instanceof Error?e.message:String(e))}finally{We(!1),A(null)}},[R,Dt]),Mt=(0,_.useCallback)(async()=>{let t=et.trim();if(t){L(null);try{let n=await e(`/api/admin/files/folder`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:w===`.`?``:w,name:t})}),r=await n.json().catch(()=>({error:`HTTP ${n.status}`}));if(!n.ok)throw Error(r.error??`HTTP ${n.status}`);P(!1),tt(``),N(e=>e+1)}catch(e){L(e instanceof Error?e.message:String(e))}}},[e,et,w]),Nt=(0,_.useCallback)(async()=>{if(!F)return;let t=nt.trim();if(!t)return;L(null);let n=w===`.`?F:`${w}/${F}`;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}`);I(null),rt(``),X(`action`),N(e=>e+1)}catch(e){L(e instanceof Error?e.message:String(e))}},[e,nt,F,w,X]);(0,_.useEffect)(()=>{if(!z)return;let e=e=>{at.current&&!at.current.contains(e.target)&&B(!1)},t=e=>{e.key===`Escape`&&B(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[z]),(0,_.useEffect)(()=>{if(!V)return;let e=e=>{ot.current&&!ot.current.contains(e.target)&&H(!1)},t=e=>{e.key===`Escape`&&H(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[V]);let $=(0,_.useCallback)(e=>D.slice(0,e+1).map(e=>e.name).join(`/`),[D]),Pt=D.length>=2,Ft=Pt?[{name:`.`,label:`data`},...D.slice(0,D.length-2).map((e,t)=>({name:$(t),label:e.displayName??e.name}))]:[];return(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)(ee,{size:14}),` Cancel`]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`div`,{className:`data-search-input`,children:[u===``&&(0,v.jsx)(ie,{size:14}),(0,v.jsx)(`input`,{ref:p,type:`text`,value:u,onChange:e=>d(e.target.value),autoFocus:!0,autoComplete:`off`,spellCheck:!1}),y&&(0,v.jsx)(c,{size:14,className:`spin`}),u!==``&&(0,v.jsx)(`button`,{type:`button`,className:`data-search-inline-btn`,onClick:()=>{d(``),p.current?.focus()},title:`Clear search`,"aria-label":`Clear search`,children:(0,v.jsx)(ee,{size:14})})]}),(0,v.jsxs)(`div`,{className:`data-toolbar-actions`,ref:ot,children:[(0,v.jsx)(`button`,{type:`button`,className:`data-action-overflow`,onClick:()=>H(e=>!e),"aria-haspopup":`menu`,"aria-expanded":V,"aria-label":`File actions`,title:`File actions`,children:(0,v.jsx)(o,{size:16})}),(0,v.jsxs)(`div`,{className:`data-action-group`,role:`group`,"aria-label":`File actions`,"data-open":V?`true`:void 0,children:[(0,v.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{lt(),H(!1)},disabled:O,title:`Refresh this folder`,"aria-label":`Refresh this folder`,children:[O?(0,v.jsx)(c,{size:16,className:`spin`}):(0,v.jsx)(l,{size:16}),(0,v.jsx)(`span`,{className:`data-action-label`,children:`Refresh`})]}),(0,v.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{Et(),H(!1)},disabled:Ue||!R,title:R?`Upload a file`:`Open a folder inside your account to upload`,"aria-label":`Upload a file`,children:[Ue?k&&k.total>0?(0,v.jsxs)(`span`,{className:`data-upload-pct`,children:[Math.round(k.loaded/k.total*100),`%`]}):(0,v.jsx)(c,{size:16,className:`spin`}):(0,v.jsx)(fe,{size:16}),(0,v.jsx)(`span`,{className:`data-action-label`,children:`Upload`})]}),(0,v.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{P(e=>!e),tt(``),L(null),H(!1)},disabled:Ue||!R,title:R?`New folder`:`Open a folder inside your account to create one`,"aria-label":`New folder`,children:[(0,v.jsx)(se,{size:16}),(0,v.jsx)(`span`,{className:`data-action-label`,children:`New folder`})]}),(0,v.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{yt(E===`grid`?`list`:`grid`),H(!1)},title:E===`grid`?`List view`:`Grid view`,"aria-label":E===`grid`?`Switch to list view`:`Switch to grid view`,"aria-pressed":E===`grid`,children:[E===`grid`?(0,v.jsx)(ue,{size:16}):(0,v.jsx)(le,{size:16}),(0,v.jsx)(`span`,{className:`data-action-label`,children:E===`grid`?`List view`:`Grid view`})]})]})]})]}),(0,v.jsxs)(`div`,{className:`data-breadcrumbs`,children:[w!==`.`&&(0,v.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost data-back-btn`,onClick:dt,title:`Up one level`,"aria-label":`Up one level`,children:(0,v.jsx)(oe,{size:14})}),Pt?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`span`,{className:`data-crumb-wrap`,ref:at,children:[(0,v.jsx)(`button`,{type:`button`,className:`data-crumb data-crumb-ellipsis`,onClick:()=>B(e=>!e),"aria-haspopup":`menu`,"aria-expanded":z,"aria-label":`Show parent folders`,title:`Show parent folders`,children:`…`}),z&&(0,v.jsx)(`div`,{className:`data-crumb-menu`,role:`menu`,children:Ft.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))})]}),[D.length-2,D.length-1].map(e=>{let t=D[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`}),D.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)))]})]}),$e&&(0,v.jsxs)(`div`,{className:`data-inline-form`,children:[(0,v.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`Folder name`,value:et,autoFocus:!0,onChange:e=>tt(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Mt(),e.key===`Escape`&&P(!1)}}),(0,v.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:Mt,children:`Create`}),(0,v.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost`,onClick:()=>P(!1),children:`Cancel`})]}),F&&(0,v.jsxs)(`div`,{className:`data-inline-form`,children:[(0,v.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`New name`,value:nt,autoFocus:!0,onChange:e=>rt(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Nt(),e.key===`Escape`&&I(null)}}),(0,v.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:Nt,children:`Rename`}),(0,v.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost`,onClick:()=>I(null),children:`Cancel`})]}),it&&(0,v.jsx)(`div`,{className:`data-error`,children:it}),(0,v.jsx)(`input`,{type:`file`,ref:M,hidden:!0,onChange:e=>{let t=e.target.files?.[0];t&&Ot(t)}})]}),(0,v.jsxs)(`div`,{className:`data-body`,"data-drag-active":Je?`true`:void 0,onDragEnter:kt,onDragOver:kt,onDragLeave:At,onDrop:jt,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]}),st.length>0&&(0,v.jsx)(`div`,{className:`data-chip-row`,role:`group`,"aria-label":`Filter by type`,children:st.map(e=>{let t=e===U;return(0,v.jsx)(`button`,{type:`button`,className:`data-chip`,"data-active":t,onClick:()=>Ee(t?null:e),children:Oe([e])??e},e)})}),g&&!y&&(0,v.jsxs)(`div`,{className:`data-results-meta`,children:[W.length,` of `,g.length,` result`,g.length===1?``:`s`]}),g&&!y&&!U&&ke>0&&!C&&(0,v.jsxs)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>Ne(!0),children:[ke,` low-confidence result`,ke===1?``:`s`,` hidden — show all`]}),g&&!y&&!U&&C&&(0,v.jsx)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>Ne(!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.`}),W&&W.length>0&&(0,v.jsx)(`ul`,{className:`data-results`,children:W.map(e=>(0,v.jsx)(De,{hit:e,mode:me,onDownload:ct,onLocate:ut},e.nodeId))})]}),(0,v.jsxs)(`section`,{className:`data-panel`,children:[k&&(0,v.jsxs)(`div`,{className:`data-upload-progress`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":k.total>0?Math.round(k.loaded/k.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:`${k.total>0?Math.round(k.loaded/k.total*100):0}%`}})}),(0,v.jsxs)(`span`,{className:`data-upload-progress-label`,children:[`Uploading… `,k.total>0?`${Math.round(k.loaded/k.total*100)}%`:``]})]}),Ge&&(0,v.jsxs)(`div`,{className:`data-error`,children:[`Upload failed: `,Ge]}),Ke&&(0,v.jsx)(`div`,{className:`data-status`,children:Ke}),Xe&&(0,v.jsxs)(`div`,{className:`data-error`,children:[`Delete failed: `,Xe]}),Ve&&(0,v.jsx)(`div`,{className:`data-error`,children:Ve}),O&&(0,v.jsxs)(`div`,{className:`data-loading`,children:[(0,v.jsx)(c,{size:14,className:`spin`}),` Loading…`]}),!K&&!O&&T&&T.length>0&&(0,v.jsxs)(`div`,{className:`data-select-hint`,children:[(0,v.jsx)(de,{size:13}),(0,v.jsx)(`span`,{children:`Press and hold a file to select, rename, or delete it.`})]}),!O&&T&&T.length===0&&!Ve&&(0,v.jsx)(`div`,{className:`data-empty-results`,children:`Empty directory.`}),!O&&T&&T.length>0&&E===`grid`&&(0,v.jsx)(`ul`,{className:`data-grid`,children:T.map(e=>{let n=e.displayName??e.name,r=K&&q.has(e.name);if(e.kind===`directory`)return(0,v.jsx)(`li`,{className:`data-grid-cell`,"data-selected":r?`true`:void 0,children:(0,v.jsxs)(`button`,{type:`button`,className:`data-grid-tile`,onPointerDown:()=>_t(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}G(w===`.`?e.name:`${w}/${e.name}`)},children:[K&&(0,v.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,v.jsx)(ce,{size:28,className:`data-grid-glyph`}),(0,v.jsx)(`span`,{className:`data-grid-label`,title:e.name,children:n})]})},e.name);if(e.kind===`file`){let a=he(e.name),o=w===`.`?e.name:`${w}/${e.name}`;return(0,v.jsx)(`li`,{className:`data-grid-cell`,"data-selected":r?`true`:void 0,children:(0,v.jsxs)(`button`,{type:`button`,className:`data-grid-tile${a?` data-grid-tile-image`:``}`,onPointerDown:()=>_t(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>a?bt(e):vt(e),title:K?void 0:a?`Preview ${n}`:`Download ${n}`,children:[K&&(0,v.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),a?(0,v.jsx)(`img`,{className:`data-grid-thumb`,src:m(i,o),alt:n,loading:`lazy`,onError:()=>console.warn(`[data] op=thumb-error path=${o}`)}):(0,v.jsx)(t,{size:28,className:`data-grid-glyph`}),(0,v.jsx)(`span`,{className:`data-grid-label`,title:e.name,children:n}),!a&&(0,v.jsx)(`span`,{className:`data-grid-sub`,children:je(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)(t,{size:28,className:`data-grid-glyph`}),(0,v.jsx)(`span`,{className:`data-grid-label`,children:n}),(0,v.jsx)(`span`,{className:`data-grid-sub`,children:`special`})]})},e.name)})}),!O&&T&&T.length>0&&E===`list`&&(0,v.jsx)(`ul`,{className:`data-entries`,children:T.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:()=>_t(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}G(w===`.`?e.name:`${w}/${e.name}`)},children:[K&&(0,v.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,v.jsx)(ce,{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:()=>_t(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>vt(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 ${Me(e.modifiedAt)}`,children:[je(e.sizeBytes),` · `,Me(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:Tt,disabled:!Y||q.size===0,title:Y?`Share selected files`:`Sharing is not supported on this device`,children:[(0,v.jsx)(re,{size:16}),` Share`]}),(0,v.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:Ct,disabled:q.size===0,children:[(0,v.jsx)(s,{size:16}),` Download`]}),(0,v.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:()=>{let e=[...q][0];e&&(I(e),rt(e))},disabled:q.size!==1,children:[(0,v.jsx)(r,{size:16}),` Rename`]}),(0,v.jsxs)(`button`,{type:`button`,className:`data-select-action data-select-delete`,onClick:wt,disabled:q.size===0,children:[(0,v.jsx)(n,{size:16}),` Delete`]})]})}),Le&&(0,v.jsx)(`div`,{className:`chat-attachment-overlay`,role:`dialog`,"aria-label":Le.alt,onClick:()=>Re(null),children:(0,v.jsx)(`img`,{className:`chat-attachment-overlay-image`,src:Le.src,alt:Le.alt})})]})}function Te({adminFetch:e,cacheKey:t,sessionRefetchNonce:n}){(0,_.useEffect)(()=>{console.info(`[data-ui] op=mount header=operator home=absent`)},[]);let r=(0,_.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]),i=(0,_.useCallback)(e=>{e===`chat`&&(window.location.href=`/`)},[]),[a,o]=(0,_.useState)([]),[s,c]=(0,_.useState)(`files`),{subAccounts:ee,activeAccountId:l,switching:u,switchAccount:d}=ne(t);(0,_.useEffect)(()=>{if(!t)return;let e=!1;return fetch(`/api/whatsapp-reader/conversations?session_key=${encodeURIComponent(t)}&includePersistedOnly=1`).then(e=>e.ok?e.json():{conversations:[]}).then(t=>{e||o(t.conversations??[])}).catch(()=>{}),()=>{e=!0}},[t]);let f=(0,_.useMemo)(()=>[...new Set(a.map(e=>e.channel))],[a]);return(0,v.jsxs)(`main`,{className:`data-main`,children:[(0,v.jsx)(g,{variant:`operator`,onNavigate:i,conversationsCount:a.length,conversationsChannels:f,onOpenConversations:()=>c(`conversations`),onToggleSidebar:()=>{},sidebarOpen:!1,onLogout:r,onDisconnect:async()=>!0,disconnecting:!1,subAccounts:ee,activeAccountId:l,switchingAccount:u,onSwitchAccount:d}),s===`conversations`?(0,v.jsx)(p,{conversations:a,sessionKey:t,onBack:()=>c(`files`)}):(0,v.jsx)(S,{adminFetch:e,cacheKey:t,sessionRefetchNonce:n})]})}function Ee({cacheKey:e}){let{adminFetch:t,cacheKey:n,sessionRefetchNonce:r}=u({initialCacheKey:e,surface:`data`});return(0,v.jsx)(`div`,{className:`data-page`,children:(0,v.jsx)(`main`,{className:`data-main`,children:(0,v.jsx)(S,{adminFetch:t,cacheKey:n,sessionRefetchNonce:r})})})}function De({hit:e,mode:t,onDownload:n,onLocate:r}){let i=ke(e.properties),a=Ae(e.properties),o=Oe(e.labels),s=C(e.properties),[c,ee]=(0,_.useState)(!1),l=a&&a.length>280,u=c||!l?a:a?.slice(0,280)+`…`,d=t===`bm25`?`bm25 ${e.bm25Score.toFixed(2)}`:`vector ${e.vectorScore.toFixed(2)} · bm25 ${e.bm25Score.toFixed(2)} · combined ${e.score.toFixed(2)}`,f=e.properties.relativePath,te=typeof f==`string`&&f.length>0,p=te?f.lastIndexOf(`/`):-1,m=te?p===-1?`data`:f.slice(0,p):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:u}),(0,v.jsxs)(`div`,{className:`data-result-scores`,children:[s&&(0,v.jsxs)(`span`,{className:`data-result-updated`,children:[`Updated `,Me(s),` · `]}),d]})]}),te&&(0,v.jsxs)(`button`,{type:`button`,className:`data-result-locate`,onClick:()=>r(e),title:`Locate in ${m}`,"aria-label":`Locate in ${m}`,children:[(0,v.jsx)(ce,{size:12}),m]}),l&&(0,v.jsx)(`button`,{type:`button`,className:`data-result-toggle`,onClick:()=>ee(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 ke(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 Ae(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 C(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 je(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 Me(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{Ee as n,be as t};