@workerdeck/web 0.18.0 → 0.19.0
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/dist/assets/{freemarker2-26AUXpV-.js → freemarker2-CxhZmijJ.js} +1 -1
- package/dist/assets/{handlebars-Dc8agYpr.js → handlebars-CdkEUMsL.js} +1 -1
- package/dist/assets/{highlighted-body-OFNGDK62-BEs6UfPz.js → highlighted-body-OFNGDK62-CgN0BRlz.js} +1 -1
- package/dist/assets/{html-PN1qN48n.js → html-aSW7bzyb.js} +1 -1
- package/dist/assets/{index-B4f5UAbn.js → index-BBZcH34f.js} +1 -1
- package/dist/assets/{index-Os9DF_RA.js → index-D-9g69rX.js} +1 -1
- package/dist/assets/{index-DeDTIRzE.js → index-DEmlzO4U.js} +3 -3
- package/dist/assets/{index-wqkAGeoL.js → index-l4INUXkL.js} +6 -6
- package/dist/assets/{javascript-BLodm1eC.js → javascript-BzBhvDy3.js} +1 -1
- package/dist/assets/{liquid-PQ6XJhbZ.js → liquid-jOsCVvm-.js} +1 -1
- package/dist/assets/{mdx-x_GbzFco.js → mdx-BAoD_fZQ.js} +1 -1
- package/dist/assets/{python-81ubkMC2.js → python-kk2XcxFX.js} +1 -1
- package/dist/assets/{razor-eO8XNYA6.js → razor-UKigr7ht.js} +1 -1
- package/dist/assets/{typescript-sh-vIuJ-.js → typescript-DVWkVnR1.js} +1 -1
- package/dist/assets/{xml-QzPuBk5g.js → xml-CwgoGRfl.js} +1 -1
- package/dist/assets/{yaml-D6aVkQ3e.js → yaml-BWWH2Aw6.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +5 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DEmlzO4U.js","assets/index-CXkKwxiP.css"])))=>i.map(i=>d[i]);
|
|
2
2
|
function YL(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const s in r)if(s!=="default"&&!(s in e)){const a=Object.getOwnPropertyDescriptor(r,s);a&&Object.defineProperty(e,s,a.get?a:{enumerable:!0,get:()=>r[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(s){if(s.ep)return;s.ep=!0;const a=n(s);fetch(s.href,a)}})();function Wp(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var l1={exports:{}},Tu={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.js
|
|
@@ -1047,11 +1047,11 @@ ${SK(e,t)}
|
|
|
1047
1047
|
`),H=document.createDocumentFragment();for(let ne=0;ne<D.length;ne++)D[ne]&&H.appendChild(document.createTextNode(D[ne])),ne<D.length-1&&H.appendChild(document.createElement("br"));ue.insertNode(H),ue.collapse(!1);const B=window.getSelection();B?.removeAllRanges(),B?.addRange(ue),dx(K);const L=n(),te=DG(L,c);if(te!==L){r(te),s(te);for(const ne of te)ne.type==="chip"&&!L.some(de=>de.type==="chip"&&de.trigger===ne.trigger&&de.value===ne.value&&de.displayText===ne.displayText)&&x?.(ne)}else r(L);m?.({segments:te,source:"external"}),a()},[t,n,r,C,a,s,c,u,h,m,x,v,N]),M=y.useCallback(G=>{G.preventDefault();const K=Ys();if(!K)return;const Y=K.cloneContents(),U=cK(Y);G.clipboardData.setData("text/plain",U);const Q=uK(Y);if(Q.some(ue=>ue.type==="chip")){const ue=np(Q);ue&&G.clipboardData.setData("text/prompt-area-segments",ue)}},[]),_=y.useCallback(G=>{M(G);const K=Ys();if(!K)return;const Y=n();C(Y),K.deleteContents();const U=t.current;U&&dx(U);const Q=n();r(Q),a()},[M,t,n,r,C,a]),I=y.useCallback(G=>{G.preventDefault()},[]),j=y.useCallback(G=>{G.preventDefault()},[]),z=y.useCallback(()=>{w.current=!0},[]),P=y.useCallback(()=>{w.current=!1,a()},[a]),F=y.useCallback(()=>{setTimeout(()=>{const G=t.current;if(!G)return;const K=document.activeElement;K&&G.parentElement?.contains(K)||l()},$_)},[t,l]),V=y.useCallback(G=>{if(!(G.metaKey||G.ctrlKey)||G.key!=="z")return!1;G.preventDefault();const Y=S.current;if(G.shiftKey){if(Y.redoStack.length===0)return!0;const U=Y.redoStack.pop();if(!U)return!0;const Q=n();Y.undoStack.push(Q),r(U),s(U),b?.(U)}else{if(Y.undoStack.length===0)return!0;const U=Y.undoStack.pop();if(!U)return!0;const Q=n();Y.redoStack.push(Q),r(U),s(U),p?.(U)}return!0},[n,r,s,p,b]);return{handlePaste:R,handleCopy:M,handleCut:_,handleDrop:I,handleDragOver:j,handleCompositionStart:z,handleCompositionEnd:P,handleBlur:F,handleKeyDownForUndoRedo:V,pushUndo:C,resetUndoHistory:A,isComposing:w}}function _K(){const[e,t]=y.useState([]),[n,r]=y.useState(!1),[s,a]=y.useState(null),l=y.useRef(0),c=y.useRef(null),u=y.useRef(null),h=y.useCallback(()=>{c.current?.abort(),u.current&&clearTimeout(u.current),t([]),r(!1),a(null)},[]),m=y.useCallback((p,b)=>{if(!b.onSearch)return;c.current?.abort(),u.current&&clearTimeout(u.current),r(!0),a(null),l.current++;const x=l.current,v=new AbortController;c.current=v;const{onSearch:N,onSearchError:w,searchDebounceMs:S}=b,C=()=>{const A=N(p,{signal:v.signal});A instanceof Promise?A.then(R=>{v.signal.aborted||l.current!==x||(t(R),r(!1))},R=>{v.signal.aborted||l.current!==x||R instanceof DOMException&&R.name==="AbortError"||(a(R instanceof Error?R.message:"Search failed"),r(!1),w?.(R))}):(t(A),r(!1))};S&&S>0&&p.length>0?u.current=setTimeout(C,S):C()},[]);return y.useEffect(()=>()=>{c.current?.abort(),u.current&&clearTimeout(u.current)},[]),{suggestions:e,suggestionsLoading:n,suggestionsError:s,search:m,reset:h}}const AK=300;function RK({value:e,onChange:t,triggers:n=[],disabled:r=!1,onSubmit:s,onEscape:a,onChipClick:l,onChipAdd:c,onChipDelete:u,onLinkClick:h,onPaste:m,onRawPaste:p,onUndo:b,onRedo:x,onImagePaste:v,markdown:N=!0,normalizeBullets:w=!0,submitOnEnter:S=!0,maxLength:C}){const A=y.useRef(null),[R,M]=y.useState(null),[_,I]=y.useState(0),[j,z]=y.useState(null),P=y.useRef(null),F=y.useRef(null),V=y.useRef(null),{suggestions:G,suggestionsLoading:K,suggestionsError:Y,search:U,reset:Q}=_K(),W=y.useRef(!1),ue=y.useRef([]),D=y.useRef(null),H=y.useRef(null),B=y.useCallback(()=>{const ee=A.current;if(!ee)return[];const me=[];let se=!1,ie=!1;for(let Z=0;Z<ee.childNodes.length;Z++){const q=ee.childNodes[Z];if(q.nodeType===Node.TEXT_NODE){const ce=q.textContent??"";ce&&(me.push({type:"text",text:ce}),se=!0)}else if(sr(q)){const ce=Rp(q);ce&&(me.push(ce),se=!0)}else if(Ap(q)){if(q.dataset.sentinel){ie=!0;continue}me.push({type:"text",text:`
|
|
1048
1048
|
`})}else if(Oi(q)){const ce=q.textContent??"";ce&&(me.push({type:"text",text:ce}),se=!0)}}return!se&&!ie?[]:me},[]),L=y.useCallback(ee=>{const me=A.current;if(!me)return;W.current=!0;const se=sK(me);for(;me.firstChild;)me.removeChild(me.firstChild);for(const ie of ee)if(ie.type==="text"){const Z=ie.text.split(`
|
|
1049
1049
|
`);for(let q=0;q<Z.length;q++)Z[q]&&me.appendChild(document.createTextNode(Z[q])),q<Z.length-1&&me.appendChild(document.createElement("br"))}else{const Z=document.createElement("span");if(Z.contentEditable="false",Z.dataset.chipTrigger=ie.trigger,Z.dataset.chipValue=ie.value,Z.dataset.chipDisplay=ie.displayText,ie.data!==void 0){const Ce=np(ie.data);Ce&&(Z.dataset.chipData=Ce)}ie.autoResolved&&(Z.dataset.chipAutoResolved="true");const q=n.find(Ce=>Ce.char===ie.trigger),ce=q?.chipStyle??"pill";Z.dataset.chipStyle=ce,Z.className=ve("prompt-area-chip",ce==="inline"&&"prompt-area-chip--inline",q?.chipClassName),Z.textContent=`${ie.trigger}${ie.displayText}`,Z.setAttribute("role","button"),Z.setAttribute("tabindex","-1"),me.appendChild(Z)}if(me.lastChild&&Ap(me.lastChild)){const ie=document.createElement("br");ie.dataset.sentinel="true",me.appendChild(ie)}mC(me,N),se&&iK(me,se),ue.current=ee,W.current=!1},[n,N]),te=y.useCallback((ee,me)=>se=>{const ie=U1(ee,me,{value:se.value,displayText:se.displayText,data:se.data});t(ie.segments),L(ie.segments),c?.({type:"chip",trigger:me.config.char,value:se.value,displayText:se.displayText,...se.data!==void 0?{data:se.data}:{}});const Z=A.current;Z&&lr(Z,ie.cursorOffset)},[t,L,c]),ne=y.useCallback(()=>{const ee=A.current;if(!ee)return;const me=B(),se=Vn(me),ie=fa(ee);if(ie===null)return;const Z=IG(se,ie,n);if(P.current=null,F.current=null,Z){M(Z),I(0);const q=aK(ee,Z.startOffset);if(q){const ce=q.getBoundingClientRect();(ce.height>0||ce.left>0||ce.top>0)&&z(ce)}Z.config.mode==="dropdown"&&Z.config.onSearch&&U(Z.query,Z.config),Z.config.mode==="callback"&&Z.config.onActivate&&Z.config.onActivate({text:se,cursorPosition:ie,insertChip:te(me,Z)})}else M(null),Q()},[n,B,te,Q,U]),de=y.useCallback(()=>{P.current=null,F.current=null,M(null),I(0),Q()},[Q]),oe=NK({editorRef:A,readSegmentsFromDOM:B,onChange:t,renderSegmentsToDOM:L,runTriggerDetection:ne,dismissTrigger:de,triggers:n,markdownEnabled:N,normalizeBullets:w,onPaste:m,onRawPaste:p,onUndo:b,onRedo:x,onChipAdd:c,onImagePaste:v});y.useEffect(()=>{if(!W.current&&!zG(e,ue.current)){if(N&&w){const ee=lC(e,!0);if(ee!==e){t(ee);return}}L(e)}},[e,L,N,w,t]);const le=y.useRef(N);y.useEffect(()=>{if(le.current===N)return;le.current=N;const ee=w?lC(e,N):e;ee!==e?t(ee):L(e)},[N,w,L,e,t]),y.useEffect(()=>()=>{D.current&&clearTimeout(D.current)},[]);const ge=y.useCallback(()=>{if(W.current)return;if(oe.isComposing.current){const q=B();ue.current=q,t(q);return}const ee=A.current,me=ee?fa(ee):null;ee&&dx(ee);const se=B();if(C!=null&&ee&&Vn(se).length>C){const q=fa(ee),ce=MG(se,C);ue.current=ce,t(ce),L(ce),lr(ee,q!=null?Math.min(q,C):C),ne();return}if(N&&w&&ee&&me!==null){const q=HG(se,me);if(q){ue.current=q.segments,t(q.segments),L(q.segments),lr(ee,q.cursorOffset),ne();return}}let ie=se,Z=null;if(N&&me!==null&&L_(Vn(se))){const q=uC(se);q.edits.length>0&&(ie=q.segments,Z=cC(me,q.edits))}H.current||(H.current=ue.current),ue.current=ie,t(ie),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{H.current&&(oe.pushUndo(H.current),H.current=null),D.current=null},AK),ee&&(Z!==null?(L(ie),lr(ee,Z)):(mC(ee,N),me!==null&&lr(ee,me))),ne()},[t,B,ne,L,N,w,C,oe]),Pe=y.useCallback(ee=>{const me=ee.target;if(!(me instanceof Node))return;const se=A.current;if(!se)return;let ie=me;for(;ie&&ie!==se;){if(KG(ie)){if(ee.metaKey||ee.ctrlKey){ee.preventDefault(),h?.(ie.href),window.open(ie.href,"_blank","noopener,noreferrer");return}break}if(sr(ie)){const Z=ie.getBoundingClientRect(),q=document.createElement("span");q.className="prompt-area-chip-ripple";const ce=Math.max(Z.width,Z.height);q.style.width=`${ce}px`,q.style.height=`${ce}px`,q.style.left=`${ee.clientX-Z.left-ce/2}px`,q.style.top=`${ee.clientY-Z.top-ce/2}px`,ie.appendChild(q),q.addEventListener("animationend",()=>q.remove());const Ce=Rp(ie);if(Ce){const Re=n.find(at=>at.char===Ce.trigger),Ue=V.current===ie;if(V.current=null,!r&&!Ue&&Re?.reopenOnChipClick&&Re.mode==="dropdown"&&Re.onSearch){const at=rp(se,ie);P.current={chip:Ce,segIndex:F1(se,at)},F.current=ie,M({config:Re,startOffset:0,query:""}),I(0),z(Z),U("",Re)}l?.(Ce)}return}ie=ie.parentNode}},[l,h,n,U,r]),Le=y.useCallback(ee=>{const me=ee.target,se=A.current;if(!se||!(me instanceof Node)){V.current=null;return}let ie=me;for(;ie&&ie!==se;){if(sr(ie)){V.current=F.current===ie?ie:null;return}ie=ie.parentNode}V.current=null},[]),Se=y.useCallback((ee,me)=>{const se=B(),ie=rp(ee,me);if(ie===-1)return!1;const Z=F1(ee,ie),q=se[Z],ce=LG(se,Z);return t(ce),L(ce),q?.type==="chip"&&u?.(q),!0},[B,t,L,u]),Oe=y.useCallback((ee,me)=>{const se=B(),ie=rp(ee,me);if(ie===-1)return!1;const Z=F1(ee,ie),q=se[Z],ce=jG(se,Z);if(!ce)return!1;let Ce=0;for(let Re=0;Re<Z;Re++){const Ue=se[Re];Ue.type==="text"?Ce+=Ue.text.length:Ce+=Ue.trigger.length+Ue.displayText.length}return Ce+=ce.revertedText.length,t(ce.segments),L(ce.segments),lr(ee,Ce),q?.type==="chip"&&u?.(q),!0},[B,t,L,u]),He=y.useCallback(()=>{const ee=A.current;if(!ee)return!1;const me=Ys();if(!me||!me.collapsed)return!1;const se=me.startContainer,ie=me.startOffset;if(se===ee&&ie>0){const Z=ee.childNodes[ie-1];if(Z&&sr(Z))return cx(Z)?Oe(ee,Z):Se(ee,Z)}if(se.nodeType===Node.TEXT_NODE&&ie===0){const Z=ux(ee,se);if(!Z)return!1;let q=Z.previousSibling;for(;q&&q.nodeType===Node.TEXT_NODE&&q.textContent==="";)q=q.previousSibling;if(q&&sr(q))return cx(q)?Oe(ee,q):Se(ee,q)}return!1},[Se,Oe]),We=y.useCallback(()=>{const ee=A.current;if(!ee)return!1;const me=Ys();if(!me||!me.collapsed)return!1;const se=me.startContainer,ie=me.startOffset;if(se===ee&&ie<ee.childNodes.length){const Z=ee.childNodes[ie];if(Z&&sr(Z))return Se(ee,Z)}if(se.nodeType===Node.TEXT_NODE&&ie===(se.textContent??"").length){const Z=ux(ee,se);if(!Z)return!1;let q=Z.nextSibling;for(;q&&q.nodeType===Node.TEXT_NODE&&q.textContent==="";)q=q.nextSibling;if(q&&sr(q))return Se(ee,q)}return!1},[Se]),Ge=y.useCallback(ee=>{const me=B(),se=ee.query,ie={value:se,label:se},Z=ee.config.onSelect?.(ie)??se,q={value:se,displayText:Z||se,autoResolved:!0},ce=U1(me,ee,q);t(ce.segments),L(ce.segments),c?.({type:"chip",trigger:ee.config.char,...q});const Ce=A.current;Ce&&lr(Ce,ce.cursorOffset),de()},[B,t,L,de,c]),De=y.useCallback(ee=>{if(!R)return;const me=B(),se=R.config.insertAsText?.(ee);if(se!==void 0){const Re=OG(me,R,se);oe.pushUndo(me),t(Re.segments),L(Re.segments);const Ue=A.current;Ue&&lr(Ue,Re.cursorOffset),de(),setTimeout(()=>{A.current?.focus()},0);return}const ie=R.config.onSelect?.(ee)??ee.label,Z={value:ee.value,displayText:ie||ee.label,data:ee.data},q=P.current;if(q){const Re=A.current;if(Re&&!r){const Ue=me[q.segIndex],Qe=Ue?.type==="chip"&&Ue.trigger===q.chip.trigger&&Ue.value===q.chip.value?q.segIndex:(()=>{const dt=[];return me.forEach((Ye,St)=>{Ye.type==="chip"&&Ye.trigger===q.chip.trigger&&Ye.value===q.chip.value&&dt.push(St)}),dt.length===1?dt[0]:-1})(),ct=Qe!==-1?me[Qe]:void 0;if(ct?.type==="chip"){const dt={type:"chip",trigger:R.config.char,...Z};let Ye=me.map((Gt,Vt)=>Vt===Qe?dt:Gt);const St=Ye[Qe+1],Mt=!St||St.type!=="text"||St.text.length===0;Mt&&(Ye=[...Ye.slice(0,Qe+1),{type:"text",text:" "},...Ye.slice(Qe+1)]),oe.pushUndo(me),t(Ye),L(Ye),ct.value===dt.value&&ct.displayText===dt.displayText&&np(ct.data)===np(dt.data)||(u?.(ct),c?.(dt));const Tt=Vn(Ye.slice(0,Qe+1)).length+(Mt?1:0);lr(Re,Tt)}}de(),setTimeout(()=>{A.current?.focus()},0);return}const ce=U1(me,R,Z);t(ce.segments),L(ce.segments),c?.({type:"chip",trigger:R.config.char,...Z});const Ce=A.current;Ce&&lr(Ce,ce.cursorOffset),de(),setTimeout(()=>{A.current?.focus()},0)},[R,B,t,L,de,c,u,oe,r]),we=De;y.useEffect(()=>{const ee=P.current;if(!ee||!R?.config.reopenOnChipClick)return;const me=G.findIndex(se=>se.value===ee.chip.value);me>0&&I(me)},[G,R]);const Te=y.useCallback(ee=>{const me=(q,ce)=>{let{segments:Ce,cursorOffset:Re}=ce;if(N){const Ue=uC(Ce);Ce=Ue.segments,Re=cC(Re,Ue.edits)}ue.current=Ce,t(Ce),L(Ce),lr(q,Re)},se=q=>{if(!N)return!1;const ce=B(),Ce=fa(q);if(Ce===null)return!1;const Re=Vn(ce);if(!cc(Re,Ce))return!1;const Ue=UG(ce,Ce);return Ue&&me(q,Ue),!0};if((ee.metaKey||ee.ctrlKey)&&ee.key==="z"&&H.current&&(D.current&&(clearTimeout(D.current),D.current=null),oe.pushUndo(H.current),H.current=null),oe.handleKeyDownForUndoRedo(ee))return;if(N&&(ee.metaKey||ee.ctrlKey)&&!ee.shiftKey&&(ee.key==="b"||ee.key==="i")){ee.preventDefault();const q=A.current;if(!q)return;const ce=Rh(q);if(!ce||ce.start===ce.end)return;const Ce=ee.key==="b"?"**":"*",Re=B();oe.pushUndo(Re);const Ue=BG(Re,ce.start,ce.end,Ce);if(!Ue)return;ue.current=Ue.segments,t(Ue.segments),L(Ue.segments),bC(q,Ue.selectionStart,Ue.selectionEnd);return}if(!ee.metaKey&&!ee.ctrlKey&&!ee.altKey&&!ee.nativeEvent.isComposing&&ee.key.length===1){const q=n.find(Ce=>Ce.mode==="launch"&&Ce.char===ee.key),ce=A.current;if(q?.onActivate&&ce){const Ce=fa(ce);if(Ce!==null){const Re=B(),Ue=Vn(Re);if(_p(Ue,Ce,q.position)){ee.preventDefault(),q.onActivate({text:Ue,cursorPosition:Ce,insertChip:te(br(Re,Ce,Ce,q.char),{config:q,startOffset:Ce,query:""})});return}}}}if(R&&R.config.mode==="dropdown"&&(G.length>0||K||Y!==null||!!R.config.emptyMessage)){if(ee.key==="ArrowDown"){ee.preventDefault(),G.length>0&&I(q=>Math.min(q+1,G.length-1));return}if(ee.key==="ArrowUp"){ee.preventDefault(),G.length>0&&I(q=>Math.max(q-1,0));return}if(ee.key==="Enter"||ee.key==="Tab"){ee.preventDefault();const q=G[_];q&&De(q);return}if(ee.key==="Escape"){ee.preventDefault(),de();return}}if(ee.key===" "&&R&&R.config.resolveOnSpace&&R.query.trim().length>0){ee.preventDefault(),Ge(R);return}if(N&&ee.key==="Tab"&&!R){const q=A.current;if(q){const ce=B(),Ce=Vn(ce),Re=fa(q);if(Re!==null&&cc(Ce,Re)){ee.preventDefault();const at=ee.shiftKey?VG(ce,Re):$G(ce,Re);at&&me(q,at);return}}}const Z=q=>{const ce=Rh(q);if(!ce)return;const Ce=B();oe.pushUndo(Ce);const Re=br(Ce,ce.start,ce.end,`
|
|
1050
|
-
`);me(q,{segments:Re,cursorOffset:ce.start+1})};if(ee.key==="Enter"&&ee.shiftKey&&!ee.nativeEvent.isComposing){ee.preventDefault();const q=A.current;q&&!se(q)&&Z(q);return}if(ee.key==="Enter"&&!ee.shiftKey&&!ee.nativeEvent.isComposing){if(ee.preventDefault(),S){s?.(B());return}const q=A.current;q&&!se(q)&&Z(q);return}if(ee.key==="Escape"&&a){a();return}if((ee.key==="Backspace"||ee.key==="Delete")&&!ee.nativeEvent.isComposing){const q=A.current;if(q){const ce=Rh(q);if(ce&&ce.start!==ce.end){ee.preventDefault();const Ce=B();oe.pushUndo(Ce);const Re=br(Ce,ce.start,ce.end,"");me(q,{segments:Re,cursorOffset:ce.start}),ne();return}}}if(ee.key==="Backspace"){const q=A.current;if(q){const ce=B(),Ce=fa(q);if(N&&Ce!==null){const Re=qG(ce,Ce);if(Re){ee.preventDefault(),me(q,Re),ne();return}}}if(He()){ee.preventDefault(),ne();return}}if(ee.key==="Delete"&&We()){ee.preventDefault(),ne();return}},[R,G,K,Y,_,s,S,a,B,t,L,N,de,He,We,Ge,ne,De,oe,n,te]),Ie=y.useMemo(()=>({focus:()=>A.current?.focus(),blur:()=>A.current?.blur(),insertChip:ee=>{const me=B(),se={type:"chip",...ee},ie=[...me,se,{type:"text",text:" "}];t(ie),L(ie),c?.(se)},getPlainText:()=>Vn(B()),clear:()=>{t([]);const ee=A.current;if(ee)for(;ee.firstChild;)ee.removeChild(ee.firstChild);oe.resetUndoHistory(),D.current&&(clearTimeout(D.current),D.current=null),H.current=null},setText:ee=>{oe.pushUndo(B());const me=RG(ee);t(me),L(me);const se=A.current;se&&lr(se,ee.length)},appendText:ee=>{const me=B();oe.pushUndo(me);const se=me[me.length-1],ie=se?.type==="text"?[...me.slice(0,-1),{type:"text",text:se.text+ee}]:[...me,{type:"text",text:ee}];t(ie),L(ie);const Z=A.current;Z&&lr(Z,Vn(ie).length)},getCursorPosition:()=>{const ee=A.current;return ee?fa(ee):null},setCursorPosition:ee=>{const me=A.current;me&&lr(me,ee)},setCursorToEnd:()=>{const ee=A.current;ee&&lr(ee,Vn(B()).length)},getSelection:()=>{const ee=A.current;return ee?Rh(ee):null},setSelection:(ee,me)=>{const se=A.current;se&&bC(se,ee,me)}}),[B,t,L,c,oe]),Be=y.useMemo(()=>({onPaste:oe.handlePaste,onCopy:oe.handleCopy,onCut:oe.handleCut,onDrop:oe.handleDrop,onDragOver:oe.handleDragOver,onCompositionStart:oe.handleCompositionStart,onCompositionEnd:oe.handleCompositionEnd,onBlur:oe.handleBlur}),[oe.handlePaste,oe.handleCopy,oe.handleCut,oe.handleDrop,oe.handleDragOver,oe.handleCompositionStart,oe.handleCompositionEnd,oe.handleBlur]);return{editorRef:A,activeTrigger:R,suggestions:G,suggestionsLoading:K,suggestionsError:Y,selectedSuggestionIndex:_,handleInput:ge,handleKeyDown:Te,handleClick:Pe,handleMouseDown:Le,selectSuggestion:we,dismissTrigger:de,handle:Ie,triggerRect:j,eventHandlers:Be}}const xC=240;function MK({suggestions:e,loading:t,error:n,emptyMessage:r,selectedIndex:s,onSelect:a,onDismiss:l,triggerRect:c,triggerChar:u}){const h=y.useRef(null),m=y.useRef(null);if(y.useEffect(()=>{m.current?.scrollIntoView({block:"nearest"})},[s]),y.useEffect(()=>{const w=S=>{const C=S.target;h.current&&C instanceof Node&&!h.current.contains(C)&&l()};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[l]),!c||e.length===0&&!t&&!n&&!r)return null;const p=Math.min(320,window.innerWidth-16),b=Math.min(c.left,window.innerWidth-p-8),x=window.innerHeight-c.bottom,v=x<xC&&c.top>x,N={position:"fixed",left:`${Math.max(8,b)}px`,zIndex:50,maxWidth:`${p}px`,maxHeight:`${xC}px`,...v?{bottom:`${window.innerHeight-c.top+4}px`}:{top:`${c.bottom+4}px`}};return d.jsx("div",{ref:h,className:ve("min-w-[200px] overflow-y-auto","bg-surface rounded-xl border p-2 shadow-md","animate-in fade-in-0 zoom-in-95"),style:N,role:"listbox","aria-label":`${u} suggestions`,children:t?d.jsx("div",{role:"option","aria-selected":!1,className:"text-muted-foreground px-3 py-2 text-sm",children:"Loading suggestions..."}):n?d.jsx("div",{role:"option","aria-selected":!1,className:"text-destructive px-3 py-2 text-sm",children:n}):e.length===0&&r?d.jsx("div",{role:"option","aria-selected":!1,className:"text-muted-foreground px-3 py-2 text-sm",children:r}):e.map((w,S)=>d.jsxs("button",{ref:S===s?m:void 0,type:"button",role:"option","aria-selected":S===s,className:ve("text-foreground flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left text-sm","hover:bg-surface-hover cursor-pointer transition-colors",S===s&&"bg-surface-hover"),onMouseDown:C=>{C.preventDefault(),a(w)},children:[w.icon&&d.jsx("span",{className:"mt-0.5 shrink-0",children:w.icon}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("div",{className:"truncate font-medium",children:w.label}),w.description&&d.jsx("div",{className:"text-muted-foreground truncate text-xs",children:w.description})]})]},w.value))})}function IK({texts:e,interval:t=3e3}){const[n,r]=y.useState(0);return y.useEffect(()=>{if(e.length<=1)return;const s=setInterval(()=>{r(a=>(a+1)%e.length)},t);return()=>clearInterval(s)},[e.length,t]),d.jsx("div",{className:"pointer-events-none absolute top-0 left-0 overflow-hidden select-none",style:{color:"var(--prompt-area-placeholder, var(--muted-foreground))"},"aria-hidden":"true",children:d.jsx("div",{className:"animate-in fade-in-0 slide-in-from-top-4 duration-300 ease-in-out",children:e[n]},n)})}function V_({onClick:e,label:t,className:n}){return d.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),e()},className:ve("absolute top-0.5 right-0.5 grid h-3.5 w-3.5 cursor-pointer place-items-center","rounded-full bg-black/60 text-white hover:bg-black/80 dark:bg-white/60 dark:text-black dark:hover:bg-white/80","transition-colors",n),"aria-label":t,children:d.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[d.jsx("line",{x1:"2.75",y1:"2.75",x2:"7.25",y2:"7.25"}),d.jsx("line",{x1:"7.25",y1:"2.75",x2:"2.75",y2:"7.25"})]})})}function OK({images:e,onRemove:t,onClick:n,className:r}){return e.length===0?null:d.jsx("div",{className:ve("flex flex-wrap gap-2",r),role:"list","aria-label":"Attached images",children:e.map(s=>d.jsxs("div",{role:"listitem",className:ve("border-border relative h-16 w-16 flex-shrink-0 overflow-hidden rounded-md border",n&&"cursor-pointer"),onClick:()=>n?.(s),children:[d.jsx("img",{src:s.url,alt:s.alt??"Attached image",className:"h-full w-full object-cover"}),s.loading&&d.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/40",children:d.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent"})}),t&&d.jsx(V_,{onClick:()=>t(s),label:`Remove ${s.alt??"image"}`})]},s.id))})}function Bd({className:e,children:t}){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:e,children:t})}const _m=d.jsxs(d.Fragment,{children:[d.jsx("path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}),d.jsx("path",{d:"M14 2v5a1 1 0 0 0 1 1h5"})]}),LK=({className:e})=>d.jsx(Bd,{className:e,children:_m}),jK=({className:e})=>d.jsxs(Bd,{className:e,children:[_m,d.jsx("path",{d:"M10 9H8"}),d.jsx("path",{d:"M16 13H8"}),d.jsx("path",{d:"M16 17H8"})]}),DK=({className:e})=>d.jsxs(Bd,{className:e,children:[_m,d.jsx("path",{d:"M8 13h2"}),d.jsx("path",{d:"M14 13h2"}),d.jsx("path",{d:"M8 17h2"}),d.jsx("path",{d:"M14 17h2"})]}),PK=({className:e})=>d.jsxs(Bd,{className:e,children:[_m,d.jsx("path",{d:"M10 12.5 8 15l2 2.5"}),d.jsx("path",{d:"m14 12.5 2 2.5-2 2.5"})]}),BK=({className:e})=>d.jsxs(Bd,{className:e,children:[d.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),d.jsx("circle",{cx:"9",cy:"9",r:"2"}),d.jsx("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]}),Mh=3;function zK(e){return e?e==="application/pdf"?"pdf":e.includes("spreadsheet")||e==="text/csv"?"spreadsheet":e.startsWith("text/")||e.includes("javascript")||e.includes("json")||e.includes("xml")?"code":e.startsWith("image/")?"image":"default":"default"}const HK={pdf:jK,spreadsheet:DK,code:PK,image:BK,default:LK};function UK(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}function FK(e){const t=e.lastIndexOf(".");return t===-1||t===e.length-1?null:e.slice(t+1).toUpperCase()}function yC({file:e,compact:t,onRemove:n,onClick:r}){const s=FK(e.name),a=e.size!=null?UK(e.size):null,l=[s,a].filter(Boolean).join(" · ");return d.jsxs("div",{role:"listitem",className:ve("border-border relative flex flex-shrink-0 items-center gap-2 overflow-hidden rounded-lg border transition-colors","hover:bg-surface-hover",t?"h-10 w-36 px-2":"h-14 w-48 px-3",r&&"cursor-pointer"),onClick:()=>r?.(e),children:[(()=>{const c=HK[zK(e.type)];return d.jsx(c,{className:ve("text-muted-foreground flex-shrink-0",t?"h-4 w-4":"h-5 w-5")})})(),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("div",{className:ve("truncate font-medium",t?"text-xs":"text-sm"),title:e.name,children:e.name}),!t&&l&&d.jsx("div",{className:"text-muted-foreground truncate text-xs",children:l})]}),e.loading&&d.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/40",children:d.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent"})}),n&&d.jsx(V_,{onClick:()=>n(e),label:`Remove ${e.name}`})]})}function $K({files:e,onRemove:t,onClick:n,className:r}){const[s,a]=y.useState(!1),l=y.useRef(null),c=y.useRef(null);if(y.useEffect(()=>{if(!s)return;const b=x=>{const v=x.target;v instanceof Node&&l.current&&!l.current.contains(v)&&!c.current?.contains(v)&&a(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[s]),e.length===0)return null;const u=e.length>Mh,h=u,m=e.length-Mh,p=e.slice(0,Mh);return d.jsxs("div",{className:ve("relative",r),children:[d.jsxs("div",{className:"flex flex-wrap gap-2",role:"list","aria-label":"Attached files",children:[(u?p:e).map(b=>d.jsx(yC,{file:b,compact:h,onRemove:t,onClick:n},b.id)),u&&d.jsx("div",{role:"listitem",children:d.jsx("button",{ref:c,type:"button",onClick:()=>a(b=>!b),className:ve("border-border text-muted-foreground hover:bg-surface-hover flex flex-shrink-0 cursor-pointer items-center justify-center rounded-lg border transition-colors",h?"h-10 px-3 text-xs":"h-14 px-4 text-sm"),children:s?"Show less":`+${m} more`})})]}),s&&d.jsx("div",{ref:l,className:ve("bg-surface border-border absolute bottom-full left-0 z-10 mb-2 max-h-48 overflow-y-auto rounded-lg border p-2 shadow-lg"),children:d.jsx("div",{className:"flex flex-wrap gap-2",role:"list","aria-label":"More attached files",children:e.slice(Mh).map(b=>d.jsx(yC,{file:b,compact:h,onRemove:t,onClick:n},b.id))})})]})}function V1({value:e,onChange:t,triggers:n,placeholder:r,className:s,disabled:a=!1,markdown:l,normalizeBullets:c,onSubmit:u,onEscape:h,onChipClick:m,onChipAdd:p,onChipDelete:b,onLinkClick:x,onPaste:v,onUndo:N,onRedo:w,minHeight:S=80,maxHeight:C,autoFocus:A=!1,autoGrow:R=!1,"aria-label":M,"data-test-id":_,images:I=[],imagePosition:j="above",onImagePaste:z,onImageRemove:P,onImageClick:F,files:V=[],filePosition:G="above",onFileRemove:K,onFileClick:Y,onKeyDown:U,onBlur:Q,onRawPaste:W,submitOnEnter:ue,spellCheck:D,maxLength:H,"aria-describedby":B,ref:L}){const{editorRef:te,activeTrigger:ne,suggestions:de,suggestionsLoading:oe,suggestionsError:le,selectedSuggestionIndex:ge,handleInput:Pe,handleKeyDown:Le,handleClick:Se,handleMouseDown:Oe,selectSuggestion:He,dismissTrigger:We,handle:Ge,triggerRect:De,eventHandlers:we}=RK({value:e,onChange:t,triggers:n,disabled:a,onSubmit:u,onEscape:h,onChipClick:m,onChipAdd:p,onChipDelete:b,onLinkClick:x,onPaste:v,onRawPaste:W,onUndo:N,onRedo:w,onImagePaste:z,markdown:l,normalizeBullets:c,submitOnEnter:ue,maxLength:H});y.useImperativeHandle(L,()=>Ge,[Ge]),y.useEffect(()=>{A&&te.current?.focus()},[A,te]);const[Te,Ie]=y.useState(!1),[Be,ee]=y.useState(void 0),me=y.useCallback(()=>{const Ye=te.current;if(!Ye)return;Ye.style.height="auto";const St=Ye.scrollHeight;Ye.style.height=`${St}px`,ee(St)},[te]),se=y.useCallback(()=>{R&&(Ie(!0),me())},[R,me]),ie=y.useCallback(()=>{we.onBlur(),R&&setTimeout(()=>{const Ye=te.current;if(!Ye)return;const St=document.activeElement;St&&Ye.parentElement?.contains(St)||(Ie(!1),ee(void 0))},$_)},[we,R,te]),Z=y.useCallback(()=>{Pe(),R&&Te&&me()},[Pe,R,Te,me]);y.useEffect(()=>{R&&Te&&requestAnimationFrame(()=>me())},[e,R,Te,me]);const[q,ce]=y.useState(!1),Ce=y.useRef(null);y.useEffect(()=>{if(!R)return;const Ye=()=>{if(Te){ce(!1);return}const Mt=te.current;Mt&&ce(Mt.scrollHeight>Mt.clientHeight)},St=Te?0:160;return Ce.current=setTimeout(Ye,St),()=>{Ce.current!==null&&clearTimeout(Ce.current)}},[R,Te,e,te]);const Re=y.useMemo(()=>{if(!R){const Ye={minHeight:`${S}px`};return C&&(Ye.maxHeight=`${C}px`,Ye.overflowY="auto"),Ye}return{height:Te&&Be?`${Be}px`:`${S}px`,minHeight:`${S}px`,maxHeight:C?`${C}px`:"70dvh",overflowY:Te?"auto":"hidden",transition:"height 150ms ease-out, min-height 240ms cubic-bezier(0.33, 1, 0.68, 1)"}},[R,S,C,Te,Be]),Ue=y.useCallback(Ye=>{U?.(Ye),!Ye.defaultPrevented&&Le(Ye)},[U,Le]),at=y.useCallback(Ye=>{Q?.(Ye),ie()},[Q,ie]),Qe=e.length===0||e.length===1&&e[0].type==="text"&&e[0].text==="",ct=I.length>0?d.jsx(OK,{images:I,onRemove:P,onClick:F,className:j==="above"?"pb-2":"pt-2"}):null,dt=V.length>0?d.jsx($K,{files:V,onRemove:K,onClick:Y,className:G==="above"?"pb-2":"pt-2"}):null;return d.jsxs("div",{className:ve("prompt-area-container relative text-sm leading-relaxed",s),children:[j==="above"&&ct,G==="above"&&dt,d.jsxs("div",{className:"relative",children:[d.jsx("div",{ref:te,contentEditable:!a,suppressContentEditableWarning:!0,role:"textbox","aria-label":M??"Text input","aria-multiline":"true","aria-disabled":a||void 0,"aria-describedby":B,"data-test-id":_,spellCheck:D,className:ve("prompt-area-editor","w-full min-w-0 break-words whitespace-pre-wrap outline-none",a&&"cursor-not-allowed opacity-50"),style:Re,onFocus:se,onInput:R?Z:Pe,onKeyDown:Ue,onMouseDown:Oe,onClick:Se,onPaste:we.onPaste,onCopy:we.onCopy,onCut:we.onCut,onDrop:we.onDrop,onDragOver:we.onDragOver,onCompositionStart:we.onCompositionStart,onCompositionEnd:we.onCompositionEnd,onBlur:at}),R&&q&&!Te&&d.jsx("div",{"aria-hidden":"true",className:"pointer-events-auto absolute right-0 bottom-0 left-0 cursor-pointer",style:{height:"32px"},onClick:()=>te.current?.focus(),children:d.jsx("div",{className:"h-full w-full",style:{background:"linear-gradient(to bottom, transparent, color-mix(in srgb, var(--prompt-area-surface, var(--background)) 80%, transparent), var(--prompt-area-surface, var(--background)))"}})}),Qe&&r&&(Array.isArray(r)?d.jsx(IK,{texts:r}):d.jsx("div",{className:"pointer-events-none absolute top-0 left-0 select-none",style:{color:"var(--prompt-area-placeholder, var(--muted-foreground))"},"aria-hidden":"true",children:r}))]}),G==="below"&&dt,j==="below"&&ct,ne&&ne.config.mode==="dropdown"&&d.jsx(MK,{suggestions:de,loading:oe,error:le,emptyMessage:ne.config.emptyMessage,selectedIndex:ge,onSelect:He,onDismiss:We,triggerRect:De,triggerChar:ne.config.char})]})}function VK(e={}){const{initialValue:t=[]}=e,[n,r]=y.useState(t),s=y.useRef(null),a=y.useMemo(()=>Vn(n),[n]),l=y.useMemo(()=>n.length===0?!0:n.every(v=>v.type==="text"&&v.text.trim()===""),[n]),c=y.useMemo(()=>n.some(v=>v.type==="chip"),[n]),u=y.useMemo(()=>n.filter(v=>v.type==="chip"),[n]),h=y.useMemo(()=>({ref:s,value:n,onChange:r}),[n]),m=y.useCallback(()=>{s.current?s.current.clear():r([])},[]),p=y.useCallback(()=>s.current?.focus(),[]),b=y.useCallback(()=>s.current?.blur(),[]),x=y.useCallback(v=>s.current?.insertChip(v),[]);return{bind:h,plainText:a,isEmpty:l,hasChips:c,chips:u,clear:m,focus:p,blur:b,insertChip:x}}function qK(e={}){const{char:t="@",...n}=e;return{char:t,position:"any",mode:"dropdown",chipStyle:"pill",accessibilityLabel:"mention",...n}}function vC(e={}){const{char:t="/",position:n="any",...r}=e;return{char:t,position:n,mode:"dropdown",chipStyle:"inline",accessibilityLabel:"command",...r}}const q_=["attention","working","idle","ended"],Y_={attention:"Needs attention",working:"Working",idle:"Idle",ended:"Ended"};function G_(e){return e.pendingPermissionCount>0||e.status==="awaiting_approval"?"attention":e.status==="failed"||e.status==="closed"?"ended":e.status==="running"||e.status==="starting"||YK(e).length>0?"working":"idle"}function YK(e){return(e.subagents??[]).filter(t=>t.status==="running")}function GK(e){return(e.agentType?.trim()??"")!==""}function fx(e){const t=e.agentType?.trim(),n=e.description?.trim();return t&&n?`${t} · ${n}`:t||n||"Sub-agent"}const hx={search:"",gateways:[],adapters:[],states:[],projects:[],scoped:!0,groupBy:"state",sortBy:"recent"};function KK(e){return[...new Set(e.map(t=>t.adapter))].sort()}function WK(e){const t=new Map;for(const n of e)t.set(_2(n),A2(n));return[...t].map(([n,r])=>({key:n,label:r})).sort((n,r)=>n.label.toLowerCase().localeCompare(r.label.toLowerCase()))}function uc(e){return e.title??e.id.slice(0,8)}function _2(e){return`${e.hostId}:${dc(e.info.project?.root??e.info.cwd)}`}function A2(e){const t=e.info.project?.name;if(t)return t;const n=dc(e.info.cwd);return n.slice(n.lastIndexOf("/")+1)||"No project"}function XK(e){const t=e.info.project?.root;if(t===void 0||!e.info.cwd)return;const n=dc(t),r=dc(e.info.cwd);if(r!==n&&r.startsWith(`${n}/`))return r.slice(n.length+1)||void 0}function QK(e){return typeof e.meta?.jobId=="string"}function ZK(e,t){return t?uc(e.info).toLowerCase().includes(t)||e.info.cwd.toLowerCase().includes(t)||(e.info.project?.name.toLowerCase().includes(t)??!1)||e.hostName.toLowerCase().includes(t)||e.adapter.toLowerCase().includes(t)||e.info.id.startsWith(t):!0}function dc(e){return e.replace(/\\/g,"/").replace(/\/+$/,"")}function JK(e,t){const n=dc(e),r=dc(t);return r===n||r.startsWith(`${n}/`)}function eW(e,t){return t.roots.some(n=>(n.hostId?n.hostId.toLowerCase()===e.hostId.toLowerCase():e.local)&&JK(n.path,e.info.cwd))}function K_(e,t){return e.scoped&&t!==void 0}function W_(e,t,n){const r=t.search.trim().toLowerCase(),s=K_(t,n)?n:void 0;return e.filter(a=>(t.gateways.length===0||t.gateways.includes(a.hostId))&&(t.adapters.length===0||t.adapters.includes(a.adapter))&&(t.states.length===0||t.states.includes(a.state))&&(!t.projects?.length||t.projects.includes(_2(a)))&&(!s||eW(a,s))&&ZK(a,r))}function tW(e,t){return t==="gateway"?e.hostId:t==="adapter"?e.adapter:t==="project"?_2(e):e.state}function X_(e,t){return t==="gateway"?e.hostName:t==="adapter"?e.adapter:t==="project"?A2(e):Y_[e.state]}function px(e,t){return t==="state"?String(q_.indexOf(e.state)):X_(e,t).toLowerCase()}const q1=(e,t)=>(t.info.lastActivityAt??t.info.createdAt)-(e.info.lastActivityAt??e.info.createdAt);function nW(e,t,n){return n==="recent"?q1(e,t):n==="name"?uc(e.info).localeCompare(uc(t.info),void 0,{sensitivity:"base"})||q1(e,t):px(e,n).localeCompare(px(t,n))||q1(e,t)}function rW(e,t){const n=[...e].sort((a,l)=>nW(a,l,t.sortBy));if(t.groupBy==="none")return n.length?[{key:"all",rows:n}]:[];const r=t.groupBy,s=new Map;for(const a of n){const l=tW(a,r),c=s.get(l);c?c.rows.push(a):s.set(l,{key:l,label:X_(a,r),rank:px(a,r),rows:[a]})}return[...s.values()].sort((a,l)=>a.rank.localeCompare(l.rank))}function sW(e,t,n,r){if(n>=r)return;const s=[];t&&K_(e,t)&&s.push(t.label);const a=(e.gateways.length?1:0)+(e.adapters.length?1:0)+(e.states.length?1:0)+(e.projects?.length?1:0);return a>0&&s.push(`${a} filter${a===1?"":"s"}`),e.search.trim()&&s.push("search"),{shown:n,total:r,causes:s}}function iW(e){return e.search.trim().length>0||e.gateways.length>0||e.adapters.length>0||e.states.length>0||(e.projects?.length??0)>0}function EC(e){return{...hx,scoped:!1,groupBy:e.groupBy,sortBy:e.sortBy}}function aW(e,t){const n={};for(const[r,s]of Object.entries(e.rateLimits??{}))n[r]={info:s,updatedAt:e.updatedAt??0};for(const[r,s]of Object.entries(t??{}))n[r]=s;return n}function Q_(e){const t=Object.entries(e??{}).filter(([,s])=>s.info.utilization!==void 0).map(([s,a])=>({key:s,info:a.info,updatedAt:a.updatedAt,inferredReset:a.inferredReset})),n=["five_hour","seven_day"].flatMap(s=>t.filter(a=>a.key===s)),r=t.filter(s=>s.key.startsWith("seven_day_")).sort((s,a)=>s.key.localeCompare(a.key));return[...n,...r]}function oW(e){if(!e)return;const t={};for(const[n,r]of Object.entries(e))t[n]=r.info;return t}const lW=720*60*60*1e3,cW=6e4,Y1=(e,t)=>`${e}:${t}`;class uW{#t;#n;constructor(t){this.#t=t,this.#n={...t.read()}}get(t,n){return this.#n[Y1(t,n)]}all(){return this.#n}mark(t,n,r,s=Date.now()){const a=Y1(t,n),l=this.#n[a],c={itemCount:Math.max(l?.itemCount??0,r.itemCount??0),activity:Math.max(l?.activity??0,r.activity??0),turns:Math.max(l?.turns??0,r.turns??0),seenAt:s};return l&&l.itemCount===c.itemCount&&l.activity===c.activity&&l.turns===c.turns&&c.seenAt-l.seenAt<cW?!1:(this.#n[a]=c,this.#t.write(this.#r(s)),!0)}forget(t,n){const r=Y1(t,n);r in this.#n&&(delete this.#n[r],this.#t.write(this.#n))}#r(t){const n=t-lW;for(const[r,s]of Object.entries(this.#n))s.seenAt<n&&delete this.#n[r];return this.#n}}function dW(e,t){return e?t.activityCount!==void 0?Math.max(0,t.activityCount-e.activity):Math.max(0,(t.turns??0)-e.turns):0}const Z_=7,Am={claude:{interactiveApprovals:!0,permissionModes:["default","acceptEdits","bypassPermissions","plan","dontAsk","auto"],defaultPermissionMode:"default",resume:!0,resumeBackfill:!0,listSessions:!0,contextUsage:!0,rateLimits:!0,mcpStatus:!0,mcpServerActions:!0,sessionMcpServers:!0,slashCommands:!0,skillsList:!1,settingSources:!0,budgets:!0,attachments:["image","pdf","text"],reasoningEfforts:["low","medium","high","xhigh","max"],vfs:!1,hostCwd:!0,streaming:"token"},codex:{interactiveApprovals:!0,permissionModes:["default","acceptEdits","bypassPermissions"],defaultPermissionMode:"default",resume:!0,resumeBackfill:!0,listSessions:!0,contextUsage:!0,rateLimits:!0,mcpStatus:!0,mcpServerActions:!1,sessionMcpServers:!1,slashCommands:!1,skillsList:!0,settingSources:!1,budgets:!1,attachments:["image","text"],reasoningEfforts:["minimal","low","medium","high","xhigh"],vfs:!1,hostCwd:!0,streaming:"token"},provider:{interactiveApprovals:!1,permissionModes:["default","bypassPermissions","dontAsk"],defaultPermissionMode:"default",resume:!1,resumeBackfill:!1,listSessions:!1,contextUsage:!1,rateLimits:!1,mcpStatus:!0,mcpServerActions:!1,sessionMcpServers:!1,slashCommands:!1,skillsList:!1,settingSources:!1,budgets:!1,attachments:["image","pdf","text"],vfs:!0,hostCwd:!1,streaming:"token"}};Am.provider.permissionModes;const J_={status:"starting",capabilities:Am.claude,items:[],pendingApprovals:[],totalCostUsd:0,lastSeq:0},mx="streaming",gx="streaming-thinking",TC=e=>e==null?mx:`${mx}:${e}`,SC=e=>e==null?gx:`${gx}:${e}`,fW=e=>e.kind==="assistant_text"&&e.id.startsWith(mx)||e.kind==="thinking"&&e.id.startsWith(gx);function hW(e){return e===void 0?"":typeof e=="string"?e:e.map(t=>typeof t.text=="string"?t.text:"").filter(Boolean).join(`
|
|
1050
|
+
`);me(q,{segments:Re,cursorOffset:ce.start+1})};if(ee.key==="Enter"&&ee.shiftKey&&!ee.nativeEvent.isComposing){ee.preventDefault();const q=A.current;q&&!se(q)&&Z(q);return}if(ee.key==="Enter"&&!ee.shiftKey&&!ee.nativeEvent.isComposing){if(ee.preventDefault(),S){s?.(B());return}const q=A.current;q&&!se(q)&&Z(q);return}if(ee.key==="Escape"&&a){a();return}if((ee.key==="Backspace"||ee.key==="Delete")&&!ee.nativeEvent.isComposing){const q=A.current;if(q){const ce=Rh(q);if(ce&&ce.start!==ce.end){ee.preventDefault();const Ce=B();oe.pushUndo(Ce);const Re=br(Ce,ce.start,ce.end,"");me(q,{segments:Re,cursorOffset:ce.start}),ne();return}}}if(ee.key==="Backspace"){const q=A.current;if(q){const ce=B(),Ce=fa(q);if(N&&Ce!==null){const Re=qG(ce,Ce);if(Re){ee.preventDefault(),me(q,Re),ne();return}}}if(He()){ee.preventDefault(),ne();return}}if(ee.key==="Delete"&&We()){ee.preventDefault(),ne();return}},[R,G,K,Y,_,s,S,a,B,t,L,N,de,He,We,Ge,ne,De,oe,n,te]),Ie=y.useMemo(()=>({focus:()=>A.current?.focus(),blur:()=>A.current?.blur(),insertChip:ee=>{const me=B(),se={type:"chip",...ee},ie=[...me,se,{type:"text",text:" "}];t(ie),L(ie),c?.(se)},getPlainText:()=>Vn(B()),clear:()=>{t([]);const ee=A.current;if(ee)for(;ee.firstChild;)ee.removeChild(ee.firstChild);oe.resetUndoHistory(),D.current&&(clearTimeout(D.current),D.current=null),H.current=null},setText:ee=>{oe.pushUndo(B());const me=RG(ee);t(me),L(me);const se=A.current;se&&lr(se,ee.length)},appendText:ee=>{const me=B();oe.pushUndo(me);const se=me[me.length-1],ie=se?.type==="text"?[...me.slice(0,-1),{type:"text",text:se.text+ee}]:[...me,{type:"text",text:ee}];t(ie),L(ie);const Z=A.current;Z&&lr(Z,Vn(ie).length)},getCursorPosition:()=>{const ee=A.current;return ee?fa(ee):null},setCursorPosition:ee=>{const me=A.current;me&&lr(me,ee)},setCursorToEnd:()=>{const ee=A.current;ee&&lr(ee,Vn(B()).length)},getSelection:()=>{const ee=A.current;return ee?Rh(ee):null},setSelection:(ee,me)=>{const se=A.current;se&&bC(se,ee,me)}}),[B,t,L,c,oe]),Be=y.useMemo(()=>({onPaste:oe.handlePaste,onCopy:oe.handleCopy,onCut:oe.handleCut,onDrop:oe.handleDrop,onDragOver:oe.handleDragOver,onCompositionStart:oe.handleCompositionStart,onCompositionEnd:oe.handleCompositionEnd,onBlur:oe.handleBlur}),[oe.handlePaste,oe.handleCopy,oe.handleCut,oe.handleDrop,oe.handleDragOver,oe.handleCompositionStart,oe.handleCompositionEnd,oe.handleBlur]);return{editorRef:A,activeTrigger:R,suggestions:G,suggestionsLoading:K,suggestionsError:Y,selectedSuggestionIndex:_,handleInput:ge,handleKeyDown:Te,handleClick:Pe,handleMouseDown:Le,selectSuggestion:we,dismissTrigger:de,handle:Ie,triggerRect:j,eventHandlers:Be}}const xC=240;function MK({suggestions:e,loading:t,error:n,emptyMessage:r,selectedIndex:s,onSelect:a,onDismiss:l,triggerRect:c,triggerChar:u}){const h=y.useRef(null),m=y.useRef(null);if(y.useEffect(()=>{m.current?.scrollIntoView({block:"nearest"})},[s]),y.useEffect(()=>{const w=S=>{const C=S.target;h.current&&C instanceof Node&&!h.current.contains(C)&&l()};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[l]),!c||e.length===0&&!t&&!n&&!r)return null;const p=Math.min(320,window.innerWidth-16),b=Math.min(c.left,window.innerWidth-p-8),x=window.innerHeight-c.bottom,v=x<xC&&c.top>x,N={position:"fixed",left:`${Math.max(8,b)}px`,zIndex:50,maxWidth:`${p}px`,maxHeight:`${xC}px`,...v?{bottom:`${window.innerHeight-c.top+4}px`}:{top:`${c.bottom+4}px`}};return d.jsx("div",{ref:h,className:ve("min-w-[200px] overflow-y-auto","bg-surface rounded-xl border p-2 shadow-md","animate-in fade-in-0 zoom-in-95"),style:N,role:"listbox","aria-label":`${u} suggestions`,children:t?d.jsx("div",{role:"option","aria-selected":!1,className:"text-muted-foreground px-3 py-2 text-sm",children:"Loading suggestions..."}):n?d.jsx("div",{role:"option","aria-selected":!1,className:"text-destructive px-3 py-2 text-sm",children:n}):e.length===0&&r?d.jsx("div",{role:"option","aria-selected":!1,className:"text-muted-foreground px-3 py-2 text-sm",children:r}):e.map((w,S)=>d.jsxs("button",{ref:S===s?m:void 0,type:"button",role:"option","aria-selected":S===s,className:ve("text-foreground flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left text-sm","hover:bg-surface-hover cursor-pointer transition-colors",S===s&&"bg-surface-hover"),onMouseDown:C=>{C.preventDefault(),a(w)},children:[w.icon&&d.jsx("span",{className:"mt-0.5 shrink-0",children:w.icon}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("div",{className:"truncate font-medium",children:w.label}),w.description&&d.jsx("div",{className:"text-muted-foreground truncate text-xs",children:w.description})]})]},w.value))})}function IK({texts:e,interval:t=3e3}){const[n,r]=y.useState(0);return y.useEffect(()=>{if(e.length<=1)return;const s=setInterval(()=>{r(a=>(a+1)%e.length)},t);return()=>clearInterval(s)},[e.length,t]),d.jsx("div",{className:"pointer-events-none absolute top-0 left-0 overflow-hidden select-none",style:{color:"var(--prompt-area-placeholder, var(--muted-foreground))"},"aria-hidden":"true",children:d.jsx("div",{className:"animate-in fade-in-0 slide-in-from-top-4 duration-300 ease-in-out",children:e[n]},n)})}function V_({onClick:e,label:t,className:n}){return d.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),e()},className:ve("absolute top-0.5 right-0.5 grid h-3.5 w-3.5 cursor-pointer place-items-center","rounded-full bg-black/60 text-white hover:bg-black/80 dark:bg-white/60 dark:text-black dark:hover:bg-white/80","transition-colors",n),"aria-label":t,children:d.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[d.jsx("line",{x1:"2.75",y1:"2.75",x2:"7.25",y2:"7.25"}),d.jsx("line",{x1:"7.25",y1:"2.75",x2:"2.75",y2:"7.25"})]})})}function OK({images:e,onRemove:t,onClick:n,className:r}){return e.length===0?null:d.jsx("div",{className:ve("flex flex-wrap gap-2",r),role:"list","aria-label":"Attached images",children:e.map(s=>d.jsxs("div",{role:"listitem",className:ve("border-border relative h-16 w-16 flex-shrink-0 overflow-hidden rounded-md border",n&&"cursor-pointer"),onClick:()=>n?.(s),children:[d.jsx("img",{src:s.url,alt:s.alt??"Attached image",className:"h-full w-full object-cover"}),s.loading&&d.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/40",children:d.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent"})}),t&&d.jsx(V_,{onClick:()=>t(s),label:`Remove ${s.alt??"image"}`})]},s.id))})}function Bd({className:e,children:t}){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:e,children:t})}const _m=d.jsxs(d.Fragment,{children:[d.jsx("path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}),d.jsx("path",{d:"M14 2v5a1 1 0 0 0 1 1h5"})]}),LK=({className:e})=>d.jsx(Bd,{className:e,children:_m}),jK=({className:e})=>d.jsxs(Bd,{className:e,children:[_m,d.jsx("path",{d:"M10 9H8"}),d.jsx("path",{d:"M16 13H8"}),d.jsx("path",{d:"M16 17H8"})]}),DK=({className:e})=>d.jsxs(Bd,{className:e,children:[_m,d.jsx("path",{d:"M8 13h2"}),d.jsx("path",{d:"M14 13h2"}),d.jsx("path",{d:"M8 17h2"}),d.jsx("path",{d:"M14 17h2"})]}),PK=({className:e})=>d.jsxs(Bd,{className:e,children:[_m,d.jsx("path",{d:"M10 12.5 8 15l2 2.5"}),d.jsx("path",{d:"m14 12.5 2 2.5-2 2.5"})]}),BK=({className:e})=>d.jsxs(Bd,{className:e,children:[d.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),d.jsx("circle",{cx:"9",cy:"9",r:"2"}),d.jsx("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]}),Mh=3;function zK(e){return e?e==="application/pdf"?"pdf":e.includes("spreadsheet")||e==="text/csv"?"spreadsheet":e.startsWith("text/")||e.includes("javascript")||e.includes("json")||e.includes("xml")?"code":e.startsWith("image/")?"image":"default":"default"}const HK={pdf:jK,spreadsheet:DK,code:PK,image:BK,default:LK};function UK(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}function FK(e){const t=e.lastIndexOf(".");return t===-1||t===e.length-1?null:e.slice(t+1).toUpperCase()}function yC({file:e,compact:t,onRemove:n,onClick:r}){const s=FK(e.name),a=e.size!=null?UK(e.size):null,l=[s,a].filter(Boolean).join(" · ");return d.jsxs("div",{role:"listitem",className:ve("border-border relative flex flex-shrink-0 items-center gap-2 overflow-hidden rounded-lg border transition-colors","hover:bg-surface-hover",t?"h-10 w-36 px-2":"h-14 w-48 px-3",r&&"cursor-pointer"),onClick:()=>r?.(e),children:[(()=>{const c=HK[zK(e.type)];return d.jsx(c,{className:ve("text-muted-foreground flex-shrink-0",t?"h-4 w-4":"h-5 w-5")})})(),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("div",{className:ve("truncate font-medium",t?"text-xs":"text-sm"),title:e.name,children:e.name}),!t&&l&&d.jsx("div",{className:"text-muted-foreground truncate text-xs",children:l})]}),e.loading&&d.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/40",children:d.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent"})}),n&&d.jsx(V_,{onClick:()=>n(e),label:`Remove ${e.name}`})]})}function $K({files:e,onRemove:t,onClick:n,className:r}){const[s,a]=y.useState(!1),l=y.useRef(null),c=y.useRef(null);if(y.useEffect(()=>{if(!s)return;const b=x=>{const v=x.target;v instanceof Node&&l.current&&!l.current.contains(v)&&!c.current?.contains(v)&&a(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[s]),e.length===0)return null;const u=e.length>Mh,h=u,m=e.length-Mh,p=e.slice(0,Mh);return d.jsxs("div",{className:ve("relative",r),children:[d.jsxs("div",{className:"flex flex-wrap gap-2",role:"list","aria-label":"Attached files",children:[(u?p:e).map(b=>d.jsx(yC,{file:b,compact:h,onRemove:t,onClick:n},b.id)),u&&d.jsx("div",{role:"listitem",children:d.jsx("button",{ref:c,type:"button",onClick:()=>a(b=>!b),className:ve("border-border text-muted-foreground hover:bg-surface-hover flex flex-shrink-0 cursor-pointer items-center justify-center rounded-lg border transition-colors",h?"h-10 px-3 text-xs":"h-14 px-4 text-sm"),children:s?"Show less":`+${m} more`})})]}),s&&d.jsx("div",{ref:l,className:ve("bg-surface border-border absolute bottom-full left-0 z-10 mb-2 max-h-48 overflow-y-auto rounded-lg border p-2 shadow-lg"),children:d.jsx("div",{className:"flex flex-wrap gap-2",role:"list","aria-label":"More attached files",children:e.slice(Mh).map(b=>d.jsx(yC,{file:b,compact:h,onRemove:t,onClick:n},b.id))})})]})}function V1({value:e,onChange:t,triggers:n,placeholder:r,className:s,disabled:a=!1,markdown:l,normalizeBullets:c,onSubmit:u,onEscape:h,onChipClick:m,onChipAdd:p,onChipDelete:b,onLinkClick:x,onPaste:v,onUndo:N,onRedo:w,minHeight:S=80,maxHeight:C,autoFocus:A=!1,autoGrow:R=!1,"aria-label":M,"data-test-id":_,images:I=[],imagePosition:j="above",onImagePaste:z,onImageRemove:P,onImageClick:F,files:V=[],filePosition:G="above",onFileRemove:K,onFileClick:Y,onKeyDown:U,onBlur:Q,onRawPaste:W,submitOnEnter:ue,spellCheck:D,maxLength:H,"aria-describedby":B,ref:L}){const{editorRef:te,activeTrigger:ne,suggestions:de,suggestionsLoading:oe,suggestionsError:le,selectedSuggestionIndex:ge,handleInput:Pe,handleKeyDown:Le,handleClick:Se,handleMouseDown:Oe,selectSuggestion:He,dismissTrigger:We,handle:Ge,triggerRect:De,eventHandlers:we}=RK({value:e,onChange:t,triggers:n,disabled:a,onSubmit:u,onEscape:h,onChipClick:m,onChipAdd:p,onChipDelete:b,onLinkClick:x,onPaste:v,onRawPaste:W,onUndo:N,onRedo:w,onImagePaste:z,markdown:l,normalizeBullets:c,submitOnEnter:ue,maxLength:H});y.useImperativeHandle(L,()=>Ge,[Ge]),y.useEffect(()=>{A&&te.current?.focus()},[A,te]);const[Te,Ie]=y.useState(!1),[Be,ee]=y.useState(void 0),me=y.useCallback(()=>{const Ye=te.current;if(!Ye)return;Ye.style.height="auto";const St=Ye.scrollHeight;Ye.style.height=`${St}px`,ee(St)},[te]),se=y.useCallback(()=>{R&&(Ie(!0),me())},[R,me]),ie=y.useCallback(()=>{we.onBlur(),R&&setTimeout(()=>{const Ye=te.current;if(!Ye)return;const St=document.activeElement;St&&Ye.parentElement?.contains(St)||(Ie(!1),ee(void 0))},$_)},[we,R,te]),Z=y.useCallback(()=>{Pe(),R&&Te&&me()},[Pe,R,Te,me]);y.useEffect(()=>{R&&Te&&requestAnimationFrame(()=>me())},[e,R,Te,me]);const[q,ce]=y.useState(!1),Ce=y.useRef(null);y.useEffect(()=>{if(!R)return;const Ye=()=>{if(Te){ce(!1);return}const Mt=te.current;Mt&&ce(Mt.scrollHeight>Mt.clientHeight)},St=Te?0:160;return Ce.current=setTimeout(Ye,St),()=>{Ce.current!==null&&clearTimeout(Ce.current)}},[R,Te,e,te]);const Re=y.useMemo(()=>{if(!R){const Ye={minHeight:`${S}px`};return C&&(Ye.maxHeight=`${C}px`,Ye.overflowY="auto"),Ye}return{height:Te&&Be?`${Be}px`:`${S}px`,minHeight:`${S}px`,maxHeight:C?`${C}px`:"70dvh",overflowY:Te?"auto":"hidden",transition:"height 150ms ease-out, min-height 240ms cubic-bezier(0.33, 1, 0.68, 1)"}},[R,S,C,Te,Be]),Ue=y.useCallback(Ye=>{U?.(Ye),!Ye.defaultPrevented&&Le(Ye)},[U,Le]),at=y.useCallback(Ye=>{Q?.(Ye),ie()},[Q,ie]),Qe=e.length===0||e.length===1&&e[0].type==="text"&&e[0].text==="",ct=I.length>0?d.jsx(OK,{images:I,onRemove:P,onClick:F,className:j==="above"?"pb-2":"pt-2"}):null,dt=V.length>0?d.jsx($K,{files:V,onRemove:K,onClick:Y,className:G==="above"?"pb-2":"pt-2"}):null;return d.jsxs("div",{className:ve("prompt-area-container relative text-sm leading-relaxed",s),children:[j==="above"&&ct,G==="above"&&dt,d.jsxs("div",{className:"relative",children:[d.jsx("div",{ref:te,contentEditable:!a,suppressContentEditableWarning:!0,role:"textbox","aria-label":M??"Text input","aria-multiline":"true","aria-disabled":a||void 0,"aria-describedby":B,"data-test-id":_,spellCheck:D,className:ve("prompt-area-editor","w-full min-w-0 break-words whitespace-pre-wrap outline-none",a&&"cursor-not-allowed opacity-50"),style:Re,onFocus:se,onInput:R?Z:Pe,onKeyDown:Ue,onMouseDown:Oe,onClick:Se,onPaste:we.onPaste,onCopy:we.onCopy,onCut:we.onCut,onDrop:we.onDrop,onDragOver:we.onDragOver,onCompositionStart:we.onCompositionStart,onCompositionEnd:we.onCompositionEnd,onBlur:at}),R&&q&&!Te&&d.jsx("div",{"aria-hidden":"true",className:"pointer-events-auto absolute right-0 bottom-0 left-0 cursor-pointer",style:{height:"32px"},onClick:()=>te.current?.focus(),children:d.jsx("div",{className:"h-full w-full",style:{background:"linear-gradient(to bottom, transparent, color-mix(in srgb, var(--prompt-area-surface, var(--background)) 80%, transparent), var(--prompt-area-surface, var(--background)))"}})}),Qe&&r&&(Array.isArray(r)?d.jsx(IK,{texts:r}):d.jsx("div",{className:"pointer-events-none absolute top-0 left-0 select-none",style:{color:"var(--prompt-area-placeholder, var(--muted-foreground))"},"aria-hidden":"true",children:r}))]}),G==="below"&&dt,j==="below"&&ct,ne&&ne.config.mode==="dropdown"&&d.jsx(MK,{suggestions:de,loading:oe,error:le,emptyMessage:ne.config.emptyMessage,selectedIndex:ge,onSelect:He,onDismiss:We,triggerRect:De,triggerChar:ne.config.char})]})}function VK(e={}){const{initialValue:t=[]}=e,[n,r]=y.useState(t),s=y.useRef(null),a=y.useMemo(()=>Vn(n),[n]),l=y.useMemo(()=>n.length===0?!0:n.every(v=>v.type==="text"&&v.text.trim()===""),[n]),c=y.useMemo(()=>n.some(v=>v.type==="chip"),[n]),u=y.useMemo(()=>n.filter(v=>v.type==="chip"),[n]),h=y.useMemo(()=>({ref:s,value:n,onChange:r}),[n]),m=y.useCallback(()=>{s.current?s.current.clear():r([])},[]),p=y.useCallback(()=>s.current?.focus(),[]),b=y.useCallback(()=>s.current?.blur(),[]),x=y.useCallback(v=>s.current?.insertChip(v),[]);return{bind:h,plainText:a,isEmpty:l,hasChips:c,chips:u,clear:m,focus:p,blur:b,insertChip:x}}function qK(e={}){const{char:t="@",...n}=e;return{char:t,position:"any",mode:"dropdown",chipStyle:"pill",accessibilityLabel:"mention",...n}}function vC(e={}){const{char:t="/",position:n="any",...r}=e;return{char:t,position:n,mode:"dropdown",chipStyle:"inline",accessibilityLabel:"command",...r}}const q_=["attention","working","idle","ended"],Y_={attention:"Needs attention",working:"Working",idle:"Idle",ended:"Ended"};function G_(e){return e.pendingPermissionCount>0||e.status==="awaiting_approval"?"attention":e.status==="failed"||e.status==="closed"?"ended":e.status==="running"||e.status==="starting"||YK(e).length>0?"working":"idle"}function YK(e){return(e.subagents??[]).filter(t=>t.status==="running")}function GK(e){return(e.agentType?.trim()??"")!==""}function fx(e){const t=e.agentType?.trim(),n=e.description?.trim();return t&&n?`${t} · ${n}`:t||n||"Sub-agent"}const hx={search:"",gateways:[],adapters:[],states:[],projects:[],scoped:!0,groupBy:"state",sortBy:"recent"};function KK(e){return[...new Set(e.map(t=>t.adapter))].sort()}function WK(e){const t=new Map;for(const n of e)t.set(_2(n),A2(n));return[...t].map(([n,r])=>({key:n,label:r})).sort((n,r)=>n.label.toLowerCase().localeCompare(r.label.toLowerCase()))}function uc(e){return e.title??e.id.slice(0,8)}function _2(e){return`${e.hostId}:${dc(e.info.project?.root??e.info.cwd)}`}function A2(e){const t=e.info.project?.name;if(t)return t;const n=dc(e.info.cwd);return n.slice(n.lastIndexOf("/")+1)||"No project"}function XK(e){const t=e.info.project?.root;if(t===void 0||!e.info.cwd)return;const n=dc(t),r=dc(e.info.cwd);if(r!==n&&r.startsWith(`${n}/`))return r.slice(n.length+1)||void 0}function QK(e){return typeof e.meta?.jobId=="string"}function ZK(e,t){return t?uc(e.info).toLowerCase().includes(t)||e.info.cwd.toLowerCase().includes(t)||(e.info.project?.name.toLowerCase().includes(t)??!1)||e.hostName.toLowerCase().includes(t)||e.adapter.toLowerCase().includes(t)||e.info.id.startsWith(t):!0}function dc(e){return e.replace(/\\/g,"/").replace(/\/+$/,"")}function JK(e,t){const n=dc(e),r=dc(t);return r===n||r.startsWith(`${n}/`)}function eW(e,t){return t.roots.some(n=>(n.hostId?n.hostId.toLowerCase()===e.hostId.toLowerCase():e.local)&&JK(n.path,e.info.cwd))}function K_(e,t){return e.scoped&&t!==void 0}function W_(e,t,n){const r=t.search.trim().toLowerCase(),s=K_(t,n)?n:void 0;return e.filter(a=>(t.gateways.length===0||t.gateways.includes(a.hostId))&&(t.adapters.length===0||t.adapters.includes(a.adapter))&&(t.states.length===0||t.states.includes(a.state))&&(!t.projects?.length||t.projects.includes(_2(a)))&&(!s||eW(a,s))&&ZK(a,r))}function tW(e,t){return t==="gateway"?e.hostId:t==="adapter"?e.adapter:t==="project"?_2(e):e.state}function X_(e,t){return t==="gateway"?e.hostName:t==="adapter"?e.adapter:t==="project"?A2(e):Y_[e.state]}function px(e,t){return t==="state"?String(q_.indexOf(e.state)):X_(e,t).toLowerCase()}const q1=(e,t)=>(t.info.lastActivityAt??t.info.createdAt)-(e.info.lastActivityAt??e.info.createdAt);function nW(e,t,n){return n==="recent"?q1(e,t):n==="name"?uc(e.info).localeCompare(uc(t.info),void 0,{sensitivity:"base"})||q1(e,t):px(e,n).localeCompare(px(t,n))||q1(e,t)}function rW(e,t){const n=[...e].sort((a,l)=>nW(a,l,t.sortBy));if(t.groupBy==="none")return n.length?[{key:"all",rows:n}]:[];const r=t.groupBy,s=new Map;for(const a of n){const l=tW(a,r),c=s.get(l);c?c.rows.push(a):s.set(l,{key:l,label:X_(a,r),rank:px(a,r),rows:[a]})}return[...s.values()].sort((a,l)=>a.rank.localeCompare(l.rank))}function sW(e,t,n,r){if(n>=r)return;const s=[];t&&K_(e,t)&&s.push(t.label);const a=(e.gateways.length?1:0)+(e.adapters.length?1:0)+(e.states.length?1:0)+(e.projects?.length?1:0);return a>0&&s.push(`${a} filter${a===1?"":"s"}`),e.search.trim()&&s.push("search"),{shown:n,total:r,causes:s}}function iW(e){return e.search.trim().length>0||e.gateways.length>0||e.adapters.length>0||e.states.length>0||(e.projects?.length??0)>0}function EC(e){return{...hx,scoped:!1,groupBy:e.groupBy,sortBy:e.sortBy}}function aW(e,t){const n={};for(const[r,s]of Object.entries(e.rateLimits??{}))n[r]={info:s,updatedAt:e.updatedAt??0};for(const[r,s]of Object.entries(t??{}))n[r]=s;return n}function Q_(e){const t=Object.entries(e??{}).filter(([,s])=>s.info.utilization!==void 0).map(([s,a])=>({key:s,info:a.info,updatedAt:a.updatedAt,inferredReset:a.inferredReset})),n=["five_hour","seven_day"].flatMap(s=>t.filter(a=>a.key===s)),r=t.filter(s=>s.key.startsWith("seven_day_")).sort((s,a)=>s.key.localeCompare(a.key));return[...n,...r]}function oW(e){if(!e)return;const t={};for(const[n,r]of Object.entries(e))t[n]=r.info;return t}const lW=720*60*60*1e3,cW=6e4,Y1=(e,t)=>`${e}:${t}`;class uW{#t;#n;constructor(t){this.#t=t,this.#n={...t.read()}}get(t,n){return this.#n[Y1(t,n)]}all(){return this.#n}mark(t,n,r,s=Date.now()){const a=Y1(t,n),l=this.#n[a],c={itemCount:Math.max(l?.itemCount??0,r.itemCount??0),activity:Math.max(l?.activity??0,r.activity??0),turns:Math.max(l?.turns??0,r.turns??0),seenAt:s};return l&&l.itemCount===c.itemCount&&l.activity===c.activity&&l.turns===c.turns&&c.seenAt-l.seenAt<cW?!1:(this.#n[a]=c,this.#t.write(this.#r(s)),!0)}forget(t,n){const r=Y1(t,n);r in this.#n&&(delete this.#n[r],this.#t.write(this.#n))}#r(t){const n=t-lW;for(const[r,s]of Object.entries(this.#n))s.seenAt<n&&delete this.#n[r];return this.#n}}function dW(e,t){return e?t.activityCount!==void 0?Math.max(0,t.activityCount-e.activity):Math.max(0,(t.turns??0)-e.turns):0}const Z_=7,Am={claude:{interactiveApprovals:!0,permissionModes:["default","acceptEdits","bypassPermissions","plan","dontAsk","auto"],defaultPermissionMode:"default",resume:!0,resumeBackfill:!0,listSessions:!0,contextUsage:!0,rateLimits:!0,mcpStatus:!0,mcpServerActions:!0,sessionMcpServers:!0,slashCommands:!0,skillsList:!1,settingSources:!0,budgets:!0,attachments:["image","pdf","text"],reasoningEfforts:["low","medium","high","xhigh","max"],vfs:!1,hostCwd:!0,streaming:"token"},codex:{interactiveApprovals:!0,permissionModes:["default","acceptEdits","bypassPermissions","auto"],defaultPermissionMode:"default",resume:!0,resumeBackfill:!0,listSessions:!0,contextUsage:!0,rateLimits:!0,mcpStatus:!0,mcpServerActions:!1,sessionMcpServers:!1,slashCommands:!1,skillsList:!0,settingSources:!1,budgets:!1,attachments:["image","text"],reasoningEfforts:["minimal","low","medium","high","xhigh"],vfs:!1,hostCwd:!0,streaming:"token"},provider:{interactiveApprovals:!1,permissionModes:["default","bypassPermissions","dontAsk"],defaultPermissionMode:"default",resume:!1,resumeBackfill:!1,listSessions:!1,contextUsage:!1,rateLimits:!1,mcpStatus:!0,mcpServerActions:!1,sessionMcpServers:!1,slashCommands:!1,skillsList:!1,settingSources:!1,budgets:!1,attachments:["image","pdf","text"],vfs:!0,hostCwd:!1,streaming:"token"}};Am.provider.permissionModes;const J_={status:"starting",capabilities:Am.claude,items:[],pendingApprovals:[],totalCostUsd:0,lastSeq:0},mx="streaming",gx="streaming-thinking",TC=e=>e==null?mx:`${mx}:${e}`,SC=e=>e==null?gx:`${gx}:${e}`,fW=e=>e.kind==="assistant_text"&&e.id.startsWith(mx)||e.kind==="thinking"&&e.id.startsWith(gx);function hW(e){return e===void 0?"":typeof e=="string"?e:e.map(t=>typeof t.text=="string"?t.text:"").filter(Boolean).join(`
|
|
1051
1051
|
`)}function kC(e,t){if(!Array.isArray(e))return;const n=e.flatMap(r=>r.type==="image_ref"?[{partIndex:Number(r.part_index),mediaType:String(r.media_type??"application/octet-stream"),bytes:Number(r.bytes??0),sourceSeq:t}]:[]);return n.length>0?n:void 0}function CC(e){return typeof e=="string"?[{type:"text",text:e}]:e}function pW(e){if(e.type==="text")return e.value;try{return JSON.stringify(e.value)}catch{return String(e.value)}}const mW=/^<local-command-(stdout|stderr)>([\s\S]*?)<\/local-command-\1>$/,gW=/<command-name>([\s\S]*?)<\/command-name>/,bW=/<command-args>([\s\S]*?)<\/command-args>/;function xW(e){const t=gW.exec(e)?.[1]?.trim();if(!t)return;const n=bW.exec(e)?.[1]?.trim();return n?`${t} ${n}`:t}function io(e,t){const n=e.findIndex(s=>s.id===t.id&&s.kind===t.kind);if(n===-1)return[...e,t];const r=[...e];return r[n]=t,r}function yW(e,t){const n=t.engine??e.engine;return{...e,status:e.lastSeq===0?t.status:e.status,model:e.model??t.model,permissionMode:e.permissionMode??t.permissionMode,cwd:e.cwd??t.cwd,sdkSessionId:e.sdkSessionId??t.sdkSessionId,engine:n,capabilities:t.capabilities??Am[n??"claude"],session:t}}function vW(e,t,n){let r=!1;const s=e.items.map(a=>a.kind!=="tool_call"||a.id!==t||!a.result?.truncated?a:(r=!0,{...a,result:{text:n,isError:a.result.isError,...a.result.images&&{images:a.result.images}}}));return r?{...e,items:s}:e}function EW(e,t){if(t.seq<=e.lastSeq)return e;const n={...e,lastSeq:t.seq};switch(t.type){case"system_init":return{...n,model:t.model,cwd:t.cwd,sdkSessionId:t.sdkSessionId,permissionMode:t.permissionMode};case"status_changed":return{...n,status:t.status,statusDetail:t.detail};case"capabilities":return{...n,models:t.models,commands:t.commands,defaultModel:t.defaultModel??n.defaultModel};case"skills":return{...n,skills:t.skills};case"file_produced":return{...n,producedFiles:{...n.producedFiles,[t.path]:{fileId:t.fileId,...t.mediaType?{mediaType:t.mediaType}:{},...t.bytes!==void 0?{bytes:t.bytes}:{}}}};case"model_changed":return t.model===void 0?n:{...n,model:t.model};case"permission_mode_changed":return{...n,permissionMode:t.mode};case"context_usage":return{...n,contextUsage:t.usage};case"rate_limit":{const r=t.info.rateLimitType;return r?{...n,rateLimits:{...n.rateLimits,[r]:t.info},rateLimitsUpdatedAt:t.ts}:n}case"plan_info":return{...n,subscriptionType:t.subscriptionType};case"conversation_reset":return{...n,items:[],contextUsage:void 0,sdkSessionId:t.sdkSessionId??n.sdkSessionId};case"user_message":{let r=n.items;for(const s of CC(t.message.content))if(s.type==="tool_result"){const a=s,l=a.is_error===!0;r=r.map(c=>c.kind==="tool_call"&&c.id===a.tool_use_id?{...c,status:l?"failed":"settled",result:{text:hW(a.content),isError:l,...a.truncated&&{truncated:!0,totalChars:a.total_chars,sourceSeq:t.seq},...kC(a.content,t.seq)&&{images:kC(a.content,t.seq)}},...t.patch&&{patch:t.patch}}:c)}else if(s.type==="text"&&!t.synthetic){const a=s.text,l=mW.exec(a.trim());l?r=io(r,{kind:"notice",id:t.uuid??`user-${t.seq}`,level:l[1]==="stderr"?"error":"info",text:l[2].trim()}):r=io(r,{kind:"user",id:t.uuid??`user-${t.seq}`,text:xW(a)??a,attachments:t.attachments,...t.parentToolUseId!=null&&{parentToolUseId:t.parentToolUseId}})}return{...n,items:r}}case"assistant_message":{const r=TC(t.parentToolUseId),s=SC(t.parentToolUseId);let a=n.items.find(u=>u.kind==="thinking"&&u.id===s)?.text??"",l=n.items.filter(u=>!(u.kind==="assistant_text"&&u.id===r)&&!(u.kind==="thinking"&&u.id===s));return CC(t.message.content).forEach((u,h)=>{const m=`${t.uuid}-${h}`;if(u.type==="text")l=io(l,{kind:"assistant_text",id:m,text:u.text,streaming:!1,parentToolUseId:t.parentToolUseId});else if(u.type==="thinking"){const p=u.thinking||a;if(a="",p.trim()==="")return;l=io(l,{kind:"thinking",id:m,text:p,parentToolUseId:t.parentToolUseId})}else if(u.type==="tool_use"){const p=u;l=io(l,{kind:"tool_call",id:p.id,name:p.name,input:p.input,parentToolUseId:t.parentToolUseId,status:"running",ts:t.ts})}}),{...n,items:l}}case"stream_delta":{const r=t.event;if(r.type!=="content_block_delta")return n;if(r.delta?.type==="text_delta"){const s=TC(t.parentToolUseId),a=n.items.find(c=>c.kind==="assistant_text"&&c.id===s),l={kind:"assistant_text",id:s,text:(a?.text??"")+(r.delta.text??""),streaming:!0,parentToolUseId:t.parentToolUseId};return{...n,items:io(n.items,l)}}if(r.delta?.type==="thinking_delta"){const s=SC(t.parentToolUseId),l=(n.items.find(u=>u.kind==="thinking"&&u.id===s)?.text??"")+(r.delta.thinking??"");if(l.trim()==="")return n;const c={kind:"thinking",id:s,text:l,parentToolUseId:t.parentToolUseId};return{...n,items:io(n.items,c)}}return n}case"turn_result":return{...n,totalCostUsd:t.totalCostUsd,items:[...n.items.map(r=>{if(!fW(r))return r;const s="parentToolUseId"in r&&r.parentToolUseId?`-${r.parentToolUseId}`:"";return r.kind==="assistant_text"?{...r,id:`text-${t.seq}${s}`,streaming:!1}:{...r,id:`thinking-${t.seq}${s}`}}),{kind:"turn_result",id:`turn-${t.seq}`,subtype:t.subtype,isError:t.isError,durationMs:t.durationMs,totalCostUsd:t.totalCostUsd,errors:t.errors}]};case"permission_requested":return{...n,pendingApprovals:[...n.pendingApprovals,t.request]};case"permission_resolved":return{...n,pendingApprovals:n.pendingApprovals.filter(r=>r.id!==t.requestId)};case"execution_dispatched":return{...n,items:n.items.map(r=>r.kind==="tool_call"&&r.id===t.executionId?{...r,status:t.deferred?"deferred":"pending",executionId:t.executionId,backend:t.backend}:r)};case"execution_result":return{...n,items:n.items.map(r=>r.kind==="tool_call"&&r.id===t.executionId?{...r,status:"settled",executionId:t.executionId,result:{text:pW(t.output),isError:!1},logs:t.logs??r.logs}:r)};case"execution_failed":return{...n,items:n.items.map(r=>r.kind==="tool_call"&&r.id===t.executionId?{...r,status:"failed",executionId:t.executionId,result:{text:`${t.reason}: ${t.error}`,isError:!0},logs:t.logs??r.logs}:r)};case"file_delivered":return{...n,items:[...n.items,{kind:"file_delivered",id:`file-${t.seq}`,path:t.path,bytes:t.bytes,description:t.description}]};case"session_error":return{...n,items:[...n.items,{kind:"notice",id:`err-${t.seq}`,level:"error",text:t.message}]};case"session_closed":return{...n,items:[...n.items,{kind:"notice",id:`closed-${t.seq}`,level:"info",text:`Session closed (${t.reason})`}]};case"sdk_event":default:return n}}const TW=5,uo=new Map;function G1(e,t){return`${e.identityKey}\0${t}`}function wC(e){return uo.get(e)}function SW(e,t){if(uo.delete(e),uo.set(e,t),uo.size>TW){const n=uo.keys().next().value;n!==void 0&&uo.delete(n)}}function kW(e){uo.delete(e)}function eA(e,t){return`${e}:${t}`}function CW(e){const t=eA(e.resyncSeq,e.key),n=e.cacheEnabled&&!e.skipCache?e.warm:void 0,r=e.seededFor!==t,s=r?n??J_:e.current;return{held:s,seed:r,seedToken:t,...s.lastSeq>0?{afterSeq:s.lastSeq}:{}}}function wW(e){return e.cacheEnabled&&!e.skipCache&&e.parting.lastSeq>0&&e.parting.session!==void 0}function NW(e,t){return t.type==="transcript_seed"?t.state:t.type==="transcript_hydrate_result"?vW(e,t.toolUseId,t.text):t.type==="attached"?yW(e,t.session):EW(e,t)}const _W=3;function AW(e){return e.replayingFrom===0&&e.session.lastSeq>0?e.session.lastSeq:void 0}function RW(e,t){return e.replayingFrom===0||t.lastSeq===0?!1:e.session.lastSeq<t.lastSeq?!0:t.session!==void 0&&e.session.createdAt!==t.session.createdAt}const MW=1500;function IW(e,t,n){const[r,s]=y.useReducer(NW,void 0,()=>(n?.cacheTranscript!==!1&&t!==void 0?wC(G1(e,t)):void 0)??J_),[a,l]=y.useState("reconnecting"),[c,u]=y.useState(),[h,m]=y.useState(),[p,b]=y.useState(0),[x,v]=y.useState(),N=y.useRef(null),w=y.useRef(n);w.current=n;const S=y.useRef(r);S.current=r;const C=y.useRef(eA(0,t===void 0?"":G1(e,t))),A=y.useRef(!1);y.useEffect(()=>{if(!t)return;const z=w.current?.cacheTranscript!==!1,P=G1(e,t),F=CW({resyncSeq:p,key:P,seededFor:C.current,current:S.current,cacheEnabled:z,skipCache:A.current,warm:wC(P)});A.current=!1,F.seed&&(s({type:"transcript_seed",state:F.held}),C.current=F.seedToken);const V=e.attach(t,{truncateResults:!0,imageRefs:!0,...F.afterSeq===void 0?{}:{afterSeq:F.afterSeq}});N.current=V,v(V);const G=V.on("event",W=>s(W)),K=V.on("attached",W=>{if(RW(W,S.current)){G(),kW(P),A.current=!0,b(ue=>ue+1);return}s(W),m(AW(W)),u(W.protocolVersion===Z_?void 0:W.protocolVersion)}),Y=V.on("connectionChange",W=>l(W?"live":"reconnecting")),U=V.on("reconnectAttempt",W=>l(W>=_W?"offline":"reconnecting")),Q=V.on("protocolError",W=>{w.current?.onProtocolError?.(W)});return()=>{G(),K(),Y(),U(),Q(),V.detach(),N.current=null,v(void 0),l("reconnecting"),u(void 0),m(void 0);const W=S.current;wW({cacheEnabled:z,skipCache:A.current,parting:W})&&SW(P,W)}},[e,t,p]),y.useEffect(()=>{if(h===void 0)return;const z=setTimeout(()=>m(void 0),MW);return()=>clearTimeout(z)},[h]),y.useEffect(()=>{h!==void 0&&r.lastSeq>=h&&m(void 0)},[h,r.lastSeq]);const R=OW(e,t,r),M=a==="live",_=h!==void 0&&r.lastSeq<h,I=y.useCallback(()=>N.current?.reconnectNow(),[]),j=y.useCallback(async z=>{if(!t)return!1;const P=S.current.items.find(V=>V.kind==="tool_call"&&V.id===z),F=P?.kind==="tool_call"?P.result:void 0;if(!F?.truncated||F.sourceSeq===void 0)return!1;try{const V=await e.toolResult(t,F.sourceSeq,z),G=typeof V.content=="string"?V.content:(V.content??[]).map(K=>typeof K.text=="string"?K.text:"").filter(Boolean).join(`
|
|
1052
1052
|
`);return s({type:"transcript_hydrate_result",toolUseId:z,text:G}),!0}catch{return!1}},[e,t]);return y.useMemo(()=>({state:r,connected:M,connection:a,replaying:_,protocolMismatch:c,models:R,effectiveModel:r.model??r.defaultModel,handle:x,send:(z,P)=>N.current?.send(z,P),approve:(z,P)=>N.current?.approve(z,P),deny:(z,P,F)=>N.current?.deny(z,P,F),interrupt:()=>N.current?.interrupt(),setPermissionMode:z=>N.current?.setPermissionMode(z),setModel:z=>N.current?.setModel(z),closeSession:()=>N.current?.closeSession(),reconnectNow:I,loadFullResult:j}),[r,M,a,_,c,R,x,I,j])}function OW(e,t,n){const[r,s]=y.useState([]),a=n.session?.profile,l=n.models,c=!!l?.length;return y.useEffect(()=>s([]),[t]),y.useEffect(()=>{if(!a||c)return;let u=!1;return e.listProfiles().then(h=>{u||s(h.profiles.find(m=>m.name===a)?.models??[])}).catch(()=>{}),()=>{u=!0}},[e,a,c]),c?l:r}function LW(e){const t=e.split(";")[0].trim().toLowerCase();if(t.startsWith("image/"))return"image";if(t==="application/pdf")return"pdf";if(t.startsWith("text/")||jW.has(t))return"text"}const jW=new Set(["application/json","application/xml","application/yaml","application/x-yaml","application/toml","application/javascript","application/typescript","application/x-sh","application/sql"]),NC=1568;function DW(e,t,{capabilities:n,engine:r}){const[s,a]=y.useState([]),[l,c]=y.useState(),u=y.useRef(0),h=y.useRef(new Map),m=y.useRef([]);m.current=s.flatMap(A=>A.previewUrl?[A.previewUrl]:[]);const p=n.attachments;y.useEffect(()=>()=>{for(const A of m.current)URL.revokeObjectURL(A)},[]);const b=y.useCallback((A,R)=>{a(M=>M.map(_=>_.key===A?{..._,...R}:_))},[]),x=y.useCallback((A,R)=>{t&&(b(A,{status:"uploading",error:void 0}),(async()=>{try{const M=await zW(R),_=await e.uploadAttachment(t,{name:R.name,mediaType:M.mediaType,data:M.body});b(A,{status:"ready",id:_.id,bytes:_.bytes??R.size})}catch(M){b(A,{status:"failed",error:M instanceof Error?M.message:"Upload failed"})}})())},[e,b,t]),v=y.useCallback(A=>{const R=[],M=[];for(const _ of A){const I=_.type||"application/octet-stream",j=LW(I);if(j&&!p.includes(j)){c(`The ${r??"claude"} engine does not take ${j} attachments.`);continue}const z=`att-${++u.current}`;R.push({key:z,name:_.name,mediaType:I,bytes:_.size,previewUrl:j==="image"?URL.createObjectURL(_):void 0,status:"uploading"}),M.push({key:z,file:_})}if(R.length!==0){a(_=>[..._,...R]),h.current=new Map([...h.current,...M.map(({key:_,file:I})=>[_,I])]);for(const{key:_,file:I}of M)x(_,I)}},[p,r,x]),N=y.useCallback(A=>{a(R=>{for(const M of R)A.includes(M.key)&&M.previewUrl&&URL.revokeObjectURL(M.previewUrl);return R.filter(M=>!A.includes(M.key))});for(const R of A)h.current.delete(R)},[]),w=y.useCallback(A=>N([A]),[N]),S=y.useCallback(()=>{a(A=>{for(const R of A)R.previewUrl&&URL.revokeObjectURL(R.previewUrl);return[]}),h.current.clear()},[]),C=y.useCallback(A=>{const R=h.current.get(A);R&&x(A,R)},[x]);return y.useMemo(()=>({items:s,readyIds:s.flatMap(A=>A.id?[A.id]:[]),uploading:s.some(A=>A.status==="uploading"),hasFailure:s.some(A=>A.status==="failed"),accept:PW(p),disabled:p.length===0||!t,add:v,retry:C,remove:w,clear:S,error:l,dismissError:()=>c(void 0)}),[s,p,t,v,C,w,S,l])}function PW(e){if(e.length===0)return"";const t=[];return e.includes("image")&&t.push("image/*"),e.includes("pdf")&&t.push("application/pdf"),e.includes("text")&&t.push("text/*",".md",".json",".yaml",".yml",".toml"),e.length===3?"":t.join(",")}const BW=globalThis;async function zW(e){const t=e.type||"application/octet-stream",{createImageBitmap:n,document:r}=BW;if(!n||!r||!t.startsWith("image/"))return{body:e,mediaType:t};if(t==="image/gif")return{body:e,mediaType:t};try{const s=await n(e),a=Math.max(s.width,s.height);if(a<=NC)return s.close(),{body:e,mediaType:t};const l=NC/a,c=r.createElement("canvas");c.width=Math.round(s.width*l),c.height=Math.round(s.height*l);const u=c.getContext("2d");if(!u)return s.close(),{body:e,mediaType:t};u.drawImage(s,0,0,c.width,c.height),s.close();const h=await new Promise(m=>c.toBlob(m,"image/jpeg",.85));return h?{body:h,mediaType:"image/jpeg"}:{body:e,mediaType:t}}catch{return{body:e,mediaType:t}}}const HW=/^[A-Za-z0-9\-_.:]+$/,UW=new Set([".",",",";",":","!","?",")","]","}",'"',"'"]);function FW(e){const t=[],n=/\S+/g;let r;for(;(r=n.exec(e))!==null;){const s=r[0],a=s[0]==="@"?"file":s[0]==="/"?"command":void 0;if(!a)continue;let l=r.index+s.length;for(;l>r.index&&UW.has(e[l-1]);)l--;const c=e.slice(r.index+1,l);c&&(a==="command"&&!HW.test(c)||t.push({kind:a,start:r.index,end:l,text:e.slice(r.index,l)}))}return t}function R2(e){let t=e.baseUrl.trim();for(;t.endsWith("/");)t=t.slice(0,-1);if(t!==""){t.includes("://")||(t="http://"+t),t.endsWith("/v1")||(t+="/v1");try{new URL(t)}catch{return}return t}}function $W(e){const t=R2(e);if(!t)return!1;try{const{hostname:n}=new URL(t);return n==="127.0.0.1"||n==="localhost"||n==="::1"||n==="[::1]"}catch{return!1}}function VW(e){const{baseUrl:t,key:n}=e;if(n==="")return{};const r=t.replace(/^http/,"ws"),s=a=>`${a}${a.includes("?")?"&":"?"}key=${encodeURIComponent(n)}`;return{headers:{authorization:`Bearer ${n}`},buildWsUrl:(a,l)=>s(`${r}/sessions/${encodeURIComponent(a)}/ws?afterSeq=${l}`),buildQueueWsUrl:()=>s(`${r}/queue/ws`)}}class Vs extends Error{status;constructor(t,n){super(t),this.name="WorkerDeckError",this.status=n}}class qW{sessionId;#t;#n;#r;#e=new Map;#s;#c=!1;#o=0;#i=[];#u;constructor(t,n,r={}){this.#t=t,this.sessionId=n,this.#n={reconnect:!0,...r},this.#s=r.afterSeq??0,this.#u=setTimeout(()=>this.#d(),0)}get lastSeq(){return this.#s}on(t,n){let r=this.#e.get(t);return r||(r=new Set,this.#e.set(t,r)),r.add(n),()=>r.delete(n)}send(t,n){this.#a({type:"user_message",text:t,attachmentIds:n?.length?n:void 0})}approve(t,n){this.#a({type:"permission_decision",requestId:t,behavior:"allow",updatedInput:n})}deny(t,n,r){this.#a({type:"permission_decision",requestId:t,behavior:"deny",message:n,interrupt:r})}interrupt(){this.#a({type:"interrupt"})}setPermissionMode(t){this.#a({type:"set_permission_mode",mode:t})}setModel(t){this.#a({type:"set_model",model:t})}sendToolCallResult(t,n,r){this.#a({type:"tool_call_result",executionId:t,output:n,logs:r})}sendToolCallError(t,n,r,s){this.#a({type:"tool_call_error",executionId:t,reason:n,error:r,logs:s})}closeSession(){this.#a({type:"close"}),this.detach()}reconnectNow(){this.#c||this.#r&&this.#r.readyState===1||(clearTimeout(this.#u),this.#o=0,this.#d())}detach(){this.#c=!0,clearTimeout(this.#u),this.#r?.close(),this.#r=void 0}#l(t,n){const r=this.#e.get(t);if(r)for(const s of r)try{s(n)}catch{}}#a(t){const n=JSON.stringify(t);this.#r&&this.#r.readyState===1?this.#r.send(n):this.#i.push(n)}#d(){if(this.#c)return;const t=this.#t.openSocket(this.sessionId,this.#s,this.#n.truncateResults,this.#n.imageRefs);this.#r=t,t.onopen=()=>{this.#o=0,this.#l("connectionChange",!0);for(const n of this.#i.splice(0))t.send(n)},t.onmessage=n=>{const r=JSON.parse(String(n.data));if(r.type==="attached")this.#l("attached",r);else if(r.type==="event"){if(r.event.seq<=this.#s)return;this.#s=r.event.seq,this.#l("event",r.event)}else r.type==="tool_call_request"?this.#l("toolCallRequest",r):r.type==="tool_call_canceled"?this.#l("toolCallCanceled",{executionId:r.executionId,reason:r.reason}):r.type==="protocol_error"&&this.#l("protocolError",r.message)},t.onclose=()=>{if(this.#l("connectionChange",!1),this.#c||!this.#n.reconnect)return;const n=Math.min(500*2**this.#o++,1e4);this.#l("reconnectAttempt",this.#o),this.#u=setTimeout(()=>this.#d(),n)},t.onerror=()=>{}}}class YW{#t;#n;#r;#e=new Map;#s=!1;#c=0;#o;constructor(t,n={}){this.#t=t,this.#n=n.reconnect??!0,this.#o=setTimeout(()=>this.#u(),0)}on(t,n){let r=this.#e.get(t);return r||(r=new Set,this.#e.set(t,r)),r.add(n),()=>r.delete(n)}detach(){this.#s=!0,clearTimeout(this.#o),this.#r?.close(),this.#r=void 0}#i(t,n){const r=this.#e.get(t);if(r)for(const s of r)try{s(n)}catch{}}#u(){if(this.#s)return;const t=this.#t.openQueueSocket();this.#r=t,t.onopen=()=>{this.#c=0,this.#i("connectionChange",!0)},t.onmessage=n=>{const r=JSON.parse(String(n.data));r.type==="queue_attached"?(this.#i("attached",r.stats),this.#i("stats",r.stats)):r.type==="job_event"?this.#i("event",r.event):r.type==="queue_stats"&&this.#i("stats",r.stats)},t.onclose=()=>{if(this.#i("connectionChange",!1),this.#s||!this.#n)return;const n=Math.min(500*2**this.#c++,1e4);this.#o=setTimeout(()=>this.#u(),n)},t.onerror=()=>{}}}class GW{#t;#n;#r;constructor(t){this.#t=t,this.#n=t.fetchImpl??fetch.bind(globalThis),this.#r=t.WebSocketImpl??WebSocket}get identityKey(){const t=Object.entries(this.#t.headers??{}).map(([n,r])=>[n.toLowerCase(),r]);return t.sort(([n],[r])=>n<r?-1:n>r?1:0),JSON.stringify([this.#t.baseUrl,t])}async createSession(t){return(await this.#e("POST","/sessions",t)).session}async listSessions(){return(await this.#e("GET","/sessions")).sessions}async getSession(t){return(await this.#e("GET",`/sessions/${encodeURIComponent(t)}`)).session}async updateSession(t,n){return(await this.#e("PATCH",`/sessions/${encodeURIComponent(t)}`,n)).session}async deleteSession(t){return(await this.#e("DELETE",`/sessions/${encodeURIComponent(t)}`)).session}async listSessionFiles(t){return(await this.#e("GET",`/sessions/${encodeURIComponent(t)}/files`)).files}async fetchSessionFile(t,n){const r=await this.#n(this.sessionFileUrl(t,n),{headers:this.#t.headers});if(!r.ok){const s=await r.json().catch(()=>({}));throw new Vs(s.error??`GET file failed with ${r.status}`,r.status)}return await r.text()}async uploadAttachment(t,n){const r=`${this.#t.baseUrl}/sessions/${encodeURIComponent(t)}/attachments?name=${encodeURIComponent(n.name)}`,s=await this.#n(r,{method:"POST",headers:{...this.#t.headers,"content-type":n.mediaType},body:n.data});if(!s.ok){const a=await s.json().catch(()=>({}));throw new Vs(a.error??`upload failed with ${s.status}`,s.status)}return(await s.json()).attachment}attachmentUrl(t,n){return`${this.#t.baseUrl}/sessions/${encodeURIComponent(t)}/attachments/${encodeURIComponent(n)}`}producedFileUrl(t,n){return`${this.#t.baseUrl}/sessions/${encodeURIComponent(t)}/produced/${encodeURIComponent(n)}`}async readProducedFile(t,n){const r=await this.#n(this.producedFileUrl(t,n),{headers:{...this.#t.headers}});if(!r.ok){const s=await r.json().catch(()=>({}));throw new Vs(s.error??`produced file request failed with ${r.status}`,r.status)}return await r.blob()}projectIconUrl(t){return`${this.#t.baseUrl}/sessions/${encodeURIComponent(t)}/project/icon`}async projectIcon(t){const n=await this.#n(this.projectIconUrl(t),{headers:{...this.#t.headers}});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Vs(r.error??`project icon request failed with ${n.status}`,n.status)}return await n.blob()}async listMcpServers(t){return(await this.#e("GET",`/sessions/${encodeURIComponent(t)}/mcp`)).servers}async mcpServerAction(t,n,r){return(await this.#e("POST",`/sessions/${encodeURIComponent(t)}/mcp/${encodeURIComponent(n)}`,{action:r})).servers}sessionFileUrl(t,n){const r=n.split("/").filter(Boolean).map(encodeURIComponent).join("/");return`${this.#t.baseUrl}/sessions/${encodeURIComponent(t)}/files/${r}`}async resolvePermission(t,n,r){await this.#e("POST",`/sessions/${encodeURIComponent(t)}/permissions/${encodeURIComponent(n)}`,r)}async submitExecutionResult(t,n){return await this.#e("POST",`/executions/${encodeURIComponent(t)}/result`,n)}async listProfiles(){return await this.#e("GET","/profiles")}async getProfile(t){return await this.#e("GET",`/profiles/${encodeURIComponent(t)}`)}async createProfile(t){return(await this.#e("POST","/profiles",t)).profile}async updateProfile(t,n){return(await this.#e("PATCH",`/profiles/${encodeURIComponent(t)}`,n)).profile}async deleteProfile(t){await this.#e("DELETE",`/profiles/${encodeURIComponent(t)}`)}async listSdkSessions(t){const n=new URLSearchParams;t?.dir&&n.set("dir",t.dir),t?.limit!==void 0&&n.set("limit",String(t.limit)),t?.offset!==void 0&&n.set("offset",String(t.offset)),t?.profile&&n.set("profile",t.profile);const r=n.size>0?`?${n.toString()}`:"";return(await this.#e("GET",`/sdk-sessions${r}`)).sdkSessions}async listHostRoots(){return await this.#e("GET","/fs/roots")}async listHostDir(t){const n=`?path=${encodeURIComponent(t)}`;return await this.#e("GET",`/fs/list${n}`)}async findHostFiles(t,n="",r){const s=new URLSearchParams({path:t,q:n});return r!==void 0&&s.set("limit",String(r)),await this.#e("GET",`/fs/find?${s.toString()}`)}async readHostFile(t){const n=`?path=${encodeURIComponent(t)}`;return await this.#e("GET",`/fs/read${n}`)}async writeHostFile(t){return await this.#e("PUT","/fs/write",t)}async createJob(t){return(await this.#e("POST","/jobs",t)).job}async listJobs(){return(await this.#e("GET","/jobs")).jobs}async getJob(t){return(await this.#e("GET",`/jobs/${encodeURIComponent(t)}`)).job}async cancelJob(t){return(await this.#e("DELETE",`/jobs/${encodeURIComponent(t)}`)).job}async queueStats(){return(await this.#e("GET","/queue")).stats}attach(t,n){return new qW(this,t,n)}attachQueue(t){return new YW(this,t)}openSocket(t,n,r=!1,s=!1){const a=`afterSeq=${n}`+(r?"&truncateResults=1":"")+(s?"&imageRefs=1":""),l=this.#t.buildWsUrl?.(t,n,r,s)??`${this.#t.baseUrl.replace(/^http/,"ws")}/sessions/${encodeURIComponent(t)}/ws?${a}`;return new this.#r(l)}async toolResult(t,n,r,s){return await this.#e("GET",`/sessions/${encodeURIComponent(t)}/events/${n}/result?toolUseId=${encodeURIComponent(r)}`+(s?.imageRefs?"&imageRefs=1":""))}async toolResultImage(t,n,r,s){const a=`/sessions/${encodeURIComponent(t)}/events/${n}/result?toolUseId=${encodeURIComponent(r)}&part=${s}`,l=await this.#n(`${this.#t.baseUrl}${a}`,{headers:{...this.#t.headers}});if(!l.ok){const c=await l.json().catch(()=>({}));throw new Vs(c.error??`image part request failed with ${l.status}`,l.status)}return await l.blob()}openQueueSocket(){const t=this.#t.buildQueueWsUrl?.()??`${this.#t.baseUrl.replace(/^http/,"ws")}/queue/ws`;return new this.#r(t)}async#e(t,n,r){const s=await this.#n(`${this.#t.baseUrl}${n}`,{method:t,headers:{...r!==void 0?{"content-type":"application/json"}:{},...this.#t.headers},body:r!==void 0?JSON.stringify(r):void 0}),a=await s.json().catch(()=>({}));if(!s.ok)throw new Vs(a.error??`${t} ${n} failed with ${s.status}`,s.status);return a}}function KW(e,t,n){const r=[],s=(a,l)=>{const c=t.get(a);if(c)for(const u of c.entries){if(u.type!=="dir"){r.push({entry:u,depth:l});continue}const h=n.has(u.path),m=t.get(u.path);r.push({entry:u,depth:l,expanded:h,loading:h&&!m,truncated:h?m?.truncated:void 0}),h&&m&&s(u.path,l+1)}};return s(e,0),r}function WW(e,t){const n=e.endsWith("/")?e.slice(0,-1):e;if(t===n||!t.startsWith(`${n}/`))return[];const r=t.slice(n.length+1).split("/"),s=[];let a=n;for(const l of r.slice(0,-1))a=`${a}/${l}`,s.push(a);return s}function tA(e,t){const[n,r]=y.useState(!1),s=y.useRef(t);y.useEffect(()=>{s.current!==t&&(s.current=t,r(!1))},[t]);const a=y.useCallback(async(l,c)=>{if(!t||n)return[];try{const u=await e.findHostFiles(t,l,c?.limit??8);return c?.signal?.aborted?[]:u.matches}catch(u){return u instanceof Vs&&u.status===404&&r(!0),[]}},[e,t,n]);return{available:!!t&&!n,search:a}}function XW(e){const[t,n]=y.useState({available:!1,canWrite:!1});return y.useEffect(()=>{let r=!1;return e.listHostRoots().then(s=>{r||n({available:!0,canWrite:s.canWrite})}).catch(()=>{r||n({available:!1,canWrite:!1})}),()=>{r=!0}},[e]),t}function QW(e,t){const[n,r]=y.useState(()=>new Map),[s,a]=y.useState(()=>new Set),[l,c]=y.useState(!1),[u,h]=y.useState(),m=y.useRef(t);y.useEffect(()=>{m.current!==t&&(m.current=t,r(new Map),a(new Set),c(!1),h(void 0))},[t]);const p=y.useRef(!0);y.useEffect(()=>(p.current=!0,()=>{p.current=!1}),[]);const b=y.useRef(new Set),x=y.useCallback((C,{force:A=!1}={})=>{l||!A&&b.current.has(C)||(b.current.add(C),e.listHostDir(C).then(R=>{p.current&&r(M=>{const _=new Map(M);return _.set(C,{entries:R.entries,truncated:R.truncated}),_})}).catch(R=>{if(p.current){if(b.current.delete(C),R instanceof Vs&&R.status===404){c(!0);return}h(R instanceof Error?R.message:"Could not read that directory")}}))},[e,l]);y.useEffect(()=>{t&&x(t)},[t,x]);const v=y.useCallback(C=>{a(A=>{const R=new Set(A);return R.has(C)?R.delete(C):R.add(C),R}),x(C)},[x]),N=y.useCallback(C=>{if(!t)return;const A=WW(t,C);if(A.length!==0){for(const R of A)x(R);a(R=>{const M=new Set(R);for(const _ of A)M.add(_);return M})}},[t,x]),w=y.useCallback(C=>{const A=C??t;A&&(h(void 0),x(A,{force:!0}))},[t,x]),S=y.useMemo(()=>t?KW(t,n,s):[],[t,n,s]);return{available:!!t&&!l,root:t,rows:S,loading:!!t&&!l&&!n.has(t)&&!u,error:u,toggle:v,reveal:N,refresh:w}}const Ih=new Map,K1=new Set,_C=new Set;function ZW(e,t){const[n,r]=y.useState(()=>Object.fromEntries(Ih));return y.useEffect(()=>{let s=!0;for(const a of e){const l=a.info.project?.icon;if(l?.type!=="image")continue;const{hash:c}=l;if(Ih.has(c)||K1.has(c)||_C.has(c))continue;const u=t(a.hostId);u&&(K1.add(c),u.projectIcon(a.info.id).then(h=>{Ih.set(c,URL.createObjectURL(h)),s&&r(Object.fromEntries(Ih))}).catch(()=>{_C.add(c)}).finally(()=>K1.delete(c)))}return()=>{s=!1}},[e,t]),n}function JW(e,t,n={}){const{intervalMs:r=6e4,enabled:s=!0}=n,[a,l]=y.useState(),[c,u]=y.useState(!1),[h,m]=y.useState(0),p=y.useCallback(()=>m(x=>x+1),[]);y.useEffect(()=>l(void 0),[e,t]);const b=y.useRef(!0);return y.useEffect(()=>(b.current=!0,()=>{b.current=!1}),[]),y.useEffect(()=>{if(!t||!s||c)return;let x=!1;const v=()=>{globalThis.document?.hidden||e.listProfiles().then(w=>{x||!b.current||l(w.profiles.find(S=>S.name===t)?.usage)}).catch(w=>{x||!b.current||w instanceof Vs&&w.status===404&&u(!0)})};v();const N=setInterval(v,r);return()=>{x=!0,clearInterval(N)}},[e,t,s,c,r,h]),{usage:a,refresh:p}}function nA(e,t){const[n,r]=y.useState(),[s,a]=y.useState(!!t),[l,c]=y.useState();return y.useEffect(()=>{if(!t){r(void 0),a(!1),c(void 0);return}let u=!1;return a(!0),c(void 0),r(void 0),e.getSession(t).then(h=>{u||(r(h),a(!1))}).catch(h=>{u||(c(h instanceof Error?h.message:"Session not found"),a(!1))}),()=>{u=!0}},[e,t]),{info:n,loading:s,error:l}}function Cd(e){return e.draft!==void 0&&e.draft!==e.content}function bx(e){return e.draft??e.content??""}const rA={files:[]};function eX(e,t){switch(t.type){case"open":{if(e.files.some(r=>r.path===t.path))return e.activePath===t.path?e:{...e,activePath:t.path};const n={path:t.path,name:AC(t.path),status:"loading"};return{files:[...e.files,n],activePath:t.path}}case"close":{const n=e.files.findIndex(a=>a.path===t.path);if(n===-1)return e;const r=e.files.filter(a=>a.path!==t.path);if(e.activePath!==t.path)return{...e,files:r};const s=r[n]??r[n-1];return{files:r,activePath:s?.path}}case"closeAll":return rA;case"activate":return e.files.some(n=>n.path===t.path)?e.activePath===t.path?e:{...e,activePath:t.path}:e;case"loaded":return ha(e,t.path,()=>({path:t.path,name:AC(t.path),status:t.encoding==="utf8"?"ready":"binary",content:t.encoding==="utf8"?t.content:void 0,bytes:t.bytes,hash:t.hash,modifiedAt:t.modifiedAt}));case"failed":return ha(e,t.path,n=>({...n,status:"error",error:t.error}));case"edit":return ha(e,t.path,n=>n.status==="ready"?{...n,draft:t.content}:n);case"revert":return ha(e,t.path,n=>({...n,draft:void 0,saveError:void 0,conflict:!1}));case"saveStart":return ha(e,t.path,n=>({...n,saving:!0,saveError:void 0,conflict:!1}));case"saved":return ha(e,t.path,n=>({...n,saving:!1,saveError:void 0,conflict:!1,content:t.content,bytes:t.bytes,hash:t.hash,modifiedAt:t.modifiedAt,draft:n.draft===t.content?void 0:n.draft}));case"saveFailed":return ha(e,t.path,n=>({...n,saving:!1,saveError:t.error,conflict:t.conflict??!1}));case"dismissConflict":return ha(e,t.path,n=>({...n,conflict:!1,saveError:void 0}))}}function ha(e,t,n){const r=e.files.findIndex(c=>c.path===t);if(r===-1)return e;const s=e.files[r],a=n(s);if(a===s)return e;const l=e.files.slice();return l[r]=a,{...e,files:l}}function AC(e){const t=e.endsWith("/")?e.slice(0,-1):e;return t.slice(t.lastIndexOf("/")+1)||t||e}function tX(e){const[t,n]=y.useReducer(eX,rA),r=y.useRef(new Set),s=y.useRef(!0);y.useEffect(()=>(s.current=!0,()=>{s.current=!1}),[]);const a=y.useRef(t);y.useEffect(()=>{a.current=t},[t]);const c=t.files.filter(_=>_.status==="loading").map(_=>_.path).join(`
|
|
1053
1053
|
`),u=y.useCallback(_=>e.readHostFile(_).then(I=>{if(s.current)return n({type:"loaded",path:_,content:I.content,encoding:I.encoding,bytes:I.bytes,hash:I.hash,modifiedAt:I.modifiedAt}),I}),[e]);y.useEffect(()=>{for(const _ of c?c.split(`
|
|
1054
|
-
`):[])r.current.has(_)||(r.current.add(_),u(_).catch(I=>{s.current&&n({type:"failed",path:_,error:I instanceof Error?I.message:"Could not read that file"})}))},[u,c]);const h=y.useCallback(_=>n({type:"open",path:_}),[]),m=y.useCallback(_=>{r.current.delete(_),n({type:"close",path:_})},[]),p=y.useCallback(()=>{r.current.clear(),n({type:"closeAll"})},[]),b=y.useCallback(_=>n({type:"activate",path:_}),[]),x=y.useCallback((_,I)=>n({type:"edit",path:_,content:I}),[]),v=y.useCallback(_=>n({type:"revert",path:_}),[]),N=y.useCallback(_=>n({type:"dismissConflict",path:_}),[]),w=y.useCallback(_=>{r.current.add(_),u(_).catch(I=>{s.current&&n({type:"failed",path:_,error:I instanceof Error?I.message:"Could not re-read that file"})})},[u]),S=y.useCallback(async(_,I,j)=>{try{const z=await e.writeHostFile({path:_,content:I,expectedHash:j});if(!s.current)return;n({type:"saved",path:_,content:I,bytes:z.bytes,hash:z.hash,modifiedAt:z.modifiedAt})}catch(z){if(!s.current)return;const P=z instanceof Vs&&z.status===409;n({type:"saveFailed",path:_,conflict:P,error:P?"This file changed on disk since you opened it.":z instanceof Error?z.message:"Could not save that file"})}},[e]),C=y.useCallback(async _=>{const I=a.current.files.find(j=>j.path===_);!I||I.saving||!Cd(I)||(n({type:"saveStart",path:_}),await S(_,bx(I),I.hash))},[S]),A=y.useCallback(async _=>{const I=a.current.files.find(z=>z.path===_);if(!I||I.saving)return;const j=bx(I);n({type:"saveStart",path:_});try{const z=await e.readHostFile(_);if(!s.current)return;await S(_,j,z.hash)}catch(z){if(!s.current)return;n({type:"saveFailed",path:_,error:z instanceof Error?z.message:"Could not save that file"})}},[e,S]),R=y.useMemo(()=>t.files.find(_=>_.path===t.activePath),[t.files,t.activePath]),M=y.useMemo(()=>t.files.some(Cd),[t.files]);return{...t,active:R,hasUnsaved:M,open:h,close:m,closeAll:p,activate:b,edit:x,save:C,revert:v,reload:w,overwrite:A,dismissConflict:N}}const nX="modulepreload",rX=function(e){return"/"+e},RC={},fc=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){let l=function(h){return Promise.all(h.map(m=>Promise.resolve(m).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),u=c?.nonce||c?.getAttribute("nonce");s=l(n.map(h=>{if(h=rX(h),h in RC)return;RC[h]=!0;const m=h.endsWith(".css"),p=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${p}`))return;const b=document.createElement("link");if(b.rel=m?"stylesheet":nX,m||(b.as="script"),b.crossOrigin="",b.href=h,u&&b.setAttribute("nonce",u),document.head.appendChild(b),m)return new Promise((x,v)=>{b.addEventListener("load",x),b.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${h}`)))})}))}function a(l){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=l,window.dispatchEvent(c),!c.defaultPrevented)throw l}return s.then(l=>{for(const c of l||[])c.status==="rejected"&&a(c.reason);return t().catch(a)})};function sX(e,t={}){const n=new Map;let r,s=!1;const a=m=>t.onExecution?.(m),l=(m,p,b,x)=>{e.sendToolCallError(m.executionId,p,b),a({executionId:m.executionId,toolName:m.toolName,status:"failed",reason:p,startedAt:x,endedAt:Date.now()})},c=async m=>{const p=Date.now();if(!(t.tools??["eval_script"]).includes(m.toolName)){l(m,"unsupported_tool",`this client does not execute '${m.toolName}'`,p);return}const x=m.input?.script;if(typeof x!="string"){l(m,"invalid_input","expected a string `script` input",p);return}const v=new AbortController;n.set(m.executionId,v),a({executionId:m.executionId,toolName:m.toolName,status:"running",startedAt:p});try{const N=await fc(()=>import("./index-B4f5UAbn.js"),[]),w=N.createVfs(m.vfsSeed),S=Math.min(m.limits?.timeoutMs??Number.POSITIVE_INFINITY,t.timeoutMs??5e3),C=Math.min(m.limits?.memoryLimitBytes??Number.POSITIVE_INFINITY,t.memoryLimitBytes??64*1024*1024),A=t.execute?await t.execute({script:x,vfs:w,timeoutMs:S,memoryLimitBytes:C,signal:v.signal}):await(async()=>(r??=(t.loadEngine??iX)(),N.runScript(await r,{script:x,vfs:w,timeoutMs:S,memoryLimitBytes:C,signal:v.signal,fetchText:t.fetchText})))();if(s||!n.has(m.executionId))return;const R=A.logs.map(M=>`[${M.level}] ${M.text}`);A.ok?(e.sendToolCallResult(m.executionId,{type:"json",value:A.value},R),a({executionId:m.executionId,toolName:m.toolName,status:"settled",startedAt:p,endedAt:Date.now()})):(e.sendToolCallError(m.executionId,A.reason,A.error,R),a({executionId:m.executionId,toolName:m.toolName,status:"failed",reason:A.reason,startedAt:p,endedAt:Date.now()}))}catch(N){if(s||!n.has(m.executionId))return;l(m,"host_error",N instanceof Error?N.message:String(N),p)}finally{n.delete(m.executionId)}},u=e.on("toolCallRequest",m=>void c(m)),h=e.on("toolCallCanceled",({executionId:m,reason:p})=>{const b=n.get(m);b&&(b.abort(),n.delete(m),a({executionId:m,toolName:"",status:"canceled",reason:p,startedAt:Date.now(),endedAt:Date.now()}))});return{dispose:()=>{s=!0,u(),h();for(const m of n.values())m.abort();n.clear()}}}async function iX(){const[e,t]=await Promise.all([fc(()=>import("./index-B4f5UAbn.js"),[]),fc(()=>import("./index-Os9DF_RA.js"),[])]);return e.loadEngine(t)}function aX(e,t={}){const[n,r]=y.useState([]),s=y.useRef(t);return s.current=t,y.useEffect(()=>{if(!e||t.enabled===!1)return;const a=sX(e,{get tools(){return s.current.tools},get timeoutMs(){return s.current.timeoutMs},get memoryLimitBytes(){return s.current.memoryLimitBytes},get loadEngine(){return s.current.loadEngine},get execute(){return s.current.execute},get fetchText(){return s.current.fetchText},onExecution:l=>{s.current.onExecution?.(l);const c=s.current.historyLimit??50;r(u=>[...u.filter(h=>h.executionId!==l.executionId),l].slice(-c))}});return()=>a.dispose()},[e,t.enabled]),{executions:n}}function oX(e,t){const n=Math.max(0,Math.min(t,e.items.length)),r=e.items.slice(n),s=new Map;let a=0,l=0,c=0,u=0,h=0;for(const b of r)switch(b.kind){case"turn_result":a+=1,b.isError&&(h+=1);break;case"assistant_text":l+=1;break;case"tool_call":c+=1,s.set(b.name,(s.get(b.name)??0)+1),(b.status==="failed"||b.result?.isError)&&(h+=1);break;case"file_delivered":u+=1;break;case"notice":b.level==="error"&&(h+=1);break}const m=[...s.entries()].sort((b,x)=>x[1]-b[1]||b[0].localeCompare(x[0])).map(([b])=>b),p=e.pendingApprovals?.length??0;return{turns:a,replies:l,tools:c,toolNames:m,files:u,errors:h,pending:p,any:a+l+c+u+h+p>0}}function lX(e){if(!e.any)return;const t=[];if(e.turns>0?t.push(Dl(e.turns,"turn")):e.replies>0&&t.push(Dl(e.replies,"reply","replies")),e.tools>0){const n=e.toolNames.slice(0,3).join(", "),r=e.toolNames.length-3;t.push(`${Dl(e.tools,"tool call")}${n?` (${n}${r>0?`, +${r}`:""})`:""}`)}return e.files>0&&t.push(Dl(e.files,"file")),e.errors>0&&t.push(Dl(e.errors,"error")),e.pending>0&&t.push(`${Dl(e.pending,"approval")} waiting`),t.join(" · ")}function Dl(e,t,n=`${t}s`){return`${e} ${e===1?t:n}`}const sA=y.createContext("cards");function iA({value:e,children:t}){return d.jsx(sA.Provider,{value:e,children:t})}function Rm(){return y.useContext(sA)}const cX=y.createContext("comfortable");function uX({value:e,children:t}){return d.jsx(cX.Provider,{value:e,children:t})}const dX={terminal:{comfortable:{className:"term-row-gap",px:18},compact:{className:"term-row-gap",px:18}},cards:{comfortable:{className:"pt-4",px:16},compact:{className:"pt-2",px:8}}};function Js(e){return e===void 0||Number.isNaN(e)?"—":e===0?"$0.00":e<.01?"<$0.01":`$${e.toFixed(2)}`}function Sc(e){if(e<1e3)return`${Math.round(e)}ms`;const t=e/1e3;return t<60?`${t.toFixed(1)}s`:`${Math.floor(t/60)}m ${Math.round(t%60)}s`}function Gr(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(Math.round(e))}function Li(e){return e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${(e/1024).toFixed(1)} KB`:`${e} B`}function xx(e,t=Date.now()){const n=e-t;if(n<=0)return"now";const r=Math.ceil(n/6e4);if(r<1)return"<1m";if(r<60)return`${r}m`;const s=Math.floor(r/1440);return s>=1?`${s}d ${Math.floor(r%1440/60)}h`:`${Math.floor(r/60)}h ${r%60}m`}function kc(e,t=Date.now()){if(!e)return"—";const n=Math.max(0,t-e),r=Math.floor(n/1e3);if(r<60)return"just now";const s=Math.floor(r/60);if(s<60)return`${s}m ago`;const a=Math.floor(s/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function fX(e){if(e==="five_hour")return"5-hour session";if(e==="seven_day")return"Weekly";if(e==="seven_day_oauth_apps")return"Weekly · apps";const t=n=>n.replace(/\b\w/g,r=>r.toUpperCase());return e.startsWith("seven_day_")?`Weekly · ${t(e.slice(10).replaceAll("_"," "))}`:t(e.replaceAll("_"," "))}function hX(e){if(e==="five_hour")return 5*3600;if(e.startsWith("seven_day"))return 7*86400}function aA(e,t=Date.now()){const n=Math.max(0,Math.floor((t-e)/1e3));if(n<60)return`${n} sec${n===1?"":"s"} ago`;if(n<3600){const s=Math.floor(n/60);return`${s} min${s===1?"":"s"} ago`}const r=Math.floor(n/3600);return`${r} hour${r===1?"":"s"} ago`}function Da(e,t=80){if(e==null)return"";if(typeof e=="object"){const r=e,s=r.command??r.file_path??r.path??r.url??r.pattern??r.query??r.description;if(typeof s=="string")return s.length>t?s.slice(0,t-1)+"…":s}const n=JSON.stringify(e)??"";return n.length>t?n.slice(0,t-1)+"…":n}const pX={gpt:{name:"GPT",joiner:"-"},deepseek:{name:"DeepSeek"},glm:{name:"GLM"},qwen:{name:"Qwen"},kimi:{name:"Kimi"},llama:{name:"Llama"},mistral:{name:"Mistral"},grok:{name:"Grok"}};function mX(e){if(!e)return;const n=(e.split("[")[0]??e).toLowerCase().split("-").filter(Boolean);n[0]==="claude"&&n.shift();const r=n.shift();if(!r)return e;const s=pX[r],a=s?.name??(/^o\d+$/.test(r)?r:`${r.charAt(0).toUpperCase()}${r.slice(1)}`),l=[],c=[];for(const h of n)/^\d{8}$/.test(h)||(/^\d+(\.\d+)?$/.test(h)?l.push(h):c.push(`${h.charAt(0).toUpperCase()}${h.slice(1)}`));return[l.length>0?`${a}${s?.joiner??" "}${l.join(".")}`:a,...c].join(" ")}function oA(e){switch(e){case"Bash":case"BashOutput":case"KillShell":return Np;case"Read":return b2;case"Write":return XV;case"Edit":case"MultiEdit":case"NotebookEdit":return $$;case"Glob":return aF;case"Grep":return km;case"WebFetch":return iU;case"WebSearch":return ax;case"Task":case"Agent":return T2;case"TodoWrite":return KV;case"Skill":return jd;case"AskUserQuestion":return t_;case"CodexCommand":return Np;case"CodexFileChange":return YU;case"CodexWebSearch":return ax;case"CodexImageGeneration":case"CodexImageView":return Z6;default:return e.startsWith("mcp__")?n_:o_}}function gX(e){return e==="Bash"||e==="CodexCommand"}function bX(e){switch(e){case"Write":case"Edit":case"MultiEdit":case"NotebookEdit":case"Update":case"CodexFileChange":return!0;default:return!1}}const Ip=["⋄","◇","◈","◆"],xX=150,yX=Ip[Ip.length-1];function vX(){const[e,t]=y.useState(!1);return y.useEffect(()=>{const n=window.matchMedia?.("(prefers-reduced-motion: reduce)");if(!n)return;t(n.matches);const r=()=>t(n.matches);return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}function zd(e){const t=vX(),n=e&&!t,[r,s]=y.useState(0);return y.useEffect(()=>{if(!n)return;const a=setInterval(()=>s(l=>l+1),xX);return()=>clearInterval(a)},[n]),n?Ip[r%Ip.length]:yX}const yx={hover:!0,actions:!0},lA=y.createContext(yx);function EX(){return y.useContext(lA)}function cA(e){return e===!1?{hover:!1,actions:!1}:e===!0||e===void 0?yx:{...yx,...e}}function TX({value:e,children:t}){return d.jsx(lA.Provider,{value:e,children:t})}function Mm({actions:e,children:t,className:n}){const{actions:r}=EX();return r?d.jsxs("div",{className:ve("term-hoverable",n),children:[t,d.jsx("div",{className:"term-actions",children:e})]}):d.jsx(d.Fragment,{children:t})}function SX({onOpen:e,label:t="Open sub-agent"}){return d.jsx("button",{type:"button",className:"term-action",title:t,"aria-label":t,onClick:n=>{n.stopPropagation(),e()},children:"⤢"})}function M2({text:e,label:t="Copy"}){const[n,r]=y.useState(!1);return d.jsx("button",{type:"button",className:"term-action",title:t,"aria-label":t,onClick:s=>{s.stopPropagation(),navigator.clipboard?.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),1200)}).catch(()=>{})},children:n?"✓":"⧉"})}function _t({glyph:e,glyphTone:t,tone:n,bold:r,indent:s,columns:a,className:l,children:c,style:u,...h}){return d.jsxs("div",{className:ve("term-row",l),"data-indent":s?String(s):void 0,"data-tone":n,"data-weight":r?"bold":void 0,style:a===void 0?u:{...u,"--term-cell":`${a}ch`},...h,children:[d.jsx("span",{className:"term-gutter","data-tone":t,"aria-hidden":!0,children:e??" "}),d.jsx("div",{className:"term-body",children:c})]})}function Gs(){return d.jsx("div",{className:"term-blank","aria-hidden":!0})}function kX({className:e,...t}){return d.jsx("div",{className:ve("term-band",e),...t})}function jr({tone:e,bold:t,className:n,...r}){return d.jsx("span",{"data-tone":e,"data-weight":t?"bold":void 0,className:n,...r})}const CX=e=>e.startsWith("+")?"add":e.startsWith("-")?"remove":"context";function wX(e){let t=e.oldStart,n=e.newStart;const r=[];for(const s of e.lines){const a=CX(s),l=s.slice(1);a==="add"?r.push({kind:a,number:n++,text:l}):a==="remove"?r.push({kind:a,number:t++,text:l}):(r.push({kind:a,number:n,text:l}),t++,n++)}return r}const MC={context:" ",add:"+",remove:"-"};function NX(e){const t=e,n=typeof t?.old_string=="string"?t.old_string:void 0,r=typeof t?.new_string=="string"?t.new_string:void 0;if(n===void 0&&r===void 0)return;const s=[...n?n.split(`
|
|
1054
|
+
`):[])r.current.has(_)||(r.current.add(_),u(_).catch(I=>{s.current&&n({type:"failed",path:_,error:I instanceof Error?I.message:"Could not read that file"})}))},[u,c]);const h=y.useCallback(_=>n({type:"open",path:_}),[]),m=y.useCallback(_=>{r.current.delete(_),n({type:"close",path:_})},[]),p=y.useCallback(()=>{r.current.clear(),n({type:"closeAll"})},[]),b=y.useCallback(_=>n({type:"activate",path:_}),[]),x=y.useCallback((_,I)=>n({type:"edit",path:_,content:I}),[]),v=y.useCallback(_=>n({type:"revert",path:_}),[]),N=y.useCallback(_=>n({type:"dismissConflict",path:_}),[]),w=y.useCallback(_=>{r.current.add(_),u(_).catch(I=>{s.current&&n({type:"failed",path:_,error:I instanceof Error?I.message:"Could not re-read that file"})})},[u]),S=y.useCallback(async(_,I,j)=>{try{const z=await e.writeHostFile({path:_,content:I,expectedHash:j});if(!s.current)return;n({type:"saved",path:_,content:I,bytes:z.bytes,hash:z.hash,modifiedAt:z.modifiedAt})}catch(z){if(!s.current)return;const P=z instanceof Vs&&z.status===409;n({type:"saveFailed",path:_,conflict:P,error:P?"This file changed on disk since you opened it.":z instanceof Error?z.message:"Could not save that file"})}},[e]),C=y.useCallback(async _=>{const I=a.current.files.find(j=>j.path===_);!I||I.saving||!Cd(I)||(n({type:"saveStart",path:_}),await S(_,bx(I),I.hash))},[S]),A=y.useCallback(async _=>{const I=a.current.files.find(z=>z.path===_);if(!I||I.saving)return;const j=bx(I);n({type:"saveStart",path:_});try{const z=await e.readHostFile(_);if(!s.current)return;await S(_,j,z.hash)}catch(z){if(!s.current)return;n({type:"saveFailed",path:_,error:z instanceof Error?z.message:"Could not save that file"})}},[e,S]),R=y.useMemo(()=>t.files.find(_=>_.path===t.activePath),[t.files,t.activePath]),M=y.useMemo(()=>t.files.some(Cd),[t.files]);return{...t,active:R,hasUnsaved:M,open:h,close:m,closeAll:p,activate:b,edit:x,save:C,revert:v,reload:w,overwrite:A,dismissConflict:N}}const nX="modulepreload",rX=function(e){return"/"+e},RC={},fc=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){let l=function(h){return Promise.all(h.map(m=>Promise.resolve(m).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),u=c?.nonce||c?.getAttribute("nonce");s=l(n.map(h=>{if(h=rX(h),h in RC)return;RC[h]=!0;const m=h.endsWith(".css"),p=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${p}`))return;const b=document.createElement("link");if(b.rel=m?"stylesheet":nX,m||(b.as="script"),b.crossOrigin="",b.href=h,u&&b.setAttribute("nonce",u),document.head.appendChild(b),m)return new Promise((x,v)=>{b.addEventListener("load",x),b.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${h}`)))})}))}function a(l){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=l,window.dispatchEvent(c),!c.defaultPrevented)throw l}return s.then(l=>{for(const c of l||[])c.status==="rejected"&&a(c.reason);return t().catch(a)})};function sX(e,t={}){const n=new Map;let r,s=!1;const a=m=>t.onExecution?.(m),l=(m,p,b,x)=>{e.sendToolCallError(m.executionId,p,b),a({executionId:m.executionId,toolName:m.toolName,status:"failed",reason:p,startedAt:x,endedAt:Date.now()})},c=async m=>{const p=Date.now();if(!(t.tools??["eval_script"]).includes(m.toolName)){l(m,"unsupported_tool",`this client does not execute '${m.toolName}'`,p);return}const x=m.input?.script;if(typeof x!="string"){l(m,"invalid_input","expected a string `script` input",p);return}const v=new AbortController;n.set(m.executionId,v),a({executionId:m.executionId,toolName:m.toolName,status:"running",startedAt:p});try{const N=await fc(()=>import("./index-BBZcH34f.js"),[]),w=N.createVfs(m.vfsSeed),S=Math.min(m.limits?.timeoutMs??Number.POSITIVE_INFINITY,t.timeoutMs??5e3),C=Math.min(m.limits?.memoryLimitBytes??Number.POSITIVE_INFINITY,t.memoryLimitBytes??64*1024*1024),A=t.execute?await t.execute({script:x,vfs:w,timeoutMs:S,memoryLimitBytes:C,signal:v.signal}):await(async()=>(r??=(t.loadEngine??iX)(),N.runScript(await r,{script:x,vfs:w,timeoutMs:S,memoryLimitBytes:C,signal:v.signal,fetchText:t.fetchText})))();if(s||!n.has(m.executionId))return;const R=A.logs.map(M=>`[${M.level}] ${M.text}`);A.ok?(e.sendToolCallResult(m.executionId,{type:"json",value:A.value},R),a({executionId:m.executionId,toolName:m.toolName,status:"settled",startedAt:p,endedAt:Date.now()})):(e.sendToolCallError(m.executionId,A.reason,A.error,R),a({executionId:m.executionId,toolName:m.toolName,status:"failed",reason:A.reason,startedAt:p,endedAt:Date.now()}))}catch(N){if(s||!n.has(m.executionId))return;l(m,"host_error",N instanceof Error?N.message:String(N),p)}finally{n.delete(m.executionId)}},u=e.on("toolCallRequest",m=>void c(m)),h=e.on("toolCallCanceled",({executionId:m,reason:p})=>{const b=n.get(m);b&&(b.abort(),n.delete(m),a({executionId:m,toolName:"",status:"canceled",reason:p,startedAt:Date.now(),endedAt:Date.now()}))});return{dispose:()=>{s=!0,u(),h();for(const m of n.values())m.abort();n.clear()}}}async function iX(){const[e,t]=await Promise.all([fc(()=>import("./index-BBZcH34f.js"),[]),fc(()=>import("./index-D-9g69rX.js"),[])]);return e.loadEngine(t)}function aX(e,t={}){const[n,r]=y.useState([]),s=y.useRef(t);return s.current=t,y.useEffect(()=>{if(!e||t.enabled===!1)return;const a=sX(e,{get tools(){return s.current.tools},get timeoutMs(){return s.current.timeoutMs},get memoryLimitBytes(){return s.current.memoryLimitBytes},get loadEngine(){return s.current.loadEngine},get execute(){return s.current.execute},get fetchText(){return s.current.fetchText},onExecution:l=>{s.current.onExecution?.(l);const c=s.current.historyLimit??50;r(u=>[...u.filter(h=>h.executionId!==l.executionId),l].slice(-c))}});return()=>a.dispose()},[e,t.enabled]),{executions:n}}function oX(e,t){const n=Math.max(0,Math.min(t,e.items.length)),r=e.items.slice(n),s=new Map;let a=0,l=0,c=0,u=0,h=0;for(const b of r)switch(b.kind){case"turn_result":a+=1,b.isError&&(h+=1);break;case"assistant_text":l+=1;break;case"tool_call":c+=1,s.set(b.name,(s.get(b.name)??0)+1),(b.status==="failed"||b.result?.isError)&&(h+=1);break;case"file_delivered":u+=1;break;case"notice":b.level==="error"&&(h+=1);break}const m=[...s.entries()].sort((b,x)=>x[1]-b[1]||b[0].localeCompare(x[0])).map(([b])=>b),p=e.pendingApprovals?.length??0;return{turns:a,replies:l,tools:c,toolNames:m,files:u,errors:h,pending:p,any:a+l+c+u+h+p>0}}function lX(e){if(!e.any)return;const t=[];if(e.turns>0?t.push(Dl(e.turns,"turn")):e.replies>0&&t.push(Dl(e.replies,"reply","replies")),e.tools>0){const n=e.toolNames.slice(0,3).join(", "),r=e.toolNames.length-3;t.push(`${Dl(e.tools,"tool call")}${n?` (${n}${r>0?`, +${r}`:""})`:""}`)}return e.files>0&&t.push(Dl(e.files,"file")),e.errors>0&&t.push(Dl(e.errors,"error")),e.pending>0&&t.push(`${Dl(e.pending,"approval")} waiting`),t.join(" · ")}function Dl(e,t,n=`${t}s`){return`${e} ${e===1?t:n}`}const sA=y.createContext("cards");function iA({value:e,children:t}){return d.jsx(sA.Provider,{value:e,children:t})}function Rm(){return y.useContext(sA)}const cX=y.createContext("comfortable");function uX({value:e,children:t}){return d.jsx(cX.Provider,{value:e,children:t})}const dX={terminal:{comfortable:{className:"term-row-gap",px:18},compact:{className:"term-row-gap",px:18}},cards:{comfortable:{className:"pt-4",px:16},compact:{className:"pt-2",px:8}}};function Js(e){return e===void 0||Number.isNaN(e)?"—":e===0?"$0.00":e<.01?"<$0.01":`$${e.toFixed(2)}`}function Sc(e){if(e<1e3)return`${Math.round(e)}ms`;const t=e/1e3;return t<60?`${t.toFixed(1)}s`:`${Math.floor(t/60)}m ${Math.round(t%60)}s`}function Gr(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(Math.round(e))}function Li(e){return e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${(e/1024).toFixed(1)} KB`:`${e} B`}function xx(e,t=Date.now()){const n=e-t;if(n<=0)return"now";const r=Math.ceil(n/6e4);if(r<1)return"<1m";if(r<60)return`${r}m`;const s=Math.floor(r/1440);return s>=1?`${s}d ${Math.floor(r%1440/60)}h`:`${Math.floor(r/60)}h ${r%60}m`}function kc(e,t=Date.now()){if(!e)return"—";const n=Math.max(0,t-e),r=Math.floor(n/1e3);if(r<60)return"just now";const s=Math.floor(r/60);if(s<60)return`${s}m ago`;const a=Math.floor(s/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function fX(e){if(e==="five_hour")return"5-hour session";if(e==="seven_day")return"Weekly";if(e==="seven_day_oauth_apps")return"Weekly · apps";const t=n=>n.replace(/\b\w/g,r=>r.toUpperCase());return e.startsWith("seven_day_")?`Weekly · ${t(e.slice(10).replaceAll("_"," "))}`:t(e.replaceAll("_"," "))}function hX(e){if(e==="five_hour")return 5*3600;if(e.startsWith("seven_day"))return 7*86400}function aA(e,t=Date.now()){const n=Math.max(0,Math.floor((t-e)/1e3));if(n<60)return`${n} sec${n===1?"":"s"} ago`;if(n<3600){const s=Math.floor(n/60);return`${s} min${s===1?"":"s"} ago`}const r=Math.floor(n/3600);return`${r} hour${r===1?"":"s"} ago`}function Da(e,t=80){if(e==null)return"";if(typeof e=="object"){const r=e,s=r.command??r.file_path??r.path??r.url??r.pattern??r.query??r.description;if(typeof s=="string")return s.length>t?s.slice(0,t-1)+"…":s}const n=JSON.stringify(e)??"";return n.length>t?n.slice(0,t-1)+"…":n}const pX={gpt:{name:"GPT",joiner:"-"},deepseek:{name:"DeepSeek"},glm:{name:"GLM"},qwen:{name:"Qwen"},kimi:{name:"Kimi"},llama:{name:"Llama"},mistral:{name:"Mistral"},grok:{name:"Grok"}};function mX(e){if(!e)return;const n=(e.split("[")[0]??e).toLowerCase().split("-").filter(Boolean);n[0]==="claude"&&n.shift();const r=n.shift();if(!r)return e;const s=pX[r],a=s?.name??(/^o\d+$/.test(r)?r:`${r.charAt(0).toUpperCase()}${r.slice(1)}`),l=[],c=[];for(const h of n)/^\d{8}$/.test(h)||(/^\d+(\.\d+)?$/.test(h)?l.push(h):c.push(`${h.charAt(0).toUpperCase()}${h.slice(1)}`));return[l.length>0?`${a}${s?.joiner??" "}${l.join(".")}`:a,...c].join(" ")}function oA(e){switch(e){case"Bash":case"BashOutput":case"KillShell":return Np;case"Read":return b2;case"Write":return XV;case"Edit":case"MultiEdit":case"NotebookEdit":return $$;case"Glob":return aF;case"Grep":return km;case"WebFetch":return iU;case"WebSearch":return ax;case"Task":case"Agent":return T2;case"TodoWrite":return KV;case"Skill":return jd;case"AskUserQuestion":return t_;case"CodexCommand":return Np;case"CodexFileChange":return YU;case"CodexWebSearch":return ax;case"CodexImageGeneration":case"CodexImageView":return Z6;default:return e.startsWith("mcp__")?n_:o_}}function gX(e){return e==="Bash"||e==="CodexCommand"}function bX(e){switch(e){case"Write":case"Edit":case"MultiEdit":case"NotebookEdit":case"Update":case"CodexFileChange":return!0;default:return!1}}const Ip=["⋄","◇","◈","◆"],xX=150,yX=Ip[Ip.length-1];function vX(){const[e,t]=y.useState(!1);return y.useEffect(()=>{const n=window.matchMedia?.("(prefers-reduced-motion: reduce)");if(!n)return;t(n.matches);const r=()=>t(n.matches);return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}function zd(e){const t=vX(),n=e&&!t,[r,s]=y.useState(0);return y.useEffect(()=>{if(!n)return;const a=setInterval(()=>s(l=>l+1),xX);return()=>clearInterval(a)},[n]),n?Ip[r%Ip.length]:yX}const yx={hover:!0,actions:!0},lA=y.createContext(yx);function EX(){return y.useContext(lA)}function cA(e){return e===!1?{hover:!1,actions:!1}:e===!0||e===void 0?yx:{...yx,...e}}function TX({value:e,children:t}){return d.jsx(lA.Provider,{value:e,children:t})}function Mm({actions:e,children:t,className:n}){const{actions:r}=EX();return r?d.jsxs("div",{className:ve("term-hoverable",n),children:[t,d.jsx("div",{className:"term-actions",children:e})]}):d.jsx(d.Fragment,{children:t})}function SX({onOpen:e,label:t="Open sub-agent"}){return d.jsx("button",{type:"button",className:"term-action",title:t,"aria-label":t,onClick:n=>{n.stopPropagation(),e()},children:"⤢"})}function M2({text:e,label:t="Copy"}){const[n,r]=y.useState(!1);return d.jsx("button",{type:"button",className:"term-action",title:t,"aria-label":t,onClick:s=>{s.stopPropagation(),navigator.clipboard?.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),1200)}).catch(()=>{})},children:n?"✓":"⧉"})}function _t({glyph:e,glyphTone:t,tone:n,bold:r,indent:s,columns:a,className:l,children:c,style:u,...h}){return d.jsxs("div",{className:ve("term-row",l),"data-indent":s?String(s):void 0,"data-tone":n,"data-weight":r?"bold":void 0,style:a===void 0?u:{...u,"--term-cell":`${a}ch`},...h,children:[d.jsx("span",{className:"term-gutter","data-tone":t,"aria-hidden":!0,children:e??" "}),d.jsx("div",{className:"term-body",children:c})]})}function Gs(){return d.jsx("div",{className:"term-blank","aria-hidden":!0})}function kX({className:e,...t}){return d.jsx("div",{className:ve("term-band",e),...t})}function jr({tone:e,bold:t,className:n,...r}){return d.jsx("span",{"data-tone":e,"data-weight":t?"bold":void 0,className:n,...r})}const CX=e=>e.startsWith("+")?"add":e.startsWith("-")?"remove":"context";function wX(e){let t=e.oldStart,n=e.newStart;const r=[];for(const s of e.lines){const a=CX(s),l=s.slice(1);a==="add"?r.push({kind:a,number:n++,text:l}):a==="remove"?r.push({kind:a,number:t++,text:l}):(r.push({kind:a,number:n,text:l}),t++,n++)}return r}const MC={context:" ",add:"+",remove:"-"};function NX(e){const t=e,n=typeof t?.old_string=="string"?t.old_string:void 0,r=typeof t?.new_string=="string"?t.new_string:void 0;if(n===void 0&&r===void 0)return;const s=[...n?n.split(`
|
|
1055
1055
|
`).map(a=>`-${a}`):[],...r?r.split(`
|
|
1056
1056
|
`).map(a=>`+${a}`):[]];if(s.length!==0)return{...typeof t?.file_path=="string"&&{path:t.file_path},hunks:[{oldStart:0,oldLines:0,newStart:0,newLines:0,lines:s}]}}function uA({patch:e}){const t=e.hunks.map(wX),n=e.hunks.some(a=>a.newStart>0),r=n?String(Math.max(...t.flat().map(a=>a.number),1)).length:0,s=n?r+3:2;return d.jsxs("div",{className:"term-diff",children:[t.map((a,l)=>d.jsxs("div",{children:[l>0?d.jsx(_t,{columns:s,glyph:" ".repeat(r)+" ⋮",tone:"faint"}):null,a.map((c,u)=>d.jsx(_t,{columns:s,"data-diff":c.kind,glyph:n?`${String(c.number).padStart(r)} ${MC[c.kind]}`:MC[c.kind],children:c.text||" "},u))]},l)),e.truncated?d.jsx(_t,{columns:s,tone:"faint",children:"… diff truncated"}):null]})}const Im=(function(e){if(e==null)return MX;if(typeof e=="function")return Om(e);if(typeof e=="object")return Array.isArray(e)?_X(e):AX(e);if(typeof e=="string")return RX(e);throw new Error("Expected function, string, or object as test")});function _X(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Im(e[n]);return Om(r);function r(...s){let a=-1;for(;++a<t.length;)if(t[a].apply(this,s))return!0;return!1}}function AX(e){const t=e;return Om(n);function n(r){const s=r;let a;for(a in e)if(s[a]!==t[a])return!1;return!0}}function RX(e){return Om(t);function t(n){return n&&n.type===e}}function Om(e){return t;function t(n,r,s){return!!(IX(n)&&e.call(this,n,typeof r=="number"?r:void 0,s||void 0))}}function MX(){return!0}function IX(e){return e!==null&&typeof e=="object"&&"type"in e}const dA=[],Ku=!0,vx=!1,Yl="skip";function I2(e,t,n,r){let s;typeof t=="function"&&typeof n!="function"?(r=n,n=t):s=t;const a=Im(s),l=r?-1:1;c(e,void 0,[])();function c(u,h,m){const p=u&&typeof u=="object"?u:{};if(typeof p.type=="string"){const x=typeof p.tagName=="string"?p.tagName:typeof p.name=="string"?p.name:void 0;Object.defineProperty(b,"name",{value:"node ("+(u.type+(x?"<"+x+">":""))+")"})}return b;function b(){let x=dA,v,N,w;if((!t||a(u,h,m[m.length-1]||void 0))&&(x=OX(n(u,m)),x[0]===vx))return x;if("children"in u&&u.children){const S=u;if(S.children&&x[0]!==Yl)for(N=(r?S.children.length:-1)+l,w=m.concat(S);N>-1&&N<S.children.length;){const C=S.children[N];if(v=c(C,N,w)(),v[0]===vx)return v;N=typeof v[1]=="number"?v[1]:N+l}}return x}}}function OX(e){return Array.isArray(e)?e:typeof e=="number"?[Ku,e]:e==null?dA:[e]}function Zs(e,t,n,r){let s,a,l;typeof t=="function"&&typeof n!="function"?(a=void 0,l=t,s=n):(a=t,l=n,s=r),I2(e,a,c,s);function c(u,h){const m=h[h.length-1],p=m?m.children.indexOf(u):void 0;return l(u,p,m)}}const hc={indicator:"indicator",textOnly:"text-only",remove:"remove"};function LX({defaultOrigin:e="",allowedLinkPrefixes:t=[],allowedImagePrefixes:n=[],allowDataImages:r=!1,allowedProtocols:s=[],blockedImageClass:a="inline-block bg-gray-200 dark:bg-gray-700 text-gray-600 dark:text-gray-400 px-3 py-1 rounded text-sm",blockedLinkClass:l="text-gray-500",linkBlockPolicy:c=hc.indicator,imageBlockPolicy:u=hc.indicator}){const h=t.length&&!t.every(p=>p==="*"),m=n.length&&!n.every(p=>p==="*");if(!e&&(h||m))throw new Error("defaultOrigin is required when allowedLinkPrefixes or allowedImagePrefixes are provided");return p=>{const b=HX(e,t,n,r,s,a,l,c,u);fA(p),Zs(p,b)}}function IC(e,t){if(typeof e!="string")return null;try{return new URL(e)}catch{if(t)try{return new URL(e,t)}catch{return null}if(e.startsWith("/")||e.startsWith("./")||e.startsWith("../"))try{return new URL(e,"http://example.com")}catch{return null}return null}}function jX(e){return typeof e!="string"?!1:e.startsWith("/")||e.startsWith("./")||e.startsWith("../")}const DX=new Set(["https:","http:","irc:","ircs:","mailto:","xmpp:","blob:"]),PX=new Set(["javascript:","data:","file:","vbscript:"]);function OC(e,t,n,r=!1,s=!1,a=[]){if(!e)return null;if(typeof e=="string"&&e.startsWith("#")&&!s)try{if(new URL(e,"http://example.com").hash===e)return e}catch{}if(typeof e=="string"&&e.startsWith("data:"))return s&&r&&e.startsWith("data:image/")?e:null;if(typeof e=="string"&&e.startsWith("blob:")){try{if(new URL(e).protocol==="blob:"&&e.length>5){const m=e.substring(5);if(m&&m.length>0&&m!=="invalid")return e}}catch{return null}return null}const l=IC(e,n);if(!l||PX.has(l.protocol)||!(DX.has(l.protocol)||a.includes(l.protocol)||a.includes("*")))return null;if(l.protocol==="mailto:"||!l.protocol.match(/^https?:$/))return l.href;const u=jX(e);return l&&t.some(h=>{const m=IC(h,n);return!m||m.origin!==l.origin?!1:l.href.startsWith(m.href)})?u?l.pathname+l.search+l.hash:l.href:t.includes("*")?l.protocol!=="https:"&&l.protocol!=="http:"?null:u?l.pathname+l.search+l.hash:l.href:null}function fA(e){if("children"in e&&Array.isArray(e.children)){e.children=e.children.filter(t=>t!=null);for(const t of e.children)fA(t)}}const W1=Symbol("node-seen");function BX(e,t,n){return t===hc.remove?{type:"remove"}:t===hc.textOnly?{type:"replace",element:{type:"element",tagName:"span",properties:{},children:[...e.children]}}:{type:"replace",element:{type:"element",tagName:"span",properties:{title:"Blocked URL: "+String(e.properties.href),class:n},children:[...e.children,{type:"text",value:" [blocked]"}]}}}function zX(e,t,n){if(t===hc.remove)return{type:"remove"};if(t===hc.textOnly){const r=String(e.properties.alt||"");return r?{type:"replace",element:{type:"element",tagName:"span",properties:{},children:[{type:"text",value:r}]}}:{type:"remove"}}return{type:"replace",element:{type:"element",tagName:"span",properties:{class:n},children:[{type:"text",value:"[Image blocked: "+String(e.properties.alt||"No description")+"]"}]}}}const HX=(e,t,n,r,s,a,l,c,u)=>{const h=(m,p,b)=>{if(m.type!=="element"||m[W1])return Ku;if(m.tagName==="a"){const x=OC(m.properties.href,t,e,!1,!1,s);if(x===null){if(m[W1]=!0,Zs(m,h),b&&typeof p=="number"){const v=BX(m,c,l);if(v.type==="remove")return b.children.splice(p,1),[Yl,p];b.children[p]=v.element}return Yl}else return m.properties.href=x,m.properties.target="_blank",m.properties.rel="noopener noreferrer",Ku}if(m.tagName==="img"){const x=OC(m.properties.src,n,e,r,!0,s);if(x===null){if(m[W1]=!0,Zs(m,h),b&&typeof p=="number"){const v=zX(m,u,a);if(v.type==="remove")return b.children.splice(p,1),[Yl,p];b.children[p]=v.element}return Yl}else return m.properties.src=x,Ku}return Ku};return h},hA=-1,Lm=0,nd=1,Op=2,O2=3,L2=4,j2=5,D2=6,pA=7,mA=8,gA=typeof self=="object"?self:globalThis,LC=(e,t)=>{switch(e){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+e)}return new gA[e](t)},UX=(e,t)=>{const n=(s,a)=>(e.set(a,s),s),r=s=>{if(e.has(s))return e.get(s);const[a,l]=t[s];switch(a){case Lm:case hA:return n(l,s);case nd:{const c=n([],s);for(const u of l)c.push(r(u));return c}case Op:{const c=n({},s);for(const[u,h]of l)c[r(u)]=r(h);return c}case O2:return n(new Date(l),s);case L2:{const{source:c,flags:u}=l;return n(new RegExp(c,u),s)}case j2:{const c=n(new Map,s);for(const[u,h]of l)c.set(r(u),r(h));return c}case D2:{const c=n(new Set,s);for(const u of l)c.add(r(u));return c}case pA:{const{name:c,message:u}=l;return n(typeof gA[c]=="function"?LC(c,u):new Error(u),s)}case mA:return n(BigInt(l),s);case"BigInt":return n(Object(BigInt(l)),s);case"ArrayBuffer":return n(new Uint8Array(l).buffer,l);case"DataView":{const{buffer:c}=new Uint8Array(l);return n(new DataView(c),l)}}return n(LC(a,l),s)};return r},jC=e=>UX(new Map,e)(0),co="",{toString:FX}={},{keys:$X}=Object,Ru=e=>{const t=typeof e;if(t!=="object"||!e)return[Lm,t];const n=FX.call(e).slice(8,-1);switch(n){case"Array":return[nd,co];case"Object":return[Op,co];case"Date":return[O2,co];case"RegExp":return[L2,co];case"Map":return[j2,co];case"Set":return[D2,co];case"DataView":return[nd,n]}return n.includes("Array")?[nd,n]:e instanceof Error?[pA,e.name||"Error"]:[Op,n]},Oh=([e,t])=>e===Lm&&(t==="function"||t==="symbol"),VX=(e,t,n,r)=>{const s=(l,c)=>{const u=r.push(l)-1;return n.set(c,u),u},a=l=>{if(n.has(l))return n.get(l);let[c,u]=Ru(l);switch(c){case Lm:{let m=l;switch(u){case"bigint":c=mA,m=l.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+u);m=null;break;case"undefined":return s([hA],l)}return s([c,m],l)}case nd:{if(u){let b=l;return u==="DataView"?b=new Uint8Array(l.buffer):u==="ArrayBuffer"&&(b=new Uint8Array(l)),s([u,[...b]],l)}const m=[],p=s([c,m],l);for(const b of l)m.push(a(b));return p}case Op:{if(u)switch(u){case"BigInt":return s([u,l.toString()],l);case"Boolean":case"Number":case"String":return s([u,l.valueOf()],l)}if(t&&"toJSON"in l)return a(l.toJSON());const m=[],p=s([c,m],l);for(const b of $X(l))(e||!Oh(Ru(l[b])))&&m.push([a(b),a(l[b])]);return p}case O2:return s([c,isNaN(l.getTime())?co:l.toISOString()],l);case L2:{const{source:m,flags:p}=l;return s([c,{source:m,flags:p}],l)}case j2:{const m=[],p=s([c,m],l);for(const[b,x]of l)(e||!(Oh(Ru(b))||Oh(Ru(x))))&&m.push([a(b),a(x)]);return p}case D2:{const m=[],p=s([c,m],l);for(const b of l)(e||!Oh(Ru(b)))&&m.push(a(b));return p}}const{message:h}=l;return s([c,{name:u,message:h}],l)};return a},DC=(e,{json:t,lossy:n}={})=>{const r=[];return VX(!(t||n),!!t,new Map,r)(e),r},jo=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?jC(DC(e,t)):structuredClone(e):(e,t)=>jC(DC(e,t));class Hd{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Hd.prototype.normal={};Hd.prototype.property={};Hd.prototype.space=void 0;function bA(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new Hd(n,r,t)}function wd(e){return e.toLowerCase()}class Pr{constructor(t,n){this.attribute=n,this.property=t}}Pr.prototype.attribute="";Pr.prototype.booleanish=!1;Pr.prototype.boolean=!1;Pr.prototype.commaOrSpaceSeparated=!1;Pr.prototype.commaSeparated=!1;Pr.prototype.defined=!1;Pr.prototype.mustUseProperty=!1;Pr.prototype.number=!1;Pr.prototype.overloadedBoolean=!1;Pr.prototype.property="";Pr.prototype.spaceSeparated=!1;Pr.prototype.space=void 0;let qX=0;const bt=Go(),zn=Go(),Ex=Go(),$e=Go(),on=Go(),wo=Go(),qr=Go();function Go(){return 2**++qX}const Tx=Object.freeze(Object.defineProperty({__proto__:null,boolean:bt,booleanish:zn,commaOrSpaceSeparated:qr,commaSeparated:wo,number:$e,overloadedBoolean:Ex,spaceSeparated:on},Symbol.toStringTag,{value:"Module"})),X1=Object.keys(Tx);class P2 extends Pr{constructor(t,n,r,s){let a=-1;if(super(t,n),PC(this,"space",s),typeof r=="number")for(;++a<X1.length;){const l=X1[a];PC(this,X1[a],(r&Tx[l])===Tx[l])}}}P2.prototype.defined=!0;function PC(e,t,n){n&&(e[t]=n)}function Cc(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const a=new P2(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[wd(r)]=r,n[wd(a.attribute)]=r}return new Hd(t,n,e.space)}const xA=Cc({properties:{ariaActiveDescendant:null,ariaAtomic:zn,ariaAutoComplete:null,ariaBusy:zn,ariaChecked:zn,ariaColCount:$e,ariaColIndex:$e,ariaColSpan:$e,ariaControls:on,ariaCurrent:null,ariaDescribedBy:on,ariaDetails:null,ariaDisabled:zn,ariaDropEffect:on,ariaErrorMessage:null,ariaExpanded:zn,ariaFlowTo:on,ariaGrabbed:zn,ariaHasPopup:null,ariaHidden:zn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:on,ariaLevel:$e,ariaLive:null,ariaModal:zn,ariaMultiLine:zn,ariaMultiSelectable:zn,ariaOrientation:null,ariaOwns:on,ariaPlaceholder:null,ariaPosInSet:$e,ariaPressed:zn,ariaReadOnly:zn,ariaRelevant:null,ariaRequired:zn,ariaRoleDescription:on,ariaRowCount:$e,ariaRowIndex:$e,ariaRowSpan:$e,ariaSelected:zn,ariaSetSize:$e,ariaSort:null,ariaValueMax:$e,ariaValueMin:$e,ariaValueNow:$e,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function yA(e,t){return t in e?e[t]:t}function vA(e,t){return yA(e,t.toLowerCase())}const YX=Cc({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:wo,acceptCharset:on,accessKey:on,action:null,allow:null,allowFullScreen:bt,allowPaymentRequest:bt,allowUserMedia:bt,alpha:bt,alt:null,as:null,async:bt,autoCapitalize:null,autoComplete:on,autoFocus:bt,autoPlay:bt,blocking:on,capture:null,charSet:null,checked:bt,cite:null,className:on,closedBy:null,colorSpace:null,cols:$e,colSpan:$e,command:null,commandFor:null,content:null,contentEditable:zn,controls:bt,controlsList:on,coords:$e|wo,crossOrigin:null,data:null,dateTime:null,decoding:null,default:bt,defer:bt,dir:null,dirName:null,disabled:bt,download:Ex,draggable:zn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:bt,formTarget:null,headers:on,height:$e,hidden:Ex,high:$e,href:null,hrefLang:null,htmlFor:on,httpEquiv:on,id:null,imageSizes:null,imageSrcSet:null,inert:bt,inputMode:null,integrity:null,is:null,isMap:bt,itemId:null,itemProp:on,itemRef:on,itemScope:bt,itemType:on,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:bt,low:$e,manifest:null,max:null,maxLength:$e,media:null,method:null,min:null,minLength:$e,multiple:bt,muted:bt,name:null,nonce:null,noModule:bt,noValidate:bt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:bt,optimum:$e,pattern:null,ping:on,placeholder:null,playsInline:bt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:bt,referrerPolicy:null,rel:on,required:bt,reversed:bt,rows:$e,rowSpan:$e,sandbox:on,scope:null,scoped:bt,seamless:bt,selected:bt,shadowRootClonable:bt,shadowRootCustomElementRegistry:bt,shadowRootDelegatesFocus:bt,shadowRootMode:null,shadowRootSerializable:bt,shape:null,size:$e,sizes:null,slot:null,span:$e,spellCheck:zn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:$e,step:null,style:null,tabIndex:$e,target:null,title:null,translate:null,type:null,typeMustMatch:bt,useMap:null,value:zn,width:$e,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:on,axis:null,background:null,bgColor:null,border:$e,borderColor:null,bottomMargin:$e,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:bt,declare:bt,event:null,face:null,frame:null,frameBorder:null,hSpace:$e,leftMargin:$e,link:null,longDesc:null,lowSrc:null,marginHeight:$e,marginWidth:$e,noResize:bt,noHref:bt,noShade:bt,noWrap:bt,object:null,profile:null,prompt:null,rev:null,rightMargin:$e,rules:null,scheme:null,scrolling:zn,standby:null,summary:null,text:null,topMargin:$e,valueType:null,version:null,vAlign:null,vLink:null,vSpace:$e,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:bt,disablePictureInPicture:bt,disableRemotePlayback:bt,exportParts:wo,part:on,prefix:null,property:null,results:$e,security:null,unselectable:null},space:"html",transform:vA}),GX=Cc({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:qr,accentHeight:$e,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:$e,amplitude:$e,arabicForm:null,ascent:$e,attributeName:null,attributeType:null,azimuth:$e,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:$e,by:null,calcMode:null,capHeight:$e,className:on,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:$e,diffuseConstant:$e,direction:null,display:null,dur:null,divisor:$e,dominantBaseline:null,download:bt,dx:null,dy:null,edgeMode:null,editable:null,elevation:$e,enableBackground:null,end:null,event:null,exponent:$e,externalResourcesRequired:null,fill:null,fillOpacity:$e,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:wo,g2:wo,glyphName:wo,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:$e,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:$e,horizOriginX:$e,horizOriginY:$e,id:null,ideographic:$e,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:$e,k:$e,k1:$e,k2:$e,k3:$e,k4:$e,kernelMatrix:qr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:$e,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:$e,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:$e,overlineThickness:$e,paintOrder:null,panose1:null,path:null,pathLength:$e,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:on,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:$e,pointsAtY:$e,pointsAtZ:$e,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:qr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:qr,rev:qr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:qr,requiredFeatures:qr,requiredFonts:qr,requiredFormats:qr,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:$e,specularExponent:$e,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:$e,strikethroughThickness:$e,string:null,stroke:null,strokeDashArray:qr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:$e,strokeOpacity:$e,strokeWidth:null,style:null,surfaceScale:$e,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:qr,tabIndex:$e,tableValues:null,target:null,targetX:$e,targetY:$e,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:qr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:$e,underlineThickness:$e,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:$e,values:null,vAlphabetic:$e,vMathematical:$e,vectorEffect:null,vHanging:$e,vIdeographic:$e,version:null,vertAdvY:$e,vertOriginX:$e,vertOriginY:$e,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:$e,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:yA}),EA=Cc({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),TA=Cc({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:vA}),SA=Cc({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),KX={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},WX=/[A-Z]/g,BC=/-[a-z]/g,XX=/^data[-\w.:]+$/i;function jm(e,t){const n=wd(t);let r=t,s=Pr;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&XX.test(t)){if(t.charAt(4)==="-"){const a=t.slice(5).replace(BC,ZX);r="data"+a.charAt(0).toUpperCase()+a.slice(1)}else{const a=t.slice(4);if(!BC.test(a)){let l=a.replace(WX,QX);l.charAt(0)!=="-"&&(l="-"+l),t="data"+l}}s=P2}return new s(r,t)}function QX(e){return"-"+e.toLowerCase()}function ZX(e){return e.charAt(1).toUpperCase()}const Ud=bA([xA,YX,EA,TA,SA],"html"),Pa=bA([xA,GX,EA,TA,SA],"svg");function zC(e){const t=[],n=String(e||"");let r=n.indexOf(","),s=0,a=!1;for(;!a;){r===-1&&(r=n.length,a=!0);const l=n.slice(s,r).trim();(l||!a)&&t.push(l),s=r+1,r=n.indexOf(",",s)}return t}function kA(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const HC=/[#.]/g;function JX(e,t){const n=e||"",r={};let s=0,a,l;for(;s<n.length;){HC.lastIndex=s;const c=HC.exec(n),u=n.slice(s,c?c.index:n.length);u&&(a?a==="#"?r.id=u:Array.isArray(r.className)?r.className.push(u):r.className=[u]:l=u,s+=u.length),c&&(a=c[0],s++)}return{type:"element",tagName:l||t||"div",properties:r,children:[]}}function UC(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function CA(e){return e.join(" ").trim()}function wA(e,t,n){const r=n?rQ(n):void 0;function s(a,l,...c){let u;if(a==null){u={type:"root",children:[]};const h=l;c.unshift(h)}else{u=JX(a,t);const h=u.tagName.toLowerCase(),m=r?r.get(h):void 0;if(u.tagName=m||h,eQ(l))c.unshift(l);else for(const[p,b]of Object.entries(l))tQ(e,u.properties,p,b)}for(const h of c)Sx(u.children,h);return u.type==="element"&&u.tagName==="template"&&(u.content={type:"root",children:u.children},u.children=[]),u}return s}function eQ(e){if(e===null||typeof e!="object"||Array.isArray(e))return!0;if(typeof e.type!="string")return!1;const t=e,n=Object.keys(e);for(const r of n){const s=t[r];if(s&&typeof s=="object"){if(!Array.isArray(s))return!0;const a=s;for(const l of a)if(typeof l!="number"&&typeof l!="string")return!0}}return!!("children"in e&&Array.isArray(e.children))}function tQ(e,t,n,r){const s=jm(e,n);let a;if(r!=null){if(typeof r=="number"){if(Number.isNaN(r))return;a=r}else typeof r=="boolean"?a=r:typeof r=="string"?s.spaceSeparated?a=UC(r):s.commaSeparated?a=zC(r):s.commaOrSpaceSeparated?a=UC(zC(r).join(" ")):a=FC(s,s.property,r):Array.isArray(r)?a=[...r]:a=s.property==="style"?nQ(r):String(r);if(Array.isArray(a)){const l=[];for(const c of a)l.push(FC(s,s.property,c));a=l}s.property==="className"&&Array.isArray(t.className)&&(a=t.className.concat(a)),t[s.property]=a}}function Sx(e,t){if(t!=null)if(typeof t=="number"||typeof t=="string")e.push({type:"text",value:String(t)});else if(Array.isArray(t))for(const n of t)Sx(e,n);else if(typeof t=="object"&&"type"in t)t.type==="root"?Sx(e,t.children):e.push(t);else throw new Error("Expected node, nodes, or string, got `"+t+"`")}function FC(e,t,n){if(typeof n=="string"){if(e.number&&n&&!Number.isNaN(Number(n)))return Number(n);if((e.boolean||e.overloadedBoolean)&&(n===""||wd(n)===wd(t)))return!0}return n}function nQ(e){const t=[];for(const[n,r]of Object.entries(e))t.push([n,r].join(": "));return t.join("; ")}function rQ(e){const t=new Map;for(const n of e)t.set(n.toLowerCase(),n);return t}const sQ=["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","solidColor","textArea","textPath"],iQ=wA(Ud,"div"),aQ=wA(Pa,"g",sQ);function oQ(e){const t=String(e),n=[];return{toOffset:s,toPoint:r};function r(a){if(typeof a=="number"&&a>-1&&a<=t.length){let l=0;for(;;){let c=n[l];if(c===void 0){const u=$C(t,n[l-1]);c=u===-1?t.length+1:u+1,n[l]=c}if(c>a)return{line:l+1,column:a-(l>0?n[l-1]:0)+1,offset:a};l++}}}function s(a){if(a&&typeof a.line=="number"&&typeof a.column=="number"&&!Number.isNaN(a.line)&&!Number.isNaN(a.column)){for(;n.length<a.line;){const c=n[n.length-1],u=$C(t,c),h=u===-1?t.length+1:u+1;if(c===h)break;n.push(h)}const l=(a.line>1?n[a.line-2]:0)+a.column-1;if(l<n[a.line-1])return l}}}function $C(e,t){const n=e.indexOf("\r",t),r=e.indexOf(`
|
|
1057
1057
|
`,t);return r===-1?n:n===-1||n+1===r?r:n<r?n:r}const To={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"},NA={}.hasOwnProperty,lQ=Object.prototype;function cQ(e,t){const n=t||{};return B2({file:n.file||void 0,location:!1,schema:n.space==="svg"?Pa:Ud,verbose:n.verbose||!1},e)}function B2(e,t){let n;switch(t.nodeName){case"#comment":{const r=t;return n={type:"comment",value:r.data},sp(e,r,n),n}case"#document":case"#document-fragment":{const r=t,s="mode"in r?r.mode==="quirks"||r.mode==="limited-quirks":!1;if(n={type:"root",children:_A(e,t.childNodes),data:{quirksMode:s}},e.file&&e.location){const a=String(e.file),l=oQ(a),c=l.toPoint(0),u=l.toPoint(a.length);n.position={start:c,end:u}}return n}case"#documentType":{const r=t;return n={type:"doctype"},sp(e,r,n),n}case"#text":{const r=t;return n={type:"text",value:r.value},sp(e,r,n),n}default:return n=uQ(e,t),n}}function _A(e,t){let n=-1;const r=[];for(;++n<t.length;){const s=B2(e,t[n]);r.push(s)}return r}function uQ(e,t){const n=e.schema;e.schema=t.namespaceURI===To.svg?Pa:Ud;let r=-1;const s={};for(;++r<t.attrs.length;){const c=t.attrs[r],u=(c.prefix?c.prefix+":":"")+c.name;NA.call(lQ,u)||(s[u]=c.value)}const l=(e.schema.space==="svg"?aQ:iQ)(t.tagName,s,_A(e,t.childNodes));if(sp(e,t,l),l.tagName==="template"){const c=t,u=c.sourceCodeLocation,h=u&&u.startTag&&Gl(u.startTag),m=u&&u.endTag&&Gl(u.endTag),p=B2(e,c.content);h&&m&&e.file&&(p.position={start:h.end,end:m.start}),l.content=p}return e.schema=n,l}function sp(e,t,n){if("sourceCodeLocation"in t&&t.sourceCodeLocation&&e.file){const r=dQ(e,n,t.sourceCodeLocation);r&&(e.location=!0,n.position=r)}}function dQ(e,t,n){const r=Gl(n);if(t.type==="element"){const s=t.children[t.children.length-1];if(r&&!n.endTag&&s&&s.position&&s.position.end&&(r.end=Object.assign({},s.position.end)),e.verbose){const a={};let l;if(n.attrs)for(l in n.attrs)NA.call(n.attrs,l)&&(a[jm(e.schema,l).property]=Gl(n.attrs[l]));n.startTag;const c=Gl(n.startTag),u=n.endTag?Gl(n.endTag):void 0,h={opening:c};u&&(h.closing=u),h.properties=a,t.data={position:h}}}return r}function Gl(e){const t=VC({line:e.startLine,column:e.startCol,offset:e.startOffset}),n=VC({line:e.endLine,column:e.endCol,offset:e.endOffset});return t||n?{start:t,end:n}:void 0}function VC(e){return e.line&&e.column?e:void 0}const qC={}.hasOwnProperty;function AA(e,t){const n=t||{};function r(s,...a){let l=r.invalid;const c=r.handlers;if(s&&qC.call(s,e)){const u=String(s[e]);l=qC.call(c,u)?c[u]:r.unknown}if(l)return l.call(this,s,...a)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}const fQ={},hQ={}.hasOwnProperty,RA=AA("type",{handlers:{root:mQ,element:vQ,text:xQ,comment:yQ,doctype:bQ}});function pQ(e,t){const r=(t||fQ).space;return RA(e,r==="svg"?Pa:Ud)}function mQ(e,t){const n={nodeName:"#document",mode:(e.data||{}).quirksMode?"quirks":"no-quirks",childNodes:[]};return n.childNodes=z2(e.children,n,t),wc(e,n),n}function gQ(e,t){const n={nodeName:"#document-fragment",childNodes:[]};return n.childNodes=z2(e.children,n,t),wc(e,n),n}function bQ(e){const t={nodeName:"#documentType",name:"html",publicId:"",systemId:"",parentNode:null};return wc(e,t),t}function xQ(e){const t={nodeName:"#text",value:e.value,parentNode:null};return wc(e,t),t}function yQ(e){const t={nodeName:"#comment",data:e.value,parentNode:null};return wc(e,t),t}function vQ(e,t){const n=t;let r=n;e.type==="element"&&e.tagName.toLowerCase()==="svg"&&n.space==="html"&&(r=Pa);const s=[];let a;if(e.properties){for(a in e.properties)if(a!=="children"&&hQ.call(e.properties,a)){const u=EQ(r,a,e.properties[a]);u&&s.push(u)}}const l=r.space,c={nodeName:e.tagName,tagName:e.tagName,attrs:s,namespaceURI:To[l],childNodes:[],parentNode:null};return c.childNodes=z2(e.children,c,r),wc(e,c),e.tagName==="template"&&e.content&&(c.content=gQ(e.content,r)),c}function EQ(e,t,n){const r=jm(e,t);if(n===!1||n===null||n===void 0||typeof n=="number"&&Number.isNaN(n)||!n&&r.boolean)return;Array.isArray(n)&&(n=r.commaSeparated?kA(n):CA(n));const s={name:r.attribute,value:n===!0?"":String(n)};if(r.space&&r.space!=="html"&&r.space!=="svg"){const a=s.name.indexOf(":");a<0?s.prefix="":(s.name=s.name.slice(a+1),s.prefix=r.attribute.slice(0,a)),s.namespace=To[r.space]}return s}function z2(e,t,n){let r=-1;const s=[];if(e)for(;++r<e.length;){const a=RA(e[r],n);a.parentNode=t,s.push(a)}return s}function wc(e,t){const n=e.position;n&&n.start&&n.end&&(n.start.offset,n.end.offset,t.sourceCodeLocation={startLine:n.start.line,startCol:n.start.column,startOffset:n.start.offset,endLine:n.end.line,endCol:n.end.column,endOffset:n.end.offset})}const TQ=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"],SQ=new Set([65534,65535,131070,131071,196606,196607,262142,262143,327678,327679,393214,393215,458750,458751,524286,524287,589822,589823,655358,655359,720894,720895,786430,786431,851966,851967,917502,917503,983038,983039,1048574,1048575,1114110,1114111]),yn="�";var X;(function(e){e[e.EOF=-1]="EOF",e[e.NULL=0]="NULL",e[e.TABULATION=9]="TABULATION",e[e.CARRIAGE_RETURN=13]="CARRIAGE_RETURN",e[e.LINE_FEED=10]="LINE_FEED",e[e.FORM_FEED=12]="FORM_FEED",e[e.SPACE=32]="SPACE",e[e.EXCLAMATION_MARK=33]="EXCLAMATION_MARK",e[e.QUOTATION_MARK=34]="QUOTATION_MARK",e[e.AMPERSAND=38]="AMPERSAND",e[e.APOSTROPHE=39]="APOSTROPHE",e[e.HYPHEN_MINUS=45]="HYPHEN_MINUS",e[e.SOLIDUS=47]="SOLIDUS",e[e.DIGIT_0=48]="DIGIT_0",e[e.DIGIT_9=57]="DIGIT_9",e[e.SEMICOLON=59]="SEMICOLON",e[e.LESS_THAN_SIGN=60]="LESS_THAN_SIGN",e[e.EQUALS_SIGN=61]="EQUALS_SIGN",e[e.GREATER_THAN_SIGN=62]="GREATER_THAN_SIGN",e[e.QUESTION_MARK=63]="QUESTION_MARK",e[e.LATIN_CAPITAL_A=65]="LATIN_CAPITAL_A",e[e.LATIN_CAPITAL_Z=90]="LATIN_CAPITAL_Z",e[e.RIGHT_SQUARE_BRACKET=93]="RIGHT_SQUARE_BRACKET",e[e.GRAVE_ACCENT=96]="GRAVE_ACCENT",e[e.LATIN_SMALL_A=97]="LATIN_SMALL_A",e[e.LATIN_SMALL_Z=122]="LATIN_SMALL_Z"})(X||(X={}));const Ar={DASH_DASH:"--",CDATA_START:"[CDATA[",DOCTYPE:"doctype",SCRIPT:"script",PUBLIC:"public",SYSTEM:"system"};function MA(e){return e>=55296&&e<=57343}function kQ(e){return e>=56320&&e<=57343}function CQ(e,t){return(e-55296)*1024+9216+t}function IA(e){return e!==32&&e!==10&&e!==13&&e!==9&&e!==12&&e>=1&&e<=31||e>=127&&e<=159}function OA(e){return e>=64976&&e<=65007||SQ.has(e)}var Ne;(function(e){e.controlCharacterInInputStream="control-character-in-input-stream",e.noncharacterInInputStream="noncharacter-in-input-stream",e.surrogateInInputStream="surrogate-in-input-stream",e.nonVoidHtmlElementStartTagWithTrailingSolidus="non-void-html-element-start-tag-with-trailing-solidus",e.endTagWithAttributes="end-tag-with-attributes",e.endTagWithTrailingSolidus="end-tag-with-trailing-solidus",e.unexpectedSolidusInTag="unexpected-solidus-in-tag",e.unexpectedNullCharacter="unexpected-null-character",e.unexpectedQuestionMarkInsteadOfTagName="unexpected-question-mark-instead-of-tag-name",e.invalidFirstCharacterOfTagName="invalid-first-character-of-tag-name",e.unexpectedEqualsSignBeforeAttributeName="unexpected-equals-sign-before-attribute-name",e.missingEndTagName="missing-end-tag-name",e.unexpectedCharacterInAttributeName="unexpected-character-in-attribute-name",e.unknownNamedCharacterReference="unknown-named-character-reference",e.missingSemicolonAfterCharacterReference="missing-semicolon-after-character-reference",e.unexpectedCharacterAfterDoctypeSystemIdentifier="unexpected-character-after-doctype-system-identifier",e.unexpectedCharacterInUnquotedAttributeValue="unexpected-character-in-unquoted-attribute-value",e.eofBeforeTagName="eof-before-tag-name",e.eofInTag="eof-in-tag",e.missingAttributeValue="missing-attribute-value",e.missingWhitespaceBetweenAttributes="missing-whitespace-between-attributes",e.missingWhitespaceAfterDoctypePublicKeyword="missing-whitespace-after-doctype-public-keyword",e.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers="missing-whitespace-between-doctype-public-and-system-identifiers",e.missingWhitespaceAfterDoctypeSystemKeyword="missing-whitespace-after-doctype-system-keyword",e.missingQuoteBeforeDoctypePublicIdentifier="missing-quote-before-doctype-public-identifier",e.missingQuoteBeforeDoctypeSystemIdentifier="missing-quote-before-doctype-system-identifier",e.missingDoctypePublicIdentifier="missing-doctype-public-identifier",e.missingDoctypeSystemIdentifier="missing-doctype-system-identifier",e.abruptDoctypePublicIdentifier="abrupt-doctype-public-identifier",e.abruptDoctypeSystemIdentifier="abrupt-doctype-system-identifier",e.cdataInHtmlContent="cdata-in-html-content",e.incorrectlyOpenedComment="incorrectly-opened-comment",e.eofInScriptHtmlCommentLikeText="eof-in-script-html-comment-like-text",e.eofInDoctype="eof-in-doctype",e.nestedComment="nested-comment",e.abruptClosingOfEmptyComment="abrupt-closing-of-empty-comment",e.eofInComment="eof-in-comment",e.incorrectlyClosedComment="incorrectly-closed-comment",e.eofInCdata="eof-in-cdata",e.absenceOfDigitsInNumericCharacterReference="absence-of-digits-in-numeric-character-reference",e.nullCharacterReference="null-character-reference",e.surrogateCharacterReference="surrogate-character-reference",e.characterReferenceOutsideUnicodeRange="character-reference-outside-unicode-range",e.controlCharacterReference="control-character-reference",e.noncharacterCharacterReference="noncharacter-character-reference",e.missingWhitespaceBeforeDoctypeName="missing-whitespace-before-doctype-name",e.missingDoctypeName="missing-doctype-name",e.invalidCharacterSequenceAfterDoctypeName="invalid-character-sequence-after-doctype-name",e.duplicateAttribute="duplicate-attribute",e.nonConformingDoctype="non-conforming-doctype",e.missingDoctype="missing-doctype",e.misplacedDoctype="misplaced-doctype",e.endTagWithoutMatchingOpenElement="end-tag-without-matching-open-element",e.closingOfElementWithOpenChildElements="closing-of-element-with-open-child-elements",e.disallowedContentInNoscriptInHead="disallowed-content-in-noscript-in-head",e.openElementsLeftAfterEof="open-elements-left-after-eof",e.abandonedHeadElementChild="abandoned-head-element-child",e.misplacedStartTagForHeadElement="misplaced-start-tag-for-head-element",e.nestedNoscriptInHead="nested-noscript-in-head",e.eofInElementThatCanContainOnlyText="eof-in-element-that-can-contain-only-text"})(Ne||(Ne={}));const wQ=65536;class NQ{constructor(t){this.handler=t,this.html="",this.pos=-1,this.lastGapPos=-2,this.gapStack=[],this.skipNextNewLine=!1,this.lastChunkWritten=!1,this.endOfChunkHit=!1,this.bufferWaterline=wQ,this.isEol=!1,this.lineStartPos=0,this.droppedBufferSize=0,this.line=1,this.lastErrOffset=-1}get col(){return this.pos-this.lineStartPos+ +(this.lastGapPos!==this.pos)}get offset(){return this.droppedBufferSize+this.pos}getError(t,n){const{line:r,col:s,offset:a}=this,l=s+n,c=a+n;return{code:t,startLine:r,endLine:r,startCol:l,endCol:l,startOffset:c,endOffset:c}}_err(t){this.handler.onParseError&&this.lastErrOffset!==this.offset&&(this.lastErrOffset=this.offset,this.handler.onParseError(this.getError(t,0)))}_addGap(){this.gapStack.push(this.lastGapPos),this.lastGapPos=this.pos}_processSurrogate(t){if(this.pos!==this.html.length-1){const n=this.html.charCodeAt(this.pos+1);if(kQ(n))return this.pos++,this._addGap(),CQ(t,n)}else if(!this.lastChunkWritten)return this.endOfChunkHit=!0,X.EOF;return this._err(Ne.surrogateInInputStream),t}willDropParsedChunk(){return this.pos>this.bufferWaterline}dropParsedChunk(){this.willDropParsedChunk()&&(this.html=this.html.substring(this.pos),this.lineStartPos-=this.pos,this.droppedBufferSize+=this.pos,this.pos=0,this.lastGapPos=-2,this.gapStack.length=0)}write(t,n){this.html.length>0?this.html+=t:this.html=t,this.endOfChunkHit=!1,this.lastChunkWritten=n}insertHtmlAtCurrentPos(t){this.html=this.html.substring(0,this.pos+1)+t+this.html.substring(this.pos+1),this.endOfChunkHit=!1}startsWith(t,n){if(this.pos+t.length>this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,!1;if(n)return this.html.startsWith(t,this.pos);for(let r=0;r<t.length;r++)if((this.html.charCodeAt(this.pos+r)|32)!==t.charCodeAt(r))return!1;return!0}peek(t){const n=this.pos+t;if(n>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,X.EOF;const r=this.html.charCodeAt(n);return r===X.CARRIAGE_RETURN?X.LINE_FEED:r}advance(){if(this.pos++,this.isEol&&(this.isEol=!1,this.line++,this.lineStartPos=this.pos),this.pos>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,X.EOF;let t=this.html.charCodeAt(this.pos);return t===X.CARRIAGE_RETURN?(this.isEol=!0,this.skipNextNewLine=!0,X.LINE_FEED):t===X.LINE_FEED&&(this.isEol=!0,this.skipNextNewLine)?(this.line--,this.skipNextNewLine=!1,this._addGap(),this.advance()):(this.skipNextNewLine=!1,MA(t)&&(t=this._processSurrogate(t)),this.handler.onParseError===null||t>31&&t<127||t===X.LINE_FEED||t===X.CARRIAGE_RETURN||t>159&&t<64976||this._checkForProblematicCharacters(t),t)}_checkForProblematicCharacters(t){IA(t)?this._err(Ne.controlCharacterInInputStream):OA(t)&&this._err(Ne.noncharacterInInputStream)}retreat(t){for(this.pos-=t;this.pos<this.lastGapPos;)this.lastGapPos=this.gapStack.pop(),this.pos--;this.isEol=!1}}var At;(function(e){e[e.CHARACTER=0]="CHARACTER",e[e.NULL_CHARACTER=1]="NULL_CHARACTER",e[e.WHITESPACE_CHARACTER=2]="WHITESPACE_CHARACTER",e[e.START_TAG=3]="START_TAG",e[e.END_TAG=4]="END_TAG",e[e.COMMENT=5]="COMMENT",e[e.DOCTYPE=6]="DOCTYPE",e[e.EOF=7]="EOF",e[e.HIBERNATION=8]="HIBERNATION"})(At||(At={}));function LA(e,t){for(let n=e.attrs.length-1;n>=0;n--)if(e.attrs[n].name===t)return e.attrs[n].value;return null}const _Q=new Uint16Array('ᵁ<Õıʊҝջאٵ۞ޢߖࠏઑඡ༉༦ረዡᐕᒝᓃᓟᔥ\0\0\0\0\0\0ᕫᛍᦍᰒᷝ↰⊍⏀⏻⑂⠤⤒ⴈ⹈⿎〖㊺㘹㞬㣾㨨㩱㫠㬮ࠀEMabcfglmnoprstu\\bfms¦³¹ÈÏlig耻Æ䃆P耻&䀦cute耻Á䃁reve;䄂Āiyx}rc耻Â䃂;䐐r;쀀𝔄rave耻À䃀pha;䎑acr;䄀d;橓Āgp¡on;䄄f;쀀𝔸plyFunction;恡ing耻Å䃅Ācs¾Ãr;쀀𝒜ign;扔ilde耻Ã䃃ml耻Ä䃄ЀaceforsuåûþėĜĢħĪĀcrêòkslash;或Ŷöø;櫧ed;挆y;䐑ƀcrtąċĔause;戵noullis;愬a;䎒r;쀀𝔅pf;쀀𝔹eve;䋘còēmpeq;扎܀HOacdefhilorsuōőŖƀƞƢƵƷƺǜȕɳɸɾcy;䐧PY耻©䂩ƀcpyŝŢźute;䄆Ā;iŧŨ拒talDifferentialD;慅leys;愭ȀaeioƉƎƔƘron;䄌dil耻Ç䃇rc;䄈nint;戰ot;䄊ĀdnƧƭilla;䂸terDot;䂷òſi;䎧rcleȀDMPTLJNjǑǖot;抙inus;抖lus;投imes;抗oĀcsǢǸkwiseContourIntegral;戲eCurlyĀDQȃȏoubleQuote;思uote;怙ȀlnpuȞȨɇɕonĀ;eȥȦ户;橴ƀgitȯȶȺruent;扡nt;戯ourIntegral;戮ĀfrɌɎ;愂oduct;成nterClockwiseContourIntegral;戳oss;樯cr;쀀𝒞pĀ;Cʄʅ拓ap;才րDJSZacefiosʠʬʰʴʸˋ˗ˡ˦̳ҍĀ;oŹʥtrahd;椑cy;䐂cy;䐅cy;䐏ƀgrsʿ˄ˇger;怡r;憡hv;櫤Āayː˕ron;䄎;䐔lĀ;t˝˞戇a;䎔r;쀀𝔇Āaf˫̧Ācm˰̢riticalȀADGT̖̜̀̆cute;䂴oŴ̋̍;䋙bleAcute;䋝rave;䁠ilde;䋜ond;拄ferentialD;慆Ѱ̽\0\0\0͔͂\0Ѕf;쀀𝔻ƀ;DE͈͉͍䂨ot;惜qual;扐blèCDLRUVͣͲϏϢϸontourIntegraìȹoɴ\0\0ͻ»͉nArrow;懓Āeo·ΤftƀARTΐΖΡrrow;懐ightArrow;懔eåˊngĀLRΫτeftĀARγιrrow;柸ightArrow;柺ightArrow;柹ightĀATϘϞrrow;懒ee;抨pɁϩ\0\0ϯrrow;懑ownArrow;懕erticalBar;戥ǹABLRTaВЪаўѿͼrrowƀ;BUНОТ憓ar;椓pArrow;懵reve;䌑eft˒к\0ц\0ѐightVector;楐eeVector;楞ectorĀ;Bљњ憽ar;楖ightǔѧ\0ѱeeVector;楟ectorĀ;BѺѻ懁ar;楗eeĀ;A҆҇护rrow;憧ĀctҒҗr;쀀𝒟rok;䄐ࠀNTacdfglmopqstuxҽӀӄӋӞӢӧӮӵԡԯԶՒ՝ՠեG;䅊H耻Ð䃐cute耻É䃉ƀaiyӒӗӜron;䄚rc耻Ê䃊;䐭ot;䄖r;쀀𝔈rave耻È䃈ement;戈ĀapӺӾcr;䄒tyɓԆ\0\0ԒmallSquare;旻erySmallSquare;斫ĀgpԦԪon;䄘f;쀀𝔼silon;䎕uĀaiԼՉlĀ;TՂՃ橵ilde;扂librium;懌Āci՚r;愰m;橳a;䎗ml耻Ë䃋Āipժկsts;戃onentialE;慇ʀcfiosօֈ֍ֲy;䐤r;쀀𝔉lledɓ֗\0\0֣mallSquare;旼erySmallSquare;斪Ͱֺ\0ֿ\0\0ׄf;쀀𝔽All;戀riertrf;愱còJTabcdfgorstרׯؒؖ؛؝أ٬ٲcy;䐃耻>䀾mmaĀ;d䎓;䏜reve;䄞ƀeiy؇،ؐdil;䄢rc;䄜;䐓ot;䄠r;쀀𝔊;拙pf;쀀𝔾eater̀EFGLSTصلَٖٛ٦qualĀ;Lؾؿ扥ess;招ullEqual;执reater;檢ess;扷lantEqual;橾ilde;扳cr;쀀𝒢;扫ЀAacfiosuڅڋږڛڞڪھۊRDcy;䐪Āctڐڔek;䋇;䁞irc;䄤r;愌lbertSpace;愋ǰگ\0ڲf;愍izontalLine;攀Āctۃۅòکrok;䄦mpńېۘownHumðįqual;扏܀EJOacdfgmnostuۺ۾܃܇ܚܞܡܨ݄ݸދޏޕcy;䐕lig;䄲cy;䐁cute耻Í䃍Āiyܓܘrc耻Î䃎;䐘ot;䄰r;愑rave耻Ì䃌ƀ;apܠܯܿĀcgܴܷr;䄪inaryI;慈lieóϝǴ݉\0ݢĀ;eݍݎ戬Āgrݓݘral;戫section;拂isibleĀCTݬݲomma;恣imes;恢ƀgptݿރވon;䄮f;쀀𝕀a;䎙cr;愐ilde;䄨ǫޚ\0ޞcy;䐆l耻Ï䃏ʀcfosuެ߂ߐĀiyޱrc;䄴;䐙r;쀀𝔍pf;쀀𝕁ǣ߇\0ߌr;쀀𝒥rcy;䐈kcy;䐄HJacfosߤߨ߽߬߱ࠂࠈcy;䐥cy;䐌ppa;䎚Āey߶dil;䄶;䐚r;쀀𝔎pf;쀀𝕂cr;쀀𝒦րJTaceflmostࠥࠩࠬࡐࡣসে্ੇcy;䐉耻<䀼ʀcmnpr࠷࠼ࡁࡄࡍute;䄹bda;䎛g;柪lacetrf;愒r;憞ƀaeyࡗࡡron;䄽dil;䄻;䐛Āfsࡨ॰tԀACDFRTUVarࡾࢩࢱࣦ࣠ࣼयज़ΐ४ĀnrࢃgleBracket;柨rowƀ;BR࢙࢚࢞憐ar;懤ightArrow;懆eiling;挈oǵࢷ\0ࣃbleBracket;柦nǔࣈ\0࣒eeVector;楡ectorĀ;Bࣛࣜ懃ar;楙loor;挊ightĀAV࣯ࣵrrow;憔ector;楎Āerँगeƀ;AVउऊऐ抣rrow;憤ector;楚iangleƀ;BEतथऩ抲ar;槏qual;抴pƀDTVषूौownVector;楑eeVector;楠ectorĀ;Bॖॗ憿ar;楘ectorĀ;B॥०憼ar;楒ightáΜs̀EFGLSTॾঋকঝঢভqualGreater;拚ullEqual;扦reater;扶ess;檡lantEqual;橽ilde;扲r;쀀𝔏Ā;eঽা拘ftarrow;懚idot;䄿ƀnpwਖਛgȀLRlr৷ਂਐeftĀAR০৬rrow;柵ightArrow;柷ightArrow;柶eftĀarγਊightáοightáϊf;쀀𝕃erĀLRਢਬeftArrow;憙ightArrow;憘ƀchtਾੀੂòࡌ;憰rok;䅁;扪Ѐacefiosuਗ਼અઋp;椅y;䐜Ādl੯iumSpace;恟lintrf;愳r;쀀𝔐nusPlus;戓pf;쀀𝕄cò੶;䎜ҀJacefostuણધભીଔଙඑඞcy;䐊cute;䅃ƀaeyહાron;䅇dil;䅅;䐝ƀgswે૰ativeƀMTV૨ediumSpace;怋hiĀcn૦ëeryThiîtedĀGLଆreaterGreateòٳessLesóੈLine;䀊r;쀀𝔑ȀBnptଢନଷreak;恠BreakingSpace;䂠f;愕ڀ;CDEGHLNPRSTV୕ୖ୪௫ఄ಄ದൡඅ櫬Āoungruent;扢pCap;扭oubleVerticalBar;戦ƀlqxஃஊement;戉ualĀ;Tஒஓ扠ilde;쀀≂̸ists;戄reater;EFGLSTஶஷ扯qual;扱ullEqual;쀀≧̸reater;쀀≫̸ess;批lantEqual;쀀⩾̸ilde;扵umpń௲ownHump;쀀≎̸qual;쀀≏̸eĀfsఊధtTriangleƀ;BEచఛడ拪ar;쀀⧏̸qual;括s̀;EGLSTవశ఼ౄోౘ扮qual;扰reater;扸ess;쀀≪̸lantEqual;쀀⩽̸ilde;扴estedĀGL౨౹reaterGreater;쀀⪢̸essLess;쀀⪡̸recedesƀ;ESಒಓಛ技qual;쀀⪯̸lantEqual;拠ĀeiಫಹverseElement;戌ghtTriangleƀ;BEೋೌ拫ar;쀀⧐̸qual;拭ĀquೝഌuareSuĀbp೨setĀ;Eೳ쀀⊏̸qual;拢ersetĀ;Eഃആ쀀⊐̸qual;拣ƀbcpഓതൎsetĀ;Eഛഞ쀀⊂⃒qual;抈ceedsȀ;ESTലള഻െ抁qual;쀀⪰̸lantEqual;拡ilde;쀀≿̸ersetĀ;E൘൛쀀⊃⃒qual;抉ildeȀ;EFT൮൯൵ൿ扁qual;扄ullEqual;扇ilde;扉erticalBar;戤cr;쀀𝒩ilde耻Ñ䃑;䎝܀Eacdfgmoprstuvලෂෛ෧ขภยา฿ไlig;䅒cute耻Ó䃓Āiyීrc耻Ô䃔;䐞blac;䅐r;쀀𝔒rave耻Ò䃒ƀaei෮ෲcr;䅌ga;䎩cron;䎟pf;쀀𝕆enCurlyĀDQฎบoubleQuote;怜uote;怘;橔Āclวฬr;쀀𝒪ash耻Ø䃘iŬืde耻Õ䃕es;樷ml耻Ö䃖erĀBP๋Āar๐๓r;怾acĀek๚;揞et;掴arenthesis;揜ҀacfhilorsງຊຏຒດຝະrtialD;戂y;䐟r;쀀𝔓i;䎦;䎠usMinus;䂱Āipຢອncareplanåڝf;愙Ȁ;eio຺ູ檻cedesȀ;EST່້扺qual;檯lantEqual;扼ilde;找me;怳Ādpuct;戏ortionĀ;aȥl;戝Āci༁༆r;쀀𝒫;䎨ȀUfos༑༖༛༟OT耻"䀢r;쀀𝔔pf;愚cr;쀀𝒬BEacefhiorsu༾གྷཇའཱིྦྷྪྭ႖ႩႴႾarr;椐G耻®䂮ƀcnrཎནབute;䅔g;柫rĀ;tཛྷཝ憠l;椖ƀaeyཧཬཱron;䅘dil;䅖;䐠Ā;vླྀཹ愜erseĀEUྂྙĀlq྇ྎement;戋uilibrium;懋pEquilibrium;楯r»ཹo;䎡ghtЀACDFTUVa࿁ဢဨၛႇϘĀnr࿆࿒gleBracket;柩rowƀ;BL憒ar;懥eftArrow;懄eiling;按oǵ\0စbleBracket;柧nǔည\0နeeVector;楝ectorĀ;Bဝသ懂ar;楕loor;挋Āerိ၃eƀ;AVဵံြ抢rrow;憦ector;楛iangleƀ;BEၐၑၕ抳ar;槐qual;抵pƀDTVၣၮၸownVector;楏eeVector;楜ectorĀ;Bႂႃ憾ar;楔ectorĀ;B႑႒懀ar;楓Āpuႛ႞f;愝ndImplies;楰ightarrow;懛ĀchႹႼr;愛;憱leDelayed;槴ڀHOacfhimoqstuფჱჷჽᄙᄞᅑᅖᅡᅧᆵᆻᆿĀCcჩხHcy;䐩y;䐨FTcy;䐬cute;䅚ʀ;aeiyᄈᄉᄎᄓᄗ檼ron;䅠dil;䅞rc;䅜;䐡r;쀀𝔖ortȀDLRUᄪᄴᄾᅉownArrow»ОeftArrow»࢚ightArrow»pArrow;憑gma;䎣allCircle;战pf;쀀𝕊ɲᅭ\0\0ᅰt;戚areȀ;ISUᅻᅼᆉᆯ斡ntersection;抓uĀbpᆏᆞsetĀ;Eᆗᆘ抏qual;抑ersetĀ;Eᆨᆩ抐qual;抒nion;抔cr;쀀𝒮ar;拆ȀbcmpᇈᇛሉላĀ;sᇍᇎ拐etĀ;Eᇍᇕqual;抆ĀchᇠህeedsȀ;ESTᇭᇮᇴᇿ扻qual;檰lantEqual;扽ilde;承Tháྌ;我ƀ;esሒሓሣ拑rsetĀ;Eሜም抃qual;抇et»ሓրHRSacfhiorsሾቄቕቱቶኟዂወዑORN耻Þ䃞ADE;愢ĀHcቒcy;䐋y;䐦Ābuቚቜ;䀉;䎤ƀaeyብቪቯron;䅤dil;䅢;䐢r;쀀𝔗ĀeiቻDzኀ\0ኇefore;戴a;䎘ĀcnኘkSpace;쀀 Space;怉ldeȀ;EFTካኬኲኼ戼qual;扃ullEqual;扅ilde;扈pf;쀀𝕋ipleDot;惛Āctዖዛr;쀀𝒯rok;䅦ૡዷጎጚጦ\0ጬጱ\0\0\0\0\0ጸጽ፷ᎅ\0ᐄᐊᐐĀcrዻጁute耻Ú䃚rĀ;oጇገ憟cir;楉rǣጓ\0y;䐎ve;䅬Āiyጞጣrc耻Û䃛;䐣blac;䅰r;쀀𝔘rave耻Ù䃙acr;䅪Ādiፁ፩erĀBPፈ፝Āarፍፐr;䁟acĀekፗፙ;揟et;掵arenthesis;揝onĀ;P፰፱拃lus;抎Āgp፻on;䅲f;쀀𝕌ЀADETadps᎕ᎮᎸᏄϨᏒᏗᏳrrowƀ;BDᅐᎠᎤar;椒ownArrow;懅ownArrow;憕quilibrium;楮eeĀ;AᏋᏌ报rrow;憥ownáϳerĀLRᏞᏨeftArrow;憖ightArrow;憗iĀ;lᏹᏺ䏒on;䎥ing;䅮cr;쀀𝒰ilde;䅨ml耻Ü䃜ҀDbcdefosvᐧᐬᐰᐳᐾᒅᒊᒐᒖash;披ar;櫫y;䐒ashĀ;lᐻᐼ抩;櫦Āerᑃᑅ;拁ƀbtyᑌᑐᑺar;怖Ā;iᑏᑕcalȀBLSTᑡᑥᑪᑴar;戣ine;䁼eparator;杘ilde;所ThinSpace;怊r;쀀𝔙pf;쀀𝕍cr;쀀𝒱dash;抪ʀcefosᒧᒬᒱᒶᒼirc;䅴dge;拀r;쀀𝔚pf;쀀𝕎cr;쀀𝒲Ȁfiosᓋᓐᓒᓘr;쀀𝔛;䎞pf;쀀𝕏cr;쀀𝒳ҀAIUacfosuᓱᓵᓹᓽᔄᔏᔔᔚᔠcy;䐯cy;䐇cy;䐮cute耻Ý䃝Āiyᔉᔍrc;䅶;䐫r;쀀𝔜pf;쀀𝕐cr;쀀𝒴ml;䅸ЀHacdefosᔵᔹᔿᕋᕏᕝᕠᕤcy;䐖cute;䅹Āayᕄᕉron;䅽;䐗ot;䅻Dzᕔ\0ᕛoWidtèa;䎖r;愨pf;愤cr;쀀𝒵ᖃᖊᖐ\0ᖰᖶᖿ\0\0\0\0ᗆᗛᗫᙟ᙭\0ᚕ᚛ᚲᚹ\0ᚾcute耻á䃡reve;䄃̀;Ediuyᖜᖝᖡᖣᖨᖭ戾;쀀∾̳;房rc耻â䃢te肻´̆;䐰lig耻æ䃦Ā;r²ᖺ;쀀𝔞rave耻à䃠ĀepᗊᗖĀfpᗏᗔsym;愵èᗓha;䎱ĀapᗟcĀclᗤᗧr;䄁g;樿ɤᗰ\0\0ᘊʀ;adsvᗺᗻᗿᘁᘇ戧nd;橕;橜lope;橘;橚;elmrszᘘᘙᘛᘞᘿᙏᙙ戠;榤e»ᘙsdĀ;aᘥᘦ戡ѡᘰᘲᘴᘶᘸᘺᘼᘾ;榨;榩;榪;榫;榬;榭;榮;榯tĀ;vᙅᙆ戟bĀ;dᙌᙍ抾;榝Āptᙔᙗh;戢»¹arr;捼Āgpᙣᙧon;䄅f;쀀𝕒;Eaeiopᙻᙽᚂᚄᚇᚊ;橰cir;橯;扊d;手s;䀧roxĀ;eᚒñᚃing耻å䃥ƀctyᚡᚦᚨr;쀀𝒶;䀪mpĀ;eᚯñʈilde耻ã䃣ml耻ä䃤Āciᛂᛈoninôɲnt;樑ࠀNabcdefiklnoprsu᛭ᛱᜰᝃᝈ០៦ᠹᡐᜍ᥈ᥰot;櫭ĀcrᛶkȀcepsᜀᜅᜍᜓong;扌psilon;䏶rime;怵imĀ;e戽q;拍Ŷᜢᜦee;抽edĀ;gᜬᜭ挅e»ᜭrkĀ;tbrk;掶Āoyᜁᝁ;䐱quo;怞ʀcmprtᝓᝡᝤᝨausĀ;eĊĉptyv;榰séᜌnoõēƀahwᝯᝳ;䎲;愶een;扬r;쀀𝔟gcostuvwឍឝឳេ៕៛ƀaiuបពរðݠrc;旯p»፱ƀdptឤឨឭot;樀lus;樁imes;樂ɱឹ\0\0ើcup;樆ar;昅riangleĀdu៍្own;施p;斳plus;樄eåᑄåᒭarow;植ƀakoᠦᠵĀcn៲ᠣkƀlst֫᠂ozenge;槫riangleȀ;dlr᠒᠓᠘斴own;斾eft;旂ight;斸k;搣Ʊᠫ\0ᠳƲᠯ\0ᠱ;斒;斑4;斓ck;斈ĀeoᠾᡍĀ;qᡃᡆ쀀=⃥uiv;쀀≡⃥t;挐Ȁptwxᡙᡞᡧᡬf;쀀𝕓Ā;tᏋᡣom»Ꮜtie;拈DHUVbdhmptuvᢅᢖᢪᢻᣗᣛᣬᤅᤊᤐᤡȀLRlrᢎᢐᢒᢔ;敗;敔;敖;敓ʀ;DUduᢡᢢᢤᢦᢨ敐;敦;敩;敤;敧ȀLRlrᢳᢵᢷᢹ;敝;敚;敜;教;HLRhlrᣊᣋᣍᣏᣑᣓᣕ救;敬;散;敠;敫;敢;敟ox;槉ȀLRlrᣤᣦᣨᣪ;敕;敒;攐;攌ʀ;DUduڽ;敥;敨;攬;攴inus;抟lus;択imes;抠ȀLRlrᤙᤛᤝ;敛;敘;攘;攔;HLRhlrᤰᤱᤳᤵᤷ᤻᤹攂;敪;敡;敞;攼;攤;攜Āevģbar耻¦䂦Ȁceioᥑᥖᥚᥠr;쀀𝒷mi;恏mĀ;elƀ;bhᥨᥩᥫ䁜;槅sub;柈ŬᥴlĀ;e怢t»pƀ;Eeįᦅᦇ;檮Ā;qۜۛೡᦧ\0᧨ᨑᨕᨲ\0ᨷᩐ\0\0᪴\0\0᫁\0\0ᬡᬮ᭒\0᯽\0ᰌƀcprᦲute;䄇̀;abcdsᦿᧀᧄ᧕᧙戩nd;橄rcup;橉Āau᧒p;橋p;橇ot;橀;쀀∩︀Āeo᧢᧥t;恁îړȀaeiu᧰᧻ᨁᨅǰ᧵\0᧸s;橍on;䄍dil耻ç䃧rc;䄉psĀ;sᨌᨍ橌m;橐ot;䄋ƀdmnᨛᨠᨦil肻¸ƭptyv;榲t脀¢;eᨭᨮ䂢räƲr;쀀𝔠ƀceiᨽᩀᩍy;䑇ckĀ;mᩇᩈ朓ark»ᩈ;䏇r;Ecefms᩠ᩢᩫ᪤᪪旋;槃ƀ;elᩩᩪᩭ䋆q;扗eɡᩴ\0\0᪈rrowĀlr᩼᪁eft;憺ight;憻ʀRSacd᪒᪔᪖»ཇ;擈st;抛irc;抚ash;抝nint;樐id;櫯cir;槂ubsĀ;u᪻᪼晣it»᪼ˬ᫇\0ᬊonĀ;eᫍᫎ䀺Ā;qÇÆɭ\0\0aĀ;t䀬;䁀ƀ;fl戁îᅠeĀmxent»eóɍǧ\0ᬇĀ;dኻᬂot;橭nôɆƀfryᬐᬔᬗ;쀀𝕔oäɔ脀©;sŕᬝr;愗Āaoᬥᬩrr;憵ss;朗Ācuᬲᬷr;쀀𝒸Ābpᬼ᭄Ā;eᭁᭂ櫏;櫑Ā;eᭉᭊ櫐;櫒dot;拯delprvw᭠᭬᭷ᮂᮬᯔarrĀlr᭨᭪;椸;椵ɰ᭲\0\0᭵r;拞c;拟arrĀ;pᮀ憶;椽̀;bcdosᮏᮐᮖᮡᮥᮨ截rcap;橈Āauᮛᮞp;橆p;橊ot;抍r;橅;쀀∪︀Ȁalrv᮵ᮿᯞᯣrrĀ;mᮼᮽ憷;椼yƀevwᯇᯔᯘqɰᯎ\0\0ᯒreã᭳uã᭵ee;拎edge;拏en耻¤䂤earrowĀlrᯮ᯳eft»ᮀight»ᮽeäᯝĀciᰁᰇoninôǷnt;戱lcty;挭ঀAHabcdefhijlorstuwz᰻᰿ᱝᱩᱵᲞᲬᲷᴍᵻᶑᶫᶻ᷆᷍ròar;楥Ȁglrs᱈ᱍ᱒᱔ger;怠eth;愸òᄳhĀ;vᱚᱛ怐»ऊūᱡᱧarow;椏aã̕Āayᱮᱳron;䄏;䐴ƀ;ao̲ᱼᲄĀgrʿᲁr;懊tseq;橷ƀglmᲑᲔᲘ耻°䂰ta;䎴ptyv;榱ĀirᲣᲨsht;楿;쀀𝔡arĀlrᲳᲵ»ࣜ»သʀaegsv᳂᳖᳜᳠mƀ;oș᳔ndĀ;ș᳑uit;晦amma;䏝in;拲ƀ;io᳧᳨᳸䃷de脀÷;o᳧ᳰntimes;拇nø᳷cy;䑒cɯᴆ\0\0ᴊrn;挞op;挍ʀlptuwᴘᴝᴢᵉᵕlar;䀤f;쀀𝕕ʀ;emps̋ᴭᴷᴽᵂqĀ;d͒ᴳot;扑inus;戸lus;戔quare;抡blebarwedgåúnƀadhᄮᵝᵧownarrowóᲃarpoonĀlrᵲᵶefôᲴighôᲶŢᵿᶅkaro÷གɯᶊ\0\0ᶎrn;挟op;挌ƀcotᶘᶣᶦĀryᶝᶡ;쀀𝒹;䑕l;槶rok;䄑Ādrᶰᶴot;拱iĀ;fᶺ᠖斿Āah᷀᷃ròЩaòྦangle;榦Āci᷒ᷕy;䑟grarr;柿ऀDacdefglmnopqrstuxḁḉḙḸոḼṉṡṾấắẽỡἪἷὄĀDoḆᴴoôĀcsḎḔute耻é䃩ter;橮ȀaioyḢḧḱḶron;䄛rĀ;cḭḮ扖耻ê䃪lon;払;䑍ot;䄗ĀDrṁṅot;扒;쀀𝔢ƀ;rsṐṑṗ檚ave耻è䃨Ā;dṜṝ檖ot;檘Ȁ;ilsṪṫṲṴ檙nters;揧;愓Ā;dṹṺ檕ot;檗ƀapsẅẉẗcr;䄓tyƀ;svẒẓẕ戅et»ẓpĀ1;ẝẤijạả;怄;怅怃ĀgsẪẬ;䅋p;怂ĀgpẴẸon;䄙f;쀀𝕖ƀalsỄỎỒrĀ;sỊị拕l;槣us;橱iƀ;lvỚớở䎵on»ớ;䏵ȀcsuvỪỳἋἣĀioữḱrc»Ḯɩỹ\0\0ỻíՈantĀglἂἆtr»ṝess»ṺƀaeiἒἚls;䀽st;扟vĀ;DȵἠD;橸parsl;槥ĀDaἯἳot;打rr;楱ƀcdiἾὁỸr;愯oô͒ĀahὉὋ;䎷耻ð䃰Āmrὓὗl耻ë䃫o;悬ƀcipὡὤὧl;䀡sôծĀeoὬὴctatioîՙnentialåչৡᾒ\0ᾞ\0ᾡᾧ\0\0ῆῌ\0ΐ\0ῦῪ \0 ⁚llingdotseñṄy;䑄male;晀ƀilrᾭᾳ῁lig;耀ffiɩᾹ\0\0᾽g;耀ffig;耀ffl;쀀𝔣lig;耀filig;쀀fjƀaltῙῡt;晭ig;耀flns;斱of;䆒ǰ΅\0ῳf;쀀𝕗ĀakֿῷĀ;vῼ´拔;櫙artint;樍Āao⁕Ācs‑⁒ႉ‸⁅⁈\0⁐β•‥‧\0耻½䂽;慓耻¼䂼;慕;慙;慛Ƴ‴\0‶;慔;慖ʴ‾⁁\0\0⁃耻¾䂾;慗;慜5;慘ƶ⁌\0⁎;慚;慝8;慞l;恄wn;挢cr;쀀𝒻ࢀEabcdefgijlnorstv₂₉₥₰₴⃰℃ℒℸ̗ℾ⅒↞Ā;lٍ₇;檌ƀcmpₐₕute;䇵maĀ;dₜ᳚䎳;檆reve;䄟Āiy₪₮rc;䄝;䐳ot;䄡Ȁ;lqsؾق₽ƀ;qsؾٌlanô٥Ȁ;cdl٥⃒⃥⃕c;檩otĀ;o⃜⃝檀Ā;l⃢⃣檂;檄Ā;e⃪⃭쀀⋛︀s;檔r;쀀𝔤Ā;gٳ؛mel;愷cy;䑓Ȁ;Eajٚℌℎℐ;檒;檥;檤ȀEaesℛℝ℩ℴ;扩pĀ;p℣ℤ檊rox»ℤĀ;q℮ℯ檈Ā;q℮ℛim;拧pf;쀀𝕘Āci⅃ⅆr;愊mƀ;el٫ⅎ⅐;檎;檐茀>;cdlqrⅠⅪⅮⅳⅹĀciⅥⅧ;檧r;橺ot;拗Par;榕uest;橼ʀadelsↄⅪ←ٖ↛ǰ↉\0proør;楸qĀlqؿ↖lesó₈ií٫Āen↣↭rtneqq;쀀≩︀Å↪ԀAabcefkosy⇄⇇⇱⇵⇺∘∝∯≨≽ròΠȀilmr⇐⇔⇗⇛rsðᒄf»․ilôکĀdr⇠⇤cy;䑊ƀ;cwࣴ⇫⇯ir;楈;憭ar;意irc;䄥ƀalr∁∎∓rtsĀ;u∉∊晥it»∊lip;怦con;抹r;쀀𝔥sĀew∣∩arow;椥arow;椦ʀamopr∺∾≃≞≣rr;懿tht;戻kĀlr≉≓eftarrow;憩ightarrow;憪f;쀀𝕙bar;怕ƀclt≯≴≸r;쀀𝒽asè⇴rok;䄧Ābp⊂⊇ull;恃hen»ᱛૡ⊣\0⊪\0⊸⋅⋎\0⋕⋳\0\0⋸⌢⍧⍢⍿\0⎆⎪⎴cute耻í䃭ƀ;iyݱ⊰⊵rc耻î䃮;䐸Ācx⊼⊿y;䐵cl耻¡䂡ĀfrΟ⋉;쀀𝔦rave耻ì䃬Ȁ;inoܾ⋝⋩⋮Āin⋢⋦nt;樌t;戭fin;槜ta;愩lig;䄳ƀaop⋾⌚⌝ƀcgt⌅⌈⌗r;䄫ƀelpܟ⌏⌓inåގarôܠh;䄱f;抷ed;䆵ʀ;cfotӴ⌬⌱⌽⍁are;愅inĀ;t⌸⌹戞ie;槝doô⌙ʀ;celpݗ⍌⍐⍛⍡al;抺Āgr⍕⍙eróᕣã⍍arhk;樗rod;樼Ȁcgpt⍯⍲⍶⍻y;䑑on;䄯f;쀀𝕚a;䎹uest耻¿䂿Āci⎊⎏r;쀀𝒾nʀ;EdsvӴ⎛⎝⎡ӳ;拹ot;拵Ā;v⎦⎧拴;拳Ā;iݷ⎮lde;䄩ǫ⎸\0⎼cy;䑖l耻ï䃯̀cfmosu⏌⏗⏜⏡⏧⏵Āiy⏑⏕rc;䄵;䐹r;쀀𝔧ath;䈷pf;쀀𝕛ǣ⏬\0⏱r;쀀𝒿rcy;䑘kcy;䑔Ѐacfghjos␋␖␢ppaĀ;v␓␔䎺;䏰Āey␛␠dil;䄷;䐺r;쀀𝔨reen;䄸cy;䑅cy;䑜pf;쀀𝕜cr;쀀𝓀ABEHabcdefghjlmnoprstuv⑰⒁⒆⒍⒑┎┽╚▀♎♞♥♹♽⚚⚲⛘❝❨➋⟀⠁⠒ƀart⑷⑺⑼ròòΕail;椛arr;椎Ā;gঔ⒋;檋ar;楢ॣ⒥\0⒪\0⒱\0\0\0\0\0⒵Ⓔ\0ⓆⓈⓍ\0⓹ute;䄺mptyv;榴raîࡌbda;䎻gƀ;dlࢎⓁⓃ;榑åࢎ;檅uo耻«䂫rЀ;bfhlpst࢙ⓞⓦⓩ⓫⓮⓱⓵Ā;f࢝ⓣs;椟s;椝ë≒p;憫l;椹im;楳l;憢ƀ;ae⓿─┄檫il;椙Ā;s┉┊檭;쀀⪭︀ƀabr┕┙┝rr;椌rk;杲Āak┢┬cĀek┨┪;䁻;䁛Āes┱┳;榋lĀdu┹┻;榏;榍Ȁaeuy╆╋╖╘ron;䄾Ādi═╔il;䄼ìࢰâ┩;䐻Ȁcqrs╣╦╭╽a;椶uoĀ;rนᝆĀdu╲╷har;楧shar;楋h;憲ʀ;fgqs▋▌উ◳◿扤tʀahlrt▘▤▷◂◨rrowĀ;t࢙□aé⓶arpoonĀdu▯▴own»њp»०eftarrows;懇ightƀahs◍◖◞rrowĀ;sࣴࢧarpoonóquigarro÷⇰hreetimes;拋ƀ;qs▋ও◺lanôবʀ;cdgsব☊☍☝☨c;檨otĀ;o☔☕橿Ā;r☚☛檁;檃Ā;e☢☥쀀⋚︀s;檓ʀadegs☳☹☽♉♋pproøⓆot;拖qĀgq♃♅ôউgtò⒌ôছiíলƀilr♕࣡♚sht;楼;쀀𝔩Ā;Eজ♣;檑š♩♶rĀdu▲♮Ā;l॥♳;楪lk;斄cy;䑙ʀ;achtੈ⚈⚋⚑⚖rò◁orneòᴈard;楫ri;旺Āio⚟⚤dot;䅀ustĀ;a⚬⚭掰che»⚭ȀEaes⚻⚽⛉⛔;扨pĀ;p⛃⛄檉rox»⛄Ā;q⛎⛏檇Ā;q⛎⚻im;拦Ѐabnoptwz⛩⛴⛷✚✯❁❇❐Ānr⛮⛱g;柬r;懽rëࣁgƀlmr⛿✍✔eftĀar০✇ightá৲apsto;柼ightá৽parrowĀlr✥✩efô⓭ight;憬ƀafl✶✹✽r;榅;쀀𝕝us;樭imes;樴š❋❏st;戗áፎƀ;ef❗❘᠀旊nge»❘arĀ;l❤❥䀨t;榓ʀachmt❳❶❼➅➇ròࢨorneòᶌarĀ;d➃;業;怎ri;抿̀achiqt➘➝ੀ➢➮➻quo;怹r;쀀𝓁mƀ;egল➪➬;檍;檏Ābu┪➳oĀ;rฟ➹;怚rok;䅂萀<;cdhilqrࠫ⟒☹⟜⟠⟥⟪⟰Āci⟗⟙;檦r;橹reå◲mes;拉arr;楶uest;橻ĀPi⟵⟹ar;榖ƀ;ef⠀भ旃rĀdu⠇⠍shar;楊har;楦Āen⠗⠡rtneqq;쀀≨︀Å⠞܀Dacdefhilnopsu⡀⡅⢂⢎⢓⢠⢥⢨⣚⣢⣤ઃ⣳⤂Dot;戺Ȁclpr⡎⡒⡣⡽r耻¯䂯Āet⡗⡙;時Ā;e⡞⡟朠se»⡟Ā;sျ⡨toȀ;dluျ⡳⡷⡻owîҌefôएðᏑker;斮Āoy⢇⢌mma;権;䐼ash;怔asuredangle»ᘦr;쀀𝔪o;愧ƀcdn⢯⢴⣉ro耻µ䂵Ȁ;acdᑤ⢽⣀⣄sôᚧir;櫰ot肻·Ƶusƀ;bd⣒ᤃ⣓戒Ā;uᴼ⣘;横ţ⣞⣡p;櫛ò−ðઁĀdp⣩⣮els;抧f;쀀𝕞Āct⣸⣽r;쀀𝓂pos»ᖝƀ;lm⤉⤊⤍䎼timap;抸ఀGLRVabcdefghijlmoprstuvw⥂⥓⥾⦉⦘⧚⧩⨕⨚⩘⩝⪃⪕⪤⪨⬄⬇⭄⭿⮮ⰴⱧⱼ⳩Āgt⥇⥋;쀀⋙̸Ā;v⥐쀀≫⃒ƀelt⥚⥲⥶ftĀar⥡⥧rrow;懍ightarrow;懎;쀀⋘̸Ā;v⥻ే쀀≪⃒ightarrow;懏ĀDd⦎⦓ash;抯ash;抮ʀbcnpt⦣⦧⦬⦱⧌la»˞ute;䅄g;쀀∠⃒ʀ;Eiop⦼⧀⧅⧈;쀀⩰̸d;쀀≋̸s;䅉roøurĀ;a⧓⧔普lĀ;s⧓ସdz⧟\0⧣p肻 ଷmpĀ;e௹ఀʀaeouy⧴⧾⨃⨐⨓ǰ⧹\0⧻;橃on;䅈dil;䅆ngĀ;dൾ⨊ot;쀀⩭̸p;橂;䐽ash;怓;Aadqsxஒ⨩⨭⨻⩁⩅⩐rr;懗rĀhr⨳⨶k;椤Ā;oᏲᏰot;쀀≐̸uiöୣĀei⩊⩎ar;椨íistĀ;sடr;쀀𝔫ȀEest⩦⩹⩼ƀ;qs⩭ƀ;qs⩴lanôií௪Ā;rஶ⪁»ஷƀAap⪊⪍⪑rò⥱rr;憮ar;櫲ƀ;svྍ⪜ྌĀ;d⪡⪢拼;拺cy;䑚AEadest⪷⪺⪾⫂⫅⫶⫹rò⥦;쀀≦̸rr;憚r;急Ȁ;fqs⫎⫣⫯tĀar⫔⫙rro÷⫁ightarro÷⪐ƀ;qs⪺⫪lanôౕĀ;sౕ⫴»శiíౝĀ;rవ⫾iĀ;eచథiäඐĀpt⬌⬑f;쀀𝕟膀¬;in⬙⬚⬶䂬nȀ;Edvஉ⬤⬨⬮;쀀⋹̸ot;쀀⋵̸ǡஉ⬳⬵;拷;拶iĀ;vಸ⬼ǡಸ⭁⭃;拾;拽ƀaor⭋⭣⭩rȀ;ast⭕⭚⭟lleìl;쀀⫽⃥;쀀∂̸lint;樔ƀ;ceಒ⭰⭳uåಥĀ;cಘ⭸Ā;eಒ⭽ñಘȀAait⮈⮋⮝⮧rò⦈rrƀ;cw⮔⮕⮙憛;쀀⤳̸;쀀↝̸ghtarrow»⮕riĀ;eೋೖchimpqu⮽⯍⯙⬄⯤⯯Ȁ;cerല⯆ഷ⯉uå;쀀𝓃ortɭ⬅\0\0⯖ará⭖mĀ;e൮⯟Ā;q൴൳suĀbp⯫⯭ååഋƀbcp⯶ⰑⰙȀ;Ees⯿ⰀഢⰄ抄;쀀⫅̸etĀ;eഛⰋqĀ;qണⰀcĀ;eലⰗñസȀ;EesⰢⰣൟⰧ抅;쀀⫆̸etĀ;e൘ⰮqĀ;qൠⰣȀgilrⰽⰿⱅⱇìௗlde耻ñ䃱çృiangleĀlrⱒⱜeftĀ;eచⱚñదightĀ;eೋⱥñĀ;mⱬⱭ䎽ƀ;esⱴⱵⱹ䀣ro;愖p;怇ҀDHadgilrsⲏⲔⲙⲞⲣⲰⲶⳓⳣash;抭arr;椄p;쀀≍⃒ash;抬ĀetⲨⲬ;쀀≥⃒;쀀>⃒nfin;槞ƀAetⲽⳁⳅrr;椂;쀀≤⃒Ā;rⳊⳍ쀀<⃒ie;쀀⊴⃒ĀAtⳘⳜrr;椃rie;쀀⊵⃒im;쀀∼⃒ƀAan⳰ⴂrr;懖rĀhr⳺⳽k;椣Ā;oᏧᏥear;椧ቓ᪕\0\0\0\0\0\0\0\0\0\0\0\0\0ⴭ\0ⴸⵈⵠⵥⶄᬇ\0\0ⶍⶫ\0ⷈⷎ\0ⷜ⸙⸫⸾⹃Ācsⴱ᪗ute耻ó䃳ĀiyⴼⵅrĀ;cⵂ耻ô䃴;䐾ʀabios᪠ⵒⵗLjⵚlac;䅑v;樸old;榼lig;䅓Ācrir;榿;쀀𝔬ͯ\0\0\0ⶂn;䋛ave耻ò䃲;槁Ābmⶈ෴ar;榵Ȁacitⶕⶥⶨrò᪀Āirⶠr;榾oss;榻nå๒;槀ƀaeiⶱⶵⶹcr;䅍ga;䏉ƀcdnⷀⷅǍron;䎿;榶pf;쀀𝕠ƀaelⷔǒr;榷rp;榹;adiosvⷪⷫⷮ⸈⸍⸐⸖戨rò᪆Ȁ;efmⷷⷸ⸂⸅橝rĀ;oⷾⷿ愴f»ⷿ耻ª䂪耻º䂺gof;抶r;橖lope;橗;橛ƀclo⸟⸡⸧ò⸁ash耻ø䃸l;折iŬⸯ⸴de耻õ䃵esĀ;aǛ⸺s;樶ml耻ö䃶bar;挽ૡ\0\0⺀⺝\0⺢⺹\0\0⻋ຜ\0⼓\0\0⼫⾼\0⿈rȀ;astЃ脀¶;l䂶leìЃɩ\0\0m;櫳;櫽y;䐿rʀcimpt⺋⺏⺓ᡥ⺗nt;䀥od;䀮il;怰enk;怱r;쀀𝔭ƀimo⺨⺰⺴Ā;v⺭⺮䏆;䏕maô੶ne;明ƀ;tv⺿⻀⻈䏀chfork»´;䏖Āau⻏⻟nĀck⻕⻝kĀ;h⇴⻛;愎ö⇴sҀ;abcdemst⻳ᤈ⼄⼆⼊⼎䀫cir;樣ir;樢Āouᵀ⼂;樥;橲n肻±ຝim;樦wo;樧ƀipu⼙⼠⼥ntint;樕f;쀀𝕡nd耻£䂣Ԁ;Eaceinosu່⼿⽁⽄⽇⾁⾉⾒⽾⾶;檳p;檷uå໙Ā;c໎⽌̀;acens່⽙⽟⽦⽨⽾pproø⽃urlyeñ໙ñ໎ƀaes⽯⽶⽺pprox;檹qq;檵im;拨iíໟmeĀ;s⾈ຮ怲ƀEas⽸⾐⽺ð⽵ƀdfp⾙⾯ƀals⾠⾥⾪lar;挮ine;挒urf;挓Ā;t⾴ïrel;抰Āci⿀⿅r;쀀𝓅;䏈ncsp;怈̀fiopsu⋢⿱r;쀀𝔮pf;쀀𝕢rime;恗cr;쀀𝓆ƀaeo⿸〉〓tĀei々rnionóڰnt;樖stĀ;e【】䀿ñἙô༔ABHabcdefhilmnoprstuxけさすムㄎㄫㅇㅢㅲㆎ㈆㈕㈤㈩㉘㉮㉲㊐㊰㊷ƀartぇおがròႳòϝail;検aròᱥar;楤cdenqrtとふへみわゔヌĀeuねぱ;쀀∽̱te;䅕iãᅮmptyv;榳gȀ;del࿑らるろ;榒;榥å࿑uo耻»䂻rր;abcfhlpstwガクシスゼゾダッデナp;極Ā;fゴs;椠;椳s;椞ë≝ð✮l;楅im;楴l;憣;憝Āaiパフil;椚oĀ;nホボ戶aló༞ƀabrョリヮrò៥rk;杳ĀakンヽcĀekヹ・;䁽;䁝Āes;榌lĀduㄊㄌ;榎;榐Ȁaeuyㄗㄜㄧㄩron;䅙Ādiㄡㄥil;䅗ìâヺ;䑀Ȁclqsㄴㄷㄽㅄa;椷dhar;楩uoĀ;rȎȍh;憳ƀacgㅎㅟངlȀ;ipsླྀㅘㅛႜnåႻarôྩt;断ƀilrㅩဣㅮsht;楽;쀀𝔯ĀaoㅷㆆrĀduㅽㅿ»ѻĀ;l႑ㆄ;楬Ā;vㆋㆌ䏁;䏱ƀgns㆕ㇹㇼht̀ahlrstㆤㆰ㇂㇘rrowĀ;tㆭaéトarpoonĀduㆻㆿowîㅾp»႒eftĀah㇊㇐rrowóarpoonóՑightarrows;應quigarro÷ニhreetimes;拌g;䋚ingdotseñἲƀahm㈍㈐㈓ròaòՑ;怏oustĀ;a㈞掱che»mid;櫮Ȁabpt㈲㈽㉀㉒Ānr㈷㈺g;柭r;懾rëဃƀafl㉇㉊㉎r;榆;쀀𝕣us;樮imes;樵Āap㉝㉧rĀ;g㉣㉤䀩t;榔olint;樒arò㇣Ȁachq㉻㊀Ⴜ㊅quo;怺r;쀀𝓇Ābu・㊊oĀ;rȔȓƀhir㊗㊛㊠reåㇸmes;拊iȀ;efl㊪ၙᠡ㊫方tri;槎luhar;楨;愞ൡ㋕㋛㋟㌬㌸㍱\0㍺㎤\0\0㏬㏰\0㐨㑈㑚㒭㒱㓊㓱\0㘖\0\0㘳cute;䅛quï➺Ԁ;Eaceinpsyᇭ㋳㋵㋿㌂㌋㌏㌟㌦㌩;檴ǰ㋺\0㋼;檸on;䅡uåᇾĀ;dᇳ㌇il;䅟rc;䅝ƀEas㌖㌘㌛;檶p;檺im;择olint;樓iíሄ;䑁otƀ;be㌴ᵇ㌵担;橦Aacmstx㍆㍊㍗㍛㍞㍣㍭rr;懘rĀhr㍐㍒ë∨Ā;oਸ਼t耻§䂧i;䀻war;椩mĀin㍩ðnuóñt;朶rĀ;o㍶⁕쀀𝔰Ȁacoy㎂㎆㎑㎠rp;景Āhy㎋㎏cy;䑉;䑈rtɭ㎙\0\0㎜iäᑤaraì耻䂭Āgm㎨㎴maƀ;fv㎱㎲㎲䏃;䏂Ѐ;deglnprካ㏅㏉㏎㏖㏞㏡㏦ot;橪Ā;qኰĀ;E㏓㏔檞;檠Ā;E㏛㏜檝;檟e;扆lus;樤arr;楲aròᄽȀaeit㏸㐈㐏㐗Āls㏽㐄lsetmé㍪hp;樳parsl;槤Ādlᑣ㐔e;挣Ā;e㐜㐝檪Ā;s㐢㐣檬;쀀⪬︀ƀflp㐮㐳㑂tcy;䑌Ā;b㐸㐹䀯Ā;a㐾㐿槄r;挿f;쀀𝕤aĀdr㑍ЂesĀ;u㑔㑕晠it»㑕ƀcsu㑠㑹㒟Āau㑥㑯pĀ;sᆈ㑫;쀀⊓︀pĀ;sᆴ㑵;쀀⊔︀uĀbp㑿㒏ƀ;esᆗᆜ㒆etĀ;eᆗ㒍ñᆝƀ;esᆨᆭ㒖etĀ;eᆨ㒝ñᆮƀ;afᅻ㒦ְrť㒫ֱ»ᅼaròᅈȀcemt㒹㒾㓂㓅r;쀀𝓈tmîñiì㐕aræᆾĀar㓎㓕rĀ;f㓔ឿ昆Āan㓚㓭ightĀep㓣㓪psiloîỠhé⺯s»⡒ʀbcmnp㓻㕞ሉ㖋㖎Ҁ;Edemnprs㔎㔏㔑㔕㔞㔣㔬㔱㔶抂;櫅ot;檽Ā;dᇚ㔚ot;櫃ult;櫁ĀEe㔨㔪;櫋;把lus;檿arr;楹ƀeiu㔽㕒㕕tƀ;en㔎㕅㕋qĀ;qᇚ㔏eqĀ;q㔫㔨m;櫇Ābp㕚㕜;櫕;櫓c̀;acensᇭ㕬㕲㕹㕻㌦pproø㋺urlyeñᇾñᇳƀaes㖂㖈㌛pproø㌚qñ㌗g;晪ڀ123;Edehlmnps㖩㖬㖯ሜ㖲㖴㗀㗉㗕㗚㗟㗨㗭耻¹䂹耻²䂲耻³䂳;櫆Āos㖹㖼t;檾ub;櫘Ā;dሢ㗅ot;櫄sĀou㗏㗒l;柉b;櫗arr;楻ult;櫂ĀEe㗤㗦;櫌;抋lus;櫀ƀeiu㗴㘉㘌tƀ;enሜ㗼㘂qĀ;qሢ㖲eqĀ;q㗧㗤m;櫈Ābp㘑㘓;櫔;櫖ƀAan㘜㘠㘭rr;懙rĀhr㘦㘨ë∮Ā;oਫwar;椪lig耻ß䃟㙑㙝㙠ዎ㙳㙹\0㙾㛂\0\0\0\0\0㛛㜃\0㜉㝬\0\0\0㞇ɲ㙖\0\0㙛get;挖;䏄rëƀaey㙦㙫㙰ron;䅥dil;䅣;䑂lrec;挕r;쀀𝔱Ȁeiko㚆㚝㚵㚼Dz㚋\0㚑eĀ4fኄኁaƀ;sv㚘㚙㚛䎸ym;䏑Ācn㚢㚲kĀas㚨㚮pproøim»ኬsðኞĀas㚺㚮ðrn耻þ䃾Ǭ̟㛆⋧es膀×;bd㛏㛐㛘䃗Ā;aᤏ㛕r;樱;樰ƀeps㛡㛣㜀á⩍Ȁ;bcf҆㛬㛰㛴ot;挶ir;櫱Ā;o㛹㛼쀀𝕥rk;櫚á㍢rime;怴ƀaip㜏㜒㝤dåቈadempst㜡㝍㝀㝑㝗㝜㝟ngleʀ;dlqr㜰㜱㜶㝀㝂斵own»ᶻeftĀ;e⠀㜾ñम;扜ightĀ;e㊪㝋ñၚot;旬inus;樺lus;樹b;槍ime;樻ezium;揢ƀcht㝲㝽㞁Āry㝷㝻;쀀𝓉;䑆cy;䑛rok;䅧Āio㞋㞎xôheadĀlr㞗㞠eftarro÷ࡏightarrow»ཝऀAHabcdfghlmoprstuw㟐㟓㟗㟤㟰㟼㠎㠜㠣㠴㡑㡝㡫㢩㣌㣒㣪㣶ròϭar;楣Ācr㟜㟢ute耻ú䃺òᅐrǣ㟪\0㟭y;䑞ve;䅭Āiy㟵㟺rc耻û䃻;䑃ƀabh㠃㠆㠋ròᎭlac;䅱aòᏃĀir㠓㠘sht;楾;쀀𝔲rave耻ù䃹š㠧㠱rĀlr㠬㠮»ॗ»ႃlk;斀Āct㠹㡍ɯ㠿\0\0㡊rnĀ;e㡅㡆挜r»㡆op;挏ri;旸Āal㡖㡚cr;䅫肻¨͉Āgp㡢㡦on;䅳f;쀀𝕦̀adhlsuᅋ㡸㡽፲㢑㢠ownáᎳarpoonĀlr㢈㢌efô㠭ighô㠯iƀ;hl㢙㢚㢜䏅»ᏺon»㢚parrows;懈ƀcit㢰㣄㣈ɯ㢶\0\0㣁rnĀ;e㢼㢽挝r»㢽op;挎ng;䅯ri;旹cr;쀀𝓊ƀdir㣙㣝㣢ot;拰lde;䅩iĀ;f㜰㣨»᠓Āam㣯㣲rò㢨l耻ü䃼angle;榧ހABDacdeflnoprsz㤜㤟㤩㤭㦵㦸㦽㧟㧤㧨㧳㧹㧽㨁㨠ròϷarĀ;v㤦㤧櫨;櫩asèϡĀnr㤲㤷grt;榜eknprst㓣㥆㥋㥒㥝㥤㦖appá␕othinçẖƀhir㓫⻈㥙opô⾵Ā;hᎷ㥢ïㆍĀiu㥩㥭gmá㎳Ābp㥲㦄setneqĀ;q㥽㦀쀀⊊︀;쀀⫋︀setneqĀ;q㦏㦒쀀⊋︀;쀀⫌︀Āhr㦛㦟etá㚜iangleĀlr㦪㦯eft»थight»ၑy;䐲ash»ံƀelr㧄㧒㧗ƀ;beⷪ㧋㧏ar;抻q;扚lip;拮Ābt㧜ᑨaòᑩr;쀀𝔳tré㦮suĀbp㧯㧱»ജ»൙pf;쀀𝕧roðtré㦴Ācu㨆㨋r;쀀𝓋Ābp㨐㨘nĀEe㦀㨖»㥾nĀEe㦒㨞»㦐igzag;榚cefoprs㨶㨻㩖㩛㩔㩡㩪irc;䅵Ādi㩀㩑Ābg㩅㩉ar;機eĀ;qᗺ㩏;扙erp;愘r;쀀𝔴pf;쀀𝕨Ā;eᑹ㩦atèᑹcr;쀀𝓌ૣណ㪇\0㪋\0㪐㪛\0\0㪝㪨㪫㪯\0\0㫃㫎\0㫘ៜtré៑r;쀀𝔵ĀAa㪔㪗ròσrò৶;䎾ĀAa㪡㪤ròθrò৫að✓is;拻ƀdptឤ㪵㪾Āfl㪺ឩ;쀀𝕩imåឲĀAa㫇㫊ròώròਁĀcq㫒ីr;쀀𝓍Āpt៖㫜ré។Ѐacefiosu㫰㫽㬈㬌㬑㬕㬛㬡cĀuy㫶㫻te耻ý䃽;䑏Āiy㬂㬆rc;䅷;䑋n耻¥䂥r;쀀𝔶cy;䑗pf;쀀𝕪cr;쀀𝓎Ācm㬦㬩y;䑎l耻ÿ䃿Ԁacdefhiosw㭂㭈㭔㭘㭤㭩㭭㭴㭺㮀cute;䅺Āay㭍㭒ron;䅾;䐷ot;䅼Āet㭝㭡træᕟa;䎶r;쀀𝔷cy;䐶grarr;懝pf;쀀𝕫cr;쀀𝓏Ājn㮅㮇;怍j;怌'.split("").map(e=>e.charCodeAt(0))),AQ=new Map([[0,65533],[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]);function RQ(e){var t;return e>=55296&&e<=57343||e>1114111?65533:(t=AQ.get(e))!==null&&t!==void 0?t:e}var Qn;(function(e){e[e.NUM=35]="NUM",e[e.SEMI=59]="SEMI",e[e.EQUALS=61]="EQUALS",e[e.ZERO=48]="ZERO",e[e.NINE=57]="NINE",e[e.LOWER_A=97]="LOWER_A",e[e.LOWER_F=102]="LOWER_F",e[e.LOWER_X=120]="LOWER_X",e[e.LOWER_Z=122]="LOWER_Z",e[e.UPPER_A=65]="UPPER_A",e[e.UPPER_F=70]="UPPER_F",e[e.UPPER_Z=90]="UPPER_Z"})(Qn||(Qn={}));const MQ=32;var ka;(function(e){e[e.VALUE_LENGTH=49152]="VALUE_LENGTH",e[e.BRANCH_LENGTH=16256]="BRANCH_LENGTH",e[e.JUMP_TABLE=127]="JUMP_TABLE"})(ka||(ka={}));function kx(e){return e>=Qn.ZERO&&e<=Qn.NINE}function IQ(e){return e>=Qn.UPPER_A&&e<=Qn.UPPER_F||e>=Qn.LOWER_A&&e<=Qn.LOWER_F}function OQ(e){return e>=Qn.UPPER_A&&e<=Qn.UPPER_Z||e>=Qn.LOWER_A&&e<=Qn.LOWER_Z||kx(e)}function LQ(e){return e===Qn.EQUALS||OQ(e)}var Gn;(function(e){e[e.EntityStart=0]="EntityStart",e[e.NumericStart=1]="NumericStart",e[e.NumericDecimal=2]="NumericDecimal",e[e.NumericHex=3]="NumericHex",e[e.NamedEntity=4]="NamedEntity"})(Gn||(Gn={}));var ki;(function(e){e[e.Legacy=0]="Legacy",e[e.Strict=1]="Strict",e[e.Attribute=2]="Attribute"})(ki||(ki={}));class jQ{constructor(t,n,r){this.decodeTree=t,this.emitCodePoint=n,this.errors=r,this.state=Gn.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=ki.Strict}startEntity(t){this.decodeMode=t,this.state=Gn.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1}write(t,n){switch(this.state){case Gn.EntityStart:return t.charCodeAt(n)===Qn.NUM?(this.state=Gn.NumericStart,this.consumed+=1,this.stateNumericStart(t,n+1)):(this.state=Gn.NamedEntity,this.stateNamedEntity(t,n));case Gn.NumericStart:return this.stateNumericStart(t,n);case Gn.NumericDecimal:return this.stateNumericDecimal(t,n);case Gn.NumericHex:return this.stateNumericHex(t,n);case Gn.NamedEntity:return this.stateNamedEntity(t,n)}}stateNumericStart(t,n){return n>=t.length?-1:(t.charCodeAt(n)|MQ)===Qn.LOWER_X?(this.state=Gn.NumericHex,this.consumed+=1,this.stateNumericHex(t,n+1)):(this.state=Gn.NumericDecimal,this.stateNumericDecimal(t,n))}addToNumericResult(t,n,r,s){if(n!==r){const a=r-n;this.result=this.result*Math.pow(s,a)+Number.parseInt(t.substr(n,a),s),this.consumed+=a}}stateNumericHex(t,n){const r=n;for(;n<t.length;){const s=t.charCodeAt(n);if(kx(s)||IQ(s))n+=1;else return this.addToNumericResult(t,r,n,16),this.emitNumericEntity(s,3)}return this.addToNumericResult(t,r,n,16),-1}stateNumericDecimal(t,n){const r=n;for(;n<t.length;){const s=t.charCodeAt(n);if(kx(s))n+=1;else return this.addToNumericResult(t,r,n,10),this.emitNumericEntity(s,2)}return this.addToNumericResult(t,r,n,10),-1}emitNumericEntity(t,n){var r;if(this.consumed<=n)return(r=this.errors)===null||r===void 0||r.absenceOfDigitsInNumericCharacterReference(this.consumed),0;if(t===Qn.SEMI)this.consumed+=1;else if(this.decodeMode===ki.Strict)return 0;return this.emitCodePoint(RQ(this.result),this.consumed),this.errors&&(t!==Qn.SEMI&&this.errors.missingSemicolonAfterCharacterReference(),this.errors.validateNumericCharacterReference(this.result)),this.consumed}stateNamedEntity(t,n){const{decodeTree:r}=this;let s=r[this.treeIndex],a=(s&ka.VALUE_LENGTH)>>14;for(;n<t.length;n++,this.excess++){const l=t.charCodeAt(n);if(this.treeIndex=DQ(r,s,this.treeIndex+Math.max(1,a),l),this.treeIndex<0)return this.result===0||this.decodeMode===ki.Attribute&&(a===0||LQ(l))?0:this.emitNotTerminatedNamedEntity();if(s=r[this.treeIndex],a=(s&ka.VALUE_LENGTH)>>14,a!==0){if(l===Qn.SEMI)return this.emitNamedEntityData(this.treeIndex,a,this.consumed+this.excess);this.decodeMode!==ki.Strict&&(this.result=this.treeIndex,this.consumed+=this.excess,this.excess=0)}}return-1}emitNotTerminatedNamedEntity(){var t;const{result:n,decodeTree:r}=this,s=(r[n]&ka.VALUE_LENGTH)>>14;return this.emitNamedEntityData(n,s,this.consumed),(t=this.errors)===null||t===void 0||t.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(t,n,r){const{decodeTree:s}=this;return this.emitCodePoint(n===1?s[t]&~ka.VALUE_LENGTH:s[t+1],r),n===3&&this.emitCodePoint(s[t+2],r),r}end(){var t;switch(this.state){case Gn.NamedEntity:return this.result!==0&&(this.decodeMode!==ki.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case Gn.NumericDecimal:return this.emitNumericEntity(0,2);case Gn.NumericHex:return this.emitNumericEntity(0,3);case Gn.NumericStart:return(t=this.errors)===null||t===void 0||t.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case Gn.EntityStart:return 0}}}function DQ(e,t,n,r){const s=(t&ka.BRANCH_LENGTH)>>7,a=t&ka.JUMP_TABLE;if(s===0)return a!==0&&r===a?n:-1;if(a){const u=r-a;return u<0||u>=s?-1:e[n+u]-1}let l=n,c=l+s-1;for(;l<=c;){const u=l+c>>>1,h=e[u];if(h<r)l=u+1;else if(h>r)c=u-1;else return e[u+s]}return-1}var je;(function(e){e.HTML="http://www.w3.org/1999/xhtml",e.MATHML="http://www.w3.org/1998/Math/MathML",e.SVG="http://www.w3.org/2000/svg",e.XLINK="http://www.w3.org/1999/xlink",e.XML="http://www.w3.org/XML/1998/namespace",e.XMLNS="http://www.w3.org/2000/xmlns/"})(je||(je={}));var No;(function(e){e.TYPE="type",e.ACTION="action",e.ENCODING="encoding",e.PROMPT="prompt",e.NAME="name",e.COLOR="color",e.FACE="face",e.SIZE="size"})(No||(No={}));var ds;(function(e){e.NO_QUIRKS="no-quirks",e.QUIRKS="quirks",e.LIMITED_QUIRKS="limited-quirks"})(ds||(ds={}));var be;(function(e){e.A="a",e.ADDRESS="address",e.ANNOTATION_XML="annotation-xml",e.APPLET="applet",e.AREA="area",e.ARTICLE="article",e.ASIDE="aside",e.B="b",e.BASE="base",e.BASEFONT="basefont",e.BGSOUND="bgsound",e.BIG="big",e.BLOCKQUOTE="blockquote",e.BODY="body",e.BR="br",e.BUTTON="button",e.CAPTION="caption",e.CENTER="center",e.CODE="code",e.COL="col",e.COLGROUP="colgroup",e.DD="dd",e.DESC="desc",e.DETAILS="details",e.DIALOG="dialog",e.DIR="dir",e.DIV="div",e.DL="dl",e.DT="dt",e.EM="em",e.EMBED="embed",e.FIELDSET="fieldset",e.FIGCAPTION="figcaption",e.FIGURE="figure",e.FONT="font",e.FOOTER="footer",e.FOREIGN_OBJECT="foreignObject",e.FORM="form",e.FRAME="frame",e.FRAMESET="frameset",e.H1="h1",e.H2="h2",e.H3="h3",e.H4="h4",e.H5="h5",e.H6="h6",e.HEAD="head",e.HEADER="header",e.HGROUP="hgroup",e.HR="hr",e.HTML="html",e.I="i",e.IMG="img",e.IMAGE="image",e.INPUT="input",e.IFRAME="iframe",e.KEYGEN="keygen",e.LABEL="label",e.LI="li",e.LINK="link",e.LISTING="listing",e.MAIN="main",e.MALIGNMARK="malignmark",e.MARQUEE="marquee",e.MATH="math",e.MENU="menu",e.META="meta",e.MGLYPH="mglyph",e.MI="mi",e.MO="mo",e.MN="mn",e.MS="ms",e.MTEXT="mtext",e.NAV="nav",e.NOBR="nobr",e.NOFRAMES="noframes",e.NOEMBED="noembed",e.NOSCRIPT="noscript",e.OBJECT="object",e.OL="ol",e.OPTGROUP="optgroup",e.OPTION="option",e.P="p",e.PARAM="param",e.PLAINTEXT="plaintext",e.PRE="pre",e.RB="rb",e.RP="rp",e.RT="rt",e.RTC="rtc",e.RUBY="ruby",e.S="s",e.SCRIPT="script",e.SEARCH="search",e.SECTION="section",e.SELECT="select",e.SOURCE="source",e.SMALL="small",e.SPAN="span",e.STRIKE="strike",e.STRONG="strong",e.STYLE="style",e.SUB="sub",e.SUMMARY="summary",e.SUP="sup",e.TABLE="table",e.TBODY="tbody",e.TEMPLATE="template",e.TEXTAREA="textarea",e.TFOOT="tfoot",e.TD="td",e.TH="th",e.THEAD="thead",e.TITLE="title",e.TR="tr",e.TRACK="track",e.TT="tt",e.U="u",e.UL="ul",e.SVG="svg",e.VAR="var",e.WBR="wbr",e.XMP="xmp"})(be||(be={}));var k;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.A=1]="A",e[e.ADDRESS=2]="ADDRESS",e[e.ANNOTATION_XML=3]="ANNOTATION_XML",e[e.APPLET=4]="APPLET",e[e.AREA=5]="AREA",e[e.ARTICLE=6]="ARTICLE",e[e.ASIDE=7]="ASIDE",e[e.B=8]="B",e[e.BASE=9]="BASE",e[e.BASEFONT=10]="BASEFONT",e[e.BGSOUND=11]="BGSOUND",e[e.BIG=12]="BIG",e[e.BLOCKQUOTE=13]="BLOCKQUOTE",e[e.BODY=14]="BODY",e[e.BR=15]="BR",e[e.BUTTON=16]="BUTTON",e[e.CAPTION=17]="CAPTION",e[e.CENTER=18]="CENTER",e[e.CODE=19]="CODE",e[e.COL=20]="COL",e[e.COLGROUP=21]="COLGROUP",e[e.DD=22]="DD",e[e.DESC=23]="DESC",e[e.DETAILS=24]="DETAILS",e[e.DIALOG=25]="DIALOG",e[e.DIR=26]="DIR",e[e.DIV=27]="DIV",e[e.DL=28]="DL",e[e.DT=29]="DT",e[e.EM=30]="EM",e[e.EMBED=31]="EMBED",e[e.FIELDSET=32]="FIELDSET",e[e.FIGCAPTION=33]="FIGCAPTION",e[e.FIGURE=34]="FIGURE",e[e.FONT=35]="FONT",e[e.FOOTER=36]="FOOTER",e[e.FOREIGN_OBJECT=37]="FOREIGN_OBJECT",e[e.FORM=38]="FORM",e[e.FRAME=39]="FRAME",e[e.FRAMESET=40]="FRAMESET",e[e.H1=41]="H1",e[e.H2=42]="H2",e[e.H3=43]="H3",e[e.H4=44]="H4",e[e.H5=45]="H5",e[e.H6=46]="H6",e[e.HEAD=47]="HEAD",e[e.HEADER=48]="HEADER",e[e.HGROUP=49]="HGROUP",e[e.HR=50]="HR",e[e.HTML=51]="HTML",e[e.I=52]="I",e[e.IMG=53]="IMG",e[e.IMAGE=54]="IMAGE",e[e.INPUT=55]="INPUT",e[e.IFRAME=56]="IFRAME",e[e.KEYGEN=57]="KEYGEN",e[e.LABEL=58]="LABEL",e[e.LI=59]="LI",e[e.LINK=60]="LINK",e[e.LISTING=61]="LISTING",e[e.MAIN=62]="MAIN",e[e.MALIGNMARK=63]="MALIGNMARK",e[e.MARQUEE=64]="MARQUEE",e[e.MATH=65]="MATH",e[e.MENU=66]="MENU",e[e.META=67]="META",e[e.MGLYPH=68]="MGLYPH",e[e.MI=69]="MI",e[e.MO=70]="MO",e[e.MN=71]="MN",e[e.MS=72]="MS",e[e.MTEXT=73]="MTEXT",e[e.NAV=74]="NAV",e[e.NOBR=75]="NOBR",e[e.NOFRAMES=76]="NOFRAMES",e[e.NOEMBED=77]="NOEMBED",e[e.NOSCRIPT=78]="NOSCRIPT",e[e.OBJECT=79]="OBJECT",e[e.OL=80]="OL",e[e.OPTGROUP=81]="OPTGROUP",e[e.OPTION=82]="OPTION",e[e.P=83]="P",e[e.PARAM=84]="PARAM",e[e.PLAINTEXT=85]="PLAINTEXT",e[e.PRE=86]="PRE",e[e.RB=87]="RB",e[e.RP=88]="RP",e[e.RT=89]="RT",e[e.RTC=90]="RTC",e[e.RUBY=91]="RUBY",e[e.S=92]="S",e[e.SCRIPT=93]="SCRIPT",e[e.SEARCH=94]="SEARCH",e[e.SECTION=95]="SECTION",e[e.SELECT=96]="SELECT",e[e.SOURCE=97]="SOURCE",e[e.SMALL=98]="SMALL",e[e.SPAN=99]="SPAN",e[e.STRIKE=100]="STRIKE",e[e.STRONG=101]="STRONG",e[e.STYLE=102]="STYLE",e[e.SUB=103]="SUB",e[e.SUMMARY=104]="SUMMARY",e[e.SUP=105]="SUP",e[e.TABLE=106]="TABLE",e[e.TBODY=107]="TBODY",e[e.TEMPLATE=108]="TEMPLATE",e[e.TEXTAREA=109]="TEXTAREA",e[e.TFOOT=110]="TFOOT",e[e.TD=111]="TD",e[e.TH=112]="TH",e[e.THEAD=113]="THEAD",e[e.TITLE=114]="TITLE",e[e.TR=115]="TR",e[e.TRACK=116]="TRACK",e[e.TT=117]="TT",e[e.U=118]="U",e[e.UL=119]="UL",e[e.SVG=120]="SVG",e[e.VAR=121]="VAR",e[e.WBR=122]="WBR",e[e.XMP=123]="XMP"})(k||(k={}));const PQ=new Map([[be.A,k.A],[be.ADDRESS,k.ADDRESS],[be.ANNOTATION_XML,k.ANNOTATION_XML],[be.APPLET,k.APPLET],[be.AREA,k.AREA],[be.ARTICLE,k.ARTICLE],[be.ASIDE,k.ASIDE],[be.B,k.B],[be.BASE,k.BASE],[be.BASEFONT,k.BASEFONT],[be.BGSOUND,k.BGSOUND],[be.BIG,k.BIG],[be.BLOCKQUOTE,k.BLOCKQUOTE],[be.BODY,k.BODY],[be.BR,k.BR],[be.BUTTON,k.BUTTON],[be.CAPTION,k.CAPTION],[be.CENTER,k.CENTER],[be.CODE,k.CODE],[be.COL,k.COL],[be.COLGROUP,k.COLGROUP],[be.DD,k.DD],[be.DESC,k.DESC],[be.DETAILS,k.DETAILS],[be.DIALOG,k.DIALOG],[be.DIR,k.DIR],[be.DIV,k.DIV],[be.DL,k.DL],[be.DT,k.DT],[be.EM,k.EM],[be.EMBED,k.EMBED],[be.FIELDSET,k.FIELDSET],[be.FIGCAPTION,k.FIGCAPTION],[be.FIGURE,k.FIGURE],[be.FONT,k.FONT],[be.FOOTER,k.FOOTER],[be.FOREIGN_OBJECT,k.FOREIGN_OBJECT],[be.FORM,k.FORM],[be.FRAME,k.FRAME],[be.FRAMESET,k.FRAMESET],[be.H1,k.H1],[be.H2,k.H2],[be.H3,k.H3],[be.H4,k.H4],[be.H5,k.H5],[be.H6,k.H6],[be.HEAD,k.HEAD],[be.HEADER,k.HEADER],[be.HGROUP,k.HGROUP],[be.HR,k.HR],[be.HTML,k.HTML],[be.I,k.I],[be.IMG,k.IMG],[be.IMAGE,k.IMAGE],[be.INPUT,k.INPUT],[be.IFRAME,k.IFRAME],[be.KEYGEN,k.KEYGEN],[be.LABEL,k.LABEL],[be.LI,k.LI],[be.LINK,k.LINK],[be.LISTING,k.LISTING],[be.MAIN,k.MAIN],[be.MALIGNMARK,k.MALIGNMARK],[be.MARQUEE,k.MARQUEE],[be.MATH,k.MATH],[be.MENU,k.MENU],[be.META,k.META],[be.MGLYPH,k.MGLYPH],[be.MI,k.MI],[be.MO,k.MO],[be.MN,k.MN],[be.MS,k.MS],[be.MTEXT,k.MTEXT],[be.NAV,k.NAV],[be.NOBR,k.NOBR],[be.NOFRAMES,k.NOFRAMES],[be.NOEMBED,k.NOEMBED],[be.NOSCRIPT,k.NOSCRIPT],[be.OBJECT,k.OBJECT],[be.OL,k.OL],[be.OPTGROUP,k.OPTGROUP],[be.OPTION,k.OPTION],[be.P,k.P],[be.PARAM,k.PARAM],[be.PLAINTEXT,k.PLAINTEXT],[be.PRE,k.PRE],[be.RB,k.RB],[be.RP,k.RP],[be.RT,k.RT],[be.RTC,k.RTC],[be.RUBY,k.RUBY],[be.S,k.S],[be.SCRIPT,k.SCRIPT],[be.SEARCH,k.SEARCH],[be.SECTION,k.SECTION],[be.SELECT,k.SELECT],[be.SOURCE,k.SOURCE],[be.SMALL,k.SMALL],[be.SPAN,k.SPAN],[be.STRIKE,k.STRIKE],[be.STRONG,k.STRONG],[be.STYLE,k.STYLE],[be.SUB,k.SUB],[be.SUMMARY,k.SUMMARY],[be.SUP,k.SUP],[be.TABLE,k.TABLE],[be.TBODY,k.TBODY],[be.TEMPLATE,k.TEMPLATE],[be.TEXTAREA,k.TEXTAREA],[be.TFOOT,k.TFOOT],[be.TD,k.TD],[be.TH,k.TH],[be.THEAD,k.THEAD],[be.TITLE,k.TITLE],[be.TR,k.TR],[be.TRACK,k.TRACK],[be.TT,k.TT],[be.U,k.U],[be.UL,k.UL],[be.SVG,k.SVG],[be.VAR,k.VAR],[be.WBR,k.WBR],[be.XMP,k.XMP]]);function Nc(e){var t;return(t=PQ.get(e))!==null&&t!==void 0?t:k.UNKNOWN}const ze=k,BQ={[je.HTML]:new Set([ze.ADDRESS,ze.APPLET,ze.AREA,ze.ARTICLE,ze.ASIDE,ze.BASE,ze.BASEFONT,ze.BGSOUND,ze.BLOCKQUOTE,ze.BODY,ze.BR,ze.BUTTON,ze.CAPTION,ze.CENTER,ze.COL,ze.COLGROUP,ze.DD,ze.DETAILS,ze.DIR,ze.DIV,ze.DL,ze.DT,ze.EMBED,ze.FIELDSET,ze.FIGCAPTION,ze.FIGURE,ze.FOOTER,ze.FORM,ze.FRAME,ze.FRAMESET,ze.H1,ze.H2,ze.H3,ze.H4,ze.H5,ze.H6,ze.HEAD,ze.HEADER,ze.HGROUP,ze.HR,ze.HTML,ze.IFRAME,ze.IMG,ze.INPUT,ze.LI,ze.LINK,ze.LISTING,ze.MAIN,ze.MARQUEE,ze.MENU,ze.META,ze.NAV,ze.NOEMBED,ze.NOFRAMES,ze.NOSCRIPT,ze.OBJECT,ze.OL,ze.P,ze.PARAM,ze.PLAINTEXT,ze.PRE,ze.SCRIPT,ze.SECTION,ze.SELECT,ze.SOURCE,ze.STYLE,ze.SUMMARY,ze.TABLE,ze.TBODY,ze.TD,ze.TEMPLATE,ze.TEXTAREA,ze.TFOOT,ze.TH,ze.THEAD,ze.TITLE,ze.TR,ze.TRACK,ze.UL,ze.WBR,ze.XMP]),[je.MATHML]:new Set([ze.MI,ze.MO,ze.MN,ze.MS,ze.MTEXT,ze.ANNOTATION_XML]),[je.SVG]:new Set([ze.TITLE,ze.FOREIGN_OBJECT,ze.DESC]),[je.XLINK]:new Set,[je.XML]:new Set,[je.XMLNS]:new Set},Cx=new Set([ze.H1,ze.H2,ze.H3,ze.H4,ze.H5,ze.H6]);be.STYLE,be.SCRIPT,be.XMP,be.IFRAME,be.NOEMBED,be.NOFRAMES,be.PLAINTEXT;var J;(function(e){e[e.DATA=0]="DATA",e[e.RCDATA=1]="RCDATA",e[e.RAWTEXT=2]="RAWTEXT",e[e.SCRIPT_DATA=3]="SCRIPT_DATA",e[e.PLAINTEXT=4]="PLAINTEXT",e[e.TAG_OPEN=5]="TAG_OPEN",e[e.END_TAG_OPEN=6]="END_TAG_OPEN",e[e.TAG_NAME=7]="TAG_NAME",e[e.RCDATA_LESS_THAN_SIGN=8]="RCDATA_LESS_THAN_SIGN",e[e.RCDATA_END_TAG_OPEN=9]="RCDATA_END_TAG_OPEN",e[e.RCDATA_END_TAG_NAME=10]="RCDATA_END_TAG_NAME",e[e.RAWTEXT_LESS_THAN_SIGN=11]="RAWTEXT_LESS_THAN_SIGN",e[e.RAWTEXT_END_TAG_OPEN=12]="RAWTEXT_END_TAG_OPEN",e[e.RAWTEXT_END_TAG_NAME=13]="RAWTEXT_END_TAG_NAME",e[e.SCRIPT_DATA_LESS_THAN_SIGN=14]="SCRIPT_DATA_LESS_THAN_SIGN",e[e.SCRIPT_DATA_END_TAG_OPEN=15]="SCRIPT_DATA_END_TAG_OPEN",e[e.SCRIPT_DATA_END_TAG_NAME=16]="SCRIPT_DATA_END_TAG_NAME",e[e.SCRIPT_DATA_ESCAPE_START=17]="SCRIPT_DATA_ESCAPE_START",e[e.SCRIPT_DATA_ESCAPE_START_DASH=18]="SCRIPT_DATA_ESCAPE_START_DASH",e[e.SCRIPT_DATA_ESCAPED=19]="SCRIPT_DATA_ESCAPED",e[e.SCRIPT_DATA_ESCAPED_DASH=20]="SCRIPT_DATA_ESCAPED_DASH",e[e.SCRIPT_DATA_ESCAPED_DASH_DASH=21]="SCRIPT_DATA_ESCAPED_DASH_DASH",e[e.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN=22]="SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN",e[e.SCRIPT_DATA_ESCAPED_END_TAG_OPEN=23]="SCRIPT_DATA_ESCAPED_END_TAG_OPEN",e[e.SCRIPT_DATA_ESCAPED_END_TAG_NAME=24]="SCRIPT_DATA_ESCAPED_END_TAG_NAME",e[e.SCRIPT_DATA_DOUBLE_ESCAPE_START=25]="SCRIPT_DATA_DOUBLE_ESCAPE_START",e[e.SCRIPT_DATA_DOUBLE_ESCAPED=26]="SCRIPT_DATA_DOUBLE_ESCAPED",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_DASH=27]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH=28]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN=29]="SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN",e[e.SCRIPT_DATA_DOUBLE_ESCAPE_END=30]="SCRIPT_DATA_DOUBLE_ESCAPE_END",e[e.BEFORE_ATTRIBUTE_NAME=31]="BEFORE_ATTRIBUTE_NAME",e[e.ATTRIBUTE_NAME=32]="ATTRIBUTE_NAME",e[e.AFTER_ATTRIBUTE_NAME=33]="AFTER_ATTRIBUTE_NAME",e[e.BEFORE_ATTRIBUTE_VALUE=34]="BEFORE_ATTRIBUTE_VALUE",e[e.ATTRIBUTE_VALUE_DOUBLE_QUOTED=35]="ATTRIBUTE_VALUE_DOUBLE_QUOTED",e[e.ATTRIBUTE_VALUE_SINGLE_QUOTED=36]="ATTRIBUTE_VALUE_SINGLE_QUOTED",e[e.ATTRIBUTE_VALUE_UNQUOTED=37]="ATTRIBUTE_VALUE_UNQUOTED",e[e.AFTER_ATTRIBUTE_VALUE_QUOTED=38]="AFTER_ATTRIBUTE_VALUE_QUOTED",e[e.SELF_CLOSING_START_TAG=39]="SELF_CLOSING_START_TAG",e[e.BOGUS_COMMENT=40]="BOGUS_COMMENT",e[e.MARKUP_DECLARATION_OPEN=41]="MARKUP_DECLARATION_OPEN",e[e.COMMENT_START=42]="COMMENT_START",e[e.COMMENT_START_DASH=43]="COMMENT_START_DASH",e[e.COMMENT=44]="COMMENT",e[e.COMMENT_LESS_THAN_SIGN=45]="COMMENT_LESS_THAN_SIGN",e[e.COMMENT_LESS_THAN_SIGN_BANG=46]="COMMENT_LESS_THAN_SIGN_BANG",e[e.COMMENT_LESS_THAN_SIGN_BANG_DASH=47]="COMMENT_LESS_THAN_SIGN_BANG_DASH",e[e.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH=48]="COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH",e[e.COMMENT_END_DASH=49]="COMMENT_END_DASH",e[e.COMMENT_END=50]="COMMENT_END",e[e.COMMENT_END_BANG=51]="COMMENT_END_BANG",e[e.DOCTYPE=52]="DOCTYPE",e[e.BEFORE_DOCTYPE_NAME=53]="BEFORE_DOCTYPE_NAME",e[e.DOCTYPE_NAME=54]="DOCTYPE_NAME",e[e.AFTER_DOCTYPE_NAME=55]="AFTER_DOCTYPE_NAME",e[e.AFTER_DOCTYPE_PUBLIC_KEYWORD=56]="AFTER_DOCTYPE_PUBLIC_KEYWORD",e[e.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER=57]="BEFORE_DOCTYPE_PUBLIC_IDENTIFIER",e[e.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED=58]="DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED",e[e.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED=59]="DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED",e[e.AFTER_DOCTYPE_PUBLIC_IDENTIFIER=60]="AFTER_DOCTYPE_PUBLIC_IDENTIFIER",e[e.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS=61]="BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS",e[e.AFTER_DOCTYPE_SYSTEM_KEYWORD=62]="AFTER_DOCTYPE_SYSTEM_KEYWORD",e[e.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER=63]="BEFORE_DOCTYPE_SYSTEM_IDENTIFIER",e[e.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED=64]="DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED",e[e.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED=65]="DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED",e[e.AFTER_DOCTYPE_SYSTEM_IDENTIFIER=66]="AFTER_DOCTYPE_SYSTEM_IDENTIFIER",e[e.BOGUS_DOCTYPE=67]="BOGUS_DOCTYPE",e[e.CDATA_SECTION=68]="CDATA_SECTION",e[e.CDATA_SECTION_BRACKET=69]="CDATA_SECTION_BRACKET",e[e.CDATA_SECTION_END=70]="CDATA_SECTION_END",e[e.CHARACTER_REFERENCE=71]="CHARACTER_REFERENCE",e[e.AMBIGUOUS_AMPERSAND=72]="AMBIGUOUS_AMPERSAND"})(J||(J={}));const In={DATA:J.DATA,RCDATA:J.RCDATA,RAWTEXT:J.RAWTEXT,SCRIPT_DATA:J.SCRIPT_DATA,PLAINTEXT:J.PLAINTEXT,CDATA_SECTION:J.CDATA_SECTION};function zQ(e){return e>=X.DIGIT_0&&e<=X.DIGIT_9}function Wu(e){return e>=X.LATIN_CAPITAL_A&&e<=X.LATIN_CAPITAL_Z}function HQ(e){return e>=X.LATIN_SMALL_A&&e<=X.LATIN_SMALL_Z}function ba(e){return HQ(e)||Wu(e)}function YC(e){return ba(e)||zQ(e)}function Lh(e){return e+32}function jA(e){return e===X.SPACE||e===X.LINE_FEED||e===X.TABULATION||e===X.FORM_FEED}function GC(e){return jA(e)||e===X.SOLIDUS||e===X.GREATER_THAN_SIGN}function UQ(e){return e===X.NULL?Ne.nullCharacterReference:e>1114111?Ne.characterReferenceOutsideUnicodeRange:MA(e)?Ne.surrogateCharacterReference:OA(e)?Ne.noncharacterCharacterReference:IA(e)||e===X.CARRIAGE_RETURN?Ne.controlCharacterReference:null}class FQ{constructor(t,n){this.options=t,this.handler=n,this.paused=!1,this.inLoop=!1,this.inForeignNode=!1,this.lastStartTagName="",this.active=!1,this.state=J.DATA,this.returnState=J.DATA,this.entityStartPos=0,this.consumedAfterSnapshot=-1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr={name:"",value:""},this.preprocessor=new NQ(n),this.currentLocation=this.getCurrentLocation(-1),this.entityDecoder=new jQ(_Q,(r,s)=>{this.preprocessor.pos=this.entityStartPos+s-1,this._flushCodePointConsumedAsCharacterReference(r)},n.onParseError?{missingSemicolonAfterCharacterReference:()=>{this._err(Ne.missingSemicolonAfterCharacterReference,1)},absenceOfDigitsInNumericCharacterReference:r=>{this._err(Ne.absenceOfDigitsInNumericCharacterReference,this.entityStartPos-this.preprocessor.pos+r)},validateNumericCharacterReference:r=>{const s=UQ(r);s&&this._err(s,1)}}:void 0)}_err(t,n=0){var r,s;(s=(r=this.handler).onParseError)===null||s===void 0||s.call(r,this.preprocessor.getError(t,n))}getCurrentLocation(t){return this.options.sourceCodeLocationInfo?{startLine:this.preprocessor.line,startCol:this.preprocessor.col-t,startOffset:this.preprocessor.offset-t,endLine:-1,endCol:-1,endOffset:-1}:null}_runParsingLoop(){if(!this.inLoop){for(this.inLoop=!0;this.active&&!this.paused;){this.consumedAfterSnapshot=0;const t=this._consume();this._ensureHibernation()||this._callState(t)}this.inLoop=!1}}pause(){this.paused=!0}resume(t){if(!this.paused)throw new Error("Parser was already resumed");this.paused=!1,!this.inLoop&&(this._runParsingLoop(),this.paused||t?.())}write(t,n,r){this.active=!0,this.preprocessor.write(t,n),this._runParsingLoop(),this.paused||r?.()}insertHtmlAtCurrentPos(t){this.active=!0,this.preprocessor.insertHtmlAtCurrentPos(t),this._runParsingLoop()}_ensureHibernation(){return this.preprocessor.endOfChunkHit?(this.preprocessor.retreat(this.consumedAfterSnapshot),this.consumedAfterSnapshot=0,this.active=!1,!0):!1}_consume(){return this.consumedAfterSnapshot++,this.preprocessor.advance()}_advanceBy(t){this.consumedAfterSnapshot+=t;for(let n=0;n<t;n++)this.preprocessor.advance()}_consumeSequenceIfMatch(t,n){return this.preprocessor.startsWith(t,n)?(this._advanceBy(t.length-1),!0):!1}_createStartTagToken(){this.currentToken={type:At.START_TAG,tagName:"",tagID:k.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(1)}}_createEndTagToken(){this.currentToken={type:At.END_TAG,tagName:"",tagID:k.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(2)}}_createCommentToken(t){this.currentToken={type:At.COMMENT,data:"",location:this.getCurrentLocation(t)}}_createDoctypeToken(t){this.currentToken={type:At.DOCTYPE,name:t,forceQuirks:!1,publicId:null,systemId:null,location:this.currentLocation}}_createCharacterToken(t,n){this.currentCharacterToken={type:t,chars:n,location:this.currentLocation}}_createAttr(t){this.currentAttr={name:t,value:""},this.currentLocation=this.getCurrentLocation(0)}_leaveAttrName(){var t,n;const r=this.currentToken;if(LA(r,this.currentAttr.name)===null){if(r.attrs.push(this.currentAttr),r.location&&this.currentLocation){const s=(t=(n=r.location).attrs)!==null&&t!==void 0?t:n.attrs=Object.create(null);s[this.currentAttr.name]=this.currentLocation,this._leaveAttrValue()}}else this._err(Ne.duplicateAttribute)}_leaveAttrValue(){this.currentLocation&&(this.currentLocation.endLine=this.preprocessor.line,this.currentLocation.endCol=this.preprocessor.col,this.currentLocation.endOffset=this.preprocessor.offset)}prepareToken(t){this._emitCurrentCharacterToken(t.location),this.currentToken=null,t.location&&(t.location.endLine=this.preprocessor.line,t.location.endCol=this.preprocessor.col+1,t.location.endOffset=this.preprocessor.offset+1),this.currentLocation=this.getCurrentLocation(-1)}emitCurrentTagToken(){const t=this.currentToken;this.prepareToken(t),t.tagID=Nc(t.tagName),t.type===At.START_TAG?(this.lastStartTagName=t.tagName,this.handler.onStartTag(t)):(t.attrs.length>0&&this._err(Ne.endTagWithAttributes),t.selfClosing&&this._err(Ne.endTagWithTrailingSolidus),this.handler.onEndTag(t)),this.preprocessor.dropParsedChunk()}emitCurrentComment(t){this.prepareToken(t),this.handler.onComment(t),this.preprocessor.dropParsedChunk()}emitCurrentDoctype(t){this.prepareToken(t),this.handler.onDoctype(t),this.preprocessor.dropParsedChunk()}_emitCurrentCharacterToken(t){if(this.currentCharacterToken){switch(t&&this.currentCharacterToken.location&&(this.currentCharacterToken.location.endLine=t.startLine,this.currentCharacterToken.location.endCol=t.startCol,this.currentCharacterToken.location.endOffset=t.startOffset),this.currentCharacterToken.type){case At.CHARACTER:{this.handler.onCharacter(this.currentCharacterToken);break}case At.NULL_CHARACTER:{this.handler.onNullCharacter(this.currentCharacterToken);break}case At.WHITESPACE_CHARACTER:{this.handler.onWhitespaceCharacter(this.currentCharacterToken);break}}this.currentCharacterToken=null}}_emitEOFToken(){const t=this.getCurrentLocation(0);t&&(t.endLine=t.startLine,t.endCol=t.startCol,t.endOffset=t.startOffset),this._emitCurrentCharacterToken(t),this.handler.onEof({type:At.EOF,location:t}),this.active=!1}_appendCharToCurrentCharacterToken(t,n){if(this.currentCharacterToken)if(this.currentCharacterToken.type===t){this.currentCharacterToken.chars+=n;return}else this.currentLocation=this.getCurrentLocation(0),this._emitCurrentCharacterToken(this.currentLocation),this.preprocessor.dropParsedChunk();this._createCharacterToken(t,n)}_emitCodePoint(t){const n=jA(t)?At.WHITESPACE_CHARACTER:t===X.NULL?At.NULL_CHARACTER:At.CHARACTER;this._appendCharToCurrentCharacterToken(n,String.fromCodePoint(t))}_emitChars(t){this._appendCharToCurrentCharacterToken(At.CHARACTER,t)}_startCharacterReference(){this.returnState=this.state,this.state=J.CHARACTER_REFERENCE,this.entityStartPos=this.preprocessor.pos,this.entityDecoder.startEntity(this._isCharacterReferenceInAttribute()?ki.Attribute:ki.Legacy)}_isCharacterReferenceInAttribute(){return this.returnState===J.ATTRIBUTE_VALUE_DOUBLE_QUOTED||this.returnState===J.ATTRIBUTE_VALUE_SINGLE_QUOTED||this.returnState===J.ATTRIBUTE_VALUE_UNQUOTED}_flushCodePointConsumedAsCharacterReference(t){this._isCharacterReferenceInAttribute()?this.currentAttr.value+=String.fromCodePoint(t):this._emitCodePoint(t)}_callState(t){switch(this.state){case J.DATA:{this._stateData(t);break}case J.RCDATA:{this._stateRcdata(t);break}case J.RAWTEXT:{this._stateRawtext(t);break}case J.SCRIPT_DATA:{this._stateScriptData(t);break}case J.PLAINTEXT:{this._statePlaintext(t);break}case J.TAG_OPEN:{this._stateTagOpen(t);break}case J.END_TAG_OPEN:{this._stateEndTagOpen(t);break}case J.TAG_NAME:{this._stateTagName(t);break}case J.RCDATA_LESS_THAN_SIGN:{this._stateRcdataLessThanSign(t);break}case J.RCDATA_END_TAG_OPEN:{this._stateRcdataEndTagOpen(t);break}case J.RCDATA_END_TAG_NAME:{this._stateRcdataEndTagName(t);break}case J.RAWTEXT_LESS_THAN_SIGN:{this._stateRawtextLessThanSign(t);break}case J.RAWTEXT_END_TAG_OPEN:{this._stateRawtextEndTagOpen(t);break}case J.RAWTEXT_END_TAG_NAME:{this._stateRawtextEndTagName(t);break}case J.SCRIPT_DATA_LESS_THAN_SIGN:{this._stateScriptDataLessThanSign(t);break}case J.SCRIPT_DATA_END_TAG_OPEN:{this._stateScriptDataEndTagOpen(t);break}case J.SCRIPT_DATA_END_TAG_NAME:{this._stateScriptDataEndTagName(t);break}case J.SCRIPT_DATA_ESCAPE_START:{this._stateScriptDataEscapeStart(t);break}case J.SCRIPT_DATA_ESCAPE_START_DASH:{this._stateScriptDataEscapeStartDash(t);break}case J.SCRIPT_DATA_ESCAPED:{this._stateScriptDataEscaped(t);break}case J.SCRIPT_DATA_ESCAPED_DASH:{this._stateScriptDataEscapedDash(t);break}case J.SCRIPT_DATA_ESCAPED_DASH_DASH:{this._stateScriptDataEscapedDashDash(t);break}case J.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataEscapedLessThanSign(t);break}case J.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:{this._stateScriptDataEscapedEndTagOpen(t);break}case J.SCRIPT_DATA_ESCAPED_END_TAG_NAME:{this._stateScriptDataEscapedEndTagName(t);break}case J.SCRIPT_DATA_DOUBLE_ESCAPE_START:{this._stateScriptDataDoubleEscapeStart(t);break}case J.SCRIPT_DATA_DOUBLE_ESCAPED:{this._stateScriptDataDoubleEscaped(t);break}case J.SCRIPT_DATA_DOUBLE_ESCAPED_DASH:{this._stateScriptDataDoubleEscapedDash(t);break}case J.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:{this._stateScriptDataDoubleEscapedDashDash(t);break}case J.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataDoubleEscapedLessThanSign(t);break}case J.SCRIPT_DATA_DOUBLE_ESCAPE_END:{this._stateScriptDataDoubleEscapeEnd(t);break}case J.BEFORE_ATTRIBUTE_NAME:{this._stateBeforeAttributeName(t);break}case J.ATTRIBUTE_NAME:{this._stateAttributeName(t);break}case J.AFTER_ATTRIBUTE_NAME:{this._stateAfterAttributeName(t);break}case J.BEFORE_ATTRIBUTE_VALUE:{this._stateBeforeAttributeValue(t);break}case J.ATTRIBUTE_VALUE_DOUBLE_QUOTED:{this._stateAttributeValueDoubleQuoted(t);break}case J.ATTRIBUTE_VALUE_SINGLE_QUOTED:{this._stateAttributeValueSingleQuoted(t);break}case J.ATTRIBUTE_VALUE_UNQUOTED:{this._stateAttributeValueUnquoted(t);break}case J.AFTER_ATTRIBUTE_VALUE_QUOTED:{this._stateAfterAttributeValueQuoted(t);break}case J.SELF_CLOSING_START_TAG:{this._stateSelfClosingStartTag(t);break}case J.BOGUS_COMMENT:{this._stateBogusComment(t);break}case J.MARKUP_DECLARATION_OPEN:{this._stateMarkupDeclarationOpen(t);break}case J.COMMENT_START:{this._stateCommentStart(t);break}case J.COMMENT_START_DASH:{this._stateCommentStartDash(t);break}case J.COMMENT:{this._stateComment(t);break}case J.COMMENT_LESS_THAN_SIGN:{this._stateCommentLessThanSign(t);break}case J.COMMENT_LESS_THAN_SIGN_BANG:{this._stateCommentLessThanSignBang(t);break}case J.COMMENT_LESS_THAN_SIGN_BANG_DASH:{this._stateCommentLessThanSignBangDash(t);break}case J.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:{this._stateCommentLessThanSignBangDashDash(t);break}case J.COMMENT_END_DASH:{this._stateCommentEndDash(t);break}case J.COMMENT_END:{this._stateCommentEnd(t);break}case J.COMMENT_END_BANG:{this._stateCommentEndBang(t);break}case J.DOCTYPE:{this._stateDoctype(t);break}case J.BEFORE_DOCTYPE_NAME:{this._stateBeforeDoctypeName(t);break}case J.DOCTYPE_NAME:{this._stateDoctypeName(t);break}case J.AFTER_DOCTYPE_NAME:{this._stateAfterDoctypeName(t);break}case J.AFTER_DOCTYPE_PUBLIC_KEYWORD:{this._stateAfterDoctypePublicKeyword(t);break}case J.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateBeforeDoctypePublicIdentifier(t);break}case J.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypePublicIdentifierDoubleQuoted(t);break}case J.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypePublicIdentifierSingleQuoted(t);break}case J.AFTER_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateAfterDoctypePublicIdentifier(t);break}case J.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:{this._stateBetweenDoctypePublicAndSystemIdentifiers(t);break}case J.AFTER_DOCTYPE_SYSTEM_KEYWORD:{this._stateAfterDoctypeSystemKeyword(t);break}case J.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateBeforeDoctypeSystemIdentifier(t);break}case J.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypeSystemIdentifierDoubleQuoted(t);break}case J.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypeSystemIdentifierSingleQuoted(t);break}case J.AFTER_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateAfterDoctypeSystemIdentifier(t);break}case J.BOGUS_DOCTYPE:{this._stateBogusDoctype(t);break}case J.CDATA_SECTION:{this._stateCdataSection(t);break}case J.CDATA_SECTION_BRACKET:{this._stateCdataSectionBracket(t);break}case J.CDATA_SECTION_END:{this._stateCdataSectionEnd(t);break}case J.CHARACTER_REFERENCE:{this._stateCharacterReference();break}case J.AMBIGUOUS_AMPERSAND:{this._stateAmbiguousAmpersand(t);break}default:throw new Error("Unknown state")}}_stateData(t){switch(t){case X.LESS_THAN_SIGN:{this.state=J.TAG_OPEN;break}case X.AMPERSAND:{this._startCharacterReference();break}case X.NULL:{this._err(Ne.unexpectedNullCharacter),this._emitCodePoint(t);break}case X.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateRcdata(t){switch(t){case X.AMPERSAND:{this._startCharacterReference();break}case X.LESS_THAN_SIGN:{this.state=J.RCDATA_LESS_THAN_SIGN;break}case X.NULL:{this._err(Ne.unexpectedNullCharacter),this._emitChars(yn);break}case X.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateRawtext(t){switch(t){case X.LESS_THAN_SIGN:{this.state=J.RAWTEXT_LESS_THAN_SIGN;break}case X.NULL:{this._err(Ne.unexpectedNullCharacter),this._emitChars(yn);break}case X.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptData(t){switch(t){case X.LESS_THAN_SIGN:{this.state=J.SCRIPT_DATA_LESS_THAN_SIGN;break}case X.NULL:{this._err(Ne.unexpectedNullCharacter),this._emitChars(yn);break}case X.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_statePlaintext(t){switch(t){case X.NULL:{this._err(Ne.unexpectedNullCharacter),this._emitChars(yn);break}case X.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateTagOpen(t){if(ba(t))this._createStartTagToken(),this.state=J.TAG_NAME,this._stateTagName(t);else switch(t){case X.EXCLAMATION_MARK:{this.state=J.MARKUP_DECLARATION_OPEN;break}case X.SOLIDUS:{this.state=J.END_TAG_OPEN;break}case X.QUESTION_MARK:{this._err(Ne.unexpectedQuestionMarkInsteadOfTagName),this._createCommentToken(1),this.state=J.BOGUS_COMMENT,this._stateBogusComment(t);break}case X.EOF:{this._err(Ne.eofBeforeTagName),this._emitChars("<"),this._emitEOFToken();break}default:this._err(Ne.invalidFirstCharacterOfTagName),this._emitChars("<"),this.state=J.DATA,this._stateData(t)}}_stateEndTagOpen(t){if(ba(t))this._createEndTagToken(),this.state=J.TAG_NAME,this._stateTagName(t);else switch(t){case X.GREATER_THAN_SIGN:{this._err(Ne.missingEndTagName),this.state=J.DATA;break}case X.EOF:{this._err(Ne.eofBeforeTagName),this._emitChars("</"),this._emitEOFToken();break}default:this._err(Ne.invalidFirstCharacterOfTagName),this._createCommentToken(2),this.state=J.BOGUS_COMMENT,this._stateBogusComment(t)}}_stateTagName(t){const n=this.currentToken;switch(t){case X.SPACE:case X.LINE_FEED:case X.TABULATION:case X.FORM_FEED:{this.state=J.BEFORE_ATTRIBUTE_NAME;break}case X.SOLIDUS:{this.state=J.SELF_CLOSING_START_TAG;break}case X.GREATER_THAN_SIGN:{this.state=J.DATA,this.emitCurrentTagToken();break}case X.NULL:{this._err(Ne.unexpectedNullCharacter),n.tagName+=yn;break}case X.EOF:{this._err(Ne.eofInTag),this._emitEOFToken();break}default:n.tagName+=String.fromCodePoint(Wu(t)?Lh(t):t)}}_stateRcdataLessThanSign(t){t===X.SOLIDUS?this.state=J.RCDATA_END_TAG_OPEN:(this._emitChars("<"),this.state=J.RCDATA,this._stateRcdata(t))}_stateRcdataEndTagOpen(t){ba(t)?(this.state=J.RCDATA_END_TAG_NAME,this._stateRcdataEndTagName(t)):(this._emitChars("</"),this.state=J.RCDATA,this._stateRcdata(t))}handleSpecialEndTag(t){if(!this.preprocessor.startsWith(this.lastStartTagName,!1))return!this._ensureHibernation();this._createEndTagToken();const n=this.currentToken;switch(n.tagName=this.lastStartTagName,this.preprocessor.peek(this.lastStartTagName.length)){case X.SPACE:case X.LINE_FEED:case X.TABULATION:case X.FORM_FEED:return this._advanceBy(this.lastStartTagName.length),this.state=J.BEFORE_ATTRIBUTE_NAME,!1;case X.SOLIDUS:return this._advanceBy(this.lastStartTagName.length),this.state=J.SELF_CLOSING_START_TAG,!1;case X.GREATER_THAN_SIGN:return this._advanceBy(this.lastStartTagName.length),this.emitCurrentTagToken(),this.state=J.DATA,!1;default:return!this._ensureHibernation()}}_stateRcdataEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=J.RCDATA,this._stateRcdata(t))}_stateRawtextLessThanSign(t){t===X.SOLIDUS?this.state=J.RAWTEXT_END_TAG_OPEN:(this._emitChars("<"),this.state=J.RAWTEXT,this._stateRawtext(t))}_stateRawtextEndTagOpen(t){ba(t)?(this.state=J.RAWTEXT_END_TAG_NAME,this._stateRawtextEndTagName(t)):(this._emitChars("</"),this.state=J.RAWTEXT,this._stateRawtext(t))}_stateRawtextEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=J.RAWTEXT,this._stateRawtext(t))}_stateScriptDataLessThanSign(t){switch(t){case X.SOLIDUS:{this.state=J.SCRIPT_DATA_END_TAG_OPEN;break}case X.EXCLAMATION_MARK:{this.state=J.SCRIPT_DATA_ESCAPE_START,this._emitChars("<!");break}default:this._emitChars("<"),this.state=J.SCRIPT_DATA,this._stateScriptData(t)}}_stateScriptDataEndTagOpen(t){ba(t)?(this.state=J.SCRIPT_DATA_END_TAG_NAME,this._stateScriptDataEndTagName(t)):(this._emitChars("</"),this.state=J.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=J.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscapeStart(t){t===X.HYPHEN_MINUS?(this.state=J.SCRIPT_DATA_ESCAPE_START_DASH,this._emitChars("-")):(this.state=J.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscapeStartDash(t){t===X.HYPHEN_MINUS?(this.state=J.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-")):(this.state=J.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscaped(t){switch(t){case X.HYPHEN_MINUS:{this.state=J.SCRIPT_DATA_ESCAPED_DASH,this._emitChars("-");break}case X.LESS_THAN_SIGN:{this.state=J.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case X.NULL:{this._err(Ne.unexpectedNullCharacter),this._emitChars(yn);break}case X.EOF:{this._err(Ne.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptDataEscapedDash(t){switch(t){case X.HYPHEN_MINUS:{this.state=J.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-");break}case X.LESS_THAN_SIGN:{this.state=J.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case X.NULL:{this._err(Ne.unexpectedNullCharacter),this.state=J.SCRIPT_DATA_ESCAPED,this._emitChars(yn);break}case X.EOF:{this._err(Ne.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=J.SCRIPT_DATA_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataEscapedDashDash(t){switch(t){case X.HYPHEN_MINUS:{this._emitChars("-");break}case X.LESS_THAN_SIGN:{this.state=J.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case X.GREATER_THAN_SIGN:{this.state=J.SCRIPT_DATA,this._emitChars(">");break}case X.NULL:{this._err(Ne.unexpectedNullCharacter),this.state=J.SCRIPT_DATA_ESCAPED,this._emitChars(yn);break}case X.EOF:{this._err(Ne.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=J.SCRIPT_DATA_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataEscapedLessThanSign(t){t===X.SOLIDUS?this.state=J.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:ba(t)?(this._emitChars("<"),this.state=J.SCRIPT_DATA_DOUBLE_ESCAPE_START,this._stateScriptDataDoubleEscapeStart(t)):(this._emitChars("<"),this.state=J.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataEscapedEndTagOpen(t){ba(t)?(this.state=J.SCRIPT_DATA_ESCAPED_END_TAG_NAME,this._stateScriptDataEscapedEndTagName(t)):(this._emitChars("</"),this.state=J.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataEscapedEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=J.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataDoubleEscapeStart(t){if(this.preprocessor.startsWith(Ar.SCRIPT,!1)&&GC(this.preprocessor.peek(Ar.SCRIPT.length))){this._emitCodePoint(t);for(let n=0;n<Ar.SCRIPT.length;n++)this._emitCodePoint(this._consume());this.state=J.SCRIPT_DATA_DOUBLE_ESCAPED}else this._ensureHibernation()||(this.state=J.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataDoubleEscaped(t){switch(t){case X.HYPHEN_MINUS:{this.state=J.SCRIPT_DATA_DOUBLE_ESCAPED_DASH,this._emitChars("-");break}case X.LESS_THAN_SIGN:{this.state=J.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case X.NULL:{this._err(Ne.unexpectedNullCharacter),this._emitChars(yn);break}case X.EOF:{this._err(Ne.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedDash(t){switch(t){case X.HYPHEN_MINUS:{this.state=J.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH,this._emitChars("-");break}case X.LESS_THAN_SIGN:{this.state=J.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case X.NULL:{this._err(Ne.unexpectedNullCharacter),this.state=J.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(yn);break}case X.EOF:{this._err(Ne.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=J.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedDashDash(t){switch(t){case X.HYPHEN_MINUS:{this._emitChars("-");break}case X.LESS_THAN_SIGN:{this.state=J.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case X.GREATER_THAN_SIGN:{this.state=J.SCRIPT_DATA,this._emitChars(">");break}case X.NULL:{this._err(Ne.unexpectedNullCharacter),this.state=J.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(yn);break}case X.EOF:{this._err(Ne.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=J.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedLessThanSign(t){t===X.SOLIDUS?(this.state=J.SCRIPT_DATA_DOUBLE_ESCAPE_END,this._emitChars("/")):(this.state=J.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(t))}_stateScriptDataDoubleEscapeEnd(t){if(this.preprocessor.startsWith(Ar.SCRIPT,!1)&&GC(this.preprocessor.peek(Ar.SCRIPT.length))){this._emitCodePoint(t);for(let n=0;n<Ar.SCRIPT.length;n++)this._emitCodePoint(this._consume());this.state=J.SCRIPT_DATA_ESCAPED}else this._ensureHibernation()||(this.state=J.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(t))}_stateBeforeAttributeName(t){switch(t){case X.SPACE:case X.LINE_FEED:case X.TABULATION:case X.FORM_FEED:break;case X.SOLIDUS:case X.GREATER_THAN_SIGN:case X.EOF:{this.state=J.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(t);break}case X.EQUALS_SIGN:{this._err(Ne.unexpectedEqualsSignBeforeAttributeName),this._createAttr("="),this.state=J.ATTRIBUTE_NAME;break}default:this._createAttr(""),this.state=J.ATTRIBUTE_NAME,this._stateAttributeName(t)}}_stateAttributeName(t){switch(t){case X.SPACE:case X.LINE_FEED:case X.TABULATION:case X.FORM_FEED:case X.SOLIDUS:case X.GREATER_THAN_SIGN:case X.EOF:{this._leaveAttrName(),this.state=J.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(t);break}case X.EQUALS_SIGN:{this._leaveAttrName(),this.state=J.BEFORE_ATTRIBUTE_VALUE;break}case X.QUOTATION_MARK:case X.APOSTROPHE:case X.LESS_THAN_SIGN:{this._err(Ne.unexpectedCharacterInAttributeName),this.currentAttr.name+=String.fromCodePoint(t);break}case X.NULL:{this._err(Ne.unexpectedNullCharacter),this.currentAttr.name+=yn;break}default:this.currentAttr.name+=String.fromCodePoint(Wu(t)?Lh(t):t)}}_stateAfterAttributeName(t){switch(t){case X.SPACE:case X.LINE_FEED:case X.TABULATION:case X.FORM_FEED:break;case X.SOLIDUS:{this.state=J.SELF_CLOSING_START_TAG;break}case X.EQUALS_SIGN:{this.state=J.BEFORE_ATTRIBUTE_VALUE;break}case X.GREATER_THAN_SIGN:{this.state=J.DATA,this.emitCurrentTagToken();break}case X.EOF:{this._err(Ne.eofInTag),this._emitEOFToken();break}default:this._createAttr(""),this.state=J.ATTRIBUTE_NAME,this._stateAttributeName(t)}}_stateBeforeAttributeValue(t){switch(t){case X.SPACE:case X.LINE_FEED:case X.TABULATION:case X.FORM_FEED:break;case X.QUOTATION_MARK:{this.state=J.ATTRIBUTE_VALUE_DOUBLE_QUOTED;break}case X.APOSTROPHE:{this.state=J.ATTRIBUTE_VALUE_SINGLE_QUOTED;break}case X.GREATER_THAN_SIGN:{this._err(Ne.missingAttributeValue),this.state=J.DATA,this.emitCurrentTagToken();break}default:this.state=J.ATTRIBUTE_VALUE_UNQUOTED,this._stateAttributeValueUnquoted(t)}}_stateAttributeValueDoubleQuoted(t){switch(t){case X.QUOTATION_MARK:{this.state=J.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case X.AMPERSAND:{this._startCharacterReference();break}case X.NULL:{this._err(Ne.unexpectedNullCharacter),this.currentAttr.value+=yn;break}case X.EOF:{this._err(Ne.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAttributeValueSingleQuoted(t){switch(t){case X.APOSTROPHE:{this.state=J.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case X.AMPERSAND:{this._startCharacterReference();break}case X.NULL:{this._err(Ne.unexpectedNullCharacter),this.currentAttr.value+=yn;break}case X.EOF:{this._err(Ne.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAttributeValueUnquoted(t){switch(t){case X.SPACE:case X.LINE_FEED:case X.TABULATION:case X.FORM_FEED:{this._leaveAttrValue(),this.state=J.BEFORE_ATTRIBUTE_NAME;break}case X.AMPERSAND:{this._startCharacterReference();break}case X.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=J.DATA,this.emitCurrentTagToken();break}case X.NULL:{this._err(Ne.unexpectedNullCharacter),this.currentAttr.value+=yn;break}case X.QUOTATION_MARK:case X.APOSTROPHE:case X.LESS_THAN_SIGN:case X.EQUALS_SIGN:case X.GRAVE_ACCENT:{this._err(Ne.unexpectedCharacterInUnquotedAttributeValue),this.currentAttr.value+=String.fromCodePoint(t);break}case X.EOF:{this._err(Ne.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAfterAttributeValueQuoted(t){switch(t){case X.SPACE:case X.LINE_FEED:case X.TABULATION:case X.FORM_FEED:{this._leaveAttrValue(),this.state=J.BEFORE_ATTRIBUTE_NAME;break}case X.SOLIDUS:{this._leaveAttrValue(),this.state=J.SELF_CLOSING_START_TAG;break}case X.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=J.DATA,this.emitCurrentTagToken();break}case X.EOF:{this._err(Ne.eofInTag),this._emitEOFToken();break}default:this._err(Ne.missingWhitespaceBetweenAttributes),this.state=J.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(t)}}_stateSelfClosingStartTag(t){switch(t){case X.GREATER_THAN_SIGN:{const n=this.currentToken;n.selfClosing=!0,this.state=J.DATA,this.emitCurrentTagToken();break}case X.EOF:{this._err(Ne.eofInTag),this._emitEOFToken();break}default:this._err(Ne.unexpectedSolidusInTag),this.state=J.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(t)}}_stateBogusComment(t){const n=this.currentToken;switch(t){case X.GREATER_THAN_SIGN:{this.state=J.DATA,this.emitCurrentComment(n);break}case X.EOF:{this.emitCurrentComment(n),this._emitEOFToken();break}case X.NULL:{this._err(Ne.unexpectedNullCharacter),n.data+=yn;break}default:n.data+=String.fromCodePoint(t)}}_stateMarkupDeclarationOpen(t){this._consumeSequenceIfMatch(Ar.DASH_DASH,!0)?(this._createCommentToken(Ar.DASH_DASH.length+1),this.state=J.COMMENT_START):this._consumeSequenceIfMatch(Ar.DOCTYPE,!1)?(this.currentLocation=this.getCurrentLocation(Ar.DOCTYPE.length+1),this.state=J.DOCTYPE):this._consumeSequenceIfMatch(Ar.CDATA_START,!0)?this.inForeignNode?this.state=J.CDATA_SECTION:(this._err(Ne.cdataInHtmlContent),this._createCommentToken(Ar.CDATA_START.length+1),this.currentToken.data="[CDATA[",this.state=J.BOGUS_COMMENT):this._ensureHibernation()||(this._err(Ne.incorrectlyOpenedComment),this._createCommentToken(2),this.state=J.BOGUS_COMMENT,this._stateBogusComment(t))}_stateCommentStart(t){switch(t){case X.HYPHEN_MINUS:{this.state=J.COMMENT_START_DASH;break}case X.GREATER_THAN_SIGN:{this._err(Ne.abruptClosingOfEmptyComment),this.state=J.DATA;const n=this.currentToken;this.emitCurrentComment(n);break}default:this.state=J.COMMENT,this._stateComment(t)}}_stateCommentStartDash(t){const n=this.currentToken;switch(t){case X.HYPHEN_MINUS:{this.state=J.COMMENT_END;break}case X.GREATER_THAN_SIGN:{this._err(Ne.abruptClosingOfEmptyComment),this.state=J.DATA,this.emitCurrentComment(n);break}case X.EOF:{this._err(Ne.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="-",this.state=J.COMMENT,this._stateComment(t)}}_stateComment(t){const n=this.currentToken;switch(t){case X.HYPHEN_MINUS:{this.state=J.COMMENT_END_DASH;break}case X.LESS_THAN_SIGN:{n.data+="<",this.state=J.COMMENT_LESS_THAN_SIGN;break}case X.NULL:{this._err(Ne.unexpectedNullCharacter),n.data+=yn;break}case X.EOF:{this._err(Ne.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+=String.fromCodePoint(t)}}_stateCommentLessThanSign(t){const n=this.currentToken;switch(t){case X.EXCLAMATION_MARK:{n.data+="!",this.state=J.COMMENT_LESS_THAN_SIGN_BANG;break}case X.LESS_THAN_SIGN:{n.data+="<";break}default:this.state=J.COMMENT,this._stateComment(t)}}_stateCommentLessThanSignBang(t){t===X.HYPHEN_MINUS?this.state=J.COMMENT_LESS_THAN_SIGN_BANG_DASH:(this.state=J.COMMENT,this._stateComment(t))}_stateCommentLessThanSignBangDash(t){t===X.HYPHEN_MINUS?this.state=J.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:(this.state=J.COMMENT_END_DASH,this._stateCommentEndDash(t))}_stateCommentLessThanSignBangDashDash(t){t!==X.GREATER_THAN_SIGN&&t!==X.EOF&&this._err(Ne.nestedComment),this.state=J.COMMENT_END,this._stateCommentEnd(t)}_stateCommentEndDash(t){const n=this.currentToken;switch(t){case X.HYPHEN_MINUS:{this.state=J.COMMENT_END;break}case X.EOF:{this._err(Ne.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="-",this.state=J.COMMENT,this._stateComment(t)}}_stateCommentEnd(t){const n=this.currentToken;switch(t){case X.GREATER_THAN_SIGN:{this.state=J.DATA,this.emitCurrentComment(n);break}case X.EXCLAMATION_MARK:{this.state=J.COMMENT_END_BANG;break}case X.HYPHEN_MINUS:{n.data+="-";break}case X.EOF:{this._err(Ne.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="--",this.state=J.COMMENT,this._stateComment(t)}}_stateCommentEndBang(t){const n=this.currentToken;switch(t){case X.HYPHEN_MINUS:{n.data+="--!",this.state=J.COMMENT_END_DASH;break}case X.GREATER_THAN_SIGN:{this._err(Ne.incorrectlyClosedComment),this.state=J.DATA,this.emitCurrentComment(n);break}case X.EOF:{this._err(Ne.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="--!",this.state=J.COMMENT,this._stateComment(t)}}_stateDoctype(t){switch(t){case X.SPACE:case X.LINE_FEED:case X.TABULATION:case X.FORM_FEED:{this.state=J.BEFORE_DOCTYPE_NAME;break}case X.GREATER_THAN_SIGN:{this.state=J.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(t);break}case X.EOF:{this._err(Ne.eofInDoctype),this._createDoctypeToken(null);const n=this.currentToken;n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(Ne.missingWhitespaceBeforeDoctypeName),this.state=J.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(t)}}_stateBeforeDoctypeName(t){if(Wu(t))this._createDoctypeToken(String.fromCharCode(Lh(t))),this.state=J.DOCTYPE_NAME;else switch(t){case X.SPACE:case X.LINE_FEED:case X.TABULATION:case X.FORM_FEED:break;case X.NULL:{this._err(Ne.unexpectedNullCharacter),this._createDoctypeToken(yn),this.state=J.DOCTYPE_NAME;break}case X.GREATER_THAN_SIGN:{this._err(Ne.missingDoctypeName),this._createDoctypeToken(null);const n=this.currentToken;n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=J.DATA;break}case X.EOF:{this._err(Ne.eofInDoctype),this._createDoctypeToken(null);const n=this.currentToken;n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._createDoctypeToken(String.fromCodePoint(t)),this.state=J.DOCTYPE_NAME}}_stateDoctypeName(t){const n=this.currentToken;switch(t){case X.SPACE:case X.LINE_FEED:case X.TABULATION:case X.FORM_FEED:{this.state=J.AFTER_DOCTYPE_NAME;break}case X.GREATER_THAN_SIGN:{this.state=J.DATA,this.emitCurrentDoctype(n);break}case X.NULL:{this._err(Ne.unexpectedNullCharacter),n.name+=yn;break}case X.EOF:{this._err(Ne.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:n.name+=String.fromCodePoint(Wu(t)?Lh(t):t)}}_stateAfterDoctypeName(t){const n=this.currentToken;switch(t){case X.SPACE:case X.LINE_FEED:case X.TABULATION:case X.FORM_FEED:break;case X.GREATER_THAN_SIGN:{this.state=J.DATA,this.emitCurrentDoctype(n);break}case X.EOF:{this._err(Ne.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._consumeSequenceIfMatch(Ar.PUBLIC,!1)?this.state=J.AFTER_DOCTYPE_PUBLIC_KEYWORD:this._consumeSequenceIfMatch(Ar.SYSTEM,!1)?this.state=J.AFTER_DOCTYPE_SYSTEM_KEYWORD:this._ensureHibernation()||(this._err(Ne.invalidCharacterSequenceAfterDoctypeName),n.forceQuirks=!0,this.state=J.BOGUS_DOCTYPE,this._stateBogusDoctype(t))}}_stateAfterDoctypePublicKeyword(t){const n=this.currentToken;switch(t){case X.SPACE:case X.LINE_FEED:case X.TABULATION:case X.FORM_FEED:{this.state=J.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER;break}case X.QUOTATION_MARK:{this._err(Ne.missingWhitespaceAfterDoctypePublicKeyword),n.publicId="",this.state=J.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case X.APOSTROPHE:{this._err(Ne.missingWhitespaceAfterDoctypePublicKeyword),n.publicId="",this.state=J.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case X.GREATER_THAN_SIGN:{this._err(Ne.missingDoctypePublicIdentifier),n.forceQuirks=!0,this.state=J.DATA,this.emitCurrentDoctype(n);break}case X.EOF:{this._err(Ne.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(Ne.missingQuoteBeforeDoctypePublicIdentifier),n.forceQuirks=!0,this.state=J.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBeforeDoctypePublicIdentifier(t){const n=this.currentToken;switch(t){case X.SPACE:case X.LINE_FEED:case X.TABULATION:case X.FORM_FEED:break;case X.QUOTATION_MARK:{n.publicId="",this.state=J.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case X.APOSTROPHE:{n.publicId="",this.state=J.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case X.GREATER_THAN_SIGN:{this._err(Ne.missingDoctypePublicIdentifier),n.forceQuirks=!0,this.state=J.DATA,this.emitCurrentDoctype(n);break}case X.EOF:{this._err(Ne.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(Ne.missingQuoteBeforeDoctypePublicIdentifier),n.forceQuirks=!0,this.state=J.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateDoctypePublicIdentifierDoubleQuoted(t){const n=this.currentToken;switch(t){case X.QUOTATION_MARK:{this.state=J.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case X.NULL:{this._err(Ne.unexpectedNullCharacter),n.publicId+=yn;break}case X.GREATER_THAN_SIGN:{this._err(Ne.abruptDoctypePublicIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=J.DATA;break}case X.EOF:{this._err(Ne.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:n.publicId+=String.fromCodePoint(t)}}_stateDoctypePublicIdentifierSingleQuoted(t){const n=this.currentToken;switch(t){case X.APOSTROPHE:{this.state=J.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case X.NULL:{this._err(Ne.unexpectedNullCharacter),n.publicId+=yn;break}case X.GREATER_THAN_SIGN:{this._err(Ne.abruptDoctypePublicIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=J.DATA;break}case X.EOF:{this._err(Ne.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:n.publicId+=String.fromCodePoint(t)}}_stateAfterDoctypePublicIdentifier(t){const n=this.currentToken;switch(t){case X.SPACE:case X.LINE_FEED:case X.TABULATION:case X.FORM_FEED:{this.state=J.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS;break}case X.GREATER_THAN_SIGN:{this.state=J.DATA,this.emitCurrentDoctype(n);break}case X.QUOTATION_MARK:{this._err(Ne.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),n.systemId="",this.state=J.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case X.APOSTROPHE:{this._err(Ne.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),n.systemId="",this.state=J.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case X.EOF:{this._err(Ne.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(Ne.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=J.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBetweenDoctypePublicAndSystemIdentifiers(t){const n=this.currentToken;switch(t){case X.SPACE:case X.LINE_FEED:case X.TABULATION:case X.FORM_FEED:break;case X.GREATER_THAN_SIGN:{this.emitCurrentDoctype(n),this.state=J.DATA;break}case X.QUOTATION_MARK:{n.systemId="",this.state=J.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case X.APOSTROPHE:{n.systemId="",this.state=J.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case X.EOF:{this._err(Ne.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(Ne.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=J.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateAfterDoctypeSystemKeyword(t){const n=this.currentToken;switch(t){case X.SPACE:case X.LINE_FEED:case X.TABULATION:case X.FORM_FEED:{this.state=J.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER;break}case X.QUOTATION_MARK:{this._err(Ne.missingWhitespaceAfterDoctypeSystemKeyword),n.systemId="",this.state=J.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case X.APOSTROPHE:{this._err(Ne.missingWhitespaceAfterDoctypeSystemKeyword),n.systemId="",this.state=J.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case X.GREATER_THAN_SIGN:{this._err(Ne.missingDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=J.DATA,this.emitCurrentDoctype(n);break}case X.EOF:{this._err(Ne.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(Ne.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=J.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBeforeDoctypeSystemIdentifier(t){const n=this.currentToken;switch(t){case X.SPACE:case X.LINE_FEED:case X.TABULATION:case X.FORM_FEED:break;case X.QUOTATION_MARK:{n.systemId="",this.state=J.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case X.APOSTROPHE:{n.systemId="",this.state=J.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case X.GREATER_THAN_SIGN:{this._err(Ne.missingDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=J.DATA,this.emitCurrentDoctype(n);break}case X.EOF:{this._err(Ne.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(Ne.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=J.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateDoctypeSystemIdentifierDoubleQuoted(t){const n=this.currentToken;switch(t){case X.QUOTATION_MARK:{this.state=J.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case X.NULL:{this._err(Ne.unexpectedNullCharacter),n.systemId+=yn;break}case X.GREATER_THAN_SIGN:{this._err(Ne.abruptDoctypeSystemIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=J.DATA;break}case X.EOF:{this._err(Ne.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:n.systemId+=String.fromCodePoint(t)}}_stateDoctypeSystemIdentifierSingleQuoted(t){const n=this.currentToken;switch(t){case X.APOSTROPHE:{this.state=J.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case X.NULL:{this._err(Ne.unexpectedNullCharacter),n.systemId+=yn;break}case X.GREATER_THAN_SIGN:{this._err(Ne.abruptDoctypeSystemIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=J.DATA;break}case X.EOF:{this._err(Ne.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:n.systemId+=String.fromCodePoint(t)}}_stateAfterDoctypeSystemIdentifier(t){const n=this.currentToken;switch(t){case X.SPACE:case X.LINE_FEED:case X.TABULATION:case X.FORM_FEED:break;case X.GREATER_THAN_SIGN:{this.emitCurrentDoctype(n),this.state=J.DATA;break}case X.EOF:{this._err(Ne.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(Ne.unexpectedCharacterAfterDoctypeSystemIdentifier),this.state=J.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBogusDoctype(t){const n=this.currentToken;switch(t){case X.GREATER_THAN_SIGN:{this.emitCurrentDoctype(n),this.state=J.DATA;break}case X.NULL:{this._err(Ne.unexpectedNullCharacter);break}case X.EOF:{this.emitCurrentDoctype(n),this._emitEOFToken();break}}}_stateCdataSection(t){switch(t){case X.RIGHT_SQUARE_BRACKET:{this.state=J.CDATA_SECTION_BRACKET;break}case X.EOF:{this._err(Ne.eofInCdata),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateCdataSectionBracket(t){t===X.RIGHT_SQUARE_BRACKET?this.state=J.CDATA_SECTION_END:(this._emitChars("]"),this.state=J.CDATA_SECTION,this._stateCdataSection(t))}_stateCdataSectionEnd(t){switch(t){case X.GREATER_THAN_SIGN:{this.state=J.DATA;break}case X.RIGHT_SQUARE_BRACKET:{this._emitChars("]");break}default:this._emitChars("]]"),this.state=J.CDATA_SECTION,this._stateCdataSection(t)}}_stateCharacterReference(){let t=this.entityDecoder.write(this.preprocessor.html,this.preprocessor.pos);if(t<0)if(this.preprocessor.lastChunkWritten)t=this.entityDecoder.end();else{this.active=!1,this.preprocessor.pos=this.preprocessor.html.length-1,this.consumedAfterSnapshot=0,this.preprocessor.endOfChunkHit=!0;return}t===0?(this.preprocessor.pos=this.entityStartPos,this._flushCodePointConsumedAsCharacterReference(X.AMPERSAND),this.state=!this._isCharacterReferenceInAttribute()&&YC(this.preprocessor.peek(1))?J.AMBIGUOUS_AMPERSAND:this.returnState):this.state=this.returnState}_stateAmbiguousAmpersand(t){YC(t)?this._flushCodePointConsumedAsCharacterReference(t):(t===X.SEMICOLON&&this._err(Ne.unknownNamedCharacterReference),this.state=this.returnState,this._callState(t))}}const DA=new Set([k.DD,k.DT,k.LI,k.OPTGROUP,k.OPTION,k.P,k.RB,k.RP,k.RT,k.RTC]),KC=new Set([...DA,k.CAPTION,k.COLGROUP,k.TBODY,k.TD,k.TFOOT,k.TH,k.THEAD,k.TR]),Lp=new Set([k.APPLET,k.CAPTION,k.HTML,k.MARQUEE,k.OBJECT,k.TABLE,k.TD,k.TEMPLATE,k.TH]),$Q=new Set([...Lp,k.OL,k.UL]),VQ=new Set([...Lp,k.BUTTON]),WC=new Set([k.ANNOTATION_XML,k.MI,k.MN,k.MO,k.MS,k.MTEXT]),XC=new Set([k.DESC,k.FOREIGN_OBJECT,k.TITLE]),qQ=new Set([k.TR,k.TEMPLATE,k.HTML]),YQ=new Set([k.TBODY,k.TFOOT,k.THEAD,k.TEMPLATE,k.HTML]),GQ=new Set([k.TABLE,k.TEMPLATE,k.HTML]),KQ=new Set([k.TD,k.TH]);class WQ{get currentTmplContentOrNode(){return this._isInTemplate()?this.treeAdapter.getTemplateContent(this.current):this.current}constructor(t,n,r){this.treeAdapter=n,this.handler=r,this.items=[],this.tagIDs=[],this.stackTop=-1,this.tmplCount=0,this.currentTagId=k.UNKNOWN,this.current=t}_indexOf(t){return this.items.lastIndexOf(t,this.stackTop)}_isInTemplate(){return this.currentTagId===k.TEMPLATE&&this.treeAdapter.getNamespaceURI(this.current)===je.HTML}_updateCurrentElement(){this.current=this.items[this.stackTop],this.currentTagId=this.tagIDs[this.stackTop]}push(t,n){this.stackTop++,this.items[this.stackTop]=t,this.current=t,this.tagIDs[this.stackTop]=n,this.currentTagId=n,this._isInTemplate()&&this.tmplCount++,this.handler.onItemPush(t,n,!0)}pop(){const t=this.current;this.tmplCount>0&&this._isInTemplate()&&this.tmplCount--,this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(t,!0)}replace(t,n){const r=this._indexOf(t);this.items[r]=n,r===this.stackTop&&(this.current=n)}insertAfter(t,n,r){const s=this._indexOf(t)+1;this.items.splice(s,0,n),this.tagIDs.splice(s,0,r),this.stackTop++,s===this.stackTop&&this._updateCurrentElement(),this.current&&this.currentTagId!==void 0&&this.handler.onItemPush(this.current,this.currentTagId,s===this.stackTop)}popUntilTagNamePopped(t){let n=this.stackTop+1;do n=this.tagIDs.lastIndexOf(t,n-1);while(n>0&&this.treeAdapter.getNamespaceURI(this.items[n])!==je.HTML);this.shortenToLength(Math.max(n,0))}shortenToLength(t){for(;this.stackTop>=t;){const n=this.current;this.tmplCount>0&&this._isInTemplate()&&(this.tmplCount-=1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(n,this.stackTop<t)}}popUntilElementPopped(t){const n=this._indexOf(t);this.shortenToLength(Math.max(n,0))}popUntilPopped(t,n){const r=this._indexOfTagNames(t,n);this.shortenToLength(Math.max(r,0))}popUntilNumberedHeaderPopped(){this.popUntilPopped(Cx,je.HTML)}popUntilTableCellPopped(){this.popUntilPopped(KQ,je.HTML)}popAllUpToHtmlElement(){this.tmplCount=0,this.shortenToLength(1)}_indexOfTagNames(t,n){for(let r=this.stackTop;r>=0;r--)if(t.has(this.tagIDs[r])&&this.treeAdapter.getNamespaceURI(this.items[r])===n)return r;return-1}clearBackTo(t,n){const r=this._indexOfTagNames(t,n);this.shortenToLength(r+1)}clearBackToTableContext(){this.clearBackTo(GQ,je.HTML)}clearBackToTableBodyContext(){this.clearBackTo(YQ,je.HTML)}clearBackToTableRowContext(){this.clearBackTo(qQ,je.HTML)}remove(t){const n=this._indexOf(t);n>=0&&(n===this.stackTop?this.pop():(this.items.splice(n,1),this.tagIDs.splice(n,1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(t,!1)))}tryPeekProperlyNestedBodyElement(){return this.stackTop>=1&&this.tagIDs[1]===k.BODY?this.items[1]:null}contains(t){return this._indexOf(t)>-1}getCommonAncestor(t){const n=this._indexOf(t)-1;return n>=0?this.items[n]:null}isRootHtmlElementCurrent(){return this.stackTop===0&&this.tagIDs[0]===k.HTML}hasInDynamicScope(t,n){for(let r=this.stackTop;r>=0;r--){const s=this.tagIDs[r];switch(this.treeAdapter.getNamespaceURI(this.items[r])){case je.HTML:{if(s===t)return!0;if(n.has(s))return!1;break}case je.SVG:{if(XC.has(s))return!1;break}case je.MATHML:{if(WC.has(s))return!1;break}}}return!0}hasInScope(t){return this.hasInDynamicScope(t,Lp)}hasInListItemScope(t){return this.hasInDynamicScope(t,$Q)}hasInButtonScope(t){return this.hasInDynamicScope(t,VQ)}hasNumberedHeaderInScope(){for(let t=this.stackTop;t>=0;t--){const n=this.tagIDs[t];switch(this.treeAdapter.getNamespaceURI(this.items[t])){case je.HTML:{if(Cx.has(n))return!0;if(Lp.has(n))return!1;break}case je.SVG:{if(XC.has(n))return!1;break}case je.MATHML:{if(WC.has(n))return!1;break}}}return!0}hasInTableScope(t){for(let n=this.stackTop;n>=0;n--)if(this.treeAdapter.getNamespaceURI(this.items[n])===je.HTML)switch(this.tagIDs[n]){case t:return!0;case k.TABLE:case k.HTML:return!1}return!0}hasTableBodyContextInTableScope(){for(let t=this.stackTop;t>=0;t--)if(this.treeAdapter.getNamespaceURI(this.items[t])===je.HTML)switch(this.tagIDs[t]){case k.TBODY:case k.THEAD:case k.TFOOT:return!0;case k.TABLE:case k.HTML:return!1}return!0}hasInSelectScope(t){for(let n=this.stackTop;n>=0;n--)if(this.treeAdapter.getNamespaceURI(this.items[n])===je.HTML)switch(this.tagIDs[n]){case t:return!0;case k.OPTION:case k.OPTGROUP:break;default:return!1}return!0}generateImpliedEndTags(){for(;this.currentTagId!==void 0&&DA.has(this.currentTagId);)this.pop()}generateImpliedEndTagsThoroughly(){for(;this.currentTagId!==void 0&&KC.has(this.currentTagId);)this.pop()}generateImpliedEndTagsWithExclusion(t){for(;this.currentTagId!==void 0&&this.currentTagId!==t&&KC.has(this.currentTagId);)this.pop()}}const Q1=3;var qs;(function(e){e[e.Marker=0]="Marker",e[e.Element=1]="Element"})(qs||(qs={}));const QC={type:qs.Marker};class XQ{constructor(t){this.treeAdapter=t,this.entries=[],this.bookmark=null}_getNoahArkConditionCandidates(t,n){const r=[],s=n.length,a=this.treeAdapter.getTagName(t),l=this.treeAdapter.getNamespaceURI(t);for(let c=0;c<this.entries.length;c++){const u=this.entries[c];if(u.type===qs.Marker)break;const{element:h}=u;if(this.treeAdapter.getTagName(h)===a&&this.treeAdapter.getNamespaceURI(h)===l){const m=this.treeAdapter.getAttrList(h);m.length===s&&r.push({idx:c,attrs:m})}}return r}_ensureNoahArkCondition(t){if(this.entries.length<Q1)return;const n=this.treeAdapter.getAttrList(t),r=this._getNoahArkConditionCandidates(t,n);if(r.length<Q1)return;const s=new Map(n.map(l=>[l.name,l.value]));let a=0;for(let l=0;l<r.length;l++){const c=r[l];c.attrs.every(u=>s.get(u.name)===u.value)&&(a+=1,a>=Q1&&this.entries.splice(c.idx,1))}}insertMarker(){this.entries.unshift(QC)}pushElement(t,n){this._ensureNoahArkCondition(t),this.entries.unshift({type:qs.Element,element:t,token:n})}insertElementAfterBookmark(t,n){const r=this.entries.indexOf(this.bookmark);this.entries.splice(r,0,{type:qs.Element,element:t,token:n})}removeEntry(t){const n=this.entries.indexOf(t);n!==-1&&this.entries.splice(n,1)}clearToLastMarker(){const t=this.entries.indexOf(QC);t===-1?this.entries.length=0:this.entries.splice(0,t+1)}getElementEntryInScopeWithTagName(t){const n=this.entries.find(r=>r.type===qs.Marker||this.treeAdapter.getTagName(r.element)===t);return n&&n.type===qs.Element?n:null}getElementEntry(t){return this.entries.find(n=>n.type===qs.Element&&n.element===t)}}const xa={createDocument(){return{nodeName:"#document",mode:ds.NO_QUIRKS,childNodes:[]}},createDocumentFragment(){return{nodeName:"#document-fragment",childNodes:[]}},createElement(e,t,n){return{nodeName:e,tagName:e,attrs:n,namespaceURI:t,childNodes:[],parentNode:null}},createCommentNode(e){return{nodeName:"#comment",data:e,parentNode:null}},createTextNode(e){return{nodeName:"#text",value:e,parentNode:null}},appendChild(e,t){e.childNodes.push(t),t.parentNode=e},insertBefore(e,t,n){const r=e.childNodes.indexOf(n);e.childNodes.splice(r,0,t),t.parentNode=e},setTemplateContent(e,t){e.content=t},getTemplateContent(e){return e.content},setDocumentType(e,t,n,r){const s=e.childNodes.find(a=>a.nodeName==="#documentType");if(s)s.name=t,s.publicId=n,s.systemId=r;else{const a={nodeName:"#documentType",name:t,publicId:n,systemId:r,parentNode:null};xa.appendChild(e,a)}},setDocumentMode(e,t){e.mode=t},getDocumentMode(e){return e.mode},detachNode(e){if(e.parentNode){const t=e.parentNode.childNodes.indexOf(e);e.parentNode.childNodes.splice(t,1),e.parentNode=null}},insertText(e,t){if(e.childNodes.length>0){const n=e.childNodes[e.childNodes.length-1];if(xa.isTextNode(n)){n.value+=t;return}}xa.appendChild(e,xa.createTextNode(t))},insertTextBefore(e,t,n){const r=e.childNodes[e.childNodes.indexOf(n)-1];r&&xa.isTextNode(r)?r.value+=t:xa.insertBefore(e,xa.createTextNode(t),n)},adoptAttributes(e,t){const n=new Set(e.attrs.map(r=>r.name));for(let r=0;r<t.length;r++)n.has(t[r].name)||e.attrs.push(t[r])},getFirstChild(e){return e.childNodes[0]},getChildNodes(e){return e.childNodes},getParentNode(e){return e.parentNode},getAttrList(e){return e.attrs},getTagName(e){return e.tagName},getNamespaceURI(e){return e.namespaceURI},getTextNodeContent(e){return e.value},getCommentNodeContent(e){return e.data},getDocumentTypeNodeName(e){return e.name},getDocumentTypeNodePublicId(e){return e.publicId},getDocumentTypeNodeSystemId(e){return e.systemId},isTextNode(e){return e.nodeName==="#text"},isCommentNode(e){return e.nodeName==="#comment"},isDocumentTypeNode(e){return e.nodeName==="#documentType"},isElementNode(e){return Object.prototype.hasOwnProperty.call(e,"tagName")},setNodeSourceCodeLocation(e,t){e.sourceCodeLocation=t},getNodeSourceCodeLocation(e){return e.sourceCodeLocation},updateNodeSourceCodeLocation(e,t){e.sourceCodeLocation={...e.sourceCodeLocation,...t}}},PA="html",QQ="about:legacy-compat",ZQ="http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd",BA=["+//silmaril//dtd html pro v0r11 19970101//","-//as//dtd html 3.0 aswedit + extensions//","-//advasoft ltd//dtd html 3.0 aswedit + extensions//","-//ietf//dtd html 2.0 level 1//","-//ietf//dtd html 2.0 level 2//","-//ietf//dtd html 2.0 strict level 1//","-//ietf//dtd html 2.0 strict level 2//","-//ietf//dtd html 2.0 strict//","-//ietf//dtd html 2.0//","-//ietf//dtd html 2.1e//","-//ietf//dtd html 3.0//","-//ietf//dtd html 3.2 final//","-//ietf//dtd html 3.2//","-//ietf//dtd html 3//","-//ietf//dtd html level 0//","-//ietf//dtd html level 1//","-//ietf//dtd html level 2//","-//ietf//dtd html level 3//","-//ietf//dtd html strict level 0//","-//ietf//dtd html strict level 1//","-//ietf//dtd html strict level 2//","-//ietf//dtd html strict level 3//","-//ietf//dtd html strict//","-//ietf//dtd html//","-//metrius//dtd metrius presentational//","-//microsoft//dtd internet explorer 2.0 html strict//","-//microsoft//dtd internet explorer 2.0 html//","-//microsoft//dtd internet explorer 2.0 tables//","-//microsoft//dtd internet explorer 3.0 html strict//","-//microsoft//dtd internet explorer 3.0 html//","-//microsoft//dtd internet explorer 3.0 tables//","-//netscape comm. corp.//dtd html//","-//netscape comm. corp.//dtd strict html//","-//o'reilly and associates//dtd html 2.0//","-//o'reilly and associates//dtd html extended 1.0//","-//o'reilly and associates//dtd html extended relaxed 1.0//","-//sq//dtd html 2.0 hotmetal + extensions//","-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//","-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//","-//spyglass//dtd html 2.0 extended//","-//sun microsystems corp.//dtd hotjava html//","-//sun microsystems corp.//dtd hotjava strict html//","-//w3c//dtd html 3 1995-03-24//","-//w3c//dtd html 3.2 draft//","-//w3c//dtd html 3.2 final//","-//w3c//dtd html 3.2//","-//w3c//dtd html 3.2s draft//","-//w3c//dtd html 4.0 frameset//","-//w3c//dtd html 4.0 transitional//","-//w3c//dtd html experimental 19960712//","-//w3c//dtd html experimental 970421//","-//w3c//dtd w3 html//","-//w3o//dtd w3 html 3.0//","-//webtechs//dtd mozilla html 2.0//","-//webtechs//dtd mozilla html//"],JQ=[...BA,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"],eZ=new Set(["-//w3o//dtd w3 html strict 3.0//en//","-/w3c/dtd html 4.0 transitional/en","html"]),zA=["-//w3c//dtd xhtml 1.0 frameset//","-//w3c//dtd xhtml 1.0 transitional//"],tZ=[...zA,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"];function ZC(e,t){return t.some(n=>e.startsWith(n))}function nZ(e){return e.name===PA&&e.publicId===null&&(e.systemId===null||e.systemId===QQ)}function rZ(e){if(e.name!==PA)return ds.QUIRKS;const{systemId:t}=e;if(t&&t.toLowerCase()===ZQ)return ds.QUIRKS;let{publicId:n}=e;if(n!==null){if(n=n.toLowerCase(),eZ.has(n))return ds.QUIRKS;let r=t===null?JQ:BA;if(ZC(n,r))return ds.QUIRKS;if(r=t===null?zA:tZ,ZC(n,r))return ds.LIMITED_QUIRKS}return ds.NO_QUIRKS}const JC={TEXT_HTML:"text/html",APPLICATION_XML:"application/xhtml+xml"},sZ="definitionurl",iZ="definitionURL",aZ=new Map(["attributeName","attributeType","baseFrequency","baseProfile","calcMode","clipPathUnits","diffuseConstant","edgeMode","filterUnits","glyphRef","gradientTransform","gradientUnits","kernelMatrix","kernelUnitLength","keyPoints","keySplines","keyTimes","lengthAdjust","limitingConeAngle","markerHeight","markerUnits","markerWidth","maskContentUnits","maskUnits","numOctaves","pathLength","patternContentUnits","patternTransform","patternUnits","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","refX","refY","repeatCount","repeatDur","requiredExtensions","requiredFeatures","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stitchTiles","surfaceScale","systemLanguage","tableValues","targetX","targetY","textLength","viewBox","viewTarget","xChannelSelector","yChannelSelector","zoomAndPan"].map(e=>[e.toLowerCase(),e])),oZ=new Map([["xlink:actuate",{prefix:"xlink",name:"actuate",namespace:je.XLINK}],["xlink:arcrole",{prefix:"xlink",name:"arcrole",namespace:je.XLINK}],["xlink:href",{prefix:"xlink",name:"href",namespace:je.XLINK}],["xlink:role",{prefix:"xlink",name:"role",namespace:je.XLINK}],["xlink:show",{prefix:"xlink",name:"show",namespace:je.XLINK}],["xlink:title",{prefix:"xlink",name:"title",namespace:je.XLINK}],["xlink:type",{prefix:"xlink",name:"type",namespace:je.XLINK}],["xml:lang",{prefix:"xml",name:"lang",namespace:je.XML}],["xml:space",{prefix:"xml",name:"space",namespace:je.XML}],["xmlns",{prefix:"",name:"xmlns",namespace:je.XMLNS}],["xmlns:xlink",{prefix:"xmlns",name:"xlink",namespace:je.XMLNS}]]),lZ=new Map(["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","textPath"].map(e=>[e.toLowerCase(),e])),cZ=new Set([k.B,k.BIG,k.BLOCKQUOTE,k.BODY,k.BR,k.CENTER,k.CODE,k.DD,k.DIV,k.DL,k.DT,k.EM,k.EMBED,k.H1,k.H2,k.H3,k.H4,k.H5,k.H6,k.HEAD,k.HR,k.I,k.IMG,k.LI,k.LISTING,k.MENU,k.META,k.NOBR,k.OL,k.P,k.PRE,k.RUBY,k.S,k.SMALL,k.SPAN,k.STRONG,k.STRIKE,k.SUB,k.SUP,k.TABLE,k.TT,k.U,k.UL,k.VAR]);function uZ(e){const t=e.tagID;return t===k.FONT&&e.attrs.some(({name:r})=>r===No.COLOR||r===No.SIZE||r===No.FACE)||cZ.has(t)}function HA(e){for(let t=0;t<e.attrs.length;t++)if(e.attrs[t].name===sZ){e.attrs[t].name=iZ;break}}function UA(e){for(let t=0;t<e.attrs.length;t++){const n=aZ.get(e.attrs[t].name);n!=null&&(e.attrs[t].name=n)}}function H2(e){for(let t=0;t<e.attrs.length;t++){const n=oZ.get(e.attrs[t].name);n&&(e.attrs[t].prefix=n.prefix,e.attrs[t].name=n.name,e.attrs[t].namespace=n.namespace)}}function dZ(e){const t=lZ.get(e.tagName);t!=null&&(e.tagName=t,e.tagID=Nc(e.tagName))}function fZ(e,t){return t===je.MATHML&&(e===k.MI||e===k.MO||e===k.MN||e===k.MS||e===k.MTEXT)}function hZ(e,t,n){if(t===je.MATHML&&e===k.ANNOTATION_XML){for(let r=0;r<n.length;r++)if(n[r].name===No.ENCODING){const s=n[r].value.toLowerCase();return s===JC.TEXT_HTML||s===JC.APPLICATION_XML}}return t===je.SVG&&(e===k.FOREIGN_OBJECT||e===k.DESC||e===k.TITLE)}function pZ(e,t,n,r){return(!r||r===je.HTML)&&hZ(e,t,n)||(!r||r===je.MATHML)&&fZ(e,t)}const mZ="hidden",gZ=8,bZ=3;var re;(function(e){e[e.INITIAL=0]="INITIAL",e[e.BEFORE_HTML=1]="BEFORE_HTML",e[e.BEFORE_HEAD=2]="BEFORE_HEAD",e[e.IN_HEAD=3]="IN_HEAD",e[e.IN_HEAD_NO_SCRIPT=4]="IN_HEAD_NO_SCRIPT",e[e.AFTER_HEAD=5]="AFTER_HEAD",e[e.IN_BODY=6]="IN_BODY",e[e.TEXT=7]="TEXT",e[e.IN_TABLE=8]="IN_TABLE",e[e.IN_TABLE_TEXT=9]="IN_TABLE_TEXT",e[e.IN_CAPTION=10]="IN_CAPTION",e[e.IN_COLUMN_GROUP=11]="IN_COLUMN_GROUP",e[e.IN_TABLE_BODY=12]="IN_TABLE_BODY",e[e.IN_ROW=13]="IN_ROW",e[e.IN_CELL=14]="IN_CELL",e[e.IN_SELECT=15]="IN_SELECT",e[e.IN_SELECT_IN_TABLE=16]="IN_SELECT_IN_TABLE",e[e.IN_TEMPLATE=17]="IN_TEMPLATE",e[e.AFTER_BODY=18]="AFTER_BODY",e[e.IN_FRAMESET=19]="IN_FRAMESET",e[e.AFTER_FRAMESET=20]="AFTER_FRAMESET",e[e.AFTER_AFTER_BODY=21]="AFTER_AFTER_BODY",e[e.AFTER_AFTER_FRAMESET=22]="AFTER_AFTER_FRAMESET"})(re||(re={}));const xZ={startLine:-1,startCol:-1,startOffset:-1,endLine:-1,endCol:-1,endOffset:-1},FA=new Set([k.TABLE,k.TBODY,k.TFOOT,k.THEAD,k.TR]),ew={scriptingEnabled:!0,sourceCodeLocationInfo:!1,treeAdapter:xa,onParseError:null};class tw{constructor(t,n,r=null,s=null){this.fragmentContext=r,this.scriptHandler=s,this.currentToken=null,this.stopped=!1,this.insertionMode=re.INITIAL,this.originalInsertionMode=re.INITIAL,this.headElement=null,this.formElement=null,this.currentNotInHTML=!1,this.tmplInsertionModeStack=[],this.pendingCharacterTokens=[],this.hasNonWhitespacePendingCharacterToken=!1,this.framesetOk=!0,this.skipNextNewLine=!1,this.fosterParentingEnabled=!1,this.options={...ew,...t},this.treeAdapter=this.options.treeAdapter,this.onParseError=this.options.onParseError,this.onParseError&&(this.options.sourceCodeLocationInfo=!0),this.document=n??this.treeAdapter.createDocument(),this.tokenizer=new FQ(this.options,this),this.activeFormattingElements=new XQ(this.treeAdapter),this.fragmentContextID=r?Nc(this.treeAdapter.getTagName(r)):k.UNKNOWN,this._setContextModes(r??this.document,this.fragmentContextID),this.openElements=new WQ(this.document,this.treeAdapter,this)}static parse(t,n){const r=new this(n);return r.tokenizer.write(t,!0),r.document}static getFragmentParser(t,n){const r={...ew,...n};t??(t=r.treeAdapter.createElement(be.TEMPLATE,je.HTML,[]));const s=r.treeAdapter.createElement("documentmock",je.HTML,[]),a=new this(r,s,t);return a.fragmentContextID===k.TEMPLATE&&a.tmplInsertionModeStack.unshift(re.IN_TEMPLATE),a._initTokenizerForFragmentParsing(),a._insertFakeRootElement(),a._resetInsertionMode(),a._findFormInFragmentContext(),a}getFragment(){const t=this.treeAdapter.getFirstChild(this.document),n=this.treeAdapter.createDocumentFragment();return this._adoptNodes(t,n),n}_err(t,n,r){var s;if(!this.onParseError)return;const a=(s=t.location)!==null&&s!==void 0?s:xZ,l={code:n,startLine:a.startLine,startCol:a.startCol,startOffset:a.startOffset,endLine:r?a.startLine:a.endLine,endCol:r?a.startCol:a.endCol,endOffset:r?a.startOffset:a.endOffset};this.onParseError(l)}onItemPush(t,n,r){var s,a;(a=(s=this.treeAdapter).onItemPush)===null||a===void 0||a.call(s,t),r&&this.openElements.stackTop>0&&this._setContextModes(t,n)}onItemPop(t,n){var r,s;if(this.options.sourceCodeLocationInfo&&this._setEndLocation(t,this.currentToken),(s=(r=this.treeAdapter).onItemPop)===null||s===void 0||s.call(r,t,this.openElements.current),n){let a,l;this.openElements.stackTop===0&&this.fragmentContext?(a=this.fragmentContext,l=this.fragmentContextID):{current:a,currentTagId:l}=this.openElements,this._setContextModes(a,l)}}_setContextModes(t,n){const r=t===this.document||t&&this.treeAdapter.getNamespaceURI(t)===je.HTML;this.currentNotInHTML=!r,this.tokenizer.inForeignNode=!r&&t!==void 0&&n!==void 0&&!this._isIntegrationPoint(n,t)}_switchToTextParsing(t,n){this._insertElement(t,je.HTML),this.tokenizer.state=n,this.originalInsertionMode=this.insertionMode,this.insertionMode=re.TEXT}switchToPlaintextParsing(){this.insertionMode=re.TEXT,this.originalInsertionMode=re.IN_BODY,this.tokenizer.state=In.PLAINTEXT}_getAdjustedCurrentElement(){return this.openElements.stackTop===0&&this.fragmentContext?this.fragmentContext:this.openElements.current}_findFormInFragmentContext(){let t=this.fragmentContext;for(;t;){if(this.treeAdapter.getTagName(t)===be.FORM){this.formElement=t;break}t=this.treeAdapter.getParentNode(t)}}_initTokenizerForFragmentParsing(){if(!(!this.fragmentContext||this.treeAdapter.getNamespaceURI(this.fragmentContext)!==je.HTML))switch(this.fragmentContextID){case k.TITLE:case k.TEXTAREA:{this.tokenizer.state=In.RCDATA;break}case k.STYLE:case k.XMP:case k.IFRAME:case k.NOEMBED:case k.NOFRAMES:case k.NOSCRIPT:{this.tokenizer.state=In.RAWTEXT;break}case k.SCRIPT:{this.tokenizer.state=In.SCRIPT_DATA;break}case k.PLAINTEXT:{this.tokenizer.state=In.PLAINTEXT;break}}}_setDocumentType(t){const n=t.name||"",r=t.publicId||"",s=t.systemId||"";if(this.treeAdapter.setDocumentType(this.document,n,r,s),t.location){const l=this.treeAdapter.getChildNodes(this.document).find(c=>this.treeAdapter.isDocumentTypeNode(c));l&&this.treeAdapter.setNodeSourceCodeLocation(l,t.location)}}_attachElementToTree(t,n){if(this.options.sourceCodeLocationInfo){const r=n&&{...n,startTag:n};this.treeAdapter.setNodeSourceCodeLocation(t,r)}if(this._shouldFosterParentOnInsertion())this._fosterParentElement(t);else{const r=this.openElements.currentTmplContentOrNode;this.treeAdapter.appendChild(r??this.document,t)}}_appendElement(t,n){const r=this.treeAdapter.createElement(t.tagName,n,t.attrs);this._attachElementToTree(r,t.location)}_insertElement(t,n){const r=this.treeAdapter.createElement(t.tagName,n,t.attrs);this._attachElementToTree(r,t.location),this.openElements.push(r,t.tagID)}_insertFakeElement(t,n){const r=this.treeAdapter.createElement(t,je.HTML,[]);this._attachElementToTree(r,null),this.openElements.push(r,n)}_insertTemplate(t){const n=this.treeAdapter.createElement(t.tagName,je.HTML,t.attrs),r=this.treeAdapter.createDocumentFragment();this.treeAdapter.setTemplateContent(n,r),this._attachElementToTree(n,t.location),this.openElements.push(n,t.tagID),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(r,null)}_insertFakeRootElement(){const t=this.treeAdapter.createElement(be.HTML,je.HTML,[]);this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(t,null),this.treeAdapter.appendChild(this.openElements.current,t),this.openElements.push(t,k.HTML)}_appendCommentNode(t,n){const r=this.treeAdapter.createCommentNode(t.data);this.treeAdapter.appendChild(n,r),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(r,t.location)}_insertCharacters(t){let n,r;if(this._shouldFosterParentOnInsertion()?({parent:n,beforeElement:r}=this._findFosterParentingLocation(),r?this.treeAdapter.insertTextBefore(n,t.chars,r):this.treeAdapter.insertText(n,t.chars)):(n=this.openElements.currentTmplContentOrNode,this.treeAdapter.insertText(n,t.chars)),!t.location)return;const s=this.treeAdapter.getChildNodes(n),a=r?s.lastIndexOf(r):s.length,l=s[a-1];if(this.treeAdapter.getNodeSourceCodeLocation(l)){const{endLine:u,endCol:h,endOffset:m}=t.location;this.treeAdapter.updateNodeSourceCodeLocation(l,{endLine:u,endCol:h,endOffset:m})}else this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(l,t.location)}_adoptNodes(t,n){for(let r=this.treeAdapter.getFirstChild(t);r;r=this.treeAdapter.getFirstChild(t))this.treeAdapter.detachNode(r),this.treeAdapter.appendChild(n,r)}_setEndLocation(t,n){if(this.treeAdapter.getNodeSourceCodeLocation(t)&&n.location){const r=n.location,s=this.treeAdapter.getTagName(t),a=n.type===At.END_TAG&&s===n.tagName?{endTag:{...r},endLine:r.endLine,endCol:r.endCol,endOffset:r.endOffset}:{endLine:r.startLine,endCol:r.startCol,endOffset:r.startOffset};this.treeAdapter.updateNodeSourceCodeLocation(t,a)}}shouldProcessStartTagTokenInForeignContent(t){if(!this.currentNotInHTML)return!1;let n,r;return this.openElements.stackTop===0&&this.fragmentContext?(n=this.fragmentContext,r=this.fragmentContextID):{current:n,currentTagId:r}=this.openElements,t.tagID===k.SVG&&this.treeAdapter.getTagName(n)===be.ANNOTATION_XML&&this.treeAdapter.getNamespaceURI(n)===je.MATHML?!1:this.tokenizer.inForeignNode||(t.tagID===k.MGLYPH||t.tagID===k.MALIGNMARK)&&r!==void 0&&!this._isIntegrationPoint(r,n,je.HTML)}_processToken(t){switch(t.type){case At.CHARACTER:{this.onCharacter(t);break}case At.NULL_CHARACTER:{this.onNullCharacter(t);break}case At.COMMENT:{this.onComment(t);break}case At.DOCTYPE:{this.onDoctype(t);break}case At.START_TAG:{this._processStartTag(t);break}case At.END_TAG:{this.onEndTag(t);break}case At.EOF:{this.onEof(t);break}case At.WHITESPACE_CHARACTER:{this.onWhitespaceCharacter(t);break}}}_isIntegrationPoint(t,n,r){const s=this.treeAdapter.getNamespaceURI(n),a=this.treeAdapter.getAttrList(n);return pZ(t,s,a,r)}_reconstructActiveFormattingElements(){const t=this.activeFormattingElements.entries.length;if(t){const n=this.activeFormattingElements.entries.findIndex(s=>s.type===qs.Marker||this.openElements.contains(s.element)),r=n===-1?t-1:n-1;for(let s=r;s>=0;s--){const a=this.activeFormattingElements.entries[s];this._insertElement(a.token,this.treeAdapter.getNamespaceURI(a.element)),a.element=this.openElements.current}}}_closeTableCell(){this.openElements.generateImpliedEndTags(),this.openElements.popUntilTableCellPopped(),this.activeFormattingElements.clearToLastMarker(),this.insertionMode=re.IN_ROW}_closePElement(){this.openElements.generateImpliedEndTagsWithExclusion(k.P),this.openElements.popUntilTagNamePopped(k.P)}_resetInsertionMode(){for(let t=this.openElements.stackTop;t>=0;t--)switch(t===0&&this.fragmentContext?this.fragmentContextID:this.openElements.tagIDs[t]){case k.TR:{this.insertionMode=re.IN_ROW;return}case k.TBODY:case k.THEAD:case k.TFOOT:{this.insertionMode=re.IN_TABLE_BODY;return}case k.CAPTION:{this.insertionMode=re.IN_CAPTION;return}case k.COLGROUP:{this.insertionMode=re.IN_COLUMN_GROUP;return}case k.TABLE:{this.insertionMode=re.IN_TABLE;return}case k.BODY:{this.insertionMode=re.IN_BODY;return}case k.FRAMESET:{this.insertionMode=re.IN_FRAMESET;return}case k.SELECT:{this._resetInsertionModeForSelect(t);return}case k.TEMPLATE:{this.insertionMode=this.tmplInsertionModeStack[0];return}case k.HTML:{this.insertionMode=this.headElement?re.AFTER_HEAD:re.BEFORE_HEAD;return}case k.TD:case k.TH:{if(t>0){this.insertionMode=re.IN_CELL;return}break}case k.HEAD:{if(t>0){this.insertionMode=re.IN_HEAD;return}break}}this.insertionMode=re.IN_BODY}_resetInsertionModeForSelect(t){if(t>0)for(let n=t-1;n>0;n--){const r=this.openElements.tagIDs[n];if(r===k.TEMPLATE)break;if(r===k.TABLE){this.insertionMode=re.IN_SELECT_IN_TABLE;return}}this.insertionMode=re.IN_SELECT}_isElementCausesFosterParenting(t){return FA.has(t)}_shouldFosterParentOnInsertion(){return this.fosterParentingEnabled&&this.openElements.currentTagId!==void 0&&this._isElementCausesFosterParenting(this.openElements.currentTagId)}_findFosterParentingLocation(){for(let t=this.openElements.stackTop;t>=0;t--){const n=this.openElements.items[t];switch(this.openElements.tagIDs[t]){case k.TEMPLATE:{if(this.treeAdapter.getNamespaceURI(n)===je.HTML)return{parent:this.treeAdapter.getTemplateContent(n),beforeElement:null};break}case k.TABLE:{const r=this.treeAdapter.getParentNode(n);return r?{parent:r,beforeElement:n}:{parent:this.openElements.items[t-1],beforeElement:null}}}}return{parent:this.openElements.items[0],beforeElement:null}}_fosterParentElement(t){const n=this._findFosterParentingLocation();n.beforeElement?this.treeAdapter.insertBefore(n.parent,t,n.beforeElement):this.treeAdapter.appendChild(n.parent,t)}_isSpecialElement(t,n){const r=this.treeAdapter.getNamespaceURI(t);return BQ[r].has(n)}onCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){KJ(this,t);return}switch(this.insertionMode){case re.INITIAL:{Mu(this,t);break}case re.BEFORE_HTML:{rd(this,t);break}case re.BEFORE_HEAD:{sd(this,t);break}case re.IN_HEAD:{id(this,t);break}case re.IN_HEAD_NO_SCRIPT:{ad(this,t);break}case re.AFTER_HEAD:{od(this,t);break}case re.IN_BODY:case re.IN_CAPTION:case re.IN_CELL:case re.IN_TEMPLATE:{VA(this,t);break}case re.TEXT:case re.IN_SELECT:case re.IN_SELECT_IN_TABLE:{this._insertCharacters(t);break}case re.IN_TABLE:case re.IN_TABLE_BODY:case re.IN_ROW:{Z1(this,t);break}case re.IN_TABLE_TEXT:{XA(this,t);break}case re.IN_COLUMN_GROUP:{jp(this,t);break}case re.AFTER_BODY:{Dp(this,t);break}case re.AFTER_AFTER_BODY:{ip(this,t);break}}}onNullCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){GJ(this,t);return}switch(this.insertionMode){case re.INITIAL:{Mu(this,t);break}case re.BEFORE_HTML:{rd(this,t);break}case re.BEFORE_HEAD:{sd(this,t);break}case re.IN_HEAD:{id(this,t);break}case re.IN_HEAD_NO_SCRIPT:{ad(this,t);break}case re.AFTER_HEAD:{od(this,t);break}case re.TEXT:{this._insertCharacters(t);break}case re.IN_TABLE:case re.IN_TABLE_BODY:case re.IN_ROW:{Z1(this,t);break}case re.IN_COLUMN_GROUP:{jp(this,t);break}case re.AFTER_BODY:{Dp(this,t);break}case re.AFTER_AFTER_BODY:{ip(this,t);break}}}onComment(t){if(this.skipNextNewLine=!1,this.currentNotInHTML){wx(this,t);return}switch(this.insertionMode){case re.INITIAL:case re.BEFORE_HTML:case re.BEFORE_HEAD:case re.IN_HEAD:case re.IN_HEAD_NO_SCRIPT:case re.AFTER_HEAD:case re.IN_BODY:case re.IN_TABLE:case re.IN_CAPTION:case re.IN_COLUMN_GROUP:case re.IN_TABLE_BODY:case re.IN_ROW:case re.IN_CELL:case re.IN_SELECT:case re.IN_SELECT_IN_TABLE:case re.IN_TEMPLATE:case re.IN_FRAMESET:case re.AFTER_FRAMESET:{wx(this,t);break}case re.IN_TABLE_TEXT:{Iu(this,t);break}case re.AFTER_BODY:{CZ(this,t);break}case re.AFTER_AFTER_BODY:case re.AFTER_AFTER_FRAMESET:{wZ(this,t);break}}}onDoctype(t){switch(this.skipNextNewLine=!1,this.insertionMode){case re.INITIAL:{NZ(this,t);break}case re.BEFORE_HEAD:case re.IN_HEAD:case re.IN_HEAD_NO_SCRIPT:case re.AFTER_HEAD:{this._err(t,Ne.misplacedDoctype);break}case re.IN_TABLE_TEXT:{Iu(this,t);break}}}onStartTag(t){this.skipNextNewLine=!1,this.currentToken=t,this._processStartTag(t),t.selfClosing&&!t.ackSelfClosing&&this._err(t,Ne.nonVoidHtmlElementStartTagWithTrailingSolidus)}_processStartTag(t){this.shouldProcessStartTagTokenInForeignContent(t)?WJ(this,t):this._startTagOutsideForeignContent(t)}_startTagOutsideForeignContent(t){switch(this.insertionMode){case re.INITIAL:{Mu(this,t);break}case re.BEFORE_HTML:{_Z(this,t);break}case re.BEFORE_HEAD:{RZ(this,t);break}case re.IN_HEAD:{Ms(this,t);break}case re.IN_HEAD_NO_SCRIPT:{OZ(this,t);break}case re.AFTER_HEAD:{jZ(this,t);break}case re.IN_BODY:{fr(this,t);break}case re.IN_TABLE:{pc(this,t);break}case re.IN_TABLE_TEXT:{Iu(this,t);break}case re.IN_CAPTION:{MJ(this,t);break}case re.IN_COLUMN_GROUP:{$2(this,t);break}case re.IN_TABLE_BODY:{Bm(this,t);break}case re.IN_ROW:{zm(this,t);break}case re.IN_CELL:{LJ(this,t);break}case re.IN_SELECT:{JA(this,t);break}case re.IN_SELECT_IN_TABLE:{DJ(this,t);break}case re.IN_TEMPLATE:{BJ(this,t);break}case re.AFTER_BODY:{HJ(this,t);break}case re.IN_FRAMESET:{UJ(this,t);break}case re.AFTER_FRAMESET:{$J(this,t);break}case re.AFTER_AFTER_BODY:{qJ(this,t);break}case re.AFTER_AFTER_FRAMESET:{YJ(this,t);break}}}onEndTag(t){this.skipNextNewLine=!1,this.currentToken=t,this.currentNotInHTML?XJ(this,t):this._endTagOutsideForeignContent(t)}_endTagOutsideForeignContent(t){switch(this.insertionMode){case re.INITIAL:{Mu(this,t);break}case re.BEFORE_HTML:{AZ(this,t);break}case re.BEFORE_HEAD:{MZ(this,t);break}case re.IN_HEAD:{IZ(this,t);break}case re.IN_HEAD_NO_SCRIPT:{LZ(this,t);break}case re.AFTER_HEAD:{DZ(this,t);break}case re.IN_BODY:{Pm(this,t);break}case re.TEXT:{EJ(this,t);break}case re.IN_TABLE:{Nd(this,t);break}case re.IN_TABLE_TEXT:{Iu(this,t);break}case re.IN_CAPTION:{IJ(this,t);break}case re.IN_COLUMN_GROUP:{OJ(this,t);break}case re.IN_TABLE_BODY:{Nx(this,t);break}case re.IN_ROW:{ZA(this,t);break}case re.IN_CELL:{jJ(this,t);break}case re.IN_SELECT:{eR(this,t);break}case re.IN_SELECT_IN_TABLE:{PJ(this,t);break}case re.IN_TEMPLATE:{zJ(this,t);break}case re.AFTER_BODY:{nR(this,t);break}case re.IN_FRAMESET:{FJ(this,t);break}case re.AFTER_FRAMESET:{VJ(this,t);break}case re.AFTER_AFTER_BODY:{ip(this,t);break}}}onEof(t){switch(this.insertionMode){case re.INITIAL:{Mu(this,t);break}case re.BEFORE_HTML:{rd(this,t);break}case re.BEFORE_HEAD:{sd(this,t);break}case re.IN_HEAD:{id(this,t);break}case re.IN_HEAD_NO_SCRIPT:{ad(this,t);break}case re.AFTER_HEAD:{od(this,t);break}case re.IN_BODY:case re.IN_TABLE:case re.IN_CAPTION:case re.IN_COLUMN_GROUP:case re.IN_TABLE_BODY:case re.IN_ROW:case re.IN_CELL:case re.IN_SELECT:case re.IN_SELECT_IN_TABLE:{KA(this,t);break}case re.TEXT:{TJ(this,t);break}case re.IN_TABLE_TEXT:{Iu(this,t);break}case re.IN_TEMPLATE:{tR(this,t);break}case re.AFTER_BODY:case re.IN_FRAMESET:case re.AFTER_FRAMESET:case re.AFTER_AFTER_BODY:case re.AFTER_AFTER_FRAMESET:{F2(this,t);break}}}onWhitespaceCharacter(t){if(this.skipNextNewLine&&(this.skipNextNewLine=!1,t.chars.charCodeAt(0)===X.LINE_FEED)){if(t.chars.length===1)return;t.chars=t.chars.substr(1)}if(this.tokenizer.inForeignNode){this._insertCharacters(t);return}switch(this.insertionMode){case re.IN_HEAD:case re.IN_HEAD_NO_SCRIPT:case re.AFTER_HEAD:case re.TEXT:case re.IN_COLUMN_GROUP:case re.IN_SELECT:case re.IN_SELECT_IN_TABLE:case re.IN_FRAMESET:case re.AFTER_FRAMESET:{this._insertCharacters(t);break}case re.IN_BODY:case re.IN_CAPTION:case re.IN_CELL:case re.IN_TEMPLATE:case re.AFTER_BODY:case re.AFTER_AFTER_BODY:case re.AFTER_AFTER_FRAMESET:{$A(this,t);break}case re.IN_TABLE:case re.IN_TABLE_BODY:case re.IN_ROW:{Z1(this,t);break}case re.IN_TABLE_TEXT:{WA(this,t);break}}}}function yZ(e,t){let n=e.activeFormattingElements.getElementEntryInScopeWithTagName(t.tagName);return n?e.openElements.contains(n.element)?e.openElements.hasInScope(t.tagID)||(n=null):(e.activeFormattingElements.removeEntry(n),n=null):GA(e,t),n}function vZ(e,t){let n=null,r=e.openElements.stackTop;for(;r>=0;r--){const s=e.openElements.items[r];if(s===t.element)break;e._isSpecialElement(s,e.openElements.tagIDs[r])&&(n=s)}return n||(e.openElements.shortenToLength(Math.max(r,0)),e.activeFormattingElements.removeEntry(t)),n}function EZ(e,t,n){let r=t,s=e.openElements.getCommonAncestor(t);for(let a=0,l=s;l!==n;a++,l=s){s=e.openElements.getCommonAncestor(l);const c=e.activeFormattingElements.getElementEntry(l),u=c&&a>=bZ;!c||u?(u&&e.activeFormattingElements.removeEntry(c),e.openElements.remove(l)):(l=TZ(e,c),r===t&&(e.activeFormattingElements.bookmark=c),e.treeAdapter.detachNode(r),e.treeAdapter.appendChild(l,r),r=l)}return r}function TZ(e,t){const n=e.treeAdapter.getNamespaceURI(t.element),r=e.treeAdapter.createElement(t.token.tagName,n,t.token.attrs);return e.openElements.replace(t.element,r),t.element=r,r}function SZ(e,t,n){const r=e.treeAdapter.getTagName(t),s=Nc(r);if(e._isElementCausesFosterParenting(s))e._fosterParentElement(n);else{const a=e.treeAdapter.getNamespaceURI(t);s===k.TEMPLATE&&a===je.HTML&&(t=e.treeAdapter.getTemplateContent(t)),e.treeAdapter.appendChild(t,n)}}function kZ(e,t,n){const r=e.treeAdapter.getNamespaceURI(n.element),{token:s}=n,a=e.treeAdapter.createElement(s.tagName,r,s.attrs);e._adoptNodes(t,a),e.treeAdapter.appendChild(t,a),e.activeFormattingElements.insertElementAfterBookmark(a,s),e.activeFormattingElements.removeEntry(n),e.openElements.remove(n.element),e.openElements.insertAfter(t,a,s.tagID)}function U2(e,t){for(let n=0;n<gZ;n++){const r=yZ(e,t);if(!r)break;const s=vZ(e,r);if(!s)break;e.activeFormattingElements.bookmark=r;const a=EZ(e,s,r.element),l=e.openElements.getCommonAncestor(r.element);e.treeAdapter.detachNode(a),l&&SZ(e,l,a),kZ(e,s,r)}}function wx(e,t){e._appendCommentNode(t,e.openElements.currentTmplContentOrNode)}function CZ(e,t){e._appendCommentNode(t,e.openElements.items[0])}function wZ(e,t){e._appendCommentNode(t,e.document)}function F2(e,t){if(e.stopped=!0,t.location){const n=e.fragmentContext?0:2;for(let r=e.openElements.stackTop;r>=n;r--)e._setEndLocation(e.openElements.items[r],t);if(!e.fragmentContext&&e.openElements.stackTop>=0){const r=e.openElements.items[0],s=e.treeAdapter.getNodeSourceCodeLocation(r);if(s&&!s.endTag&&(e._setEndLocation(r,t),e.openElements.stackTop>=1)){const a=e.openElements.items[1],l=e.treeAdapter.getNodeSourceCodeLocation(a);l&&!l.endTag&&e._setEndLocation(a,t)}}}}function NZ(e,t){e._setDocumentType(t);const n=t.forceQuirks?ds.QUIRKS:rZ(t);nZ(t)||e._err(t,Ne.nonConformingDoctype),e.treeAdapter.setDocumentMode(e.document,n),e.insertionMode=re.BEFORE_HTML}function Mu(e,t){e._err(t,Ne.missingDoctype,!0),e.treeAdapter.setDocumentMode(e.document,ds.QUIRKS),e.insertionMode=re.BEFORE_HTML,e._processToken(t)}function _Z(e,t){t.tagID===k.HTML?(e._insertElement(t,je.HTML),e.insertionMode=re.BEFORE_HEAD):rd(e,t)}function AZ(e,t){const n=t.tagID;(n===k.HTML||n===k.HEAD||n===k.BODY||n===k.BR)&&rd(e,t)}function rd(e,t){e._insertFakeRootElement(),e.insertionMode=re.BEFORE_HEAD,e._processToken(t)}function RZ(e,t){switch(t.tagID){case k.HTML:{fr(e,t);break}case k.HEAD:{e._insertElement(t,je.HTML),e.headElement=e.openElements.current,e.insertionMode=re.IN_HEAD;break}default:sd(e,t)}}function MZ(e,t){const n=t.tagID;n===k.HEAD||n===k.BODY||n===k.HTML||n===k.BR?sd(e,t):e._err(t,Ne.endTagWithoutMatchingOpenElement)}function sd(e,t){e._insertFakeElement(be.HEAD,k.HEAD),e.headElement=e.openElements.current,e.insertionMode=re.IN_HEAD,e._processToken(t)}function Ms(e,t){switch(t.tagID){case k.HTML:{fr(e,t);break}case k.BASE:case k.BASEFONT:case k.BGSOUND:case k.LINK:case k.META:{e._appendElement(t,je.HTML),t.ackSelfClosing=!0;break}case k.TITLE:{e._switchToTextParsing(t,In.RCDATA);break}case k.NOSCRIPT:{e.options.scriptingEnabled?e._switchToTextParsing(t,In.RAWTEXT):(e._insertElement(t,je.HTML),e.insertionMode=re.IN_HEAD_NO_SCRIPT);break}case k.NOFRAMES:case k.STYLE:{e._switchToTextParsing(t,In.RAWTEXT);break}case k.SCRIPT:{e._switchToTextParsing(t,In.SCRIPT_DATA);break}case k.TEMPLATE:{e._insertTemplate(t),e.activeFormattingElements.insertMarker(),e.framesetOk=!1,e.insertionMode=re.IN_TEMPLATE,e.tmplInsertionModeStack.unshift(re.IN_TEMPLATE);break}case k.HEAD:{e._err(t,Ne.misplacedStartTagForHeadElement);break}default:id(e,t)}}function IZ(e,t){switch(t.tagID){case k.HEAD:{e.openElements.pop(),e.insertionMode=re.AFTER_HEAD;break}case k.BODY:case k.BR:case k.HTML:{id(e,t);break}case k.TEMPLATE:{Ko(e,t);break}default:e._err(t,Ne.endTagWithoutMatchingOpenElement)}}function Ko(e,t){e.openElements.tmplCount>0?(e.openElements.generateImpliedEndTagsThoroughly(),e.openElements.currentTagId!==k.TEMPLATE&&e._err(t,Ne.closingOfElementWithOpenChildElements),e.openElements.popUntilTagNamePopped(k.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode()):e._err(t,Ne.endTagWithoutMatchingOpenElement)}function id(e,t){e.openElements.pop(),e.insertionMode=re.AFTER_HEAD,e._processToken(t)}function OZ(e,t){switch(t.tagID){case k.HTML:{fr(e,t);break}case k.BASEFONT:case k.BGSOUND:case k.HEAD:case k.LINK:case k.META:case k.NOFRAMES:case k.STYLE:{Ms(e,t);break}case k.NOSCRIPT:{e._err(t,Ne.nestedNoscriptInHead);break}default:ad(e,t)}}function LZ(e,t){switch(t.tagID){case k.NOSCRIPT:{e.openElements.pop(),e.insertionMode=re.IN_HEAD;break}case k.BR:{ad(e,t);break}default:e._err(t,Ne.endTagWithoutMatchingOpenElement)}}function ad(e,t){const n=t.type===At.EOF?Ne.openElementsLeftAfterEof:Ne.disallowedContentInNoscriptInHead;e._err(t,n),e.openElements.pop(),e.insertionMode=re.IN_HEAD,e._processToken(t)}function jZ(e,t){switch(t.tagID){case k.HTML:{fr(e,t);break}case k.BODY:{e._insertElement(t,je.HTML),e.framesetOk=!1,e.insertionMode=re.IN_BODY;break}case k.FRAMESET:{e._insertElement(t,je.HTML),e.insertionMode=re.IN_FRAMESET;break}case k.BASE:case k.BASEFONT:case k.BGSOUND:case k.LINK:case k.META:case k.NOFRAMES:case k.SCRIPT:case k.STYLE:case k.TEMPLATE:case k.TITLE:{e._err(t,Ne.abandonedHeadElementChild),e.openElements.push(e.headElement,k.HEAD),Ms(e,t),e.openElements.remove(e.headElement);break}case k.HEAD:{e._err(t,Ne.misplacedStartTagForHeadElement);break}default:od(e,t)}}function DZ(e,t){switch(t.tagID){case k.BODY:case k.HTML:case k.BR:{od(e,t);break}case k.TEMPLATE:{Ko(e,t);break}default:e._err(t,Ne.endTagWithoutMatchingOpenElement)}}function od(e,t){e._insertFakeElement(be.BODY,k.BODY),e.insertionMode=re.IN_BODY,Dm(e,t)}function Dm(e,t){switch(t.type){case At.CHARACTER:{VA(e,t);break}case At.WHITESPACE_CHARACTER:{$A(e,t);break}case At.COMMENT:{wx(e,t);break}case At.START_TAG:{fr(e,t);break}case At.END_TAG:{Pm(e,t);break}case At.EOF:{KA(e,t);break}}}function $A(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t)}function VA(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t),e.framesetOk=!1}function PZ(e,t){e.openElements.tmplCount===0&&e.treeAdapter.adoptAttributes(e.openElements.items[0],t.attrs)}function BZ(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e.openElements.tmplCount===0&&(e.framesetOk=!1,e.treeAdapter.adoptAttributes(n,t.attrs))}function zZ(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();e.framesetOk&&n&&(e.treeAdapter.detachNode(n),e.openElements.popAllUpToHtmlElement(),e._insertElement(t,je.HTML),e.insertionMode=re.IN_FRAMESET)}function HZ(e,t){e.openElements.hasInButtonScope(k.P)&&e._closePElement(),e._insertElement(t,je.HTML)}function UZ(e,t){e.openElements.hasInButtonScope(k.P)&&e._closePElement(),e.openElements.currentTagId!==void 0&&Cx.has(e.openElements.currentTagId)&&e.openElements.pop(),e._insertElement(t,je.HTML)}function FZ(e,t){e.openElements.hasInButtonScope(k.P)&&e._closePElement(),e._insertElement(t,je.HTML),e.skipNextNewLine=!0,e.framesetOk=!1}function $Z(e,t){const n=e.openElements.tmplCount>0;(!e.formElement||n)&&(e.openElements.hasInButtonScope(k.P)&&e._closePElement(),e._insertElement(t,je.HTML),n||(e.formElement=e.openElements.current))}function VZ(e,t){e.framesetOk=!1;const n=t.tagID;for(let r=e.openElements.stackTop;r>=0;r--){const s=e.openElements.tagIDs[r];if(n===k.LI&&s===k.LI||(n===k.DD||n===k.DT)&&(s===k.DD||s===k.DT)){e.openElements.generateImpliedEndTagsWithExclusion(s),e.openElements.popUntilTagNamePopped(s);break}if(s!==k.ADDRESS&&s!==k.DIV&&s!==k.P&&e._isSpecialElement(e.openElements.items[r],s))break}e.openElements.hasInButtonScope(k.P)&&e._closePElement(),e._insertElement(t,je.HTML)}function qZ(e,t){e.openElements.hasInButtonScope(k.P)&&e._closePElement(),e._insertElement(t,je.HTML),e.tokenizer.state=In.PLAINTEXT}function YZ(e,t){e.openElements.hasInScope(k.BUTTON)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(k.BUTTON)),e._reconstructActiveFormattingElements(),e._insertElement(t,je.HTML),e.framesetOk=!1}function GZ(e,t){const n=e.activeFormattingElements.getElementEntryInScopeWithTagName(be.A);n&&(U2(e,t),e.openElements.remove(n.element),e.activeFormattingElements.removeEntry(n)),e._reconstructActiveFormattingElements(),e._insertElement(t,je.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function KZ(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,je.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function WZ(e,t){e._reconstructActiveFormattingElements(),e.openElements.hasInScope(k.NOBR)&&(U2(e,t),e._reconstructActiveFormattingElements()),e._insertElement(t,je.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function XZ(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,je.HTML),e.activeFormattingElements.insertMarker(),e.framesetOk=!1}function QZ(e,t){e.treeAdapter.getDocumentMode(e.document)!==ds.QUIRKS&&e.openElements.hasInButtonScope(k.P)&&e._closePElement(),e._insertElement(t,je.HTML),e.framesetOk=!1,e.insertionMode=re.IN_TABLE}function qA(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,je.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function YA(e){const t=LA(e,No.TYPE);return t!=null&&t.toLowerCase()===mZ}function ZZ(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,je.HTML),YA(t)||(e.framesetOk=!1),t.ackSelfClosing=!0}function JZ(e,t){e._appendElement(t,je.HTML),t.ackSelfClosing=!0}function eJ(e,t){e.openElements.hasInButtonScope(k.P)&&e._closePElement(),e._appendElement(t,je.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function tJ(e,t){t.tagName=be.IMG,t.tagID=k.IMG,qA(e,t)}function nJ(e,t){e._insertElement(t,je.HTML),e.skipNextNewLine=!0,e.tokenizer.state=In.RCDATA,e.originalInsertionMode=e.insertionMode,e.framesetOk=!1,e.insertionMode=re.TEXT}function rJ(e,t){e.openElements.hasInButtonScope(k.P)&&e._closePElement(),e._reconstructActiveFormattingElements(),e.framesetOk=!1,e._switchToTextParsing(t,In.RAWTEXT)}function sJ(e,t){e.framesetOk=!1,e._switchToTextParsing(t,In.RAWTEXT)}function nw(e,t){e._switchToTextParsing(t,In.RAWTEXT)}function iJ(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,je.HTML),e.framesetOk=!1,e.insertionMode=e.insertionMode===re.IN_TABLE||e.insertionMode===re.IN_CAPTION||e.insertionMode===re.IN_TABLE_BODY||e.insertionMode===re.IN_ROW||e.insertionMode===re.IN_CELL?re.IN_SELECT_IN_TABLE:re.IN_SELECT}function aJ(e,t){e.openElements.currentTagId===k.OPTION&&e.openElements.pop(),e._reconstructActiveFormattingElements(),e._insertElement(t,je.HTML)}function oJ(e,t){e.openElements.hasInScope(k.RUBY)&&e.openElements.generateImpliedEndTags(),e._insertElement(t,je.HTML)}function lJ(e,t){e.openElements.hasInScope(k.RUBY)&&e.openElements.generateImpliedEndTagsWithExclusion(k.RTC),e._insertElement(t,je.HTML)}function cJ(e,t){e._reconstructActiveFormattingElements(),HA(t),H2(t),t.selfClosing?e._appendElement(t,je.MATHML):e._insertElement(t,je.MATHML),t.ackSelfClosing=!0}function uJ(e,t){e._reconstructActiveFormattingElements(),UA(t),H2(t),t.selfClosing?e._appendElement(t,je.SVG):e._insertElement(t,je.SVG),t.ackSelfClosing=!0}function rw(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,je.HTML)}function fr(e,t){switch(t.tagID){case k.I:case k.S:case k.B:case k.U:case k.EM:case k.TT:case k.BIG:case k.CODE:case k.FONT:case k.SMALL:case k.STRIKE:case k.STRONG:{KZ(e,t);break}case k.A:{GZ(e,t);break}case k.H1:case k.H2:case k.H3:case k.H4:case k.H5:case k.H6:{UZ(e,t);break}case k.P:case k.DL:case k.OL:case k.UL:case k.DIV:case k.DIR:case k.NAV:case k.MAIN:case k.MENU:case k.ASIDE:case k.CENTER:case k.FIGURE:case k.FOOTER:case k.HEADER:case k.HGROUP:case k.DIALOG:case k.DETAILS:case k.ADDRESS:case k.ARTICLE:case k.SEARCH:case k.SECTION:case k.SUMMARY:case k.FIELDSET:case k.BLOCKQUOTE:case k.FIGCAPTION:{HZ(e,t);break}case k.LI:case k.DD:case k.DT:{VZ(e,t);break}case k.BR:case k.IMG:case k.WBR:case k.AREA:case k.EMBED:case k.KEYGEN:{qA(e,t);break}case k.HR:{eJ(e,t);break}case k.RB:case k.RTC:{oJ(e,t);break}case k.RT:case k.RP:{lJ(e,t);break}case k.PRE:case k.LISTING:{FZ(e,t);break}case k.XMP:{rJ(e,t);break}case k.SVG:{uJ(e,t);break}case k.HTML:{PZ(e,t);break}case k.BASE:case k.LINK:case k.META:case k.STYLE:case k.TITLE:case k.SCRIPT:case k.BGSOUND:case k.BASEFONT:case k.TEMPLATE:{Ms(e,t);break}case k.BODY:{BZ(e,t);break}case k.FORM:{$Z(e,t);break}case k.NOBR:{WZ(e,t);break}case k.MATH:{cJ(e,t);break}case k.TABLE:{QZ(e,t);break}case k.INPUT:{ZZ(e,t);break}case k.PARAM:case k.TRACK:case k.SOURCE:{JZ(e,t);break}case k.IMAGE:{tJ(e,t);break}case k.BUTTON:{YZ(e,t);break}case k.APPLET:case k.OBJECT:case k.MARQUEE:{XZ(e,t);break}case k.IFRAME:{sJ(e,t);break}case k.SELECT:{iJ(e,t);break}case k.OPTION:case k.OPTGROUP:{aJ(e,t);break}case k.NOEMBED:case k.NOFRAMES:{nw(e,t);break}case k.FRAMESET:{zZ(e,t);break}case k.TEXTAREA:{nJ(e,t);break}case k.NOSCRIPT:{e.options.scriptingEnabled?nw(e,t):rw(e,t);break}case k.PLAINTEXT:{qZ(e,t);break}case k.COL:case k.TH:case k.TD:case k.TR:case k.HEAD:case k.FRAME:case k.TBODY:case k.TFOOT:case k.THEAD:case k.CAPTION:case k.COLGROUP:break;default:rw(e,t)}}function dJ(e,t){if(e.openElements.hasInScope(k.BODY)&&(e.insertionMode=re.AFTER_BODY,e.options.sourceCodeLocationInfo)){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e._setEndLocation(n,t)}}function fJ(e,t){e.openElements.hasInScope(k.BODY)&&(e.insertionMode=re.AFTER_BODY,nR(e,t))}function hJ(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n))}function pJ(e){const t=e.openElements.tmplCount>0,{formElement:n}=e;t||(e.formElement=null),(n||t)&&e.openElements.hasInScope(k.FORM)&&(e.openElements.generateImpliedEndTags(),t?e.openElements.popUntilTagNamePopped(k.FORM):n&&e.openElements.remove(n))}function mJ(e){e.openElements.hasInButtonScope(k.P)||e._insertFakeElement(be.P,k.P),e._closePElement()}function gJ(e){e.openElements.hasInListItemScope(k.LI)&&(e.openElements.generateImpliedEndTagsWithExclusion(k.LI),e.openElements.popUntilTagNamePopped(k.LI))}function bJ(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTagsWithExclusion(n),e.openElements.popUntilTagNamePopped(n))}function xJ(e){e.openElements.hasNumberedHeaderInScope()&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilNumberedHeaderPopped())}function yJ(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker())}function vJ(e){e._reconstructActiveFormattingElements(),e._insertFakeElement(be.BR,k.BR),e.openElements.pop(),e.framesetOk=!1}function GA(e,t){const n=t.tagName,r=t.tagID;for(let s=e.openElements.stackTop;s>0;s--){const a=e.openElements.items[s],l=e.openElements.tagIDs[s];if(r===l&&(r!==k.UNKNOWN||e.treeAdapter.getTagName(a)===n)){e.openElements.generateImpliedEndTagsWithExclusion(r),e.openElements.stackTop>=s&&e.openElements.shortenToLength(s);break}if(e._isSpecialElement(a,l))break}}function Pm(e,t){switch(t.tagID){case k.A:case k.B:case k.I:case k.S:case k.U:case k.EM:case k.TT:case k.BIG:case k.CODE:case k.FONT:case k.NOBR:case k.SMALL:case k.STRIKE:case k.STRONG:{U2(e,t);break}case k.P:{mJ(e);break}case k.DL:case k.UL:case k.OL:case k.DIR:case k.DIV:case k.NAV:case k.PRE:case k.MAIN:case k.MENU:case k.ASIDE:case k.BUTTON:case k.CENTER:case k.FIGURE:case k.FOOTER:case k.HEADER:case k.HGROUP:case k.DIALOG:case k.ADDRESS:case k.ARTICLE:case k.DETAILS:case k.SEARCH:case k.SECTION:case k.SUMMARY:case k.LISTING:case k.FIELDSET:case k.BLOCKQUOTE:case k.FIGCAPTION:{hJ(e,t);break}case k.LI:{gJ(e);break}case k.DD:case k.DT:{bJ(e,t);break}case k.H1:case k.H2:case k.H3:case k.H4:case k.H5:case k.H6:{xJ(e);break}case k.BR:{vJ(e);break}case k.BODY:{dJ(e,t);break}case k.HTML:{fJ(e,t);break}case k.FORM:{pJ(e);break}case k.APPLET:case k.OBJECT:case k.MARQUEE:{yJ(e,t);break}case k.TEMPLATE:{Ko(e,t);break}default:GA(e,t)}}function KA(e,t){e.tmplInsertionModeStack.length>0?tR(e,t):F2(e,t)}function EJ(e,t){var n;t.tagID===k.SCRIPT&&((n=e.scriptHandler)===null||n===void 0||n.call(e,e.openElements.current)),e.openElements.pop(),e.insertionMode=e.originalInsertionMode}function TJ(e,t){e._err(t,Ne.eofInElementThatCanContainOnlyText),e.openElements.pop(),e.insertionMode=e.originalInsertionMode,e.onEof(t)}function Z1(e,t){if(e.openElements.currentTagId!==void 0&&FA.has(e.openElements.currentTagId))switch(e.pendingCharacterTokens.length=0,e.hasNonWhitespacePendingCharacterToken=!1,e.originalInsertionMode=e.insertionMode,e.insertionMode=re.IN_TABLE_TEXT,t.type){case At.CHARACTER:{XA(e,t);break}case At.WHITESPACE_CHARACTER:{WA(e,t);break}}else Fd(e,t)}function SJ(e,t){e.openElements.clearBackToTableContext(),e.activeFormattingElements.insertMarker(),e._insertElement(t,je.HTML),e.insertionMode=re.IN_CAPTION}function kJ(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,je.HTML),e.insertionMode=re.IN_COLUMN_GROUP}function CJ(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(be.COLGROUP,k.COLGROUP),e.insertionMode=re.IN_COLUMN_GROUP,$2(e,t)}function wJ(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,je.HTML),e.insertionMode=re.IN_TABLE_BODY}function NJ(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(be.TBODY,k.TBODY),e.insertionMode=re.IN_TABLE_BODY,Bm(e,t)}function _J(e,t){e.openElements.hasInTableScope(k.TABLE)&&(e.openElements.popUntilTagNamePopped(k.TABLE),e._resetInsertionMode(),e._processStartTag(t))}function AJ(e,t){YA(t)?e._appendElement(t,je.HTML):Fd(e,t),t.ackSelfClosing=!0}function RJ(e,t){!e.formElement&&e.openElements.tmplCount===0&&(e._insertElement(t,je.HTML),e.formElement=e.openElements.current,e.openElements.pop())}function pc(e,t){switch(t.tagID){case k.TD:case k.TH:case k.TR:{NJ(e,t);break}case k.STYLE:case k.SCRIPT:case k.TEMPLATE:{Ms(e,t);break}case k.COL:{CJ(e,t);break}case k.FORM:{RJ(e,t);break}case k.TABLE:{_J(e,t);break}case k.TBODY:case k.TFOOT:case k.THEAD:{wJ(e,t);break}case k.INPUT:{AJ(e,t);break}case k.CAPTION:{SJ(e,t);break}case k.COLGROUP:{kJ(e,t);break}default:Fd(e,t)}}function Nd(e,t){switch(t.tagID){case k.TABLE:{e.openElements.hasInTableScope(k.TABLE)&&(e.openElements.popUntilTagNamePopped(k.TABLE),e._resetInsertionMode());break}case k.TEMPLATE:{Ko(e,t);break}case k.BODY:case k.CAPTION:case k.COL:case k.COLGROUP:case k.HTML:case k.TBODY:case k.TD:case k.TFOOT:case k.TH:case k.THEAD:case k.TR:break;default:Fd(e,t)}}function Fd(e,t){const n=e.fosterParentingEnabled;e.fosterParentingEnabled=!0,Dm(e,t),e.fosterParentingEnabled=n}function WA(e,t){e.pendingCharacterTokens.push(t)}function XA(e,t){e.pendingCharacterTokens.push(t),e.hasNonWhitespacePendingCharacterToken=!0}function Iu(e,t){let n=0;if(e.hasNonWhitespacePendingCharacterToken)for(;n<e.pendingCharacterTokens.length;n++)Fd(e,e.pendingCharacterTokens[n]);else for(;n<e.pendingCharacterTokens.length;n++)e._insertCharacters(e.pendingCharacterTokens[n]);e.insertionMode=e.originalInsertionMode,e._processToken(t)}const QA=new Set([k.CAPTION,k.COL,k.COLGROUP,k.TBODY,k.TD,k.TFOOT,k.TH,k.THEAD,k.TR]);function MJ(e,t){const n=t.tagID;QA.has(n)?e.openElements.hasInTableScope(k.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(k.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=re.IN_TABLE,pc(e,t)):fr(e,t)}function IJ(e,t){const n=t.tagID;switch(n){case k.CAPTION:case k.TABLE:{e.openElements.hasInTableScope(k.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(k.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=re.IN_TABLE,n===k.TABLE&&Nd(e,t));break}case k.BODY:case k.COL:case k.COLGROUP:case k.HTML:case k.TBODY:case k.TD:case k.TFOOT:case k.TH:case k.THEAD:case k.TR:break;default:Pm(e,t)}}function $2(e,t){switch(t.tagID){case k.HTML:{fr(e,t);break}case k.COL:{e._appendElement(t,je.HTML),t.ackSelfClosing=!0;break}case k.TEMPLATE:{Ms(e,t);break}default:jp(e,t)}}function OJ(e,t){switch(t.tagID){case k.COLGROUP:{e.openElements.currentTagId===k.COLGROUP&&(e.openElements.pop(),e.insertionMode=re.IN_TABLE);break}case k.TEMPLATE:{Ko(e,t);break}case k.COL:break;default:jp(e,t)}}function jp(e,t){e.openElements.currentTagId===k.COLGROUP&&(e.openElements.pop(),e.insertionMode=re.IN_TABLE,e._processToken(t))}function Bm(e,t){switch(t.tagID){case k.TR:{e.openElements.clearBackToTableBodyContext(),e._insertElement(t,je.HTML),e.insertionMode=re.IN_ROW;break}case k.TH:case k.TD:{e.openElements.clearBackToTableBodyContext(),e._insertFakeElement(be.TR,k.TR),e.insertionMode=re.IN_ROW,zm(e,t);break}case k.CAPTION:case k.COL:case k.COLGROUP:case k.TBODY:case k.TFOOT:case k.THEAD:{e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=re.IN_TABLE,pc(e,t));break}default:pc(e,t)}}function Nx(e,t){const n=t.tagID;switch(t.tagID){case k.TBODY:case k.TFOOT:case k.THEAD:{e.openElements.hasInTableScope(n)&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=re.IN_TABLE);break}case k.TABLE:{e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=re.IN_TABLE,Nd(e,t));break}case k.BODY:case k.CAPTION:case k.COL:case k.COLGROUP:case k.HTML:case k.TD:case k.TH:case k.TR:break;default:Nd(e,t)}}function zm(e,t){switch(t.tagID){case k.TH:case k.TD:{e.openElements.clearBackToTableRowContext(),e._insertElement(t,je.HTML),e.insertionMode=re.IN_CELL,e.activeFormattingElements.insertMarker();break}case k.CAPTION:case k.COL:case k.COLGROUP:case k.TBODY:case k.TFOOT:case k.THEAD:case k.TR:{e.openElements.hasInTableScope(k.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=re.IN_TABLE_BODY,Bm(e,t));break}default:pc(e,t)}}function ZA(e,t){switch(t.tagID){case k.TR:{e.openElements.hasInTableScope(k.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=re.IN_TABLE_BODY);break}case k.TABLE:{e.openElements.hasInTableScope(k.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=re.IN_TABLE_BODY,Nx(e,t));break}case k.TBODY:case k.TFOOT:case k.THEAD:{(e.openElements.hasInTableScope(t.tagID)||e.openElements.hasInTableScope(k.TR))&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=re.IN_TABLE_BODY,Nx(e,t));break}case k.BODY:case k.CAPTION:case k.COL:case k.COLGROUP:case k.HTML:case k.TD:case k.TH:break;default:Nd(e,t)}}function LJ(e,t){const n=t.tagID;QA.has(n)?(e.openElements.hasInTableScope(k.TD)||e.openElements.hasInTableScope(k.TH))&&(e._closeTableCell(),zm(e,t)):fr(e,t)}function jJ(e,t){const n=t.tagID;switch(n){case k.TD:case k.TH:{e.openElements.hasInTableScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=re.IN_ROW);break}case k.TABLE:case k.TBODY:case k.TFOOT:case k.THEAD:case k.TR:{e.openElements.hasInTableScope(n)&&(e._closeTableCell(),ZA(e,t));break}case k.BODY:case k.CAPTION:case k.COL:case k.COLGROUP:case k.HTML:break;default:Pm(e,t)}}function JA(e,t){switch(t.tagID){case k.HTML:{fr(e,t);break}case k.OPTION:{e.openElements.currentTagId===k.OPTION&&e.openElements.pop(),e._insertElement(t,je.HTML);break}case k.OPTGROUP:{e.openElements.currentTagId===k.OPTION&&e.openElements.pop(),e.openElements.currentTagId===k.OPTGROUP&&e.openElements.pop(),e._insertElement(t,je.HTML);break}case k.HR:{e.openElements.currentTagId===k.OPTION&&e.openElements.pop(),e.openElements.currentTagId===k.OPTGROUP&&e.openElements.pop(),e._appendElement(t,je.HTML),t.ackSelfClosing=!0;break}case k.INPUT:case k.KEYGEN:case k.TEXTAREA:case k.SELECT:{e.openElements.hasInSelectScope(k.SELECT)&&(e.openElements.popUntilTagNamePopped(k.SELECT),e._resetInsertionMode(),t.tagID!==k.SELECT&&e._processStartTag(t));break}case k.SCRIPT:case k.TEMPLATE:{Ms(e,t);break}}}function eR(e,t){switch(t.tagID){case k.OPTGROUP:{e.openElements.stackTop>0&&e.openElements.currentTagId===k.OPTION&&e.openElements.tagIDs[e.openElements.stackTop-1]===k.OPTGROUP&&e.openElements.pop(),e.openElements.currentTagId===k.OPTGROUP&&e.openElements.pop();break}case k.OPTION:{e.openElements.currentTagId===k.OPTION&&e.openElements.pop();break}case k.SELECT:{e.openElements.hasInSelectScope(k.SELECT)&&(e.openElements.popUntilTagNamePopped(k.SELECT),e._resetInsertionMode());break}case k.TEMPLATE:{Ko(e,t);break}}}function DJ(e,t){const n=t.tagID;n===k.CAPTION||n===k.TABLE||n===k.TBODY||n===k.TFOOT||n===k.THEAD||n===k.TR||n===k.TD||n===k.TH?(e.openElements.popUntilTagNamePopped(k.SELECT),e._resetInsertionMode(),e._processStartTag(t)):JA(e,t)}function PJ(e,t){const n=t.tagID;n===k.CAPTION||n===k.TABLE||n===k.TBODY||n===k.TFOOT||n===k.THEAD||n===k.TR||n===k.TD||n===k.TH?e.openElements.hasInTableScope(n)&&(e.openElements.popUntilTagNamePopped(k.SELECT),e._resetInsertionMode(),e.onEndTag(t)):eR(e,t)}function BJ(e,t){switch(t.tagID){case k.BASE:case k.BASEFONT:case k.BGSOUND:case k.LINK:case k.META:case k.NOFRAMES:case k.SCRIPT:case k.STYLE:case k.TEMPLATE:case k.TITLE:{Ms(e,t);break}case k.CAPTION:case k.COLGROUP:case k.TBODY:case k.TFOOT:case k.THEAD:{e.tmplInsertionModeStack[0]=re.IN_TABLE,e.insertionMode=re.IN_TABLE,pc(e,t);break}case k.COL:{e.tmplInsertionModeStack[0]=re.IN_COLUMN_GROUP,e.insertionMode=re.IN_COLUMN_GROUP,$2(e,t);break}case k.TR:{e.tmplInsertionModeStack[0]=re.IN_TABLE_BODY,e.insertionMode=re.IN_TABLE_BODY,Bm(e,t);break}case k.TD:case k.TH:{e.tmplInsertionModeStack[0]=re.IN_ROW,e.insertionMode=re.IN_ROW,zm(e,t);break}default:e.tmplInsertionModeStack[0]=re.IN_BODY,e.insertionMode=re.IN_BODY,fr(e,t)}}function zJ(e,t){t.tagID===k.TEMPLATE&&Ko(e,t)}function tR(e,t){e.openElements.tmplCount>0?(e.openElements.popUntilTagNamePopped(k.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode(),e.onEof(t)):F2(e,t)}function HJ(e,t){t.tagID===k.HTML?fr(e,t):Dp(e,t)}function nR(e,t){var n;if(t.tagID===k.HTML){if(e.fragmentContext||(e.insertionMode=re.AFTER_AFTER_BODY),e.options.sourceCodeLocationInfo&&e.openElements.tagIDs[0]===k.HTML){e._setEndLocation(e.openElements.items[0],t);const r=e.openElements.items[1];r&&!(!((n=e.treeAdapter.getNodeSourceCodeLocation(r))===null||n===void 0)&&n.endTag)&&e._setEndLocation(r,t)}}else Dp(e,t)}function Dp(e,t){e.insertionMode=re.IN_BODY,Dm(e,t)}function UJ(e,t){switch(t.tagID){case k.HTML:{fr(e,t);break}case k.FRAMESET:{e._insertElement(t,je.HTML);break}case k.FRAME:{e._appendElement(t,je.HTML),t.ackSelfClosing=!0;break}case k.NOFRAMES:{Ms(e,t);break}}}function FJ(e,t){t.tagID===k.FRAMESET&&!e.openElements.isRootHtmlElementCurrent()&&(e.openElements.pop(),!e.fragmentContext&&e.openElements.currentTagId!==k.FRAMESET&&(e.insertionMode=re.AFTER_FRAMESET))}function $J(e,t){switch(t.tagID){case k.HTML:{fr(e,t);break}case k.NOFRAMES:{Ms(e,t);break}}}function VJ(e,t){t.tagID===k.HTML&&(e.insertionMode=re.AFTER_AFTER_FRAMESET)}function qJ(e,t){t.tagID===k.HTML?fr(e,t):ip(e,t)}function ip(e,t){e.insertionMode=re.IN_BODY,Dm(e,t)}function YJ(e,t){switch(t.tagID){case k.HTML:{fr(e,t);break}case k.NOFRAMES:{Ms(e,t);break}}}function GJ(e,t){t.chars=yn,e._insertCharacters(t)}function KJ(e,t){e._insertCharacters(t),e.framesetOk=!1}function rR(e){for(;e.treeAdapter.getNamespaceURI(e.openElements.current)!==je.HTML&&e.openElements.currentTagId!==void 0&&!e._isIntegrationPoint(e.openElements.currentTagId,e.openElements.current);)e.openElements.pop()}function WJ(e,t){if(uZ(t))rR(e),e._startTagOutsideForeignContent(t);else{const n=e._getAdjustedCurrentElement(),r=e.treeAdapter.getNamespaceURI(n);r===je.MATHML?HA(t):r===je.SVG&&(dZ(t),UA(t)),H2(t),t.selfClosing?e._appendElement(t,r):e._insertElement(t,r),t.ackSelfClosing=!0}}function XJ(e,t){if(t.tagID===k.P||t.tagID===k.BR){rR(e),e._endTagOutsideForeignContent(t);return}for(let n=e.openElements.stackTop;n>0;n--){const r=e.openElements.items[n];if(e.treeAdapter.getNamespaceURI(r)===je.HTML){e._endTagOutsideForeignContent(t);break}const s=e.treeAdapter.getTagName(r);if(s.toLowerCase()===t.tagName){t.tagName=s,e.openElements.shortenToLength(n);break}}}be.AREA,be.BASE,be.BASEFONT,be.BGSOUND,be.BR,be.COL,be.EMBED,be.FRAME,be.HR,be.IMG,be.INPUT,be.KEYGEN,be.LINK,be.META,be.PARAM,be.SOURCE,be.TRACK,be.WBR;const Hm=sR("end"),ei=sR("start");function sR(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function iR(e){const t=ei(e),n=Hm(e);if(t&&n)return{start:t,end:n}}const QJ=/<(\/?)(iframe|noembed|noframes|plaintext|script|style|textarea|title|xmp)(?=[\t\n\f\r />])/gi,ZJ=new Set(["mdxFlowExpression","mdxJsxFlowElement","mdxJsxTextElement","mdxTextExpression","mdxjsEsm"]),sw={sourceCodeLocationInfo:!0,scriptingEnabled:!1};function aR(e,t){const n=lee(e),r=AA("type",{handlers:{root:JJ,element:eee,text:tee,comment:lR,doctype:nee,raw:see},unknown:iee}),s={parser:n?new tw(sw):tw.getFragmentParser(void 0,sw),handle(c){r(c,s)},stitches:!1,options:t||{}};r(e,s),_c(s,ei());const a=n?s.parser.document:s.parser.getFragment(),l=cQ(a,{file:s.options.file});return s.stitches&&Zs(l,"comment",function(c,u,h){const m=c;if(m.value.stitch&&h&&u!==void 0){const p=h.children;return p[u]=m.value.stitch,u}}),l.type==="root"&&l.children.length===1&&l.children[0].type===e.type?l.children[0]:l}function oR(e,t){let n=-1;if(e)for(;++n<e.length;)t.handle(e[n])}function JJ(e,t){oR(e.children,t)}function eee(e,t){aee(e,t),oR(e.children,t),oee(e,t)}function tee(e,t){t.parser.tokenizer.state>4&&(t.parser.tokenizer.state=0);const n={type:At.CHARACTER,chars:e.value,location:$d(e)};_c(t,ei(e)),t.parser.currentToken=n,t.parser._processToken(t.parser.currentToken)}function nee(e,t){const n={type:At.DOCTYPE,name:"html",forceQuirks:!1,publicId:"",systemId:"",location:$d(e)};_c(t,ei(e)),t.parser.currentToken=n,t.parser._processToken(t.parser.currentToken)}function ree(e,t){t.stitches=!0;const n=cee(e);if("children"in e&&"children"in n){const r=aR({type:"root",children:e.children},t.options);n.children=r.children}lR({type:"comment",value:{stitch:n}},t)}function lR(e,t){const n=e.value,r={type:At.COMMENT,data:n,location:$d(e)};_c(t,ei(e)),t.parser.currentToken=r,t.parser._processToken(t.parser.currentToken)}function see(e,t){if(t.parser.tokenizer.preprocessor.html="",t.parser.tokenizer.preprocessor.pos=-1,t.parser.tokenizer.preprocessor.lastGapPos=-2,t.parser.tokenizer.preprocessor.gapStack=[],t.parser.tokenizer.preprocessor.skipNextNewLine=!1,t.parser.tokenizer.preprocessor.lastChunkWritten=!1,t.parser.tokenizer.preprocessor.endOfChunkHit=!1,t.parser.tokenizer.preprocessor.isEol=!1,cR(t,ei(e)),t.parser.tokenizer.write(t.options.tagfilter?e.value.replace(QJ,"<$1$2"):e.value,!1),t.parser.tokenizer._runParsingLoop(),t.parser.tokenizer.state===72||t.parser.tokenizer.state===78){t.parser.tokenizer.preprocessor.lastChunkWritten=!0;const n=t.parser.tokenizer._consume();t.parser.tokenizer._callState(n)}}function iee(e,t){const n=e;if(t.options.passThrough&&t.options.passThrough.includes(n.type))ree(n,t);else{let r="";throw ZJ.has(n.type)&&(r=". It looks like you are using MDX nodes with `hast-util-raw` (or `rehype-raw`). If you use this because you are using remark or rehype plugins that inject `'html'` nodes, then please raise an issue with that plugin, as its a bad and slow idea. If you use this because you are using markdown syntax, then you have to configure this utility (or plugin) to pass through these nodes (see `passThrough` in docs), but you can also migrate to use the MDX syntax"),new Error("Cannot compile `"+n.type+"` node"+r)}}function _c(e,t){cR(e,t);const n=e.parser.tokenizer.currentCharacterToken;n&&n.location&&(n.location.endLine=e.parser.tokenizer.preprocessor.line,n.location.endCol=e.parser.tokenizer.preprocessor.col+1,n.location.endOffset=e.parser.tokenizer.preprocessor.offset+1,e.parser.currentToken=n,e.parser._processToken(e.parser.currentToken)),e.parser.tokenizer.paused=!1,e.parser.tokenizer.inLoop=!1,e.parser.tokenizer.active=!1,e.parser.tokenizer.returnState=In.DATA,e.parser.tokenizer.charRefCode=-1,e.parser.tokenizer.consumedAfterSnapshot=-1,e.parser.tokenizer.currentLocation=null,e.parser.tokenizer.currentCharacterToken=null,e.parser.tokenizer.currentToken=null,e.parser.tokenizer.currentAttr={name:"",value:""}}function cR(e,t){if(t&&t.offset!==void 0){const n={startLine:t.line,startCol:t.column,startOffset:t.offset,endLine:-1,endCol:-1,endOffset:-1};e.parser.tokenizer.preprocessor.lineStartPos=-t.column+1,e.parser.tokenizer.preprocessor.droppedBufferSize=t.offset,e.parser.tokenizer.preprocessor.line=t.line,e.parser.tokenizer.currentLocation=n}}function aee(e,t){const n=e.tagName.toLowerCase();if(t.parser.tokenizer.state===In.PLAINTEXT)return;_c(t,ei(e));const r=t.parser.openElements.current;let s="namespaceURI"in r?r.namespaceURI:To.html;s===To.html&&n==="svg"&&(s=To.svg);const a=pQ({...e,children:[]},{space:s===To.svg?"svg":"html"}),l={type:At.START_TAG,tagName:n,tagID:Nc(n),selfClosing:!1,ackSelfClosing:!1,attrs:"attrs"in a?a.attrs:[],location:$d(e)};t.parser.currentToken=l,t.parser._processToken(t.parser.currentToken),t.parser.tokenizer.lastStartTagName=n}function oee(e,t){const n=e.tagName.toLowerCase();if(!t.parser.tokenizer.inForeignNode&&TQ.includes(n)||t.parser.tokenizer.state===In.PLAINTEXT)return;_c(t,Hm(e));const r={type:At.END_TAG,tagName:n,tagID:Nc(n),selfClosing:!1,ackSelfClosing:!1,attrs:[],location:$d(e)};t.parser.currentToken=r,t.parser._processToken(t.parser.currentToken),n===t.parser.tokenizer.lastStartTagName&&(t.parser.tokenizer.state===In.RCDATA||t.parser.tokenizer.state===In.RAWTEXT||t.parser.tokenizer.state===In.SCRIPT_DATA)&&(t.parser.tokenizer.state=In.DATA)}function lee(e){const t=e.type==="root"?e.children[0]:e;return!!(t&&(t.type==="doctype"||t.type==="element"&&t.tagName.toLowerCase()==="html"))}function $d(e){const t=ei(e)||{line:void 0,column:void 0,offset:void 0},n=Hm(e)||{line:void 0,column:void 0,offset:void 0};return{startLine:t.line,startCol:t.column,startOffset:t.offset,endLine:n.line,endCol:n.column,endOffset:n.offset}}function cee(e){return"children"in e?jo({...e,children:[]}):jo(e)}function _x(e){return function(t,n){return aR(t,{...e,file:n})}}const ao=["ariaDescribedBy","ariaLabel","ariaLabelledBy"],fo={ancestors:{tbody:["table"],td:["table"],th:["table"],thead:["table"],tfoot:["table"],tr:["table"]},attributes:{a:[...ao,"dataFootnoteBackref","dataFootnoteRef",["className","data-footnote-backref"],"href"],blockquote:["cite"],code:[["className",/^language-./]],del:["cite"],div:["itemScope","itemType"],dl:[...ao],h2:[["className","sr-only"]],img:[...ao,"longDesc","src"],input:[["disabled",!0],["type","checkbox"]],ins:["cite"],li:[["className","task-list-item"]],ol:[...ao,["className","contains-task-list"]],q:["cite"],section:["dataFootnotes",["className","footnotes"]],source:["srcSet"],summary:[...ao],table:[...ao],ul:[...ao,["className","contains-task-list"]],"*":["abbr","accept","acceptCharset","accessKey","action","align","alt","axis","border","cellPadding","cellSpacing","char","charOff","charSet","checked","clear","colSpan","color","cols","compact","coords","dateTime","dir","encType","frame","hSpace","headers","height","hrefLang","htmlFor","id","isMap","itemProp","label","lang","maxLength","media","method","multiple","name","noHref","noShade","noWrap","open","prompt","readOnly","rev","rowSpan","rows","rules","scope","selected","shape","size","span","start","summary","tabIndex","title","useMap","vAlign","value","width"]},clobber:["ariaDescribedBy","ariaLabelledBy","id","name"],clobberPrefix:"user-content-",protocols:{cite:["http","https"],href:["http","https","irc","ircs","mailto","xmpp"],longDesc:["http","https"],src:["http","https"]},required:{input:{disabled:!0,type:"checkbox"}},strip:["script"],tagNames:["a","b","blockquote","br","code","dd","del","details","div","dl","dt","em","h1","h2","h3","h4","h5","h6","hr","i","img","input","ins","kbd","li","ol","p","picture","pre","q","rp","rt","ruby","s","samp","section","source","span","strike","strong","sub","summary","sup","table","tbody","td","tfoot","th","thead","tr","tt","ul","var"]},va={}.hasOwnProperty;function uee(e,t){let n={type:"root",children:[]};const r={schema:t?{...fo,...t}:fo,stack:[]},s=uR(r,e);return s&&(Array.isArray(s)?s.length===1?n=s[0]:n.children=s:n=s),n}function uR(e,t){if(t&&typeof t=="object"){const n=t;switch(typeof n.type=="string"?n.type:""){case"comment":return dee(e,n);case"doctype":return fee(e,n);case"element":return hee(e,n);case"root":return pee(e,n);case"text":return mee(e,n)}}}function dee(e,t){if(e.schema.allowComments){const n=typeof t.value=="string"?t.value:"",r=n.indexOf("-->"),a={type:"comment",value:r<0?n:n.slice(0,r)};return Vd(a,t),a}}function fee(e,t){if(e.schema.allowDoctypes){const n={type:"doctype"};return Vd(n,t),n}}function hee(e,t){const n=typeof t.tagName=="string"?t.tagName:"";e.stack.push(n);const r=dR(e,t.children),s=gee(e,t.properties);e.stack.pop();let a=!1;if(n&&n!=="*"&&(!e.schema.tagNames||e.schema.tagNames.includes(n))&&(a=!0,e.schema.ancestors&&va.call(e.schema.ancestors,n))){const c=e.schema.ancestors[n];let u=-1;for(a=!1;++u<c.length;)e.stack.includes(c[u])&&(a=!0)}if(!a)return e.schema.strip&&!e.schema.strip.includes(n)?r:void 0;const l={type:"element",tagName:n,properties:s,children:r};return Vd(l,t),l}function pee(e,t){const r={type:"root",children:dR(e,t.children)};return Vd(r,t),r}function mee(e,t){const r={type:"text",value:typeof t.value=="string"?t.value:""};return Vd(r,t),r}function dR(e,t){const n=[];if(Array.isArray(t)){const r=t;let s=-1;for(;++s<r.length;){const a=uR(e,r[s]);a&&(Array.isArray(a)?n.push(...a):n.push(a))}}return n}function gee(e,t){const n=e.stack[e.stack.length-1],r=e.schema.attributes,s=e.schema.required,a=r&&va.call(r,n)?r[n]:void 0,l=r&&va.call(r,"*")?r["*"]:void 0,c=t&&typeof t=="object"?t:{},u={};let h;for(h in c)if(va.call(c,h)){const m=c[h];let p=iw(e,aw(a,h),h,m);p==null&&(p=iw(e,aw(l,h),h,m)),p!=null&&(u[h]=p)}if(s&&va.call(s,n)){const m=s[n];for(h in m)va.call(m,h)&&!va.call(u,h)&&(u[h]=m[h])}return u}function iw(e,t,n,r){return t?Array.isArray(r)?bee(e,t,n,r):fR(e,t,n,r):void 0}function bee(e,t,n,r){let s=-1;const a=[];for(;++s<r.length;){const l=fR(e,t,n,r[s]);(typeof l=="number"||typeof l=="string")&&a.push(l)}return a}function fR(e,t,n,r){if(!(typeof r!="boolean"&&typeof r!="number"&&typeof r!="string")&&xee(e,n,r)){if(typeof t=="object"&&t.length>1){let s=!1,a=0;for(;++a<t.length;){const l=t[a];if(l&&typeof l=="object"&&"flags"in l){if(l.test(String(r))){s=!0;break}}else if(l===r){s=!0;break}}if(!s)return}return e.schema.clobber&&e.schema.clobberPrefix&&e.schema.clobber.includes(n)?e.schema.clobberPrefix+r:r}}function xee(e,t,n){const r=e.schema.protocols&&va.call(e.schema.protocols,t)?e.schema.protocols[t]:void 0;if(!r||r.length===0)return!0;const s=String(n),a=s.indexOf(":"),l=s.indexOf("?"),c=s.indexOf("#"),u=s.indexOf("/");if(a<0||u>-1&&a>u||l>-1&&a>l||c>-1&&a>c)return!0;let h=-1;for(;++h<r.length;){const m=r[h];if(a===m.length&&s.slice(0,m.length)===m)return!0}return!1}function Vd(e,t){const n=iR(t);t.data&&(e.data=jo(t.data)),n&&(e.position=n)}function aw(e,t){let n,r=-1;if(e)for(;++r<e.length;){const s=e[r],a=typeof s=="string"?s:s[0];if(a===t)return s;a==="data*"&&(n=s)}if(t.length>4&&t.slice(0,4).toLowerCase()==="data")return n}function hR(e){return function(t){return uee(t,e)}}function ow(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,s=n.indexOf(t);for(;s!==-1;)r++,s=n.indexOf(t,s+t.length);return r}const gr=Ba(/[A-Za-z]/),ur=Ba(/[\dA-Za-z]/),yee=Ba(/[#-'*+\--9=?A-Z^-~]/);function Pp(e){return e!==null&&(e<32||e===127)}const Ax=Ba(/\d/),vee=Ba(/[\dA-Fa-f]/),Eee=Ba(/[!-/:-@[-`{-~]/);function lt(e){return e!==null&&e<-2}function ln(e){return e!==null&&(e<0||e===32)}function jt(e){return e===-2||e===-1||e===32}const Um=Ba(/\p{P}|\p{S}/u),Do=Ba(/\s/);function Ba(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Tee(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function See(e,t,n){const s=Im((n||{}).ignore||[]),a=kee(t);let l=-1;for(;++l<a.length;)I2(e,"text",c);function c(h,m){let p=-1,b;for(;++p<m.length;){const x=m[p],v=b?b.children:void 0;if(s(x,v?v.indexOf(x):void 0,b))return;b=x}if(b)return u(h,m)}function u(h,m){const p=m[m.length-1],b=a[l][0],x=a[l][1];let v=0;const w=p.children.indexOf(h);let S=!1,C=[];b.lastIndex=0;let A=b.exec(h.value);for(;A;){const R=A.index,M={index:A.index,input:A.input,stack:[...m,h]};let _=x(...A,M);if(typeof _=="string"&&(_=_.length>0?{type:"text",value:_}:void 0),_===!1?b.lastIndex=R+1:(v!==R&&C.push({type:"text",value:h.value.slice(v,R)}),Array.isArray(_)?C.push(..._):_&&C.push(_),v=R+A[0].length,S=!0),!b.global)break;A=b.exec(h.value)}return S?(v<h.value.length&&C.push({type:"text",value:h.value.slice(v)}),p.children.splice(w,1,...C)):C=[h],w+C.length}}function kee(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const s=n[r];t.push([Cee(s[0]),wee(s[1])])}return t}function Cee(e){return typeof e=="string"?new RegExp(Tee(e),"g"):e}function wee(e){return typeof e=="function"?e:function(){return e}}const J1="phrasing",eb=["autolink","link","image","label"];function Nee(){return{transforms:[Lee],enter:{literalAutolink:Aee,literalAutolinkEmail:tb,literalAutolinkHttp:tb,literalAutolinkWww:tb},exit:{literalAutolink:Oee,literalAutolinkEmail:Iee,literalAutolinkHttp:Ree,literalAutolinkWww:Mee}}}function _ee(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:J1,notInConstruct:eb},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:J1,notInConstruct:eb},{character:":",before:"[ps]",after:"\\/",inConstruct:J1,notInConstruct:eb}]}}function Aee(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function tb(e){this.config.enter.autolinkProtocol.call(this,e)}function Ree(e){this.config.exit.autolinkProtocol.call(this,e)}function Mee(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function Iee(e){this.config.exit.autolinkEmail.call(this,e)}function Oee(e){this.exit(e)}function Lee(e){See(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,jee],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,Dee]],{ignore:["link","linkReference"]})}function jee(e,t,n,r,s){let a="";if(!pR(s)||(/^w/i.test(t)&&(n=t+n,t="",a="http://"),!Pee(n)))return!1;const l=Bee(n+r);if(!l[0])return!1;const c={type:"link",title:null,url:a+t+l[0],children:[{type:"text",value:t+l[0]}]};return l[1]?[c,{type:"text",value:l[1]}]:c}function Dee(e,t,n,r){return!pR(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function Pee(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function Bee(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const s=ow(e,"(");let a=ow(e,")");for(;r!==-1&&s>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),a++;return[e,n]}function pR(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Do(n)||Um(n))&&(!t||n!==47)}function ws(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}mR.peek=Gee;function zee(){this.buffer()}function Hee(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function Uee(){this.buffer()}function Fee(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function $ee(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=ws(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Vee(e){this.exit(e)}function qee(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=ws(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Yee(e){this.exit(e)}function Gee(){return"["}function mR(e,t,n,r){const s=n.createTracker(r);let a=s.move("[^");const l=n.enter("footnoteReference"),c=n.enter("reference");return a+=s.move(n.safe(n.associationId(e),{after:"]",before:a})),c(),l(),a+=s.move("]"),a}function Kee(){return{enter:{gfmFootnoteCallString:zee,gfmFootnoteCall:Hee,gfmFootnoteDefinitionLabelString:Uee,gfmFootnoteDefinition:Fee},exit:{gfmFootnoteCallString:$ee,gfmFootnoteCall:Vee,gfmFootnoteDefinitionLabelString:qee,gfmFootnoteDefinition:Yee}}}function Wee(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:mR},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,s,a,l){const c=a.createTracker(l);let u=c.move("[^");const h=a.enter("footnoteDefinition"),m=a.enter("label");return u+=c.move(a.safe(a.associationId(r),{before:u,after:"]"})),m(),u+=c.move("]:"),r.children&&r.children.length>0&&(c.shift(4),u+=c.move((t?`
|
|
@@ -1163,7 +1163,7 @@ ${t}</tr>
|
|
|
1163
1163
|
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${zs(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:n,tokens:r}){let s=this.parser.parseInline(r),a=Qw(t);if(a===null)return s;t=a;let l='<a href="'+t+'"';return n&&(l+=' title="'+zs(n)+'"'),l+=">"+s+"</a>",l}image({href:t,title:n,text:r,tokens:s}){s&&(r=this.parser.parseInline(s,this.parser.textRenderer));let a=Qw(t);if(a===null)return zs(r);t=a;let l=`<img src="${t}" alt="${zs(r)}"`;return n&&(l+=` title="${zs(n)}"`),l+=">",l}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:zs(t.text)}},uv=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},Cs=class Bx{options;renderer;textRenderer;constructor(t){this.options=t||Xo,this.options.renderer=this.options.renderer||new Up,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new uv}static parse(t,n){return new Bx(n).parse(t)}static parseInline(t,n){return new Bx(n).parseInline(t)}parse(t){this.renderer.parser=this;let n="";for(let r=0;r<t.length;r++){let s=t[r];if(this.options.extensions?.renderers?.[s.type]){let l=s,c=this.options.extensions.renderers[l.type].call({parser:this},l);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(l.type)){n+=c||"";continue}}let a=s;switch(a.type){case"space":{n+=this.renderer.space(a);break}case"hr":{n+=this.renderer.hr(a);break}case"heading":{n+=this.renderer.heading(a);break}case"code":{n+=this.renderer.code(a);break}case"table":{n+=this.renderer.table(a);break}case"blockquote":{n+=this.renderer.blockquote(a);break}case"list":{n+=this.renderer.list(a);break}case"checkbox":{n+=this.renderer.checkbox(a);break}case"html":{n+=this.renderer.html(a);break}case"def":{n+=this.renderer.def(a);break}case"paragraph":{n+=this.renderer.paragraph(a);break}case"text":{n+=this.renderer.text(a);break}default:{let l='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return n}parseInline(t,n=this.renderer){this.renderer.parser=this;let r="";for(let s=0;s<t.length;s++){let a=t[s];if(this.options.extensions?.renderers?.[a.type]){let c=this.options.extensions.renderers[a.type].call({parser:this},a);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){r+=c||"";continue}}let l=a;switch(l.type){case"escape":{r+=n.text(l);break}case"html":{r+=n.html(l);break}case"link":{r+=n.link(l);break}case"image":{r+=n.image(l);break}case"checkbox":{r+=n.checkbox(l);break}case"strong":{r+=n.strong(l);break}case"em":{r+=n.em(l);break}case"codespan":{r+=n.codespan(l);break}case"br":{r+=n.br(l);break}case"del":{r+=n.del(l);break}case"text":{r+=n.text(l);break}default:{let c='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return r}},Xu=class{options;block;constructor(e){this.options=e||Xo}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?hs.lex:hs.lexInline}provideParser(e=this.block){return e?Cs.parse:Cs.parseInline}},lle=class{defaults=nv();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Cs;Renderer=Up;TextRenderer=uv;Lexer=hs;Tokenizer=Hp;Hooks=Xu;constructor(...t){this.use(...t)}walkTokens(t,n){let r=[];for(let s of t)switch(r=r.concat(n.call(this,s)),s.type){case"table":{let a=s;for(let l of a.header)r=r.concat(this.walkTokens(l.tokens,n));for(let l of a.rows)for(let c of l)r=r.concat(this.walkTokens(c.tokens,n));break}case"list":{let a=s;r=r.concat(this.walkTokens(a.items,n));break}default:{let a=s;this.defaults.extensions?.childTokens?.[a.type]?this.defaults.extensions.childTokens[a.type].forEach(l=>{let c=a[l].flat(1/0);r=r.concat(this.walkTokens(c,n))}):a.tokens&&(r=r.concat(this.walkTokens(a.tokens,n)))}}return r}use(...t){let n=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(r=>{let s={...r};if(s.async=this.defaults.async||s.async||!1,r.extensions&&(r.extensions.forEach(a=>{if(!a.name)throw new Error("extension name required");if("renderer"in a){let l=n.renderers[a.name];l?n.renderers[a.name]=function(...c){let u=a.renderer.apply(this,c);return u===!1&&(u=l.apply(this,c)),u}:n.renderers[a.name]=a.renderer}if("tokenizer"in a){if(!a.level||a.level!=="block"&&a.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let l=n[a.level];l?l.unshift(a.tokenizer):n[a.level]=[a.tokenizer],a.start&&(a.level==="block"?n.startBlock?n.startBlock.push(a.start):n.startBlock=[a.start]:a.level==="inline"&&(n.startInline?n.startInline.push(a.start):n.startInline=[a.start]))}"childTokens"in a&&a.childTokens&&(n.childTokens[a.name]=a.childTokens)}),s.extensions=n),r.renderer){let a=this.defaults.renderer||new Up(this.defaults);for(let l in r.renderer){if(!(l in a))throw new Error(`renderer '${l}' does not exist`);if(["options","parser"].includes(l))continue;let c=l,u=r.renderer[c],h=a[c];a[c]=(...m)=>{let p=u.apply(a,m);return p===!1&&(p=h.apply(a,m)),p||""}}s.renderer=a}if(r.tokenizer){let a=this.defaults.tokenizer||new Hp(this.defaults);for(let l in r.tokenizer){if(!(l in a))throw new Error(`tokenizer '${l}' does not exist`);if(["options","rules","lexer"].includes(l))continue;let c=l,u=r.tokenizer[c],h=a[c];a[c]=(...m)=>{let p=u.apply(a,m);return p===!1&&(p=h.apply(a,m)),p}}s.tokenizer=a}if(r.hooks){let a=this.defaults.hooks||new Xu;for(let l in r.hooks){if(!(l in a))throw new Error(`hook '${l}' does not exist`);if(["options","block"].includes(l))continue;let c=l,u=r.hooks[c],h=a[c];Xu.passThroughHooks.has(l)?a[c]=m=>{if(this.defaults.async&&Xu.passThroughHooksRespectAsync.has(l))return(async()=>{let b=await u.call(a,m);return h.call(a,b)})();let p=u.call(a,m);return h.call(a,p)}:a[c]=(...m)=>{if(this.defaults.async)return(async()=>{let b=await u.apply(a,m);return b===!1&&(b=await h.apply(a,m)),b})();let p=u.apply(a,m);return p===!1&&(p=h.apply(a,m)),p}}s.hooks=a}if(r.walkTokens){let a=this.defaults.walkTokens,l=r.walkTokens;s.walkTokens=function(c){let u=[];return u.push(l.call(this,c)),a&&(u=u.concat(a.call(this,c))),u}}this.defaults={...this.defaults,...s}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,n){return hs.lex(t,n??this.defaults)}parser(t,n){return Cs.parse(t,n??this.defaults)}parseMarkdown(t){return(n,r)=>{let s={...r},a={...this.defaults,...s},l=this.onError(!!a.silent,!!a.async);if(this.defaults.async===!0&&s.async===!1)return l(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||n===null)return l(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return l(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(a.hooks&&(a.hooks.options=a,a.hooks.block=t),a.async)return(async()=>{let c=a.hooks?await a.hooks.preprocess(n):n,u=await(a.hooks?await a.hooks.provideLexer(t):t?hs.lex:hs.lexInline)(c,a),h=a.hooks?await a.hooks.processAllTokens(u):u;a.walkTokens&&await Promise.all(this.walkTokens(h,a.walkTokens));let m=await(a.hooks?await a.hooks.provideParser(t):t?Cs.parse:Cs.parseInline)(h,a);return a.hooks?await a.hooks.postprocess(m):m})().catch(l);try{a.hooks&&(n=a.hooks.preprocess(n));let c=(a.hooks?a.hooks.provideLexer(t):t?hs.lex:hs.lexInline)(n,a);a.hooks&&(c=a.hooks.processAllTokens(c)),a.walkTokens&&this.walkTokens(c,a.walkTokens);let u=(a.hooks?a.hooks.provideParser(t):t?Cs.parse:Cs.parseInline)(c,a);return a.hooks&&(u=a.hooks.postprocess(u)),u}catch(c){return l(c)}}}onError(t,n){return r=>{if(r.message+=`
|
|
1164
1164
|
Please report this to https://github.com/markedjs/marked.`,t){let s="<p>An error occurred:</p><pre>"+zs(r.message+"",!0)+"</pre>";return n?Promise.resolve(s):s}if(n)return Promise.reject(r);throw r}}},Po=new lle;function sn(e,t){return Po.parse(e,t)}sn.options=sn.setOptions=function(e){return Po.setOptions(e),sn.defaults=Po.defaults,fM(sn.defaults),sn};sn.getDefaults=nv;sn.defaults=Xo;sn.use=function(...e){return Po.use(...e),sn.defaults=Po.defaults,fM(sn.defaults),sn};sn.walkTokens=function(e,t){return Po.walkTokens(e,t)};sn.parseInline=Po.parseInline;sn.Parser=Cs;sn.parser=Cs.parse;sn.Renderer=Up;sn.TextRenderer=uv;sn.Lexer=hs;sn.lexer=hs.lex;sn.Tokenizer=Hp;sn.Hooks=Xu;sn.parse=sn;sn.options;sn.setOptions;sn.use;sn.walkTokens;sn.parseInline;Cs.parse;hs.lex;var cle=300,ule="300px",dle=500;function fle(e={}){let{immediate:t=!1,debounceDelay:n=cle,rootMargin:r=ule,idleTimeout:s=dle}=e,[a,l]=y.useState(!1),c=y.useRef(null),u=y.useRef(null),h=y.useRef(null),m=y.useMemo(()=>x=>{let v=Date.now();return window.setTimeout(()=>{x({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-v))})},1)},[]),p=y.useMemo(()=>typeof window<"u"&&window.requestIdleCallback?(x,v)=>window.requestIdleCallback(x,v):m,[m]),b=y.useMemo(()=>typeof window<"u"&&window.cancelIdleCallback?x=>window.cancelIdleCallback(x):x=>{clearTimeout(x)},[]);return y.useEffect(()=>{if(t){l(!0);return}let x=c.current;if(!x)return;u.current&&(clearTimeout(u.current),u.current=null),h.current&&(b(h.current),h.current=null);let v=()=>{u.current&&(clearTimeout(u.current),u.current=null),h.current&&(b(h.current),h.current=null)},N=A=>{h.current=p(R=>{R.timeRemaining()>0||R.didTimeout?(l(!0),A.disconnect()):h.current=p(()=>{l(!0),A.disconnect()},{timeout:s/2})},{timeout:s})},w=A=>{v(),u.current=window.setTimeout(()=>{var R,M;let _=A.takeRecords();(_.length===0||(M=(R=_.at(-1))==null?void 0:R.isIntersecting)!=null&&M)&&N(A)},n)},S=(A,R)=>{A.isIntersecting?w(R):v()},C=new IntersectionObserver(A=>{for(let R of A)S(R,C)},{rootMargin:r,threshold:0});return C.observe(x),()=>{u.current&&clearTimeout(u.current),h.current&&b(h.current),C.disconnect()}},[t,n,r,s,b,p]),{shouldRender:a,containerRef:c}}var TM=/\s/,hle=/^\s+$/,ple=new Set(["code","pre","svg","math","annotation"]),mle=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",gle=e=>e.some(t=>mle(t)&&ple.has(t.tagName)),ble=e=>{let t=[],n="",r=!1;for(let s of e){let a=TM.test(s);a!==r&&n&&(t.push(n),n=""),n+=s,r=a}return n&&t.push(n),t},xle=e=>{let t=[],n="";for(let r of e)TM.test(r)?n+=r:(n&&(t.push(n),n=""),t.push(r));return n&&t.push(n),t},yle=(e,t,n,r,s,a)=>{let l=`--sd-animation:sd-${t};--sd-duration:${s?0:n}ms;--sd-easing:${r}`;return a&&(l+=`;--sd-delay:${a}ms`),{type:"element",tagName:"span",properties:{"data-sd-animate":!0,style:l},children:[{type:"text",value:e}]}},vle=(e,t,n,r,s)=>{let a=t.at(-1);if(!(a&&"children"in a))return;if(gle(t))return Yl;let l=a,c=l.children.indexOf(e);if(c===-1)return;let u=e.value;if(!u.trim()){s.count+=u.length;return}let h=n.sep==="char"?xle(u):ble(u),m=r.prevContentLength,p=h.map(b=>{let x=s.count;if(s.count+=b.length,hle.test(b))return{type:"text",value:b};let v=m>0&&x<m,N=v?0:s.newIndex++*n.stagger;return yle(b,n.animation,n.duration,n.easing,v,N)});return l.children.splice(c,1,...p),c+p.length},Ele=0;function zx(e){var t,n,r,s,a;let l={animation:(t=e?.animation)!=null?t:"fadeIn",duration:(n=e?.duration)!=null?n:150,easing:(r=e?.easing)!=null?r:"ease",sep:(s=e?.sep)!=null?s:"word",stagger:(a=e?.stagger)!=null?a:40},c={prevContentLength:0,lastRenderCharCount:0},u=Ele++,h=()=>m=>{let p={count:0,newIndex:0};I2(m,"text",(b,x)=>vle(b,x,l,c,p)),c.lastRenderCharCount=p.count,c.prevContentLength=0};return Object.defineProperty(h,"name",{value:`rehypeAnimate$${u}`}),{name:"animate",type:"animate",rehypePlugin:h,setPrevContentLength(m){c.prevContentLength=m},getLastRenderCharCount(){let m=c.lastRenderCharCount;return c.lastRenderCharCount=0,m}}}zx();var SM=y.createContext(!1),Tle=()=>y.useContext(SM),dv=(...e)=>l5(tm(e)),Sle=(e,t)=>{if(!e||!t)return t;let n=`${e}:`;return t.split(/\s+/).filter(Boolean).map(r=>r.startsWith(n)?r:`${e}:${r}`).join(" ")},kle=e=>e?(...t)=>Sle(e,l5(tm(t))):dv,ec=(e,t,n)=>{let r=typeof t=="string"&&n.startsWith("text/csv")?"\uFEFF":"",s=typeof t=="string"?new Blob([r+t],{type:n}):t,a=URL.createObjectURL(s),l=document.createElement("a");l.href=a,l.download=e,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(a)},Hx=y.createContext(dv),Rt=()=>y.useContext(Hx),Cle=dv("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-6","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),wle=e=>{let t={};for(let n of e.split(";")){let r=n.indexOf(":");if(r>0){let s=n.slice(0,r).trim(),a=n.slice(r+1).trim();s&&a&&(t[s]=a)}}return t},Nle=y.memo(({children:e,result:t,language:n,className:r,startLine:s,lineNumbers:a=!0,...l})=>{let c=Rt(),u=y.useMemo(()=>c(Cle),[c]),h=y.useMemo(()=>{let m={};return t.bg&&(m["--sdm-bg"]=t.bg),t.fg&&(m["--sdm-fg"]=t.fg),t.rootStyle&&Object.assign(m,wle(t.rootStyle)),m},[t.bg,t.fg,t.rootStyle]);return d.jsx("div",{className:c(r,"overflow-x-auto rounded-md border border-border bg-background p-4 text-sm"),"data-language":n,"data-streamdown":"code-block-body",...l,children:d.jsx("pre",{className:c(r,"bg-[var(--sdm-bg,inherit]","dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit)]"),style:h,children:d.jsx("code",{className:a?c("[counter-increment:line_0] [counter-reset:line]"):void 0,style:a&&s&&s>1?{counterReset:`line ${s-1}`}:void 0,children:t.tokens.map((m,p)=>d.jsx("span",{className:a?u:void 0,children:m.length===0||m.length===1&&m[0].content===""?`
|
|
1165
1165
|
`:m.map((b,x)=>{let v={},N=!!b.bgColor;if(b.color&&(v["--sdm-c"]=b.color),b.bgColor&&(v["--sdm-tbg"]=b.bgColor),b.htmlStyle)for(let[w,S]of Object.entries(b.htmlStyle))w==="color"?v["--sdm-c"]=S:w==="background-color"?(v["--sdm-tbg"]=S,N=!0):v[w]=S;return d.jsx("span",{className:c("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",N&&"bg-[var(--sdm-tbg)]",N&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:v,...b.htmlAttrs,children:b.content},x)})},p))})})})},(e,t)=>e.result===t.result&&e.language===t.language&&e.className===t.className&&e.startLine===t.startLine&&e.lineNumbers===t.lineNumbers),_le=({className:e,language:t,style:n,isIncomplete:r,...s})=>{let a=Rt();return d.jsx("div",{className:a("my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",e),"data-incomplete":r||void 0,"data-language":t,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...n},...s})},kM=y.createContext({code:""}),CM=()=>y.useContext(kM),Ale=({language:e})=>{let t=Rt();return d.jsx("div",{className:t("flex h-8 items-center text-muted-foreground text-xs"),"data-language":e,"data-streamdown":"code-block-header",children:d.jsx("span",{className:t("ml-1 font-mono lowercase"),children:e})})},Rle=e=>{let t=e.length;for(;t>0&&e[t-1]===`
|
|
1166
|
-
`;)t--;return e.slice(0,t)},Mle=y.lazy(()=>fc(()=>import("./highlighted-body-OFNGDK62-
|
|
1166
|
+
`;)t--;return e.slice(0,t)},Mle=y.lazy(()=>fc(()=>import("./highlighted-body-OFNGDK62-CgN0BRlz.js"),[]).then(e=>({default:e.HighlightedCodeBlockBody}))),Ile=({code:e,language:t,className:n,children:r,isIncomplete:s=!1,startLine:a,lineNumbers:l,...c})=>{let u=Rt(),h=y.useMemo(()=>Rle(e),[e]),m=y.useMemo(()=>({bg:"transparent",fg:"inherit",tokens:h.split(`
|
|
1167
1167
|
`).map(p=>[{content:p,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[h]);return d.jsx(kM.Provider,{value:{code:e},children:d.jsxs(_le,{isIncomplete:s,language:t,children:[d.jsx(Ale,{language:t}),r?d.jsx("div",{className:u("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:d.jsx("div",{className:u("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"code-block-actions",children:r})}):null,d.jsx(y.Suspense,{fallback:d.jsx(Nle,{className:n,language:t,lineNumbers:l,result:m,startLine:a,...c}),children:d.jsx(Mle,{className:n,code:h,language:t,lineNumbers:l,raw:m,startLine:a,...c})})]})})},Ole=e=>d.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:d.jsx("path",{clipRule:"evenodd",d:"M15.5607 3.99999L15.0303 4.53032L6.23744 13.3232C5.55403 14.0066 4.44599 14.0066 3.76257 13.3232L4.2929 12.7929L3.76257 13.3232L0.969676 10.5303L0.439346 9.99999L1.50001 8.93933L2.03034 9.46966L4.82323 12.2626C4.92086 12.3602 5.07915 12.3602 5.17678 12.2626L13.9697 3.46966L14.5 2.93933L15.5607 3.99999Z",fill:"currentColor",fillRule:"evenodd"})}),Lle=e=>d.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:d.jsx("path",{clipRule:"evenodd",d:"M2.75 0.5C1.7835 0.5 1 1.2835 1 2.25V9.75C1 10.7165 1.7835 11.5 2.75 11.5H3.75H4.5V10H3.75H2.75C2.61193 10 2.5 9.88807 2.5 9.75V2.25C2.5 2.11193 2.61193 2 2.75 2H8.25C8.38807 2 8.5 2.11193 8.5 2.25V3H10V2.25C10 1.2835 9.2165 0.5 8.25 0.5H2.75ZM7.75 4.5C6.7835 4.5 6 5.2835 6 6.25V13.75C6 14.7165 6.7835 15.5 7.75 15.5H13.25C14.2165 15.5 15 14.7165 15 13.75V6.25C15 5.2835 14.2165 4.5 13.25 4.5H7.75ZM7.5 6.25C7.5 6.11193 7.61193 6 7.75 6H13.25C13.3881 6 13.5 6.11193 13.5 6.25V13.75C13.5 13.8881 13.3881 14 13.25 14H7.75C7.61193 14 7.5 13.8881 7.5 13.75V6.25Z",fill:"currentColor",fillRule:"evenodd"})}),jle=e=>d.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:d.jsx("path",{clipRule:"evenodd",d:"M8.75 1V1.75V8.68934L10.7197 6.71967L11.25 6.18934L12.3107 7.25L11.7803 7.78033L8.70711 10.8536C8.31658 11.2441 7.68342 11.2441 7.29289 10.8536L4.21967 7.78033L3.68934 7.25L4.75 6.18934L5.28033 6.71967L7.25 8.68934V1.75V1H8.75ZM13.5 9.25V13.5H2.5V9.25V8.5H1V9.25V14C1 14.5523 1.44771 15 2 15H14C14.5523 15 15 14.5523 15 14V9.25V8.5H13.5V9.25Z",fill:"currentColor",fillRule:"evenodd"})}),Dle=e=>d.jsxs("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:[d.jsx("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),d.jsx("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),d.jsx("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),d.jsx("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),d.jsx("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),d.jsx("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),d.jsx("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),d.jsx("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),d.jsx("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),d.jsx("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),Ple=e=>d.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:d.jsx("path",{clipRule:"evenodd",d:"M1 5.25V6H2.5V5.25V2.5H5.25H6V1H5.25H2C1.44772 1 1 1.44772 1 2V5.25ZM5.25 14.9994H6V13.4994H5.25H2.5V10.7494V9.99939H1V10.7494V13.9994C1 14.5517 1.44772 14.9994 2 14.9994H5.25ZM15 10V10.75V14C15 14.5523 14.5523 15 14 15H10.75H10V13.5H10.75H13.5V10.75V10H15ZM10.75 1H10V2.5H10.75H13.5V5.25V6H15V5.25V2C15 1.44772 14.5523 1 14 1H10.75Z",fill:"currentColor",fillRule:"evenodd"})}),Ble=e=>d.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:d.jsx("path",{clipRule:"evenodd",d:"M13.5 8C13.5 4.96643 11.0257 2.5 7.96452 2.5C5.42843 2.5 3.29365 4.19393 2.63724 6.5H5.25H6V8H5.25H0.75C0.335787 8 0 7.66421 0 7.25V2.75V2H1.5V2.75V5.23347C2.57851 2.74164 5.06835 1 7.96452 1C11.8461 1 15 4.13001 15 8C15 11.87 11.8461 15 7.96452 15C5.62368 15 3.54872 13.8617 2.27046 12.1122L1.828 11.5066L3.03915 10.6217L3.48161 11.2273C4.48831 12.6051 6.12055 13.5 7.96452 13.5C11.0257 13.5 13.5 11.0336 13.5 8Z",fill:"currentColor",fillRule:"evenodd"})}),zle=e=>d.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:d.jsx("path",{clipRule:"evenodd",d:"M12.4697 13.5303L13 14.0607L14.0607 13L13.5303 12.4697L9.06065 7.99999L13.5303 3.53032L14.0607 2.99999L13 1.93933L12.4697 2.46966L7.99999 6.93933L3.53032 2.46966L2.99999 1.93933L1.93933 2.99999L2.46966 3.53032L6.93933 7.99999L2.46966 12.4697L1.93933 13L2.99999 14.0607L3.53032 13.5303L7.99999 9.06065L12.4697 13.5303Z",fill:"currentColor",fillRule:"evenodd"})}),Hle=e=>d.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:d.jsx("path",{clipRule:"evenodd",d:"M13.5 10.25V13.25C13.5 13.3881 13.3881 13.5 13.25 13.5H2.75C2.61193 13.5 2.5 13.3881 2.5 13.25L2.5 2.75C2.5 2.61193 2.61193 2.5 2.75 2.5H5.75H6.5V1H5.75H2.75C1.7835 1 1 1.7835 1 2.75V13.25C1 14.2165 1.7835 15 2.75 15H13.25C14.2165 15 15 14.2165 15 13.25V10.25V9.5H13.5V10.25ZM9 1H9.75H14.2495C14.6637 1 14.9995 1.33579 14.9995 1.75V6.25V7H13.4995V6.25V3.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L12.4388 2.5H9.75H9V1Z",fill:"currentColor",fillRule:"evenodd"})}),Ule=e=>d.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:d.jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H5.875V4.75V4.125H7.125V4.75V5.875H8.25H8.875V7.125H8.25H7.125V8.25V8.875H5.875V8.25V7.125H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})}),Fle=e=>d.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:d.jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H8.25H8.875V7.125H8.25H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})}),Qu={CheckIcon:Ole,CopyIcon:Lle,DownloadIcon:jle,ExternalLinkIcon:Hle,Loader2Icon:Dle,Maximize2Icon:Ple,RotateCcwIcon:Ble,XIcon:zle,ZoomInIcon:Ule,ZoomOutIcon:Fle},wM=y.createContext(Qu),$le=(e,t)=>{if(e===t)return!0;if(!(e&&t))return e===t;let n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(s=>e[s]===t[s])},e4=({icons:e,children:t})=>{let n=y.useRef(e),r=y.useRef(e?{...Qu,...e}:Qu);$le(n.current,e)||(n.current=e,r.current=e?{...Qu,...e}:Qu);let s=r.current;return d.jsx(wM.Provider,{value:s,children:t})},Is=()=>y.useContext(wM),NM={copyCode:"Copy Code",downloadFile:"Download file",downloadDiagram:"Download diagram",downloadDiagramAsSvg:"Download diagram as SVG",downloadDiagramAsPng:"Download diagram as PNG",downloadDiagramAsMmd:"Download diagram as MMD",viewFullscreen:"View fullscreen",exitFullscreen:"Exit fullscreen",mermaidFormatSvg:"SVG",mermaidFormatPng:"PNG",mermaidFormatMmd:"MMD",copyTable:"Copy table",copyTableAsMarkdown:"Copy table as Markdown",copyTableAsCsv:"Copy table as CSV",copyTableAsTsv:"Copy table as TSV",downloadTable:"Download table",downloadTableAsCsv:"Download table as CSV",downloadTableAsMarkdown:"Download table as Markdown",tableFormatMarkdown:"Markdown",tableFormatCsv:"CSV",tableFormatTsv:"TSV",imageNotAvailable:"Image not available",downloadImage:"Download image",openExternalLink:"Open external link?",externalLinkWarning:"You're about to visit an external website.",close:"Close",copyLink:"Copy link",copied:"Copied",openLink:"Open link"},Ux=y.createContext(NM),Ui=()=>y.useContext(Ux),t4=({onCopy:e,onError:t,timeout:n=2e3,children:r,className:s,code:a,...l})=>{let c=Rt(),[u,h]=y.useState(!1),m=y.useRef(0),{code:p}=CM(),{isAnimating:b}=y.useContext(Zr),x=Ui(),v=a??p,N=async()=>{var C;if(typeof window>"u"||!((C=navigator?.clipboard)!=null&&C.writeText)){t?.(new Error("Clipboard API not available"));return}try{u||(await navigator.clipboard.writeText(v),h(!0),e?.(),m.current=window.setTimeout(()=>h(!1),n))}catch(A){t?.(A)}};y.useEffect(()=>()=>{window.clearTimeout(m.current)},[]);let w=Is(),S=u?w.CheckIcon:w.CopyIcon;return d.jsx("button",{className:c("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",s),"data-streamdown":"code-block-copy-button",disabled:b,onClick:N,title:x.copyCode,type:"button",...l,children:r??d.jsx(S,{size:14})})},n4={"1c":"1c","1c-query":"1cq",abap:"abap","actionscript-3":"as",ada:"ada",adoc:"adoc","angular-html":"html","angular-ts":"ts",apache:"conf",apex:"cls",apl:"apl",applescript:"applescript",ara:"ara",asciidoc:"adoc",asm:"asm",astro:"astro",awk:"awk",ballerina:"bal",bash:"sh",bat:"bat",batch:"bat",be:"be",beancount:"beancount",berry:"berry",bibtex:"bib",bicep:"bicep",blade:"blade.php",bsl:"bsl",c:"c","c#":"cs","c++":"cpp",cadence:"cdc",cairo:"cairo",cdc:"cdc",clarity:"clar",clj:"clj",clojure:"clj","closure-templates":"soy",cmake:"cmake",cmd:"cmd",cobol:"cob",codeowners:"CODEOWNERS",codeql:"ql",coffee:"coffee",coffeescript:"coffee","common-lisp":"lisp",console:"sh",coq:"v",cpp:"cpp",cql:"cql",crystal:"cr",cs:"cs",csharp:"cs",css:"css",csv:"csv",cue:"cue",cypher:"cql",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",docker:"dockerfile",dockerfile:"dockerfile",dotenv:"env","dream-maker":"dm",edge:"edge",elisp:"el",elixir:"ex",elm:"elm","emacs-lisp":"el",erb:"erb",erl:"erl",erlang:"erl",f:"f","f#":"fs",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"f90",f95:"f95",fennel:"fnl",fish:"fish",fluent:"ftl",for:"for","fortran-fixed-form":"f","fortran-free-form":"f90",fs:"fs",fsharp:"fs",fsl:"fsl",ftl:"ftl",gdresource:"tres",gdscript:"gd",gdshader:"gdshader",genie:"gs",gherkin:"feature","git-commit":"gitcommit","git-rebase":"gitrebase",gjs:"js",gleam:"gleam","glimmer-js":"js","glimmer-ts":"ts",glsl:"glsl",gnuplot:"plt",go:"go",gql:"gql",graphql:"graphql",groovy:"groovy",gts:"gts",hack:"hack",haml:"haml",handlebars:"hbs",haskell:"hs",haxe:"hx",hbs:"hbs",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",hs:"hs",html:"html","html-derivative":"html",http:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",jade:"jade",java:"java",javascript:"js",jinja:"jinja",jison:"jison",jl:"jl",js:"js",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",julia:"jl",kotlin:"kt",kql:"kql",kt:"kt",kts:"kts",kusto:"kql",latex:"tex",lean:"lean",lean4:"lean",less:"less",liquid:"liquid",lisp:"lisp",lit:"lit",llvm:"ll",log:"log",logo:"logo",lua:"lua",luau:"luau",make:"mak",makefile:"mak",markdown:"md",marko:"marko",matlab:"m",md:"md",mdc:"mdc",mdx:"mdx",mediawiki:"wiki",mermaid:"mmd",mips:"s",mipsasm:"s",mmd:"mmd",mojo:"mojo",move:"move",nar:"nar",narrat:"narrat",nextflow:"nf",nf:"nf",nginx:"conf",nim:"nim",nix:"nix",nu:"nu",nushell:"nu",objc:"m","objective-c":"m","objective-cpp":"mm",ocaml:"ml",pascal:"pas",perl:"pl",perl6:"p6",php:"php",plsql:"pls",po:"po",polar:"polar",postcss:"pcss",pot:"pot",potx:"potx",powerquery:"pq",powershell:"ps1",prisma:"prisma",prolog:"pl",properties:"properties",proto:"proto",protobuf:"proto",ps:"ps",ps1:"ps1",pug:"pug",puppet:"pp",purescript:"purs",py:"py",python:"py",ql:"ql",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",racket:"rkt",raku:"raku",razor:"cshtml",rb:"rb",reg:"reg",regex:"regex",regexp:"regexp",rel:"rel",riscv:"s",rs:"rs",rst:"rst",ruby:"rb",rust:"rs",sas:"sas",sass:"sass",scala:"scala",scheme:"scm",scss:"scss",sdbl:"sdbl",sh:"sh",shader:"shader",shaderlab:"shader",shell:"sh",shellscript:"sh",shellsession:"sh",smalltalk:"st",solidity:"sol",soy:"soy",sparql:"rq",spl:"spl",splunk:"spl",sql:"sql","ssh-config":"config",stata:"do",styl:"styl",stylus:"styl",svelte:"svelte",swift:"swift","system-verilog":"sv",systemd:"service",talon:"talon",talonscript:"talon",tasl:"tasl",tcl:"tcl",templ:"templ",terraform:"tf",tex:"tex",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"ts","ts-tags":"ts",tsp:"tsp",tsv:"tsv",tsx:"tsx",turtle:"ttl",twig:"twig",typ:"typ",typescript:"ts",typespec:"tsp",typst:"typ",v:"v",vala:"vala",vb:"vb",verilog:"v",vhdl:"vhdl",vim:"vim",viml:"vim",vimscript:"vim",vue:"vue","vue-html":"html","vue-vine":"vine",vy:"vy",vyper:"vy",wasm:"wasm",wenyan:"wy",wgsl:"wgsl",wiki:"wiki",wikitext:"wiki",wit:"wit",wl:"wl",wolfram:"wl",xml:"xml",xsl:"xsl",yaml:"yaml",yml:"yml",zenscript:"zs",zig:"zig",zsh:"zsh",文言:"wy"},Vle=({onDownload:e,onError:t,language:n,children:r,className:s,code:a,...l})=>{let c=Rt(),{code:u}=CM(),{isAnimating:h}=y.useContext(Zr),m=Ui(),p=Is(),b=a??u,x=`file.${n&&n in n4?n4[n]:"txt"}`,v="text/plain",N=()=>{try{ec(x,b,v),e?.()}catch(w){t?.(w)}};return d.jsx("button",{className:c("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",s),"data-streamdown":"code-block-download-button",disabled:h,onClick:N,title:m.downloadFile,type:"button",...l,children:r??d.jsx(p.DownloadIcon,{size:14})})},r4=()=>{let{Loader2Icon:e}=Is(),t=Rt();return d.jsxs("div",{className:t("w-full divide-y divide-border overflow-hidden rounded-xl border border-border"),children:[d.jsx("div",{className:t("h-[46px] w-full bg-muted/80")}),d.jsx("div",{className:t("flex w-full items-center justify-center p-4"),children:d.jsx(e,{className:t("size-4 animate-spin")})})]})},qle=/\.[^/.]+$/,Yle=({node:e,className:t,src:n,alt:r,onLoad:s,onError:a,...l})=>{let{DownloadIcon:c}=Is(),u=Rt(),h=y.useRef(null),[m,p]=y.useState(!1),[b,x]=y.useState(!1),v=Ui(),N=l.width!=null||l.height!=null,w=(m||N)&&!b,S=b&&!N;y.useEffect(()=>{let M=h.current;if(M!=null&&M.complete){let _=M.naturalWidth>0;p(_),x(!_)}},[]);let C=y.useCallback(M=>{p(!0),x(!1),s?.(M)},[s]),A=y.useCallback(M=>{p(!1),x(!0),a?.(M)},[a]),R=async()=>{if(n)try{let M=await(await fetch(n)).blob(),_=new URL(n,window.location.origin).pathname.split("/").pop()||"",I=_.split(".").pop(),j=_.includes(".")&&I!==void 0&&I.length<=4,z="";if(j)z=_;else{let P=M.type,F="png";P.includes("jpeg")||P.includes("jpg")?F="jpg":P.includes("png")?F="png":P.includes("svg")?F="svg":P.includes("gif")?F="gif":P.includes("webp")&&(F="webp"),z=`${(r||_||"image").replace(qle,"")}.${F}`}ec(z,M,M.type)}catch{window.open(n,"_blank")}};return n?d.jsxs("div",{className:u("group relative my-4 inline-block"),"data-streamdown":"image-wrapper",children:[d.jsx("img",{alt:r,className:u("max-w-full rounded-lg",S&&"hidden",t),"data-streamdown":"image",onError:A,onLoad:C,ref:h,src:n,...l}),S&&d.jsx("span",{className:u("text-muted-foreground text-xs italic"),"data-streamdown":"image-fallback",children:v.imageNotAvailable}),d.jsx("div",{className:u("pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block")}),w&&d.jsx("button",{className:u("absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background","opacity-0 group-hover:opacity-100"),onClick:R,title:v.downloadImage,type:"button",children:d.jsx(c,{size:14})})]}):null},ud=0,fv=()=>{ud+=1,ud===1&&(document.body.style.overflow="hidden")},hv=()=>{ud=Math.max(0,ud-1),ud===0&&(document.body.style.overflow="")},Gle=({url:e,isOpen:t,onClose:n,onConfirm:r})=>{let{CheckIcon:s,CopyIcon:a,ExternalLinkIcon:l,XIcon:c}=Is(),u=Rt(),[h,m]=y.useState(!1),p=Ui(),b=y.useCallback(async()=>{try{await navigator.clipboard.writeText(e),m(!0),setTimeout(()=>m(!1),2e3)}catch{}},[e]),x=y.useCallback(()=>{r(),n()},[r,n]);return y.useEffect(()=>{if(t){fv();let v=N=>{N.key==="Escape"&&n()};return document.addEventListener("keydown",v),()=>{document.removeEventListener("keydown",v),hv()}}},[t,n]),t?d.jsx("div",{className:u("fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm"),"data-streamdown":"link-safety-modal",onClick:n,onKeyDown:v=>{v.key==="Escape"&&n()},role:"button",tabIndex:0,children:d.jsxs("div",{className:u("relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg"),onClick:v=>v.stopPropagation(),onKeyDown:v=>v.stopPropagation(),role:"presentation",children:[d.jsx("button",{className:u("absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:n,title:p.close,type:"button",children:d.jsx(c,{size:16})}),d.jsxs("div",{className:u("flex flex-col gap-2"),children:[d.jsxs("div",{className:u("flex items-center gap-2 font-semibold text-lg"),children:[d.jsx(l,{size:20}),d.jsx("span",{children:p.openExternalLink})]}),d.jsx("p",{className:u("text-muted-foreground text-sm"),children:p.externalLinkWarning})]}),d.jsx("div",{className:u("break-all rounded-md bg-muted p-3 font-mono text-sm",e.length>100&&"max-h-32 overflow-y-auto"),children:e}),d.jsxs("div",{className:u("flex gap-2"),children:[d.jsx("button",{className:u("flex flex-1 items-center justify-center gap-2 rounded-md border bg-background px-4 py-2 font-medium text-sm transition-all hover:bg-muted"),onClick:b,type:"button",children:h?d.jsxs(d.Fragment,{children:[d.jsx(s,{size:14}),d.jsx("span",{children:p.copied})]}):d.jsxs(d.Fragment,{children:[d.jsx(a,{size:14}),d.jsx("span",{children:p.copyLink})]})}),d.jsxs("button",{className:u("flex flex-1 items-center justify-center gap-2 rounded-md bg-primary px-4 py-2 font-medium text-primary-foreground text-sm transition-all hover:bg-primary/90"),onClick:x,type:"button",children:[d.jsx(l,{size:14}),d.jsx("span",{children:p.openLink})]})]})]})}):null},Fx=y.createContext(null),pv=()=>y.useContext(Fx),rme=()=>{var e;let t=pv();return(e=t?.code)!=null?e:null},mv=()=>{var e;let t=pv();return(e=t?.mermaid)!=null?e:null},Kle=e=>{var t;let n=pv();return n!=null&&n.renderers&&e&&(t=n.renderers.find(r=>Array.isArray(r.language)?r.language.includes(e):r.language===e))!=null?t:null},Wle=(e,t)=>{var n;let r=(n=void 0)!=null?n:5;return new Promise((s,a)=>{let l="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e))),c=new Image;c.crossOrigin="anonymous",c.onload=()=>{let u=document.createElement("canvas"),h=c.width*r,m=c.height*r;u.width=h,u.height=m;let p=u.getContext("2d");if(!p){a(new Error("Failed to create 2D canvas context for PNG export"));return}p.drawImage(c,0,0,h,m),u.toBlob(b=>{if(!b){a(new Error("Failed to create PNG blob"));return}s(b)},"image/png")},c.onerror=()=>a(new Error("Failed to load SVG image")),c.src=l})},Xle=({chart:e,children:t,className:n,onDownload:r,config:s,onError:a})=>{let l=Rt(),[c,u]=y.useState(!1),h=y.useRef(null),{isAnimating:m}=y.useContext(Zr),p=Is(),b=mv(),x=Ui(),v=async N=>{try{if(N==="mmd"){ec("diagram.mmd",e,"text/plain"),u(!1),r?.(N);return}if(!b){a?.(new Error("Mermaid plugin not available"));return}let w=b.getMermaid(s),S=e.split("").reduce((R,M)=>(R<<5)-R+M.charCodeAt(0)|0,0),C=`mermaid-${Math.abs(S)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:A}=await w.render(C,e);if(!A){a?.(new Error("SVG not found. Please wait for the diagram to render."));return}if(N==="svg"){ec("diagram.svg",A,"image/svg+xml"),u(!1),r?.(N);return}if(N==="png"){let R=await Wle(A);ec("diagram.png",R,"image/png"),r?.(N),u(!1);return}}catch(w){a?.(w)}};return y.useEffect(()=>{let N=w=>{let S=w.composedPath();h.current&&!S.includes(h.current)&&u(!1)};return document.addEventListener("mousedown",N),()=>{document.removeEventListener("mousedown",N)}},[]),d.jsxs("div",{className:l("relative"),ref:h,children:[d.jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",n),disabled:m,onClick:()=>u(!c),title:x.downloadDiagram,type:"button",children:t??d.jsx(p.DownloadIcon,{size:14})}),c?d.jsxs("div",{className:l("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[d.jsx("button",{className:l("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>v("svg"),title:x.downloadDiagramAsSvg,type:"button",children:x.mermaidFormatSvg}),d.jsx("button",{className:l("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>v("png"),title:x.downloadDiagramAsPng,type:"button",children:x.mermaidFormatPng}),d.jsx("button",{className:l("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>v("mmd"),title:x.downloadDiagramAsMmd,type:"button",children:x.mermaidFormatMmd})]}):null]})},Qle=({chart:e,config:t,onFullscreen:n,onExit:r,className:s,...a})=>{let{Maximize2Icon:l,XIcon:c}=Is(),u=Rt(),[h,m]=y.useState(!1),{isAnimating:p,controls:b}=y.useContext(Zr),x=Ui(),v=(()=>{if(typeof b=="boolean")return b;let w=b.mermaid;return w===!1?!1:w===!0||w===void 0?!0:w.panZoom!==!1})(),N=()=>{m(!h)};return y.useEffect(()=>{if(h){fv();let w=S=>{S.key==="Escape"&&m(!1)};return document.addEventListener("keydown",w),()=>{document.removeEventListener("keydown",w),hv()}}},[h]),y.useEffect(()=>{h?n?.():r&&r()},[h,n,r]),d.jsxs(d.Fragment,{children:[d.jsx("button",{className:u("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",s),disabled:p,onClick:N,title:x.viewFullscreen,type:"button",...a,children:d.jsx(l,{size:14})}),h?ir.createPortal(d.jsxs("div",{className:u("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),onClick:N,onKeyDown:w=>{w.key==="Escape"&&N()},role:"button",tabIndex:0,children:[d.jsx("button",{className:u("absolute top-4 right-4 z-10 rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:N,title:x.exitFullscreen,type:"button",children:d.jsx(c,{size:20})}),d.jsx("div",{className:u("flex size-full items-center justify-center p-4"),onClick:w=>w.stopPropagation(),onKeyDown:w=>w.stopPropagation(),role:"presentation",children:d.jsx(oI,{chart:e,className:u("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:t,fullscreen:!0,showControls:v})})]}),document.body):null]})},_M=e=>{var t,n;let r=[],s=[],a=e.querySelectorAll("thead th");for(let c of a)r.push(((t=c.textContent)==null?void 0:t.trim())||"");let l=e.querySelectorAll("tbody tr");for(let c of l){let u=[],h=c.querySelectorAll("td");for(let m of h)u.push(((n=m.textContent)==null?void 0:n.trim())||"");s.push(u)}return{headers:r,rows:s}},AM=e=>{let{headers:t,rows:n}=e,r=c=>{let u=!1,h=!1;for(let m of c){if(m==='"'){u=!0,h=!0;break}(m===","||m===`
|
|
1168
1168
|
`)&&(u=!0)}return u?h?`"${c.replace(/"/g,'""')}"`:`"${c}"`:c},s=t.length>0?n.length+1:n.length,a=new Array(s),l=0;t.length>0&&(a[l]=t.map(r).join(","),l+=1);for(let c of n)a[l]=c.map(r).join(","),l+=1;return a.join(`
|
|
1169
1169
|
`)},Zle=e=>{let{headers:t,rows:n}=e,r=c=>{let u=!1;for(let m of c)if(m===" "||m===`
|
|
@@ -1185,7 +1185,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let s="<p>An error
|
|
|
1185
1185
|
`})}return n},Ice=/([\\`*_~[\]|])/g,Oce=e=>e.replace(Ice,"\\$1"),Lce=(e,t)=>{if(!t.length)return e;let n=e;for(let r of t){let s=new RegExp(`(<${r}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${r}\\s*>)`,"gi");n=n.replace(s,(a,l,c,u)=>{let h=Oce(c).replace(/\n\n/g," ");return l+h+u})}return n},rI=e=>e.type==="text"?e.value:"children"in e&&Array.isArray(e.children)?e.children.map(rI).join(""):"",jce=e=>t=>{if(!e||e.length===0)return;let n=new Set(e.map(r=>r.toLowerCase()));Zs(t,"element",r=>{if(n.has(r.tagName.toLowerCase())){let s=rI(r);r.children=s?[{type:"text",value:s}]:[]}})},Dce=()=>e=>{Zs(e,"code",t=>{var n,r;t.meta&&(t.data=(n=t.data)!=null?n:{},t.data.hProperties={...(r=t.data.hProperties)!=null?r:{},metastring:t.meta})})},Pce=/^[ \t]*<[\w!/?-]/,Bce=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,zce=e=>typeof e!="string"||e.length===0||!Pce.test(e)?e:e.replace(Bce,"$1"),p4,m4,g4,b4,op={...fo,protocols:{...fo.protocols,href:[...(m4=(p4=fo.protocols)==null?void 0:p4.href)!=null?m4:[],"tel"]},attributes:{...fo.attributes,code:[...(b4=(g4=fo.attributes)==null?void 0:g4.code)!=null?b4:[],"metastring"]}},qx={raw:_x,sanitize:[hR,op],harden:[LX,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:!0}]},Hce={gfm:[Zre,{}],codeMeta:Dce},x4=Object.values(qx),Uce=Object.values(Hce),Fce={block:" ▋",circle:" ●"},sI=["github-light","github-dark"],iI={enabled:!0},$ce={shikiTheme:sI,controls:!0,isAnimating:!1,lineNumbers:!0,mode:"streaming",mermaid:void 0,linkSafety:iI},Zr=y.createContext($ce),aI=y.memo(({content:e,shouldParseIncompleteMarkdown:t,shouldNormalizeHtmlIndentation:n,index:r,isIncomplete:s,dir:a,animatePlugin:l,...c})=>{if(l){let m=l.getLastRenderCharCount();l.setPrevContentLength(m)}let u=typeof e=="string"&&n?zce(e):e,h=d.jsx(nI,{...c,children:u});return d.jsx(SM.Provider,{value:s,children:a?d.jsx("div",{dir:a,style:{display:"contents"},children:h}):h})},(e,t)=>{if(e.content!==t.content||e.shouldNormalizeHtmlIndentation!==t.shouldNormalizeHtmlIndentation||e.index!==t.index||e.isIncomplete!==t.isIncomplete||e.dir!==t.dir)return!1;if(e.components!==t.components){let n=Object.keys(e.components||{}),r=Object.keys(t.components||{});if(n.length!==r.length||n.some(s=>{var a,l;return((a=e.components)==null?void 0:a[s])!==((l=t.components)==null?void 0:l[s])}))return!1}return!(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});aI.displayName="Block";var bv=y.memo(({children:e,mode:t="streaming",dir:n,parseIncompleteMarkdown:r=!0,normalizeHtmlIndentation:s=!1,components:a,rehypePlugins:l=x4,remarkPlugins:c=Uce,className:u,shikiTheme:h=sI,mermaid:m,controls:p=!0,isAnimating:b=!1,animated:x,BlockComponent:v=aI,parseMarkdownIntoBlocksFn:N=Rce,caret:w,plugins:S,remend:C,linkSafety:A=iI,lineNumbers:R=!0,allowedTags:M,literalTagContent:_,translations:I,icons:j,prefix:z,onAnimationStart:P,onAnimationEnd:F,...V})=>{let G=y.useId(),[K,Y]=y.useTransition(),U=y.useMemo(()=>kle(z),[z]),Q=y.useRef(null),W=y.useRef(P),ue=y.useRef(F);W.current=P,ue.current=F,y.useEffect(()=>{var we,Te,Ie;if(t==="static")return;let Be=Q.current;if(Q.current=b,Be===null){b&&((we=W.current)==null||we.call(W));return}b&&!Be?(Te=W.current)==null||Te.call(W):!b&&Be&&((Ie=ue.current)==null||Ie.call(ue))},[b,t]);let D=y.useMemo(()=>M?Object.keys(M):[],[M]),H=y.useMemo(()=>{if(typeof e!="string")return"";let we=t==="streaming"&&r?cie(e,C):e;return _&&_.length>0&&(we=Lce(we,_)),D.length>0&&(we=Mce(we,D)),we},[e,t,r,C,D,_]),B=y.useMemo(()=>N(H),[H,N]),[L,te]=y.useState(B);y.useEffect(()=>{t==="streaming"&&!ge?Y(()=>{te(B)}):te(B)},[B,t]);let ne=t==="streaming"?L:B,de=y.useMemo(()=>n==="auto"?ne.map(i4):void 0,[ne,n]),oe=y.useMemo(()=>ne.map((we,Te)=>`${G}-${Te}`),[ne.length,G]),le=y.useMemo(()=>x===!0?"true":x?JSON.stringify(x):"",[x]),ge=y.useMemo(()=>le?le==="true"?zx():zx(x):null,[le]),Pe=y.useMemo(()=>{var we,Te;return{shikiTheme:(Te=(we=S?.code)==null?void 0:we.getThemes())!=null?Te:h,controls:p,isAnimating:b,lineNumbers:R,mode:t,mermaid:m,linkSafety:A}},[h,p,b,R,t,m,A,S?.code]),Le=y.useMemo(()=>I?JSON.stringify(I):"",[I]),Se=y.useMemo(()=>({...NM,...I}),[Le]),Oe=y.useMemo(()=>{let{inlineCode:we,...Te}=a??{},Ie={...oce,...Te};if(we){let Be=Ie.code;Ie.code=ee=>"data-block"in ee?Be?y.createElement(Be,ee):null:y.createElement(we,ee)}return Ie},[a]),He=y.useMemo(()=>{let we=[];return S!=null&&S.cjk&&(we=[...we,...S.cjk.remarkPluginsBefore]),we=[...we,...c],S!=null&&S.cjk&&(we=[...we,...S.cjk.remarkPluginsAfter]),S!=null&&S.math&&(we=[...we,S.math.remarkPlugin]),we},[c,S?.math,S?.cjk]),We=y.useMemo(()=>{var we;let Te=l;if(M&&Object.keys(M).length>0&&l===x4){let Ie={...op,tagNames:[...(we=op.tagNames)!=null?we:[],...Object.keys(M)],attributes:{...op.attributes,...M}};Te=[qx.raw,[hR,Ie],qx.harden]}return _&&_.length>0&&(Te=[...Te,[jce,_]]),S!=null&&S.math&&(Te=[...Te,S.math.rehypePlugin]),ge&&b&&(Te=[...Te,ge.rehypePlugin]),Te},[l,S?.math,ge,b,M,_]),Ge=y.useMemo(()=>{if(!b||ne.length===0)return!1;let we=ne.at(-1);return a4(we)||fce(we)},[b,ne]),De=y.useMemo(()=>w&&b&&!Ge?{"--streamdown-caret":`"${Fce[w]}"`}:void 0,[w,b,Ge]);return t==="static"?d.jsx(Ux.Provider,{value:Se,children:d.jsx(Fx.Provider,{value:S??null,children:d.jsx(Zr.Provider,{value:Pe,children:d.jsx(e4,{icons:j,children:d.jsx(Hx.Provider,{value:U,children:d.jsx("div",{className:U("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",u),dir:n==="auto"?i4(H):n,children:d.jsx(nI,{components:Oe,rehypePlugins:We,remarkPlugins:He,...V,children:H})})})})})})}):d.jsx(Ux.Provider,{value:Se,children:d.jsx(Fx.Provider,{value:S??null,children:d.jsx(Zr.Provider,{value:Pe,children:d.jsx(e4,{icons:j,children:d.jsx(Hx.Provider,{value:U,children:d.jsxs("div",{className:U("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",w&&!Ge?"[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--streamdown-caret)]":null,u),style:De,children:[ne.length===0&&w&&b&&d.jsx("span",{}),ne.map((we,Te)=>{var Ie;let Be=Te===ne.length-1,ee=b&&Be&&a4(we);return d.jsx(v,{animatePlugin:ge,components:Oe,content:we,dir:(Ie=de?.[Te])!=null?Ie:n!=="auto"?n:void 0,index:Te,isIncomplete:ee,rehypePlugins:We,remarkPlugins:He,shouldNormalizeHtmlIndentation:s,shouldParseIncompleteMarkdown:r,...V},oe[Te])})]})})})})})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.animated===t.animated&&e.mode===t.mode&&e.plugins===t.plugins&&e.className===t.className&&e.linkSafety===t.linkSafety&&e.lineNumbers===t.lineNumbers&&e.normalizeHtmlIndentation===t.normalizeHtmlIndentation&&e.literalTagContent===t.literalTagContent&&JSON.stringify(e.translations)===JSON.stringify(t.translations)&&e.prefix===t.prefix&&e.dir===t.dir);bv.displayName="Streamdown";var Vce=({children:e,className:t,minZoom:n=.5,maxZoom:r=3,zoomStep:s=.1,showControls:a=!0,initialZoom:l=1,fullscreen:c=!1})=>{let{RotateCcwIcon:u,ZoomInIcon:h,ZoomOutIcon:m}=Is(),p=Rt(),b=y.useRef(null),x=y.useRef(null),[v,N]=y.useState(l),[w,S]=y.useState({x:0,y:0}),[C,A]=y.useState(!1),[R,M]=y.useState({x:0,y:0}),[_,I]=y.useState({x:0,y:0}),j=y.useCallback(U=>{N(Q=>Math.max(n,Math.min(r,Q+U)))},[n,r]),z=y.useCallback(()=>{j(s)},[j,s]),P=y.useCallback(()=>{j(-s)},[j,s]),F=y.useCallback(()=>{N(l),S({x:0,y:0})},[l]),V=y.useCallback(U=>{U.preventDefault();let Q=U.deltaY>0?-s:s;j(Q)},[j,s]),G=y.useCallback(U=>{if(U.button!==0||U.isPrimary===!1)return;A(!0),M({x:U.clientX,y:U.clientY}),I(w);let Q=U.currentTarget;Q instanceof HTMLElement&&Q.setPointerCapture(U.pointerId)},[w]),K=y.useCallback(U=>{if(!C)return;U.preventDefault();let Q=U.clientX-R.x,W=U.clientY-R.y;S({x:_.x+Q,y:_.y+W})},[C,R,_]),Y=y.useCallback(U=>{A(!1);let Q=U.currentTarget;Q instanceof HTMLElement&&Q.releasePointerCapture(U.pointerId)},[]);return y.useEffect(()=>{let U=b.current;if(U)return U.addEventListener("wheel",V,{passive:!1}),()=>{U.removeEventListener("wheel",V)}},[V]),y.useEffect(()=>{let U=x.current;if(U&&C)return document.body.style.userSelect="none",U.addEventListener("pointermove",K,{passive:!1}),U.addEventListener("pointerup",Y),U.addEventListener("pointercancel",Y),()=>{document.body.style.userSelect="",U.removeEventListener("pointermove",K),U.removeEventListener("pointerup",Y),U.removeEventListener("pointercancel",Y)}},[C,K,Y]),d.jsxs("div",{className:p("relative flex flex-col",c?"h-full w-full":"min-h-28 w-full",t),ref:b,style:{cursor:C?"grabbing":"grab"},children:[a?d.jsxs("div",{className:p("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/80 p-1 supports-[backdrop-filter]:bg-background/70 supports-[backdrop-filter]:backdrop-blur-sm",c?"bottom-4 left-4":"bottom-2 left-2"),children:[d.jsx("button",{className:p("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50"),disabled:v>=r,onClick:z,title:"Zoom in",type:"button",children:d.jsx(h,{size:16})}),d.jsx("button",{className:p("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50"),disabled:v<=n,onClick:P,title:"Zoom out",type:"button",children:d.jsx(m,{size:16})}),d.jsx("button",{className:p("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"),onClick:F,title:"Reset zoom and pan",type:"button",children:d.jsx(u,{size:16})})]}):null,d.jsx("div",{className:p("flex-1 origin-center transition-transform duration-150 ease-out",c?"flex h-full w-full items-center justify-center":"flex w-full items-center justify-center"),onPointerDown:G,ref:x,role:"application",style:{transform:`translate(${w.x}px, ${w.y}px) scale(${v})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})},oI=({chart:e,className:t,config:n,fullscreen:r=!1,showControls:s=!0})=>{let a=Rt(),[l,c]=y.useState(null),[u,h]=y.useState(!1),[m,p]=y.useState(""),[b,x]=y.useState(""),[v,N]=y.useState(0),{mermaid:w}=y.useContext(Zr),S=mv(),C=w?.errorComponent,{shouldRender:A,containerRef:R}=fle({immediate:r});if(y.useEffect(()=>{if(A){if(!S){c("Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.");return}(async()=>{try{c(null),h(!0);let _=S.getMermaid(n),I=e.split("").reduce((P,F)=>(P<<5)-P+F.charCodeAt(0)|0,0),j=`mermaid-${Math.abs(I)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:z}=await _.render(j,e);p(z),x(z)}catch(_){if(!(b||m)){let I=_ instanceof Error?_.message:"Failed to render Mermaid chart";c(I)}}finally{h(!1)}})()}},[e,n,v,A,S]),!(A||m||b))return d.jsx("div",{className:a("my-4 min-h-[200px]",t),ref:R});if(u&&!m&&!b)return d.jsx("div",{className:a("my-4 flex justify-center p-4",t),ref:R,children:d.jsxs("div",{className:a("flex items-center space-x-2 text-muted-foreground"),children:[d.jsx("div",{className:a("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),d.jsx("span",{className:a("text-sm"),children:"Loading diagram..."})]})});if(l&&!m&&!b){let _=()=>N(I=>I+1);return C?d.jsx("div",{ref:R,children:d.jsx(C,{chart:e,error:l,retry:_})}):d.jsxs("div",{className:a("rounded-md bg-red-50 p-4",t),ref:R,children:[d.jsxs("p",{className:a("font-mono text-red-700 text-sm"),children:["Mermaid Error: ",l]}),d.jsxs("details",{className:a("mt-2"),children:[d.jsx("summary",{className:a("cursor-pointer text-red-600 text-xs"),children:"Show Code"}),d.jsx("pre",{className:a("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:e})]})]})}let M=m||b;return d.jsx("div",{className:a("size-full",t),"data-streamdown":"mermaid",ref:R,children:d.jsx(Vce,{className:a(r?"size-full overflow-hidden":"overflow-hidden",t),fullscreen:r,maxZoom:3,minZoom:.5,showControls:s,zoomStep:.1,children:d.jsx("div",{"aria-label":"Mermaid chart",className:a("flex justify-center",r?"size-full items-center":null),dangerouslySetInnerHTML:{__html:M},role:"img"})})})};function Yx(e){if(e==null||typeof e=="boolean")return"";if(typeof e=="string"||typeof e=="number")return String(e);if(Array.isArray(e))return e.map(Yx).join("");const t=e;return t.props?Yx(t.props.children):""}function qce(e){const n=(Array.isArray(e)?e.find(Boolean):e)?.props?.className;return/language-([\w-]+)/.exec(n??"")?.[1]}function Yce({code:e,language:t}){return d.jsx(Mm,{className:"term-block",actions:d.jsx(M2,{text:e,label:"Copy code"}),children:d.jsx(kX,{className:"term-code","data-language":t,children:d.jsx("pre",{className:"term-pre",children:e})})})}const Bl=e=>function({children:n}){return d.jsx("div",{className:"term-block","data-tone":e,"data-weight":"bold",children:n})},Gce={p:({children:e})=>d.jsx("div",{className:"term-block",children:e}),h1:Bl("bright"),h2:Bl("bright"),h3:Bl("bright"),h4:Bl("fg"),h5:Bl("fg"),h6:Bl("fg"),ul:({children:e})=>d.jsx("ul",{className:"term-block term-list",children:e}),ol:({children:e})=>d.jsx("ol",{className:"term-block term-list term-list-ordered",children:e}),li:({children:e})=>d.jsxs("li",{className:"term-row term-li",children:[d.jsx("span",{className:"term-gutter","aria-hidden":!0}),d.jsx("div",{className:"term-body",children:e})]}),blockquote:({children:e})=>d.jsx("blockquote",{className:"term-block term-quote","data-tone":"dim",children:e}),hr:()=>d.jsx("div",{className:"term-block term-rule","aria-hidden":!0}),pre:({children:e})=>d.jsx(Yce,{code:Yx(e),language:qce(e)}),code:({children:e})=>d.jsx("code",{className:"term-inline-code","data-tone":"blue",children:e}),strong:({children:e})=>d.jsx("strong",{"data-tone":"bright","data-weight":"bold",children:e}),em:({children:e})=>d.jsx("em",{className:"term-em",children:e}),a:({children:e,href:t})=>d.jsx("a",{className:"term-link","data-tone":"blue",href:t,target:"_blank",rel:"noreferrer",children:e}),table:({children:e})=>d.jsx("div",{className:"term-block term-table-wrap",children:d.jsx("table",{className:"term-table",children:e})}),thead:({children:e})=>d.jsx("thead",{className:"term-thead",children:e}),tbody:({children:e})=>d.jsx("tbody",{children:e}),tr:({children:e})=>d.jsx("tr",{children:e}),th:({children:e})=>d.jsx("th",{"data-tone":"bright","data-weight":"bold",children:e}),td:({children:e})=>d.jsx("td",{children:e})},Kce=y.memo(function({children:t,streaming:n,className:r}){return d.jsx(bv,{mode:n?"streaming":"static",parseIncompleteMarkdown:n,controls:!1,components:Gce,className:ve("term-md",r),children:t})},(e,t)=>e.children===t.children&&e.streaming===t.streaming&&e.className===t.className),Wce=4;function Gm({onPress:e,expanded:t,className:n,children:r}){const s=y.useRef(null);return d.jsx("div",{role:"button",tabIndex:0,"aria-expanded":t,className:ve("term-press",n),onPointerDown:a=>{s.current={x:a.clientX,y:a.clientY}},onClick:a=>{const l=s.current;if(s.current=null,l&&Math.abs(a.clientX-l.x)+Math.abs(a.clientY-l.y)>Wce)return;const c=window.getSelection?.();c&&!c.isCollapsed&&c.containsNode(a.currentTarget,!0)||e()},onKeyDown:a=>{a.key!=="Enter"&&a.key!==" "||(a.preventDefault(),e())},children:r})}function xv(e){const t=y.useRef(null),n=y.useRef(e);return y.useEffect(()=>{const r=e&&!n.current;if(n.current=e,!r)return;const s=t.current;if(!s)return;const a=requestAnimationFrame(()=>{const l=Xce(s);if(!l)return;const c=s.getBoundingClientRect().top-l.getBoundingClientRect().top+l.scrollTop;if(c>=l.scrollTop)return;const u=Number.parseFloat(getComputedStyle(s).lineHeight)||0;l.scrollTop=Math.max(0,c-u)});return()=>cancelAnimationFrame(a)},[e]),t}function Xce(e){let t=e.parentElement;for(;t;){const n=getComputedStyle(t).overflowY;if((n==="auto"||n==="scroll")&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null}const lI=12;function Fp(e){return`image · ${Li(e.bytes)}`}const cI="image unavailable",Qce=4,Uh=400;function uI(e,t){const n=[];let r=0,s=!1;for(const u of e.slice(0,Qce)){if(n.length===0&&u.length>Uh){n.push(`${u.slice(0,Uh)}…`),r=Uh,s=!0;break}if(n.length>0&&r+u.length>Uh)break;n.push(u),r+=u.length+1}const a=e.join(`
|
|
1186
1186
|
`).length,l=t??a;if(s)return{shown:n,more:`… +${(l-r).toLocaleString()} chars`};if(t!==void 0&&l>a)return{shown:n,more:`… +${(l-r).toLocaleString()} chars`};const c=e.length-n.length;return{shown:n,more:c>0?`… +${c} line${c===1?"":"s"}`:void 0}}const dI=y.createContext(async()=>!1);function Zce({value:e,children:t}){return d.jsx(dI.Provider,{value:e??Jce,children:t})}const Jce=async()=>!1;function fI(){return y.useContext(dI)}const hI=async()=>{},pI=y.createContext(hI);function eue({value:e,children:t}){return d.jsx(pI.Provider,{value:e??hI,children:t})}function tue(){return y.useContext(pI)}const nue=150;function mI(e){const t=tue(),[n,r]=y.useState({failed:!1}),{toolUseId:s,sourceSeq:a,partIndex:l,mediaType:c,bytes:u}=e;return y.useEffect(()=>{let h=!0;r({failed:!1});const m=setTimeout(()=>{t({toolUseId:s,sourceSeq:a,partIndex:l,mediaType:c,bytes:u}).then(p=>{h&&r({src:p,failed:p===void 0})}).catch(()=>{h&&r({failed:!0})})},nue);return()=>{h=!1,clearTimeout(m)}},[t,s,a,l,c,u]),n}const rue=64*1024*1024;function sue(e,t){const n=y.useRef(new Map);return y.useEffect(()=>()=>{for(const r of n.current.values())r.url&&URL.revokeObjectURL(r.url);n.current.clear()},[]),y.useCallback(r=>{if(!t)return Promise.resolve(void 0);const s=`${t}:${r.sourceSeq}:${r.toolUseId}:${r.partIndex}`,a=n.current.get(s);if(a)return n.current.delete(s),n.current.set(s,a),a.pending;const l=e.toolResultImage(t,r.sourceSeq,r.toolUseId,r.partIndex).then(c=>{if(c.size===0)return;const u=URL.createObjectURL(c),h=n.current.get(s);return h?(h.url=u,h.bytes=c.size,iue(n.current,s)):URL.revokeObjectURL(u),u}).catch(()=>{});return n.current.set(s,{pending:l,bytes:r.bytes}),l},[e,t])}function iue(e,t){let n=0;for(const r of e.values())n+=r.bytes;for(const[r,s]of e){if(n<=rue)return;r!==t&&(s.url&&URL.revokeObjectURL(s.url),e.delete(r),n-=s.bytes)}}function aue(e,t){return e.parentToolUseId===t.parentToolUseId}function oue(e){if(gX(e))return"shell";const t=/^mcp__([^_]+(?:_[^_]+)*?)__/.exec(e);return t?.[1]?t[1].replace(/_/g,"-"):e.toLowerCase()}function gI(e,t){const n=t?"Running ":"Ran ",r=t?"…":"",s=e.length,a=new Map;for(const c of e){const u=oue(c.name);a.set(u,(a.get(u)??0)+1)}if(a.size===1&&a.has("shell"))return`${n}${s} shell command${s===1?"":"s"}${r}`;const l=[...a.entries()].sort((c,u)=>u[1]-c[1]||c[0].localeCompare(u[0])).map(([c,u])=>`${u} ${c}`).join(", ");return`${n}${s} tool${s===1?"":"s"} · ${l}${r}`}const y4=(e,t=80)=>e.length>t?e.slice(0,t-1)+"…":e,Gx=e=>typeof e=="string"&&e.trim()!==""?e.trim():void 0;function lue(e){return`${e.name}(${bI(e)})`}function bI(e){const t=e.input,n=Gx(t?.description),r=Gx(t?.subagent_type);return r&&n?`${r} · ${y4(n)}`:r??(n?y4(n):Da(e.input))}function xI(e){const t=e.input;return Gx(t?.prompt)}const v4=e=>e.status==="running"||e.status==="pending",yI=e=>e.status==="failed"||e.result?.isError===!0;function cue(e){const t=e[e.length-1];return t!==void 0&&yI(t)}function Km(e,t){return v4(e)||t.some(n=>n.kind==="tool_call"&&v4(n))}function vI(e){return yI(e)}function EI(e,t){const n=Km(e,t),r=t.reduce((a,l)=>a+(l.kind==="tool_call"?1:0),0),s=lue(e);return r===0?n?`${s} · working…`:`${s} · done`:`${s} · ${r} tool${r===1?"":"s"}${n?"…":""}`}function Ks(e){return("parentToolUseId"in e?e.parentToolUseId:void 0)??void 0}function TI(e,t){return e.filter(n=>Ks(n)===t)}function uue(e){return e.kind==="tool_call"}function SI(e){return e.children.flatMap(t=>"run"in t?t.run:[t.item])}function E4(e,t,n){const r=e.at(-1);if(uue(t)){r&&"run"in r&&aue(r.run[0],t)?(r.run.push(t),r.indices.push(n)):e.push({key:`run:${t.id}`,run:[t],indices:[n],index:n});return}e.push({key:`${t.kind}:${t.id}`,item:t,index:n})}function due(e,t=0,n=!0){if(!n)return e.map((l,c)=>({key:`${l.kind}:${l.id}`,item:l,index:t+c}));const r=new Set;for(const l of e)l.kind==="tool_call"&&Ks(l)===void 0&&r.add(l.id);const s=new Map;e.forEach((l,c)=>{const u=Ks(l);if(u!==void 0&&r.has(u)){const h=s.get(u);h?h.push({item:l,index:t+c}):s.set(u,[{item:l,index:t+c}])}});const a=[];for(const[l,c]of e.entries()){const u=t+l,h=Ks(c);if(!(h!==void 0&&s.has(h))){if(c.kind==="tool_call"){const m=s.get(c.id);if(m){const p=[];for(const b of m)E4(p,b.item,b.index);a.push({key:`task:${c.id}`,task:c,children:p,childIndices:m.map(b=>b.index),index:u});continue}}E4(a,c,u)}}return a}function fue(e,t){return!(e.kind==="tool_call"&&t.kind==="tool_call")}function hue(e,t){const n=r=>"item"in r?r.item.kind:"tool_call";return!(n(e)==="tool_call"&&n(t)==="tool_call")}const Kx="❯",pue=2e3;function mue(e,t){const n=[];let r=0;for(const s of e){if(n.length>0&&r+s.length>t)break;n.push(s),r+=s.length+1}return n}function gue({item:e}){return d.jsxs("div",{className:"term-user",children:[e.attachments?.length?d.jsx(_t,{glyph:Kx,glyphTone:"dim",tone:"dim",children:e.attachments.map(t=>t.name).join(", ")}):null,e.text?e.text.split(`
|
|
1187
1187
|
`).map((t,n)=>d.jsx(_t,{glyph:n===0?Kx:void 0,glyphTone:"dim",tone:"fg",children:t||" "},n)):null]})}function bue({item:e}){return d.jsx(Mm,{actions:e.streaming?null:d.jsx(M2,{text:e.text,label:"Copy message"}),children:d.jsx(_t,{glyph:"●",glyphTone:"fg",tone:"fg",children:d.jsx(Kce,{streaming:e.streaming,children:e.text})})})}function xue({item:e}){return d.jsx(_t,{glyph:"✻",glyphTone:"dim",tone:"dim",children:d.jsx("span",{className:"term-em",children:e.text})})}const yue={running:"blue",pending:"blue",deferred:"yellow",settled:"dim",failed:"red"};function kI({item:e}){const[t,n]=y.useState(!1),[r,s]=y.useState(!1),[a,l]=y.useState(!1),c=fI(),u=xv(t),h=e.status??(e.result===void 0?"running":"settled"),m=h==="running"||h==="pending",p=h==="failed"||e.result?.isError===!0,b=zd(m),x=e.result?.text??"",v=x.trimEnd().split(`
|
|
1188
|
-
`),N=uI(v,e.result?.totalChars),w=t?r?v:mue(v,pue):N.shown,S=v.length-w.length,C=t&&!r&&S>0,A=e.result?.truncated===!0,R=A?(e.result?.totalChars??0)-x.length:0,M=p?"red":h==="settled"&&bX(e.name)?"green":yue[h]??"dim",_=e.input?.command,I=typeof _=="string"?_:x;return d.jsx("div",{ref:u,className:t?"term-open":void 0,children:d.jsxs(Mm,{actions:I?d.jsx(M2,{text:I,label:"Copy"}):null,children:[d.jsx(Gm,{onPress:()=>n(j=>!j),expanded:t,children:d.jsxs(_t,{glyph:m?b:"●",glyphTone:M,tone:"fg",children:[d.jsx(jr,{bold:!0,tone:"bright",children:e.name}),d.jsxs(jr,{tone:"dim",children:["(",Da(e.input),")"]}),e.backend&&e.backend!=="server"?d.jsxs(jr,{tone:"faint",children:[" · ",e.backend]}):null]})}),e.result?.images?.map(j=>d.jsx(vue,{toolUseId:e.id,image:j},j.partIndex)),e.patch&&!t?d.jsx(uA,{patch:e.patch}):x?d.jsxs(d.Fragment,{children:[w.map((j,z)=>d.jsx(_t,{indent:1,columns:3,glyph:z===0?"⎿":void 0,tone:p?"red":"dim",children:j||" "},z)),t?C||A?d.jsx(_t,{indent:1,columns:3,tone:"faint",children:a?d.jsxs(d.Fragment,{children:["… fetching ",(e.result?.totalChars??0).toLocaleString()," chars"]}):C||A?d.jsx("button",{type:"button",className:"term-press term-link",onClick:()=>{s(!0),A&&(l(!0),c(e.id).finally(()=>l(!1)))},children:A?`… +${R.toLocaleString()} chars — fetch the rest`:`… +${S} line${S===1?"":"s"} — show all ${x.length.toLocaleString()} chars`}):d.jsxs(d.Fragment,{children:["… +",S," line",S===1?"":"s"]})}):S>0?d.jsxs(_t,{indent:1,columns:3,tone:"faint",children:["… +",S," line",S===1?"":"s"]}):null:N.more?d.jsx(_t,{indent:1,columns:3,tone:"faint",children:N.more}):null]}):null]})})}function vue({toolUseId:e,image:t}){const{src:n,failed:r}=mI({toolUseId:e,...t});return d.jsx(_t,{indent:1,columns:3,children:d.jsx("div",{className:"term-image","data-state":n?"loaded":r?"failed":"pending",style:{height:`calc(var(--term-line) * ${lI})`},children:n?d.jsx("img",{src:n,alt:Fp(t)}):d.jsx(jr,{tone:"faint",children:r?cI:Fp(t)})})})}function CI({items:e}){const[t,n]=y.useState(!1),r=xv(t),s=e.some(c=>{const u=c.status??(c.result===void 0?"running":"settled");return u==="running"||u==="pending"}),a=cue(e),l=zd(s);return d.jsxs("div",{ref:r,className:t?"term-open":void 0,children:[d.jsx(Gm,{onPress:()=>n(c=>!c),expanded:t,children:d.jsx(_t,{glyph:s?l:void 0,glyphTone:s?"mark":void 0,tone:a?"red":"dim",children:gI(e,s)})}),t?d.jsx("div",{children:e.map(c=>d.jsx(kI,{item:c},c.id))}):null]})}function Eue({item:e}){return d.jsxs("div",{children:[d.jsxs(_t,{tone:e.isError?"red":"faint",children:[e.isError?e.subtype:"done"," · ",Sc(e.durationMs)," ·"," ",Js(e.totalCostUsd)]}),e.errors?.map((t,n)=>d.jsx(_t,{tone:"red",children:t},n))]})}function Tue({item:e}){const t=e.level==="error";return d.jsx(_t,{glyph:"!",glyphTone:t?"red":"yellow",tone:t?"red":"dim",children:e.text})}function Sue({item:e,href:t}){return d.jsxs(_t,{glyph:"⤓",glyphTone:"blue",tone:"dim",children:[t?d.jsx("a",{className:"term-link","data-tone":"blue",href:t,download:!0,children:e.path}):d.jsx(jr,{tone:"blue",children:e.path}),d.jsxs(jr,{tone:"faint",children:[" · ",Li(e.bytes)]}),e.description?d.jsxs(jr,{tone:"faint",children:[" · ",e.description]}):null]})}function wI(e){const[t,n]=y.useState(()=>Date.now());return y.useEffect(()=>{if(!e)return;const r=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(r)},[e]),t}function T4({label:e,startedAt:t,tokens:n}){const r=zd(!0),s=wI(t!==void 0),l=[t===void 0?void 0:Sc(s-t),n?`↓ ${(n/1e3).toFixed(1)}k tokens`:void 0].filter(Boolean);return d.jsxs(_t,{glyph:r,glyphTone:"mark",tone:"mark",children:[e,l.length?d.jsxs(jr,{tone:"faint",children:[" (",l.join(" · "),")"]}):null]})}function Mc({fontSize:e,lineHeight:t,bleed:n,affordances:r,className:s,style:a,children:l,...c}){const u=cA(r);return d.jsx("div",{"data-terminal":"","data-affordances":[u.hover&&"hover",u.actions&&"actions"].filter(Boolean).join(" ")||void 0,className:ve("min-w-0",s),style:{...e!==void 0&&{"--term-font-size":`${Math.round(e)}px`},...t!==void 0&&{"--term-line":`${Math.round(t)}px`},...n!==void 0&&{"--term-bleed":n},...a},...c,children:d.jsx(TX,{value:u,children:l})})}const kue=e=>e.replace(/\s*\(MCP\)$/i,"");function NI(e){const t=e.defaultPrompt?.trim()||`$${e.name}`;return/\s$/.test(t)?t:t+" "}function S4(e,t){const n=e.toLowerCase(),r=t.map(s=>s.toLowerCase());return r.some(s=>s.startsWith(n))?2:r.some(s=>s.includes(n))?1:0}function Cue({onSend:e,onInterrupt:t,busy:n,disabled:r,placeholder:s="Message the agent…",commands:a,skills:l,onSearchFiles:c,attachments:u,toolbar:h,layout:m="stacked",fontSize:p,lineHeight:b,affordances:x,className:v,ref:N}){const w=m==="inline",S=Rm()==="terminal",{bind:C,plainText:A,isEmpty:R,clear:M,focus:_}=VK(),I=y.useRef(null),[j,z]=y.useState(!1);y.useImperativeHandle(N,()=>({insertText:L=>{const te=A.length>0&&!/\s$/.test(A)?" ":"";C.ref.current?.appendText(te+L),_()},focus:_}),[C.ref,A,_]);const P=y.useMemo(()=>{const L=[],te=(l??[]).filter(ne=>ne.enabled);if(a&&a.length>0){const ne=new Set,de=a.flatMap(oe=>{const le=kue(oe.name);return ne.has(le)?[]:(ne.add(le),[{...oe,name:le}])});L.push(vC({onSearch:oe=>{const le=[];for(const ge of de){const Pe=S4(oe,[ge.name,...ge.aliases??[],...ge.name.split(":")]);Pe!==0&&le.push({score:Pe,suggestion:{value:ge.name,label:`/${ge.name}${ge.argumentHint?` ${ge.argumentHint}`:""}`,description:ge.description}})}return le.sort((ge,Pe)=>Pe.score-ge.score),le.map(({suggestion:ge})=>ge)},onSelect:oe=>oe.value,chipClassName:"font-mono"}))}return te.length>0&&L.push(vC({char:"$",accessibilityLabel:"skill",onSearch:ne=>{const de=[];for(const oe of te){const le=S4(ne,[oe.name,...oe.name.split(/[-:_]/)]);if(le===0)continue;const ge=oe.shortDescription??oe.description;de.push({score:le,suggestion:{value:oe.name,label:oe.displayName??oe.name,description:ge?`Skill · ${ge}`:"Skill · inserts a message you can edit",icon:d.jsx(jd,{className:"size-3.5 text-fg-3"})}})}return de.sort((oe,le)=>le.score-oe.score),de.map(({suggestion:oe})=>oe)},insertAsText:ne=>{const de=te.find(oe=>oe.name===ne.value);return de?NI(de):`$${ne.value} `}})),c&&L.push(qK({searchDebounceMs:150,onSearch:async(ne,de)=>(await c(ne,de)).map(le=>({value:le.relative,label:le.relative,description:le.path})),onSelect:ne=>ne.value,chipStyle:"inline",chipClassName:"font-mono",emptyMessage:"No matching files"})),L.length>0?L:void 0},[a,l,c]),F=u?.items??[],V=!r&&(!R||F.length>0)&&!u?.uploading&&!u?.hasFailure,G=()=>{V&&(e(A.trim(),u?.readyIds??[]),u?.clear(),M(),_())},K=L=>{L&&L.length>0&&u?.add(L)},Y=u&&!u.disabled?d.jsx("input",{ref:I,type:"file",multiple:!0,accept:u.accept||void 0,className:"hidden",onChange:L=>{K(L.target.files),L.target.value=""}}):null,U=!!u&&!u.disabled,Q=U?d.jsxs(d.Fragment,{children:[Y,d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":"Attach files",disabled:r,onClick:()=>I.current?.click(),children:d.jsx(z$,{className:"size-4"})})]}):null,W=n?d.jsx(xb,{gutter:!0,label:"Interrupt",tone:"yellow",onClick:t,children:"✕"}):U?d.jsx(xb,{gutter:!0,label:"Attach files",disabled:r,onClick:()=>I.current?.click(),children:"+"}):d.jsx("span",{"aria-hidden":!0,className:"term-gutter","data-tone":"blue",children:Kx}),D=S?d.jsx(xb,{label:"Send",disabled:!V,onClick:G,tone:V?"blue":void 0,children:"↵"}):n&&!V?d.jsx(tt,{variant:"outline",size:"icon-sm","aria-label":"Interrupt",className:"rounded-full",onClick:t,children:d.jsx(i_,{className:"size-3"})}):d.jsx(tt,{size:"icon-sm","aria-label":"Send",className:"rounded-full",disabled:!V,onClick:G,children:d.jsx(dH,{className:"size-4"})}),H={onDragOver:L=>{u&&!u.disabled&&(L.preventDefault(),z(!0))},onDragLeave:()=>z(!1),onDrop:L=>{!u||u.disabled||(L.preventDefault(),z(!1),K(L.dataTransfer.files))}},B=u?.error?d.jsxs("div",{className:ve("mx-auto mt-1 flex w-full max-w-[var(--wd-content-max-w,48rem)] items-center gap-2 text-label text-danger"),children:[d.jsx(Jl,{className:"size-3 shrink-0"}),d.jsx("span",{className:"min-w-0 flex-1",children:u.error}),d.jsx("button",{type:"button",onClick:u.dismissError,"aria-label":"Dismiss",className:"shrink-0 opacity-70 hover:opacity-100",children:d.jsx(_s,{className:"size-3"})})]}):null;if(S){const L=b??18;return d.jsxs("div",{"data-slot":"composer",className:ve("shrink-0",v),children:[d.jsx(Mc,{...H,fontSize:p,lineHeight:b,affordances:x,bleed:"1ch","data-dragging":j||void 0,className:ve("term-composer",r&&"opacity-60"),children:d.jsxs("div",{className:"term-composer-body",children:[F.length>0&&u?d.jsx(k4,{attachments:u}):null,d.jsxs("div",{className:"term-row",children:[U?Y:null,W,d.jsxs("div",{className:"flex min-w-0 items-start",children:[d.jsx(V1,{...C,triggers:P,normalizeBullets:!1,onSubmit:G,disabled:r,placeholder:r?"Session ended":s,minHeight:L,maxHeight:L*10,"aria-label":"Message the agent",className:"term-composer-field min-w-0 flex-1",onImagePaste:te=>u?.add([te])}),D]})]}),h?d.jsxs("div",{className:"term-row",children:[d.jsx("span",{"aria-hidden":!0,className:"term-gutter"}),d.jsx("div",{className:"flex min-w-0 items-center gap-[1ch]",children:h})]}):null]})}),B]})}return d.jsxs("div",{"data-slot":"composer",className:ve("px-3 pb-3",v),children:[d.jsxs("div",{...H,className:ve("mx-auto w-full max-w-[var(--wd-content-max-w,48rem)] overflow-hidden border border-border bg-bg","transition-colors rounded-lg shadow-(--shadow-xs)","focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/30",j&&"border-ring ring-2 ring-ring/30",r&&"opacity-60"),children:[F.length>0&&u?d.jsx(k4,{attachments:u}):null,w?d.jsxs("div",{className:"flex items-end gap-1 p-1",children:[Q,d.jsx(V1,{...C,triggers:P,normalizeBullets:!1,onSubmit:G,disabled:r,placeholder:r?"Session ended":s,minHeight:20,maxHeight:192,"aria-label":"Message the agent",className:"min-w-0 flex-1 py-0.5 text-body-sm text-text",onImagePaste:L=>u?.add([L])}),D]}):d.jsxs(d.Fragment,{children:[d.jsx(V1,{...C,triggers:P,normalizeBullets:!1,onSubmit:G,disabled:r,placeholder:r?"Session ended":s,minHeight:28,maxHeight:192,"aria-label":"Message the agent",className:"px-3 pt-2.5 pb-1 text-body-sm text-text",onImagePaste:L=>u?.add([L])}),d.jsxs("div",{className:"flex items-center justify-between gap-2 px-2 pb-2",children:[d.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[Q,h]}),D]})]})]}),B]})}function xb({tone:e,label:t,disabled:n,onClick:r,gutter:s,className:a,children:l}){return d.jsx("button",{type:"button","aria-label":t,title:t,disabled:n,onClick:r,"data-tone":e,"data-gutter":s||void 0,className:ve("term-glyph",a),children:l})}function k4({attachments:e}){const t=Rm()==="terminal";return d.jsx("div",{className:ve("flex gap-2 overflow-x-auto",t?"term-attachments":"border-b border-border px-2 py-2"),children:e.items.map(n=>d.jsx(wue,{item:n,onRetry:()=>e.retry(n.key),onRemove:()=>e.remove(n.key)},n.key))})}function wue({item:e,onRetry:t,onRemove:n}){const r=e.status==="failed",s=Rm()==="terminal",a=s?"":"rounded-md";return d.jsxs("div",{className:"group relative shrink-0",title:r?`${e.name} — ${e.error}`:`${e.name} · ${Li(e.bytes)}`,children:[d.jsx("div",{className:ve("flex size-14 items-center justify-center overflow-hidden bg-surface",a,s?"term-attachment":"border border-border",r&&"border-danger/50"),"data-failed":s&&r?"":void 0,children:e.previewUrl?d.jsx("img",{src:e.previewUrl,alt:e.name,className:"size-full object-cover"}):d.jsxs("div",{className:"flex flex-col items-center gap-0.5 text-fg-3",children:[d.jsx(b2,{className:"size-4"}),d.jsx("span",{className:"max-w-12 truncate text-[9px] font-semibold uppercase",children:Nue(e.name)})]})}),e.status==="uploading"?d.jsx("div",{className:ve("absolute inset-0 flex items-center justify-center bg-black/35",a),children:d.jsx(Tn,{className:"size-4 text-white"})}):null,r?d.jsx("button",{type:"button",onClick:t,"aria-label":`Retry ${e.name}`,className:ve("absolute inset-0 flex items-center justify-center bg-black/45 text-warning",a),children:d.jsx(E2,{className:"size-4"})}):null,d.jsx("button",{type:"button",onClick:n,"aria-label":`Remove ${e.name}`,className:ve("absolute flex size-4 items-center justify-center bg-surface text-fg-3 hover:text-fg-1",s?"term-attachment-remove":"-top-1 -right-1 rounded-full border border-border shadow-(--shadow-xs)"),children:d.jsx(_s,{className:"size-2.5"})})]})}const Nue=e=>{const t=e.lastIndexOf(".");return t>0?e.slice(t+1).toUpperCase():"FILE"},_ue=e=>typeof CSS<"u"&&CSS.supports("color",e)?e:void 0,Aue=e=>e>=90?"bg-danger":e>=70?"bg-warning":"bg-accent";function Rue({usage:e,open:t,onOpenChange:n}){return d.jsx(gs,{open:t,onOpenChange:n,children:d.jsxs(bs,{children:[d.jsx(xs,{title:"Context",description:e?.model}),d.jsx(ys,{children:e?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[d.jsx("span",{className:"text-label text-fg-3",children:"Used"}),d.jsxs("span",{className:"font-mono text-body-sm text-fg-1",children:[Gr(e.totalTokens)," / ",Gr(e.maxTokens)," ·"," ",e.percentage.toFixed(0),"%"]})]}),d.jsx("div",{className:"mt-2 h-2 overflow-hidden rounded-full bg-border",children:d.jsx("div",{className:ve("h-full rounded-full",Aue(e.percentage)),style:{width:`${Math.min(100,Math.max(2,e.percentage))}%`}})}),e.categories.length>0?d.jsxs("div",{className:"mt-5",children:[d.jsx("h3",{className:"text-label font-medium text-fg-3",children:"Breakdown"}),d.jsx("div",{className:"mt-2 flex flex-col gap-3",children:e.categories.map(r=>{const s=r.tokens/Math.max(e.maxTokens,1)*100,a=_ue(r.color);return d.jsxs("div",{children:[d.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[d.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[d.jsx("span",{className:"size-2 shrink-0 rounded-full bg-fg-4",style:a?{backgroundColor:a}:void 0}),d.jsx("span",{className:"truncate text-body-sm text-fg-1",children:r.name})]}),d.jsx("span",{className:"shrink-0 font-mono text-label text-fg-3",children:Gr(r.tokens)})]}),d.jsx("div",{className:"mt-1 h-1 overflow-hidden rounded-full bg-border",children:d.jsx("div",{className:"h-full rounded-full bg-fg-4",style:{width:`${Math.min(100,s)}%`,backgroundColor:a}})})]},r.name)})})]}):null]}):d.jsx("p",{className:"py-6 text-center text-body-sm text-fg-4",children:"No reading yet — the context window is measured after a turn completes."})})]})})}function Mue({client:e,cwd:t,open:n,onOpenChange:r}){const[s,a]=y.useState(t),[l,c]=y.useState([]),[u,h]=y.useState(!1),[m,p]=y.useState(""),[b,x]=y.useState(),[v,N]=y.useState(),[w,S]=y.useState(!1),[C,A]=y.useState(),R=y.useCallback(async j=>{S(!0),A(void 0);try{const z=await e.listHostDir(j);a(z.path),c(z.entries),h(z.truncated??!1)}catch(z){A(z instanceof Error?z.message:"Could not read that directory")}finally{S(!1)}},[e]);y.useEffect(()=>{n&&(N(void 0),p(""),x(void 0),A(void 0),t&&R(t))},[n,t,R]),y.useEffect(()=>{if(!n||!t)return;const j=m.trim();if(!j){x(void 0);return}const z=setTimeout(()=>{e.findHostFiles(t,j,40).then(P=>x(P.matches)).catch(()=>x([]))},150);return()=>clearTimeout(z)},[e,t,m,n]);const M=async j=>{S(!0),A(void 0);try{const z=await e.readHostFile(j);N({path:z.path,bytes:z.bytes,content:z.encoding==="utf8"?z.content:"(binary file — not shown)"})}catch(z){A(z instanceof Error?z.message:"Could not read that file")}finally{S(!1)}},_=s&&t&&s!==t?s.slice(0,s.lastIndexOf("/"))||"/":void 0,I=b??l;return d.jsx(gs,{open:n,onOpenChange:r,children:d.jsxs(bs,{size:"lg",children:[d.jsx(xs,{title:v?v.path.split("/").pop():"Files",description:v?v.path:s,actions:v?d.jsxs(tt,{variant:"ghost",size:"xs",onClick:()=>N(void 0),children:[d.jsx(Cp,{className:"size-3.5"}),"Back"]}):_?d.jsxs(tt,{variant:"ghost",size:"xs",onClick:()=>void R(_),children:[d.jsx(Cp,{className:"size-3.5"}),"Up"]}):null}),d.jsxs(ys,{className:"flex flex-col gap-3",children:[C?d.jsx("div",{className:"rounded-md bg-danger-bg px-3 py-2 text-body-sm text-danger",children:C}):null,v?d.jsxs(d.Fragment,{children:[d.jsx("p",{className:"text-label text-fg-4",children:Li(v.bytes)}),d.jsx(R_,{code:v.content,label:v.path.split("/").pop()})]}):d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"relative",children:[d.jsx(km,{className:"absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-fg-4"}),d.jsx(Zt,{value:m,onChange:j=>p(j.target.value),placeholder:"Search this project…",className:"pl-7",spellCheck:!1})]}),w&&I.length===0?d.jsx("div",{className:"py-6 text-center",children:d.jsx(Tn,{className:"size-4 text-fg-4"})}):I.length===0?d.jsx("p",{className:"py-6 text-center text-body-sm text-fg-4",children:b?"No matching files.":"This directory is empty."}):d.jsx("ul",{className:"flex flex-col",children:b?b.map(j=>d.jsx("li",{children:d.jsxs("button",{type:"button",onClick:()=>void M(j.path),className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-surface-hover",children:[d.jsx(vm,{className:"size-3.5 shrink-0 text-fg-4"}),d.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-label text-fg-1",children:j.relative})]})},j.path)):l.map(j=>d.jsx("li",{children:d.jsxs("button",{type:"button",onClick:()=>j.type==="dir"?void R(j.path):void M(j.path),className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-surface-hover",children:[d.jsx(Iue,{type:j.type}),d.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono text-label text-fg-1",children:[j.name,j.type==="dir"?"/":""]}),j.bytes!==void 0?d.jsx("span",{className:"shrink-0 text-label text-fg-4",children:Li(j.bytes)}):null]})},j.path))}),u&&!b?d.jsx("p",{className:"text-label text-fg-4",children:"More entries than the server will return — use the search box."}):null]})]})]})})}function Iue({type:e}){return e==="dir"?d.jsx(Em,{className:"size-3.5 shrink-0 text-accent"}):e==="symlink"?d.jsx(J6,{className:"size-3.5 shrink-0 text-fg-4"}):d.jsx(vm,{className:"size-3.5 shrink-0 text-fg-4"})}const _I={connected:"success",failed:"danger","needs-auth":"warning",pending:"info",disabled:"neutral"};function Oue({client:e,sessionId:t,open:n,onOpenChange:r,canManageServers:s=!0}){const[a,l]=y.useState(),[c,u]=y.useState(),[h,m]=y.useState(!1),[p,b]=y.useState(),[x,v]=y.useState(),[N,w]=y.useState(),S=y.useCallback(async()=>{if(t){m(!0),u(void 0);try{l(await e.listMcpServers(t))}catch(_){u(_ instanceof Error?_.message:"Could not read MCP status")}finally{m(!1)}}},[e,t]);y.useEffect(()=>{n&&(v(void 0),w(void 0),S())},[n,S]);const C=async(_,I)=>{if(t){b(_),u(void 0);try{l(await e.mcpServerAction(t,_,I))}catch(j){u(j instanceof Error?j.message:`Could not ${I} ${_}`)}finally{b(void 0)}}},A=a?.find(_=>_.name===x),R=A?.tools?.find(_=>_.name===N),M=R?.name??A?.name??"MCP servers";return d.jsx(gs,{open:n,onOpenChange:r,children:d.jsxs(bs,{children:[d.jsx(xs,{title:M,description:R?`${A?.name} tool`:A?A.serverInfo?.name:void 0,actions:x?d.jsxs(tt,{variant:"ghost",size:"xs",onClick:()=>N?w(void 0):v(void 0),children:[d.jsx(Cp,{className:"size-3.5"}),"Back"]}):d.jsxs(tt,{variant:"ghost",size:"xs",onClick:()=>void S(),disabled:h,children:[h?d.jsx(Tn,{className:"size-3 text-current"}):d.jsx(E2,{className:"size-3"}),"Refresh"]})}),d.jsxs(ys,{children:[c?d.jsx("div",{className:"mb-3 rounded-md bg-danger-bg px-3 py-2 text-body-sm text-danger",children:c}):null,R?d.jsx(Due,{tool:R}):A?d.jsx(jue,{server:A,busy:p===A.name,canManage:s,onAct:_=>void C(A.name,_),onSelectTool:w}):c&&!a?null:d.jsx(Lue,{servers:a,loading:h,onSelect:v})]})]})})}function Lue({servers:e,loading:t,onSelect:n}){if(t&&!e)return d.jsx("div",{className:"py-6 text-center",children:d.jsx(Tn,{className:"size-4 text-fg-4"})});if(!e?.length)return d.jsx("p",{className:"py-6 text-center text-body-sm text-fg-4",children:"No MCP servers configured for this session."});const r=[...new Set(e.map(s=>s.scope??"other"))];return d.jsx("div",{className:"flex flex-col gap-4",children:r.map(s=>d.jsxs("div",{children:[d.jsx("h3",{className:"text-label font-medium text-fg-3 capitalize",children:s}),d.jsx("ul",{className:"mt-1 flex flex-col",children:e.filter(a=>(a.scope??"other")===s).map(a=>d.jsx("li",{children:d.jsxs("button",{type:"button",onClick:()=>n(a.name),className:"flex w-full items-center gap-2 rounded-md px-2 py-2 text-left transition-colors hover:bg-surface-hover",children:[d.jsx("span",{className:"min-w-0 flex-1 truncate text-body-sm text-fg-1",children:a.name}),a.tools?.length?d.jsxs("span",{className:"shrink-0 text-label text-fg-4",children:[a.tools.length," tools"]}):null,d.jsx(En,{variant:_I[a.status]??"neutral",dot:!0,className:"shrink-0",children:a.status}),d.jsx(Tc,{className:"size-3.5 shrink-0 text-fg-4"})]})},a.name))})]},s))})}function jue({server:e,busy:t,canManage:n,onAct:r,onSelectTool:s}){const a=e.status==="disabled";return d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsxs("div",{children:[d.jsx(cr,{label:"Status",children:d.jsx(En,{variant:_I[e.status]??"neutral",dot:!0,children:e.status})}),e.transport?d.jsx(cr,{label:"Transport",children:e.transport}):null,e.scope?d.jsx(cr,{label:"Scope",children:e.scope}):null,e.serverInfo?d.jsxs(cr,{label:"Server",children:[e.serverInfo.name," ",e.serverInfo.version]}):null,e.command?d.jsx(cr,{label:"Command",mono:!0,children:[e.command,...e.args??[]].join(" ")}):null,e.url?d.jsx(cr,{label:"URL",mono:!0,children:e.url}):null]}),e.error?d.jsx("div",{className:"rounded-md bg-danger-bg px-3 py-2 text-body-sm break-words text-danger",children:e.error}):null,n?d.jsxs("div",{className:"flex gap-2",children:[d.jsxs(tt,{variant:"outline",size:"sm",disabled:t,onClick:()=>r("reconnect"),children:[t?d.jsx(Tn,{className:"size-3 text-current"}):d.jsx(E2,{className:"size-3"}),"Reconnect"]}),d.jsxs(tt,{variant:"outline",size:"sm",disabled:t,onClick:()=>r(a?"enable":"disable"),children:[a?d.jsx(rV,{className:"size-3"}):d.jsx(tV,{className:"size-3"}),a?"Enable":"Disable"]})]}):null,d.jsxs("div",{children:[d.jsx("h3",{className:"text-label font-medium text-fg-3",children:"Tools"}),e.tools?.length?d.jsx("ul",{className:"mt-1 flex flex-col",children:e.tools.map(l=>d.jsx("li",{children:d.jsxs("button",{type:"button",onClick:()=>s(l.name),className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-surface-hover",children:[d.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-label text-fg-1",children:l.name}),d.jsx(Tc,{className:"size-3.5 shrink-0 text-fg-4"})]})},l.name))}):d.jsx("p",{className:"py-2 text-body-sm text-fg-4",children:e.status==="connected"?"This server exposes no tools.":"Tools are listed once the server connects."})]})]})}function Due({tool:e}){const t=e.annotations;return d.jsxs("div",{className:"flex flex-col gap-3",children:[e.description?d.jsx("p",{className:"text-body-sm whitespace-pre-wrap text-fg-2",children:e.description}):d.jsx("p",{className:"text-body-sm text-fg-4",children:"This tool carries no description."}),t?d.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.readOnly?d.jsx(En,{variant:"success",children:"read-only"}):null,t.destructive?d.jsx(En,{variant:"danger",children:"destructive"}):null,t.openWorld?d.jsx(En,{variant:"warning",children:"open world"}):null]}):null,e.inputSchema!==void 0?d.jsxs("div",{children:[d.jsx("h3",{className:"text-label font-medium text-fg-3",children:"Parameters"}),d.jsx("pre",{className:"mt-1 max-h-64 overflow-auto rounded-md bg-surface px-3 py-2 text-label text-fg-2",children:Pue(e.inputSchema)})]}):d.jsx("p",{className:ve("text-label text-fg-4"),children:"Parameters aren’t available: this engine names and describes each tool but reports no input schema."})]})}function Pue(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}const AI={user:"Personal",repo:"This project",system:"System",admin:"Managed"};function Bue({skills:e,open:t,onOpenChange:n,onUse:r}){const[s,a]=y.useState(),l=e?.find(c=>c.name===s);return d.jsx(gs,{open:t,onOpenChange:c=>{c||a(void 0),n(c)},children:d.jsxs(bs,{children:[d.jsx(xs,{title:l?l.displayName??l.name:"Skills",description:l?l.name!==(l.displayName??l.name)?l.name:void 0:"Capabilities the agent can choose to use. Not commands — the model picks them from their descriptions.",actions:l?d.jsxs(tt,{variant:"ghost",size:"xs",onClick:()=>a(void 0),children:[d.jsx(Cp,{className:"size-3.5"}),"Back"]}):void 0}),d.jsx(ys,{children:l?d.jsx(Hue,{skill:l,onUse:r,onUsed:()=>n(!1)}):d.jsx(zue,{skills:e,onSelect:a})})]})})}function zue({skills:e,onSelect:t}){if(!e)return d.jsx("p",{className:"py-6 text-center text-body-sm text-fg-4",children:"Skills are listed once the session connects — send a message first."});if(e.length===0)return d.jsx("p",{className:"py-6 text-center text-body-sm text-fg-4",children:"This session found no skills."});const n=[...new Set(e.map(r=>r.scope??"other"))];return d.jsx("div",{className:"flex flex-col gap-4",children:n.map(r=>d.jsxs("div",{children:[d.jsx("h3",{className:"text-label font-medium text-fg-3",children:AI[r]??r}),d.jsx("ul",{className:"mt-1 flex flex-col",children:e.filter(s=>(s.scope??"other")===r).map(s=>d.jsx("li",{children:d.jsxs("button",{type:"button",onClick:()=>t(s.name),className:"flex w-full items-start gap-2 rounded-md px-2 py-2 text-left transition-colors hover:bg-surface-hover",children:[d.jsxs("span",{className:"min-w-0 flex-1",children:[d.jsx("span",{className:"block truncate text-body-sm text-fg-1",children:s.displayName??s.name}),s.shortDescription??s.description?d.jsx("span",{className:"block truncate text-label text-fg-4",children:s.shortDescription??s.description}):null]}),s.enabled?null:d.jsx(En,{variant:"neutral",className:"mt-0.5 shrink-0",children:"off"}),d.jsx(Tc,{className:"mt-0.5 size-3.5 shrink-0 text-fg-4"})]})},s.name))})]},r))})}function Hue({skill:e,onUse:t,onUsed:n}){return d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsxs("div",{children:[e.scope?d.jsx(cr,{label:"Scope",children:AI[e.scope]??e.scope}):null,d.jsx(cr,{label:"Status",children:d.jsx(En,{variant:e.enabled?"success":"neutral",dot:!0,children:e.enabled?"enabled":"disabled"})})]}),e.description?d.jsxs("div",{children:[d.jsx("h3",{className:"text-label font-medium text-fg-3",children:"Description"}),d.jsx("p",{className:"mt-1 text-body-sm whitespace-pre-wrap text-fg-2",children:e.description})]}):d.jsx("p",{className:"text-body-sm text-fg-4",children:"This skill carries no description."}),t&&e.enabled?d.jsxs("div",{children:[d.jsx(tt,{variant:"outline",size:"sm",onClick:()=>{t(e),n()},children:"Use this skill"}),d.jsx("p",{className:"mt-1.5 text-label text-fg-4",children:"Writes an opening message into the composer for you to edit — it isn’t sent, and there is no command that runs a skill directly."})]}):null]})}const Wx=e=>e==="default",yb=e=>e.replace(/\[.*\]$/,"");function C4(e){const t=e.toLowerCase().split("-");return t[0]==="claude"&&t.shift(),t[0]??""}function Uue(e,t){if(t===e.value||t===e.resolvedModel)return!0;const n=yb(t);if(e.resolvedModel)return n===yb(e.resolvedModel);const r=C4(n);return r!==""&&r===C4(yb(e.value))}function Fue(e,t){if(t)return e.filter(n=>!Wx(n.value)).find(n=>Uue(n,t))}function RI({models:e,model:t,onModelChange:n,variant:r="toolbar",disabled:s,className:a}){const l=Fue(e,t)??(t?void 0:e.find(c=>Wx(c.value)));return d.jsxs(Di,{items:e.map(c=>({value:c.value,label:c.displayName})),value:l?.value??null,onValueChange:c=>{typeof c!="string"||c===l?.value||n(Wx(c)?void 0:c)},disabled:s,children:[d.jsx(Bi,{"aria-label":"Model",className:ve(r==="toolbar"&&"h-6 max-w-56 border-transparent bg-transparent text-fg-3 hover:bg-surface-hover",a),children:d.jsx("span",{className:ve("truncate",r==="toolbar"&&"font-mono text-label"),children:d.jsx(Pi,{placeholder:t??"model"})})}),d.jsx(zi,{className:"min-w-72",children:e.map(c=>d.jsxs(Qs,{value:c.value,children:[d.jsx(Xs,{children:d.jsx("span",{className:"font-medium",children:c.displayName})}),c.description?d.jsx("span",{className:"text-label text-fg-4",children:c.description}):null]},c.value))})]})}const Rd=[{value:"default",label:"Manual",shortLabel:"Manual",description:"Always ask before making changes",icon:Q6},{value:"acceptEdits",label:"Accept edits",shortLabel:"Edits",description:"Automatically accept all file edits",icon:g2},{value:"plan",label:"Plan",shortLabel:"Plan",description:"Create a plan before making changes",icon:fU},{value:"auto",label:"Auto",shortLabel:"Auto",description:"Claude handles permission decisions",icon:l_},{value:"dontAsk",label:"Don't ask",shortLabel:"Don't ask",description:"Never ask — deny anything not pre-approved",icon:OV},{value:"bypassPermissions",label:"Bypass permissions",shortLabel:"Bypass",description:"Skip every approval — the agent is unsupervised",icon:Jl,dangerous:!0}],$ue=e=>Rd.find(t=>t.value===e);function Vue(e,t){return(e?Rd.filter(r=>e.includes(r.value)):Rd).map(r=>({value:r.value,label:r.label,description:r.value==="bypassPermissions"&&t===!1?"Only available to a session started in this mode":r.description,dangerous:r.dangerous,disabled:r.value==="bypassPermissions"&&t===!1}))}function yv({mode:e,onModeChange:t,modes:n,canBypass:r,variant:s="toolbar",disabled:a,className:l}){const c=e==="bypassPermissions",u=n?Rd.filter(m=>n.includes(m.value)):Rd,h=m=>m.value==="bypassPermissions"&&r===!1;return d.jsxs(Di,{items:u.map(m=>({value:m.value,label:m.label})),value:e??null,onValueChange:m=>{typeof m=="string"&&m!==e&&t(m)},disabled:a,children:[d.jsx(Bi,{"aria-label":"Permission mode",className:ve(s==="toolbar"&&"h-6 max-w-44 border-transparent bg-transparent hover:bg-surface-hover",c?"text-danger":s==="toolbar"?"text-fg-3":void 0,l),children:d.jsx("span",{className:ve("truncate",s==="toolbar"&&"text-label"),children:d.jsx(Pi,{placeholder:"permissions"})})}),d.jsx(zi,{className:"min-w-64",children:u.map(m=>{const p=h(m);return d.jsxs(Qs,{value:m.value,disabled:p,children:[d.jsx(Xs,{children:d.jsxs("span",{className:"flex items-center gap-2",children:[d.jsx(m.icon,{className:ve("size-3.5 shrink-0",m.dangerous?"text-danger":"text-fg-3")}),d.jsx("span",{className:ve("font-medium",m.dangerous&&"text-danger"),children:m.label})]})}),d.jsx("span",{className:ve("pl-5.5 text-label",p?"text-fg-4":m.dangerous?"text-danger/80":"text-fg-4"),children:p?"Only available to a session started in this mode":m.description})]},m.value)})})]})}function que({request:e,onApprove:t,onDeny:n,className:r}){const[s,a]=y.useState(!1),[l,c]=y.useState(!1),[u,h]=y.useState(""),m=x=>{const v=u.trim();n(e.id,v||void 0,x||void 0),h(""),c(!1)},p=Da(e.input),b=oA(e.toolName);return d.jsxs("div",{"data-slot":"permission-prompt",className:ve("rounded-lg border border-warning/40 bg-warning-bg p-3",r),children:[d.jsxs("div",{className:"flex items-start gap-2.5",children:[d.jsx(Q6,{className:"mt-0.5 size-4 shrink-0 text-warning"}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("div",{className:"text-body-sm font-medium text-fg-1",children:e.title??e.displayName??"Permission needed"}),e.description?d.jsx("div",{className:"mt-0.5 text-label text-fg-3",children:e.description}):null,e.decisionReason?d.jsx("div",{className:"mt-0.5 text-label text-fg-4",children:e.decisionReason}):null,d.jsxs("div",{className:"mt-1.5 flex min-w-0 items-center gap-2",children:[d.jsx(b,{className:"size-3 shrink-0 text-fg-3"}),d.jsx("span",{className:"shrink-0 font-mono text-label font-medium text-fg-2",children:e.toolName}),p?d.jsx("span",{className:"min-w-0 truncate font-mono text-label text-fg-4",children:p}):null]}),d.jsxs("button",{type:"button",className:"mt-1 font-mono text-label text-fg-3 underline-offset-2 hover:underline",onClick:()=>a(x=>!x),children:[s?"Hide":"Show"," ",e.toolName," input"]}),s?d.jsx("pre",{className:"mt-1.5 max-h-48 overflow-auto rounded-md bg-code-bg px-2.5 py-1.5 font-mono text-label whitespace-pre-wrap text-fg-2",children:JSON.stringify(e.input,null,2)}):null]}),d.jsxs("div",{className:"flex shrink-0 flex-wrap justify-end gap-1.5",children:[d.jsx(tt,{size:"sm",onClick:()=>t(e.id),children:"Allow"}),d.jsx(tt,{size:"sm",variant:"outline",onClick:()=>c(x=>!x),children:"Deny"}),d.jsx(tt,{size:"sm",variant:"outline",onClick:()=>m(!0),children:"Deny & stop"})]})]}),l?d.jsxs("div",{className:"mt-2.5 flex items-center gap-2 border-t border-warning/30 pt-2.5",children:[d.jsx(Zt,{autoFocus:!0,value:u,onChange:x=>h(x.target.value),onKeyDown:x=>{x.key==="Enter"&&m(!1),x.key==="Escape"&&c(!1)},placeholder:"Reason (optional) — the agent reads this and can try something else",className:"h-7 flex-1"}),d.jsx(tt,{size:"sm",variant:"outline",onClick:()=>c(!1),children:"Cancel"}),d.jsx(tt,{size:"sm",variant:"destructive",onClick:()=>m(!1),children:"Deny"})]}):null]})}function Yue({task:e,items:t,label:n,onBack:r,terminal:s,fontSize:a,lineHeight:l}){const c=e?Km(e,t):!1,u=e?vI(e):!1,h=zd(c),m=t.reduce((S,C)=>S+(C.kind==="tool_call"?1:0),0),p=c?e?.ts:void 0,b=wI(p!==void 0),x=p===void 0?void 0:Sc(b-p),v=e?bI(e):n,N=e?u?"failed":c?`${h} working…`:"done":void 0,w=[m>0?`${m} tool${m===1?"":"s"}`:void 0,x].filter(Boolean).join(" · ");return s?d.jsx(Mc,{fontSize:a,lineHeight:l,className:"shrink-0",children:d.jsx("button",{type:"button",onClick:r,"aria-label":"Back to the session",className:"block w-full cursor-pointer text-left",children:d.jsxs(_t,{glyph:"←",glyphTone:"dim",indent:1,tone:u?"red":"green",children:[v,N?d.jsxs(jr,{tone:u?"red":c?"mark":"dim",children:[" · ",N]}):null,w?d.jsxs(jr,{tone:"faint",children:[" · ",w]}):null]})})}):d.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-3 py-1.5",children:[d.jsxs(tt,{variant:"ghost",size:"sm",onClick:r,className:"h-6 gap-1 px-1.5",children:[d.jsx(oH,{className:"size-3.5"}),"Back"]}),d.jsx("span",{className:ve("min-w-0 flex-1 truncate text-body-sm",u?"text-danger":"text-fg-2"),children:v}),N?d.jsx("span",{className:ve("shrink-0 text-label",u?"text-danger":c?"text-accent":"text-fg-3"),children:N}):null,w?d.jsx("span",{className:"shrink-0 text-label text-fg-4",children:w}):null]})}const w4=[{value:"auto",label:"Auto-answer",description:"pick each question’s recommended option"},{value:"ask",label:"Ask",description:"wait for a watcher or webhook controller to answer"},{value:"deny",label:"Disabled",description:"the agent is told to decide on its own"}];function vv(e){return(Array.isArray(e.questions)?e.questions:[]).flatMap(n=>{const r=n;if(typeof r.question!="string"||!Array.isArray(r.options))return[];const s=r.options.filter(a=>typeof a?.label=="string");return s.length===0?[]:[{question:r.question,header:typeof r.header=="string"?r.header:"",options:s,multiSelect:r.multiSelect===!0}]})}const Bu={labels:[],other:"",otherActive:!1};function N4(e){const t=[...e.labels];return e.otherActive&&e.other.trim()&&t.push(e.other.trim()),t.join(", ")}function Gue({request:e,onAnswer:t,onDismiss:n,className:r}){const s=vv(e.input),[a,l]=y.useState(()=>s.map(()=>Bu)),c=(p,b)=>{l(x=>x.map((v,N)=>N===p?{...v,...b}:v))},u=(p,b,x)=>{const v=a[p]??Bu;x?c(p,{labels:v.labels.includes(b)?v.labels.filter(N=>N!==b):[...v.labels,b]}):c(p,{labels:v.labels[0]===b?[]:[b],otherActive:!1})},h=s.every((p,b)=>N4(a[b]??Bu)!==""),m=()=>{const p={};s.forEach((b,x)=>{p[b.question]=N4(a[x]??Bu)}),t(e.id,{...e.input,answers:p})};return d.jsx("div",{"data-slot":"question-prompt",className:ve("rounded-lg border border-info/40 bg-info-bg p-3",r),children:d.jsxs("div",{className:"flex items-start gap-2.5",children:[d.jsx(t_,{className:"mt-0.5 size-4 shrink-0 text-info"}),d.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-3",children:[s.map((p,b)=>{const x=a[b]??Bu;return d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[p.header?d.jsx(En,{variant:"info",children:p.header}):null,d.jsx("span",{className:"text-body-sm font-medium text-fg-1",children:p.question})]}),d.jsxs("div",{className:"flex flex-col gap-1",children:[p.options.map(v=>{const N=x.labels.includes(v.label);return d.jsxs("button",{type:"button",onClick:()=>u(b,v.label,p.multiSelect===!0),className:ve("rounded-md border px-2.5 py-1.5 text-left transition-colors",N?"border-info bg-bg":"border-border bg-bg/50 hover:border-border-strong hover:bg-bg"),children:[d.jsx("span",{className:"block text-body-sm font-medium text-fg-1",children:v.label}),v.description?d.jsx("span",{className:"block text-label text-fg-4",children:v.description}):null,N&&v.preview?d.jsx("pre",{className:"mt-1.5 max-h-40 overflow-auto rounded-md bg-code-bg px-2.5 py-1.5 font-mono text-label whitespace-pre-wrap text-fg-2",children:v.preview}):null]},v.label)}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("button",{type:"button",onClick:()=>c(b,{otherActive:!x.otherActive}),className:ve("shrink-0 rounded-md border px-2.5 py-1.5 text-body-sm font-medium transition-colors",x.otherActive?"border-info bg-bg text-fg-1":"border-border bg-bg/50 text-fg-3 hover:border-border-strong hover:bg-bg"),children:"Other…"}),x.otherActive?d.jsx(Zt,{autoFocus:!0,value:x.other,onChange:v=>c(b,{other:v.target.value}),placeholder:"Type your own answer",className:"flex-1"}):null]})]})]},b)}),d.jsx("div",{children:d.jsx(tt,{size:"sm",onClick:m,disabled:!h,children:"Answer"})})]}),d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":"Dismiss question",className:"shrink-0",onClick:()=>n(e.id,"Question dismissed by user"),children:d.jsx(_s,{className:"size-3.5"})})]})})}function Xx({dashed:e}){return d.jsx("div",{className:ve("term-rule-row",e&&"term-rule-dashed"),"aria-hidden":!0})}function MI({children:e}){return d.jsx(_t,{tone:"faint",children:e})}function Kue({children:e,className:t}){return d.jsx("div",{className:ve("term-box",t),children:e})}function Wue({title:e,subject:t}){return d.jsxs(d.Fragment,{children:[d.jsx(_t,{tone:"blue",bold:!0,children:e}),t?d.jsx(_t,{tone:"dim",children:t}):null]})}const Xue={check:["[ ]","[✓]"],radio:["( )","(•)"]};function Que(e){return!(e instanceof HTMLElement)||!(e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable)?!1:(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?e.value:e.textContent??"").trim().length>0}function Ev({options:e,focused:t,onFocus:n,onChoose:r,active:s=!0,autoFocus:a=!0,label:l}){const c=y.useRef([]);y.useEffect(()=>{!s||!c.current.some(m=>m!==null&&m===document.activeElement)&&(!a||Que(document.activeElement))||c.current[t]?.focus()},[s,t,a]);const u=h=>{e.length>0&&n((t+h+e.length)%e.length)};return d.jsx("div",{role:"group","aria-label":l,onKeyDown:h=>{if(h.key==="ArrowDown"){u(1),h.preventDefault();return}if(h.key==="ArrowUp"){u(-1),h.preventDefault();return}const m=Number(h.key);Number.isInteger(m)&&m>=1&&m<=Math.min(e.length,9)&&(n(m-1),r(m-1),h.preventDefault())},children:e.map((h,m)=>{const p=m===t;return d.jsxs("div",{children:[d.jsx("button",{ref:b=>{c.current[m]=b},type:"button",tabIndex:p?0:-1,"aria-pressed":h.checked,onFocus:()=>n(m),onClick:()=>r(m),className:"term-press",children:d.jsxs(_t,{columns:5,glyph:`${p?"❯":" "} ${m+1}.`,glyphTone:p?"fg":"faint",tone:h.danger?"red":h.selected?"green":"fg","data-focused":p?"":void 0,children:[h.checked!==void 0?d.jsxs(jr,{tone:h.checked?"green":"faint",children:[Xue[h.marker??"check"][h.checked?1:0]," "]}):null,d.jsx(jr,{bold:p||h.selected,children:h.label})]})}),h.description?d.jsx(_t,{columns:5,tone:"dim",children:h.description}):null,h.detail?d.jsx("div",{className:"term-detail",children:h.detail}):null]},h.key)})})}function II({value:e,onChange:t,onSubmit:n,onCancel:r,placeholder:s}){return d.jsx(_t,{columns:5,glyph:" ›",glyphTone:"dim",children:d.jsx("input",{autoFocus:!0,value:e,placeholder:s,onChange:a=>t(a.target.value),onKeyDown:a=>{a.key==="Enter"&&(a.preventDefault(),n()),a.key==="Escape"&&(a.stopPropagation(),r())},className:"term-input"})})}function Zue({tabs:e,active:t,onSelect:n}){return d.jsxs(_t,{glyph:"←",glyphTone:"faint",children:[e.map((r,s)=>d.jsxs("button",{type:"button",tabIndex:-1,onClick:()=>n(s),className:ve("term-tab",s===t&&"term-tab-active"),children:[r.glyph," ",r.label]},r.key)),d.jsx(jr,{tone:"faint",children:" →"})]})}function Jue({request:e,onApprove:t,onDeny:n}){const[r,s]=y.useState(0),[a,l]=y.useState(!1),[c,u]=y.useState(""),h=N=>{const w=c.trim();n(e.id,w||void 0,N||void 0),u(""),l(!1)},m=NX(e.input),p=Da(e.input),b=e.displayName??e.title??"Permission needed",x=m?.path??(p||void 0),v=[{key:"allow",label:"Yes"},{key:"deny",label:"No, and tell the agent what to do differently",detail:a?d.jsx(II,{value:c,onChange:u,onSubmit:()=>h(!1),onCancel:()=>l(!1),placeholder:"Reason (optional) — the agent reads this and can try something else"}):void 0},{key:"stop",label:"No, and stop the turn",danger:!0}];return d.jsxs("div",{"data-slot":"permission-prompt",onKeyDown:N=>{N.key==="Escape"&&(N.preventDefault(),h(!1))},children:[d.jsx(Xx,{}),d.jsx(Wue,{title:b,subject:x}),d.jsx(Gs,{}),m?d.jsxs(d.Fragment,{children:[d.jsx(uA,{patch:m}),d.jsx(Gs,{}),d.jsx(Xx,{dashed:!0})]}):e.description?d.jsxs(d.Fragment,{children:[d.jsx(_t,{tone:"dim",children:e.description}),d.jsx(Gs,{})]}):null,e.decisionReason?d.jsx(_t,{tone:"faint",children:e.decisionReason}):null,d.jsx(_t,{children:e.title??"Do you want to proceed?"}),d.jsx(Ev,{label:b,options:v,focused:r,onFocus:s,active:!a,onChoose:N=>{N===0?t(e.id):N===1?l(!0):h(!0)}}),d.jsx(Gs,{}),d.jsx(MI,{children:"Enter to select · ↑/↓ to navigate · 1–3 to choose · Esc to cancel"})]})}const zu={labels:[],other:"",otherActive:!1};function vb(e){const t=[...e.labels];return e.otherActive&&e.other.trim()&&t.push(e.other.trim()),t.join(", ")}function ede({request:e,onAnswer:t,onDismiss:n}){const r=vv(e.input),[s,a]=y.useState(()=>r.map(()=>zu)),[l,c]=y.useState(()=>r.map(()=>0)),[u,h]=y.useState(0),[m,p]=y.useState(0),b=u>=r.length,x=s[u]??zu,v=M=>vb(s[M]??zu)!=="",N=r.every((M,_)=>v(_)),w=(M,_)=>a(I=>I.map((j,z)=>z===M?{...j,..._}:j)),S=(M,_,I)=>{a(j=>j.map((z,P)=>P!==M?z:I?{...z,labels:z.labels.includes(_)?z.labels.filter(F=>F!==_):[...z.labels,_]}:{...z,labels:[_],otherActive:!1}))},C=()=>{const M={};r.forEach((_,I)=>{M[_.question]=vb(s[I]??zu)}),t(e.id,{...e.input,answers:M})},A=()=>n(e.id,"Question dismissed by user"),R=M=>h(_=>Math.min(r.length,Math.max(0,_+M)));return d.jsxs("div",{"data-slot":"question-prompt",onKeyDown:M=>{if(M.key==="Escape"){M.preventDefault(),A();return}M.key==="Tab"&&(M.preventDefault(),R(M.shiftKey?-1:1))},children:[d.jsx(Xx,{}),d.jsx(Zue,{tabs:[...r.map((M,_)=>({key:`q${_}`,label:M.header||`Question ${_+1}`,glyph:v(_)?"▣":"▢"})),{key:"submit",label:"Submit",glyph:"✓"}],active:u,onSelect:h}),d.jsx(Gs,{}),b?d.jsx(nde,{questions:r,answers:r.map((M,_)=>vb(s[_]??zu)),complete:N,cursor:m,onCursor:p,onSubmit:C,onCancel:A}):d.jsx(tde,{question:r[u],selection:x,cursor:l[u]??0,onCursor:M=>c(_=>_.map((I,j)=>j===u?M:I)),onToggle:M=>S(u,M,r[u].multiSelect===!0),onOther:M=>w(u,M),onAdvance:()=>R(1),onDismiss:A},u),d.jsx(Gs,{}),d.jsx(MI,{children:"Enter to select · ↑/↓ to navigate · Tab to switch questions · Esc to cancel"})]})}function tde({question:e,selection:t,cursor:n,onCursor:r,onToggle:s,onOther:a,onAdvance:l,onDismiss:c}){const u=e.multiSelect===!0,h=[...e.options.map((m,p)=>{const b=t.labels.includes(m.label);return{key:m.label,label:m.label,description:m.description,checked:u?b:void 0,marker:"check",selected:!u&&b,detail:m.preview&&n===p?d.jsx(Kue,{children:m.preview.split(`
|
|
1188
|
+
`),N=uI(v,e.result?.totalChars),w=t?r?v:mue(v,pue):N.shown,S=v.length-w.length,C=t&&!r&&S>0,A=e.result?.truncated===!0,R=A?(e.result?.totalChars??0)-x.length:0,M=p?"red":h==="settled"&&bX(e.name)?"green":yue[h]??"dim",_=e.input?.command,I=typeof _=="string"?_:x;return d.jsx("div",{ref:u,className:t?"term-open":void 0,children:d.jsxs(Mm,{actions:I?d.jsx(M2,{text:I,label:"Copy"}):null,children:[d.jsx(Gm,{onPress:()=>n(j=>!j),expanded:t,children:d.jsxs(_t,{glyph:m?b:"●",glyphTone:M,tone:"fg",children:[d.jsx(jr,{bold:!0,tone:"bright",children:e.name}),d.jsxs(jr,{tone:"dim",children:["(",Da(e.input),")"]}),e.backend&&e.backend!=="server"?d.jsxs(jr,{tone:"faint",children:[" · ",e.backend]}):null]})}),e.result?.images?.map(j=>d.jsx(vue,{toolUseId:e.id,image:j},j.partIndex)),e.patch&&!t?d.jsx(uA,{patch:e.patch}):x?d.jsxs(d.Fragment,{children:[w.map((j,z)=>d.jsx(_t,{indent:1,columns:3,glyph:z===0?"⎿":void 0,tone:p?"red":"dim",children:j||" "},z)),t?C||A?d.jsx(_t,{indent:1,columns:3,tone:"faint",children:a?d.jsxs(d.Fragment,{children:["… fetching ",(e.result?.totalChars??0).toLocaleString()," chars"]}):C||A?d.jsx("button",{type:"button",className:"term-press term-link",onClick:()=>{s(!0),A&&(l(!0),c(e.id).finally(()=>l(!1)))},children:A?`… +${R.toLocaleString()} chars — fetch the rest`:`… +${S} line${S===1?"":"s"} — show all ${x.length.toLocaleString()} chars`}):d.jsxs(d.Fragment,{children:["… +",S," line",S===1?"":"s"]})}):S>0?d.jsxs(_t,{indent:1,columns:3,tone:"faint",children:["… +",S," line",S===1?"":"s"]}):null:N.more?d.jsx(_t,{indent:1,columns:3,tone:"faint",children:N.more}):null]}):null]})})}function vue({toolUseId:e,image:t}){const{src:n,failed:r}=mI({toolUseId:e,...t});return d.jsx(_t,{indent:1,columns:3,children:d.jsx("div",{className:"term-image","data-state":n?"loaded":r?"failed":"pending",style:{height:`calc(var(--term-line) * ${lI})`},children:n?d.jsx("img",{src:n,alt:Fp(t)}):d.jsx(jr,{tone:"faint",children:r?cI:Fp(t)})})})}function CI({items:e}){const[t,n]=y.useState(!1),r=xv(t),s=e.some(c=>{const u=c.status??(c.result===void 0?"running":"settled");return u==="running"||u==="pending"}),a=cue(e),l=zd(s);return d.jsxs("div",{ref:r,className:t?"term-open":void 0,children:[d.jsx(Gm,{onPress:()=>n(c=>!c),expanded:t,children:d.jsx(_t,{glyph:s?l:void 0,glyphTone:s?"mark":void 0,tone:a?"red":"dim",children:gI(e,s)})}),t?d.jsx("div",{children:e.map(c=>d.jsx(kI,{item:c},c.id))}):null]})}function Eue({item:e}){return d.jsxs("div",{children:[d.jsxs(_t,{tone:e.isError?"red":"faint",children:[e.isError?e.subtype:"done"," · ",Sc(e.durationMs)," ·"," ",Js(e.totalCostUsd)]}),e.errors?.map((t,n)=>d.jsx(_t,{tone:"red",children:t},n))]})}function Tue({item:e}){const t=e.level==="error";return d.jsx(_t,{glyph:"!",glyphTone:t?"red":"yellow",tone:t?"red":"dim",children:e.text})}function Sue({item:e,href:t}){return d.jsxs(_t,{glyph:"⤓",glyphTone:"blue",tone:"dim",children:[t?d.jsx("a",{className:"term-link","data-tone":"blue",href:t,download:!0,children:e.path}):d.jsx(jr,{tone:"blue",children:e.path}),d.jsxs(jr,{tone:"faint",children:[" · ",Li(e.bytes)]}),e.description?d.jsxs(jr,{tone:"faint",children:[" · ",e.description]}):null]})}function wI(e){const[t,n]=y.useState(()=>Date.now());return y.useEffect(()=>{if(!e)return;const r=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(r)},[e]),t}function T4({label:e,startedAt:t,tokens:n}){const r=zd(!0),s=wI(t!==void 0),l=[t===void 0?void 0:Sc(s-t),n?`↓ ${(n/1e3).toFixed(1)}k tokens`:void 0].filter(Boolean);return d.jsxs(_t,{glyph:r,glyphTone:"mark",tone:"mark",children:[e,l.length?d.jsxs(jr,{tone:"faint",children:[" (",l.join(" · "),")"]}):null]})}function Mc({fontSize:e,lineHeight:t,bleed:n,affordances:r,className:s,style:a,children:l,...c}){const u=cA(r);return d.jsx("div",{"data-terminal":"","data-affordances":[u.hover&&"hover",u.actions&&"actions"].filter(Boolean).join(" ")||void 0,className:ve("min-w-0",s),style:{...e!==void 0&&{"--term-font-size":`${Math.round(e)}px`},...t!==void 0&&{"--term-line":`${Math.round(t)}px`},...n!==void 0&&{"--term-bleed":n},...a},...c,children:d.jsx(TX,{value:u,children:l})})}const kue=e=>e.replace(/\s*\(MCP\)$/i,"");function NI(e){const t=e.defaultPrompt?.trim()||`$${e.name}`;return/\s$/.test(t)?t:t+" "}function S4(e,t){const n=e.toLowerCase(),r=t.map(s=>s.toLowerCase());return r.some(s=>s.startsWith(n))?2:r.some(s=>s.includes(n))?1:0}function Cue({onSend:e,onInterrupt:t,busy:n,disabled:r,placeholder:s="Message the agent…",commands:a,skills:l,onSearchFiles:c,attachments:u,toolbar:h,layout:m="stacked",fontSize:p,lineHeight:b,affordances:x,className:v,ref:N}){const w=m==="inline",S=Rm()==="terminal",{bind:C,plainText:A,isEmpty:R,clear:M,focus:_}=VK(),I=y.useRef(null),[j,z]=y.useState(!1);y.useImperativeHandle(N,()=>({insertText:L=>{const te=A.length>0&&!/\s$/.test(A)?" ":"";C.ref.current?.appendText(te+L),_()},focus:_}),[C.ref,A,_]);const P=y.useMemo(()=>{const L=[],te=(l??[]).filter(ne=>ne.enabled);if(a&&a.length>0){const ne=new Set,de=a.flatMap(oe=>{const le=kue(oe.name);return ne.has(le)?[]:(ne.add(le),[{...oe,name:le}])});L.push(vC({onSearch:oe=>{const le=[];for(const ge of de){const Pe=S4(oe,[ge.name,...ge.aliases??[],...ge.name.split(":")]);Pe!==0&&le.push({score:Pe,suggestion:{value:ge.name,label:`/${ge.name}${ge.argumentHint?` ${ge.argumentHint}`:""}`,description:ge.description}})}return le.sort((ge,Pe)=>Pe.score-ge.score),le.map(({suggestion:ge})=>ge)},onSelect:oe=>oe.value,chipClassName:"font-mono"}))}return te.length>0&&L.push(vC({char:"$",accessibilityLabel:"skill",onSearch:ne=>{const de=[];for(const oe of te){const le=S4(ne,[oe.name,...oe.name.split(/[-:_]/)]);if(le===0)continue;const ge=oe.shortDescription??oe.description;de.push({score:le,suggestion:{value:oe.name,label:oe.displayName??oe.name,description:ge?`Skill · ${ge}`:"Skill · inserts a message you can edit",icon:d.jsx(jd,{className:"size-3.5 text-fg-3"})}})}return de.sort((oe,le)=>le.score-oe.score),de.map(({suggestion:oe})=>oe)},insertAsText:ne=>{const de=te.find(oe=>oe.name===ne.value);return de?NI(de):`$${ne.value} `}})),c&&L.push(qK({searchDebounceMs:150,onSearch:async(ne,de)=>(await c(ne,de)).map(le=>({value:le.relative,label:le.relative,description:le.path})),onSelect:ne=>ne.value,chipStyle:"inline",chipClassName:"font-mono",emptyMessage:"No matching files"})),L.length>0?L:void 0},[a,l,c]),F=u?.items??[],V=!r&&(!R||F.length>0)&&!u?.uploading&&!u?.hasFailure,G=()=>{V&&(e(A.trim(),u?.readyIds??[]),u?.clear(),M(),_())},K=L=>{L&&L.length>0&&u?.add(L)},Y=u&&!u.disabled?d.jsx("input",{ref:I,type:"file",multiple:!0,accept:u.accept||void 0,className:"hidden",onChange:L=>{K(L.target.files),L.target.value=""}}):null,U=!!u&&!u.disabled,Q=U?d.jsxs(d.Fragment,{children:[Y,d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":"Attach files",disabled:r,onClick:()=>I.current?.click(),children:d.jsx(z$,{className:"size-4"})})]}):null,W=n?d.jsx(xb,{gutter:!0,label:"Interrupt",tone:"yellow",onClick:t,children:"✕"}):U?d.jsx(xb,{gutter:!0,label:"Attach files",disabled:r,onClick:()=>I.current?.click(),children:"+"}):d.jsx("span",{"aria-hidden":!0,className:"term-gutter","data-tone":"blue",children:Kx}),D=S?d.jsx(xb,{label:"Send",disabled:!V,onClick:G,tone:V?"blue":void 0,children:"↵"}):n&&!V?d.jsx(tt,{variant:"outline",size:"icon-sm","aria-label":"Interrupt",className:"rounded-full",onClick:t,children:d.jsx(i_,{className:"size-3"})}):d.jsx(tt,{size:"icon-sm","aria-label":"Send",className:"rounded-full",disabled:!V,onClick:G,children:d.jsx(dH,{className:"size-4"})}),H={onDragOver:L=>{u&&!u.disabled&&(L.preventDefault(),z(!0))},onDragLeave:()=>z(!1),onDrop:L=>{!u||u.disabled||(L.preventDefault(),z(!1),K(L.dataTransfer.files))}},B=u?.error?d.jsxs("div",{className:ve("mx-auto mt-1 flex w-full max-w-[var(--wd-content-max-w,48rem)] items-center gap-2 text-label text-danger"),children:[d.jsx(Jl,{className:"size-3 shrink-0"}),d.jsx("span",{className:"min-w-0 flex-1",children:u.error}),d.jsx("button",{type:"button",onClick:u.dismissError,"aria-label":"Dismiss",className:"shrink-0 opacity-70 hover:opacity-100",children:d.jsx(_s,{className:"size-3"})})]}):null;if(S){const L=b??18;return d.jsxs("div",{"data-slot":"composer",className:ve("shrink-0",v),children:[d.jsx(Mc,{...H,fontSize:p,lineHeight:b,affordances:x,bleed:"1ch","data-dragging":j||void 0,className:ve("term-composer",r&&"opacity-60"),children:d.jsxs("div",{className:"term-composer-body",children:[F.length>0&&u?d.jsx(k4,{attachments:u}):null,d.jsxs("div",{className:"term-row",children:[U?Y:null,W,d.jsxs("div",{className:"flex min-w-0 items-start",children:[d.jsx(V1,{...C,triggers:P,normalizeBullets:!1,onSubmit:G,disabled:r,placeholder:r?"Session ended":s,minHeight:L,maxHeight:L*10,"aria-label":"Message the agent",className:"term-composer-field min-w-0 flex-1",onImagePaste:te=>u?.add([te])}),D]})]}),h?d.jsxs("div",{className:"term-row",children:[d.jsx("span",{"aria-hidden":!0,className:"term-gutter"}),d.jsx("div",{className:"flex min-w-0 items-center gap-[1ch]",children:h})]}):null]})}),B]})}return d.jsxs("div",{"data-slot":"composer",className:ve("px-3 pb-3",v),children:[d.jsxs("div",{...H,className:ve("mx-auto w-full max-w-[var(--wd-content-max-w,48rem)] overflow-hidden border border-border bg-bg","transition-colors rounded-lg shadow-(--shadow-xs)","focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/30",j&&"border-ring ring-2 ring-ring/30",r&&"opacity-60"),children:[F.length>0&&u?d.jsx(k4,{attachments:u}):null,w?d.jsxs("div",{className:"flex items-end gap-1 p-1",children:[Q,d.jsx(V1,{...C,triggers:P,normalizeBullets:!1,onSubmit:G,disabled:r,placeholder:r?"Session ended":s,minHeight:20,maxHeight:192,"aria-label":"Message the agent",className:"min-w-0 flex-1 py-0.5 text-body-sm text-text",onImagePaste:L=>u?.add([L])}),D]}):d.jsxs(d.Fragment,{children:[d.jsx(V1,{...C,triggers:P,normalizeBullets:!1,onSubmit:G,disabled:r,placeholder:r?"Session ended":s,minHeight:28,maxHeight:192,"aria-label":"Message the agent",className:"px-3 pt-2.5 pb-1 text-body-sm text-text",onImagePaste:L=>u?.add([L])}),d.jsxs("div",{className:"flex items-center justify-between gap-2 px-2 pb-2",children:[d.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[Q,h]}),D]})]})]}),B]})}function xb({tone:e,label:t,disabled:n,onClick:r,gutter:s,className:a,children:l}){return d.jsx("button",{type:"button","aria-label":t,title:t,disabled:n,onClick:r,"data-tone":e,"data-gutter":s||void 0,className:ve("term-glyph",a),children:l})}function k4({attachments:e}){const t=Rm()==="terminal";return d.jsx("div",{className:ve("flex gap-2 overflow-x-auto",t?"term-attachments":"border-b border-border px-2 py-2"),children:e.items.map(n=>d.jsx(wue,{item:n,onRetry:()=>e.retry(n.key),onRemove:()=>e.remove(n.key)},n.key))})}function wue({item:e,onRetry:t,onRemove:n}){const r=e.status==="failed",s=Rm()==="terminal",a=s?"":"rounded-md";return d.jsxs("div",{className:"group relative shrink-0",title:r?`${e.name} — ${e.error}`:`${e.name} · ${Li(e.bytes)}`,children:[d.jsx("div",{className:ve("flex size-14 items-center justify-center overflow-hidden bg-surface",a,s?"term-attachment":"border border-border",r&&"border-danger/50"),"data-failed":s&&r?"":void 0,children:e.previewUrl?d.jsx("img",{src:e.previewUrl,alt:e.name,className:"size-full object-cover"}):d.jsxs("div",{className:"flex flex-col items-center gap-0.5 text-fg-3",children:[d.jsx(b2,{className:"size-4"}),d.jsx("span",{className:"max-w-12 truncate text-[9px] font-semibold uppercase",children:Nue(e.name)})]})}),e.status==="uploading"?d.jsx("div",{className:ve("absolute inset-0 flex items-center justify-center bg-black/35",a),children:d.jsx(Tn,{className:"size-4 text-white"})}):null,r?d.jsx("button",{type:"button",onClick:t,"aria-label":`Retry ${e.name}`,className:ve("absolute inset-0 flex items-center justify-center bg-black/45 text-warning",a),children:d.jsx(E2,{className:"size-4"})}):null,d.jsx("button",{type:"button",onClick:n,"aria-label":`Remove ${e.name}`,className:ve("absolute flex size-4 items-center justify-center bg-surface text-fg-3 hover:text-fg-1",s?"term-attachment-remove":"-top-1 -right-1 rounded-full border border-border shadow-(--shadow-xs)"),children:d.jsx(_s,{className:"size-2.5"})})]})}const Nue=e=>{const t=e.lastIndexOf(".");return t>0?e.slice(t+1).toUpperCase():"FILE"},_ue=e=>typeof CSS<"u"&&CSS.supports("color",e)?e:void 0,Aue=e=>e>=90?"bg-danger":e>=70?"bg-warning":"bg-accent";function Rue({usage:e,open:t,onOpenChange:n}){return d.jsx(gs,{open:t,onOpenChange:n,children:d.jsxs(bs,{children:[d.jsx(xs,{title:"Context",description:e?.model}),d.jsx(ys,{children:e?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[d.jsx("span",{className:"text-label text-fg-3",children:"Used"}),d.jsxs("span",{className:"font-mono text-body-sm text-fg-1",children:[Gr(e.totalTokens)," / ",Gr(e.maxTokens)," ·"," ",e.percentage.toFixed(0),"%"]})]}),d.jsx("div",{className:"mt-2 h-2 overflow-hidden rounded-full bg-border",children:d.jsx("div",{className:ve("h-full rounded-full",Aue(e.percentage)),style:{width:`${Math.min(100,Math.max(2,e.percentage))}%`}})}),e.categories.length>0?d.jsxs("div",{className:"mt-5",children:[d.jsx("h3",{className:"text-label font-medium text-fg-3",children:"Breakdown"}),d.jsx("div",{className:"mt-2 flex flex-col gap-3",children:e.categories.map(r=>{const s=r.tokens/Math.max(e.maxTokens,1)*100,a=_ue(r.color);return d.jsxs("div",{children:[d.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[d.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[d.jsx("span",{className:"size-2 shrink-0 rounded-full bg-fg-4",style:a?{backgroundColor:a}:void 0}),d.jsx("span",{className:"truncate text-body-sm text-fg-1",children:r.name})]}),d.jsx("span",{className:"shrink-0 font-mono text-label text-fg-3",children:Gr(r.tokens)})]}),d.jsx("div",{className:"mt-1 h-1 overflow-hidden rounded-full bg-border",children:d.jsx("div",{className:"h-full rounded-full bg-fg-4",style:{width:`${Math.min(100,s)}%`,backgroundColor:a}})})]},r.name)})})]}):null]}):d.jsx("p",{className:"py-6 text-center text-body-sm text-fg-4",children:"No reading yet — the context window is measured after a turn completes."})})]})})}function Mue({client:e,cwd:t,open:n,onOpenChange:r}){const[s,a]=y.useState(t),[l,c]=y.useState([]),[u,h]=y.useState(!1),[m,p]=y.useState(""),[b,x]=y.useState(),[v,N]=y.useState(),[w,S]=y.useState(!1),[C,A]=y.useState(),R=y.useCallback(async j=>{S(!0),A(void 0);try{const z=await e.listHostDir(j);a(z.path),c(z.entries),h(z.truncated??!1)}catch(z){A(z instanceof Error?z.message:"Could not read that directory")}finally{S(!1)}},[e]);y.useEffect(()=>{n&&(N(void 0),p(""),x(void 0),A(void 0),t&&R(t))},[n,t,R]),y.useEffect(()=>{if(!n||!t)return;const j=m.trim();if(!j){x(void 0);return}const z=setTimeout(()=>{e.findHostFiles(t,j,40).then(P=>x(P.matches)).catch(()=>x([]))},150);return()=>clearTimeout(z)},[e,t,m,n]);const M=async j=>{S(!0),A(void 0);try{const z=await e.readHostFile(j);N({path:z.path,bytes:z.bytes,content:z.encoding==="utf8"?z.content:"(binary file — not shown)"})}catch(z){A(z instanceof Error?z.message:"Could not read that file")}finally{S(!1)}},_=s&&t&&s!==t?s.slice(0,s.lastIndexOf("/"))||"/":void 0,I=b??l;return d.jsx(gs,{open:n,onOpenChange:r,children:d.jsxs(bs,{size:"lg",children:[d.jsx(xs,{title:v?v.path.split("/").pop():"Files",description:v?v.path:s,actions:v?d.jsxs(tt,{variant:"ghost",size:"xs",onClick:()=>N(void 0),children:[d.jsx(Cp,{className:"size-3.5"}),"Back"]}):_?d.jsxs(tt,{variant:"ghost",size:"xs",onClick:()=>void R(_),children:[d.jsx(Cp,{className:"size-3.5"}),"Up"]}):null}),d.jsxs(ys,{className:"flex flex-col gap-3",children:[C?d.jsx("div",{className:"rounded-md bg-danger-bg px-3 py-2 text-body-sm text-danger",children:C}):null,v?d.jsxs(d.Fragment,{children:[d.jsx("p",{className:"text-label text-fg-4",children:Li(v.bytes)}),d.jsx(R_,{code:v.content,label:v.path.split("/").pop()})]}):d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"relative",children:[d.jsx(km,{className:"absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-fg-4"}),d.jsx(Zt,{value:m,onChange:j=>p(j.target.value),placeholder:"Search this project…",className:"pl-7",spellCheck:!1})]}),w&&I.length===0?d.jsx("div",{className:"py-6 text-center",children:d.jsx(Tn,{className:"size-4 text-fg-4"})}):I.length===0?d.jsx("p",{className:"py-6 text-center text-body-sm text-fg-4",children:b?"No matching files.":"This directory is empty."}):d.jsx("ul",{className:"flex flex-col",children:b?b.map(j=>d.jsx("li",{children:d.jsxs("button",{type:"button",onClick:()=>void M(j.path),className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-surface-hover",children:[d.jsx(vm,{className:"size-3.5 shrink-0 text-fg-4"}),d.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-label text-fg-1",children:j.relative})]})},j.path)):l.map(j=>d.jsx("li",{children:d.jsxs("button",{type:"button",onClick:()=>j.type==="dir"?void R(j.path):void M(j.path),className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-surface-hover",children:[d.jsx(Iue,{type:j.type}),d.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono text-label text-fg-1",children:[j.name,j.type==="dir"?"/":""]}),j.bytes!==void 0?d.jsx("span",{className:"shrink-0 text-label text-fg-4",children:Li(j.bytes)}):null]})},j.path))}),u&&!b?d.jsx("p",{className:"text-label text-fg-4",children:"More entries than the server will return — use the search box."}):null]})]})]})})}function Iue({type:e}){return e==="dir"?d.jsx(Em,{className:"size-3.5 shrink-0 text-accent"}):e==="symlink"?d.jsx(J6,{className:"size-3.5 shrink-0 text-fg-4"}):d.jsx(vm,{className:"size-3.5 shrink-0 text-fg-4"})}const _I={connected:"success",failed:"danger","needs-auth":"warning",pending:"info",disabled:"neutral"};function Oue({client:e,sessionId:t,open:n,onOpenChange:r,canManageServers:s=!0}){const[a,l]=y.useState(),[c,u]=y.useState(),[h,m]=y.useState(!1),[p,b]=y.useState(),[x,v]=y.useState(),[N,w]=y.useState(),S=y.useCallback(async()=>{if(t){m(!0),u(void 0);try{l(await e.listMcpServers(t))}catch(_){u(_ instanceof Error?_.message:"Could not read MCP status")}finally{m(!1)}}},[e,t]);y.useEffect(()=>{n&&(v(void 0),w(void 0),S())},[n,S]);const C=async(_,I)=>{if(t){b(_),u(void 0);try{l(await e.mcpServerAction(t,_,I))}catch(j){u(j instanceof Error?j.message:`Could not ${I} ${_}`)}finally{b(void 0)}}},A=a?.find(_=>_.name===x),R=A?.tools?.find(_=>_.name===N),M=R?.name??A?.name??"MCP servers";return d.jsx(gs,{open:n,onOpenChange:r,children:d.jsxs(bs,{children:[d.jsx(xs,{title:M,description:R?`${A?.name} tool`:A?A.serverInfo?.name:void 0,actions:x?d.jsxs(tt,{variant:"ghost",size:"xs",onClick:()=>N?w(void 0):v(void 0),children:[d.jsx(Cp,{className:"size-3.5"}),"Back"]}):d.jsxs(tt,{variant:"ghost",size:"xs",onClick:()=>void S(),disabled:h,children:[h?d.jsx(Tn,{className:"size-3 text-current"}):d.jsx(E2,{className:"size-3"}),"Refresh"]})}),d.jsxs(ys,{children:[c?d.jsx("div",{className:"mb-3 rounded-md bg-danger-bg px-3 py-2 text-body-sm text-danger",children:c}):null,R?d.jsx(Due,{tool:R}):A?d.jsx(jue,{server:A,busy:p===A.name,canManage:s,onAct:_=>void C(A.name,_),onSelectTool:w}):c&&!a?null:d.jsx(Lue,{servers:a,loading:h,onSelect:v})]})]})})}function Lue({servers:e,loading:t,onSelect:n}){if(t&&!e)return d.jsx("div",{className:"py-6 text-center",children:d.jsx(Tn,{className:"size-4 text-fg-4"})});if(!e?.length)return d.jsx("p",{className:"py-6 text-center text-body-sm text-fg-4",children:"No MCP servers configured for this session."});const r=[...new Set(e.map(s=>s.scope??"other"))];return d.jsx("div",{className:"flex flex-col gap-4",children:r.map(s=>d.jsxs("div",{children:[d.jsx("h3",{className:"text-label font-medium text-fg-3 capitalize",children:s}),d.jsx("ul",{className:"mt-1 flex flex-col",children:e.filter(a=>(a.scope??"other")===s).map(a=>d.jsx("li",{children:d.jsxs("button",{type:"button",onClick:()=>n(a.name),className:"flex w-full items-center gap-2 rounded-md px-2 py-2 text-left transition-colors hover:bg-surface-hover",children:[d.jsx("span",{className:"min-w-0 flex-1 truncate text-body-sm text-fg-1",children:a.name}),a.tools?.length?d.jsxs("span",{className:"shrink-0 text-label text-fg-4",children:[a.tools.length," tools"]}):null,d.jsx(En,{variant:_I[a.status]??"neutral",dot:!0,className:"shrink-0",children:a.status}),d.jsx(Tc,{className:"size-3.5 shrink-0 text-fg-4"})]})},a.name))})]},s))})}function jue({server:e,busy:t,canManage:n,onAct:r,onSelectTool:s}){const a=e.status==="disabled";return d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsxs("div",{children:[d.jsx(cr,{label:"Status",children:d.jsx(En,{variant:_I[e.status]??"neutral",dot:!0,children:e.status})}),e.transport?d.jsx(cr,{label:"Transport",children:e.transport}):null,e.scope?d.jsx(cr,{label:"Scope",children:e.scope}):null,e.serverInfo?d.jsxs(cr,{label:"Server",children:[e.serverInfo.name," ",e.serverInfo.version]}):null,e.command?d.jsx(cr,{label:"Command",mono:!0,children:[e.command,...e.args??[]].join(" ")}):null,e.url?d.jsx(cr,{label:"URL",mono:!0,children:e.url}):null]}),e.error?d.jsx("div",{className:"rounded-md bg-danger-bg px-3 py-2 text-body-sm break-words text-danger",children:e.error}):null,n?d.jsxs("div",{className:"flex gap-2",children:[d.jsxs(tt,{variant:"outline",size:"sm",disabled:t,onClick:()=>r("reconnect"),children:[t?d.jsx(Tn,{className:"size-3 text-current"}):d.jsx(E2,{className:"size-3"}),"Reconnect"]}),d.jsxs(tt,{variant:"outline",size:"sm",disabled:t,onClick:()=>r(a?"enable":"disable"),children:[a?d.jsx(rV,{className:"size-3"}):d.jsx(tV,{className:"size-3"}),a?"Enable":"Disable"]})]}):null,d.jsxs("div",{children:[d.jsx("h3",{className:"text-label font-medium text-fg-3",children:"Tools"}),e.tools?.length?d.jsx("ul",{className:"mt-1 flex flex-col",children:e.tools.map(l=>d.jsx("li",{children:d.jsxs("button",{type:"button",onClick:()=>s(l.name),className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-surface-hover",children:[d.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-label text-fg-1",children:l.name}),d.jsx(Tc,{className:"size-3.5 shrink-0 text-fg-4"})]})},l.name))}):d.jsx("p",{className:"py-2 text-body-sm text-fg-4",children:e.status==="connected"?"This server exposes no tools.":"Tools are listed once the server connects."})]})]})}function Due({tool:e}){const t=e.annotations;return d.jsxs("div",{className:"flex flex-col gap-3",children:[e.description?d.jsx("p",{className:"text-body-sm whitespace-pre-wrap text-fg-2",children:e.description}):d.jsx("p",{className:"text-body-sm text-fg-4",children:"This tool carries no description."}),t?d.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.readOnly?d.jsx(En,{variant:"success",children:"read-only"}):null,t.destructive?d.jsx(En,{variant:"danger",children:"destructive"}):null,t.openWorld?d.jsx(En,{variant:"warning",children:"open world"}):null]}):null,e.inputSchema!==void 0?d.jsxs("div",{children:[d.jsx("h3",{className:"text-label font-medium text-fg-3",children:"Parameters"}),d.jsx("pre",{className:"mt-1 max-h-64 overflow-auto rounded-md bg-surface px-3 py-2 text-label text-fg-2",children:Pue(e.inputSchema)})]}):d.jsx("p",{className:ve("text-label text-fg-4"),children:"Parameters aren’t available: this engine names and describes each tool but reports no input schema."})]})}function Pue(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}const AI={user:"Personal",repo:"This project",system:"System",admin:"Managed"};function Bue({skills:e,open:t,onOpenChange:n,onUse:r}){const[s,a]=y.useState(),l=e?.find(c=>c.name===s);return d.jsx(gs,{open:t,onOpenChange:c=>{c||a(void 0),n(c)},children:d.jsxs(bs,{children:[d.jsx(xs,{title:l?l.displayName??l.name:"Skills",description:l?l.name!==(l.displayName??l.name)?l.name:void 0:"Capabilities the agent can choose to use. Not commands — the model picks them from their descriptions.",actions:l?d.jsxs(tt,{variant:"ghost",size:"xs",onClick:()=>a(void 0),children:[d.jsx(Cp,{className:"size-3.5"}),"Back"]}):void 0}),d.jsx(ys,{children:l?d.jsx(Hue,{skill:l,onUse:r,onUsed:()=>n(!1)}):d.jsx(zue,{skills:e,onSelect:a})})]})})}function zue({skills:e,onSelect:t}){if(!e)return d.jsx("p",{className:"py-6 text-center text-body-sm text-fg-4",children:"Skills are listed once the session connects — send a message first."});if(e.length===0)return d.jsx("p",{className:"py-6 text-center text-body-sm text-fg-4",children:"This session found no skills."});const n=[...new Set(e.map(r=>r.scope??"other"))];return d.jsx("div",{className:"flex flex-col gap-4",children:n.map(r=>d.jsxs("div",{children:[d.jsx("h3",{className:"text-label font-medium text-fg-3",children:AI[r]??r}),d.jsx("ul",{className:"mt-1 flex flex-col",children:e.filter(s=>(s.scope??"other")===r).map(s=>d.jsx("li",{children:d.jsxs("button",{type:"button",onClick:()=>t(s.name),className:"flex w-full items-start gap-2 rounded-md px-2 py-2 text-left transition-colors hover:bg-surface-hover",children:[d.jsxs("span",{className:"min-w-0 flex-1",children:[d.jsx("span",{className:"block truncate text-body-sm text-fg-1",children:s.displayName??s.name}),s.shortDescription??s.description?d.jsx("span",{className:"block truncate text-label text-fg-4",children:s.shortDescription??s.description}):null]}),s.enabled?null:d.jsx(En,{variant:"neutral",className:"mt-0.5 shrink-0",children:"off"}),d.jsx(Tc,{className:"mt-0.5 size-3.5 shrink-0 text-fg-4"})]})},s.name))})]},r))})}function Hue({skill:e,onUse:t,onUsed:n}){return d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsxs("div",{children:[e.scope?d.jsx(cr,{label:"Scope",children:AI[e.scope]??e.scope}):null,d.jsx(cr,{label:"Status",children:d.jsx(En,{variant:e.enabled?"success":"neutral",dot:!0,children:e.enabled?"enabled":"disabled"})})]}),e.description?d.jsxs("div",{children:[d.jsx("h3",{className:"text-label font-medium text-fg-3",children:"Description"}),d.jsx("p",{className:"mt-1 text-body-sm whitespace-pre-wrap text-fg-2",children:e.description})]}):d.jsx("p",{className:"text-body-sm text-fg-4",children:"This skill carries no description."}),t&&e.enabled?d.jsxs("div",{children:[d.jsx(tt,{variant:"outline",size:"sm",onClick:()=>{t(e),n()},children:"Use this skill"}),d.jsx("p",{className:"mt-1.5 text-label text-fg-4",children:"Writes an opening message into the composer for you to edit — it isn’t sent, and there is no command that runs a skill directly."})]}):null]})}const Wx=e=>e==="default",yb=e=>e.replace(/\[.*\]$/,"");function C4(e){const t=e.toLowerCase().split("-");return t[0]==="claude"&&t.shift(),t[0]??""}function Uue(e,t){if(t===e.value||t===e.resolvedModel)return!0;const n=yb(t);if(e.resolvedModel)return n===yb(e.resolvedModel);const r=C4(n);return r!==""&&r===C4(yb(e.value))}function Fue(e,t){if(t)return e.filter(n=>!Wx(n.value)).find(n=>Uue(n,t))}function RI({models:e,model:t,onModelChange:n,variant:r="toolbar",disabled:s,className:a}){const l=Fue(e,t)??(t?void 0:e.find(c=>Wx(c.value)));return d.jsxs(Di,{items:e.map(c=>({value:c.value,label:c.displayName})),value:l?.value??null,onValueChange:c=>{typeof c!="string"||c===l?.value||n(Wx(c)?void 0:c)},disabled:s,children:[d.jsx(Bi,{"aria-label":"Model",className:ve(r==="toolbar"&&"h-6 max-w-56 border-transparent bg-transparent text-fg-3 hover:bg-surface-hover",a),children:d.jsx("span",{className:ve("truncate",r==="toolbar"&&"font-mono text-label"),children:d.jsx(Pi,{placeholder:t??"model"})})}),d.jsx(zi,{className:"min-w-72",children:e.map(c=>d.jsxs(Qs,{value:c.value,children:[d.jsx(Xs,{children:d.jsx("span",{className:"font-medium",children:c.displayName})}),c.description?d.jsx("span",{className:"text-label text-fg-4",children:c.description}):null]},c.value))})]})}const Rd=[{value:"default",label:"Manual",shortLabel:"Manual",description:"Always ask before making changes",icon:Q6},{value:"acceptEdits",label:"Accept edits",shortLabel:"Edits",description:"Automatically accept all file edits",icon:g2},{value:"plan",label:"Plan",shortLabel:"Plan",description:"Create a plan before making changes",icon:fU},{value:"auto",label:"Auto",shortLabel:"Auto",description:"The agent handles permission decisions",icon:l_},{value:"dontAsk",label:"Don't ask",shortLabel:"Don't ask",description:"Never ask — deny anything not pre-approved",icon:OV},{value:"bypassPermissions",label:"Bypass permissions",shortLabel:"Bypass",description:"Skip every approval — the agent is unsupervised",icon:Jl,dangerous:!0}],$ue=e=>Rd.find(t=>t.value===e);function Vue(e,t){return(e?Rd.filter(r=>e.includes(r.value)):Rd).map(r=>({value:r.value,label:r.label,description:r.value==="bypassPermissions"&&t===!1?"Only available to a session started in this mode":r.description,dangerous:r.dangerous,disabled:r.value==="bypassPermissions"&&t===!1}))}function yv({mode:e,onModeChange:t,modes:n,canBypass:r,variant:s="toolbar",disabled:a,className:l}){const c=e==="bypassPermissions",u=n?Rd.filter(m=>n.includes(m.value)):Rd,h=m=>m.value==="bypassPermissions"&&r===!1;return d.jsxs(Di,{items:u.map(m=>({value:m.value,label:m.label})),value:e??null,onValueChange:m=>{typeof m=="string"&&m!==e&&t(m)},disabled:a,children:[d.jsx(Bi,{"aria-label":"Permission mode",className:ve(s==="toolbar"&&"h-6 max-w-44 border-transparent bg-transparent hover:bg-surface-hover",c?"text-danger":s==="toolbar"?"text-fg-3":void 0,l),children:d.jsx("span",{className:ve("truncate",s==="toolbar"&&"text-label"),children:d.jsx(Pi,{placeholder:"permissions"})})}),d.jsx(zi,{className:"min-w-64",children:u.map(m=>{const p=h(m);return d.jsxs(Qs,{value:m.value,disabled:p,children:[d.jsx(Xs,{children:d.jsxs("span",{className:"flex items-center gap-2",children:[d.jsx(m.icon,{className:ve("size-3.5 shrink-0",m.dangerous?"text-danger":"text-fg-3")}),d.jsx("span",{className:ve("font-medium",m.dangerous&&"text-danger"),children:m.label})]})}),d.jsx("span",{className:ve("pl-5.5 text-label",p?"text-fg-4":m.dangerous?"text-danger/80":"text-fg-4"),children:p?"Only available to a session started in this mode":m.description})]},m.value)})})]})}function que({request:e,onApprove:t,onDeny:n,className:r}){const[s,a]=y.useState(!1),[l,c]=y.useState(!1),[u,h]=y.useState(""),m=x=>{const v=u.trim();n(e.id,v||void 0,x||void 0),h(""),c(!1)},p=Da(e.input),b=oA(e.toolName);return d.jsxs("div",{"data-slot":"permission-prompt",className:ve("rounded-lg border border-warning/40 bg-warning-bg p-3",r),children:[d.jsxs("div",{className:"flex items-start gap-2.5",children:[d.jsx(Q6,{className:"mt-0.5 size-4 shrink-0 text-warning"}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("div",{className:"text-body-sm font-medium text-fg-1",children:e.title??e.displayName??"Permission needed"}),e.description?d.jsx("div",{className:"mt-0.5 text-label text-fg-3",children:e.description}):null,e.decisionReason?d.jsx("div",{className:"mt-0.5 text-label text-fg-4",children:e.decisionReason}):null,d.jsxs("div",{className:"mt-1.5 flex min-w-0 items-center gap-2",children:[d.jsx(b,{className:"size-3 shrink-0 text-fg-3"}),d.jsx("span",{className:"shrink-0 font-mono text-label font-medium text-fg-2",children:e.toolName}),p?d.jsx("span",{className:"min-w-0 truncate font-mono text-label text-fg-4",children:p}):null]}),d.jsxs("button",{type:"button",className:"mt-1 font-mono text-label text-fg-3 underline-offset-2 hover:underline",onClick:()=>a(x=>!x),children:[s?"Hide":"Show"," ",e.toolName," input"]}),s?d.jsx("pre",{className:"mt-1.5 max-h-48 overflow-auto rounded-md bg-code-bg px-2.5 py-1.5 font-mono text-label whitespace-pre-wrap text-fg-2",children:JSON.stringify(e.input,null,2)}):null]}),d.jsxs("div",{className:"flex shrink-0 flex-wrap justify-end gap-1.5",children:[d.jsx(tt,{size:"sm",onClick:()=>t(e.id),children:"Allow"}),d.jsx(tt,{size:"sm",variant:"outline",onClick:()=>c(x=>!x),children:"Deny"}),d.jsx(tt,{size:"sm",variant:"outline",onClick:()=>m(!0),children:"Deny & stop"})]})]}),l?d.jsxs("div",{className:"mt-2.5 flex items-center gap-2 border-t border-warning/30 pt-2.5",children:[d.jsx(Zt,{autoFocus:!0,value:u,onChange:x=>h(x.target.value),onKeyDown:x=>{x.key==="Enter"&&m(!1),x.key==="Escape"&&c(!1)},placeholder:"Reason (optional) — the agent reads this and can try something else",className:"h-7 flex-1"}),d.jsx(tt,{size:"sm",variant:"outline",onClick:()=>c(!1),children:"Cancel"}),d.jsx(tt,{size:"sm",variant:"destructive",onClick:()=>m(!1),children:"Deny"})]}):null]})}function Yue({task:e,items:t,label:n,onBack:r,terminal:s,fontSize:a,lineHeight:l}){const c=e?Km(e,t):!1,u=e?vI(e):!1,h=zd(c),m=t.reduce((S,C)=>S+(C.kind==="tool_call"?1:0),0),p=c?e?.ts:void 0,b=wI(p!==void 0),x=p===void 0?void 0:Sc(b-p),v=e?bI(e):n,N=e?u?"failed":c?`${h} working…`:"done":void 0,w=[m>0?`${m} tool${m===1?"":"s"}`:void 0,x].filter(Boolean).join(" · ");return s?d.jsx(Mc,{fontSize:a,lineHeight:l,className:"shrink-0",children:d.jsx("button",{type:"button",onClick:r,"aria-label":"Back to the session",className:"block w-full cursor-pointer text-left",children:d.jsxs(_t,{glyph:"←",glyphTone:"dim",indent:1,tone:u?"red":"green",children:[v,N?d.jsxs(jr,{tone:u?"red":c?"mark":"dim",children:[" · ",N]}):null,w?d.jsxs(jr,{tone:"faint",children:[" · ",w]}):null]})})}):d.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-3 py-1.5",children:[d.jsxs(tt,{variant:"ghost",size:"sm",onClick:r,className:"h-6 gap-1 px-1.5",children:[d.jsx(oH,{className:"size-3.5"}),"Back"]}),d.jsx("span",{className:ve("min-w-0 flex-1 truncate text-body-sm",u?"text-danger":"text-fg-2"),children:v}),N?d.jsx("span",{className:ve("shrink-0 text-label",u?"text-danger":c?"text-accent":"text-fg-3"),children:N}):null,w?d.jsx("span",{className:"shrink-0 text-label text-fg-4",children:w}):null]})}const w4=[{value:"auto",label:"Auto-answer",description:"pick each question’s recommended option"},{value:"ask",label:"Ask",description:"wait for a watcher or webhook controller to answer"},{value:"deny",label:"Disabled",description:"the agent is told to decide on its own"}];function vv(e){return(Array.isArray(e.questions)?e.questions:[]).flatMap(n=>{const r=n;if(typeof r.question!="string"||!Array.isArray(r.options))return[];const s=r.options.filter(a=>typeof a?.label=="string");return s.length===0?[]:[{question:r.question,header:typeof r.header=="string"?r.header:"",options:s,multiSelect:r.multiSelect===!0}]})}const Bu={labels:[],other:"",otherActive:!1};function N4(e){const t=[...e.labels];return e.otherActive&&e.other.trim()&&t.push(e.other.trim()),t.join(", ")}function Gue({request:e,onAnswer:t,onDismiss:n,className:r}){const s=vv(e.input),[a,l]=y.useState(()=>s.map(()=>Bu)),c=(p,b)=>{l(x=>x.map((v,N)=>N===p?{...v,...b}:v))},u=(p,b,x)=>{const v=a[p]??Bu;x?c(p,{labels:v.labels.includes(b)?v.labels.filter(N=>N!==b):[...v.labels,b]}):c(p,{labels:v.labels[0]===b?[]:[b],otherActive:!1})},h=s.every((p,b)=>N4(a[b]??Bu)!==""),m=()=>{const p={};s.forEach((b,x)=>{p[b.question]=N4(a[x]??Bu)}),t(e.id,{...e.input,answers:p})};return d.jsx("div",{"data-slot":"question-prompt",className:ve("rounded-lg border border-info/40 bg-info-bg p-3",r),children:d.jsxs("div",{className:"flex items-start gap-2.5",children:[d.jsx(t_,{className:"mt-0.5 size-4 shrink-0 text-info"}),d.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-3",children:[s.map((p,b)=>{const x=a[b]??Bu;return d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[p.header?d.jsx(En,{variant:"info",children:p.header}):null,d.jsx("span",{className:"text-body-sm font-medium text-fg-1",children:p.question})]}),d.jsxs("div",{className:"flex flex-col gap-1",children:[p.options.map(v=>{const N=x.labels.includes(v.label);return d.jsxs("button",{type:"button",onClick:()=>u(b,v.label,p.multiSelect===!0),className:ve("rounded-md border px-2.5 py-1.5 text-left transition-colors",N?"border-info bg-bg":"border-border bg-bg/50 hover:border-border-strong hover:bg-bg"),children:[d.jsx("span",{className:"block text-body-sm font-medium text-fg-1",children:v.label}),v.description?d.jsx("span",{className:"block text-label text-fg-4",children:v.description}):null,N&&v.preview?d.jsx("pre",{className:"mt-1.5 max-h-40 overflow-auto rounded-md bg-code-bg px-2.5 py-1.5 font-mono text-label whitespace-pre-wrap text-fg-2",children:v.preview}):null]},v.label)}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("button",{type:"button",onClick:()=>c(b,{otherActive:!x.otherActive}),className:ve("shrink-0 rounded-md border px-2.5 py-1.5 text-body-sm font-medium transition-colors",x.otherActive?"border-info bg-bg text-fg-1":"border-border bg-bg/50 text-fg-3 hover:border-border-strong hover:bg-bg"),children:"Other…"}),x.otherActive?d.jsx(Zt,{autoFocus:!0,value:x.other,onChange:v=>c(b,{other:v.target.value}),placeholder:"Type your own answer",className:"flex-1"}):null]})]})]},b)}),d.jsx("div",{children:d.jsx(tt,{size:"sm",onClick:m,disabled:!h,children:"Answer"})})]}),d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":"Dismiss question",className:"shrink-0",onClick:()=>n(e.id,"Question dismissed by user"),children:d.jsx(_s,{className:"size-3.5"})})]})})}function Xx({dashed:e}){return d.jsx("div",{className:ve("term-rule-row",e&&"term-rule-dashed"),"aria-hidden":!0})}function MI({children:e}){return d.jsx(_t,{tone:"faint",children:e})}function Kue({children:e,className:t}){return d.jsx("div",{className:ve("term-box",t),children:e})}function Wue({title:e,subject:t}){return d.jsxs(d.Fragment,{children:[d.jsx(_t,{tone:"blue",bold:!0,children:e}),t?d.jsx(_t,{tone:"dim",children:t}):null]})}const Xue={check:["[ ]","[✓]"],radio:["( )","(•)"]};function Que(e){return!(e instanceof HTMLElement)||!(e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable)?!1:(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?e.value:e.textContent??"").trim().length>0}function Ev({options:e,focused:t,onFocus:n,onChoose:r,active:s=!0,autoFocus:a=!0,label:l}){const c=y.useRef([]);y.useEffect(()=>{!s||!c.current.some(m=>m!==null&&m===document.activeElement)&&(!a||Que(document.activeElement))||c.current[t]?.focus()},[s,t,a]);const u=h=>{e.length>0&&n((t+h+e.length)%e.length)};return d.jsx("div",{role:"group","aria-label":l,onKeyDown:h=>{if(h.key==="ArrowDown"){u(1),h.preventDefault();return}if(h.key==="ArrowUp"){u(-1),h.preventDefault();return}const m=Number(h.key);Number.isInteger(m)&&m>=1&&m<=Math.min(e.length,9)&&(n(m-1),r(m-1),h.preventDefault())},children:e.map((h,m)=>{const p=m===t;return d.jsxs("div",{children:[d.jsx("button",{ref:b=>{c.current[m]=b},type:"button",tabIndex:p?0:-1,"aria-pressed":h.checked,onFocus:()=>n(m),onClick:()=>r(m),className:"term-press",children:d.jsxs(_t,{columns:5,glyph:`${p?"❯":" "} ${m+1}.`,glyphTone:p?"fg":"faint",tone:h.danger?"red":h.selected?"green":"fg","data-focused":p?"":void 0,children:[h.checked!==void 0?d.jsxs(jr,{tone:h.checked?"green":"faint",children:[Xue[h.marker??"check"][h.checked?1:0]," "]}):null,d.jsx(jr,{bold:p||h.selected,children:h.label})]})}),h.description?d.jsx(_t,{columns:5,tone:"dim",children:h.description}):null,h.detail?d.jsx("div",{className:"term-detail",children:h.detail}):null]},h.key)})})}function II({value:e,onChange:t,onSubmit:n,onCancel:r,placeholder:s}){return d.jsx(_t,{columns:5,glyph:" ›",glyphTone:"dim",children:d.jsx("input",{autoFocus:!0,value:e,placeholder:s,onChange:a=>t(a.target.value),onKeyDown:a=>{a.key==="Enter"&&(a.preventDefault(),n()),a.key==="Escape"&&(a.stopPropagation(),r())},className:"term-input"})})}function Zue({tabs:e,active:t,onSelect:n}){return d.jsxs(_t,{glyph:"←",glyphTone:"faint",children:[e.map((r,s)=>d.jsxs("button",{type:"button",tabIndex:-1,onClick:()=>n(s),className:ve("term-tab",s===t&&"term-tab-active"),children:[r.glyph," ",r.label]},r.key)),d.jsx(jr,{tone:"faint",children:" →"})]})}function Jue({request:e,onApprove:t,onDeny:n}){const[r,s]=y.useState(0),[a,l]=y.useState(!1),[c,u]=y.useState(""),h=N=>{const w=c.trim();n(e.id,w||void 0,N||void 0),u(""),l(!1)},m=NX(e.input),p=Da(e.input),b=e.displayName??e.title??"Permission needed",x=m?.path??(p||void 0),v=[{key:"allow",label:"Yes"},{key:"deny",label:"No, and tell the agent what to do differently",detail:a?d.jsx(II,{value:c,onChange:u,onSubmit:()=>h(!1),onCancel:()=>l(!1),placeholder:"Reason (optional) — the agent reads this and can try something else"}):void 0},{key:"stop",label:"No, and stop the turn",danger:!0}];return d.jsxs("div",{"data-slot":"permission-prompt",onKeyDown:N=>{N.key==="Escape"&&(N.preventDefault(),h(!1))},children:[d.jsx(Xx,{}),d.jsx(Wue,{title:b,subject:x}),d.jsx(Gs,{}),m?d.jsxs(d.Fragment,{children:[d.jsx(uA,{patch:m}),d.jsx(Gs,{}),d.jsx(Xx,{dashed:!0})]}):e.description?d.jsxs(d.Fragment,{children:[d.jsx(_t,{tone:"dim",children:e.description}),d.jsx(Gs,{})]}):null,e.decisionReason?d.jsx(_t,{tone:"faint",children:e.decisionReason}):null,d.jsx(_t,{children:e.title??"Do you want to proceed?"}),d.jsx(Ev,{label:b,options:v,focused:r,onFocus:s,active:!a,onChoose:N=>{N===0?t(e.id):N===1?l(!0):h(!0)}}),d.jsx(Gs,{}),d.jsx(MI,{children:"Enter to select · ↑/↓ to navigate · 1–3 to choose · Esc to cancel"})]})}const zu={labels:[],other:"",otherActive:!1};function vb(e){const t=[...e.labels];return e.otherActive&&e.other.trim()&&t.push(e.other.trim()),t.join(", ")}function ede({request:e,onAnswer:t,onDismiss:n}){const r=vv(e.input),[s,a]=y.useState(()=>r.map(()=>zu)),[l,c]=y.useState(()=>r.map(()=>0)),[u,h]=y.useState(0),[m,p]=y.useState(0),b=u>=r.length,x=s[u]??zu,v=M=>vb(s[M]??zu)!=="",N=r.every((M,_)=>v(_)),w=(M,_)=>a(I=>I.map((j,z)=>z===M?{...j,..._}:j)),S=(M,_,I)=>{a(j=>j.map((z,P)=>P!==M?z:I?{...z,labels:z.labels.includes(_)?z.labels.filter(F=>F!==_):[...z.labels,_]}:{...z,labels:[_],otherActive:!1}))},C=()=>{const M={};r.forEach((_,I)=>{M[_.question]=vb(s[I]??zu)}),t(e.id,{...e.input,answers:M})},A=()=>n(e.id,"Question dismissed by user"),R=M=>h(_=>Math.min(r.length,Math.max(0,_+M)));return d.jsxs("div",{"data-slot":"question-prompt",onKeyDown:M=>{if(M.key==="Escape"){M.preventDefault(),A();return}M.key==="Tab"&&(M.preventDefault(),R(M.shiftKey?-1:1))},children:[d.jsx(Xx,{}),d.jsx(Zue,{tabs:[...r.map((M,_)=>({key:`q${_}`,label:M.header||`Question ${_+1}`,glyph:v(_)?"▣":"▢"})),{key:"submit",label:"Submit",glyph:"✓"}],active:u,onSelect:h}),d.jsx(Gs,{}),b?d.jsx(nde,{questions:r,answers:r.map((M,_)=>vb(s[_]??zu)),complete:N,cursor:m,onCursor:p,onSubmit:C,onCancel:A}):d.jsx(tde,{question:r[u],selection:x,cursor:l[u]??0,onCursor:M=>c(_=>_.map((I,j)=>j===u?M:I)),onToggle:M=>S(u,M,r[u].multiSelect===!0),onOther:M=>w(u,M),onAdvance:()=>R(1),onDismiss:A},u),d.jsx(Gs,{}),d.jsx(MI,{children:"Enter to select · ↑/↓ to navigate · Tab to switch questions · Esc to cancel"})]})}function tde({question:e,selection:t,cursor:n,onCursor:r,onToggle:s,onOther:a,onAdvance:l,onDismiss:c}){const u=e.multiSelect===!0,h=[...e.options.map((m,p)=>{const b=t.labels.includes(m.label);return{key:m.label,label:m.label,description:m.description,checked:u?b:void 0,marker:"check",selected:!u&&b,detail:m.preview&&n===p?d.jsx(Kue,{children:m.preview.split(`
|
|
1189
1189
|
`).map((x,v)=>d.jsx(_t,{columns:0,tone:"dim",children:x||" "},v))}):void 0}}),{key:"__other",label:"Other…",checked:t.otherActive,marker:"check",detail:t.otherActive?d.jsx(II,{value:t.other,onChange:m=>a({other:m}),onSubmit:l,onCancel:()=>a({otherActive:!1,other:""}),placeholder:"Type your own answer"}):void 0},...u?[{key:"__next",label:"Submit"}]:[],{key:"__chat",label:"Chat about this"}];return d.jsxs(d.Fragment,{children:[d.jsx(_t,{bold:!0,tone:"bright",children:e.question}),d.jsx(Gs,{}),d.jsx(Ev,{label:e.question,options:h,focused:n,active:!t.otherActive,onFocus:r,onChoose:m=>{if(m<e.options.length){s(e.options[m].label),u||l();return}if(m===e.options.length){a({otherActive:!t.otherActive});return}if(u&&m===e.options.length+1){l();return}c()}})]})}function nde({questions:e,answers:t,complete:n,cursor:r,onCursor:s,onSubmit:a,onCancel:l}){return d.jsxs(d.Fragment,{children:[d.jsx(_t,{bold:!0,tone:"bright",children:"Review your answers"}),d.jsx(Gs,{}),e.map((c,u)=>d.jsxs("div",{children:[d.jsx(_t,{glyph:"●",glyphTone:"dim",children:c.question}),d.jsx(_t,{indent:1,glyph:"→",glyphTone:"green",children:d.jsx(jr,{tone:t[u]?"green":"faint",children:t[u]||"not answered"})})]},u)),d.jsx(Gs,{}),d.jsx(_t,{children:n?"Ready to submit your answers?":"Some questions are unanswered."}),d.jsx(Ev,{label:"Submit answers",options:[{key:"submit",label:n?"Submit answers":"Submit anyway"},{key:"cancel",label:"Cancel",danger:!0}],focused:r,onFocus:s,onChoose:c=>c===0?a():l()})]})}function rde({state:e,client:t,sessionId:n,open:r,onOpenChange:s}){const a=e.session,l=e.permissionMode?$ue(e.permissionMode):void 0;return d.jsx(gs,{open:r,onOpenChange:s,children:d.jsxs(bs,{children:[d.jsx(xs,{title:"Session info",description:a?.title}),d.jsx(ys,{children:d.jsxs("div",{className:"flex flex-col divide-y divide-border",children:[d.jsxs("div",{className:"pb-2",children:[d.jsx(cr,{label:"Engine",children:e.engine??"claude"}),a?.profile?d.jsx(cr,{label:"Profile",children:a.profile}):null,e.model?d.jsx(cr,{label:"Model",mono:!0,children:e.model}):null,l?d.jsx(cr,{label:"Permission mode",children:l.label}):null,a?.apiKeySource?d.jsx(cr,{label:"Credentials",children:a.apiKeySource}):null]}),d.jsxs("div",{className:"py-2",children:[e.cwd?d.jsx(Eb,{label:"Working directory",value:e.cwd}):null,e.sdkSessionId?d.jsx(Eb,{label:"Engine session id",value:e.sdkSessionId}):null,a?d.jsx(Eb,{label:"Gateway session id",value:a.id}):null]}),d.jsxs("div",{className:"py-2",children:[a?.createdAt?d.jsx(cr,{label:"Started",children:kc(a.createdAt)}):null,a?.numTurns!==void 0?d.jsx(cr,{label:"Turns",children:a.numTurns}):null,d.jsx(cr,{label:"Cost",mono:!0,children:Js(e.totalCostUsd)})]}),e.capabilities.vfs?d.jsx(sde,{client:t,sessionId:n,open:r}):null]})})]})})}function Eb({label:e,value:t}){return d.jsxs("div",{className:"flex items-start justify-between gap-2 py-1.5",children:[d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("div",{className:"text-label text-fg-3",children:e}),d.jsx("div",{className:"mt-0.5 font-mono text-label break-all text-fg-1",children:t})]}),d.jsx(Sd,{value:t,"aria-label":`Copy ${e.toLowerCase()}`})]})}function sde({client:e,sessionId:t,open:n}){const[r,s]=y.useState(),[a,l]=y.useState(!1);return y.useEffect(()=>{if(!n||!t)return;let c=!1;return l(!0),e.listSessionFiles(t).then(u=>{c||s(u)}).catch(()=>{c||s([])}).finally(()=>{c||l(!1)}),()=>{c=!0}},[e,t,n]),d.jsxs("div",{className:"pt-3",children:[d.jsx("h3",{className:"text-label font-medium text-fg-3",children:"Files"}),a?d.jsx("div",{className:"py-3 text-center",children:d.jsx(Tn,{className:"size-4 text-fg-4"})}):r?.length?d.jsx("ul",{className:"mt-1 flex flex-col",children:r.map(c=>d.jsx("li",{children:d.jsxs("a",{href:t?e.sessionFileUrl(t,c.path):void 0,className:"flex items-center gap-2 rounded-md px-1 py-1.5 hover:bg-surface-hover",children:[d.jsx(W6,{className:"size-3.5 shrink-0 text-fg-4"}),d.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-label text-fg-1",children:c.path}),d.jsx("span",{className:"shrink-0 text-label text-fg-4",children:Li(c.bytes)})]})},c.path))}):d.jsx("p",{className:"py-2 text-body-sm text-fg-4",children:"Nothing delivered yet."})]})}function ide(e){return e===void 0?"none":e>=95?"error":e>=80?"warning":"none"}function OI(e){const t=ide(e);return t==="error"?"text-danger":t==="warning"?"text-warning":"text-fg-3"}const ade={starting:{label:"Starting",variant:"info",busy:!0},running:{label:"Running",variant:"info",busy:!0},awaiting_approval:{label:"Needs approval",variant:"warning",busy:!0},idle:{label:"Idle",variant:"success",busy:!1},parked:{label:"Parked",variant:"accent",busy:!1},failed:{label:"Failed",variant:"danger",busy:!1},closed:{label:"Closed",variant:"neutral",busy:!1}};function ode(e=3e4){const[t,n]=y.useState(()=>Date.now());return y.useEffect(()=>{const r=setInterval(()=>n(Date.now()),e);return()=>clearInterval(r)},[e]),t}const LI=e=>OI(e),lde=e=>typeof CSS<"u"&&CSS.supports("color",e)?e:void 0;function cde({usage:e}){return d.jsx(w2,{content:d.jsxs("div",{className:"flex min-w-44 flex-col gap-1 py-0.5",children:[e.categories.map(t=>d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{className:"size-2 shrink-0 rounded-full bg-fg-4",style:lde(t.color)?{backgroundColor:t.color}:void 0}),d.jsx("span",{className:"flex-1",children:t.name}),d.jsx("span",{className:"font-mono text-fg-3",children:Gr(t.tokens)})]},t.name)),d.jsxs("div",{className:"mt-0.5 flex items-center justify-between gap-2 border-t border-border pt-1",children:[d.jsx("span",{children:"Total"}),d.jsxs("span",{className:"font-mono text-fg-3",children:[Gr(e.totalTokens)," / ",Gr(e.maxTokens)," (",e.percentage.toFixed(0),"%)"]})]})]}),children:d.jsxs("span",{className:ve("inline-flex cursor-default items-center gap-1 font-mono text-label",LI(e.percentage)),children:["Ctx ",Gr(e.totalTokens)]})})}function _4({label:e,info:t,now:n}){const r=t.utilization,s=t.resetsAt!==void 0?t.resetsAt*1e3:void 0;return d.jsx(w2,{content:d.jsxs("div",{className:"flex min-w-36 flex-col gap-1 py-0.5",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsxs("span",{children:[e," usage"]}),d.jsx("span",{className:"font-mono text-fg-3",children:r!==void 0?`${r.toFixed(1)}%`:"—"})]}),s!==void 0?d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsx("span",{children:"Resets in"}),d.jsx("span",{className:"font-mono text-fg-3",children:xx(s,n)})]}):null,t.isUsingOverage?d.jsx("div",{className:"text-warning",children:"Using overage"}):null,t.status==="rejected"?d.jsx("div",{className:"text-danger",children:"Limit reached"}):null]}),children:d.jsxs("span",{className:ve("cursor-default font-mono text-label whitespace-nowrap",t.status==="rejected"?"text-danger":LI(r??0)),children:[d.jsx(N2,{value:r??0,className:"mr-1 inline-block align-middle"}),e,r!==void 0?` ${r.toFixed(0)}%`:"",s!==void 0?d.jsxs("span",{className:"text-fg-4",children:[" · ",xx(s,n)]}):null]})})}function Tb({onClick:e,hint:t,children:n}){return e?d.jsx("button",{type:"button",onClick:e,"aria-label":t,className:"rounded-md py-0.5 leading-4 transition-colors outline-none hover:bg-surface-hover focus-visible:bg-surface-hover",children:n}):d.jsx(d.Fragment,{children:n})}function ude({state:e,rateLimits:t,connected:n,connection:r,onOpenStatus:s,onOpenContext:a,onOpenUsage:l,controls:c,actions:u,placement:h="top",className:m}){const p=ade[e.status],b=ode(),x=t??e.rateLimits,v=x?.five_hour,N=x?.seven_day,w=r??(n===!1?"reconnecting":"live"),S=Rm()==="terminal";return d.jsxs("div",{"data-slot":"status-bar",className:ve("flex h-[38px] items-baseline gap-2 border-border bg-surface p-1.5",h==="bottom"?S?void 0:"border-t":"border-b",m),children:[d.jsx(Tb,{onClick:s,hint:"Session info",children:w==="live"?d.jsxs(En,{variant:p.variant,dot:!p.busy,className:"items-baseline",children:[p.busy?d.jsx(Tn,{className:"size-3 self-center text-current"}):null,p.label]}):d.jsxs(En,{variant:w==="offline"?"danger":"warning",dot:!1,className:"items-baseline",children:[w==="offline"?d.jsx(Bq,{className:"size-3 self-center text-current"}):d.jsx(Sm,{className:"size-3 animate-spin self-center text-current"}),w==="offline"?"Offline":"Reconnecting…"]})}),e.capabilities.contextUsage&&e.contextUsage?d.jsx(Tb,{onClick:a,hint:"Context breakdown",children:d.jsx(cde,{usage:e.contextUsage})}):null,v||N?d.jsx(Tb,{onClick:l,hint:"Plan usage",children:d.jsxs("span",{className:"inline-flex items-baseline gap-2",children:[v?d.jsx(_4,{label:"Session",info:v,now:b}):null,N?d.jsx(_4,{label:"Weekly",info:N,now:b}):null]})}):null,c,d.jsx("span",{className:"flex-1"}),d.jsx("span",{className:"font-mono text-label text-fg-3",children:Js(e.totalCostUsd)}),u]})}function dde(e,t,n){const r=new Array(e);return new Proxy(r,{get(s,a,l){if(typeof a=="string"){const c=a.charCodeAt(0);if(c>=48&&c<=57){const u=+a;if(Number.isInteger(u)&&u>=0&&u<e){let h=s[u];if(!h){const m=t[u*2];h=s[u]={index:u,key:n(u),start:m,size:t[u*2+1],end:m+t[u*2+1],lane:0}}return h}}if(a==="length")return e}return Reflect.get(s,a,l)}})}function zl(e,t,n){let r=n.initialDeps??[],s,a=!0;function l(){const c=e();return(c.length!==r.length||c.some((h,m)=>r[m]!==h))&&(r=c,s=t(...c),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(s),a=!1),s}return l.updateDeps=c=>{r=c},l}function A4(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const fde=(e,t)=>Math.abs(e-t)<1.01,hde=(e,t,n)=>{let r;return function(...s){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,s),n)}};let Hu;const Sb=()=>{if(Hu!==void 0)return Hu;if(typeof navigator>"u")return Hu=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Hu=!0;const e=navigator.maxTouchPoints;return Hu=navigator.platform==="MacIntel"&&e!==void 0&&e>0},R4=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},pde=e=>e,jI=e=>{const t=Math.max(e.startIndex-e.overscan,0),r=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,s=new Array(r);for(let a=0;a<r;a++)s[a]=t+a;return s},mde=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const s=l=>{const{width:c,height:u}=l;t({width:Math.round(c),height:Math.round(u)})};if(s(R4(n)),!r.ResizeObserver)return()=>{};const a=new r.ResizeObserver(l=>{const c=()=>{const u=l[0];if(u?.borderBoxSize){const h=u.borderBoxSize[0];if(h){s({width:h.inlineSize,height:h.blockSize});return}}s(R4(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()});return a.observe(n,{box:"border-box"}),()=>{a.unobserve(n)}},$p={passive:!0},gde=typeof window>"u"?!0:"onscrollend"in window,bde=(e,t,n)=>{const r=e.scrollElement;if(!r)return;const s=e.targetWindow;if(!s)return;const a=e.options.useScrollendEvent&&gde;let l=0;const c=a?null:hde(s,()=>t(l,!1),e.options.isScrollingResetDelay),u=p=>()=>{l=n(r),c?.(),t(l,p)},h=u(!0),m=u(!1);return r.addEventListener("scroll",h,$p),a&&r.addEventListener("scrollend",m,$p),()=>{r.removeEventListener("scroll",h),a&&r.removeEventListener("scrollend",m)}},xde=(e,t)=>bde(e,t,n=>{const{horizontal:r,isRtl:s}=e.options;return r?n.scrollLeft*(s&&-1||1):n.scrollTop}),yde=(e,t,n)=>{if(n.options.useCachedMeasurements){const r=n.indexFromElement(e),s=n.options.getItemKey(r);return n.itemSizeCache.get(s)??n.options.estimateSize(r)}if(t?.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}if(!t){const r=n.indexFromElement(e),s=n.options.getItemKey(r),a=n.itemSizeCache.get(s);if(a!==void 0)return a}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},vde=(e,{adjustments:t=0,behavior:n},r)=>{var s,a;(a=(s=r.scrollElement)==null?void 0:s.scrollTo)==null||a.call(s,{[r.options.horizontal?"left":"top"]:e+t,behavior:n})},Ede=vde;class Tde{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var n,r,s;return((s=(r=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:r.now)==null?void 0:s.call(r))??Date.now()},this.observer=(()=>{let n=null;const r=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(s=>{s.forEach(a=>{const l=()=>{const c=a.target,u=this.indexFromElement(c);if(!c.isConnected){this.observer.unobserve(c);for(const[h,m]of this.elementsCache)if(m===c){this.elementsCache.delete(h);break}return}this.shouldMeasureDuringScroll(u)&&this.resizeItem(u,this.options.measureElement(c,a,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()})}));return{disconnect:()=>{var s;(s=r())==null||s.disconnect(),n=null},observe:s=>{var a;return(a=r())==null?void 0:a.observe(s,{box:"border-box"})},unobserve:s=>{var a;return(a=r())==null?void 0:a.unobserve(s)}}})(),this.range=null,this.setOptions=n=>{var r,s;const a={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:pde,rangeExtractor:jI,onChange:()=>{},measureElement:yde,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const b in n){const x=n[b];x!==void 0&&(a[b]=x)}const l=this.options;let c=null,u=null,h=!1;if(l!==void 0&&l.enabled&&a.enabled&&a.anchorTo==="end"&&this.scrollElement!==null){const b=l.count,x=a.count,v=this.getMeasurements(),N=b>0?((r=v[0])==null?void 0:r.key)??l.getItemKey(0):null,w=b>0?((s=v[b-1])==null?void 0:s.key)??l.getItemKey(b-1):null;if(x!==b||b>0&&x>0&&(a.getItemKey(0)!==N||a.getItemKey(x-1)!==w)){h=!0;const A=b>0?this.getVirtualItemForOffset(this.getScrollOffset())??v[0]:null;A&&(c=[A.key,this.getScrollOffset()-A.start]);const R=a.followOnAppend===!0?"auto":a.followOnAppend||null;R&&x>b&&this.isAtEnd(l.scrollEndThreshold)&&(b===0||a.getItemKey(x-1)!==w)&&(u=R)}}this.options=a,h&&(this.pendingMin=0,this.itemSizeCacheVersion++);let m=!1,p=0;if(c&&this.scrollOffset!==null){const[b,x]=c,v=this.getMeasurements(),{count:N,getItemKey:w}=this.options;let S=0;for(;S<N&&w(S)!==b;)S++;if(S<N){const C=v[S];if(C){const A=Math.max(0,C.start+x);A!==this.scrollOffset&&(p=A-this.scrollOffset,this.scrollOffset=A,m=!0)}}}(m||u)&&(this.pendingScrollAnchor=[m?c[0]:null,m?c[1]:0,u,p])},this.notify=n=>{var r,s;(s=(r=this.options).onChange)==null||s.call(r,this,n)},this.maybeNotify=zl(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}if(this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(a=>{this.observer.observe(a)}),this.unsubs.push(this.options.observeElementRect(this,a=>{this.scrollRect=a,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(a,l)=>{if(l&&this._intendedScrollOffset===null&&a===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(a-this._intendedScrollOffset)<1.5&&(a=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const c=this.getScrollOffset();this.scrollDirection=l?c===a?this.scrollDirection:c<a?"forward":"backward":null,this.scrollOffset=a,this.isScrolling=l,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const a=this.scrollElement,l=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},c=()=>{this._iosTouching=!1,!(!Sb()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};a.addEventListener("touchstart",l,$p),a.addEventListener("touchend",c,$p),this.unsubs.push(()=>{a.removeEventListener("touchstart",l),a.removeEventListener("touchend",c),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const s=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,s&&this.scrollElement&&this.options.enabled){const[a,l,c,u]=s;a!==null&&!c&&(Sb()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?u!==0&&(this._iosDeferredAdjustment+=u):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),c&&this.scrollToEnd({behavior:c})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const n=this.getScrollOffset(),r=this.getMaxScrollOffset();if(n<0||n>r)return;if(this._iosDeferredAdjustment<0&&n>=r-1){this._iosDeferredAdjustment=0;return}const s=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(n,{adjustments:this.scrollAdjustments+=s,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=zl(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(n,r,s,a,l,c,u,h)=>(this.prevLanes!==void 0&&this.prevLanes!==c&&(this.lanesChangedFlag=!0),this.prevLanes=c,this.pendingMin=null,{count:n,paddingStart:r,scrollMargin:s,getItemKey:a,enabled:l,lanes:c,laneAssignmentMode:u,gap:h}),{key:!1}),this.getMeasurements=zl(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:n,paddingStart:r,scrollMargin:s,getItemKey:a,enabled:l,lanes:c,laneAssignmentMode:u,gap:h},m)=>{const p=this.itemSizeCache;if(!l)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const S of this.laneAssignments.keys())S>=n&&this.laneAssignments.delete(S);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(S=>{this.itemSizeCache.set(S.key,S.size)}));const b=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1),c===1){const S=n*2;let C=this._flatMeasurements;if(!C||C.length<S){const M=new Float64Array(S);C&&b>0&&M.set(C.subarray(0,b*2)),C=M,this._flatMeasurements=C}let A;if(b===0)A=r+s;else{const M=b-1;A=C[M*2]+C[M*2+1]+h}for(let M=b;M<n;M++){const _=a(M),I=p.get(_),j=typeof I=="number"?I:this.options.estimateSize(M);C[M*2]=A,C[M*2+1]=j,A+=j+h}const R=dde(n,C,a);return this.measurementsCache=R,R}const x=this.measurementsCache.slice(0,b),v=new Array(c).fill(void 0),N=new Float64Array(c);let w=0;for(let S=0;S<b;S++){const C=x[S];C&&(v[C.lane]===void 0&&w++,v[C.lane]=S,N[C.lane]=C.end)}for(let S=b;S<n;S++){const C=a(S),A=this.laneAssignments.get(S);let R,M;const _=u==="estimate"||p.has(C);if(A!==void 0&&this.options.lanes>1){R=A;const P=v[R],F=P!==void 0?x[P]:void 0;M=F?F.end+h:r+s}else if(w===c){let P=0,F=N[0],V=v[0];for(let G=1;G<c;G++){const K=N[G];(K<F||K===F&&v[G]<V)&&(P=G,F=K,V=v[G])}R=P,M=F+h,_&&this.laneAssignments.set(S,R)}else R=S%this.options.lanes,M=r+s,_&&this.laneAssignments.set(S,R);const I=p.get(C),j=typeof I=="number"?I:this.options.estimateSize(S),z=M+j;x[S]={index:S,start:M,size:j,end:z,key:C,lane:R},v[R]===void 0&&w++,v[R]=S,N[R]=z}return this.measurementsCache=x,x},{key:!1,debug:()=>this.options.debug}),this.calculateRange=zl(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,r,s,a)=>n.length===0||r===0?(this.range=null,null):(this.range=kde(n,r,s,a,a===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=zl(()=>{let n=null,r=null;const s=this.calculateRange();return s&&(n=s.startIndex,r=s.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,r]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,r]},(n,r,s,a,l)=>a===null||l===null?[]:n({startIndex:a,endIndex:l,overscan:r,count:s}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const r=this.options.indexAttribute,s=n.getAttribute(r);return s?parseInt(s,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=n=>{var r;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const s=this.scrollState.index??((r=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:r.index);if(s!==void 0&&this.range){const a=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),l=Math.max(0,s-a),c=Math.min(this.options.count-1,s+a);return n>=l&&n<=c}return!0},this.measureElement=n=>{if(!n){this.elementsCache.forEach((l,c)=>{l.isConnected||(this.observer.unobserve(l),this.elementsCache.delete(c))});return}const r=this.indexFromElement(n),s=this.options.getItemKey(r),a=this.elementsCache.get(s);a!==n&&(a&&this.observer.unobserve(a),this.observer.observe(n),this.elementsCache.set(s,n)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(r)&&this.resizeItem(r,this.options.measureElement(n,void 0,this))},this.resizeItem=(n,r)=>{var s,a;if(n<0||n>=this.options.count)return;let l,c,u;const h=this._flatMeasurements;if(this.options.lanes===1&&h!==null)u=this.options.getItemKey(n),c=h[n*2],l=h[n*2+1];else{const b=this.measurementsCache[n];if(!b)return;u=b.key,c=b.start,l=b.size}const m=this.itemSizeCache.get(u)??l,p=r-m;if(p!==0){const b=this.options.anchorTo==="end"&&((s=this.scrollState)==null?void 0:s.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,x=b?this.getTotalSize():0,v=this.getScrollOffset()+this.scrollAdjustments,w=!this.itemSizeCache.has(u)?c<v:c+m<=v&&this.scrollDirection!=="backward",S=((a=this.scrollState)==null?void 0:a.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[n]??{index:n,key:u,start:c,size:l,end:c+l,lane:0},p,this):w);(this.pendingMin===null||n<this.pendingMin)&&(this.pendingMin=n),this.itemSizeCache.set(u,r),this.itemSizeCacheVersion++;let C=!1;b?C=this.applyScrollAdjustment(this.getTotalSize()-x):S&&(C=this.applyScrollAdjustment(p)),this.notify(C)}},this.getVirtualItems=zl(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,r)=>{const s=[];for(let a=0,l=n.length;a<l;a++){const c=n[a],u=r[c];s.push(u)}return s},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const r=this.getMeasurements();if(r.length===0)return;const s=this._flatMeasurements,a=this.options.lanes===1&&s!=null,l=DI(0,r.length-1,a?c=>s[c*2]:c=>A4(r[c]).start,n);return A4(r[l])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const n=this.scrollElement.document.documentElement;return this.options.horizontal?n.scrollWidth-this.scrollElement.innerWidth:n.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(n=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=n,this.getOffsetForAlignment=(n,r,s=0)=>{if(!this.scrollElement)return 0;const a=this.getSize(),l=this.getScrollOffset();r==="auto"&&(r=n>=l+a?"end":"start"),r==="center"?n+=(s-a)/2:r==="end"&&(n-=a);const c=this.getMaxScrollOffset();return Math.max(Math.min(c,n),0)},this.getOffsetForIndex=(n,r="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const s=this.getSize(),a=this.getScrollOffset(),l=this.measurementsCache[n];if(!l)return;if(r==="auto")if(l.end>=a+s-this.options.scrollPaddingEnd)r="end";else if(l.start<=a+this.options.scrollPaddingStart)r="start";else return[a,r];if(r==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),r];const c=r==="end"?l.end+this.options.scrollPaddingEnd:l.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(c,r,l.size),r]},this.scrollToOffset=(n,{align:r="start",behavior:s="auto"}={})=>{this._iosDeferredAdjustment=0;const a=this.getOffsetForAlignment(n,r),l=this.now();this.scrollState={index:null,align:r,behavior:s,startedAt:l,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollToIndex=(n,{align:r="auto",behavior:s="auto"}={})=>{this._iosDeferredAdjustment=0,n=Math.max(0,Math.min(n,this.options.count-1));const a=this.getOffsetForIndex(n,r);if(!a)return;const[l,c]=a,u=this.now();this.scrollState={index:n,align:c,behavior:s,startedAt:u,lastTargetOffset:l,stableFrames:0},this._scrollToOffset(l,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollBy=(n,{behavior:r="auto"}={})=>{const s=this.getScrollOffset()+n,a=this.now();this.scrollState={index:null,align:"start",behavior:r,startedAt:a,lastTargetOffset:s,stableFrames:0},this._scrollToOffset(s,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:n="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:n});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:n})},this.getTotalSize=()=>{var n;const r=this.getMeasurements();let s;if(r.length===0)s=this.options.paddingStart;else if(this.options.lanes===1){const a=r.length-1,l=this._flatMeasurements;l!=null?s=l[a*2]+l[a*2+1]:s=((n=r[a])==null?void 0:n.end)??0}else{const a=Array(this.options.lanes).fill(null);let l=r.length-1;for(;l>=0&&a.some(c=>c===null);){const c=r[l];a[c.lane]===null&&(a[c.lane]=c.end),l--}s=Math.max(...a.filter(c=>c!==null))}return Math.max(s-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const n=[];if(this.itemSizeCache.size===0)return n;const r=this.getMeasurements();for(const s of r)s&&this.itemSizeCache.has(s.key)&&n.push({index:s.index,key:s.key,start:s.start,size:s.size,end:s.end,lane:s.lane});return n},this._scrollToOffset=(n,{adjustments:r,behavior:s})=>{this._intendedScrollOffset=n+(r??0),this.options.scrollToFn(n,{behavior:s,adjustments:r},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(t)}applyScrollAdjustment(t,n){return t===0?!1:Sb()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?(this._iosDeferredAdjustment+=t,!1):(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=t,behavior:n}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const r=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,s=r?r[0]:this.scrollState.lastTargetOffset,a=1,l=s!==this.scrollState.lastTargetOffset;if(!l&&fde(s,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=a){this.getScrollOffset()!==s&&this._scrollToOffset(s,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,l){const c=this.getSize()||600,u=Math.abs(s-this.getScrollOffset()),h=this.scrollState.behavior==="smooth"&&u>c;this.scrollState.lastTargetOffset=s,h||(this.scrollState.behavior="auto"),this._scrollToOffset(s,{adjustments:void 0,behavior:h?"smooth":"auto"})}this.scheduleScrollReconcile()}}const DI=(e,t,n,r)=>{for(;e<=t;){const s=(e+t)/2|0,a=n(s);if(a<r)e=s+1;else if(a>r)t=s-1;else return s}return e>0?e-1:0};function Sde(e,t,n){let r=0;for(;r<=t;){const s=(r+t)/2|0,a=e[s*2];if(a<n)r=s+1;else if(a>n)t=s-1;else return s}return r>0?r-1:0}function kde(e,t,n,r,s){const a=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:a};if(r===1&&s!==null){const h=Sde(s,a,n);let m=h;const p=n+t;for(;m<a&&s[m*2]+s[m*2+1]<p;)m++;return{startIndex:h,endIndex:m}}let c=DI(0,a,h=>e[h].start,n),u=c;if(r===1)for(;u<a&&e[u].end<n+t;)u++;else if(r>1){const h=Array(r).fill(0);for(;u<a&&h.some(p=>p<n+t);){const p=e[u];h[p.lane]=p.end,u++}const m=Array(r).fill(n+t);for(;c>=0&&m.some(p=>p>=n);){const p=e[c];m[p.lane]=p.start,c--}c=Math.max(0,c-c%r),u=Math.min(a,u+(r-1-u%r))}return{startIndex:c,endIndex:u}}const kb=typeof document<"u"?y.useLayoutEffect:y.useEffect;function Cde({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n="transform",...r}){const s=y.useReducer(m=>m+1,0)[1],a=y.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;const l=m=>{const p=a.current;if(!p.enabled||!p.container)return;const b=m.getTotalSize();if(b!==p.lastSize){p.lastSize=b;const x=m.options.horizontal?"width":"height";p.container.style[x]=`${b}px`}},c=m=>{const p=a.current;if(!p.enabled||!p.container)return;l(m);const b=!!m.options.horizontal,x=p.mode==="transform",v=b?"left":"top",N=m.options.scrollMargin,w=m.getVirtualItems();for(const S of w){const C=S.start-N,A=m.elementsCache.get(S.key);A&&p.lastPositions.get(A)!==C&&(p.lastPositions.set(A,C),x?A.style.transform=b?`translate3d(${C}px, 0, 0)`:`translate3d(0, ${C}px, 0)`:A.style[v]=`${C}px`)}},u={...r,onChange:(m,p)=>{var b;const x=a.current;let v=!0;if(x.enabled){c(m);const N=m.range,w=x.prevRange;v=!w||w.isScrolling!==m.isScrolling||w.startIndex!==N?.startIndex||w.endIndex!==N?.endIndex,v&&(x.prevRange=N?{startIndex:N.startIndex,endIndex:N.endIndex,isScrolling:m.isScrolling}:null)}v&&(e&&p?ir.flushSync(s):s()),(b=r.onChange)==null||b.call(r,m,p)}},[h]=y.useState(()=>{const m=new Tde(u);return Object.assign(m,{containerRef:p=>{const b=a.current;if(b.container=p,b.lastSize=null,p&&b.enabled){const x=m.getTotalSize();b.lastSize=x;const v=m.options.horizontal?"width":"height";p.style[v]=`${x}px`}}})});return h.setOptions(u),kb(()=>h._didMount(),[]),kb(()=>(l(h),h._willUpdate())),kb(()=>{c(h)}),h}function wde(e){return Cde({observeElementRect:mde,observeElementOffset:xde,scrollToFn:Ede,...e})}/*!---------------------------------------------------------------------------------------------
|
|
1190
1190
|
* Copyright (c) StackBlitz. All rights reserved.
|
|
1191
1191
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
@@ -1200,4 +1200,4 @@ Please report this to https://github.com/markedjs/marked.`,t){let s="<p>An error
|
|
|
1200
1200
|
`)){const b=FI(p,s);h+=Math.max(1,b.lines)*t.line,m=m&&b.exact}l=Wn(l,{px:Math.max(h,t.line),exact:m});break}case"list":{let h=0,m=!0;for(const p of u.items)for(const b of p.lines){const x=Kl(b,s-p.indent-p.gutter);h+=x.lines*t.line,m=m&&x.exact}l=Wn(l,{px:h,exact:m});break}case"quote":{let h=0,m=!0;for(const[p,b]of u.paras.entries()){p>0&&(h+=t.line);for(const x of b){const v=Kl(x,s-2);h+=v.lines*t.line,m=m&&v.exact}}l=Wn(l,{px:h,exact:m});break}case"table":l=Wn(l,{px:u.rows*t.line,exact:!0});break;case"hr":l=Wn(l,{px:t.line,exact:!0});break}return{px:Math.max(l.px,t.line),exact:l.exact}}function ofe(e,t,n=0){const r=h=>{let m=h.newStart,p=h.oldStart;return h.lines.map(b=>{const x=b.startsWith("+")?"add":b.startsWith("-")?"remove":"context",v=b.slice(1),N=x==="add"?m++:x==="remove"?p++:m;return x==="context"&&(p++,m++),{number:N,text:v}})},s=e.hunks.map(r),a=e.hunks.some(h=>h.newStart>0),l=a?String(Math.max(...s.flat().map(h=>h.number),1)).length:0,c=a?l+3:2;let u={px:0,exact:!0};for(const[h,m]of s.entries()){h>0&&(u=Wn(u,{px:t.line,exact:!0}));for(const p of m)u=Wn(u,Yr(p.text||" ",t,{indentCells:2,gutterCells:c,extraPx:n}))}return e.truncated&&(u=Wn(u,{px:t.line,exact:!0})),u}function lfe(e,t,n){const r=Da(e.input),s=e.backend&&e.backend!=="server"?` · ${e.backend}`:"";let a=Yr(`${e.name}(${r})${s}`,t,{gutterCells:2,extraPx:n});const l=e.result?.images;if(l?.length&&(a=Wn(a,{px:l.length*lI*t.line,exact:!0})),e.patch)return Wn(a,ofe(e.patch,t,n));const c=e.result?.text??"";if(!c)return a;const{shown:u,more:h}=uI(c.trimEnd().split(`
|
|
1201
1201
|
`),e.result?.totalChars);for(const m of u)a=Wn(a,Yr(m||" ",t,{indentCells:3,gutterCells:3,extraPx:n}));return h&&(a=Wn(a,Yr(h,t,{indentCells:3,gutterCells:3,extraPx:n}))),a}const cfe=e=>"parentToolUseId"in e&&e.parentToolUseId!=null?14:0;function VI(e,t){const n=cfe(e);switch(e.kind){case"user":{let r={px:0,exact:!0};if(e.attachments?.length&&(r=Wn(r,Yr(e.attachments.map(s=>s.name).join(", "),t,{extraPx:n}))),e.text)for(const s of e.text.split(`
|
|
1202
1202
|
`))r=Wn(r,Yr(s||" ",t,{extraPx:n}));return r}case"assistant_text":return afe(e.text,t,n);case"thinking":return Yr(e.text,t,{extraPx:n});case"tool_call":return lfe(e,t,n);case"turn_result":{let r=Yr(`${e.isError?e.subtype:"done"} · ${Sc(e.durationMs)} · ${Js(e.totalCostUsd)}`,t,{extraPx:n});for(const s of e.errors??[])r=Wn(r,Yr(s,t,{extraPx:n}));return r}case"notice":return Yr(e.text,t,{extraPx:n});case"file_delivered":{const r=`${e.path} · ${Li(e.bytes)}`+(e.description?` · ${e.description}`:"");return Yr(r,t,{extraPx:n})}default:return{px:0,exact:!1}}}function ufe(e,t){if("task"in e)return Yr(EI(e.task,SI(e)),t);if("run"in e){const n=e.run.some(r=>r.status==="running"||r.status==="pending");return Yr(gI(e.run,n),t)}return VI(e.item,t)}function D4(e,t){let n;for(const r of e.marks)(!n||Math.abs(r.y-t)<Math.abs(n.y-t))&&(n=r);return n?.mark}const P4={user:"l",subagent:"l",turn:"r",turnFailed:"r",toolFailed:"r",error:"r",approval:"f",recap:"f",bookmark:"f"},B4={approval:7,error:6,turnFailed:5,toolFailed:4,user:3,turn:2,bookmark:1,subagent:1,recap:0},dfe={user:"you",subagent:"sub-agent",turn:"response · turn end",turnFailed:"turn failed",toolFailed:"tool failed",error:"error",approval:"pending approval",recap:"catch-up boundary",bookmark:"bookmark"},$h=2;function qI(e,t,n){return t>0?e/Math.max(t,n):0}const YI=e=>`${e.isError?e.subtype:"done"} · ${Sc(e.durationMs)} · ${Js(e.totalCostUsd)}`;function ffe(e){switch(e.kind){case"user":case"assistant_text":case"thinking":case"notice":return e.text;case"tool_call":return`${e.name}(${Da(e.input)})`;case"turn_result":return YI(e);case"file_delivered":return e.path;default:return""}}function hfe(e,t){const{items:n,bookmarks:r,frameParentId:s,recapRow:a,pendingApprovals:l,rowIndexFor:c,offsetOfRow:u,sizeOfRow:h,positionInRow:m,totalSize:p,viewportH:b}=e,x=[],v=new Set;for(const M of n){const _=Ks(M);_!==void 0&&v.add(_)}const N=new Map;n.forEach((M,_)=>{M.kind!=="tool_call"||Ks(M)!==s||N.set(c(_),_)});let w={};const S=()=>{const M=w.response??w.turn;M!==void 0&&x.push({kind:w.failed?"turnFailed":"turn",itemIndex:M,rowIndex:c(M),turnIndex:w.turn}),w={}};n.forEach((M,_)=>{if(M.kind==="tool_call"&&v.has(M.id)&&x.push({kind:"subagent",itemIndex:_,rowIndex:c(_)}),M.kind==="user"&&Ks(M)===s)S(),x.push({kind:"user",itemIndex:_,rowIndex:c(_)});else if(M.kind==="turn_result")w.turn=_,w.failed=M.isError,S();else if(M.kind==="notice"&&M.level==="error")x.push({kind:"error",itemIndex:_,rowIndex:c(_)});else if(M.kind==="tool_call"&&(M.status==="failed"||M.result?.isError===!0)&&N.get(c(_))===_)x.push({kind:"toolFailed",itemIndex:_,rowIndex:c(_)});else if(M.kind==="assistant_text"&&Ks(M)===s){if(s!==void 0){x.push({kind:"turn",itemIndex:_,rowIndex:c(_)});return}w.response=_}}),S();for(const M of r)M>=0&&M<n.length&&x.push({kind:"bookmark",itemIndex:M,rowIndex:c(M)});a&&x.push({kind:"recap",itemIndex:-1,rowIndex:a.rowIndex});const C=qI(t,p,b),A=new Map;for(const M of x){const _=M.itemIndex>=0?m?.(M.itemIndex):void 0,I=h(M.rowIndex),j=_?$h:Math.max($h,Math.round(I*C)),z=Math.min(Math.max(0,t-j),Math.round((u(M.rowIndex)+(_?_.ordinal/_.count*I:0))*C)),P=P4[M.kind],F=A.get(P)??[];F.push({mark:M,y:z,h:j}),A.set(P,F)}const R=[];for(const[M,_]of A){_.sort((j,z)=>j.y-z.y);let I=null;for(const{mark:j,y:z,h:P}of _)I&&z<=I.y+I.h+1?(I.h=Math.max(I.h,z+P-I.y),B4[j.kind]>B4[I.kind]&&(I.kind=j.kind),I.marks.push({mark:j,y:z})):(I={lane:M,kind:j.kind,y:z,h:P,marks:[{mark:j,y:z}]},R.push(I))}return l.length>0&&R.push({lane:P4.approval,kind:"approval",y:Math.max(0,t-$h),h:$h,marks:[]}),R}function pfe(e,t,{items:n,pendingApprovals:r,recapRow:s}){const a=e.marks.length>1?` · ${e.marks.length} marks`:"";let l=null;if(e.kind==="approval"){const c=r[0];l=c?d.jsxs(d.Fragment,{children:[d.jsx("div",{"data-tone":"bright",children:c.title??"Permission required"}),d.jsx("div",{className:"term-scrub-ex","data-tone":"fg",children:`${c.displayName??c.toolName}(${Da(c.input)})`})]}):null}else if(e.kind==="recap"&&!t)l=d.jsxs("div",{"data-tone":"faint",children:["※ ",s?.label]});else if(t){const c=n[t.itemIndex];if(t.kind==="recap")l=d.jsxs("div",{"data-tone":"faint",children:["※ ",s?.label]});else if(t.kind==="turn"||t.kind==="turnFailed"){const u=t.turnIndex===void 0?void 0:n[t.turnIndex];l=d.jsxs(d.Fragment,{children:[c?.kind==="assistant_text"?d.jsxs("div",{className:"term-scrub-ex","data-tone":"fg",children:[d.jsx("span",{"data-tone":"dim",children:"● "}),c.text]}):null,u?.kind==="turn_result"?d.jsxs(d.Fragment,{children:[d.jsx("div",{"data-tone":u.isError?"red":"faint",children:YI(u)}),u.errors?.map((h,m)=>d.jsx("div",{"data-tone":"red",children:h},m))]}):null]})}else if(c){const u=t.kind==="toolFailed"&&c.kind==="tool_call"?c.result?.text.split(`
|
|
1203
|
-
`).find(h=>h.trim()!==""):void 0;l=d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"term-scrub-ex","data-tone":t.kind==="error"||t.kind==="toolFailed"?"red":"fg",children:[t.kind==="user"?d.jsx("span",{"data-tone":"dim",children:"❯ "}):null,ffe(c)]}),u?d.jsx("div",{className:"term-scrub-ex","data-tone":"red",children:u}):null]})}}return d.jsxs(d.Fragment,{children:[d.jsxs("div",{"data-tone":"faint",children:[dfe[t?.kind??e.kind],a]}),l]})}function mfe(e){const{scrollOffset:t,viewportH:n,totalSize:r,onJumpToRow:s,interactive:a,fontSize:l,lineHeight:c}=e,u=Xm(),h=y.useRef(null),m=y.useRef(null),[p,b]=y.useState(0),[x,v]=y.useState(null),N=y.useRef(null);y.useEffect(()=>{const F=h.current;if(!F)return;const V=new ResizeObserver(()=>b(F.clientHeight));return V.observe(F),b(F.clientHeight),()=>V.disconnect()},[]);const[w,S]=y.useState(t);y.useEffect(()=>{const F=u.scrollRef.current;if(!F)return;const V=()=>S(F.scrollTop);return F.addEventListener("scroll",V,{passive:!0}),S(F.scrollTop),()=>F.removeEventListener("scroll",V)},[u.scrollRef]),y.useEffect(()=>{v(null)},[e.items]),y.useEffect(()=>{if(!a)return;const F=h.current;if(!F)return;const V=G=>{const K=u.scrollRef.current;K&&(K.scrollTop+=G.deltaY,G.preventDefault())};return F.addEventListener("wheel",V,{passive:!1}),()=>F.removeEventListener("wheel",V)},[a,u.scrollRef]),y.useLayoutEffect(()=>{const F=m.current;if(!F||!x)return;const V=F.offsetHeight,G=h.current?.clientHeight??0;F.style.top=`${Math.max(4,Math.min(G-V-4,x.y-V/2))}px`},[x]);const C=y.useMemo(()=>p>0?hfe(e,p):[],[e.items,e.bookmarks,e.recapRow,e.pendingApprovals,r,p,n]),A=qI(p,r,n),R=Math.max(2,Math.min(p,Math.round(n*A))),M=Math.max(0,Math.min(p-R,Math.round(w*A))),_=F=>{const V=h.current,G=u.scrollRef.current;if(!V||!G)return;const K=V.getBoundingClientRect(),Y=Math.min(1,Math.max(0,(F-K.top)/K.height));G.scrollTop=Y*G.scrollHeight-G.clientHeight/2},I=F=>F-(h.current?.getBoundingClientRect().top??0),j=(F,V)=>{if(F.kind==="approval"&&F.marks.length===0){u.scrollToBottom();return}const G=D4(F,I(V));G&&s(G.rowIndex)},z=(F,V)=>{const G=I(V),K=D4(F,G);v(Y=>Y&&Y.cluster===F&&Y.mark===K?Y:{cluster:F,mark:K,y:Math.min(Math.max(G,F.y),F.y+F.h)})},P=Math.max(1,r-n);return d.jsx(Mc,{fontSize:l,lineHeight:c,className:"term-scrubber","data-interactive":a||void 0,...a?{role:"scrollbar","aria-orientation":"vertical","aria-label":"Transcript overview","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.min(100,Math.max(0,Math.round(w/P*100)))}:{"aria-hidden":!0},children:d.jsxs("div",{ref:h,className:"term-scrubber-body",...a?{onPointerDown:F=>{u.stopScroll(),N.current={y:F.clientY,moved:!1,target:F.target},F.currentTarget.setPointerCapture(F.pointerId)},onPointerMove:F=>{const V=N.current;V&&(!V.moved&&Math.abs(F.clientY-V.y)<3||(V.moved=!0,v(null),_(F.clientY)))},onPointerUp:F=>{const V=N.current;if(N.current=null,!V||V.moved)return;const G=V.target?.closest?.("[data-ci]"),K=G?Number(G.dataset.ci):Number.NaN;Number.isInteger(K)&&C[K]?j(C[K],F.clientY):_(F.clientY)}}:null,children:[d.jsx("div",{className:"term-scrub-band",style:{top:M,height:R}}),C.map((F,V)=>d.jsx("div",{"data-ci":V,className:"term-scrub-mark","data-lane":F.lane,"data-kind":F.kind,style:{top:F.y,height:F.h},...a?{onPointerEnter:G=>z(F,G.clientY),onPointerMove:G=>{N.current||z(F,G.clientY)},onPointerLeave:()=>v(null)}:null},V)),x?d.jsx("div",{ref:m,className:"term-scrub-peek",style:{top:x.y},children:pfe(x.cluster,x.mark,e)}):null]})})}function z4(e){if(e){if("item"in e)return e.item;if("run"in e)return e.run[0];if("task"in e)return e.task}}function Qx(e,t){const n=z4(e[t-1]),r=z4(e[t]);return!n||!r?!0:fue(n,r)}const H4=new WeakMap;function gfe(e){const t=H4.get(e);if(t)return t;const n=new Map;return e.forEach((r,s)=>{if("task"in r)for(const a of r.childIndices)n.set(a,s)}),H4.set(e,n),n}function U4(e,t){const n=gfe(e).get(t);if(n!==void 0)return n;let r=0,s=e.length-1,a=0;for(;r<=s;){const l=r+s>>1,c=e[l];let u;if("index"in c)u=c.index;else{const h=e[l+1];u=h&&"index"in h?h.index:Number.MAX_SAFE_INTEGER}u<=t?("index"in c&&(a=l),r=l+1):s=l-1}return a}const F4=new WeakMap;function bfe(e){const t=F4.get(e);if(t)return t;const n=new Map;for(const r of e)if("task"in r){const s=r.childIndices.length;r.childIndices.forEach((a,l)=>n.set(a,{ordinal:l,count:s}))}else if("run"in r&&r.run.length>1){const s=r.run.length;r.indices.forEach((a,l)=>n.set(a,{ordinal:l,count:s}))}return F4.set(e,n),n}function xfe(e,t){return bfe(e).get(t)}function yfe(e){const{terminal:t,fontSize:n,lineHeight:r,rowsRef:s}=e,[a,l]=y.useState(null);return y.useEffect(()=>{if(!t)return;const c=s.current;if(!c)return;let u;const h=()=>{const p=Number.parseFloat(getComputedStyle(c).getPropertyValue("--term-line")),b=c.clientWidth,x=Qde(c);!p||!b||!x||l(v=>v&&v.width===b&&v.ch===x&&v.line===p?v:Kde(b,x,p))},m=new ResizeObserver(()=>{clearTimeout(u),u=setTimeout(h,150)});return m.observe(c),h(),()=>{m.disconnect(),clearTimeout(u)}},[t,n,r,s]),a}const $4=4,V4=50;function vfe(e){const{rows:t,terminal:n,stickyPrompt:r,epoch:s,promptRows:a,scrollElement:l,rowsRef:c,virtualizer:u,stick:h,jumpToRecapRef:m,repinRef:p}=e,b=y.useRef(void 0);y.useEffect(()=>()=>clearTimeout(b.current),[]);const x=(v,N="center")=>{if(v<0||v>=t.length||!l)return;if(h.stopScroll(),clearTimeout(b.current),N==="start"){const S=R=>n&&s&&R>0&&Qx(t,R)?s.line:0,C=()=>{const R=u.measurementsCache[v]?.start??0,M=c.current?c.current.getBoundingClientRect().top-l.getBoundingClientRect().top+l.scrollTop:0;let _=R+M+S(v);return n&&r&&s&&!a.includes(v)&&a.some(j=>j<v)&&(_-=s.line),Math.round(_)},A=R=>{const M=C();l.scrollTo({top:M,behavior:"instant"}),!(R>=$4)&&(b.current=setTimeout(()=>{Math.abs(l.scrollTop-C())>1&&A(R+1)},V4))};A(0);return}const w=S=>{const C=l.querySelector(`[data-index="${v}"]`);if(C){C.scrollIntoView({behavior:"instant",block:N});return}S>=$4||(u.scrollToIndex(v,{align:N,behavior:"auto"}),b.current=setTimeout(()=>w(S+1),V4))};w(0)};return y.useEffect(()=>{if(m)return m.current=()=>{x(t.findIndex(v=>v.key==="recap"),"start")},()=>{m.current=null}}),y.useEffect(()=>{if(p)return p.current=()=>{h.scrollToBottom("instant")},()=>{p.current=null}}),x}function GI({item:e,fileUrl:t}){switch(e.kind){case"user":return d.jsx(gue,{item:e});case"assistant_text":return d.jsx(bue,{item:e});case"thinking":return d.jsx(xue,{item:e});case"tool_call":return d.jsx(kI,{item:e});case"turn_result":return d.jsx(Eue,{item:e});case"notice":return d.jsx(Tue,{item:e});case"file_delivered":return d.jsx(Sue,{item:e,href:t?.(e.path)});default:return null}}function KI({text:e,terminal:t}){const[n,r]=y.useState(!1);return t?d.jsx("div",{"data-slot":"brief",children:d.jsx(Gm,{onPress:()=>r(s=>!s),expanded:n,children:d.jsx(_t,{glyph:">",glyphTone:"blue",tone:"dim",children:d.jsx("span",{className:ve("whitespace-pre-wrap",!n&&"term-brief-clip"),style:n?void 0:{WebkitLineClamp:zI},children:e})})})}):d.jsx("div",{"data-slot":"brief",className:"px-4 py-2 text-body-sm whitespace-pre-wrap text-fg-2",children:e})}function Efe({block:e,fileUrl:t,onOpenSubagent:n}){const[r,s]=y.useState(!1),a=xv(r),l=y.useMemo(()=>SI(e),[e]),c=l.some(b=>b.kind==="user")?void 0:xI(e.task),u=Km(e.task,l),h=vI(e.task),m=zd(u),p=d.jsxs("div",{ref:a,className:r?"term-open":void 0,children:[d.jsx(Gm,{onPress:()=>s(b=>!b),expanded:r,children:d.jsx(_t,{glyph:u?m:"●",glyphTone:h?"red":u?"mark":"dim",tone:h?"red":"green",children:EI(e.task,l)})}),r?d.jsxs("div",{className:"term-nested",children:[c?d.jsx(KI,{text:c,terminal:!0}):null,e.children.map((b,x)=>d.jsxs(y.Fragment,{children:[x>0&&hue(e.children[x-1],b)?d.jsx(Gs,{}):null,"run"in b?d.jsx(CI,{items:b.run}):d.jsx(GI,{item:b.item,fileUrl:t})]},b.key))]}):null]});return n===void 0?p:d.jsx(Mm,{actions:d.jsx(SX,{onOpen:()=>n(e.task.id)}),children:p})}function Tfe({item:e}){return d.jsxs("div",{"data-slot":"turn-result",className:"py-1",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("div",{className:"h-px flex-1 bg-border"}),d.jsxs("span",{className:ve("font-mono text-label",e.isError?"text-danger":"text-fg-4"),children:[e.isError?e.subtype:"turn done"," · ",Sc(e.durationMs)," ·"," ",Js(e.totalCostUsd)]}),d.jsx("div",{className:"h-px flex-1 bg-border"})]}),e.errors?.length?d.jsx("ul",{className:"mt-1 flex flex-col gap-0.5 text-center",children:e.errors.map((t,n)=>d.jsx("li",{className:"text-label break-words text-danger",children:t},n))}):null]})}function Sfe({item:e}){return d.jsx("div",{"data-slot":"notice",className:ve("rounded-md border px-3 py-2 text-body-sm",e.level==="error"?"border-transparent bg-danger-bg text-danger":"border-border bg-surface text-fg-3"),children:e.text})}function kfe({item:e,fileUrl:t,attachmentUrl:n,hostImage:r,terminal:s}){if(s)return d.jsx(GI,{item:e,fileUrl:t});switch(e.kind){case"user":return d.jsxs(O4,{from:"user",children:[e.attachments?.length?d.jsx(_fe,{attachments:e.attachments,attachmentUrl:n}):null,e.text?d.jsx(L4,{children:d.jsx(Pde,{text:e.text})}):null]});case"assistant_text":return d.jsx(O4,{from:"assistant",children:d.jsx(L4,{children:d.jsx(BI,{streaming:e.streaming,children:e.text})})});case"thinking":return d.jsx(Bde,{isStreaming:e.id==="streaming-thinking",children:e.text});case"tool_call":return d.jsx(qde,{item:e,hostImage:r});case"turn_result":return d.jsx(Tfe,{item:e});case"notice":return d.jsx(Sfe,{item:e});case"file_delivered":return d.jsx(Dde,{item:e,href:t?.(e.path)});default:return null}}function Cfe({line:e,since:t,terminal:n}){const r=t===void 0?void 0:kc(t),s=r?`${e} · last here ${r}`:e;return n?d.jsx("div",{"data-slot":"recap",children:d.jsxs(_t,{glyph:"※",glyphTone:"faint",tone:"faint",children:["recap: ",s]})}):d.jsxs("div",{"data-slot":"recap",className:"flex items-center gap-2 py-1",children:[d.jsx("div",{className:"h-px flex-1 bg-border"}),d.jsxs("span",{className:"font-mono text-label text-fg-3",children:["※ recap: ",s]}),d.jsx("div",{className:"h-px flex-1 bg-border"})]})}function wfe(e){const t=e==="running"||e==="starting",[n,r]=y.useState(void 0);return y.useEffect(()=>{r(s=>t?s??Date.now():void 0)},[t]),t?n:void 0}function Nfe(e){if(e.status!=="running"&&e.status!=="starting")return!1;const t=e.items.at(-1);return t?t.kind==="assistant_text"&&t.streaming||t.kind==="thinking"&&t.id==="streaming-thinking"?!1:t.kind!=="turn_result"||e.status==="running":!0}function _fe({attachments:e,attachmentUrl:t}){return d.jsx("div",{className:"mb-1 flex flex-wrap justify-start gap-1.5",children:e.map(n=>{const r=t?.(n.id);return n.mediaType.startsWith("image/")&&r?d.jsx("img",{src:r,alt:n.name,className:"size-20 rounded-md border border-border object-cover"},n.id):d.jsx("span",{className:"rounded-full border border-border bg-surface px-2.5 py-1 text-body-xs text-fg-3",children:n.name},n.id)})})}function Afe({active:e,fontSize:t,lineHeight:n,affordances:r,children:s}){return e?d.jsx(Mc,{fontSize:t,lineHeight:n,affordances:r,bleed:"1ch",className:"term-transcript",children:s}):d.jsx(d.Fragment,{children:s})}function Ab(e,t){return e!==void 0&&t<e}function Rfe(e,t){const n="parentToolUseId"in e?e.parentToolUseId:void 0;return n!=null&&n!==t?"border-l-2 border-border pl-3":void 0}function Mfe({top:e,height:t,gapClass:n,scrollRoot:r,index:s,measureRef:a,content:l}){const c=y.useRef(null),u=y.useRef(null);return y.useEffect(()=>{const h=c.current,m=u.current;if(!h||!m||!r)return;const p=new IntersectionObserver(([b])=>{if(!b)return;const x=!b.isIntersecting&&b.boundingClientRect.top<(b.rootBounds?.top??0);h.toggleAttribute("data-stuck",x)},{root:r});return p.observe(m),()=>p.disconnect()},[r]),d.jsxs("div",{"data-sticky-lane":"",className:"absolute inset-x-0",style:{top:e,height:t},children:[d.jsx("div",{"data-sticky-headlane":"","aria-hidden":!0,children:d.jsx("div",{ref:c,"data-sticky-head":"",className:n||void 0,children:l})}),d.jsx("div",{ref:u,"aria-hidden":!0,className:"absolute left-0 w-px",style:{top:n?"var(--term-line)":0,height:1}}),d.jsx("div",{ref:a,"data-index":s,className:n||void 0,children:l})]})}function Ife({rows:e,boundary:t,since:n,terminal:r,replaying:s,stickyPrompt:a,frameParentId:l,onOpenSubagent:c,gap:u,fontSize:h,lineHeight:m,items:p,pendingApprovals:b,scrubber:x,scrubberMarks:v,affordances:N,fileUrl:w,attachmentUrl:S,hostImage:C,jumpToRecapRef:A,repinRef:R,reveal:M}){const _=Xm(),[I,j]=y.useState(null),z=y.useMemo(()=>e.flatMap((B,L)=>"item"in B&&B.item.kind==="user"&&Ks(B.item)===void 0?[L]:[]),[e]),P=y.useRef({enabled:!1,promptRows:[]});P.current={enabled:r&&a,promptRows:z},y.useEffect(()=>{j(_.scrollRef.current)},[_.scrollRef]),y.useEffect(()=>{if(!I)return;let B=I.clientHeight;const L=new ResizeObserver(()=>{const te=I.clientHeight;te!==B&&(B=te,_.state.isAtBottom&&_.scrollToBottom("instant"))});return L.observe(I),()=>L.disconnect()},[I,_]);const F=y.useRef(s);y.useLayoutEffect(()=>{const B=F.current;F.current=s,!(!B||s)&&_.state.isAtBottom&&(_.state.scrollTop=_.state.calculatedTargetScrollTop)},[s,_]);const V=y.useRef(null),G=yfe({terminal:r,fontSize:h,lineHeight:m,rowsRef:V}),K=wde({count:e.length,getScrollElement:()=>(I&&K.scrollElement!==I&&(K.scrollOffset=I.scrollTop),I),estimateSize:B=>{if(r&&G){const L=e[B],te=B>0&&Qx(e,B)?G.line:0;return L&&"text"in L&&L.key==="brief"?Xde(L.text,G)+te:L&&!("line"in L)?Wde(L,G)+te:G.line+te}return(r?36:100)+u.px},overscan:8,getItemKey:B=>e[B].key,rangeExtractor:y.useCallback(B=>{const L=new Set(jI(B)),{enabled:te,promptRows:ne}=P.current;if(te){const de=K.scrollOffset??0;let oe=-1;for(const le of ne)if((K.measurementsCache[le]?.start??1/0)<=de)oe=le;else break;oe>=0&&L.add(oe)}return[...L].sort((de,oe)=>de-oe)},[]),useFlushSync:!0});K.shouldAdjustScrollPositionOnItemSizeChange=(B,L,te)=>{if(_.state.isAtBottom)return!1;const ne=(te.scrollOffset??0)+te.scrollAdjustments;return te.itemSizeCache.has(B.key)?B.end<=ne&&te.scrollDirection!=="backward":B.start<ne},y.useEffect(()=>{if(!r||!G)return;K.measure();const B=V.current;if(B){K.getTotalSize();for(const L of B.querySelectorAll("[data-index]")){const te=Number(L.getAttribute("data-index"));Number.isInteger(te)&&te>=0&&K.resizeItem(te,L.getBoundingClientRect().height)}}},[r,G,K]);const Y=vfe({rows:e,terminal:r,stickyPrompt:a,epoch:G,promptRows:z,scrollElement:I,rowsRef:V,virtualizer:K,stick:_,jumpToRecapRef:A,repinRef:R}),U=M?.nonce,Q=M?.toolUseId;y.useEffect(()=>{if(Q===void 0)return;const B=p.findIndex(L=>L.kind==="tool_call"&&L.id===Q);B<0||Y(U4(e,B),"start")},[U]);const W=cA(N).hover,ue=e.findIndex(B=>B.key==="recap"),D=ue>=0?{rowIndex:ue,label:e[ue].line}:void 0;y.useEffect(()=>{if(!(!r||!x||!W||!I))return I.setAttribute("data-term-scrubber-host",""),()=>I.removeAttribute("data-term-scrubber-host")},[r,x,W,I]);const H=K.measurementsCache;return d.jsxs("div",{ref:V,"data-slot":"transcript-rows",className:"relative w-full",style:{height:K.getTotalSize()},children:[K.getVirtualItems().map(B=>{const L=e[B.index],te=B.index>0&&(!r||Qx(e,B.index))?u.className:void 0,ne="run"in L?d.jsx("div",{className:ve(Ab(t,L.index)&&"opacity-45"),children:d.jsx(CI,{items:L.run})}):"item"in L?d.jsx("div",{className:ve(Ab(t,L.index)&&"opacity-45",Rfe(L.item,l)),children:d.jsx(kfe,{item:L.item,fileUrl:w,attachmentUrl:S,hostImage:C,terminal:r})}):"text"in L&&L.key==="brief"?d.jsx(KI,{text:L.text,terminal:r}):"line"in L?d.jsx(Cfe,{line:L.line,since:n,terminal:r}):d.jsx("div",{className:ve(Ab(t,L.index)&&"opacity-45"),children:d.jsx(Efe,{block:L,fileUrl:w,onOpenSubagent:c})});if(r&&a&&"item"in L&&L.item.kind==="user"&&Ks(L.item)===void 0){const de=z.find(le=>le>B.index),oe=de===void 0?K.getTotalSize():H[de]?.start??B.start;return d.jsx(Mfe,{top:B.start,height:Math.max(oe-B.start,0),gapClass:te,scrollRoot:I,index:B.index,measureRef:K.measureElement,content:ne},L.key)}return d.jsx("div",{ref:K.measureElement,"data-index":B.index,className:ve("absolute inset-x-0 top-0",te),style:{transform:`translateY(${B.start}px)`},children:ne},L.key)}),r&&x&&I?.parentElement?ir.createPortal(d.jsx(mfe,{items:p,pendingApprovals:b,recapRow:D,bookmarks:v??[],frameParentId:l,rowIndexFor:B=>U4(e,B),positionInRow:B=>xfe(e,B),offsetOfRow:B=>K.measurementsCache[B]?.start??0,sizeOfRow:B=>K.measurementsCache[B]?.size??0,totalSize:K.getTotalSize(),scrollOffset:K.scrollOffset??0,viewportH:K.scrollRect?.height??0,onJumpToRow:B=>Y(B,"start"),interactive:W,fontSize:h,lineHeight:m}),I.parentElement):null]})}function Ofe({state:e,fileUrl:t,attachmentUrl:n,canBrowseFiles:r,hostImage:s,variant:a="cards",density:l="comfortable",fontSize:c,lineHeight:u,affordances:h,stickyPrompt:m=!1,scrubber:p,scrubberMarks:b,replaying:x=!1,catchUp:v,jumpToRecapRef:N,repinRef:w,reveal:S,frame:C,onOpenSubagent:A,className:R}){const M=a==="terminal",_=y.useMemo(()=>C?TI(e.items,C.parentToolUseId):e.items,[e.items,C]),I=y.useMemo(()=>C?e.items.find(K=>K.kind==="tool_call"&&K.id===C.parentToolUseId):void 0,[e.items,C]),j=dX[a][l],z=wfe(e.status),P=!C&&v&&v.from>0&&v.from<e.items.length?v.from:void 0,F=y.useMemo(()=>P===void 0?void 0:lX(oX(e,P)),[e,P]),V=y.useMemo(()=>C&&I&&!_.some(K=>K.kind==="user")?xI(I):void 0,[C,I,_]),G=y.useMemo(()=>{const K=(U,Q)=>due(_.slice(U,Q),U,M),Y=V?[{key:"brief",text:V}]:[];return P===void 0||!F?[...Y,...K(0,_.length)]:[...K(0,P),{key:"recap",line:F},...K(P,_.length)]},[_,P,F,M,V]);return d.jsx(iA,{value:a,children:d.jsxs(Ode,{className:ve(x&&"invisible",R),children:[d.jsx(Lde,{className:ve(M&&"gap-0 p-0"),children:d.jsxs(Afe,{active:M,fontSize:c,lineHeight:u,affordances:h,children:[C?I===void 0&&!x?d.jsx("div",{className:ve(M?"term-row text-fg-4":"p-4 text-body-sm text-fg-4"),children:"This sub-agent's work is not in this transcript."}):null:_.length===0&&e.status!=="starting"?d.jsx(zde,{cwd:e.cwd,hasCommands:!!e.commands?.length,hasSkills:!!e.skills?.some(K=>K.enabled),canBrowseFiles:r}):null,C&&I===void 0&&!x?null:d.jsx(Ife,{rows:G,boundary:P,since:v?.since,terminal:M,replaying:x,stickyPrompt:!C&&m,gap:j,fontSize:c,lineHeight:u,items:_,pendingApprovals:e.pendingApprovals,scrubber:p,scrubberMarks:C?void 0:b,affordances:h,fileUrl:t,attachmentUrl:n,hostImage:s,jumpToRecapRef:N,repinRef:w,reveal:C?void 0:S,frameParentId:C?.parentToolUseId,onOpenSubagent:C?void 0:A}),(C?I!==void 0&&Km(I,_):Nfe(e))?M?d.jsxs(d.Fragment,{children:[e.items.length>0?d.jsx("div",{className:"term-blank","aria-hidden":!0}):null,d.jsx(T4,{label:e.status==="starting"?"Starting…":"Working…",startedAt:z,tokens:e.contextUsage?.totalTokens})]}):d.jsx(I4,{label:e.status==="starting"?"Starting session…":void 0,startedAt:z,tokens:e.contextUsage?.totalTokens}):null]})}),d.jsx(jde,{}),x?d.jsx("div",{"data-slot":"transcript-hold","aria-hidden":!0,className:"wd-hold-appear visible pointer-events-none absolute inset-0 overflow-hidden",children:d.jsx("div",{className:ve("mx-auto w-full max-w-[var(--wd-content-max-w,48rem)]",!M&&"px-4 py-4"),children:M?d.jsx(Mc,{fontSize:c,lineHeight:u,affordances:!1,bleed:"1ch",className:"term-transcript",children:d.jsx(T4,{label:"Loading…"})}):d.jsx(I4,{label:"Loading session…"})})}):null]})})}function WI(e=!0){const[t,n]=y.useState(()=>Date.now());return y.useEffect(()=>{if(!e)return;n(Date.now());const r=setInterval(()=>n(Date.now()),6e4);return()=>clearInterval(r)},[e]),t}const Lfe=e=>e>=90?"bg-danger":e>=70?"bg-warning":"bg-accent";function XI({windows:e,now:t,className:n}){const r=WI(t===void 0),s=t??r;return d.jsx("div",{className:ve("flex flex-col gap-5",n),children:e.map(a=>d.jsx(jfe,{window:a,now:s},a.key))})}function jfe({window:e,now:t}){const{key:n,info:r,updatedAt:s,inferredReset:a}=e,l=r.utilization??0,c=r.resetsAt!==void 0?r.resetsAt*1e3:void 0,u=hX(n),h=c!==void 0?(c-t)/1e3:void 0,m=u!==void 0&&h!==void 0&&h>0&&h<u?(u-h)/u:void 0;return d.jsxs("div",{children:[d.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[d.jsx("span",{className:"truncate text-body-sm text-fg-1",children:fX(n)}),d.jsxs("span",{className:ve("shrink-0 font-mono text-body-sm font-medium",r.status==="rejected"?"text-danger":"text-fg-1"),children:[l.toFixed(0),"% used"]})]}),d.jsxs("div",{className:"relative mt-2 h-2 rounded-full bg-border",children:[d.jsx("div",{className:ve("h-full rounded-full",Lfe(l)),style:{width:`${Math.min(100,Math.max(2,l))}%`}}),m!==void 0?d.jsx("span",{"aria-hidden":!0,title:"Spent evenly, usage would be here by now",className:"absolute -top-1 h-4 w-0.5 -translate-x-1/2 rounded-full bg-fg-1",style:{left:`${Math.min(100,Math.max(0,m*100))}%`}}):null]}),d.jsxs("div",{className:"mt-1.5 flex items-center gap-3 text-label text-fg-4",children:[c!==void 0?d.jsxs("span",{className:"inline-flex items-center gap-1",children:[d.jsx(mV,{className:"size-3"})," Resets in ",xx(c,t)]}):null,r.isUsingOverage?d.jsx("span",{className:"text-warning",children:"overage"}):null,r.status==="rejected"?d.jsx("span",{className:"text-danger",children:"limit reached"}):null,a?d.jsx("span",{children:"window reset · nothing reported since"}):null,s&&!a?d.jsx("span",{children:aA(s,t)}):null]})]})}function Dfe({rateLimits:e,subscriptionType:t,engine:n,totalCostUsd:r,updatedAt:s,open:a,onOpenChange:l}){const c=WI(a);return d.jsx(gs,{open:a,onOpenChange:l,children:d.jsxs(bs,{children:[d.jsx(xs,{title:"Usage",description:n==="claude"?"Claude Code":n,actions:t?d.jsx(En,{variant:"accent",className:"mt-0.5 shrink-0 capitalize",children:t}):null}),d.jsxs(ys,{children:[e.length===0?d.jsx("p",{className:"py-6 text-center text-body-sm text-fg-4",children:n==="claude"?"This session reports no plan windows — API-key sessions have none, and a subscription session reports them once a turn has run.":`Plan windows are a claude.ai subscription thing; this session runs on the ${n} engine.`}):d.jsx(XI,{windows:e,now:c}),d.jsxs("div",{className:"mt-5 flex items-baseline justify-between gap-4 border-t border-border pt-3",children:[d.jsx("span",{className:"text-label text-fg-3",children:"This session has cost"}),d.jsx("span",{className:"font-mono text-body-sm text-fg-1",children:Js(r)})]}),s?d.jsxs("p",{className:"mt-2 text-label text-fg-4",children:["Updated ",aA(s,c)]}):null]})]})})}function Pfe({terminal:e,metrics:t,affordances:n,children:r}){return e?d.jsx(Mc,{fontSize:t?.fontSize,lineHeight:t?.lineHeight,affordances:n,bleed:"1ch",className:"term-transcript",children:r}):d.jsx("div",{className:"mx-auto flex w-full max-w-[var(--wd-content-max-w,48rem)] flex-col gap-2",children:r})}const Bfe=["button","a","input","textarea","select","summary","img",'[contenteditable="true"]','[role="button"]','[role="menuitem"]','[role="checkbox"]','[role="radio"]','[role="tab"]'].join(",");function zfe({client:e,sessionId:t,header:n,panelSurface:r="internal",statusSurface:s="internal",statusPlacement:a="top",onOpenPanel:l,onVitals:c,transcriptVariant:u="cards",transcriptDensity:h="comfortable",transcriptFont:m="sans",affordances:p,terminalMetrics:b,scrubber:x=!1,scrubberMarks:v,reveal:N,openSubagent:w,stickyPrompt:S=!1,controlsSurface:C="internal",onControls:A,focusComposerOnClick:R=!1,unseen:M,readOnly:_=!1,toolHost:I,cacheTranscript:j,className:z}){const P=r==="external",F=s==="external",V=C==="status"&&!F,G=C==="external"||V,[K,Y]=y.useState(void 0),[U,Q]=y.useState(),[W,ue]=y.useState(void 0),[D,H]=y.useState(void 0),{state:B,connection:L,replaying:te,protocolMismatch:ne,models:de,effectiveModel:oe,handle:le,send:ge,approve:Pe,deny:Le,interrupt:Se,setModel:Oe,setPermissionMode:He,reconnectNow:We,loadFullResult:Ge}=IW(e,t,{onProtocolError:Y,cacheTranscript:j});y.useEffect(()=>Y(void 0),[t]),y.useEffect(()=>{ue(void 0),H(void 0)},[t]);const De=w?.nonce,we=w?.toolUseId;y.useEffect(()=>{we!==void 0&&ue(we)},[De]);const Te=N?.nonce;y.useEffect(()=>{Te!==void 0&&ue(void 0)},[Te]);const Ie=y.useCallback(()=>{ue(qe=>{qe!==void 0&&H({toolUseId:qe,nonce:Date.now()})})},[]);y.useEffect(()=>{if(W===void 0)return;const qe=cn=>{cn.key!=="Escape"||cn.defaultPrevented||Ie()};return window.addEventListener("keydown",qe),()=>window.removeEventListener("keydown",qe)},[W,Ie]);const[Be,ee]=y.useState(!1);y.useEffect(()=>{ee(!1)},[t]);const[me]=y.useState(M),se=Be?void 0:me,ie=se?Math.max(0,B.items.length-se.itemCount):0,Z=y.useCallback(qe=>{P?l?.(qe):Q(qe)},[P,l]);y.useEffect(()=>{const qe=()=>{document.visibilityState==="visible"&&We()};return document.addEventListener("visibilitychange",qe),()=>document.removeEventListener("visibilitychange",qe)},[We]),aX(le,I===!1?{enabled:!1}:I);const q=u==="terminal",ce=y.useMemo(()=>W===void 0?[]:TI(B.items,W),[B.items,W]),Ce=y.useMemo(()=>W===void 0?void 0:B.items.find(qe=>qe.kind==="tool_call"&&qe.id===W),[B.items,W]),Re=y.useMemo(()=>{const qe=B.session?.subagents?.find(cn=>cn.toolUseId===W);return qe?fx(qe):"Sub-agent"},[B.session,W]),Ue=B.capabilities,{usage:at}=JW(e,B.session?.profile,{enabled:Ue.rateLimits}),Qe=y.useMemo(()=>aW({rateLimits:B.rateLimits,updatedAt:B.rateLimitsUpdatedAt},at),[B.rateLimits,B.rateLimitsUpdatedAt,at]),ct=y.useMemo(()=>Object.keys(Qe).length>0?oW(Qe):void 0,[Qe]),dt=y.useMemo(()=>{const qe=Object.values(Qe).map(cn=>cn.updatedAt);return qe.length>0?Math.max(...qe):void 0},[Qe]),Ye=y.useRef(c);Ye.current=c;const St=oe??B.model,Mt=y.useMemo(()=>Vue(Ue.permissionModes,B.session?.canBypassPermissions),[Ue.permissionModes,B.session?.canBypassPermissions]);y.useEffect(()=>{Ye.current?.({status:B.status,connection:L,engine:B.engine,capabilities:B.capabilities,model:St,models:de,permissionMode:B.permissionMode,permissionModes:Mt,cwd:B.cwd,contextUsage:B.contextUsage,rateLimits:ct,itemCount:B.items.length})},[B.status,L,B.engine,B.capabilities,St,de,B.permissionMode,Mt,B.cwd,B.contextUsage,ct,B.items.length]);const ot=y.useRef(A);ot.current=A;const Tt=y.useRef({setModel:Oe,setPermissionMode:He,interrupt:Se});Tt.current={setModel:Oe,setPermissionMode:He,interrupt:Se};const Gt=y.useRef({setModel:qe=>Tt.current.setModel(qe),setPermissionMode:qe=>Tt.current.setPermissionMode(qe),interrupt:()=>Tt.current.interrupt(),focusComposer:()=>xt.current?.focus()});y.useEffect(()=>{const qe=ot.current;return qe?.(Gt.current),()=>qe?.(void 0)},[t]);const Vt=B.status==="running"||B.status==="awaiting_approval",qt=B.status==="failed"||B.status==="closed",Xe=DW(e,t,{capabilities:Ue,engine:B.engine}),gt=tA(e,B.cwd),Ut=y.useMemo(()=>Q_(Qe),[Qe]),Kt=Hfe(e,t,B.producedFiles),Un=sue(e,t),xt=y.useRef(null),Jt=y.useRef(null),Jn=y.useRef(null),fn=y.useMemo(()=>{if(B.commands)return B.commands.some(qe=>qe.name==="model")?B.commands:[{name:"model",description:"Switch the model for this session",argumentHint:"<model>"},...B.commands]},[B.commands]),Sn=(qe,cn)=>{if(cn.length===0){const es=/^\/model\s+(\S+)$/.exec(qe);if(es){Oe(es[1]);return}if(Ue.mcpStatus&&qe.trim()==="/mcp"){Z("mcp");return}}ee(!0),Jn.current?.(),ge(qe,cn)},ft=d.jsxs(MY,{children:[d.jsx(IY,{render:d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":"Session actions",children:d.jsx(FU,{className:"size-4"})})}),d.jsxs(OY,{children:[Ue.contextUsage?d.jsxs(jl,{onClick:()=>Z("context"),children:[d.jsx(XH,{className:"size-3.5 text-fg-3"})," Context"]}):null,Ue.rateLimits?d.jsxs(jl,{onClick:()=>Z("usage"),children:[d.jsx(X6,{className:"size-3.5 text-fg-3"})," Usage"]}):null,d.jsxs(jl,{onClick:()=>Z("info"),children:[d.jsx(zF,{className:"size-3.5 text-fg-3"})," Session info"]}),Ue.mcpStatus?d.jsxs(jl,{onClick:()=>Z("mcp"),children:[d.jsx(Tm,{className:"size-3.5 text-fg-3"})," MCP servers"]}):null,Ue.skillsList?d.jsxs(jl,{onClick:()=>Z("skills"),children:[d.jsx(jd,{className:"size-3.5 text-fg-3"})," Skills"]}):null,gt.available?d.jsxs(jl,{onClick:()=>Z("files"),children:[d.jsx(lF,{className:"size-3.5 text-fg-3"})," Project files"]}):null]})]}),kt=P?null:ft,hn=typeof n=="function",An=d.jsxs(d.Fragment,{children:[de.length?d.jsx(RI,{models:de,model:oe,onModelChange:Oe,disabled:qt,className:V?"h-5":void 0}):null,B.permissionMode?d.jsx(yv,{mode:B.permissionMode,onModeChange:He,modes:Ue.permissionModes,canBypass:B.session?.canBypassPermissions,disabled:qt,className:V?"h-5":void 0}):null]}),kn=F?null:d.jsx(ude,{state:B,rateLimits:ct,connection:L,placement:a,controls:V&&!_?An:void 0,onOpenStatus:P&&!l?void 0:()=>Z("info"),onOpenContext:P&&!l?void 0:()=>Z("context"),onOpenUsage:P&&!l?void 0:()=>Z("usage"),actions:hn?void 0:kt}),Wt=qe=>{!R||_||qe.target?.closest(Bfe)||window.getSelection()?.isCollapsed!==!1&&xt.current?.focus()};return d.jsx(iA,{value:u,children:d.jsx(uX,{value:h,children:d.jsx(Zce,{value:Ge,children:d.jsx(eue,{value:Un,children:d.jsxs("div",{"data-slot":"session-panel","data-agent-font":m,onClick:Wt,className:ve("flex h-full min-h-0 flex-col overflow-hidden bg-bg",z),children:[hn?n({actions:kt}):n,a==="top"?kn:null,ne!==void 0?d.jsxs(q4,{level:"warning",children:["Server speaks protocol v",ne,", this build renders v",Z_,". Some events may not render."]}):null,K?d.jsx(q4,{level:"error",onDismiss:()=>Y(void 0),children:K}):null,W!==void 0?d.jsx(Yue,{task:Ce,items:ce,label:Re,onBack:Ie,terminal:q,fontSize:b?.fontSize,lineHeight:b?.lineHeight}):null,d.jsx(Ofe,{state:B,fileUrl:t?qe=>e.sessionFileUrl(t,qe):void 0,attachmentUrl:t?qe=>e.attachmentUrl(t,qe):void 0,canBrowseFiles:gt.available,hostImage:Kt,variant:u,density:h,fontSize:b?.fontSize,lineHeight:b?.lineHeight,affordances:p,stickyPrompt:S,scrubber:x,scrubberMarks:v,replaying:te,catchUp:se&&ie>0?{from:se.itemCount,since:se.since}:void 0,reveal:D??N,frame:W===void 0?void 0:{parentToolUseId:W},onOpenSubagent:ue,jumpToRecapRef:Jt,repinRef:Jn},W??"session"),se&&ie>0&&!te&&W===void 0?d.jsx("div",{className:"px-3 pb-1",children:d.jsxs("div",{"data-slot":"catch-up",className:"mx-auto flex w-full max-w-[var(--wd-content-max-w,48rem)] items-center gap-2 text-label text-fg-3",children:[d.jsx("span",{"aria-hidden":!0,className:ve("select-none",q?"text-fg-3":"text-accent"),children:"※"}),d.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[ie," new ",ie===1?"row":"rows",se.since!==void 0?" since you were last here":""]}),d.jsx("button",{type:"button",onClick:()=>Jt.current?.(),className:"shrink-0 underline-offset-2 hover:text-fg-1 hover:underline",children:"jump"}),d.jsx("button",{type:"button",onClick:()=>ee(!0),className:"shrink-0 underline-offset-2 hover:text-fg-1 hover:underline",children:"dismiss"})]})}):null,!_&&Ue.interactiveApprovals&&B.pendingApprovals.length>0?d.jsx("div",{className:ve(q?"pb-2":"px-3 pb-2"),children:d.jsx(Pfe,{terminal:q,metrics:b,affordances:p,children:B.pendingApprovals.map(qe=>{const cn=qe.toolName==="AskUserQuestion"&&vv(qe.input).length>0;return q?cn?d.jsx(ede,{request:qe,onAnswer:Pe,onDismiss:es=>Le(es,"Question dismissed by user")},qe.id):d.jsx(Jue,{request:qe,onApprove:Pe,onDeny:Le},qe.id):cn?d.jsx(Gue,{request:qe,onAnswer:Pe,onDismiss:es=>Le(es,"Question dismissed by user")},qe.id):d.jsx(que,{request:qe,onApprove:Pe,onDeny:Le},qe.id)})})}):null,_||W!==void 0?null:d.jsx(Cue,{ref:xt,onSend:Sn,onInterrupt:Se,busy:Vt,disabled:qt||!t,commands:Ue.slashCommands?fn:void 0,skills:Ue.skillsList?B.skills:void 0,attachments:Xe,onSearchFiles:gt.available?(qe,cn)=>gt.search(qe,{...cn,limit:8}):void 0,layout:G?"inline":"stacked",toolbar:G?void 0:An,fontSize:b?.fontSize,lineHeight:b?.lineHeight,affordances:p}),a==="bottom"?kn:null,P?null:d.jsxs(d.Fragment,{children:[d.jsx(rde,{state:B,client:e,sessionId:t,open:U==="info",onOpenChange:qe=>Q(qe?"info":void 0)}),d.jsx(Rue,{usage:B.contextUsage,open:U==="context",onOpenChange:qe=>Q(qe?"context":void 0)}),d.jsx(Dfe,{rateLimits:Ut,subscriptionType:B.subscriptionType,engine:B.engine??"claude",totalCostUsd:B.totalCostUsd,updatedAt:dt,open:U==="usage",onOpenChange:qe=>Q(qe?"usage":void 0)}),d.jsx(Oue,{client:e,sessionId:t,canManageServers:Ue.mcpServerActions,open:U==="mcp",onOpenChange:qe=>Q(qe?"mcp":void 0)}),d.jsx(Bue,{skills:B.skills,open:U==="skills",onOpenChange:qe=>Q(qe?"skills":void 0),onUse:qe=>xt.current?.insertText(NI(qe))}),d.jsx(Mue,{client:e,cwd:B.cwd,open:U==="files",onOpenChange:qe=>Q(qe?"files":void 0)})]})]})})})})})}function Hfe(e,t,n){const r=y.useRef(new Map),s=y.useRef([]);return y.useEffect(()=>()=>{for(const a of s.current)URL.revokeObjectURL(a);s.current=[]},[]),y.useCallback(a=>{const l=n?.[a],c=l?`produced:${l.fileId}`:`fs:${a}`,u=r.current.get(c);if(u)return u;const h=l&&t?e.readProducedFile(t,l.fileId).then(m=>{if(m.size===0)return;const p=URL.createObjectURL(m);return s.current.push(p),p}).catch(()=>{}):e.readHostFile(a).then(m=>{if(m.encoding!=="base64")return;const p=a.slice(a.lastIndexOf(".")+1).toLowerCase(),b=Ufe[p];return b?`data:${b};base64,${m.content}`:void 0}).catch(()=>{});return r.current.set(c,h),h},[e,t,n])}const Ufe={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp"};function q4({level:e,onDismiss:t,children:n}){return d.jsx("div",{className:"px-3 pt-2",children:d.jsxs("div",{role:"alert",className:ve("mx-auto flex w-full max-w-[var(--wd-content-max-w,48rem)] items-start gap-2 rounded-md border px-3 py-2 text-body-sm",e==="error"?"border-danger/40 bg-danger-bg text-danger":"border-warning/40 bg-warning-bg text-warning"),children:[d.jsx(Jl,{className:"mt-0.5 size-3.5 shrink-0"}),d.jsx("span",{className:"min-w-0 flex-1 break-words",children:n}),t?d.jsx("button",{type:"button",onClick:t,"aria-label":"Dismiss",className:"shrink-0 opacity-70 transition-opacity hover:opacity-100",children:d.jsx(_s,{className:"size-3.5"})}):null]})})}function Ffe({usage:e,size:t=11,className:n}){return e===void 0?null:d.jsx("span",{title:`Context ${e.percentage.toFixed(0)}% · ${Gr(e.totalTokens)} / ${Gr(e.maxTokens)}`,className:ve("shrink-0 leading-none",OI(e.percentage),n),children:d.jsx(N2,{value:e.percentage,size:t,strokeWidth:2})})}const $fe={claude:{title:"Claude",d:"M4.709 15.955l4.72-2.647.08-.23-.08-.128H9.2l-.79-.048-2.698-.073-2.339-.097-2.266-.122-.571-.121L0 11.784l.055-.352.48-.321.686.06 1.52.103 2.278.158 1.652.097 2.449.255h.389l.055-.157-.134-.098-.103-.097-2.358-1.596-2.552-1.688-1.336-.972-.724-.491-.364-.462-.158-1.008.656-.722.881.06.225.061.893.686 1.908 1.476 2.491 1.833.365.304.145-.103.019-.073-.164-.274-1.355-2.446-1.446-2.49-.644-1.032-.17-.619a2.97 2.97 0 01-.104-.729L6.283.134 6.696 0l.996.134.42.364.62 1.414 1.002 2.229 1.555 3.03.456.898.243.832.091.255h.158V9.01l.128-1.706.237-2.095.23-2.695.08-.76.376-.91.747-.492.584.28.48.685-.067.444-.286 1.851-.559 2.903-.364 1.942h.212l.243-.242.985-1.306 1.652-2.064.73-.82.85-.904.547-.431h1.033l.76 1.129-.34 1.166-1.064 1.347-.881 1.142-1.264 1.7-.79 1.36.073.11.188-.02 2.856-.606 1.543-.28 1.841-.315.833.388.091.395-.328.807-1.969.486-2.309.462-3.439.813-.042.03.049.061 1.549.146.662.036h1.622l3.02.225.79.522.474.638-.079.485-1.215.62-1.64-.389-3.829-.91-1.312-.329h-.182v.11l1.093 1.068 2.006 1.81 2.509 2.33.127.578-.322.455-.34-.049-2.205-1.657-.851-.747-1.926-1.62h-.128v.17l.444.649 2.345 3.521.122 1.08-.17.353-.608.213-.668-.122-1.374-1.925-1.415-2.167-1.143-1.943-.14.08-.674 7.254-.316.37-.729.28-.607-.461-.322-.747.322-1.476.389-1.924.315-1.53.286-1.9.17-.632-.012-.042-.14.018-1.434 1.967-2.18 2.945-1.726 1.845-.414.164-.717-.37.067-.662.401-.589 2.388-3.036 1.44-1.882.93-1.086-.006-.158h-.055L4.132 18.56l-1.13.146-.487-.456.061-.746.231-.243 1.908-1.312-.006.006z"},codex:{title:"OpenAI",d:"M9.205 8.658v-2.26c0-.19.072-.333.238-.428l4.543-2.616c.619-.357 1.356-.523 2.117-.523 2.854 0 4.662 2.212 4.662 4.566 0 .167 0 .357-.024.547l-4.71-2.759a.797.797 0 00-.856 0l-5.97 3.473zm10.609 8.8V12.06c0-.333-.143-.57-.429-.737l-5.97-3.473 1.95-1.118a.433.433 0 01.476 0l4.543 2.617c1.309.76 2.189 2.378 2.189 3.948 0 1.808-1.07 3.473-2.76 4.163zM7.802 12.703l-1.95-1.142c-.167-.095-.239-.238-.239-.428V5.899c0-2.545 1.95-4.472 4.591-4.472 1 0 1.927.333 2.712.928L8.23 5.067c-.285.166-.428.404-.428.737v6.898zM12 15.128l-2.795-1.57v-3.33L12 8.658l2.795 1.57v3.33L12 15.128zm1.796 7.23c-1 0-1.927-.332-2.712-.927l4.686-2.712c.285-.166.428-.404.428-.737v-6.898l1.974 1.142c.167.095.238.238.238.428v5.233c0 2.545-1.974 4.472-4.614 4.472zm-5.637-5.303l-4.544-2.617c-1.308-.761-2.188-2.378-2.188-3.948A4.482 4.482 0 014.21 6.327v5.423c0 .333.143.571.428.738l5.947 3.449-1.95 1.118a.432.432 0 01-.476 0zm-.262 3.9c-2.688 0-4.662-2.021-4.662-4.519 0-.19.024-.38.047-.57l4.686 2.71c.286.167.571.167.856 0l5.97-3.448v2.26c0 .19-.07.333-.237.428l-4.543 2.616c-.619.357-1.356.523-2.117.523zm5.899 2.83a5.947 5.947 0 005.827-4.756C22.287 18.339 24 15.84 24 13.296c0-1.665-.713-3.282-1.998-4.448.119-.5.19-.999.19-1.498 0-3.401-2.759-5.947-5.946-5.947-.642 0-1.26.095-1.88.31A5.962 5.962 0 0010.205 0a5.947 5.947 0 00-5.827 4.757C1.713 5.447 0 7.945 0 10.49c0 1.666.713 3.283 1.998 4.448-.119.5-.19 1-.19 1.499 0 3.401 2.759 5.946 5.946 5.946.642 0 1.26-.095 1.88-.309a5.96 5.96 0 004.162 1.713z"},gemini:{title:"Gemini",d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z"},deepseek:{title:"DeepSeek",d:"M23.748 4.482c-.254-.124-.364.113-.512.234-.051.039-.094.09-.137.136-.372.397-.806.657-1.373.626-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.352-.156-.708-.311-.955-.65-.172-.241-.219-.51-.305-.774-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434 1.202-.422 1.84.027 1.436.633 2.58 1.838 3.393.137.093.172.187.129.323-.082.28-.18.552-.266.833-.055.179-.137.217-.329.14a5.526 5.526 0 01-1.736-1.18c-.857-.828-1.631-1.742-2.597-2.458a11.365 11.365 0 00-.689-.471c-.985-.957.13-1.743.388-1.836.27-.098.093-.432-.779-.428-.872.004-1.67.295-2.687.684a3.055 3.055 0 01-.465.137 9.597 9.597 0 00-2.883-.102c-1.885.21-3.39 1.102-4.497 2.623C.082 8.606-.231 10.684.152 12.85c.403 2.284 1.569 4.175 3.36 5.653 1.858 1.533 3.997 2.284 6.438 2.14 1.482-.085 3.133-.284 4.994-1.86.47.234.962.327 1.78.397.63.059 1.236-.03 1.705-.128.735-.156.684-.837.419-.961-2.155-1.004-1.682-.595-2.113-.926 1.096-1.296 2.746-2.642 3.392-7.003.05-.347.007-.565 0-.845-.004-.17.035-.237.23-.256a4.173 4.173 0 001.545-.475c1.396-.763 1.96-2.015 2.093-3.517.02-.23-.004-.467-.247-.588zM11.581 18c-2.089-1.642-3.102-2.183-3.52-2.16-.392.024-.321.471-.235.763.09.288.207.486.371.739.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.167-1.361-.802-2.5-1.86-3.301-3.307-.774-1.393-1.224-2.887-1.298-4.482-.02-.386.093-.522.477-.592a4.696 4.696 0 011.529-.039c2.132.312 3.946 1.265 5.468 2.774.868.86 1.525 1.887 2.202 2.891.72 1.066 1.494 2.082 2.48 2.914.348.292.625.514.891.677-.802.09-2.14.11-3.054-.614zm1-6.44a.306.306 0 01.415-.287.302.302 0 01.2.288.306.306 0 01-.31.307.303.303 0 01-.304-.308zm3.11 1.596c-.2.081-.399.151-.59.16a1.245 1.245 0 01-.798-.254c-.274-.23-.47-.358-.552-.758a1.73 1.73 0 01.016-.588c.07-.327-.008-.537-.239-.727-.187-.156-.426-.199-.688-.199a.559.559 0 01-.254-.078c-.11-.054-.2-.19-.114-.358.028-.054.16-.186.192-.21.356-.202.767-.136 1.146.016.352.144.618.408 1.001.782.391.451.462.576.685.914.176.265.336.537.445.848.067.195-.019.354-.25.452z"},moonshot:{title:"Moonshot",d:"M1.052 16.916l9.539 2.552a21.007 21.007 0 00.06 2.033l5.956 1.593a11.997 11.997 0 01-5.586.865l-.18-.016-.044-.004-.084-.009-.094-.01a11.605 11.605 0 01-.157-.02l-.107-.014-.11-.016a11.962 11.962 0 01-.32-.051l-.042-.008-.075-.013-.107-.02-.07-.015-.093-.019-.075-.016-.095-.02-.097-.023-.094-.022-.068-.017-.088-.022-.09-.024-.095-.025-.082-.023-.109-.03-.062-.02-.084-.025-.093-.028-.105-.034-.058-.019-.08-.026-.09-.031-.066-.024a6.293 6.293 0 01-.044-.015l-.068-.025-.101-.037-.057-.022-.08-.03-.087-.035-.088-.035-.079-.032-.095-.04-.063-.028-.063-.027a5.655 5.655 0 01-.041-.018l-.066-.03-.103-.047-.052-.024-.096-.046-.062-.03-.084-.04-.086-.044-.093-.047-.052-.027-.103-.055-.057-.03-.058-.032a6.49 6.49 0 01-.046-.026l-.094-.053-.06-.034-.051-.03-.072-.041-.082-.05-.093-.056-.052-.032-.084-.053-.061-.039-.079-.05-.07-.047-.053-.035a7.785 7.785 0 01-.054-.036l-.044-.03-.044-.03a6.066 6.066 0 01-.04-.028l-.057-.04-.076-.054-.069-.05-.074-.054-.056-.042-.076-.057-.076-.059-.086-.067-.045-.035-.064-.052-.074-.06-.089-.073-.046-.039-.046-.039a7.516 7.516 0 01-.043-.037l-.045-.04-.061-.053-.07-.062-.068-.06-.062-.058-.067-.062-.053-.05-.088-.084a13.28 13.28 0 01-.099-.097l-.029-.028-.041-.042-.069-.07-.05-.051-.05-.053a6.457 6.457 0 01-.168-.179l-.08-.088-.062-.07-.071-.08-.042-.049-.053-.062-.058-.068-.046-.056a7.175 7.175 0 01-.027-.033l-.045-.055-.066-.082-.041-.052-.05-.064-.02-.025a11.99 11.99 0 01-1.44-2.402zm-1.02-5.794l11.353 3.037a20.468 20.468 0 00-.469 2.011l10.817 2.894a12.076 12.076 0 01-1.845 2.005L.657 15.923l-.016-.046-.035-.104a11.965 11.965 0 01-.05-.153l-.007-.023a11.896 11.896 0 01-.207-.741l-.03-.126-.018-.08-.021-.097-.018-.081-.018-.09-.017-.084-.018-.094c-.026-.141-.05-.283-.071-.426l-.017-.118-.011-.083-.013-.102a12.01 12.01 0 01-.019-.161l-.005-.047a12.12 12.12 0 01-.034-2.145zm1.593-5.15l11.948 3.196c-.368.605-.705 1.231-1.01 1.875l11.295 3.022c-.142.82-.368 1.612-.668 2.365l-11.55-3.09L.124 10.26l.015-.1.008-.049.01-.067.015-.087.018-.098c.026-.148.056-.295.088-.442l.028-.124.02-.085.024-.097c.022-.09.045-.18.07-.268l.028-.102.023-.083.03-.1.025-.082.03-.096.026-.082.031-.095a11.896 11.896 0 011.01-2.232zm4.442-4.4L17.352 4.59a20.77 20.77 0 00-1.688 1.721l7.823 2.093c.267.852.442 1.744.513 2.665L2.106 5.213l.045-.065.027-.04.04-.055.046-.065.055-.076.054-.072.064-.086.05-.065.057-.073.055-.07.06-.074.055-.069.065-.077.054-.066.066-.077.053-.06.072-.082.053-.06.067-.074.054-.058.073-.078.058-.06.063-.067.168-.17.1-.098.059-.056.076-.071a12.084 12.084 0 012.272-1.677zM12.017 0h.097l.082.001.069.001.054.002.068.002.046.001.076.003.047.002.06.003.054.002.087.005.105.007.144.011.088.007.044.004.077.008.082.008.047.005.102.012.05.006.108.014.081.01.042.006.065.01.207.032.07.012.065.011.14.026.092.018.11.022.046.01.075.016.041.01L14.7.3l.042.01.065.015.049.012.071.017.096.024.112.03.113.03.113.032.05.015.07.02.078.024.073.023.05.016.05.016.076.025.099.033.102.036.048.017.064.023.093.034.11.041.116.045.1.04.047.02.06.024.041.018.063.026.04.018.057.025.11.048.1.046.074.035.075.036.06.028.092.046.091.045.102.052.053.028.049.026.046.024.06.033.041.022.052.029.088.05.106.06.087.051.057.034.053.032.096.059.088.055.098.062.036.024.064.041.084.056.04.027.062.042.062.043.023.017c.054.037.108.075.161.114l.083.06.065.048.056.043.086.065.082.064.04.03.05.041.086.069.079.065.085.071c.712.6 1.353 1.283 1.909 2.031L7.222.994l.062-.027.065-.028.081-.034.086-.035c.113-.045.227-.09.341-.131l.096-.035.093-.033.084-.03.096-.031c.087-.03.176-.058.264-.085l.091-.027.086-.025.102-.03.085-.023.1-.026L9.04.37l.09-.023.091-.022.095-.022.09-.02.098-.021.091-.02.095-.018.092-.018.1-.018.091-.016.098-.017.092-.014.097-.015.092-.013.102-.013.091-.012.105-.012.09-.01.105-.01c.093-.01.186-.018.28-.024l.106-.008.09-.005.11-.006.093-.004.1-.004.097-.002.099-.002.197-.002z"}};function Sv(e,t){if(e==="claude")return"claude";if(e==="codex")return"codex";const n=t?.toLowerCase()??"";if(n){if(n.includes("gemini"))return"gemini";if(n.includes("deepseek"))return"deepseek";if(n.includes("moonshot")||n.includes("kimi"))return"moonshot";if(n.includes("claude"))return"claude";if(n.startsWith("gpt")||n.startsWith("o1")||n.startsWith("o3")||n.includes("openai"))return"codex"}}const Vfe={claude:"text-vendor-claude",codex:"text-vendor-openai"},qfe={claude:"text-vendor-claude"};function Yfe(e,t){return Vfe[Sv(e,t)??""]??"text-fg-3"}function Gfe(e,t){return qfe[Sv(e,t)??""]??"text-fg-3"}function kv({engine:e,model:t,className:n}){const r=$fe[Sv(e,t)??""];return r?d.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",role:"img","aria-label":r.title,className:ve("size-3 shrink-0 text-fg-3",n),children:[d.jsx("title",{children:r.title}),d.jsx("path",{d:r.d})]}):d.jsx("span",{"aria-hidden":!0,title:e,className:ve("shrink-0 text-fg-3",n),children:"·"})}const Kfe={anchor:rH,atom:mH,beaker:bH,bike:EH,binary:SH,blocks:CH,bot:NH,box:AH,brain:Y6,briefcase:IH,brush:LH,bug:DH,"building-2":BH,cable:HH,camera:VH,car:YH,cat:KH,"circuit-board":uU,cloud:gU,code:g2,coffee:xU,cog:EU,compass:SU,container:CU,cpu:AU,"credit-card":MU,database:OU,diamond:jU,dog:PU,feather:VU,film:ZU,flame:eF,"flask-conical":nF,folder:Em,"gamepad-2":hF,gauge:X6,gem:gF,ghost:xF,gift:vF,"git-branch":TF,globe:ax,"graduation-cap":CF,hammer:NF,hexagon:RF,house:LF,image:Z6,key:UF,landmark:$F,laptop:qF,layers:wp,leaf:KF,library:XF,lightbulb:ZF,lock:i$,mail:o$,map:c$,"message-circle":f$,mic:g$,monitor:x$,moon:x2,mountain:E$,music:S$,network:C$,newspaper:N$,notebook:A$,orbit:M$,package:O$,palette:j$,"pen-tool":U$,phone:G$,"piggy-bank":W$,plane:Q$,plug:Tm,puzzle:n_,radar:aV,radio:lV,receipt:uV,rocket:hV,ruler:xV,satellite:vV,scale:kV,scissors:wV,server:s_,shield:jV,ship:PV,"shopping-cart":zV,signal:UV,smartphone:$V,sparkles:jd,sprout:YV,square:i_,star:rq,sun:a_,table:aq,tag:lq,target:uq,telescope:fq,terminal:Np,"test-tube":mq,"tree-pine":xq,trophy:Eq,truck:Sq,umbrella:Cq,users:_q,wallet:Rq,wand:Iq,waves:Lq,webhook:Dq,wifi:Hq,wrench:o_,zap:l_};function QI({icon:e,src:t,name:n,className:r}){if(!e)return null;if(e.type==="image")return t?d.jsx("img",{src:t,alt:"","aria-hidden":!0,title:n,className:ve("inline-block size-3 shrink-0 object-contain",r)}):null;const s=Kfe[e.name]??Em;return d.jsx(s,{className:ve("inline-block size-3 shrink-0",r)})}function Wfe(e,t){return(e.subagents??[]).map(n=>({key:n.toolUseId,label:fx(n),noun:"agent",kind:GK(n)?"agent":"task",state:Xfe(n.status),detail:n.toolCount>0?String(n.toolCount):void 0,title:`${fx(n)} · ${n.toolCount} tool${n.toolCount===1?"":"s"}`,onSelect:()=>t(n.toolUseId)}))}function Xfe(e){switch(e){case"running":return"running";case"failed":return"failed";default:return"done"}}function Qfe(e){return e.filter(t=>t.state==="running").length}function Zfe({expanded:e,running:t,total:n,noun:r,onToggle:s}){const a=t>0&&t<n?`${t}/${n}`:String(n),l=t>0&&t<n?`${t} of ${n} ${r}s running`:`${n} ${r}${n===1?"":"s"}`,c=e?m2:Tc;return d.jsxs("button",{type:"button","aria-expanded":e,"aria-label":`${e?"Hide":"Show"} ${l}`,title:`${e?"Hide":"Show"} ${l}`,onClick:u=>{u.stopPropagation(),s()},className:ve("flex shrink-0 items-center gap-0.5 rounded px-0.5 outline-none","hover:bg-surface-hover hover:text-fg-2",t>0?"text-info":"text-fg-4"),children:[d.jsx(c,{className:"size-3"}),d.jsx("span",{className:"tabular-nums",children:a})]})}function Jfe({step:e,onSelect:t}){const n=e.kind==="agent",r=e.state==="failed"?"text-danger":n?"text-success":"text-fg-4",s=d.jsxs(d.Fragment,{children:[d.jsx(ehe,{state:e.state,kind:e.kind}),d.jsx("span",{className:"min-w-0 flex-1 truncate",children:e.label}),e.detail?d.jsx("span",{className:"shrink-0 tabular-nums text-fg-4",children:e.detail}):null,n?d.jsx(cH,{className:"size-3 shrink-0 opacity-60"}):null]}),a="flex w-full items-center gap-2 border-t border-black/25 py-1 pl-3 pr-2 text-left text-label outline-none";return n?d.jsx("button",{type:"button",title:e.title,onClick:l=>{l.stopPropagation(),t()},className:ve(a,"hover:bg-surface-hover",r),children:s}):d.jsx("div",{title:e.title,onClick:l=>l.stopPropagation(),className:ve(a,r),children:s})}function ehe({state:e,kind:t}){if(t==="task"&&e!=="running"&&e!=="failed")return d.jsx(zU,{className:"size-3 shrink-0"});switch(e){case"running":return d.jsx(Tn,{className:"size-3 shrink-0"});case"failed":return d.jsx(G6,{className:"size-3 shrink-0"});case"pending":return d.jsx(K6,{className:"size-3 shrink-0"});default:return d.jsx(p2,{className:"size-3 shrink-0"})}}function ZI(e){return ve("px-2 py-1.5 hover:bg-row-hover",e?"mr-1 ml-0 rounded-r-md border-l-4 border-l-accent":"mx-1 rounded-md")}function the({rows:e,config:t,onConfigChange:n,scope:r,activeId:s,onSelect:a,onDelete:l,onRename:c,onSelectSubagent:u,emptyState:h,showControls:m=!0,projectIcons:p,className:b}){const x=y.useMemo(()=>W_(e,t,r),[e,t,r]),v=y.useMemo(()=>rW(x,t),[x,t]),N=sW(t,r,x.length,e.length),w=y.useMemo(()=>KK(e),[e]),S=y.useMemo(()=>WK(e),[e]),C=y.useMemo(()=>{const R=new Map;for(const M of e)R.set(M.hostId,M.hostName);return[...R].map(([M,_])=>({id:M,name:_}))},[e]),A=R=>n({...t,...R});return d.jsxs("div",{"data-slot":"session-browser",className:ve("flex flex-col gap-3",b),children:[d.jsxs("div",{className:ve("flex flex-col gap-1.5 px-2",!m&&"hidden"),children:[d.jsxs("div",{className:"relative",children:[d.jsx(km,{className:"pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-fg-4"}),d.jsx(Zt,{value:t.search,onChange:R=>A({search:R.target.value}),placeholder:"Search sessions","aria-label":"Search sessions",className:"pl-8"})]}),d.jsx(Hl,{label:"State",children:d.jsx(Vh,{label:"State",value:t.states,options:q_.map(R=>({value:R,label:Y_[R]})),onChange:R=>A({states:R})})}),w.length>1?d.jsx(Hl,{label:"Engine",children:d.jsx(Vh,{label:"Engine",value:t.adapters,options:w.map(R=>({value:R,label:R})),onChange:R=>A({adapters:R})})}):null,C.length>1?d.jsx(Hl,{label:"Gateway",children:d.jsx(Vh,{label:"Gateway",value:t.gateways,options:C.map(R=>({value:R.id,label:R.name})),onChange:R=>A({gateways:R})})}):null,S.length>1?d.jsx(Hl,{label:"Project",children:d.jsx(Vh,{label:"Project",value:t.projects??[],options:S.map(R=>({value:R.key,label:R.label})),onChange:R=>A({projects:R})})}):null,d.jsx(Hl,{label:"Group",children:d.jsx(G4,{label:"Group",value:t.groupBy,options:[{value:"none",label:"No grouping"},{value:"state",label:"By state"},{value:"adapter",label:"By engine"},...S.length>1?[{value:"project",label:"By project"}]:[],...C.length>1?[{value:"gateway",label:"By gateway"}]:[]],onChange:R=>A({groupBy:R})})}),d.jsx(Hl,{label:"Sort",children:d.jsx(G4,{label:"Sort",value:t.sortBy,options:[{value:"recent",label:"Recent"},{value:"name",label:"Name"},{value:"state",label:"State"},...S.length>1?[{value:"project",label:"Project"}]:[],...C.length>1?[{value:"gateway",label:"Gateway"}]:[]],onChange:R=>A({sortBy:R})})})]}),N?d.jsxs("div",{className:"flex items-center gap-2 px-3 text-label text-fg-4",children:[d.jsxs("span",{children:[N.shown," of ",N.total,N.causes.length?` · ${N.causes.join(" · ")}`:null]}),d.jsx("button",{type:"button",className:"text-fg-3 underline underline-offset-2 hover:text-fg-1",onClick:()=>n(EC(t)),children:"Show all"})]}):null,e.length===0?h??d.jsx(Wr,{icon:d.jsx(wp,{}),title:"No sessions yet"}):x.length===0?iW(t)?d.jsx(Wr,{icon:d.jsx(r_,{}),title:"No matches",description:"No session matches the current search and filters.",action:"Clear filters",onAction:()=>n(EC(t))}):d.jsx(Wr,{icon:d.jsx(wp,{}),title:"Nothing here",description:"No session to show."}):d.jsx("div",{className:"flex flex-col gap-4",children:v.map(R=>d.jsxs("div",{className:"flex flex-col gap-1",children:[t.groupBy!=="none"&&R.label?d.jsxs("div",{className:"flex items-center gap-2 px-3 text-label font-medium text-fg-4",children:[t.groupBy==="project"?d.jsx(QI,{icon:R.rows[0]?.info.project?.icon,src:JI(R.rows[0],p),name:R.label}):null,d.jsx("span",{className:"uppercase tracking-wide",children:R.label}),d.jsx("span",{className:"text-fg-4/70",children:R.rows.length})]}):null,R.rows.map(M=>d.jsx(nhe,{row:M,active:M.info.id===s,showGateway:C.length>1&&t.groupBy!=="gateway",showProject:t.groupBy!=="project",projectIcons:p,onSelect:a,onDelete:l,onRename:c,onSelectSubagent:u},`${M.hostId}:${M.info.id}`))]},R.key))})]})}function JI(e,t){const n=e?.info.project?.icon;return n?.type==="image"?t?.[n.hash]:void 0}function nhe({row:e,active:t,showGateway:n,showProject:r=!0,projectIcons:s,onSelect:a,onDelete:l,onRename:c,onSelectSubagent:u}){const{info:h}=e,[m,p]=y.useState(!1),[b,x]=y.useState(!1),v=r?A2(e):XK(e),N=r?h.project?.icon:void 0,w=h.engine??"claude",S=[v,n?e.hostName:void 0,h.profile?`@${h.profile}`:void 0,Js(h.totalCostUsd)].filter(Boolean),C=Wfe(h,R=>u?u(e,R):a?.(e)),A=v===void 0?-1:S.indexOf(v);return d.jsxs("div",{"data-slot":"session-row","data-active":t||void 0,onClick:()=>!m&&a?.(e),className:ve("group flex cursor-pointer flex-col gap-0.5 text-left transition-colors",ZI(t===!0)),children:[d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx(Y4,{children:d.jsx(e8,{row:e})}),m&&c?d.jsx(rhe,{initial:h.title??"",onCommit:R=>{p(!1),c(e,R)},onCancel:()=>p(!1)}):d.jsx("button",{type:"button",className:ve("min-w-0 flex-1 truncate text-left text-body-sm outline-none",t?"font-medium text-fg-1":"text-fg-2"),children:uc(h)}),e.unseen>0?d.jsx("span",{title:`${e.unseen} new`,className:"shrink-0 rounded-full bg-accent px-1.5 text-label text-accent-fg",children:e.unseen}):null,d.jsx("span",{className:"shrink-0 text-label text-fg-4",children:kc(h.lastActivityAt??h.createdAt)}),d.jsx(Ffe,{usage:h.contextUsage})]}),d.jsxs("div",{className:"flex items-center gap-1 text-label text-fg-4",children:[d.jsx(Y4,{children:d.jsx(kv,{engine:w,model:h.model,className:Yfe(w,h.model)})}),d.jsxs("button",{type:"button",tabIndex:-1,className:"min-w-0 flex-1 truncate text-left font-mono outline-none",children:[d.jsx("span",{className:Gfe(w,h.model),children:mX(h.model)}),S.length>0?" · ":"",A<0?S.join(" · "):d.jsxs(d.Fragment,{children:[S.slice(0,A).map(R=>`${R} · `),d.jsx(QI,{icon:N,src:JI(e,s),name:v,className:"mr-1 align-[-0.2em]"}),S.slice(A).join(" · ")]})]}),C.length>0?d.jsx(Zfe,{expanded:b,running:Qfe(C),total:C.length,noun:C[0].noun,onToggle:()=>x(R=>!R)}):null,c&&!m?d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":"Rename session",className:"size-5 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",onClick:R=>{R.stopPropagation(),p(!0)},children:d.jsx(q$,{className:"size-3 text-fg-3"})}):null,l?d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":"Close session",className:"size-5 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",onClick:R=>{R.stopPropagation(),l(e)},children:d.jsx(Dd,{className:"size-3 text-fg-3"})}):null]}),b?C.map(R=>d.jsx(Jfe,{step:R,onSelect:R.onSelect},R.key)):null]})}function Y4({children:e}){return d.jsx("span",{className:"flex w-3.5 shrink-0 items-center justify-center",children:e})}function e8({row:e}){const{info:t}=e;if(e.state==="attention")return d.jsx(yH,{className:"size-3.5 shrink-0 animate-pulse text-warning"});if(e.state==="working")return d.jsx(Tn,{className:"size-3.5 shrink-0 text-info"});switch(t.status){case"failed":return d.jsx(G6,{className:"size-3.5 shrink-0 text-danger"});case"closed":return d.jsx(lU,{className:"size-3.5 shrink-0 text-fg-4"});case"parked":return d.jsx(K6,{className:"size-3.5 shrink-0 text-fg-3"});default:return d.jsx(x2,{className:"size-3.5 shrink-0 text-fg-4"})}}function rhe({initial:e,onCommit:t,onCancel:n}){const[r,s]=y.useState(e),a=y.useRef(null);return y.useEffect(()=>{a.current?.select()},[]),d.jsx("input",{ref:a,value:r,autoFocus:!0,"aria-label":"Session name",onClick:l=>l.stopPropagation(),onChange:l=>s(l.target.value),onBlur:()=>document.hasFocus()?t(r.trim()):void 0,onKeyDown:l=>{l.key==="Enter"?t(r.trim()):l.key==="Escape"&&n(),l.stopPropagation()},className:"-my-0.5 min-w-0 flex-1 rounded-sm border border-ring bg-bg px-1 py-0.5 text-body-sm font-medium text-fg-1 outline-none"})}function Hl({label:e,children:t}){return d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{"aria-hidden":!0,className:"w-14 shrink-0 truncate text-label text-fg-3",children:e}),d.jsx("div",{className:"min-w-0 flex-1",children:t})]})}function Vh({label:e,value:t,options:n,onChange:r}){return d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsxs(Di,{multiple:!0,value:t,onValueChange:s=>r(s),children:[d.jsx(Bi,{"aria-label":e,className:"min-w-0 flex-1",children:d.jsx(Pi,{children:t.length===0?"All":t.length===1?n.find(s=>s.value===t[0])?.label??"All":`${t.length} selected`})}),d.jsx(zi,{children:n.map(s=>d.jsx(Qs,{value:s.value,children:d.jsx(Xs,{children:s.label})},s.value))})]}),t.length>0?d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":`Clear ${e}`,onClick:()=>r([]),children:d.jsx(_s,{className:"size-3 text-fg-4"})}):null]})}function G4({label:e,value:t,options:n,onChange:r}){return d.jsxs(Di,{value:t,onValueChange:s=>r(s),children:[d.jsx(Bi,{"aria-label":e,className:"w-full min-w-0",children:d.jsx(Pi,{children:n.find(s=>s.value===t)?.label??e})}),d.jsx(zi,{children:n.map(s=>d.jsx(Qs,{value:s.value,children:d.jsx(Xs,{children:s.label})},s.value))})]})}function t8(){const[e,t]=y.useState(dy());return d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":"Toggle theme",onClick:()=>t(sj()),children:e==="dark"?d.jsx(a_,{className:"size-4"}):d.jsx(x2,{className:"size-4"})})}const n8=[{value:"default",displayName:"Default (recommended)",description:"The CLI's configured default model"},{value:"fable",displayName:"Fable",description:"Fable 5 · Most capable for your hardest and longest-running tasks"},{value:"opus",displayName:"Opus",description:"Opus 5 with 1M context · Best for everyday, complex tasks"},{value:"sonnet",displayName:"Sonnet",description:"Sonnet 5 · Efficient for routine tasks"},{value:"haiku",displayName:"Haiku",description:"Haiku 4.5 · Fastest for quick answers"}],r8="workerdeck.transcript-density";function Cv(){return localStorage.getItem(r8)==="compact"?"compact":"comfortable"}function she(e){localStorage.setItem(r8,e)}const s8="workerdeck.transcript-variant";function qp(){const e=localStorage.getItem(s8);return e==="terminal"||e==="lines"?"terminal":"cards"}function ihe(e){localStorage.setItem(s8,e)}const i8="workerdeck.transcript-font";function wv(){return localStorage.getItem(i8)==="mono"?"mono":"sans"}function ahe(e){localStorage.setItem(i8,e)}function Rb({label:e,options:t,read:n,write:r,onChange:s}){const[a,l]=y.useState(n);return d.jsxs(Di,{value:a,onValueChange:c=>{l(c),r(c),s?.(c)},children:[d.jsx(Bi,{"aria-label":e,className:"min-w-40",children:d.jsx(Pi,{children:t.find(c=>c.value===a)?.label})}),d.jsx(zi,{children:t.map(c=>d.jsx(Qs,{value:c.value,children:d.jsx(Xs,{children:c.label})},c.value))})]})}function ohe({title:e,children:t}){return d.jsxs("section",{className:"flex flex-col gap-3",children:[d.jsx("h3",{className:"text-label font-medium tracking-wide text-fg-3 uppercase",children:e}),t]})}function lhe({open:e,onOpenChange:t}){const[n,r]=y.useState(qp);return d.jsx(gs,{open:e,onOpenChange:t,children:d.jsxs(bs,{size:"md",className:"w-[min(30rem,calc(100vw-2rem))]",children:[d.jsx(xs,{title:"Settings",description:"Preferences held by this browser. What a run defaults to lives on its profile; server policy lives where the gateway runs."}),d.jsx(ys,{children:d.jsx("div",{className:"flex flex-col gap-6",children:d.jsxs(ohe,{title:"Appearance",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-body-sm text-fg-2",children:"Theme"}),d.jsx(t8,{})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-body-sm text-fg-2",children:"Agent view style"}),d.jsx(Rb,{label:"Agent view style",options:[{value:"cards",label:"Cards"},{value:"terminal",label:"Terminal"}],read:qp,write:ihe,onChange:r})]}),n==="cards"?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-body-sm text-fg-2",children:"Agent view density"}),d.jsx(Rb,{label:"Agent view density",options:[{value:"comfortable",label:"Comfortable"},{value:"compact",label:"Compact"}],read:Cv,write:she})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-body-sm text-fg-2",children:"Agent view font"}),d.jsx(Rb,{label:"Agent view font",options:[{value:"sans",label:"Regular"},{value:"mono",label:"Monospace"}],read:wv,write:ahe})]})]}):null]})})})]})})}function a8({className:e}){return d.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:e,children:[d.jsx("path",{d:"M12 3 20.5 7.75 12 12.5 3.5 7.75Z"}),d.jsx("path",{d:"M3.5 12.25 12 17l8.5-4.75"}),d.jsx("path",{d:"M3.5 16.5 12 21.25l8.5-4.75"}),d.jsx("path",{d:"M12 6.15 14.85 7.75 12 9.35 9.15 7.75Z",fill:"#2fbf71",stroke:"none"})]})}const o8="workerdeck.hosts.v1",Zx=e=>`workerdeck.host.${e}.key`,l8="gateway";let ms={hosts:[],ready:!1};const Jx=new Set;function Nv(e){ms=e,ey.clear();for(const t of Jx)t()}function _v(){try{const e=localStorage.getItem(o8),t=e?JSON.parse(e):[];return Array.isArray(t)?t.map(({implicit:n,...r})=>r):[]}catch{return[]}}function c8(e){try{localStorage.setItem(o8,JSON.stringify(e.filter(t=>!t.implicit)))}catch{}}function che(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;const t=[...e].map(n=>n.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function u8(e){try{return localStorage.getItem(Zx(e))??""}catch{return""}}function d8(e,t){try{t===""?localStorage.removeItem(Zx(e)):localStorage.setItem(Zx(e),t)}catch{}}const ey=new Map;function tc(e){const t=ey.get(e);if(t)return t;const n=ms.hosts.find(a=>a.id===e);if(!n)return;const r=R2(n);if(r===void 0)return;const s=new GW({baseUrl:r,...n.implicit?{}:VW({baseUrl:r,key:u8(n.id)})});return ey.set(e,s),s}function Qm(){return ms.hosts.find(e=>e.implicit)??ms.hosts[0]}function uhe(){const e=Qm();return e?tc(e.id):void 0}function f8(e){return $W(e)}function dhe(e,t){const n=_v(),r=n.some(s=>s.id===e.id)?n.map(s=>s.id===e.id?e:s):[...n,e];c8(r),d8(e.id,t),Nv({...ms,hosts:[...ms.hosts.filter(s=>s.implicit),...r]})}function fhe(e){const t=_v().filter(n=>n.id!==e);c8(t),d8(e,""),Nv({...ms,hosts:[...ms.hosts.filter(n=>n.implicit),...t]})}async function hhe(){try{const e=await fetch(`${location.origin}/auth/status`,{headers:{accept:"application/json"}});if(!e.ok||!e.headers.get("content-type")?.includes("application/json"))return!1;const t=await e.json();return typeof t=="object"&&t!==null&&"enabled"in t}catch{return!1}}let K4=!1;function h8(){if(K4)return;K4=!0;const e=_v();ms={hosts:e,ready:!1},hhe().then(t=>{Nv({hosts:t?[{id:l8,name:"This gateway",baseUrl:location.origin,implicit:!0},...e]:e,ready:!0})})}function p8(e){return h8(),Jx.add(e),()=>Jx.delete(e)}function Av(){return y.useSyncExternalStore(p8,()=>ms,()=>ms)}function phe(){return h8(),ms.hosts}function mhe(e){return p8(e)}function m8({host:e,submitLabel:t="Save",onSaved:n,actions:r}){const[s,a]=y.useState(e.name),[l,c]=y.useState(e.baseUrl),[u,h]=y.useState(()=>u8(e.id)),m=()=>{if(R2({baseUrl:l})===void 0){un.error("That address is not a URL");return}if(!s.trim()){un.error("Give the gateway a name");return}const p={id:e.id,name:s.trim(),baseUrl:l.trim()};dhe(p,u),n(p)};return d.jsxs("div",{className:"flex flex-col gap-3",children:[d.jsxs("label",{className:"flex flex-col gap-1",children:[d.jsx("span",{className:"text-label text-fg-3",children:"Name"}),d.jsx(Zt,{value:s,onChange:p=>a(p.target.value),placeholder:"Mac mini"})]}),d.jsxs("label",{className:"flex flex-col gap-1",children:[d.jsx("span",{className:"text-label text-fg-3",children:"Address"}),d.jsx(Zt,{value:l,onChange:p=>c(p.target.value),placeholder:"http://toby.ts.net:8787",spellCheck:!1,className:"font-mono"})]}),d.jsxs("label",{className:"flex flex-col gap-1",children:[d.jsx("span",{className:"text-label text-fg-3",children:"Auth key"}),d.jsx(Zt,{type:"password",value:u,onChange:p=>h(p.target.value),placeholder:"Leave empty for an unauthenticated gateway",spellCheck:!1}),d.jsx("span",{className:"text-label text-fg-4",children:"Stored in this browser’s local storage, and sent on the WebSocket URL when attaching. Use a gateway you control, over a network you trust."})]}),d.jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[r,d.jsx(tt,{onClick:m,children:t})]})]})}function ghe({open:e,onOpenChange:t,onCreated:n}){const[r,s]=y.useState(()=>W4());return d.jsx(gs,{open:e,onOpenChange:a=>{a&&s(W4()),t(a)},children:d.jsxs(bs,{children:[d.jsx(xs,{title:"Add gateway",description:"A workerdeck gateway you run — typically over Tailscale."}),d.jsx(ys,{children:d.jsx(m8,{host:r,submitLabel:"Add gateway",onSaved:n,actions:d.jsx(tt,{variant:"outline",onClick:()=>t(!1),children:"Cancel"})})})]})})}function W4(){return{id:che(),name:"",baseUrl:""}}function g8({host:e,onClose:t,onRemoved:n}){return d.jsx(gs,{open:!0,onOpenChange:r=>!r&&t(),children:d.jsxs(bs,{children:[d.jsx(xs,{title:`Remove ${e.name}?`,description:"Its auth key is deleted from this browser. The gateway itself keeps running."}),d.jsx(ys,{children:d.jsxs("div",{className:"flex justify-end gap-2",children:[d.jsx(tt,{variant:"outline",onClick:t,children:"Cancel"}),d.jsx(tt,{variant:"destructive",onClick:()=>{fhe(e.id),n()},children:"Remove"})]})})]})})}const b8=240,x8=520,ty=300,y8=e=>e==="sessions"?"workerdeck.sessions-sidebar-width":`workerdeck.${e}-sidebar-width`,v8=e=>e==="sessions"?"workerdeck.sessions-sidebar-collapsed":`workerdeck.${e}-sidebar-collapsed`;function bhe(e){try{const t=Number(localStorage.getItem(y8(e)));return t?Math.min(x8,Math.max(b8,t)):ty}catch{return ty}}function xhe(e,t){try{localStorage.setItem(y8(e),String(t))}catch{}}function yhe(e){try{return localStorage.getItem(v8(e))==="1"}catch{return!1}}function vhe(e,t){try{localStorage.setItem(v8(e),t?"1":"0")}catch{}}const E8="workerdeck.sessions-filters-shown";function Ehe(){try{return localStorage.getItem(E8)==="1"}catch{return!1}}function The(e){try{localStorage.setItem(E8,e?"1":"0")}catch{}}function Zm({section:e,title:t,badge:n,actions:r,children:s,rail:a,railActions:l}){const[c,u]=y.useState(()=>bhe(e)),[h,m]=y.useState(()=>yhe(e)),p=b=>{m(b),vhe(e,b)};return h?d.jsxs("div",{className:"flex min-h-0 w-11 shrink-0 flex-col items-center gap-1 border-r border-border bg-sidebar py-1.5",children:[d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":`Expand ${t.toLowerCase()}`,onClick:()=>p(!1),children:d.jsx(v2,{className:"size-4"})}),l,a?d.jsx("div",{className:"flex min-h-0 w-full flex-1 flex-col items-center gap-0.5 overflow-y-auto pt-1",children:a}):null]}):d.jsxs(d.Fragment,{children:[d.jsxs("div",{style:{width:c},className:"flex min-h-0 shrink-0 flex-col border-r border-border bg-sidebar",children:[d.jsxs("header",{className:"flex h-9 shrink-0 items-center gap-1 pr-1 pl-3",children:[d.jsx("span",{className:"truncate text-label font-medium tracking-wide text-fg-3 uppercase",children:t}),n,d.jsx("span",{className:"flex-1"}),d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":`Collapse ${t.toLowerCase()}`,onClick:()=>p(!0),children:d.jsx(y2,{className:"size-3.5"})}),r]}),s]}),d.jsx(lx,{orientation:"vertical",value:c,onValueChange:b=>{u(b),xhe(e,b)},min:b8,max:x8,defaultValue:ty,"aria-label":`Resize ${t.toLowerCase()} sidebar`})]})}function Jm({children:e,className:t}){return d.jsx("div",{className:ve("min-h-0 flex-1 overflow-y-auto pb-2",t),children:e})}function Rv({title:e,status:t,description:n,actions:r,active:s,onSelect:a,onDoubleClick:l}){return d.jsxs("div",{"data-slot":"sidebar-row","data-active":s||void 0,onClick:a,onDoubleClick:l,className:ve("group flex cursor-pointer flex-col gap-0.5 text-left transition-colors",ZI(s===!0)),children:[d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx("button",{type:"button",className:ve("min-w-0 flex-1 truncate text-left text-body-sm outline-none",s?"font-medium text-fg-1":"text-fg-2"),children:e}),t]}),d.jsxs("div",{className:"flex items-center gap-1 text-label text-fg-4",children:[d.jsx("button",{type:"button",tabIndex:-1,className:"flex min-w-0 flex-1 items-center gap-1.5 truncate text-left font-mono outline-none",children:n}),r]})]})}function T8({label:e,onClick:t,children:n}){return d.jsx("button",{type:"button","aria-label":e,title:e,onClick:r=>{r.stopPropagation(),t()},className:"flex size-5 shrink-0 items-center justify-center rounded text-fg-3 opacity-0 transition-opacity outline-none hover:bg-surface-hover hover:text-fg-1 group-hover:opacity-100",children:n})}const X4="workerdeck.watermarks.v1",ny=new Set;let ry=0;const She={read:()=>{try{const e=localStorage.getItem(X4);return e?JSON.parse(e):void 0}catch{return}},write:e=>{try{localStorage.setItem(X4,JSON.stringify(e))}catch{}ry+=1;for(const t of ny)t()}},Yp=new uW(She);function khe(e){return ny.add(e),()=>ny.delete(e)}function Che(){return y.useSyncExternalStore(khe,()=>ry,()=>ry),{unseenFor:y.useCallback((t,n)=>dW(Yp.get(t,n.id),{activityCount:n.activityCount,turns:n.numTurns}),[]),watermarks:Yp}}function whe(e,t){const n=Yp.get(e,t);return n?{itemCount:n.itemCount,since:n.seenAt}:void 0}function Nhe(e,t){const n=y.useRef({});return y.useCallback(r=>{!t||document.hidden||(n.current={...n.current,...r},Yp.mark(e,t,n.current))},[e,t])}const _he=5e3,Ahe=1200,Rhe=700;let dd={snapshots:[],loaded:!1};const sy=new Set;function Mhe(e){dd=e;for(const t of sy)t()}let Mb,S8=0,Ib;function fd(){return Mb??=(async()=>{S8=Date.now();try{const e=phe(),t=new Map(dd.snapshots.map(r=>[r.host.id,r])),n=await Promise.all(e.map(async r=>{const s=tc(r.id);if(!s)return{host:r,sessions:[],error:"unusable address"};try{return{host:r,sessions:await s.listSessions()}}catch(a){return{host:r,sessions:t.get(r.id)?.sessions??[],error:a instanceof Error?a.message:String(a)}}}));Mhe({snapshots:n,loaded:!0})}finally{Mb=void 0}})(),Mb}function Ihe(){if(Ib!==void 0)return;const e=Math.max(0,Rhe-(Date.now()-S8));Ib=setTimeout(()=>{Ib=void 0,fd()},e)}function Ohe(e){return sy.add(e),()=>sy.delete(e)}let qh,Q4;function Lhe(e){const t=e?Ahe:_he;qh!==void 0&&Q4===t||(qh!==void 0&&clearInterval(qh),Q4=t,qh=setInterval(()=>void fd(),t))}function Ic(){const e=y.useSyncExternalStore(Ohe,()=>dd,()=>dd);y.useEffect(()=>mhe(()=>void fd()),[]);const t=e.snapshots.some(n=>n.sessions.some(r=>{const s=G_(r);return s==="working"||s==="attention"}));return y.useEffect(()=>{Lhe(t),dd.loaded||fd()},[t]),{...e,refresh:fd}}function jhe(e){const{unseenFor:t}=Che();return y.useMemo(()=>e.flatMap(({host:n,sessions:r})=>r.filter(s=>!QK(s)).map(s=>({hostId:n.id,hostName:n.name,local:f8(n),adapter:s.engine??"claude",state:G_(s),info:s,unseen:t(n.id,s)}))),[e,t])}function Dhe(){const e=As(),t=Id({select:p=>p.location.pathname.match(/^\/gateways\/(.+)$/)?.[1]}),{hosts:n,ready:r}=Av(),{snapshots:s}=Ic(),[a,l]=y.useState(!1),[c,u]=y.useState(),h=s.filter(p=>p.error===void 0).length,m=d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":"Add gateway",onClick:()=>l(!0),children:d.jsx($o,{className:"size-4"})});return d.jsxs(d.Fragment,{children:[d.jsx(Zm,{section:"gateways",title:"Gateways",badge:r&&n.length>0?d.jsxs("span",{className:"shrink-0 text-label text-fg-4",children:[h,"/",n.length]}):void 0,actions:m,railActions:m,children:d.jsxs(Jm,{children:[r&&n.length===0?d.jsx(Wr,{icon:d.jsx(s_,{}),title:"No gateways yet",description:d.jsxs(d.Fragment,{children:["Add one with ",d.jsx(qo,{children:"+"})," above."]})}):null,n.map(p=>{const b=s.find(v=>v.host.id===p.id),x=b===void 0?"pending":b.error?"error":"ok";return d.jsx(Rv,{active:p.id===t,onSelect:()=>void e({to:"/gateways/$hostId",params:{hostId:p.id}}),title:p.name,status:d.jsxs(d.Fragment,{children:[p.implicit?d.jsx("span",{className:"shrink-0 text-label text-fg-4",children:"this page"}):null,d.jsx("span",{"aria-hidden":!0,title:b?.error??(x==="ok"?"Connected":"Connecting…"),className:ve("size-1.5 shrink-0 rounded-full",x==="ok"?"bg-success":x==="error"?"bg-danger":"bg-fg-4")})]}),description:p.baseUrl,actions:p.implicit?null:d.jsx(T8,{label:`Remove ${p.name}`,onClick:()=>u(p),children:d.jsx(Dd,{className:"size-3"})})},p.id)})]})}),c?d.jsx(g8,{host:c,onClose:()=>u(void 0),onRemoved:()=>{const p=c.id===t;u(void 0),p&&e({to:"/gateways"})}}):null,d.jsx(ghe,{open:a,onOpenChange:l,onCreated:p=>{l(!1),e({to:"/gateways/$hostId",params:{hostId:p.id}})}})]})}function k8({value:e,onChange:t,models:n=n8,className:r}){return d.jsx(RI,{variant:"form",models:n,model:e||void 0,onModelChange:s=>t(s??""),className:r})}function Phe({profiles:e,value:t,onChange:n,className:r}){return e.length===0?null:d.jsxs("label",{className:"flex min-w-0 flex-col gap-1",children:[d.jsx("span",{className:"text-label font-medium text-fg-3",children:"Profile"}),d.jsxs(Di,{items:e.map(s=>({value:s.name,label:s.name})),value:t,onValueChange:s=>n(s),children:[d.jsx(Bi,{className:r,children:d.jsx(Pi,{})}),d.jsx(zi,{children:e.map(s=>d.jsx(Qs,{value:s.name,children:d.jsx(Xs,{children:d.jsxs("span",{className:s.available===!1?"text-fg-4":void 0,title:s.unavailableReason,children:[s.description?`${s.name} — ${s.description}`:s.name,s.available===!1?" (unavailable)":""]})})},s.name))})]})]})}function Dr(){return uhe()}function C8(e,t,n){const r=e?.capabilities??Am[e?.engine??"claude"],s=r.permissionModes.includes(t)?t:r.defaultPermissionMode;let a,l;if(e?.models?.length)a=e.models,l=e.defaultModel;else if(e?.engine==="provider"){const h=e.provider;a=(h?.models?.length?h.models:h?.model?[h.model]:[]).map(p=>({value:p,displayName:p})),l=h?.model}else a=n8.filter(h=>h.value!=="default");const c=a.find(h=>h.value===n||h.resolvedModel===n),u=c||n===""?n:"";return{capabilities:r,modes:r.permissionModes,models:[{value:"default",displayName:"Profile default",description:l??"the profile's configured model"},...a],mode:s,model:u,reasoningEfforts:(c?c.reasoningEfforts:void 0)??r.reasoningEfforts??[]}}const iy={profiles:[]};let ay,Ob;const oy=new Set;async function Z4(){const e=await(Dr()?.listProfiles().catch(()=>iy)??Promise.resolve(iy));ay=e;for(const t of oy)t(e);return e}function Mv(){const[e,t]=y.useState(ay??iy);y.useEffect(()=>(oy.add(t),ay||(Ob??=Z4()),()=>{oy.delete(t)}),[]);const n=y.useCallback(async()=>{Ob=Z4(),await Ob},[]);return{...e,refresh:n}}function Bhe(){return Mv().profiles}const J4="workerdeck.last-profile";function zhe(){const e=Bhe(),[t,n]=y.useState(()=>localStorage.getItem(J4)??""),r=e.some(l=>l.name===t)?t:e[0]?.name??"",s=e.find(l=>l.name===r);return{profiles:e,profile:r,selected:s,select:l=>{n(l),localStorage.setItem(J4,l)}}}const ly="workerdeck.last-cwd";function Hhe(e){const[t,n]=y.useState([]);return y.useEffect(()=>{Dr()?.listHostRoots().then(r=>n(r.roots.map(s=>s.path))).catch(()=>n([]))},[]),y.useMemo(()=>{const r=localStorage.getItem(ly),s=[...r?[r]:[],...[...e].sort((a,l)=>(l.lastActivityAt??l.createdAt)-(a.lastActivityAt??a.createdAt)).map(a=>a.cwd),...t];return[...new Set(s)].slice(0,12)},[e,t])}const Uhe={session:"default",job:"acceptEdits"};function w8(e){const[t,n]=y.useState(()=>localStorage.getItem(ly)??""),[r,s]=y.useState(""),[a,l]=y.useState(""),[c,u]=y.useState(void 0),[h,m]=y.useState(""),{profiles:p,profile:b,selected:x,select:v}=zhe(),N=c??x?.defaults?.permissionMode??Uhe[e],w=C8(x,N,a),S=A=>({cwd:w.capabilities.hostCwd===!1?void 0:t.trim(),profile:b||void 0,prompt:A.prompt,permissionMode:w.mode,model:w.model.trim()||void 0,resume:A.resume,reasoningEffort:h&&w.reasoningEfforts.includes(h)?h:void 0,...w.capabilities.settingSources?{settingSources:["user","project"],allowDangerouslySkipPermissions:A.allowBypass||void 0}:{}}),C=A=>localStorage.setItem(ly,t.trim()||A);return{cwd:t,setCwd:n,prompt:r,setPrompt:s,mode:w.mode,setMode:u,model:a,setModel:l,effort:h,setEffort:m,profiles:p,profile:b,selectProfile:v,engine:w,sessionFields:S,rememberCwd:C}}function N8({form:e,sessions:t,promptLabel:n,promptPlaceholder:r="e.g. /verify-content 42, or a task description",extras:s,actions:a,onProfileChange:l}){const c=Hhe(t),u=y.useId(),{engine:h}=e;return d.jsxs(d.Fragment,{children:[h.capabilities.hostCwd!==!1&&d.jsxs("label",{className:"flex flex-col gap-1",children:[d.jsx("span",{className:"text-label font-medium text-fg-3",children:"Working directory"}),d.jsx(Zt,{value:e.cwd,list:u,onChange:m=>e.setCwd(m.target.value),placeholder:"/path/to/project",spellCheck:!1,className:"font-mono"}),d.jsx("datalist",{id:u,children:c.map(m=>d.jsx("option",{value:m},m))})]}),d.jsxs("label",{className:"flex flex-col gap-1",children:[d.jsx("span",{className:"text-label font-medium text-fg-3",children:n}),d.jsx(c5,{value:e.prompt,onChange:m=>e.setPrompt(m.target.value),rows:2,placeholder:r})]}),d.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[d.jsx(Phe,{profiles:e.profiles,value:e.profile,onChange:m=>{e.selectProfile(m),l?.(m)},className:"min-w-32"}),d.jsxs("label",{className:"flex min-w-0 flex-col gap-1",children:[d.jsx("span",{className:"text-label font-medium text-fg-3",children:"Permission mode"}),d.jsx(yv,{variant:"form",mode:h.mode,onModeChange:e.setMode,modes:h.modes,className:"min-w-44"})]}),s,d.jsxs("label",{className:"flex min-w-0 flex-col gap-1",children:[d.jsx("span",{className:"text-label font-medium text-fg-3",children:"Model"}),d.jsx(k8,{value:h.model,onChange:e.setModel,models:h.models,className:"min-w-40"})]}),h.reasoningEfforts.length>0?d.jsxs("label",{className:"flex min-w-0 flex-col gap-1",children:[d.jsx("span",{className:"text-label font-medium text-fg-3",children:"Effort"}),d.jsxs(Di,{items:[{value:"default",label:"Default"},...h.reasoningEfforts.map(m=>({value:m,label:m}))],value:e.effort||"default",onValueChange:m=>e.setEffort(m==="default"?"":String(m)),children:[d.jsx(Bi,{className:"min-w-28",children:d.jsx(Pi,{})}),d.jsx(zi,{children:["default",...h.reasoningEfforts].map(m=>d.jsx(Qs,{value:m,children:d.jsx(Xs,{children:m})},m))})]})]}):null,a]})]})}const Fhe=15e3;let Ci={jobs:[],stats:void 0,enabled:!0,live:!1,error:void 0};const cy=new Set;function _o(e){Ci={...Ci,...e};for(const t of cy)t()}let Lb;function Gp(){return Lb??=(async()=>{try{const e=Dr();if(!e)return;const[t,n]=await Promise.all([e.listJobs(),e.queueStats()]);_o({jobs:t,stats:n,enabled:!0,error:void 0})}catch(e){const t=e instanceof Error?e.message:String(e);/not configured/i.test(t)?_o({enabled:!1,error:void 0}):_o({error:t})}finally{Lb=void 0}})(),Lb}let uy=0,jb,Kp;function $he(e){return cy.add(e),++uy===1&&(Gp(),jb=setInterval(()=>void Gp(),Fhe)),()=>{cy.delete(e),--uy===0&&(clearInterval(jb),jb=void 0,Kp?.(),Kp=void 0,_o({live:!1}))}}function Vhe(){if(Kp||!Ci.enabled||Ci.stats===void 0||uy===0)return;const e=Dr();if(!e)return;const t=e.attachQueue(),n=[t.on("attached",()=>void Gp()),t.on("stats",r=>_o({stats:r})),t.on("connectionChange",r=>_o({live:r})),t.on("event",r=>{_o({jobs:Ci.jobs.some(s=>s.id===r.job.id)?Ci.jobs.map(s=>s.id===r.job.id?r.job:s):[...Ci.jobs,r.job]})})];Kp=()=>{for(const r of n)r();t.detach()}}function Iv(){const e=y.useSyncExternalStore($he,()=>Ci,()=>Ci);return y.useEffect(Vhe,[e.enabled,e.stats]),{...e,refresh:Gp}}function qhe({stats:e}){const t=e.dailyTokenLimit!==void 0&&e.dailyTokenLimit>0?e.dailyTokensUsed/e.dailyTokenLimit*100:void 0;return d.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-x-5 gap-y-2 rounded-md border border-border bg-surface px-3 py-2 text-body-sm text-fg-2",children:[d.jsxs("span",{children:["Running ",d.jsxs("span",{className:"font-mono text-fg-1",children:[e.running,"/",e.maxConcurrency]})]}),d.jsxs("span",{children:["Queued ",d.jsx("span",{className:"font-mono text-fg-1",children:e.queued})]}),e.parked>0?d.jsxs("span",{children:["Parked ",d.jsx("span",{className:"font-mono text-fg-1",children:e.parked})]}):null,d.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t!==void 0?d.jsx(N2,{value:t,className:t>=95?"text-danger":t>=80?"text-warning":"text-fg-3"}):null,"Daily tokens"," ",d.jsxs("span",{className:"font-mono text-fg-1",children:[Gr(e.dailyTokensUsed),e.dailyTokenLimit!==void 0?` / ${Gr(e.dailyTokenLimit)}`:""]})]}),e.sessionTokenLimit!==void 0?d.jsxs("span",{children:["Per-job cap ",d.jsx("span",{className:"font-mono text-fg-1",children:Gr(e.sessionTokenLimit)})]}):null,e.paused?d.jsx(En,{variant:"warning",dot:!0,children:"Paused — daily budget exhausted"}):null]})}function Yhe({onScheduled:e}){const{snapshots:t}=Ic(),n=t.find(C=>C.host.id===Qm()?.id)?.sessions??[],r=w8("job"),[s,a]=y.useState("auto"),[l,c]=y.useState(!1),[u,h]=y.useState(""),[m,p]=y.useState(""),[b,x]=y.useState(""),[v,N]=y.useState(!1),{engine:w}=r,S=async()=>{if(!r.cwd.trim()||!r.prompt.trim()){un.error("Working directory and prompt are required");return}const C=u.trim()?Number(u.trim()):void 0;if(C!==void 0&&(!Number.isFinite(C)||C<=0)){un.error("Max tokens must be a positive number");return}const A=m.trim()?Number(m.trim()):void 0;if(A!==void 0&&(!Number.isInteger(A)||A<1)){un.error("Attempts must be a whole number of at least 1");return}N(!0);try{r.rememberCwd(r.cwd.trim()),await Dr().createJob({session:{...r.sessionFields({allowBypass:l}),prompt:r.prompt.trim(),questionBehavior:w.capabilities.interactiveApprovals?s:void 0},maxTokens:C,attempts:A,webhook:b.trim()?{url:b.trim()}:void 0}),r.setPrompt(""),un.success("Job scheduled"),e()}catch(R){un.error(R instanceof Error?R.message:"Failed to schedule job")}finally{N(!1)}};return d.jsxs("div",{className:"flex flex-col gap-3",children:[d.jsx(N8,{form:r,sessions:n,promptLabel:"Prompt (the task — runs unattended)",extras:w.capabilities.interactiveApprovals?d.jsxs("label",{className:"flex min-w-0 flex-col gap-1",children:[d.jsx("span",{className:"text-label font-medium text-fg-3",children:"Questions"}),d.jsxs(Di,{items:w4.map(C=>({value:C.value,label:C.label})),value:s,onValueChange:C=>a(C),children:[d.jsx(Bi,{className:"min-w-36",children:d.jsx(Pi,{})}),d.jsx(zi,{children:w4.map(C=>d.jsx(Qs,{value:C.value,children:d.jsx(Xs,{children:`${C.label} — ${C.description}`})},C.value))})]})]}):null,actions:d.jsxs(d.Fragment,{children:[d.jsxs("label",{className:"flex min-w-0 flex-col gap-1",children:[d.jsx("span",{className:"text-label font-medium text-fg-3",children:"Max tokens (optional)"}),d.jsx(Zt,{value:u,onChange:C=>h(C.target.value),placeholder:"per-job cap",inputMode:"numeric",className:"min-w-28 font-mono"})]}),d.jsxs("label",{className:"flex min-w-0 flex-col gap-1",children:[d.jsx("span",{className:"text-label font-medium text-fg-3",children:"Attempts (optional)"}),d.jsx(Zt,{value:m,onChange:C=>p(C.target.value),placeholder:"1",inputMode:"numeric",className:"min-w-20 font-mono"})]}),d.jsxs("label",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[d.jsx("span",{className:"text-label font-medium text-fg-3",children:"Webhook URL (optional)"}),d.jsx(Zt,{value:b,onChange:C=>x(C.target.value),placeholder:"https://…/hook",spellCheck:!1,className:"min-w-44 font-mono"})]}),d.jsxs(tt,{className:"ml-auto",onClick:()=>void S(),disabled:v,children:[v?d.jsx(Tn,{className:"size-3.5 text-current"}):d.jsx($o,{className:"size-4"}),"Schedule"]})]})}),w.capabilities.settingSources?d.jsxs("label",{className:"flex w-fit cursor-pointer items-center gap-2 text-body-sm text-fg-2",title:"Spawns the CLI with --dangerously-skip-permissions available, so the mode can be switched on while watching the run. The job still starts in the mode selected above.",children:[d.jsx("input",{type:"checkbox",checked:l,onChange:C=>c(C.target.checked),className:"size-3.5 accent-(--color-fg-1)"}),"Allow switching to ",d.jsx("code",{className:"font-mono",children:"bypassPermissions"})," mid-run",d.jsx("span",{className:"text-label text-fg-4",children:"(dangerous)"})]}):null,d.jsxs("p",{className:"text-label text-fg-4",children:["Unattended runs still surface permission prompts — the job's page is read-only, so answer them from the session itself, or pick a mode that doesn't ask. Unanswered prompts deny after the server's timeout. With Questions set to Ask, webhook deliveries carry the full question so a controller can answer via"," ",d.jsx("code",{className:"font-mono",children:"POST /sessions/:id/permissions/:requestId"}),"."]})]})}function Ghe({open:e,onOpenChange:t,onScheduled:n}){return d.jsx(gs,{open:e,onOpenChange:t,children:d.jsxs(bs,{size:"lg",children:[d.jsx(xs,{title:"Schedule a job",description:"A one-shot run the queue executes unattended."}),d.jsx(ys,{children:e?d.jsx(Yhe,{onScheduled:n}):null})]})})}function Khe(){const{stats:e,enabled:t,error:n}=Iv();return d.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-8 text-center",children:[n?d.jsxs("div",{className:"rounded-md bg-danger-bg px-3 py-2 text-body-sm text-danger",children:["Can't reach the worker server: ",n,". Start it with"," ",d.jsx("code",{className:"font-mono",children:"pnpm server"}),"."]}):null,t?d.jsxs(d.Fragment,{children:[d.jsx(Wr,{icon:d.jsx(e_,{}),title:"No job selected",description:d.jsxs(d.Fragment,{children:["Pick one on the left, or schedule one with ",d.jsx(qo,{children:"+"})," above."]})}),e?d.jsx("div",{className:"mt-2 w-full max-w-xl",children:d.jsx(qhe,{stats:e})}):null]}):d.jsxs(d.Fragment,{children:[d.jsx(FH,{className:"size-8 text-fg-4"}),d.jsx("p",{className:"text-body-sm text-fg-3",children:"The server has no job queue configured."}),d.jsxs("p",{className:"max-w-md text-label text-fg-4",children:["Pass ",d.jsxs("code",{className:"font-mono",children:["queue: ","{ maxConcurrency, … }"]})," to"," ",d.jsx("code",{className:"font-mono",children:"createWorkerServer"})," — the dev server enables it by default."]})]})]})}const _8={queued:{label:"Queued",variant:"neutral"},running:{label:"Running",variant:"info",busy:!0},parked:{label:"Parked",variant:"accent"},succeeded:{label:"Succeeded",variant:"success"},failed:{label:"Failed",variant:"danger"},canceled:{label:"Canceled",variant:"warning"}},Whe=["queued","running","parked"];function Xhe(){const e=As(),t=Id({select:w=>w.location.pathname.match(/^\/jobs\/(.+)$/)?.[1]}),{jobs:n,enabled:r,live:s,refresh:a}=Iv(),[l,c]=y.useState(!1),[u,h]=y.useState(""),[m,p]=y.useState(!1),b=u.trim().toLowerCase(),x=[...n].sort((w,S)=>S.createdAt-w.createdAt).filter(w=>(!m||Whe.includes(w.status))&&(!b||w.prompt.toLowerCase().includes(b)||w.cwd.toLowerCase().includes(b)||(w.profile?.toLowerCase().includes(b)??!1)||w.id.startsWith(b))),v=n.length-x.length,N=r?d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":"Schedule a job",onClick:()=>c(!0),children:d.jsx($o,{className:"size-4"})}):void 0;return d.jsxs(d.Fragment,{children:[d.jsx(Zm,{section:"jobs",title:"Jobs",badge:r?d.jsx("span",{"aria-hidden":!0,title:s?"Streaming over the queue socket":"Polling",className:ve("size-1.5 shrink-0 rounded-full",s?"bg-success":"bg-fg-4")}):void 0,actions:d.jsxs(d.Fragment,{children:[d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":"Refresh",onClick:()=>void a(),children:d.jsx(Sm,{className:"size-3.5"})}),N]}),railActions:N,children:r?d.jsxs(d.Fragment,{children:[n.length>0?d.jsxs("div",{className:"flex items-center gap-1 px-2 pb-2",children:[d.jsx(Zt,{value:u,onChange:w=>h(w.target.value),placeholder:"Search jobs","aria-label":"Search jobs",className:"h-7 min-w-0 flex-1 text-body-sm"}),d.jsx(tt,{variant:m?"default":"outline",size:"xs","aria-pressed":m,onClick:()=>p(!m),children:"Active"})]}):null,d.jsxs(Jm,{children:[n.length===0?d.jsx(Wr,{icon:d.jsx(sC,{}),title:"No jobs yet",description:d.jsxs(d.Fragment,{children:["Schedule one with ",d.jsx(qo,{children:"+"})," above."]})}):x.length===0?d.jsx(Wr,{icon:d.jsx(r_,{}),title:"No matches",description:"No job matches the active filter.",action:"Show all",onAction:()=>p(!1)}):null,x.map(w=>d.jsx(Qhe,{job:w,active:w.id===t,onOpen:()=>void e({to:"/jobs/$jobId",params:{jobId:w.id}}),onChanged:()=>void a()},w.id)),v>0?d.jsxs("p",{className:"px-1 pt-2 text-center text-label text-fg-4",children:[x.length," of ",n.length]}):null]})]}):d.jsx(Wr,{icon:d.jsx(sC,{}),title:"No job queue",description:"This gateway runs without one, so there is nothing to schedule against."})}),d.jsx(Ghe,{open:l,onOpenChange:c,onScheduled:()=>{c(!1),a()}})]})}function Qhe({job:e,active:t,onOpen:n,onChanged:r}){const s=_8[e.status],a=e.status==="queued"||e.status==="running"||e.status==="parked",l=[kc(e.finishedAt??e.startedAt??e.createdAt),e.cwd.split("/").filter(Boolean).pop()??e.cwd];return e.profile&&l.push(`@${e.profile}`),e.usage.totalCostUsd>0&&l.push(Js(e.usage.totalCostUsd)),d.jsx(Rv,{active:t,onSelect:n,title:e.prompt,status:d.jsxs(En,{variant:s.variant,dot:!s.busy,className:"shrink-0",children:[s.busy?d.jsx(Tn,{className:"size-3 text-current"}):null,s.label]}),description:l.join(" · "),actions:a?d.jsx(T8,{label:"Cancel job",onClick:()=>{Dr()?.cancelJob(e.id).then(r).catch(c=>un.error(c instanceof Error?c.message:"Cancel failed"))},children:d.jsx(_s,{className:"size-3"})}):null})}const Zhe=["web_search","download","web_fetch","deliver_file"],Yh=e=>e.split(",").map(t=>t.trim()).filter(Boolean);function ks({label:e,children:t}){return d.jsxs("label",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[d.jsx("span",{className:"text-label font-medium text-fg-3",children:e}),t]})}function Jhe({onCreated:e}){const[t,n]=y.useState("provider"),[r,s]=y.useState(""),[a,l]=y.useState(""),[c,u]=y.useState(""),[h,m]=y.useState(""),[p,b]=y.useState(""),[x,v]=y.useState(""),[N,w]=y.useState(""),[S,C]=y.useState([]),[A,R]=y.useState(""),[M,_]=y.useState(""),[I,j]=y.useState(!1),z=t==="provider",P=async()=>{if(!r.trim()){un.error("Name is required");return}const F={name:r.trim(),engine:t};if(a.trim()&&(F.description=a.trim()),z){F.provider={id:c.trim(),model:h.trim()||void 0,models:Yh(p).length>0?Yh(p):void 0,apiKeyEnv:x.trim()||void 0};const V={};S.length>0&&(V.capabilities=S),Yh(A).length>0&&(V.mcpServers=Yh(A)),M.trim()&&(V.instructions=M.trim()),Object.keys(V).length>0&&(F.session=V)}else F.configDir=N.trim();j(!0);try{await Dr().createProfile(F),un.success(`Profile '${F.name}' created`),e(F.name)}catch(V){un.error(V instanceof Error?V.message:"Failed to create profile")}finally{j(!1)}};return d.jsxs("div",{className:"flex flex-col gap-3",children:[d.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[d.jsx(ks,{label:"Engine",children:d.jsxs(Di,{items:[{value:"provider",label:"provider"},{value:"claude",label:"claude"}],value:t,onValueChange:F=>n(F),children:[d.jsx(Bi,{className:"min-w-32",children:d.jsx(Pi,{})}),d.jsxs(zi,{children:[d.jsx(Qs,{value:"provider",children:d.jsx(Xs,{children:"provider — model-agnostic engine"})}),d.jsx(Qs,{value:"claude",children:d.jsx(Xs,{children:"claude — Agent SDK + config dir"})})]})]})}),d.jsx(ks,{label:"Name",children:d.jsx(Zt,{value:r,onChange:F=>s(F.target.value),placeholder:"kimi"})}),d.jsx(ks,{label:"Description (optional)",children:d.jsx(Zt,{value:a,onChange:F=>l(F.target.value),placeholder:"what this profile is for"})})]}),z?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[d.jsx(ks,{label:"Provider id",children:d.jsx(Zt,{value:c,onChange:F=>u(F.target.value),placeholder:"anthropic / openai / moonshotai",className:"font-mono"})}),d.jsx(ks,{label:"Default model",children:d.jsx(Zt,{value:h,onChange:F=>m(F.target.value),placeholder:"kimi-k3",className:"font-mono"})}),d.jsx(ks,{label:"Models offered (comma-separated)",children:d.jsx(Zt,{value:p,onChange:F=>b(F.target.value),placeholder:"kimi-k3, kimi-k2",className:"font-mono"})}),d.jsx(ks,{label:"API key variable",children:d.jsx(Zt,{value:x,onChange:F=>v(F.target.value),placeholder:"MOONSHOT_API_KEY",className:"font-mono"})})]}),d.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[d.jsx(ks,{label:"Capabilities granted",children:d.jsx("div",{className:"flex flex-wrap gap-3 py-1.5",children:Zhe.map(F=>d.jsxs("label",{className:"flex cursor-pointer items-center gap-1.5 text-body-sm text-fg-2",children:[d.jsx("input",{type:"checkbox",checked:S.includes(F),onChange:V=>C(G=>V.target.checked?[...G,F]:G.filter(K=>K!==F)),className:"size-3.5 accent-(--color-fg-1)"}),d.jsx("code",{className:"font-mono text-label",children:F})]},F))})}),d.jsx(ks,{label:"MCP servers (names, comma-separated)",children:d.jsx(Zt,{value:A,onChange:F=>R(F.target.value),placeholder:"deepwiki",className:"font-mono"})})]}),d.jsx(ks,{label:"Instructions (optional)",children:d.jsx(Zt,{value:M,onChange:F=>_(F.target.value),placeholder:"prepended to the session's system prompt"})}),d.jsx("p",{className:"text-label text-fg-4",children:"Leave capabilities and MCP servers empty to inherit whatever the server's engine factory wired — that factory is the ceiling either way, so a grant here can never exceed it. MCP servers are named, never configured: their transport config (and any credentials in it) stays on the server."})]}):d.jsxs(d.Fragment,{children:[d.jsx(ks,{label:"Config directory",children:d.jsx(Zt,{value:N,onChange:F=>w(F.target.value),placeholder:"/Users/you/.claude",spellCheck:!1,className:"font-mono"})}),d.jsxs("p",{className:"text-label text-fg-4",children:["Must resolve inside the server's"," ",d.jsx("code",{className:"font-mono",children:"allowedConfigDirRoots"})," — a config directory is a credential store, so the server bounds which ones a managed profile may point at."]})]}),d.jsx("div",{className:"flex justify-end",children:d.jsxs(tt,{onClick:()=>void P(),disabled:I,children:[I?d.jsx(Tn,{className:"size-3.5 text-current"}):d.jsx($o,{className:"size-4"}),"Create profile"]})})]})}function epe({open:e,onOpenChange:t,onCreated:n}){return d.jsx(gs,{open:e,onOpenChange:t,children:d.jsxs(bs,{size:"lg",children:[d.jsx(xs,{title:"New profile",description:"What a session runs as — a Claude config directory, or a model provider."}),d.jsx(ys,{children:e?d.jsx(Jhe,{onCreated:n}):null})]})})}function tpe(){const e=As(),t=Id({select:u=>u.location.pathname.match(/^\/profiles\/(.+)$/)?.[1]}),{profiles:n,canManage:r,refresh:s}=Mv(),[a,l]=y.useState(!1),c=r?d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":"New profile",onClick:()=>l(!0),children:d.jsx($o,{className:"size-4"})}):void 0;return d.jsxs(d.Fragment,{children:[d.jsx(Zm,{section:"profiles",title:"Profiles",badge:n.length>0?d.jsx("span",{className:"shrink-0 text-label text-fg-4",children:n.length}):void 0,actions:c,railActions:c,children:d.jsxs(Jm,{children:[n.length===0?d.jsx(Wr,{icon:d.jsx(DF,{}),title:r?"No profiles yet":"No profiles",description:r?d.jsxs(d.Fragment,{children:["Add one with ",d.jsx(qo,{children:"+"})," above."]}):"This gateway declares none, and this login may not add them."}):null,n.map(u=>d.jsx(Rv,{active:u.name===t,onSelect:()=>void e({to:"/profiles/$profileName",params:{profileName:u.name}}),title:u.name,status:u.managed?null:d.jsx(En,{variant:"neutral",className:"shrink-0",children:"declared"}),description:d.jsxs(d.Fragment,{children:[d.jsx(kv,{engine:u.engine??"claude",model:u.defaults?.model??u.provider?.model,className:"size-3 shrink-0 text-fg-3"}),d.jsx("span",{className:"min-w-0 truncate",children:u.configDir??(u.provider?`${u.provider.id}${u.provider.model?` · ${u.provider.model}`:""}`:u.engine??"claude")})]})},u.name))]})}),d.jsx(epe,{open:a,onOpenChange:l,onCreated:u=>{l(!1),s(),e({to:"/profiles/$profileName",params:{profileName:u}})}})]})}function npe({sessions:e,onCreated:t}){const n=w8("session"),[r,s]=y.useState(!1),[a,l]=y.useState(),[c,u]=y.useState(!1),{engine:h}=n,m=async b=>{const x=b?.cwd??n.cwd.trim();if(!x){un.error("Working directory is required");return}s(!0);try{n.rememberCwd(x);const v=await Dr().createSession({...n.sessionFields({prompt:b?void 0:n.prompt.trim()||void 0,resume:b?.sessionId,allowBypass:!0}),cwd:x});t(v.id)}catch(v){un.error(v instanceof Error?v.message:"Failed to create session")}finally{s(!1)}},p=async()=>{if(!n.cwd.trim()){un.error("Set a working directory first — resumable sessions are listed per project");return}u(!0);try{l(await Dr().listSdkSessions({dir:n.cwd.trim(),limit:20,profile:n.profile||void 0}))}catch(b){un.error(b instanceof Error?b.message:"Failed to list resumable sessions")}finally{u(!1)}};return d.jsxs("div",{className:"flex flex-col gap-3",children:[d.jsx(N8,{form:n,sessions:e,promptLabel:"Initial prompt (optional)",onProfileChange:()=>l(void 0),actions:d.jsxs(tt,{className:"ml-auto",onClick:()=>void m(),disabled:r,children:[r?d.jsx(Tn,{className:"size-3.5 text-current"}):d.jsx($o,{className:"size-4"}),"Create"]})}),h.capabilities.listSessions?d.jsxs("div",{className:"mt-1 border-t border-border pt-3",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-label font-medium text-fg-3",children:"Resume a previous session"}),d.jsxs(tt,{variant:"ghost",size:"xs",onClick:()=>void p(),disabled:c,children:[c?d.jsx(Tn,{className:"size-3 text-current"}):d.jsx(IF,{className:"size-3"}),a?"Reload":"Browse"]})]}),a!==void 0?a.length===0?d.jsx("div",{className:"py-3 text-center text-body-sm text-fg-4",children:"No stored sessions for this directory."}):d.jsx("ul",{className:"mt-2 flex flex-col gap-1",children:a.map(b=>d.jsxs("li",{className:"flex items-center gap-2 rounded-md px-2 py-1.5 hover:bg-surface-hover",children:[d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("div",{className:"truncate text-body-sm text-fg-1",children:b.customTitle??b.summary}),d.jsxs("div",{className:"flex gap-2 font-mono text-label text-fg-4",children:[b.gitBranch?d.jsx("span",{className:"truncate",children:b.gitBranch}):null,d.jsx("span",{className:"shrink-0",children:kc(b.lastModified)})]})]}),d.jsx(tt,{variant:"outline",size:"xs",onClick:()=>void m(b),disabled:r,children:"Resume"})]},b.sessionId))}):null]}):null]})}function rpe({open:e,onOpenChange:t,sessions:n,onCreated:r}){return d.jsx(gs,{open:e,onOpenChange:t,children:d.jsxs(bs,{size:"lg",children:[d.jsx(xs,{title:"New session",description:"Pick a directory and an engine."}),d.jsx(ys,{children:d.jsx(npe,{sessions:n,onCreated:r})})]})})}function spe(){return d.jsx("div",{className:"flex flex-1 items-center justify-center p-8",children:d.jsx(Wr,{icon:d.jsx(a8,{}),title:"No session open",description:d.jsxs(d.Fragment,{children:["Pick one on the left, or start a new one with ",d.jsx(qo,{children:"+"})," above."]})})})}const eN="workerdeck.view-config";function ipe(){const[e,t]=y.useState(()=>{try{const r=localStorage.getItem(eN),s=r?JSON.parse(r):{};return{...hx,...s,search:"",scoped:!1}}catch{return{...hx,scoped:!1}}}),n=y.useCallback(r=>{t(r);try{localStorage.setItem(eN,JSON.stringify(r))}catch{}},[]);return[e,n]}function ape(){const e=As(),t=Id({select:_=>_.location.pathname.match(/^\/sessions\/[^/]+\/(.+)$/)?.[1]??void 0}),{snapshots:n,refresh:r}=Ic(),s=jhe(n),a=ZW(s,tc),l=n.filter(_=>_.error!==void 0),c=Qm(),u=n.find(_=>_.host.id===c?.id)?.sessions??[],h=_=>{c&&e({to:"/sessions/$hostId/$sessionId",params:{hostId:c.id,sessionId:_},search:{}})},[m,p]=ipe(),[b,x]=y.useState(!1),[v,N]=y.useState(Ehe),w=y.useMemo(()=>W_(s,m),[s,m]),S=_=>void e({to:"/sessions/$hostId/$sessionId",params:{hostId:_.hostId,sessionId:_.info.id},search:{}}),C=y.useRef(0),A=(_,I)=>void e({to:"/sessions/$hostId/$sessionId",params:{hostId:_.hostId,sessionId:_.info.id},search:{subagent:I,sn:++C.current}}),R=(_,I)=>{tc(_.hostId)?.updateSession(_.info.id,{title:I||null}).then(()=>r()).catch(j=>un.error(j instanceof Error?j.message:"Rename failed"))},M=d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":"New session",onClick:()=>x(!0),children:d.jsx($o,{className:"size-4"})});return d.jsxs(d.Fragment,{children:[d.jsxs(Zm,{section:"sessions",title:"Sessions",railActions:M,actions:d.jsxs(d.Fragment,{children:[d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":v?"Hide filters":"Show filters","aria-pressed":v,onClick:()=>{N(!v),The(!v)},children:d.jsx(dF,{className:ve("size-3.5",v&&"fill-current text-fg-1")})}),d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":"Refresh",onClick:()=>void r(),children:d.jsx(Sm,{className:"size-3.5"})}),M]}),rail:w.map(_=>d.jsxs("button",{type:"button",title:`${uc(_.info)} — ${_.state}`,"aria-label":uc(_.info),onClick:()=>S(_),className:ve("flex w-full flex-col items-center gap-0.5 border-l-2 py-1.5",_.info.id===t?"border-l-accent bg-row-active":"border-l-transparent hover:bg-row-hover"),children:[d.jsx(kv,{engine:_.adapter,model:_.info.model,className:"size-4"}),d.jsx(e8,{row:_})]},_.info.id)),children:[l.map(({host:_,error:I})=>d.jsxs("div",{className:"mx-2 mb-2 rounded-md bg-danger-bg px-2 py-1.5 text-label text-danger",children:["Can’t reach ",_.name,": ",I]},_.id)),d.jsx(Jm,{children:d.jsx(the,{rows:s,config:m,onConfigChange:p,showControls:v,projectIcons:a,activeId:t,onSelect:S,onSelectSubagent:A,onRename:R,onDelete:_=>{tc(_.hostId)?.deleteSession(_.info.id).then(()=>r()).catch(I=>un.error(I instanceof Error?I.message:"Delete failed"))},emptyState:d.jsx(Wr,{icon:d.jsx(wp,{}),title:"No sessions yet",description:d.jsxs(d.Fragment,{children:["Start one with ",d.jsx(qo,{children:"+"})," above."]})})})})]}),d.jsx(rpe,{open:b,onOpenChange:x,sessions:u,onCreated:_=>{x(!1),h(_),r()}})]})}const tN=[{id:"sessions",label:"Sessions",icon:eq,path:"/sessions",sidebar:ape},{id:"gateways",label:"Gateways",icon:Tm,path:"/gateways",sidebar:Dhe},{id:"jobs",label:"Jobs",icon:e_,path:"/jobs",sidebar:Xhe},{id:"profiles",label:"Profiles",icon:T2,path:"/profiles",sidebar:tpe}],nN="workerdeck.sidebar-collapsed";function ope({children:e}){const t=Id({select:p=>p.location.pathname}),n=[...tN].sort((p,b)=>b.path.length-p.path.length).find(p=>t.startsWith(p.path)),r=n?.sidebar,[s,a]=y.useState(!1),[l,c]=y.useState(()=>{try{return localStorage.getItem(nN)==="1"}catch{return!1}}),u=()=>{c(p=>{try{localStorage.setItem(nN,p?"0":"1")}catch{}return!p})},h="flex size-7 items-center justify-center rounded-md text-fg-3 transition-colors outline-none hover:bg-row-hover hover:text-fg-1",m=p=>ve("flex items-center rounded-md text-body-sm transition-colors outline-none",l?"justify-center p-2":"gap-2 px-2 py-1.5",p?"bg-surface font-medium text-fg-1 shadow-(--shadow-xs)":"text-fg-3 hover:bg-row-hover hover:text-fg-1");return d.jsxs("div",{className:"flex h-dvh bg-sidebar",children:[d.jsxs("aside",{className:ve("flex shrink-0 flex-col gap-1 p-3 transition-[width] duration-150",l?"w-14 items-center":"w-52"),children:[d.jsxs("div",{className:ve("flex items-center py-2",l?"justify-center":"gap-2 px-2"),children:[d.jsx(a8,{className:"size-4 shrink-0 text-fg-1"}),!l&&d.jsx("span",{className:"text-body-sm font-semibold tracking-tight text-fg-1",children:"workerdeck"})]}),d.jsx("nav",{className:ve("mt-1 flex flex-1 flex-col gap-0.5",l&&"items-center"),children:tN.map(p=>d.jsxs(em,{to:p.path,title:l?p.label:void 0,"aria-label":p.label,onClick:b=>{p.id===n?.id&&b.preventDefault()},className:m(p.id===n?.id),children:[d.jsx(p.icon,{className:"size-4 shrink-0"}),!l&&p.label]},p.id))}),d.jsxs("div",{className:ve("mt-1 grid place-items-center gap-1",l?"grid-rows-3":"grid-cols-3"),children:[d.jsx("button",{type:"button",onClick:()=>a(!0),title:"Settings","aria-label":"Settings",className:h,children:d.jsx(MV,{className:"size-4"})}),d.jsx(t8,{}),d.jsx("button",{type:"button",onClick:u,title:l?"Expand sidebar":"Collapse sidebar","aria-label":l?"Expand sidebar":"Collapse sidebar",className:h,children:l?d.jsx(v2,{className:"size-4"}):d.jsx(y2,{className:"size-4"})})]})]}),d.jsxs("div",{className:"app-frame frame-shine m-2 ml-0 flex min-w-0 flex-1 overflow-hidden rounded-xl",children:[r?d.jsx(r,{},n?.id):null,d.jsx("main",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:e??d.jsx(qN,{})})]}),d.jsx(lhe,{open:s,onOpenChange:a})]})}function Ov({crumbs:e,actions:t,children:n}){return d.jsxs("div",{className:"flex h-11 shrink-0 items-center gap-2 border-b border-border bg-surface px-3",children:[d.jsx("nav",{"aria-label":"Breadcrumb",className:"flex min-w-0 items-center gap-1",children:e.map((r,s)=>d.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[s>0?d.jsx(Tc,{"aria-hidden":!0,className:"size-3 shrink-0 text-fg-4"}):null,r.to?d.jsx(em,{to:r.to,className:"shrink-0 text-body-sm text-fg-3 outline-none hover:text-fg-1",children:r.label}):d.jsx("span",{"aria-current":"page",className:"min-w-0 truncate text-body-sm font-medium text-fg-1",title:r.label,children:r.label})]},r.label))}),n,d.jsx("span",{className:"flex-1"}),t]})}function A8({children:e}){return d.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:d.jsx("div",{className:"mx-auto flex w-full max-w-3xl flex-col gap-5 px-6 py-6",children:e})})}function Uu({label:e,children:t}){return d.jsxs("div",{className:"flex items-baseline justify-between gap-4 py-1.5",children:[d.jsx("span",{className:"shrink-0 text-label font-medium text-fg-3",children:e}),d.jsx("span",{className:"min-w-0 text-right text-body-sm text-fg-1",children:t})]})}function lpe(){const{hostId:e}=gc({from:"/gateways/$hostId"}),t=As(),{hosts:n,ready:r}=Av(),{snapshots:s}=Ic(),[a,l]=y.useState(!1),c=n.find(m=>m.id===e),u=s.find(m=>m.host.id===e);if(y.useEffect(()=>{!r||c||t({to:"/gateways"})},[r,c,t]),!c)return null;const h=u===void 0?"pending":u.error?"error":"ok";return d.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[d.jsx(Ov,{crumbs:[{label:"Gateways",to:"/gateways"},{label:c.name}],actions:c.implicit?null:d.jsxs(tt,{variant:"outline",size:"xs",onClick:()=>l(!0),children:[d.jsx(Dd,{className:"size-3"}),"Remove"]}),children:d.jsx("span",{className:"min-w-0 truncate font-mono text-label text-fg-4",title:c.baseUrl,children:c.baseUrl})}),d.jsxs(A8,{children:[d.jsxs(bo,{children:[d.jsx(xo,{children:d.jsx(yo,{children:"Connection"})}),d.jsxs(vo,{className:"flex flex-col divide-y divide-border",children:[d.jsx(Uu,{label:"Status",children:h==="ok"?d.jsx(En,{variant:"success",dot:!0,children:"Connected"}):h==="error"?d.jsx(En,{variant:"danger",dot:!0,children:"Unreachable"}):d.jsx(En,{variant:"neutral",dot:!0,children:"Connecting…"})}),u?.error?d.jsx(Uu,{label:"Last error",children:d.jsx("span",{className:"text-danger",children:u.error})}):null,d.jsx(Uu,{label:"Live sessions",children:u?u.sessions.length:d.jsx("span",{className:"text-fg-4",children:"—"})}),d.jsx(Uu,{label:"Reachability",children:f8(c)?"This machine (loopback)":"Remote"}),d.jsx(Uu,{label:"Credential",children:c.implicit?d.jsx("span",{className:"text-fg-4",children:"the login cookie it set — same origin"}):d.jsx("span",{className:"text-fg-4",children:"an auth key held in this browser"})})]})]}),c.implicit?d.jsx("p",{className:"text-label text-fg-4",children:"This is the gateway that served the page. Its address is this origin and its credential is the cookie it already set, so there is nothing here to change — and nothing to remove, since removing it would just be closing the tab."}):d.jsxs(bo,{children:[d.jsx(xo,{children:d.jsx(yo,{children:"Settings"})}),d.jsx(vo,{children:d.jsx(m8,{host:c,onSaved:m=>un.success(`Saved ${m.name}`)},c.id)})]}),a?d.jsx(g8,{host:c,onClose:()=>l(!1),onRemoved:()=>{l(!1),t({to:"/gateways"})}}):null]})]})}function cpe(){return d.jsx("div",{className:"flex flex-1 items-center justify-center p-8",children:d.jsx(Wr,{icon:d.jsx(Tm,{}),title:"No gateway selected",description:d.jsxs(d.Fragment,{children:["Pick one on the left, or add one with ",d.jsx(qo,{children:"+"})," above."]})})})}function upe({files:e,activePath:t,onActivate:n,onClose:r,className:s}){return d.jsx(ZY,{delay:500,closeDelay:0,children:d.jsx("div",{"data-slot":"editor-tabs",role:"tablist","aria-label":"Open files",className:ve("flex shrink-0 items-stretch overflow-x-auto border-b border-border bg-surface",s),children:e.map(a=>d.jsx(dpe,{file:a,active:a.path===t,onActivate:()=>n(a.path),onClose:()=>r(a.path),onArrow:l=>{const c=e.findIndex(h=>h.path===a.path),u=e[c+l];u&&n(u.path)}},a.path))})})}function dpe({file:e,active:t,onActivate:n,onClose:r,onArrow:s}){const a=Cd(e),l=y.useRef(null);y.useEffect(()=>{t&&l.current?.scrollIntoView({block:"nearest",inline:"nearest"})},[t]);const c=u=>{u.button===1&&(u.preventDefault(),r())};return d.jsxs(w2,{side:"bottom",render:d.jsx("div",{ref:l,role:"tab",tabIndex:t?0:-1,"aria-selected":t,onClick:n,onAuxClick:c,onKeyDown:u=>{if(u.key==="ArrowRight")s(1);else if(u.key==="ArrowLeft")s(-1);else if(u.key==="Enter"||u.key===" ")n();else return;u.preventDefault()},className:ve("group flex min-w-0 shrink-0 cursor-pointer items-center gap-1.5 border-r border-border px-3 py-1.5 transition-colors","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent focus-visible:ring-inset",t?"bg-bg text-fg-1":"text-fg-3 hover:bg-surface-hover hover:text-fg-2")}),content:d.jsxs("span",{className:"flex flex-col gap-0.5",children:[d.jsx("span",{className:"font-mono break-all",children:e.path}),e.bytes!==void 0?d.jsx("span",{className:"text-fg-4",children:Li(e.bytes)}):null]}),children:[d.jsx("span",{className:ve("max-w-40 truncate font-mono text-label",a&&"italic"),children:e.name}),e.status==="error"?d.jsx("span",{className:"shrink-0 text-danger",children:"!"}):null,d.jsxs("button",{type:"button","aria-label":a?`Close ${e.name} (unsaved changes)`:`Close ${e.name}`,onClick:u=>{u.stopPropagation(),r()},className:ve("shrink-0 rounded p-0.5 text-fg-4 transition-opacity hover:bg-surface-hover hover:text-fg-1",t||a?"opacity-70":"opacity-0 group-hover:opacity-70 focus-visible:opacity-100"),children:[d.jsx("span",{className:ve("block",a&&"group-hover:hidden"),children:a?d.jsx("span",{className:"block size-3 rounded-full bg-fg-2"}):d.jsx(_s,{className:"size-3"})}),a?d.jsx("span",{className:"hidden group-hover:block",children:d.jsx(_s,{className:"size-3"})}):null]})]})}const R8=12;function fpe({tree:e,search:t,activePath:n,onOpenFile:r,onCollapse:s,style:a,className:l}){const[c,u]=y.useState(""),[h,m]=y.useState(),p=c.trim().length>0;return y.useEffect(()=>{if(!t?.available)return;const b=c.trim();if(!b){m(void 0);return}const x=new AbortController,v=setTimeout(()=>{t.search(b,{limit:60,signal:x.signal}).then(N=>{x.signal.aborted||m(N)})},150);return()=>{x.abort(),clearTimeout(v)}},[t,c]),d.jsxs("div",{"data-slot":"file-tree",style:a,className:ve("flex min-h-0 min-w-0 flex-col bg-surface",l),children:[d.jsxs("div",{className:"flex items-center gap-1 px-2 pt-2",children:[t?.available?d.jsxs("div",{className:"relative min-w-0 flex-1",children:[d.jsx(km,{className:"absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-fg-4"}),d.jsx(Zt,{value:c,onChange:b=>u(b.target.value),placeholder:"Search files…",className:"h-7 pr-7 pl-7 text-label",spellCheck:!1}),p?d.jsx("button",{type:"button",onClick:()=>u(""),"aria-label":"Clear search",className:"absolute top-1/2 right-1.5 -translate-y-1/2 text-fg-4 transition-colors hover:text-fg-2",children:d.jsx(_s,{className:"size-3.5"})}):null]}):d.jsx("span",{className:"min-w-0 flex-1 truncate px-1 text-label text-fg-4",children:e.root}),d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":"Refresh the file tree",onClick:()=>e.refresh(),children:d.jsx(Sm,{className:"size-3.5 text-fg-3"})}),s?d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":"Hide project files",onClick:s,children:d.jsx(y2,{className:"size-3.5 text-fg-3"})}):null]}),d.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-1 py-1",children:e.error?d.jsx("p",{className:"px-2 py-3 text-body-sm text-danger",children:e.error}):p?h===void 0?d.jsx("div",{className:"py-6 text-center",children:d.jsx(Tn,{className:"size-4 text-fg-4"})}):h.length===0?d.jsx("p",{className:"px-2 py-6 text-center text-body-sm text-fg-4",children:"No matching files."}):d.jsx("ul",{children:h.map(b=>d.jsx("li",{children:d.jsx(rN,{label:hpe(b.relative),detail:ppe(b.relative),title:b.relative,icon:d.jsx(vm,{className:"size-3.5 shrink-0 text-fg-4"}),active:b.path===n,onClick:()=>r(b.path)})},b.path))}):e.loading?d.jsx("div",{className:"py-6 text-center",children:d.jsx(Tn,{className:"size-4 text-fg-4"})}):e.rows.length===0?d.jsx("p",{className:"px-2 py-6 text-center text-body-sm text-fg-4",children:"This project is empty."}):d.jsx("ul",{role:"tree","aria-label":"Project files",children:e.rows.map(b=>d.jsxs("li",{role:"treeitem","aria-expanded":b.expanded,"aria-level":b.depth+1,children:[d.jsx(rN,{label:b.entry.name,indent:b.depth,active:b.entry.path===n,icon:b.entry.type==="dir"?b.loading?d.jsx(Tn,{className:"size-3.5 shrink-0 text-fg-4"}):b.expanded?d.jsx(sF,{className:"size-3.5 shrink-0 text-accent"}):d.jsx(Em,{className:"size-3.5 shrink-0 text-accent"}):d.jsx(mpe,{type:b.entry.type}),chevron:b.entry.type==="dir"?d.jsx(Tc,{className:ve("size-3 shrink-0 text-fg-4 transition-transform",b.expanded&&"rotate-90")}):void 0,onClick:()=>b.entry.type==="dir"?e.toggle(b.entry.path):r(b.entry.path)}),b.truncated?d.jsx("p",{className:"truncate py-0.5 text-label text-fg-4",style:{paddingLeft:(b.depth+1)*R8+22},children:"More entries than the server will return — use search."}):null]},b.entry.path))})})]})}function rN({label:e,detail:t,title:n,icon:r,chevron:s,indent:a=0,active:l,onClick:c}){const u=y.useRef(null);return y.useEffect(()=>{l&&u.current?.scrollIntoView({block:"nearest"})},[l]),d.jsxs("button",{ref:u,type:"button",onClick:c,title:n??e,style:{paddingLeft:a*R8+4},className:ve("flex w-full items-center gap-1 rounded py-1 pr-2 text-left transition-colors",l?"bg-surface-hover text-fg-1":"text-fg-2 hover:bg-surface-hover"),children:[d.jsx("span",{className:"flex size-3 shrink-0 items-center justify-center",children:s}),r,d.jsx("span",{className:"shrink-0 truncate text-label",children:e}),t?d.jsx("span",{className:"min-w-0 flex-1 truncate text-label text-fg-4",children:t}):null]})}function hpe(e){return e.slice(e.lastIndexOf("/")+1)}function ppe(e){const t=e.lastIndexOf("/");return t===-1?void 0:e.slice(0,t)}function mpe({type:e}){return e==="symlink"?d.jsx(J6,{className:"size-3.5 shrink-0 text-fg-4"}):d.jsx(vm,{className:"size-3.5 shrink-0 text-fg-4"})}function gpe({path:e,value:t,onChange:n,onSave:r,readOnly:s,className:a}){const l=y.useRef(null),c=y.useRef(null),u=y.useRef(null),[h,m]=y.useState(!1),p=bpe(),b=y.useRef({onChange:n,onSave:r});return b.current={onChange:n,onSave:r},y.useEffect(()=>{let x=!1;return xpe().then(v=>{if(x||!l.current)return;u.current=v;const N=v.editor.create(l.current,{value:t,language:aN(e),readOnly:s,automaticLayout:!0,theme:sN(document.documentElement.getAttribute("data-theme")),minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:12,lineHeight:20,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace',renderLineHighlight:"line",smoothScrolling:!0,padding:{top:8,bottom:8},scrollbar:{verticalScrollbarSize:10,horizontalScrollbarSize:10},wordBasedSuggestions:"off",quickSuggestions:!1});c.current=N,N.onDidChangeModelContent(()=>{b.current.onChange?.(N.getValue())}),N.addCommand(v.KeyMod.CtrlCmd|v.KeyCode.KeyS,()=>{b.current.onSave?.()}),m(!0)}),()=>{x=!0,c.current?.dispose(),c.current=null,m(!1)}},[]),y.useEffect(()=>{const x=u.current,v=c.current;if(!x||!v||!h)return;const N=x.Uri.parse(`workerdeck://host${e}`),w=x.editor.getModel(N)??x.editor.createModel(t,aN(e),N);v.getModel()!==w&&v.setModel(w)},[e,h,t]),y.useEffect(()=>{const x=c.current;if(!x||!h)return;const v=x.getModel();!v||v.getValue()===t||v.pushEditOperations([],[{range:v.getFullModelRange(),text:t}],()=>null)},[t,h]),y.useEffect(()=>{h&&c.current?.updateOptions({readOnly:s})},[s,h]),y.useEffect(()=>{h&&u.current?.editor.setTheme(sN(p))},[p,h]),d.jsxs("div",{className:ve("relative min-h-0 min-w-0 flex-1",a),children:[d.jsx("div",{ref:l,className:"absolute inset-0"}),h?null:d.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bg",children:d.jsx(Tn,{className:"size-4 text-fg-4"})})]})}function bpe(){const[e,t]=y.useState(()=>typeof document>"u"?null:document.documentElement.getAttribute("data-theme"));return y.useEffect(()=>{const n=document.documentElement,r=()=>t(n.getAttribute("data-theme"));r();const s=new MutationObserver(r);return s.observe(n,{attributes:!0,attributeFilter:["data-theme"]}),()=>s.disconnect()},[]),e}function sN(e){return e==="light"?"wd-light":"wd-dark"}let iN;function xpe(){return iN??=(async()=>{const e=await fc(()=>import("./index-DeDTIRzE.js"),__vite__mapDeps([0,1]));return e.editor.defineTheme("wd-dark",{base:"vs-dark",inherit:!0,rules:[],colors:{"editor.background":"#00000000"}}),e.editor.defineTheme("wd-light",{base:"vs",inherit:!0,rules:[],colors:{"editor.background":"#00000000"}}),e})(),iN}function aN(e){const t=e.slice(e.lastIndexOf("/")+1),n=ype[t.toLowerCase()];if(n)return n;const r=t.slice(t.lastIndexOf(".")+1).toLowerCase();return vpe[r]??"plaintext"}const ype={dockerfile:"dockerfile",makefile:"plaintext",".gitignore":"plaintext",".env":"shell"},vpe={ts:"typescript",tsx:"typescript",mts:"typescript",cts:"typescript",js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",json:"json",jsonc:"json",md:"markdown",mdx:"markdown",css:"css",scss:"scss",less:"less",html:"html",htm:"html",xml:"xml",svg:"xml",yml:"yaml",yaml:"yaml",toml:"plaintext",sh:"shell",bash:"shell",zsh:"shell",fish:"shell",py:"python",rb:"ruby",rs:"rust",go:"go",swift:"swift",java:"java",kt:"kotlin",c:"c",h:"c",cpp:"cpp",cc:"cpp",hpp:"cpp",cs:"csharp",php:"php",sql:"sql",graphql:"graphql",gql:"graphql",lua:"lua",r:"r",pl:"perl",dart:"dart",scala:"scala",ini:"ini",cfg:"ini",conf:"ini",txt:"plaintext",log:"plaintext"};function Epe({file:e,canWrite:t,onChange:n,onSave:r,onRevert:s,onReload:a,onOverwrite:l,onDismissConflict:c,className:u}){return e?d.jsxs("div",{"data-slot":"file-viewer",className:ve("flex min-h-0 min-w-0 flex-1 flex-col bg-bg",u),children:[e.conflict?d.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 border-b border-warning/40 bg-warning-bg px-3 py-2",children:[d.jsx(Jl,{className:"size-3.5 shrink-0 text-warning"}),d.jsx("span",{className:"min-w-0 flex-1 text-body-sm text-warning",children:"This file changed on disk since you opened it."}),d.jsx(tt,{variant:"outline",size:"xs",onClick:()=>a?.(e.path),children:"Use the version on disk"}),d.jsx(tt,{variant:"outline",size:"xs",onClick:()=>l?.(e.path),children:"Keep mine"}),d.jsx(tt,{variant:"ghost",size:"xs",onClick:()=>c?.(e.path),children:"Dismiss"})]}):e.saveError?d.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-danger/40 bg-danger-bg px-3 py-2",children:[d.jsx(Jl,{className:"size-3.5 shrink-0 text-danger"}),d.jsx("span",{className:"min-w-0 flex-1 text-body-sm text-danger",children:e.saveError}),d.jsx(tt,{variant:"ghost",size:"xs",onClick:()=>c?.(e.path),children:"Dismiss"})]}):null,e.status==="loading"?d.jsx(Db,{children:d.jsx(Tn,{className:"size-4 text-fg-4"})}):e.status==="error"?d.jsxs(Db,{children:[d.jsx(Jl,{className:"size-4 text-danger"}),d.jsx("p",{className:"text-body-sm text-danger",children:e.error})]}):e.status==="binary"?d.jsxs(Db,{children:[d.jsx(KU,{className:"size-4 text-fg-4"}),d.jsx("p",{className:"text-body-sm text-fg-4",children:"This file isn’t text."}),d.jsx("p",{className:"text-label text-fg-4",children:"It can’t be edited here without corrupting it."})]}):d.jsx(gpe,{path:e.path,value:bx(e),readOnly:!t,onChange:n?h=>n(e.path,h):void 0,onSave:r?()=>r(e.path):void 0}),e.status==="ready"&&(e.saving||Cd(e)||!t)?d.jsx("div",{className:"flex shrink-0 items-center gap-2 border-t border-border px-3 py-1",children:e.saving?d.jsxs(d.Fragment,{children:[d.jsx(Tn,{className:"size-3 text-fg-4"}),d.jsx("span",{className:"text-label text-fg-4",children:"Saving…"})]}):t?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"text-label text-fg-3",children:"Unsaved changes"}),d.jsx("span",{className:"flex-1"}),d.jsx(tt,{variant:"ghost",size:"xs",onClick:()=>s?.(e.path),children:"Revert"}),d.jsxs(tt,{variant:"outline",size:"xs",onClick:()=>r?.(e.path),children:["Save",d.jsx("span",{className:"ml-1 text-fg-4",children:"⌘S"})]})]}):d.jsx("span",{className:"text-label text-fg-4",children:"Read-only — this gateway doesn’t allow writes."})}):null]}):null}function Db({children:e}){return d.jsx("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-2 p-6",children:e})}const oN="wd-path-link",Tpe=/^(\/[^\s:'"`()[\]{}]+|[\w.@~-]+(?:\/[\w.@~-]+)+)(?::(\d+))?$/,Spe=/^([\w.@-]+\.[A-Za-z0-9]{1,10})(?::(\d+))?$/,kpe=.6;function Cpe(e,t){const n=e.trim();if(!n||n.endsWith("/"))return;const r=Tpe.exec(n)??(t?Spe.exec(n):null);if(r)return{path:r[1],line:r[2]?Number(r[2]):void 0}}function lN(e){if(!e)return;const t=e.closest("code")!==null,n=e.textContent??"",r=Cpe(n,t);if(r&&!(!t&&r.path.length<n.trim().length*kpe))return r}function wpe({container:e,onOpen:t,enabled:n=!0,ignore:r}){y.useEffect(()=>{const s=e.current;if(!s||!n)return;const a=p=>p?.closest(r)!==null&&p!==void 0;let l;const c=()=>{l?.classList.remove(oN),l=void 0},u=p=>{if(!p.metaKey&&!p.ctrlKey)return;const b=p.target instanceof HTMLElement?p.target:void 0;if(a(b))return;const x=lN(b);x&&(p.preventDefault(),p.stopPropagation(),c(),t(x))},h=p=>{if(!p.metaKey&&!p.ctrlKey)return c();const b=p.target instanceof HTMLElement?p.target:void 0;b!==l&&(c(),!(!b||a(b)||!lN(b))&&(l=b,b.classList.add(oN)))},m=p=>{!p.metaKey&&!p.ctrlKey&&c()};return s.addEventListener("click",u,!0),s.addEventListener("mousemove",h),document.addEventListener("keydown",m),document.addEventListener("keyup",m),window.addEventListener("blur",c),()=>{c(),s.removeEventListener("click",u,!0),s.removeEventListener("mousemove",h),document.removeEventListener("keydown",m),document.removeEventListener("keyup",m),window.removeEventListener("blur",c)}},[e,t,n,r])}function Npe(e,t){return e.startsWith("/")||!t?e:`${t.replace(/\/$/,"")}/${e.replace(/^\.\//,"")}`}const _pe=180,Ape=520,Rpe=220,cN=120;function M8({client:e,sessionId:t,header:n,transcriptVariant:r,transcriptDensity:s,transcriptFont:a,scrubber:l,scrubberMarks:c,stickyPrompt:u,openSubagent:h,statusPlacement:m,controlsSurface:p,unseen:b,readOnly:x,onVitals:v,defaultRailWidth:N=260,defaultRailCollapsed:w,onRailChange:S,className:C}){const{info:A}=nA(e,t),R=A?.cwd,M=QW(e,R),_=tA(e,R),I=tX(e),{canWrite:j}=XW(e);y.useEffect(()=>{if(!I.hasUnsaved)return;const le=ge=>ge.preventDefault();return window.addEventListener("beforeunload",le),()=>window.removeEventListener("beforeunload",le)},[I.hasUnsaved]);const z=Ipe(),[P,F]=y.useState(w??!1),[V,G]=y.useState(N),K=y.useRef(S);K.current=S,y.useEffect(()=>{K.current?.({width:V,collapsed:P})},[V,P]);const[Y,U]=y.useState(360),Q=I.files.length>0,W=!z,ue=M.available&&!P;y.useEffect(()=>{W&&F(!0)},[W]);const D=y.useCallback(le=>{const ge=I.files.find(Pe=>Pe.path===le);if(ge&&Cd(ge)){const Pe=ge.name;if(!window.confirm(`${Pe} has unsaved changes. Close it and lose them?`))return}I.close(le)},[I]),H=y.useRef(null),B=Mpe(H),L=y.useCallback(({path:le})=>I.open(Npe(le,R)),[I.open,R]);wpe({container:H,onOpen:L,enabled:M.available,ignore:".monaco-editor"});const te=Math.max(cN,B-Rpe),[ne,de]=y.useState(null),oe=n===void 0||ne===null?void 0:typeof n=="function"?le=>ir.createPortal(n(le),ne):ir.createPortal(n,ne);return d.jsxs("div",{"data-slot":"session-workspace",className:ve("flex h-full min-h-0 w-full flex-col overflow-hidden bg-bg",C),children:[n!==void 0?d.jsx("div",{ref:de,className:"shrink-0"}):null,d.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[ue?d.jsx(fpe,{tree:M,search:_,activePath:I.activePath,onOpenFile:I.open,onCollapse:()=>F(!0),style:{width:W?Math.min(V,320):V},className:ve("shrink-0 border-r border-border",W&&"absolute inset-y-0 left-0 z-20 shadow-lg")}):M.available?d.jsx("div",{className:"flex w-8 shrink-0 flex-col items-center border-r border-border bg-surface pt-1.5",children:d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":"Show project files",onClick:()=>F(!1),children:d.jsx(v2,{className:"size-4 text-fg-3"})})}):null,ue&&!W?d.jsx(lx,{orientation:"vertical",value:V,onValueChange:G,min:_pe,max:Ape,defaultValue:N,"aria-label":"Resize the file tree"}):null,d.jsxs("div",{ref:H,className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[Q?d.jsxs("div",{className:"flex min-h-0 shrink-0 flex-col overflow-hidden",style:{height:Math.min(Y,te||Y)},children:[d.jsx(upe,{files:I.files,activePath:I.activePath,onActivate:I.activate,onClose:D}),d.jsx(Epe,{file:I.active,canWrite:j,onChange:I.edit,onSave:le=>void I.save(le),onRevert:I.revert,onReload:I.reload,onOverwrite:le=>void I.overwrite(le),onDismissConflict:I.dismissConflict})]}):null,Q?d.jsx(lx,{orientation:"horizontal",value:Math.min(Y,te||Y),onValueChange:U,min:cN,max:te,"aria-label":"Resize the open file"}):null,d.jsx(zfe,{client:e,sessionId:t,header:oe,transcriptVariant:r,transcriptDensity:s,transcriptFont:a,scrubber:l,scrubberMarks:c,stickyPrompt:u,openSubagent:h,controlsSurface:p,statusPlacement:m,unseen:b,readOnly:x,onVitals:v,className:"min-h-0 flex-1"})]}),W&&ue?d.jsx("button",{type:"button","aria-label":"Close the file tree",onClick:()=>F(!0),className:"absolute inset-0 z-10 bg-black/30"}):null]})]})}function Mpe(e){const[t,n]=y.useState(0);return y.useLayoutEffect(()=>{const r=e.current;if(!r)return;const s=new ResizeObserver(([a])=>{a&&n(a.contentRect.height)});return s.observe(r),()=>s.disconnect()},[e]),t}function Ipe(){const[e,t]=y.useState(!0);return y.useEffect(()=>{const n=window.matchMedia("(min-width: 768px)"),r=()=>t(n.matches);return r(),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}const I8="workerdeck.rail",uN={width:260,collapsed:!1};function O8(){try{const e=localStorage.getItem(I8),t=e?JSON.parse(e):{};return{width:Math.min(520,Math.max(180,Number(t.width)||uN.width)),collapsed:t.collapsed===!0}}catch{return uN}}function L8(e){try{localStorage.setItem(I8,JSON.stringify(e))}catch{}}function Ope(){const{jobId:e}=gc({from:"/jobs/$jobId"}),t=As(),{jobs:n,refresh:r}=Iv(),{snapshots:s}=Ic(),a=n.find(w=>w.id===e),l=Dr(),c=Qm()?.id,u=a?.sessionId!==void 0&&(s.find(w=>w.host.id===c)?.sessions.some(w=>w.id===a.sessionId)??!1),[h,m]=y.useState(!1);y.useEffect(()=>{n.length>0&&m(!0)},[n.length]),y.useEffect(()=>{!h||a||(un.error("That job is no longer in the queue"),t({to:"/jobs"}))},[h,a,t]);const[p]=y.useState(Cv),[b]=y.useState(qp),[x]=y.useState(wv),[v]=y.useState(O8);if(!a)return null;const N=d.jsx(dN,{job:a,onChanged:()=>void r()});return!l||!u||!a.sessionId?d.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[N,d.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 p-8 text-center",children:[d.jsx("p",{className:"text-body-sm text-fg-3",children:a.sessionId?"This job’s session is no longer on the gateway.":"This job never got as far as a session."}),d.jsx("p",{className:"max-w-md text-label text-fg-4",children:"The queue keeps the job record — status, usage, error — but the transcript lives with the session, and that one has been closed or swept."})]})]}):d.jsx(M8,{client:l,sessionId:a.sessionId,readOnly:!0,transcriptVariant:b,transcriptDensity:p,transcriptFont:x,scrubber:!0,stickyPrompt:!0,statusPlacement:"bottom",defaultRailWidth:v.width,defaultRailCollapsed:v.collapsed,onRailChange:L8,header:({actions:w})=>d.jsx(dN,{job:a,onChanged:()=>void r(),actions:w})},a.sessionId)}function dN({job:e,onChanged:t,actions:n}){const r=_8[e.status],s=e.status==="queued"||e.status==="running"||e.status==="parked",a=async()=>{try{await Dr().cancelJob(e.id),t()}catch(l){un.error(l instanceof Error?l.message:"Cancel failed")}};return d.jsxs(Ov,{crumbs:[{label:"Jobs",to:"/jobs"},{label:e.prompt}],actions:d.jsxs(d.Fragment,{children:[d.jsx(En,{variant:"neutral",className:"shrink-0",children:"read-only"}),d.jsx(Sd,{value:e.id,"aria-label":"Copy job id"}),s?d.jsxs(tt,{variant:"outline",size:"xs",onClick:()=>void a(),children:[d.jsx(_s,{className:"size-3"}),"Cancel"]}):null,n]}),children:[d.jsxs(En,{variant:r.variant,dot:!r.busy,className:"shrink-0",children:[r.busy?d.jsx(Tn,{className:"size-3 text-current"}):null,r.label]}),d.jsxs("div",{className:"flex min-w-0 items-center gap-x-3 font-mono text-label text-fg-4",children:[d.jsx("span",{className:"truncate",children:e.cwd}),e.profile?d.jsxs("span",{className:"shrink-0",children:["@",e.profile]}):null,d.jsx("span",{className:"shrink-0",children:kc(e.finishedAt??e.startedAt??e.createdAt)}),e.maxAttempts!==void 0&&e.maxAttempts>1?d.jsxs("span",{className:"shrink-0",children:["attempt ",e.attempt??1,"/",e.maxAttempts,e.status==="queued"&&e.nextRunAt!==void 0&&e.nextRunAt>Date.now()?" — retry pending":""]}):null,e.usage.tokens>0?d.jsxs("span",{className:"shrink-0",children:[Gr(e.usage.tokens)," tok"]}):null,e.usage.totalCostUsd>0?d.jsx("span",{className:"shrink-0",children:Js(e.usage.totalCostUsd)}):null,e.error?d.jsx("span",{className:"truncate text-danger",children:e.error}):null]})]})}const Lpe=["web_search","download","web_fetch","deliver_file"],Gh=e=>e.split(",").map(t=>t.trim()).filter(Boolean);function ma({label:e,children:t}){return d.jsxs("label",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[d.jsx("span",{className:"text-label font-medium text-fg-3",children:e}),t]})}function jpe({profile:e,onSaved:t}){const n=e.engine==="provider",[r,s]=y.useState(e.description??""),[a,l]=y.useState(e.defaults?.model??""),[c,u]=y.useState(e.defaults?.permissionMode),[h,m]=y.useState(e.provider?.model??""),[p,b]=y.useState((e.provider?.models??[]).join(", ")),[x,v]=y.useState(e.session?.capabilities),[N,w]=y.useState((e.session?.mcpServers??[]).join(", ")),[S,C]=y.useState(e.session?.instructions??""),[A,R]=y.useState(!1),M=C8(e,c??"default",a),_=M.models.map(j=>j.value==="default"?{...j,displayName:"Unset",description:e.defaultModel??"whatever the engine's own config picks"}:j),I=async()=>{const j={description:r.trim()||void 0,defaults:{model:a.trim()||void 0,permissionMode:c}};n&&(j.provider={...e.provider,id:e.provider?.id??"",model:h.trim()||void 0,models:Gh(p).length>0?Gh(p):void 0},j.session={capabilities:x,mcpServers:Gh(N).length>0?Gh(N):void 0,instructions:S.trim()||void 0}),R(!0);try{t(await Dr().updateProfile(e.name,j)),un.success("Profile saved")}catch(z){un.error(z instanceof Error?z.message:"Failed to save profile")}finally{R(!1)}};return d.jsxs(bo,{children:[d.jsx(xo,{children:d.jsx(yo,{children:"Edit profile"})}),d.jsxs(vo,{className:"flex flex-col gap-3",children:[d.jsx(ma,{label:"Description",children:d.jsx(Zt,{value:r,onChange:j=>s(j.target.value)})}),d.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[d.jsx(ma,{label:"Default model",children:_.length>1?d.jsx(k8,{value:a,onChange:l,models:_}):d.jsx(Zt,{value:a,onChange:j=>l(j.target.value),placeholder:"unset — request / engine default",className:"font-mono"})}),d.jsx(ma,{label:"Default permission mode",children:d.jsx(yv,{variant:"form",mode:c,onModeChange:u,modes:M.modes})})]}),n?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[d.jsx(ma,{label:"Default model id",children:d.jsx(Zt,{value:h,onChange:j=>m(j.target.value),className:"font-mono"})}),d.jsx(ma,{label:"Models offered (comma-separated)",children:d.jsx(Zt,{value:p,onChange:j=>b(j.target.value),className:"font-mono"})})]}),d.jsx(ma,{label:"Capabilities granted",children:d.jsxs("div",{className:"flex flex-wrap items-center gap-3 py-1.5",children:[d.jsxs("label",{className:"flex cursor-pointer items-center gap-1.5 text-body-sm text-fg-2",children:[d.jsx("input",{type:"checkbox",checked:x===void 0,onChange:j=>v(j.target.checked?void 0:[]),className:"size-3.5 accent-(--color-fg-1)"}),"not declared"]}),Lpe.map(j=>d.jsxs("label",{className:"flex cursor-pointer items-center gap-1.5 text-body-sm text-fg-2",children:[d.jsx("input",{type:"checkbox",disabled:x===void 0,checked:x?.includes(j)??!1,onChange:z=>v(P=>z.target.checked?[...P??[],j]:(P??[]).filter(F=>F!==j)),className:"size-3.5 accent-(--color-fg-1) disabled:opacity-40"}),d.jsx("code",{className:"font-mono text-label",children:j})]},j))]})}),d.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[d.jsx(ma,{label:"MCP servers (names, comma-separated)",children:d.jsx(Zt,{value:N,onChange:j=>w(j.target.value),className:"font-mono"})}),d.jsx(ma,{label:"Instructions",children:d.jsx(Zt,{value:S,onChange:j=>C(j.target.value)})})]})]}):null,d.jsxs("div",{className:"flex items-center justify-between gap-3",children:[d.jsx("p",{className:"text-label text-fg-4",children:"Name and engine are fixed — sessions and jobs are pinned to the name, and the engine decides what the rest of these fields mean."}),d.jsxs(tt,{onClick:()=>void I(),disabled:A,children:[A?d.jsx(Tn,{className:"size-3.5 text-current"}):d.jsx(TV,{className:"size-4"}),"Save"]})]})]})]})}function Dpe(e){window.location.href=`vscode://file${e}`}function Ppe(){return d.jsx("div",{className:"flex flex-1 items-center justify-center p-8",children:d.jsx(Wr,{icon:d.jsx(T2,{}),title:"No profile selected",description:"A profile is what a session runs as — its config directory and credentials, or a model provider."})})}function Bn({label:e,children:t}){return d.jsxs("div",{className:"flex items-baseline justify-between gap-4 py-1.5",children:[d.jsx("span",{className:"shrink-0 text-label font-medium text-fg-3",children:e}),d.jsx("span",{className:"min-w-0 text-right text-body-sm text-fg-1",children:t})]})}function ga({items:e,empty:t}){return e.length===0?d.jsx("span",{className:"text-fg-4",children:t}):d.jsx("span",{className:"flex flex-wrap justify-end gap-1",children:e.map(n=>d.jsx(En,{variant:"neutral",children:n},n))})}function Bpe(){const{profileName:e}=gc({from:"/profiles/$profileName"}),t=As(),{refresh:n}=Mv(),[r,s]=y.useState(),[a,l]=y.useState();y.useEffect(()=>{let p=!0;const b=()=>{Dr()?.getProfile(e).then(v=>{p&&s(v)}).catch(v=>{p&&l(v instanceof Error?v.message:"Failed to load profile")})};b();const x=setInterval(b,6e4);return()=>{p=!1,clearInterval(x)}},[e]);const c=r?.profile,u=r?.config,h=y.useMemo(()=>Q_(c?.usage),[c?.usage]),m=async()=>{try{await Dr().deleteProfile(e),await n(),un.success(`Profile '${e}' deleted`),t({to:"/profiles"})}catch(p){un.error(p instanceof Error?p.message:"Delete failed")}};return d.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[d.jsx(Ov,{crumbs:[{label:"Profiles",to:"/profiles"},{label:e}],actions:d.jsxs(d.Fragment,{children:[c?.configDir?d.jsxs(tt,{variant:"outline",size:"xs",onClick:()=>Dpe(c.configDir),children:[d.jsx(g2,{className:"size-3"}),"Open in VSCode"]}):null,c?.managed?d.jsxs(tt,{variant:"outline",size:"xs",onClick:()=>void m(),children:[d.jsx(Dd,{className:"size-3"}),"Delete"]}):null]}),children:c?.description?d.jsx("span",{className:"min-w-0 truncate text-label text-fg-4",children:c.description}):null}),d.jsxs(A8,{children:[a?d.jsx("div",{className:"rounded-md bg-danger-bg px-3 py-2 text-body-sm text-danger",children:a}):null,!r&&!a?d.jsx(Tn,{className:"mx-auto size-5 text-fg-4"}):null,c&&u?d.jsxs(d.Fragment,{children:[d.jsxs(bo,{children:[d.jsx(xo,{children:d.jsx(yo,{children:"Worker defaults"})}),d.jsxs(vo,{className:"flex flex-col divide-y divide-border",children:[d.jsx(Bn,{label:"Engine",children:d.jsx(En,{variant:"neutral",children:c.engine??"claude"})}),c.engine==="provider"?d.jsx(Bn,{label:"Provider",children:d.jsx("span",{className:"font-mono text-label",children:c.provider?.id})}):d.jsx(Bn,{label:"Config directory",children:d.jsx("span",{className:"font-mono text-label",children:c.configDir})}),d.jsx(Bn,{label:"Default model",children:c.defaults?.model??c.provider?.model??d.jsx("span",{className:"text-fg-4",children:"request / engine default"})}),d.jsx(Bn,{label:"Default permission mode",children:c.defaults?.permissionMode??d.jsx("span",{className:"text-fg-4",children:"request / engine default"})}),c.engine==="provider"?d.jsxs(d.Fragment,{children:[d.jsx(Bn,{label:"Models offered",children:d.jsx(ga,{items:c.provider?.models??[],empty:"the default model only"})}),d.jsx(Bn,{label:"API key variable",children:c.provider?.apiKeyEnv?d.jsx("span",{className:"font-mono text-label",children:c.provider.apiKeyEnv}):d.jsx("span",{className:"text-fg-4",children:"provider SDK default"})})]}):null]})]}),h.length>0?d.jsxs(bo,{children:[d.jsx(xo,{children:d.jsx(yo,{children:"Plan usage"})}),d.jsx(vo,{children:d.jsx(XI,{windows:h})})]}):null,c.engine==="provider"?d.jsxs(bo,{children:[d.jsx(xo,{children:d.jsx(yo,{children:"Session grants"})}),d.jsxs(vo,{className:"flex flex-col divide-y divide-border",children:[d.jsx(Bn,{label:"Capabilities",children:d.jsx(ga,{items:c.session?.capabilities??[],empty:"not declared — whatever the server wired"})}),d.jsx(Bn,{label:"MCP servers",children:d.jsx(ga,{items:c.session?.mcpServers??[],empty:"not declared — every connected server"})}),d.jsx(Bn,{label:"Instructions",children:c.session?.instructions?`${c.session.instructions.length} characters`:d.jsx("span",{className:"text-fg-4",children:"none"})})]})]}):null,c.engine==="provider"?null:d.jsxs(bo,{children:[d.jsx(xo,{children:d.jsx(yo,{children:"Claude Code configuration"})}),d.jsxs(vo,{className:"flex flex-col divide-y divide-border",children:[u.settings?d.jsxs(d.Fragment,{children:[d.jsx(Bn,{label:"Model (settings.json)",children:u.settings.model??d.jsx("span",{className:"text-fg-4",children:"not set"})}),d.jsx(Bn,{label:"Default permission mode",children:u.settings.defaultPermissionMode??d.jsx("span",{className:"text-fg-4",children:"not set"})}),d.jsx(Bn,{label:"Permission rules",children:d.jsx("span",{className:"font-mono text-label",children:u.settings.permissionRules?`${u.settings.permissionRules.allow} allow · ${u.settings.permissionRules.ask} ask · ${u.settings.permissionRules.deny} deny`:"—"})}),d.jsx(Bn,{label:"Env vars (names only)",children:d.jsx(ga,{items:u.settings.envKeys??[],empty:"none"})}),d.jsx(Bn,{label:"Hooks",children:d.jsx(ga,{items:u.settings.hooks??[],empty:"none"})})]}):d.jsx(Bn,{label:"settings.json",children:d.jsx("span",{className:"text-fg-4",children:"not found"})}),d.jsx(Bn,{label:"User memory (CLAUDE.md)",children:u.hasUserMemory?"present":d.jsx("span",{className:"text-fg-4",children:"none"})}),d.jsx(Bn,{label:"Skills",children:d.jsx(ga,{items:u.skills,empty:"none"})}),d.jsx(Bn,{label:"Agents",children:d.jsx(ga,{items:u.agents,empty:"none"})}),d.jsx(Bn,{label:"Commands",children:d.jsx(ga,{items:u.commands,empty:"none"})})]})]}),c.managed?d.jsx(jpe,{profile:c,onSaved:p=>s({...r,profile:p})}):null,d.jsxs("p",{className:"text-label text-fg-4",children:[c.managed?"Stored on the server and editable here. ":"View only — this profile is declared in the server options. ","Other profile configuration lives on the server (the"," ",d.jsx("code",{className:"font-mono",children:"profiles"})," option; for Claude profiles, the config directory itself, e.g. via VSCode). Provider credentials are resolved from the server's environment and never leave it."]})]}):null]})]})}function zpe(){const{hostId:e,sessionId:t}=gc({from:"/sessions/$hostId/$sessionId"}),{ready:n}=Av(),r=As(),s=tc(e);return y.useEffect(()=>{!n||s||(un.error("That gateway is not configured here"),r({to:"/sessions"}))},[n,s,r]),s?d.jsx(Hpe,{hostId:e,sessionId:t,client:s},`${e}:${t}`):null}function Hpe({hostId:e,sessionId:t,client:n}){const r=As(),{subagent:s,sn:a}=by({from:"/sessions/$hostId/$sessionId"}),{info:l,error:c}=nA(n,t),u=Nhe(e,t),[h]=y.useState(()=>whe(e,t)),[m]=y.useState(Cv),[p]=y.useState(qp),[b]=y.useState(wv),[x]=y.useState(O8);y.useEffect(()=>{c&&(un.error("Session not found"),r({to:"/sessions"}))},[c,r]);const[v,N]=y.useState(()=>!document.hidden);y.useEffect(()=>{const R=()=>N(!document.hidden);return document.addEventListener("visibilitychange",R),()=>document.removeEventListener("visibilitychange",R)},[]);const{snapshots:w}=Ic(),S=y.useMemo(()=>w.find(R=>R.host.id===e)?.sessions.find(R=>R.id===t),[w,e,t]);y.useEffect(()=>{!S||!v||u({activity:S.activityCount,turns:S.numTurns})},[S?.activityCount,S?.numTurns,v,u]);const C=async()=>{try{await n.deleteSession(t)}catch{}r({to:"/sessions"})},A=l?.cwd?.split("/").filter(Boolean).pop();return d.jsx(M8,{client:n,sessionId:t,transcriptVariant:p,transcriptDensity:m,transcriptFont:b,openSubagent:s?{toolUseId:s,nonce:a??0}:void 0,scrubber:!0,stickyPrompt:!0,statusPlacement:"bottom",controlsSurface:"status",defaultRailWidth:x.width,defaultRailCollapsed:x.collapsed,onRailChange:L8,unseen:h,onVitals:R=>{u({itemCount:R.itemCount}),Ihe()},header:({actions:R})=>d.jsxs("div",{className:"flex items-center gap-2 border-b border-border bg-surface px-3 py-2",children:[d.jsx("span",{className:"truncate text-body-sm font-medium text-fg-1",children:l?.title??A??t.slice(0,8)}),l?.engine&&l.engine!=="claude"?d.jsx(En,{variant:"neutral",className:"shrink-0",children:l.engine}):null,l?.cwd?d.jsx("span",{className:"min-w-0 truncate font-mono text-label text-fg-4",title:l.cwd,children:l.cwd}):null,d.jsx("span",{className:"flex-1"}),d.jsx(Sd,{value:t,"aria-label":"Copy session id"}),d.jsxs(nY,{children:[d.jsx(rY,{render:d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":"Close session",children:d.jsx(Dd,{className:"size-4 text-fg-3"})})}),d.jsxs(iY,{children:[d.jsx(aY,{children:"Close this session?"}),d.jsx(oY,{children:"The run is terminated on the server. You can pick it up later from “Resume a previous session” — the transcript is kept by the engine, not by the gateway."}),d.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[d.jsx(sY,{render:d.jsx(tt,{variant:"outline",children:"Cancel"})}),d.jsx(tt,{variant:"destructive",onClick:()=>void C(),children:"Close session"})]})]})]}),R]})},t)}const vs=I9({component:ope}),Upe=Rs({getParentRoute:()=>vs,path:"/",beforeLoad:()=>{throw Qp({to:"/sessions"})}}),Fpe=Rs({getParentRoute:()=>vs,path:"/sessions",component:spe}),$pe=Rs({getParentRoute:()=>vs,path:"/sessions/$hostId/$sessionId",component:zpe,validateSearch:e=>({subagent:typeof e.subagent=="string"?e.subagent:void 0,sn:typeof e.sn=="number"?e.sn:void 0})}),Vpe=Rs({getParentRoute:()=>vs,path:"/sessions/$sessionId",beforeLoad:({params:e})=>{throw Qp({to:"/sessions/$hostId/$sessionId",params:{hostId:l8,sessionId:e.sessionId},search:{}})}}),qpe=Rs({getParentRoute:()=>vs,path:"/gateways",component:cpe}),Ype=Rs({getParentRoute:()=>vs,path:"/gateways/$hostId",component:lpe}),Gpe=Rs({getParentRoute:()=>vs,path:"/jobs",component:Khe}),Kpe=Rs({getParentRoute:()=>vs,path:"/jobs/$jobId",component:Ope}),Wpe=Rs({getParentRoute:()=>vs,path:"/profiles",component:Ppe}),Xpe=Rs({getParentRoute:()=>vs,path:"/profiles/$profileName",component:Bpe}),Qpe=Rs({getParentRoute:()=>vs,path:"/settings",beforeLoad:()=>{throw Qp({to:"/sessions"})}}),Zpe=q9({routeTree:vs.addChildren([Upe,Fpe,$pe,Vpe,qpe,Ype,Gpe,Kpe,Wpe,Xpe,Qpe]),history:Xj()});function Jpe(){return d.jsxs(d.Fragment,{children:[d.jsx(K9,{router:Zpe}),d.jsx(NG,{})]})}pN();const j8=document.getElementById("root");if(!j8)throw new Error("Root element #root not found");nj.createRoot(j8).render(d.jsx(y.StrictMode,{children:d.jsx(Jpe,{})}));const eme=Object.freeze(Object.defineProperty({__proto__:null,Mermaid:oI},Symbol.toStringTag,{value:"Module"}));export{Nle as A,rme as L,Zr as R,fc as _,d as j,y as r};
|
|
1203
|
+
`).find(h=>h.trim()!==""):void 0;l=d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"term-scrub-ex","data-tone":t.kind==="error"||t.kind==="toolFailed"?"red":"fg",children:[t.kind==="user"?d.jsx("span",{"data-tone":"dim",children:"❯ "}):null,ffe(c)]}),u?d.jsx("div",{className:"term-scrub-ex","data-tone":"red",children:u}):null]})}}return d.jsxs(d.Fragment,{children:[d.jsxs("div",{"data-tone":"faint",children:[dfe[t?.kind??e.kind],a]}),l]})}function mfe(e){const{scrollOffset:t,viewportH:n,totalSize:r,onJumpToRow:s,interactive:a,fontSize:l,lineHeight:c}=e,u=Xm(),h=y.useRef(null),m=y.useRef(null),[p,b]=y.useState(0),[x,v]=y.useState(null),N=y.useRef(null);y.useEffect(()=>{const F=h.current;if(!F)return;const V=new ResizeObserver(()=>b(F.clientHeight));return V.observe(F),b(F.clientHeight),()=>V.disconnect()},[]);const[w,S]=y.useState(t);y.useEffect(()=>{const F=u.scrollRef.current;if(!F)return;const V=()=>S(F.scrollTop);return F.addEventListener("scroll",V,{passive:!0}),S(F.scrollTop),()=>F.removeEventListener("scroll",V)},[u.scrollRef]),y.useEffect(()=>{v(null)},[e.items]),y.useEffect(()=>{if(!a)return;const F=h.current;if(!F)return;const V=G=>{const K=u.scrollRef.current;K&&(K.scrollTop+=G.deltaY,G.preventDefault())};return F.addEventListener("wheel",V,{passive:!1}),()=>F.removeEventListener("wheel",V)},[a,u.scrollRef]),y.useLayoutEffect(()=>{const F=m.current;if(!F||!x)return;const V=F.offsetHeight,G=h.current?.clientHeight??0;F.style.top=`${Math.max(4,Math.min(G-V-4,x.y-V/2))}px`},[x]);const C=y.useMemo(()=>p>0?hfe(e,p):[],[e.items,e.bookmarks,e.recapRow,e.pendingApprovals,r,p,n]),A=qI(p,r,n),R=Math.max(2,Math.min(p,Math.round(n*A))),M=Math.max(0,Math.min(p-R,Math.round(w*A))),_=F=>{const V=h.current,G=u.scrollRef.current;if(!V||!G)return;const K=V.getBoundingClientRect(),Y=Math.min(1,Math.max(0,(F-K.top)/K.height));G.scrollTop=Y*G.scrollHeight-G.clientHeight/2},I=F=>F-(h.current?.getBoundingClientRect().top??0),j=(F,V)=>{if(F.kind==="approval"&&F.marks.length===0){u.scrollToBottom();return}const G=D4(F,I(V));G&&s(G.rowIndex)},z=(F,V)=>{const G=I(V),K=D4(F,G);v(Y=>Y&&Y.cluster===F&&Y.mark===K?Y:{cluster:F,mark:K,y:Math.min(Math.max(G,F.y),F.y+F.h)})},P=Math.max(1,r-n);return d.jsx(Mc,{fontSize:l,lineHeight:c,className:"term-scrubber","data-interactive":a||void 0,...a?{role:"scrollbar","aria-orientation":"vertical","aria-label":"Transcript overview","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.min(100,Math.max(0,Math.round(w/P*100)))}:{"aria-hidden":!0},children:d.jsxs("div",{ref:h,className:"term-scrubber-body",...a?{onPointerDown:F=>{u.stopScroll(),N.current={y:F.clientY,moved:!1,target:F.target},F.currentTarget.setPointerCapture(F.pointerId)},onPointerMove:F=>{const V=N.current;V&&(!V.moved&&Math.abs(F.clientY-V.y)<3||(V.moved=!0,v(null),_(F.clientY)))},onPointerUp:F=>{const V=N.current;if(N.current=null,!V||V.moved)return;const G=V.target?.closest?.("[data-ci]"),K=G?Number(G.dataset.ci):Number.NaN;Number.isInteger(K)&&C[K]?j(C[K],F.clientY):_(F.clientY)}}:null,children:[d.jsx("div",{className:"term-scrub-band",style:{top:M,height:R}}),C.map((F,V)=>d.jsx("div",{"data-ci":V,className:"term-scrub-mark","data-lane":F.lane,"data-kind":F.kind,style:{top:F.y,height:F.h},...a?{onPointerEnter:G=>z(F,G.clientY),onPointerMove:G=>{N.current||z(F,G.clientY)},onPointerLeave:()=>v(null)}:null},V)),x?d.jsx("div",{ref:m,className:"term-scrub-peek",style:{top:x.y},children:pfe(x.cluster,x.mark,e)}):null]})})}function z4(e){if(e){if("item"in e)return e.item;if("run"in e)return e.run[0];if("task"in e)return e.task}}function Qx(e,t){const n=z4(e[t-1]),r=z4(e[t]);return!n||!r?!0:fue(n,r)}const H4=new WeakMap;function gfe(e){const t=H4.get(e);if(t)return t;const n=new Map;return e.forEach((r,s)=>{if("task"in r)for(const a of r.childIndices)n.set(a,s)}),H4.set(e,n),n}function U4(e,t){const n=gfe(e).get(t);if(n!==void 0)return n;let r=0,s=e.length-1,a=0;for(;r<=s;){const l=r+s>>1,c=e[l];let u;if("index"in c)u=c.index;else{const h=e[l+1];u=h&&"index"in h?h.index:Number.MAX_SAFE_INTEGER}u<=t?("index"in c&&(a=l),r=l+1):s=l-1}return a}const F4=new WeakMap;function bfe(e){const t=F4.get(e);if(t)return t;const n=new Map;for(const r of e)if("task"in r){const s=r.childIndices.length;r.childIndices.forEach((a,l)=>n.set(a,{ordinal:l,count:s}))}else if("run"in r&&r.run.length>1){const s=r.run.length;r.indices.forEach((a,l)=>n.set(a,{ordinal:l,count:s}))}return F4.set(e,n),n}function xfe(e,t){return bfe(e).get(t)}function yfe(e){const{terminal:t,fontSize:n,lineHeight:r,rowsRef:s}=e,[a,l]=y.useState(null);return y.useEffect(()=>{if(!t)return;const c=s.current;if(!c)return;let u;const h=()=>{const p=Number.parseFloat(getComputedStyle(c).getPropertyValue("--term-line")),b=c.clientWidth,x=Qde(c);!p||!b||!x||l(v=>v&&v.width===b&&v.ch===x&&v.line===p?v:Kde(b,x,p))},m=new ResizeObserver(()=>{clearTimeout(u),u=setTimeout(h,150)});return m.observe(c),h(),()=>{m.disconnect(),clearTimeout(u)}},[t,n,r,s]),a}const $4=4,V4=50;function vfe(e){const{rows:t,terminal:n,stickyPrompt:r,epoch:s,promptRows:a,scrollElement:l,rowsRef:c,virtualizer:u,stick:h,jumpToRecapRef:m,repinRef:p}=e,b=y.useRef(void 0);y.useEffect(()=>()=>clearTimeout(b.current),[]);const x=(v,N="center")=>{if(v<0||v>=t.length||!l)return;if(h.stopScroll(),clearTimeout(b.current),N==="start"){const S=R=>n&&s&&R>0&&Qx(t,R)?s.line:0,C=()=>{const R=u.measurementsCache[v]?.start??0,M=c.current?c.current.getBoundingClientRect().top-l.getBoundingClientRect().top+l.scrollTop:0;let _=R+M+S(v);return n&&r&&s&&!a.includes(v)&&a.some(j=>j<v)&&(_-=s.line),Math.round(_)},A=R=>{const M=C();l.scrollTo({top:M,behavior:"instant"}),!(R>=$4)&&(b.current=setTimeout(()=>{Math.abs(l.scrollTop-C())>1&&A(R+1)},V4))};A(0);return}const w=S=>{const C=l.querySelector(`[data-index="${v}"]`);if(C){C.scrollIntoView({behavior:"instant",block:N});return}S>=$4||(u.scrollToIndex(v,{align:N,behavior:"auto"}),b.current=setTimeout(()=>w(S+1),V4))};w(0)};return y.useEffect(()=>{if(m)return m.current=()=>{x(t.findIndex(v=>v.key==="recap"),"start")},()=>{m.current=null}}),y.useEffect(()=>{if(p)return p.current=()=>{h.scrollToBottom("instant")},()=>{p.current=null}}),x}function GI({item:e,fileUrl:t}){switch(e.kind){case"user":return d.jsx(gue,{item:e});case"assistant_text":return d.jsx(bue,{item:e});case"thinking":return d.jsx(xue,{item:e});case"tool_call":return d.jsx(kI,{item:e});case"turn_result":return d.jsx(Eue,{item:e});case"notice":return d.jsx(Tue,{item:e});case"file_delivered":return d.jsx(Sue,{item:e,href:t?.(e.path)});default:return null}}function KI({text:e,terminal:t}){const[n,r]=y.useState(!1);return t?d.jsx("div",{"data-slot":"brief",children:d.jsx(Gm,{onPress:()=>r(s=>!s),expanded:n,children:d.jsx(_t,{glyph:">",glyphTone:"blue",tone:"dim",children:d.jsx("span",{className:ve("whitespace-pre-wrap",!n&&"term-brief-clip"),style:n?void 0:{WebkitLineClamp:zI},children:e})})})}):d.jsx("div",{"data-slot":"brief",className:"px-4 py-2 text-body-sm whitespace-pre-wrap text-fg-2",children:e})}function Efe({block:e,fileUrl:t,onOpenSubagent:n}){const[r,s]=y.useState(!1),a=xv(r),l=y.useMemo(()=>SI(e),[e]),c=l.some(b=>b.kind==="user")?void 0:xI(e.task),u=Km(e.task,l),h=vI(e.task),m=zd(u),p=d.jsxs("div",{ref:a,className:r?"term-open":void 0,children:[d.jsx(Gm,{onPress:()=>s(b=>!b),expanded:r,children:d.jsx(_t,{glyph:u?m:"●",glyphTone:h?"red":u?"mark":"dim",tone:h?"red":"green",children:EI(e.task,l)})}),r?d.jsxs("div",{className:"term-nested",children:[c?d.jsx(KI,{text:c,terminal:!0}):null,e.children.map((b,x)=>d.jsxs(y.Fragment,{children:[x>0&&hue(e.children[x-1],b)?d.jsx(Gs,{}):null,"run"in b?d.jsx(CI,{items:b.run}):d.jsx(GI,{item:b.item,fileUrl:t})]},b.key))]}):null]});return n===void 0?p:d.jsx(Mm,{actions:d.jsx(SX,{onOpen:()=>n(e.task.id)}),children:p})}function Tfe({item:e}){return d.jsxs("div",{"data-slot":"turn-result",className:"py-1",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("div",{className:"h-px flex-1 bg-border"}),d.jsxs("span",{className:ve("font-mono text-label",e.isError?"text-danger":"text-fg-4"),children:[e.isError?e.subtype:"turn done"," · ",Sc(e.durationMs)," ·"," ",Js(e.totalCostUsd)]}),d.jsx("div",{className:"h-px flex-1 bg-border"})]}),e.errors?.length?d.jsx("ul",{className:"mt-1 flex flex-col gap-0.5 text-center",children:e.errors.map((t,n)=>d.jsx("li",{className:"text-label break-words text-danger",children:t},n))}):null]})}function Sfe({item:e}){return d.jsx("div",{"data-slot":"notice",className:ve("rounded-md border px-3 py-2 text-body-sm",e.level==="error"?"border-transparent bg-danger-bg text-danger":"border-border bg-surface text-fg-3"),children:e.text})}function kfe({item:e,fileUrl:t,attachmentUrl:n,hostImage:r,terminal:s}){if(s)return d.jsx(GI,{item:e,fileUrl:t});switch(e.kind){case"user":return d.jsxs(O4,{from:"user",children:[e.attachments?.length?d.jsx(_fe,{attachments:e.attachments,attachmentUrl:n}):null,e.text?d.jsx(L4,{children:d.jsx(Pde,{text:e.text})}):null]});case"assistant_text":return d.jsx(O4,{from:"assistant",children:d.jsx(L4,{children:d.jsx(BI,{streaming:e.streaming,children:e.text})})});case"thinking":return d.jsx(Bde,{isStreaming:e.id==="streaming-thinking",children:e.text});case"tool_call":return d.jsx(qde,{item:e,hostImage:r});case"turn_result":return d.jsx(Tfe,{item:e});case"notice":return d.jsx(Sfe,{item:e});case"file_delivered":return d.jsx(Dde,{item:e,href:t?.(e.path)});default:return null}}function Cfe({line:e,since:t,terminal:n}){const r=t===void 0?void 0:kc(t),s=r?`${e} · last here ${r}`:e;return n?d.jsx("div",{"data-slot":"recap",children:d.jsxs(_t,{glyph:"※",glyphTone:"faint",tone:"faint",children:["recap: ",s]})}):d.jsxs("div",{"data-slot":"recap",className:"flex items-center gap-2 py-1",children:[d.jsx("div",{className:"h-px flex-1 bg-border"}),d.jsxs("span",{className:"font-mono text-label text-fg-3",children:["※ recap: ",s]}),d.jsx("div",{className:"h-px flex-1 bg-border"})]})}function wfe(e){const t=e==="running"||e==="starting",[n,r]=y.useState(void 0);return y.useEffect(()=>{r(s=>t?s??Date.now():void 0)},[t]),t?n:void 0}function Nfe(e){if(e.status!=="running"&&e.status!=="starting")return!1;const t=e.items.at(-1);return t?t.kind==="assistant_text"&&t.streaming||t.kind==="thinking"&&t.id==="streaming-thinking"?!1:t.kind!=="turn_result"||e.status==="running":!0}function _fe({attachments:e,attachmentUrl:t}){return d.jsx("div",{className:"mb-1 flex flex-wrap justify-start gap-1.5",children:e.map(n=>{const r=t?.(n.id);return n.mediaType.startsWith("image/")&&r?d.jsx("img",{src:r,alt:n.name,className:"size-20 rounded-md border border-border object-cover"},n.id):d.jsx("span",{className:"rounded-full border border-border bg-surface px-2.5 py-1 text-body-xs text-fg-3",children:n.name},n.id)})})}function Afe({active:e,fontSize:t,lineHeight:n,affordances:r,children:s}){return e?d.jsx(Mc,{fontSize:t,lineHeight:n,affordances:r,bleed:"1ch",className:"term-transcript",children:s}):d.jsx(d.Fragment,{children:s})}function Ab(e,t){return e!==void 0&&t<e}function Rfe(e,t){const n="parentToolUseId"in e?e.parentToolUseId:void 0;return n!=null&&n!==t?"border-l-2 border-border pl-3":void 0}function Mfe({top:e,height:t,gapClass:n,scrollRoot:r,index:s,measureRef:a,content:l}){const c=y.useRef(null),u=y.useRef(null);return y.useEffect(()=>{const h=c.current,m=u.current;if(!h||!m||!r)return;const p=new IntersectionObserver(([b])=>{if(!b)return;const x=!b.isIntersecting&&b.boundingClientRect.top<(b.rootBounds?.top??0);h.toggleAttribute("data-stuck",x)},{root:r});return p.observe(m),()=>p.disconnect()},[r]),d.jsxs("div",{"data-sticky-lane":"",className:"absolute inset-x-0",style:{top:e,height:t},children:[d.jsx("div",{"data-sticky-headlane":"","aria-hidden":!0,children:d.jsx("div",{ref:c,"data-sticky-head":"",className:n||void 0,children:l})}),d.jsx("div",{ref:u,"aria-hidden":!0,className:"absolute left-0 w-px",style:{top:n?"var(--term-line)":0,height:1}}),d.jsx("div",{ref:a,"data-index":s,className:n||void 0,children:l})]})}function Ife({rows:e,boundary:t,since:n,terminal:r,replaying:s,stickyPrompt:a,frameParentId:l,onOpenSubagent:c,gap:u,fontSize:h,lineHeight:m,items:p,pendingApprovals:b,scrubber:x,scrubberMarks:v,affordances:N,fileUrl:w,attachmentUrl:S,hostImage:C,jumpToRecapRef:A,repinRef:R,reveal:M}){const _=Xm(),[I,j]=y.useState(null),z=y.useMemo(()=>e.flatMap((B,L)=>"item"in B&&B.item.kind==="user"&&Ks(B.item)===void 0?[L]:[]),[e]),P=y.useRef({enabled:!1,promptRows:[]});P.current={enabled:r&&a,promptRows:z},y.useEffect(()=>{j(_.scrollRef.current)},[_.scrollRef]),y.useEffect(()=>{if(!I)return;let B=I.clientHeight;const L=new ResizeObserver(()=>{const te=I.clientHeight;te!==B&&(B=te,_.state.isAtBottom&&_.scrollToBottom("instant"))});return L.observe(I),()=>L.disconnect()},[I,_]);const F=y.useRef(s);y.useLayoutEffect(()=>{const B=F.current;F.current=s,!(!B||s)&&_.state.isAtBottom&&(_.state.scrollTop=_.state.calculatedTargetScrollTop)},[s,_]);const V=y.useRef(null),G=yfe({terminal:r,fontSize:h,lineHeight:m,rowsRef:V}),K=wde({count:e.length,getScrollElement:()=>(I&&K.scrollElement!==I&&(K.scrollOffset=I.scrollTop),I),estimateSize:B=>{if(r&&G){const L=e[B],te=B>0&&Qx(e,B)?G.line:0;return L&&"text"in L&&L.key==="brief"?Xde(L.text,G)+te:L&&!("line"in L)?Wde(L,G)+te:G.line+te}return(r?36:100)+u.px},overscan:8,getItemKey:B=>e[B].key,rangeExtractor:y.useCallback(B=>{const L=new Set(jI(B)),{enabled:te,promptRows:ne}=P.current;if(te){const de=K.scrollOffset??0;let oe=-1;for(const le of ne)if((K.measurementsCache[le]?.start??1/0)<=de)oe=le;else break;oe>=0&&L.add(oe)}return[...L].sort((de,oe)=>de-oe)},[]),useFlushSync:!0});K.shouldAdjustScrollPositionOnItemSizeChange=(B,L,te)=>{if(_.state.isAtBottom)return!1;const ne=(te.scrollOffset??0)+te.scrollAdjustments;return te.itemSizeCache.has(B.key)?B.end<=ne&&te.scrollDirection!=="backward":B.start<ne},y.useEffect(()=>{if(!r||!G)return;K.measure();const B=V.current;if(B){K.getTotalSize();for(const L of B.querySelectorAll("[data-index]")){const te=Number(L.getAttribute("data-index"));Number.isInteger(te)&&te>=0&&K.resizeItem(te,L.getBoundingClientRect().height)}}},[r,G,K]);const Y=vfe({rows:e,terminal:r,stickyPrompt:a,epoch:G,promptRows:z,scrollElement:I,rowsRef:V,virtualizer:K,stick:_,jumpToRecapRef:A,repinRef:R}),U=M?.nonce,Q=M?.toolUseId;y.useEffect(()=>{if(Q===void 0)return;const B=p.findIndex(L=>L.kind==="tool_call"&&L.id===Q);B<0||Y(U4(e,B),"start")},[U]);const W=cA(N).hover,ue=e.findIndex(B=>B.key==="recap"),D=ue>=0?{rowIndex:ue,label:e[ue].line}:void 0;y.useEffect(()=>{if(!(!r||!x||!W||!I))return I.setAttribute("data-term-scrubber-host",""),()=>I.removeAttribute("data-term-scrubber-host")},[r,x,W,I]);const H=K.measurementsCache;return d.jsxs("div",{ref:V,"data-slot":"transcript-rows",className:"relative w-full",style:{height:K.getTotalSize()},children:[K.getVirtualItems().map(B=>{const L=e[B.index],te=B.index>0&&(!r||Qx(e,B.index))?u.className:void 0,ne="run"in L?d.jsx("div",{className:ve(Ab(t,L.index)&&"opacity-45"),children:d.jsx(CI,{items:L.run})}):"item"in L?d.jsx("div",{className:ve(Ab(t,L.index)&&"opacity-45",Rfe(L.item,l)),children:d.jsx(kfe,{item:L.item,fileUrl:w,attachmentUrl:S,hostImage:C,terminal:r})}):"text"in L&&L.key==="brief"?d.jsx(KI,{text:L.text,terminal:r}):"line"in L?d.jsx(Cfe,{line:L.line,since:n,terminal:r}):d.jsx("div",{className:ve(Ab(t,L.index)&&"opacity-45"),children:d.jsx(Efe,{block:L,fileUrl:w,onOpenSubagent:c})});if(r&&a&&"item"in L&&L.item.kind==="user"&&Ks(L.item)===void 0){const de=z.find(le=>le>B.index),oe=de===void 0?K.getTotalSize():H[de]?.start??B.start;return d.jsx(Mfe,{top:B.start,height:Math.max(oe-B.start,0),gapClass:te,scrollRoot:I,index:B.index,measureRef:K.measureElement,content:ne},L.key)}return d.jsx("div",{ref:K.measureElement,"data-index":B.index,className:ve("absolute inset-x-0 top-0",te),style:{transform:`translateY(${B.start}px)`},children:ne},L.key)}),r&&x&&I?.parentElement?ir.createPortal(d.jsx(mfe,{items:p,pendingApprovals:b,recapRow:D,bookmarks:v??[],frameParentId:l,rowIndexFor:B=>U4(e,B),positionInRow:B=>xfe(e,B),offsetOfRow:B=>K.measurementsCache[B]?.start??0,sizeOfRow:B=>K.measurementsCache[B]?.size??0,totalSize:K.getTotalSize(),scrollOffset:K.scrollOffset??0,viewportH:K.scrollRect?.height??0,onJumpToRow:B=>Y(B,"start"),interactive:W,fontSize:h,lineHeight:m}),I.parentElement):null]})}function Ofe({state:e,fileUrl:t,attachmentUrl:n,canBrowseFiles:r,hostImage:s,variant:a="cards",density:l="comfortable",fontSize:c,lineHeight:u,affordances:h,stickyPrompt:m=!1,scrubber:p,scrubberMarks:b,replaying:x=!1,catchUp:v,jumpToRecapRef:N,repinRef:w,reveal:S,frame:C,onOpenSubagent:A,className:R}){const M=a==="terminal",_=y.useMemo(()=>C?TI(e.items,C.parentToolUseId):e.items,[e.items,C]),I=y.useMemo(()=>C?e.items.find(K=>K.kind==="tool_call"&&K.id===C.parentToolUseId):void 0,[e.items,C]),j=dX[a][l],z=wfe(e.status),P=!C&&v&&v.from>0&&v.from<e.items.length?v.from:void 0,F=y.useMemo(()=>P===void 0?void 0:lX(oX(e,P)),[e,P]),V=y.useMemo(()=>C&&I&&!_.some(K=>K.kind==="user")?xI(I):void 0,[C,I,_]),G=y.useMemo(()=>{const K=(U,Q)=>due(_.slice(U,Q),U,M),Y=V?[{key:"brief",text:V}]:[];return P===void 0||!F?[...Y,...K(0,_.length)]:[...K(0,P),{key:"recap",line:F},...K(P,_.length)]},[_,P,F,M,V]);return d.jsx(iA,{value:a,children:d.jsxs(Ode,{className:ve(x&&"invisible",R),children:[d.jsx(Lde,{className:ve(M&&"gap-0 p-0"),children:d.jsxs(Afe,{active:M,fontSize:c,lineHeight:u,affordances:h,children:[C?I===void 0&&!x?d.jsx("div",{className:ve(M?"term-row text-fg-4":"p-4 text-body-sm text-fg-4"),children:"This sub-agent's work is not in this transcript."}):null:_.length===0&&e.status!=="starting"?d.jsx(zde,{cwd:e.cwd,hasCommands:!!e.commands?.length,hasSkills:!!e.skills?.some(K=>K.enabled),canBrowseFiles:r}):null,C&&I===void 0&&!x?null:d.jsx(Ife,{rows:G,boundary:P,since:v?.since,terminal:M,replaying:x,stickyPrompt:!C&&m,gap:j,fontSize:c,lineHeight:u,items:_,pendingApprovals:e.pendingApprovals,scrubber:p,scrubberMarks:C?void 0:b,affordances:h,fileUrl:t,attachmentUrl:n,hostImage:s,jumpToRecapRef:N,repinRef:w,reveal:C?void 0:S,frameParentId:C?.parentToolUseId,onOpenSubagent:C?void 0:A}),(C?I!==void 0&&Km(I,_):Nfe(e))?M?d.jsxs(d.Fragment,{children:[e.items.length>0?d.jsx("div",{className:"term-blank","aria-hidden":!0}):null,d.jsx(T4,{label:e.status==="starting"?"Starting…":"Working…",startedAt:z,tokens:e.contextUsage?.totalTokens})]}):d.jsx(I4,{label:e.status==="starting"?"Starting session…":void 0,startedAt:z,tokens:e.contextUsage?.totalTokens}):null]})}),d.jsx(jde,{}),x?d.jsx("div",{"data-slot":"transcript-hold","aria-hidden":!0,className:"wd-hold-appear visible pointer-events-none absolute inset-0 overflow-hidden",children:d.jsx("div",{className:ve("mx-auto w-full max-w-[var(--wd-content-max-w,48rem)]",!M&&"px-4 py-4"),children:M?d.jsx(Mc,{fontSize:c,lineHeight:u,affordances:!1,bleed:"1ch",className:"term-transcript",children:d.jsx(T4,{label:"Loading…"})}):d.jsx(I4,{label:"Loading session…"})})}):null]})})}function WI(e=!0){const[t,n]=y.useState(()=>Date.now());return y.useEffect(()=>{if(!e)return;n(Date.now());const r=setInterval(()=>n(Date.now()),6e4);return()=>clearInterval(r)},[e]),t}const Lfe=e=>e>=90?"bg-danger":e>=70?"bg-warning":"bg-accent";function XI({windows:e,now:t,className:n}){const r=WI(t===void 0),s=t??r;return d.jsx("div",{className:ve("flex flex-col gap-5",n),children:e.map(a=>d.jsx(jfe,{window:a,now:s},a.key))})}function jfe({window:e,now:t}){const{key:n,info:r,updatedAt:s,inferredReset:a}=e,l=r.utilization??0,c=r.resetsAt!==void 0?r.resetsAt*1e3:void 0,u=hX(n),h=c!==void 0?(c-t)/1e3:void 0,m=u!==void 0&&h!==void 0&&h>0&&h<u?(u-h)/u:void 0;return d.jsxs("div",{children:[d.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[d.jsx("span",{className:"truncate text-body-sm text-fg-1",children:fX(n)}),d.jsxs("span",{className:ve("shrink-0 font-mono text-body-sm font-medium",r.status==="rejected"?"text-danger":"text-fg-1"),children:[l.toFixed(0),"% used"]})]}),d.jsxs("div",{className:"relative mt-2 h-2 rounded-full bg-border",children:[d.jsx("div",{className:ve("h-full rounded-full",Lfe(l)),style:{width:`${Math.min(100,Math.max(2,l))}%`}}),m!==void 0?d.jsx("span",{"aria-hidden":!0,title:"Spent evenly, usage would be here by now",className:"absolute -top-1 h-4 w-0.5 -translate-x-1/2 rounded-full bg-fg-1",style:{left:`${Math.min(100,Math.max(0,m*100))}%`}}):null]}),d.jsxs("div",{className:"mt-1.5 flex items-center gap-3 text-label text-fg-4",children:[c!==void 0?d.jsxs("span",{className:"inline-flex items-center gap-1",children:[d.jsx(mV,{className:"size-3"})," Resets in ",xx(c,t)]}):null,r.isUsingOverage?d.jsx("span",{className:"text-warning",children:"overage"}):null,r.status==="rejected"?d.jsx("span",{className:"text-danger",children:"limit reached"}):null,a?d.jsx("span",{children:"window reset · nothing reported since"}):null,s&&!a?d.jsx("span",{children:aA(s,t)}):null]})]})}function Dfe({rateLimits:e,subscriptionType:t,engine:n,totalCostUsd:r,updatedAt:s,open:a,onOpenChange:l}){const c=WI(a);return d.jsx(gs,{open:a,onOpenChange:l,children:d.jsxs(bs,{children:[d.jsx(xs,{title:"Usage",description:n==="claude"?"Claude Code":n,actions:t?d.jsx(En,{variant:"accent",className:"mt-0.5 shrink-0 capitalize",children:t}):null}),d.jsxs(ys,{children:[e.length===0?d.jsx("p",{className:"py-6 text-center text-body-sm text-fg-4",children:n==="claude"?"This session reports no plan windows — API-key sessions have none, and a subscription session reports them once a turn has run.":`Plan windows are a claude.ai subscription thing; this session runs on the ${n} engine.`}):d.jsx(XI,{windows:e,now:c}),d.jsxs("div",{className:"mt-5 flex items-baseline justify-between gap-4 border-t border-border pt-3",children:[d.jsx("span",{className:"text-label text-fg-3",children:"This session has cost"}),d.jsx("span",{className:"font-mono text-body-sm text-fg-1",children:Js(r)})]}),s?d.jsxs("p",{className:"mt-2 text-label text-fg-4",children:["Updated ",aA(s,c)]}):null]})]})})}function Pfe({terminal:e,metrics:t,affordances:n,children:r}){return e?d.jsx(Mc,{fontSize:t?.fontSize,lineHeight:t?.lineHeight,affordances:n,bleed:"1ch",className:"term-transcript",children:r}):d.jsx("div",{className:"mx-auto flex w-full max-w-[var(--wd-content-max-w,48rem)] flex-col gap-2",children:r})}const Bfe=["button","a","input","textarea","select","summary","img",'[contenteditable="true"]','[role="button"]','[role="menuitem"]','[role="checkbox"]','[role="radio"]','[role="tab"]'].join(",");function zfe({client:e,sessionId:t,header:n,panelSurface:r="internal",statusSurface:s="internal",statusPlacement:a="top",onOpenPanel:l,onVitals:c,transcriptVariant:u="cards",transcriptDensity:h="comfortable",transcriptFont:m="sans",affordances:p,terminalMetrics:b,scrubber:x=!1,scrubberMarks:v,reveal:N,openSubagent:w,stickyPrompt:S=!1,controlsSurface:C="internal",onControls:A,focusComposerOnClick:R=!1,unseen:M,readOnly:_=!1,toolHost:I,cacheTranscript:j,className:z}){const P=r==="external",F=s==="external",V=C==="status"&&!F,G=C==="external"||V,[K,Y]=y.useState(void 0),[U,Q]=y.useState(),[W,ue]=y.useState(void 0),[D,H]=y.useState(void 0),{state:B,connection:L,replaying:te,protocolMismatch:ne,models:de,effectiveModel:oe,handle:le,send:ge,approve:Pe,deny:Le,interrupt:Se,setModel:Oe,setPermissionMode:He,reconnectNow:We,loadFullResult:Ge}=IW(e,t,{onProtocolError:Y,cacheTranscript:j});y.useEffect(()=>Y(void 0),[t]),y.useEffect(()=>{ue(void 0),H(void 0)},[t]);const De=w?.nonce,we=w?.toolUseId;y.useEffect(()=>{we!==void 0&&ue(we)},[De]);const Te=N?.nonce;y.useEffect(()=>{Te!==void 0&&ue(void 0)},[Te]);const Ie=y.useCallback(()=>{ue(qe=>{qe!==void 0&&H({toolUseId:qe,nonce:Date.now()})})},[]);y.useEffect(()=>{if(W===void 0)return;const qe=cn=>{cn.key!=="Escape"||cn.defaultPrevented||Ie()};return window.addEventListener("keydown",qe),()=>window.removeEventListener("keydown",qe)},[W,Ie]);const[Be,ee]=y.useState(!1);y.useEffect(()=>{ee(!1)},[t]);const[me]=y.useState(M),se=Be?void 0:me,ie=se?Math.max(0,B.items.length-se.itemCount):0,Z=y.useCallback(qe=>{P?l?.(qe):Q(qe)},[P,l]);y.useEffect(()=>{const qe=()=>{document.visibilityState==="visible"&&We()};return document.addEventListener("visibilitychange",qe),()=>document.removeEventListener("visibilitychange",qe)},[We]),aX(le,I===!1?{enabled:!1}:I);const q=u==="terminal",ce=y.useMemo(()=>W===void 0?[]:TI(B.items,W),[B.items,W]),Ce=y.useMemo(()=>W===void 0?void 0:B.items.find(qe=>qe.kind==="tool_call"&&qe.id===W),[B.items,W]),Re=y.useMemo(()=>{const qe=B.session?.subagents?.find(cn=>cn.toolUseId===W);return qe?fx(qe):"Sub-agent"},[B.session,W]),Ue=B.capabilities,{usage:at}=JW(e,B.session?.profile,{enabled:Ue.rateLimits}),Qe=y.useMemo(()=>aW({rateLimits:B.rateLimits,updatedAt:B.rateLimitsUpdatedAt},at),[B.rateLimits,B.rateLimitsUpdatedAt,at]),ct=y.useMemo(()=>Object.keys(Qe).length>0?oW(Qe):void 0,[Qe]),dt=y.useMemo(()=>{const qe=Object.values(Qe).map(cn=>cn.updatedAt);return qe.length>0?Math.max(...qe):void 0},[Qe]),Ye=y.useRef(c);Ye.current=c;const St=oe??B.model,Mt=y.useMemo(()=>Vue(Ue.permissionModes,B.session?.canBypassPermissions),[Ue.permissionModes,B.session?.canBypassPermissions]);y.useEffect(()=>{Ye.current?.({status:B.status,connection:L,engine:B.engine,capabilities:B.capabilities,model:St,models:de,permissionMode:B.permissionMode,permissionModes:Mt,cwd:B.cwd,contextUsage:B.contextUsage,rateLimits:ct,itemCount:B.items.length})},[B.status,L,B.engine,B.capabilities,St,de,B.permissionMode,Mt,B.cwd,B.contextUsage,ct,B.items.length]);const ot=y.useRef(A);ot.current=A;const Tt=y.useRef({setModel:Oe,setPermissionMode:He,interrupt:Se});Tt.current={setModel:Oe,setPermissionMode:He,interrupt:Se};const Gt=y.useRef({setModel:qe=>Tt.current.setModel(qe),setPermissionMode:qe=>Tt.current.setPermissionMode(qe),interrupt:()=>Tt.current.interrupt(),focusComposer:()=>xt.current?.focus()});y.useEffect(()=>{const qe=ot.current;return qe?.(Gt.current),()=>qe?.(void 0)},[t]);const Vt=B.status==="running"||B.status==="awaiting_approval",qt=B.status==="failed"||B.status==="closed",Xe=DW(e,t,{capabilities:Ue,engine:B.engine}),gt=tA(e,B.cwd),Ut=y.useMemo(()=>Q_(Qe),[Qe]),Kt=Hfe(e,t,B.producedFiles),Un=sue(e,t),xt=y.useRef(null),Jt=y.useRef(null),Jn=y.useRef(null),fn=y.useMemo(()=>{if(B.commands)return B.commands.some(qe=>qe.name==="model")?B.commands:[{name:"model",description:"Switch the model for this session",argumentHint:"<model>"},...B.commands]},[B.commands]),Sn=(qe,cn)=>{if(cn.length===0){const es=/^\/model\s+(\S+)$/.exec(qe);if(es){Oe(es[1]);return}if(Ue.mcpStatus&&qe.trim()==="/mcp"){Z("mcp");return}}ee(!0),Jn.current?.(),ge(qe,cn)},ft=d.jsxs(MY,{children:[d.jsx(IY,{render:d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":"Session actions",children:d.jsx(FU,{className:"size-4"})})}),d.jsxs(OY,{children:[Ue.contextUsage?d.jsxs(jl,{onClick:()=>Z("context"),children:[d.jsx(XH,{className:"size-3.5 text-fg-3"})," Context"]}):null,Ue.rateLimits?d.jsxs(jl,{onClick:()=>Z("usage"),children:[d.jsx(X6,{className:"size-3.5 text-fg-3"})," Usage"]}):null,d.jsxs(jl,{onClick:()=>Z("info"),children:[d.jsx(zF,{className:"size-3.5 text-fg-3"})," Session info"]}),Ue.mcpStatus?d.jsxs(jl,{onClick:()=>Z("mcp"),children:[d.jsx(Tm,{className:"size-3.5 text-fg-3"})," MCP servers"]}):null,Ue.skillsList?d.jsxs(jl,{onClick:()=>Z("skills"),children:[d.jsx(jd,{className:"size-3.5 text-fg-3"})," Skills"]}):null,gt.available?d.jsxs(jl,{onClick:()=>Z("files"),children:[d.jsx(lF,{className:"size-3.5 text-fg-3"})," Project files"]}):null]})]}),kt=P?null:ft,hn=typeof n=="function",An=d.jsxs(d.Fragment,{children:[de.length?d.jsx(RI,{models:de,model:oe,onModelChange:Oe,disabled:qt,className:V?"h-5":void 0}):null,B.permissionMode?d.jsx(yv,{mode:B.permissionMode,onModeChange:He,modes:Ue.permissionModes,canBypass:B.session?.canBypassPermissions,disabled:qt,className:V?"h-5":void 0}):null]}),kn=F?null:d.jsx(ude,{state:B,rateLimits:ct,connection:L,placement:a,controls:V&&!_?An:void 0,onOpenStatus:P&&!l?void 0:()=>Z("info"),onOpenContext:P&&!l?void 0:()=>Z("context"),onOpenUsage:P&&!l?void 0:()=>Z("usage"),actions:hn?void 0:kt}),Wt=qe=>{!R||_||qe.target?.closest(Bfe)||window.getSelection()?.isCollapsed!==!1&&xt.current?.focus()};return d.jsx(iA,{value:u,children:d.jsx(uX,{value:h,children:d.jsx(Zce,{value:Ge,children:d.jsx(eue,{value:Un,children:d.jsxs("div",{"data-slot":"session-panel","data-agent-font":m,onClick:Wt,className:ve("flex h-full min-h-0 flex-col overflow-hidden bg-bg",z),children:[hn?n({actions:kt}):n,a==="top"?kn:null,ne!==void 0?d.jsxs(q4,{level:"warning",children:["Server speaks protocol v",ne,", this build renders v",Z_,". Some events may not render."]}):null,K?d.jsx(q4,{level:"error",onDismiss:()=>Y(void 0),children:K}):null,W!==void 0?d.jsx(Yue,{task:Ce,items:ce,label:Re,onBack:Ie,terminal:q,fontSize:b?.fontSize,lineHeight:b?.lineHeight}):null,d.jsx(Ofe,{state:B,fileUrl:t?qe=>e.sessionFileUrl(t,qe):void 0,attachmentUrl:t?qe=>e.attachmentUrl(t,qe):void 0,canBrowseFiles:gt.available,hostImage:Kt,variant:u,density:h,fontSize:b?.fontSize,lineHeight:b?.lineHeight,affordances:p,stickyPrompt:S,scrubber:x,scrubberMarks:v,replaying:te,catchUp:se&&ie>0?{from:se.itemCount,since:se.since}:void 0,reveal:D??N,frame:W===void 0?void 0:{parentToolUseId:W},onOpenSubagent:ue,jumpToRecapRef:Jt,repinRef:Jn},W??"session"),se&&ie>0&&!te&&W===void 0?d.jsx("div",{className:"px-3 pb-1",children:d.jsxs("div",{"data-slot":"catch-up",className:"mx-auto flex w-full max-w-[var(--wd-content-max-w,48rem)] items-center gap-2 text-label text-fg-3",children:[d.jsx("span",{"aria-hidden":!0,className:ve("select-none",q?"text-fg-3":"text-accent"),children:"※"}),d.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[ie," new ",ie===1?"row":"rows",se.since!==void 0?" since you were last here":""]}),d.jsx("button",{type:"button",onClick:()=>Jt.current?.(),className:"shrink-0 underline-offset-2 hover:text-fg-1 hover:underline",children:"jump"}),d.jsx("button",{type:"button",onClick:()=>ee(!0),className:"shrink-0 underline-offset-2 hover:text-fg-1 hover:underline",children:"dismiss"})]})}):null,!_&&Ue.interactiveApprovals&&B.pendingApprovals.length>0?d.jsx("div",{className:ve(q?"pb-2":"px-3 pb-2"),children:d.jsx(Pfe,{terminal:q,metrics:b,affordances:p,children:B.pendingApprovals.map(qe=>{const cn=qe.toolName==="AskUserQuestion"&&vv(qe.input).length>0;return q?cn?d.jsx(ede,{request:qe,onAnswer:Pe,onDismiss:es=>Le(es,"Question dismissed by user")},qe.id):d.jsx(Jue,{request:qe,onApprove:Pe,onDeny:Le},qe.id):cn?d.jsx(Gue,{request:qe,onAnswer:Pe,onDismiss:es=>Le(es,"Question dismissed by user")},qe.id):d.jsx(que,{request:qe,onApprove:Pe,onDeny:Le},qe.id)})})}):null,_||W!==void 0?null:d.jsx(Cue,{ref:xt,onSend:Sn,onInterrupt:Se,busy:Vt,disabled:qt||!t,commands:Ue.slashCommands?fn:void 0,skills:Ue.skillsList?B.skills:void 0,attachments:Xe,onSearchFiles:gt.available?(qe,cn)=>gt.search(qe,{...cn,limit:8}):void 0,layout:G?"inline":"stacked",toolbar:G?void 0:An,fontSize:b?.fontSize,lineHeight:b?.lineHeight,affordances:p}),a==="bottom"?kn:null,P?null:d.jsxs(d.Fragment,{children:[d.jsx(rde,{state:B,client:e,sessionId:t,open:U==="info",onOpenChange:qe=>Q(qe?"info":void 0)}),d.jsx(Rue,{usage:B.contextUsage,open:U==="context",onOpenChange:qe=>Q(qe?"context":void 0)}),d.jsx(Dfe,{rateLimits:Ut,subscriptionType:B.subscriptionType,engine:B.engine??"claude",totalCostUsd:B.totalCostUsd,updatedAt:dt,open:U==="usage",onOpenChange:qe=>Q(qe?"usage":void 0)}),d.jsx(Oue,{client:e,sessionId:t,canManageServers:Ue.mcpServerActions,open:U==="mcp",onOpenChange:qe=>Q(qe?"mcp":void 0)}),d.jsx(Bue,{skills:B.skills,open:U==="skills",onOpenChange:qe=>Q(qe?"skills":void 0),onUse:qe=>xt.current?.insertText(NI(qe))}),d.jsx(Mue,{client:e,cwd:B.cwd,open:U==="files",onOpenChange:qe=>Q(qe?"files":void 0)})]})]})})})})})}function Hfe(e,t,n){const r=y.useRef(new Map),s=y.useRef([]);return y.useEffect(()=>()=>{for(const a of s.current)URL.revokeObjectURL(a);s.current=[]},[]),y.useCallback(a=>{const l=n?.[a],c=l?`produced:${l.fileId}`:`fs:${a}`,u=r.current.get(c);if(u)return u;const h=l&&t?e.readProducedFile(t,l.fileId).then(m=>{if(m.size===0)return;const p=URL.createObjectURL(m);return s.current.push(p),p}).catch(()=>{}):e.readHostFile(a).then(m=>{if(m.encoding!=="base64")return;const p=a.slice(a.lastIndexOf(".")+1).toLowerCase(),b=Ufe[p];return b?`data:${b};base64,${m.content}`:void 0}).catch(()=>{});return r.current.set(c,h),h},[e,t,n])}const Ufe={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp"};function q4({level:e,onDismiss:t,children:n}){return d.jsx("div",{className:"px-3 pt-2",children:d.jsxs("div",{role:"alert",className:ve("mx-auto flex w-full max-w-[var(--wd-content-max-w,48rem)] items-start gap-2 rounded-md border px-3 py-2 text-body-sm",e==="error"?"border-danger/40 bg-danger-bg text-danger":"border-warning/40 bg-warning-bg text-warning"),children:[d.jsx(Jl,{className:"mt-0.5 size-3.5 shrink-0"}),d.jsx("span",{className:"min-w-0 flex-1 break-words",children:n}),t?d.jsx("button",{type:"button",onClick:t,"aria-label":"Dismiss",className:"shrink-0 opacity-70 transition-opacity hover:opacity-100",children:d.jsx(_s,{className:"size-3.5"})}):null]})})}function Ffe({usage:e,size:t=11,className:n}){return e===void 0?null:d.jsx("span",{title:`Context ${e.percentage.toFixed(0)}% · ${Gr(e.totalTokens)} / ${Gr(e.maxTokens)}`,className:ve("shrink-0 leading-none",OI(e.percentage),n),children:d.jsx(N2,{value:e.percentage,size:t,strokeWidth:2})})}const $fe={claude:{title:"Claude",d:"M4.709 15.955l4.72-2.647.08-.23-.08-.128H9.2l-.79-.048-2.698-.073-2.339-.097-2.266-.122-.571-.121L0 11.784l.055-.352.48-.321.686.06 1.52.103 2.278.158 1.652.097 2.449.255h.389l.055-.157-.134-.098-.103-.097-2.358-1.596-2.552-1.688-1.336-.972-.724-.491-.364-.462-.158-1.008.656-.722.881.06.225.061.893.686 1.908 1.476 2.491 1.833.365.304.145-.103.019-.073-.164-.274-1.355-2.446-1.446-2.49-.644-1.032-.17-.619a2.97 2.97 0 01-.104-.729L6.283.134 6.696 0l.996.134.42.364.62 1.414 1.002 2.229 1.555 3.03.456.898.243.832.091.255h.158V9.01l.128-1.706.237-2.095.23-2.695.08-.76.376-.91.747-.492.584.28.48.685-.067.444-.286 1.851-.559 2.903-.364 1.942h.212l.243-.242.985-1.306 1.652-2.064.73-.82.85-.904.547-.431h1.033l.76 1.129-.34 1.166-1.064 1.347-.881 1.142-1.264 1.7-.79 1.36.073.11.188-.02 2.856-.606 1.543-.28 1.841-.315.833.388.091.395-.328.807-1.969.486-2.309.462-3.439.813-.042.03.049.061 1.549.146.662.036h1.622l3.02.225.79.522.474.638-.079.485-1.215.62-1.64-.389-3.829-.91-1.312-.329h-.182v.11l1.093 1.068 2.006 1.81 2.509 2.33.127.578-.322.455-.34-.049-2.205-1.657-.851-.747-1.926-1.62h-.128v.17l.444.649 2.345 3.521.122 1.08-.17.353-.608.213-.668-.122-1.374-1.925-1.415-2.167-1.143-1.943-.14.08-.674 7.254-.316.37-.729.28-.607-.461-.322-.747.322-1.476.389-1.924.315-1.53.286-1.9.17-.632-.012-.042-.14.018-1.434 1.967-2.18 2.945-1.726 1.845-.414.164-.717-.37.067-.662.401-.589 2.388-3.036 1.44-1.882.93-1.086-.006-.158h-.055L4.132 18.56l-1.13.146-.487-.456.061-.746.231-.243 1.908-1.312-.006.006z"},codex:{title:"OpenAI",d:"M9.205 8.658v-2.26c0-.19.072-.333.238-.428l4.543-2.616c.619-.357 1.356-.523 2.117-.523 2.854 0 4.662 2.212 4.662 4.566 0 .167 0 .357-.024.547l-4.71-2.759a.797.797 0 00-.856 0l-5.97 3.473zm10.609 8.8V12.06c0-.333-.143-.57-.429-.737l-5.97-3.473 1.95-1.118a.433.433 0 01.476 0l4.543 2.617c1.309.76 2.189 2.378 2.189 3.948 0 1.808-1.07 3.473-2.76 4.163zM7.802 12.703l-1.95-1.142c-.167-.095-.239-.238-.239-.428V5.899c0-2.545 1.95-4.472 4.591-4.472 1 0 1.927.333 2.712.928L8.23 5.067c-.285.166-.428.404-.428.737v6.898zM12 15.128l-2.795-1.57v-3.33L12 8.658l2.795 1.57v3.33L12 15.128zm1.796 7.23c-1 0-1.927-.332-2.712-.927l4.686-2.712c.285-.166.428-.404.428-.737v-6.898l1.974 1.142c.167.095.238.238.238.428v5.233c0 2.545-1.974 4.472-4.614 4.472zm-5.637-5.303l-4.544-2.617c-1.308-.761-2.188-2.378-2.188-3.948A4.482 4.482 0 014.21 6.327v5.423c0 .333.143.571.428.738l5.947 3.449-1.95 1.118a.432.432 0 01-.476 0zm-.262 3.9c-2.688 0-4.662-2.021-4.662-4.519 0-.19.024-.38.047-.57l4.686 2.71c.286.167.571.167.856 0l5.97-3.448v2.26c0 .19-.07.333-.237.428l-4.543 2.616c-.619.357-1.356.523-2.117.523zm5.899 2.83a5.947 5.947 0 005.827-4.756C22.287 18.339 24 15.84 24 13.296c0-1.665-.713-3.282-1.998-4.448.119-.5.19-.999.19-1.498 0-3.401-2.759-5.947-5.946-5.947-.642 0-1.26.095-1.88.31A5.962 5.962 0 0010.205 0a5.947 5.947 0 00-5.827 4.757C1.713 5.447 0 7.945 0 10.49c0 1.666.713 3.283 1.998 4.448-.119.5-.19 1-.19 1.499 0 3.401 2.759 5.946 5.946 5.946.642 0 1.26-.095 1.88-.309a5.96 5.96 0 004.162 1.713z"},gemini:{title:"Gemini",d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z"},deepseek:{title:"DeepSeek",d:"M23.748 4.482c-.254-.124-.364.113-.512.234-.051.039-.094.09-.137.136-.372.397-.806.657-1.373.626-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.352-.156-.708-.311-.955-.65-.172-.241-.219-.51-.305-.774-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434 1.202-.422 1.84.027 1.436.633 2.58 1.838 3.393.137.093.172.187.129.323-.082.28-.18.552-.266.833-.055.179-.137.217-.329.14a5.526 5.526 0 01-1.736-1.18c-.857-.828-1.631-1.742-2.597-2.458a11.365 11.365 0 00-.689-.471c-.985-.957.13-1.743.388-1.836.27-.098.093-.432-.779-.428-.872.004-1.67.295-2.687.684a3.055 3.055 0 01-.465.137 9.597 9.597 0 00-2.883-.102c-1.885.21-3.39 1.102-4.497 2.623C.082 8.606-.231 10.684.152 12.85c.403 2.284 1.569 4.175 3.36 5.653 1.858 1.533 3.997 2.284 6.438 2.14 1.482-.085 3.133-.284 4.994-1.86.47.234.962.327 1.78.397.63.059 1.236-.03 1.705-.128.735-.156.684-.837.419-.961-2.155-1.004-1.682-.595-2.113-.926 1.096-1.296 2.746-2.642 3.392-7.003.05-.347.007-.565 0-.845-.004-.17.035-.237.23-.256a4.173 4.173 0 001.545-.475c1.396-.763 1.96-2.015 2.093-3.517.02-.23-.004-.467-.247-.588zM11.581 18c-2.089-1.642-3.102-2.183-3.52-2.16-.392.024-.321.471-.235.763.09.288.207.486.371.739.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.167-1.361-.802-2.5-1.86-3.301-3.307-.774-1.393-1.224-2.887-1.298-4.482-.02-.386.093-.522.477-.592a4.696 4.696 0 011.529-.039c2.132.312 3.946 1.265 5.468 2.774.868.86 1.525 1.887 2.202 2.891.72 1.066 1.494 2.082 2.48 2.914.348.292.625.514.891.677-.802.09-2.14.11-3.054-.614zm1-6.44a.306.306 0 01.415-.287.302.302 0 01.2.288.306.306 0 01-.31.307.303.303 0 01-.304-.308zm3.11 1.596c-.2.081-.399.151-.59.16a1.245 1.245 0 01-.798-.254c-.274-.23-.47-.358-.552-.758a1.73 1.73 0 01.016-.588c.07-.327-.008-.537-.239-.727-.187-.156-.426-.199-.688-.199a.559.559 0 01-.254-.078c-.11-.054-.2-.19-.114-.358.028-.054.16-.186.192-.21.356-.202.767-.136 1.146.016.352.144.618.408 1.001.782.391.451.462.576.685.914.176.265.336.537.445.848.067.195-.019.354-.25.452z"},moonshot:{title:"Moonshot",d:"M1.052 16.916l9.539 2.552a21.007 21.007 0 00.06 2.033l5.956 1.593a11.997 11.997 0 01-5.586.865l-.18-.016-.044-.004-.084-.009-.094-.01a11.605 11.605 0 01-.157-.02l-.107-.014-.11-.016a11.962 11.962 0 01-.32-.051l-.042-.008-.075-.013-.107-.02-.07-.015-.093-.019-.075-.016-.095-.02-.097-.023-.094-.022-.068-.017-.088-.022-.09-.024-.095-.025-.082-.023-.109-.03-.062-.02-.084-.025-.093-.028-.105-.034-.058-.019-.08-.026-.09-.031-.066-.024a6.293 6.293 0 01-.044-.015l-.068-.025-.101-.037-.057-.022-.08-.03-.087-.035-.088-.035-.079-.032-.095-.04-.063-.028-.063-.027a5.655 5.655 0 01-.041-.018l-.066-.03-.103-.047-.052-.024-.096-.046-.062-.03-.084-.04-.086-.044-.093-.047-.052-.027-.103-.055-.057-.03-.058-.032a6.49 6.49 0 01-.046-.026l-.094-.053-.06-.034-.051-.03-.072-.041-.082-.05-.093-.056-.052-.032-.084-.053-.061-.039-.079-.05-.07-.047-.053-.035a7.785 7.785 0 01-.054-.036l-.044-.03-.044-.03a6.066 6.066 0 01-.04-.028l-.057-.04-.076-.054-.069-.05-.074-.054-.056-.042-.076-.057-.076-.059-.086-.067-.045-.035-.064-.052-.074-.06-.089-.073-.046-.039-.046-.039a7.516 7.516 0 01-.043-.037l-.045-.04-.061-.053-.07-.062-.068-.06-.062-.058-.067-.062-.053-.05-.088-.084a13.28 13.28 0 01-.099-.097l-.029-.028-.041-.042-.069-.07-.05-.051-.05-.053a6.457 6.457 0 01-.168-.179l-.08-.088-.062-.07-.071-.08-.042-.049-.053-.062-.058-.068-.046-.056a7.175 7.175 0 01-.027-.033l-.045-.055-.066-.082-.041-.052-.05-.064-.02-.025a11.99 11.99 0 01-1.44-2.402zm-1.02-5.794l11.353 3.037a20.468 20.468 0 00-.469 2.011l10.817 2.894a12.076 12.076 0 01-1.845 2.005L.657 15.923l-.016-.046-.035-.104a11.965 11.965 0 01-.05-.153l-.007-.023a11.896 11.896 0 01-.207-.741l-.03-.126-.018-.08-.021-.097-.018-.081-.018-.09-.017-.084-.018-.094c-.026-.141-.05-.283-.071-.426l-.017-.118-.011-.083-.013-.102a12.01 12.01 0 01-.019-.161l-.005-.047a12.12 12.12 0 01-.034-2.145zm1.593-5.15l11.948 3.196c-.368.605-.705 1.231-1.01 1.875l11.295 3.022c-.142.82-.368 1.612-.668 2.365l-11.55-3.09L.124 10.26l.015-.1.008-.049.01-.067.015-.087.018-.098c.026-.148.056-.295.088-.442l.028-.124.02-.085.024-.097c.022-.09.045-.18.07-.268l.028-.102.023-.083.03-.1.025-.082.03-.096.026-.082.031-.095a11.896 11.896 0 011.01-2.232zm4.442-4.4L17.352 4.59a20.77 20.77 0 00-1.688 1.721l7.823 2.093c.267.852.442 1.744.513 2.665L2.106 5.213l.045-.065.027-.04.04-.055.046-.065.055-.076.054-.072.064-.086.05-.065.057-.073.055-.07.06-.074.055-.069.065-.077.054-.066.066-.077.053-.06.072-.082.053-.06.067-.074.054-.058.073-.078.058-.06.063-.067.168-.17.1-.098.059-.056.076-.071a12.084 12.084 0 012.272-1.677zM12.017 0h.097l.082.001.069.001.054.002.068.002.046.001.076.003.047.002.06.003.054.002.087.005.105.007.144.011.088.007.044.004.077.008.082.008.047.005.102.012.05.006.108.014.081.01.042.006.065.01.207.032.07.012.065.011.14.026.092.018.11.022.046.01.075.016.041.01L14.7.3l.042.01.065.015.049.012.071.017.096.024.112.03.113.03.113.032.05.015.07.02.078.024.073.023.05.016.05.016.076.025.099.033.102.036.048.017.064.023.093.034.11.041.116.045.1.04.047.02.06.024.041.018.063.026.04.018.057.025.11.048.1.046.074.035.075.036.06.028.092.046.091.045.102.052.053.028.049.026.046.024.06.033.041.022.052.029.088.05.106.06.087.051.057.034.053.032.096.059.088.055.098.062.036.024.064.041.084.056.04.027.062.042.062.043.023.017c.054.037.108.075.161.114l.083.06.065.048.056.043.086.065.082.064.04.03.05.041.086.069.079.065.085.071c.712.6 1.353 1.283 1.909 2.031L7.222.994l.062-.027.065-.028.081-.034.086-.035c.113-.045.227-.09.341-.131l.096-.035.093-.033.084-.03.096-.031c.087-.03.176-.058.264-.085l.091-.027.086-.025.102-.03.085-.023.1-.026L9.04.37l.09-.023.091-.022.095-.022.09-.02.098-.021.091-.02.095-.018.092-.018.1-.018.091-.016.098-.017.092-.014.097-.015.092-.013.102-.013.091-.012.105-.012.09-.01.105-.01c.093-.01.186-.018.28-.024l.106-.008.09-.005.11-.006.093-.004.1-.004.097-.002.099-.002.197-.002z"}};function Sv(e,t){if(e==="claude")return"claude";if(e==="codex")return"codex";const n=t?.toLowerCase()??"";if(n){if(n.includes("gemini"))return"gemini";if(n.includes("deepseek"))return"deepseek";if(n.includes("moonshot")||n.includes("kimi"))return"moonshot";if(n.includes("claude"))return"claude";if(n.startsWith("gpt")||n.startsWith("o1")||n.startsWith("o3")||n.includes("openai"))return"codex"}}const Vfe={claude:"text-vendor-claude",codex:"text-vendor-openai"},qfe={claude:"text-vendor-claude"};function Yfe(e,t){return Vfe[Sv(e,t)??""]??"text-fg-3"}function Gfe(e,t){return qfe[Sv(e,t)??""]??"text-fg-3"}function kv({engine:e,model:t,className:n}){const r=$fe[Sv(e,t)??""];return r?d.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",role:"img","aria-label":r.title,className:ve("size-3 shrink-0 text-fg-3",n),children:[d.jsx("title",{children:r.title}),d.jsx("path",{d:r.d})]}):d.jsx("span",{"aria-hidden":!0,title:e,className:ve("shrink-0 text-fg-3",n),children:"·"})}const Kfe={anchor:rH,atom:mH,beaker:bH,bike:EH,binary:SH,blocks:CH,bot:NH,box:AH,brain:Y6,briefcase:IH,brush:LH,bug:DH,"building-2":BH,cable:HH,camera:VH,car:YH,cat:KH,"circuit-board":uU,cloud:gU,code:g2,coffee:xU,cog:EU,compass:SU,container:CU,cpu:AU,"credit-card":MU,database:OU,diamond:jU,dog:PU,feather:VU,film:ZU,flame:eF,"flask-conical":nF,folder:Em,"gamepad-2":hF,gauge:X6,gem:gF,ghost:xF,gift:vF,"git-branch":TF,globe:ax,"graduation-cap":CF,hammer:NF,hexagon:RF,house:LF,image:Z6,key:UF,landmark:$F,laptop:qF,layers:wp,leaf:KF,library:XF,lightbulb:ZF,lock:i$,mail:o$,map:c$,"message-circle":f$,mic:g$,monitor:x$,moon:x2,mountain:E$,music:S$,network:C$,newspaper:N$,notebook:A$,orbit:M$,package:O$,palette:j$,"pen-tool":U$,phone:G$,"piggy-bank":W$,plane:Q$,plug:Tm,puzzle:n_,radar:aV,radio:lV,receipt:uV,rocket:hV,ruler:xV,satellite:vV,scale:kV,scissors:wV,server:s_,shield:jV,ship:PV,"shopping-cart":zV,signal:UV,smartphone:$V,sparkles:jd,sprout:YV,square:i_,star:rq,sun:a_,table:aq,tag:lq,target:uq,telescope:fq,terminal:Np,"test-tube":mq,"tree-pine":xq,trophy:Eq,truck:Sq,umbrella:Cq,users:_q,wallet:Rq,wand:Iq,waves:Lq,webhook:Dq,wifi:Hq,wrench:o_,zap:l_};function QI({icon:e,src:t,name:n,className:r}){if(!e)return null;if(e.type==="image")return t?d.jsx("img",{src:t,alt:"","aria-hidden":!0,title:n,className:ve("inline-block size-3 shrink-0 object-contain",r)}):null;const s=Kfe[e.name]??Em;return d.jsx(s,{className:ve("inline-block size-3 shrink-0",r)})}function Wfe(e,t){return(e.subagents??[]).map(n=>({key:n.toolUseId,label:fx(n),noun:"agent",kind:GK(n)?"agent":"task",state:Xfe(n.status),detail:n.toolCount>0?String(n.toolCount):void 0,title:`${fx(n)} · ${n.toolCount} tool${n.toolCount===1?"":"s"}`,onSelect:()=>t(n.toolUseId)}))}function Xfe(e){switch(e){case"running":return"running";case"failed":return"failed";default:return"done"}}function Qfe(e){return e.filter(t=>t.state==="running").length}function Zfe({expanded:e,running:t,total:n,noun:r,onToggle:s}){const a=t>0&&t<n?`${t}/${n}`:String(n),l=t>0&&t<n?`${t} of ${n} ${r}s running`:`${n} ${r}${n===1?"":"s"}`,c=e?m2:Tc;return d.jsxs("button",{type:"button","aria-expanded":e,"aria-label":`${e?"Hide":"Show"} ${l}`,title:`${e?"Hide":"Show"} ${l}`,onClick:u=>{u.stopPropagation(),s()},className:ve("flex shrink-0 items-center gap-0.5 rounded px-0.5 outline-none","hover:bg-surface-hover hover:text-fg-2",t>0?"text-info":"text-fg-4"),children:[d.jsx(c,{className:"size-3"}),d.jsx("span",{className:"tabular-nums",children:a})]})}function Jfe({step:e,onSelect:t}){const n=e.kind==="agent",r=e.state==="failed"?"text-danger":n?"text-success":"text-fg-4",s=d.jsxs(d.Fragment,{children:[d.jsx(ehe,{state:e.state,kind:e.kind}),d.jsx("span",{className:"min-w-0 flex-1 truncate",children:e.label}),e.detail?d.jsx("span",{className:"shrink-0 tabular-nums text-fg-4",children:e.detail}):null,n?d.jsx(cH,{className:"size-3 shrink-0 opacity-60"}):null]}),a="flex w-full items-center gap-2 border-t border-black/25 py-1 pl-3 pr-2 text-left text-label outline-none";return n?d.jsx("button",{type:"button",title:e.title,onClick:l=>{l.stopPropagation(),t()},className:ve(a,"hover:bg-surface-hover",r),children:s}):d.jsx("div",{title:e.title,onClick:l=>l.stopPropagation(),className:ve(a,r),children:s})}function ehe({state:e,kind:t}){if(t==="task"&&e!=="running"&&e!=="failed")return d.jsx(zU,{className:"size-3 shrink-0"});switch(e){case"running":return d.jsx(Tn,{className:"size-3 shrink-0"});case"failed":return d.jsx(G6,{className:"size-3 shrink-0"});case"pending":return d.jsx(K6,{className:"size-3 shrink-0"});default:return d.jsx(p2,{className:"size-3 shrink-0"})}}function ZI(e){return ve("px-2 py-1.5 hover:bg-row-hover",e?"mr-1 ml-0 rounded-r-md border-l-4 border-l-accent":"mx-1 rounded-md")}function the({rows:e,config:t,onConfigChange:n,scope:r,activeId:s,onSelect:a,onDelete:l,onRename:c,onSelectSubagent:u,emptyState:h,showControls:m=!0,projectIcons:p,className:b}){const x=y.useMemo(()=>W_(e,t,r),[e,t,r]),v=y.useMemo(()=>rW(x,t),[x,t]),N=sW(t,r,x.length,e.length),w=y.useMemo(()=>KK(e),[e]),S=y.useMemo(()=>WK(e),[e]),C=y.useMemo(()=>{const R=new Map;for(const M of e)R.set(M.hostId,M.hostName);return[...R].map(([M,_])=>({id:M,name:_}))},[e]),A=R=>n({...t,...R});return d.jsxs("div",{"data-slot":"session-browser",className:ve("flex flex-col gap-3",b),children:[d.jsxs("div",{className:ve("flex flex-col gap-1.5 px-2",!m&&"hidden"),children:[d.jsxs("div",{className:"relative",children:[d.jsx(km,{className:"pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-fg-4"}),d.jsx(Zt,{value:t.search,onChange:R=>A({search:R.target.value}),placeholder:"Search sessions","aria-label":"Search sessions",className:"pl-8"})]}),d.jsx(Hl,{label:"State",children:d.jsx(Vh,{label:"State",value:t.states,options:q_.map(R=>({value:R,label:Y_[R]})),onChange:R=>A({states:R})})}),w.length>1?d.jsx(Hl,{label:"Engine",children:d.jsx(Vh,{label:"Engine",value:t.adapters,options:w.map(R=>({value:R,label:R})),onChange:R=>A({adapters:R})})}):null,C.length>1?d.jsx(Hl,{label:"Gateway",children:d.jsx(Vh,{label:"Gateway",value:t.gateways,options:C.map(R=>({value:R.id,label:R.name})),onChange:R=>A({gateways:R})})}):null,S.length>1?d.jsx(Hl,{label:"Project",children:d.jsx(Vh,{label:"Project",value:t.projects??[],options:S.map(R=>({value:R.key,label:R.label})),onChange:R=>A({projects:R})})}):null,d.jsx(Hl,{label:"Group",children:d.jsx(G4,{label:"Group",value:t.groupBy,options:[{value:"none",label:"No grouping"},{value:"state",label:"By state"},{value:"adapter",label:"By engine"},...S.length>1?[{value:"project",label:"By project"}]:[],...C.length>1?[{value:"gateway",label:"By gateway"}]:[]],onChange:R=>A({groupBy:R})})}),d.jsx(Hl,{label:"Sort",children:d.jsx(G4,{label:"Sort",value:t.sortBy,options:[{value:"recent",label:"Recent"},{value:"name",label:"Name"},{value:"state",label:"State"},...S.length>1?[{value:"project",label:"Project"}]:[],...C.length>1?[{value:"gateway",label:"Gateway"}]:[]],onChange:R=>A({sortBy:R})})})]}),N?d.jsxs("div",{className:"flex items-center gap-2 px-3 text-label text-fg-4",children:[d.jsxs("span",{children:[N.shown," of ",N.total,N.causes.length?` · ${N.causes.join(" · ")}`:null]}),d.jsx("button",{type:"button",className:"text-fg-3 underline underline-offset-2 hover:text-fg-1",onClick:()=>n(EC(t)),children:"Show all"})]}):null,e.length===0?h??d.jsx(Wr,{icon:d.jsx(wp,{}),title:"No sessions yet"}):x.length===0?iW(t)?d.jsx(Wr,{icon:d.jsx(r_,{}),title:"No matches",description:"No session matches the current search and filters.",action:"Clear filters",onAction:()=>n(EC(t))}):d.jsx(Wr,{icon:d.jsx(wp,{}),title:"Nothing here",description:"No session to show."}):d.jsx("div",{className:"flex flex-col gap-4",children:v.map(R=>d.jsxs("div",{className:"flex flex-col gap-1",children:[t.groupBy!=="none"&&R.label?d.jsxs("div",{className:"flex items-center gap-2 px-3 text-label font-medium text-fg-4",children:[t.groupBy==="project"?d.jsx(QI,{icon:R.rows[0]?.info.project?.icon,src:JI(R.rows[0],p),name:R.label}):null,d.jsx("span",{className:"uppercase tracking-wide",children:R.label}),d.jsx("span",{className:"text-fg-4/70",children:R.rows.length})]}):null,R.rows.map(M=>d.jsx(nhe,{row:M,active:M.info.id===s,showGateway:C.length>1&&t.groupBy!=="gateway",showProject:t.groupBy!=="project",projectIcons:p,onSelect:a,onDelete:l,onRename:c,onSelectSubagent:u},`${M.hostId}:${M.info.id}`))]},R.key))})]})}function JI(e,t){const n=e?.info.project?.icon;return n?.type==="image"?t?.[n.hash]:void 0}function nhe({row:e,active:t,showGateway:n,showProject:r=!0,projectIcons:s,onSelect:a,onDelete:l,onRename:c,onSelectSubagent:u}){const{info:h}=e,[m,p]=y.useState(!1),[b,x]=y.useState(!1),v=r?A2(e):XK(e),N=r?h.project?.icon:void 0,w=h.engine??"claude",S=[v,n?e.hostName:void 0,h.profile?`@${h.profile}`:void 0,Js(h.totalCostUsd)].filter(Boolean),C=Wfe(h,R=>u?u(e,R):a?.(e)),A=v===void 0?-1:S.indexOf(v);return d.jsxs("div",{"data-slot":"session-row","data-active":t||void 0,onClick:()=>!m&&a?.(e),className:ve("group flex cursor-pointer flex-col gap-0.5 text-left transition-colors",ZI(t===!0)),children:[d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx(Y4,{children:d.jsx(e8,{row:e})}),m&&c?d.jsx(rhe,{initial:h.title??"",onCommit:R=>{p(!1),c(e,R)},onCancel:()=>p(!1)}):d.jsx("button",{type:"button",className:ve("min-w-0 flex-1 truncate text-left text-body-sm outline-none",t?"font-medium text-fg-1":"text-fg-2"),children:uc(h)}),e.unseen>0?d.jsx("span",{title:`${e.unseen} new`,className:"shrink-0 rounded-full bg-accent px-1.5 text-label text-accent-fg",children:e.unseen}):null,d.jsx("span",{className:"shrink-0 text-label text-fg-4",children:kc(h.lastActivityAt??h.createdAt)}),d.jsx(Ffe,{usage:h.contextUsage})]}),d.jsxs("div",{className:"flex items-center gap-1 text-label text-fg-4",children:[d.jsx(Y4,{children:d.jsx(kv,{engine:w,model:h.model,className:Yfe(w,h.model)})}),d.jsxs("button",{type:"button",tabIndex:-1,className:"min-w-0 flex-1 truncate text-left font-mono outline-none",children:[d.jsx("span",{className:Gfe(w,h.model),children:mX(h.model)}),S.length>0?" · ":"",A<0?S.join(" · "):d.jsxs(d.Fragment,{children:[S.slice(0,A).map(R=>`${R} · `),d.jsx(QI,{icon:N,src:JI(e,s),name:v,className:"mr-1 align-[-0.2em]"}),S.slice(A).join(" · ")]})]}),C.length>0?d.jsx(Zfe,{expanded:b,running:Qfe(C),total:C.length,noun:C[0].noun,onToggle:()=>x(R=>!R)}):null,c&&!m?d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":"Rename session",className:"size-5 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",onClick:R=>{R.stopPropagation(),p(!0)},children:d.jsx(q$,{className:"size-3 text-fg-3"})}):null,l?d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":"Close session",className:"size-5 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",onClick:R=>{R.stopPropagation(),l(e)},children:d.jsx(Dd,{className:"size-3 text-fg-3"})}):null]}),b?C.map(R=>d.jsx(Jfe,{step:R,onSelect:R.onSelect},R.key)):null]})}function Y4({children:e}){return d.jsx("span",{className:"flex w-3.5 shrink-0 items-center justify-center",children:e})}function e8({row:e}){const{info:t}=e;if(e.state==="attention")return d.jsx(yH,{className:"size-3.5 shrink-0 animate-pulse text-warning"});if(e.state==="working")return d.jsx(Tn,{className:"size-3.5 shrink-0 text-info"});switch(t.status){case"failed":return d.jsx(G6,{className:"size-3.5 shrink-0 text-danger"});case"closed":return d.jsx(lU,{className:"size-3.5 shrink-0 text-fg-4"});case"parked":return d.jsx(K6,{className:"size-3.5 shrink-0 text-fg-3"});default:return d.jsx(x2,{className:"size-3.5 shrink-0 text-fg-4"})}}function rhe({initial:e,onCommit:t,onCancel:n}){const[r,s]=y.useState(e),a=y.useRef(null);return y.useEffect(()=>{a.current?.select()},[]),d.jsx("input",{ref:a,value:r,autoFocus:!0,"aria-label":"Session name",onClick:l=>l.stopPropagation(),onChange:l=>s(l.target.value),onBlur:()=>document.hasFocus()?t(r.trim()):void 0,onKeyDown:l=>{l.key==="Enter"?t(r.trim()):l.key==="Escape"&&n(),l.stopPropagation()},className:"-my-0.5 min-w-0 flex-1 rounded-sm border border-ring bg-bg px-1 py-0.5 text-body-sm font-medium text-fg-1 outline-none"})}function Hl({label:e,children:t}){return d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{"aria-hidden":!0,className:"w-14 shrink-0 truncate text-label text-fg-3",children:e}),d.jsx("div",{className:"min-w-0 flex-1",children:t})]})}function Vh({label:e,value:t,options:n,onChange:r}){return d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsxs(Di,{multiple:!0,value:t,onValueChange:s=>r(s),children:[d.jsx(Bi,{"aria-label":e,className:"min-w-0 flex-1",children:d.jsx(Pi,{children:t.length===0?"All":t.length===1?n.find(s=>s.value===t[0])?.label??"All":`${t.length} selected`})}),d.jsx(zi,{children:n.map(s=>d.jsx(Qs,{value:s.value,children:d.jsx(Xs,{children:s.label})},s.value))})]}),t.length>0?d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":`Clear ${e}`,onClick:()=>r([]),children:d.jsx(_s,{className:"size-3 text-fg-4"})}):null]})}function G4({label:e,value:t,options:n,onChange:r}){return d.jsxs(Di,{value:t,onValueChange:s=>r(s),children:[d.jsx(Bi,{"aria-label":e,className:"w-full min-w-0",children:d.jsx(Pi,{children:n.find(s=>s.value===t)?.label??e})}),d.jsx(zi,{children:n.map(s=>d.jsx(Qs,{value:s.value,children:d.jsx(Xs,{children:s.label})},s.value))})]})}function t8(){const[e,t]=y.useState(dy());return d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":"Toggle theme",onClick:()=>t(sj()),children:e==="dark"?d.jsx(a_,{className:"size-4"}):d.jsx(x2,{className:"size-4"})})}const n8=[{value:"default",displayName:"Default (recommended)",description:"The CLI's configured default model"},{value:"fable",displayName:"Fable",description:"Fable 5 · Most capable for your hardest and longest-running tasks"},{value:"opus",displayName:"Opus",description:"Opus 5 with 1M context · Best for everyday, complex tasks"},{value:"sonnet",displayName:"Sonnet",description:"Sonnet 5 · Efficient for routine tasks"},{value:"haiku",displayName:"Haiku",description:"Haiku 4.5 · Fastest for quick answers"}],r8="workerdeck.transcript-density";function Cv(){return localStorage.getItem(r8)==="compact"?"compact":"comfortable"}function she(e){localStorage.setItem(r8,e)}const s8="workerdeck.transcript-variant";function qp(){const e=localStorage.getItem(s8);return e==="terminal"||e==="lines"?"terminal":"cards"}function ihe(e){localStorage.setItem(s8,e)}const i8="workerdeck.transcript-font";function wv(){return localStorage.getItem(i8)==="mono"?"mono":"sans"}function ahe(e){localStorage.setItem(i8,e)}function Rb({label:e,options:t,read:n,write:r,onChange:s}){const[a,l]=y.useState(n);return d.jsxs(Di,{value:a,onValueChange:c=>{l(c),r(c),s?.(c)},children:[d.jsx(Bi,{"aria-label":e,className:"min-w-40",children:d.jsx(Pi,{children:t.find(c=>c.value===a)?.label})}),d.jsx(zi,{children:t.map(c=>d.jsx(Qs,{value:c.value,children:d.jsx(Xs,{children:c.label})},c.value))})]})}function ohe({title:e,children:t}){return d.jsxs("section",{className:"flex flex-col gap-3",children:[d.jsx("h3",{className:"text-label font-medium tracking-wide text-fg-3 uppercase",children:e}),t]})}function lhe({open:e,onOpenChange:t}){const[n,r]=y.useState(qp);return d.jsx(gs,{open:e,onOpenChange:t,children:d.jsxs(bs,{size:"md",className:"w-[min(30rem,calc(100vw-2rem))]",children:[d.jsx(xs,{title:"Settings",description:"Preferences held by this browser. What a run defaults to lives on its profile; server policy lives where the gateway runs."}),d.jsx(ys,{children:d.jsx("div",{className:"flex flex-col gap-6",children:d.jsxs(ohe,{title:"Appearance",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-body-sm text-fg-2",children:"Theme"}),d.jsx(t8,{})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-body-sm text-fg-2",children:"Agent view style"}),d.jsx(Rb,{label:"Agent view style",options:[{value:"cards",label:"Cards"},{value:"terminal",label:"Terminal"}],read:qp,write:ihe,onChange:r})]}),n==="cards"?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-body-sm text-fg-2",children:"Agent view density"}),d.jsx(Rb,{label:"Agent view density",options:[{value:"comfortable",label:"Comfortable"},{value:"compact",label:"Compact"}],read:Cv,write:she})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-body-sm text-fg-2",children:"Agent view font"}),d.jsx(Rb,{label:"Agent view font",options:[{value:"sans",label:"Regular"},{value:"mono",label:"Monospace"}],read:wv,write:ahe})]})]}):null]})})})]})})}function a8({className:e}){return d.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:e,children:[d.jsx("path",{d:"M12 3 20.5 7.75 12 12.5 3.5 7.75Z"}),d.jsx("path",{d:"M3.5 12.25 12 17l8.5-4.75"}),d.jsx("path",{d:"M3.5 16.5 12 21.25l8.5-4.75"}),d.jsx("path",{d:"M12 6.15 14.85 7.75 12 9.35 9.15 7.75Z",fill:"#2fbf71",stroke:"none"})]})}const o8="workerdeck.hosts.v1",Zx=e=>`workerdeck.host.${e}.key`,l8="gateway";let ms={hosts:[],ready:!1};const Jx=new Set;function Nv(e){ms=e,ey.clear();for(const t of Jx)t()}function _v(){try{const e=localStorage.getItem(o8),t=e?JSON.parse(e):[];return Array.isArray(t)?t.map(({implicit:n,...r})=>r):[]}catch{return[]}}function c8(e){try{localStorage.setItem(o8,JSON.stringify(e.filter(t=>!t.implicit)))}catch{}}function che(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;const t=[...e].map(n=>n.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function u8(e){try{return localStorage.getItem(Zx(e))??""}catch{return""}}function d8(e,t){try{t===""?localStorage.removeItem(Zx(e)):localStorage.setItem(Zx(e),t)}catch{}}const ey=new Map;function tc(e){const t=ey.get(e);if(t)return t;const n=ms.hosts.find(a=>a.id===e);if(!n)return;const r=R2(n);if(r===void 0)return;const s=new GW({baseUrl:r,...n.implicit?{}:VW({baseUrl:r,key:u8(n.id)})});return ey.set(e,s),s}function Qm(){return ms.hosts.find(e=>e.implicit)??ms.hosts[0]}function uhe(){const e=Qm();return e?tc(e.id):void 0}function f8(e){return $W(e)}function dhe(e,t){const n=_v(),r=n.some(s=>s.id===e.id)?n.map(s=>s.id===e.id?e:s):[...n,e];c8(r),d8(e.id,t),Nv({...ms,hosts:[...ms.hosts.filter(s=>s.implicit),...r]})}function fhe(e){const t=_v().filter(n=>n.id!==e);c8(t),d8(e,""),Nv({...ms,hosts:[...ms.hosts.filter(n=>n.implicit),...t]})}async function hhe(){try{const e=await fetch(`${location.origin}/auth/status`,{headers:{accept:"application/json"}});if(!e.ok||!e.headers.get("content-type")?.includes("application/json"))return!1;const t=await e.json();return typeof t=="object"&&t!==null&&"enabled"in t}catch{return!1}}let K4=!1;function h8(){if(K4)return;K4=!0;const e=_v();ms={hosts:e,ready:!1},hhe().then(t=>{Nv({hosts:t?[{id:l8,name:"This gateway",baseUrl:location.origin,implicit:!0},...e]:e,ready:!0})})}function p8(e){return h8(),Jx.add(e),()=>Jx.delete(e)}function Av(){return y.useSyncExternalStore(p8,()=>ms,()=>ms)}function phe(){return h8(),ms.hosts}function mhe(e){return p8(e)}function m8({host:e,submitLabel:t="Save",onSaved:n,actions:r}){const[s,a]=y.useState(e.name),[l,c]=y.useState(e.baseUrl),[u,h]=y.useState(()=>u8(e.id)),m=()=>{if(R2({baseUrl:l})===void 0){un.error("That address is not a URL");return}if(!s.trim()){un.error("Give the gateway a name");return}const p={id:e.id,name:s.trim(),baseUrl:l.trim()};dhe(p,u),n(p)};return d.jsxs("div",{className:"flex flex-col gap-3",children:[d.jsxs("label",{className:"flex flex-col gap-1",children:[d.jsx("span",{className:"text-label text-fg-3",children:"Name"}),d.jsx(Zt,{value:s,onChange:p=>a(p.target.value),placeholder:"Mac mini"})]}),d.jsxs("label",{className:"flex flex-col gap-1",children:[d.jsx("span",{className:"text-label text-fg-3",children:"Address"}),d.jsx(Zt,{value:l,onChange:p=>c(p.target.value),placeholder:"http://toby.ts.net:8787",spellCheck:!1,className:"font-mono"})]}),d.jsxs("label",{className:"flex flex-col gap-1",children:[d.jsx("span",{className:"text-label text-fg-3",children:"Auth key"}),d.jsx(Zt,{type:"password",value:u,onChange:p=>h(p.target.value),placeholder:"Leave empty for an unauthenticated gateway",spellCheck:!1}),d.jsx("span",{className:"text-label text-fg-4",children:"Stored in this browser’s local storage, and sent on the WebSocket URL when attaching. Use a gateway you control, over a network you trust."})]}),d.jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[r,d.jsx(tt,{onClick:m,children:t})]})]})}function ghe({open:e,onOpenChange:t,onCreated:n}){const[r,s]=y.useState(()=>W4());return d.jsx(gs,{open:e,onOpenChange:a=>{a&&s(W4()),t(a)},children:d.jsxs(bs,{children:[d.jsx(xs,{title:"Add gateway",description:"A workerdeck gateway you run — typically over Tailscale."}),d.jsx(ys,{children:d.jsx(m8,{host:r,submitLabel:"Add gateway",onSaved:n,actions:d.jsx(tt,{variant:"outline",onClick:()=>t(!1),children:"Cancel"})})})]})})}function W4(){return{id:che(),name:"",baseUrl:""}}function g8({host:e,onClose:t,onRemoved:n}){return d.jsx(gs,{open:!0,onOpenChange:r=>!r&&t(),children:d.jsxs(bs,{children:[d.jsx(xs,{title:`Remove ${e.name}?`,description:"Its auth key is deleted from this browser. The gateway itself keeps running."}),d.jsx(ys,{children:d.jsxs("div",{className:"flex justify-end gap-2",children:[d.jsx(tt,{variant:"outline",onClick:t,children:"Cancel"}),d.jsx(tt,{variant:"destructive",onClick:()=>{fhe(e.id),n()},children:"Remove"})]})})]})})}const b8=240,x8=520,ty=300,y8=e=>e==="sessions"?"workerdeck.sessions-sidebar-width":`workerdeck.${e}-sidebar-width`,v8=e=>e==="sessions"?"workerdeck.sessions-sidebar-collapsed":`workerdeck.${e}-sidebar-collapsed`;function bhe(e){try{const t=Number(localStorage.getItem(y8(e)));return t?Math.min(x8,Math.max(b8,t)):ty}catch{return ty}}function xhe(e,t){try{localStorage.setItem(y8(e),String(t))}catch{}}function yhe(e){try{return localStorage.getItem(v8(e))==="1"}catch{return!1}}function vhe(e,t){try{localStorage.setItem(v8(e),t?"1":"0")}catch{}}const E8="workerdeck.sessions-filters-shown";function Ehe(){try{return localStorage.getItem(E8)==="1"}catch{return!1}}function The(e){try{localStorage.setItem(E8,e?"1":"0")}catch{}}function Zm({section:e,title:t,badge:n,actions:r,children:s,rail:a,railActions:l}){const[c,u]=y.useState(()=>bhe(e)),[h,m]=y.useState(()=>yhe(e)),p=b=>{m(b),vhe(e,b)};return h?d.jsxs("div",{className:"flex min-h-0 w-11 shrink-0 flex-col items-center gap-1 border-r border-border bg-sidebar py-1.5",children:[d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":`Expand ${t.toLowerCase()}`,onClick:()=>p(!1),children:d.jsx(v2,{className:"size-4"})}),l,a?d.jsx("div",{className:"flex min-h-0 w-full flex-1 flex-col items-center gap-0.5 overflow-y-auto pt-1",children:a}):null]}):d.jsxs(d.Fragment,{children:[d.jsxs("div",{style:{width:c},className:"flex min-h-0 shrink-0 flex-col border-r border-border bg-sidebar",children:[d.jsxs("header",{className:"flex h-9 shrink-0 items-center gap-1 pr-1 pl-3",children:[d.jsx("span",{className:"truncate text-label font-medium tracking-wide text-fg-3 uppercase",children:t}),n,d.jsx("span",{className:"flex-1"}),d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":`Collapse ${t.toLowerCase()}`,onClick:()=>p(!0),children:d.jsx(y2,{className:"size-3.5"})}),r]}),s]}),d.jsx(lx,{orientation:"vertical",value:c,onValueChange:b=>{u(b),xhe(e,b)},min:b8,max:x8,defaultValue:ty,"aria-label":`Resize ${t.toLowerCase()} sidebar`})]})}function Jm({children:e,className:t}){return d.jsx("div",{className:ve("min-h-0 flex-1 overflow-y-auto pb-2",t),children:e})}function Rv({title:e,status:t,description:n,actions:r,active:s,onSelect:a,onDoubleClick:l}){return d.jsxs("div",{"data-slot":"sidebar-row","data-active":s||void 0,onClick:a,onDoubleClick:l,className:ve("group flex cursor-pointer flex-col gap-0.5 text-left transition-colors",ZI(s===!0)),children:[d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx("button",{type:"button",className:ve("min-w-0 flex-1 truncate text-left text-body-sm outline-none",s?"font-medium text-fg-1":"text-fg-2"),children:e}),t]}),d.jsxs("div",{className:"flex items-center gap-1 text-label text-fg-4",children:[d.jsx("button",{type:"button",tabIndex:-1,className:"flex min-w-0 flex-1 items-center gap-1.5 truncate text-left font-mono outline-none",children:n}),r]})]})}function T8({label:e,onClick:t,children:n}){return d.jsx("button",{type:"button","aria-label":e,title:e,onClick:r=>{r.stopPropagation(),t()},className:"flex size-5 shrink-0 items-center justify-center rounded text-fg-3 opacity-0 transition-opacity outline-none hover:bg-surface-hover hover:text-fg-1 group-hover:opacity-100",children:n})}const X4="workerdeck.watermarks.v1",ny=new Set;let ry=0;const She={read:()=>{try{const e=localStorage.getItem(X4);return e?JSON.parse(e):void 0}catch{return}},write:e=>{try{localStorage.setItem(X4,JSON.stringify(e))}catch{}ry+=1;for(const t of ny)t()}},Yp=new uW(She);function khe(e){return ny.add(e),()=>ny.delete(e)}function Che(){return y.useSyncExternalStore(khe,()=>ry,()=>ry),{unseenFor:y.useCallback((t,n)=>dW(Yp.get(t,n.id),{activityCount:n.activityCount,turns:n.numTurns}),[]),watermarks:Yp}}function whe(e,t){const n=Yp.get(e,t);return n?{itemCount:n.itemCount,since:n.seenAt}:void 0}function Nhe(e,t){const n=y.useRef({});return y.useCallback(r=>{!t||document.hidden||(n.current={...n.current,...r},Yp.mark(e,t,n.current))},[e,t])}const _he=5e3,Ahe=1200,Rhe=700;let dd={snapshots:[],loaded:!1};const sy=new Set;function Mhe(e){dd=e;for(const t of sy)t()}let Mb,S8=0,Ib;function fd(){return Mb??=(async()=>{S8=Date.now();try{const e=phe(),t=new Map(dd.snapshots.map(r=>[r.host.id,r])),n=await Promise.all(e.map(async r=>{const s=tc(r.id);if(!s)return{host:r,sessions:[],error:"unusable address"};try{return{host:r,sessions:await s.listSessions()}}catch(a){return{host:r,sessions:t.get(r.id)?.sessions??[],error:a instanceof Error?a.message:String(a)}}}));Mhe({snapshots:n,loaded:!0})}finally{Mb=void 0}})(),Mb}function Ihe(){if(Ib!==void 0)return;const e=Math.max(0,Rhe-(Date.now()-S8));Ib=setTimeout(()=>{Ib=void 0,fd()},e)}function Ohe(e){return sy.add(e),()=>sy.delete(e)}let qh,Q4;function Lhe(e){const t=e?Ahe:_he;qh!==void 0&&Q4===t||(qh!==void 0&&clearInterval(qh),Q4=t,qh=setInterval(()=>void fd(),t))}function Ic(){const e=y.useSyncExternalStore(Ohe,()=>dd,()=>dd);y.useEffect(()=>mhe(()=>void fd()),[]);const t=e.snapshots.some(n=>n.sessions.some(r=>{const s=G_(r);return s==="working"||s==="attention"}));return y.useEffect(()=>{Lhe(t),dd.loaded||fd()},[t]),{...e,refresh:fd}}function jhe(e){const{unseenFor:t}=Che();return y.useMemo(()=>e.flatMap(({host:n,sessions:r})=>r.filter(s=>!QK(s)).map(s=>({hostId:n.id,hostName:n.name,local:f8(n),adapter:s.engine??"claude",state:G_(s),info:s,unseen:t(n.id,s)}))),[e,t])}function Dhe(){const e=As(),t=Id({select:p=>p.location.pathname.match(/^\/gateways\/(.+)$/)?.[1]}),{hosts:n,ready:r}=Av(),{snapshots:s}=Ic(),[a,l]=y.useState(!1),[c,u]=y.useState(),h=s.filter(p=>p.error===void 0).length,m=d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":"Add gateway",onClick:()=>l(!0),children:d.jsx($o,{className:"size-4"})});return d.jsxs(d.Fragment,{children:[d.jsx(Zm,{section:"gateways",title:"Gateways",badge:r&&n.length>0?d.jsxs("span",{className:"shrink-0 text-label text-fg-4",children:[h,"/",n.length]}):void 0,actions:m,railActions:m,children:d.jsxs(Jm,{children:[r&&n.length===0?d.jsx(Wr,{icon:d.jsx(s_,{}),title:"No gateways yet",description:d.jsxs(d.Fragment,{children:["Add one with ",d.jsx(qo,{children:"+"})," above."]})}):null,n.map(p=>{const b=s.find(v=>v.host.id===p.id),x=b===void 0?"pending":b.error?"error":"ok";return d.jsx(Rv,{active:p.id===t,onSelect:()=>void e({to:"/gateways/$hostId",params:{hostId:p.id}}),title:p.name,status:d.jsxs(d.Fragment,{children:[p.implicit?d.jsx("span",{className:"shrink-0 text-label text-fg-4",children:"this page"}):null,d.jsx("span",{"aria-hidden":!0,title:b?.error??(x==="ok"?"Connected":"Connecting…"),className:ve("size-1.5 shrink-0 rounded-full",x==="ok"?"bg-success":x==="error"?"bg-danger":"bg-fg-4")})]}),description:p.baseUrl,actions:p.implicit?null:d.jsx(T8,{label:`Remove ${p.name}`,onClick:()=>u(p),children:d.jsx(Dd,{className:"size-3"})})},p.id)})]})}),c?d.jsx(g8,{host:c,onClose:()=>u(void 0),onRemoved:()=>{const p=c.id===t;u(void 0),p&&e({to:"/gateways"})}}):null,d.jsx(ghe,{open:a,onOpenChange:l,onCreated:p=>{l(!1),e({to:"/gateways/$hostId",params:{hostId:p.id}})}})]})}function k8({value:e,onChange:t,models:n=n8,className:r}){return d.jsx(RI,{variant:"form",models:n,model:e||void 0,onModelChange:s=>t(s??""),className:r})}function Phe({profiles:e,value:t,onChange:n,className:r}){return e.length===0?null:d.jsxs("label",{className:"flex min-w-0 flex-col gap-1",children:[d.jsx("span",{className:"text-label font-medium text-fg-3",children:"Profile"}),d.jsxs(Di,{items:e.map(s=>({value:s.name,label:s.name})),value:t,onValueChange:s=>n(s),children:[d.jsx(Bi,{className:r,children:d.jsx(Pi,{})}),d.jsx(zi,{children:e.map(s=>d.jsx(Qs,{value:s.name,children:d.jsx(Xs,{children:d.jsxs("span",{className:s.available===!1?"text-fg-4":void 0,title:s.unavailableReason,children:[s.description?`${s.name} — ${s.description}`:s.name,s.available===!1?" (unavailable)":""]})})},s.name))})]})]})}function Dr(){return uhe()}function C8(e,t,n){const r=e?.capabilities??Am[e?.engine??"claude"],s=r.permissionModes.includes(t)?t:r.defaultPermissionMode;let a,l;if(e?.models?.length)a=e.models,l=e.defaultModel;else if(e?.engine==="provider"){const h=e.provider;a=(h?.models?.length?h.models:h?.model?[h.model]:[]).map(p=>({value:p,displayName:p})),l=h?.model}else a=n8.filter(h=>h.value!=="default");const c=a.find(h=>h.value===n||h.resolvedModel===n),u=c||n===""?n:"";return{capabilities:r,modes:r.permissionModes,models:[{value:"default",displayName:"Profile default",description:l??"the profile's configured model"},...a],mode:s,model:u,reasoningEfforts:(c?c.reasoningEfforts:void 0)??r.reasoningEfforts??[]}}const iy={profiles:[]};let ay,Ob;const oy=new Set;async function Z4(){const e=await(Dr()?.listProfiles().catch(()=>iy)??Promise.resolve(iy));ay=e;for(const t of oy)t(e);return e}function Mv(){const[e,t]=y.useState(ay??iy);y.useEffect(()=>(oy.add(t),ay||(Ob??=Z4()),()=>{oy.delete(t)}),[]);const n=y.useCallback(async()=>{Ob=Z4(),await Ob},[]);return{...e,refresh:n}}function Bhe(){return Mv().profiles}const J4="workerdeck.last-profile";function zhe(){const e=Bhe(),[t,n]=y.useState(()=>localStorage.getItem(J4)??""),r=e.some(l=>l.name===t)?t:e[0]?.name??"",s=e.find(l=>l.name===r);return{profiles:e,profile:r,selected:s,select:l=>{n(l),localStorage.setItem(J4,l)}}}const ly="workerdeck.last-cwd";function Hhe(e){const[t,n]=y.useState([]);return y.useEffect(()=>{Dr()?.listHostRoots().then(r=>n(r.roots.map(s=>s.path))).catch(()=>n([]))},[]),y.useMemo(()=>{const r=localStorage.getItem(ly),s=[...r?[r]:[],...[...e].sort((a,l)=>(l.lastActivityAt??l.createdAt)-(a.lastActivityAt??a.createdAt)).map(a=>a.cwd),...t];return[...new Set(s)].slice(0,12)},[e,t])}const Uhe={session:"default",job:"acceptEdits"};function w8(e){const[t,n]=y.useState(()=>localStorage.getItem(ly)??""),[r,s]=y.useState(""),[a,l]=y.useState(""),[c,u]=y.useState(void 0),[h,m]=y.useState(""),{profiles:p,profile:b,selected:x,select:v}=zhe(),N=c??x?.defaults?.permissionMode??Uhe[e],w=C8(x,N,a),S=A=>({cwd:w.capabilities.hostCwd===!1?void 0:t.trim(),profile:b||void 0,prompt:A.prompt,permissionMode:w.mode,model:w.model.trim()||void 0,resume:A.resume,reasoningEffort:h&&w.reasoningEfforts.includes(h)?h:void 0,...w.capabilities.settingSources?{settingSources:["user","project"],allowDangerouslySkipPermissions:A.allowBypass||void 0}:{}}),C=A=>localStorage.setItem(ly,t.trim()||A);return{cwd:t,setCwd:n,prompt:r,setPrompt:s,mode:w.mode,setMode:u,model:a,setModel:l,effort:h,setEffort:m,profiles:p,profile:b,selectProfile:v,engine:w,sessionFields:S,rememberCwd:C}}function N8({form:e,sessions:t,promptLabel:n,promptPlaceholder:r="e.g. /verify-content 42, or a task description",extras:s,actions:a,onProfileChange:l}){const c=Hhe(t),u=y.useId(),{engine:h}=e;return d.jsxs(d.Fragment,{children:[h.capabilities.hostCwd!==!1&&d.jsxs("label",{className:"flex flex-col gap-1",children:[d.jsx("span",{className:"text-label font-medium text-fg-3",children:"Working directory"}),d.jsx(Zt,{value:e.cwd,list:u,onChange:m=>e.setCwd(m.target.value),placeholder:"/path/to/project",spellCheck:!1,className:"font-mono"}),d.jsx("datalist",{id:u,children:c.map(m=>d.jsx("option",{value:m},m))})]}),d.jsxs("label",{className:"flex flex-col gap-1",children:[d.jsx("span",{className:"text-label font-medium text-fg-3",children:n}),d.jsx(c5,{value:e.prompt,onChange:m=>e.setPrompt(m.target.value),rows:2,placeholder:r})]}),d.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[d.jsx(Phe,{profiles:e.profiles,value:e.profile,onChange:m=>{e.selectProfile(m),l?.(m)},className:"min-w-32"}),d.jsxs("label",{className:"flex min-w-0 flex-col gap-1",children:[d.jsx("span",{className:"text-label font-medium text-fg-3",children:"Permission mode"}),d.jsx(yv,{variant:"form",mode:h.mode,onModeChange:e.setMode,modes:h.modes,className:"min-w-44"})]}),s,d.jsxs("label",{className:"flex min-w-0 flex-col gap-1",children:[d.jsx("span",{className:"text-label font-medium text-fg-3",children:"Model"}),d.jsx(k8,{value:h.model,onChange:e.setModel,models:h.models,className:"min-w-40"})]}),h.reasoningEfforts.length>0?d.jsxs("label",{className:"flex min-w-0 flex-col gap-1",children:[d.jsx("span",{className:"text-label font-medium text-fg-3",children:"Effort"}),d.jsxs(Di,{items:[{value:"default",label:"Default"},...h.reasoningEfforts.map(m=>({value:m,label:m}))],value:e.effort||"default",onValueChange:m=>e.setEffort(m==="default"?"":String(m)),children:[d.jsx(Bi,{className:"min-w-28",children:d.jsx(Pi,{})}),d.jsx(zi,{children:["default",...h.reasoningEfforts].map(m=>d.jsx(Qs,{value:m,children:d.jsx(Xs,{children:m})},m))})]})]}):null,a]})]})}const Fhe=15e3;let Ci={jobs:[],stats:void 0,enabled:!0,live:!1,error:void 0};const cy=new Set;function _o(e){Ci={...Ci,...e};for(const t of cy)t()}let Lb;function Gp(){return Lb??=(async()=>{try{const e=Dr();if(!e)return;const[t,n]=await Promise.all([e.listJobs(),e.queueStats()]);_o({jobs:t,stats:n,enabled:!0,error:void 0})}catch(e){const t=e instanceof Error?e.message:String(e);/not configured/i.test(t)?_o({enabled:!1,error:void 0}):_o({error:t})}finally{Lb=void 0}})(),Lb}let uy=0,jb,Kp;function $he(e){return cy.add(e),++uy===1&&(Gp(),jb=setInterval(()=>void Gp(),Fhe)),()=>{cy.delete(e),--uy===0&&(clearInterval(jb),jb=void 0,Kp?.(),Kp=void 0,_o({live:!1}))}}function Vhe(){if(Kp||!Ci.enabled||Ci.stats===void 0||uy===0)return;const e=Dr();if(!e)return;const t=e.attachQueue(),n=[t.on("attached",()=>void Gp()),t.on("stats",r=>_o({stats:r})),t.on("connectionChange",r=>_o({live:r})),t.on("event",r=>{_o({jobs:Ci.jobs.some(s=>s.id===r.job.id)?Ci.jobs.map(s=>s.id===r.job.id?r.job:s):[...Ci.jobs,r.job]})})];Kp=()=>{for(const r of n)r();t.detach()}}function Iv(){const e=y.useSyncExternalStore($he,()=>Ci,()=>Ci);return y.useEffect(Vhe,[e.enabled,e.stats]),{...e,refresh:Gp}}function qhe({stats:e}){const t=e.dailyTokenLimit!==void 0&&e.dailyTokenLimit>0?e.dailyTokensUsed/e.dailyTokenLimit*100:void 0;return d.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-x-5 gap-y-2 rounded-md border border-border bg-surface px-3 py-2 text-body-sm text-fg-2",children:[d.jsxs("span",{children:["Running ",d.jsxs("span",{className:"font-mono text-fg-1",children:[e.running,"/",e.maxConcurrency]})]}),d.jsxs("span",{children:["Queued ",d.jsx("span",{className:"font-mono text-fg-1",children:e.queued})]}),e.parked>0?d.jsxs("span",{children:["Parked ",d.jsx("span",{className:"font-mono text-fg-1",children:e.parked})]}):null,d.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t!==void 0?d.jsx(N2,{value:t,className:t>=95?"text-danger":t>=80?"text-warning":"text-fg-3"}):null,"Daily tokens"," ",d.jsxs("span",{className:"font-mono text-fg-1",children:[Gr(e.dailyTokensUsed),e.dailyTokenLimit!==void 0?` / ${Gr(e.dailyTokenLimit)}`:""]})]}),e.sessionTokenLimit!==void 0?d.jsxs("span",{children:["Per-job cap ",d.jsx("span",{className:"font-mono text-fg-1",children:Gr(e.sessionTokenLimit)})]}):null,e.paused?d.jsx(En,{variant:"warning",dot:!0,children:"Paused — daily budget exhausted"}):null]})}function Yhe({onScheduled:e}){const{snapshots:t}=Ic(),n=t.find(C=>C.host.id===Qm()?.id)?.sessions??[],r=w8("job"),[s,a]=y.useState("auto"),[l,c]=y.useState(!1),[u,h]=y.useState(""),[m,p]=y.useState(""),[b,x]=y.useState(""),[v,N]=y.useState(!1),{engine:w}=r,S=async()=>{if(!r.cwd.trim()||!r.prompt.trim()){un.error("Working directory and prompt are required");return}const C=u.trim()?Number(u.trim()):void 0;if(C!==void 0&&(!Number.isFinite(C)||C<=0)){un.error("Max tokens must be a positive number");return}const A=m.trim()?Number(m.trim()):void 0;if(A!==void 0&&(!Number.isInteger(A)||A<1)){un.error("Attempts must be a whole number of at least 1");return}N(!0);try{r.rememberCwd(r.cwd.trim()),await Dr().createJob({session:{...r.sessionFields({allowBypass:l}),prompt:r.prompt.trim(),questionBehavior:w.capabilities.interactiveApprovals?s:void 0},maxTokens:C,attempts:A,webhook:b.trim()?{url:b.trim()}:void 0}),r.setPrompt(""),un.success("Job scheduled"),e()}catch(R){un.error(R instanceof Error?R.message:"Failed to schedule job")}finally{N(!1)}};return d.jsxs("div",{className:"flex flex-col gap-3",children:[d.jsx(N8,{form:r,sessions:n,promptLabel:"Prompt (the task — runs unattended)",extras:w.capabilities.interactiveApprovals?d.jsxs("label",{className:"flex min-w-0 flex-col gap-1",children:[d.jsx("span",{className:"text-label font-medium text-fg-3",children:"Questions"}),d.jsxs(Di,{items:w4.map(C=>({value:C.value,label:C.label})),value:s,onValueChange:C=>a(C),children:[d.jsx(Bi,{className:"min-w-36",children:d.jsx(Pi,{})}),d.jsx(zi,{children:w4.map(C=>d.jsx(Qs,{value:C.value,children:d.jsx(Xs,{children:`${C.label} — ${C.description}`})},C.value))})]})]}):null,actions:d.jsxs(d.Fragment,{children:[d.jsxs("label",{className:"flex min-w-0 flex-col gap-1",children:[d.jsx("span",{className:"text-label font-medium text-fg-3",children:"Max tokens (optional)"}),d.jsx(Zt,{value:u,onChange:C=>h(C.target.value),placeholder:"per-job cap",inputMode:"numeric",className:"min-w-28 font-mono"})]}),d.jsxs("label",{className:"flex min-w-0 flex-col gap-1",children:[d.jsx("span",{className:"text-label font-medium text-fg-3",children:"Attempts (optional)"}),d.jsx(Zt,{value:m,onChange:C=>p(C.target.value),placeholder:"1",inputMode:"numeric",className:"min-w-20 font-mono"})]}),d.jsxs("label",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[d.jsx("span",{className:"text-label font-medium text-fg-3",children:"Webhook URL (optional)"}),d.jsx(Zt,{value:b,onChange:C=>x(C.target.value),placeholder:"https://…/hook",spellCheck:!1,className:"min-w-44 font-mono"})]}),d.jsxs(tt,{className:"ml-auto",onClick:()=>void S(),disabled:v,children:[v?d.jsx(Tn,{className:"size-3.5 text-current"}):d.jsx($o,{className:"size-4"}),"Schedule"]})]})}),w.capabilities.settingSources?d.jsxs("label",{className:"flex w-fit cursor-pointer items-center gap-2 text-body-sm text-fg-2",title:"Spawns the CLI with --dangerously-skip-permissions available, so the mode can be switched on while watching the run. The job still starts in the mode selected above.",children:[d.jsx("input",{type:"checkbox",checked:l,onChange:C=>c(C.target.checked),className:"size-3.5 accent-(--color-fg-1)"}),"Allow switching to ",d.jsx("code",{className:"font-mono",children:"bypassPermissions"})," mid-run",d.jsx("span",{className:"text-label text-fg-4",children:"(dangerous)"})]}):null,d.jsxs("p",{className:"text-label text-fg-4",children:["Unattended runs still surface permission prompts — the job's page is read-only, so answer them from the session itself, or pick a mode that doesn't ask. Unanswered prompts deny after the server's timeout. With Questions set to Ask, webhook deliveries carry the full question so a controller can answer via"," ",d.jsx("code",{className:"font-mono",children:"POST /sessions/:id/permissions/:requestId"}),"."]})]})}function Ghe({open:e,onOpenChange:t,onScheduled:n}){return d.jsx(gs,{open:e,onOpenChange:t,children:d.jsxs(bs,{size:"lg",children:[d.jsx(xs,{title:"Schedule a job",description:"A one-shot run the queue executes unattended."}),d.jsx(ys,{children:e?d.jsx(Yhe,{onScheduled:n}):null})]})})}function Khe(){const{stats:e,enabled:t,error:n}=Iv();return d.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-8 text-center",children:[n?d.jsxs("div",{className:"rounded-md bg-danger-bg px-3 py-2 text-body-sm text-danger",children:["Can't reach the worker server: ",n,". Start it with"," ",d.jsx("code",{className:"font-mono",children:"pnpm server"}),"."]}):null,t?d.jsxs(d.Fragment,{children:[d.jsx(Wr,{icon:d.jsx(e_,{}),title:"No job selected",description:d.jsxs(d.Fragment,{children:["Pick one on the left, or schedule one with ",d.jsx(qo,{children:"+"})," above."]})}),e?d.jsx("div",{className:"mt-2 w-full max-w-xl",children:d.jsx(qhe,{stats:e})}):null]}):d.jsxs(d.Fragment,{children:[d.jsx(FH,{className:"size-8 text-fg-4"}),d.jsx("p",{className:"text-body-sm text-fg-3",children:"The server has no job queue configured."}),d.jsxs("p",{className:"max-w-md text-label text-fg-4",children:["Pass ",d.jsxs("code",{className:"font-mono",children:["queue: ","{ maxConcurrency, … }"]})," to"," ",d.jsx("code",{className:"font-mono",children:"createWorkerServer"})," — the dev server enables it by default."]})]})]})}const _8={queued:{label:"Queued",variant:"neutral"},running:{label:"Running",variant:"info",busy:!0},parked:{label:"Parked",variant:"accent"},succeeded:{label:"Succeeded",variant:"success"},failed:{label:"Failed",variant:"danger"},canceled:{label:"Canceled",variant:"warning"}},Whe=["queued","running","parked"];function Xhe(){const e=As(),t=Id({select:w=>w.location.pathname.match(/^\/jobs\/(.+)$/)?.[1]}),{jobs:n,enabled:r,live:s,refresh:a}=Iv(),[l,c]=y.useState(!1),[u,h]=y.useState(""),[m,p]=y.useState(!1),b=u.trim().toLowerCase(),x=[...n].sort((w,S)=>S.createdAt-w.createdAt).filter(w=>(!m||Whe.includes(w.status))&&(!b||w.prompt.toLowerCase().includes(b)||w.cwd.toLowerCase().includes(b)||(w.profile?.toLowerCase().includes(b)??!1)||w.id.startsWith(b))),v=n.length-x.length,N=r?d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":"Schedule a job",onClick:()=>c(!0),children:d.jsx($o,{className:"size-4"})}):void 0;return d.jsxs(d.Fragment,{children:[d.jsx(Zm,{section:"jobs",title:"Jobs",badge:r?d.jsx("span",{"aria-hidden":!0,title:s?"Streaming over the queue socket":"Polling",className:ve("size-1.5 shrink-0 rounded-full",s?"bg-success":"bg-fg-4")}):void 0,actions:d.jsxs(d.Fragment,{children:[d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":"Refresh",onClick:()=>void a(),children:d.jsx(Sm,{className:"size-3.5"})}),N]}),railActions:N,children:r?d.jsxs(d.Fragment,{children:[n.length>0?d.jsxs("div",{className:"flex items-center gap-1 px-2 pb-2",children:[d.jsx(Zt,{value:u,onChange:w=>h(w.target.value),placeholder:"Search jobs","aria-label":"Search jobs",className:"h-7 min-w-0 flex-1 text-body-sm"}),d.jsx(tt,{variant:m?"default":"outline",size:"xs","aria-pressed":m,onClick:()=>p(!m),children:"Active"})]}):null,d.jsxs(Jm,{children:[n.length===0?d.jsx(Wr,{icon:d.jsx(sC,{}),title:"No jobs yet",description:d.jsxs(d.Fragment,{children:["Schedule one with ",d.jsx(qo,{children:"+"})," above."]})}):x.length===0?d.jsx(Wr,{icon:d.jsx(r_,{}),title:"No matches",description:"No job matches the active filter.",action:"Show all",onAction:()=>p(!1)}):null,x.map(w=>d.jsx(Qhe,{job:w,active:w.id===t,onOpen:()=>void e({to:"/jobs/$jobId",params:{jobId:w.id}}),onChanged:()=>void a()},w.id)),v>0?d.jsxs("p",{className:"px-1 pt-2 text-center text-label text-fg-4",children:[x.length," of ",n.length]}):null]})]}):d.jsx(Wr,{icon:d.jsx(sC,{}),title:"No job queue",description:"This gateway runs without one, so there is nothing to schedule against."})}),d.jsx(Ghe,{open:l,onOpenChange:c,onScheduled:()=>{c(!1),a()}})]})}function Qhe({job:e,active:t,onOpen:n,onChanged:r}){const s=_8[e.status],a=e.status==="queued"||e.status==="running"||e.status==="parked",l=[kc(e.finishedAt??e.startedAt??e.createdAt),e.cwd.split("/").filter(Boolean).pop()??e.cwd];return e.profile&&l.push(`@${e.profile}`),e.usage.totalCostUsd>0&&l.push(Js(e.usage.totalCostUsd)),d.jsx(Rv,{active:t,onSelect:n,title:e.prompt,status:d.jsxs(En,{variant:s.variant,dot:!s.busy,className:"shrink-0",children:[s.busy?d.jsx(Tn,{className:"size-3 text-current"}):null,s.label]}),description:l.join(" · "),actions:a?d.jsx(T8,{label:"Cancel job",onClick:()=>{Dr()?.cancelJob(e.id).then(r).catch(c=>un.error(c instanceof Error?c.message:"Cancel failed"))},children:d.jsx(_s,{className:"size-3"})}):null})}const Zhe=["web_search","download","web_fetch","deliver_file"],Yh=e=>e.split(",").map(t=>t.trim()).filter(Boolean);function ks({label:e,children:t}){return d.jsxs("label",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[d.jsx("span",{className:"text-label font-medium text-fg-3",children:e}),t]})}function Jhe({onCreated:e}){const[t,n]=y.useState("provider"),[r,s]=y.useState(""),[a,l]=y.useState(""),[c,u]=y.useState(""),[h,m]=y.useState(""),[p,b]=y.useState(""),[x,v]=y.useState(""),[N,w]=y.useState(""),[S,C]=y.useState([]),[A,R]=y.useState(""),[M,_]=y.useState(""),[I,j]=y.useState(!1),z=t==="provider",P=async()=>{if(!r.trim()){un.error("Name is required");return}const F={name:r.trim(),engine:t};if(a.trim()&&(F.description=a.trim()),z){F.provider={id:c.trim(),model:h.trim()||void 0,models:Yh(p).length>0?Yh(p):void 0,apiKeyEnv:x.trim()||void 0};const V={};S.length>0&&(V.capabilities=S),Yh(A).length>0&&(V.mcpServers=Yh(A)),M.trim()&&(V.instructions=M.trim()),Object.keys(V).length>0&&(F.session=V)}else F.configDir=N.trim();j(!0);try{await Dr().createProfile(F),un.success(`Profile '${F.name}' created`),e(F.name)}catch(V){un.error(V instanceof Error?V.message:"Failed to create profile")}finally{j(!1)}};return d.jsxs("div",{className:"flex flex-col gap-3",children:[d.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[d.jsx(ks,{label:"Engine",children:d.jsxs(Di,{items:[{value:"provider",label:"provider"},{value:"claude",label:"claude"}],value:t,onValueChange:F=>n(F),children:[d.jsx(Bi,{className:"min-w-32",children:d.jsx(Pi,{})}),d.jsxs(zi,{children:[d.jsx(Qs,{value:"provider",children:d.jsx(Xs,{children:"provider — model-agnostic engine"})}),d.jsx(Qs,{value:"claude",children:d.jsx(Xs,{children:"claude — Agent SDK + config dir"})})]})]})}),d.jsx(ks,{label:"Name",children:d.jsx(Zt,{value:r,onChange:F=>s(F.target.value),placeholder:"kimi"})}),d.jsx(ks,{label:"Description (optional)",children:d.jsx(Zt,{value:a,onChange:F=>l(F.target.value),placeholder:"what this profile is for"})})]}),z?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[d.jsx(ks,{label:"Provider id",children:d.jsx(Zt,{value:c,onChange:F=>u(F.target.value),placeholder:"anthropic / openai / moonshotai",className:"font-mono"})}),d.jsx(ks,{label:"Default model",children:d.jsx(Zt,{value:h,onChange:F=>m(F.target.value),placeholder:"kimi-k3",className:"font-mono"})}),d.jsx(ks,{label:"Models offered (comma-separated)",children:d.jsx(Zt,{value:p,onChange:F=>b(F.target.value),placeholder:"kimi-k3, kimi-k2",className:"font-mono"})}),d.jsx(ks,{label:"API key variable",children:d.jsx(Zt,{value:x,onChange:F=>v(F.target.value),placeholder:"MOONSHOT_API_KEY",className:"font-mono"})})]}),d.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[d.jsx(ks,{label:"Capabilities granted",children:d.jsx("div",{className:"flex flex-wrap gap-3 py-1.5",children:Zhe.map(F=>d.jsxs("label",{className:"flex cursor-pointer items-center gap-1.5 text-body-sm text-fg-2",children:[d.jsx("input",{type:"checkbox",checked:S.includes(F),onChange:V=>C(G=>V.target.checked?[...G,F]:G.filter(K=>K!==F)),className:"size-3.5 accent-(--color-fg-1)"}),d.jsx("code",{className:"font-mono text-label",children:F})]},F))})}),d.jsx(ks,{label:"MCP servers (names, comma-separated)",children:d.jsx(Zt,{value:A,onChange:F=>R(F.target.value),placeholder:"deepwiki",className:"font-mono"})})]}),d.jsx(ks,{label:"Instructions (optional)",children:d.jsx(Zt,{value:M,onChange:F=>_(F.target.value),placeholder:"prepended to the session's system prompt"})}),d.jsx("p",{className:"text-label text-fg-4",children:"Leave capabilities and MCP servers empty to inherit whatever the server's engine factory wired — that factory is the ceiling either way, so a grant here can never exceed it. MCP servers are named, never configured: their transport config (and any credentials in it) stays on the server."})]}):d.jsxs(d.Fragment,{children:[d.jsx(ks,{label:"Config directory",children:d.jsx(Zt,{value:N,onChange:F=>w(F.target.value),placeholder:"/Users/you/.claude",spellCheck:!1,className:"font-mono"})}),d.jsxs("p",{className:"text-label text-fg-4",children:["Must resolve inside the server's"," ",d.jsx("code",{className:"font-mono",children:"allowedConfigDirRoots"})," — a config directory is a credential store, so the server bounds which ones a managed profile may point at."]})]}),d.jsx("div",{className:"flex justify-end",children:d.jsxs(tt,{onClick:()=>void P(),disabled:I,children:[I?d.jsx(Tn,{className:"size-3.5 text-current"}):d.jsx($o,{className:"size-4"}),"Create profile"]})})]})}function epe({open:e,onOpenChange:t,onCreated:n}){return d.jsx(gs,{open:e,onOpenChange:t,children:d.jsxs(bs,{size:"lg",children:[d.jsx(xs,{title:"New profile",description:"What a session runs as — a Claude config directory, or a model provider."}),d.jsx(ys,{children:e?d.jsx(Jhe,{onCreated:n}):null})]})})}function tpe(){const e=As(),t=Id({select:u=>u.location.pathname.match(/^\/profiles\/(.+)$/)?.[1]}),{profiles:n,canManage:r,refresh:s}=Mv(),[a,l]=y.useState(!1),c=r?d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":"New profile",onClick:()=>l(!0),children:d.jsx($o,{className:"size-4"})}):void 0;return d.jsxs(d.Fragment,{children:[d.jsx(Zm,{section:"profiles",title:"Profiles",badge:n.length>0?d.jsx("span",{className:"shrink-0 text-label text-fg-4",children:n.length}):void 0,actions:c,railActions:c,children:d.jsxs(Jm,{children:[n.length===0?d.jsx(Wr,{icon:d.jsx(DF,{}),title:r?"No profiles yet":"No profiles",description:r?d.jsxs(d.Fragment,{children:["Add one with ",d.jsx(qo,{children:"+"})," above."]}):"This gateway declares none, and this login may not add them."}):null,n.map(u=>d.jsx(Rv,{active:u.name===t,onSelect:()=>void e({to:"/profiles/$profileName",params:{profileName:u.name}}),title:u.name,status:u.managed?null:d.jsx(En,{variant:"neutral",className:"shrink-0",children:"declared"}),description:d.jsxs(d.Fragment,{children:[d.jsx(kv,{engine:u.engine??"claude",model:u.defaults?.model??u.provider?.model,className:"size-3 shrink-0 text-fg-3"}),d.jsx("span",{className:"min-w-0 truncate",children:u.configDir??(u.provider?`${u.provider.id}${u.provider.model?` · ${u.provider.model}`:""}`:u.engine??"claude")})]})},u.name))]})}),d.jsx(epe,{open:a,onOpenChange:l,onCreated:u=>{l(!1),s(),e({to:"/profiles/$profileName",params:{profileName:u}})}})]})}function npe({sessions:e,onCreated:t}){const n=w8("session"),[r,s]=y.useState(!1),[a,l]=y.useState(),[c,u]=y.useState(!1),{engine:h}=n,m=async b=>{const x=b?.cwd??n.cwd.trim();if(!x){un.error("Working directory is required");return}s(!0);try{n.rememberCwd(x);const v=await Dr().createSession({...n.sessionFields({prompt:b?void 0:n.prompt.trim()||void 0,resume:b?.sessionId,allowBypass:!0}),cwd:x});t(v.id)}catch(v){un.error(v instanceof Error?v.message:"Failed to create session")}finally{s(!1)}},p=async()=>{if(!n.cwd.trim()){un.error("Set a working directory first — resumable sessions are listed per project");return}u(!0);try{l(await Dr().listSdkSessions({dir:n.cwd.trim(),limit:20,profile:n.profile||void 0}))}catch(b){un.error(b instanceof Error?b.message:"Failed to list resumable sessions")}finally{u(!1)}};return d.jsxs("div",{className:"flex flex-col gap-3",children:[d.jsx(N8,{form:n,sessions:e,promptLabel:"Initial prompt (optional)",onProfileChange:()=>l(void 0),actions:d.jsxs(tt,{className:"ml-auto",onClick:()=>void m(),disabled:r,children:[r?d.jsx(Tn,{className:"size-3.5 text-current"}):d.jsx($o,{className:"size-4"}),"Create"]})}),h.capabilities.listSessions?d.jsxs("div",{className:"mt-1 border-t border-border pt-3",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-label font-medium text-fg-3",children:"Resume a previous session"}),d.jsxs(tt,{variant:"ghost",size:"xs",onClick:()=>void p(),disabled:c,children:[c?d.jsx(Tn,{className:"size-3 text-current"}):d.jsx(IF,{className:"size-3"}),a?"Reload":"Browse"]})]}),a!==void 0?a.length===0?d.jsx("div",{className:"py-3 text-center text-body-sm text-fg-4",children:"No stored sessions for this directory."}):d.jsx("ul",{className:"mt-2 flex flex-col gap-1",children:a.map(b=>d.jsxs("li",{className:"flex items-center gap-2 rounded-md px-2 py-1.5 hover:bg-surface-hover",children:[d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("div",{className:"truncate text-body-sm text-fg-1",children:b.customTitle??b.summary}),d.jsxs("div",{className:"flex gap-2 font-mono text-label text-fg-4",children:[b.gitBranch?d.jsx("span",{className:"truncate",children:b.gitBranch}):null,d.jsx("span",{className:"shrink-0",children:kc(b.lastModified)})]})]}),d.jsx(tt,{variant:"outline",size:"xs",onClick:()=>void m(b),disabled:r,children:"Resume"})]},b.sessionId))}):null]}):null]})}function rpe({open:e,onOpenChange:t,sessions:n,onCreated:r}){return d.jsx(gs,{open:e,onOpenChange:t,children:d.jsxs(bs,{size:"lg",children:[d.jsx(xs,{title:"New session",description:"Pick a directory and an engine."}),d.jsx(ys,{children:d.jsx(npe,{sessions:n,onCreated:r})})]})})}function spe(){return d.jsx("div",{className:"flex flex-1 items-center justify-center p-8",children:d.jsx(Wr,{icon:d.jsx(a8,{}),title:"No session open",description:d.jsxs(d.Fragment,{children:["Pick one on the left, or start a new one with ",d.jsx(qo,{children:"+"})," above."]})})})}const eN="workerdeck.view-config";function ipe(){const[e,t]=y.useState(()=>{try{const r=localStorage.getItem(eN),s=r?JSON.parse(r):{};return{...hx,...s,search:"",scoped:!1}}catch{return{...hx,scoped:!1}}}),n=y.useCallback(r=>{t(r);try{localStorage.setItem(eN,JSON.stringify(r))}catch{}},[]);return[e,n]}function ape(){const e=As(),t=Id({select:_=>_.location.pathname.match(/^\/sessions\/[^/]+\/(.+)$/)?.[1]??void 0}),{snapshots:n,refresh:r}=Ic(),s=jhe(n),a=ZW(s,tc),l=n.filter(_=>_.error!==void 0),c=Qm(),u=n.find(_=>_.host.id===c?.id)?.sessions??[],h=_=>{c&&e({to:"/sessions/$hostId/$sessionId",params:{hostId:c.id,sessionId:_},search:{}})},[m,p]=ipe(),[b,x]=y.useState(!1),[v,N]=y.useState(Ehe),w=y.useMemo(()=>W_(s,m),[s,m]),S=_=>void e({to:"/sessions/$hostId/$sessionId",params:{hostId:_.hostId,sessionId:_.info.id},search:{}}),C=y.useRef(0),A=(_,I)=>void e({to:"/sessions/$hostId/$sessionId",params:{hostId:_.hostId,sessionId:_.info.id},search:{subagent:I,sn:++C.current}}),R=(_,I)=>{tc(_.hostId)?.updateSession(_.info.id,{title:I||null}).then(()=>r()).catch(j=>un.error(j instanceof Error?j.message:"Rename failed"))},M=d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":"New session",onClick:()=>x(!0),children:d.jsx($o,{className:"size-4"})});return d.jsxs(d.Fragment,{children:[d.jsxs(Zm,{section:"sessions",title:"Sessions",railActions:M,actions:d.jsxs(d.Fragment,{children:[d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":v?"Hide filters":"Show filters","aria-pressed":v,onClick:()=>{N(!v),The(!v)},children:d.jsx(dF,{className:ve("size-3.5",v&&"fill-current text-fg-1")})}),d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":"Refresh",onClick:()=>void r(),children:d.jsx(Sm,{className:"size-3.5"})}),M]}),rail:w.map(_=>d.jsxs("button",{type:"button",title:`${uc(_.info)} — ${_.state}`,"aria-label":uc(_.info),onClick:()=>S(_),className:ve("flex w-full flex-col items-center gap-0.5 border-l-2 py-1.5",_.info.id===t?"border-l-accent bg-row-active":"border-l-transparent hover:bg-row-hover"),children:[d.jsx(kv,{engine:_.adapter,model:_.info.model,className:"size-4"}),d.jsx(e8,{row:_})]},_.info.id)),children:[l.map(({host:_,error:I})=>d.jsxs("div",{className:"mx-2 mb-2 rounded-md bg-danger-bg px-2 py-1.5 text-label text-danger",children:["Can’t reach ",_.name,": ",I]},_.id)),d.jsx(Jm,{children:d.jsx(the,{rows:s,config:m,onConfigChange:p,showControls:v,projectIcons:a,activeId:t,onSelect:S,onSelectSubagent:A,onRename:R,onDelete:_=>{tc(_.hostId)?.deleteSession(_.info.id).then(()=>r()).catch(I=>un.error(I instanceof Error?I.message:"Delete failed"))},emptyState:d.jsx(Wr,{icon:d.jsx(wp,{}),title:"No sessions yet",description:d.jsxs(d.Fragment,{children:["Start one with ",d.jsx(qo,{children:"+"})," above."]})})})})]}),d.jsx(rpe,{open:b,onOpenChange:x,sessions:u,onCreated:_=>{x(!1),h(_),r()}})]})}const tN=[{id:"sessions",label:"Sessions",icon:eq,path:"/sessions",sidebar:ape},{id:"gateways",label:"Gateways",icon:Tm,path:"/gateways",sidebar:Dhe},{id:"jobs",label:"Jobs",icon:e_,path:"/jobs",sidebar:Xhe},{id:"profiles",label:"Profiles",icon:T2,path:"/profiles",sidebar:tpe}],nN="workerdeck.sidebar-collapsed";function ope({children:e}){const t=Id({select:p=>p.location.pathname}),n=[...tN].sort((p,b)=>b.path.length-p.path.length).find(p=>t.startsWith(p.path)),r=n?.sidebar,[s,a]=y.useState(!1),[l,c]=y.useState(()=>{try{return localStorage.getItem(nN)==="1"}catch{return!1}}),u=()=>{c(p=>{try{localStorage.setItem(nN,p?"0":"1")}catch{}return!p})},h="flex size-7 items-center justify-center rounded-md text-fg-3 transition-colors outline-none hover:bg-row-hover hover:text-fg-1",m=p=>ve("flex items-center rounded-md text-body-sm transition-colors outline-none",l?"justify-center p-2":"gap-2 px-2 py-1.5",p?"bg-surface font-medium text-fg-1 shadow-(--shadow-xs)":"text-fg-3 hover:bg-row-hover hover:text-fg-1");return d.jsxs("div",{className:"flex h-dvh bg-sidebar",children:[d.jsxs("aside",{className:ve("flex shrink-0 flex-col gap-1 p-3 transition-[width] duration-150",l?"w-14 items-center":"w-52"),children:[d.jsxs("div",{className:ve("flex items-center py-2",l?"justify-center":"gap-2 px-2"),children:[d.jsx(a8,{className:"size-4 shrink-0 text-fg-1"}),!l&&d.jsx("span",{className:"text-body-sm font-semibold tracking-tight text-fg-1",children:"workerdeck"})]}),d.jsx("nav",{className:ve("mt-1 flex flex-1 flex-col gap-0.5",l&&"items-center"),children:tN.map(p=>d.jsxs(em,{to:p.path,title:l?p.label:void 0,"aria-label":p.label,onClick:b=>{p.id===n?.id&&b.preventDefault()},className:m(p.id===n?.id),children:[d.jsx(p.icon,{className:"size-4 shrink-0"}),!l&&p.label]},p.id))}),d.jsxs("div",{className:ve("mt-1 grid place-items-center gap-1",l?"grid-rows-3":"grid-cols-3"),children:[d.jsx("button",{type:"button",onClick:()=>a(!0),title:"Settings","aria-label":"Settings",className:h,children:d.jsx(MV,{className:"size-4"})}),d.jsx(t8,{}),d.jsx("button",{type:"button",onClick:u,title:l?"Expand sidebar":"Collapse sidebar","aria-label":l?"Expand sidebar":"Collapse sidebar",className:h,children:l?d.jsx(v2,{className:"size-4"}):d.jsx(y2,{className:"size-4"})})]})]}),d.jsxs("div",{className:"app-frame frame-shine m-2 ml-0 flex min-w-0 flex-1 overflow-hidden rounded-xl",children:[r?d.jsx(r,{},n?.id):null,d.jsx("main",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:e??d.jsx(qN,{})})]}),d.jsx(lhe,{open:s,onOpenChange:a})]})}function Ov({crumbs:e,actions:t,children:n}){return d.jsxs("div",{className:"flex h-11 shrink-0 items-center gap-2 border-b border-border bg-surface px-3",children:[d.jsx("nav",{"aria-label":"Breadcrumb",className:"flex min-w-0 items-center gap-1",children:e.map((r,s)=>d.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[s>0?d.jsx(Tc,{"aria-hidden":!0,className:"size-3 shrink-0 text-fg-4"}):null,r.to?d.jsx(em,{to:r.to,className:"shrink-0 text-body-sm text-fg-3 outline-none hover:text-fg-1",children:r.label}):d.jsx("span",{"aria-current":"page",className:"min-w-0 truncate text-body-sm font-medium text-fg-1",title:r.label,children:r.label})]},r.label))}),n,d.jsx("span",{className:"flex-1"}),t]})}function A8({children:e}){return d.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:d.jsx("div",{className:"mx-auto flex w-full max-w-3xl flex-col gap-5 px-6 py-6",children:e})})}function Uu({label:e,children:t}){return d.jsxs("div",{className:"flex items-baseline justify-between gap-4 py-1.5",children:[d.jsx("span",{className:"shrink-0 text-label font-medium text-fg-3",children:e}),d.jsx("span",{className:"min-w-0 text-right text-body-sm text-fg-1",children:t})]})}function lpe(){const{hostId:e}=gc({from:"/gateways/$hostId"}),t=As(),{hosts:n,ready:r}=Av(),{snapshots:s}=Ic(),[a,l]=y.useState(!1),c=n.find(m=>m.id===e),u=s.find(m=>m.host.id===e);if(y.useEffect(()=>{!r||c||t({to:"/gateways"})},[r,c,t]),!c)return null;const h=u===void 0?"pending":u.error?"error":"ok";return d.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[d.jsx(Ov,{crumbs:[{label:"Gateways",to:"/gateways"},{label:c.name}],actions:c.implicit?null:d.jsxs(tt,{variant:"outline",size:"xs",onClick:()=>l(!0),children:[d.jsx(Dd,{className:"size-3"}),"Remove"]}),children:d.jsx("span",{className:"min-w-0 truncate font-mono text-label text-fg-4",title:c.baseUrl,children:c.baseUrl})}),d.jsxs(A8,{children:[d.jsxs(bo,{children:[d.jsx(xo,{children:d.jsx(yo,{children:"Connection"})}),d.jsxs(vo,{className:"flex flex-col divide-y divide-border",children:[d.jsx(Uu,{label:"Status",children:h==="ok"?d.jsx(En,{variant:"success",dot:!0,children:"Connected"}):h==="error"?d.jsx(En,{variant:"danger",dot:!0,children:"Unreachable"}):d.jsx(En,{variant:"neutral",dot:!0,children:"Connecting…"})}),u?.error?d.jsx(Uu,{label:"Last error",children:d.jsx("span",{className:"text-danger",children:u.error})}):null,d.jsx(Uu,{label:"Live sessions",children:u?u.sessions.length:d.jsx("span",{className:"text-fg-4",children:"—"})}),d.jsx(Uu,{label:"Reachability",children:f8(c)?"This machine (loopback)":"Remote"}),d.jsx(Uu,{label:"Credential",children:c.implicit?d.jsx("span",{className:"text-fg-4",children:"the login cookie it set — same origin"}):d.jsx("span",{className:"text-fg-4",children:"an auth key held in this browser"})})]})]}),c.implicit?d.jsx("p",{className:"text-label text-fg-4",children:"This is the gateway that served the page. Its address is this origin and its credential is the cookie it already set, so there is nothing here to change — and nothing to remove, since removing it would just be closing the tab."}):d.jsxs(bo,{children:[d.jsx(xo,{children:d.jsx(yo,{children:"Settings"})}),d.jsx(vo,{children:d.jsx(m8,{host:c,onSaved:m=>un.success(`Saved ${m.name}`)},c.id)})]}),a?d.jsx(g8,{host:c,onClose:()=>l(!1),onRemoved:()=>{l(!1),t({to:"/gateways"})}}):null]})]})}function cpe(){return d.jsx("div",{className:"flex flex-1 items-center justify-center p-8",children:d.jsx(Wr,{icon:d.jsx(Tm,{}),title:"No gateway selected",description:d.jsxs(d.Fragment,{children:["Pick one on the left, or add one with ",d.jsx(qo,{children:"+"})," above."]})})})}function upe({files:e,activePath:t,onActivate:n,onClose:r,className:s}){return d.jsx(ZY,{delay:500,closeDelay:0,children:d.jsx("div",{"data-slot":"editor-tabs",role:"tablist","aria-label":"Open files",className:ve("flex shrink-0 items-stretch overflow-x-auto border-b border-border bg-surface",s),children:e.map(a=>d.jsx(dpe,{file:a,active:a.path===t,onActivate:()=>n(a.path),onClose:()=>r(a.path),onArrow:l=>{const c=e.findIndex(h=>h.path===a.path),u=e[c+l];u&&n(u.path)}},a.path))})})}function dpe({file:e,active:t,onActivate:n,onClose:r,onArrow:s}){const a=Cd(e),l=y.useRef(null);y.useEffect(()=>{t&&l.current?.scrollIntoView({block:"nearest",inline:"nearest"})},[t]);const c=u=>{u.button===1&&(u.preventDefault(),r())};return d.jsxs(w2,{side:"bottom",render:d.jsx("div",{ref:l,role:"tab",tabIndex:t?0:-1,"aria-selected":t,onClick:n,onAuxClick:c,onKeyDown:u=>{if(u.key==="ArrowRight")s(1);else if(u.key==="ArrowLeft")s(-1);else if(u.key==="Enter"||u.key===" ")n();else return;u.preventDefault()},className:ve("group flex min-w-0 shrink-0 cursor-pointer items-center gap-1.5 border-r border-border px-3 py-1.5 transition-colors","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent focus-visible:ring-inset",t?"bg-bg text-fg-1":"text-fg-3 hover:bg-surface-hover hover:text-fg-2")}),content:d.jsxs("span",{className:"flex flex-col gap-0.5",children:[d.jsx("span",{className:"font-mono break-all",children:e.path}),e.bytes!==void 0?d.jsx("span",{className:"text-fg-4",children:Li(e.bytes)}):null]}),children:[d.jsx("span",{className:ve("max-w-40 truncate font-mono text-label",a&&"italic"),children:e.name}),e.status==="error"?d.jsx("span",{className:"shrink-0 text-danger",children:"!"}):null,d.jsxs("button",{type:"button","aria-label":a?`Close ${e.name} (unsaved changes)`:`Close ${e.name}`,onClick:u=>{u.stopPropagation(),r()},className:ve("shrink-0 rounded p-0.5 text-fg-4 transition-opacity hover:bg-surface-hover hover:text-fg-1",t||a?"opacity-70":"opacity-0 group-hover:opacity-70 focus-visible:opacity-100"),children:[d.jsx("span",{className:ve("block",a&&"group-hover:hidden"),children:a?d.jsx("span",{className:"block size-3 rounded-full bg-fg-2"}):d.jsx(_s,{className:"size-3"})}),a?d.jsx("span",{className:"hidden group-hover:block",children:d.jsx(_s,{className:"size-3"})}):null]})]})}const R8=12;function fpe({tree:e,search:t,activePath:n,onOpenFile:r,onCollapse:s,style:a,className:l}){const[c,u]=y.useState(""),[h,m]=y.useState(),p=c.trim().length>0;return y.useEffect(()=>{if(!t?.available)return;const b=c.trim();if(!b){m(void 0);return}const x=new AbortController,v=setTimeout(()=>{t.search(b,{limit:60,signal:x.signal}).then(N=>{x.signal.aborted||m(N)})},150);return()=>{x.abort(),clearTimeout(v)}},[t,c]),d.jsxs("div",{"data-slot":"file-tree",style:a,className:ve("flex min-h-0 min-w-0 flex-col bg-surface",l),children:[d.jsxs("div",{className:"flex items-center gap-1 px-2 pt-2",children:[t?.available?d.jsxs("div",{className:"relative min-w-0 flex-1",children:[d.jsx(km,{className:"absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-fg-4"}),d.jsx(Zt,{value:c,onChange:b=>u(b.target.value),placeholder:"Search files…",className:"h-7 pr-7 pl-7 text-label",spellCheck:!1}),p?d.jsx("button",{type:"button",onClick:()=>u(""),"aria-label":"Clear search",className:"absolute top-1/2 right-1.5 -translate-y-1/2 text-fg-4 transition-colors hover:text-fg-2",children:d.jsx(_s,{className:"size-3.5"})}):null]}):d.jsx("span",{className:"min-w-0 flex-1 truncate px-1 text-label text-fg-4",children:e.root}),d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":"Refresh the file tree",onClick:()=>e.refresh(),children:d.jsx(Sm,{className:"size-3.5 text-fg-3"})}),s?d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":"Hide project files",onClick:s,children:d.jsx(y2,{className:"size-3.5 text-fg-3"})}):null]}),d.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-1 py-1",children:e.error?d.jsx("p",{className:"px-2 py-3 text-body-sm text-danger",children:e.error}):p?h===void 0?d.jsx("div",{className:"py-6 text-center",children:d.jsx(Tn,{className:"size-4 text-fg-4"})}):h.length===0?d.jsx("p",{className:"px-2 py-6 text-center text-body-sm text-fg-4",children:"No matching files."}):d.jsx("ul",{children:h.map(b=>d.jsx("li",{children:d.jsx(rN,{label:hpe(b.relative),detail:ppe(b.relative),title:b.relative,icon:d.jsx(vm,{className:"size-3.5 shrink-0 text-fg-4"}),active:b.path===n,onClick:()=>r(b.path)})},b.path))}):e.loading?d.jsx("div",{className:"py-6 text-center",children:d.jsx(Tn,{className:"size-4 text-fg-4"})}):e.rows.length===0?d.jsx("p",{className:"px-2 py-6 text-center text-body-sm text-fg-4",children:"This project is empty."}):d.jsx("ul",{role:"tree","aria-label":"Project files",children:e.rows.map(b=>d.jsxs("li",{role:"treeitem","aria-expanded":b.expanded,"aria-level":b.depth+1,children:[d.jsx(rN,{label:b.entry.name,indent:b.depth,active:b.entry.path===n,icon:b.entry.type==="dir"?b.loading?d.jsx(Tn,{className:"size-3.5 shrink-0 text-fg-4"}):b.expanded?d.jsx(sF,{className:"size-3.5 shrink-0 text-accent"}):d.jsx(Em,{className:"size-3.5 shrink-0 text-accent"}):d.jsx(mpe,{type:b.entry.type}),chevron:b.entry.type==="dir"?d.jsx(Tc,{className:ve("size-3 shrink-0 text-fg-4 transition-transform",b.expanded&&"rotate-90")}):void 0,onClick:()=>b.entry.type==="dir"?e.toggle(b.entry.path):r(b.entry.path)}),b.truncated?d.jsx("p",{className:"truncate py-0.5 text-label text-fg-4",style:{paddingLeft:(b.depth+1)*R8+22},children:"More entries than the server will return — use search."}):null]},b.entry.path))})})]})}function rN({label:e,detail:t,title:n,icon:r,chevron:s,indent:a=0,active:l,onClick:c}){const u=y.useRef(null);return y.useEffect(()=>{l&&u.current?.scrollIntoView({block:"nearest"})},[l]),d.jsxs("button",{ref:u,type:"button",onClick:c,title:n??e,style:{paddingLeft:a*R8+4},className:ve("flex w-full items-center gap-1 rounded py-1 pr-2 text-left transition-colors",l?"bg-surface-hover text-fg-1":"text-fg-2 hover:bg-surface-hover"),children:[d.jsx("span",{className:"flex size-3 shrink-0 items-center justify-center",children:s}),r,d.jsx("span",{className:"shrink-0 truncate text-label",children:e}),t?d.jsx("span",{className:"min-w-0 flex-1 truncate text-label text-fg-4",children:t}):null]})}function hpe(e){return e.slice(e.lastIndexOf("/")+1)}function ppe(e){const t=e.lastIndexOf("/");return t===-1?void 0:e.slice(0,t)}function mpe({type:e}){return e==="symlink"?d.jsx(J6,{className:"size-3.5 shrink-0 text-fg-4"}):d.jsx(vm,{className:"size-3.5 shrink-0 text-fg-4"})}function gpe({path:e,value:t,onChange:n,onSave:r,readOnly:s,className:a}){const l=y.useRef(null),c=y.useRef(null),u=y.useRef(null),[h,m]=y.useState(!1),p=bpe(),b=y.useRef({onChange:n,onSave:r});return b.current={onChange:n,onSave:r},y.useEffect(()=>{let x=!1;return xpe().then(v=>{if(x||!l.current)return;u.current=v;const N=v.editor.create(l.current,{value:t,language:aN(e),readOnly:s,automaticLayout:!0,theme:sN(document.documentElement.getAttribute("data-theme")),minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:12,lineHeight:20,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace',renderLineHighlight:"line",smoothScrolling:!0,padding:{top:8,bottom:8},scrollbar:{verticalScrollbarSize:10,horizontalScrollbarSize:10},wordBasedSuggestions:"off",quickSuggestions:!1});c.current=N,N.onDidChangeModelContent(()=>{b.current.onChange?.(N.getValue())}),N.addCommand(v.KeyMod.CtrlCmd|v.KeyCode.KeyS,()=>{b.current.onSave?.()}),m(!0)}),()=>{x=!0,c.current?.dispose(),c.current=null,m(!1)}},[]),y.useEffect(()=>{const x=u.current,v=c.current;if(!x||!v||!h)return;const N=x.Uri.parse(`workerdeck://host${e}`),w=x.editor.getModel(N)??x.editor.createModel(t,aN(e),N);v.getModel()!==w&&v.setModel(w)},[e,h,t]),y.useEffect(()=>{const x=c.current;if(!x||!h)return;const v=x.getModel();!v||v.getValue()===t||v.pushEditOperations([],[{range:v.getFullModelRange(),text:t}],()=>null)},[t,h]),y.useEffect(()=>{h&&c.current?.updateOptions({readOnly:s})},[s,h]),y.useEffect(()=>{h&&u.current?.editor.setTheme(sN(p))},[p,h]),d.jsxs("div",{className:ve("relative min-h-0 min-w-0 flex-1",a),children:[d.jsx("div",{ref:l,className:"absolute inset-0"}),h?null:d.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bg",children:d.jsx(Tn,{className:"size-4 text-fg-4"})})]})}function bpe(){const[e,t]=y.useState(()=>typeof document>"u"?null:document.documentElement.getAttribute("data-theme"));return y.useEffect(()=>{const n=document.documentElement,r=()=>t(n.getAttribute("data-theme"));r();const s=new MutationObserver(r);return s.observe(n,{attributes:!0,attributeFilter:["data-theme"]}),()=>s.disconnect()},[]),e}function sN(e){return e==="light"?"wd-light":"wd-dark"}let iN;function xpe(){return iN??=(async()=>{const e=await fc(()=>import("./index-DEmlzO4U.js"),__vite__mapDeps([0,1]));return e.editor.defineTheme("wd-dark",{base:"vs-dark",inherit:!0,rules:[],colors:{"editor.background":"#00000000"}}),e.editor.defineTheme("wd-light",{base:"vs",inherit:!0,rules:[],colors:{"editor.background":"#00000000"}}),e})(),iN}function aN(e){const t=e.slice(e.lastIndexOf("/")+1),n=ype[t.toLowerCase()];if(n)return n;const r=t.slice(t.lastIndexOf(".")+1).toLowerCase();return vpe[r]??"plaintext"}const ype={dockerfile:"dockerfile",makefile:"plaintext",".gitignore":"plaintext",".env":"shell"},vpe={ts:"typescript",tsx:"typescript",mts:"typescript",cts:"typescript",js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",json:"json",jsonc:"json",md:"markdown",mdx:"markdown",css:"css",scss:"scss",less:"less",html:"html",htm:"html",xml:"xml",svg:"xml",yml:"yaml",yaml:"yaml",toml:"plaintext",sh:"shell",bash:"shell",zsh:"shell",fish:"shell",py:"python",rb:"ruby",rs:"rust",go:"go",swift:"swift",java:"java",kt:"kotlin",c:"c",h:"c",cpp:"cpp",cc:"cpp",hpp:"cpp",cs:"csharp",php:"php",sql:"sql",graphql:"graphql",gql:"graphql",lua:"lua",r:"r",pl:"perl",dart:"dart",scala:"scala",ini:"ini",cfg:"ini",conf:"ini",txt:"plaintext",log:"plaintext"};function Epe({file:e,canWrite:t,onChange:n,onSave:r,onRevert:s,onReload:a,onOverwrite:l,onDismissConflict:c,className:u}){return e?d.jsxs("div",{"data-slot":"file-viewer",className:ve("flex min-h-0 min-w-0 flex-1 flex-col bg-bg",u),children:[e.conflict?d.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 border-b border-warning/40 bg-warning-bg px-3 py-2",children:[d.jsx(Jl,{className:"size-3.5 shrink-0 text-warning"}),d.jsx("span",{className:"min-w-0 flex-1 text-body-sm text-warning",children:"This file changed on disk since you opened it."}),d.jsx(tt,{variant:"outline",size:"xs",onClick:()=>a?.(e.path),children:"Use the version on disk"}),d.jsx(tt,{variant:"outline",size:"xs",onClick:()=>l?.(e.path),children:"Keep mine"}),d.jsx(tt,{variant:"ghost",size:"xs",onClick:()=>c?.(e.path),children:"Dismiss"})]}):e.saveError?d.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-danger/40 bg-danger-bg px-3 py-2",children:[d.jsx(Jl,{className:"size-3.5 shrink-0 text-danger"}),d.jsx("span",{className:"min-w-0 flex-1 text-body-sm text-danger",children:e.saveError}),d.jsx(tt,{variant:"ghost",size:"xs",onClick:()=>c?.(e.path),children:"Dismiss"})]}):null,e.status==="loading"?d.jsx(Db,{children:d.jsx(Tn,{className:"size-4 text-fg-4"})}):e.status==="error"?d.jsxs(Db,{children:[d.jsx(Jl,{className:"size-4 text-danger"}),d.jsx("p",{className:"text-body-sm text-danger",children:e.error})]}):e.status==="binary"?d.jsxs(Db,{children:[d.jsx(KU,{className:"size-4 text-fg-4"}),d.jsx("p",{className:"text-body-sm text-fg-4",children:"This file isn’t text."}),d.jsx("p",{className:"text-label text-fg-4",children:"It can’t be edited here without corrupting it."})]}):d.jsx(gpe,{path:e.path,value:bx(e),readOnly:!t,onChange:n?h=>n(e.path,h):void 0,onSave:r?()=>r(e.path):void 0}),e.status==="ready"&&(e.saving||Cd(e)||!t)?d.jsx("div",{className:"flex shrink-0 items-center gap-2 border-t border-border px-3 py-1",children:e.saving?d.jsxs(d.Fragment,{children:[d.jsx(Tn,{className:"size-3 text-fg-4"}),d.jsx("span",{className:"text-label text-fg-4",children:"Saving…"})]}):t?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"text-label text-fg-3",children:"Unsaved changes"}),d.jsx("span",{className:"flex-1"}),d.jsx(tt,{variant:"ghost",size:"xs",onClick:()=>s?.(e.path),children:"Revert"}),d.jsxs(tt,{variant:"outline",size:"xs",onClick:()=>r?.(e.path),children:["Save",d.jsx("span",{className:"ml-1 text-fg-4",children:"⌘S"})]})]}):d.jsx("span",{className:"text-label text-fg-4",children:"Read-only — this gateway doesn’t allow writes."})}):null]}):null}function Db({children:e}){return d.jsx("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-2 p-6",children:e})}const oN="wd-path-link",Tpe=/^(\/[^\s:'"`()[\]{}]+|[\w.@~-]+(?:\/[\w.@~-]+)+)(?::(\d+))?$/,Spe=/^([\w.@-]+\.[A-Za-z0-9]{1,10})(?::(\d+))?$/,kpe=.6;function Cpe(e,t){const n=e.trim();if(!n||n.endsWith("/"))return;const r=Tpe.exec(n)??(t?Spe.exec(n):null);if(r)return{path:r[1],line:r[2]?Number(r[2]):void 0}}function lN(e){if(!e)return;const t=e.closest("code")!==null,n=e.textContent??"",r=Cpe(n,t);if(r&&!(!t&&r.path.length<n.trim().length*kpe))return r}function wpe({container:e,onOpen:t,enabled:n=!0,ignore:r}){y.useEffect(()=>{const s=e.current;if(!s||!n)return;const a=p=>p?.closest(r)!==null&&p!==void 0;let l;const c=()=>{l?.classList.remove(oN),l=void 0},u=p=>{if(!p.metaKey&&!p.ctrlKey)return;const b=p.target instanceof HTMLElement?p.target:void 0;if(a(b))return;const x=lN(b);x&&(p.preventDefault(),p.stopPropagation(),c(),t(x))},h=p=>{if(!p.metaKey&&!p.ctrlKey)return c();const b=p.target instanceof HTMLElement?p.target:void 0;b!==l&&(c(),!(!b||a(b)||!lN(b))&&(l=b,b.classList.add(oN)))},m=p=>{!p.metaKey&&!p.ctrlKey&&c()};return s.addEventListener("click",u,!0),s.addEventListener("mousemove",h),document.addEventListener("keydown",m),document.addEventListener("keyup",m),window.addEventListener("blur",c),()=>{c(),s.removeEventListener("click",u,!0),s.removeEventListener("mousemove",h),document.removeEventListener("keydown",m),document.removeEventListener("keyup",m),window.removeEventListener("blur",c)}},[e,t,n,r])}function Npe(e,t){return e.startsWith("/")||!t?e:`${t.replace(/\/$/,"")}/${e.replace(/^\.\//,"")}`}const _pe=180,Ape=520,Rpe=220,cN=120;function M8({client:e,sessionId:t,header:n,transcriptVariant:r,transcriptDensity:s,transcriptFont:a,scrubber:l,scrubberMarks:c,stickyPrompt:u,openSubagent:h,statusPlacement:m,controlsSurface:p,unseen:b,readOnly:x,onVitals:v,defaultRailWidth:N=260,defaultRailCollapsed:w,onRailChange:S,className:C}){const{info:A}=nA(e,t),R=A?.cwd,M=QW(e,R),_=tA(e,R),I=tX(e),{canWrite:j}=XW(e);y.useEffect(()=>{if(!I.hasUnsaved)return;const le=ge=>ge.preventDefault();return window.addEventListener("beforeunload",le),()=>window.removeEventListener("beforeunload",le)},[I.hasUnsaved]);const z=Ipe(),[P,F]=y.useState(w??!1),[V,G]=y.useState(N),K=y.useRef(S);K.current=S,y.useEffect(()=>{K.current?.({width:V,collapsed:P})},[V,P]);const[Y,U]=y.useState(360),Q=I.files.length>0,W=!z,ue=M.available&&!P;y.useEffect(()=>{W&&F(!0)},[W]);const D=y.useCallback(le=>{const ge=I.files.find(Pe=>Pe.path===le);if(ge&&Cd(ge)){const Pe=ge.name;if(!window.confirm(`${Pe} has unsaved changes. Close it and lose them?`))return}I.close(le)},[I]),H=y.useRef(null),B=Mpe(H),L=y.useCallback(({path:le})=>I.open(Npe(le,R)),[I.open,R]);wpe({container:H,onOpen:L,enabled:M.available,ignore:".monaco-editor"});const te=Math.max(cN,B-Rpe),[ne,de]=y.useState(null),oe=n===void 0||ne===null?void 0:typeof n=="function"?le=>ir.createPortal(n(le),ne):ir.createPortal(n,ne);return d.jsxs("div",{"data-slot":"session-workspace",className:ve("flex h-full min-h-0 w-full flex-col overflow-hidden bg-bg",C),children:[n!==void 0?d.jsx("div",{ref:de,className:"shrink-0"}):null,d.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[ue?d.jsx(fpe,{tree:M,search:_,activePath:I.activePath,onOpenFile:I.open,onCollapse:()=>F(!0),style:{width:W?Math.min(V,320):V},className:ve("shrink-0 border-r border-border",W&&"absolute inset-y-0 left-0 z-20 shadow-lg")}):M.available?d.jsx("div",{className:"flex w-8 shrink-0 flex-col items-center border-r border-border bg-surface pt-1.5",children:d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":"Show project files",onClick:()=>F(!1),children:d.jsx(v2,{className:"size-4 text-fg-3"})})}):null,ue&&!W?d.jsx(lx,{orientation:"vertical",value:V,onValueChange:G,min:_pe,max:Ape,defaultValue:N,"aria-label":"Resize the file tree"}):null,d.jsxs("div",{ref:H,className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[Q?d.jsxs("div",{className:"flex min-h-0 shrink-0 flex-col overflow-hidden",style:{height:Math.min(Y,te||Y)},children:[d.jsx(upe,{files:I.files,activePath:I.activePath,onActivate:I.activate,onClose:D}),d.jsx(Epe,{file:I.active,canWrite:j,onChange:I.edit,onSave:le=>void I.save(le),onRevert:I.revert,onReload:I.reload,onOverwrite:le=>void I.overwrite(le),onDismissConflict:I.dismissConflict})]}):null,Q?d.jsx(lx,{orientation:"horizontal",value:Math.min(Y,te||Y),onValueChange:U,min:cN,max:te,"aria-label":"Resize the open file"}):null,d.jsx(zfe,{client:e,sessionId:t,header:oe,transcriptVariant:r,transcriptDensity:s,transcriptFont:a,scrubber:l,scrubberMarks:c,stickyPrompt:u,openSubagent:h,controlsSurface:p,statusPlacement:m,unseen:b,readOnly:x,onVitals:v,className:"min-h-0 flex-1"})]}),W&&ue?d.jsx("button",{type:"button","aria-label":"Close the file tree",onClick:()=>F(!0),className:"absolute inset-0 z-10 bg-black/30"}):null]})]})}function Mpe(e){const[t,n]=y.useState(0);return y.useLayoutEffect(()=>{const r=e.current;if(!r)return;const s=new ResizeObserver(([a])=>{a&&n(a.contentRect.height)});return s.observe(r),()=>s.disconnect()},[e]),t}function Ipe(){const[e,t]=y.useState(!0);return y.useEffect(()=>{const n=window.matchMedia("(min-width: 768px)"),r=()=>t(n.matches);return r(),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}const I8="workerdeck.rail",uN={width:260,collapsed:!1};function O8(){try{const e=localStorage.getItem(I8),t=e?JSON.parse(e):{};return{width:Math.min(520,Math.max(180,Number(t.width)||uN.width)),collapsed:t.collapsed===!0}}catch{return uN}}function L8(e){try{localStorage.setItem(I8,JSON.stringify(e))}catch{}}function Ope(){const{jobId:e}=gc({from:"/jobs/$jobId"}),t=As(),{jobs:n,refresh:r}=Iv(),{snapshots:s}=Ic(),a=n.find(w=>w.id===e),l=Dr(),c=Qm()?.id,u=a?.sessionId!==void 0&&(s.find(w=>w.host.id===c)?.sessions.some(w=>w.id===a.sessionId)??!1),[h,m]=y.useState(!1);y.useEffect(()=>{n.length>0&&m(!0)},[n.length]),y.useEffect(()=>{!h||a||(un.error("That job is no longer in the queue"),t({to:"/jobs"}))},[h,a,t]);const[p]=y.useState(Cv),[b]=y.useState(qp),[x]=y.useState(wv),[v]=y.useState(O8);if(!a)return null;const N=d.jsx(dN,{job:a,onChanged:()=>void r()});return!l||!u||!a.sessionId?d.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[N,d.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 p-8 text-center",children:[d.jsx("p",{className:"text-body-sm text-fg-3",children:a.sessionId?"This job’s session is no longer on the gateway.":"This job never got as far as a session."}),d.jsx("p",{className:"max-w-md text-label text-fg-4",children:"The queue keeps the job record — status, usage, error — but the transcript lives with the session, and that one has been closed or swept."})]})]}):d.jsx(M8,{client:l,sessionId:a.sessionId,readOnly:!0,transcriptVariant:b,transcriptDensity:p,transcriptFont:x,scrubber:!0,stickyPrompt:!0,statusPlacement:"bottom",defaultRailWidth:v.width,defaultRailCollapsed:v.collapsed,onRailChange:L8,header:({actions:w})=>d.jsx(dN,{job:a,onChanged:()=>void r(),actions:w})},a.sessionId)}function dN({job:e,onChanged:t,actions:n}){const r=_8[e.status],s=e.status==="queued"||e.status==="running"||e.status==="parked",a=async()=>{try{await Dr().cancelJob(e.id),t()}catch(l){un.error(l instanceof Error?l.message:"Cancel failed")}};return d.jsxs(Ov,{crumbs:[{label:"Jobs",to:"/jobs"},{label:e.prompt}],actions:d.jsxs(d.Fragment,{children:[d.jsx(En,{variant:"neutral",className:"shrink-0",children:"read-only"}),d.jsx(Sd,{value:e.id,"aria-label":"Copy job id"}),s?d.jsxs(tt,{variant:"outline",size:"xs",onClick:()=>void a(),children:[d.jsx(_s,{className:"size-3"}),"Cancel"]}):null,n]}),children:[d.jsxs(En,{variant:r.variant,dot:!r.busy,className:"shrink-0",children:[r.busy?d.jsx(Tn,{className:"size-3 text-current"}):null,r.label]}),d.jsxs("div",{className:"flex min-w-0 items-center gap-x-3 font-mono text-label text-fg-4",children:[d.jsx("span",{className:"truncate",children:e.cwd}),e.profile?d.jsxs("span",{className:"shrink-0",children:["@",e.profile]}):null,d.jsx("span",{className:"shrink-0",children:kc(e.finishedAt??e.startedAt??e.createdAt)}),e.maxAttempts!==void 0&&e.maxAttempts>1?d.jsxs("span",{className:"shrink-0",children:["attempt ",e.attempt??1,"/",e.maxAttempts,e.status==="queued"&&e.nextRunAt!==void 0&&e.nextRunAt>Date.now()?" — retry pending":""]}):null,e.usage.tokens>0?d.jsxs("span",{className:"shrink-0",children:[Gr(e.usage.tokens)," tok"]}):null,e.usage.totalCostUsd>0?d.jsx("span",{className:"shrink-0",children:Js(e.usage.totalCostUsd)}):null,e.error?d.jsx("span",{className:"truncate text-danger",children:e.error}):null]})]})}const Lpe=["web_search","download","web_fetch","deliver_file"],Gh=e=>e.split(",").map(t=>t.trim()).filter(Boolean);function ma({label:e,children:t}){return d.jsxs("label",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[d.jsx("span",{className:"text-label font-medium text-fg-3",children:e}),t]})}function jpe({profile:e,onSaved:t}){const n=e.engine==="provider",[r,s]=y.useState(e.description??""),[a,l]=y.useState(e.defaults?.model??""),[c,u]=y.useState(e.defaults?.permissionMode),[h,m]=y.useState(e.provider?.model??""),[p,b]=y.useState((e.provider?.models??[]).join(", ")),[x,v]=y.useState(e.session?.capabilities),[N,w]=y.useState((e.session?.mcpServers??[]).join(", ")),[S,C]=y.useState(e.session?.instructions??""),[A,R]=y.useState(!1),M=C8(e,c??"default",a),_=M.models.map(j=>j.value==="default"?{...j,displayName:"Unset",description:e.defaultModel??"whatever the engine's own config picks"}:j),I=async()=>{const j={description:r.trim()||void 0,defaults:{model:a.trim()||void 0,permissionMode:c}};n&&(j.provider={...e.provider,id:e.provider?.id??"",model:h.trim()||void 0,models:Gh(p).length>0?Gh(p):void 0},j.session={capabilities:x,mcpServers:Gh(N).length>0?Gh(N):void 0,instructions:S.trim()||void 0}),R(!0);try{t(await Dr().updateProfile(e.name,j)),un.success("Profile saved")}catch(z){un.error(z instanceof Error?z.message:"Failed to save profile")}finally{R(!1)}};return d.jsxs(bo,{children:[d.jsx(xo,{children:d.jsx(yo,{children:"Edit profile"})}),d.jsxs(vo,{className:"flex flex-col gap-3",children:[d.jsx(ma,{label:"Description",children:d.jsx(Zt,{value:r,onChange:j=>s(j.target.value)})}),d.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[d.jsx(ma,{label:"Default model",children:_.length>1?d.jsx(k8,{value:a,onChange:l,models:_}):d.jsx(Zt,{value:a,onChange:j=>l(j.target.value),placeholder:"unset — request / engine default",className:"font-mono"})}),d.jsx(ma,{label:"Default permission mode",children:d.jsx(yv,{variant:"form",mode:c,onModeChange:u,modes:M.modes})})]}),n?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[d.jsx(ma,{label:"Default model id",children:d.jsx(Zt,{value:h,onChange:j=>m(j.target.value),className:"font-mono"})}),d.jsx(ma,{label:"Models offered (comma-separated)",children:d.jsx(Zt,{value:p,onChange:j=>b(j.target.value),className:"font-mono"})})]}),d.jsx(ma,{label:"Capabilities granted",children:d.jsxs("div",{className:"flex flex-wrap items-center gap-3 py-1.5",children:[d.jsxs("label",{className:"flex cursor-pointer items-center gap-1.5 text-body-sm text-fg-2",children:[d.jsx("input",{type:"checkbox",checked:x===void 0,onChange:j=>v(j.target.checked?void 0:[]),className:"size-3.5 accent-(--color-fg-1)"}),"not declared"]}),Lpe.map(j=>d.jsxs("label",{className:"flex cursor-pointer items-center gap-1.5 text-body-sm text-fg-2",children:[d.jsx("input",{type:"checkbox",disabled:x===void 0,checked:x?.includes(j)??!1,onChange:z=>v(P=>z.target.checked?[...P??[],j]:(P??[]).filter(F=>F!==j)),className:"size-3.5 accent-(--color-fg-1) disabled:opacity-40"}),d.jsx("code",{className:"font-mono text-label",children:j})]},j))]})}),d.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[d.jsx(ma,{label:"MCP servers (names, comma-separated)",children:d.jsx(Zt,{value:N,onChange:j=>w(j.target.value),className:"font-mono"})}),d.jsx(ma,{label:"Instructions",children:d.jsx(Zt,{value:S,onChange:j=>C(j.target.value)})})]})]}):null,d.jsxs("div",{className:"flex items-center justify-between gap-3",children:[d.jsx("p",{className:"text-label text-fg-4",children:"Name and engine are fixed — sessions and jobs are pinned to the name, and the engine decides what the rest of these fields mean."}),d.jsxs(tt,{onClick:()=>void I(),disabled:A,children:[A?d.jsx(Tn,{className:"size-3.5 text-current"}):d.jsx(TV,{className:"size-4"}),"Save"]})]})]})]})}function Dpe(e){window.location.href=`vscode://file${e}`}function Ppe(){return d.jsx("div",{className:"flex flex-1 items-center justify-center p-8",children:d.jsx(Wr,{icon:d.jsx(T2,{}),title:"No profile selected",description:"A profile is what a session runs as — its config directory and credentials, or a model provider."})})}function Bn({label:e,children:t}){return d.jsxs("div",{className:"flex items-baseline justify-between gap-4 py-1.5",children:[d.jsx("span",{className:"shrink-0 text-label font-medium text-fg-3",children:e}),d.jsx("span",{className:"min-w-0 text-right text-body-sm text-fg-1",children:t})]})}function ga({items:e,empty:t}){return e.length===0?d.jsx("span",{className:"text-fg-4",children:t}):d.jsx("span",{className:"flex flex-wrap justify-end gap-1",children:e.map(n=>d.jsx(En,{variant:"neutral",children:n},n))})}function Bpe(){const{profileName:e}=gc({from:"/profiles/$profileName"}),t=As(),{refresh:n}=Mv(),[r,s]=y.useState(),[a,l]=y.useState();y.useEffect(()=>{let p=!0;const b=()=>{Dr()?.getProfile(e).then(v=>{p&&s(v)}).catch(v=>{p&&l(v instanceof Error?v.message:"Failed to load profile")})};b();const x=setInterval(b,6e4);return()=>{p=!1,clearInterval(x)}},[e]);const c=r?.profile,u=r?.config,h=y.useMemo(()=>Q_(c?.usage),[c?.usage]),m=async()=>{try{await Dr().deleteProfile(e),await n(),un.success(`Profile '${e}' deleted`),t({to:"/profiles"})}catch(p){un.error(p instanceof Error?p.message:"Delete failed")}};return d.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[d.jsx(Ov,{crumbs:[{label:"Profiles",to:"/profiles"},{label:e}],actions:d.jsxs(d.Fragment,{children:[c?.configDir?d.jsxs(tt,{variant:"outline",size:"xs",onClick:()=>Dpe(c.configDir),children:[d.jsx(g2,{className:"size-3"}),"Open in VSCode"]}):null,c?.managed?d.jsxs(tt,{variant:"outline",size:"xs",onClick:()=>void m(),children:[d.jsx(Dd,{className:"size-3"}),"Delete"]}):null]}),children:c?.description?d.jsx("span",{className:"min-w-0 truncate text-label text-fg-4",children:c.description}):null}),d.jsxs(A8,{children:[a?d.jsx("div",{className:"rounded-md bg-danger-bg px-3 py-2 text-body-sm text-danger",children:a}):null,!r&&!a?d.jsx(Tn,{className:"mx-auto size-5 text-fg-4"}):null,c&&u?d.jsxs(d.Fragment,{children:[d.jsxs(bo,{children:[d.jsx(xo,{children:d.jsx(yo,{children:"Worker defaults"})}),d.jsxs(vo,{className:"flex flex-col divide-y divide-border",children:[d.jsx(Bn,{label:"Engine",children:d.jsx(En,{variant:"neutral",children:c.engine??"claude"})}),c.engine==="provider"?d.jsx(Bn,{label:"Provider",children:d.jsx("span",{className:"font-mono text-label",children:c.provider?.id})}):d.jsx(Bn,{label:"Config directory",children:d.jsx("span",{className:"font-mono text-label",children:c.configDir})}),d.jsx(Bn,{label:"Default model",children:c.defaults?.model??c.provider?.model??d.jsx("span",{className:"text-fg-4",children:"request / engine default"})}),d.jsx(Bn,{label:"Default permission mode",children:c.defaults?.permissionMode??d.jsx("span",{className:"text-fg-4",children:"request / engine default"})}),c.engine==="provider"?d.jsxs(d.Fragment,{children:[d.jsx(Bn,{label:"Models offered",children:d.jsx(ga,{items:c.provider?.models??[],empty:"the default model only"})}),d.jsx(Bn,{label:"API key variable",children:c.provider?.apiKeyEnv?d.jsx("span",{className:"font-mono text-label",children:c.provider.apiKeyEnv}):d.jsx("span",{className:"text-fg-4",children:"provider SDK default"})})]}):null]})]}),h.length>0?d.jsxs(bo,{children:[d.jsx(xo,{children:d.jsx(yo,{children:"Plan usage"})}),d.jsx(vo,{children:d.jsx(XI,{windows:h})})]}):null,c.engine==="provider"?d.jsxs(bo,{children:[d.jsx(xo,{children:d.jsx(yo,{children:"Session grants"})}),d.jsxs(vo,{className:"flex flex-col divide-y divide-border",children:[d.jsx(Bn,{label:"Capabilities",children:d.jsx(ga,{items:c.session?.capabilities??[],empty:"not declared — whatever the server wired"})}),d.jsx(Bn,{label:"MCP servers",children:d.jsx(ga,{items:c.session?.mcpServers??[],empty:"not declared — every connected server"})}),d.jsx(Bn,{label:"Instructions",children:c.session?.instructions?`${c.session.instructions.length} characters`:d.jsx("span",{className:"text-fg-4",children:"none"})})]})]}):null,c.engine==="provider"?null:d.jsxs(bo,{children:[d.jsx(xo,{children:d.jsx(yo,{children:"Claude Code configuration"})}),d.jsxs(vo,{className:"flex flex-col divide-y divide-border",children:[u.settings?d.jsxs(d.Fragment,{children:[d.jsx(Bn,{label:"Model (settings.json)",children:u.settings.model??d.jsx("span",{className:"text-fg-4",children:"not set"})}),d.jsx(Bn,{label:"Default permission mode",children:u.settings.defaultPermissionMode??d.jsx("span",{className:"text-fg-4",children:"not set"})}),d.jsx(Bn,{label:"Permission rules",children:d.jsx("span",{className:"font-mono text-label",children:u.settings.permissionRules?`${u.settings.permissionRules.allow} allow · ${u.settings.permissionRules.ask} ask · ${u.settings.permissionRules.deny} deny`:"—"})}),d.jsx(Bn,{label:"Env vars (names only)",children:d.jsx(ga,{items:u.settings.envKeys??[],empty:"none"})}),d.jsx(Bn,{label:"Hooks",children:d.jsx(ga,{items:u.settings.hooks??[],empty:"none"})})]}):d.jsx(Bn,{label:"settings.json",children:d.jsx("span",{className:"text-fg-4",children:"not found"})}),d.jsx(Bn,{label:"User memory (CLAUDE.md)",children:u.hasUserMemory?"present":d.jsx("span",{className:"text-fg-4",children:"none"})}),d.jsx(Bn,{label:"Skills",children:d.jsx(ga,{items:u.skills,empty:"none"})}),d.jsx(Bn,{label:"Agents",children:d.jsx(ga,{items:u.agents,empty:"none"})}),d.jsx(Bn,{label:"Commands",children:d.jsx(ga,{items:u.commands,empty:"none"})})]})]}),c.managed?d.jsx(jpe,{profile:c,onSaved:p=>s({...r,profile:p})}):null,d.jsxs("p",{className:"text-label text-fg-4",children:[c.managed?"Stored on the server and editable here. ":"View only — this profile is declared in the server options. ","Other profile configuration lives on the server (the"," ",d.jsx("code",{className:"font-mono",children:"profiles"})," option; for Claude profiles, the config directory itself, e.g. via VSCode). Provider credentials are resolved from the server's environment and never leave it."]})]}):null]})]})}function zpe(){const{hostId:e,sessionId:t}=gc({from:"/sessions/$hostId/$sessionId"}),{ready:n}=Av(),r=As(),s=tc(e);return y.useEffect(()=>{!n||s||(un.error("That gateway is not configured here"),r({to:"/sessions"}))},[n,s,r]),s?d.jsx(Hpe,{hostId:e,sessionId:t,client:s},`${e}:${t}`):null}function Hpe({hostId:e,sessionId:t,client:n}){const r=As(),{subagent:s,sn:a}=by({from:"/sessions/$hostId/$sessionId"}),{info:l,error:c}=nA(n,t),u=Nhe(e,t),[h]=y.useState(()=>whe(e,t)),[m]=y.useState(Cv),[p]=y.useState(qp),[b]=y.useState(wv),[x]=y.useState(O8);y.useEffect(()=>{c&&(un.error("Session not found"),r({to:"/sessions"}))},[c,r]);const[v,N]=y.useState(()=>!document.hidden);y.useEffect(()=>{const R=()=>N(!document.hidden);return document.addEventListener("visibilitychange",R),()=>document.removeEventListener("visibilitychange",R)},[]);const{snapshots:w}=Ic(),S=y.useMemo(()=>w.find(R=>R.host.id===e)?.sessions.find(R=>R.id===t),[w,e,t]);y.useEffect(()=>{!S||!v||u({activity:S.activityCount,turns:S.numTurns})},[S?.activityCount,S?.numTurns,v,u]);const C=async()=>{try{await n.deleteSession(t)}catch{}r({to:"/sessions"})},A=l?.cwd?.split("/").filter(Boolean).pop();return d.jsx(M8,{client:n,sessionId:t,transcriptVariant:p,transcriptDensity:m,transcriptFont:b,openSubagent:s?{toolUseId:s,nonce:a??0}:void 0,scrubber:!0,stickyPrompt:!0,statusPlacement:"bottom",controlsSurface:"status",defaultRailWidth:x.width,defaultRailCollapsed:x.collapsed,onRailChange:L8,unseen:h,onVitals:R=>{u({itemCount:R.itemCount}),Ihe()},header:({actions:R})=>d.jsxs("div",{className:"flex items-center gap-2 border-b border-border bg-surface px-3 py-2",children:[d.jsx("span",{className:"truncate text-body-sm font-medium text-fg-1",children:l?.title??A??t.slice(0,8)}),l?.engine&&l.engine!=="claude"?d.jsx(En,{variant:"neutral",className:"shrink-0",children:l.engine}):null,l?.cwd?d.jsx("span",{className:"min-w-0 truncate font-mono text-label text-fg-4",title:l.cwd,children:l.cwd}):null,d.jsx("span",{className:"flex-1"}),d.jsx(Sd,{value:t,"aria-label":"Copy session id"}),d.jsxs(nY,{children:[d.jsx(rY,{render:d.jsx(tt,{variant:"ghost",size:"icon-sm","aria-label":"Close session",children:d.jsx(Dd,{className:"size-4 text-fg-3"})})}),d.jsxs(iY,{children:[d.jsx(aY,{children:"Close this session?"}),d.jsx(oY,{children:"The run is terminated on the server. You can pick it up later from “Resume a previous session” — the transcript is kept by the engine, not by the gateway."}),d.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[d.jsx(sY,{render:d.jsx(tt,{variant:"outline",children:"Cancel"})}),d.jsx(tt,{variant:"destructive",onClick:()=>void C(),children:"Close session"})]})]})]}),R]})},t)}const vs=I9({component:ope}),Upe=Rs({getParentRoute:()=>vs,path:"/",beforeLoad:()=>{throw Qp({to:"/sessions"})}}),Fpe=Rs({getParentRoute:()=>vs,path:"/sessions",component:spe}),$pe=Rs({getParentRoute:()=>vs,path:"/sessions/$hostId/$sessionId",component:zpe,validateSearch:e=>({subagent:typeof e.subagent=="string"?e.subagent:void 0,sn:typeof e.sn=="number"?e.sn:void 0})}),Vpe=Rs({getParentRoute:()=>vs,path:"/sessions/$sessionId",beforeLoad:({params:e})=>{throw Qp({to:"/sessions/$hostId/$sessionId",params:{hostId:l8,sessionId:e.sessionId},search:{}})}}),qpe=Rs({getParentRoute:()=>vs,path:"/gateways",component:cpe}),Ype=Rs({getParentRoute:()=>vs,path:"/gateways/$hostId",component:lpe}),Gpe=Rs({getParentRoute:()=>vs,path:"/jobs",component:Khe}),Kpe=Rs({getParentRoute:()=>vs,path:"/jobs/$jobId",component:Ope}),Wpe=Rs({getParentRoute:()=>vs,path:"/profiles",component:Ppe}),Xpe=Rs({getParentRoute:()=>vs,path:"/profiles/$profileName",component:Bpe}),Qpe=Rs({getParentRoute:()=>vs,path:"/settings",beforeLoad:()=>{throw Qp({to:"/sessions"})}}),Zpe=q9({routeTree:vs.addChildren([Upe,Fpe,$pe,Vpe,qpe,Ype,Gpe,Kpe,Wpe,Xpe,Qpe]),history:Xj()});function Jpe(){return d.jsxs(d.Fragment,{children:[d.jsx(K9,{router:Zpe}),d.jsx(NG,{})]})}pN();const j8=document.getElementById("root");if(!j8)throw new Error("Root element #root not found");nj.createRoot(j8).render(d.jsx(y.StrictMode,{children:d.jsx(Jpe,{})}));const eme=Object.freeze(Object.defineProperty({__proto__:null,Mermaid:oI},Symbol.toStringTag,{value:"Module"}));export{Nle as A,rme as L,Zr as R,fc as _,d as j,y as r};
|