@rubytech/create-realagent 1.0.690 → 1.0.691

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rubytech/create-realagent",
3
- "version": "1.0.690",
3
+ "version": "1.0.691",
4
4
  "description": "Install Real Agent — Built for agents. By agents.",
5
5
  "bin": {
6
6
  "create-realagent": "./dist/index.js"
@@ -349,4 +349,4 @@ ${JSON.stringify(u.input,null,2)}`,f=se.get(r),p=o?void 0:f??t;return(0,B.jsx)(g
349
349
 
350
350
  ---
351
351
 
352
- `)}function SE(e){let{selectionMode:t,selectedItems:n,copyToast:r,exitSelection:i,enterSelection:a,copySelected:o,showCopyToast:s,input:c,setInput:l,inputRef:f,pendingFiles:g,setPendingFiles:y,isDragOver:b,attachError:x,fileInputRef:S,addFiles:C,removeFile:w,onDragOver:T,onDragLeave:A,onDrop:j,isStreaming:N,wasPaused:P,messages:te,messageQueueRef:ne,setQueue:re,sendMessage:ie,stopStreaming:ae,disconnecting:se,handleDisconnect:ce,claudeInfo:le,setClaudeInfo:de,setShowClaudeInfo:fe,conversationId:pe,onNewConversation:me,newConversationDisabled:he,onOpenConversations:ge}=e,[_e,I]=(0,z.useState)(!1),L=(0,z.useRef)(null),[ye,R]=(0,z.useState)(!1),be=(0,z.useRef)(null),xe=(0,z.useRef)(!1),Se=F(),Ce=Se.state===`recording`||Se.state===`paused`||Se.state===`sending`,we=!Ce&&!P&&!c.trim()&&g.length===0;async function Te(){let e=await Se.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(N){re([...ne.current,{text:`[Voice note]`,files:[n],timestamp:Date.now()}]);return}ie(`[Voice note]`,[n])}return(0,z.useEffect)(()=>{t||R(!1)},[t]),(0,z.useEffect)(()=>{if(!ye)return;let e=e=>{e.target.closest(`.selection-copy-wrap`)||R(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[ye]),(0,z.useEffect)(()=>{if(!_e)return;let e=e=>{if(e.key===`Escape`){I(!1);return}if(e.key===`Tab`&&L.current){let t=L.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=>{L.current&&!L.current.contains(e.target)&&I(!1)};return document.addEventListener(`keydown`,e),document.addEventListener(`mousedown`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`mousedown`,t)}},[_e]),t?(0,B.jsx)(`div`,{className:`chat-input-area`,children:(0,B.jsxs)(`div`,{className:`selection-bar`,children:[(0,B.jsxs)(`span`,{className:`selection-count`,children:[n.size,` Selected`]}),(0,B.jsxs)(`div`,{className:`selection-copy-wrap`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`selection-copy`,onPointerDown:()=>{if(ye){R(!1);return}xe.current=!1,be.current=setTimeout(()=>{xe.current=!0,R(!0),be.current=null},500)},onPointerUp:()=>{be.current!==null&&(clearTimeout(be.current),be.current=null)},onPointerLeave:()=>{be.current!==null&&(clearTimeout(be.current),be.current=null)},onPointerCancel:()=>{be.current!==null&&(clearTimeout(be.current),be.current=null)},onClick:async()=>{xe.current||await o(e=>bE(te,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,B.jsx)(m,{size:18}),(0,B.jsx)(`span`,{children:`Copy`})]}),ye&&(0,B.jsx)(`div`,{className:`copy-menu`,children:[[`all`,`All events`],[`text`,`Text messages only`],[`non-text`,`Non-text only`]].map(([e,t])=>(0,B.jsx)(`button`,{type:`button`,className:`copy-menu-item`,onClick:async()=>{let t=xE(te,e);t&&s(await _(t)),i()},children:t},e))})]}),(0,B.jsx)(`button`,{type:`button`,className:`selection-cancel`,onClick:i,children:`Cancel`})]})}):(0,B.jsxs)(`div`,{className:`chat-input-area`,children:[(0,B.jsx)(`input`,{ref:S,type:`file`,multiple:!0,accept:dt,style:{display:`none`},onChange:e=>{e.target.files&&C([...e.target.files]),e.target.value=``}}),g.length>0&&(0,B.jsx)(`div`,{className:`attachment-strip`,children:g.map((e,t)=>(0,B.jsxs)(`div`,{className:`attachment-chip`,children:[e.type.startsWith(`image/`)?(0,B.jsx)(`img`,{src:URL.createObjectURL(e),alt:e.name,className:`attachment-chip-thumb`}):e.type===`application/pdf`?(0,B.jsx)(O,{size:14}):(0,B.jsx)(p,{size:14}),(0,B.jsx)(`span`,{className:`attachment-chip-name`,children:e.name}),(0,B.jsx)(`button`,{type:`button`,className:`attachment-chip-remove`,onClick:()=>w(t),"aria-label":`Remove ${e.name}`,children:`×`})]},t))}),x&&(0,B.jsx)(`p`,{className:`attach-error`,children:x}),Se.state===`error`&&Se.errorMessage&&(0,B.jsxs)(`p`,{className:`voice-error`,role:`alert`,children:[(0,B.jsx)(k,{size:14}),Se.errorMessage]}),(0,B.jsx)(D,{inputRef:f}),Ce?(0,B.jsx)(`div`,{className:`chat-form voice-active`,children:(0,B.jsx)(M,{state:Se.state,elapsedSeconds:Se.elapsedSeconds,waveform:Se.waveform,onTogglePause:Se.togglePause,onDiscard:Se.discard,onSend:Te})}):(0,B.jsxs)(`form`,{className:`chat-form${b?` drag-over`:``}`,onSubmit:e=>{e.preventDefault();let t=c.trim()||(P?`continue`:``);if(!(!t&&g.length===0)){if(N){re([...ne.current,{text:t,files:[...g],timestamp:Date.now()}]),l(``),y([]),f.current?.resetHeight();return}ie(t),f.current?.resetHeight()}},onDragOver:T,onDragLeave:A,onDrop:j,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&&C(n)},children:[(0,B.jsx)(E,{variant:`icon`,type:`button`,onClick:()=>S.current?.click(),"aria-label":`Attach file`,children:(0,B.jsx)(h,{size:14})}),(0,B.jsx)(ee,{ref:f,value:c,onChange:l}),N?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(E,{variant:`send`,type:`button`,onClick:()=>ae(!0),"aria-label":`Pause`,style:{background:`var(--text-secondary)`},children:(0,B.jsx)(u,{size:14})}),(0,B.jsx)(E,{variant:`send`,type:`button`,onClick:()=>ae(!1),"aria-label":`Stop`,style:{background:`var(--danger)`},children:(0,B.jsx)(et,{size:14})})]}):we?(0,B.jsx)(E,{variant:`send`,type:`button`,onClick:Se.start,"aria-label":`Record voice note`,children:(0,B.jsx)(k,{size:14})}):(0,B.jsx)(E,{variant:`send`,type:`submit`,disabled:!c.trim()&&g.length===0&&!P,"aria-label":`Send message`,children:P?(0,B.jsx)(d,{size:14}):(0,B.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,B.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,B.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,B.jsxs)(`div`,{className:`chat-actions`,ref:L,children:[(0,B.jsx)(`button`,{className:`burger-trigger`,onClick:()=>I(e=>!e),"aria-expanded":_e,"aria-haspopup":`true`,"aria-label":`Actions menu`,children:(0,B.jsx)(ue,{size:16})}),(0,B.jsxs)(`div`,{className:`actions-menu-items${_e?` actions-menu-open`:``}`,children:[(0,B.jsxs)(`button`,{className:`chat-action`,disabled:he,onClick:()=>{I(!1),me()},children:[(0,B.jsx)(Ne,{size:14}),(0,B.jsx)(`span`,{className:`action-label`,children:`New conversation`})]}),(0,B.jsxs)(`button`,{className:`chat-action`,onClick:()=>{I(!1),ge()},children:[(0,B.jsx)(Ve,{size:14}),(0,B.jsx)(`span`,{className:`action-label`,children:`Conversations`})]}),(0,B.jsxs)(`button`,{className:`chat-action`,disabled:se,onClick:async()=>{I(!1),await ce()},children:[se?(0,B.jsx)(oe,{size:14,className:`animate-spin`}):(0,B.jsx)(ve,{size:14}),(0,B.jsx)(`span`,{className:`action-label`,children:se?`Disconnecting...`:`Disconnect Claude`})]}),(0,B.jsxs)(`button`,{className:`chat-action`,disabled:!pe,onClick:()=>{if(I(!1),!pe){console.debug(`[stream-log-button] disabled reason=no-conversation-id`);return}let e=document.createElement(`a`);e.href=`/api/admin/logs?type=stream&conversationId=${encodeURIComponent(pe)}&download=1`,e.click()},title:pe?`Download stream log`:`No conversation active — start a message to create a stream log`,children:[(0,B.jsx)(Ze,{size:14}),(0,B.jsx)(`span`,{className:`action-label`,children:`Stream log`})]}),(0,B.jsxs)(`button`,{className:`chat-action`,onClick:()=>{I(!1),a()},title:`Select messages`,children:[(0,B.jsx)(v,{size:14}),(0,B.jsx)(`span`,{className:`action-label`,children:`Select`})]})]}),(0,B.jsxs)(`div`,{className:`powered-by`,onClick:async()=>{if(fe(!0),!le){let e=await fetch(`/api/admin/claude-info`);e.ok&&de(await e.json())}},children:[(0,B.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`powered-by-icon`}),(0,B.jsx)(`span`,{children:`Powered by Claude Code`})]})]})]})}function CE(e){let{show:t,onClose:n,conversationsLoading:r,conversationsError:a,conversationsList:o,setConversationsList:s,sessionKey:c,isStreaming:l,resetConversation:u,setMessages:p,setConversationId:m}=e,[h,g]=(0,z.useState)(null),[_,v]=(0,z.useState)(null),[y,b]=(0,z.useState)(``),[x,S]=(0,z.useState)(!1),C=(0,z.useRef)(null);(0,z.useEffect)(()=>{t||(g(null),v(null),b(``),S(!1))},[t]),(0,z.useEffect)(()=>{_?.phase===`editing`&&(C.current?.focus(),C.current?.select())},[_]);function w(){g(null),v(null),b(``),S(!1)}async function T(e){if(c){w(),g(e),v({phase:`loading`});try{let t=await fetch(`/api/admin/sessions/${encodeURIComponent(e)}/label?session_key=${encodeURIComponent(c)}`,{method:`POST`});if(!t.ok){v({phase:`error`,reason:(await t.json().catch(()=>({}))).error||`Request failed`});return}let n=await t.json();n.label?(v({phase:`editing`}),b(n.label)):v({phase:`error`,reason:`Not enough message content to suggest a name`})}catch(e){console.error(`[admin-modal] label suggestion failed:`,e),v({phase:`error`,reason:e instanceof Error?e.message:String(e)})}}}async function E(e){if(!(!c||!y.trim()||x)){S(!0);try{let t=await fetch(`/api/admin/sessions/${encodeURIComponent(e)}/label`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({label:y.trim(),session_key:c})});if(!t.ok){v({phase:`error`,reason:(await t.json().catch(()=>({}))).error||`Rename failed`}),S(!1);return}s(t=>t.map(t=>t.conversationId===e?{...t,name:y.trim()}:t)),w()}catch(e){console.error(`[admin-modal] label rename failed:`,e),v({phase:`error`,reason:e instanceof Error?e.message:String(e)}),S(!1)}}}return t?(0,B.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,B.jsxs)(`div`,{className:`claude-info-modal conversations-modal`,onClick:e=>e.stopPropagation(),children:[(0,B.jsxs)(`div`,{className:`claude-info-header`,children:[(0,B.jsx)(Ve,{size:12}),`Conversations`,(0,B.jsx)(`button`,{className:`claude-info-close`,onClick:n,children:`✕`})]}),(0,B.jsxs)(`div`,{className:`conversations-list`,children:[r&&(0,B.jsxs)(`div`,{className:`conversations-empty`,children:[(0,B.jsx)(oe,{size:14,className:`spin`}),` Loading…`]}),a&&(0,B.jsx)(`div`,{className:`conversations-empty conversations-error`,children:a}),!r&&!a&&o.length===0&&(0,B.jsx)(`div`,{className:`conversations-empty`,children:`No recent conversations`}),!r&&!a&&o.map(e=>{let t=h===e.conversationId,r=t&&_?.phase===`loading`,a=t&&_?.phase===`editing`,o=t&&_?.phase===`error`;return(0,B.jsxs)(`div`,{className:`conversations-row`,children:[(0,B.jsxs)(`div`,{className:`conversations-row-info`,children:[r&&(0,B.jsxs)(`span`,{className:`conversations-row-name conversations-edit-loading`,children:[(0,B.jsx)(oe,{size:12,className:`spin`}),` Generating suggestion…`]}),a&&(0,B.jsxs)(`div`,{className:`conversations-edit-inline`,children:[(0,B.jsx)(`input`,{ref:C,type:`text`,className:`conversations-edit-input`,value:y,onChange:e=>b(e.target.value),onKeyDown:t=>{t.key===`Enter`&&y.trim()&&E(e.conversationId),t.key===`Escape`&&w()},maxLength:200}),(0,B.jsx)(`button`,{type:`button`,className:`conversations-action conversations-confirm`,title:`Confirm rename`,disabled:!y.trim()||x,onClick:()=>E(e.conversationId),children:x?(0,B.jsx)(oe,{size:13,className:`spin`}):(0,B.jsx)(f,{size:13})}),(0,B.jsx)(`button`,{type:`button`,className:`conversations-action conversations-cancel`,title:`Cancel`,onClick:w,children:(0,B.jsx)(he,{size:13})})]}),o&&(0,B.jsxs)(`div`,{className:`conversations-edit-inline`,children:[(0,B.jsx)(`span`,{className:`conversations-edit-error`,children:_.reason}),(0,B.jsx)(`button`,{type:`button`,className:`conversations-action conversations-retry`,title:`Retry`,onClick:()=>T(e.conversationId),children:(0,B.jsx)(me,{size:13})}),(0,B.jsx)(`button`,{type:`button`,className:`conversations-action conversations-cancel`,title:`Cancel`,onClick:w,children:(0,B.jsx)(he,{size:13})})]}),!t&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`conversations-row-name`,children:e.name||e.conversationId.slice(0,12)+`…`}),(0,B.jsxs)(`span`,{className:`conversations-row-meta`,children:[(0,B.jsx)(`span`,{className:`conversations-row-id`,children:e.conversationId.slice(0,8)}),(0,B.jsxs)(`span`,{className:`conversations-row-time`,children:[(0,B.jsx)(we,{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``}})()]})]})]})]}),(0,B.jsx)(`div`,{className:`conversations-row-actions`,children:!t&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`button`,{type:`button`,className:`conversations-action conversations-rename`,title:`Rename conversation`,onClick:()=>T(e.conversationId),children:(0,B.jsx)(Ye,{size:13})}),(0,B.jsx)(`button`,{type:`button`,className:`conversations-action conversations-play`,title:`Resume conversation`,disabled:l,onClick:()=>{l||!c||(n(),u(),fetch(`/api/admin/sessions/${encodeURIComponent(e.conversationId)}/resume?session_key=${encodeURIComponent(c)}`,{method:`POST`}).then(e=>e.ok?e.json():Promise.reject(Error(`Failed to resume conversation`))).then(e=>{e.conversationId&&m(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`?[{type:`text`,content:e.content}]:void 0,timestamp:new Date(e.createdAt).getTime()||0,historical:!0}));t.length>0&&p(t)}).catch(e=>{console.error(`[chat] conversation resume failed:`,e),p([{role:`maxy`,events:[{type:`text`,content:`Could not load conversation history.`}],timestamp:Date.now()-1,historical:!0}])}))},children:(0,B.jsx)(d,{size:13})}),(0,B.jsx)(`button`,{type:`button`,className:`conversations-action conversations-delete`,title:`Delete conversation`,onClick:()=>{s(t=>t.filter(t=>t.conversationId!==e.conversationId)),c&&fetch(`/api/admin/sessions/${encodeURIComponent(e.conversationId)}?session_key=${encodeURIComponent(c)}`,{method:`DELETE`}).catch(e=>console.error(`[chat] conversation delete failed:`,e))},children:(0,B.jsx)(i,{size:13})})]})})]},e.conversationId)})]})]})}):null}function wE({src:e,onClose:t}){return e?(0,B.jsxs)(`div`,{className:`attachment-lightbox`,onClick:t,children:[(0,B.jsx)(`button`,{className:`attachment-lightbox-close`,onClick:t,"aria-label":`Close`,children:`×`}),(0,B.jsx)(`img`,{src:e,alt:`Attachment`,onClick:e=>e.stopPropagation()})]}):null}function TE({show:e,onClose:t,onConfirm:n}){return e?(0,B.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,B.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,B.jsxs)(`div`,{className:`claude-info-header`,children:[(0,B.jsx)(`span`,{children:`Compact conversation?`}),(0,B.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:`✕`})]}),(0,B.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,B.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,B.jsx)(E,{variant:`secondary`,size:`sm`,style:{background:`var(--accent)`,flex:1},onClick:()=>{t(),n()},children:`Yes, compact`}),(0,B.jsx)(E,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:t,children:`No`})]})]})}):null}function EE(e){let{show:t,onClose:n,claudeInfo:r,messages:i,sessionElapsed:a,conversationId:o,contextModeHint:s,handleContextModeToggle:c}=e;if(!t)return null;let l=i.flatMap(e=>e.events?.filter(e=>e.type===`usage`)??[]),u=l.at(-1),d=u?.peak_request_pct==null?u?.context_window?Math.round((u.input_tokens+u.cache_creation_tokens+u.cache_read_tokens)/u.context_window*100):0:Math.round(u.peak_request_pct*100),f=l.reduce((e,t)=>e+t.input_tokens+t.cache_creation_tokens+t.cache_read_tokens+t.output_tokens,0),p=i.flatMap(e=>e.events?.filter(e=>e.type===`rate_limit`)??[]).at(-1),m=l.reduce((e,t)=>e+(t.total_cost_usd??0),0),h=r?.account?.subscriptionType,g=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,B.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,B.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,B.jsxs)(`div`,{className:`claude-info-header`,children:[(0,B.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`claude-info-icon`}),(0,B.jsx)(`span`,{children:`Claude Code`}),(0,B.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,B.jsxs)(`div`,{className:`claude-info-section`,children:[(0,B.jsxs)(`div`,{className:`claude-info-row`,children:[(0,B.jsx)(`span`,{className:`claude-info-label`,children:`Version`}),(0,B.jsx)(`span`,{className:`claude-info-value`,children:r?r.version:`…`})]}),(0,B.jsxs)(`div`,{className:`claude-info-row`,children:[(0,B.jsx)(`span`,{className:`claude-info-label`,children:`Email`}),(0,B.jsx)(`span`,{className:`claude-info-value`,children:r?.account?.email??`…`})]})]}),(h||p||m>0)&&(0,B.jsxs)(`div`,{className:`claude-info-section`,children:[h&&(0,B.jsxs)(`div`,{className:`claude-info-row`,children:[(0,B.jsx)(`span`,{className:`claude-info-label`,children:`Plan`}),(0,B.jsx)(`span`,{className:`claude-info-value`,style:{textTransform:`capitalize`},children:h})]}),p&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`claude-info-row`,children:[(0,B.jsx)(`span`,{className:`claude-info-label`,children:`Usage`}),(0,B.jsxs)(`span`,{className:`claude-info-value`,children:[Math.round(p.utilization*100),`%`]})]}),(0,B.jsxs)(`div`,{className:`claude-info-row`,children:[(0,B.jsx)(`span`,{className:`claude-info-label`,children:`Resets in`}),(0,B.jsx)(`span`,{className:`claude-info-value`,children:g(p.resetsAt)})]}),p.isUsingOverage&&(0,B.jsxs)(`div`,{className:`claude-info-row`,children:[(0,B.jsx)(`span`,{className:`claude-info-label`,children:`Overage`}),(0,B.jsx)(`span`,{className:`claude-info-value`,children:`Active`})]})]}),m>0&&(0,B.jsxs)(`div`,{className:`claude-info-row`,children:[(0,B.jsx)(`span`,{className:`claude-info-label`,children:`Session cost`}),(0,B.jsxs)(`span`,{className:`claude-info-value`,children:[`$`,m<.01?m.toFixed(4):m.toFixed(2)]})]})]}),(0,B.jsxs)(`div`,{className:`claude-info-section`,children:[(0,B.jsxs)(`div`,{className:`claude-info-row`,children:[(0,B.jsx)(`span`,{className:`claude-info-label`,children:`Model`}),(0,B.jsx)(`span`,{className:`claude-info-value`,children:r?.model??`…`})]}),(0,B.jsxs)(`div`,{className:`claude-info-row`,children:[(0,B.jsx)(`span`,{className:`claude-info-label`,children:`Context mode`}),(0,B.jsxs)(`span`,{className:`claude-info-value claude-info-toggle`,role:`button`,tabIndex:0,onClick:c,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},children:[r?.contextMode??`…`,s?` (next turn)`:``]})]}),(0,B.jsxs)(`div`,{className:`claude-info-row`,children:[(0,B.jsx)(`span`,{className:`claude-info-label`,children:`Context used`}),(0,B.jsx)(`span`,{className:`claude-info-value`,children:d>0?`${d}%`:`—`})]}),(0,B.jsxs)(`div`,{className:`claude-info-row`,children:[(0,B.jsx)(`span`,{className:`claude-info-label`,children:`Tokens`}),(0,B.jsx)(`span`,{className:`claude-info-value`,children:f>0?lt(f):`—`})]}),(0,B.jsxs)(`div`,{className:`claude-info-row`,children:[(0,B.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,B.jsx)(`span`,{className:`claude-info-value`,children:ct(a)})]}),o&&(0,B.jsxs)(`div`,{className:`claude-info-row`,children:[(0,B.jsx)(`span`,{className:`claude-info-label`,children:`Conversation`}),(0,B.jsx)(`span`,{className:`claude-info-value`,style:{fontFamily:`monospace`,fontSize:10},children:o.slice(0,8)})]})]})]})})}var DE=5e3,OE={atPhase:8};function kE({show:e,onClose:t,versionInfo:n,sessionKey:r,onUpgradeComplete:i}){let[a,o]=(0,z.useState)(`prompt`),[s,c]=(0,z.useState)(``),[l,u]=(0,z.useState)(!1),[d,f]=(0,z.useState)(null),[p,m]=(0,z.useState)(null),[h,g]=(0,z.useState)(null),_=(0,z.useRef)(null),v=n?.latest??null,y=(0,z.useCallback)(()=>{_.current&&=(clearInterval(_.current),null)},[]);(0,z.useEffect)(()=>{e||(y(),o(`prompt`),c(``),u(!1),f(null),m(null),g(null))},[e,y]),(0,z.useEffect)(()=>y,[y]),(0,z.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{}},DE),y},[e,a,v,i,y]);let b=(0,z.useCallback)(async()=>{if(!(!v||!r||a!==`prompt`)){if(!s){f(`Enter your sudo 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??`sudo prime failed (status ${e.status})`),o(`prompt`);return}}catch(e){f(e instanceof Error?e.message:`sudo prime 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,B.jsx)(`div`,{className:`claude-info-overlay`,onClick:()=>{(a===`prompt`||a===`succeeded`||a===`launch-failed`)&&t()},children:(0,B.jsxs)(`div`,{className:`claude-info-modal update-modal`,onClick:e=>e.stopPropagation(),children:[(0,B.jsxs)(`div`,{className:`claude-info-header`,children:[(0,B.jsx)(fe,{size:12}),`Software Update`,(0,B.jsx)(`button`,{className:`claude-info-close`,onClick:t,children:`✕`})]}),(0,B.jsxs)(`div`,{className:`update-modal-body`,children:[(0,B.jsxs)(`div`,{className:`update-modal-versions`,children:[(0,B.jsxs)(`div`,{className:`claude-info-row`,children:[(0,B.jsx)(`span`,{className:`claude-info-label`,children:`Installed`}),(0,B.jsxs)(`span`,{className:`claude-info-value`,children:[`v`,n?.installed??`…`]})]}),(0,B.jsxs)(`div`,{className:`claude-info-row`,children:[(0,B.jsx)(`span`,{className:`claude-info-label`,children:`Available`}),(0,B.jsxs)(`span`,{className:`claude-info-value update-version-new`,children:[`v`,v??`…`]})]})]}),(a===`prompt`||a===`priming`||a===`launch-failed`)&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`form-input__field`,style:{marginTop:12},children:[(0,B.jsx)(`label`,{className:`form-input__label`,htmlFor:`upgrade-sudo`,children:`Sudo password`}),(0,B.jsxs)(`div`,{className:`tunnel-route__row`,children:[(0,B.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,B.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,B.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,B.jsx)(`div`,{className:`tunnel-route__error`,children:d}),p&&(0,B.jsx)(`div`,{className:`tunnel-route__error`,role:`alert`,children:p})]}),(0,B.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,B.jsx)(`div`,{className:`update-modal-terminal`,style:{height:360,marginTop:10},children:(0,B.jsx)(qT,{actionId:h,sessionKey:r,selfRestart:OE})}),a===`succeeded`&&(0,B.jsxs)(`div`,{className:`update-modal-result`,children:[(0,B.jsx)(be,{size:14,className:`update-success-icon`}),(0,B.jsxs)(`span`,{children:[`Upgraded to v`,v,` — reloading…`]})]})]})]})}):null}function AE({onClose:e}){st();let[t,n]=(0,z.useState)(!1),r=(0,z.useRef)(null),i=(0,z.useRef)(null),a=(0,z.useCallback)(()=>{i.current&&=(clearInterval(i.current),null),r.current&&!r.current.closed&&r.current.close(),r.current=null,n(!1)},[]),o=(0,z.useCallback)(()=>{let t=`/vnc-popout.html?title=${encodeURIComponent(y.productName)}`,o=window.open(t,`maxy-vnc-overlay-popout`,`width=1024,height=768`);o&&(r.current=o,n(!0),i.current=setInterval(()=>{r.current?.closed&&(a(),e())},500))},[a,e]),s=(0,z.useCallback)(()=>{a(),e()},[a,e]);(0,z.useEffect)(()=>{if(t)return;let e=e=>{e.key===`Escape`&&s()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,s]),(0,z.useEffect)(()=>()=>a(),[a]);let l=Rt({handlePopout:o,disabled:t});return t?(0,B.jsxs)(`div`,{className:`browser-overlay-popout`,children:[(0,B.jsx)(c,{className:`browser-viewer__icon`}),(0,B.jsx)(`span`,{className:`browser-viewer__title`,children:y.productName}),(0,B.jsx)(`span`,{className:`browser-viewer__popout-label`,children:`Popped out`}),(0,B.jsx)(E,{variant:`ghost`,size:`sm`,icon:Ke,onClick:()=>{a()},"aria-label":`Pop back in`}),(0,B.jsx)(E,{variant:`ghost`,size:`sm`,icon:he,onClick:s,"aria-label":`Close`})]}):(0,B.jsxs)(`div`,{className:`browser-viewer-fullscreen`,children:[(0,B.jsxs)(`div`,{className:`browser-viewer-fullscreen__bar`,...l,children:[(0,B.jsx)(c,{className:`browser-viewer__icon`}),(0,B.jsx)(`span`,{className:`browser-viewer-fullscreen__title`,children:y.productName}),(0,B.jsxs)(`div`,{className:`browser-viewer-fullscreen__actions`,children:[(0,B.jsx)(E,{variant:`ghost`,size:`sm`,icon:ke,onClick:o,"aria-label":`Pop out`}),(0,B.jsx)(E,{variant:`ghost`,size:`sm`,icon:he,onClick:s,"aria-label":`Close`})]})]}),(0,B.jsx)(`iframe`,{src:`/vnc-viewer.html`,className:`browser-viewer-fullscreen__iframe`,title:y.productName})]})}function jE(){st();let e=(0,z.useRef)(null),[t,n]=(0,z.useState)(null),[r,a]=(0,z.useState)(!1),[o,s]=(0,z.useState)(!1),[u,d]=(0,z.useState)(``),[p,m]=(0,z.useState)(!1),[h,g]=(0,z.useState)(null),[_,v]=(0,z.useState)(!1),[b,x]=(0,z.useState)(null),[S,C]=(0,z.useState)(null),[T,E]=(0,z.useState)(!1),[D,O]=(0,z.useState)([]),[k,A]=(0,z.useState)(!1),[j,M]=(0,z.useState)(null),[N,P]=(0,z.useState)(null),[ee,te]=(0,z.useState)(!1),[F,ne]=(0,z.useState)(null),[re,ie]=(0,z.useState)(!1),[ce,fe]=(0,z.useState)(!1),pe=(0,z.useRef)(!1),me=(0,z.useRef)(!1),ge=(0,z.useRef)(!1),_e=(0,z.useRef)(null),I=l(),ve=ut(),L=gt(),ye=Tt(),R=wt({sessionKey:L.sessionKey,setSessionKey:L.setSessionKey,setAppState:L.setAppState,setConversationId:L.setConversationId,startElapsedTimer:ve.startElapsedTimer,stopElapsedTimer:ve.stopElapsedTimer,resetTimerState:ve.resetTimerState,pausedElapsedRef:ve.pausedElapsedRef,expandAllDefaultRef:L.expandAllDefaultRef,setExpandAll:L.setExpandAll,getPendingFiles:()=>ye.pendingFiles,clearPendingFiles:ye.clearFiles,inputRef:e});(0,z.useEffect)(()=>{d(window.location.hostname.startsWith(`admin.`)?window.location.origin.replace(`admin.`,`public.`):window.location.origin)},[]),(0,z.useEffect)(()=>{function e(e){e.key===`Escape`&&(t?n(null):I.selectionMode&&I.exitSelection())}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,I.selectionMode]),(0,z.useEffect)(()=>{(L.appState===`set-pin`||L.appState===`enter-pin`)&&setTimeout(()=>L.pinInputRef.current?.focus(),100),L.appState===`chat`&&setTimeout(()=>e.current?.focus(),100)},[L.appState,R.greetingGeneration]),(0,z.useEffect)(()=>{if(L.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)},[L.appState]);let be=(0,z.useRef)(R.greetingGeneration);return(0,z.useEffect)(()=>{R.greetingGeneration!==be.current&&(be.current=R.greetingGeneration,L.onboardingComplete===!1&&(pe.current=!1))},[R.greetingGeneration,L.onboardingComplete]),(0,z.useEffect)(()=>{L.appState===`chat`&&L.onboardingComplete===!1&&(pe.current||(pe.current=!0,R.sendSystemPrompt(`[Begin onboarding.]`)))},[L.appState,L.onboardingComplete,R.greetingGeneration]),(0,z.useEffect)(()=>{if(!p)return;let e=!1;return fetch(`/api/admin/version`).then(e=>e.json()).then(t=>{e||P(t)}).catch(e=>{console.error(`[admin/version] menu-open client fetch failed:`,e)}),()=>{e=!0}},[p]),(0,z.useEffect)(()=>{if(L.appState!==`chat`){me.current=!1,ge.current=!1;return}if(me.current)return;me.current=!0;let e=!1;return fetch(`/api/admin/version`).then(e=>e.json()).then(t=>{e||(P(t),!(!t.updateAvailable||ge.current)&&(ne(t),te(!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}},[L.appState]),(0,z.useEffect)(()=>{if(!p){g(null),x(null),C(null),P(null);return}function e(e){_e.current&&!_e.current.contains(e.target)&&m(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[p]),(0,z.useEffect)(()=>{if(typeof BroadcastChannel>`u`)return;let e=new BroadcastChannel(`platform-onboarding`);return e.onmessage=e=>{e.data?.type===`remote-password-set`&&R.sendMessageRef.current(`I've set the remote password`)},()=>e.close()},[]),L.appState===`loading`?(0,B.jsx)(`div`,{className:`chat-page admin-page`,children:(0,B.jsx)(`header`,{className:`chat-header`,children:(0,B.jsx)(`img`,{src:ae,alt:y.productName,className:`chat-logo`})})}):L.appState===`set-pin`?(0,B.jsx)(Dt,{pin:L.pin,setPin:L.setPin,confirmPin:L.confirmPin,setConfirmPin:L.setConfirmPin,showPin:L.showPin,setShowPin:L.setShowPin,pinLoading:L.pinLoading,pinError:L.pinError,pinInputRef:L.pinInputRef,confirmPinInputRef:L.confirmPinInputRef,setPinFormRef:L.setPinFormRef,onSubmit:L.handleSetPin}):L.appState===`onboarding-choice`?(0,B.jsx)(jt,{setAppState:L.setAppState,setOnboardingComplete:L.setOnboardingComplete}):L.appState===`connect-claude`?(0,B.jsx)(At,{authPolling:L.authPolling,setAuthPolling:L.setAuthPolling,authLoading:L.authLoading,setAuthLoading:L.setAuthLoading,pinError:L.pinError,setPinError:L.setPinError,setAppState:L.setAppState}):L.appState===`enter-pin`?(0,B.jsx)(Ot,{pin:L.pin,setPin:L.setPin,showPin:L.showPin,setShowPin:L.setShowPin,pinLoading:L.pinLoading,pinError:L.pinError,pinInputRef:L.pinInputRef,onSubmit:L.handleLogin,onChangePin:L.handleChangePin}):L.appState===`account-picker`?(0,B.jsx)(kt,{accounts:L.accounts,loading:L.accountPickerLoading,error:L.pinError,onSelect:L.handleAccountSelect}):(0,B.jsx)(w,{value:{onShowVnc:()=>ie(!0)},children:(0,B.jsxs)(`div`,{className:`chat-page admin-page`,children:[(0,B.jsxs)(`header`,{className:`chat-header`,children:[(0,B.jsx)(`img`,{src:ae,alt:y.productName,className:`chat-logo`}),(!y.logoContainsName||L.businessName)&&(0,B.jsx)(`div`,{children:(0,B.jsx)(`h1`,{className:`chat-tagline`,children:L.businessName||y.productName})}),(0,B.jsxs)(`div`,{className:`chat-burger-wrap`,ref:_e,children:[(0,B.jsx)(`button`,{type:`button`,className:`chat-burger`,onClick:()=>m(e=>!e),"aria-label":`Menu`,"aria-haspopup":`true`,"aria-expanded":p,children:(0,B.jsx)(ue,{size:20})}),p&&(0,B.jsxs)(`div`,{className:`chat-menu`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:async()=>{if(!(re||ce)){fe(!0),m(!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`);ie(!0)}catch(e){console.error(`[browser] Launch failed:`,e),alert(e instanceof Error?e.message:`Failed to launch browser`)}finally{fe(!1)}}},disabled:ce,children:[(0,B.jsx)(c,{size:14}),` Browser`,ce&&(0,B.jsx)(oe,{size:12,className:`spin`})]}),(0,B.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{m(!1),window.location.href=`/data`},children:[(0,B.jsx)(le,{size:14}),` Data`]}),(0,B.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{m(!1),window.location.href=`/graph`},children:[(0,B.jsx)(de,{size:14}),` Graph`]}),(0,B.jsx)(`div`,{className:`chat-menu-divider`}),(0,B.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:async()=>{if(h!==null){g(null),C(null);return}v(!0),x(null);try{let e=await fetch(`/api/admin/agents`);if(!e.ok)throw Error(`Failed to load agents`);g((await e.json()).agents??[])}catch(e){console.error(`[admin] agent list failed:`,e),x(e instanceof Error?e.message:String(e))}finally{v(!1)}},children:[(0,B.jsx)(ke,{size:14}),` Public`,_&&(0,B.jsx)(oe,{size:12,className:`spin`})]}),h!==null&&(0,B.jsxs)(`div`,{className:`chat-menu-agents`,children:[b&&(0,B.jsx)(`span`,{className:`chat-menu-agent-error`,children:b}),h.length===0&&!b&&(0,B.jsx)(`span`,{className:`chat-menu-agent-empty`,children:`No public agents configured`}),h.map(e=>(0,B.jsxs)(`div`,{className:`chat-menu-item chat-menu-agent-item`,children:[(0,B.jsx)(`span`,{className:`agent-status-dot ${e.status}`}),(0,B.jsxs)(`span`,{className:`agent-text`,children:[(0,B.jsx)(`span`,{className:`agent-display-name`,children:e.displayName}),(0,B.jsxs)(`span`,{className:`agent-slug`,children:[`/`,e.slug]})]}),S===e.slug?(0,B.jsxs)(`span`,{className:`agent-actions agent-confirm`,children:[(0,B.jsx)(`button`,{type:`button`,className:`agent-action-btn agent-confirm-yes`,title:`Confirm delete`,onClick:()=>{C(null),g(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,B.jsx)(f,{size:12})}),(0,B.jsx)(`button`,{type:`button`,className:`agent-action-btn agent-confirm-no`,title:`Cancel`,onClick:()=>C(null),children:(0,B.jsx)(he,{size:12})})]}):(0,B.jsxs)(`span`,{className:`agent-actions`,children:[(0,B.jsx)(`a`,{href:`${u}/${e.slug}`,target:`_blank`,rel:`noopener noreferrer`,className:`agent-action-btn`,title:`Open agent`,onClick:()=>m(!1),children:(0,B.jsx)(ke,{size:12})}),(0,B.jsx)(`button`,{type:`button`,className:`agent-action-btn agent-delete-btn`,title:`Delete agent`,onClick:()=>C(e.slug),children:(0,B.jsx)(i,{size:12})})]})]},e.slug))]}),(0,B.jsx)(`div`,{className:`chat-menu-divider`}),N?.updateAvailable?(0,B.jsxs)(`button`,{type:`button`,className:`chat-menu-version`,onClick:()=>{N.latest&&(ne(N),m(!1),te(!0))},children:[(0,B.jsx)(Ie,{size:14}),(0,B.jsxs)(`span`,{className:`version-installed`,children:[`v`,N.installed,(0,B.jsx)(`span`,{className:`version-update-dot`})]})]}):(0,B.jsxs)(`div`,{className:`chat-menu-version chat-menu-version-passive`,children:[(0,B.jsx)(Ie,{size:14}),(0,B.jsxs)(`span`,{className:`version-installed`,children:[N?`v${N.installed}`:`…`,N&&!N.updateAvailable&&(0,B.jsx)(`span`,{className:`version-uptodate-dot`})]})]}),(0,B.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{m(!1),L.handleLogout(),R.setMessages([])},children:[(0,B.jsx)(se,{size:14}),` Log out`]})]})]})]}),(0,B.jsxs)(`div`,{className:`chat-content`,children:[(0,B.jsx)(vE,{messages:R.messages,isStreaming:R.isStreaming,elapsedSeconds:ve.elapsedSeconds,sessionTurnStart:ve.sessionTurnStart,expandAll:L.expandAll,setExpandAll:L.setExpandAll,conversationCompacted:R.conversationCompacted,isCompacting:R.isCompacting,setShowCompactConfirm:s,handleComponentSubmit:R.handleComponentSubmit,effectiveSubmitted:R.effectiveSubmitted,selectionMode:I.selectionMode,selectedItems:I.selectedItems,toggleSelectItem:I.toggleSelectItem,sessionKey:L.sessionKey,setLightboxSrc:n,messageQueue:R.messageQueue,messageQueueRef:R.messageQueueRef,setQueue:R.setQueue,sendMessage:R.sendMessage,appState:L.appState,onboardingComplete:L.onboardingComplete}),(0,B.jsx)(yE,{offer:R.topicChangeOffer,onFreshStart:R.handleTopicFreshStart,onContinue:R.handleTopicContinue,disabled:R.isStreaming}),(0,B.jsx)(SE,{selectionMode:I.selectionMode,selectedItems:I.selectedItems,copyToast:I.copyToast||null,exitSelection:I.exitSelection,enterSelection:I.enterSelection,copySelected:I.copySelected,showCopyToast:I.showCopyToast,input:R.input,setInput:R.setInput,inputRef:e,pendingFiles:ye.pendingFiles,setPendingFiles:ye.setPendingFiles,isDragOver:ye.isDragOver,attachError:ye.attachError,fileInputRef:ye.fileInputRef,addFiles:ye.addFiles,removeFile:ye.removeFile,onDragOver:ye.onDragOver,onDragLeave:ye.onDragLeave,onDrop:ye.onDrop,isStreaming:R.isStreaming,wasPaused:R.wasPaused,messages:R.messages,messageQueueRef:R.messageQueueRef,setQueue:R.setQueue,sendMessage:R.sendMessage,stopStreaming:R.stopStreaming,disconnecting:L.disconnecting,handleDisconnect:L.handleDisconnect,claudeInfo:L.claudeInfo,setClaudeInfo:L.setClaudeInfo,setShowClaudeInfo:a,conversationId:L.conversationId,onNewConversation:R.startNewConversation,newConversationDisabled:R.isStreaming||R.isCompacting,onOpenConversations:async()=>{E(!0),A(!0),M(null);try{let e=await fetch(`/api/admin/sessions?session_key=${encodeURIComponent(L.sessionKey)}`);if(!e.ok)throw Error(`Failed to load conversations`);O((await e.json()).sessions??[])}catch(e){console.error(`[admin] conversation list failed:`,e),M(e instanceof Error?e.message:String(e))}finally{A(!1)}}})]}),I.copyToast&&(0,B.jsx)(`span`,{className:`copy-toast${I.copyToast===`failed`?` copy-toast-failed`:``}`,children:I.copyToast===`copied`?`Copied`:`Copy failed`}),(0,B.jsx)(CE,{show:T,onClose:()=>E(!1),conversationsLoading:k,conversationsError:j,conversationsList:D,setConversationsList:O,sessionKey:L.sessionKey,isStreaming:R.isStreaming,resetConversation:R.resetConversation,setMessages:R.setMessages,setConversationId:L.setConversationId}),(0,B.jsx)(wE,{src:t,onClose:()=>n(null)}),(0,B.jsx)(TE,{show:o,onClose:()=>s(!1),onConfirm:R.handleCompactNow}),(0,B.jsx)(EE,{show:r,onClose:()=>{a(!1),L.setClaudeInfo(null)},claudeInfo:L.claudeInfo,messages:R.messages,sessionElapsed:ve.sessionElapsed,conversationId:L.conversationId,contextModeHint:L.contextModeHint,handleContextModeToggle:L.handleContextModeToggle}),(0,B.jsx)(kE,{show:ee,onClose:()=>{te(!1),ge.current=!0},versionInfo:F,sessionKey:L.sessionKey,onUpgradeComplete:()=>P(null)}),re&&(0,B.jsx)(AE,{onClose:()=>ie(!1)})]})})}(0,ot.createRoot)(document.getElementById(`root`)).render((0,B.jsx)(jE,{}));
352
+ `)}function SE(e){let{selectionMode:t,selectedItems:n,copyToast:r,exitSelection:i,enterSelection:a,copySelected:o,showCopyToast:s,input:c,setInput:l,inputRef:f,pendingFiles:g,setPendingFiles:y,isDragOver:b,attachError:x,fileInputRef:S,addFiles:C,removeFile:w,onDragOver:T,onDragLeave:A,onDrop:j,isStreaming:N,wasPaused:P,messages:te,messageQueueRef:ne,setQueue:re,sendMessage:ie,stopStreaming:ae,disconnecting:se,handleDisconnect:ce,claudeInfo:le,setClaudeInfo:de,setShowClaudeInfo:fe,conversationId:pe,onNewConversation:me,newConversationDisabled:he,onOpenConversations:ge}=e,[_e,I]=(0,z.useState)(!1),L=(0,z.useRef)(null),[ye,R]=(0,z.useState)(!1),be=(0,z.useRef)(null),xe=(0,z.useRef)(!1),Se=F(),Ce=Se.state===`recording`||Se.state===`paused`||Se.state===`sending`,we=!Ce&&!P&&!c.trim()&&g.length===0;async function Te(){let e=await Se.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(N){re([...ne.current,{text:`[Voice note]`,files:[n],timestamp:Date.now()}]);return}ie(`[Voice note]`,[n])}return(0,z.useEffect)(()=>{t||R(!1)},[t]),(0,z.useEffect)(()=>{if(!ye)return;let e=e=>{e.target.closest(`.selection-copy-wrap`)||R(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[ye]),(0,z.useEffect)(()=>{if(!_e)return;let e=e=>{if(e.key===`Escape`){I(!1);return}if(e.key===`Tab`&&L.current){let t=L.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=>{L.current&&!L.current.contains(e.target)&&I(!1)};return document.addEventListener(`keydown`,e),document.addEventListener(`mousedown`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`mousedown`,t)}},[_e]),t?(0,B.jsx)(`div`,{className:`chat-input-area`,children:(0,B.jsxs)(`div`,{className:`selection-bar`,children:[(0,B.jsxs)(`span`,{className:`selection-count`,children:[n.size,` Selected`]}),(0,B.jsxs)(`div`,{className:`selection-copy-wrap`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`selection-copy`,onPointerDown:()=>{if(ye){R(!1);return}xe.current=!1,be.current=setTimeout(()=>{xe.current=!0,R(!0),be.current=null},500)},onPointerUp:()=>{be.current!==null&&(clearTimeout(be.current),be.current=null)},onPointerLeave:()=>{be.current!==null&&(clearTimeout(be.current),be.current=null)},onPointerCancel:()=>{be.current!==null&&(clearTimeout(be.current),be.current=null)},onClick:async()=>{xe.current||await o(e=>bE(te,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,B.jsx)(m,{size:18}),(0,B.jsx)(`span`,{children:`Copy`})]}),ye&&(0,B.jsx)(`div`,{className:`copy-menu`,children:[[`all`,`All events`],[`text`,`Text messages only`],[`non-text`,`Non-text only`]].map(([e,t])=>(0,B.jsx)(`button`,{type:`button`,className:`copy-menu-item`,onClick:async()=>{let t=xE(te,e);t&&s(await _(t)),i()},children:t},e))})]}),(0,B.jsx)(`button`,{type:`button`,className:`selection-cancel`,onClick:i,children:`Cancel`})]})}):(0,B.jsxs)(`div`,{className:`chat-input-area`,children:[(0,B.jsx)(`input`,{ref:S,type:`file`,multiple:!0,accept:dt,style:{display:`none`},onChange:e=>{e.target.files&&C([...e.target.files]),e.target.value=``}}),g.length>0&&(0,B.jsx)(`div`,{className:`attachment-strip`,children:g.map((e,t)=>(0,B.jsxs)(`div`,{className:`attachment-chip`,children:[e.type.startsWith(`image/`)?(0,B.jsx)(`img`,{src:URL.createObjectURL(e),alt:e.name,className:`attachment-chip-thumb`}):e.type===`application/pdf`?(0,B.jsx)(O,{size:14}):(0,B.jsx)(p,{size:14}),(0,B.jsx)(`span`,{className:`attachment-chip-name`,children:e.name}),(0,B.jsx)(`button`,{type:`button`,className:`attachment-chip-remove`,onClick:()=>w(t),"aria-label":`Remove ${e.name}`,children:`×`})]},t))}),x&&(0,B.jsx)(`p`,{className:`attach-error`,children:x}),Se.state===`error`&&Se.errorMessage&&(0,B.jsxs)(`p`,{className:`voice-error`,role:`alert`,children:[(0,B.jsx)(k,{size:14}),Se.errorMessage]}),(0,B.jsx)(D,{inputRef:f}),Ce?(0,B.jsx)(`div`,{className:`chat-form voice-active`,children:(0,B.jsx)(M,{state:Se.state,elapsedSeconds:Se.elapsedSeconds,waveform:Se.waveform,onTogglePause:Se.togglePause,onDiscard:Se.discard,onSend:Te})}):(0,B.jsxs)(`form`,{className:`chat-form${b?` drag-over`:``}`,onSubmit:e=>{e.preventDefault();let t=c.trim()||(P?`continue`:``);if(!(!t&&g.length===0)){if(N){re([...ne.current,{text:t,files:[...g],timestamp:Date.now()}]),l(``),y([]),f.current?.resetHeight();return}ie(t),f.current?.resetHeight()}},onDragOver:T,onDragLeave:A,onDrop:j,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&&C(n)},children:[(0,B.jsx)(E,{variant:`icon`,type:`button`,onClick:()=>S.current?.click(),"aria-label":`Attach file`,children:(0,B.jsx)(h,{size:14})}),(0,B.jsx)(ee,{ref:f,value:c,onChange:l}),N?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(E,{variant:`send`,type:`button`,onClick:()=>ae(!0),"aria-label":`Pause`,style:{background:`var(--text-secondary)`},children:(0,B.jsx)(u,{size:14})}),(0,B.jsx)(E,{variant:`send`,type:`button`,onClick:()=>ae(!1),"aria-label":`Stop`,style:{background:`var(--danger)`},children:(0,B.jsx)(et,{size:14})})]}):we?(0,B.jsx)(E,{variant:`send`,type:`button`,onClick:Se.start,"aria-label":`Record voice note`,children:(0,B.jsx)(k,{size:14})}):(0,B.jsx)(E,{variant:`send`,type:`submit`,disabled:!c.trim()&&g.length===0&&!P,"aria-label":`Send message`,children:P?(0,B.jsx)(d,{size:14}):(0,B.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,B.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,B.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,B.jsxs)(`div`,{className:`chat-actions`,ref:L,children:[(0,B.jsx)(`button`,{className:`burger-trigger`,onClick:()=>I(e=>!e),"aria-expanded":_e,"aria-haspopup":`true`,"aria-label":`Actions menu`,children:(0,B.jsx)(ue,{size:16})}),(0,B.jsxs)(`div`,{className:`actions-menu-items${_e?` actions-menu-open`:``}`,children:[(0,B.jsxs)(`button`,{className:`chat-action`,disabled:he,onClick:()=>{I(!1),me()},children:[(0,B.jsx)(Ne,{size:14}),(0,B.jsx)(`span`,{className:`action-label`,children:`New conversation`})]}),(0,B.jsxs)(`button`,{className:`chat-action`,onClick:()=>{I(!1),ge()},children:[(0,B.jsx)(Ve,{size:14}),(0,B.jsx)(`span`,{className:`action-label`,children:`Conversations`})]}),(0,B.jsxs)(`button`,{className:`chat-action`,disabled:se,onClick:async()=>{I(!1),await ce()},children:[se?(0,B.jsx)(oe,{size:14,className:`animate-spin`}):(0,B.jsx)(ve,{size:14}),(0,B.jsx)(`span`,{className:`action-label`,children:se?`Disconnecting...`:`Disconnect Claude`})]}),(0,B.jsxs)(`button`,{className:`chat-action`,disabled:!pe,onClick:()=>{if(I(!1),!pe){console.debug(`[stream-log-button] disabled reason=no-conversation-id`);return}let e=document.createElement(`a`);e.href=`/api/admin/logs?type=stream&conversationId=${encodeURIComponent(pe)}&download=1`,e.click()},title:pe?`Download stream log`:`No conversation active — start a message to create a stream log`,children:[(0,B.jsx)(Ze,{size:14}),(0,B.jsx)(`span`,{className:`action-label`,children:`Stream log`})]}),(0,B.jsxs)(`button`,{className:`chat-action`,onClick:()=>{I(!1),a()},title:`Select messages`,children:[(0,B.jsx)(v,{size:14}),(0,B.jsx)(`span`,{className:`action-label`,children:`Select`})]})]}),(0,B.jsxs)(`div`,{className:`powered-by`,onClick:async()=>{if(fe(!0),!le){let e=await fetch(`/api/admin/claude-info`);e.ok&&de(await e.json())}},children:[(0,B.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`powered-by-icon`}),(0,B.jsx)(`span`,{children:`Powered by Claude Code`})]})]})]})}function CE(e){let{show:t,onClose:n,conversationsLoading:r,conversationsError:a,conversationsList:o,setConversationsList:s,sessionKey:c,isStreaming:l,resetConversation:u,setMessages:p,setConversationId:m}=e,[h,g]=(0,z.useState)(null),[_,v]=(0,z.useState)(null),[y,b]=(0,z.useState)(``),[x,S]=(0,z.useState)(!1),C=(0,z.useRef)(null);(0,z.useEffect)(()=>{t||(g(null),v(null),b(``),S(!1))},[t]),(0,z.useEffect)(()=>{_?.phase===`editing`&&(C.current?.focus(),C.current?.select())},[_]);function w(){g(null),v(null),b(``),S(!1)}async function T(e){if(c){w(),g(e),v({phase:`loading`});try{let t=await fetch(`/api/admin/sessions/${encodeURIComponent(e)}/label?session_key=${encodeURIComponent(c)}`,{method:`POST`});if(!t.ok){v({phase:`error`,reason:(await t.json().catch(()=>({}))).error||`Request failed`});return}let n=await t.json();n.label?(v({phase:`editing`}),b(n.label)):v({phase:`error`,reason:`Not enough message content to suggest a name`})}catch(e){console.error(`[admin-modal] label suggestion failed:`,e),v({phase:`error`,reason:e instanceof Error?e.message:String(e)})}}}async function E(e){if(!(!c||!y.trim()||x)){S(!0);try{let t=await fetch(`/api/admin/sessions/${encodeURIComponent(e)}/label`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({label:y.trim(),session_key:c})});if(!t.ok){v({phase:`error`,reason:(await t.json().catch(()=>({}))).error||`Rename failed`}),S(!1);return}s(t=>t.map(t=>t.conversationId===e?{...t,name:y.trim()}:t)),w()}catch(e){console.error(`[admin-modal] label rename failed:`,e),v({phase:`error`,reason:e instanceof Error?e.message:String(e)}),S(!1)}}}return t?(0,B.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,B.jsxs)(`div`,{className:`claude-info-modal conversations-modal`,onClick:e=>e.stopPropagation(),children:[(0,B.jsxs)(`div`,{className:`claude-info-header`,children:[(0,B.jsx)(Ve,{size:12}),`Conversations`,(0,B.jsx)(`button`,{className:`claude-info-close`,onClick:n,children:`✕`})]}),(0,B.jsxs)(`div`,{className:`conversations-list`,children:[r&&(0,B.jsxs)(`div`,{className:`conversations-empty`,children:[(0,B.jsx)(oe,{size:14,className:`spin`}),` Loading…`]}),a&&(0,B.jsx)(`div`,{className:`conversations-empty conversations-error`,children:a}),!r&&!a&&o.length===0&&(0,B.jsx)(`div`,{className:`conversations-empty`,children:`No recent conversations`}),!r&&!a&&o.map(e=>{let t=h===e.conversationId,r=t&&_?.phase===`loading`,a=t&&_?.phase===`editing`,o=t&&_?.phase===`error`;return(0,B.jsxs)(`div`,{className:`conversations-row`,children:[(0,B.jsxs)(`div`,{className:`conversations-row-info`,children:[r&&(0,B.jsxs)(`span`,{className:`conversations-row-name conversations-edit-loading`,children:[(0,B.jsx)(oe,{size:12,className:`spin`}),` Generating suggestion…`]}),a&&(0,B.jsxs)(`div`,{className:`conversations-edit-inline`,children:[(0,B.jsx)(`input`,{ref:C,type:`text`,className:`conversations-edit-input`,value:y,onChange:e=>b(e.target.value),onKeyDown:t=>{t.key===`Enter`&&y.trim()&&E(e.conversationId),t.key===`Escape`&&w()},maxLength:200}),(0,B.jsx)(`button`,{type:`button`,className:`conversations-action conversations-confirm`,title:`Confirm rename`,disabled:!y.trim()||x,onClick:()=>E(e.conversationId),children:x?(0,B.jsx)(oe,{size:13,className:`spin`}):(0,B.jsx)(f,{size:13})}),(0,B.jsx)(`button`,{type:`button`,className:`conversations-action conversations-cancel`,title:`Cancel`,onClick:w,children:(0,B.jsx)(he,{size:13})})]}),o&&(0,B.jsxs)(`div`,{className:`conversations-edit-inline`,children:[(0,B.jsx)(`span`,{className:`conversations-edit-error`,children:_.reason}),(0,B.jsx)(`button`,{type:`button`,className:`conversations-action conversations-retry`,title:`Retry`,onClick:()=>T(e.conversationId),children:(0,B.jsx)(me,{size:13})}),(0,B.jsx)(`button`,{type:`button`,className:`conversations-action conversations-cancel`,title:`Cancel`,onClick:w,children:(0,B.jsx)(he,{size:13})})]}),!t&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`conversations-row-name`,children:e.name||e.conversationId.slice(0,12)+`…`}),(0,B.jsxs)(`span`,{className:`conversations-row-meta`,children:[(0,B.jsx)(`span`,{className:`conversations-row-id`,children:e.conversationId.slice(0,8)}),(0,B.jsxs)(`span`,{className:`conversations-row-time`,children:[(0,B.jsx)(we,{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``}})()]})]})]})]}),(0,B.jsx)(`div`,{className:`conversations-row-actions`,children:!t&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`button`,{type:`button`,className:`conversations-action conversations-rename`,title:`Rename conversation`,onClick:()=>T(e.conversationId),children:(0,B.jsx)(Ye,{size:13})}),(0,B.jsx)(`button`,{type:`button`,className:`conversations-action conversations-play`,title:`Resume conversation`,disabled:l,onClick:()=>{l||!c||(n(),u(),fetch(`/api/admin/sessions/${encodeURIComponent(e.conversationId)}/resume?session_key=${encodeURIComponent(c)}`,{method:`POST`}).then(e=>e.ok?e.json():Promise.reject(Error(`Failed to resume conversation`))).then(e=>{e.conversationId&&m(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`?[{type:`text`,content:e.content}]:void 0,timestamp:new Date(e.createdAt).getTime()||0,historical:!0}));t.length>0&&p(t)}).catch(e=>{console.error(`[chat] conversation resume failed:`,e),p([{role:`maxy`,events:[{type:`text`,content:`Could not load conversation history.`}],timestamp:Date.now()-1,historical:!0}])}))},children:(0,B.jsx)(d,{size:13})}),(0,B.jsx)(`button`,{type:`button`,className:`conversations-action conversations-delete`,title:`Delete conversation`,onClick:()=>{s(t=>t.filter(t=>t.conversationId!==e.conversationId)),c&&fetch(`/api/admin/sessions/${encodeURIComponent(e.conversationId)}?session_key=${encodeURIComponent(c)}`,{method:`DELETE`}).catch(e=>console.error(`[chat] conversation delete failed:`,e))},children:(0,B.jsx)(i,{size:13})})]})})]},e.conversationId)})]})]})}):null}function wE({src:e,onClose:t}){return e?(0,B.jsxs)(`div`,{className:`attachment-lightbox`,onClick:t,children:[(0,B.jsx)(`button`,{className:`attachment-lightbox-close`,onClick:t,"aria-label":`Close`,children:`×`}),(0,B.jsx)(`img`,{src:e,alt:`Attachment`,onClick:e=>e.stopPropagation()})]}):null}function TE({show:e,onClose:t,onConfirm:n}){return e?(0,B.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,B.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,B.jsxs)(`div`,{className:`claude-info-header`,children:[(0,B.jsx)(`span`,{children:`Compact conversation?`}),(0,B.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:`✕`})]}),(0,B.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,B.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,B.jsx)(E,{variant:`secondary`,size:`sm`,style:{background:`var(--accent)`,flex:1},onClick:()=>{t(),n()},children:`Yes, compact`}),(0,B.jsx)(E,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:t,children:`No`})]})]})}):null}function EE(e){let{show:t,onClose:n,claudeInfo:r,messages:i,sessionElapsed:a,conversationId:o,contextModeHint:s,handleContextModeToggle:c}=e;if(!t)return null;let l=i.flatMap(e=>e.events?.filter(e=>e.type===`usage`)??[]),u=l.at(-1),d=u?.peak_request_pct==null?u?.context_window?Math.round((u.input_tokens+u.cache_creation_tokens+u.cache_read_tokens)/u.context_window*100):0:Math.round(u.peak_request_pct*100),f=l.reduce((e,t)=>e+t.input_tokens+t.cache_creation_tokens+t.cache_read_tokens+t.output_tokens,0),p=i.flatMap(e=>e.events?.filter(e=>e.type===`rate_limit`)??[]).at(-1),m=l.reduce((e,t)=>e+(t.total_cost_usd??0),0),h=r?.account?.subscriptionType,g=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,B.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,B.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,B.jsxs)(`div`,{className:`claude-info-header`,children:[(0,B.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`claude-info-icon`}),(0,B.jsx)(`span`,{children:`Claude Code`}),(0,B.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,B.jsxs)(`div`,{className:`claude-info-section`,children:[(0,B.jsxs)(`div`,{className:`claude-info-row`,children:[(0,B.jsx)(`span`,{className:`claude-info-label`,children:`Version`}),(0,B.jsx)(`span`,{className:`claude-info-value`,children:r?r.version:`…`})]}),(0,B.jsxs)(`div`,{className:`claude-info-row`,children:[(0,B.jsx)(`span`,{className:`claude-info-label`,children:`Email`}),(0,B.jsx)(`span`,{className:`claude-info-value`,children:r?.account?.email??`…`})]})]}),(h||p||m>0)&&(0,B.jsxs)(`div`,{className:`claude-info-section`,children:[h&&(0,B.jsxs)(`div`,{className:`claude-info-row`,children:[(0,B.jsx)(`span`,{className:`claude-info-label`,children:`Plan`}),(0,B.jsx)(`span`,{className:`claude-info-value`,style:{textTransform:`capitalize`},children:h})]}),p&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`claude-info-row`,children:[(0,B.jsx)(`span`,{className:`claude-info-label`,children:`Usage`}),(0,B.jsxs)(`span`,{className:`claude-info-value`,children:[Math.round(p.utilization*100),`%`]})]}),(0,B.jsxs)(`div`,{className:`claude-info-row`,children:[(0,B.jsx)(`span`,{className:`claude-info-label`,children:`Resets in`}),(0,B.jsx)(`span`,{className:`claude-info-value`,children:g(p.resetsAt)})]}),p.isUsingOverage&&(0,B.jsxs)(`div`,{className:`claude-info-row`,children:[(0,B.jsx)(`span`,{className:`claude-info-label`,children:`Overage`}),(0,B.jsx)(`span`,{className:`claude-info-value`,children:`Active`})]})]}),m>0&&(0,B.jsxs)(`div`,{className:`claude-info-row`,children:[(0,B.jsx)(`span`,{className:`claude-info-label`,children:`Session cost`}),(0,B.jsxs)(`span`,{className:`claude-info-value`,children:[`$`,m<.01?m.toFixed(4):m.toFixed(2)]})]})]}),(0,B.jsxs)(`div`,{className:`claude-info-section`,children:[(0,B.jsxs)(`div`,{className:`claude-info-row`,children:[(0,B.jsx)(`span`,{className:`claude-info-label`,children:`Model`}),(0,B.jsx)(`span`,{className:`claude-info-value`,children:r?.model??`…`})]}),(0,B.jsxs)(`div`,{className:`claude-info-row`,children:[(0,B.jsx)(`span`,{className:`claude-info-label`,children:`Context mode`}),(0,B.jsxs)(`span`,{className:`claude-info-value claude-info-toggle`,role:`button`,tabIndex:0,onClick:c,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},children:[r?.contextMode??`…`,s?` (next turn)`:``]})]}),(0,B.jsxs)(`div`,{className:`claude-info-row`,children:[(0,B.jsx)(`span`,{className:`claude-info-label`,children:`Context used`}),(0,B.jsx)(`span`,{className:`claude-info-value`,children:d>0?`${d}%`:`—`})]}),(0,B.jsxs)(`div`,{className:`claude-info-row`,children:[(0,B.jsx)(`span`,{className:`claude-info-label`,children:`Tokens`}),(0,B.jsx)(`span`,{className:`claude-info-value`,children:f>0?lt(f):`—`})]}),(0,B.jsxs)(`div`,{className:`claude-info-row`,children:[(0,B.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,B.jsx)(`span`,{className:`claude-info-value`,children:ct(a)})]}),o&&(0,B.jsxs)(`div`,{className:`claude-info-row`,children:[(0,B.jsx)(`span`,{className:`claude-info-label`,children:`Conversation`}),(0,B.jsx)(`span`,{className:`claude-info-value`,style:{fontFamily:`monospace`,fontSize:10},children:o.slice(0,8)})]})]})]})})}var DE=5e3,OE={atPhase:8};function kE({show:e,onClose:t,versionInfo:n,sessionKey:r,onUpgradeComplete:i}){let[a,o]=(0,z.useState)(`prompt`),[s,c]=(0,z.useState)(``),[l,u]=(0,z.useState)(!1),[d,f]=(0,z.useState)(null),[p,m]=(0,z.useState)(null),[h,g]=(0,z.useState)(null),_=(0,z.useRef)(null),v=n?.latest??null,y=(0,z.useCallback)(()=>{_.current&&=(clearInterval(_.current),null)},[]);(0,z.useEffect)(()=>{e||(y(),o(`prompt`),c(``),u(!1),f(null),m(null),g(null))},[e,y]),(0,z.useEffect)(()=>y,[y]),(0,z.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{}},DE),y},[e,a,v,i,y]);let b=(0,z.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,B.jsx)(`div`,{className:`claude-info-overlay`,onClick:()=>{(a===`prompt`||a===`succeeded`||a===`launch-failed`)&&t()},children:(0,B.jsxs)(`div`,{className:`claude-info-modal update-modal`,onClick:e=>e.stopPropagation(),children:[(0,B.jsxs)(`div`,{className:`claude-info-header`,children:[(0,B.jsx)(fe,{size:12}),`Software Update`,(0,B.jsx)(`button`,{className:`claude-info-close`,onClick:t,children:`✕`})]}),(0,B.jsxs)(`div`,{className:`update-modal-body`,children:[(0,B.jsxs)(`div`,{className:`update-modal-versions`,children:[(0,B.jsxs)(`div`,{className:`claude-info-row`,children:[(0,B.jsx)(`span`,{className:`claude-info-label`,children:`Installed`}),(0,B.jsxs)(`span`,{className:`claude-info-value`,children:[`v`,n?.installed??`…`]})]}),(0,B.jsxs)(`div`,{className:`claude-info-row`,children:[(0,B.jsx)(`span`,{className:`claude-info-label`,children:`Available`}),(0,B.jsxs)(`span`,{className:`claude-info-value update-version-new`,children:[`v`,v??`…`]})]})]}),(a===`prompt`||a===`priming`||a===`launch-failed`)&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`form-input__field`,style:{marginTop:12},children:[(0,B.jsx)(`label`,{className:`form-input__label`,htmlFor:`upgrade-sudo`,children:`Device password`}),(0,B.jsxs)(`div`,{className:`tunnel-route__row`,children:[(0,B.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,B.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,B.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,B.jsx)(`div`,{className:`tunnel-route__error`,children:d}),p&&(0,B.jsx)(`div`,{className:`tunnel-route__error`,role:`alert`,children:p})]}),(0,B.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,B.jsx)(`div`,{className:`update-modal-terminal`,style:{height:360,marginTop:10},children:(0,B.jsx)(qT,{actionId:h,sessionKey:r,selfRestart:OE})}),a===`succeeded`&&(0,B.jsxs)(`div`,{className:`update-modal-result`,children:[(0,B.jsx)(be,{size:14,className:`update-success-icon`}),(0,B.jsxs)(`span`,{children:[`Upgraded to v`,v,` — reloading…`]})]})]})]})}):null}function AE({onClose:e}){st();let[t,n]=(0,z.useState)(!1),r=(0,z.useRef)(null),i=(0,z.useRef)(null),a=(0,z.useCallback)(()=>{i.current&&=(clearInterval(i.current),null),r.current&&!r.current.closed&&r.current.close(),r.current=null,n(!1)},[]),o=(0,z.useCallback)(()=>{let t=`/vnc-popout.html?title=${encodeURIComponent(y.productName)}`,o=window.open(t,`maxy-vnc-overlay-popout`,`width=1024,height=768`);o&&(r.current=o,n(!0),i.current=setInterval(()=>{r.current?.closed&&(a(),e())},500))},[a,e]),s=(0,z.useCallback)(()=>{a(),e()},[a,e]);(0,z.useEffect)(()=>{if(t)return;let e=e=>{e.key===`Escape`&&s()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,s]),(0,z.useEffect)(()=>()=>a(),[a]);let l=Rt({handlePopout:o,disabled:t});return t?(0,B.jsxs)(`div`,{className:`browser-overlay-popout`,children:[(0,B.jsx)(c,{className:`browser-viewer__icon`}),(0,B.jsx)(`span`,{className:`browser-viewer__title`,children:y.productName}),(0,B.jsx)(`span`,{className:`browser-viewer__popout-label`,children:`Popped out`}),(0,B.jsx)(E,{variant:`ghost`,size:`sm`,icon:Ke,onClick:()=>{a()},"aria-label":`Pop back in`}),(0,B.jsx)(E,{variant:`ghost`,size:`sm`,icon:he,onClick:s,"aria-label":`Close`})]}):(0,B.jsxs)(`div`,{className:`browser-viewer-fullscreen`,children:[(0,B.jsxs)(`div`,{className:`browser-viewer-fullscreen__bar`,...l,children:[(0,B.jsx)(c,{className:`browser-viewer__icon`}),(0,B.jsx)(`span`,{className:`browser-viewer-fullscreen__title`,children:y.productName}),(0,B.jsxs)(`div`,{className:`browser-viewer-fullscreen__actions`,children:[(0,B.jsx)(E,{variant:`ghost`,size:`sm`,icon:ke,onClick:o,"aria-label":`Pop out`}),(0,B.jsx)(E,{variant:`ghost`,size:`sm`,icon:he,onClick:s,"aria-label":`Close`})]})]}),(0,B.jsx)(`iframe`,{src:`/vnc-viewer.html`,className:`browser-viewer-fullscreen__iframe`,title:y.productName})]})}function jE(){st();let e=(0,z.useRef)(null),[t,n]=(0,z.useState)(null),[r,a]=(0,z.useState)(!1),[o,s]=(0,z.useState)(!1),[u,d]=(0,z.useState)(``),[p,m]=(0,z.useState)(!1),[h,g]=(0,z.useState)(null),[_,v]=(0,z.useState)(!1),[b,x]=(0,z.useState)(null),[S,C]=(0,z.useState)(null),[T,E]=(0,z.useState)(!1),[D,O]=(0,z.useState)([]),[k,A]=(0,z.useState)(!1),[j,M]=(0,z.useState)(null),[N,P]=(0,z.useState)(null),[ee,te]=(0,z.useState)(!1),[F,ne]=(0,z.useState)(null),[re,ie]=(0,z.useState)(!1),[ce,fe]=(0,z.useState)(!1),pe=(0,z.useRef)(!1),me=(0,z.useRef)(!1),ge=(0,z.useRef)(!1),_e=(0,z.useRef)(null),I=l(),ve=ut(),L=gt(),ye=Tt(),R=wt({sessionKey:L.sessionKey,setSessionKey:L.setSessionKey,setAppState:L.setAppState,setConversationId:L.setConversationId,startElapsedTimer:ve.startElapsedTimer,stopElapsedTimer:ve.stopElapsedTimer,resetTimerState:ve.resetTimerState,pausedElapsedRef:ve.pausedElapsedRef,expandAllDefaultRef:L.expandAllDefaultRef,setExpandAll:L.setExpandAll,getPendingFiles:()=>ye.pendingFiles,clearPendingFiles:ye.clearFiles,inputRef:e});(0,z.useEffect)(()=>{d(window.location.hostname.startsWith(`admin.`)?window.location.origin.replace(`admin.`,`public.`):window.location.origin)},[]),(0,z.useEffect)(()=>{function e(e){e.key===`Escape`&&(t?n(null):I.selectionMode&&I.exitSelection())}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,I.selectionMode]),(0,z.useEffect)(()=>{(L.appState===`set-pin`||L.appState===`enter-pin`)&&setTimeout(()=>L.pinInputRef.current?.focus(),100),L.appState===`chat`&&setTimeout(()=>e.current?.focus(),100)},[L.appState,R.greetingGeneration]),(0,z.useEffect)(()=>{if(L.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)},[L.appState]);let be=(0,z.useRef)(R.greetingGeneration);return(0,z.useEffect)(()=>{R.greetingGeneration!==be.current&&(be.current=R.greetingGeneration,L.onboardingComplete===!1&&(pe.current=!1))},[R.greetingGeneration,L.onboardingComplete]),(0,z.useEffect)(()=>{L.appState===`chat`&&L.onboardingComplete===!1&&(pe.current||(pe.current=!0,R.sendSystemPrompt(`[Begin onboarding.]`)))},[L.appState,L.onboardingComplete,R.greetingGeneration]),(0,z.useEffect)(()=>{if(!p)return;let e=!1;return fetch(`/api/admin/version`).then(e=>e.json()).then(t=>{e||P(t)}).catch(e=>{console.error(`[admin/version] menu-open client fetch failed:`,e)}),()=>{e=!0}},[p]),(0,z.useEffect)(()=>{if(L.appState!==`chat`){me.current=!1,ge.current=!1;return}if(me.current)return;me.current=!0;let e=!1;return fetch(`/api/admin/version`).then(e=>e.json()).then(t=>{e||(P(t),!(!t.updateAvailable||ge.current)&&(ne(t),te(!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}},[L.appState]),(0,z.useEffect)(()=>{if(!p){g(null),x(null),C(null),P(null);return}function e(e){_e.current&&!_e.current.contains(e.target)&&m(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[p]),(0,z.useEffect)(()=>{if(typeof BroadcastChannel>`u`)return;let e=new BroadcastChannel(`platform-onboarding`);return e.onmessage=e=>{e.data?.type===`remote-password-set`&&R.sendMessageRef.current(`I've set the remote password`)},()=>e.close()},[]),L.appState===`loading`?(0,B.jsx)(`div`,{className:`chat-page admin-page`,children:(0,B.jsx)(`header`,{className:`chat-header`,children:(0,B.jsx)(`img`,{src:ae,alt:y.productName,className:`chat-logo`})})}):L.appState===`set-pin`?(0,B.jsx)(Dt,{pin:L.pin,setPin:L.setPin,confirmPin:L.confirmPin,setConfirmPin:L.setConfirmPin,showPin:L.showPin,setShowPin:L.setShowPin,pinLoading:L.pinLoading,pinError:L.pinError,pinInputRef:L.pinInputRef,confirmPinInputRef:L.confirmPinInputRef,setPinFormRef:L.setPinFormRef,onSubmit:L.handleSetPin}):L.appState===`onboarding-choice`?(0,B.jsx)(jt,{setAppState:L.setAppState,setOnboardingComplete:L.setOnboardingComplete}):L.appState===`connect-claude`?(0,B.jsx)(At,{authPolling:L.authPolling,setAuthPolling:L.setAuthPolling,authLoading:L.authLoading,setAuthLoading:L.setAuthLoading,pinError:L.pinError,setPinError:L.setPinError,setAppState:L.setAppState}):L.appState===`enter-pin`?(0,B.jsx)(Ot,{pin:L.pin,setPin:L.setPin,showPin:L.showPin,setShowPin:L.setShowPin,pinLoading:L.pinLoading,pinError:L.pinError,pinInputRef:L.pinInputRef,onSubmit:L.handleLogin,onChangePin:L.handleChangePin}):L.appState===`account-picker`?(0,B.jsx)(kt,{accounts:L.accounts,loading:L.accountPickerLoading,error:L.pinError,onSelect:L.handleAccountSelect}):(0,B.jsx)(w,{value:{onShowVnc:()=>ie(!0)},children:(0,B.jsxs)(`div`,{className:`chat-page admin-page`,children:[(0,B.jsxs)(`header`,{className:`chat-header`,children:[(0,B.jsx)(`img`,{src:ae,alt:y.productName,className:`chat-logo`}),(!y.logoContainsName||L.businessName)&&(0,B.jsx)(`div`,{children:(0,B.jsx)(`h1`,{className:`chat-tagline`,children:L.businessName||y.productName})}),(0,B.jsxs)(`div`,{className:`chat-burger-wrap`,ref:_e,children:[(0,B.jsx)(`button`,{type:`button`,className:`chat-burger`,onClick:()=>m(e=>!e),"aria-label":`Menu`,"aria-haspopup":`true`,"aria-expanded":p,children:(0,B.jsx)(ue,{size:20})}),p&&(0,B.jsxs)(`div`,{className:`chat-menu`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:async()=>{if(!(re||ce)){fe(!0),m(!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`);ie(!0)}catch(e){console.error(`[browser] Launch failed:`,e),alert(e instanceof Error?e.message:`Failed to launch browser`)}finally{fe(!1)}}},disabled:ce,children:[(0,B.jsx)(c,{size:14}),` Browser`,ce&&(0,B.jsx)(oe,{size:12,className:`spin`})]}),(0,B.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{m(!1),window.location.href=`/data`},children:[(0,B.jsx)(le,{size:14}),` Data`]}),(0,B.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{m(!1),window.location.href=`/graph`},children:[(0,B.jsx)(de,{size:14}),` Graph`]}),(0,B.jsx)(`div`,{className:`chat-menu-divider`}),(0,B.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:async()=>{if(h!==null){g(null),C(null);return}v(!0),x(null);try{let e=await fetch(`/api/admin/agents`);if(!e.ok)throw Error(`Failed to load agents`);g((await e.json()).agents??[])}catch(e){console.error(`[admin] agent list failed:`,e),x(e instanceof Error?e.message:String(e))}finally{v(!1)}},children:[(0,B.jsx)(ke,{size:14}),` Public`,_&&(0,B.jsx)(oe,{size:12,className:`spin`})]}),h!==null&&(0,B.jsxs)(`div`,{className:`chat-menu-agents`,children:[b&&(0,B.jsx)(`span`,{className:`chat-menu-agent-error`,children:b}),h.length===0&&!b&&(0,B.jsx)(`span`,{className:`chat-menu-agent-empty`,children:`No public agents configured`}),h.map(e=>(0,B.jsxs)(`div`,{className:`chat-menu-item chat-menu-agent-item`,children:[(0,B.jsx)(`span`,{className:`agent-status-dot ${e.status}`}),(0,B.jsxs)(`span`,{className:`agent-text`,children:[(0,B.jsx)(`span`,{className:`agent-display-name`,children:e.displayName}),(0,B.jsxs)(`span`,{className:`agent-slug`,children:[`/`,e.slug]})]}),S===e.slug?(0,B.jsxs)(`span`,{className:`agent-actions agent-confirm`,children:[(0,B.jsx)(`button`,{type:`button`,className:`agent-action-btn agent-confirm-yes`,title:`Confirm delete`,onClick:()=>{C(null),g(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,B.jsx)(f,{size:12})}),(0,B.jsx)(`button`,{type:`button`,className:`agent-action-btn agent-confirm-no`,title:`Cancel`,onClick:()=>C(null),children:(0,B.jsx)(he,{size:12})})]}):(0,B.jsxs)(`span`,{className:`agent-actions`,children:[(0,B.jsx)(`a`,{href:`${u}/${e.slug}`,target:`_blank`,rel:`noopener noreferrer`,className:`agent-action-btn`,title:`Open agent`,onClick:()=>m(!1),children:(0,B.jsx)(ke,{size:12})}),(0,B.jsx)(`button`,{type:`button`,className:`agent-action-btn agent-delete-btn`,title:`Delete agent`,onClick:()=>C(e.slug),children:(0,B.jsx)(i,{size:12})})]})]},e.slug))]}),(0,B.jsx)(`div`,{className:`chat-menu-divider`}),N?.updateAvailable?(0,B.jsxs)(`button`,{type:`button`,className:`chat-menu-version`,onClick:()=>{N.latest&&(ne(N),m(!1),te(!0))},children:[(0,B.jsx)(Ie,{size:14}),(0,B.jsxs)(`span`,{className:`version-installed`,children:[`v`,N.installed,(0,B.jsx)(`span`,{className:`version-update-dot`})]})]}):(0,B.jsxs)(`div`,{className:`chat-menu-version chat-menu-version-passive`,children:[(0,B.jsx)(Ie,{size:14}),(0,B.jsxs)(`span`,{className:`version-installed`,children:[N?`v${N.installed}`:`…`,N&&!N.updateAvailable&&(0,B.jsx)(`span`,{className:`version-uptodate-dot`})]})]}),(0,B.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{m(!1),L.handleLogout(),R.setMessages([])},children:[(0,B.jsx)(se,{size:14}),` Log out`]})]})]})]}),(0,B.jsxs)(`div`,{className:`chat-content`,children:[(0,B.jsx)(vE,{messages:R.messages,isStreaming:R.isStreaming,elapsedSeconds:ve.elapsedSeconds,sessionTurnStart:ve.sessionTurnStart,expandAll:L.expandAll,setExpandAll:L.setExpandAll,conversationCompacted:R.conversationCompacted,isCompacting:R.isCompacting,setShowCompactConfirm:s,handleComponentSubmit:R.handleComponentSubmit,effectiveSubmitted:R.effectiveSubmitted,selectionMode:I.selectionMode,selectedItems:I.selectedItems,toggleSelectItem:I.toggleSelectItem,sessionKey:L.sessionKey,setLightboxSrc:n,messageQueue:R.messageQueue,messageQueueRef:R.messageQueueRef,setQueue:R.setQueue,sendMessage:R.sendMessage,appState:L.appState,onboardingComplete:L.onboardingComplete}),(0,B.jsx)(yE,{offer:R.topicChangeOffer,onFreshStart:R.handleTopicFreshStart,onContinue:R.handleTopicContinue,disabled:R.isStreaming}),(0,B.jsx)(SE,{selectionMode:I.selectionMode,selectedItems:I.selectedItems,copyToast:I.copyToast||null,exitSelection:I.exitSelection,enterSelection:I.enterSelection,copySelected:I.copySelected,showCopyToast:I.showCopyToast,input:R.input,setInput:R.setInput,inputRef:e,pendingFiles:ye.pendingFiles,setPendingFiles:ye.setPendingFiles,isDragOver:ye.isDragOver,attachError:ye.attachError,fileInputRef:ye.fileInputRef,addFiles:ye.addFiles,removeFile:ye.removeFile,onDragOver:ye.onDragOver,onDragLeave:ye.onDragLeave,onDrop:ye.onDrop,isStreaming:R.isStreaming,wasPaused:R.wasPaused,messages:R.messages,messageQueueRef:R.messageQueueRef,setQueue:R.setQueue,sendMessage:R.sendMessage,stopStreaming:R.stopStreaming,disconnecting:L.disconnecting,handleDisconnect:L.handleDisconnect,claudeInfo:L.claudeInfo,setClaudeInfo:L.setClaudeInfo,setShowClaudeInfo:a,conversationId:L.conversationId,onNewConversation:R.startNewConversation,newConversationDisabled:R.isStreaming||R.isCompacting,onOpenConversations:async()=>{E(!0),A(!0),M(null);try{let e=await fetch(`/api/admin/sessions?session_key=${encodeURIComponent(L.sessionKey)}`);if(!e.ok)throw Error(`Failed to load conversations`);O((await e.json()).sessions??[])}catch(e){console.error(`[admin] conversation list failed:`,e),M(e instanceof Error?e.message:String(e))}finally{A(!1)}}})]}),I.copyToast&&(0,B.jsx)(`span`,{className:`copy-toast${I.copyToast===`failed`?` copy-toast-failed`:``}`,children:I.copyToast===`copied`?`Copied`:`Copy failed`}),(0,B.jsx)(CE,{show:T,onClose:()=>E(!1),conversationsLoading:k,conversationsError:j,conversationsList:D,setConversationsList:O,sessionKey:L.sessionKey,isStreaming:R.isStreaming,resetConversation:R.resetConversation,setMessages:R.setMessages,setConversationId:L.setConversationId}),(0,B.jsx)(wE,{src:t,onClose:()=>n(null)}),(0,B.jsx)(TE,{show:o,onClose:()=>s(!1),onConfirm:R.handleCompactNow}),(0,B.jsx)(EE,{show:r,onClose:()=>{a(!1),L.setClaudeInfo(null)},claudeInfo:L.claudeInfo,messages:R.messages,sessionElapsed:ve.sessionElapsed,conversationId:L.conversationId,contextModeHint:L.contextModeHint,handleContextModeToggle:L.handleContextModeToggle}),(0,B.jsx)(kE,{show:ee,onClose:()=>{te(!1),ge.current=!0},versionInfo:F,sessionKey:L.sessionKey,onUpgradeComplete:()=>P(null)}),re&&(0,B.jsx)(AE,{onClose:()=>ie(!1)})]})})}(0,ot.createRoot)(document.getElementById(`root`)).render((0,B.jsx)(jE,{}));
@@ -46,5 +46,5 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
46
46
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function I_(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var L_=Up(`DELETE`);function R_(){var e=z_.apply(void 0,arguments);return V_(e),e}function z_(){var e=[...arguments];if(e.length<2)return e[0];var t;if(e.length>2)return z_.apply(void 0,Jp(t=[R_(e[0],e[1])]).call(t,Hp(Yp(e).call(e,2))));var n=e[0],r=e[1];if(n instanceof Date&&r instanceof Date)return n.setTime(r.getTime()),n;var i,a=F_(nm(r));try{for(a.s();!(i=a.n()).done;){var o=i.value;Object.prototype.propertyIsEnumerable.call(r,o)&&(r[o]===L_?delete n[o]:n[o]===null||r[o]===null||typeof n[o]!=`object`||typeof r[o]!=`object`||rm(n[o])||rm(r[o])?n[o]=B_(r[o]):n[o]=z_(n[o],r[o]))}}catch(e){a.e(e)}finally{a.f()}return n}function B_(e){return rm(e)?Kd(e).call(e,(function(e){return B_(e)})):typeof e==`object`&&e?e instanceof Date?new Date(e.getTime()):z_({},e):e}function V_(e){for(var t=0,n=om(e);t<n.length;t++){var r=n[t];e[r]===L_?delete e[r]:typeof e[r]==`object`&&e[r]!==null&&V_(e[r])}}var H_=typeof window<`u`?window.Hammer||P_:function(){return function(){var e=function(){};return{on:e,off:e,destroy:e,emit:e,get:()=>({set:e})}}()};function U_(e){var t,n=this;this._cleanupQueue=[],this.active=!1,this._dom={container:e,overlay:document.createElement(`div`)},this._dom.overlay.classList.add(`vis-overlay`),this._dom.container.appendChild(this._dom.overlay),this._cleanupQueue.push((function(){n._dom.overlay.parentNode.removeChild(n._dom.overlay)}));var r=H_(this._dom.overlay);r.on(`tap`,vd(t=this._onTapOverlay).call(t,this)),this._cleanupQueue.push((function(){r.destroy()}));var i=[`tap`,`doubletap`,`press`,`pinch`,`pan`,`panstart`,`panmove`,`panend`];_m(i).call(i,(function(e){r.on(e,(function(e){e.srcEvent.stopPropagation()}))})),document&&document.body&&(this._onClick=function(t){(function(e,t){for(;e;){if(e===t)return!0;e=e.parentNode}return!1})(t.target,e)||n.deactivate()},document.body.addEventListener(`click`,this._onClick),this._cleanupQueue.push((function(){document.body.removeEventListener(`click`,n._onClick)}))),this._escListener=function(e){(`key`in e?e.key===`Escape`:e.keyCode===27)&&n.deactivate()}}Bh(U_.prototype),U_.current=null,U_.prototype.destroy=function(){var e,t;this.deactivate();var n,r=F_(Dm(e=Jm(t=this._cleanupQueue).call(t,0)).call(e));try{for(r.s();!(n=r.n()).done;)(0,n.value)()}catch(e){r.e(e)}finally{r.f()}},U_.prototype.activate=function(){U_.current&&U_.current.deactivate(),U_.current=this,this.active=!0,this._dom.overlay.style.display=`none`,this._dom.container.classList.add(`vis-active`),this.emit(`change`),this.emit(`activate`),document.body.addEventListener(`keydown`,this._escListener)},U_.prototype.deactivate=function(){this.active=!1,this._dom.overlay.style.display=`block`,this._dom.container.classList.remove(`vis-active`),document.body.removeEventListener(`keydown`,this._escListener),this.emit(`change`),this.emit(`deactivate`)},U_.prototype._onTapOverlay=function(e){this.activate(),e.srcEvent.stopPropagation()};var W_=Hr,G_=Ke,K_=TypeError,q_=function(e){if(W_(e))return e;throw new K_(G_(e)+` is not a constructor`)},J_=L,Y_=p,X_=cd,Z_=q_,Q_=Sn,$_=M,ev=sa,tv=s,nv=P(`Reflect`,`construct`),rv=Object.prototype,iv=[].push,av=tv((function(){function e(){}return!(nv((function(){}),[],e)instanceof e)})),ov=!tv((function(){nv((function(){}))})),sv=av||ov;J_({target:`Reflect`,stat:!0,forced:sv,sham:sv},{construct:function(e,t){Z_(e),Q_(t);var n=arguments.length<3?e:Z_(arguments[2]);if(ov&&!av)return nv(e,t,n);if(e===n){switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3])}var r=[null];return Y_(iv,r,t),new(Y_(X_,e,r))}var i=n.prototype,a=ev($_(i)?i:rv),o=Y_(e,a,t);return $_(o)?o:a}});var cv=r(N.Reflect.construct),lv=r(N.Object.getOwnPropertySymbols),uv={exports:{}},dv=L,fv=s,pv=j,mv=D.f,hv=O;dv({target:`Object`,stat:!0,forced:!hv||fv((function(){mv(1)})),sham:!hv},{getOwnPropertyDescriptor:function(e,t){return mv(pv(e),t)}});var gv=N.Object,_v=uv.exports=function(e,t){return gv.getOwnPropertyDescriptor(e,t)};gv.getOwnPropertyDescriptor.sham&&(_v.sham=!0);var vv=r(uv.exports),yv=tm,bv=j,xv=D,Sv=hr;L({target:`Object`,stat:!0,sham:!O},{getOwnPropertyDescriptors:function(e){for(var t,n,r=bv(e),i=xv.f,a=yv(r),o={},s=0;a.length>s;)(n=i(r,t=a[s++]))!==void 0&&Sv(o,t,n);return o}});var Cv=r(N.Object.getOwnPropertyDescriptors),wv={exports:{}},Tv=L,Ev=O,Dv=gi.f;Tv({target:`Object`,stat:!0,forced:Object.defineProperties!==Dv,sham:!Ev},{defineProperties:Dv});var Ov=N.Object,kv=wv.exports=function(e,t){return Ov.defineProperties(e,t)};Ov.defineProperties.sham&&(kv.sham=!0);var Av=r(wv.exports),jv=r(Qn);function U(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}var Mv=mh,Nv=r(Mv);L({target:`Object`,stat:!0},{setPrototypeOf:_l});var Pv=N.Object.setPrototypeOf,Fv=r(Pv),Iv=r(_d);function Lv(e,t){var n;return Lv=Fv?Iv(n=Fv).call(n):function(e,t){return e.__proto__=t,e},Lv(e,t)}function Rv(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Nv(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),er(e,`prototype`,{writable:!1}),t&&Lv(e,t)}function zv(e,t){if(t&&(Ku(t)===`object`||typeof t==`function`))return t;if(t!==void 0)throw TypeError(`Derived constructors may only return object or undefined`);return U(e)}var Bv=fh,Vv=r(Bv);function Hv(e){var t;return Hv=Fv?Iv(t=Vv).call(t):function(e){return e.__proto__||Vv(e)},Hv(e)}var Uv={exports:{}},Wv={exports:{}};(function(e){var t=Tu,n=Wu;function r(i){return e.exports=r=typeof t==`function`&&typeof n==`symbol`?function(e){return typeof e}:function(e){return e&&typeof t==`function`&&e.constructor===t&&e!==t.prototype?`symbol`:typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,r(i)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(Wv);var Gv=Wv.exports,Kv=gm,qv=_t,Jv=tm,Yv=D,Xv=_n,Zv=M,Qv=In,$v=Error,ey=v(``.replace),ty=String(new $v(`zxcasd`).stack),ny=/\n\s*at [^:]*:[^\n]*/,ry=ny.test(ty),iy=le,ay=!s((function(){var e=Error(`a`);return!(`stack`in e)||(Object.defineProperty(e,`stack`,iy(1,7)),e.stack!==7)})),oy=In,sy=function(e,t){if(ry&&typeof e==`string`&&!$v.prepareStackTrace)for(;t--;)e=ey(e,ny,``);return e},cy=ay,ly=Error.captureStackTrace,uy=gn,dy=ie,fy=Sn,W=Ke,G=bf,py=lr,my=F,hy=Mf,gy=Ef,_y=mf,vy=TypeError,yy=function(e,t){this.stopped=e,this.result=t},by=yy.prototype,xy=function(e,t,n){var r,i,a,o,s,c,l,u=n&&n.that,d=!(!n||!n.AS_ENTRIES),f=!(!n||!n.IS_RECORD),p=!(!n||!n.IS_ITERATOR),m=!(!n||!n.INTERRUPTED),h=uy(t,u),g=function(e){return r&&_y(r,`normal`,e),new yy(!0,e)},_=function(e){return d?(fy(e),m?h(e[0],e[1],g):h(e[0],e[1])):m?h(e,g):h(e)};if(f)r=e.iterator;else if(p)r=e;else{if(!(i=gy(e)))throw new vy(W(e)+` is not iterable`);if(G(i)){for(a=0,o=py(e);o>a;a++)if((s=_(e[a]))&&my(by,s))return s;return new yy(!1)}r=hy(e,i)}for(c=f?e.next:r.next;!(l=dy(c,r)).done;){try{s=_(l.value)}catch(e){_y(r,`throw`,e)}if(typeof s==`object`&&s&&my(by,s))return s}return new yy(!1)},Sy=hi,Cy=L,wy=F,Ty=qc,Ey=_l,Dy=function(e,t,n){for(var r=Jv(t),i=Xv.f,a=Yv.f,o=0;o<r.length;o++){var s=r[o];qv(e,s)||n&&qv(n,s)||i(e,s,a(t,s))}},Oy=sa,ky=In,Ay=le,jy=function(e,t){Zv(t)&&`cause`in t&&Qv(e,`cause`,t.cause)},My=function(e,t,n,r){cy&&(ly?ly(e,t):oy(e,`stack`,sy(n,r)))},Ny=xy,Py=function(e,t){return e===void 0?arguments.length<2?``:t:Sy(e)},Fy=jt(`toStringTag`),Iy=Error,Ly=[].push,Ry=function(e,t){var n,r=wy(zy,this);Ey?n=Ey(new Iy,r?Ty(this):zy):(n=r?this:Oy(zy),ky(n,Fy,`Error`)),t!==void 0&&ky(n,`message`,Py(t)),My(n,Ry,n.stack,1),arguments.length>2&&jy(n,arguments[2]);var i=[];return Ny(e,Ly,{that:i}),ky(n,`errors`,i),n};Ey?Ey(Ry,Iy):Dy(Ry,Iy,{name:!0});var zy=Ry.prototype=Oy(Iy.prototype,{constructor:Ay(1,Ry),message:Ay(1,``),name:Ay(1,`AggregateError`)});Cy({global:!0,constructor:!0,arity:2},{AggregateError:Ry});var By,Vy,Hy,Uy,Wy=P,Gy=Da,Ky=O,qy=jt(`species`),Jy=function(e){var t=Wy(e);Ky&&t&&!t[qy]&&Gy(t,qy,{configurable:!0,get:function(){return this}})},Yy=F,Xy=TypeError,Zy=function(e,t){if(Yy(t,e))return e;throw new Xy(`Incorrect invocation`)},Qy=Sn,$y=q_,eb=he,tb=jt(`species`),nb=function(e,t){var n,r=Qy(e).constructor;return r===void 0||eb(n=Qy(r)[tb])?t:$y(n)},rb=/(?:ipad|iphone|ipod).*applewebkit/i.test(De),ib=o,ab=p,ob=gn,sb=E,cb=_t,lb=s,ub=Wi,db=qs,fb=Gt,pb=xh,mb=rb,hb=Od,gb=ib.setImmediate,_b=ib.clearImmediate,vb=ib.process,yb=ib.Dispatch,bb=ib.Function,xb=ib.MessageChannel,Sb=ib.String,Cb=0,wb={},Tb=`onreadystatechange`;lb((function(){By=ib.location}));var Eb=function(e){if(cb(wb,e)){var t=wb[e];delete wb[e],t()}},Db=function(e){return function(){Eb(e)}},Ob=function(e){Eb(e.data)},kb=function(e){ib.postMessage(Sb(e),By.protocol+`//`+By.host)};gb&&_b||(gb=function(e){pb(arguments.length,1);var t=sb(e)?e:bb(e),n=db(arguments,1);return wb[++Cb]=function(){ab(t,void 0,n)},Vy(Cb),Cb},_b=function(e){delete wb[e]},hb?Vy=function(e){vb.nextTick(Db(e))}:yb&&yb.now?Vy=function(e){yb.now(Db(e))}:xb&&!mb?(Uy=(Hy=new xb).port2,Hy.port1.onmessage=Ob,Vy=ob(Uy.postMessage,Uy)):ib.addEventListener&&sb(ib.postMessage)&&!ib.importScripts&&By&&By.protocol!==`file:`&&!lb(kb)?(Vy=kb,ib.addEventListener(`message`,Ob,!1)):Vy=Tb in fb(`script`)?function(e){ub.appendChild(fb(`script`))[Tb]=function(){ub.removeChild(this),Eb(e)}}:function(e){setTimeout(Db(e),0)});var Ab={set:gb,clear:_b},jb=function(){this.head=null,this.tail=null};jb.prototype={add:function(e){var t={item:e,next:null},n=this.tail;n?n.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return(this.head=e.next)===null&&(this.tail=null),e.item}};var Mb,Nb,Pb,Fb,Ib,Lb=jb,Rb=/ipad|iphone|ipod/i.test(De)&&typeof Pebble<`u`,zb=/web0s(?!.*chrome)/i.test(De),Bb=o,Vb=gn,Hb=D.f,Ub=Ab.set,Wb=Lb,Gb=rb,Kb=Rb,qb=zb,Jb=Od,Yb=Bb.MutationObserver||Bb.WebKitMutationObserver,Xb=Bb.document,Zb=Bb.process,Qb=Bb.Promise,$b=Hb(Bb,`queueMicrotask`),ex=$b&&$b.value;if(!ex){var tx=new Wb,nx=function(){var e,t;for(Jb&&(e=Zb.domain)&&e.exit();t=tx.get();)try{t()}catch(e){throw tx.head&&Mb(),e}e&&e.enter()};Gb||Jb||qb||!Yb||!Xb?!Kb&&Qb&&Qb.resolve?((Fb=Qb.resolve(void 0)).constructor=Qb,Ib=Vb(Fb.then,Fb),Mb=function(){Ib(nx)}):Jb?Mb=function(){Zb.nextTick(nx)}:(Ub=Vb(Ub,Bb),Mb=function(){Ub(nx)}):(Nb=!0,Pb=Xb.createTextNode(``),new Yb(nx).observe(Pb,{characterData:!0}),Mb=function(){Pb.data=Nb=!Nb}),ex=function(e){tx.head||Mb(),tx.add(e)}}var rx=ex,ix=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}},ax=o.Promise,ox=typeof Deno==`object`&&Deno&&typeof Deno.version==`object`,sx=!ox&&!Od&&typeof window==`object`&&typeof document==`object`,cx=o,lx=ax,ux=E,dx=fn,fx=Or,px=jt,mx=sx,hx=ox,gx=Pe,_x=lx&&lx.prototype,vx=px(`species`),yx=!1,bx=ux(cx.PromiseRejectionEvent),xx={CONSTRUCTOR:dx(`Promise`,(function(){var e=fx(lx),t=e!==String(lx);if(!t&&gx===66||!_x.catch||!_x.finally)return!0;if(!gx||gx<51||!/native code/.test(e)){var n=new lx((function(e){e(1)})),r=function(e){e((function(){}),(function(){}))};if((n.constructor={})[vx]=r,!(yx=n.then((function(){}))instanceof r))return!0}return!t&&(mx||hx)&&!bx})),REJECTION_EVENT:bx,SUBCLASSING:yx},Sx={},Cx=Xe,wx=TypeError,Tx=function(e){var t,n;this.promise=new e((function(e,r){if(t!==void 0||n!==void 0)throw new wx(`Bad Promise constructor`);t=e,n=r})),this.resolve=Cx(t),this.reject=Cx(n)};Sx.f=function(e){return new Tx(e)};var Ex,Dx,Ox=L,kx=Od,Ax=o,jx=ie,Mx=Ta,Nx=Xa,Px=Jy,Fx=Xe,Ix=E,Lx=M,Rx=Zy,zx=nb,Bx=Ab.set,Vx=rx,Hx=function(e,t){try{arguments.length===1?console.error(e):console.error(e,t)}catch{}},Ux=ix,Wx=Lb,Gx=po,Kx=ax,qx=xx,Jx=Sx,Yx=`Promise`,Xx=qx.CONSTRUCTOR,Zx=qx.REJECTION_EVENT,Qx=Gx.getterFor(Yx),$x=Gx.set,eS=Kx&&Kx.prototype,tS=Kx,nS=eS,rS=Ax.TypeError,iS=Ax.document,aS=Ax.process,oS=Jx.f,sS=oS,cS=!!(iS&&iS.createEvent&&Ax.dispatchEvent),lS=`unhandledrejection`,uS=function(e){var t;return!(!Lx(e)||!Ix(t=e.then))&&t},dS=function(e,t){var n,r,i,a=t.value,o=t.state===1,s=o?e.ok:e.fail,c=e.resolve,l=e.reject,u=e.domain;try{s?(o||(t.rejection===2&&gS(t),t.rejection=1),!0===s?n=a:(u&&u.enter(),n=s(a),u&&(u.exit(),i=!0)),n===e.promise?l(new rS(`Promise-chain cycle`)):(r=uS(n))?jx(r,n,c,l):c(n)):l(a)}catch(e){u&&!i&&u.exit(),l(e)}},fS=function(e,t){e.notified||(e.notified=!0,Vx((function(){for(var n,r=e.reactions;n=r.get();)dS(n,e);e.notified=!1,t&&!e.rejection&&mS(e)})))},pS=function(e,t,n){var r,i;cS?((r=iS.createEvent(`Event`)).promise=t,r.reason=n,r.initEvent(e,!1,!0),Ax.dispatchEvent(r)):r={promise:t,reason:n},!Zx&&(i=Ax[`on`+e])?i(r):e===lS&&Hx(`Unhandled promise rejection`,n)},mS=function(e){jx(Bx,Ax,(function(){var t,n=e.facade,r=e.value;if(hS(e)&&(t=Ux((function(){kx?aS.emit(`unhandledRejection`,r,n):pS(lS,n,r)})),e.rejection=kx||hS(e)?2:1,t.error))throw t.value}))},hS=function(e){return e.rejection!==1&&!e.parent},gS=function(e){jx(Bx,Ax,(function(){var t=e.facade;kx?aS.emit(`rejectionHandled`,t):pS(`rejectionhandled`,t,e.value)}))},_S=function(e,t,n){return function(r){e(t,r,n)}},vS=function(e,t,n){e.done||(e.done=!0,n&&(e=n),e.value=t,e.state=2,fS(e,!0))},yS=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw new rS(`Promise can't be resolved itself`);var r=uS(t);r?Vx((function(){var n={done:!1};try{jx(r,t,_S(yS,n,e),_S(vS,n,e))}catch(t){vS(n,t,e)}})):(e.value=t,e.state=1,fS(e,!1))}catch(t){vS({done:!1},t,e)}}};Xx&&(nS=(tS=function(e){Rx(this,nS),Fx(e),jx(Ex,this);var t=Qx(this);try{e(_S(yS,t),_S(vS,t))}catch(e){vS(t,e)}}).prototype,(Ex=function(e){$x(this,{type:Yx,done:!1,notified:!1,parent:!1,reactions:new Wx,rejection:!1,state:0,value:void 0})}).prototype=Mx(nS,`then`,(function(e,t){var n=Qx(this),r=oS(zx(this,tS));return n.parent=!0,r.ok=!Ix(e)||e,r.fail=Ix(t)&&t,r.domain=kx?aS.domain:void 0,n.state===0?n.reactions.add(r):Vx((function(){dS(r,n)})),r.promise})),Dx=function(){var e=new Ex,t=Qx(e);this.promise=e,this.resolve=_S(yS,t),this.reject=_S(vS,t)},Jx.f=oS=function(e){return e===tS||e===void 0?new Dx(e):sS(e)}),Ox({global:!0,constructor:!0,wrap:!0,forced:Xx},{Promise:tS}),Nx(tS,Yx,!1,!0),Px(Yx);var bS=ax,xS=xx.CONSTRUCTOR||!Jf((function(e){bS.all(e).then(void 0,(function(){}))})),SS=ie,CS=Xe,wS=Sx,TS=ix,ES=xy;L({target:`Promise`,stat:!0,forced:xS},{all:function(e){var t=this,n=wS.f(t),r=n.resolve,i=n.reject,a=TS((function(){var n=CS(t.resolve),a=[],o=0,s=1;ES(e,(function(e){var c=o++,l=!1;s++,SS(n,t,e).then((function(e){l||(l=!0,a[c]=e,--s||r(a))}),i)})),--s||r(a)}));return a.error&&i(a.value),n.promise}});var DS=L,OS=xx.CONSTRUCTOR;ax&&ax.prototype,DS({target:`Promise`,proto:!0,forced:OS,real:!0},{catch:function(e){return this.then(void 0,e)}});var kS=ie,AS=Xe,jS=Sx,MS=ix,NS=xy;L({target:`Promise`,stat:!0,forced:xS},{race:function(e){var t=this,n=jS.f(t),r=n.reject,i=MS((function(){var i=AS(t.resolve);NS(e,(function(e){kS(i,t,e).then(n.resolve,r)}))}));return i.error&&r(i.value),n.promise}});var PS=ie,FS=Sx;L({target:`Promise`,stat:!0,forced:xx.CONSTRUCTOR},{reject:function(e){var t=FS.f(this);return PS(t.reject,void 0,e),t.promise}});var IS=Sn,LS=M,RS=Sx,zS=function(e,t){if(IS(e),LS(t)&&t.constructor===e)return t;var n=RS.f(e);return(0,n.resolve)(t),n.promise},BS=L,VS=ax,HS=xx.CONSTRUCTOR,US=zS,K=P(`Promise`),WS=!HS;BS({target:`Promise`,stat:!0,forced:!0},{resolve:function(e){return US(WS&&this===K?VS:this,e)}});var GS=ie,KS=Xe,qS=Sx,q=ix,JS=xy;L({target:`Promise`,stat:!0,forced:xS},{allSettled:function(e){var t=this,n=qS.f(t),r=n.resolve,i=n.reject,a=q((function(){var n=KS(t.resolve),i=[],a=0,o=1;JS(e,(function(e){var s=a++,c=!1;o++,GS(n,t,e).then((function(e){c||(c=!0,i[s]={status:`fulfilled`,value:e},--o||r(i))}),(function(e){c||(c=!0,i[s]={status:`rejected`,reason:e},--o||r(i))}))})),--o||r(i)}));return a.error&&i(a.value),n.promise}});var YS=ie,J=Xe,XS=P,ZS=Sx,QS=ix,$S=xy,eC=`No one promise resolved`;L({target:`Promise`,stat:!0,forced:xS},{any:function(e){var t=this,n=XS(`AggregateError`),r=ZS.f(t),i=r.resolve,a=r.reject,o=QS((function(){var r=J(t.resolve),o=[],s=0,c=1,l=!1;$S(e,(function(e){var u=s++,d=!1;c++,YS(r,t,e).then((function(e){d||l||(l=!0,i(e))}),(function(e){d||l||(d=!0,o[u]=e,--c||a(new n(o,eC)))}))})),--c||a(new n(o,eC))}));return o.error&&a(o.value),r.promise}});var tC=L,nC=ax,rC=s,iC=P,aC=E,oC=nb,sC=zS,cC=nC&&nC.prototype;tC({target:`Promise`,proto:!0,real:!0,forced:!!nC&&rC((function(){cC.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=oC(this,iC(`Promise`)),n=aC(e);return this.then(n?function(n){return sC(t,e()).then((function(){return n}))}:e,n?function(n){return sC(t,e()).then((function(){throw n}))}:e)}});var lC=N.Promise,uC=Sx;L({target:`Promise`,stat:!0},{withResolvers:function(){var e=uC.f(this);return{promise:e.promise,resolve:e.resolve,reject:e.reject}}});var dC=lC,fC=Sx,pC=ix;L({target:`Promise`,stat:!0,forced:!0},{try:function(e){var t=fC.f(this),n=pC(e);return(n.error?t.reject:t.resolve)(n.value),t.promise}});var mC=dC,hC=Em;(function(e){var t=Gv.default,n=$n,r=Tu,i=Mv,a=Bv,o=Kv,s=hp,c=Pv,l=mC,u=hC,d=Ip;function f(){e.exports=f=function(){return m},e.exports.__esModule=!0,e.exports.default=e.exports;var p,m={},h=Object.prototype,g=h.hasOwnProperty,_=n||function(e,t,n){e[t]=n.value},v=typeof r==`function`?r:{},y=v.iterator||`@@iterator`,b=v.asyncIterator||`@@asyncIterator`,x=v.toStringTag||`@@toStringTag`;function S(e,t,r){return n(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{S({},``)}catch{S=function(e,t,n){return e[t]=n}}function ee(e,t,n,r){var a=i((t&&t.prototype instanceof D?t:D).prototype);return _(a,`_invoke`,{value:se(e,n,new de(r||[]))}),a}function C(e,t,n){try{return{type:`normal`,arg:e.call(t,n)}}catch(e){return{type:`throw`,arg:e}}}m.wrap=ee;var te=`suspendedStart`,w=`suspendedYield`,ne=`executing`,T=`completed`,E={};function D(){}function O(){}function k(){}var re={};S(re,y,(function(){return this}));var ie=a&&a(a(fe([])));ie&&ie!==h&&g.call(ie,y)&&(re=ie);var A=k.prototype=D.prototype=i(re);function ae(e){var t;o(t=[`next`,`throw`,`return`]).call(t,(function(t){S(e,t,(function(e){return this._invoke(t,e)}))}))}function oe(e,n){function r(i,a,o,s){var c=C(e[i],e,a);if(c.type!==`throw`){var l=c.arg,u=l.value;return u&&t(u)==`object`&&g.call(u,`__await`)?n.resolve(u.__await).then((function(e){r(`next`,e,o,s)}),(function(e){r(`throw`,e,o,s)})):n.resolve(u).then((function(e){l.value=e,o(l)}),(function(e){return r(`throw`,e,o,s)}))}s(c.arg)}var i;_(this,`_invoke`,{value:function(e,t){function a(){return new n((function(n,i){r(e,t,n,i)}))}return i=i?i.then(a,a):a()}})}function se(e,t,n){var r=te;return function(i,a){if(r===ne)throw Error(`Generator is already running`);if(r===T){if(i===`throw`)throw a;return{value:p,done:!0}}for(n.method=i,n.arg=a;;){var o=n.delegate;if(o){var s=ce(o,n);if(s){if(s===E)continue;return s}}if(n.method===`next`)n.sent=n._sent=n.arg;else if(n.method===`throw`){if(r===te)throw r=T,n.arg;n.dispatchException(n.arg)}else n.method===`return`&&n.abrupt(`return`,n.arg);r=ne;var c=C(e,t,n);if(c.type===`normal`){if(r=n.done?T:w,c.arg===E)continue;return{value:c.arg,done:n.done}}c.type===`throw`&&(r=T,n.method=`throw`,n.arg=c.arg)}}}function ce(e,t){var n=t.method,r=e.iterator[n];if(r===p)return t.delegate=null,n===`throw`&&e.iterator.return&&(t.method=`return`,t.arg=p,ce(e,t),t.method===`throw`)||n!==`return`&&(t.method=`throw`,t.arg=TypeError(`The iterator does not provide a '`+n+`' method`)),E;var i=C(r,e.iterator,t.arg);if(i.type===`throw`)return t.method=`throw`,t.arg=i.arg,t.delegate=null,E;var a=i.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,t.method!==`return`&&(t.method=`next`,t.arg=p),t.delegate=null,E):a:(t.method=`throw`,t.arg=TypeError(`iterator result is not an object`),t.delegate=null,E)}function le(e){var t,n={tryLoc:e[0]};1 in e&&(n.catchLoc=e[1]),2 in e&&(n.finallyLoc=e[2],n.afterLoc=e[3]),s(t=this.tryEntries).call(t,n)}function ue(e){var t=e.completion||{};t.type=`normal`,delete t.arg,e.completion=t}function de(e){this.tryEntries=[{tryLoc:`root`}],o(e).call(e,le,this),this.reset(!0)}function fe(e){if(e||e===``){var n=e[y];if(n)return n.call(e);if(typeof e.next==`function`)return e;if(!isNaN(e.length)){var r=-1,i=function t(){for(;++r<e.length;)if(g.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=p,t.done=!0,t};return i.next=i}}throw TypeError(t(e)+` is not iterable`)}return O.prototype=k,_(A,`constructor`,{value:k,configurable:!0}),_(k,`constructor`,{value:O,configurable:!0}),O.displayName=S(k,x,`GeneratorFunction`),m.isGeneratorFunction=function(e){var t=typeof e==`function`&&e.constructor;return!!t&&(t===O||(t.displayName||t.name)===`GeneratorFunction`)},m.mark=function(e){return c?c(e,k):(e.__proto__=k,S(e,x,`GeneratorFunction`)),e.prototype=i(A),e},m.awrap=function(e){return{__await:e}},ae(oe.prototype),S(oe.prototype,b,(function(){return this})),m.AsyncIterator=oe,m.async=function(e,t,n,r,i){i===void 0&&(i=l);var a=new oe(ee(e,t,n,r),i);return m.isGeneratorFunction(t)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},ae(A),S(A,x,`Generator`),S(A,y,(function(){return this})),S(A,`toString`,(function(){return`[object Generator]`})),m.keys=function(e){var t=Object(e),n=[];for(var r in t)s(n).call(n,r);return u(n).call(n),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},m.values=fe,de.prototype={constructor:de,reset:function(e){var t;if(this.prev=0,this.next=0,this.sent=this._sent=p,this.done=!1,this.delegate=null,this.method=`next`,this.arg=p,o(t=this.tryEntries).call(t,ue),!e)for(var n in this)n.charAt(0)===`t`&&g.call(this,n)&&!isNaN(+d(n).call(n,1))&&(this[n]=p)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if(e.type===`throw`)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(n,r){return a.type=`throw`,a.arg=e,t.next=n,r&&(t.method=`next`,t.arg=p),!!r}for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r],a=i.completion;if(i.tryLoc===`root`)return n(`end`);if(i.tryLoc<=this.prev){var o=g.call(i,`catchLoc`),s=g.call(i,`finallyLoc`);if(o&&s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(o){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!s)throw Error(`try statement without catch or finally`);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&g.call(r,`finallyLoc`)&&this.prev<r.finallyLoc){var i=r;break}}i&&(e===`break`||e===`continue`)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method=`next`,this.next=i.finallyLoc,E):this.complete(a)},complete:function(e,t){if(e.type===`throw`)throw e.arg;return e.type===`break`||e.type===`continue`?this.next=e.arg:e.type===`return`?(this.rval=this.arg=e.arg,this.method=`return`,this.next=`end`):e.type===`normal`&&t&&(this.next=t),E},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),ue(n),E}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if(r.type===`throw`){var i=r.arg;ue(n)}return i}}throw Error(`illegal catch attempt`)},delegateYield:function(e,t,n){return this.delegate={iterator:fe(e),resultName:t,nextLoc:n},this.method===`next`&&(this.arg=p),E}},m}e.exports=f,e.exports.__esModule=!0,e.exports.default=e.exports})(Uv);var gC=(0,Uv.exports)(),_C=gC;try{regeneratorRuntime=gC}catch{typeof globalThis==`object`?globalThis.regeneratorRuntime=gC:Function(`r`,`regeneratorRuntime = r`)(gC)}var vC=r(_C),yC={exports:{}},bC=s((function(){if(typeof ArrayBuffer==`function`){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,`a`,{value:8})}})),xC=s,SC=M,CC=S,wC=bC,TC=Object.isExtensible,EC=xC((function(){TC(1)}))||wC?function(e){return!!SC(e)&&(!wC||CC(e)!==`ArrayBuffer`)&&(!TC||TC(e))}:TC,DC=!s((function(){return Object.isExtensible(Object.preventExtensions({}))})),OC=L,kC=v,AC=Ei,jC=M,MC=_t,NC=_n.f,PC=ca,FC=da,IC=EC,LC=DC,RC=!1,zC=St(`meta`),BC=0,VC=function(e){NC(e,zC,{value:{objectID:`O`+ BC++,weakData:{}}})},HC=yC.exports={enable:function(){HC.enable=function(){},RC=!0;var e=PC.f,t=kC([].splice),n={};n[zC]=1,e(n).length&&(PC.f=function(n){for(var r=e(n),i=0,a=r.length;i<a;i++)if(r[i]===zC){t(r,i,1);break}return r},OC({target:`Object`,stat:!0,forced:!0},{getOwnPropertyNames:FC.f}))},fastKey:function(e,t){if(!jC(e))return typeof e==`symbol`?e:(typeof e==`string`?`S`:`P`)+e;if(!MC(e,zC)){if(!IC(e))return`F`;if(!t)return`E`;VC(e)}return e[zC].objectID},getWeakData:function(e,t){if(!MC(e,zC)){if(!IC(e))return!0;if(!t)return!1;VC(e)}return e[zC].weakData},onFreeze:function(e){return LC&&RC&&IC(e)&&!MC(e,zC)&&VC(e),e}};AC[zC]=!0;var UC=yC.exports,WC=L,GC=o,KC=UC,qC=s,JC=In,YC=xy,XC=Zy,ZC=E,QC=M,$C=he,ew=Xa,tw=_n.f,nw=xo.forEach,rw=O,iw=po.set,aw=po.getterFor,ow=function(e,t,n){var r,i=e.indexOf(`Map`)!==-1,a=e.indexOf(`Weak`)!==-1,o=i?`set`:`add`,s=GC[e],c=s&&s.prototype,l={};if(rw&&ZC(s)&&(a||c.forEach&&!qC((function(){new s().entries().next()})))){var u=(r=t((function(t,n){iw(XC(t,u),{type:e,collection:new s}),$C(n)||YC(n,t[o],{that:t,AS_ENTRIES:i})}))).prototype,d=aw(e);nw([`add`,`clear`,`delete`,`forEach`,`get`,`has`,`set`,`keys`,`values`,`entries`],(function(e){var t=e===`add`||e===`set`;!(e in c)||a&&e===`clear`||JC(u,e,(function(n,r){var i=d(this).collection;if(!t&&a&&!QC(n))return e===`get`&&void 0;var o=i[e](n===0?0:n,r);return t?this:o}))})),a||tw(u,`size`,{configurable:!0,get:function(){return d(this).collection.size}})}else r=n.getConstructor(t,e,i,o),KC.enable();return ew(r,e,!1,!0),l[e]=r,WC({global:!0,forced:!0},l),a||n.setStrong(r,e,i),r},sw=Ta,cw=sa,lw=Da,uw=function(e,t,n){for(var r in t)n&&n.unsafe&&e[r]?e[r]=t[r]:sw(e,r,t[r],n);return e},dw=gn,fw=Zy,pw=he,mw=xy,hw=Pl,gw=Fl,_w=Jy,vw=O,yw=UC.fastKey,bw=po.set,xw=po.getterFor,Sw={getConstructor:function(e,t,n,r){var i=e((function(e,i){fw(e,a),bw(e,{type:t,index:cw(null),first:void 0,last:void 0,size:0}),vw||(e.size=0),pw(i)||mw(i,e[r],{that:e,AS_ENTRIES:n})})),a=i.prototype,o=xw(t),s=function(e,t,n){var r,i,a=o(e),s=c(e,t);return s?s.value=n:(a.last=s={index:i=yw(t,!0),key:t,value:n,previous:r=a.last,next:void 0,removed:!1},a.first||=s,r&&(r.next=s),vw?a.size++:e.size++,i!==`F`&&(a.index[i]=s)),e},c=function(e,t){var n,r=o(e),i=yw(t);if(i!==`F`)return r.index[i];for(n=r.first;n;n=n.next)if(n.key===t)return n};return uw(a,{clear:function(){for(var e=o(this),t=e.index,n=e.first;n;)n.removed=!0,n.previous&&=n.previous.next=void 0,delete t[n.index],n=n.next;e.first=e.last=void 0,vw?e.size=0:this.size=0},delete:function(e){var t=this,n=o(t),r=c(t,e);if(r){var i=r.next,a=r.previous;delete n.index[r.index],r.removed=!0,a&&(a.next=i),i&&(i.previous=a),n.first===r&&(n.first=i),n.last===r&&(n.last=a),vw?n.size--:t.size--}return!!r},forEach:function(e){for(var t,n=o(this),r=dw(e,arguments.length>1?arguments[1]:void 0);t=t?t.next:n.first;)for(r(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!c(this,e)}}),uw(a,n?{get:function(e){var t=c(this,e);return t&&t.value},set:function(e,t){return s(this,e===0?0:e,t)}}:{add:function(e){return s(this,e=e===0?0:e,e)}}),vw&&lw(a,`size`,{configurable:!0,get:function(){return o(this).size}}),i},setStrong:function(e,t,n){var r=t+` Iterator`,i=xw(t),a=xw(r);hw(e,t,(function(e,t){bw(this,{type:r,target:e,state:i(e),kind:t,last:void 0})}),(function(){for(var e=a(this),t=e.kind,n=e.last;n&&n.removed;)n=n.previous;return e.target&&(e.last=n=n?n.next:e.state.first)?gw(t===`keys`?n.key:t===`values`?n.value:[n.key,n.value],!1):(e.target=void 0,gw(void 0,!0))}),n?`entries`:`values`,!n,!0),_w(t)}};ow(`Map`,(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),Sw);var Cw=r(N.Map),ww=xo.some;L({target:`Array`,proto:!0,forced:!Dd(`some`)},{some:function(e){return ww(this,e,arguments.length>1?arguments[1]:void 0)}});var Tw=fd(`Array`,`some`),Ew=F,Dw=Tw,Ow=Array.prototype,kw=r((function(e){var t=e.some;return e===Ow||Ew(Ow,e)&&t===Ow.some?Dw:t})),Aw=fd(`Array`,`keys`),jw=wr,Mw=_t,Nw=F,Pw=Aw,Fw=Array.prototype,Iw={DOMTokenList:!0,NodeList:!0},Lw=r((function(e){var t=e.keys;return e===Fw||Nw(Fw,e)&&t===Fw.keys||Mw(Iw,jw(e))?Pw:t})),Rw=_a,zw=Math.floor,Bw=function(e,t){var n=e.length,r=zw(n/2);return n<8?Vw(e,t):Hw(e,Bw(Rw(e,0,r),t),Bw(Rw(e,r),t),t)},Vw=function(e,t){for(var n,r,i=e.length,a=1;a<i;){for(r=a,n=e[a];r&&t(e[r-1],n)>0;)e[r]=e[--r];r!==a++&&(e[r]=n)}return e},Hw=function(e,t,n,r){for(var i=t.length,a=n.length,o=0,s=0;o<i||s<a;)e[o+s]=o<i&&s<a?r(t[o],n[s])<=0?t[o++]:n[s++]:o<i?t[o++]:n[s++];return e},Uw=Bw,Ww=De.match(/firefox\/(\d+)/i),Gw=!!Ww&&+Ww[1],Kw=/MSIE|Trident/.test(De),qw=De.match(/AppleWebKit\/(\d+)\./),Jw=!!qw&&+qw[1],Yw=L,Xw=v,Zw=Xe,Qw=mt,$w=lr,eT=Am,tT=hi,nT=s,rT=Uw,iT=Dd,aT=Gw,oT=Kw,sT=Pe,cT=Jw,lT=[],uT=Xw(lT.sort),dT=Xw(lT.push),fT=nT((function(){lT.sort(void 0)})),pT=nT((function(){lT.sort(null)})),mT=iT(`sort`),hT=!nT((function(){if(sT)return sT<70;if(!(aT&&aT>3)){if(oT)return!0;if(cT)return cT<603;var e,t,n,r,i=``;for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:n=3;break;case 68:case 71:n=4;break;default:n=2}for(r=0;r<47;r++)lT.push({k:t+r,v:n})}for(lT.sort((function(e,t){return t.v-e.v})),r=0;r<lT.length;r++)t=lT[r].k.charAt(0),i.charAt(i.length-1)!==t&&(i+=t);return i!==`DGBEFHACIJK`}}));Yw({target:`Array`,proto:!0,forced:fT||!pT||!mT||!hT},{sort:function(e){e!==void 0&&Zw(e);var t=Qw(this);if(hT)return e===void 0?uT(t):uT(t,e);var n,r,i=[],a=$w(t);for(r=0;r<a;r++)r in t&&dT(i,t[r]);for(rT(i,function(e){return function(t,n){return n===void 0?-1:t===void 0?1:e===void 0?tT(t)>tT(n)?1:-1:+e(t,n)||0}}(e)),n=$w(i),r=0;r<n;)t[r]=i[r++];for(;r<a;)eT(t,r++);return t}});var gT=fd(`Array`,`sort`),_T=F,vT=gT,yT=Array.prototype,bT=r((function(e){var t=e.sort;return e===yT||_T(yT,e)&&t===yT.sort?vT:t})),xT=fd(`Array`,`values`),ST=wr,CT=_t,wT=F,TT=xT,ET=Array.prototype,DT={DOMTokenList:!0,NodeList:!0},OT=r((function(e){var t=e.values;return e===ET||wT(ET,e)&&t===ET.values||CT(DT,ST(e))?TT:t})),kT=r(Uu),AT=fd(`Array`,`entries`),jT=wr,MT=_t,NT=F,PT=AT,FT=Array.prototype,IT={DOMTokenList:!0,NodeList:!0},LT=r((function(e){var t=e.entries;return e===FT||NT(FT,e)&&t===FT.entries||MT(IT,jT(e))?PT:t}));let RT,zT=new Uint8Array(16);function BT(){if(!RT&&(RT=typeof crypto<`u`&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!RT))throw Error(`crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported`);return RT(zT)}let VT=[];for(let e=0;e<256;++e)VT.push((e+256).toString(16).slice(1));var HT={randomUUID:typeof crypto<`u`&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function UT(e,t,n){if(HT.randomUUID&&!t&&!e)return HT.randomUUID();let r=(e||={}).random||(e.rng||BT)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n||=0;for(let e=0;e<16;++e)t[n+e]=r[e];return t}return function(e,t=0){return VT[e[t+0]]+VT[e[t+1]]+VT[e[t+2]]+VT[e[t+3]]+`-`+VT[e[t+4]]+VT[e[t+5]]+`-`+VT[e[t+6]]+VT[e[t+7]]+`-`+VT[e[t+8]]+VT[e[t+9]]+`-`+VT[e[t+10]]+VT[e[t+11]]+VT[e[t+12]]+VT[e[t+13]]+VT[e[t+14]]+VT[e[t+15]]}(r)}function WT(e){return typeof e==`string`||typeof e==`number`}var GT=function(){function e(n){t(this,e),Zu(this,`_queue`,[]),Zu(this,`_timeout`,null),Zu(this,`_extended`,null),this.delay=null,this.max=1/0,this.setOptions(n)}return Xu(e,[{key:`setOptions`,value:function(e){e&&e.delay!==void 0&&(this.delay=e.delay),e&&e.max!==void 0&&(this.max=e.max),this._flushIfNeeded()}},{key:`destroy`,value:function(){if(this.flush(),this._extended){for(var e=this._extended.object,t=this._extended.methods,n=0;n<t.length;n++){var r=t[n];r.original?e[r.name]=r.original:delete e[r.name]}this._extended=null}}},{key:`replace`,value:function(e,t){var n=this,r=e[t];if(!r)throw Error(`Method `+t+` undefined`);e[t]=function(){var e=[...arguments];n.queue({args:e,fn:r,context:this})}}},{key:`queue`,value:function(e){typeof e==`function`?this._queue.push({fn:e}):this._queue.push(e),this._flushIfNeeded()}},{key:`_flushIfNeeded`,value:function(){var e=this;this._queue.length>this.max&&this.flush(),this._timeout!=null&&(clearTimeout(this._timeout),this._timeout=null),this.queue.length>0&&typeof this.delay==`number`&&(this._timeout=H((function(){e.flush()}),this.delay))}},{key:`flush`,value:function(){var e,t;_m(e=Jm(t=this._queue).call(t,0)).call(e,(function(e){e.fn.apply(e.context||e.fn,e.args||[])}))}}],[{key:`extend`,value:function(t,n){var r=new e(n);if(t.flush!==void 0)throw Error(`Target object already has a property flush`);t.flush=function(){r.flush()};var i=[{name:`flush`,original:void 0}];if(n&&n.replace)for(var a=0;a<n.replace.length;a++){var o=n.replace[a];i.push({name:o,original:t[o]}),r.replace(t,o)}return r._extended={object:t,methods:i},r}}]),e}(),KT=function(){function e(){t(this,e),Zu(this,`_subscribers`,{"*":[],add:[],remove:[],update:[]}),Zu(this,`subscribe`,e.prototype.on),Zu(this,`unsubscribe`,e.prototype.off)}return Xu(e,[{key:`_trigger`,value:function(e,t,n){var r,i;if(e===`*`)throw Error(`Cannot trigger event *`);_m(r=Jp(i=[]).call(i,Hp(this._subscribers[e]),Hp(this._subscribers[`*`]))).call(r,(function(r){r(e,t,n??null)}))}},{key:`on`,value:function(e,t){typeof t==`function`&&this._subscribers[e].push(t)}},{key:`off`,value:function(e,t){var n;this._subscribers[e]=Bd(n=this._subscribers[e]).call(n,(function(e){return e!==t}))}}]),e}();ow(`Set`,(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),Sw);var qT=r(N.Set),JT=r(Mf);function YT(e,t){var n=Up!==void 0&&$f(e)||e[`@@iterator`];if(!n){if(rm(e)||(n=function(e,t){var n;if(e){if(typeof e==`string`)return XT(e,t);var r=Yp(n=Object.prototype.toString.call(e)).call(n,8,-1);if(r===`Object`&&e.constructor&&(r=e.constructor.name),r===`Map`||r===`Set`)return Xf(e);if(r===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return XT(e,t)}}(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
47
47
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function XT(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var ZT=function(e){function n(e){t(this,n),this._pairs=e}return Xu(n,[{key:e,value:vC.mark((function e(){var t,n,r,i,a;return vC.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=YT(this._pairs),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=9;break}return r=Vp(n.value,2),i=r[0],a=r[1],e.next=7,[i,a];case 7:e.next=3;break;case 9:e.next=14;break;case 11:e.prev=11,e.t0=e.catch(1),t.e(e.t0);case 14:return e.prev=14,t.f(),e.finish(14);case 17:case`end`:return e.stop()}}),e,this,[[1,11,14,17]])}))},{key:`entries`,value:vC.mark((function e(){var t,n,r,i,a;return vC.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=YT(this._pairs),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=9;break}return r=Vp(n.value,2),i=r[0],a=r[1],e.next=7,[i,a];case 7:e.next=3;break;case 9:e.next=14;break;case 11:e.prev=11,e.t0=e.catch(1),t.e(e.t0);case 14:return e.prev=14,t.f(),e.finish(14);case 17:case`end`:return e.stop()}}),e,this,[[1,11,14,17]])}))},{key:`keys`,value:vC.mark((function e(){var t,n,r,i;return vC.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=YT(this._pairs),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=9;break}return r=Vp(n.value,1),i=r[0],e.next=7,i;case 7:e.next=3;break;case 9:e.next=14;break;case 11:e.prev=11,e.t0=e.catch(1),t.e(e.t0);case 14:return e.prev=14,t.f(),e.finish(14);case 17:case`end`:return e.stop()}}),e,this,[[1,11,14,17]])}))},{key:`values`,value:vC.mark((function e(){var t,n,r,i;return vC.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=YT(this._pairs),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=9;break}return r=Vp(n.value,2),i=r[1],e.next=7,i;case 7:e.next=3;break;case 9:e.next=14;break;case 11:e.prev=11,e.t0=e.catch(1),t.e(e.t0);case 14:return e.prev=14,t.f(),e.finish(14);case 17:case`end`:return e.stop()}}),e,this,[[1,11,14,17]])}))},{key:`toIdArray`,value:function(){var e;return Kd(e=Hp(this._pairs)).call(e,(function(e){return e[0]}))}},{key:`toItemArray`,value:function(){var e;return Kd(e=Hp(this._pairs)).call(e,(function(e){return e[1]}))}},{key:`toEntryArray`,value:function(){return Hp(this._pairs)}},{key:`toObjectMap`,value:function(){var e,t=hh(null),n=YT(this._pairs);try{for(n.s();!(e=n.n()).done;){var r=Vp(e.value,2),i=r[0];t[i]=r[1]}}catch(e){n.e(e)}finally{n.f()}return t}},{key:`toMap`,value:function(){return new Cw(this._pairs)}},{key:`toIdSet`,value:function(){return new qT(this.toIdArray())}},{key:`toItemSet`,value:function(){return new qT(this.toItemArray())}},{key:`cache`,value:function(){return new n(Hp(this._pairs))}},{key:`distinct`,value:function(e){var t,n=new qT,r=YT(this._pairs);try{for(r.s();!(t=r.n()).done;){var i=Vp(t.value,2),a=i[0],o=i[1];n.add(e(o,a))}}catch(e){r.e(e)}finally{r.f()}return n}},{key:`filter`,value:function(e){var t=this._pairs;return new n({[kT]:()=>vC.mark((function n(){var r,i,a,o,s;return vC.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:r=YT(t),n.prev=1,r.s();case 3:if((i=r.n()).done){n.next=10;break}if(a=Vp(i.value,2),o=a[0],s=a[1],!e(s,o)){n.next=8;break}return n.next=8,[o,s];case 8:n.next=3;break;case 10:n.next=15;break;case 12:n.prev=12,n.t0=n.catch(1),r.e(n.t0);case 15:return n.prev=15,r.f(),n.finish(15);case 18:case`end`:return n.stop()}}),n,null,[[1,12,15,18]])}))()})}},{key:`forEach`,value:function(e){var t,n=YT(this._pairs);try{for(n.s();!(t=n.n()).done;){var r=Vp(t.value,2),i=r[0];e(r[1],i)}}catch(e){n.e(e)}finally{n.f()}}},{key:`map`,value:function(e){var t=this._pairs;return new n({[kT]:()=>vC.mark((function n(){var r,i,a,o,s;return vC.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:r=YT(t),n.prev=1,r.s();case 3:if((i=r.n()).done){n.next=9;break}return a=Vp(i.value,2),o=a[0],s=a[1],n.next=7,[o,e(s,o)];case 7:n.next=3;break;case 9:n.next=14;break;case 11:n.prev=11,n.t0=n.catch(1),r.e(n.t0);case 14:return n.prev=14,r.f(),n.finish(14);case 17:case`end`:return n.stop()}}),n,null,[[1,11,14,17]])}))()})}},{key:`max`,value:function(e){var t=JT(this._pairs),n=t.next();if(n.done)return null;for(var r=n.value[1],i=e(n.value[1],n.value[0]);!(n=t.next()).done;){var a=Vp(n.value,2),o=a[0],s=a[1],c=e(s,o);c>i&&(i=c,r=s)}return r}},{key:`min`,value:function(e){var t=JT(this._pairs),n=t.next();if(n.done)return null;for(var r=n.value[1],i=e(n.value[1],n.value[0]);!(n=t.next()).done;){var a=Vp(n.value,2),o=a[0],s=a[1],c=e(s,o);c<i&&(i=c,r=s)}return r}},{key:`reduce`,value:function(e,t){var n,r=YT(this._pairs);try{for(r.s();!(n=r.n()).done;){var i=Vp(n.value,2),a=i[0];t=e(t,i[1],a)}}catch(e){r.e(e)}finally{r.f()}return t}},{key:`sort`,value:function(e){var t=this;return new n({[kT]:function(){var n;return JT(bT(n=Hp(t._pairs)).call(n,(function(t,n){var r=Vp(t,2),i=r[0],a=r[1],o=Vp(n,2),s=o[0],c=o[1];return e(a,c,i,s)})))}})}}]),n}(kT);function QT(e,t){var n=om(e);if(lv){var r=lv(e);t&&(r=Bd(r).call(r,(function(t){return vv(e,t).enumerable}))),n.push.apply(n,r)}return n}function $T(e){for(var t=1;t<arguments.length;t++){var n,r,i=arguments[t]==null?{}:arguments[t];t%2?_m(n=QT(Object(i),!0)).call(n,(function(t){Zu(e,t,i[t])})):Cv?Av(e,Cv(i)):_m(r=QT(Object(i))).call(r,(function(t){jv(e,t,vv(i,t))}))}return e}function eE(e,t){var n=Up!==void 0&&$f(e)||e[`@@iterator`];if(!n){if(rm(e)||(n=function(e,t){var n;if(e){if(typeof e==`string`)return tE(e,t);var r=Yp(n=Object.prototype.toString.call(e)).call(n,8,-1);if(r===`Object`&&e.constructor&&(r=e.constructor.name),r===`Map`||r===`Set`)return Xf(e);if(r===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return tE(e,t)}}(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
48
48
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function tE(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function nE(e){var t=function(){if(typeof Reflect>`u`||!cv||cv.sham)return!1;if(typeof Proxy==`function`)return!0;try{return Boolean.prototype.valueOf.call(cv(Boolean,[],(function(){}))),!0}catch{return!1}}();return function(){var n,r=Hv(e);if(t){var i=Hv(this).constructor;n=cv(r,arguments,i)}else n=r.apply(this,arguments);return zv(this,n)}}var rE=function(e){Rv(r,e);var n=nE(r);function r(e,i){var a;return t(this,r),Zu(U(a=n.call(this)),`_queue`,null),e&&!rm(e)&&(i=e,e=[]),a._options=i||{},a._data=new Cw,a.length=0,a._idProp=a._options.fieldId||`id`,e&&e.length&&a.add(e),a.setOptions(i),a}return Xu(r,[{key:`idProp`,get:function(){return this._idProp}},{key:`setOptions`,value:function(e){e&&e.queue!==void 0&&(!1===e.queue?this._queue&&=(this._queue.destroy(),null):(this._queue||=GT.extend(this,{replace:[`add`,`update`,`remove`]}),e.queue&&typeof e.queue==`object`&&this._queue.setOptions(e.queue)))}},{key:`add`,value:function(e,t){var n,r=this,i=[];if(rm(e)){var a=Kd(e).call(e,(function(e){return e[r._idProp]}));if(kw(a).call(a,(function(e){return r._data.has(e)})))throw Error(`A duplicate id was found in the parameter array.`);for(var o=0,s=e.length;o<s;o++)n=this._addItem(e[o]),i.push(n)}else{if(!e||typeof e!=`object`)throw Error(`Unknown dataType`);n=this._addItem(e),i.push(n)}return i.length&&this._trigger(`add`,{items:i},t),i}},{key:`update`,value:function(e,t){var n=this,r=[],i=[],a=[],o=[],s=this._idProp,c=function(e){var t=e[s];if(t!=null&&n._data.has(t)){var c=e,l=ch({},n._data.get(t)),u=n._updateItem(c);i.push(u),o.push(c),a.push(l)}else{var d=n._addItem(e);r.push(d)}};if(rm(e))for(var l=0,u=e.length;l<u;l++)e[l]&&typeof e[l]==`object`?c(e[l]):console.warn(`Ignoring input item, which is not an object at index `+l);else{if(!e||typeof e!=`object`)throw Error(`Unknown dataType`);c(e)}if(r.length&&this._trigger(`add`,{items:r},t),i.length){var d={items:i,oldData:a,data:o};this._trigger(`update`,d,t)}return Jp(r).call(r,i)}},{key:`updateOnly`,value:function(e,t){var n,r=this;rm(e)||(e=[e]);var i=Kd(n=Kd(e).call(e,(function(e){var t=r._data.get(e[r._idProp]);if(t==null)throw Error(`Updating non-existent items is not allowed.`);return{oldData:t,update:e}}))).call(n,(function(e){var t=e.oldData,n=e.update,i=t[r._idProp],a=function(e){for(var t,n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return R_.apply(void 0,Jp(t=[{},e]).call(t,r))}(t,n);return r._data.set(i,a),{id:i,oldData:t,updatedData:a}}));if(i.length){var a={items:Kd(i).call(i,(function(e){return e.id})),oldData:Kd(i).call(i,(function(e){return e.oldData})),data:Kd(i).call(i,(function(e){return e.updatedData}))};return this._trigger(`update`,a,t),a.items}return[]}},{key:`get`,value:function(e,t){var n=void 0,r=void 0,i=void 0;WT(e)?(n=e,i=t):rm(e)?(r=e,i=t):i=e;var a=i&&i.returnType===`Object`?`Object`:`Array`,o=i&&Bd(i),s=[],c=void 0,l=void 0,u=void 0;if(n!=null)(c=this._data.get(n))&&o&&!o(c)&&(c=void 0);else if(r!=null)for(var d=0,f=r.length;d<f;d++)(c=this._data.get(r[d]))==null||o&&!o(c)||s.push(c);else for(var p,m=0,h=(l=Hp(Lw(p=this._data).call(p))).length;m<h;m++)u=l[m],(c=this._data.get(u))==null||o&&!o(c)||s.push(c);if(i&&i.order&&n==null&&this._sort(s,i.order),i&&i.fields){var g=i.fields;if(n!=null&&c!=null)c=this._filterFields(c,g);else for(var _=0,v=s.length;_<v;_++)s[_]=this._filterFields(s[_],g)}if(a==`Object`){for(var y={},b=0,x=s.length;b<x;b++){var S=s[b];y[S[this._idProp]]=S}return y}return n==null?s:c??null}},{key:`getIds`,value:function(e){var t=this._data,n=e&&Bd(e),r=e&&e.order,i=Hp(Lw(t).call(t)),a=[];if(n)if(r){for(var o=[],s=0,c=i.length;s<c;s++){var l=i[s],u=this._data.get(l);u!=null&&n(u)&&o.push(u)}this._sort(o,r);for(var d=0,f=o.length;d<f;d++)a.push(o[d][this._idProp])}else for(var p=0,m=i.length;p<m;p++){var h=i[p],g=this._data.get(h);g!=null&&n(g)&&a.push(g[this._idProp])}else if(r){for(var _=[],v=0,y=i.length;v<y;v++){var b=i[v];_.push(t.get(b))}this._sort(_,r);for(var x=0,S=_.length;x<S;x++)a.push(_[x][this._idProp])}else for(var ee=0,C=i.length;ee<C;ee++){var te=i[ee],w=t.get(te);w!=null&&a.push(w[this._idProp])}return a}},{key:`getDataSet`,value:function(){return this}},{key:`forEach`,value:function(e,t){var n=t&&Bd(t),r=this._data,i=Hp(Lw(r).call(r));if(t&&t.order)for(var a=this.get(t),o=0,s=a.length;o<s;o++){var c=a[o];e(c,c[this._idProp])}else for(var l=0,u=i.length;l<u;l++){var d=i[l],f=this._data.get(d);f==null||n&&!n(f)||e(f,d)}}},{key:`map`,value:function(e,t){for(var n=t&&Bd(t),r=[],i=this._data,a=Hp(Lw(i).call(i)),o=0,s=a.length;o<s;o++){var c=a[o],l=this._data.get(c);l==null||n&&!n(l)||r.push(e(l,c))}return t&&t.order&&this._sort(r,t.order),r}},{key:`_filterFields`,value:function(e,t){var n;return e&&Pd(n=rm(t)?t:om(t)).call(n,(function(t,n){return t[n]=e[n],t}),{})}},{key:`_sort`,value:function(e,t){if(typeof t==`string`){var n=t;bT(e).call(e,(function(e,t){var r=e[n],i=t[n];return r>i?1:r<i?-1:0}))}else{if(typeof t!=`function`)throw TypeError(`Order must be a function or a string`);bT(e).call(e,t)}}},{key:`remove`,value:function(e,t){for(var n=[],r=[],i=rm(e)?e:[e],a=0,o=i.length;a<o;a++){var s=this._remove(i[a]);if(s){var c=s[this._idProp];c!=null&&(n.push(c),r.push(s))}}return n.length&&this._trigger(`remove`,{items:n,oldData:r},t),n}},{key:`_remove`,value:function(e){var t;if(WT(e)?t=e:e&&typeof e==`object`&&(t=e[this._idProp]),t!=null&&this._data.has(t)){var n=this._data.get(t)||null;return this._data.delete(t),--this.length,n}return null}},{key:`clear`,value:function(e){for(var t,n=Hp(Lw(t=this._data).call(t)),r=[],i=0,a=n.length;i<a;i++)r.push(this._data.get(n[i]));return this._data.clear(),this.length=0,this._trigger(`remove`,{items:n,oldData:r},e),n}},{key:`max`,value:function(e){var t,n,r=null,i=null,a=eE(OT(t=this._data).call(t));try{for(a.s();!(n=a.n()).done;){var o=n.value,s=o[e];typeof s==`number`&&(i==null||s>i)&&(r=o,i=s)}}catch(e){a.e(e)}finally{a.f()}return r||null}},{key:`min`,value:function(e){var t,n,r=null,i=null,a=eE(OT(t=this._data).call(t));try{for(a.s();!(n=a.n()).done;){var o=n.value,s=o[e];typeof s==`number`&&(i==null||s<i)&&(r=o,i=s)}}catch(e){a.e(e)}finally{a.f()}return r||null}},{key:`distinct`,value:function(e){for(var t=this._data,n=Hp(Lw(t).call(t)),r=[],i=0,a=0,o=n.length;a<o;a++){for(var s=n[a],c=t.get(s)[e],l=!1,u=0;u<i;u++)if(r[u]==c){l=!0;break}l||c===void 0||(r[i]=c,i++)}return r}},{key:`_addItem`,value:function(e){var t=function(e,t){return e[t]??(e[t]=UT()),e}(e,this._idProp),n=t[this._idProp];if(this._data.has(n))throw Error(`Cannot add item: item with id `+n+` already exists`);return this._data.set(n,t),++this.length,n}},{key:`_updateItem`,value:function(e){var t=e[this._idProp];if(t==null)throw Error(`Cannot update item: item has no id (item: `+vh(e)+`)`);var n=this._data.get(t);if(!n)throw Error(`Cannot update item: no item with id `+t+` found`);return this._data.set(t,$T($T({},n),e)),t}},{key:`stream`,value:function(e){if(e){var t=this._data;return new ZT({[kT]:()=>vC.mark((function n(){var r,i,a,o;return vC.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:r=eE(e),n.prev=1,r.s();case 3:if((i=r.n()).done){n.next=11;break}if(a=i.value,(o=t.get(a))==null){n.next=9;break}return n.next=9,[a,o];case 9:n.next=3;break;case 11:n.next=16;break;case 13:n.prev=13,n.t0=n.catch(1),r.e(n.t0);case 16:return n.prev=16,r.f(),n.finish(16);case 19:case`end`:return n.stop()}}),n,null,[[1,13,16,19]])}))()})}var n;return new ZT({[kT]:vd(n=LT(this._data)).call(n,this._data)})}}]),r}(KT);function iE(e,t){var n=Up!==void 0&&$f(e)||e[`@@iterator`];if(!n){if(rm(e)||(n=function(e,t){var n;if(e){if(typeof e==`string`)return aE(e,t);var r=Yp(n=Object.prototype.toString.call(e)).call(n,8,-1);if(r===`Object`&&e.constructor&&(r=e.constructor.name),r===`Map`||r===`Set`)return Xf(e);if(r===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return aE(e,t)}}(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
49
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function aE(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function oE(e){var t=function(){if(typeof Reflect>`u`||!cv||cv.sham)return!1;if(typeof Proxy==`function`)return!0;try{return Boolean.prototype.valueOf.call(cv(Boolean,[],(function(){}))),!0}catch{return!1}}();return function(){var n,r=Hv(e);if(t){var i=Hv(this).constructor;n=cv(r,arguments,i)}else n=r.apply(this,arguments);return zv(this,n)}}var sE=function(e){Rv(r,e);var n=oE(r);function r(e,i){var a,o;return t(this,r),Zu(U(o=n.call(this)),`length`,0),Zu(U(o),`_ids`,new qT),o._options=i||{},o._listener=vd(a=o._onEvent).call(a,U(o)),o.setData(e),o}return Xu(r,[{key:`idProp`,get:function(){return this.getDataSet().idProp}},{key:`setData`,value:function(e){if(this._data){this._data.off&&this._data.off(`*`,this._listener);var t=this._data.getIds({filter:Bd(this._options)}),n=this._data.get(t);this._ids.clear(),this.length=0,this._trigger(`remove`,{items:t,oldData:n})}if(e!=null){this._data=e;for(var r=this._data.getIds({filter:Bd(this._options)}),i=0,a=r.length;i<a;i++){var o=r[i];this._ids.add(o)}this.length=r.length,this._trigger(`add`,{items:r})}else this._data=new rE;this._data.on&&this._data.on(`*`,this._listener)}},{key:`refresh`,value:function(){for(var e=this._data.getIds({filter:Bd(this._options)}),t=Hp(this._ids),n={},r=[],i=[],a=[],o=0,s=e.length;o<s;o++){var c=e[o];n[c]=!0,this._ids.has(c)||(r.push(c),this._ids.add(c))}for(var l=0,u=t.length;l<u;l++){var d=t[l],f=this._data.get(d);f==null?console.error(`If you see this, report it please.`):n[d]||(i.push(d),a.push(f),this._ids.delete(d))}this.length+=r.length-i.length,r.length&&this._trigger(`add`,{items:r}),i.length&&this._trigger(`remove`,{items:i,oldData:a})}},{key:`get`,value:function(e,t){if(this._data==null)return null;var n,r=null;WT(e)||rm(e)?(r=e,n=t):n=e;var i=ch({},this._options,n),a=Bd(this._options),o=n&&Bd(n);return a&&o&&(i.filter=function(e){return a(e)&&o(e)}),r==null?this._data.get(i):this._data.get(r,i)}},{key:`getIds`,value:function(e){if(this._data.length){var t,n=Bd(this._options),r=e==null?null:Bd(e);return t=r?n?function(e){return n(e)&&r(e)}:r:n,this._data.getIds({filter:t,order:e&&e.order})}return[]}},{key:`forEach`,value:function(e,t){if(this._data){var n,r,i=Bd(this._options),a=t&&Bd(t);r=a?i?function(e){return i(e)&&a(e)}:a:i,_m(n=this._data).call(n,e,{filter:r,order:t&&t.order})}}},{key:`map`,value:function(e,t){if(this._data){var n,r,i=Bd(this._options),a=t&&Bd(t);return r=a?i?function(e){return i(e)&&a(e)}:a:i,Kd(n=this._data).call(n,e,{filter:r,order:t&&t.order})}return[]}},{key:`getDataSet`,value:function(){return this._data.getDataSet()}},{key:`stream`,value:function(e){var t;return this._data.stream(e||{[kT]:vd(t=Lw(this._ids)).call(t,this._ids)})}},{key:`dispose`,value:function(){var e;(e=this._data)!=null&&e.off&&this._data.off(`*`,this._listener);var t,n=`This data view has already been disposed of.`,i={get:function(){throw Error(n)},set:function(){throw Error(n)},configurable:!1},a=iE(nm(r.prototype));try{for(a.s();!(t=a.n()).done;){var o=t.value;jv(this,o,i)}}catch(e){a.e(e)}finally{a.f()}}},{key:`_onEvent`,value:function(e,t,n){if(t&&t.items&&this._data){var r=t.items,i=[],a=[],o=[],s=[],c=[],l=[];switch(e){case`add`:for(var u=0,d=r.length;u<d;u++){var f=r[u];this.get(f)&&(this._ids.add(f),i.push(f))}break;case`update`:for(var p=0,m=r.length;p<m;p++){var h=r[p];this.get(h)?this._ids.has(h)?(a.push(h),c.push(t.data[p]),s.push(t.oldData[p])):(this._ids.add(h),i.push(h)):this._ids.has(h)&&(this._ids.delete(h),o.push(h),l.push(t.oldData[p]))}break;case`remove`:for(var g=0,_=r.length;g<_;g++){var v=r[g];this._ids.has(v)&&(this._ids.delete(v),o.push(v),l.push(t.oldData[g]))}}this.length+=i.length-o.length,i.length&&this._trigger(`add`,{items:i},n),a.length&&this._trigger(`update`,{items:a,oldData:s,data:c},n),o.length&&this._trigger(`remove`,{items:o,oldData:l},n)}}}]),r}(KT);function cE(e,t){return typeof t==`object`&&!!t&&e===t.idProp&&typeof t.add==`function`&&typeof t.clear==`function`&&typeof t.distinct==`function`&&typeof _m(t)==`function`&&typeof t.get==`function`&&typeof t.getDataSet==`function`&&typeof t.getIds==`function`&&typeof t.length==`number`&&typeof Kd(t)==`function`&&typeof t.max==`function`&&typeof t.min==`function`&&typeof t.off==`function`&&typeof t.on==`function`&&typeof t.remove==`function`&&typeof t.setOptions==`function`&&typeof t.stream==`function`&&typeof t.update==`function`&&typeof t.updateOnly==`function`}e.DELETE=L_,e.DataSet=rE,e.DataStream=ZT,e.DataView=sE,e.Queue=GT,e.createNewDataPipeFrom=function(e){return new uf(e)},e.isDataSetLike=cE,e.isDataViewLike=function(e,t){return typeof t==`object`&&!!t&&e===t.idProp&&typeof _m(t)==`function`&&typeof t.get==`function`&&typeof t.getDataSet==`function`&&typeof t.getIds==`function`&&typeof t.length==`number`&&typeof Kd(t)==`function`&&typeof t.off==`function`&&typeof t.on==`function`&&typeof t.stream==`function`&&cE(e,t.getDataSet())}}))}))(),S=b(),ee=n(),C=e(i(),1),te={LocalBusiness:`#2E5090`,Service:`#3A6BB0`,PriceSpecification:`#5B8DD0`,OpeningHoursSpecification:`#7AAFE8`,Person:`#C2410C`,UserProfile:`#EA580C`,Preference:`#F97316`,AdminUser:`#9A3412`,AccessGrant:`#7C2D12`,KnowledgeDocument:`#16A34A`,Section:`#22C55E`,Chunk:`#4ADE80`,DigitalDocument:`#15803D`,CreativeWork:`#86EFAC`,Question:`#A7F3D0`,FAQPage:`#34D399`,DefinedTerm:`#10B981`,Review:`#059669`,ImageObject:`#6EE7B7`,Conversation:`#7C3AED`,AdminConversation:`#4338CA`,PublicConversation:`#A855F7`,Message:`#64748B`,UserMessage:`#F97316`,AssistantMessage:`#FACC15`,ToolCall:`#C4B5FD`,Task:`#DB2777`,Project:`#BE185D`,Event:`#EC4899`,Workflow:`#0891B2`,WorkflowStep:`#06B6D4`,WorkflowRun:`#22D3EE`,StepResult:`#67E8F9`,OnboardingState:`#8B5CF6`,Email:`#65A30D`,EmailAccount:`#84CC16`,ReviewAlert:`#DC2626`},w=`#94A3B8`;Object.freeze(Object.keys(te));var ne=Object.freeze(new Set([`Chunk`,`GraphPreference`]));Object.freeze(new Set([`Message`,`UserMessage`,`AssistantMessage`,`Conversation`,`Section`,`ToolCall`,`WorkflowRun`,`WorkflowStep`,`StepResult`,`ReviewAlert`]));var T=Object.freeze(new Set([`Message`,`UserMessage`,`AssistantMessage`,`Section`,`ToolCall`,`WorkflowStep`,`StepResult`,`ReviewAlert`]));function E(e){for(let t of e)if(T.has(t))return!0;return!1}function D(e){for(let t=1;t<e.length;t++)if(Object.prototype.hasOwnProperty.call(te,e[t]))return e[t];return e[0]??null}function O(e){return te[e]??`#94A3B8`}function k(e){let t=D(e),n=t?O(t):w,r=0;for(let t=1;t<e.length;t++)Object.prototype.hasOwnProperty.call(te,e[t])&&r++;return{displayLabel:t,colour:n,driftCandidates:r}}function re(e,t){return e.length<10?[...e,t]:[e[0],...e.slice(e.length-8),t]}function ie(e){return e.length<=1?e:e.slice(0,-1)}function A(e){return[e]}function ae(e){let t=e[e.length-1];return t.kind===`filter`?`f:${[...t.selectedLabels].sort().join(`,`)}:${t.includeTrashed?1:0}`:`n:${t.rootElementId}`}function oe(e){let t=e[0];if(t.kind!==`filter`)throw Error(`view-stack invariant: root must be filter view`);return t}function se(e){return e.trashed===!0?`skip-trashed`:E(e.labels)?`skip-child`:`pivot`}var ce=new Set([`Conversation`,`AdminConversation`,`PublicConversation`]),le=/^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})/,ue=/^\d{4}-\d{2}-\d{2}T(\d{2}:\d{2}:\d{2})/,de=/^(\d{4}-\d{2}-\d{2})T/,fe=24;function pe(e){let t=e.match(le);return t?`${t[1]} ${t[2]}`:null}function me(e){let t=e.match(ue);return t?t[1]:null}function he(e){let t=e.match(de);return t?t[1]:null}function ge(e){let t=e.properties,n=e.labels[0];if(n===`ToolCall`){let e=t.toolName;if(typeof e==`string`&&e.length>0)return e.length>24?e.slice(0,24)+`…`:e}else if(n===`WorkflowRun`){let e=t.startedAt;if(typeof e==`string`&&e.length>0){let t=pe(e);if(t)return t}}else if(n===`WorkflowStep`){let e=t.label;if(typeof e==`string`&&e.length>0)return e.length>24?e.slice(0,24)+`…`:e}else if(n===`Person`){let e=typeof t.name==`string`?t.name:``;if(e.length>0)return e.length>24?e.slice(0,24)+`…`:e;let n=[typeof t.givenName==`string`?t.givenName:``,typeof t.familyName==`string`?t.familyName:``].filter(e=>e.length>0).join(` `);if(n.length>0)return n.length>24?n.slice(0,24)+`…`:n}else if(n===`Message`){let e=typeof t.role==`string`?t.role:``,n=e===`user`?`user`:e===`assistant`?`asst`:e===`system`?`sys`:e===`tool`?`tool`:null,r=typeof t.createdAt==`string`?t.createdAt:``;if(n&&r){let e=me(r);if(e)return`${n} ${e}`}}for(let e of[`name`,`title`,`summary`,`givenName`,`subject`,`text`]){let n=t[e];if(typeof n==`string`&&n.length>0)return n.length>24?n.slice(0,24)+`…`:n}if(n===`Conversation`){let e=typeof t.conversationId==`string`?t.conversationId:null;if(e)return`Conv ${e.slice(0,8)}`}return n??`…`}function _e(e){let t=e.properties,n=e.labels[0];if(n===`ToolCall`){let e=t.toolName;if(typeof e==`string`&&e.length>0)return e}else if(n===`WorkflowRun`){let e=t.startedAt;if(typeof e==`string`&&e.length>0){let t=pe(e);if(t)return t}}else if(n===`WorkflowStep`){let e=t.label;if(typeof e==`string`&&e.length>0)return e}else if(n===`Person`){let e=typeof t.name==`string`?t.name:``;if(e.length>0)return e;let n=[typeof t.givenName==`string`?t.givenName:``,typeof t.familyName==`string`?t.familyName:``].filter(e=>e.length>0).join(` `);if(n.length>0)return n}for(let e of[`name`,`title`,`summary`,`givenName`,`subject`,`text`]){let n=t[e];if(typeof n==`string`&&n.length>0)return n}if(n===`Conversation`){let e=typeof t.conversationId==`string`?t.conversationId:null;if(e)return`Conv ${e.slice(0,8)}`}return n??`…`}function ve(e){if(e.length===0)return``;let t=e.split(/\s+/).filter(e=>e.length>0);if(t.length===0)return``;if(t.length===1){let e=t[0];return e.length<=fe?e:e.slice(0,fe-1)+`…`}let n=``,r=0;for(;r<t.length;){let e=n.length===0?t[r]:`${n} ${t[r]}`;if(e.length<=fe)n=e,r++;else break}if(n.length===0)return n=t[0].slice(0,fe-1)+`…`,n;if(r>=t.length)return n;let i=``;for(;r<t.length;){let e=i.length===0?t[r]:`${i} ${t[r]}`;if(e.length<=fe)i=e,r++;else break}if(r<t.length){let e=t.slice(r).join(` `);i=(i.length===0?e:`${i} ${e}`).slice(0,fe-1)+`…`}return`${n}\n${i}`}function ye(e,t){let n=e.labels[0];if(!n||!ce.has(n)||t<.7)return ge(e);let r=ve(_e(e));if(t<1.3)return r;let i=e.properties,a=typeof i.createdAt==`string`?i.createdAt:``,o=typeof i.messageCount==`number`?i.messageCount:null;if(a.length===0||o===null)return r;let s=he(a);return s===null?r:`${r}\n${s} · ${o} msgs`}function be(e){let t=e.properties,n=typeof t.createdAt==`string`?t.createdAt:``,r=typeof t.updatedAt==`string`?t.updatedAt:``,i=e.labels.join(` · `);return[_e(e),i,`id: ${e.id}`,n?`createdAt: ${n}`:``,r?`updatedAt: ${r}`:``].filter(e=>e.length>0).join(`
49
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function aE(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function oE(e){var t=function(){if(typeof Reflect>`u`||!cv||cv.sham)return!1;if(typeof Proxy==`function`)return!0;try{return Boolean.prototype.valueOf.call(cv(Boolean,[],(function(){}))),!0}catch{return!1}}();return function(){var n,r=Hv(e);if(t){var i=Hv(this).constructor;n=cv(r,arguments,i)}else n=r.apply(this,arguments);return zv(this,n)}}var sE=function(e){Rv(r,e);var n=oE(r);function r(e,i){var a,o;return t(this,r),Zu(U(o=n.call(this)),`length`,0),Zu(U(o),`_ids`,new qT),o._options=i||{},o._listener=vd(a=o._onEvent).call(a,U(o)),o.setData(e),o}return Xu(r,[{key:`idProp`,get:function(){return this.getDataSet().idProp}},{key:`setData`,value:function(e){if(this._data){this._data.off&&this._data.off(`*`,this._listener);var t=this._data.getIds({filter:Bd(this._options)}),n=this._data.get(t);this._ids.clear(),this.length=0,this._trigger(`remove`,{items:t,oldData:n})}if(e!=null){this._data=e;for(var r=this._data.getIds({filter:Bd(this._options)}),i=0,a=r.length;i<a;i++){var o=r[i];this._ids.add(o)}this.length=r.length,this._trigger(`add`,{items:r})}else this._data=new rE;this._data.on&&this._data.on(`*`,this._listener)}},{key:`refresh`,value:function(){for(var e=this._data.getIds({filter:Bd(this._options)}),t=Hp(this._ids),n={},r=[],i=[],a=[],o=0,s=e.length;o<s;o++){var c=e[o];n[c]=!0,this._ids.has(c)||(r.push(c),this._ids.add(c))}for(var l=0,u=t.length;l<u;l++){var d=t[l],f=this._data.get(d);f==null?console.error(`If you see this, report it please.`):n[d]||(i.push(d),a.push(f),this._ids.delete(d))}this.length+=r.length-i.length,r.length&&this._trigger(`add`,{items:r}),i.length&&this._trigger(`remove`,{items:i,oldData:a})}},{key:`get`,value:function(e,t){if(this._data==null)return null;var n,r=null;WT(e)||rm(e)?(r=e,n=t):n=e;var i=ch({},this._options,n),a=Bd(this._options),o=n&&Bd(n);return a&&o&&(i.filter=function(e){return a(e)&&o(e)}),r==null?this._data.get(i):this._data.get(r,i)}},{key:`getIds`,value:function(e){if(this._data.length){var t,n=Bd(this._options),r=e==null?null:Bd(e);return t=r?n?function(e){return n(e)&&r(e)}:r:n,this._data.getIds({filter:t,order:e&&e.order})}return[]}},{key:`forEach`,value:function(e,t){if(this._data){var n,r,i=Bd(this._options),a=t&&Bd(t);r=a?i?function(e){return i(e)&&a(e)}:a:i,_m(n=this._data).call(n,e,{filter:r,order:t&&t.order})}}},{key:`map`,value:function(e,t){if(this._data){var n,r,i=Bd(this._options),a=t&&Bd(t);return r=a?i?function(e){return i(e)&&a(e)}:a:i,Kd(n=this._data).call(n,e,{filter:r,order:t&&t.order})}return[]}},{key:`getDataSet`,value:function(){return this._data.getDataSet()}},{key:`stream`,value:function(e){var t;return this._data.stream(e||{[kT]:vd(t=Lw(this._ids)).call(t,this._ids)})}},{key:`dispose`,value:function(){var e;(e=this._data)!=null&&e.off&&this._data.off(`*`,this._listener);var t,n=`This data view has already been disposed of.`,i={get:function(){throw Error(n)},set:function(){throw Error(n)},configurable:!1},a=iE(nm(r.prototype));try{for(a.s();!(t=a.n()).done;){var o=t.value;jv(this,o,i)}}catch(e){a.e(e)}finally{a.f()}}},{key:`_onEvent`,value:function(e,t,n){if(t&&t.items&&this._data){var r=t.items,i=[],a=[],o=[],s=[],c=[],l=[];switch(e){case`add`:for(var u=0,d=r.length;u<d;u++){var f=r[u];this.get(f)&&(this._ids.add(f),i.push(f))}break;case`update`:for(var p=0,m=r.length;p<m;p++){var h=r[p];this.get(h)?this._ids.has(h)?(a.push(h),c.push(t.data[p]),s.push(t.oldData[p])):(this._ids.add(h),i.push(h)):this._ids.has(h)&&(this._ids.delete(h),o.push(h),l.push(t.oldData[p]))}break;case`remove`:for(var g=0,_=r.length;g<_;g++){var v=r[g];this._ids.has(v)&&(this._ids.delete(v),o.push(v),l.push(t.oldData[g]))}}this.length+=i.length-o.length,i.length&&this._trigger(`add`,{items:i},n),a.length&&this._trigger(`update`,{items:a,oldData:s,data:c},n),o.length&&this._trigger(`remove`,{items:o,oldData:l},n)}}}]),r}(KT);function cE(e,t){return typeof t==`object`&&!!t&&e===t.idProp&&typeof t.add==`function`&&typeof t.clear==`function`&&typeof t.distinct==`function`&&typeof _m(t)==`function`&&typeof t.get==`function`&&typeof t.getDataSet==`function`&&typeof t.getIds==`function`&&typeof t.length==`number`&&typeof Kd(t)==`function`&&typeof t.max==`function`&&typeof t.min==`function`&&typeof t.off==`function`&&typeof t.on==`function`&&typeof t.remove==`function`&&typeof t.setOptions==`function`&&typeof t.stream==`function`&&typeof t.update==`function`&&typeof t.updateOnly==`function`}e.DELETE=L_,e.DataSet=rE,e.DataStream=ZT,e.DataView=sE,e.Queue=GT,e.createNewDataPipeFrom=function(e){return new uf(e)},e.isDataSetLike=cE,e.isDataViewLike=function(e,t){return typeof t==`object`&&!!t&&e===t.idProp&&typeof _m(t)==`function`&&typeof t.get==`function`&&typeof t.getDataSet==`function`&&typeof t.getIds==`function`&&typeof t.length==`number`&&typeof Kd(t)==`function`&&typeof t.off==`function`&&typeof t.on==`function`&&typeof t.stream==`function`&&cE(e,t.getDataSet())}}))}))(),S=b(),ee=n(),C=e(i(),1),te={LocalBusiness:`#2E5090`,Service:`#3A6BB0`,PriceSpecification:`#5B8DD0`,OpeningHoursSpecification:`#7AAFE8`,Organization:`#A16207`,Person:`#C2410C`,UserProfile:`#EA580C`,Preference:`#F97316`,AdminUser:`#9A3412`,AccessGrant:`#7C2D12`,KnowledgeDocument:`#16A34A`,Section:`#22C55E`,Chunk:`#4ADE80`,DigitalDocument:`#15803D`,CreativeWork:`#86EFAC`,Question:`#A7F3D0`,FAQPage:`#34D399`,DefinedTerm:`#10B981`,Review:`#059669`,ImageObject:`#6EE7B7`,Conversation:`#7C3AED`,AdminConversation:`#4338CA`,PublicConversation:`#A855F7`,Message:`#64748B`,UserMessage:`#F97316`,AssistantMessage:`#FACC15`,ToolCall:`#C4B5FD`,Task:`#DB2777`,Project:`#BE185D`,Event:`#EC4899`,Workflow:`#0891B2`,WorkflowStep:`#06B6D4`,WorkflowRun:`#22D3EE`,StepResult:`#67E8F9`,OnboardingState:`#8B5CF6`,Email:`#65A30D`,EmailAccount:`#84CC16`,ReviewAlert:`#DC2626`},w=`#94A3B8`;Object.freeze(Object.keys(te));var ne=Object.freeze(new Set([`Chunk`,`GraphPreference`]));Object.freeze(new Set([`Message`,`UserMessage`,`AssistantMessage`,`Conversation`,`Section`,`ToolCall`,`WorkflowRun`,`WorkflowStep`,`StepResult`,`ReviewAlert`]));var T=Object.freeze(new Set([`Message`,`UserMessage`,`AssistantMessage`,`Section`,`ToolCall`,`WorkflowStep`,`StepResult`,`ReviewAlert`]));function E(e){for(let t of e)if(T.has(t))return!0;return!1}function D(e){for(let t=1;t<e.length;t++)if(Object.prototype.hasOwnProperty.call(te,e[t]))return e[t];return e[0]??null}function O(e){return te[e]??`#94A3B8`}function k(e){let t=D(e),n=t?O(t):w,r=0;for(let t=1;t<e.length;t++)Object.prototype.hasOwnProperty.call(te,e[t])&&r++;return{displayLabel:t,colour:n,driftCandidates:r}}function re(e,t){return e.length<10?[...e,t]:[e[0],...e.slice(e.length-8),t]}function ie(e){return e.length<=1?e:e.slice(0,-1)}function A(e){return[e]}function ae(e){let t=e[e.length-1];return t.kind===`filter`?`f:${[...t.selectedLabels].sort().join(`,`)}:${t.includeTrashed?1:0}`:`n:${t.rootElementId}`}function oe(e){let t=e[0];if(t.kind!==`filter`)throw Error(`view-stack invariant: root must be filter view`);return t}function se(e){return e.trashed===!0?`skip-trashed`:E(e.labels)?`skip-child`:`pivot`}var ce=new Set([`Conversation`,`AdminConversation`,`PublicConversation`]),le=/^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})/,ue=/^\d{4}-\d{2}-\d{2}T(\d{2}:\d{2}:\d{2})/,de=/^(\d{4}-\d{2}-\d{2})T/,fe=24;function pe(e){let t=e.match(le);return t?`${t[1]} ${t[2]}`:null}function me(e){let t=e.match(ue);return t?t[1]:null}function he(e){let t=e.match(de);return t?t[1]:null}function ge(e){let t=e.properties,n=e.labels[0];if(n===`ToolCall`){let e=t.toolName;if(typeof e==`string`&&e.length>0)return e.length>24?e.slice(0,24)+`…`:e}else if(n===`WorkflowRun`){let e=t.startedAt;if(typeof e==`string`&&e.length>0){let t=pe(e);if(t)return t}}else if(n===`WorkflowStep`){let e=t.label;if(typeof e==`string`&&e.length>0)return e.length>24?e.slice(0,24)+`…`:e}else if(n===`Person`){let e=typeof t.name==`string`?t.name:``;if(e.length>0)return e.length>24?e.slice(0,24)+`…`:e;let n=[typeof t.givenName==`string`?t.givenName:``,typeof t.familyName==`string`?t.familyName:``].filter(e=>e.length>0).join(` `);if(n.length>0)return n.length>24?n.slice(0,24)+`…`:n}else if(n===`Message`){let e=typeof t.role==`string`?t.role:``,n=e===`user`?`user`:e===`assistant`?`asst`:e===`system`?`sys`:e===`tool`?`tool`:null,r=typeof t.createdAt==`string`?t.createdAt:``;if(n&&r){let e=me(r);if(e)return`${n} ${e}`}}for(let e of[`name`,`title`,`summary`,`givenName`,`subject`,`text`]){let n=t[e];if(typeof n==`string`&&n.length>0)return n.length>24?n.slice(0,24)+`…`:n}if(n===`Conversation`){let e=typeof t.conversationId==`string`?t.conversationId:null;if(e)return`Conv ${e.slice(0,8)}`}return n??`…`}function _e(e){let t=e.properties,n=e.labels[0];if(n===`ToolCall`){let e=t.toolName;if(typeof e==`string`&&e.length>0)return e}else if(n===`WorkflowRun`){let e=t.startedAt;if(typeof e==`string`&&e.length>0){let t=pe(e);if(t)return t}}else if(n===`WorkflowStep`){let e=t.label;if(typeof e==`string`&&e.length>0)return e}else if(n===`Person`){let e=typeof t.name==`string`?t.name:``;if(e.length>0)return e;let n=[typeof t.givenName==`string`?t.givenName:``,typeof t.familyName==`string`?t.familyName:``].filter(e=>e.length>0).join(` `);if(n.length>0)return n}for(let e of[`name`,`title`,`summary`,`givenName`,`subject`,`text`]){let n=t[e];if(typeof n==`string`&&n.length>0)return n}if(n===`Conversation`){let e=typeof t.conversationId==`string`?t.conversationId:null;if(e)return`Conv ${e.slice(0,8)}`}return n??`…`}function ve(e){if(e.length===0)return``;let t=e.split(/\s+/).filter(e=>e.length>0);if(t.length===0)return``;if(t.length===1){let e=t[0];return e.length<=fe?e:e.slice(0,fe-1)+`…`}let n=``,r=0;for(;r<t.length;){let e=n.length===0?t[r]:`${n} ${t[r]}`;if(e.length<=fe)n=e,r++;else break}if(n.length===0)return n=t[0].slice(0,fe-1)+`…`,n;if(r>=t.length)return n;let i=``;for(;r<t.length;){let e=i.length===0?t[r]:`${i} ${t[r]}`;if(e.length<=fe)i=e,r++;else break}if(r<t.length){let e=t.slice(r).join(` `);i=(i.length===0?e:`${i} ${e}`).slice(0,fe-1)+`…`}return`${n}\n${i}`}function ye(e,t){let n=e.labels[0];if(!n||!ce.has(n)||t<.7)return ge(e);let r=ve(_e(e));if(t<1.3)return r;let i=e.properties,a=typeof i.createdAt==`string`?i.createdAt:``,o=typeof i.messageCount==`number`?i.messageCount:null;if(a.length===0||o===null)return r;let s=he(a);return s===null?r:`${r}\n${s} · ${o} msgs`}function be(e){let t=e.properties,n=typeof t.createdAt==`string`?t.createdAt:``,r=typeof t.updatedAt==`string`?t.updatedAt:``,i=e.labels.join(` · `);return[_e(e),i,`id: ${e.id}`,n?`createdAt: ${n}`:``,r?`updatedAt: ${r}`:``].filter(e=>e.length>0).join(`
50
50
  `)}var j=o();function xe(e){return e<.7?`compact`:e<1.3?`wrapped`:`detailed`}var Se=150;function M(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}var N=250,Ce=1200;function we(){let[e,t]=(0,C.useState)(null),[n,r]=(0,C.useState)(!1);return(0,C.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!n){t(null),r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`;return}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]),n?e?(0,j.jsxs)(`div`,{className:`data-page graph-page`,children:[(0,j.jsxs)(`header`,{className:`data-header`,children:[(0,j.jsxs)(`h1`,{className:`data-title`,children:[(0,j.jsx)(f,{size:18}),` Graph`]}),(0,j.jsx)(Te,{})]}),(0,j.jsx)(`main`,{className:`graph-main`,children:(0,j.jsx)(Ee,{sessionKey:e})})]}):(0,j.jsxs)(`div`,{className:`data-page`,children:[(0,j.jsx)(`header`,{className:`data-header`,children:(0,j.jsxs)(`h1`,{className:`data-title`,children:[(0,j.jsx)(f,{size:18}),` Graph`]})}),(0,j.jsxs)(`div`,{className:`data-empty`,children:[(0,j.jsx)(`p`,{children:`You are not signed in.`}),(0,j.jsxs)(`p`,{children:[`Open the `,(0,j.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})]}):(0,j.jsx)(`div`,{className:`data-page`,children:(0,j.jsxs)(`div`,{className:`data-loading`,children:[(0,j.jsx)(s,{size:18,className:`spin`}),` Loading…`]})})}function Te(){let[e,t]=(0,C.useState)(!1),n=(0,C.useRef)(null);(0,C.useEffect)(()=>{if(!e)return;let r=e=>{n.current&&(n.current.contains(e.target)||t(!1))},i=e=>{e.key===`Escape`&&t(!1)};return document.addEventListener(`mousedown`,r),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`mousedown`,r),document.removeEventListener(`keydown`,i)}},[e]);let r=(0,C.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]);return(0,j.jsxs)(`div`,{className:`chat-burger-wrap`,ref:n,children:[(0,j.jsx)(`button`,{type:`button`,className:`chat-burger`,onClick:()=>t(e=>!e),"aria-label":`Menu`,"aria-haspopup":`true`,"aria-expanded":e,children:(0,j.jsx)(d,{size:20})}),e&&(0,j.jsxs)(`div`,{className:`chat-menu`,children:[(0,j.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{t(!1),window.location.href=`/`},children:[(0,j.jsx)(p,{size:14}),` Chat`]}),(0,j.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{t(!1),window.location.href=`/data`},children:[(0,j.jsx)(u,{size:14}),` Data`]}),(0,j.jsx)(`div`,{className:`chat-menu-divider`}),(0,j.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{t(!1),r()},children:[(0,j.jsx)(c,{size:14}),` Log out`]})]})]})}function Ee({sessionKey:e}){let t=(0,C.useRef)(null),n=(0,C.useRef)(null),i=(0,C.useRef)(null),a=(0,C.useRef)(null),o=(0,C.useRef)(new Map),c=(0,C.useRef)(null),u=(0,C.useRef)(null),d=(0,C.useRef)(null),f=(0,C.useRef)(null),p=(0,C.useRef)(null),[m,y]=(0,C.useState)([{kind:`filter`,selectedLabels:[],includeTrashed:!1}]),[b,ee]=(0,C.useState)(!1),[te,w]=(0,C.useState)(null),[T,E]=(0,C.useState)(null),[le,ue]=(0,C.useState)(0),[de,fe]=(0,C.useState)(null),[pe,me]=(0,C.useState)(!1),[he,_e]=(0,C.useState)(!1),[ve,we]=(0,C.useState)(null),[Te,Ee]=(0,C.useState)(``),[Ae,je]=(0,C.useState)(``),[Me,Ne]=(0,C.useState)(null),[Pe,Fe]=(0,C.useState)(null),[Ie,Le]=(0,C.useState)(0),[Re,ze]=(0,C.useState)([]),[Be,Ve]=(0,C.useState)({labels:[],includeTrashed:!1}),[He,Ue]=(0,C.useState)(!1),[We,Ge]=(0,C.useState)(!1),Ke=(0,C.useRef)(!1),qe=(0,C.useRef)(null),Je=(0,C.useMemo)(()=>{let e=new Set;for(let t of o.current.values()){let n=D(t.labels);n&&e.add(n)}return[...e].sort()},[le]);(0,C.useEffect)(()=>{let t=!1,n=fetch(`/api/admin/graph-labels-in-graph?session_key=${encodeURIComponent(e)}`).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return await e.json()}).catch(e=>{let t=e instanceof Error?e.message:String(e);try{fetch(`/api/_client-error`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:`graph-labels-in-graph`,msg:t}),keepalive:!0}).catch(()=>{})}catch{}return{labels:[]}}),r=fetch(`/api/admin/graph-default-view?session_key=${encodeURIComponent(e)}`).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return await e.json()}).catch(e=>{let t=e instanceof Error?e.message:String(e);try{fetch(`/api/_client-error`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:`graph-default-view`,msg:t}),keepalive:!0}).catch(()=>{})}catch{}return{labels:[],includeTrashed:!1}});return Promise.all([n,r]).then(([e,n])=>{if(!t&&(ze(e.labels),Ve(n),!Ke.current)){Ke.current=!0;let t=new Set(e.labels.map(e=>e.label)),r=n.labels.filter(e=>t.has(e));(r.length>0||n.includeTrashed)&&y([{kind:`filter`,selectedLabels:r,includeTrashed:n.includeTrashed}])}}),()=>{t=!0}},[e]),(0,C.useEffect)(()=>{if(!He)return;let e=e=>{qe.current&&(qe.current.contains(e.target)||Ue(!1))},t=e=>{e.key===`Escape`&&Ue(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[He]);let Ye=(0,C.useCallback)(()=>{if(i.current)try{i.current.clear()}catch{}if(a.current)try{a.current.clear()}catch{}},[]),Xe=(0,C.useCallback)((t,r)=>{we(null),fetch(`/api/admin/graph-delete?session_key=${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({elementId:t,by:`graph-drag-trash`})}).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);fe(null);try{n.current?.unselectAll()}catch{}y(e=>[oe(e)]),Le(e=>e+1)}).catch(e=>{let n=e instanceof Error?e.message:String(e);we(`Failed to delete: ${n}`),_e(!0),window.setTimeout(()=>_e(!1),Ce);try{fetch(`/api/_client-error`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:`graph-drag-delete`,elementId:t,label:r,msg:n}),keepalive:!0}).catch(()=>{})}catch{}})},[e]),Ze=m[m.length-1],Qe=(0,C.useMemo)(()=>ae(m),[m]),$e=(0,C.useRef)(Qe);(0,C.useEffect)(()=>{$e.current=Qe},[Qe]),(0,C.useEffect)(()=>{if(Ze.kind===`filter`&&Ze.selectedLabels.length===0){c.current?.abort(),c.current=null,ee(!1),w(null),E(null),ue(0),o.current=new Map,Ye();return}let t=window.setTimeout(()=>{c.current?.abort();let t=new AbortController;c.current=t,ee(!0),w(null),E(null);let n=F(e,Ze);fetch(n,{signal:t.signal}).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(e.status===413)throw new De(t);if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{t.signal.aborted||(o.current=new Map(e.nodes.map(e=>[e.id,e])),ue(e.nodes.length),et(e.nodes,e.edges))}).catch(e=>{if(!t.signal.aborted){if(e instanceof De){E(e.body),ue(0),o.current=new Map,Ye();return}w(e instanceof Error?e.message:String(e))}}).finally(()=>{t.signal.aborted||ee(!1)})},N);return()=>{window.clearTimeout(t)}},[e,Qe,Ie]),(0,C.useEffect)(()=>()=>{c.current?.abort(),n.current?.destroy(),n.current=null,p.current!==null&&(clearTimeout(p.current),p.current=null)},[]);let et=(0,C.useCallback)((e,r)=>{if(!t.current)return;let s=new Set([`Message`,`UserMessage`,`AssistantMessage`]),c=e=>e.labels.some(e=>s.has(e)),l=new Map,m=e.filter(c);if(m.length>0){let e=new Set(m.map(e=>e.id)),n=new Map,i=new Set;for(let t of r)t.type===`NEXT`&&e.has(t.from)&&e.has(t.to)&&(n.set(t.from,t.to),i.add(t.to));let a=[],o=new Set;for(let e of m){if(i.has(e.id))continue;let t=e.id;for(;t&&!o.has(t);)o.add(t),a.push(t),t=n.get(t)}for(let e of m)o.has(e.id)||(a.push(e.id),o.add(e.id));let s=t.current?.clientWidth??1200,c=Math.max(s-160,300),u=Math.max(Math.floor(c/150),2);a.forEach((e,t)=>{let n=t%u,r=Math.floor(t/u);l.set(e,{x:n*150,y:r*90})})}let h=e.map(e=>{let t=e.labels[0]??`Unknown`,n=k(e.labels);n.displayLabel;let r=n.colour;n.driftCandidates;let i=l.get(e.id),a=i?{x:i.x,y:i.y,physics:!1}:{};return e.trashed?{id:e.id,label:ge(e),title:be(e),color:{background:`${r}40`,border:r},borderWidth:2,shapeProperties:{borderDashes:[6,4]},group:t,...a}:{id:e.id,label:ge(e),title:be(e),color:r,group:t,...a}}),g=r.filter(e=>e.type!==`PART_OF`).map(e=>({id:e.id,from:e.from,to:e.to,label:e.type}));i.current=new x.DataSet(h),a.current=new x.DataSet(g);let _={autoResize:!0,layout:{improvedLayout:!1,randomSeed:M($e.current)},physics:{solver:`barnesHut`,barnesHut:{gravitationalConstant:-4e3,centralGravity:.3,springLength:95,springConstant:.04},stabilization:{iterations:200}},nodes:{shape:`dot`,size:14,font:{color:`#1F2937`,size:12,face:`DM Sans, sans-serif`},borderWidth:0,chosen:{node:e=>{e.size=20,e.borderWidth=3},label:e=>{e.size=14}}},edges:{arrows:{to:{enabled:!0,scaleFactor:.4}},color:{color:`#CBD5E1`,highlight:`#475569`},font:{color:`#64748B`,size:9,face:`DM Sans, sans-serif`,align:`middle`,strokeWidth:0},smooth:{enabled:!0,type:`continuous`,roundness:.4},width:1,chosen:{edge:!0,label:!1}},interaction:{hover:!0,tooltipDelay:150}};try{n.current?.destroy(),p.current!==null&&(clearTimeout(p.current),p.current=null),f.current=null;let e=new S.Network(t.current,{nodes:i.current,edges:a.current},_);n.current=e,e.on(`zoom`,()=>{p.current!==null&&clearTimeout(p.current),p.current=setTimeout(()=>{p.current=null;let e=n.current,t=i.current;if(!e||!t)return;let r;try{r=e.getScale()}catch{return}let a=xe(r);if(a===f.current)return;f.current=a;let s=[];for(let e of o.current.values()){let t=e.labels[0];if(!t||!ce.has(t))continue;let{colour:n}=k(e.labels),i=e.trashed?{background:`${n}40`,border:n}:n;s.push({id:e.id,label:ye(e,r),color:i})}s.length>0&&t.update(s),console.error(`[graph-page] zoom-tier scale=${r.toFixed(3)} tier=${a} conversations=${s.length}`)},Se)}),e.on(`selectNode`,e=>{let t=e.nodes[0],n=o.current.get(t);if(!n)return;fe(n);let r=se(n);if(r===`skip-trashed`)return;if(r===`skip-child`){ke(`nav-skip`,{kind:`child-label`,rootElementId:t,labels:n.labels.join(`,`)});return}let i={kind:`neighbourhood`,rootElementId:t,rootLabel:n.labels[0]??null};y(e=>{let n=re(e,i),r=n.length-1;return n.length>e.length&&ke(`nav-push`,{depth:r,kind:i.kind,rootElementId:t}),n.length===10&&e.length===10&&ke(`view-stack-cap-hit`,{depth:10,rootElementId:t}),n})}),e.on(`deselectNode`,()=>{fe(null)});let r=e=>{let n=t.current,r=u.current;if(!n||!r)return!1;let i=n.getBoundingClientRect(),a=r.getBoundingClientRect(),o=i.left+e.x,s=i.top+e.y;return o>=a.left&&o<=a.right&&s>=a.top&&s<=a.bottom},s=t.current?.parentElement??null;e.on(`dragStart`,e=>{let t=e.nodes[0];if(!t){d.current=null;return}d.current=t,s?.classList.add(`graph-dragging`)}),e.on(`dragging`,e=>{if(!d.current)return;let t=r(e.pointer.DOM);me(e=>e===t?e:t)}),e.on(`dragEnd`,e=>{let t=d.current;d.current=null,me(!1),s?.classList.remove(`graph-dragging`),t&&r(e.pointer.DOM)&&Xe(t,o.current.get(t)?.labels[0]??`Unknown`)})}catch(e){let t=e instanceof Error?e.message:String(e);w(`Visualisation failed to load: ${t}`);try{fetch(`/api/_client-error`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:`graph-render`,msg:t}),keepalive:!0}).catch(()=>{})}catch{}}},[]);(0,C.useEffect)(()=>{let e=Te.trim();if(!e){je(``),Ne(null),Fe(null),n.current?.unselectAll();return}let t=setTimeout(()=>je(e),300);return()=>clearTimeout(t)},[Te]);let tt=(0,C.useCallback)(e=>{let t=n.current;if(!t)return;let r=[];for(let t of e)o.current.has(t.nodeId)&&r.push(t.nodeId);r.length>0&&(t.selectNodes(r,!0),t.fit({nodes:r,animation:{duration:400,easingFunction:`easeInOutQuad`}}))},[]);(0,C.useEffect)(()=>{if(!Ae)return;let t=!1;Fe(null);let n=`/api/admin/graph-search?session_key=${encodeURIComponent(e)}&q=${encodeURIComponent(Ae)}&limit=20`;return fetch(n).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{if(t)return;Ne(e.results),tt(e.results);let n=new Set;for(let t of e.results)for(let e of t.labels)ne.has(e)||n.add(e);n.size!==0&&y(e=>{if(e.length!==1)return e;let t=oe(e),r=new Set(t.selectedLabels),i=0;for(let e of n)r.has(e)||(r.add(e),i++);return i===0?e:A({kind:`filter`,selectedLabels:[...r].sort(),includeTrashed:t.includeTrashed})})}).catch(e=>{t||Fe(e instanceof Error?e.message:String(e))}),()=>{t=!0}},[Ae,e,tt]);let nt=(0,C.useMemo)(()=>{if(!Me)return 0;let e=0;for(let t of Me)o.current.has(t.nodeId)||e++;return e},[Me,le]),rt=(0,C.useCallback)(e=>{y(t=>{let n=oe(t),r=new Set(n.selectedLabels);return r.has(e)?r.delete(e):r.add(e),A({kind:`filter`,selectedLabels:[...r].sort(),includeTrashed:n.includeTrashed})})},[]),it=(0,C.useCallback)(()=>{y(e=>{let t=oe(e);return A({...t,includeTrashed:!t.includeTrashed})})},[]),at=(0,C.useCallback)(()=>{Ee(``),je(``),Ne(null),Fe(null);try{n.current?.unselectAll()}catch{}},[]),ot=(0,C.useCallback)(()=>{y(()=>A({kind:`filter`,selectedLabels:[],includeTrashed:!1}))},[]),st=(0,C.useCallback)(()=>{fe(null);try{n.current?.unselectAll()}catch{}y(e=>{let t=ie(e);return t!==e&&ke(`nav-pop`,{depth:t.length-1}),t})},[]),ct=(0,C.useCallback)(()=>{let t=oe(m),n={labels:[...t.selectedLabels].sort(),includeTrashed:t.includeTrashed};Ge(!0),fetch(`/api/admin/graph-default-view?session_key=${encodeURIComponent(e)}`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(n)}).then(async e=>{if(!e.ok){let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));throw Error(t.error??`HTTP ${e.status}`)}Ve(n)}).catch(e=>{let t=e instanceof Error?e.message:String(e);try{fetch(`/api/_client-error`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:`graph-default-view-save`,msg:t}),keepalive:!0}).catch(()=>{})}catch{}}).finally(()=>Ge(!1))},[e,m]),lt=(0,C.useCallback)(()=>{fe(null);try{n.current?.unselectAll()}catch{}Le(e=>e+1)},[]),ut=Ze.kind===`neighbourhood`,dt=oe(m),ft=dt.selectedLabels,pt=dt.includeTrashed,mt=(0,C.useMemo)(()=>{if(pt!==Be.includeTrashed||ft.length!==Be.labels.length)return!0;for(let e=0;e<ft.length;e++)if(ft[e]!==Be.labels[e])return!0;return!1},[pt,ft,Be]);return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`graph-toolbar`,children:[(0,j.jsxs)(`div`,{className:`data-search-input graph-search-input`,children:[(0,j.jsx)(l,{size:14}),(0,j.jsx)(`input`,{type:`text`,placeholder:`Search nodes…`,value:Te,onChange:e=>Ee(e.target.value),autoComplete:`off`,spellCheck:!1}),Ae&&!Me&&!Pe&&(0,j.jsx)(s,{size:14,className:`spin`}),Te.length>0&&(0,j.jsx)(`button`,{type:`button`,className:`graph-search-clear`,onClick:at,"aria-label":`Clear search`,title:`Clear search`,children:(0,j.jsx)(h,{size:14})})]}),!ut&&(0,j.jsxs)(`div`,{className:`graph-filter-wrap`,ref:qe,children:[(0,j.jsxs)(`button`,{type:`button`,className:`graph-filter-toggle${He?` is-open`:``}${ft.length>0||pt?` has-selection`:``}`,onClick:()=>Ue(e=>!e),"aria-haspopup":`true`,"aria-expanded":He,"aria-label":`Filter node types`,children:[(0,j.jsx)(v,{size:14}),(0,j.jsx)(`span`,{children:`Filter`}),ft.length>0&&(0,j.jsx)(`span`,{className:`graph-filter-count`,children:ft.length})]}),He&&(0,j.jsxs)(`div`,{className:`graph-filter-popover`,role:`dialog`,"aria-label":`Node type filter`,children:[(0,j.jsxs)(`div`,{className:`graph-filter-popover-header`,children:[(0,j.jsxs)(`button`,{type:`button`,className:`graph-toggle-trashed${pt?` active`:``}`,onClick:it,"aria-pressed":pt,title:`Show trashed nodes — restored with Restore button on each node`,children:[(0,j.jsx)(_,{size:14}),` Show trashed`]}),(ft.length>0||pt)&&(0,j.jsx)(`button`,{type:`button`,className:`graph-filter-clear`,onClick:ot,"aria-label":`Clear filter selection`,title:`Clear filter selection`,children:(0,j.jsx)(h,{size:14})})]}),Re.length===0&&(0,j.jsx)(`p`,{className:`graph-filter-popover-empty`,children:`No node types in your graph yet.`}),(0,j.jsx)(`div`,{className:`graph-filter-rows`,role:`group`,"aria-label":`Node type filter`,children:Re.map(({label:e,nodeCount:t})=>{let n=ft.includes(e),r=O(e);return(0,j.jsxs)(`button`,{type:`button`,className:`graph-filter-row${n?` active`:``}`,onClick:()=>rt(e),"aria-pressed":n,children:[(0,j.jsx)(`span`,{className:`graph-filter-row-swatch`,style:{backgroundColor:r}}),(0,j.jsx)(`span`,{className:`graph-filter-row-label`,children:e}),(0,j.jsx)(`span`,{className:`graph-filter-row-count`,children:t})]},e)})}),(0,j.jsx)(`div`,{className:`graph-filter-popover-footer`,children:(0,j.jsx)(`button`,{type:`button`,className:`graph-filter-set-default`,onClick:ct,disabled:!mt||We,children:We?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(s,{size:12,className:`spin`}),` Saving…`]}):`Set default view`})})]})]}),(0,j.jsxs)(`div`,{className:`graph-meta`,children:[m.length>1&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`button`,{type:`button`,className:`graph-back-to-filter graph-back-desktop`,onClick:st,children:`← Back`}),(0,j.jsx)(`button`,{type:`button`,className:`graph-back-to-filter graph-back-mobile`,onClick:st,"aria-label":`Back`,children:(0,j.jsx)(g,{size:16})})]}),le>0&&(0,j.jsxs)(`span`,{className:`graph-meta-count`,children:[le,` node`,le===1?``:`s`]})]})]}),m.length>1&&(0,j.jsx)(Oe,{viewStack:m}),Pe&&(0,j.jsxs)(`div`,{className:`data-error graph-error-banner`,children:[`Search unavailable: `,Pe]}),Me&&Me.length===0&&!Pe&&(0,j.jsx)(`div`,{className:`graph-search-status`,children:`No matches in your graph.`}),Me&&nt>0&&(0,j.jsxs)(`div`,{className:`graph-search-status`,children:[nt,` match`,nt===1?``:`es`,` not in current view. Adjust your filter or search more specifically.`]}),(0,j.jsxs)(`div`,{className:`graph-canvas-wrap`,children:[b&&(0,j.jsxs)(`div`,{className:`graph-canvas-overlay`,children:[(0,j.jsx)(s,{size:20,className:`spin`}),` Loading your graph…`]}),te&&!b&&(0,j.jsxs)(`div`,{className:`graph-canvas-overlay graph-canvas-error`,children:[(0,j.jsx)(`p`,{children:te}),(0,j.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:()=>window.location.reload(),children:`Retry`})]}),T&&!b&&(0,j.jsxs)(`div`,{className:`graph-canvas-overlay graph-canvas-error`,children:[(0,j.jsxs)(`p`,{children:[`Refine your filter — `,(0,j.jsx)(`strong`,{children:T.matched}),` matches exceed the 2000 cap.`]}),(0,j.jsx)(`p`,{className:`graph-canvas-hint`,children:`Pick a more specific label combination, or narrow your brand's data.`})]}),!b&&!te&&!T&&le===0&&!ut&&ft.length===0&&(0,j.jsxs)(`div`,{className:`graph-canvas-overlay`,children:[(0,j.jsx)(v,{size:20}),(0,j.jsx)(`p`,{children:`Open Filter to pick a node type and see what's in your graph.`})]}),!b&&!te&&!T&&le===0&&!ut&&ft.length>0&&(0,j.jsx)(`div`,{className:`graph-canvas-overlay`,children:(0,j.jsxs)(`p`,{children:[`No `,ft.join(`, `),` nodes in your graph yet.`]})}),(0,j.jsx)(`div`,{ref:t,className:`graph-canvas`}),le>0&&(0,j.jsx)(`div`,{ref:u,className:`graph-trash-drop-zone${pe?` is-hover`:``}${he?` is-error`:``}`,"aria-hidden":`true`,children:(0,j.jsx)(r,{size:18})}),ve&&(0,j.jsxs)(`div`,{className:`graph-drag-error-banner`,role:`alert`,children:[(0,j.jsx)(`span`,{children:ve}),(0,j.jsx)(`button`,{type:`button`,className:`graph-drag-error-dismiss`,onClick:()=>we(null),"aria-label":`Dismiss`,children:(0,j.jsx)(h,{size:14})})]})]}),de&&(0,j.jsx)(P,{node:de,sessionKey:e,onClose:()=>{fe(null);try{n.current?.unselectAll()}catch{}},onRestored:lt}),le>0&&Je.length>0&&(0,j.jsx)(`div`,{className:`graph-legend`,children:Je.map(e=>(0,j.jsxs)(`div`,{className:`graph-legend-item`,children:[(0,j.jsx)(`span`,{className:`graph-legend-swatch`,style:{backgroundColor:O(e)}}),(0,j.jsx)(`span`,{children:e})]},e))})]})}function P({node:e,sessionKey:t,onClose:n,onRestored:r}){let i=Object.entries(e.properties).filter(([,e])=>e!=null),[a,o]=(0,C.useState)(!1),[c,l]=(0,C.useState)(null);(0,C.useEffect)(()=>{o(!1),l(null)},[e.id]);let u=(0,C.useCallback)(()=>{o(!0),l(null),fetch(`/api/admin/graph-restore?session_key=${encodeURIComponent(t)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({elementId:e.id})}).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);r()}).catch(e=>{l(e instanceof Error?e.message:String(e)),o(!1)})},[e.id,r,t]);return(0,j.jsxs)(`aside`,{className:`graph-side-panel${e.trashed?` graph-side-panel-trashed`:``}`,children:[(0,j.jsxs)(`header`,{className:`graph-side-header`,children:[(0,j.jsx)(`div`,{children:(()=>{if(e.labels.some(e=>ce.has(e))){let t=_e(e),n=e.properties.createdAt,r=typeof n==`string`?n:``,i=r?pe(r):null,a=e.labels.join(` · `)+(e.trashed?` · Trashed`:``)+` · ${e.id}`;return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`h2`,{className:`graph-side-name`,title:t,children:t}),i&&(0,j.jsx)(`div`,{className:`graph-side-created`,children:i}),(0,j.jsx)(`div`,{className:`graph-side-meta`,children:a})]})}return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`graph-side-labels`,children:[e.labels.join(` · `),e.trashed?` · Trashed`:``]}),(0,j.jsx)(`div`,{className:`graph-side-id`,children:e.id})]})})()}),(0,j.jsx)(`button`,{type:`button`,className:`graph-side-close`,onClick:n,"aria-label":`Close`,children:(0,j.jsx)(h,{size:14})})]}),e.trashed&&(0,j.jsxs)(`dl`,{className:`graph-side-props graph-side-trash-meta`,children:[(0,j.jsxs)(`div`,{className:`graph-side-prop`,children:[(0,j.jsx)(`dt`,{children:`trashedAt`}),(0,j.jsx)(`dd`,{children:Ae(e.properties.trashedAt)})]}),(0,j.jsxs)(`div`,{className:`graph-side-prop`,children:[(0,j.jsx)(`dt`,{children:`trashedBy`}),(0,j.jsx)(`dd`,{children:Ae(e.properties.trashedBy)})]})]}),(0,j.jsxs)(`dl`,{className:`graph-side-props`,children:[i.length===0&&(0,j.jsx)(`div`,{className:`graph-side-empty`,children:`No properties.`}),i.map(([e,t])=>(0,j.jsxs)(`div`,{className:`graph-side-prop`,children:[(0,j.jsx)(`dt`,{children:e}),(0,j.jsx)(`dd`,{children:Ae(t)})]},e))]}),e.trashed&&(0,j.jsxs)(`footer`,{className:`graph-side-footer`,children:[!a&&!c&&(0,j.jsxs)(`button`,{type:`button`,className:`graph-side-restore`,onClick:u,children:[(0,j.jsx)(m,{size:14}),` Restore`]}),a&&(0,j.jsx)(`div`,{className:`graph-delete-confirm`,children:(0,j.jsxs)(`p`,{children:[(0,j.jsx)(s,{size:14,className:`spin`}),` Restoring…`]})}),c&&(0,j.jsxs)(`div`,{className:`graph-delete-confirm graph-delete-confirm-error`,children:[(0,j.jsxs)(`p`,{children:[`Restore failed: `,c]}),(0,j.jsxs)(`div`,{className:`graph-delete-confirm-buttons`,children:[(0,j.jsx)(`button`,{type:`button`,className:`graph-delete-confirm-cancel`,onClick:()=>{l(null)},children:`Close`}),(0,j.jsx)(`button`,{type:`button`,className:`graph-delete-confirm-do`,onClick:u,children:`Retry`})]})]})]})]})}function F(e,t){let n=`/api/admin/graph-subgraph?session_key=${encodeURIComponent(e)}`;return t.kind===`neighbourhood`?`${n}&mode=neighbourhood&elementId=${encodeURIComponent(t.rootElementId)}`:`${n}&mode=default&labels=${encodeURIComponent(t.selectedLabels.join(`,`))}${t.includeTrashed?`&includeTrashed=1`:``}`}var De=class extends Error{body;constructor(e){super(e.error),this.body=e}};function Oe({viewStack:e}){let t=e.map(e=>e.kind===`filter`?`Filter`:e.rootLabel??`Node`);return(0,j.jsx)(`div`,{className:`graph-breadcrumb`,role:`navigation`,"aria-label":`Graph navigation breadcrumb`,children:t.map((e,n)=>(0,j.jsxs)(`span`,{className:`graph-breadcrumb-item`,children:[n>0&&(0,j.jsx)(`span`,{className:`graph-breadcrumb-separator`,"aria-hidden":`true`,children:`›`}),(0,j.jsx)(`span`,{className:`graph-breadcrumb-label${n===t.length-1?` is-current`:``}`,children:e})]},n))})}function ke(e,t){let n=`[graph-page] ${e} ${Object.entries(t).map(([e,t])=>`${e}=${String(t)}`).join(` `)}`;try{fetch(`/api/_client-error`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:`graph-nav`,msg:n}),keepalive:!0}).catch(()=>{})}catch{}}function Ae(e){return e==null?``:Array.isArray(e)?e.length>8?`[${e.length} items]`:e.map(String).join(`, `):typeof e==`object`?`year`in e&&`month`in e&&`day`in e&&typeof e.year==`object`?`[unserialised temporal] ${JSON.stringify(e)}`:JSON.stringify(e):String(e)}(0,ee.createRoot)(document.getElementById(`root`)).render((0,j.jsx)(we,{}));
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Graph — Maxy</title>
7
7
  <link rel="icon" href="/favicon.ico">
8
- <script type="module" crossorigin src="/assets/graph-BPfHSY8L.js"></script>
8
+ <script type="module" crossorigin src="/assets/graph-ByzS1__T.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-CT8kMwlr.js">
11
11
  <link rel="modulepreload" crossorigin href="/assets/share-2-DZHAp0uN.js">
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Real Agent</title>
7
7
  <link rel="icon" href="/favicon.ico">
8
- <script type="module" crossorigin src="/assets/admin-gMMW5H75.js"></script>
8
+ <script type="module" crossorigin src="/assets/admin-Db49Ee_m.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-CT8kMwlr.js">
11
11
  <link rel="modulepreload" crossorigin href="/assets/preload-helper-qlgyTAkD.js">
@@ -9771,6 +9771,11 @@ var GRAPH_LABEL_COLOURS = {
9771
9771
  Service: "#3A6BB0",
9772
9772
  PriceSpecification: "#5B8DD0",
9773
9773
  OpeningHoursSpecification: "#7AAFE8",
9774
+ // External business entity — schema:Organization, written by memory-write
9775
+ // as the Supplier label (per platform/plugins/memory/references/schema-base.md).
9776
+ // Registry reconciled same shape as Task 626's ReviewAlert fix: label-in-graph
9777
+ // advertised it, default-mode 400'd it, registration closes the drift.
9778
+ Organization: "#A16207",
9774
9779
  // People
9775
9780
  Person: "#C2410C",
9776
9781
  UserProfile: "#EA580C",