@rubytech/create-maxy 1.0.893 → 1.0.894
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.
package/package.json
CHANGED
|
@@ -349,4 +349,4 @@ ${JSON.stringify(u.input,null,2)}`,f=ae.get(r),p=o?void 0:f??t;return(0,W.jsx)(Z
|
|
|
349
349
|
|
|
350
350
|
---
|
|
351
351
|
|
|
352
|
-
`)}var rD=`Cloudflare setup completed (actionId: `,iD=`{"_componentDone"`,aD=`{"_lifecycle"`;function oD(e){return typeof e!=`string`||e.length===0?!1:e.startsWith(iD)||e.startsWith(aD)||e.startsWith(rD)}function sD(e){let{row:t,surface:n,isStreaming:r,activeCacheKey:a,isLogsOpen:o,onLogsToggle:s,onRequestRename:c,onResume:l,onDelete:u,onSwitchPreFlush:d}=e,f=t.phase===`pre-flush`,p=f&&t.cacheKey!==null&&t.cacheKey!==a;return(0,W.jsxs)(`div`,{className:`conversations-row-actions`,"data-surface":n,children:[(0,W.jsx)(`button`,{type:`button`,className:`conversations-action conversations-logs`,title:f?`View pre-flush logs`:`View logs`,"aria-haspopup":`menu`,"aria-expanded":o,onClick:e=>{e.stopPropagation(),s(e.currentTarget)},children:(0,W.jsx)(g,{size:13})}),p&&d&&(0,W.jsx)(`button`,{type:`button`,className:`conversations-action conversations-play`,title:`Switch into this in-memory session`,disabled:r||!a,onClick:e=>{e.stopPropagation(),!(r||!a)&&d()},children:(0,W.jsx)(_,{size:13})}),!f&&t.conversationId&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`button`,{type:`button`,className:`conversations-action conversations-rename`,title:`Rename conversation`,onClick:e=>{e.stopPropagation(),c()},children:(0,W.jsx)(dt,{size:13})}),(0,W.jsx)(`button`,{type:`button`,className:`conversations-action conversations-play`,title:`Resume conversation`,disabled:r,onClick:e=>{e.stopPropagation(),!(r||!a)&&l()},children:(0,W.jsx)(_,{size:13})}),(0,W.jsx)(`button`,{type:`button`,className:`conversations-action conversations-delete`,title:`Delete conversation`,onClick:e=>{e.stopPropagation(),u()},children:(0,W.jsx)(i,{size:13})})]})]})}var cD=[{type:`stream`,label:`Stream`},{type:`error`,label:`Errors`},{type:`sse`,label:`SSE`}];function lD(e){let{state:t,popoverRef:n,surface:r,buildLogsUrl:i,onClose:a}=e;return t?(0,W.jsx)(`div`,{ref:n,className:`conversations-logs-popover`,role:`menu`,style:{top:t.top,right:t.right},"data-surface":r,children:cD.map(({type:e,label:n})=>(0,W.jsxs)(`a`,{role:`menuitem`,className:`conversations-logs-popover-item`,href:i({conversationId:t.conversationId,cacheKey:t.cacheKey},e),target:`_blank`,rel:`noopener noreferrer`,onClick:()=>{console.debug(`[admin-logs-popover] open-log`,{surface:r,conversationId:t.conversationId,cacheKey:t.cacheKey,type:e}),a()},children:[(0,W.jsx)(g,{size:12}),(0,W.jsx)(`span`,{children:n})]},e))}):null}function uD(e){let[t,n]=(0,U.useState)(null),r=(0,U.useRef)(null),i=(0,U.useCallback)(()=>n(null),[]),a=(0,U.useCallback)((e,t,r)=>{n(n=>{if(n?.rowId===e)return null;let i=r.getBoundingClientRect();return{rowId:e,conversationId:t.conversationId,cacheKey:t.cacheKey,top:i.bottom+4,right:Math.max(8,window.innerWidth-i.right)}})},[]);return(0,U.useEffect)(()=>{if(!t)return;function e(e){let t=e.target;t&&r.current?.contains(t)||t&&t.closest?.(`.conversations-logs`)||n(null)}function i(e){e.key===`Escape`&&n(null)}return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,i)}},[t]),(0,U.useEffect)(()=>{if(!t||!e?.current)return;let r=e.current,i=()=>n(null);return r.addEventListener(`scroll`,i,{passive:!0}),()=>r.removeEventListener(`scroll`,i)},[t,e]),{popover:t,popoverRef:r,toggle:a,close:i}}function dD(e,t){let[n,r]=(0,U.useState)(null),[i,a]=(0,U.useState)(null),[o,s]=(0,U.useState)(``),[c,l]=(0,U.useState)(!1),u=(0,U.useRef)(null);(0,U.useEffect)(()=>{i?.phase===`editing`&&(u.current?.focus(),u.current?.select())},[i]);let d=(0,U.useCallback)(()=>{r(null),a(null),s(``),l(!1)},[]);return{editingId:n,editState:i,editValue:o,setEditValue:s,confirming:c,editInputRef:u,requestSuggestion:(0,U.useCallback)(async t=>{if(e){d(),r(t),a({phase:`loading`});try{let n=await fetch(`/api/admin/sessions/${encodeURIComponent(t)}/label?session_key=${encodeURIComponent(e)}`,{method:`POST`});if(!n.ok){a({phase:`error`,reason:(await n.json().catch(()=>({}))).error||`Request failed`});return}let r=await n.json();r.label?(a({phase:`editing`}),s(r.label)):a({phase:`error`,reason:`Not enough message content to suggest a name`})}catch(e){console.error(`[admin-rename] label suggestion failed:`,e),a({phase:`error`,reason:e instanceof Error?e.message:String(e)})}}},[e,d]),confirmRename:(0,U.useCallback)(async n=>{let r=o.trim();if(!(!e||!r||c)){l(!0);try{let i=await fetch(`/api/admin/sessions/${encodeURIComponent(n)}/label`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({label:r,session_key:e})});if(!i.ok){a({phase:`error`,reason:(await i.json().catch(()=>({}))).error||`Rename failed`}),l(!1);return}t(e=>e.map(e=>e.conversationId===n?{...e,name:r}:e)),d()}catch(e){console.error(`[admin-rename] label rename failed:`,e),a({phase:`error`,reason:e instanceof Error?e.message:String(e)}),l(!1)}}},[e,o,c,t,d]),cancelEdit:d,isEditingRow:(0,U.useCallback)(e=>e!==null&&n===e,[n])}}var fD=`maxy-admin-session-key`;function pD(e,t){return e.conversationId?`/api/admin/logs?type=${t}&conversationId=${encodeURIComponent(e.conversationId)}`:e.cacheKey?`/api/admin/logs?type=${t}&cacheKey=${encodeURIComponent(e.cacheKey)}`:`/api/admin/logs?type=${t}`}function mD(e){let{show:t,onClose:n,conversationsLoading:r,conversationsError:i,conversationsList:a,setConversationsList:o,cacheKey:s,setCacheKey:c,isStreaming:l,resetConversation:u,setMessages:d,setConversationId:f}=e,[p,h]=(0,U.useState)(null),[g,_]=(0,U.useState)(null),v=(0,U.useRef)(null),y=(0,U.useRef)(null),b=(0,U.useRef)(null),{popover:x,popoverRef:S,toggle:C,close:w}=uD(b),T=dD(s,o);(0,U.useEffect)(()=>{t||(T.cancelEdit(),w(),h(null),_(null),v.current&&=(clearTimeout(v.current),null),y.current&&=(clearTimeout(y.current),null))},[t,T,w]);async function E(e){await L(e)?(h(e),_(null),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>h(null),1500)):(_(e),h(null),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>_(null),1500))}return t?(0,W.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,W.jsxs)(`div`,{className:`claude-info-modal conversations-modal`,onClick:e=>e.stopPropagation(),children:[(0,W.jsxs)(`div`,{className:`claude-info-header`,children:[(0,W.jsx)(et,{size:12}),`Conversations`,(0,W.jsx)(`button`,{className:`claude-info-close`,onClick:n,children:`✕`})]}),(0,W.jsxs)(`div`,{className:`conversations-list`,ref:b,children:[r&&(0,W.jsxs)(`div`,{className:`conversations-empty`,children:[(0,W.jsx)(he,{size:14,className:`spin`}),` Loading…`]}),i&&(0,W.jsx)(`div`,{className:`conversations-empty conversations-error`,children:i}),!r&&!i&&a.length===0&&(0,W.jsx)(`div`,{className:`conversations-empty`,children:`No recent conversations`}),!r&&!i&&a.map(e=>{let t=e.conversationId??e.cacheKey??``,r=e.phase===`pre-flush`,i=T.isEditingRow(e.conversationId),a=i&&T.editState?.phase===`loading`,h=i&&T.editState?.phase===`editing`,_=i&&T.editState?.phase===`error`,v=e.conversationId??e.cacheKey??``;return(0,W.jsxs)(`div`,{className:`conversations-row${r?` conversations-row-pre-flush`:``}`,children:[(0,W.jsxs)(`div`,{className:`conversations-row-info`,children:[a&&(0,W.jsxs)(`span`,{className:`conversations-row-name conversations-edit-loading`,children:[(0,W.jsx)(he,{size:12,className:`spin`}),` Generating suggestion…`]}),h&&(0,W.jsxs)(`div`,{className:`conversations-edit-inline`,children:[(0,W.jsx)(`input`,{ref:T.editInputRef,type:`text`,className:`conversations-edit-input`,value:T.editValue,onChange:e=>T.setEditValue(e.target.value),onKeyDown:t=>{t.key===`Enter`&&T.editValue.trim()&&T.confirmRename(e.conversationId),t.key===`Escape`&&T.cancelEdit()},maxLength:200}),(0,W.jsx)(`button`,{type:`button`,className:`conversations-action conversations-confirm`,title:`Confirm rename`,disabled:!T.editValue.trim()||T.confirming,onClick:()=>T.confirmRename(e.conversationId),children:T.confirming?(0,W.jsx)(he,{size:13,className:`spin`}):(0,W.jsx)(m,{size:13})}),(0,W.jsx)(`button`,{type:`button`,className:`conversations-action conversations-cancel`,title:`Cancel`,onClick:T.cancelEdit,children:(0,W.jsx)(oe,{size:13})})]}),_&&(0,W.jsxs)(`div`,{className:`conversations-edit-inline`,children:[(0,W.jsx)(`span`,{className:`conversations-edit-error`,children:T.editState.reason}),(0,W.jsx)(`button`,{type:`button`,className:`conversations-action conversations-retry`,title:`Retry`,onClick:()=>T.requestSuggestion(e.conversationId),children:(0,W.jsx)(ae,{size:13})}),(0,W.jsx)(`button`,{type:`button`,className:`conversations-action conversations-cancel`,title:`Cancel`,onClick:T.cancelEdit,children:(0,W.jsx)(oe,{size:13})})]}),!i&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`span`,{className:`conversations-row-name`,children:[e.name||(r?`session ${v}`:v),r&&(0,W.jsx)(`span`,{className:`conversations-row-phase-badge`,title:`Pre-flush — conversation not yet persisted`,children:`pre-flush`})]}),(0,W.jsxs)(`span`,{className:`conversations-row-meta`,children:[(0,W.jsx)(`button`,{type:`button`,className:`conversations-row-id${p===t?` copied`:``}${g===t?` copy-failed`:``}`,title:v,"aria-label":r?`Copy session key ${v}`:`Copy conversation id ${v}`,onClick:e=>{e.stopPropagation(),E(t)},children:p===t?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(m,{size:10}),` copied`]}):g===t?`copy failed`:v.slice(0,8)}),(0,W.jsxs)(`span`,{className:`conversations-row-time`,children:[(0,W.jsx)(Ne,{size:10}),(()=>{try{let t=new Date(e.updatedAt),n=Date.now()-t.getTime();return n<6e4?`just now`:n<36e5?`${Math.floor(n/6e4)}m ago`:n<864e5?`${Math.floor(n/36e5)}h ago`:`${Math.floor(n/864e5)}d ago`}catch{return``}})()]})]})]})]}),!i&&(0,W.jsx)(sD,{row:e,surface:`conversations-modal`,rowId:t,isStreaming:l,activeCacheKey:s,isLogsOpen:x?.rowId===t,onLogsToggle:n=>{console.info(`[admin-session-identity] cacheKey=${(e.cacheKey??`null`).slice(0,8)} conversationId=${(e.conversationId??`null`).slice(0,8)} phase=${e.phase} surface=conversations-modal action=logs`),C(t,{conversationId:e.conversationId,cacheKey:e.cacheKey},n)},onRequestRename:()=>{e.conversationId&&(console.info(`[admin-session-identity] cacheKey=${(e.cacheKey??`null`).slice(0,8)} conversationId=${e.conversationId.slice(0,8)} phase=${e.phase} surface=conversations-modal action=rename`),T.requestSuggestion(e.conversationId))},onResume:()=>{!e.conversationId||!s||(console.info(`[admin-session-identity] cacheKey=${s.slice(0,8)} conversationId=${e.conversationId.slice(0,8)} phase=${e.phase} surface=conversations-modal action=resume`),n(),u(),fetch(`/api/admin/sessions/${encodeURIComponent(e.conversationId)}/resume?session_key=${encodeURIComponent(s)}`,{method:`POST`}).then(e=>e.ok?e.json():Promise.reject(Error(`Failed to resume conversation`))).then(e=>{e.conversationId&&f(e.conversationId);let t=(e.messages??[]).map(e=>({role:e.role===`user`?`admin`:`maxy`,content:e.role===`user`?e.content:void 0,events:e.role===`assistant`?e.events??(e.content?[{type:`text`,content:e.content}]:[]):void 0,...e.role===`user`&&e.attachments&&e.attachments.length>0?{attachments:e.attachments}:{},...e.role===`user`&&oD(e.content)?{hidden:!0}:{},timestamp:new Date(e.createdAt).getTime()||0,historical:!0,...e.messageId?{messageId:e.messageId}:{}}));t.length>0&&d(t)}).catch(e=>{console.error(`[chat] conversation resume failed:`,e),d([{role:`maxy`,events:[{type:`text`,content:`Could not load conversation history.`}],timestamp:Date.now()-1,historical:!0}])}))},onDelete:()=>{e.conversationId&&(console.info(`[admin-session-identity] cacheKey=${(e.cacheKey??`null`).slice(0,8)} conversationId=${e.conversationId.slice(0,8)} phase=${e.phase} surface=conversations-modal action=delete`),o(t=>t.filter(t=>t.conversationId!==e.conversationId)),s&&fetch(`/api/admin/sessions/${encodeURIComponent(e.conversationId)}?session_key=${encodeURIComponent(s)}`,{method:`DELETE`}).catch(e=>console.error(`[chat] conversation delete failed:`,e)))},onSwitchPreFlush:()=>{if(l||!s||!e.cacheKey)return;let t=e.cacheKey;console.info(`[admin-session-identity] cacheKey=${s.slice(0,8)} conversationId=null phase=${e.phase} surface=conversations-modal action=switch-pre-flush target=${t.slice(0,8)}`),n(),u(),d([]),fetch(`/api/admin/sessions/switch?session_key=${encodeURIComponent(s)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({target_session_key:t})}).then(e=>e.ok?e.json():Promise.reject(Error(`switch returned ${e.status}`))).then(e=>{try{sessionStorage.setItem(fD,e.session_key)}catch{}_e(e.session_key,`chat`),c(e.session_key),f(e.conversationId)}).catch(e=>{console.error(`[chat] pre-flush session switch failed:`,e),d([{role:`maxy`,events:[{type:`text`,content:`Could not switch into that session.`}],timestamp:Date.now()-1,historical:!0}])})}})]},t)})]}),(0,W.jsx)(lD,{state:x,popoverRef:S,surface:`conversations-modal`,buildLogsUrl:pD,onClose:w})]})}):null}function hD({src:e,onClose:t}){return e?(0,W.jsxs)(`div`,{className:`attachment-lightbox`,onClick:t,children:[(0,W.jsx)(`button`,{className:`attachment-lightbox-close`,onClick:t,"aria-label":`Close`,children:`×`}),(0,W.jsx)(`img`,{src:e,alt:`Attachment`,onClick:e=>e.stopPropagation()})]}):null}function gD({show:e,onClose:t,onConfirm:n}){return e?(0,W.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,W.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,W.jsxs)(`div`,{className:`claude-info-header`,children:[(0,W.jsx)(`span`,{children:`Compact conversation?`}),(0,W.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:`✕`})]}),(0,W.jsx)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:`Summarises the conversation history to free up context window space. The session continues with a compressed summary.`}),(0,W.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,W.jsx)(E,{variant:`secondary`,size:`sm`,style:{background:`var(--accent)`,flex:1},onClick:()=>{t(),n()},children:`Yes, compact`}),(0,W.jsx)(E,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:t,children:`No`})]})]})}):null}function _D(e){let{show:t,onClose:n,claudeInfo:r,messages:i,sessionElapsed:a,conversationId:o,cacheKey:s}=e,[c,l]=(0,U.useState)(null);if(!t)return null;let u=i.flatMap(e=>e.events?.filter(e=>e.type===`usage`)??[]),d=u.at(-1),f=d?.peak_request_pct==null?d?.context_window?Math.round((d.input_tokens+d.cache_creation_tokens+d.cache_read_tokens)/d.context_window*100):0:Math.round(d.peak_request_pct*100),p=u.reduce((e,t)=>e+t.input_tokens+t.cache_creation_tokens+t.cache_read_tokens+t.output_tokens,0),m=i.flatMap(e=>e.events?.filter(e=>e.type===`rate_limit`)??[]).at(-1),h=u.reduce((e,t)=>e+(t.total_cost_usd??0),0),g=r?.account?.subscriptionType,_=e=>{let t=e*1e3-Date.now();if(t<=0)return`now`;let n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return n>0?`${n}h ${r}m`:`${r}m`};return(0,W.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,W.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,W.jsxs)(`div`,{className:`claude-info-header`,children:[(0,W.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`claude-info-icon`}),(0,W.jsx)(`span`,{children:`Claude Code`}),(0,W.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,W.jsxs)(`div`,{className:`claude-info-section`,children:[(0,W.jsxs)(`div`,{className:`claude-info-row`,children:[(0,W.jsx)(`span`,{className:`claude-info-label`,children:`Version`}),(0,W.jsx)(`span`,{className:`claude-info-value`,children:r?r.version:`…`})]}),(0,W.jsxs)(`div`,{className:`claude-info-row`,children:[(0,W.jsx)(`span`,{className:`claude-info-label`,children:`Email`}),(0,W.jsx)(`span`,{className:`claude-info-value`,children:r?.account?.email??`…`})]})]}),(g||m||h>0)&&(0,W.jsxs)(`div`,{className:`claude-info-section`,children:[g&&(0,W.jsxs)(`div`,{className:`claude-info-row`,children:[(0,W.jsx)(`span`,{className:`claude-info-label`,children:`Plan`}),(0,W.jsx)(`span`,{className:`claude-info-value`,style:{textTransform:`capitalize`},children:g})]}),m&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`claude-info-row`,children:[(0,W.jsx)(`span`,{className:`claude-info-label`,children:`Usage`}),(0,W.jsxs)(`span`,{className:`claude-info-value`,children:[Math.round(m.utilization*100),`%`]})]}),(0,W.jsxs)(`div`,{className:`claude-info-row`,children:[(0,W.jsx)(`span`,{className:`claude-info-label`,children:`Resets in`}),(0,W.jsx)(`span`,{className:`claude-info-value`,children:_(m.resetsAt)})]}),m.isUsingOverage&&(0,W.jsxs)(`div`,{className:`claude-info-row`,children:[(0,W.jsx)(`span`,{className:`claude-info-label`,children:`Overage`}),(0,W.jsx)(`span`,{className:`claude-info-value`,children:`Active`})]})]}),h>0&&(0,W.jsxs)(`div`,{className:`claude-info-row`,children:[(0,W.jsx)(`span`,{className:`claude-info-label`,children:`Session cost`}),(0,W.jsxs)(`span`,{className:`claude-info-value`,children:[`$`,h<.01?h.toFixed(4):h.toFixed(2)]})]})]}),(0,W.jsxs)(`div`,{className:`claude-info-section`,children:[(0,W.jsxs)(`div`,{className:`claude-info-row`,children:[(0,W.jsx)(`span`,{className:`claude-info-label`,children:`Model`}),(0,W.jsx)(`span`,{className:`claude-info-value`,children:r?.model??`…`})]}),(0,W.jsxs)(`div`,{className:`claude-info-row`,children:[(0,W.jsx)(`span`,{className:`claude-info-label`,children:`Context used`}),(0,W.jsx)(`span`,{className:`claude-info-value`,children:f>0?`${f}%`:`—`})]}),(0,W.jsxs)(`div`,{className:`claude-info-row`,children:[(0,W.jsx)(`span`,{className:`claude-info-label`,children:`Tokens`}),(0,W.jsx)(`span`,{className:`claude-info-value`,children:p>0?wt(p):`—`})]}),(0,W.jsxs)(`div`,{className:`claude-info-row`,children:[(0,W.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,W.jsx)(`span`,{className:`claude-info-value`,children:Ct(a)})]}),(o||s)&&(()=>{let e=o??s??``;return(0,W.jsxs)(`div`,{className:`claude-info-row`,children:[(0,W.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,W.jsx)(`button`,{type:`button`,className:`claude-info-value`,title:`${e} (${o?`flushed`:`pre-flush`}) — click to copy`,onClick:async()=>{l(await L(e)?`copied`:`failed`),setTimeout(()=>l(null),1200)},children:c===`copied`?`copied ✓`:c===`failed`?`copy failed ✕`:`${e.slice(0,8)}…`})]})})()]})]})})}var vD=5e3,yD={atPhase:8};function bD({show:e,onClose:t,versionInfo:n,cacheKey:r,onUpgradeComplete:i}){let[a,o]=(0,U.useState)(`prompt`),[s,c]=(0,U.useState)(``),[l,u]=(0,U.useState)(!1),[d,f]=(0,U.useState)(null),[p,m]=(0,U.useState)(null),[h,g]=(0,U.useState)(null),_=(0,U.useRef)(null),v=n?.latest??null,y=(0,U.useCallback)(()=>{_.current&&=(clearInterval(_.current),null)},[]);(0,U.useEffect)(()=>{e||(y(),o(`prompt`),c(``),u(!1),f(null),m(null),g(null))},[e,y]),(0,U.useEffect)(()=>y,[y]),(0,U.useEffect)(()=>{if(!(!e||a!==`running`||!v))return _.current=setInterval(async()=>{try{let e=await fetch(`/api/admin/version`,{cache:`no-store`});if(!e.ok)return;(await e.json()).installed===v&&(y(),o(`succeeded`),i(),setTimeout(()=>window.location.reload(),2e3))}catch{}},vD),y},[e,a,v,i,y]);let b=(0,U.useCallback)(async()=>{if(!(!v||!r||a!==`prompt`)){if(!s){f(`Enter your device password first.`);return}f(null),m(null),o(`priming`);try{let e=await fetch(`/api/admin/actions/sudo-prime?session_key=${encodeURIComponent(r)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({password:s,session_key:r})});if(e.status!==204){f((await e.json().catch(()=>({}))).error??`Password check failed (status ${e.status})`),o(`prompt`);return}}catch(e){f(e instanceof Error?e.message:`Password check network error`),o(`prompt`);return}try{let e=await fetch(`/api/admin/actions/upgrade?session_key=${encodeURIComponent(r)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sudoPassword:s,session_key:r})}),t=await e.json().catch(()=>({}));if(!e.ok||!t.actionId){m(t.error??`launch failed (status ${e.status})`),o(`launch-failed`);return}g(t.actionId),o(`running`)}catch(e){m(e instanceof Error?e.message:`launch network error`),o(`launch-failed`)}finally{c(``)}}},[s,v,r,a]);return e?(0,W.jsx)(`div`,{className:`claude-info-overlay`,onClick:()=>{(a===`prompt`||a===`succeeded`||a===`launch-failed`)&&t()},children:(0,W.jsxs)(`div`,{className:`claude-info-modal update-modal`,onClick:e=>e.stopPropagation(),children:[(0,W.jsxs)(`div`,{className:`claude-info-header`,children:[(0,W.jsx)(ue,{size:12}),`Software Update`,(0,W.jsx)(`button`,{className:`claude-info-close`,onClick:t,children:`✕`})]}),(0,W.jsxs)(`div`,{className:`update-modal-body`,children:[(0,W.jsxs)(`div`,{className:`update-modal-versions`,children:[(0,W.jsxs)(`div`,{className:`claude-info-row`,children:[(0,W.jsx)(`span`,{className:`claude-info-label`,children:`Installed`}),(0,W.jsxs)(`span`,{className:`claude-info-value`,children:[`v`,n?.installed??`…`]})]}),(0,W.jsxs)(`div`,{className:`claude-info-row`,children:[(0,W.jsx)(`span`,{className:`claude-info-label`,children:`Available`}),(0,W.jsxs)(`span`,{className:`claude-info-value update-version-new`,children:[`v`,v??`…`]})]})]}),(a===`prompt`||a===`priming`||a===`launch-failed`)&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`form-input__field`,style:{marginTop:12},children:[(0,W.jsx)(`label`,{className:`form-input__label`,htmlFor:`upgrade-sudo`,children:`Device password`}),(0,W.jsxs)(`div`,{className:`tunnel-route__row`,children:[(0,W.jsx)(`input`,{id:`upgrade-sudo`,className:`form-input__input tunnel-route__input`,type:l?`text`:`password`,autoComplete:`current-password`,value:s,onChange:e=>{c(e.target.value),f(null)},disabled:a===`priming`,onKeyDown:e=>{e.key===`Enter`&&s&&b()}}),(0,W.jsx)(`button`,{type:`button`,className:`tunnel-route__suffix`,onClick:()=>u(e=>!e),disabled:a===`priming`,style:{cursor:`pointer`,border:`none`,background:`inherit`},"aria-label":l?`Hide password`:`Show password`,children:l?`Hide`:`Show`})]}),(0,W.jsx)(`div`,{className:`form-input__field-desc`,children:`Needed once. The installer uses it to run the privileged steps; it is never saved.`}),d&&(0,W.jsx)(`div`,{className:`tunnel-route__error`,children:d}),p&&(0,W.jsx)(`div`,{className:`tunnel-route__error`,role:`alert`,children:p})]}),(0,W.jsx)(`button`,{type:`button`,className:`update-modal-btn`,onClick:b,disabled:!v||!s||a===`priming`,children:a===`priming`?`Checking password…`:a===`launch-failed`?`Try again`:`Upgrade`})]}),a===`running`&&h&&r&&(0,W.jsx)(`div`,{className:`update-modal-terminal`,style:{height:360,marginTop:10},children:(0,W.jsx)(TE,{actionId:h,cacheKey:r,selfRestart:yD})}),a===`succeeded`&&(0,W.jsxs)(`div`,{className:`update-modal-result`,children:[(0,W.jsx)(ke,{size:14,className:`update-success-icon`}),(0,W.jsxs)(`span`,{children:[`Upgraded to v`,v,` — reloading…`]})]})]})]})}):null}function xD(e){let{conversationId:t,cacheKey:n,disconnecting:r,onOpenConversations:i,handleDisconnect:a,onAfterAction:o}=e,s=!t&&!n;return(0,W.jsxs)(`div`,{className:`chat-actions-menu`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`chat-action`,onClick:()=>{o(),i()},children:[(0,W.jsx)(et,{size:14}),(0,W.jsx)(`span`,{className:`action-label`,children:`Conversations`})]}),(0,W.jsxs)(`button`,{type:`button`,className:`chat-action`,disabled:r,onClick:async()=>{o(),await a()},children:[r?(0,W.jsx)(he,{size:14,className:`animate-spin`}):(0,W.jsx)(V,{size:14}),(0,W.jsx)(`span`,{className:`action-label`,children:r?`Disconnecting...`:`Disconnect Claude`})]}),(0,W.jsxs)(`button`,{type:`button`,className:`chat-action`,disabled:s,title:t?`Download stream log`:n?`Download stream log (pre-flush)`:`No session active — reload the page to start one`,onClick:async()=>{o();let e=(t??``).slice(-8),r=(n??``).slice(-8);if(console.debug(`[stream-log-button] click conversationId=${e||`null`} cacheKey=${r||`null`} disabled=${s}`),s)return;let i=`${pD({conversationId:t,cacheKey:n},`stream`)}&download=1`,a=0,c=0,l;try{let e=await fetch(i);a=e.status;let t=e.headers.get(`content-length`);l=await e.blob(),c=t?Number(t):l.size}catch(e){a=0,console.debug(`[stream-log-button] fetch-failed reason=${e instanceof Error?e.message:String(e)}`)}try{let t=JSON.stringify({kind:`event`,source:`stream-log-click`,url:i,status:a,bytes:c,conversationId:e});navigator.sendBeacon(`/api/_client-error`,new Blob([t],{type:`application/json`}))||console.debug(`[stream-log-button] sendBeacon returned false`)}catch(e){console.debug(`[stream-log-button] beacon-failed reason=${e instanceof Error?e.message:String(e)}`)}if(l&&a>=200&&a<300){let t=URL.createObjectURL(l),n=document.createElement(`a`);n.href=t,n.download=`stream-${e||`session`}.log`,n.click(),setTimeout(()=>URL.revokeObjectURL(t),5e3)}},children:[(0,W.jsx)(ft,{size:14}),(0,W.jsx)(`span`,{className:`action-label`,children:`Stream log`})]})]})}function SD(e){let{selectionMode:t,selectedItems:n,copyToast:r,exitSelection:i,enterSelection:a,copySelected:o,showCopyToast:s,input:l,setInput:d,inputRef:p,pendingFiles:m,setPendingFiles:h,isDragOver:y,attachError:b,fileInputRef:x,addFiles:S,removeFile:C,onDragOver:w,onDragLeave:T,onDrop:D,isStreaming:j,wasPaused:M,messages:P,messageQueueRef:ee,setQueue:F,sendMessage:ne,stopStreaming:re,disconnecting:ie,handleDisconnect:R,claudeInfo:ae,setClaudeInfo:z,setShowClaudeInfo:oe,conversationId:se,cacheKey:ce,onNewConversation:B,newConversationDisabled:le,onOpenConversations:ue,sidebarVisible:de}=e,[fe,pe]=(0,U.useState)(!1),me=(0,U.useRef)(null),[he,ge]=(0,U.useState)(!1),_e=(0,U.useRef)(null),ve=(0,U.useRef)(!1),ye=I(),be=ye.state===`recording`||ye.state===`paused`||ye.state===`sending`,xe=!be&&!M&&!l.trim()&&m.length===0;async function Se(){let e=await ye.send();if(!e)return;let t=e.type===`audio/ogg`?`.ogg`:e.type===`audio/mp4`?`.m4a`:`.webm`,n=new File([e],`voice-note${t}`,{type:e.type});if(j){F([...ee.current,{text:`[Voice note]`,files:[n],timestamp:Date.now()}]);return}ne(`[Voice note]`,[n])}return(0,U.useEffect)(()=>{t||ge(!1)},[t]),(0,U.useEffect)(()=>{if(!he)return;let e=e=>{e.target.closest(`.selection-copy-wrap`)||ge(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[he]),(0,U.useEffect)(()=>{if(!fe)return;let e=e=>{if(e.key===`Escape`){pe(!1);return}if(e.key===`Tab`&&me.current){let t=me.current.querySelectorAll(`.actions-menu-items button:not([disabled])`);if(t.length===0)return;let n=t[0],r=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())}},t=e=>{me.current&&!me.current.contains(e.target)&&pe(!1)};return document.addEventListener(`keydown`,e),document.addEventListener(`mousedown`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`mousedown`,t)}},[fe]),t?(0,W.jsx)(`div`,{className:`chat-input-area`,children:(0,W.jsxs)(`div`,{className:`selection-bar`,children:[(0,W.jsxs)(`span`,{className:`selection-count`,children:[n.size,` Selected`]}),(0,W.jsxs)(`div`,{className:`selection-copy-wrap`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`selection-copy`,onPointerDown:()=>{if(he){ge(!1);return}ve.current=!1,_e.current=setTimeout(()=>{ve.current=!0,ge(!0),_e.current=null},500)},onPointerUp:()=>{_e.current!==null&&(clearTimeout(_e.current),_e.current=null)},onPointerLeave:()=>{_e.current!==null&&(clearTimeout(_e.current),_e.current=null)},onPointerCancel:()=>{_e.current!==null&&(clearTimeout(_e.current),_e.current=null)},onClick:async()=>{ve.current||await o(e=>tD(P,e),(e,t)=>{let[n,r]=[e.slice(0,e.lastIndexOf(`_`)),e.slice(e.lastIndexOf(`_`)+1)],[i,a]=[t.slice(0,t.lastIndexOf(`_`)),t.slice(t.lastIndexOf(`_`)+1)],o=parseInt(n,10)-parseInt(i,10);return o===0?r===`admin`?-1:a===`admin`?1:parseInt(r,10)-parseInt(a,10):o})},children:[(0,W.jsx)(f,{size:18}),(0,W.jsx)(`span`,{children:`Copy`})]}),he&&(0,W.jsx)(`div`,{className:`copy-menu`,children:[[`all`,`All events`],[`text`,`Text messages only`],[`non-text`,`Non-text only`]].map(([e,t])=>(0,W.jsx)(`button`,{type:`button`,className:`copy-menu-item`,onClick:async()=>{let t=nD(P,e);t&&s(await L(t)),i()},children:t},e))})]}),(0,W.jsx)(`button`,{type:`button`,className:`selection-cancel`,onClick:i,children:`Cancel`})]})}):(0,W.jsxs)(`div`,{className:`chat-input-area`,children:[(0,W.jsx)(`input`,{ref:x,type:`file`,multiple:!0,accept:Dt,style:{display:`none`},onChange:e=>{e.target.files&&S([...e.target.files]),e.target.value=``}}),m.length>0&&(0,W.jsx)(`div`,{className:`attachment-strip`,children:m.map((e,t)=>(0,W.jsxs)(`div`,{className:`attachment-chip`,children:[e.type.startsWith(`image/`)?(0,W.jsx)(`img`,{src:URL.createObjectURL(e),alt:e.name,className:`attachment-chip-thumb`}):e.type.startsWith(`audio/`)?(0,W.jsx)(k,{size:14}):e.type===`application/pdf`?(0,W.jsx)(g,{size:14}):(0,W.jsx)(v,{size:14}),(0,W.jsx)(`span`,{className:`attachment-chip-name`,children:e.name}),(0,W.jsx)(`button`,{type:`button`,className:`attachment-chip-remove`,onClick:()=>C(t),"aria-label":`Remove ${e.name}`,children:`×`})]},t))}),b&&(0,W.jsx)(`p`,{className:`attach-error`,children:b}),ye.state===`error`&&ye.errorMessage&&(0,W.jsxs)(`p`,{className:`voice-error`,role:`alert`,children:[(0,W.jsx)(k,{size:14}),ye.errorMessage]}),(0,W.jsx)(O,{inputRef:p}),be?(0,W.jsx)(`div`,{className:`chat-form voice-active`,children:(0,W.jsx)(N,{state:ye.state,elapsedSeconds:ye.elapsedSeconds,waveform:ye.waveform,onTogglePause:ye.togglePause,onDiscard:ye.discard,onSend:Se})}):(0,W.jsxs)(`form`,{className:`chat-form${y?` drag-over`:``}`,onSubmit:e=>{e.preventDefault();let t=l.trim()||(M?`continue`:``);if(!(!t&&m.length===0)){if(j){F([...ee.current,{text:t,files:[...m],timestamp:Date.now()}]),d(``),h([]),p.current?.resetHeight();return}ne(t),p.current?.resetHeight()}},onDragOver:w,onDragLeave:T,onDrop:D,onPaste:e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e of t){if(e.kind!==`file`)continue;let t=e.getAsFile();if(!t)continue;let r=t.type.split(`/`)[1]?.replace(`jpeg`,`jpg`)||`png`;n.push(new File([t],`pasted-image-${Date.now()}.${r}`,{type:t.type}))}n.length>0&&S(n)},children:[(0,W.jsx)(E,{variant:`icon`,type:`button`,onClick:()=>x.current?.click(),"aria-label":`Attach file`,children:(0,W.jsx)(c,{size:14})}),(0,W.jsx)(te,{ref:p,value:l,onChange:d}),j?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(E,{variant:`send`,type:`button`,onClick:()=>re(!0),"aria-label":`Pause`,style:{background:`var(--text-secondary)`},children:(0,W.jsx)(A,{size:14})}),(0,W.jsx)(E,{variant:`send`,type:`button`,onClick:()=>re(!1),"aria-label":`Stop`,style:{background:`var(--danger)`},children:(0,W.jsx)(ht,{size:14})})]}):xe?(0,W.jsx)(E,{variant:`send`,type:`button`,onClick:ye.start,"aria-label":`Record voice note`,children:(0,W.jsx)(k,{size:14})}):(0,W.jsx)(E,{variant:`send`,type:`submit`,disabled:!l.trim()&&m.length===0&&!M,"aria-label":`Send message`,children:M?(0,W.jsx)(_,{size:14}):(0,W.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,W.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,W.jsxs)(`div`,{className:`chat-actions`,ref:me,children:[!de&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`button`,{className:`burger-trigger`,onClick:()=>pe(e=>!e),"aria-expanded":fe,"aria-haspopup":`true`,"aria-label":`Conversation actions`,children:(0,W.jsx)(Re,{size:16})}),(0,W.jsx)(`div`,{className:`actions-menu-items${fe?` actions-menu-open`:``}`,children:(0,W.jsx)(xD,{conversationId:se,cacheKey:ce,disconnecting:ie,onOpenConversations:ue,handleDisconnect:R,onAfterAction:()=>pe(!1)})})]}),(0,W.jsx)(`button`,{type:`button`,className:`chat-action-icon`,title:`New conversation`,"aria-label":`New conversation`,disabled:le,onClick:B,children:(0,W.jsx)(Ge,{size:16})}),(0,W.jsx)(`button`,{type:`button`,className:`chat-action-icon`,title:`Select messages`,"aria-label":`Select messages`,onClick:a,children:(0,W.jsx)(u,{size:16})}),(0,W.jsxs)(`div`,{className:`powered-by`,onClick:async()=>{if(oe(!0),!ae){let e=await fetch(`/api/admin/claude-info`);e.ok&&z(await e.json())}},children:[(0,W.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`powered-by-icon`}),(0,W.jsx)(`span`,{children:`Powered by Claude Code`})]})]})]})}var CD=`maxy-vnc-overlay-popout`;function wD(e){let[t,n]=(0,U.useState)(!1),r=(0,U.useRef)(null),i=(0,U.useRef)(null),a=(0,U.useCallback)(()=>{i.current&&=(clearInterval(i.current),null),r.current&&!r.current.closed&&r.current.close(),r.current=null,n(!1)},[]),o=(0,U.useCallback)(()=>{let t=`/vnc-popout.html?title=${encodeURIComponent(R.productName)}`,o=window.open(t,CD,`width=1024,height=768`);o&&(r.current=o,n(!0),i.current=setInterval(()=>{r.current?.closed&&(a(),e?.())},500))},[a,e]);return(0,U.useEffect)(()=>()=>a(),[a]),{poppedOut:t,popout:o,cleanupPopout:a}}var TD=(0,U.forwardRef)(function({onClose:e},t){St(),un(`overlay`);let{poppedOut:n,popout:r,cleanupPopout:i}=wD(e);return(0,U.useImperativeHandle)(t,()=>({popout:r}),[r]),n?(0,W.jsxs)(`div`,{className:`browser-overlay-popout`,children:[(0,W.jsx)(h,{className:`browser-viewer__icon`}),(0,W.jsx)(`span`,{className:`browser-viewer__title`,children:R.productName}),(0,W.jsx)(`span`,{className:`browser-viewer__popout-label`,children:`Popped out`}),(0,W.jsx)(E,{variant:`ghost`,size:`sm`,icon:st,onClick:()=>i(),"aria-label":`Pop back in`}),e&&(0,W.jsx)(E,{variant:`ghost`,size:`sm`,icon:oe,onClick:()=>{i(),e()},"aria-label":`Close`})]}):(0,W.jsx)(`iframe`,{src:`/vnc-viewer.html`,className:`browser-surface__iframe`,title:R.productName})});function ED({onClose:e}){St(),un(`overlay`);let{poppedOut:t,popout:n,cleanupPopout:r}=wD(e),i=(0,U.useCallback)(()=>{r(),e()},[r,e]);(0,U.useEffect)(()=>{if(t)return;let e=e=>{e.key===`Escape`&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,i]);let a=ln({handlePopout:n,disabled:t});return t?(0,W.jsxs)(`div`,{className:`browser-overlay-popout`,children:[(0,W.jsx)(h,{className:`browser-viewer__icon`}),(0,W.jsx)(`span`,{className:`browser-viewer__title`,children:R.productName}),(0,W.jsx)(`span`,{className:`browser-viewer__popout-label`,children:`Popped out`}),(0,W.jsx)(E,{variant:`ghost`,size:`sm`,icon:st,onClick:()=>{r()},"aria-label":`Pop back in`}),(0,W.jsx)(E,{variant:`ghost`,size:`sm`,icon:oe,onClick:i,"aria-label":`Close`})]}):(0,W.jsxs)(`div`,{className:`browser-viewer-fullscreen`,children:[(0,W.jsxs)(`div`,{className:`browser-viewer-fullscreen__bar`,...a,children:[(0,W.jsx)(h,{className:`browser-viewer__icon`}),(0,W.jsx)(`span`,{className:`browser-viewer-fullscreen__title`,children:R.productName}),(0,W.jsxs)(`div`,{className:`browser-viewer-fullscreen__actions`,children:[(0,W.jsx)(E,{variant:`ghost`,size:`sm`,icon:ze,onClick:n,"aria-label":`Pop out`}),(0,W.jsx)(E,{variant:`ghost`,size:`sm`,icon:oe,onClick:i,"aria-label":`Close`})]})]}),(0,W.jsx)(`iframe`,{src:`/vnc-viewer.html`,className:`browser-viewer-fullscreen__iframe`,title:R.productName})]})}var DD=`maxy-admin-session-key`,OD=(0,U.forwardRef)(function(e,t){let{businessName:n,cacheKey:r,conversationId:i,role:a,userName:o,userAvatar:s,sessions:c,sessionsLoading:l,sessionsError:u,ensureSessionsLoaded:d,refetchSessions:f,onSelectSession:p,onSelectArtefact:h,onSelectProjects:_,onSelectPeople:v,onSelectTasks:y,onSelectAgents:b,onCloseMobileDrawer:x,collapsed:S,onToggleCollapsed:C,mobileDrawerOpen:w,actions:T,recentsActions:E}=e;(0,U.useEffect)(()=>{d()},[d]);let D=(0,U.useRef)(null),{popover:O,popoverRef:k,toggle:A,close:j}=uD(D),M=dD(r,E.setSessions),N=R.productName,P=typeof o==`string`?o:o===null?`name unavailable`:n||N,ee=(P.trim().charAt(0)||`?`).toUpperCase(),[te,F]=(0,U.useState)(`all`),I=(0,U.useMemo)(()=>c.filter(e=>e.name).filter(e=>te===`all`?!0:(e.channel??`webchat`)===te),[c,te]),ne=I.length,re=i??r,[L,ie]=(0,U.useState)(`chat`),[z,ce]=(0,U.useState)([]),[B,le]=(0,U.useState)(!1),[ue,de]=(0,U.useState)(null),[fe,pe]=(0,U.useState)(!1);(0,U.useImperativeHandle)(t,()=>({patchArtefact(e,t){ce(n=>n.map(n=>n.id===e?{...n,...t}:n))}}),[]);let[me,ge]=(0,U.useState)(!1),ve=(0,U.useRef)(null);(0,U.useEffect)(()=>{if(!me)return;function e(e){ve.current&&!ve.current.contains(e.target)&&ge(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[me]);let ye=(0,U.useCallback)(async()=>{if(r){pe(!0),de(null);try{let e=await fetch(`/api/admin/sidebar-artefacts?session_key=${encodeURIComponent(r)}`);if(!e.ok)throw Error(`status ${e.status}`);ce((await e.json()).artefacts??[]),le(!0)}catch(e){let t=e instanceof Error?e.message:String(e);de(`Failed to load artefacts: ${t}`),console.error(`[admin-ui] sidebar-artefacts fetch failed: ${t}`)}finally{pe(!1)}}},[r]),be=()=>{ie(`chat`),console.info(`[admin-ui] sidebar-nav surface=chat count=${ne}`)},xe=()=>{ie(`artefacts`),console.info(`[admin-ui] sidebar-nav surface=artefacts count=${B?z.length:0} collapsed=${S}`),S&&C(),B||ye()},Se=S?24:16,Ce=L===`chat`?`Recents`:`Artefacts`,we=L===`chat`?l?`…`:String(ne):fe?`…`:String(z.length),Te=L===`chat`?l:fe,V=()=>{L===`chat`?f():ye(),console.info(`[admin-ui] sidebar-refresh surface=${L}`)};return(0,W.jsxs)(`aside`,{className:`side`,children:[(0,W.jsx)(`div`,{className:`side-head`,children:(0,W.jsx)(`button`,{className:`icon-btn side-head-toggle`,title:w?`Close sidebar`:S?`Expand sidebar`:`Collapse sidebar`,type:`button`,"aria-label":w?`Close sidebar`:S?`Expand sidebar`:`Collapse sidebar`,onClick:()=>{w?(console.info(`[admin-ui] sidebar-head-toggle action=close-drawer state=closed`),x()):(console.info(`[admin-ui] sidebar-head-toggle action=toggle-collapsed state=${S?`expanded`:`collapsed`}`),C())},children:S?(0,W.jsx)(ut,{size:28}):(0,W.jsx)(lt,{size:28})})}),(0,W.jsxs)(`nav`,{className:`side-nav`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`nav-row${L===`chat`?` active`:``}`,onClick:be,children:[(0,W.jsx)(ot,{size:Se}),(0,W.jsx)(`span`,{className:`label`,children:`Chat`}),(0,W.jsx)(`span`,{className:`kbd`})]}),(0,W.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=people`),v(),x()},children:[(0,W.jsx)(yt,{size:Se}),(0,W.jsx)(`span`,{className:`label`,children:`People`}),(0,W.jsx)(`span`,{className:`kbd`})]}),(0,W.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=agents`),b(),x()},children:[(0,W.jsx)(Ee,{size:Se}),(0,W.jsx)(`span`,{className:`label`,children:`Agents`}),(0,W.jsx)(`span`,{className:`kbd`})]}),(0,W.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=projects`),_(),x()},children:[(0,W.jsx)(De,{size:Se}),(0,W.jsx)(`span`,{className:`label`,children:`Projects`}),(0,W.jsx)(`span`,{className:`kbd`})]}),(0,W.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=tasks`),y(),x()},children:[(0,W.jsx)($e,{size:Se}),(0,W.jsx)(`span`,{className:`label`,children:`Tasks`}),(0,W.jsx)(`span`,{className:`kbd`})]}),(0,W.jsxs)(`button`,{type:`button`,className:`nav-row${L===`artefacts`?` active`:``}`,onClick:xe,children:[(0,W.jsx)(g,{size:Se}),(0,W.jsx)(`span`,{className:`label`,children:`Artefacts`}),(0,W.jsx)(`span`,{className:`kbd`})]})]}),(0,W.jsxs)(`div`,{className:`side-list`,ref:D,children:[(0,W.jsxs)(`div`,{className:`group-head`,children:[(0,W.jsx)(`span`,{children:Ce}),(0,W.jsxs)(`span`,{className:`group-head-meta`,children:[(0,W.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh ${Ce.toLowerCase()}`,"aria-label":`Refresh ${Ce.toLowerCase()}`,onClick:V,disabled:Te,children:(0,W.jsx)(se,{size:12,className:Te?`spinning`:void 0})}),(0,W.jsx)(`span`,{children:we})]})]}),L===`chat`&&(0,W.jsxs)(W.Fragment,{children:[u&&(0,W.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:u}),(0,W.jsxs)(an,{className:`conv-channel-filter`,value:te,onChange:e=>{let t=e.target.value;F(t),console.info(`[admin-ui] sidebar-channel-filter set value=${t}`)},"aria-label":`Filter conversations by channel`,children:[(0,W.jsx)(`option`,{value:`all`,children:`All channels`}),(0,W.jsx)(`option`,{value:`webchat`,children:`Web`})]}),I.map(e=>{let t=e.conversationId??e.cacheKey??``,n=t!==``&&t===re,i=e.channel??`webchat`,a=e.phase===`pre-flush`,o=M.isEditingRow(e.conversationId),s=o&&M.editState?.phase===`loading`,c=o&&M.editState?.phase===`editing`,l=o&&M.editState?.phase===`error`,u=t=>{let n=e.cacheKey?e.cacheKey.slice(0,8):`null`,r=e.conversationId?e.conversationId.slice(0,8):`null`;console.info(`[admin-session-identity] cacheKey=${n} conversationId=${r} phase=${e.phase} surface=sidebar-recents action=${t}`)};return(0,W.jsxs)(`div`,{className:`conv${n?` active`:``}${a?` conv-pre-flush`:``}${o?` conv-editing`:``}`,children:[!o&&(0,W.jsxs)(`button`,{type:`button`,className:`conv-name-button`,onClick:()=>{u(`select`),p(e),x()},children:[i===`whatsapp`&&(0,W.jsx)(rt,{size:12,className:`conv-channel-icon`,"aria-label":`WhatsApp`}),(0,W.jsx)(`span`,{className:`conv-name`,children:e.name??`(untitled)`})]}),s&&(0,W.jsxs)(`span`,{className:`conversations-row-name conversations-edit-loading conv-edit-loading`,children:[(0,W.jsx)(he,{size:12,className:`spin`}),` Generating suggestion…`]}),c&&(0,W.jsxs)(`div`,{className:`conversations-edit-inline conv-edit-inline`,children:[(0,W.jsx)(`input`,{ref:M.editInputRef,type:`text`,className:`conversations-edit-input`,value:M.editValue,onChange:e=>M.setEditValue(e.target.value),onKeyDown:t=>{t.key===`Enter`&&M.editValue.trim()&&e.conversationId&&M.confirmRename(e.conversationId),t.key===`Escape`&&M.cancelEdit()},maxLength:200}),(0,W.jsx)(`button`,{type:`button`,className:`conversations-action conversations-confirm`,title:`Confirm rename`,disabled:!M.editValue.trim()||M.confirming,onClick:()=>e.conversationId&&M.confirmRename(e.conversationId),children:M.confirming?(0,W.jsx)(he,{size:13,className:`spin`}):(0,W.jsx)(m,{size:13})}),(0,W.jsx)(`button`,{type:`button`,className:`conversations-action conversations-cancel`,title:`Cancel`,onClick:M.cancelEdit,children:(0,W.jsx)(oe,{size:13})})]}),l&&(0,W.jsxs)(`div`,{className:`conversations-edit-inline conv-edit-inline`,children:[(0,W.jsx)(`span`,{className:`conversations-edit-error`,children:M.editState.reason}),(0,W.jsx)(`button`,{type:`button`,className:`conversations-action conversations-retry`,title:`Retry`,onClick:()=>e.conversationId&&M.requestSuggestion(e.conversationId),children:(0,W.jsx)(ae,{size:13})}),(0,W.jsx)(`button`,{type:`button`,className:`conversations-action conversations-cancel`,title:`Cancel`,onClick:M.cancelEdit,children:(0,W.jsx)(oe,{size:13})})]}),!o&&(0,W.jsx)(sD,{row:e,surface:`sidebar-recents`,rowId:t,isStreaming:E.isStreaming,activeCacheKey:r,isLogsOpen:O?.rowId===t,onLogsToggle:n=>{u(`logs`),A(t,{conversationId:e.conversationId,cacheKey:e.cacheKey},n)},onRequestRename:()=>{e.conversationId&&(u(`rename`),M.requestSuggestion(e.conversationId))},onResume:()=>{!e.conversationId||E.isStreaming||(u(`resume`),p(e),x())},onDelete:()=>{if(!e.conversationId)return;u(`delete`);let t=e.conversationId;E.setSessions(e=>e.filter(e=>e.conversationId!==t)),r&&fetch(`/api/admin/sessions/${encodeURIComponent(t)}?session_key=${encodeURIComponent(r)}`,{method:`DELETE`}).catch(e=>console.error(`[chat] conversation delete failed:`,e))},onSwitchPreFlush:()=>{if(E.isStreaming||!r||!e.cacheKey)return;let t=e.cacheKey;u(`switch-pre-flush target=${t.slice(0,8)}`),E.resetConversation(),E.setMessages([]),fetch(`/api/admin/sessions/switch?session_key=${encodeURIComponent(r)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({target_session_key:t})}).then(e=>e.ok?e.json():Promise.reject(Error(`switch returned ${e.status}`))).then(e=>{try{sessionStorage.setItem(DD,e.session_key)}catch{}_e(e.session_key,`chat`),E.setCacheKey(e.session_key),E.setConversationId(e.conversationId)}).catch(e=>{console.error(`[chat] pre-flush session switch failed:`,e),E.setMessages([{role:`maxy`,events:[{type:`text`,content:`Could not switch into that session.`}],timestamp:Date.now()-1,historical:!0}])})}})]},t===``?e.updatedAt:t)})]}),L===`artefacts`&&(0,W.jsxs)(W.Fragment,{children:[ue&&(0,W.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:ue}),B&&!ue&&z.length===0&&(0,W.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No artefacts yet`}),z.map(e=>(0,W.jsxs)(`button`,{type:`button`,className:`conv`,onClick:()=>{h({docId:e.id,name:e.name,content:e.content,editable:e.editable,mimeType:e.mimeType,skipReason:e.skipReason},`sidebar-artefacts`),x()},children:[(0,W.jsx)(`span`,{className:`conv-name`,children:e.name}),(0,W.jsx)(`span`,{className:`conv-kind`,"data-kind":e.kind===`agent-template`?`agent`:`doc`,children:e.kind===`agent-template`?`agent`:`doc`})]},e.id))]}),(0,W.jsx)(lD,{state:O,popoverRef:k,surface:`sidebar-recents`,buildLogsUrl:pD,onClose:j})]}),(0,W.jsxs)(`div`,{className:`side-foot`,ref:ve,children:[(0,W.jsx)(`div`,{className:`avatar`,children:s?(0,W.jsx)(`img`,{src:s,alt:P}):ee}),(0,W.jsxs)(`div`,{className:`who`,children:[(0,W.jsx)(`span`,{className:`name`,children:P}),(0,W.jsx)(`span`,{className:`role`,children:a??`operator`})]}),(0,W.jsx)(`button`,{className:`icon-btn side-foot-actions-trigger`,title:`Conversation actions`,type:`button`,"aria-label":`Conversation actions`,"aria-haspopup":`true`,"aria-expanded":me,onClick:()=>ge(e=>!e),children:(0,W.jsx)(Re,{size:Se})}),me&&(0,W.jsx)(`div`,{className:`side-foot-actions-popover`,children:(0,W.jsx)(xD,{...T,onAfterAction:()=>ge(!1)})})]})]})}),kD=()=>{},AD=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function jD(e){return AD.test(e)?`uuid`:e.startsWith(`agent-template:`)?`agent-template`:`other`}var MD={"null-attachmentId":`No file backing this artefact.`,"non-text-mime":`Content type cannot be displayed inline.`,"containment-rejected":`File path failed containment check; cannot display.`,"missing-on-disk":`File is missing on disk.`};function ND({reason:e}){return(0,W.jsxs)(`div`,{className:`art-skip-banner`,role:`status`,children:[(0,W.jsx)(He,{size:14}),(0,W.jsx)(`span`,{children:MD[e]})]})}function PD({src:e,name:t,docId:n}){let[r,i]=(0,U.useState)(!1),a=(0,U.useRef)(null),o=(0,U.useRef)(!1),s=(0,U.useRef)(!1),c=(0,U.useCallback)(e=>{s.current||(s.current=!0,console.info(`[admin-ui] artefact-pdf-fallback id=${n.slice(0,8)} reason=${e}`),i(!0))},[n]);(0,U.useEffect)(()=>{let e=setTimeout(()=>{o.current||c(`onload-timeout`)},3e3);return()=>clearTimeout(e)},[c]);let l=()=>{o.current=!0;try{let e=a.current?.contentDocument?.body;e&&e.children.length===0&&!e.textContent?.trim()&&c(`empty-body`)}catch{}};return r?(0,W.jsxs)(`a`,{className:`art-pdf-fallback`,href:e,download:t,children:[(0,W.jsx)(g,{size:20}),(0,W.jsxs)(`div`,{className:`art-pdf-fallback-text`,children:[(0,W.jsx)(`div`,{className:`art-pdf-fallback-name`,children:t}),(0,W.jsx)(`div`,{className:`art-pdf-fallback-hint`,children:`Your browser can't display this PDF inline. Click to download.`})]}),(0,W.jsx)(ue,{size:16})]}):(0,W.jsx)(`iframe`,{ref:a,className:`art-pdf`,src:e,title:t,"aria-label":`PDF preview of ${t}`,onLoad:l,onError:()=>c(`onerror`)})}var FD={browser:`Browser`,data:`Data`,graph:`Graph`};function ID({selection:e,trigger:t,cacheKey:n,onClose:r,onArtefactSaved:i,onSwapToGraph:a}){let o=e!==null,s=e?.surface??null,c=(0,U.useRef)(null),l=(0,U.useRef)(null),[u,d]=(0,U.useState)(null),p=e?.surface===`doc`?e.docId:null,m=[250,500,1e3,2e3],g=(0,U.useCallback)(e=>{if(!n||!p)return;let t={};try{t=JSON.parse(e)}catch{return}if(t.action!==`save`||typeof t.content!=`string`)return;d(null);let r=t.content,a=e=>{fetch(`/api/admin/sidebar-artefact-save?session_key=${encodeURIComponent(n)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({id:p,content:r})}).then(async t=>{if(t.status===503&&e<m.length){let t=m[e];console.info(`[admin-ui] artefact-save-retry docId=${p} attempt=${e+1} delayMs=${t} status=503`),setTimeout(()=>a(e+1),t);return}if(!t.ok){let n=(await t.json().catch(()=>({}))).error??`status ${t.status}`,r=t.status===503?`retries-exhausted`:`status-${t.status}`;d(`Save failed: ${n}`),console.error(`[admin-ui] artefact-save-failed docId=${p} status=${t.status} attempts=${e+1} source=${r} error="${n}"`);return}let n=await t.json();i?.(p,n.updatedAt,r)}).catch(t=>{let n=t instanceof Error?t.message:String(t);d(`Save failed: ${n}`),console.error(`[admin-ui] artefact-save-failed docId=${p} attempts=${e+1} error="${n}"`)})};a(0)},[n,p,i]);(0,U.useEffect)(()=>{d(null)},[p]),(0,U.useEffect)(()=>{let n=e?.surface===`doc`?e.docId:null,r=e?.surface===`graph`?e.focusNodeId??null:null,i=e?.surface??null,a=i===null?`closed`:`${i}:${n??`none`}:${r??`none`}`;if(a===c.current)return;let s=o?`open`:`closed`,l=o?t??`chat-link`:`toolbar-close`,u=i??c.current?.split(`:`)[0]??`doc`,d=n?` docIdShape=${jD(n)} docIdSample=${n.slice(0,8)}`:``;console.info(`[admin-ui] artefact-pane state=${s} docId=${n??`none`} trigger=${l} surface=${u}${d}`),c.current=a},[e,t,o]);let _=e?.surface===`doc`,v=_?(e.tag||e.name.split(`.`).pop()||`doc`).toUpperCase().slice(0,6):``,y=_?e.revision||`rev 1`:`live`,b=e&&e.surface!==`doc`?FD[e.surface]:``,x=_?e.name:b;return(0,W.jsxs)(`aside`,{className:`artefact`,"data-open":o,"data-surface":s??`none`,children:[(0,W.jsxs)(`div`,{className:`art-head`,children:[(0,W.jsxs)(`div`,{className:`left`,children:[!_&&s===`browser`&&(0,W.jsx)(h,{size:14,className:`art-head-surface-icon`}),!_&&s===`data`&&(0,W.jsx)(ve,{size:14,className:`art-head-surface-icon`}),!_&&s===`graph`&&(0,W.jsx)(ye,{size:14,className:`art-head-surface-icon`}),(0,W.jsx)(`span`,{className:`file-name`,children:x}),_&&(0,W.jsx)(`span`,{className:`file-tag`,children:v})]}),(0,W.jsxs)(`div`,{className:`right`,children:[_&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`button`,{className:`icon-btn`,title:`Copy`,type:`button`,"aria-label":`Copy`,onClick:()=>{L(e.content)},children:(0,W.jsx)(f,{size:14})}),(0,W.jsx)(`button`,{className:`icon-btn`,title:`Refresh`,type:`button`,"aria-label":`Refresh`,children:(0,W.jsx)(ae,{size:14})})]}),s===`browser`&&(0,W.jsx)(`button`,{className:`icon-btn`,title:`Pop out`,type:`button`,"aria-label":`Pop out`,onClick:()=>l.current?.popout(),children:(0,W.jsx)(ze,{size:14})}),o&&(0,W.jsx)(`button`,{className:`icon-btn`,title:`Close`,type:`button`,"aria-label":`Close`,onClick:r,children:(0,W.jsx)(oe,{size:14})})]})]}),(0,W.jsxs)(`div`,{className:`art-toolbar`,children:[(0,W.jsxs)(`span`,{className:`seg`,children:[(0,W.jsx)(`span`,{className:`bullet`}),(0,W.jsx)(`strong`,{children:_?`Artefact`:b})]}),(0,W.jsx)(`span`,{className:`right-meta`,children:y})]}),(0,W.jsxs)(`div`,{className:`art-body`,"data-surface":s??`none`,children:[_&&(()=>{let t=e.editable!==!1,r=e.skipReason??null,i=(e.mimeType??``).startsWith(`application/pdf`);if(r)return(0,W.jsx)(ND,{reason:r});if(i&&n){let t=`/api/admin/sidebar-artefact-content?id=${encodeURIComponent(e.docId)}&session_key=${encodeURIComponent(n)}`;return(0,W.jsx)(PD,{src:t,name:e.name,docId:e.docId},t)}return(0,W.jsxs)(W.Fragment,{children:[u&&(0,W.jsx)(`div`,{className:`art-save-error`,role:`alert`,children:u}),(0,W.jsx)(lT,{data:{title:e.name,content:e.content,readOnly:!t},onSubmit:t?g:kD,submitted:!1})]})})(),s===`browser`&&(0,W.jsx)(TD,{ref:l,onClose:r}),s===`data`&&n&&(0,W.jsx)(fe,{cacheKey:n,onOpenInGraph:a?e=>{let t=pe(e.properties);a(e.nodeId,t??e.labels[0]??null)}:void 0}),e?.surface===`graph`&&n&&(0,W.jsx)(le,{cacheKey:n,initialFocus:e.focusNodeId?{nodeId:e.focusNodeId,nodeLabel:e.focusNodeLabel??null}:null,initialLabels:e.initialLabels??null})]}),(0,W.jsxs)(`div`,{className:`art-foot`,children:[(0,W.jsx)(`span`,{className:`left`,children:y}),(0,W.jsx)(`span`,{className:`right in-sync`,children:`in sync`})]})]})}var LD=`maxy-shell-artefact-px`;function RD(){if(typeof window>`u`)return 320;let e=window.innerWidth,t=document.querySelector(`.platform > .side`)?.getBoundingClientRect(),n=t?t.right:Math.round(e*.3);return BD(Math.round((e-n)*(2/3)))}function zD(){if(typeof window>`u`)return 320;try{let e=window.localStorage.getItem(LD);if(!e)return RD();let t=parseInt(e,10);if(Number.isFinite(t)&&t>=320)return t}catch{}return RD()}function BD(e){if(typeof window>`u`)return e;let t=window.innerWidth,n=document.querySelector(`.platform > .side`)?.getBoundingClientRect(),r=n?n.right:Math.round(t*.3),i=Math.max(320,t-r-480);return Math.min(Math.max(e,320),i)}function VD({targetSelector:e=`.platform`}){let t=(0,U.useRef)(null),[n,r]=(0,U.useState)(()=>zD()),i=(0,U.useRef)(n);(0,U.useEffect)(()=>{let t=document.querySelector(e);!t||!(t instanceof HTMLElement)||(t.style.setProperty(`--artefact-px`,`${n}px`),i.current=n)},[n,e]);let a=(0,U.useCallback)(()=>{r(e=>{let t=BD(e);return t===e?e:t})},[]);(0,U.useEffect)(()=>(a(),window.addEventListener(`resize`,a),()=>window.removeEventListener(`resize`,a)),[a]);let o=e=>{e.preventDefault();let n=t.current;if(!n)return;n.setPointerCapture(e.pointerId),n.classList.add(`dragging`);let a=!1,o=e=>{a=!0,r(BD(Math.round(window.innerWidth-e.clientX)))},s=()=>{if(n.releasePointerCapture(e.pointerId),n.classList.remove(`dragging`),window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),!a)return;let t=i.current;try{window.localStorage.setItem(LD,String(t))}catch{}console.info(`[admin-ui] artefact-resize px=${t}`)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},s=()=>{let e=RD();r(e);try{window.localStorage.removeItem(LD)}catch{}console.info(`[admin-ui] artefact-resize px=${e}`)};return(0,W.jsx)(`div`,{ref:t,className:`art-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize artefact pane`,onPointerDown:o,onDoubleClick:s})}var HD=`maxy-shell-side-px`;function UD(){if(typeof window>`u`)return 0;let e=document.querySelector(`.platform > .artefact`)?.getBoundingClientRect();return e&&e.width>0?Math.round(e.width):0}function WD(e){if(typeof window>`u`)return e;let t=window.innerWidth,n=Math.max(248,t-480-UD());return Math.min(Math.max(e,248),n)}function GD(){if(typeof window>`u`)return 264;try{let e=window.localStorage.getItem(HD);if(!e)return 264;let t=parseInt(e,10);if(Number.isFinite(t)&&t>=248)return WD(t)}catch{}return 264}function KD({targetSelector:e=`.platform`}){let t=(0,U.useRef)(null),[n,r]=(0,U.useState)(()=>GD()),i=(0,U.useRef)(n);(0,U.useEffect)(()=>{let t=document.querySelector(e);!t||!(t instanceof HTMLElement)||(t.style.setProperty(`--side-px`,`${n}px`),i.current=n)},[n,e]);let a=(0,U.useCallback)(()=>{r(e=>{let t=WD(e);return t===e?e:t})},[]);(0,U.useEffect)(()=>{a(),window.addEventListener(`resize`,a);let t=document.querySelector(e),n=null;return t instanceof HTMLElement&&(n=new MutationObserver(a),n.observe(t,{attributes:!0,attributeFilter:[`data-artefact`,`class`]})),()=>{window.removeEventListener(`resize`,a),n?.disconnect()}},[a,e]);let o=e=>{e.preventDefault();let n=t.current;if(!n)return;n.setPointerCapture(e.pointerId),n.classList.add(`dragging`);let a=!1,o=e=>{a=!0,r(WD(Math.round(e.clientX)))},s=()=>{if(n.releasePointerCapture(e.pointerId),n.classList.remove(`dragging`),window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),!a)return;let t=i.current;try{window.localStorage.setItem(HD,String(t))}catch{}console.info(`[admin-ui] sidebar-resize px=${t}`)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},s=()=>{let e=WD(264);r(e);try{window.localStorage.removeItem(HD)}catch{}console.info(`[admin-ui] sidebar-resize px=${e}`)};return(0,W.jsx)(`div`,{ref:t,className:`side-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,onPointerDown:o,onDoubleClick:s})}var qD=50;function JD(e){let[t,n]=(0,U.useState)([]),[r,i]=(0,U.useState)(!1),[a,o]=(0,U.useState)(null),[s,c]=(0,U.useState)(null),l=(0,U.useCallback)(async t=>{if(e&&!(!t&&s===e)){i(!0),o(null);try{let t=await fetch(`/api/admin/sessions?session_key=${encodeURIComponent(e)}`);if(!t.ok)throw Error(`sessions fetch returned ${t.status}`);n((await t.json()).sessions??[]),c(e)}catch(e){console.error(`[admin/sessions] fetch failed:`,e),o(e instanceof Error?e.message:String(e))}finally{i(!1)}}},[e,s]);(0,U.useEffect)(()=>{e||(c(null),n([]),o(null))},[e]);let u=(0,U.useCallback)(()=>l(!1),[l]),d=(0,U.useCallback)(()=>l(!0),[l]),f=(0,U.useRef)(d);return(0,U.useEffect)(()=>{f.current=d},[d]),(0,U.useEffect)(()=>{if(!e)return;let t=null,n=ce(()=>{t&&clearTimeout(t),t=setTimeout(()=>{t=null,f.current()},qD)});return()=>{t&&clearTimeout(t),n()}},[e]),{sessions:t,setSessions:n,loading:r,loaded:s!==null&&s===e,error:a,ensureLoaded:u,refetch:d}}function YD(){St();let e=(0,U.useRef)(null),[t,n]=(0,U.useState)(null),[r,a]=(0,U.useState)(!1),[o,s]=(0,U.useState)(!1),[c,l]=(0,U.useState)(``),[u,d]=(0,U.useState)(!1),[f,p]=(0,U.useState)(null),[g,_]=(0,U.useState)(!1),[v,y]=(0,U.useState)(null),[x,S]=(0,U.useState)(null),[C,w]=(0,U.useState)(!1),[E,D]=(0,U.useState)(null),[O,k]=(0,U.useState)(!1),[A,j]=(0,U.useState)(null),[M,N]=(0,U.useState)(!1),[P,ee]=(0,U.useState)(!1),[te,F]=(0,U.useState)(!1),[I,ne]=(0,U.useState)(!1),re=(0,U.useRef)(!0);(0,U.useEffect)(()=>{if(re.current){re.current=!1;return}ne(!0);let e=window.setTimeout(()=>ne(!1),240);return()=>window.clearTimeout(e)},[te]);let[L,ae]=(0,U.useState)(!1),[z,se]=(0,U.useState)(null),[ce,B]=(0,U.useState)(null),le=(0,U.useRef)(null),[ue,de]=(0,U.useState)(()=>typeof window<`u`&&window.matchMedia(`(min-width: 721px)`).matches);(0,U.useEffect)(()=>{let e=window.matchMedia(`(min-width: 721px)`),t=e=>de(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let[fe,pe]=(0,U.useState)(()=>typeof window<`u`&&window.matchMedia(`(min-width: 1080px)`).matches);(0,U.useEffect)(()=>{let e=window.matchMedia(`(min-width: 1080px)`),t=e=>pe(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let me=(0,U.useRef)(!1),_e=(0,U.useRef)(!1),xe=(0,U.useRef)(!1),Se=(0,U.useRef)(!1),Ce=(0,U.useRef)(null),we=b(),Te=Tt(),V=jt(),Ee=Jt(),De=JD(V.cacheKey),H=qt({cacheKey:V.cacheKey,setCacheKey:V.setCacheKey,setAppState:V.setAppState,conversationId:V.conversationId,setConversationId:V.setConversationId,startElapsedTimer:Te.startElapsedTimer,stopElapsedTimer:Te.stopElapsedTimer,resetTimerState:Te.resetTimerState,pausedElapsedRef:Te.pausedElapsedRef,expandAllDefaultRef:V.expandAllDefaultRef,setExpandAll:V.setExpandAll,getPendingFiles:()=>Ee.pendingFiles,clearPendingFiles:Ee.clearFiles,inputRef:e});(0,U.useEffect)(()=>{l(window.location.hostname.startsWith(`admin.`)?window.location.origin.replace(`admin.`,`public.`):window.location.origin)},[]),(0,U.useEffect)(()=>{function e(e){e.key===`Escape`&&(t?n(null):we.selectionMode&&we.exitSelection())}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,we.selectionMode]),(0,U.useEffect)(()=>{(V.appState===`set-pin`||V.appState===`enter-pin`)&&setTimeout(()=>V.pinInputRef.current?.focus(),100),V.appState===`chat`&&setTimeout(()=>e.current?.focus(),100)},[V.appState,H.greetingGeneration]),(0,U.useEffect)(()=>{if(V.appState!==`chat`)return;history.pushState({maxyChat:!0},``);function e(){console.debug(`[history-guard] popstate absorbed`),history.pushState({maxyChat:!0},``)}return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[V.appState]);let Oe=(0,U.useRef)(H.greetingGeneration);(0,U.useEffect)(()=>{H.greetingGeneration!==Oe.current&&(Oe.current=H.greetingGeneration,V.onboardingComplete===!1&&(me.current=!1))},[H.greetingGeneration,V.onboardingComplete]),(0,U.useEffect)(()=>{V.appState===`chat`&&V.onboardingComplete===!1&&(me.current||(me.current=!0,H.sendSystemPrompt(`[Begin onboarding.]`)))},[V.appState,V.onboardingComplete,H.greetingGeneration]),(0,U.useEffect)(()=>{if(!u)return;let e=!1;return fetch(`/api/admin/version`).then(e=>e.json()).then(t=>{e||D(t)}).catch(e=>{console.error(`[admin/version] menu-open client fetch failed:`,e)}),()=>{e=!0}},[u]),(0,U.useEffect)(()=>{if(V.appState!==`chat`){xe.current=!1,Se.current=!1;return}if(xe.current)return;xe.current=!0;let e=!1;return fetch(`/api/admin/version`).then(e=>e.json()).then(t=>{e||(D(t),!(!t.updateAvailable||Se.current)&&(j(t),k(!0),fetch(`/api/admin/version/alert-surfaced`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({installed:t.installed,latest:t.latest})}).catch(e=>{console.error(`[admin/version] alert-surfaced signal failed:`,e)})))}).catch(e=>{console.error(`[admin/version] session-start client fetch failed:`,e)}),()=>{e=!0}},[V.appState]),(0,U.useEffect)(()=>{if(V.appState!==`chat`||!V.cacheKey)return;let e=V.conversationId?`flushed`:`pre-flush`,t=V.cacheKey.slice(0,8),n=V.conversationId?V.conversationId.slice(0,8):`null`;console.info(`[admin-session-identity] cacheKey=${t} conversationId=${n} phase=${e} surface=chat-header`)},[V.appState,V.cacheKey,V.conversationId]),(0,U.useEffect)(()=>{if(V.appState!==`chat`){_e.current=!1;return}if(_e.current||!De.loaded)return;_e.current=!0;let e=De.sessions.filter(e=>e.name).length,t=z?`open`:`closed`;console.info(`[admin-ui] platform-shell brand=${R.productName} sidebar=${e} artefact=${t}`)},[V.appState,De.loaded,De.sessions,z]);let ke=De.sessions.find(e=>V.conversationId&&e.conversationId===V.conversationId||V.cacheKey&&e.cacheKey===V.cacheKey)?.name||V.businessName||(R.logoContainsName?``:R.productName);if((0,U.useEffect)(()=>{if(!u){p(null),y(null),S(null),D(null);return}function e(e){Ce.current&&!Ce.current.contains(e.target)&&d(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[u]),(0,U.useEffect)(()=>{if(typeof BroadcastChannel>`u`)return;let e=new BroadcastChannel(`platform-onboarding`);return e.onmessage=e=>{e.data?.type===`remote-password-set`&&H.sendMessageRef.current(`I've set the remote password`)},()=>e.close()},[]),V.appState===`loading`)return(0,W.jsx)(`div`,{className:`chat-page admin-page`,children:(0,W.jsx)(`header`,{className:`chat-header`,children:(0,W.jsx)(`img`,{src:ie,alt:R.productName,className:`chat-logo`})})});if(V.appState===`set-pin`)return(0,W.jsx)(Xt,{pin:V.pin,setPin:V.setPin,confirmPin:V.confirmPin,setConfirmPin:V.setConfirmPin,operatorName:V.operatorName,setOperatorName:V.setOperatorName,showPin:V.showPin,setShowPin:V.setShowPin,pinLoading:V.pinLoading,pinError:V.pinError,pinInputRef:V.pinInputRef,confirmPinInputRef:V.confirmPinInputRef,setPinFormRef:V.setPinFormRef,onSubmit:V.handleSetPin});if(V.appState===`onboarding-choice`)return(0,W.jsx)(en,{setAppState:V.setAppState,setOnboardingComplete:V.setOnboardingComplete});if(V.appState===`connect-claude`)return(0,W.jsx)($t,{authPolling:V.authPolling,setAuthPolling:V.setAuthPolling,authLoading:V.authLoading,setAuthLoading:V.setAuthLoading,pinError:V.pinError,setPinError:V.setPinError,setAppState:V.setAppState});if(V.appState===`enter-pin`)return(0,W.jsx)(Zt,{pin:V.pin,setPin:V.setPin,showPin:V.showPin,setShowPin:V.setShowPin,pinLoading:V.pinLoading,pinError:V.pinError,pinInputRef:V.pinInputRef,onSubmit:V.handleLogin,onChangePin:V.handleChangePin,remoteAuthEnabled:V.remoteAuthEnabled,onSignOutRemote:()=>{window.location.href=`/__remote-auth/logout`}});if(V.appState===`account-picker`)return(0,W.jsx)(Qt,{accounts:V.accounts,loading:V.accountPickerLoading,error:V.pinError,onSelect:V.handleAccountSelect});let Ae=z?`open`:`closed`,je=L&&ue,Me=`platform${te?` menu-open`:``}${je?` sidebar-collapsed`:``}${I?` drawer-animating`:``}`,Ne=(0,U.useCallback)(e=>{V.cacheKey&&fetch(`/api/admin/sessions/${encodeURIComponent(e)}/resume?session_key=${encodeURIComponent(V.cacheKey)}`,{method:`POST`}).then(e=>e.ok?e.json():Promise.reject(Error(`resume returned ${e.status}`))).then(e=>{e.conversationId&&V.setConversationId(e.conversationId);let t=(e.messages??[]).map(e=>({role:e.role===`user`?`admin`:`maxy`,content:e.role===`user`?e.content:void 0,events:e.role===`assistant`?e.events??[]:void 0,...e.role===`user`&&e.attachments&&e.attachments.length>0?{attachments:e.attachments}:{},...e.role===`user`&&oD(e.content)?{hidden:!0}:{},timestamp:new Date(e.createdAt).getTime()||0,historical:!0,...e.messageId?{messageId:e.messageId}:{}}));if(t.length>0&&H.setMessages(t),e.resumeHeal){let{missingTurns:n,failed:r,jsonlMissing:i}=e.resumeHeal,a;r>0?a=`Could not heal ${r} of ${n} turn${n===1?``:`s`} that were missing from the graph. The JSONL replay rendered them above so the conversation is intact, but they may not appear in future searches until the writer recovers.`:i&&t.length>0&&(a=`This conversation's SDK transcript file is no longer on disk; the conversation is rendered from the graph projection. The next message you send will start a fresh SDK session under the same conversation.`),a&&H.setMessages(e=>[{role:`maxy`,events:[{type:`text`,content:a}],timestamp:Date.now()-2,historical:!0},...e])}let n=[];for(let t of e.messages??[]){if(t.role!==`assistant`||!t.submittedEventIndices?.length)continue;let e=new Date(t.createdAt).getTime()||0;for(let r of t.submittedEventIndices)n.push(`${e}_${r}`)}n.length>0&&H.seedSubmittedComponents(n)}).catch(e=>{console.error(`[chat] sidebar conversation resume failed:`,e),H.setMessages([{role:`maxy`,events:[{type:`text`,content:`Could not load conversation history.`}],timestamp:Date.now()-1,historical:!0}])})},[V.cacheKey,V.setConversationId,H.setMessages,H.seedSubmittedComponents]),Pe=e=>{if(!H.isStreaming&&V.cacheKey){if(!e.conversationId){H.resetConversation(),H.setMessages([]),V.setConversationId(null);return}H.resetConversation(),H.setMessages([]),Ne(e.conversationId)}},Fe=(0,U.useRef)(null);(0,U.useEffect)(()=>{V.appState===`chat`&&(!V.cacheKey||!V.conversationId||H.messages.length>0||Fe.current!==V.cacheKey&&(Fe.current=V.cacheKey,Ne(V.conversationId)))},[V.appState,V.cacheKey,V.conversationId,H.messages.length,Ne]);let Ie={conversationId:V.conversationId,cacheKey:V.cacheKey,disconnecting:V.disconnecting,onOpenConversations:()=>{w(!0),De.refetch()},handleDisconnect:V.handleDisconnect};return(0,W.jsx)(T,{value:{onShowVnc:()=>N(!0)},children:(0,W.jsxs)(`div`,{className:Me,"data-artefact":Ae,children:[(0,W.jsx)(`div`,{className:`scrim`,onClick:()=>{F(!1),console.info(`[admin-ui] mobile-drawer state=closed`)}}),(0,W.jsx)(OD,{ref:le,businessName:V.businessName??null,cacheKey:V.cacheKey,conversationId:V.conversationId,role:V.role,userName:V.userName,userAvatar:V.userAvatar,sessions:De.sessions,sessionsLoading:De.loading,sessionsError:De.error,ensureSessionsLoaded:De.ensureLoaded,refetchSessions:De.refetch,recentsActions:{setSessions:De.setSessions,isStreaming:H.isStreaming,resetConversation:H.resetConversation,setMessages:H.setMessages,setConversationId:V.setConversationId,setCacheKey:V.setCacheKey},onSelectSession:Pe,onSelectArtefact:(e,t)=>{se({surface:`doc`,...e}),B(t)},onSelectProjects:()=>{se({surface:`graph`,initialLabels:[`Project`]}),B(`sidebar-projects`)},onSelectPeople:()=>{se({surface:`graph`,initialLabels:[`Person`]}),B(`sidebar-people`)},onSelectTasks:()=>{se({surface:`graph`,initialLabels:[`Task`]}),B(`sidebar-tasks`)},onSelectAgents:()=>{se({surface:`graph`,initialLabels:[`Agent`]}),B(`sidebar-agents`)},onCloseMobileDrawer:()=>{te&&(F(!1),console.info(`[admin-ui] mobile-drawer state=closed`))},collapsed:je,onToggleCollapsed:()=>ae(e=>!e),mobileDrawerOpen:te,actions:Ie}),(0,W.jsxs)(`div`,{className:`chat-page admin-page`,children:[(0,W.jsxs)(`header`,{className:`chat-header`,children:[(0,W.jsx)(`button`,{type:`button`,className:`chat-logo-btn`,"aria-label":`Show sidebar`,title:`Show sidebar`,onClick:()=>{F(e=>{let t=!e;return console.info(`[admin-ui] header-logo-tap state=${t?`open`:`closed`}`),t})},children:(0,W.jsx)(`img`,{src:ie,alt:R.productName,className:`chat-logo`})}),(0,W.jsx)(`div`,{className:`chat-header-label`,children:(0,W.jsx)(`h1`,{className:`chat-tagline`,children:ke})}),(0,W.jsxs)(`div`,{className:`chat-burger-wrap`,ref:Ce,children:[(0,W.jsx)(`button`,{type:`button`,className:`chat-burger`,onClick:()=>d(e=>!e),"aria-label":`Menu`,"aria-haspopup":`true`,"aria-expanded":u,children:(0,W.jsx)(ge,{size:20})}),u&&(0,W.jsxs)(`div`,{className:`chat-menu`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:async()=>{if(!P&&!(!fe&&M)){ee(!0),d(!1);try{let e=await(await fetch(`/api/admin/browser/launch`,{method:`POST`})).json().catch(()=>({ok:!1,error:`Invalid response`}));if(!e.ok)throw Error(e.error??`Failed to launch browser`);fe?(se({surface:`browser`}),B(`header-menu`)):N(!0)}catch(e){console.error(`[browser] Launch failed:`,e),alert(e instanceof Error?e.message:`Failed to launch browser`)}finally{ee(!1)}}},disabled:P,children:[(0,W.jsx)(h,{size:14}),` Browser`,P&&(0,W.jsx)(he,{size:12,className:`spin`})]}),(0,W.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{d(!1),fe?(se({surface:`data`}),B(`header-menu`)):window.location.href=`/data`},children:[(0,W.jsx)(ve,{size:14}),` Data`]}),(0,W.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{d(!1),fe?(se({surface:`graph`}),B(`header-menu`)):window.location.href=`/graph`},children:[(0,W.jsx)(ye,{size:14}),` Graph`]}),(0,W.jsx)(`div`,{className:`chat-menu-divider`}),(0,W.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:async()=>{if(f!==null){p(null),S(null);return}_(!0),y(null);try{let e=await fetch(`/api/admin/agents`);if(!e.ok)throw Error(`Failed to load agents`);p((await e.json()).agents??[])}catch(e){console.error(`[admin] agent list failed:`,e),y(e instanceof Error?e.message:String(e))}finally{_(!1)}},children:[(0,W.jsx)(ze,{size:14}),` Public`,g&&(0,W.jsx)(he,{size:12,className:`spin`})]}),f!==null&&(0,W.jsxs)(`div`,{className:`chat-menu-agents`,children:[v&&(0,W.jsx)(`span`,{className:`chat-menu-agent-error`,children:v}),f.length===0&&!v&&(0,W.jsx)(`span`,{className:`chat-menu-agent-empty`,children:`No public agents configured`}),f.map(e=>(0,W.jsxs)(`div`,{className:`chat-menu-item chat-menu-agent-item`,children:[(0,W.jsx)(`span`,{className:`agent-status-dot ${e.status}`}),(0,W.jsxs)(`span`,{className:`agent-text`,children:[(0,W.jsx)(`span`,{className:`agent-display-name`,children:e.displayName}),(0,W.jsxs)(`span`,{className:`agent-slug`,children:[`/`,e.slug]})]}),x===e.slug?(0,W.jsxs)(`span`,{className:`agent-actions agent-confirm`,children:[(0,W.jsx)(`button`,{type:`button`,className:`agent-action-btn agent-confirm-yes`,title:`Confirm delete`,onClick:()=>{S(null),p(t=>t?.filter(t=>t.slug!==e.slug)??null),fetch(`/api/admin/agents/${encodeURIComponent(e.slug)}`,{method:`DELETE`}).catch(e=>console.error(`[admin/agents] delete failed:`,e))},children:(0,W.jsx)(m,{size:12})}),(0,W.jsx)(`button`,{type:`button`,className:`agent-action-btn agent-confirm-no`,title:`Cancel`,onClick:()=>S(null),children:(0,W.jsx)(oe,{size:12})})]}):(0,W.jsxs)(`span`,{className:`agent-actions`,children:[(0,W.jsx)(`a`,{href:`${c}/${e.slug}`,target:`_blank`,rel:`noopener noreferrer`,className:`agent-action-btn`,title:`Open agent`,onClick:()=>d(!1),children:(0,W.jsx)(ze,{size:12})}),(0,W.jsx)(`button`,{type:`button`,className:`agent-action-btn agent-delete-btn`,title:`Delete agent`,onClick:()=>S(e.slug),children:(0,W.jsx)(i,{size:12})})]})]},e.slug))]}),(0,W.jsx)(`div`,{className:`chat-menu-divider`}),E?.updateAvailable?(0,W.jsxs)(`button`,{type:`button`,className:`chat-menu-version`,onClick:()=>{E.latest&&(j(E),d(!1),k(!0))},children:[(0,W.jsx)(Je,{size:14}),(0,W.jsxs)(`span`,{className:`version-installed`,children:[`v`,E.installed,(0,W.jsx)(`span`,{className:`version-update-dot`})]})]}):(0,W.jsxs)(`div`,{className:`chat-menu-version chat-menu-version-passive`,children:[(0,W.jsx)(Je,{size:14}),(0,W.jsxs)(`span`,{className:`version-installed`,children:[E?`v${E.installed}`:`…`,E&&!E.updateAvailable&&(0,W.jsx)(`span`,{className:`version-uptodate-dot`})]})]}),(0,W.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,"data-testid":`report-turn`,onClick:async()=>{d(!1);let e=await H.reportTurn();e.ok||console.warn(`[admin-chat] report-turn failed:`,e.payload)},children:[(0,W.jsx)(Je,{size:14}),` Report this turn`]}),(0,W.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{d(!1),V.handleLogout(),H.setMessages([])},children:[(0,W.jsx)(be,{size:14}),` Log out`]})]})]})]}),(0,W.jsxs)(`div`,{className:`chat-content`,children:[(0,W.jsx)($E,{messages:H.messages,isStreaming:H.isStreaming,elapsedSeconds:Te.elapsedSeconds,sessionTurnStart:Te.sessionTurnStart,expandAll:V.expandAll,setExpandAll:V.setExpandAll,conversationCompacted:H.conversationCompacted,isCompacting:H.isCompacting,setShowCompactConfirm:s,handleComponentSubmit:H.handleComponentSubmit,effectiveSubmitted:H.effectiveSubmitted,selectionMode:we.selectionMode,selectedItems:we.selectedItems,toggleSelectItem:we.toggleSelectItem,cacheKey:V.cacheKey,setLightboxSrc:n,messageQueue:H.messageQueue,messageQueueRef:H.messageQueueRef,setQueue:H.setQueue,sendMessage:H.sendMessage,appState:V.appState,onboardingComplete:V.onboardingComplete,onOpenArtefact:e=>{se({surface:`doc`,...e}),B(`chat-link`)}}),(0,W.jsx)(eD,{offer:H.topicChangeOffer,onFreshStart:H.handleTopicFreshStart,onContinue:H.handleTopicContinue,disabled:H.isStreaming}),(0,W.jsx)(SD,{selectionMode:we.selectionMode,selectedItems:we.selectedItems,copyToast:we.copyToast||null,exitSelection:we.exitSelection,enterSelection:we.enterSelection,copySelected:we.copySelected,showCopyToast:we.showCopyToast,input:H.input,setInput:H.setInput,inputRef:e,pendingFiles:Ee.pendingFiles,setPendingFiles:Ee.setPendingFiles,isDragOver:Ee.isDragOver,attachError:Ee.attachError,fileInputRef:Ee.fileInputRef,addFiles:Ee.addFiles,removeFile:Ee.removeFile,onDragOver:Ee.onDragOver,onDragLeave:Ee.onDragLeave,onDrop:Ee.onDrop,isStreaming:H.isStreaming,wasPaused:H.wasPaused,messages:H.messages,messageQueueRef:H.messageQueueRef,setQueue:H.setQueue,sendMessage:H.sendMessage,stopStreaming:H.stopStreaming,disconnecting:V.disconnecting,handleDisconnect:V.handleDisconnect,claudeInfo:V.claudeInfo,setClaudeInfo:V.setClaudeInfo,setShowClaudeInfo:a,conversationId:V.conversationId,cacheKey:V.cacheKey,onNewConversation:H.startNewConversation,newConversationDisabled:H.isStreaming||H.isCompacting,onOpenConversations:()=>{w(!0),De.refetch()},sidebarVisible:ue})]}),we.copyToast&&(0,W.jsx)(`span`,{className:`copy-toast${we.copyToast===`failed`?` copy-toast-failed`:``}`,children:we.copyToast===`copied`?`Copied`:`Copy failed`}),(0,W.jsx)(mD,{show:C,onClose:()=>w(!1),conversationsLoading:De.loading,conversationsError:De.error,conversationsList:De.sessions,setConversationsList:De.setSessions,cacheKey:V.cacheKey,setCacheKey:V.setCacheKey,isStreaming:H.isStreaming,resetConversation:H.resetConversation,setMessages:H.setMessages,setConversationId:V.setConversationId}),(0,W.jsx)(hD,{src:t,onClose:()=>n(null)}),(0,W.jsx)(gD,{show:o,onClose:()=>s(!1),onConfirm:H.handleCompactNow}),(0,W.jsx)(_D,{show:r,onClose:()=>{a(!1),V.setClaudeInfo(null)},claudeInfo:V.claudeInfo,messages:H.messages,sessionElapsed:Te.sessionElapsed,conversationId:V.conversationId,cacheKey:V.cacheKey}),(0,W.jsx)(bD,{show:O,onClose:()=>{k(!1),Se.current=!0},versionInfo:A,cacheKey:V.cacheKey,onUpgradeComplete:()=>D(null)}),M&&(0,W.jsx)(ED,{onClose:()=>N(!1)})]}),(0,W.jsx)(KD,{}),(0,W.jsx)(VD,{}),(0,W.jsx)(ID,{selection:z,trigger:ce,cacheKey:V.cacheKey,onClose:()=>{se(null),B(null)},onArtefactSaved:(e,t,n)=>{le.current?.patchArtefact(e,{updatedAt:t,content:n})},onSwapToGraph:(e,t)=>{se({surface:`graph`,focusNodeId:e,focusNodeLabel:t}),B(`chat-link`)}})]})})}(0,Se.createRoot)(document.getElementById(`root`)).render((0,W.jsx)(YD,{}));
|
|
352
|
+
`)}var rD=`Cloudflare setup completed (actionId: `,iD=`{"_componentDone"`,aD=`{"_lifecycle"`;function oD(e){return typeof e!=`string`||e.length===0?!1:e.startsWith(iD)||e.startsWith(aD)||e.startsWith(rD)}function sD(e){let{row:t,surface:n,isStreaming:r,activeCacheKey:a,isLogsOpen:o,onLogsToggle:s,onRequestRename:c,onResume:l,onDelete:u,onSwitchPreFlush:d}=e,f=t.phase===`pre-flush`,p=f&&t.cacheKey!==null&&t.cacheKey!==a;return(0,W.jsxs)(`div`,{className:`conversations-row-actions`,"data-surface":n,children:[(0,W.jsx)(`button`,{type:`button`,className:`conversations-action conversations-logs`,title:f?`View pre-flush logs`:`View logs`,"aria-haspopup":`menu`,"aria-expanded":o,onClick:e=>{e.stopPropagation(),s(e.currentTarget)},children:(0,W.jsx)(g,{size:13})}),p&&d&&(0,W.jsx)(`button`,{type:`button`,className:`conversations-action conversations-play`,title:`Switch into this in-memory session`,disabled:r||!a,onClick:e=>{e.stopPropagation(),!(r||!a)&&d()},children:(0,W.jsx)(_,{size:13})}),!f&&t.conversationId&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`button`,{type:`button`,className:`conversations-action conversations-rename`,title:`Rename conversation`,onClick:e=>{e.stopPropagation(),c()},children:(0,W.jsx)(dt,{size:13})}),(0,W.jsx)(`button`,{type:`button`,className:`conversations-action conversations-play`,title:`Resume conversation`,disabled:r,onClick:e=>{e.stopPropagation(),!(r||!a)&&l()},children:(0,W.jsx)(_,{size:13})}),(0,W.jsx)(`button`,{type:`button`,className:`conversations-action conversations-delete`,title:`Delete conversation`,onClick:e=>{e.stopPropagation(),u()},children:(0,W.jsx)(i,{size:13})})]})]})}var cD=[{type:`stream`,label:`Stream`},{type:`error`,label:`Errors`},{type:`sse`,label:`SSE`}];function lD(e){let{state:t,popoverRef:n,surface:r,buildLogsUrl:i,onClose:a}=e;return t?(0,W.jsx)(`div`,{ref:n,className:`conversations-logs-popover`,role:`menu`,style:{top:t.top,right:t.right},"data-surface":r,children:cD.map(({type:e,label:n})=>(0,W.jsxs)(`a`,{role:`menuitem`,className:`conversations-logs-popover-item`,href:i({conversationId:t.conversationId,cacheKey:t.cacheKey},e),target:`_blank`,rel:`noopener noreferrer`,onClick:()=>{console.debug(`[admin-logs-popover] open-log`,{surface:r,conversationId:t.conversationId,cacheKey:t.cacheKey,type:e}),a()},children:[(0,W.jsx)(g,{size:12}),(0,W.jsx)(`span`,{children:n})]},e))}):null}function uD(e){let[t,n]=(0,U.useState)(null),r=(0,U.useRef)(null),i=(0,U.useCallback)(()=>n(null),[]),a=(0,U.useCallback)((e,t,r)=>{n(n=>{if(n?.rowId===e)return null;let i=r.getBoundingClientRect();return{rowId:e,conversationId:t.conversationId,cacheKey:t.cacheKey,top:i.bottom+4,right:Math.max(8,window.innerWidth-i.right)}})},[]);return(0,U.useEffect)(()=>{if(!t)return;function e(e){let t=e.target;t&&r.current?.contains(t)||t&&t.closest?.(`.conversations-logs`)||n(null)}function i(e){e.key===`Escape`&&n(null)}return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,i)}},[t]),(0,U.useEffect)(()=>{if(!t||!e?.current)return;let r=e.current,i=()=>n(null);return r.addEventListener(`scroll`,i,{passive:!0}),()=>r.removeEventListener(`scroll`,i)},[t,e]),{popover:t,popoverRef:r,toggle:a,close:i}}function dD(e,t){let[n,r]=(0,U.useState)(null),[i,a]=(0,U.useState)(null),[o,s]=(0,U.useState)(``),[c,l]=(0,U.useState)(!1),u=(0,U.useRef)(null);(0,U.useEffect)(()=>{i?.phase===`editing`&&(u.current?.focus(),u.current?.select())},[i]);let d=(0,U.useCallback)(()=>{r(null),a(null),s(``),l(!1)},[]);return{editingId:n,editState:i,editValue:o,setEditValue:s,confirming:c,editInputRef:u,requestSuggestion:(0,U.useCallback)(async t=>{if(e){d(),r(t),a({phase:`loading`});try{let n=await fetch(`/api/admin/sessions/${encodeURIComponent(t)}/label?session_key=${encodeURIComponent(e)}`,{method:`POST`});if(!n.ok){a({phase:`error`,reason:(await n.json().catch(()=>({}))).error||`Request failed`});return}let r=await n.json();r.label?(a({phase:`editing`}),s(r.label)):a({phase:`error`,reason:`Not enough message content to suggest a name`})}catch(e){console.error(`[admin-rename] label suggestion failed:`,e),a({phase:`error`,reason:e instanceof Error?e.message:String(e)})}}},[e,d]),confirmRename:(0,U.useCallback)(async n=>{let r=o.trim();if(!(!e||!r||c)){l(!0);try{let i=await fetch(`/api/admin/sessions/${encodeURIComponent(n)}/label`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({label:r,session_key:e})});if(!i.ok){a({phase:`error`,reason:(await i.json().catch(()=>({}))).error||`Rename failed`}),l(!1);return}t(e=>e.map(e=>e.conversationId===n?{...e,name:r}:e)),d()}catch(e){console.error(`[admin-rename] label rename failed:`,e),a({phase:`error`,reason:e instanceof Error?e.message:String(e)}),l(!1)}}},[e,o,c,t,d]),cancelEdit:d,isEditingRow:(0,U.useCallback)(e=>e!==null&&n===e,[n])}}var fD=`maxy-admin-session-key`;function pD(e,t){return e.conversationId?`/api/admin/logs?type=${t}&conversationId=${encodeURIComponent(e.conversationId)}`:e.cacheKey?`/api/admin/logs?type=${t}&cacheKey=${encodeURIComponent(e.cacheKey)}`:`/api/admin/logs?type=${t}`}function mD(e){let{show:t,onClose:n,conversationsLoading:r,conversationsError:i,conversationsList:a,setConversationsList:o,cacheKey:s,setCacheKey:c,isStreaming:l,resetConversation:u,setMessages:d,setConversationId:f}=e,[p,h]=(0,U.useState)(null),[g,_]=(0,U.useState)(null),v=(0,U.useRef)(null),y=(0,U.useRef)(null),b=(0,U.useRef)(null),{popover:x,popoverRef:S,toggle:C,close:w}=uD(b),T=dD(s,o);(0,U.useEffect)(()=>{t||(T.cancelEdit(),w(),h(null),_(null),v.current&&=(clearTimeout(v.current),null),y.current&&=(clearTimeout(y.current),null))},[t,T,w]);async function E(e){await L(e)?(h(e),_(null),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>h(null),1500)):(_(e),h(null),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>_(null),1500))}return t?(0,W.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,W.jsxs)(`div`,{className:`claude-info-modal conversations-modal`,onClick:e=>e.stopPropagation(),children:[(0,W.jsxs)(`div`,{className:`claude-info-header`,children:[(0,W.jsx)(et,{size:12}),`Conversations`,(0,W.jsx)(`button`,{className:`claude-info-close`,onClick:n,children:`✕`})]}),(0,W.jsxs)(`div`,{className:`conversations-list`,ref:b,children:[r&&(0,W.jsxs)(`div`,{className:`conversations-empty`,children:[(0,W.jsx)(he,{size:14,className:`spin`}),` Loading…`]}),i&&(0,W.jsx)(`div`,{className:`conversations-empty conversations-error`,children:i}),!r&&!i&&a.length===0&&(0,W.jsx)(`div`,{className:`conversations-empty`,children:`No recent conversations`}),!r&&!i&&a.map(e=>{let t=e.conversationId??e.cacheKey??``,r=e.phase===`pre-flush`,i=T.isEditingRow(e.conversationId),a=i&&T.editState?.phase===`loading`,h=i&&T.editState?.phase===`editing`,_=i&&T.editState?.phase===`error`,v=e.conversationId??e.cacheKey??``;return(0,W.jsxs)(`div`,{className:`conversations-row${r?` conversations-row-pre-flush`:``}`,children:[(0,W.jsxs)(`div`,{className:`conversations-row-info`,children:[a&&(0,W.jsxs)(`span`,{className:`conversations-row-name conversations-edit-loading`,children:[(0,W.jsx)(he,{size:12,className:`spin`}),` Generating suggestion…`]}),h&&(0,W.jsxs)(`div`,{className:`conversations-edit-inline`,children:[(0,W.jsx)(`input`,{ref:T.editInputRef,type:`text`,className:`conversations-edit-input`,value:T.editValue,onChange:e=>T.setEditValue(e.target.value),onKeyDown:t=>{t.key===`Enter`&&T.editValue.trim()&&T.confirmRename(e.conversationId),t.key===`Escape`&&T.cancelEdit()},maxLength:200}),(0,W.jsx)(`button`,{type:`button`,className:`conversations-action conversations-confirm`,title:`Confirm rename`,disabled:!T.editValue.trim()||T.confirming,onClick:()=>T.confirmRename(e.conversationId),children:T.confirming?(0,W.jsx)(he,{size:13,className:`spin`}):(0,W.jsx)(m,{size:13})}),(0,W.jsx)(`button`,{type:`button`,className:`conversations-action conversations-cancel`,title:`Cancel`,onClick:T.cancelEdit,children:(0,W.jsx)(oe,{size:13})})]}),_&&(0,W.jsxs)(`div`,{className:`conversations-edit-inline`,children:[(0,W.jsx)(`span`,{className:`conversations-edit-error`,children:T.editState.reason}),(0,W.jsx)(`button`,{type:`button`,className:`conversations-action conversations-retry`,title:`Retry`,onClick:()=>T.requestSuggestion(e.conversationId),children:(0,W.jsx)(ae,{size:13})}),(0,W.jsx)(`button`,{type:`button`,className:`conversations-action conversations-cancel`,title:`Cancel`,onClick:T.cancelEdit,children:(0,W.jsx)(oe,{size:13})})]}),!i&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`span`,{className:`conversations-row-name`,children:[e.name||(r?`session ${v}`:v),r&&(0,W.jsx)(`span`,{className:`conversations-row-phase-badge`,title:`Pre-flush — conversation not yet persisted`,children:`pre-flush`})]}),(0,W.jsxs)(`span`,{className:`conversations-row-meta`,children:[(0,W.jsx)(`button`,{type:`button`,className:`conversations-row-id${p===t?` copied`:``}${g===t?` copy-failed`:``}`,title:v,"aria-label":r?`Copy session key ${v}`:`Copy conversation id ${v}`,onClick:e=>{e.stopPropagation(),E(t)},children:p===t?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(m,{size:10}),` copied`]}):g===t?`copy failed`:v.slice(0,8)}),(0,W.jsxs)(`span`,{className:`conversations-row-time`,children:[(0,W.jsx)(Ne,{size:10}),(()=>{try{let t=new Date(e.updatedAt),n=Date.now()-t.getTime();return n<6e4?`just now`:n<36e5?`${Math.floor(n/6e4)}m ago`:n<864e5?`${Math.floor(n/36e5)}h ago`:`${Math.floor(n/864e5)}d ago`}catch{return``}})()]})]})]})]}),!i&&(0,W.jsx)(sD,{row:e,surface:`conversations-modal`,rowId:t,isStreaming:l,activeCacheKey:s,isLogsOpen:x?.rowId===t,onLogsToggle:n=>{console.info(`[admin-session-identity] cacheKey=${(e.cacheKey??`null`).slice(0,8)} conversationId=${(e.conversationId??`null`).slice(0,8)} phase=${e.phase} surface=conversations-modal action=logs`),C(t,{conversationId:e.conversationId,cacheKey:e.cacheKey},n)},onRequestRename:()=>{e.conversationId&&(console.info(`[admin-session-identity] cacheKey=${(e.cacheKey??`null`).slice(0,8)} conversationId=${e.conversationId.slice(0,8)} phase=${e.phase} surface=conversations-modal action=rename`),T.requestSuggestion(e.conversationId))},onResume:()=>{!e.conversationId||!s||(console.info(`[admin-session-identity] cacheKey=${s.slice(0,8)} conversationId=${e.conversationId.slice(0,8)} phase=${e.phase} surface=conversations-modal action=resume`),n(),u(),fetch(`/api/admin/sessions/${encodeURIComponent(e.conversationId)}/resume?session_key=${encodeURIComponent(s)}`,{method:`POST`}).then(e=>e.ok?e.json():Promise.reject(Error(`Failed to resume conversation`))).then(e=>{e.conversationId&&f(e.conversationId);let t=(e.messages??[]).map(e=>({role:e.role===`user`?`admin`:`maxy`,content:e.role===`user`?e.content:void 0,events:e.role===`assistant`?e.events??(e.content?[{type:`text`,content:e.content}]:[]):void 0,...e.role===`user`&&e.attachments&&e.attachments.length>0?{attachments:e.attachments}:{},...e.role===`user`&&oD(e.content)?{hidden:!0}:{},timestamp:new Date(e.createdAt).getTime()||0,historical:!0,...e.messageId?{messageId:e.messageId}:{}}));t.length>0&&d(t)}).catch(e=>{console.error(`[chat] conversation resume failed:`,e),d([{role:`maxy`,events:[{type:`text`,content:`Could not load conversation history.`}],timestamp:Date.now()-1,historical:!0}])}))},onDelete:()=>{e.conversationId&&(console.info(`[admin-session-identity] cacheKey=${(e.cacheKey??`null`).slice(0,8)} conversationId=${e.conversationId.slice(0,8)} phase=${e.phase} surface=conversations-modal action=delete`),o(t=>t.filter(t=>t.conversationId!==e.conversationId)),s&&fetch(`/api/admin/sessions/${encodeURIComponent(e.conversationId)}?session_key=${encodeURIComponent(s)}`,{method:`DELETE`}).catch(e=>console.error(`[chat] conversation delete failed:`,e)))},onSwitchPreFlush:()=>{if(l||!s||!e.cacheKey)return;let t=e.cacheKey;console.info(`[admin-session-identity] cacheKey=${s.slice(0,8)} conversationId=null phase=${e.phase} surface=conversations-modal action=switch-pre-flush target=${t.slice(0,8)}`),n(),u(),d([]),fetch(`/api/admin/sessions/switch?session_key=${encodeURIComponent(s)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({target_session_key:t})}).then(e=>e.ok?e.json():Promise.reject(Error(`switch returned ${e.status}`))).then(e=>{try{sessionStorage.setItem(fD,e.session_key)}catch{}_e(e.session_key,`chat`),c(e.session_key),f(e.conversationId)}).catch(e=>{console.error(`[chat] pre-flush session switch failed:`,e),d([{role:`maxy`,events:[{type:`text`,content:`Could not switch into that session.`}],timestamp:Date.now()-1,historical:!0}])})}})]},t)})]}),(0,W.jsx)(lD,{state:x,popoverRef:S,surface:`conversations-modal`,buildLogsUrl:pD,onClose:w})]})}):null}function hD({src:e,onClose:t}){return e?(0,W.jsxs)(`div`,{className:`attachment-lightbox`,onClick:t,children:[(0,W.jsx)(`button`,{className:`attachment-lightbox-close`,onClick:t,"aria-label":`Close`,children:`×`}),(0,W.jsx)(`img`,{src:e,alt:`Attachment`,onClick:e=>e.stopPropagation()})]}):null}function gD({show:e,onClose:t,onConfirm:n}){return e?(0,W.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,W.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,W.jsxs)(`div`,{className:`claude-info-header`,children:[(0,W.jsx)(`span`,{children:`Compact conversation?`}),(0,W.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:`✕`})]}),(0,W.jsx)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:`Summarises the conversation history to free up context window space. The session continues with a compressed summary.`}),(0,W.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,W.jsx)(E,{variant:`secondary`,size:`sm`,style:{background:`var(--accent)`,flex:1},onClick:()=>{t(),n()},children:`Yes, compact`}),(0,W.jsx)(E,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:t,children:`No`})]})]})}):null}function _D(e){let{show:t,onClose:n,claudeInfo:r,messages:i,sessionElapsed:a,conversationId:o,cacheKey:s}=e,[c,l]=(0,U.useState)(null);if(!t)return null;let u=i.flatMap(e=>e.events?.filter(e=>e.type===`usage`)??[]),d=u.at(-1),f=d?.peak_request_pct==null?d?.context_window?Math.round((d.input_tokens+d.cache_creation_tokens+d.cache_read_tokens)/d.context_window*100):0:Math.round(d.peak_request_pct*100),p=u.reduce((e,t)=>e+t.input_tokens+t.cache_creation_tokens+t.cache_read_tokens+t.output_tokens,0),m=i.flatMap(e=>e.events?.filter(e=>e.type===`rate_limit`)??[]).at(-1),h=u.reduce((e,t)=>e+(t.total_cost_usd??0),0),g=r?.account?.subscriptionType,_=e=>{let t=e*1e3-Date.now();if(t<=0)return`now`;let n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return n>0?`${n}h ${r}m`:`${r}m`};return(0,W.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,W.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,W.jsxs)(`div`,{className:`claude-info-header`,children:[(0,W.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`claude-info-icon`}),(0,W.jsx)(`span`,{children:`Claude Code`}),(0,W.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,W.jsxs)(`div`,{className:`claude-info-section`,children:[(0,W.jsxs)(`div`,{className:`claude-info-row`,children:[(0,W.jsx)(`span`,{className:`claude-info-label`,children:`Version`}),(0,W.jsx)(`span`,{className:`claude-info-value`,children:r?r.version:`…`})]}),(0,W.jsxs)(`div`,{className:`claude-info-row`,children:[(0,W.jsx)(`span`,{className:`claude-info-label`,children:`Email`}),(0,W.jsx)(`span`,{className:`claude-info-value`,children:r?.account?.email??`…`})]})]}),(g||m||h>0)&&(0,W.jsxs)(`div`,{className:`claude-info-section`,children:[g&&(0,W.jsxs)(`div`,{className:`claude-info-row`,children:[(0,W.jsx)(`span`,{className:`claude-info-label`,children:`Plan`}),(0,W.jsx)(`span`,{className:`claude-info-value`,style:{textTransform:`capitalize`},children:g})]}),m&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`claude-info-row`,children:[(0,W.jsx)(`span`,{className:`claude-info-label`,children:`Usage`}),(0,W.jsxs)(`span`,{className:`claude-info-value`,children:[Math.round(m.utilization*100),`%`]})]}),(0,W.jsxs)(`div`,{className:`claude-info-row`,children:[(0,W.jsx)(`span`,{className:`claude-info-label`,children:`Resets in`}),(0,W.jsx)(`span`,{className:`claude-info-value`,children:_(m.resetsAt)})]}),m.isUsingOverage&&(0,W.jsxs)(`div`,{className:`claude-info-row`,children:[(0,W.jsx)(`span`,{className:`claude-info-label`,children:`Overage`}),(0,W.jsx)(`span`,{className:`claude-info-value`,children:`Active`})]})]}),h>0&&(0,W.jsxs)(`div`,{className:`claude-info-row`,children:[(0,W.jsx)(`span`,{className:`claude-info-label`,children:`Session cost`}),(0,W.jsxs)(`span`,{className:`claude-info-value`,children:[`$`,h<.01?h.toFixed(4):h.toFixed(2)]})]})]}),(0,W.jsxs)(`div`,{className:`claude-info-section`,children:[(0,W.jsxs)(`div`,{className:`claude-info-row`,children:[(0,W.jsx)(`span`,{className:`claude-info-label`,children:`Model`}),(0,W.jsx)(`span`,{className:`claude-info-value`,children:r?.model??`…`})]}),(0,W.jsxs)(`div`,{className:`claude-info-row`,children:[(0,W.jsx)(`span`,{className:`claude-info-label`,children:`Context used`}),(0,W.jsx)(`span`,{className:`claude-info-value`,children:f>0?`${f}%`:`—`})]}),(0,W.jsxs)(`div`,{className:`claude-info-row`,children:[(0,W.jsx)(`span`,{className:`claude-info-label`,children:`Tokens`}),(0,W.jsx)(`span`,{className:`claude-info-value`,children:p>0?wt(p):`—`})]}),(0,W.jsxs)(`div`,{className:`claude-info-row`,children:[(0,W.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,W.jsx)(`span`,{className:`claude-info-value`,children:Ct(a)})]}),(o||s)&&(()=>{let e=o??s??``;return(0,W.jsxs)(`div`,{className:`claude-info-row`,children:[(0,W.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,W.jsx)(`button`,{type:`button`,className:`claude-info-value`,title:`${e} (${o?`flushed`:`pre-flush`}) — click to copy`,onClick:async()=>{l(await L(e)?`copied`:`failed`),setTimeout(()=>l(null),1200)},children:c===`copied`?`copied ✓`:c===`failed`?`copy failed ✕`:`${e.slice(0,8)}…`})]})})()]})]})})}var vD=5e3,yD={atPhase:8};function bD({show:e,onClose:t,versionInfo:n,cacheKey:r,onUpgradeComplete:i}){let[a,o]=(0,U.useState)(`prompt`),[s,c]=(0,U.useState)(``),[l,u]=(0,U.useState)(!1),[d,f]=(0,U.useState)(null),[p,m]=(0,U.useState)(null),[h,g]=(0,U.useState)(null),_=(0,U.useRef)(null),v=n?.latest??null,y=(0,U.useCallback)(()=>{_.current&&=(clearInterval(_.current),null)},[]);(0,U.useEffect)(()=>{e||(y(),o(`prompt`),c(``),u(!1),f(null),m(null),g(null))},[e,y]),(0,U.useEffect)(()=>y,[y]),(0,U.useEffect)(()=>{if(!(!e||a!==`running`||!v))return _.current=setInterval(async()=>{try{let e=await fetch(`/api/admin/version`,{cache:`no-store`});if(!e.ok)return;(await e.json()).installed===v&&(y(),o(`succeeded`),i(),setTimeout(()=>window.location.reload(),2e3))}catch{}},vD),y},[e,a,v,i,y]);let b=(0,U.useCallback)(async()=>{if(!(!v||!r||a!==`prompt`)){if(!s){f(`Enter your device password first.`);return}f(null),m(null),o(`priming`);try{let e=await fetch(`/api/admin/actions/sudo-prime?session_key=${encodeURIComponent(r)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({password:s,session_key:r})});if(e.status!==204){f((await e.json().catch(()=>({}))).error??`Password check failed (status ${e.status})`),o(`prompt`);return}}catch(e){f(e instanceof Error?e.message:`Password check network error`),o(`prompt`);return}try{let e=await fetch(`/api/admin/actions/upgrade?session_key=${encodeURIComponent(r)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sudoPassword:s,session_key:r})}),t=await e.json().catch(()=>({}));if(!e.ok||!t.actionId){m(t.error??`launch failed (status ${e.status})`),o(`launch-failed`);return}g(t.actionId),o(`running`)}catch(e){m(e instanceof Error?e.message:`launch network error`),o(`launch-failed`)}finally{c(``)}}},[s,v,r,a]);return e?(0,W.jsx)(`div`,{className:`claude-info-overlay`,onClick:()=>{(a===`prompt`||a===`succeeded`||a===`launch-failed`)&&t()},children:(0,W.jsxs)(`div`,{className:`claude-info-modal update-modal`,onClick:e=>e.stopPropagation(),children:[(0,W.jsxs)(`div`,{className:`claude-info-header`,children:[(0,W.jsx)(ue,{size:12}),`Software Update`,(0,W.jsx)(`button`,{className:`claude-info-close`,onClick:t,children:`✕`})]}),(0,W.jsxs)(`div`,{className:`update-modal-body`,children:[(0,W.jsxs)(`div`,{className:`update-modal-versions`,children:[(0,W.jsxs)(`div`,{className:`claude-info-row`,children:[(0,W.jsx)(`span`,{className:`claude-info-label`,children:`Installed`}),(0,W.jsxs)(`span`,{className:`claude-info-value`,children:[`v`,n?.installed??`…`]})]}),(0,W.jsxs)(`div`,{className:`claude-info-row`,children:[(0,W.jsx)(`span`,{className:`claude-info-label`,children:`Available`}),(0,W.jsxs)(`span`,{className:`claude-info-value update-version-new`,children:[`v`,v??`…`]})]})]}),(a===`prompt`||a===`priming`||a===`launch-failed`)&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`form-input__field`,style:{marginTop:12},children:[(0,W.jsx)(`label`,{className:`form-input__label`,htmlFor:`upgrade-sudo`,children:`Device password`}),(0,W.jsxs)(`div`,{className:`tunnel-route__row`,children:[(0,W.jsx)(`input`,{id:`upgrade-sudo`,className:`form-input__input tunnel-route__input`,type:l?`text`:`password`,autoComplete:`current-password`,value:s,onChange:e=>{c(e.target.value),f(null)},disabled:a===`priming`,onKeyDown:e=>{e.key===`Enter`&&s&&b()}}),(0,W.jsx)(`button`,{type:`button`,className:`tunnel-route__suffix`,onClick:()=>u(e=>!e),disabled:a===`priming`,style:{cursor:`pointer`,border:`none`,background:`inherit`},"aria-label":l?`Hide password`:`Show password`,children:l?`Hide`:`Show`})]}),(0,W.jsx)(`div`,{className:`form-input__field-desc`,children:`Needed once. The installer uses it to run the privileged steps; it is never saved.`}),d&&(0,W.jsx)(`div`,{className:`tunnel-route__error`,children:d}),p&&(0,W.jsx)(`div`,{className:`tunnel-route__error`,role:`alert`,children:p})]}),(0,W.jsx)(`button`,{type:`button`,className:`update-modal-btn`,onClick:b,disabled:!v||!s||a===`priming`,children:a===`priming`?`Checking password…`:a===`launch-failed`?`Try again`:`Upgrade`})]}),a===`running`&&h&&r&&(0,W.jsx)(`div`,{className:`update-modal-terminal`,style:{height:360,marginTop:10},children:(0,W.jsx)(TE,{actionId:h,cacheKey:r,selfRestart:yD})}),a===`succeeded`&&(0,W.jsxs)(`div`,{className:`update-modal-result`,children:[(0,W.jsx)(ke,{size:14,className:`update-success-icon`}),(0,W.jsxs)(`span`,{children:[`Upgraded to v`,v,` — reloading…`]})]})]})]})}):null}function xD(e){let{conversationId:t,cacheKey:n,disconnecting:r,onOpenConversations:i,handleDisconnect:a,onAfterAction:o}=e,s=!t&&!n;return(0,W.jsxs)(`div`,{className:`chat-actions-menu`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`chat-action`,onClick:()=>{o(),i()},children:[(0,W.jsx)(et,{size:14}),(0,W.jsx)(`span`,{className:`action-label`,children:`Conversations`})]}),(0,W.jsxs)(`button`,{type:`button`,className:`chat-action`,disabled:r,onClick:async()=>{o(),await a()},children:[r?(0,W.jsx)(he,{size:14,className:`animate-spin`}):(0,W.jsx)(V,{size:14}),(0,W.jsx)(`span`,{className:`action-label`,children:r?`Disconnecting...`:`Disconnect Claude`})]}),(0,W.jsxs)(`button`,{type:`button`,className:`chat-action`,disabled:s,title:t?`Download stream log`:n?`Download stream log (pre-flush)`:`No session active — reload the page to start one`,onClick:async()=>{o();let e=(t??``).slice(-8),r=(n??``).slice(-8);if(console.debug(`[stream-log-button] click conversationId=${e||`null`} cacheKey=${r||`null`} disabled=${s}`),s)return;let i=`${pD({conversationId:t,cacheKey:n},`stream`)}&download=1`,a=0,c=0,l;try{let e=await fetch(i);a=e.status;let t=e.headers.get(`content-length`);l=await e.blob(),c=t?Number(t):l.size}catch(e){a=0,console.debug(`[stream-log-button] fetch-failed reason=${e instanceof Error?e.message:String(e)}`)}try{let t=JSON.stringify({kind:`event`,source:`stream-log-click`,url:i,status:a,bytes:c,conversationId:e});navigator.sendBeacon(`/api/_client-error`,new Blob([t],{type:`application/json`}))||console.debug(`[stream-log-button] sendBeacon returned false`)}catch(e){console.debug(`[stream-log-button] beacon-failed reason=${e instanceof Error?e.message:String(e)}`)}if(l&&a>=200&&a<300){let t=URL.createObjectURL(l),n=document.createElement(`a`);n.href=t,n.download=`stream-${e||`session`}.log`,n.click(),setTimeout(()=>URL.revokeObjectURL(t),5e3)}},children:[(0,W.jsx)(ft,{size:14}),(0,W.jsx)(`span`,{className:`action-label`,children:`Stream log`})]})]})}function SD(e){let{selectionMode:t,selectedItems:n,copyToast:r,exitSelection:i,enterSelection:a,copySelected:o,showCopyToast:s,input:l,setInput:d,inputRef:p,pendingFiles:m,setPendingFiles:h,isDragOver:y,attachError:b,fileInputRef:x,addFiles:S,removeFile:C,onDragOver:w,onDragLeave:T,onDrop:D,isStreaming:j,wasPaused:M,messages:P,messageQueueRef:ee,setQueue:F,sendMessage:ne,stopStreaming:re,disconnecting:ie,handleDisconnect:R,claudeInfo:ae,setClaudeInfo:z,setShowClaudeInfo:oe,conversationId:se,cacheKey:ce,onNewConversation:B,newConversationDisabled:le,onOpenConversations:ue,sidebarVisible:de}=e,[fe,pe]=(0,U.useState)(!1),me=(0,U.useRef)(null),[he,ge]=(0,U.useState)(!1),_e=(0,U.useRef)(null),ve=(0,U.useRef)(!1),ye=I(),be=ye.state===`recording`||ye.state===`paused`||ye.state===`sending`,xe=!be&&!M&&!l.trim()&&m.length===0;async function Se(){let e=await ye.send();if(!e)return;let t=e.type===`audio/ogg`?`.ogg`:e.type===`audio/mp4`?`.m4a`:`.webm`,n=new File([e],`voice-note${t}`,{type:e.type});if(j){F([...ee.current,{text:`[Voice note]`,files:[n],timestamp:Date.now()}]);return}ne(`[Voice note]`,[n])}return(0,U.useEffect)(()=>{t||ge(!1)},[t]),(0,U.useEffect)(()=>{if(!he)return;let e=e=>{e.target.closest(`.selection-copy-wrap`)||ge(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[he]),(0,U.useEffect)(()=>{if(!fe)return;let e=e=>{if(e.key===`Escape`){pe(!1);return}if(e.key===`Tab`&&me.current){let t=me.current.querySelectorAll(`.actions-menu-items button:not([disabled])`);if(t.length===0)return;let n=t[0],r=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())}},t=e=>{me.current&&!me.current.contains(e.target)&&pe(!1)};return document.addEventListener(`keydown`,e),document.addEventListener(`mousedown`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`mousedown`,t)}},[fe]),t?(0,W.jsx)(`div`,{className:`chat-input-area`,children:(0,W.jsxs)(`div`,{className:`selection-bar`,children:[(0,W.jsxs)(`span`,{className:`selection-count`,children:[n.size,` Selected`]}),(0,W.jsxs)(`div`,{className:`selection-copy-wrap`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`selection-copy`,onPointerDown:()=>{if(he){ge(!1);return}ve.current=!1,_e.current=setTimeout(()=>{ve.current=!0,ge(!0),_e.current=null},500)},onPointerUp:()=>{_e.current!==null&&(clearTimeout(_e.current),_e.current=null)},onPointerLeave:()=>{_e.current!==null&&(clearTimeout(_e.current),_e.current=null)},onPointerCancel:()=>{_e.current!==null&&(clearTimeout(_e.current),_e.current=null)},onClick:async()=>{ve.current||await o(e=>tD(P,e),(e,t)=>{let[n,r]=[e.slice(0,e.lastIndexOf(`_`)),e.slice(e.lastIndexOf(`_`)+1)],[i,a]=[t.slice(0,t.lastIndexOf(`_`)),t.slice(t.lastIndexOf(`_`)+1)],o=parseInt(n,10)-parseInt(i,10);return o===0?r===`admin`?-1:a===`admin`?1:parseInt(r,10)-parseInt(a,10):o})},children:[(0,W.jsx)(f,{size:18}),(0,W.jsx)(`span`,{children:`Copy`})]}),he&&(0,W.jsx)(`div`,{className:`copy-menu`,children:[[`all`,`All events`],[`text`,`Text messages only`],[`non-text`,`Non-text only`]].map(([e,t])=>(0,W.jsx)(`button`,{type:`button`,className:`copy-menu-item`,onClick:async()=>{let t=nD(P,e);t&&s(await L(t)),i()},children:t},e))})]}),(0,W.jsx)(`button`,{type:`button`,className:`selection-cancel`,onClick:i,children:`Cancel`})]})}):(0,W.jsxs)(`div`,{className:`chat-input-area`,children:[(0,W.jsx)(`input`,{ref:x,type:`file`,multiple:!0,accept:Dt,style:{display:`none`},onChange:e=>{e.target.files&&S([...e.target.files]),e.target.value=``}}),m.length>0&&(0,W.jsx)(`div`,{className:`attachment-strip`,children:m.map((e,t)=>(0,W.jsxs)(`div`,{className:`attachment-chip`,children:[e.type.startsWith(`image/`)?(0,W.jsx)(`img`,{src:URL.createObjectURL(e),alt:e.name,className:`attachment-chip-thumb`}):e.type.startsWith(`audio/`)?(0,W.jsx)(k,{size:14}):e.type===`application/pdf`?(0,W.jsx)(g,{size:14}):(0,W.jsx)(v,{size:14}),(0,W.jsx)(`span`,{className:`attachment-chip-name`,children:e.name}),(0,W.jsx)(`button`,{type:`button`,className:`attachment-chip-remove`,onClick:()=>C(t),"aria-label":`Remove ${e.name}`,children:`×`})]},t))}),b&&(0,W.jsx)(`p`,{className:`attach-error`,children:b}),ye.state===`error`&&ye.errorMessage&&(0,W.jsxs)(`p`,{className:`voice-error`,role:`alert`,children:[(0,W.jsx)(k,{size:14}),ye.errorMessage]}),(0,W.jsx)(O,{inputRef:p}),be?(0,W.jsx)(`div`,{className:`chat-form voice-active`,children:(0,W.jsx)(N,{state:ye.state,elapsedSeconds:ye.elapsedSeconds,waveform:ye.waveform,onTogglePause:ye.togglePause,onDiscard:ye.discard,onSend:Se})}):(0,W.jsxs)(`form`,{className:`chat-form${y?` drag-over`:``}`,onSubmit:e=>{e.preventDefault();let t=l.trim()||(M?`continue`:``);if(!(!t&&m.length===0)){if(j){F([...ee.current,{text:t,files:[...m],timestamp:Date.now()}]),d(``),h([]),p.current?.resetHeight();return}ne(t),p.current?.resetHeight()}},onDragOver:w,onDragLeave:T,onDrop:D,onPaste:e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e of t){if(e.kind!==`file`)continue;let t=e.getAsFile();if(!t)continue;let r=t.type.split(`/`)[1]?.replace(`jpeg`,`jpg`)||`png`;n.push(new File([t],`pasted-image-${Date.now()}.${r}`,{type:t.type}))}n.length>0&&S(n)},children:[(0,W.jsx)(E,{variant:`icon`,type:`button`,onClick:()=>x.current?.click(),"aria-label":`Attach file`,children:(0,W.jsx)(c,{size:14})}),(0,W.jsx)(te,{ref:p,value:l,onChange:d}),j?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(E,{variant:`send`,type:`button`,onClick:()=>re(!0),"aria-label":`Pause`,style:{background:`var(--text-secondary)`},children:(0,W.jsx)(A,{size:14})}),(0,W.jsx)(E,{variant:`send`,type:`button`,onClick:()=>re(!1),"aria-label":`Stop`,style:{background:`var(--danger)`},children:(0,W.jsx)(ht,{size:14})})]}):xe?(0,W.jsx)(E,{variant:`send`,type:`button`,onClick:ye.start,"aria-label":`Record voice note`,children:(0,W.jsx)(k,{size:14})}):(0,W.jsx)(E,{variant:`send`,type:`submit`,disabled:!l.trim()&&m.length===0&&!M,"aria-label":`Send message`,children:M?(0,W.jsx)(_,{size:14}):(0,W.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,W.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,W.jsxs)(`div`,{className:`chat-actions`,ref:me,children:[!de&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`button`,{className:`burger-trigger`,onClick:()=>pe(e=>!e),"aria-expanded":fe,"aria-haspopup":`true`,"aria-label":`Conversation actions`,children:(0,W.jsx)(Re,{size:16})}),(0,W.jsx)(`div`,{className:`actions-menu-items${fe?` actions-menu-open`:``}`,children:(0,W.jsx)(xD,{conversationId:se,cacheKey:ce,disconnecting:ie,onOpenConversations:ue,handleDisconnect:R,onAfterAction:()=>pe(!1)})})]}),(0,W.jsx)(`button`,{type:`button`,className:`chat-action-icon`,title:`New conversation`,"aria-label":`New conversation`,disabled:le,onClick:B,children:(0,W.jsx)(Ge,{size:16})}),(0,W.jsx)(`button`,{type:`button`,className:`chat-action-icon`,title:`Select messages`,"aria-label":`Select messages`,onClick:a,children:(0,W.jsx)(u,{size:16})}),(0,W.jsxs)(`div`,{className:`powered-by`,onClick:async()=>{if(oe(!0),!ae){let e=await fetch(`/api/admin/claude-info`);e.ok&&z(await e.json())}},children:[(0,W.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`powered-by-icon`}),(0,W.jsx)(`span`,{children:`Powered by Claude Code`})]})]})]})}var CD=`maxy-vnc-overlay-popout`;function wD(e){let[t,n]=(0,U.useState)(!1),r=(0,U.useRef)(null),i=(0,U.useRef)(null),a=(0,U.useCallback)(()=>{i.current&&=(clearInterval(i.current),null),r.current&&!r.current.closed&&r.current.close(),r.current=null,n(!1)},[]),o=(0,U.useCallback)(()=>{let t=`/vnc-popout.html?title=${encodeURIComponent(R.productName)}`,o=window.open(t,CD,`width=1024,height=768`);o&&(r.current=o,n(!0),i.current=setInterval(()=>{r.current?.closed&&(a(),e?.())},500))},[a,e]);return(0,U.useEffect)(()=>()=>a(),[a]),{poppedOut:t,popout:o,cleanupPopout:a}}var TD=(0,U.forwardRef)(function({onClose:e},t){St(),un(`overlay`);let{poppedOut:n,popout:r,cleanupPopout:i}=wD(e);return(0,U.useImperativeHandle)(t,()=>({popout:r}),[r]),n?(0,W.jsxs)(`div`,{className:`browser-overlay-popout`,children:[(0,W.jsx)(h,{className:`browser-viewer__icon`}),(0,W.jsx)(`span`,{className:`browser-viewer__title`,children:R.productName}),(0,W.jsx)(`span`,{className:`browser-viewer__popout-label`,children:`Popped out`}),(0,W.jsx)(E,{variant:`ghost`,size:`sm`,icon:st,onClick:()=>i(),"aria-label":`Pop back in`}),e&&(0,W.jsx)(E,{variant:`ghost`,size:`sm`,icon:oe,onClick:()=>{i(),e()},"aria-label":`Close`})]}):(0,W.jsx)(`iframe`,{src:`/vnc-viewer.html`,className:`browser-surface__iframe`,title:R.productName})});function ED({onClose:e}){St(),un(`overlay`);let{poppedOut:t,popout:n,cleanupPopout:r}=wD(e),i=(0,U.useCallback)(()=>{r(),e()},[r,e]);(0,U.useEffect)(()=>{if(t)return;let e=e=>{e.key===`Escape`&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,i]);let a=ln({handlePopout:n,disabled:t});return t?(0,W.jsxs)(`div`,{className:`browser-overlay-popout`,children:[(0,W.jsx)(h,{className:`browser-viewer__icon`}),(0,W.jsx)(`span`,{className:`browser-viewer__title`,children:R.productName}),(0,W.jsx)(`span`,{className:`browser-viewer__popout-label`,children:`Popped out`}),(0,W.jsx)(E,{variant:`ghost`,size:`sm`,icon:st,onClick:()=>{r()},"aria-label":`Pop back in`}),(0,W.jsx)(E,{variant:`ghost`,size:`sm`,icon:oe,onClick:i,"aria-label":`Close`})]}):(0,W.jsxs)(`div`,{className:`browser-viewer-fullscreen`,children:[(0,W.jsxs)(`div`,{className:`browser-viewer-fullscreen__bar`,...a,children:[(0,W.jsx)(h,{className:`browser-viewer__icon`}),(0,W.jsx)(`span`,{className:`browser-viewer-fullscreen__title`,children:R.productName}),(0,W.jsxs)(`div`,{className:`browser-viewer-fullscreen__actions`,children:[(0,W.jsx)(E,{variant:`ghost`,size:`sm`,icon:ze,onClick:n,"aria-label":`Pop out`}),(0,W.jsx)(E,{variant:`ghost`,size:`sm`,icon:oe,onClick:i,"aria-label":`Close`})]})]}),(0,W.jsx)(`iframe`,{src:`/vnc-viewer.html`,className:`browser-viewer-fullscreen__iframe`,title:R.productName})]})}var DD=`maxy-admin-session-key`,OD=(0,U.forwardRef)(function(e,t){let{businessName:n,cacheKey:r,conversationId:i,role:a,userName:o,userAvatar:s,sessions:c,sessionsLoading:l,sessionsError:u,ensureSessionsLoaded:d,refetchSessions:f,onSelectSession:p,onSelectArtefact:h,onSelectProjects:_,onSelectPeople:v,onSelectTasks:y,onSelectAgents:b,onCloseMobileDrawer:x,collapsed:S,onToggleCollapsed:C,mobileDrawerOpen:w,actions:T,recentsActions:E}=e;(0,U.useEffect)(()=>{d()},[d]);let D=(0,U.useRef)(null),{popover:O,popoverRef:k,toggle:A,close:j}=uD(D),M=dD(r,E.setSessions),N=R.productName,P=typeof o==`string`?o:o===null?`name unavailable`:n||N,ee=(P.trim().charAt(0)||`?`).toUpperCase(),[te,F]=(0,U.useState)(`all`),I=(0,U.useMemo)(()=>c.filter(e=>e.name).filter(e=>te===`all`?!0:(e.channel??`webchat`)===te),[c,te]),ne=I.length,re=i??r,[L,ie]=(0,U.useState)(`chat`),[z,ce]=(0,U.useState)([]),[B,le]=(0,U.useState)(!1),[ue,de]=(0,U.useState)(null),[fe,pe]=(0,U.useState)(!1);(0,U.useImperativeHandle)(t,()=>({patchArtefact(e,t){ce(n=>n.map(n=>n.id===e?{...n,...t}:n))}}),[]);let[me,ge]=(0,U.useState)(!1),ve=(0,U.useRef)(null);(0,U.useEffect)(()=>{if(!me)return;function e(e){ve.current&&!ve.current.contains(e.target)&&ge(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[me]);let ye=(0,U.useCallback)(async()=>{if(r){pe(!0),de(null);try{let e=await fetch(`/api/admin/sidebar-artefacts?session_key=${encodeURIComponent(r)}`);if(!e.ok)throw Error(`status ${e.status}`);ce((await e.json()).artefacts??[]),le(!0)}catch(e){let t=e instanceof Error?e.message:String(e);de(`Failed to load artefacts: ${t}`),console.error(`[admin-ui] sidebar-artefacts fetch failed: ${t}`)}finally{pe(!1)}}},[r]),be=()=>{ie(`chat`),console.info(`[admin-ui] sidebar-nav surface=chat count=${ne}`)},xe=()=>{ie(`artefacts`),console.info(`[admin-ui] sidebar-nav surface=artefacts count=${B?z.length:0} collapsed=${S}`),S&&C(),B||ye()},Se=S?24:16,Ce=L===`chat`?`Recents`:`Artefacts`,we=L===`chat`?l?`…`:String(ne):fe?`…`:String(z.length),Te=L===`chat`?l:fe,V=()=>{L===`chat`?f():ye(),console.info(`[admin-ui] sidebar-refresh surface=${L}`)};return(0,W.jsxs)(`aside`,{className:`side`,children:[(0,W.jsx)(`div`,{className:`side-head`,children:(0,W.jsx)(`button`,{className:`icon-btn side-head-toggle`,title:w?`Close sidebar`:S?`Expand sidebar`:`Collapse sidebar`,type:`button`,"aria-label":w?`Close sidebar`:S?`Expand sidebar`:`Collapse sidebar`,onClick:()=>{w?(console.info(`[admin-ui] sidebar-head-toggle action=close-drawer state=closed`),x()):(console.info(`[admin-ui] sidebar-head-toggle action=toggle-collapsed state=${S?`expanded`:`collapsed`}`),C())},children:S?(0,W.jsx)(ut,{size:28}):(0,W.jsx)(lt,{size:28})})}),(0,W.jsxs)(`nav`,{className:`side-nav`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`nav-row${L===`chat`?` active`:``}`,onClick:be,children:[(0,W.jsx)(ot,{size:Se}),(0,W.jsx)(`span`,{className:`label`,children:`Chat`}),(0,W.jsx)(`span`,{className:`kbd`})]}),(0,W.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=people`),v(),x()},children:[(0,W.jsx)(yt,{size:Se}),(0,W.jsx)(`span`,{className:`label`,children:`People`}),(0,W.jsx)(`span`,{className:`kbd`})]}),(0,W.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=agents`),b(),x()},children:[(0,W.jsx)(Ee,{size:Se}),(0,W.jsx)(`span`,{className:`label`,children:`Agents`}),(0,W.jsx)(`span`,{className:`kbd`})]}),(0,W.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=projects`),_(),x()},children:[(0,W.jsx)(De,{size:Se}),(0,W.jsx)(`span`,{className:`label`,children:`Projects`}),(0,W.jsx)(`span`,{className:`kbd`})]}),(0,W.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=tasks`),y(),x()},children:[(0,W.jsx)($e,{size:Se}),(0,W.jsx)(`span`,{className:`label`,children:`Tasks`}),(0,W.jsx)(`span`,{className:`kbd`})]}),(0,W.jsxs)(`button`,{type:`button`,className:`nav-row${L===`artefacts`?` active`:``}`,onClick:xe,children:[(0,W.jsx)(g,{size:Se}),(0,W.jsx)(`span`,{className:`label`,children:`Artefacts`}),(0,W.jsx)(`span`,{className:`kbd`})]})]}),(0,W.jsxs)(`div`,{className:`side-list`,ref:D,children:[(0,W.jsxs)(`div`,{className:`group-head`,children:[(0,W.jsx)(`span`,{children:Ce}),(0,W.jsxs)(`span`,{className:`group-head-meta`,children:[(0,W.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh ${Ce.toLowerCase()}`,"aria-label":`Refresh ${Ce.toLowerCase()}`,onClick:V,disabled:Te,children:(0,W.jsx)(se,{size:12,className:Te?`spinning`:void 0})}),(0,W.jsx)(`span`,{children:we})]})]}),L===`chat`&&(0,W.jsxs)(W.Fragment,{children:[u&&(0,W.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:u}),(0,W.jsxs)(an,{className:`conv-channel-filter`,value:te,onChange:e=>{let t=e.target.value;F(t),console.info(`[admin-ui] sidebar-channel-filter set value=${t}`)},"aria-label":`Filter conversations by channel`,children:[(0,W.jsx)(`option`,{value:`all`,children:`All channels`}),(0,W.jsx)(`option`,{value:`webchat`,children:`Web`})]}),I.map(e=>{let t=e.conversationId??e.cacheKey??``,n=t!==``&&t===re,i=e.channel??`webchat`,a=e.phase===`pre-flush`,o=M.isEditingRow(e.conversationId),s=o&&M.editState?.phase===`loading`,c=o&&M.editState?.phase===`editing`,l=o&&M.editState?.phase===`error`,u=t=>{let n=e.cacheKey?e.cacheKey.slice(0,8):`null`,r=e.conversationId?e.conversationId.slice(0,8):`null`;console.info(`[admin-session-identity] cacheKey=${n} conversationId=${r} phase=${e.phase} surface=sidebar-recents action=${t}`)};return(0,W.jsxs)(`div`,{className:`conv${n?` active`:``}${a?` conv-pre-flush`:``}${o?` conv-editing`:``}`,children:[!o&&(0,W.jsxs)(`button`,{type:`button`,className:`conv-name-button`,onClick:()=>{u(`select`),p(e),x()},children:[i===`whatsapp`&&(0,W.jsx)(rt,{size:12,className:`conv-channel-icon`,"aria-label":`WhatsApp`}),(0,W.jsx)(`span`,{className:`conv-name`,children:e.name??`(untitled)`})]}),s&&(0,W.jsxs)(`span`,{className:`conversations-row-name conversations-edit-loading conv-edit-loading`,children:[(0,W.jsx)(he,{size:12,className:`spin`}),` Generating suggestion…`]}),c&&(0,W.jsxs)(`div`,{className:`conversations-edit-inline conv-edit-inline`,children:[(0,W.jsx)(`input`,{ref:M.editInputRef,type:`text`,className:`conversations-edit-input`,value:M.editValue,onChange:e=>M.setEditValue(e.target.value),onKeyDown:t=>{t.key===`Enter`&&M.editValue.trim()&&e.conversationId&&M.confirmRename(e.conversationId),t.key===`Escape`&&M.cancelEdit()},maxLength:200}),(0,W.jsx)(`button`,{type:`button`,className:`conversations-action conversations-confirm`,title:`Confirm rename`,disabled:!M.editValue.trim()||M.confirming,onClick:()=>e.conversationId&&M.confirmRename(e.conversationId),children:M.confirming?(0,W.jsx)(he,{size:13,className:`spin`}):(0,W.jsx)(m,{size:13})}),(0,W.jsx)(`button`,{type:`button`,className:`conversations-action conversations-cancel`,title:`Cancel`,onClick:M.cancelEdit,children:(0,W.jsx)(oe,{size:13})})]}),l&&(0,W.jsxs)(`div`,{className:`conversations-edit-inline conv-edit-inline`,children:[(0,W.jsx)(`span`,{className:`conversations-edit-error`,children:M.editState.reason}),(0,W.jsx)(`button`,{type:`button`,className:`conversations-action conversations-retry`,title:`Retry`,onClick:()=>e.conversationId&&M.requestSuggestion(e.conversationId),children:(0,W.jsx)(ae,{size:13})}),(0,W.jsx)(`button`,{type:`button`,className:`conversations-action conversations-cancel`,title:`Cancel`,onClick:M.cancelEdit,children:(0,W.jsx)(oe,{size:13})})]}),!o&&(0,W.jsx)(sD,{row:e,surface:`sidebar-recents`,rowId:t,isStreaming:E.isStreaming,activeCacheKey:r,isLogsOpen:O?.rowId===t,onLogsToggle:n=>{u(`logs`),A(t,{conversationId:e.conversationId,cacheKey:e.cacheKey},n)},onRequestRename:()=>{e.conversationId&&(u(`rename`),M.requestSuggestion(e.conversationId))},onResume:()=>{!e.conversationId||E.isStreaming||(u(`resume`),p(e),x())},onDelete:()=>{if(!e.conversationId)return;u(`delete`);let t=e.conversationId;E.setSessions(e=>e.filter(e=>e.conversationId!==t)),r&&fetch(`/api/admin/sessions/${encodeURIComponent(t)}?session_key=${encodeURIComponent(r)}`,{method:`DELETE`}).catch(e=>console.error(`[chat] conversation delete failed:`,e))},onSwitchPreFlush:()=>{if(E.isStreaming||!r||!e.cacheKey)return;let t=e.cacheKey;u(`switch-pre-flush target=${t.slice(0,8)}`),E.resetConversation(),E.setMessages([]),fetch(`/api/admin/sessions/switch?session_key=${encodeURIComponent(r)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({target_session_key:t})}).then(e=>e.ok?e.json():Promise.reject(Error(`switch returned ${e.status}`))).then(e=>{try{sessionStorage.setItem(DD,e.session_key)}catch{}_e(e.session_key,`chat`),E.setCacheKey(e.session_key),E.setConversationId(e.conversationId)}).catch(e=>{console.error(`[chat] pre-flush session switch failed:`,e),E.setMessages([{role:`maxy`,events:[{type:`text`,content:`Could not switch into that session.`}],timestamp:Date.now()-1,historical:!0}])})}})]},t===``?e.updatedAt:t)})]}),L===`artefacts`&&(0,W.jsxs)(W.Fragment,{children:[ue&&(0,W.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:ue}),B&&!ue&&z.length===0&&(0,W.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No artefacts yet`}),z.map(e=>(0,W.jsxs)(`button`,{type:`button`,className:`conv`,onClick:()=>{h({docId:e.id,name:e.name,content:e.content,editable:e.editable,mimeType:e.mimeType,skipReason:e.skipReason},`sidebar-artefacts`),x()},children:[(0,W.jsx)(`span`,{className:`conv-name`,children:e.name}),(0,W.jsx)(`span`,{className:`conv-kind`,"data-kind":e.kind===`agent-template`?`agent`:`doc`,children:e.kind===`agent-template`?`agent`:`doc`})]},e.id))]}),(0,W.jsx)(lD,{state:O,popoverRef:k,surface:`sidebar-recents`,buildLogsUrl:pD,onClose:j})]}),(0,W.jsxs)(`div`,{className:`side-foot`,ref:ve,children:[(0,W.jsx)(`div`,{className:`avatar`,children:s?(0,W.jsx)(`img`,{src:s,alt:P}):ee}),(0,W.jsxs)(`div`,{className:`who`,children:[(0,W.jsx)(`span`,{className:`name`,children:P}),(0,W.jsx)(`span`,{className:`role`,children:a??`operator`})]}),(0,W.jsx)(`button`,{className:`icon-btn side-foot-actions-trigger`,title:`Conversation actions`,type:`button`,"aria-label":`Conversation actions`,"aria-haspopup":`true`,"aria-expanded":me,onClick:()=>ge(e=>!e),children:(0,W.jsx)(Re,{size:Se})}),me&&(0,W.jsx)(`div`,{className:`side-foot-actions-popover`,children:(0,W.jsx)(xD,{...T,onAfterAction:()=>ge(!1)})})]})]})}),kD=()=>{},AD=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function jD(e){return AD.test(e)?`uuid`:e.startsWith(`agent-template:`)?`agent-template`:`other`}var MD={"null-attachmentId":`No file backing this artefact.`,"non-text-mime":`Content type cannot be displayed inline.`,"containment-rejected":`File path failed containment check; cannot display.`,"missing-on-disk":`File is missing on disk.`};function ND({reason:e}){return(0,W.jsxs)(`div`,{className:`art-skip-banner`,role:`status`,children:[(0,W.jsx)(He,{size:14}),(0,W.jsx)(`span`,{children:MD[e]})]})}function PD({src:e,name:t,docId:n}){let[r,i]=(0,U.useState)(!1),a=(0,U.useRef)(null),o=(0,U.useRef)(!1),s=(0,U.useRef)(!1),c=(0,U.useCallback)(e=>{s.current||(s.current=!0,console.info(`[admin-ui] artefact-pdf-fallback id=${n.slice(0,8)} reason=${e}`),i(!0))},[n]);(0,U.useEffect)(()=>{let e=setTimeout(()=>{o.current||c(`onload-timeout`)},3e3);return()=>clearTimeout(e)},[c]);let l=()=>{o.current=!0;try{let e=a.current?.contentDocument?.body;e&&e.children.length===0&&!e.textContent?.trim()&&c(`empty-body`)}catch{}};return r?(0,W.jsxs)(`a`,{className:`art-pdf-fallback`,href:e,download:t,children:[(0,W.jsx)(g,{size:20}),(0,W.jsxs)(`div`,{className:`art-pdf-fallback-text`,children:[(0,W.jsx)(`div`,{className:`art-pdf-fallback-name`,children:t}),(0,W.jsx)(`div`,{className:`art-pdf-fallback-hint`,children:`Your browser can't display this PDF inline. Click to download.`})]}),(0,W.jsx)(ue,{size:16})]}):(0,W.jsx)(`iframe`,{ref:a,className:`art-pdf`,src:e,title:t,"aria-label":`PDF preview of ${t}`,onLoad:l,onError:()=>c(`onerror`)})}var FD={browser:`Browser`,data:`Data`,graph:`Graph`};function ID({selection:e,trigger:t,cacheKey:n,onClose:r,onArtefactSaved:i,onSwapToGraph:a}){let o=e!==null,s=e?.surface??null,c=(0,U.useRef)(null),l=(0,U.useRef)(null),[u,d]=(0,U.useState)(null),p=e?.surface===`doc`?e.docId:null,m=[250,500,1e3,2e3],g=(0,U.useCallback)(e=>{if(!n||!p)return;let t={};try{t=JSON.parse(e)}catch{return}if(t.action!==`save`||typeof t.content!=`string`)return;d(null);let r=t.content,a=e=>{fetch(`/api/admin/sidebar-artefact-save?session_key=${encodeURIComponent(n)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({id:p,content:r})}).then(async t=>{if(t.status===503&&e<m.length){let t=m[e];console.info(`[admin-ui] artefact-save-retry docId=${p} attempt=${e+1} delayMs=${t} status=503`),setTimeout(()=>a(e+1),t);return}if(!t.ok){let n=(await t.json().catch(()=>({}))).error??`status ${t.status}`,r=t.status===503?`retries-exhausted`:`status-${t.status}`;d(`Save failed: ${n}`),console.error(`[admin-ui] artefact-save-failed docId=${p} status=${t.status} attempts=${e+1} source=${r} error="${n}"`);return}let n=await t.json();i?.(p,n.updatedAt,r)}).catch(t=>{let n=t instanceof Error?t.message:String(t);d(`Save failed: ${n}`),console.error(`[admin-ui] artefact-save-failed docId=${p} attempts=${e+1} error="${n}"`)})};a(0)},[n,p,i]);(0,U.useEffect)(()=>{d(null)},[p]),(0,U.useEffect)(()=>{let n=e?.surface===`doc`?e.docId:null,r=e?.surface===`graph`?e.focusNodeId??null:null,i=e?.surface??null,a=i===null?`closed`:`${i}:${n??`none`}:${r??`none`}`;if(a===c.current)return;let s=o?`open`:`closed`,l=o?t??`chat-link`:`toolbar-close`,u=i??c.current?.split(`:`)[0]??`doc`,d=n?` docIdShape=${jD(n)} docIdSample=${n.slice(0,8)}`:``;console.info(`[admin-ui] artefact-pane state=${s} docId=${n??`none`} trigger=${l} surface=${u}${d}`),c.current=a},[e,t,o]);let _=e?.surface===`doc`,v=_?(e.tag||e.name.split(`.`).pop()||`doc`).toUpperCase().slice(0,6):``,y=_?e.revision||`rev 1`:`live`,b=e&&e.surface!==`doc`?FD[e.surface]:``,x=_?e.name:b;return(0,W.jsxs)(`aside`,{className:`artefact`,"data-open":o,"data-surface":s??`none`,children:[(0,W.jsxs)(`div`,{className:`art-head`,children:[(0,W.jsxs)(`div`,{className:`left`,children:[!_&&s===`browser`&&(0,W.jsx)(h,{size:14,className:`art-head-surface-icon`}),!_&&s===`data`&&(0,W.jsx)(ve,{size:14,className:`art-head-surface-icon`}),!_&&s===`graph`&&(0,W.jsx)(ye,{size:14,className:`art-head-surface-icon`}),(0,W.jsx)(`span`,{className:`file-name`,children:x}),_&&(0,W.jsx)(`span`,{className:`file-tag`,children:v})]}),(0,W.jsxs)(`div`,{className:`right`,children:[_&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`button`,{className:`icon-btn`,title:`Copy`,type:`button`,"aria-label":`Copy`,onClick:()=>{L(e.content)},children:(0,W.jsx)(f,{size:14})}),(0,W.jsx)(`button`,{className:`icon-btn`,title:`Refresh`,type:`button`,"aria-label":`Refresh`,children:(0,W.jsx)(ae,{size:14})})]}),s===`browser`&&(0,W.jsx)(`button`,{className:`icon-btn`,title:`Pop out`,type:`button`,"aria-label":`Pop out`,onClick:()=>l.current?.popout(),children:(0,W.jsx)(ze,{size:14})}),o&&(0,W.jsx)(`button`,{className:`icon-btn`,title:`Close`,type:`button`,"aria-label":`Close`,onClick:r,children:(0,W.jsx)(oe,{size:14})})]})]}),(0,W.jsxs)(`div`,{className:`art-toolbar`,children:[(0,W.jsxs)(`span`,{className:`seg`,children:[(0,W.jsx)(`span`,{className:`bullet`}),(0,W.jsx)(`strong`,{children:_?`Artefact`:b})]}),(0,W.jsx)(`span`,{className:`right-meta`,children:y})]}),(0,W.jsxs)(`div`,{className:`art-body`,"data-surface":s??`none`,children:[_&&(()=>{let t=e.editable!==!1,r=e.skipReason??null,i=(e.mimeType??``).startsWith(`application/pdf`);if(r)return(0,W.jsx)(ND,{reason:r});if(i&&n){let t=`/api/admin/sidebar-artefact-content?id=${encodeURIComponent(e.docId)}&session_key=${encodeURIComponent(n)}`;return(0,W.jsx)(PD,{src:t,name:e.name,docId:e.docId},t)}return(0,W.jsxs)(W.Fragment,{children:[u&&(0,W.jsx)(`div`,{className:`art-save-error`,role:`alert`,children:u}),(0,W.jsx)(lT,{data:{title:e.name,content:e.content,readOnly:!t},onSubmit:t?g:kD,submitted:!1})]})})(),s===`browser`&&(0,W.jsx)(TD,{ref:l,onClose:r}),s===`data`&&n&&(0,W.jsx)(fe,{cacheKey:n,onOpenInGraph:a?e=>{let t=pe(e.properties);a(e.nodeId,t??e.labels[0]??null)}:void 0}),e?.surface===`graph`&&n&&(0,W.jsx)(le,{cacheKey:n,initialFocus:e.focusNodeId?{nodeId:e.focusNodeId,nodeLabel:e.focusNodeLabel??null}:null,initialLabels:e.initialLabels??null})]}),(0,W.jsxs)(`div`,{className:`art-foot`,children:[(0,W.jsx)(`span`,{className:`left`,children:y}),(0,W.jsx)(`span`,{className:`right in-sync`,children:`in sync`})]})]})}var LD=`maxy-shell-artefact-px`;function RD(){if(typeof window>`u`)return 320;let e=window.innerWidth,t=document.querySelector(`.platform > .side`)?.getBoundingClientRect(),n=t?t.right:Math.round(e*.3);return BD(Math.round((e-n)*(2/3)))}function zD(){if(typeof window>`u`)return 320;try{let e=window.localStorage.getItem(LD);if(!e)return RD();let t=parseInt(e,10);if(Number.isFinite(t)&&t>=320)return t}catch{}return RD()}function BD(e){if(typeof window>`u`)return e;let t=window.innerWidth,n=document.querySelector(`.platform > .side`)?.getBoundingClientRect(),r=n?n.right:Math.round(t*.3),i=Math.max(320,t-r-480);return Math.min(Math.max(e,320),i)}function VD({targetSelector:e=`.platform`}){let t=(0,U.useRef)(null),[n,r]=(0,U.useState)(()=>zD()),i=(0,U.useRef)(n);(0,U.useEffect)(()=>{let t=document.querySelector(e);!t||!(t instanceof HTMLElement)||(t.style.setProperty(`--artefact-px`,`${n}px`),i.current=n)},[n,e]);let a=(0,U.useCallback)(()=>{r(e=>{let t=BD(e);return t===e?e:t})},[]);(0,U.useEffect)(()=>(a(),window.addEventListener(`resize`,a),()=>window.removeEventListener(`resize`,a)),[a]);let o=e=>{e.preventDefault();let n=t.current;if(!n)return;n.setPointerCapture(e.pointerId),n.classList.add(`dragging`);let a=!1,o=e=>{a=!0,r(BD(Math.round(window.innerWidth-e.clientX)))},s=()=>{if(n.releasePointerCapture(e.pointerId),n.classList.remove(`dragging`),window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),!a)return;let t=i.current;try{window.localStorage.setItem(LD,String(t))}catch{}console.info(`[admin-ui] artefact-resize px=${t}`)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},s=()=>{let e=RD();r(e);try{window.localStorage.removeItem(LD)}catch{}console.info(`[admin-ui] artefact-resize px=${e}`)};return(0,W.jsx)(`div`,{ref:t,className:`art-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize artefact pane`,onPointerDown:o,onDoubleClick:s})}var HD=`maxy-shell-side-px`;function UD(){if(typeof window>`u`)return 0;let e=document.querySelector(`.platform > .artefact`)?.getBoundingClientRect();return e&&e.width>0?Math.round(e.width):0}function WD(e){if(typeof window>`u`)return e;let t=window.innerWidth,n=Math.max(248,t-480-UD());return Math.min(Math.max(e,248),n)}function GD(){if(typeof window>`u`)return 264;try{let e=window.localStorage.getItem(HD);if(!e)return 264;let t=parseInt(e,10);if(Number.isFinite(t)&&t>=248)return WD(t)}catch{}return 264}function KD({targetSelector:e=`.platform`}){let t=(0,U.useRef)(null),[n,r]=(0,U.useState)(()=>GD()),i=(0,U.useRef)(n);(0,U.useEffect)(()=>{let t=document.querySelector(e);!t||!(t instanceof HTMLElement)||(t.style.setProperty(`--side-px`,`${n}px`),i.current=n)},[n,e]);let a=(0,U.useCallback)(()=>{r(e=>{let t=WD(e);return t===e?e:t})},[]);(0,U.useEffect)(()=>{a(),window.addEventListener(`resize`,a);let t=document.querySelector(e),n=null;return t instanceof HTMLElement&&(n=new MutationObserver(a),n.observe(t,{attributes:!0,attributeFilter:[`data-artefact`,`class`]})),()=>{window.removeEventListener(`resize`,a),n?.disconnect()}},[a,e]);let o=e=>{e.preventDefault();let n=t.current;if(!n)return;n.setPointerCapture(e.pointerId),n.classList.add(`dragging`);let a=!1,o=e=>{a=!0,r(WD(Math.round(e.clientX)))},s=()=>{if(n.releasePointerCapture(e.pointerId),n.classList.remove(`dragging`),window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),!a)return;let t=i.current;try{window.localStorage.setItem(HD,String(t))}catch{}console.info(`[admin-ui] sidebar-resize px=${t}`)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},s=()=>{let e=WD(264);r(e);try{window.localStorage.removeItem(HD)}catch{}console.info(`[admin-ui] sidebar-resize px=${e}`)};return(0,W.jsx)(`div`,{ref:t,className:`side-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,onPointerDown:o,onDoubleClick:s})}var qD=50;function JD(e){let[t,n]=(0,U.useState)([]),[r,i]=(0,U.useState)(!1),[a,o]=(0,U.useState)(null),[s,c]=(0,U.useState)(null),l=(0,U.useCallback)(async t=>{if(e&&!(!t&&s===e)){i(!0),o(null);try{let t=await fetch(`/api/admin/sessions?session_key=${encodeURIComponent(e)}`);if(!t.ok)throw Error(`sessions fetch returned ${t.status}`);n((await t.json()).sessions??[]),c(e)}catch(e){console.error(`[admin/sessions] fetch failed:`,e),o(e instanceof Error?e.message:String(e))}finally{i(!1)}}},[e,s]);(0,U.useEffect)(()=>{e||(c(null),n([]),o(null))},[e]);let u=(0,U.useCallback)(()=>l(!1),[l]),d=(0,U.useCallback)(()=>l(!0),[l]),f=(0,U.useRef)(d);return(0,U.useEffect)(()=>{f.current=d},[d]),(0,U.useEffect)(()=>{if(!e)return;let t=null,n=ce(()=>{t&&clearTimeout(t),t=setTimeout(()=>{t=null,f.current()},qD)});return()=>{t&&clearTimeout(t),n()}},[e]),{sessions:t,setSessions:n,loading:r,loaded:s!==null&&s===e,error:a,ensureLoaded:u,refetch:d}}function YD(){St();let e=(0,U.useRef)(null),[t,n]=(0,U.useState)(null),[r,a]=(0,U.useState)(!1),[o,s]=(0,U.useState)(!1),[c,l]=(0,U.useState)(``),[u,d]=(0,U.useState)(!1),[f,p]=(0,U.useState)(null),[g,_]=(0,U.useState)(!1),[v,y]=(0,U.useState)(null),[x,S]=(0,U.useState)(null),[C,w]=(0,U.useState)(!1),[E,D]=(0,U.useState)(null),[O,k]=(0,U.useState)(!1),[A,j]=(0,U.useState)(null),[M,N]=(0,U.useState)(!1),[P,ee]=(0,U.useState)(!1),[te,F]=(0,U.useState)(!1),[I,ne]=(0,U.useState)(!1),re=(0,U.useRef)(!0);(0,U.useEffect)(()=>{if(re.current){re.current=!1;return}ne(!0);let e=window.setTimeout(()=>ne(!1),240);return()=>window.clearTimeout(e)},[te]);let[L,ae]=(0,U.useState)(!1),[z,se]=(0,U.useState)(null),[ce,B]=(0,U.useState)(null),le=(0,U.useRef)(null),[ue,de]=(0,U.useState)(()=>typeof window<`u`&&window.matchMedia(`(min-width: 721px)`).matches);(0,U.useEffect)(()=>{let e=window.matchMedia(`(min-width: 721px)`),t=e=>de(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let[fe,pe]=(0,U.useState)(()=>typeof window<`u`&&window.matchMedia(`(min-width: 1080px)`).matches);(0,U.useEffect)(()=>{let e=window.matchMedia(`(min-width: 1080px)`),t=e=>pe(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let me=(0,U.useRef)(!1),_e=(0,U.useRef)(!1),xe=(0,U.useRef)(!1),Se=(0,U.useRef)(!1),Ce=(0,U.useRef)(null),we=b(),Te=Tt(),V=jt(),Ee=Jt(),De=JD(V.cacheKey),H=qt({cacheKey:V.cacheKey,setCacheKey:V.setCacheKey,setAppState:V.setAppState,conversationId:V.conversationId,setConversationId:V.setConversationId,startElapsedTimer:Te.startElapsedTimer,stopElapsedTimer:Te.stopElapsedTimer,resetTimerState:Te.resetTimerState,pausedElapsedRef:Te.pausedElapsedRef,expandAllDefaultRef:V.expandAllDefaultRef,setExpandAll:V.setExpandAll,getPendingFiles:()=>Ee.pendingFiles,clearPendingFiles:Ee.clearFiles,inputRef:e});(0,U.useEffect)(()=>{l(window.location.hostname.startsWith(`admin.`)?window.location.origin.replace(`admin.`,`public.`):window.location.origin)},[]),(0,U.useEffect)(()=>{function e(e){e.key===`Escape`&&(t?n(null):we.selectionMode&&we.exitSelection())}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,we.selectionMode]),(0,U.useEffect)(()=>{(V.appState===`set-pin`||V.appState===`enter-pin`)&&setTimeout(()=>V.pinInputRef.current?.focus(),100),V.appState===`chat`&&setTimeout(()=>e.current?.focus(),100)},[V.appState,H.greetingGeneration]),(0,U.useEffect)(()=>{if(V.appState!==`chat`)return;history.pushState({maxyChat:!0},``);function e(){console.debug(`[history-guard] popstate absorbed`),history.pushState({maxyChat:!0},``)}return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[V.appState]);let Oe=(0,U.useRef)(H.greetingGeneration);(0,U.useEffect)(()=>{H.greetingGeneration!==Oe.current&&(Oe.current=H.greetingGeneration,V.onboardingComplete===!1&&(me.current=!1))},[H.greetingGeneration,V.onboardingComplete]),(0,U.useEffect)(()=>{V.appState===`chat`&&V.onboardingComplete===!1&&(me.current||(me.current=!0,H.sendSystemPrompt(`[Begin onboarding.]`)))},[V.appState,V.onboardingComplete,H.greetingGeneration]),(0,U.useEffect)(()=>{if(!u)return;let e=!1;return fetch(`/api/admin/version`).then(e=>e.json()).then(t=>{e||D(t)}).catch(e=>{console.error(`[admin/version] menu-open client fetch failed:`,e)}),()=>{e=!0}},[u]),(0,U.useEffect)(()=>{if(V.appState!==`chat`){xe.current=!1,Se.current=!1;return}if(xe.current)return;xe.current=!0;let e=!1;return fetch(`/api/admin/version`).then(e=>e.json()).then(t=>{e||(D(t),!(!t.updateAvailable||Se.current)&&(j(t),k(!0),fetch(`/api/admin/version/alert-surfaced`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({installed:t.installed,latest:t.latest})}).catch(e=>{console.error(`[admin/version] alert-surfaced signal failed:`,e)})))}).catch(e=>{console.error(`[admin/version] session-start client fetch failed:`,e)}),()=>{e=!0}},[V.appState]),(0,U.useEffect)(()=>{if(V.appState!==`chat`||!V.cacheKey)return;let e=V.conversationId?`flushed`:`pre-flush`,t=V.cacheKey.slice(0,8),n=V.conversationId?V.conversationId.slice(0,8):`null`;console.info(`[admin-session-identity] cacheKey=${t} conversationId=${n} phase=${e} surface=chat-header`)},[V.appState,V.cacheKey,V.conversationId]),(0,U.useEffect)(()=>{if(V.appState!==`chat`){_e.current=!1;return}if(_e.current||!De.loaded)return;_e.current=!0;let e=De.sessions.filter(e=>e.name).length,t=z?`open`:`closed`;console.info(`[admin-ui] platform-shell brand=${R.productName} sidebar=${e} artefact=${t}`)},[V.appState,De.loaded,De.sessions,z]);let ke=De.sessions.find(e=>V.conversationId&&e.conversationId===V.conversationId||V.cacheKey&&e.cacheKey===V.cacheKey)?.name||V.businessName||(R.logoContainsName?``:R.productName);(0,U.useEffect)(()=>{if(!u){p(null),y(null),S(null),D(null);return}function e(e){Ce.current&&!Ce.current.contains(e.target)&&d(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[u]),(0,U.useEffect)(()=>{if(typeof BroadcastChannel>`u`)return;let e=new BroadcastChannel(`platform-onboarding`);return e.onmessage=e=>{e.data?.type===`remote-password-set`&&H.sendMessageRef.current(`I've set the remote password`)},()=>e.close()},[]);let Ae=(0,U.useCallback)(e=>{V.cacheKey&&fetch(`/api/admin/sessions/${encodeURIComponent(e)}/resume?session_key=${encodeURIComponent(V.cacheKey)}`,{method:`POST`}).then(e=>e.ok?e.json():Promise.reject(Error(`resume returned ${e.status}`))).then(e=>{e.conversationId&&V.setConversationId(e.conversationId);let t=(e.messages??[]).map(e=>({role:e.role===`user`?`admin`:`maxy`,content:e.role===`user`?e.content:void 0,events:e.role===`assistant`?e.events??[]:void 0,...e.role===`user`&&e.attachments&&e.attachments.length>0?{attachments:e.attachments}:{},...e.role===`user`&&oD(e.content)?{hidden:!0}:{},timestamp:new Date(e.createdAt).getTime()||0,historical:!0,...e.messageId?{messageId:e.messageId}:{}}));if(t.length>0&&H.setMessages(t),e.resumeHeal){let{missingTurns:n,failed:r,jsonlMissing:i}=e.resumeHeal,a;r>0?a=`Could not heal ${r} of ${n} turn${n===1?``:`s`} that were missing from the graph. The JSONL replay rendered them above so the conversation is intact, but they may not appear in future searches until the writer recovers.`:i&&t.length>0&&(a=`This conversation's SDK transcript file is no longer on disk; the conversation is rendered from the graph projection. The next message you send will start a fresh SDK session under the same conversation.`),a&&H.setMessages(e=>[{role:`maxy`,events:[{type:`text`,content:a}],timestamp:Date.now()-2,historical:!0},...e])}let n=[];for(let t of e.messages??[]){if(t.role!==`assistant`||!t.submittedEventIndices?.length)continue;let e=new Date(t.createdAt).getTime()||0;for(let r of t.submittedEventIndices)n.push(`${e}_${r}`)}n.length>0&&H.seedSubmittedComponents(n)}).catch(e=>{console.error(`[chat] sidebar conversation resume failed:`,e),H.setMessages([{role:`maxy`,events:[{type:`text`,content:`Could not load conversation history.`}],timestamp:Date.now()-1,historical:!0}])})},[V.cacheKey,V.setConversationId,H.setMessages,H.seedSubmittedComponents]),je=(0,U.useRef)(null);if((0,U.useEffect)(()=>{V.appState===`chat`&&(!V.cacheKey||!V.conversationId||H.messages.length>0||je.current!==V.cacheKey&&(je.current=V.cacheKey,Ae(V.conversationId)))},[V.appState,V.cacheKey,V.conversationId,H.messages.length,Ae]),V.appState===`loading`)return(0,W.jsx)(`div`,{className:`chat-page admin-page`,children:(0,W.jsx)(`header`,{className:`chat-header`,children:(0,W.jsx)(`img`,{src:ie,alt:R.productName,className:`chat-logo`})})});if(V.appState===`set-pin`)return(0,W.jsx)(Xt,{pin:V.pin,setPin:V.setPin,confirmPin:V.confirmPin,setConfirmPin:V.setConfirmPin,operatorName:V.operatorName,setOperatorName:V.setOperatorName,showPin:V.showPin,setShowPin:V.setShowPin,pinLoading:V.pinLoading,pinError:V.pinError,pinInputRef:V.pinInputRef,confirmPinInputRef:V.confirmPinInputRef,setPinFormRef:V.setPinFormRef,onSubmit:V.handleSetPin});if(V.appState===`onboarding-choice`)return(0,W.jsx)(en,{setAppState:V.setAppState,setOnboardingComplete:V.setOnboardingComplete});if(V.appState===`connect-claude`)return(0,W.jsx)($t,{authPolling:V.authPolling,setAuthPolling:V.setAuthPolling,authLoading:V.authLoading,setAuthLoading:V.setAuthLoading,pinError:V.pinError,setPinError:V.setPinError,setAppState:V.setAppState});if(V.appState===`enter-pin`)return(0,W.jsx)(Zt,{pin:V.pin,setPin:V.setPin,showPin:V.showPin,setShowPin:V.setShowPin,pinLoading:V.pinLoading,pinError:V.pinError,pinInputRef:V.pinInputRef,onSubmit:V.handleLogin,onChangePin:V.handleChangePin,remoteAuthEnabled:V.remoteAuthEnabled,onSignOutRemote:()=>{window.location.href=`/__remote-auth/logout`}});if(V.appState===`account-picker`)return(0,W.jsx)(Qt,{accounts:V.accounts,loading:V.accountPickerLoading,error:V.pinError,onSelect:V.handleAccountSelect});let Me=z?`open`:`closed`,Ne=L&&ue,Pe=`platform${te?` menu-open`:``}${Ne?` sidebar-collapsed`:``}${I?` drawer-animating`:``}`,Fe=e=>{if(!H.isStreaming&&V.cacheKey){if(!e.conversationId){H.resetConversation(),H.setMessages([]),V.setConversationId(null);return}H.resetConversation(),H.setMessages([]),Ae(e.conversationId)}},Ie={conversationId:V.conversationId,cacheKey:V.cacheKey,disconnecting:V.disconnecting,onOpenConversations:()=>{w(!0),De.refetch()},handleDisconnect:V.handleDisconnect};return(0,W.jsx)(T,{value:{onShowVnc:()=>N(!0)},children:(0,W.jsxs)(`div`,{className:Pe,"data-artefact":Me,children:[(0,W.jsx)(`div`,{className:`scrim`,onClick:()=>{F(!1),console.info(`[admin-ui] mobile-drawer state=closed`)}}),(0,W.jsx)(OD,{ref:le,businessName:V.businessName??null,cacheKey:V.cacheKey,conversationId:V.conversationId,role:V.role,userName:V.userName,userAvatar:V.userAvatar,sessions:De.sessions,sessionsLoading:De.loading,sessionsError:De.error,ensureSessionsLoaded:De.ensureLoaded,refetchSessions:De.refetch,recentsActions:{setSessions:De.setSessions,isStreaming:H.isStreaming,resetConversation:H.resetConversation,setMessages:H.setMessages,setConversationId:V.setConversationId,setCacheKey:V.setCacheKey},onSelectSession:Fe,onSelectArtefact:(e,t)=>{se({surface:`doc`,...e}),B(t)},onSelectProjects:()=>{se({surface:`graph`,initialLabels:[`Project`]}),B(`sidebar-projects`)},onSelectPeople:()=>{se({surface:`graph`,initialLabels:[`Person`]}),B(`sidebar-people`)},onSelectTasks:()=>{se({surface:`graph`,initialLabels:[`Task`]}),B(`sidebar-tasks`)},onSelectAgents:()=>{se({surface:`graph`,initialLabels:[`Agent`]}),B(`sidebar-agents`)},onCloseMobileDrawer:()=>{te&&(F(!1),console.info(`[admin-ui] mobile-drawer state=closed`))},collapsed:Ne,onToggleCollapsed:()=>ae(e=>!e),mobileDrawerOpen:te,actions:Ie}),(0,W.jsxs)(`div`,{className:`chat-page admin-page`,children:[(0,W.jsxs)(`header`,{className:`chat-header`,children:[(0,W.jsx)(`button`,{type:`button`,className:`chat-logo-btn`,"aria-label":`Show sidebar`,title:`Show sidebar`,onClick:()=>{F(e=>{let t=!e;return console.info(`[admin-ui] header-logo-tap state=${t?`open`:`closed`}`),t})},children:(0,W.jsx)(`img`,{src:ie,alt:R.productName,className:`chat-logo`})}),(0,W.jsx)(`div`,{className:`chat-header-label`,children:(0,W.jsx)(`h1`,{className:`chat-tagline`,children:ke})}),(0,W.jsxs)(`div`,{className:`chat-burger-wrap`,ref:Ce,children:[(0,W.jsx)(`button`,{type:`button`,className:`chat-burger`,onClick:()=>d(e=>!e),"aria-label":`Menu`,"aria-haspopup":`true`,"aria-expanded":u,children:(0,W.jsx)(ge,{size:20})}),u&&(0,W.jsxs)(`div`,{className:`chat-menu`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:async()=>{if(!P&&!(!fe&&M)){ee(!0),d(!1);try{let e=await(await fetch(`/api/admin/browser/launch`,{method:`POST`})).json().catch(()=>({ok:!1,error:`Invalid response`}));if(!e.ok)throw Error(e.error??`Failed to launch browser`);fe?(se({surface:`browser`}),B(`header-menu`)):N(!0)}catch(e){console.error(`[browser] Launch failed:`,e),alert(e instanceof Error?e.message:`Failed to launch browser`)}finally{ee(!1)}}},disabled:P,children:[(0,W.jsx)(h,{size:14}),` Browser`,P&&(0,W.jsx)(he,{size:12,className:`spin`})]}),(0,W.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{d(!1),fe?(se({surface:`data`}),B(`header-menu`)):window.location.href=`/data`},children:[(0,W.jsx)(ve,{size:14}),` Data`]}),(0,W.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{d(!1),fe?(se({surface:`graph`}),B(`header-menu`)):window.location.href=`/graph`},children:[(0,W.jsx)(ye,{size:14}),` Graph`]}),(0,W.jsx)(`div`,{className:`chat-menu-divider`}),(0,W.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:async()=>{if(f!==null){p(null),S(null);return}_(!0),y(null);try{let e=await fetch(`/api/admin/agents`);if(!e.ok)throw Error(`Failed to load agents`);p((await e.json()).agents??[])}catch(e){console.error(`[admin] agent list failed:`,e),y(e instanceof Error?e.message:String(e))}finally{_(!1)}},children:[(0,W.jsx)(ze,{size:14}),` Public`,g&&(0,W.jsx)(he,{size:12,className:`spin`})]}),f!==null&&(0,W.jsxs)(`div`,{className:`chat-menu-agents`,children:[v&&(0,W.jsx)(`span`,{className:`chat-menu-agent-error`,children:v}),f.length===0&&!v&&(0,W.jsx)(`span`,{className:`chat-menu-agent-empty`,children:`No public agents configured`}),f.map(e=>(0,W.jsxs)(`div`,{className:`chat-menu-item chat-menu-agent-item`,children:[(0,W.jsx)(`span`,{className:`agent-status-dot ${e.status}`}),(0,W.jsxs)(`span`,{className:`agent-text`,children:[(0,W.jsx)(`span`,{className:`agent-display-name`,children:e.displayName}),(0,W.jsxs)(`span`,{className:`agent-slug`,children:[`/`,e.slug]})]}),x===e.slug?(0,W.jsxs)(`span`,{className:`agent-actions agent-confirm`,children:[(0,W.jsx)(`button`,{type:`button`,className:`agent-action-btn agent-confirm-yes`,title:`Confirm delete`,onClick:()=>{S(null),p(t=>t?.filter(t=>t.slug!==e.slug)??null),fetch(`/api/admin/agents/${encodeURIComponent(e.slug)}`,{method:`DELETE`}).catch(e=>console.error(`[admin/agents] delete failed:`,e))},children:(0,W.jsx)(m,{size:12})}),(0,W.jsx)(`button`,{type:`button`,className:`agent-action-btn agent-confirm-no`,title:`Cancel`,onClick:()=>S(null),children:(0,W.jsx)(oe,{size:12})})]}):(0,W.jsxs)(`span`,{className:`agent-actions`,children:[(0,W.jsx)(`a`,{href:`${c}/${e.slug}`,target:`_blank`,rel:`noopener noreferrer`,className:`agent-action-btn`,title:`Open agent`,onClick:()=>d(!1),children:(0,W.jsx)(ze,{size:12})}),(0,W.jsx)(`button`,{type:`button`,className:`agent-action-btn agent-delete-btn`,title:`Delete agent`,onClick:()=>S(e.slug),children:(0,W.jsx)(i,{size:12})})]})]},e.slug))]}),(0,W.jsx)(`div`,{className:`chat-menu-divider`}),E?.updateAvailable?(0,W.jsxs)(`button`,{type:`button`,className:`chat-menu-version`,onClick:()=>{E.latest&&(j(E),d(!1),k(!0))},children:[(0,W.jsx)(Je,{size:14}),(0,W.jsxs)(`span`,{className:`version-installed`,children:[`v`,E.installed,(0,W.jsx)(`span`,{className:`version-update-dot`})]})]}):(0,W.jsxs)(`div`,{className:`chat-menu-version chat-menu-version-passive`,children:[(0,W.jsx)(Je,{size:14}),(0,W.jsxs)(`span`,{className:`version-installed`,children:[E?`v${E.installed}`:`…`,E&&!E.updateAvailable&&(0,W.jsx)(`span`,{className:`version-uptodate-dot`})]})]}),(0,W.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,"data-testid":`report-turn`,onClick:async()=>{d(!1);let e=await H.reportTurn();e.ok||console.warn(`[admin-chat] report-turn failed:`,e.payload)},children:[(0,W.jsx)(Je,{size:14}),` Report this turn`]}),(0,W.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{d(!1),V.handleLogout(),H.setMessages([])},children:[(0,W.jsx)(be,{size:14}),` Log out`]})]})]})]}),(0,W.jsxs)(`div`,{className:`chat-content`,children:[(0,W.jsx)($E,{messages:H.messages,isStreaming:H.isStreaming,elapsedSeconds:Te.elapsedSeconds,sessionTurnStart:Te.sessionTurnStart,expandAll:V.expandAll,setExpandAll:V.setExpandAll,conversationCompacted:H.conversationCompacted,isCompacting:H.isCompacting,setShowCompactConfirm:s,handleComponentSubmit:H.handleComponentSubmit,effectiveSubmitted:H.effectiveSubmitted,selectionMode:we.selectionMode,selectedItems:we.selectedItems,toggleSelectItem:we.toggleSelectItem,cacheKey:V.cacheKey,setLightboxSrc:n,messageQueue:H.messageQueue,messageQueueRef:H.messageQueueRef,setQueue:H.setQueue,sendMessage:H.sendMessage,appState:V.appState,onboardingComplete:V.onboardingComplete,onOpenArtefact:e=>{se({surface:`doc`,...e}),B(`chat-link`)}}),(0,W.jsx)(eD,{offer:H.topicChangeOffer,onFreshStart:H.handleTopicFreshStart,onContinue:H.handleTopicContinue,disabled:H.isStreaming}),(0,W.jsx)(SD,{selectionMode:we.selectionMode,selectedItems:we.selectedItems,copyToast:we.copyToast||null,exitSelection:we.exitSelection,enterSelection:we.enterSelection,copySelected:we.copySelected,showCopyToast:we.showCopyToast,input:H.input,setInput:H.setInput,inputRef:e,pendingFiles:Ee.pendingFiles,setPendingFiles:Ee.setPendingFiles,isDragOver:Ee.isDragOver,attachError:Ee.attachError,fileInputRef:Ee.fileInputRef,addFiles:Ee.addFiles,removeFile:Ee.removeFile,onDragOver:Ee.onDragOver,onDragLeave:Ee.onDragLeave,onDrop:Ee.onDrop,isStreaming:H.isStreaming,wasPaused:H.wasPaused,messages:H.messages,messageQueueRef:H.messageQueueRef,setQueue:H.setQueue,sendMessage:H.sendMessage,stopStreaming:H.stopStreaming,disconnecting:V.disconnecting,handleDisconnect:V.handleDisconnect,claudeInfo:V.claudeInfo,setClaudeInfo:V.setClaudeInfo,setShowClaudeInfo:a,conversationId:V.conversationId,cacheKey:V.cacheKey,onNewConversation:H.startNewConversation,newConversationDisabled:H.isStreaming||H.isCompacting,onOpenConversations:()=>{w(!0),De.refetch()},sidebarVisible:ue})]}),we.copyToast&&(0,W.jsx)(`span`,{className:`copy-toast${we.copyToast===`failed`?` copy-toast-failed`:``}`,children:we.copyToast===`copied`?`Copied`:`Copy failed`}),(0,W.jsx)(mD,{show:C,onClose:()=>w(!1),conversationsLoading:De.loading,conversationsError:De.error,conversationsList:De.sessions,setConversationsList:De.setSessions,cacheKey:V.cacheKey,setCacheKey:V.setCacheKey,isStreaming:H.isStreaming,resetConversation:H.resetConversation,setMessages:H.setMessages,setConversationId:V.setConversationId}),(0,W.jsx)(hD,{src:t,onClose:()=>n(null)}),(0,W.jsx)(gD,{show:o,onClose:()=>s(!1),onConfirm:H.handleCompactNow}),(0,W.jsx)(_D,{show:r,onClose:()=>{a(!1),V.setClaudeInfo(null)},claudeInfo:V.claudeInfo,messages:H.messages,sessionElapsed:Te.sessionElapsed,conversationId:V.conversationId,cacheKey:V.cacheKey}),(0,W.jsx)(bD,{show:O,onClose:()=>{k(!1),Se.current=!0},versionInfo:A,cacheKey:V.cacheKey,onUpgradeComplete:()=>D(null)}),M&&(0,W.jsx)(ED,{onClose:()=>N(!1)})]}),(0,W.jsx)(KD,{}),(0,W.jsx)(VD,{}),(0,W.jsx)(ID,{selection:z,trigger:ce,cacheKey:V.cacheKey,onClose:()=>{se(null),B(null)},onArtefactSaved:(e,t,n)=>{le.current?.patchArtefact(e,{updatedAt:t,content:n})},onSwapToGraph:(e,t)=>{se({surface:`graph`,focusNodeId:e,focusNodeLabel:t}),B(`chat-link`)}})]})})}(0,Se.createRoot)(document.getElementById(`root`)).render((0,W.jsx)(YD,{}));
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Maxy</title>
|
|
7
7
|
<link rel="icon" href="/favicon.ico">
|
|
8
|
-
<script type="module" crossorigin src="/assets/admin-
|
|
8
|
+
<script type="module" crossorigin src="/assets/admin-BGhZNd6Q.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/chunk-DD-I1_y5.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/jsx-runtime-vPsBTwUp.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/preload-helper-qlgyTAkD.js">
|