claude-code-session-manager 0.21.3 → 0.21.4
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/{TiptapBody-PdmsfUCQ.js → TiptapBody-CZLSQ6pj.js} +1 -1
- package/dist/assets/{index-DO3ROR11.js → index-BUrrcj7x.js} +4 -4
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/main/__tests__/runVerify.test.cjs +37 -0
- package/src/main/runVerify.cjs +23 -0
- package/src/main/scheduler.cjs +75 -1
- package/src/main/webRemote.cjs +6 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./monaco-editor-BW5C4Iv1.js","./monaco-editor-BTnBOi8r.css","./TiptapBody-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./monaco-editor-BW5C4Iv1.js","./monaco-editor-BTnBOi8r.css","./TiptapBody-CZLSQ6pj.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
var D8=Object.defineProperty;var L8=(e,r,n)=>r in e?D8(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n;var en=(e,r,n)=>L8(e,typeof r!="symbol"?r+"":r,n);import{_ as rm}from"./monaco-editor-BW5C4Iv1.js";(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(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"&&i(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 i(s){if(s.ep)return;s.ep=!0;const a=n(s);fetch(s.href,a)}})();var ox=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function nn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var J_={exports:{}},Wg={},Q_={exports:{}},xr={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react.production.min.js
|
|
@@ -38,7 +38,7 @@ var D8=Object.defineProperty;var L8=(e,r,n)=>r in e?D8(e,r,{enumerable:!0,config
|
|
|
38
38
|
`+H[ue].replace(" at new "," at ");return p.displayName&&Ne.includes("<anonymous>")&&(Ne=Ne.replace("<anonymous>",p.displayName)),Ne}while(1<=ue&&0<=Se);break}}}finally{he=!1,Error.prepareStackTrace=A}return(p=p?p.displayName||p.name:"")?re(p):""}function Ce(p){switch(p.tag){case 5:return re(p.type);case 16:return re("Lazy");case 13:return re("Suspense");case 19:return re("SuspenseList");case 0:case 2:case 15:return p=we(p.type,!1),p;case 11:return p=we(p.type.render,!1),p;case 1:return p=we(p.type,!0),p;default:return""}}function Me(p){if(p==null)return null;if(typeof p=="function")return p.displayName||p.name||null;if(typeof p=="string")return p;switch(p){case P:return"Fragment";case $:return"Portal";case I:return"Profiler";case N:return"StrictMode";case F:return"Suspense";case z:return"SuspenseList"}if(typeof p=="object")switch(p.$$typeof){case V:return(p.displayName||"Context")+".Consumer";case U:return(p._context.displayName||"Context")+".Provider";case q:var v=p.render;return p=p.displayName,p||(p=v.displayName||v.name||"",p=p!==""?"ForwardRef("+p+")":"ForwardRef"),p;case G:return v=p.displayName||null,v!==null?v:Me(p.type)||"Memo";case Y:v=p._payload,p=p._init;try{return Me(p(v))}catch{}}return null}function be(p){var v=p.type;switch(p.tag){case 24:return"Cache";case 9:return(v.displayName||"Context")+".Consumer";case 10:return(v._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return p=v.render,p=p.displayName||p.name||"",v.displayName||(p!==""?"ForwardRef("+p+")":"ForwardRef");case 7:return"Fragment";case 5:return v;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Me(v);case 8:return v===N?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof v=="function")return v.displayName||v.name||null;if(typeof v=="string")return v}return null}function se(p){switch(typeof p){case"boolean":case"number":case"string":case"undefined":return p;case"object":return p;default:return""}}function ve(p){var v=p.type;return(p=p.nodeName)&&p.toLowerCase()==="input"&&(v==="checkbox"||v==="radio")}function xe(p){var v=ve(p)?"checked":"value",A=Object.getOwnPropertyDescriptor(p.constructor.prototype,v),M=""+p[v];if(!p.hasOwnProperty(v)&&typeof A<"u"&&typeof A.get=="function"&&typeof A.set=="function"){var H=A.get,ee=A.set;return Object.defineProperty(p,v,{configurable:!0,get:function(){return H.call(this)},set:function(ue){M=""+ue,ee.call(this,ue)}}),Object.defineProperty(p,v,{enumerable:A.enumerable}),{getValue:function(){return M},setValue:function(ue){M=""+ue},stopTracking:function(){p._valueTracker=null,delete p[v]}}}}function Ve(p){p._valueTracker||(p._valueTracker=xe(p))}function Re(p){if(!p)return!1;var v=p._valueTracker;if(!v)return!0;var A=v.getValue(),M="";return p&&(M=ve(p)?p.checked?"true":"false":p.value),p=M,p!==A?(v.setValue(p),!0):!1}function We(p){if(p=p||(typeof document<"u"?document:void 0),typeof p>"u")return null;try{return p.activeElement||p.body}catch{return p.body}}function Le(p,v){var A=v.checked;return K({},v,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:A??p._wrapperState.initialChecked})}function Ze(p,v){var A=v.defaultValue==null?"":v.defaultValue,M=v.checked!=null?v.checked:v.defaultChecked;A=se(v.value!=null?v.value:A),p._wrapperState={initialChecked:M,initialValue:A,controlled:v.type==="checkbox"||v.type==="radio"?v.checked!=null:v.value!=null}}function ct(p,v){v=v.checked,v!=null&&k(p,"checked",v,!1)}function ut(p,v){ct(p,v);var A=se(v.value),M=v.type;if(A!=null)M==="number"?(A===0&&p.value===""||p.value!=A)&&(p.value=""+A):p.value!==""+A&&(p.value=""+A);else if(M==="submit"||M==="reset"){p.removeAttribute("value");return}v.hasOwnProperty("value")?Xt(p,v.type,A):v.hasOwnProperty("defaultValue")&&Xt(p,v.type,se(v.defaultValue)),v.checked==null&&v.defaultChecked!=null&&(p.defaultChecked=!!v.defaultChecked)}function dr(p,v,A){if(v.hasOwnProperty("value")||v.hasOwnProperty("defaultValue")){var M=v.type;if(!(M!=="submit"&&M!=="reset"||v.value!==void 0&&v.value!==null))return;v=""+p._wrapperState.initialValue,A||v===p.value||(p.value=v),p.defaultValue=v}A=p.name,A!==""&&(p.name=""),p.defaultChecked=!!p._wrapperState.initialChecked,A!==""&&(p.name=A)}function Xt(p,v,A){(v!=="number"||We(p.ownerDocument)!==p)&&(A==null?p.defaultValue=""+p._wrapperState.initialValue:p.defaultValue!==""+A&&(p.defaultValue=""+A))}var Qt=Array.isArray;function cr(p,v,A,M){if(p=p.options,v){v={};for(var H=0;H<A.length;H++)v["$"+A[H]]=!0;for(A=0;A<p.length;A++)H=v.hasOwnProperty("$"+p[A].value),p[A].selected!==H&&(p[A].selected=H),H&&M&&(p[A].defaultSelected=!0)}else{for(A=""+se(A),v=null,H=0;H<p.length;H++){if(p[H].value===A){p[H].selected=!0,M&&(p[H].defaultSelected=!0);return}v!==null||p[H].disabled||(v=p[H])}v!==null&&(v.selected=!0)}}function Or(p,v){if(v.dangerouslySetInnerHTML!=null)throw Error(n(91));return K({},v,{value:void 0,defaultValue:void 0,children:""+p._wrapperState.initialValue})}function wr(p,v){var A=v.value;if(A==null){if(A=v.children,v=v.defaultValue,A!=null){if(v!=null)throw Error(n(92));if(Qt(A)){if(1<A.length)throw Error(n(93));A=A[0]}v=A}v==null&&(v=""),A=v}p._wrapperState={initialValue:se(A)}}function sn(p,v){var A=se(v.value),M=se(v.defaultValue);A!=null&&(A=""+A,A!==p.value&&(p.value=A),v.defaultValue==null&&p.defaultValue!==A&&(p.defaultValue=A)),M!=null&&(p.defaultValue=""+M)}function Wr(p){var v=p.textContent;v===p._wrapperState.initialValue&&v!==""&&v!==null&&(p.value=v)}function ii(p){switch(p){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Kn(p,v){return p==null||p==="http://www.w3.org/1999/xhtml"?ii(v):p==="http://www.w3.org/2000/svg"&&v==="foreignObject"?"http://www.w3.org/1999/xhtml":p}var mr,vt=(function(p){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(v,A,M,H){MSApp.execUnsafeLocalFunction(function(){return p(v,A,M,H)})}:p})(function(p,v){if(p.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in p)p.innerHTML=v;else{for(mr=mr||document.createElement("div"),mr.innerHTML="<svg>"+v.valueOf().toString()+"</svg>",v=mr.firstChild;p.firstChild;)p.removeChild(p.firstChild);for(;v.firstChild;)p.appendChild(v.firstChild)}});function jt(p,v){if(v){var A=p.firstChild;if(A&&A===p.lastChild&&A.nodeType===3){A.nodeValue=v;return}}p.textContent=v}var It={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Pt=["Webkit","ms","Moz","O"];Object.keys(It).forEach(function(p){Pt.forEach(function(v){v=v+p.charAt(0).toUpperCase()+p.substring(1),It[v]=It[p]})});function Ir(p,v,A){return v==null||typeof v=="boolean"||v===""?"":A||typeof v!="number"||v===0||It.hasOwnProperty(p)&&It[p]?(""+v).trim():v+"px"}function yi(p,v){p=p.style;for(var A in v)if(v.hasOwnProperty(A)){var M=A.indexOf("--")===0,H=Ir(A,v[A],M);A==="float"&&(A="cssFloat"),M?p.setProperty(A,H):p[A]=H}}var Sa=K({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Ii(p,v){if(v){if(Sa[p]&&(v.children!=null||v.dangerouslySetInnerHTML!=null))throw Error(n(137,p));if(v.dangerouslySetInnerHTML!=null){if(v.children!=null)throw Error(n(60));if(typeof v.dangerouslySetInnerHTML!="object"||!("__html"in v.dangerouslySetInnerHTML))throw Error(n(61))}if(v.style!=null&&typeof v.style!="object")throw Error(n(62))}}function Cr(p,v){if(p.indexOf("-")===-1)return typeof v.is=="string";switch(p){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var si=null;function In(p){return p=p.target||p.srcElement||window,p.correspondingUseElement&&(p=p.correspondingUseElement),p.nodeType===3?p.parentNode:p}var Ge=null,rt=null,$t=null;function ur(p){if(p=Vc(p)){if(typeof Ge!="function")throw Error(n(280));var v=p.stateNode;v&&(v=ed(v),Ge(p.stateNode,p.type,v))}}function Pr(p){rt?$t?$t.push(p):$t=[p]:rt=p}function Yr(){if(rt){var p=rt,v=$t;if($t=rt=null,ur(p),v)for(p=0;p<v.length;p++)ur(v[p])}}function an(p,v){return p(v)}function Di(){}var pn=!1;function es(p,v,A){if(pn)return p(v,A);pn=!0;try{return an(p,v,A)}finally{pn=!1,(rt!==null||$t!==null)&&(Di(),Yr())}}function Li(p,v){var A=p.stateNode;if(A===null)return null;var M=ed(A);if(M===null)return null;A=M[v];e:switch(v){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(M=!M.disabled)||(p=p.type,M=!(p==="button"||p==="input"||p==="select"||p==="textarea")),p=!M;break e;default:p=!1}if(p)return null;if(A&&typeof A!="function")throw Error(n(231,v,typeof A));return A}var _r=!1;if(o)try{var Xn={};Object.defineProperty(Xn,"passive",{get:function(){_r=!0}}),window.addEventListener("test",Xn,Xn),window.removeEventListener("test",Xn,Xn)}catch{_r=!1}function El(p,v,A,M,H,ee,ue,Se,Ne){var Ke=Array.prototype.slice.call(arguments,3);try{v.apply(A,Ke)}catch(dt){this.onError(dt)}}var Ps=!1,Rs=null,us=!1,Kt=null,bi={onError:function(p){Ps=!0,Rs=p}};function Sr(p,v,A,M,H,ee,ue,Se,Ne){Ps=!1,Rs=null,El.apply(bi,arguments)}function ai(p,v,A,M,H,ee,ue,Se,Ne){if(Sr.apply(this,arguments),Ps){if(Ps){var Ke=Rs;Ps=!1,Rs=null}else throw Error(n(198));us||(us=!0,Kt=Ke)}}function Nt(p){var v=p,A=p;if(p.alternate)for(;v.return;)v=v.return;else{p=v;do v=p,(v.flags&4098)!==0&&(A=v.return),p=v.return;while(p)}return v.tag===3?A:null}function ea(p){if(p.tag===13){var v=p.memoizedState;if(v===null&&(p=p.alternate,p!==null&&(v=p.memoizedState)),v!==null)return v.dehydrated}return null}function ka(p){if(Nt(p)!==p)throw Error(n(188))}function zo(p){var v=p.alternate;if(!v){if(v=Nt(p),v===null)throw Error(n(188));return v!==p?null:p}for(var A=p,M=v;;){var H=A.return;if(H===null)break;var ee=H.alternate;if(ee===null){if(M=H.return,M!==null){A=M;continue}break}if(H.child===ee.child){for(ee=H.child;ee;){if(ee===A)return ka(H),p;if(ee===M)return ka(H),v;ee=ee.sibling}throw Error(n(188))}if(A.return!==M.return)A=H,M=ee;else{for(var ue=!1,Se=H.child;Se;){if(Se===A){ue=!0,A=H,M=ee;break}if(Se===M){ue=!0,M=H,A=ee;break}Se=Se.sibling}if(!ue){for(Se=ee.child;Se;){if(Se===A){ue=!0,A=ee,M=H;break}if(Se===M){ue=!0,M=ee,A=H;break}Se=Se.sibling}if(!ue)throw Error(n(189))}}if(A.alternate!==M)throw Error(n(190))}if(A.tag!==3)throw Error(n(188));return A.stateNode.current===A?p:v}function ds(p){return p=zo(p),p!==null?ta(p):null}function ta(p){if(p.tag===5||p.tag===6)return p;for(p=p.child;p!==null;){var v=ta(p);if(v!==null)return v;p=p.sibling}return null}var xi=r.unstable_scheduleCallback,Dn=r.unstable_cancelCallback,Fo=r.unstable_shouldYield,Tl=r.unstable_requestPaint,Jr=r.unstable_now,oi=r.unstable_getCurrentPriorityLevel,kn=r.unstable_ImmediatePriority,bn=r.unstable_UserBlockingPriority,Et=r.unstable_NormalPriority,_e=r.unstable_LowPriority,it=r.unstable_IdlePriority,_t=null,lr=null;function mt(p){if(lr&&typeof lr.onCommitFiberRoot=="function")try{lr.onCommitFiberRoot(_t,p,void 0,(p.current.flags&128)===128)}catch{}}var fr=Math.clz32?Math.clz32:Jn,on=Math.log,Yn=Math.LN2;function Jn(p){return p>>>=0,p===0?32:31-(on(p)/Yn|0)|0}var fs=64,Rr=4194304;function hs(p){switch(p&-p){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return p&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return p&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return p}}function Ms(p,v){var A=p.pendingLanes;if(A===0)return 0;var M=0,H=p.suspendedLanes,ee=p.pingedLanes,ue=A&268435455;if(ue!==0){var Se=ue&~H;Se!==0?M=hs(Se):(ee&=ue,ee!==0&&(M=hs(ee)))}else ue=A&~H,ue!==0?M=hs(ue):ee!==0&&(M=hs(ee));if(M===0)return 0;if(v!==0&&v!==M&&(v&H)===0&&(H=M&-M,ee=v&-v,H>=ee||H===16&&(ee&4194240)!==0))return v;if((M&4)!==0&&(M|=A&16),v=p.entangledLanes,v!==0)for(p=p.entanglements,v&=M;0<v;)A=31-fr(v),H=1<<A,M|=p[A],v&=~H;return M}function hr(p,v){switch(p){case 1:case 2:case 4:return v+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return v+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ps(p,v){for(var A=p.suspendedLanes,M=p.pingedLanes,H=p.expirationTimes,ee=p.pendingLanes;0<ee;){var ue=31-fr(ee),Se=1<<ue,Ne=H[ue];Ne===-1?((Se&A)===0||(Se&M)!==0)&&(H[ue]=hr(Se,v)):Ne<=v&&(p.expiredLanes|=Se),ee&=~Se}}function Uo(p){return p=p.pendingLanes&-1073741825,p!==0?p:p&1073741824?1073741824:0}function ra(){var p=fs;return fs<<=1,(fs&4194240)===0&&(fs=64),p}function Qe(p){for(var v=[],A=0;31>A;A++)v.push(p);return v}function Is(p,v,A){p.pendingLanes|=v,v!==536870912&&(p.suspendedLanes=0,p.pingedLanes=0),p=p.eventTimes,v=31-fr(v),p[v]=A}function $c(p,v){var A=p.pendingLanes&~v;p.pendingLanes=v,p.suspendedLanes=0,p.pingedLanes=0,p.expiredLanes&=v,p.mutableReadLanes&=v,p.entangledLanes&=v,v=p.entanglements;var M=p.eventTimes;for(p=p.expirationTimes;0<A;){var H=31-fr(A),ee=1<<H;v[H]=0,M[H]=-1,p[H]=-1,A&=~ee}}function Al(p,v){var A=p.entangledLanes|=v;for(p=p.entanglements;A;){var M=31-fr(A),H=1<<M;H&v|p[M]&v&&(p[M]|=v),A&=~H}}var gr=0;function Ft(p){return p&=-p,1<p?4<p?(p&268435455)!==0?16:536870912:4:1}var na,Ca,ja,ro,qo,no=!1,ts=[],li=null,ms=null,gs=null,Ea=new Map,io=new Map,Ds=[],bf="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function so(p,v){switch(p){case"focusin":case"focusout":li=null;break;case"dragenter":case"dragleave":ms=null;break;case"mouseover":case"mouseout":gs=null;break;case"pointerover":case"pointerout":Ea.delete(v.pointerId);break;case"gotpointercapture":case"lostpointercapture":io.delete(v.pointerId)}}function ao(p,v,A,M,H,ee){return p===null||p.nativeEvent!==ee?(p={blockedOn:v,domEventName:A,eventSystemFlags:M,nativeEvent:ee,targetContainers:[H]},v!==null&&(v=Vc(v),v!==null&&Ca(v)),p):(p.eventSystemFlags|=M,v=p.targetContainers,H!==null&&v.indexOf(H)===-1&&v.push(H),p)}function Lu(p,v,A,M,H){switch(v){case"focusin":return li=ao(li,p,v,A,M,H),!0;case"dragenter":return ms=ao(ms,p,v,A,M,H),!0;case"mouseover":return gs=ao(gs,p,v,A,M,H),!0;case"pointerover":var ee=H.pointerId;return Ea.set(ee,ao(Ea.get(ee)||null,p,v,A,M,H)),!0;case"gotpointercapture":return ee=H.pointerId,io.set(ee,ao(io.get(ee)||null,p,v,A,M,H)),!0}return!1}function Nc(p){var v=Vo(p.target);if(v!==null){var A=Nt(v);if(A!==null){if(v=A.tag,v===13){if(v=ea(A),v!==null){p.blockedOn=v,qo(p.priority,function(){ja(A)});return}}else if(v===3&&A.stateNode.current.memoizedState.isDehydrated){p.blockedOn=A.tag===3?A.stateNode.containerInfo:null;return}}}p.blockedOn=null}function oo(p){if(p.blockedOn!==null)return!1;for(var v=p.targetContainers;0<v.length;){var A=ae(p.domEventName,p.eventSystemFlags,v[0],p.nativeEvent);if(A===null){A=p.nativeEvent;var M=new A.constructor(A.type,A);si=M,A.target.dispatchEvent(M),si=null}else return v=Vc(A),v!==null&&Ca(v),p.blockedOn=A,!1;v.shift()}return!0}function $l(p,v,A){oo(p)&&A.delete(v)}function Oc(){no=!1,li!==null&&oo(li)&&(li=null),ms!==null&&oo(ms)&&(ms=null),gs!==null&&oo(gs)&&(gs=null),Ea.forEach($l),io.forEach($l)}function ia(p,v){p.blockedOn===v&&(p.blockedOn=null,no||(no=!0,r.unstable_scheduleCallback(r.unstable_NormalPriority,Oc)))}function Ta(p){function v(H){return ia(H,p)}if(0<ts.length){ia(ts[0],p);for(var A=1;A<ts.length;A++){var M=ts[A];M.blockedOn===p&&(M.blockedOn=null)}}for(li!==null&&ia(li,p),ms!==null&&ia(ms,p),gs!==null&&ia(gs,p),Ea.forEach(v),io.forEach(v),A=0;A<Ds.length;A++)M=Ds[A],M.blockedOn===p&&(M.blockedOn=null);for(;0<Ds.length&&(A=Ds[0],A.blockedOn===null);)Nc(A),A.blockedOn===null&&Ds.shift()}var sa=T.ReactCurrentBatchConfig,lo=!0;function Bu(p,v,A,M){var H=gr,ee=sa.transition;sa.transition=null;try{gr=1,Pc(p,v,A,M)}finally{gr=H,sa.transition=ee}}function zu(p,v,A,M){var H=gr,ee=sa.transition;sa.transition=null;try{gr=4,Pc(p,v,A,M)}finally{gr=H,sa.transition=ee}}function Pc(p,v,A,M){if(lo){var H=ae(p,v,A,M);if(H===null)Pf(p,v,M,Rc,A),so(p,M);else if(Lu(H,p,v,A,M))M.stopPropagation();else if(so(p,M),v&4&&-1<bf.indexOf(p)){for(;H!==null;){var ee=Vc(H);if(ee!==null&&na(ee),ee=ae(p,v,A,M),ee===null&&Pf(p,v,M,Rc,A),ee===H)break;H=ee}H!==null&&M.stopPropagation()}else Pf(p,v,M,null,A)}}var Rc=null;function ae(p,v,A,M){if(Rc=null,p=In(M),p=Vo(p),p!==null)if(v=Nt(p),v===null)p=null;else if(A=v.tag,A===13){if(p=ea(v),p!==null)return p;p=null}else if(A===3){if(v.stateNode.current.memoizedState.isDehydrated)return v.tag===3?v.stateNode.containerInfo:null;p=null}else v!==p&&(p=null);return Rc=p,null}function fe(p){switch(p){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(oi()){case kn:return 1;case bn:return 4;case Et:case _e:return 16;case it:return 536870912;default:return 16}default:return 16}}var ye=null,$e=null,je=null;function ze(){if(je)return je;var p,v=$e,A=v.length,M,H="value"in ye?ye.value:ye.textContent,ee=H.length;for(p=0;p<A&&v[p]===H[p];p++);var ue=A-p;for(M=1;M<=ue&&v[A-M]===H[ee-M];M++);return je=H.slice(p,1<M?1-M:void 0)}function Oe(p){var v=p.keyCode;return"charCode"in p?(p=p.charCode,p===0&&v===13&&(p=13)):p=v,p===10&&(p=13),32<=p||p===13?p:0}function Pe(){return!0}function Ue(){return!1}function tt(p){function v(A,M,H,ee,ue){this._reactName=A,this._targetInst=H,this.type=M,this.nativeEvent=ee,this.target=ue,this.currentTarget=null;for(var Se in p)p.hasOwnProperty(Se)&&(A=p[Se],this[Se]=A?A(ee):ee[Se]);return this.isDefaultPrevented=(ee.defaultPrevented!=null?ee.defaultPrevented:ee.returnValue===!1)?Pe:Ue,this.isPropagationStopped=Ue,this}return K(v.prototype,{preventDefault:function(){this.defaultPrevented=!0;var A=this.nativeEvent;A&&(A.preventDefault?A.preventDefault():typeof A.returnValue!="unknown"&&(A.returnValue=!1),this.isDefaultPrevented=Pe)},stopPropagation:function(){var A=this.nativeEvent;A&&(A.stopPropagation?A.stopPropagation():typeof A.cancelBubble!="unknown"&&(A.cancelBubble=!0),this.isPropagationStopped=Pe)},persist:function(){},isPersistent:Pe}),v}var ot={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(p){return p.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},nt=tt(ot),Je=K({},ot,{view:0,detail:0}),Ot=tt(Je),Be,pt,Br,nr=K({},Je,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:pr,button:0,buttons:0,relatedTarget:function(p){return p.relatedTarget===void 0?p.fromElement===p.srcElement?p.toElement:p.fromElement:p.relatedTarget},movementX:function(p){return"movementX"in p?p.movementX:(p!==Br&&(Br&&p.type==="mousemove"?(Be=p.screenX-Br.screenX,pt=p.screenY-Br.screenY):pt=Be=0,Br=p),Be)},movementY:function(p){return"movementY"in p?p.movementY:pt}}),ir=tt(nr),zr=K({},nr,{dataTransfer:0}),Ut=tt(zr),Hr=K({},Je,{relatedTarget:0}),yr=tt(Hr),Ln=K({},ot,{animationName:0,elapsedTime:0,pseudoElement:0}),ci=tt(Ln),wi=K({},ot,{clipboardData:function(p){return"clipboardData"in p?p.clipboardData:window.clipboardData}}),Nl=tt(wi),_i=K({},ot,{data:0}),Mc=tt(_i),Fu={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Bn={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},Ls={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Uu(p){var v=this.nativeEvent;return v.getModifierState?v.getModifierState(p):(p=Ls[p])?!!v[p]:!1}function pr(){return Uu}var vs=K({},Je,{key:function(p){if(p.key){var v=Fu[p.key]||p.key;if(v!=="Unidentified")return v}return p.type==="keypress"?(p=Oe(p),p===13?"Enter":String.fromCharCode(p)):p.type==="keydown"||p.type==="keyup"?Bn[p.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:pr,charCode:function(p){return p.type==="keypress"?Oe(p):0},keyCode:function(p){return p.type==="keydown"||p.type==="keyup"?p.keyCode:0},which:function(p){return p.type==="keypress"?Oe(p):p.type==="keydown"||p.type==="keyup"?p.keyCode:0}}),xf=tt(vs),aa=K({},nr,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Wo=tt(aa),Cn=K({},Je,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:pr}),Si=tt(Cn),Ic=K({},ot,{propertyName:0,elapsedTime:0,pseudoElement:0}),ki=tt(Ic),qu=K({},nr,{deltaX:function(p){return"deltaX"in p?p.deltaX:"wheelDeltaX"in p?-p.wheelDeltaX:0},deltaY:function(p){return"deltaY"in p?p.deltaY:"wheelDeltaY"in p?-p.wheelDeltaY:"wheelDelta"in p?-p.wheelDelta:0},deltaZ:0,deltaMode:0}),wf=tt(qu),oa=[9,13,27,32],ys=o&&"CompositionEvent"in window,Bs=null;o&&"documentMode"in document&&(Bs=document.documentMode);var jn=o&&"TextEvent"in window&&!Bs,ln=o&&(!ys||Bs&&8<Bs&&11>=Bs),bs=" ",Wu=!1;function Hu(p,v){switch(p){case"keyup":return oa.indexOf(v.keyCode)!==-1;case"keydown":return v.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ub(p){return p=p.detail,typeof p=="object"&&"data"in p?p.data:null}var Ci=!1;function db(p,v){switch(p){case"compositionend":return ub(v);case"keypress":return v.which!==32?null:(Wu=!0,bs);case"textInput":return p=v.data,p===bs&&Wu?null:p;default:return null}}function _f(p,v){if(Ci)return p==="compositionend"||!ys&&Hu(p,v)?(p=ze(),je=$e=ye=null,Ci=!1,p):null;switch(p){case"paste":return null;case"keypress":if(!(v.ctrlKey||v.altKey||v.metaKey)||v.ctrlKey&&v.altKey){if(v.char&&1<v.char.length)return v.char;if(v.which)return String.fromCharCode(v.which)}return null;case"compositionend":return ln&&v.locale!=="ko"?null:v.data;default:return null}}var dm={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function zs(p){var v=p&&p.nodeName&&p.nodeName.toLowerCase();return v==="input"?!!dm[p.type]:v==="textarea"}function fm(p,v,A,M){Pr(M),v=Xu(v,"onChange"),0<v.length&&(A=new nt("onChange","change",null,A,M),p.push({event:A,listeners:v}))}var Dc=null,Lc=null;function fb(p){Tm(p,0)}function Vu(p){var v=Rl(p);if(Re(v))return p}function hb(p,v){if(p==="change")return v}var hm=!1;if(o){var Sf;if(o){var kf="oninput"in document;if(!kf){var pm=document.createElement("div");pm.setAttribute("oninput","return;"),kf=typeof pm.oninput=="function"}Sf=kf}else Sf=!1;hm=Sf&&(!document.documentMode||9<document.documentMode)}function Fs(){Dc&&(Dc.detachEvent("onpropertychange",mm),Lc=Dc=null)}function mm(p){if(p.propertyName==="value"&&Vu(Lc)){var v=[];fm(v,Lc,p,In(p)),es(fb,v)}}function pb(p,v,A){p==="focusin"?(Fs(),Dc=v,Lc=A,Dc.attachEvent("onpropertychange",mm)):p==="focusout"&&Fs()}function mb(p){if(p==="selectionchange"||p==="keyup"||p==="keydown")return Vu(Lc)}function gb(p,v){if(p==="click")return Vu(v)}function vb(p,v){if(p==="input"||p==="change")return Vu(v)}function yb(p,v){return p===v&&(p!==0||1/p===1/v)||p!==p&&v!==v}var Us=typeof Object.is=="function"?Object.is:yb;function Bc(p,v){if(Us(p,v))return!0;if(typeof p!="object"||p===null||typeof v!="object"||v===null)return!1;var A=Object.keys(p),M=Object.keys(v);if(A.length!==M.length)return!1;for(M=0;M<A.length;M++){var H=A[M];if(!u.call(v,H)||!Us(p[H],v[H]))return!1}return!0}function gm(p){for(;p&&p.firstChild;)p=p.firstChild;return p}function vm(p,v){var A=gm(p);p=0;for(var M;A;){if(A.nodeType===3){if(M=p+A.textContent.length,p<=v&&M>=v)return{node:A,offset:v-p};p=M}e:{for(;A;){if(A.nextSibling){A=A.nextSibling;break e}A=A.parentNode}A=void 0}A=gm(A)}}function Cf(p,v){return p&&v?p===v?!0:p&&p.nodeType===3?!1:v&&v.nodeType===3?Cf(p,v.parentNode):"contains"in p?p.contains(v):p.compareDocumentPosition?!!(p.compareDocumentPosition(v)&16):!1:!1}function jf(){for(var p=window,v=We();v instanceof p.HTMLIFrameElement;){try{var A=typeof v.contentWindow.location.href=="string"}catch{A=!1}if(A)p=v.contentWindow;else break;v=We(p.document)}return v}function Ef(p){var v=p&&p.nodeName&&p.nodeName.toLowerCase();return v&&(v==="input"&&(p.type==="text"||p.type==="search"||p.type==="tel"||p.type==="url"||p.type==="password")||v==="textarea"||p.contentEditable==="true")}function bb(p){var v=jf(),A=p.focusedElem,M=p.selectionRange;if(v!==A&&A&&A.ownerDocument&&Cf(A.ownerDocument.documentElement,A)){if(M!==null&&Ef(A)){if(v=M.start,p=M.end,p===void 0&&(p=v),"selectionStart"in A)A.selectionStart=v,A.selectionEnd=Math.min(p,A.value.length);else if(p=(v=A.ownerDocument||document)&&v.defaultView||window,p.getSelection){p=p.getSelection();var H=A.textContent.length,ee=Math.min(M.start,H);M=M.end===void 0?ee:Math.min(M.end,H),!p.extend&&ee>M&&(H=M,M=ee,ee=H),H=vm(A,ee);var ue=vm(A,M);H&&ue&&(p.rangeCount!==1||p.anchorNode!==H.node||p.anchorOffset!==H.offset||p.focusNode!==ue.node||p.focusOffset!==ue.offset)&&(v=v.createRange(),v.setStart(H.node,H.offset),p.removeAllRanges(),ee>M?(p.addRange(v),p.extend(ue.node,ue.offset)):(v.setEnd(ue.node,ue.offset),p.addRange(v)))}}for(v=[],p=A;p=p.parentNode;)p.nodeType===1&&v.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof A.focus=="function"&&A.focus(),A=0;A<v.length;A++)p=v[A],p.element.scrollLeft=p.left,p.element.scrollTop=p.top}}var ym=o&&"documentMode"in document&&11>=document.documentMode,zc=null,Tf=null,Ho=null,Af=!1;function bm(p,v,A){var M=A.window===A?A.document:A.nodeType===9?A:A.ownerDocument;Af||zc==null||zc!==We(M)||(M=zc,"selectionStart"in M&&Ef(M)?M={start:M.selectionStart,end:M.selectionEnd}:(M=(M.ownerDocument&&M.ownerDocument.defaultView||window).getSelection(),M={anchorNode:M.anchorNode,anchorOffset:M.anchorOffset,focusNode:M.focusNode,focusOffset:M.focusOffset}),Ho&&Bc(Ho,M)||(Ho=M,M=Xu(Tf,"onSelect"),0<M.length&&(v=new nt("onSelect","select",null,v,A),p.push({event:v,listeners:M}),v.target=zc)))}function Gu(p,v){var A={};return A[p.toLowerCase()]=v.toLowerCase(),A["Webkit"+p]="webkit"+v,A["Moz"+p]="moz"+v,A}var Aa={animationend:Gu("Animation","AnimationEnd"),animationiteration:Gu("Animation","AnimationIteration"),animationstart:Gu("Animation","AnimationStart"),transitionend:Gu("Transition","TransitionEnd")},$f={},xm={};o&&(xm=document.createElement("div").style,"AnimationEvent"in window||(delete Aa.animationend.animation,delete Aa.animationiteration.animation,delete Aa.animationstart.animation),"TransitionEvent"in window||delete Aa.transitionend.transition);function Fc(p){if($f[p])return $f[p];if(!Aa[p])return p;var v=Aa[p],A;for(A in v)if(v.hasOwnProperty(A)&&A in xm)return $f[p]=v[A];return p}var wm=Fc("animationend"),_m=Fc("animationiteration"),Sm=Fc("animationstart"),km=Fc("transitionend"),xb=new Map,Cm="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function co(p,v){xb.set(p,v),a(v,[p])}for(var Nf=0;Nf<Cm.length;Nf++){var jm=Cm[Nf],wb=jm.toLowerCase(),jr=jm[0].toUpperCase()+jm.slice(1);co(wb,"on"+jr)}co(wm,"onAnimationEnd"),co(_m,"onAnimationIteration"),co(Sm,"onAnimationStart"),co("dblclick","onDoubleClick"),co("focusin","onFocus"),co("focusout","onBlur"),co(km,"onTransitionEnd"),l("onMouseEnter",["mouseout","mouseover"]),l("onMouseLeave",["mouseout","mouseover"]),l("onPointerEnter",["pointerout","pointerover"]),l("onPointerLeave",["pointerout","pointerover"]),a("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),a("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),a("onBeforeInput",["compositionend","keypress","textInput","paste"]),a("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),a("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),a("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Uc="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),_b=new Set("cancel close invalid load scroll toggle".split(" ").concat(Uc));function Em(p,v,A){var M=p.type||"unknown-event";p.currentTarget=A,ai(M,v,void 0,p),p.currentTarget=null}function Tm(p,v){v=(v&4)!==0;for(var A=0;A<p.length;A++){var M=p[A],H=M.event;M=M.listeners;e:{var ee=void 0;if(v)for(var ue=M.length-1;0<=ue;ue--){var Se=M[ue],Ne=Se.instance,Ke=Se.currentTarget;if(Se=Se.listener,Ne!==ee&&H.isPropagationStopped())break e;Em(H,Se,Ke),ee=Ne}else for(ue=0;ue<M.length;ue++){if(Se=M[ue],Ne=Se.instance,Ke=Se.currentTarget,Se=Se.listener,Ne!==ee&&H.isPropagationStopped())break e;Em(H,Se,Ke),ee=Ne}}}if(us)throw p=Kt,us=!1,Kt=null,p}function Qr(p,v){var A=v[Bf];A===void 0&&(A=v[Bf]=new Set);var M=p+"__bubble";A.has(M)||(Am(v,p,2,!1),A.add(M))}function Of(p,v,A){var M=0;v&&(M|=4),Am(A,p,M,v)}var Ku="_reactListening"+Math.random().toString(36).slice(2);function qc(p){if(!p[Ku]){p[Ku]=!0,i.forEach(function(A){A!=="selectionchange"&&(_b.has(A)||Of(A,!1,p),Of(A,!0,p))});var v=p.nodeType===9?p:p.ownerDocument;v===null||v[Ku]||(v[Ku]=!0,Of("selectionchange",!1,v))}}function Am(p,v,A,M){switch(fe(v)){case 1:var H=Bu;break;case 4:H=zu;break;default:H=Pc}A=H.bind(null,v,A,p),H=void 0,!_r||v!=="touchstart"&&v!=="touchmove"&&v!=="wheel"||(H=!0),M?H!==void 0?p.addEventListener(v,A,{capture:!0,passive:H}):p.addEventListener(v,A,!0):H!==void 0?p.addEventListener(v,A,{passive:H}):p.addEventListener(v,A,!1)}function Pf(p,v,A,M,H){var ee=M;if((v&1)===0&&(v&2)===0&&M!==null)e:for(;;){if(M===null)return;var ue=M.tag;if(ue===3||ue===4){var Se=M.stateNode.containerInfo;if(Se===H||Se.nodeType===8&&Se.parentNode===H)break;if(ue===4)for(ue=M.return;ue!==null;){var Ne=ue.tag;if((Ne===3||Ne===4)&&(Ne=ue.stateNode.containerInfo,Ne===H||Ne.nodeType===8&&Ne.parentNode===H))return;ue=ue.return}for(;Se!==null;){if(ue=Vo(Se),ue===null)return;if(Ne=ue.tag,Ne===5||Ne===6){M=ee=ue;continue e}Se=Se.parentNode}}M=M.return}es(function(){var Ke=ee,dt=In(A),ht=[];e:{var lt=xb.get(p);if(lt!==void 0){var Ct=nt,Mt=p;switch(p){case"keypress":if(Oe(A)===0)break e;case"keydown":case"keyup":Ct=xf;break;case"focusin":Mt="focus",Ct=yr;break;case"focusout":Mt="blur",Ct=yr;break;case"beforeblur":case"afterblur":Ct=yr;break;case"click":if(A.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ct=ir;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ct=Ut;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ct=Si;break;case wm:case _m:case Sm:Ct=ci;break;case km:Ct=ki;break;case"scroll":Ct=Ot;break;case"wheel":Ct=wf;break;case"copy":case"cut":case"paste":Ct=Nl;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ct=Wo}var Dt=(v&4)!==0,Gr=!Dt&&p==="scroll",qe=Dt?lt!==null?lt+"Capture":null:lt;Dt=[];for(var Ie=Ke,Xe;Ie!==null;){Xe=Ie;var yt=Xe.stateNode;if(Xe.tag===5&&yt!==null&&(Xe=yt,qe!==null&&(yt=Li(Ie,qe),yt!=null&&Dt.push(Wc(Ie,yt,Xe)))),Gr)break;Ie=Ie.return}0<Dt.length&&(lt=new Ct(lt,Mt,null,A,dt),ht.push({event:lt,listeners:Dt}))}}if((v&7)===0){e:{if(lt=p==="mouseover"||p==="pointerover",Ct=p==="mouseout"||p==="pointerout",lt&&A!==si&&(Mt=A.relatedTarget||A.fromElement)&&(Vo(Mt)||Mt[ca]))break e;if((Ct||lt)&&(lt=dt.window===dt?dt:(lt=dt.ownerDocument)?lt.defaultView||lt.parentWindow:window,Ct?(Mt=A.relatedTarget||A.toElement,Ct=Ke,Mt=Mt?Vo(Mt):null,Mt!==null&&(Gr=Nt(Mt),Mt!==Gr||Mt.tag!==5&&Mt.tag!==6)&&(Mt=null)):(Ct=null,Mt=Ke),Ct!==Mt)){if(Dt=ir,yt="onMouseLeave",qe="onMouseEnter",Ie="mouse",(p==="pointerout"||p==="pointerover")&&(Dt=Wo,yt="onPointerLeave",qe="onPointerEnter",Ie="pointer"),Gr=Ct==null?lt:Rl(Ct),Xe=Mt==null?lt:Rl(Mt),lt=new Dt(yt,Ie+"leave",Ct,A,dt),lt.target=Gr,lt.relatedTarget=Xe,yt=null,Vo(dt)===Ke&&(Dt=new Dt(qe,Ie+"enter",Mt,A,dt),Dt.target=Xe,Dt.relatedTarget=Gr,yt=Dt),Gr=yt,Ct&&Mt)t:{for(Dt=Ct,qe=Mt,Ie=0,Xe=Dt;Xe;Xe=Ol(Xe))Ie++;for(Xe=0,yt=qe;yt;yt=Ol(yt))Xe++;for(;0<Ie-Xe;)Dt=Ol(Dt),Ie--;for(;0<Xe-Ie;)qe=Ol(qe),Xe--;for(;Ie--;){if(Dt===qe||qe!==null&&Dt===qe.alternate)break t;Dt=Ol(Dt),qe=Ol(qe)}Dt=null}else Dt=null;Ct!==null&&$m(ht,lt,Ct,Dt,!1),Mt!==null&&Gr!==null&&$m(ht,Gr,Mt,Dt,!0)}}e:{if(lt=Ke?Rl(Ke):window,Ct=lt.nodeName&<.nodeName.toLowerCase(),Ct==="select"||Ct==="input"&<.type==="file")var Wt=hb;else if(zs(lt))if(hm)Wt=vb;else{Wt=mb;var tr=pb}else(Ct=lt.nodeName)&&Ct.toLowerCase()==="input"&&(lt.type==="checkbox"||lt.type==="radio")&&(Wt=gb);if(Wt&&(Wt=Wt(p,Ke))){fm(ht,Wt,A,dt);break e}tr&&tr(p,lt,Ke),p==="focusout"&&(tr=lt._wrapperState)&&tr.controlled&<.type==="number"&&Xt(lt,"number",lt.value)}switch(tr=Ke?Rl(Ke):window,p){case"focusin":(zs(tr)||tr.contentEditable==="true")&&(zc=tr,Tf=Ke,Ho=null);break;case"focusout":Ho=Tf=zc=null;break;case"mousedown":Af=!0;break;case"contextmenu":case"mouseup":case"dragend":Af=!1,bm(ht,A,dt);break;case"selectionchange":if(ym)break;case"keydown":case"keyup":bm(ht,A,dt)}var rr;if(ys)e:{switch(p){case"compositionstart":var ar="onCompositionStart";break e;case"compositionend":ar="onCompositionEnd";break e;case"compositionupdate":ar="onCompositionUpdate";break e}ar=void 0}else Ci?Hu(p,A)&&(ar="onCompositionEnd"):p==="keydown"&&A.keyCode===229&&(ar="onCompositionStart");ar&&(ln&&A.locale!=="ko"&&(Ci||ar!=="onCompositionStart"?ar==="onCompositionEnd"&&Ci&&(rr=ze()):(ye=dt,$e="value"in ye?ye.value:ye.textContent,Ci=!0)),tr=Xu(Ke,ar),0<tr.length&&(ar=new Mc(ar,p,null,A,dt),ht.push({event:ar,listeners:tr}),rr?ar.data=rr:(rr=ub(A),rr!==null&&(ar.data=rr)))),(rr=jn?db(p,A):_f(p,A))&&(Ke=Xu(Ke,"onBeforeInput"),0<Ke.length&&(dt=new Mc("onBeforeInput","beforeinput",null,A,dt),ht.push({event:dt,listeners:Ke}),dt.data=rr))}Tm(ht,v)})}function Wc(p,v,A){return{instance:p,listener:v,currentTarget:A}}function Xu(p,v){for(var A=v+"Capture",M=[];p!==null;){var H=p,ee=H.stateNode;H.tag===5&&ee!==null&&(H=ee,ee=Li(p,A),ee!=null&&M.unshift(Wc(p,ee,H)),ee=Li(p,v),ee!=null&&M.push(Wc(p,ee,H))),p=p.return}return M}function Ol(p){if(p===null)return null;do p=p.return;while(p&&p.tag!==5);return p||null}function $m(p,v,A,M,H){for(var ee=v._reactName,ue=[];A!==null&&A!==M;){var Se=A,Ne=Se.alternate,Ke=Se.stateNode;if(Ne!==null&&Ne===M)break;Se.tag===5&&Ke!==null&&(Se=Ke,H?(Ne=Li(A,ee),Ne!=null&&ue.unshift(Wc(A,Ne,Se))):H||(Ne=Li(A,ee),Ne!=null&&ue.push(Wc(A,Ne,Se)))),A=A.return}ue.length!==0&&p.push({event:v,listeners:ue})}var Yu=/\r\n?/g,Sb=/\u0000|\uFFFD/g;function Ju(p){return(typeof p=="string"?p:""+p).replace(Yu,`
|
|
39
39
|
`).replace(Sb,"")}function Qu(p,v,A){if(v=Ju(v),Ju(p)!==v&&A)throw Error(n(425))}function Zu(){}var Rf=null,Mf=null;function If(p,v){return p==="textarea"||p==="noscript"||typeof v.children=="string"||typeof v.children=="number"||typeof v.dangerouslySetInnerHTML=="object"&&v.dangerouslySetInnerHTML!==null&&v.dangerouslySetInnerHTML.__html!=null}var Df=typeof setTimeout=="function"?setTimeout:void 0,kb=typeof clearTimeout=="function"?clearTimeout:void 0,Nm=typeof Promise=="function"?Promise:void 0,Cb=typeof queueMicrotask=="function"?queueMicrotask:typeof Nm<"u"?function(p){return Nm.resolve(null).then(p).catch(jb)}:Df;function jb(p){setTimeout(function(){throw p})}function Lf(p,v){var A=v,M=0;do{var H=A.nextSibling;if(p.removeChild(A),H&&H.nodeType===8)if(A=H.data,A==="/$"){if(M===0){p.removeChild(H),Ta(v);return}M--}else A!=="$"&&A!=="$?"&&A!=="$!"||M++;A=H}while(A);Ta(v)}function uo(p){for(;p!=null;p=p.nextSibling){var v=p.nodeType;if(v===1||v===3)break;if(v===8){if(v=p.data,v==="$"||v==="$!"||v==="$?")break;if(v==="/$")return null}}return p}function Om(p){p=p.previousSibling;for(var v=0;p;){if(p.nodeType===8){var A=p.data;if(A==="$"||A==="$!"||A==="$?"){if(v===0)return p;v--}else A==="/$"&&v++}p=p.previousSibling}return null}var Pl=Math.random().toString(36).slice(2),la="__reactFiber$"+Pl,Hc="__reactProps$"+Pl,ca="__reactContainer$"+Pl,Bf="__reactEvents$"+Pl,Pm="__reactListeners$"+Pl,Rm="__reactHandles$"+Pl;function Vo(p){var v=p[la];if(v)return v;for(var A=p.parentNode;A;){if(v=A[ca]||A[la]){if(A=v.alternate,v.child!==null||A!==null&&A.child!==null)for(p=Om(p);p!==null;){if(A=p[la])return A;p=Om(p)}return v}p=A,A=p.parentNode}return null}function Vc(p){return p=p[la]||p[ca],!p||p.tag!==5&&p.tag!==6&&p.tag!==13&&p.tag!==3?null:p}function Rl(p){if(p.tag===5||p.tag===6)return p.stateNode;throw Error(n(33))}function ed(p){return p[Hc]||null}var zf=[],Ml=-1;function $a(p){return{current:p}}function Zr(p){0>Ml||(p.current=zf[Ml],zf[Ml]=null,Ml--)}function Vr(p,v){Ml++,zf[Ml]=p.current,p.current=v}var fo={},ji=$a(fo),Bi=$a(!1),Go=fo;function Ei(p,v){var A=p.type.contextTypes;if(!A)return fo;var M=p.stateNode;if(M&&M.__reactInternalMemoizedUnmaskedChildContext===v)return M.__reactInternalMemoizedMaskedChildContext;var H={},ee;for(ee in A)H[ee]=v[ee];return M&&(p=p.stateNode,p.__reactInternalMemoizedUnmaskedChildContext=v,p.__reactInternalMemoizedMaskedChildContext=H),H}function zi(p){return p=p.childContextTypes,p!=null}function td(){Zr(Bi),Zr(ji)}function Mm(p,v,A){if(ji.current!==fo)throw Error(n(168));Vr(ji,v),Vr(Bi,A)}function Im(p,v,A){var M=p.stateNode;if(v=v.childContextTypes,typeof M.getChildContext!="function")return A;M=M.getChildContext();for(var H in M)if(!(H in v))throw Error(n(108,be(p)||"Unknown",H));return K({},A,M)}function rd(p){return p=(p=p.stateNode)&&p.__reactInternalMemoizedMergedChildContext||fo,Go=ji.current,Vr(ji,p),Vr(Bi,Bi.current),!0}function Dm(p,v,A){var M=p.stateNode;if(!M)throw Error(n(169));A?(p=Im(p,v,Go),M.__reactInternalMemoizedMergedChildContext=p,Zr(Bi),Zr(ji),Vr(ji,p)):Zr(Bi),Vr(Bi,A)}var Na=null,nd=!1,Ff=!1;function Lm(p){Na===null?Na=[p]:Na.push(p)}function F_(p){nd=!0,Lm(p)}function ho(){if(!Ff&&Na!==null){Ff=!0;var p=0,v=gr;try{var A=Na;for(gr=1;p<A.length;p++){var M=A[p];do M=M(!0);while(M!==null)}Na=null,nd=!1}catch(H){throw Na!==null&&(Na=Na.slice(p+1)),xi(kn,ho),H}finally{gr=v,Ff=!1}}return null}var Il=[],Dl=0,id=null,sd=0,xs=[],qs=0,ws=null,Fi=1,Ui="";function po(p,v){Il[Dl++]=sd,Il[Dl++]=id,id=p,sd=v}function Ko(p,v,A){xs[qs++]=Fi,xs[qs++]=Ui,xs[qs++]=ws,ws=p;var M=Fi;p=Ui;var H=32-fr(M)-1;M&=~(1<<H),A+=1;var ee=32-fr(v)+H;if(30<ee){var ue=H-H%5;ee=(M&(1<<ue)-1).toString(32),M>>=ue,H-=ue,Fi=1<<32-fr(v)+H|A<<H|M,Ui=ee+p}else Fi=1<<ee|A<<H|M,Ui=p}function An(p){p.return!==null&&(po(p,1),Ko(p,1,0))}function Uf(p){for(;p===id;)id=Il[--Dl],Il[Dl]=null,sd=Il[--Dl],Il[Dl]=null;for(;p===ws;)ws=xs[--qs],xs[qs]=null,Ui=xs[--qs],xs[qs]=null,Fi=xs[--qs],xs[qs]=null}var qi=null,rs=null,dn=!1,Wi=null;function qf(p,v){var A=is(5,null,null,0);A.elementType="DELETED",A.stateNode=v,A.return=p,v=p.deletions,v===null?(p.deletions=[A],p.flags|=16):v.push(A)}function Wf(p,v){switch(p.tag){case 5:var A=p.type;return v=v.nodeType!==1||A.toLowerCase()!==v.nodeName.toLowerCase()?null:v,v!==null?(p.stateNode=v,qi=p,rs=uo(v.firstChild),!0):!1;case 6:return v=p.pendingProps===""||v.nodeType!==3?null:v,v!==null?(p.stateNode=v,qi=p,rs=null,!0):!1;case 13:return v=v.nodeType!==8?null:v,v!==null?(A=ws!==null?{id:Fi,overflow:Ui}:null,p.memoizedState={dehydrated:v,treeContext:A,retryLane:1073741824},A=is(18,null,null,0),A.stateNode=v,A.return=p,p.child=A,qi=p,rs=null,!0):!1;default:return!1}}function Hf(p){return(p.mode&1)!==0&&(p.flags&128)===0}function Vf(p){if(dn){var v=rs;if(v){var A=v;if(!Wf(p,v)){if(Hf(p))throw Error(n(418));v=uo(A.nextSibling);var M=qi;v&&Wf(p,v)?qf(M,A):(p.flags=p.flags&-4097|2,dn=!1,qi=p)}}else{if(Hf(p))throw Error(n(418));p.flags=p.flags&-4097|2,dn=!1,qi=p}}}function Gf(p){for(p=p.return;p!==null&&p.tag!==5&&p.tag!==3&&p.tag!==13;)p=p.return;qi=p}function Gc(p){if(p!==qi)return!1;if(!dn)return Gf(p),dn=!0,!1;var v;if((v=p.tag!==3)&&!(v=p.tag!==5)&&(v=p.type,v=v!=="head"&&v!=="body"&&!If(p.type,p.memoizedProps)),v&&(v=rs)){if(Hf(p))throw Bm(),Error(n(418));for(;v;)qf(p,v),v=uo(v.nextSibling)}if(Gf(p),p.tag===13){if(p=p.memoizedState,p=p!==null?p.dehydrated:null,!p)throw Error(n(317));e:{for(p=p.nextSibling,v=0;p;){if(p.nodeType===8){var A=p.data;if(A==="/$"){if(v===0){rs=uo(p.nextSibling);break e}v--}else A!=="$"&&A!=="$!"&&A!=="$?"||v++}p=p.nextSibling}rs=null}}else rs=qi?uo(p.stateNode.nextSibling):null;return!0}function Bm(){for(var p=rs;p;)p=uo(p.nextSibling)}function Xo(){rs=qi=null,dn=!1}function Kf(p){Wi===null?Wi=[p]:Wi.push(p)}var Xf=T.ReactCurrentBatchConfig;function Ll(p,v,A){if(p=A.ref,p!==null&&typeof p!="function"&&typeof p!="object"){if(A._owner){if(A=A._owner,A){if(A.tag!==1)throw Error(n(309));var M=A.stateNode}if(!M)throw Error(n(147,p));var H=M,ee=""+p;return v!==null&&v.ref!==null&&typeof v.ref=="function"&&v.ref._stringRef===ee?v.ref:(v=function(ue){var Se=H.refs;ue===null?delete Se[ee]:Se[ee]=ue},v._stringRef=ee,v)}if(typeof p!="string")throw Error(n(284));if(!A._owner)throw Error(n(290,p))}return p}function ad(p,v){throw p=Object.prototype.toString.call(v),Error(n(31,p==="[object Object]"?"object with keys {"+Object.keys(v).join(", ")+"}":p))}function zm(p){var v=p._init;return v(p._payload)}function Eb(p){function v(qe,Ie){if(p){var Xe=qe.deletions;Xe===null?(qe.deletions=[Ie],qe.flags|=16):Xe.push(Ie)}}function A(qe,Ie){if(!p)return null;for(;Ie!==null;)v(qe,Ie),Ie=Ie.sibling;return null}function M(qe,Ie){for(qe=new Map;Ie!==null;)Ie.key!==null?qe.set(Ie.key,Ie):qe.set(Ie.index,Ie),Ie=Ie.sibling;return qe}function H(qe,Ie){return qe=_o(qe,Ie),qe.index=0,qe.sibling=null,qe}function ee(qe,Ie,Xe){return qe.index=Xe,p?(Xe=qe.alternate,Xe!==null?(Xe=Xe.index,Xe<Ie?(qe.flags|=2,Ie):Xe):(qe.flags|=2,Ie)):(qe.flags|=1048576,Ie)}function ue(qe){return p&&qe.alternate===null&&(qe.flags|=2),qe}function Se(qe,Ie,Xe,yt){return Ie===null||Ie.tag!==6?(Ie=Vh(Xe,qe.mode,yt),Ie.return=qe,Ie):(Ie=H(Ie,Xe),Ie.return=qe,Ie)}function Ne(qe,Ie,Xe,yt){var Wt=Xe.type;return Wt===P?dt(qe,Ie,Xe.props.children,yt,Xe.key):Ie!==null&&(Ie.elementType===Wt||typeof Wt=="object"&&Wt!==null&&Wt.$$typeof===Y&&zm(Wt)===Ie.type)?(yt=H(Ie,Xe.props),yt.ref=Ll(qe,Ie,Xe),yt.return=qe,yt):(yt=Td(Xe.type,Xe.key,Xe.props,null,qe.mode,yt),yt.ref=Ll(qe,Ie,Xe),yt.return=qe,yt)}function Ke(qe,Ie,Xe,yt){return Ie===null||Ie.tag!==4||Ie.stateNode.containerInfo!==Xe.containerInfo||Ie.stateNode.implementation!==Xe.implementation?(Ie=Gh(Xe,qe.mode,yt),Ie.return=qe,Ie):(Ie=H(Ie,Xe.children||[]),Ie.return=qe,Ie)}function dt(qe,Ie,Xe,yt,Wt){return Ie===null||Ie.tag!==7?(Ie=Kl(Xe,qe.mode,yt,Wt),Ie.return=qe,Ie):(Ie=H(Ie,Xe),Ie.return=qe,Ie)}function ht(qe,Ie,Xe){if(typeof Ie=="string"&&Ie!==""||typeof Ie=="number")return Ie=Vh(""+Ie,qe.mode,Xe),Ie.return=qe,Ie;if(typeof Ie=="object"&&Ie!==null){switch(Ie.$$typeof){case j:return Xe=Td(Ie.type,Ie.key,Ie.props,null,qe.mode,Xe),Xe.ref=Ll(qe,null,Ie),Xe.return=qe,Xe;case $:return Ie=Gh(Ie,qe.mode,Xe),Ie.return=qe,Ie;case Y:var yt=Ie._init;return ht(qe,yt(Ie._payload),Xe)}if(Qt(Ie)||J(Ie))return Ie=Kl(Ie,qe.mode,Xe,null),Ie.return=qe,Ie;ad(qe,Ie)}return null}function lt(qe,Ie,Xe,yt){var Wt=Ie!==null?Ie.key:null;if(typeof Xe=="string"&&Xe!==""||typeof Xe=="number")return Wt!==null?null:Se(qe,Ie,""+Xe,yt);if(typeof Xe=="object"&&Xe!==null){switch(Xe.$$typeof){case j:return Xe.key===Wt?Ne(qe,Ie,Xe,yt):null;case $:return Xe.key===Wt?Ke(qe,Ie,Xe,yt):null;case Y:return Wt=Xe._init,lt(qe,Ie,Wt(Xe._payload),yt)}if(Qt(Xe)||J(Xe))return Wt!==null?null:dt(qe,Ie,Xe,yt,null);ad(qe,Xe)}return null}function Ct(qe,Ie,Xe,yt,Wt){if(typeof yt=="string"&&yt!==""||typeof yt=="number")return qe=qe.get(Xe)||null,Se(Ie,qe,""+yt,Wt);if(typeof yt=="object"&&yt!==null){switch(yt.$$typeof){case j:return qe=qe.get(yt.key===null?Xe:yt.key)||null,Ne(Ie,qe,yt,Wt);case $:return qe=qe.get(yt.key===null?Xe:yt.key)||null,Ke(Ie,qe,yt,Wt);case Y:var tr=yt._init;return Ct(qe,Ie,Xe,tr(yt._payload),Wt)}if(Qt(yt)||J(yt))return qe=qe.get(Xe)||null,dt(Ie,qe,yt,Wt,null);ad(Ie,yt)}return null}function Mt(qe,Ie,Xe,yt){for(var Wt=null,tr=null,rr=Ie,ar=Ie=0,Un=null;rr!==null&&ar<Xe.length;ar++){rr.index>ar?(Un=rr,rr=null):Un=rr.sibling;var $r=lt(qe,rr,Xe[ar],yt);if($r===null){rr===null&&(rr=Un);break}p&&rr&&$r.alternate===null&&v(qe,rr),Ie=ee($r,Ie,ar),tr===null?Wt=$r:tr.sibling=$r,tr=$r,rr=Un}if(ar===Xe.length)return A(qe,rr),dn&&po(qe,ar),Wt;if(rr===null){for(;ar<Xe.length;ar++)rr=ht(qe,Xe[ar],yt),rr!==null&&(Ie=ee(rr,Ie,ar),tr===null?Wt=rr:tr.sibling=rr,tr=rr);return dn&&po(qe,ar),Wt}for(rr=M(qe,rr);ar<Xe.length;ar++)Un=Ct(rr,qe,ar,Xe[ar],yt),Un!==null&&(p&&Un.alternate!==null&&rr.delete(Un.key===null?ar:Un.key),Ie=ee(Un,Ie,ar),tr===null?Wt=Un:tr.sibling=Un,tr=Un);return p&&rr.forEach(function(Ia){return v(qe,Ia)}),dn&&po(qe,ar),Wt}function Dt(qe,Ie,Xe,yt){var Wt=J(Xe);if(typeof Wt!="function")throw Error(n(150));if(Xe=Wt.call(Xe),Xe==null)throw Error(n(151));for(var tr=Wt=null,rr=Ie,ar=Ie=0,Un=null,$r=Xe.next();rr!==null&&!$r.done;ar++,$r=Xe.next()){rr.index>ar?(Un=rr,rr=null):Un=rr.sibling;var Ia=lt(qe,rr,$r.value,yt);if(Ia===null){rr===null&&(rr=Un);break}p&&rr&&Ia.alternate===null&&v(qe,rr),Ie=ee(Ia,Ie,ar),tr===null?Wt=Ia:tr.sibling=Ia,tr=Ia,rr=Un}if($r.done)return A(qe,rr),dn&&po(qe,ar),Wt;if(rr===null){for(;!$r.done;ar++,$r=Xe.next())$r=ht(qe,$r.value,yt),$r!==null&&(Ie=ee($r,Ie,ar),tr===null?Wt=$r:tr.sibling=$r,tr=$r);return dn&&po(qe,ar),Wt}for(rr=M(qe,rr);!$r.done;ar++,$r=Xe.next())$r=Ct(rr,qe,ar,$r.value,yt),$r!==null&&(p&&$r.alternate!==null&&rr.delete($r.key===null?ar:$r.key),Ie=ee($r,Ie,ar),tr===null?Wt=$r:tr.sibling=$r,tr=$r);return p&&rr.forEach(function(ax){return v(qe,ax)}),dn&&po(qe,ar),Wt}function Gr(qe,Ie,Xe,yt){if(typeof Xe=="object"&&Xe!==null&&Xe.type===P&&Xe.key===null&&(Xe=Xe.props.children),typeof Xe=="object"&&Xe!==null){switch(Xe.$$typeof){case j:e:{for(var Wt=Xe.key,tr=Ie;tr!==null;){if(tr.key===Wt){if(Wt=Xe.type,Wt===P){if(tr.tag===7){A(qe,tr.sibling),Ie=H(tr,Xe.props.children),Ie.return=qe,qe=Ie;break e}}else if(tr.elementType===Wt||typeof Wt=="object"&&Wt!==null&&Wt.$$typeof===Y&&zm(Wt)===tr.type){A(qe,tr.sibling),Ie=H(tr,Xe.props),Ie.ref=Ll(qe,tr,Xe),Ie.return=qe,qe=Ie;break e}A(qe,tr);break}else v(qe,tr);tr=tr.sibling}Xe.type===P?(Ie=Kl(Xe.props.children,qe.mode,yt,Xe.key),Ie.return=qe,qe=Ie):(yt=Td(Xe.type,Xe.key,Xe.props,null,qe.mode,yt),yt.ref=Ll(qe,Ie,Xe),yt.return=qe,qe=yt)}return ue(qe);case $:e:{for(tr=Xe.key;Ie!==null;){if(Ie.key===tr)if(Ie.tag===4&&Ie.stateNode.containerInfo===Xe.containerInfo&&Ie.stateNode.implementation===Xe.implementation){A(qe,Ie.sibling),Ie=H(Ie,Xe.children||[]),Ie.return=qe,qe=Ie;break e}else{A(qe,Ie);break}else v(qe,Ie);Ie=Ie.sibling}Ie=Gh(Xe,qe.mode,yt),Ie.return=qe,qe=Ie}return ue(qe);case Y:return tr=Xe._init,Gr(qe,Ie,tr(Xe._payload),yt)}if(Qt(Xe))return Mt(qe,Ie,Xe,yt);if(J(Xe))return Dt(qe,Ie,Xe,yt);ad(qe,Xe)}return typeof Xe=="string"&&Xe!==""||typeof Xe=="number"?(Xe=""+Xe,Ie!==null&&Ie.tag===6?(A(qe,Ie.sibling),Ie=H(Ie,Xe),Ie.return=qe,qe=Ie):(A(qe,Ie),Ie=Vh(Xe,qe.mode,yt),Ie.return=qe,qe=Ie),ue(qe)):A(qe,Ie)}return Gr}var Bl=Eb(!0),Yf=Eb(!1),Yo=$a(null),od=null,Jo=null,Jf=null;function Qf(){Jf=Jo=od=null}function Zf(p){var v=Yo.current;Zr(Yo),p._currentValue=v}function Fm(p,v,A){for(;p!==null;){var M=p.alternate;if((p.childLanes&v)!==v?(p.childLanes|=v,M!==null&&(M.childLanes|=v)):M!==null&&(M.childLanes&v)!==v&&(M.childLanes|=v),p===A)break;p=p.return}}function zl(p,v){od=p,Jf=Jo=null,p=p.dependencies,p!==null&&p.firstContext!==null&&((p.lanes&v)!==0&&(Hi=!0),p.firstContext=null)}function _s(p){var v=p._currentValue;if(Jf!==p)if(p={context:p,memoizedValue:v,next:null},Jo===null){if(od===null)throw Error(n(308));Jo=p,od.dependencies={lanes:0,firstContext:p}}else Jo=Jo.next=p;return v}var Fl=null;function eh(p){Fl===null?Fl=[p]:Fl.push(p)}function ld(p,v,A,M){var H=v.interleaved;return H===null?(A.next=A,eh(v)):(A.next=H.next,H.next=A),v.interleaved=A,Oa(p,M)}function Oa(p,v){p.lanes|=v;var A=p.alternate;for(A!==null&&(A.lanes|=v),A=p,p=p.return;p!==null;)p.childLanes|=v,A=p.alternate,A!==null&&(A.childLanes|=v),A=p,p=p.return;return A.tag===3?A.stateNode:null}var ua=!1;function cd(p){p.updateQueue={baseState:p.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function th(p,v){p=p.updateQueue,v.updateQueue===p&&(v.updateQueue={baseState:p.baseState,firstBaseUpdate:p.firstBaseUpdate,lastBaseUpdate:p.lastBaseUpdate,shared:p.shared,effects:p.effects})}function Pa(p,v){return{eventTime:p,lane:v,tag:0,payload:null,callback:null,next:null}}function mo(p,v,A){var M=p.updateQueue;if(M===null)return null;if(M=M.shared,(Er&2)!==0){var H=M.pending;return H===null?v.next=v:(v.next=H.next,H.next=v),M.pending=v,Oa(p,A)}return H=M.interleaved,H===null?(v.next=v,eh(M)):(v.next=H.next,H.next=v),M.interleaved=v,Oa(p,A)}function Kc(p,v,A){if(v=v.updateQueue,v!==null&&(v=v.shared,(A&4194240)!==0)){var M=v.lanes;M&=p.pendingLanes,A|=M,v.lanes=A,Al(p,A)}}function Tb(p,v){var A=p.updateQueue,M=p.alternate;if(M!==null&&(M=M.updateQueue,A===M)){var H=null,ee=null;if(A=A.firstBaseUpdate,A!==null){do{var ue={eventTime:A.eventTime,lane:A.lane,tag:A.tag,payload:A.payload,callback:A.callback,next:null};ee===null?H=ee=ue:ee=ee.next=ue,A=A.next}while(A!==null);ee===null?H=ee=v:ee=ee.next=v}else H=ee=v;A={baseState:M.baseState,firstBaseUpdate:H,lastBaseUpdate:ee,shared:M.shared,effects:M.effects},p.updateQueue=A;return}p=A.lastBaseUpdate,p===null?A.firstBaseUpdate=v:p.next=v,A.lastBaseUpdate=v}function ud(p,v,A,M){var H=p.updateQueue;ua=!1;var ee=H.firstBaseUpdate,ue=H.lastBaseUpdate,Se=H.shared.pending;if(Se!==null){H.shared.pending=null;var Ne=Se,Ke=Ne.next;Ne.next=null,ue===null?ee=Ke:ue.next=Ke,ue=Ne;var dt=p.alternate;dt!==null&&(dt=dt.updateQueue,Se=dt.lastBaseUpdate,Se!==ue&&(Se===null?dt.firstBaseUpdate=Ke:Se.next=Ke,dt.lastBaseUpdate=Ne))}if(ee!==null){var ht=H.baseState;ue=0,dt=Ke=Ne=null,Se=ee;do{var lt=Se.lane,Ct=Se.eventTime;if((M<)===lt){dt!==null&&(dt=dt.next={eventTime:Ct,lane:0,tag:Se.tag,payload:Se.payload,callback:Se.callback,next:null});e:{var Mt=p,Dt=Se;switch(lt=v,Ct=A,Dt.tag){case 1:if(Mt=Dt.payload,typeof Mt=="function"){ht=Mt.call(Ct,ht,lt);break e}ht=Mt;break e;case 3:Mt.flags=Mt.flags&-65537|128;case 0:if(Mt=Dt.payload,lt=typeof Mt=="function"?Mt.call(Ct,ht,lt):Mt,lt==null)break e;ht=K({},ht,lt);break e;case 2:ua=!0}}Se.callback!==null&&Se.lane!==0&&(p.flags|=64,lt=H.effects,lt===null?H.effects=[Se]:lt.push(Se))}else Ct={eventTime:Ct,lane:lt,tag:Se.tag,payload:Se.payload,callback:Se.callback,next:null},dt===null?(Ke=dt=Ct,Ne=ht):dt=dt.next=Ct,ue|=lt;if(Se=Se.next,Se===null){if(Se=H.shared.pending,Se===null)break;lt=Se,Se=lt.next,lt.next=null,H.lastBaseUpdate=lt,H.shared.pending=null}}while(!0);if(dt===null&&(Ne=ht),H.baseState=Ne,H.firstBaseUpdate=Ke,H.lastBaseUpdate=dt,v=H.shared.interleaved,v!==null){H=v;do ue|=H.lane,H=H.next;while(H!==v)}else ee===null&&(H.shared.lanes=0);nl|=ue,p.lanes=ue,p.memoizedState=ht}}function Ab(p,v,A){if(p=v.effects,v.effects=null,p!==null)for(v=0;v<p.length;v++){var M=p[v],H=M.callback;if(H!==null){if(M.callback=null,M=A,typeof H!="function")throw Error(n(191,H));H.call(M)}}}var Xc={},da=$a(Xc),Yc=$a(Xc),Ul=$a(Xc);function Qo(p){if(p===Xc)throw Error(n(174));return p}function rh(p,v){switch(Vr(Ul,v),Vr(Yc,p),Vr(da,Xc),p=v.nodeType,p){case 9:case 11:v=(v=v.documentElement)?v.namespaceURI:Kn(null,"");break;default:p=p===8?v.parentNode:v,v=p.namespaceURI||null,p=p.tagName,v=Kn(v,p)}Zr(da),Vr(da,v)}function Zo(){Zr(da),Zr(Yc),Zr(Ul)}function Um(p){Qo(Ul.current);var v=Qo(da.current),A=Kn(v,p.type);v!==A&&(Vr(Yc,p),Vr(da,A))}function nh(p){Yc.current===p&&(Zr(da),Zr(Yc))}var mn=$a(0);function dd(p){for(var v=p;v!==null;){if(v.tag===13){var A=v.memoizedState;if(A!==null&&(A=A.dehydrated,A===null||A.data==="$?"||A.data==="$!"))return v}else if(v.tag===19&&v.memoizedProps.revealOrder!==void 0){if((v.flags&128)!==0)return v}else if(v.child!==null){v.child.return=v,v=v.child;continue}if(v===p)break;for(;v.sibling===null;){if(v.return===null||v.return===p)return null;v=v.return}v.sibling.return=v.return,v=v.sibling}return null}var ih=[];function sh(){for(var p=0;p<ih.length;p++)ih[p]._workInProgressVersionPrimary=null;ih.length=0}var ah=T.ReactCurrentDispatcher,oh=T.ReactCurrentBatchConfig,el=0,fn=null,$n=null,zn=null,lh=!1,tl=!1,go=0,qm=0;function ui(){throw Error(n(321))}function ch(p,v){if(v===null)return!1;for(var A=0;A<v.length&&A<p.length;A++)if(!Us(p[A],v[A]))return!1;return!0}function uh(p,v,A,M,H,ee){if(el=ee,fn=v,v.memoizedState=null,v.updateQueue=null,v.lanes=0,ah.current=p===null||p.memoizedState===null?Mb:Ib,p=A(M,H),tl){ee=0;do{if(tl=!1,go=0,25<=ee)throw Error(n(301));ee+=1,zn=$n=null,v.updateQueue=null,ah.current=q_,p=A(M,H)}while(tl)}if(ah.current=md,v=$n!==null&&$n.next!==null,el=0,zn=$n=fn=null,lh=!1,v)throw Error(n(300));return p}function dh(){var p=go!==0;return go=0,p}function Ws(){var p={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return zn===null?fn.memoizedState=zn=p:zn=zn.next=p,zn}function Ss(){if($n===null){var p=fn.alternate;p=p!==null?p.memoizedState:null}else p=$n.next;var v=zn===null?fn.memoizedState:zn.next;if(v!==null)zn=v,$n=p;else{if(p===null)throw Error(n(310));$n=p,p={memoizedState:$n.memoizedState,baseState:$n.baseState,baseQueue:$n.baseQueue,queue:$n.queue,next:null},zn===null?fn.memoizedState=zn=p:zn=zn.next=p}return zn}function Jc(p,v){return typeof v=="function"?v(p):v}function fh(p){var v=Ss(),A=v.queue;if(A===null)throw Error(n(311));A.lastRenderedReducer=p;var M=$n,H=M.baseQueue,ee=A.pending;if(ee!==null){if(H!==null){var ue=H.next;H.next=ee.next,ee.next=ue}M.baseQueue=H=ee,A.pending=null}if(H!==null){ee=H.next,M=M.baseState;var Se=ue=null,Ne=null,Ke=ee;do{var dt=Ke.lane;if((el&dt)===dt)Ne!==null&&(Ne=Ne.next={lane:0,action:Ke.action,hasEagerState:Ke.hasEagerState,eagerState:Ke.eagerState,next:null}),M=Ke.hasEagerState?Ke.eagerState:p(M,Ke.action);else{var ht={lane:dt,action:Ke.action,hasEagerState:Ke.hasEagerState,eagerState:Ke.eagerState,next:null};Ne===null?(Se=Ne=ht,ue=M):Ne=Ne.next=ht,fn.lanes|=dt,nl|=dt}Ke=Ke.next}while(Ke!==null&&Ke!==ee);Ne===null?ue=M:Ne.next=Se,Us(M,v.memoizedState)||(Hi=!0),v.memoizedState=M,v.baseState=ue,v.baseQueue=Ne,A.lastRenderedState=M}if(p=A.interleaved,p!==null){H=p;do ee=H.lane,fn.lanes|=ee,nl|=ee,H=H.next;while(H!==p)}else H===null&&(A.lanes=0);return[v.memoizedState,A.dispatch]}function Wm(p){var v=Ss(),A=v.queue;if(A===null)throw Error(n(311));A.lastRenderedReducer=p;var M=A.dispatch,H=A.pending,ee=v.memoizedState;if(H!==null){A.pending=null;var ue=H=H.next;do ee=p(ee,ue.action),ue=ue.next;while(ue!==H);Us(ee,v.memoizedState)||(Hi=!0),v.memoizedState=ee,v.baseQueue===null&&(v.baseState=ee),A.lastRenderedState=ee}return[ee,M]}function Hm(){}function hh(p,v){var A=fn,M=Ss(),H=v(),ee=!Us(M.memoizedState,H);if(ee&&(M.memoizedState=H,Hi=!0),M=M.queue,Zm(Km.bind(null,A,M,p),[p]),M.getSnapshot!==v||ee||zn!==null&&zn.memoizedState.tag&1){if(A.flags|=2048,fd(9,Gm.bind(null,A,M,H,v),void 0,null),On===null)throw Error(n(349));(el&30)!==0||Vm(A,v,H)}return H}function Vm(p,v,A){p.flags|=16384,p={getSnapshot:v,value:A},v=fn.updateQueue,v===null?(v={lastEffect:null,stores:null},fn.updateQueue=v,v.stores=[p]):(A=v.stores,A===null?v.stores=[p]:A.push(p))}function Gm(p,v,A,M){v.value=A,v.getSnapshot=M,$b(v)&&Xm(p)}function Km(p,v,A){return A(function(){$b(v)&&Xm(p)})}function $b(p){var v=p.getSnapshot;p=p.value;try{var A=v();return!Us(p,A)}catch{return!0}}function Xm(p){var v=Oa(p,1);v!==null&&Gs(v,p,1,-1)}function Ym(p){var v=Ws();return typeof p=="function"&&(p=p()),v.memoizedState=v.baseState=p,p={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Jc,lastRenderedState:p},v.queue=p,p=p.dispatch=Pb.bind(null,fn,p),[v.memoizedState,p]}function fd(p,v,A,M){return p={tag:p,create:v,destroy:A,deps:M,next:null},v=fn.updateQueue,v===null?(v={lastEffect:null,stores:null},fn.updateQueue=v,v.lastEffect=p.next=p):(A=v.lastEffect,A===null?v.lastEffect=p.next=p:(M=A.next,A.next=p,p.next=M,v.lastEffect=p)),p}function Jm(){return Ss().memoizedState}function hd(p,v,A,M){var H=Ws();fn.flags|=p,H.memoizedState=fd(1|v,A,void 0,M===void 0?null:M)}function pd(p,v,A,M){var H=Ss();M=M===void 0?null:M;var ee=void 0;if($n!==null){var ue=$n.memoizedState;if(ee=ue.destroy,M!==null&&ch(M,ue.deps)){H.memoizedState=fd(v,A,ee,M);return}}fn.flags|=p,H.memoizedState=fd(1|v,A,ee,M)}function Qm(p,v){return hd(8390656,8,p,v)}function Zm(p,v){return pd(2048,8,p,v)}function eg(p,v){return pd(4,2,p,v)}function tg(p,v){return pd(4,4,p,v)}function rg(p,v){if(typeof v=="function")return p=p(),v(p),function(){v(null)};if(v!=null)return p=p(),v.current=p,function(){v.current=null}}function Nb(p,v,A){return A=A!=null?A.concat([p]):null,pd(4,4,rg.bind(null,v,p),A)}function ph(){}function ng(p,v){var A=Ss();v=v===void 0?null:v;var M=A.memoizedState;return M!==null&&v!==null&&ch(v,M[1])?M[0]:(A.memoizedState=[p,v],p)}function ig(p,v){var A=Ss();v=v===void 0?null:v;var M=A.memoizedState;return M!==null&&v!==null&&ch(v,M[1])?M[0]:(p=p(),A.memoizedState=[p,v],p)}function sg(p,v,A){return(el&21)===0?(p.baseState&&(p.baseState=!1,Hi=!0),p.memoizedState=A):(Us(A,v)||(A=ra(),fn.lanes|=A,nl|=A,p.baseState=!0),v)}function U_(p,v){var A=gr;gr=A!==0&&4>A?A:4,p(!0);var M=oh.transition;oh.transition={};try{p(!1),v()}finally{gr=A,oh.transition=M}}function ag(){return Ss().memoizedState}function Ob(p,v,A){var M=xo(p);if(A={lane:M,action:A,hasEagerState:!1,eagerState:null,next:null},og(p))Rb(v,A);else if(A=ld(p,v,A,M),A!==null){var H=Ai();Gs(A,p,M,H),lg(A,v,M)}}function Pb(p,v,A){var M=xo(p),H={lane:M,action:A,hasEagerState:!1,eagerState:null,next:null};if(og(p))Rb(v,H);else{var ee=p.alternate;if(p.lanes===0&&(ee===null||ee.lanes===0)&&(ee=v.lastRenderedReducer,ee!==null))try{var ue=v.lastRenderedState,Se=ee(ue,A);if(H.hasEagerState=!0,H.eagerState=Se,Us(Se,ue)){var Ne=v.interleaved;Ne===null?(H.next=H,eh(v)):(H.next=Ne.next,Ne.next=H),v.interleaved=H;return}}catch{}finally{}A=ld(p,v,H,M),A!==null&&(H=Ai(),Gs(A,p,M,H),lg(A,v,M))}}function og(p){var v=p.alternate;return p===fn||v!==null&&v===fn}function Rb(p,v){tl=lh=!0;var A=p.pending;A===null?v.next=v:(v.next=A.next,A.next=v),p.pending=v}function lg(p,v,A){if((A&4194240)!==0){var M=v.lanes;M&=p.pendingLanes,A|=M,v.lanes=A,Al(p,A)}}var md={readContext:_s,useCallback:ui,useContext:ui,useEffect:ui,useImperativeHandle:ui,useInsertionEffect:ui,useLayoutEffect:ui,useMemo:ui,useReducer:ui,useRef:ui,useState:ui,useDebugValue:ui,useDeferredValue:ui,useTransition:ui,useMutableSource:ui,useSyncExternalStore:ui,useId:ui,unstable_isNewReconciler:!1},Mb={readContext:_s,useCallback:function(p,v){return Ws().memoizedState=[p,v===void 0?null:v],p},useContext:_s,useEffect:Qm,useImperativeHandle:function(p,v,A){return A=A!=null?A.concat([p]):null,hd(4194308,4,rg.bind(null,v,p),A)},useLayoutEffect:function(p,v){return hd(4194308,4,p,v)},useInsertionEffect:function(p,v){return hd(4,2,p,v)},useMemo:function(p,v){var A=Ws();return v=v===void 0?null:v,p=p(),A.memoizedState=[p,v],p},useReducer:function(p,v,A){var M=Ws();return v=A!==void 0?A(v):v,M.memoizedState=M.baseState=v,p={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:p,lastRenderedState:v},M.queue=p,p=p.dispatch=Ob.bind(null,fn,p),[M.memoizedState,p]},useRef:function(p){var v=Ws();return p={current:p},v.memoizedState=p},useState:Ym,useDebugValue:ph,useDeferredValue:function(p){return Ws().memoizedState=p},useTransition:function(){var p=Ym(!1),v=p[0];return p=U_.bind(null,p[1]),Ws().memoizedState=p,[v,p]},useMutableSource:function(){},useSyncExternalStore:function(p,v,A){var M=fn,H=Ws();if(dn){if(A===void 0)throw Error(n(407));A=A()}else{if(A=v(),On===null)throw Error(n(349));(el&30)!==0||Vm(M,v,A)}H.memoizedState=A;var ee={value:A,getSnapshot:v};return H.queue=ee,Qm(Km.bind(null,M,ee,p),[p]),M.flags|=2048,fd(9,Gm.bind(null,M,ee,A,v),void 0,null),A},useId:function(){var p=Ws(),v=On.identifierPrefix;if(dn){var A=Ui,M=Fi;A=(M&~(1<<32-fr(M)-1)).toString(32)+A,v=":"+v+"R"+A,A=go++,0<A&&(v+="H"+A.toString(32)),v+=":"}else A=qm++,v=":"+v+"r"+A.toString(32)+":";return p.memoizedState=v},unstable_isNewReconciler:!1},Ib={readContext:_s,useCallback:ng,useContext:_s,useEffect:Zm,useImperativeHandle:Nb,useInsertionEffect:eg,useLayoutEffect:tg,useMemo:ig,useReducer:fh,useRef:Jm,useState:function(){return fh(Jc)},useDebugValue:ph,useDeferredValue:function(p){var v=Ss();return sg(v,$n.memoizedState,p)},useTransition:function(){var p=fh(Jc)[0],v=Ss().memoizedState;return[p,v]},useMutableSource:Hm,useSyncExternalStore:hh,useId:ag,unstable_isNewReconciler:!1},q_={readContext:_s,useCallback:ng,useContext:_s,useEffect:Zm,useImperativeHandle:Nb,useInsertionEffect:eg,useLayoutEffect:tg,useMemo:ig,useReducer:Wm,useRef:Jm,useState:function(){return Wm(Jc)},useDebugValue:ph,useDeferredValue:function(p){var v=Ss();return $n===null?v.memoizedState=p:sg(v,$n.memoizedState,p)},useTransition:function(){var p=Wm(Jc)[0],v=Ss().memoizedState;return[p,v]},useMutableSource:Hm,useSyncExternalStore:hh,useId:ag,unstable_isNewReconciler:!1};function Nn(p,v){if(p&&p.defaultProps){v=K({},v),p=p.defaultProps;for(var A in p)v[A]===void 0&&(v[A]=p[A]);return v}return v}function fa(p,v,A,M){v=p.memoizedState,A=A(M,v),A=A==null?v:K({},v,A),p.memoizedState=A,p.lanes===0&&(p.updateQueue.baseState=A)}var Ra={isMounted:function(p){return(p=p._reactInternals)?Nt(p)===p:!1},enqueueSetState:function(p,v,A){p=p._reactInternals;var M=Ai(),H=xo(p),ee=Pa(M,H);ee.payload=v,A!=null&&(ee.callback=A),v=mo(p,ee,H),v!==null&&(Gs(v,p,H,M),Kc(v,p,H))},enqueueReplaceState:function(p,v,A){p=p._reactInternals;var M=Ai(),H=xo(p),ee=Pa(M,H);ee.tag=1,ee.payload=v,A!=null&&(ee.callback=A),v=mo(p,ee,H),v!==null&&(Gs(v,p,H,M),Kc(v,p,H))},enqueueForceUpdate:function(p,v){p=p._reactInternals;var A=Ai(),M=xo(p),H=Pa(A,M);H.tag=2,v!=null&&(H.callback=v),v=mo(p,H,M),v!==null&&(Gs(v,p,M,A),Kc(v,p,M))}};function rl(p,v,A,M,H,ee,ue){return p=p.stateNode,typeof p.shouldComponentUpdate=="function"?p.shouldComponentUpdate(M,ee,ue):v.prototype&&v.prototype.isPureReactComponent?!Bc(A,M)||!Bc(H,ee):!0}function cg(p,v,A){var M=!1,H=fo,ee=v.contextType;return typeof ee=="object"&&ee!==null?ee=_s(ee):(H=zi(v)?Go:ji.current,M=v.contextTypes,ee=(M=M!=null)?Ei(p,H):fo),v=new v(A,ee),p.memoizedState=v.state!==null&&v.state!==void 0?v.state:null,v.updater=Ra,p.stateNode=v,v._reactInternals=p,M&&(p=p.stateNode,p.__reactInternalMemoizedUnmaskedChildContext=H,p.__reactInternalMemoizedMaskedChildContext=ee),v}function ug(p,v,A,M){p=v.state,typeof v.componentWillReceiveProps=="function"&&v.componentWillReceiveProps(A,M),typeof v.UNSAFE_componentWillReceiveProps=="function"&&v.UNSAFE_componentWillReceiveProps(A,M),v.state!==p&&Ra.enqueueReplaceState(v,v.state,null)}function mh(p,v,A,M){var H=p.stateNode;H.props=A,H.state=p.memoizedState,H.refs={},cd(p);var ee=v.contextType;typeof ee=="object"&&ee!==null?H.context=_s(ee):(ee=zi(v)?Go:ji.current,H.context=Ei(p,ee)),H.state=p.memoizedState,ee=v.getDerivedStateFromProps,typeof ee=="function"&&(fa(p,v,ee,A),H.state=p.memoizedState),typeof v.getDerivedStateFromProps=="function"||typeof H.getSnapshotBeforeUpdate=="function"||typeof H.UNSAFE_componentWillMount!="function"&&typeof H.componentWillMount!="function"||(v=H.state,typeof H.componentWillMount=="function"&&H.componentWillMount(),typeof H.UNSAFE_componentWillMount=="function"&&H.UNSAFE_componentWillMount(),v!==H.state&&Ra.enqueueReplaceState(H,H.state,null),ud(p,A,H,M),H.state=p.memoizedState),typeof H.componentDidMount=="function"&&(p.flags|=4194308)}function ql(p,v){try{var A="",M=v;do A+=Ce(M),M=M.return;while(M);var H=A}catch(ee){H=`
|
|
40
40
|
Error generating stack: `+ee.message+`
|
|
41
|
-
`+ee.stack}return{value:p,source:v,stack:H,digest:null}}function gh(p,v,A){return{value:p,source:null,stack:A??null,digest:v??null}}function vh(p,v){try{console.error(v.value)}catch(A){setTimeout(function(){throw A})}}var Db=typeof WeakMap=="function"?WeakMap:Map;function dg(p,v,A){A=Pa(-1,A),A.tag=3,A.payload={element:null};var M=v.value;return A.callback=function(){Sd||(Sd=!0,Lh=M),vh(p,v)},A}function fg(p,v,A){A=Pa(-1,A),A.tag=3;var M=p.type.getDerivedStateFromError;if(typeof M=="function"){var H=v.value;A.payload=function(){return M(H)},A.callback=function(){vh(p,v)}}var ee=p.stateNode;return ee!==null&&typeof ee.componentDidCatch=="function"&&(A.callback=function(){vh(p,v),typeof M!="function"&&(bo===null?bo=new Set([this]):bo.add(this));var ue=v.stack;this.componentDidCatch(v.value,{componentStack:ue!==null?ue:""})}),A}function hg(p,v,A){var M=p.pingCache;if(M===null){M=p.pingCache=new Db;var H=new Set;M.set(v,H)}else H=M.get(v),H===void 0&&(H=new Set,M.set(v,H));H.has(A)||(H.add(A),p=Xb.bind(null,p,v,A),v.then(p,p))}function Lb(p){do{var v;if((v=p.tag===13)&&(v=p.memoizedState,v=v!==null?v.dehydrated!==null:!0),v)return p;p=p.return}while(p!==null);return null}function Ti(p,v,A,M,H){return(p.mode&1)===0?(p===v?p.flags|=65536:(p.flags|=128,A.flags|=131072,A.flags&=-52805,A.tag===1&&(A.alternate===null?A.tag=17:(v=Pa(-1,1),v.tag=2,mo(A,v,1))),A.lanes|=1),p):(p.flags|=65536,p.lanes=H,p)}var Bb=T.ReactCurrentOwner,Hi=!1;function di(p,v,A,M){v.child=p===null?Yf(v,null,A,M):Bl(v,p.child,A,M)}function pg(p,v,A,M,H){A=A.render;var ee=v.ref;return zl(v,H),M=uh(p,v,A,M,ee,H),A=dh(),p!==null&&!Hi?(v.updateQueue=p.updateQueue,v.flags&=-2053,p.lanes&=~H,Ma(p,v,H)):(dn&&A&&An(v),v.flags|=1,di(p,v,M,H),v.child)}function Qc(p,v,A,M,H){if(p===null){var ee=A.type;return typeof ee=="function"&&!Hh(ee)&&ee.defaultProps===void 0&&A.compare===null&&A.defaultProps===void 0?(v.tag=15,v.type=ee,mg(p,v,ee,M,H)):(p=Td(A.type,null,M,v,v.mode,H),p.ref=v.ref,p.return=v,v.child=p)}if(ee=p.child,(p.lanes&H)===0){var ue=ee.memoizedProps;if(A=A.compare,A=A!==null?A:Bc,A(ue,M)&&p.ref===v.ref)return Ma(p,v,H)}return v.flags|=1,p=_o(ee,M),p.ref=v.ref,p.return=v,v.child=p}function mg(p,v,A,M,H){if(p!==null){var ee=p.memoizedProps;if(Bc(ee,M)&&p.ref===v.ref)if(Hi=!1,v.pendingProps=M=ee,(p.lanes&H)!==0)(p.flags&131072)!==0&&(Hi=!0);else return v.lanes=p.lanes,Ma(p,v,H)}return yh(p,v,A,M,H)}function gg(p,v,A){var M=v.pendingProps,H=M.children,ee=p!==null?p.memoizedState:null;if(M.mode==="hidden")if((v.mode&1)===0)v.memoizedState={baseLanes:0,cachePool:null,transitions:null},Vr(Hl,ns),ns|=A;else{if((A&1073741824)===0)return p=ee!==null?ee.baseLanes|A:A,v.lanes=v.childLanes=1073741824,v.memoizedState={baseLanes:p,cachePool:null,transitions:null},v.updateQueue=null,Vr(Hl,ns),ns|=p,null;v.memoizedState={baseLanes:0,cachePool:null,transitions:null},M=ee!==null?ee.baseLanes:A,Vr(Hl,ns),ns|=M}else ee!==null?(M=ee.baseLanes|A,v.memoizedState=null):M=A,Vr(Hl,ns),ns|=M;return di(p,v,H,A),v.child}function vg(p,v){var A=v.ref;(p===null&&A!==null||p!==null&&p.ref!==A)&&(v.flags|=512,v.flags|=2097152)}function yh(p,v,A,M,H){var ee=zi(A)?Go:ji.current;return ee=Ei(v,ee),zl(v,H),A=uh(p,v,A,M,ee,H),M=dh(),p!==null&&!Hi?(v.updateQueue=p.updateQueue,v.flags&=-2053,p.lanes&=~H,Ma(p,v,H)):(dn&&M&&An(v),v.flags|=1,di(p,v,A,H),v.child)}function yg(p,v,A,M,H){if(zi(A)){var ee=!0;rd(v)}else ee=!1;if(zl(v,H),v.stateNode===null)vd(p,v),cg(v,A,M),mh(v,A,M,H),M=!0;else if(p===null){var ue=v.stateNode,Se=v.memoizedProps;ue.props=Se;var Ne=ue.context,Ke=A.contextType;typeof Ke=="object"&&Ke!==null?Ke=_s(Ke):(Ke=zi(A)?Go:ji.current,Ke=Ei(v,Ke));var dt=A.getDerivedStateFromProps,ht=typeof dt=="function"||typeof ue.getSnapshotBeforeUpdate=="function";ht||typeof ue.UNSAFE_componentWillReceiveProps!="function"&&typeof ue.componentWillReceiveProps!="function"||(Se!==M||Ne!==Ke)&&ug(v,ue,M,Ke),ua=!1;var lt=v.memoizedState;ue.state=lt,ud(v,M,ue,H),Ne=v.memoizedState,Se!==M||lt!==Ne||Bi.current||ua?(typeof dt=="function"&&(fa(v,A,dt,M),Ne=v.memoizedState),(Se=ua||rl(v,A,Se,M,lt,Ne,Ke))?(ht||typeof ue.UNSAFE_componentWillMount!="function"&&typeof ue.componentWillMount!="function"||(typeof ue.componentWillMount=="function"&&ue.componentWillMount(),typeof ue.UNSAFE_componentWillMount=="function"&&ue.UNSAFE_componentWillMount()),typeof ue.componentDidMount=="function"&&(v.flags|=4194308)):(typeof ue.componentDidMount=="function"&&(v.flags|=4194308),v.memoizedProps=M,v.memoizedState=Ne),ue.props=M,ue.state=Ne,ue.context=Ke,M=Se):(typeof ue.componentDidMount=="function"&&(v.flags|=4194308),M=!1)}else{ue=v.stateNode,th(p,v),Se=v.memoizedProps,Ke=v.type===v.elementType?Se:Nn(v.type,Se),ue.props=Ke,ht=v.pendingProps,lt=ue.context,Ne=A.contextType,typeof Ne=="object"&&Ne!==null?Ne=_s(Ne):(Ne=zi(A)?Go:ji.current,Ne=Ei(v,Ne));var Ct=A.getDerivedStateFromProps;(dt=typeof Ct=="function"||typeof ue.getSnapshotBeforeUpdate=="function")||typeof ue.UNSAFE_componentWillReceiveProps!="function"&&typeof ue.componentWillReceiveProps!="function"||(Se!==ht||lt!==Ne)&&ug(v,ue,M,Ne),ua=!1,lt=v.memoizedState,ue.state=lt,ud(v,M,ue,H);var Mt=v.memoizedState;Se!==ht||lt!==Mt||Bi.current||ua?(typeof Ct=="function"&&(fa(v,A,Ct,M),Mt=v.memoizedState),(Ke=ua||rl(v,A,Ke,M,lt,Mt,Ne)||!1)?(dt||typeof ue.UNSAFE_componentWillUpdate!="function"&&typeof ue.componentWillUpdate!="function"||(typeof ue.componentWillUpdate=="function"&&ue.componentWillUpdate(M,Mt,Ne),typeof ue.UNSAFE_componentWillUpdate=="function"&&ue.UNSAFE_componentWillUpdate(M,Mt,Ne)),typeof ue.componentDidUpdate=="function"&&(v.flags|=4),typeof ue.getSnapshotBeforeUpdate=="function"&&(v.flags|=1024)):(typeof ue.componentDidUpdate!="function"||Se===p.memoizedProps&<===p.memoizedState||(v.flags|=4),typeof ue.getSnapshotBeforeUpdate!="function"||Se===p.memoizedProps&<===p.memoizedState||(v.flags|=1024),v.memoizedProps=M,v.memoizedState=Mt),ue.props=M,ue.state=Mt,ue.context=Ne,M=Ke):(typeof ue.componentDidUpdate!="function"||Se===p.memoizedProps&<===p.memoizedState||(v.flags|=4),typeof ue.getSnapshotBeforeUpdate!="function"||Se===p.memoizedProps&<===p.memoizedState||(v.flags|=1024),M=!1)}return bh(p,v,A,M,ee,H)}function bh(p,v,A,M,H,ee){vg(p,v);var ue=(v.flags&128)!==0;if(!M&&!ue)return H&&Dm(v,A,!1),Ma(p,v,ee);M=v.stateNode,Bb.current=v;var Se=ue&&typeof A.getDerivedStateFromError!="function"?null:M.render();return v.flags|=1,p!==null&&ue?(v.child=Bl(v,p.child,null,ee),v.child=Bl(v,null,Se,ee)):di(p,v,Se,ee),v.memoizedState=M.state,H&&Dm(v,A,!0),v.child}function xh(p){var v=p.stateNode;v.pendingContext?Mm(p,v.pendingContext,v.pendingContext!==v.context):v.context&&Mm(p,v.context,!1),rh(p,v.containerInfo)}function bg(p,v,A,M,H){return Xo(),Kf(H),v.flags|=256,di(p,v,A,M),v.child}var wh={dehydrated:null,treeContext:null,retryLane:0};function _h(p){return{baseLanes:p,cachePool:null,transitions:null}}function xg(p,v,A){var M=v.pendingProps,H=mn.current,ee=!1,ue=(v.flags&128)!==0,Se;if((Se=ue)||(Se=p!==null&&p.memoizedState===null?!1:(H&2)!==0),Se?(ee=!0,v.flags&=-129):(p===null||p.memoizedState!==null)&&(H|=1),Vr(mn,H&1),p===null)return Vf(v),p=v.memoizedState,p!==null&&(p=p.dehydrated,p!==null)?((v.mode&1)===0?v.lanes=1:p.data==="$!"?v.lanes=8:v.lanes=1073741824,null):(ue=M.children,p=M.fallback,ee?(M=v.mode,ee=v.child,ue={mode:"hidden",children:ue},(M&1)===0&&ee!==null?(ee.childLanes=0,ee.pendingProps=ue):ee=Ad(ue,M,0,null),p=Kl(p,M,A,null),ee.return=v,p.return=v,ee.sibling=p,v.child=ee,v.child.memoizedState=_h(A),v.memoizedState=wh,p):Zc(v,ue));if(H=p.memoizedState,H!==null&&(Se=H.dehydrated,Se!==null))return zb(p,v,ue,M,Se,H,A);if(ee){ee=M.fallback,ue=v.mode,H=p.child,Se=H.sibling;var Ne={mode:"hidden",children:M.children};return(ue&1)===0&&v.child!==H?(M=v.child,M.childLanes=0,M.pendingProps=Ne,v.deletions=null):(M=_o(H,Ne),M.subtreeFlags=H.subtreeFlags&14680064),Se!==null?ee=_o(Se,ee):(ee=Kl(ee,ue,A,null),ee.flags|=2),ee.return=v,M.return=v,M.sibling=ee,v.child=M,M=ee,ee=v.child,ue=p.child.memoizedState,ue=ue===null?_h(A):{baseLanes:ue.baseLanes|A,cachePool:null,transitions:ue.transitions},ee.memoizedState=ue,ee.childLanes=p.childLanes&~A,v.memoizedState=wh,M}return ee=p.child,p=ee.sibling,M=_o(ee,{mode:"visible",children:M.children}),(v.mode&1)===0&&(M.lanes=A),M.return=v,M.sibling=null,p!==null&&(A=v.deletions,A===null?(v.deletions=[p],v.flags|=16):A.push(p)),v.child=M,v.memoizedState=null,M}function Zc(p,v){return v=Ad({mode:"visible",children:v},p.mode,0,null),v.return=p,p.child=v}function gd(p,v,A,M){return M!==null&&Kf(M),Bl(v,p.child,null,A),p=Zc(v,v.pendingProps.children),p.flags|=2,v.memoizedState=null,p}function zb(p,v,A,M,H,ee,ue){if(A)return v.flags&256?(v.flags&=-257,M=gh(Error(n(422))),gd(p,v,ue,M)):v.memoizedState!==null?(v.child=p.child,v.flags|=128,null):(ee=M.fallback,H=v.mode,M=Ad({mode:"visible",children:M.children},H,0,null),ee=Kl(ee,H,ue,null),ee.flags|=2,M.return=v,ee.return=v,M.sibling=ee,v.child=M,(v.mode&1)!==0&&Bl(v,p.child,null,ue),v.child.memoizedState=_h(ue),v.memoizedState=wh,ee);if((v.mode&1)===0)return gd(p,v,ue,null);if(H.data==="$!"){if(M=H.nextSibling&&H.nextSibling.dataset,M)var Se=M.dgst;return M=Se,ee=Error(n(419)),M=gh(ee,M,void 0),gd(p,v,ue,M)}if(Se=(ue&p.childLanes)!==0,Hi||Se){if(M=On,M!==null){switch(ue&-ue){case 4:H=2;break;case 16:H=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:H=32;break;case 536870912:H=268435456;break;default:H=0}H=(H&(M.suspendedLanes|ue))!==0?0:H,H!==0&&H!==ee.retryLane&&(ee.retryLane=H,Oa(p,H),Gs(M,p,H,-1))}return Wh(),M=gh(Error(n(421))),gd(p,v,ue,M)}return H.data==="$?"?(v.flags|=128,v.child=p.child,v=Jb.bind(null,p),H._reactRetry=v,null):(p=ee.treeContext,rs=uo(H.nextSibling),qi=v,dn=!0,Wi=null,p!==null&&(xs[qs++]=Fi,xs[qs++]=Ui,xs[qs++]=ws,Fi=p.id,Ui=p.overflow,ws=v),v=Zc(v,M.children),v.flags|=4096,v)}function wg(p,v,A){p.lanes|=v;var M=p.alternate;M!==null&&(M.lanes|=v),Fm(p.return,v,A)}function Sh(p,v,A,M,H){var ee=p.memoizedState;ee===null?p.memoizedState={isBackwards:v,rendering:null,renderingStartTime:0,last:M,tail:A,tailMode:H}:(ee.isBackwards=v,ee.rendering=null,ee.renderingStartTime=0,ee.last=M,ee.tail=A,ee.tailMode=H)}function kh(p,v,A){var M=v.pendingProps,H=M.revealOrder,ee=M.tail;if(di(p,v,M.children,A),M=mn.current,(M&2)!==0)M=M&1|2,v.flags|=128;else{if(p!==null&&(p.flags&128)!==0)e:for(p=v.child;p!==null;){if(p.tag===13)p.memoizedState!==null&&wg(p,A,v);else if(p.tag===19)wg(p,A,v);else if(p.child!==null){p.child.return=p,p=p.child;continue}if(p===v)break e;for(;p.sibling===null;){if(p.return===null||p.return===v)break e;p=p.return}p.sibling.return=p.return,p=p.sibling}M&=1}if(Vr(mn,M),(v.mode&1)===0)v.memoizedState=null;else switch(H){case"forwards":for(A=v.child,H=null;A!==null;)p=A.alternate,p!==null&&dd(p)===null&&(H=A),A=A.sibling;A=H,A===null?(H=v.child,v.child=null):(H=A.sibling,A.sibling=null),Sh(v,!1,H,A,ee);break;case"backwards":for(A=null,H=v.child,v.child=null;H!==null;){if(p=H.alternate,p!==null&&dd(p)===null){v.child=H;break}p=H.sibling,H.sibling=A,A=H,H=p}Sh(v,!0,A,null,ee);break;case"together":Sh(v,!1,null,null,void 0);break;default:v.memoizedState=null}return v.child}function vd(p,v){(v.mode&1)===0&&p!==null&&(p.alternate=null,v.alternate=null,v.flags|=2)}function Ma(p,v,A){if(p!==null&&(v.dependencies=p.dependencies),nl|=v.lanes,(A&v.childLanes)===0)return null;if(p!==null&&v.child!==p.child)throw Error(n(153));if(v.child!==null){for(p=v.child,A=_o(p,p.pendingProps),v.child=A,A.return=v;p.sibling!==null;)p=p.sibling,A=A.sibling=_o(p,p.pendingProps),A.return=v;A.sibling=null}return v.child}function W_(p,v,A){switch(v.tag){case 3:xh(v),Xo();break;case 5:Um(v);break;case 1:zi(v.type)&&rd(v);break;case 4:rh(v,v.stateNode.containerInfo);break;case 10:var M=v.type._context,H=v.memoizedProps.value;Vr(Yo,M._currentValue),M._currentValue=H;break;case 13:if(M=v.memoizedState,M!==null)return M.dehydrated!==null?(Vr(mn,mn.current&1),v.flags|=128,null):(A&v.child.childLanes)!==0?xg(p,v,A):(Vr(mn,mn.current&1),p=Ma(p,v,A),p!==null?p.sibling:null);Vr(mn,mn.current&1);break;case 19:if(M=(A&v.childLanes)!==0,(p.flags&128)!==0){if(M)return kh(p,v,A);v.flags|=128}if(H=v.memoizedState,H!==null&&(H.rendering=null,H.tail=null,H.lastEffect=null),Vr(mn,mn.current),M)break;return null;case 22:case 23:return v.lanes=0,gg(p,v,A)}return Ma(p,v,A)}var Ch,jh,_g,Sg;Ch=function(p,v){for(var A=v.child;A!==null;){if(A.tag===5||A.tag===6)p.appendChild(A.stateNode);else if(A.tag!==4&&A.child!==null){A.child.return=A,A=A.child;continue}if(A===v)break;for(;A.sibling===null;){if(A.return===null||A.return===v)return;A=A.return}A.sibling.return=A.return,A=A.sibling}},jh=function(){},_g=function(p,v,A,M){var H=p.memoizedProps;if(H!==M){p=v.stateNode,Qo(da.current);var ee=null;switch(A){case"input":H=Le(p,H),M=Le(p,M),ee=[];break;case"select":H=K({},H,{value:void 0}),M=K({},M,{value:void 0}),ee=[];break;case"textarea":H=Or(p,H),M=Or(p,M),ee=[];break;default:typeof H.onClick!="function"&&typeof M.onClick=="function"&&(p.onclick=Zu)}Ii(A,M);var ue;A=null;for(Ke in H)if(!M.hasOwnProperty(Ke)&&H.hasOwnProperty(Ke)&&H[Ke]!=null)if(Ke==="style"){var Se=H[Ke];for(ue in Se)Se.hasOwnProperty(ue)&&(A||(A={}),A[ue]="")}else Ke!=="dangerouslySetInnerHTML"&&Ke!=="children"&&Ke!=="suppressContentEditableWarning"&&Ke!=="suppressHydrationWarning"&&Ke!=="autoFocus"&&(s.hasOwnProperty(Ke)?ee||(ee=[]):(ee=ee||[]).push(Ke,null));for(Ke in M){var Ne=M[Ke];if(Se=H!=null?H[Ke]:void 0,M.hasOwnProperty(Ke)&&Ne!==Se&&(Ne!=null||Se!=null))if(Ke==="style")if(Se){for(ue in Se)!Se.hasOwnProperty(ue)||Ne&&Ne.hasOwnProperty(ue)||(A||(A={}),A[ue]="");for(ue in Ne)Ne.hasOwnProperty(ue)&&Se[ue]!==Ne[ue]&&(A||(A={}),A[ue]=Ne[ue])}else A||(ee||(ee=[]),ee.push(Ke,A)),A=Ne;else Ke==="dangerouslySetInnerHTML"?(Ne=Ne?Ne.__html:void 0,Se=Se?Se.__html:void 0,Ne!=null&&Se!==Ne&&(ee=ee||[]).push(Ke,Ne)):Ke==="children"?typeof Ne!="string"&&typeof Ne!="number"||(ee=ee||[]).push(Ke,""+Ne):Ke!=="suppressContentEditableWarning"&&Ke!=="suppressHydrationWarning"&&(s.hasOwnProperty(Ke)?(Ne!=null&&Ke==="onScroll"&&Qr("scroll",p),ee||Se===Ne||(ee=[])):(ee=ee||[]).push(Ke,Ne))}A&&(ee=ee||[]).push("style",A);var Ke=ee;(v.updateQueue=Ke)&&(v.flags|=4)}},Sg=function(p,v,A,M){A!==M&&(v.flags|=4)};function yd(p,v){if(!dn)switch(p.tailMode){case"hidden":v=p.tail;for(var A=null;v!==null;)v.alternate!==null&&(A=v),v=v.sibling;A===null?p.tail=null:A.sibling=null;break;case"collapsed":A=p.tail;for(var M=null;A!==null;)A.alternate!==null&&(M=A),A=A.sibling;M===null?v||p.tail===null?p.tail=null:p.tail.sibling=null:M.sibling=null}}function fi(p){var v=p.alternate!==null&&p.alternate.child===p.child,A=0,M=0;if(v)for(var H=p.child;H!==null;)A|=H.lanes|H.childLanes,M|=H.subtreeFlags&14680064,M|=H.flags&14680064,H.return=p,H=H.sibling;else for(H=p.child;H!==null;)A|=H.lanes|H.childLanes,M|=H.subtreeFlags,M|=H.flags,H.return=p,H=H.sibling;return p.subtreeFlags|=M,p.childLanes=A,v}function Fb(p,v,A){var M=v.pendingProps;switch(Uf(v),v.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return fi(v),null;case 1:return zi(v.type)&&td(),fi(v),null;case 3:return M=v.stateNode,Zo(),Zr(Bi),Zr(ji),sh(),M.pendingContext&&(M.context=M.pendingContext,M.pendingContext=null),(p===null||p.child===null)&&(Gc(v)?v.flags|=4:p===null||p.memoizedState.isDehydrated&&(v.flags&256)===0||(v.flags|=1024,Wi!==null&&(Fh(Wi),Wi=null))),jh(p,v),fi(v),null;case 5:nh(v);var H=Qo(Ul.current);if(A=v.type,p!==null&&v.stateNode!=null)_g(p,v,A,M,H),p.ref!==v.ref&&(v.flags|=512,v.flags|=2097152);else{if(!M){if(v.stateNode===null)throw Error(n(166));return fi(v),null}if(p=Qo(da.current),Gc(v)){M=v.stateNode,A=v.type;var ee=v.memoizedProps;switch(M[la]=v,M[Hc]=ee,p=(v.mode&1)!==0,A){case"dialog":Qr("cancel",M),Qr("close",M);break;case"iframe":case"object":case"embed":Qr("load",M);break;case"video":case"audio":for(H=0;H<Uc.length;H++)Qr(Uc[H],M);break;case"source":Qr("error",M);break;case"img":case"image":case"link":Qr("error",M),Qr("load",M);break;case"details":Qr("toggle",M);break;case"input":Ze(M,ee),Qr("invalid",M);break;case"select":M._wrapperState={wasMultiple:!!ee.multiple},Qr("invalid",M);break;case"textarea":wr(M,ee),Qr("invalid",M)}Ii(A,ee),H=null;for(var ue in ee)if(ee.hasOwnProperty(ue)){var Se=ee[ue];ue==="children"?typeof Se=="string"?M.textContent!==Se&&(ee.suppressHydrationWarning!==!0&&Qu(M.textContent,Se,p),H=["children",Se]):typeof Se=="number"&&M.textContent!==""+Se&&(ee.suppressHydrationWarning!==!0&&Qu(M.textContent,Se,p),H=["children",""+Se]):s.hasOwnProperty(ue)&&Se!=null&&ue==="onScroll"&&Qr("scroll",M)}switch(A){case"input":Ve(M),dr(M,ee,!0);break;case"textarea":Ve(M),Wr(M);break;case"select":case"option":break;default:typeof ee.onClick=="function"&&(M.onclick=Zu)}M=H,v.updateQueue=M,M!==null&&(v.flags|=4)}else{ue=H.nodeType===9?H:H.ownerDocument,p==="http://www.w3.org/1999/xhtml"&&(p=ii(A)),p==="http://www.w3.org/1999/xhtml"?A==="script"?(p=ue.createElement("div"),p.innerHTML="<script><\/script>",p=p.removeChild(p.firstChild)):typeof M.is=="string"?p=ue.createElement(A,{is:M.is}):(p=ue.createElement(A),A==="select"&&(ue=p,M.multiple?ue.multiple=!0:M.size&&(ue.size=M.size))):p=ue.createElementNS(p,A),p[la]=v,p[Hc]=M,Ch(p,v,!1,!1),v.stateNode=p;e:{switch(ue=Cr(A,M),A){case"dialog":Qr("cancel",p),Qr("close",p),H=M;break;case"iframe":case"object":case"embed":Qr("load",p),H=M;break;case"video":case"audio":for(H=0;H<Uc.length;H++)Qr(Uc[H],p);H=M;break;case"source":Qr("error",p),H=M;break;case"img":case"image":case"link":Qr("error",p),Qr("load",p),H=M;break;case"details":Qr("toggle",p),H=M;break;case"input":Ze(p,M),H=Le(p,M),Qr("invalid",p);break;case"option":H=M;break;case"select":p._wrapperState={wasMultiple:!!M.multiple},H=K({},M,{value:void 0}),Qr("invalid",p);break;case"textarea":wr(p,M),H=Or(p,M),Qr("invalid",p);break;default:H=M}Ii(A,H),Se=H;for(ee in Se)if(Se.hasOwnProperty(ee)){var Ne=Se[ee];ee==="style"?yi(p,Ne):ee==="dangerouslySetInnerHTML"?(Ne=Ne?Ne.__html:void 0,Ne!=null&&vt(p,Ne)):ee==="children"?typeof Ne=="string"?(A!=="textarea"||Ne!=="")&&jt(p,Ne):typeof Ne=="number"&&jt(p,""+Ne):ee!=="suppressContentEditableWarning"&&ee!=="suppressHydrationWarning"&&ee!=="autoFocus"&&(s.hasOwnProperty(ee)?Ne!=null&&ee==="onScroll"&&Qr("scroll",p):Ne!=null&&k(p,ee,Ne,ue))}switch(A){case"input":Ve(p),dr(p,M,!1);break;case"textarea":Ve(p),Wr(p);break;case"option":M.value!=null&&p.setAttribute("value",""+se(M.value));break;case"select":p.multiple=!!M.multiple,ee=M.value,ee!=null?cr(p,!!M.multiple,ee,!1):M.defaultValue!=null&&cr(p,!!M.multiple,M.defaultValue,!0);break;default:typeof H.onClick=="function"&&(p.onclick=Zu)}switch(A){case"button":case"input":case"select":case"textarea":M=!!M.autoFocus;break e;case"img":M=!0;break e;default:M=!1}}M&&(v.flags|=4)}v.ref!==null&&(v.flags|=512,v.flags|=2097152)}return fi(v),null;case 6:if(p&&v.stateNode!=null)Sg(p,v,p.memoizedProps,M);else{if(typeof M!="string"&&v.stateNode===null)throw Error(n(166));if(A=Qo(Ul.current),Qo(da.current),Gc(v)){if(M=v.stateNode,A=v.memoizedProps,M[la]=v,(ee=M.nodeValue!==A)&&(p=qi,p!==null))switch(p.tag){case 3:Qu(M.nodeValue,A,(p.mode&1)!==0);break;case 5:p.memoizedProps.suppressHydrationWarning!==!0&&Qu(M.nodeValue,A,(p.mode&1)!==0)}ee&&(v.flags|=4)}else M=(A.nodeType===9?A:A.ownerDocument).createTextNode(M),M[la]=v,v.stateNode=M}return fi(v),null;case 13:if(Zr(mn),M=v.memoizedState,p===null||p.memoizedState!==null&&p.memoizedState.dehydrated!==null){if(dn&&rs!==null&&(v.mode&1)!==0&&(v.flags&128)===0)Bm(),Xo(),v.flags|=98560,ee=!1;else if(ee=Gc(v),M!==null&&M.dehydrated!==null){if(p===null){if(!ee)throw Error(n(318));if(ee=v.memoizedState,ee=ee!==null?ee.dehydrated:null,!ee)throw Error(n(317));ee[la]=v}else Xo(),(v.flags&128)===0&&(v.memoizedState=null),v.flags|=4;fi(v),ee=!1}else Wi!==null&&(Fh(Wi),Wi=null),ee=!0;if(!ee)return v.flags&65536?v:null}return(v.flags&128)!==0?(v.lanes=A,v):(M=M!==null,M!==(p!==null&&p.memoizedState!==null)&&M&&(v.child.flags|=8192,(v.mode&1)!==0&&(p===null||(mn.current&1)!==0?Fn===0&&(Fn=3):Wh())),v.updateQueue!==null&&(v.flags|=4),fi(v),null);case 4:return Zo(),jh(p,v),p===null&&qc(v.stateNode.containerInfo),fi(v),null;case 10:return Zf(v.type._context),fi(v),null;case 17:return zi(v.type)&&td(),fi(v),null;case 19:if(Zr(mn),ee=v.memoizedState,ee===null)return fi(v),null;if(M=(v.flags&128)!==0,ue=ee.rendering,ue===null)if(M)yd(ee,!1);else{if(Fn!==0||p!==null&&(p.flags&128)!==0)for(p=v.child;p!==null;){if(ue=dd(p),ue!==null){for(v.flags|=128,yd(ee,!1),M=ue.updateQueue,M!==null&&(v.updateQueue=M,v.flags|=4),v.subtreeFlags=0,M=A,A=v.child;A!==null;)ee=A,p=M,ee.flags&=14680066,ue=ee.alternate,ue===null?(ee.childLanes=0,ee.lanes=p,ee.child=null,ee.subtreeFlags=0,ee.memoizedProps=null,ee.memoizedState=null,ee.updateQueue=null,ee.dependencies=null,ee.stateNode=null):(ee.childLanes=ue.childLanes,ee.lanes=ue.lanes,ee.child=ue.child,ee.subtreeFlags=0,ee.deletions=null,ee.memoizedProps=ue.memoizedProps,ee.memoizedState=ue.memoizedState,ee.updateQueue=ue.updateQueue,ee.type=ue.type,p=ue.dependencies,ee.dependencies=p===null?null:{lanes:p.lanes,firstContext:p.firstContext}),A=A.sibling;return Vr(mn,mn.current&1|2),v.child}p=p.sibling}ee.tail!==null&&Jr()>Vl&&(v.flags|=128,M=!0,yd(ee,!1),v.lanes=4194304)}else{if(!M)if(p=dd(ue),p!==null){if(v.flags|=128,M=!0,A=p.updateQueue,A!==null&&(v.updateQueue=A,v.flags|=4),yd(ee,!0),ee.tail===null&&ee.tailMode==="hidden"&&!ue.alternate&&!dn)return fi(v),null}else 2*Jr()-ee.renderingStartTime>Vl&&A!==1073741824&&(v.flags|=128,M=!0,yd(ee,!1),v.lanes=4194304);ee.isBackwards?(ue.sibling=v.child,v.child=ue):(A=ee.last,A!==null?A.sibling=ue:v.child=ue,ee.last=ue)}return ee.tail!==null?(v=ee.tail,ee.rendering=v,ee.tail=v.sibling,ee.renderingStartTime=Jr(),v.sibling=null,A=mn.current,Vr(mn,M?A&1|2:A&1),v):(fi(v),null);case 22:case 23:return qh(),M=v.memoizedState!==null,p!==null&&p.memoizedState!==null!==M&&(v.flags|=8192),M&&(v.mode&1)!==0?(ns&1073741824)!==0&&(fi(v),v.subtreeFlags&6&&(v.flags|=8192)):fi(v),null;case 24:return null;case 25:return null}throw Error(n(156,v.tag))}function Ub(p,v){switch(Uf(v),v.tag){case 1:return zi(v.type)&&td(),p=v.flags,p&65536?(v.flags=p&-65537|128,v):null;case 3:return Zo(),Zr(Bi),Zr(ji),sh(),p=v.flags,(p&65536)!==0&&(p&128)===0?(v.flags=p&-65537|128,v):null;case 5:return nh(v),null;case 13:if(Zr(mn),p=v.memoizedState,p!==null&&p.dehydrated!==null){if(v.alternate===null)throw Error(n(340));Xo()}return p=v.flags,p&65536?(v.flags=p&-65537|128,v):null;case 19:return Zr(mn),null;case 4:return Zo(),null;case 10:return Zf(v.type._context),null;case 22:case 23:return qh(),null;case 24:return null;default:return null}}var Eh=!1,hi=!1,qb=typeof WeakSet=="function"?WeakSet:Set,Rt=null;function Wl(p,v){var A=p.ref;if(A!==null)if(typeof A=="function")try{A(null)}catch(M){gn(p,v,M)}else A.current=null}function Th(p,v,A){try{A()}catch(M){gn(p,v,M)}}var kg=!1;function Wb(p,v){if(Rf=lo,p=jf(),Ef(p)){if("selectionStart"in p)var A={start:p.selectionStart,end:p.selectionEnd};else e:{A=(A=p.ownerDocument)&&A.defaultView||window;var M=A.getSelection&&A.getSelection();if(M&&M.rangeCount!==0){A=M.anchorNode;var H=M.anchorOffset,ee=M.focusNode;M=M.focusOffset;try{A.nodeType,ee.nodeType}catch{A=null;break e}var ue=0,Se=-1,Ne=-1,Ke=0,dt=0,ht=p,lt=null;t:for(;;){for(var Ct;ht!==A||H!==0&&ht.nodeType!==3||(Se=ue+H),ht!==ee||M!==0&&ht.nodeType!==3||(Ne=ue+M),ht.nodeType===3&&(ue+=ht.nodeValue.length),(Ct=ht.firstChild)!==null;)lt=ht,ht=Ct;for(;;){if(ht===p)break t;if(lt===A&&++Ke===H&&(Se=ue),lt===ee&&++dt===M&&(Ne=ue),(Ct=ht.nextSibling)!==null)break;ht=lt,lt=ht.parentNode}ht=Ct}A=Se===-1||Ne===-1?null:{start:Se,end:Ne}}else A=null}A=A||{start:0,end:0}}else A=null;for(Mf={focusedElem:p,selectionRange:A},lo=!1,Rt=v;Rt!==null;)if(v=Rt,p=v.child,(v.subtreeFlags&1028)!==0&&p!==null)p.return=v,Rt=p;else for(;Rt!==null;){v=Rt;try{var Mt=v.alternate;if((v.flags&1024)!==0)switch(v.tag){case 0:case 11:case 15:break;case 1:if(Mt!==null){var Dt=Mt.memoizedProps,Gr=Mt.memoizedState,qe=v.stateNode,Ie=qe.getSnapshotBeforeUpdate(v.elementType===v.type?Dt:Nn(v.type,Dt),Gr);qe.__reactInternalSnapshotBeforeUpdate=Ie}break;case 3:var Xe=v.stateNode.containerInfo;Xe.nodeType===1?Xe.textContent="":Xe.nodeType===9&&Xe.documentElement&&Xe.removeChild(Xe.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(yt){gn(v,v.return,yt)}if(p=v.sibling,p!==null){p.return=v.return,Rt=p;break}Rt=v.return}return Mt=kg,kg=!1,Mt}function eu(p,v,A){var M=v.updateQueue;if(M=M!==null?M.lastEffect:null,M!==null){var H=M=M.next;do{if((H.tag&p)===p){var ee=H.destroy;H.destroy=void 0,ee!==void 0&&Th(v,A,ee)}H=H.next}while(H!==M)}}function Ah(p,v){if(v=v.updateQueue,v=v!==null?v.lastEffect:null,v!==null){var A=v=v.next;do{if((A.tag&p)===p){var M=A.create;A.destroy=M()}A=A.next}while(A!==v)}}function $h(p){var v=p.ref;if(v!==null){var A=p.stateNode;switch(p.tag){case 5:p=A;break;default:p=A}typeof v=="function"?v(p):v.current=p}}function Cg(p){var v=p.alternate;v!==null&&(p.alternate=null,Cg(v)),p.child=null,p.deletions=null,p.sibling=null,p.tag===5&&(v=p.stateNode,v!==null&&(delete v[la],delete v[Hc],delete v[Bf],delete v[Pm],delete v[Rm])),p.stateNode=null,p.return=null,p.dependencies=null,p.memoizedProps=null,p.memoizedState=null,p.pendingProps=null,p.stateNode=null,p.updateQueue=null}function jg(p){return p.tag===5||p.tag===3||p.tag===4}function Eg(p){e:for(;;){for(;p.sibling===null;){if(p.return===null||jg(p.return))return null;p=p.return}for(p.sibling.return=p.return,p=p.sibling;p.tag!==5&&p.tag!==6&&p.tag!==18;){if(p.flags&2||p.child===null||p.tag===4)continue e;p.child.return=p,p=p.child}if(!(p.flags&2))return p.stateNode}}function Nh(p,v,A){var M=p.tag;if(M===5||M===6)p=p.stateNode,v?A.nodeType===8?A.parentNode.insertBefore(p,v):A.insertBefore(p,v):(A.nodeType===8?(v=A.parentNode,v.insertBefore(p,A)):(v=A,v.appendChild(p)),A=A._reactRootContainer,A!=null||v.onclick!==null||(v.onclick=Zu));else if(M!==4&&(p=p.child,p!==null))for(Nh(p,v,A),p=p.sibling;p!==null;)Nh(p,v,A),p=p.sibling}function Oh(p,v,A){var M=p.tag;if(M===5||M===6)p=p.stateNode,v?A.insertBefore(p,v):A.appendChild(p);else if(M!==4&&(p=p.child,p!==null))for(Oh(p,v,A),p=p.sibling;p!==null;)Oh(p,v,A),p=p.sibling}var Qn=null,Hs=!1;function vo(p,v,A){for(A=A.child;A!==null;)Hb(p,v,A),A=A.sibling}function Hb(p,v,A){if(lr&&typeof lr.onCommitFiberUnmount=="function")try{lr.onCommitFiberUnmount(_t,A)}catch{}switch(A.tag){case 5:hi||Wl(A,v);case 6:var M=Qn,H=Hs;Qn=null,vo(p,v,A),Qn=M,Hs=H,Qn!==null&&(Hs?(p=Qn,A=A.stateNode,p.nodeType===8?p.parentNode.removeChild(A):p.removeChild(A)):Qn.removeChild(A.stateNode));break;case 18:Qn!==null&&(Hs?(p=Qn,A=A.stateNode,p.nodeType===8?Lf(p.parentNode,A):p.nodeType===1&&Lf(p,A),Ta(p)):Lf(Qn,A.stateNode));break;case 4:M=Qn,H=Hs,Qn=A.stateNode.containerInfo,Hs=!0,vo(p,v,A),Qn=M,Hs=H;break;case 0:case 11:case 14:case 15:if(!hi&&(M=A.updateQueue,M!==null&&(M=M.lastEffect,M!==null))){H=M=M.next;do{var ee=H,ue=ee.destroy;ee=ee.tag,ue!==void 0&&((ee&2)!==0||(ee&4)!==0)&&Th(A,v,ue),H=H.next}while(H!==M)}vo(p,v,A);break;case 1:if(!hi&&(Wl(A,v),M=A.stateNode,typeof M.componentWillUnmount=="function"))try{M.props=A.memoizedProps,M.state=A.memoizedState,M.componentWillUnmount()}catch(Se){gn(A,v,Se)}vo(p,v,A);break;case 21:vo(p,v,A);break;case 22:A.mode&1?(hi=(M=hi)||A.memoizedState!==null,vo(p,v,A),hi=M):vo(p,v,A);break;default:vo(p,v,A)}}function tu(p){var v=p.updateQueue;if(v!==null){p.updateQueue=null;var A=p.stateNode;A===null&&(A=p.stateNode=new qb),v.forEach(function(M){var H=Qb.bind(null,p,M);A.has(M)||(A.add(M),M.then(H,H))})}}function ks(p,v){var A=v.deletions;if(A!==null)for(var M=0;M<A.length;M++){var H=A[M];try{var ee=p,ue=v,Se=ue;e:for(;Se!==null;){switch(Se.tag){case 5:Qn=Se.stateNode,Hs=!1;break e;case 3:Qn=Se.stateNode.containerInfo,Hs=!0;break e;case 4:Qn=Se.stateNode.containerInfo,Hs=!0;break e}Se=Se.return}if(Qn===null)throw Error(n(160));Hb(ee,ue,H),Qn=null,Hs=!1;var Ne=H.alternate;Ne!==null&&(Ne.return=null),H.return=null}catch(Ke){gn(H,v,Ke)}}if(v.subtreeFlags&12854)for(v=v.child;v!==null;)Ph(v,p),v=v.sibling}function Ph(p,v){var A=p.alternate,M=p.flags;switch(p.tag){case 0:case 11:case 14:case 15:if(ks(v,p),Vs(p),M&4){try{eu(3,p,p.return),Ah(3,p)}catch(Dt){gn(p,p.return,Dt)}try{eu(5,p,p.return)}catch(Dt){gn(p,p.return,Dt)}}break;case 1:ks(v,p),Vs(p),M&512&&A!==null&&Wl(A,A.return);break;case 5:if(ks(v,p),Vs(p),M&512&&A!==null&&Wl(A,A.return),p.flags&32){var H=p.stateNode;try{jt(H,"")}catch(Dt){gn(p,p.return,Dt)}}if(M&4&&(H=p.stateNode,H!=null)){var ee=p.memoizedProps,ue=A!==null?A.memoizedProps:ee,Se=p.type,Ne=p.updateQueue;if(p.updateQueue=null,Ne!==null)try{Se==="input"&&ee.type==="radio"&&ee.name!=null&&ct(H,ee),Cr(Se,ue);var Ke=Cr(Se,ee);for(ue=0;ue<Ne.length;ue+=2){var dt=Ne[ue],ht=Ne[ue+1];dt==="style"?yi(H,ht):dt==="dangerouslySetInnerHTML"?vt(H,ht):dt==="children"?jt(H,ht):k(H,dt,ht,Ke)}switch(Se){case"input":ut(H,ee);break;case"textarea":sn(H,ee);break;case"select":var lt=H._wrapperState.wasMultiple;H._wrapperState.wasMultiple=!!ee.multiple;var Ct=ee.value;Ct!=null?cr(H,!!ee.multiple,Ct,!1):lt!==!!ee.multiple&&(ee.defaultValue!=null?cr(H,!!ee.multiple,ee.defaultValue,!0):cr(H,!!ee.multiple,ee.multiple?[]:"",!1))}H[Hc]=ee}catch(Dt){gn(p,p.return,Dt)}}break;case 6:if(ks(v,p),Vs(p),M&4){if(p.stateNode===null)throw Error(n(162));H=p.stateNode,ee=p.memoizedProps;try{H.nodeValue=ee}catch(Dt){gn(p,p.return,Dt)}}break;case 3:if(ks(v,p),Vs(p),M&4&&A!==null&&A.memoizedState.isDehydrated)try{Ta(v.containerInfo)}catch(Dt){gn(p,p.return,Dt)}break;case 4:ks(v,p),Vs(p);break;case 13:ks(v,p),Vs(p),H=p.child,H.flags&8192&&(ee=H.memoizedState!==null,H.stateNode.isHidden=ee,!ee||H.alternate!==null&&H.alternate.memoizedState!==null||(Dh=Jr())),M&4&&tu(p);break;case 22:if(dt=A!==null&&A.memoizedState!==null,p.mode&1?(hi=(Ke=hi)||dt,ks(v,p),hi=Ke):ks(v,p),Vs(p),M&8192){if(Ke=p.memoizedState!==null,(p.stateNode.isHidden=Ke)&&!dt&&(p.mode&1)!==0)for(Rt=p,dt=p.child;dt!==null;){for(ht=Rt=dt;Rt!==null;){switch(lt=Rt,Ct=lt.child,lt.tag){case 0:case 11:case 14:case 15:eu(4,lt,lt.return);break;case 1:Wl(lt,lt.return);var Mt=lt.stateNode;if(typeof Mt.componentWillUnmount=="function"){M=lt,A=lt.return;try{v=M,Mt.props=v.memoizedProps,Mt.state=v.memoizedState,Mt.componentWillUnmount()}catch(Dt){gn(M,A,Dt)}}break;case 5:Wl(lt,lt.return);break;case 22:if(lt.memoizedState!==null){Rh(ht);continue}}Ct!==null?(Ct.return=lt,Rt=Ct):Rh(ht)}dt=dt.sibling}e:for(dt=null,ht=p;;){if(ht.tag===5){if(dt===null){dt=ht;try{H=ht.stateNode,Ke?(ee=H.style,typeof ee.setProperty=="function"?ee.setProperty("display","none","important"):ee.display="none"):(Se=ht.stateNode,Ne=ht.memoizedProps.style,ue=Ne!=null&&Ne.hasOwnProperty("display")?Ne.display:null,Se.style.display=Ir("display",ue))}catch(Dt){gn(p,p.return,Dt)}}}else if(ht.tag===6){if(dt===null)try{ht.stateNode.nodeValue=Ke?"":ht.memoizedProps}catch(Dt){gn(p,p.return,Dt)}}else if((ht.tag!==22&&ht.tag!==23||ht.memoizedState===null||ht===p)&&ht.child!==null){ht.child.return=ht,ht=ht.child;continue}if(ht===p)break e;for(;ht.sibling===null;){if(ht.return===null||ht.return===p)break e;dt===ht&&(dt=null),ht=ht.return}dt===ht&&(dt=null),ht.sibling.return=ht.return,ht=ht.sibling}}break;case 19:ks(v,p),Vs(p),M&4&&tu(p);break;case 21:break;default:ks(v,p),Vs(p)}}function Vs(p){var v=p.flags;if(v&2){try{e:{for(var A=p.return;A!==null;){if(jg(A)){var M=A;break e}A=A.return}throw Error(n(160))}switch(M.tag){case 5:var H=M.stateNode;M.flags&32&&(jt(H,""),M.flags&=-33);var ee=Eg(p);Oh(p,ee,H);break;case 3:case 4:var ue=M.stateNode.containerInfo,Se=Eg(p);Nh(p,Se,ue);break;default:throw Error(n(161))}}catch(Ne){gn(p,p.return,Ne)}p.flags&=-3}v&4096&&(p.flags&=-4097)}function Tg(p,v,A){Rt=p,Ag(p)}function Ag(p,v,A){for(var M=(p.mode&1)!==0;Rt!==null;){var H=Rt,ee=H.child;if(H.tag===22&&M){var ue=H.memoizedState!==null||Eh;if(!ue){var Se=H.alternate,Ne=Se!==null&&Se.memoizedState!==null||hi;Se=Eh;var Ke=hi;if(Eh=ue,(hi=Ne)&&!Ke)for(Rt=H;Rt!==null;)ue=Rt,Ne=ue.child,ue.tag===22&&ue.memoizedState!==null?Mh(H):Ne!==null?(Ne.return=ue,Rt=Ne):Mh(H);for(;ee!==null;)Rt=ee,Ag(ee),ee=ee.sibling;Rt=H,Eh=Se,hi=Ke}$g(p)}else(H.subtreeFlags&8772)!==0&&ee!==null?(ee.return=H,Rt=ee):$g(p)}}function $g(p){for(;Rt!==null;){var v=Rt;if((v.flags&8772)!==0){var A=v.alternate;try{if((v.flags&8772)!==0)switch(v.tag){case 0:case 11:case 15:hi||Ah(5,v);break;case 1:var M=v.stateNode;if(v.flags&4&&!hi)if(A===null)M.componentDidMount();else{var H=v.elementType===v.type?A.memoizedProps:Nn(v.type,A.memoizedProps);M.componentDidUpdate(H,A.memoizedState,M.__reactInternalSnapshotBeforeUpdate)}var ee=v.updateQueue;ee!==null&&Ab(v,ee,M);break;case 3:var ue=v.updateQueue;if(ue!==null){if(A=null,v.child!==null)switch(v.child.tag){case 5:A=v.child.stateNode;break;case 1:A=v.child.stateNode}Ab(v,ue,A)}break;case 5:var Se=v.stateNode;if(A===null&&v.flags&4){A=Se;var Ne=v.memoizedProps;switch(v.type){case"button":case"input":case"select":case"textarea":Ne.autoFocus&&A.focus();break;case"img":Ne.src&&(A.src=Ne.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(v.memoizedState===null){var Ke=v.alternate;if(Ke!==null){var dt=Ke.memoizedState;if(dt!==null){var ht=dt.dehydrated;ht!==null&&Ta(ht)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}hi||v.flags&512&&$h(v)}catch(lt){gn(v,v.return,lt)}}if(v===p){Rt=null;break}if(A=v.sibling,A!==null){A.return=v.return,Rt=A;break}Rt=v.return}}function Rh(p){for(;Rt!==null;){var v=Rt;if(v===p){Rt=null;break}var A=v.sibling;if(A!==null){A.return=v.return,Rt=A;break}Rt=v.return}}function Mh(p){for(;Rt!==null;){var v=Rt;try{switch(v.tag){case 0:case 11:case 15:var A=v.return;try{Ah(4,v)}catch(Ne){gn(v,A,Ne)}break;case 1:var M=v.stateNode;if(typeof M.componentDidMount=="function"){var H=v.return;try{M.componentDidMount()}catch(Ne){gn(v,H,Ne)}}var ee=v.return;try{$h(v)}catch(Ne){gn(v,ee,Ne)}break;case 5:var ue=v.return;try{$h(v)}catch(Ne){gn(v,ue,Ne)}}}catch(Ne){gn(v,v.return,Ne)}if(v===p){Rt=null;break}var Se=v.sibling;if(Se!==null){Se.return=v.return,Rt=Se;break}Rt=v.return}}var Vb=Math.ceil,bd=T.ReactCurrentDispatcher,xd=T.ReactCurrentOwner,Cs=T.ReactCurrentBatchConfig,Er=0,On=null,En=null,Zn=0,ns=0,Hl=$a(0),Fn=0,ru=null,nl=0,wd=0,Ih=0,_d=null,Vi=null,Dh=0,Vl=1/0,yo=null,Sd=!1,Lh=null,bo=null,kd=!1,il=null,Cd=0,nu=0,Bh=null,iu=-1,jd=0;function Ai(){return(Er&6)!==0?Jr():iu!==-1?iu:iu=Jr()}function xo(p){return(p.mode&1)===0?1:(Er&2)!==0&&Zn!==0?Zn&-Zn:Xf.transition!==null?(jd===0&&(jd=ra()),jd):(p=gr,p!==0||(p=window.event,p=p===void 0?16:fe(p.type)),p)}function Gs(p,v,A,M){if(50<nu)throw nu=0,Bh=null,Error(n(185));Is(p,A,M),((Er&2)===0||p!==On)&&(p===On&&((Er&2)===0&&(wd|=A),Fn===4&&wo(p,Zn)),Gi(p,M),A===1&&Er===0&&(v.mode&1)===0&&(Vl=Jr()+500,nd&&ho()))}function Gi(p,v){var A=p.callbackNode;ps(p,v);var M=Ms(p,p===On?Zn:0);if(M===0)A!==null&&Dn(A),p.callbackNode=null,p.callbackPriority=0;else if(v=M&-M,p.callbackPriority!==v){if(A!=null&&Dn(A),v===1)p.tag===0?F_(Pg.bind(null,p)):Lm(Pg.bind(null,p)),Cb(function(){(Er&6)===0&&ho()}),A=null;else{switch(Ft(M)){case 1:A=kn;break;case 4:A=bn;break;case 16:A=Et;break;case 536870912:A=it;break;default:A=Et}A=Bg(A,Ng.bind(null,p))}p.callbackPriority=v,p.callbackNode=A}}function Ng(p,v){if(iu=-1,jd=0,(Er&6)!==0)throw Error(n(327));var A=p.callbackNode;if(Gl()&&p.callbackNode!==A)return null;var M=Ms(p,p===On?Zn:0);if(M===0)return null;if((M&30)!==0||(M&p.expiredLanes)!==0||v)v=Ed(p,M);else{v=M;var H=Er;Er|=2;var ee=Gb();(On!==p||Zn!==v)&&(yo=null,Vl=Jr()+500,al(p,v));do try{H_();break}catch(Se){Rg(p,Se)}while(!0);Qf(),bd.current=ee,Er=H,En!==null?v=0:(On=null,Zn=0,v=Fn)}if(v!==0){if(v===2&&(H=Uo(p),H!==0&&(M=H,v=zh(p,H))),v===1)throw A=ru,al(p,0),wo(p,M),Gi(p,Jr()),A;if(v===6)wo(p,M);else{if(H=p.current.alternate,(M&30)===0&&!Og(H)&&(v=Ed(p,M),v===2&&(ee=Uo(p),ee!==0&&(M=ee,v=zh(p,ee))),v===1))throw A=ru,al(p,0),wo(p,M),Gi(p,Jr()),A;switch(p.finishedWork=H,p.finishedLanes=M,v){case 0:case 1:throw Error(n(345));case 2:ol(p,Vi,yo);break;case 3:if(wo(p,M),(M&130023424)===M&&(v=Dh+500-Jr(),10<v)){if(Ms(p,0)!==0)break;if(H=p.suspendedLanes,(H&M)!==M){Ai(),p.pingedLanes|=p.suspendedLanes&H;break}p.timeoutHandle=Df(ol.bind(null,p,Vi,yo),v);break}ol(p,Vi,yo);break;case 4:if(wo(p,M),(M&4194240)===M)break;for(v=p.eventTimes,H=-1;0<M;){var ue=31-fr(M);ee=1<<ue,ue=v[ue],ue>H&&(H=ue),M&=~ee}if(M=H,M=Jr()-M,M=(120>M?120:480>M?480:1080>M?1080:1920>M?1920:3e3>M?3e3:4320>M?4320:1960*Vb(M/1960))-M,10<M){p.timeoutHandle=Df(ol.bind(null,p,Vi,yo),M);break}ol(p,Vi,yo);break;case 5:ol(p,Vi,yo);break;default:throw Error(n(329))}}}return Gi(p,Jr()),p.callbackNode===A?Ng.bind(null,p):null}function zh(p,v){var A=_d;return p.current.memoizedState.isDehydrated&&(al(p,v).flags|=256),p=Ed(p,v),p!==2&&(v=Vi,Vi=A,v!==null&&Fh(v)),p}function Fh(p){Vi===null?Vi=p:Vi.push.apply(Vi,p)}function Og(p){for(var v=p;;){if(v.flags&16384){var A=v.updateQueue;if(A!==null&&(A=A.stores,A!==null))for(var M=0;M<A.length;M++){var H=A[M],ee=H.getSnapshot;H=H.value;try{if(!Us(ee(),H))return!1}catch{return!1}}}if(A=v.child,v.subtreeFlags&16384&&A!==null)A.return=v,v=A;else{if(v===p)break;for(;v.sibling===null;){if(v.return===null||v.return===p)return!0;v=v.return}v.sibling.return=v.return,v=v.sibling}}return!0}function wo(p,v){for(v&=~Ih,v&=~wd,p.suspendedLanes|=v,p.pingedLanes&=~v,p=p.expirationTimes;0<v;){var A=31-fr(v),M=1<<A;p[A]=-1,v&=~M}}function Pg(p){if((Er&6)!==0)throw Error(n(327));Gl();var v=Ms(p,0);if((v&1)===0)return Gi(p,Jr()),null;var A=Ed(p,v);if(p.tag!==0&&A===2){var M=Uo(p);M!==0&&(v=M,A=zh(p,M))}if(A===1)throw A=ru,al(p,0),wo(p,v),Gi(p,Jr()),A;if(A===6)throw Error(n(345));return p.finishedWork=p.current.alternate,p.finishedLanes=v,ol(p,Vi,yo),Gi(p,Jr()),null}function Uh(p,v){var A=Er;Er|=1;try{return p(v)}finally{Er=A,Er===0&&(Vl=Jr()+500,nd&&ho())}}function sl(p){il!==null&&il.tag===0&&(Er&6)===0&&Gl();var v=Er;Er|=1;var A=Cs.transition,M=gr;try{if(Cs.transition=null,gr=1,p)return p()}finally{gr=M,Cs.transition=A,Er=v,(Er&6)===0&&ho()}}function qh(){ns=Hl.current,Zr(Hl)}function al(p,v){p.finishedWork=null,p.finishedLanes=0;var A=p.timeoutHandle;if(A!==-1&&(p.timeoutHandle=-1,kb(A)),En!==null)for(A=En.return;A!==null;){var M=A;switch(Uf(M),M.tag){case 1:M=M.type.childContextTypes,M!=null&&td();break;case 3:Zo(),Zr(Bi),Zr(ji),sh();break;case 5:nh(M);break;case 4:Zo();break;case 13:Zr(mn);break;case 19:Zr(mn);break;case 10:Zf(M.type._context);break;case 22:case 23:qh()}A=A.return}if(On=p,En=p=_o(p.current,null),Zn=ns=v,Fn=0,ru=null,Ih=wd=nl=0,Vi=_d=null,Fl!==null){for(v=0;v<Fl.length;v++)if(A=Fl[v],M=A.interleaved,M!==null){A.interleaved=null;var H=M.next,ee=A.pending;if(ee!==null){var ue=ee.next;ee.next=H,M.next=ue}A.pending=M}Fl=null}return p}function Rg(p,v){do{var A=En;try{if(Qf(),ah.current=md,lh){for(var M=fn.memoizedState;M!==null;){var H=M.queue;H!==null&&(H.pending=null),M=M.next}lh=!1}if(el=0,zn=$n=fn=null,tl=!1,go=0,xd.current=null,A===null||A.return===null){Fn=1,ru=v,En=null;break}e:{var ee=p,ue=A.return,Se=A,Ne=v;if(v=Zn,Se.flags|=32768,Ne!==null&&typeof Ne=="object"&&typeof Ne.then=="function"){var Ke=Ne,dt=Se,ht=dt.tag;if((dt.mode&1)===0&&(ht===0||ht===11||ht===15)){var lt=dt.alternate;lt?(dt.updateQueue=lt.updateQueue,dt.memoizedState=lt.memoizedState,dt.lanes=lt.lanes):(dt.updateQueue=null,dt.memoizedState=null)}var Ct=Lb(ue);if(Ct!==null){Ct.flags&=-257,Ti(Ct,ue,Se,ee,v),Ct.mode&1&&hg(ee,Ke,v),v=Ct,Ne=Ke;var Mt=v.updateQueue;if(Mt===null){var Dt=new Set;Dt.add(Ne),v.updateQueue=Dt}else Mt.add(Ne);break e}else{if((v&1)===0){hg(ee,Ke,v),Wh();break e}Ne=Error(n(426))}}else if(dn&&Se.mode&1){var Gr=Lb(ue);if(Gr!==null){(Gr.flags&65536)===0&&(Gr.flags|=256),Ti(Gr,ue,Se,ee,v),Kf(ql(Ne,Se));break e}}ee=Ne=ql(Ne,Se),Fn!==4&&(Fn=2),_d===null?_d=[ee]:_d.push(ee),ee=ue;do{switch(ee.tag){case 3:ee.flags|=65536,v&=-v,ee.lanes|=v;var qe=dg(ee,Ne,v);Tb(ee,qe);break e;case 1:Se=Ne;var Ie=ee.type,Xe=ee.stateNode;if((ee.flags&128)===0&&(typeof Ie.getDerivedStateFromError=="function"||Xe!==null&&typeof Xe.componentDidCatch=="function"&&(bo===null||!bo.has(Xe)))){ee.flags|=65536,v&=-v,ee.lanes|=v;var yt=fg(ee,Se,v);Tb(ee,yt);break e}}ee=ee.return}while(ee!==null)}su(A)}catch(Wt){v=Wt,En===A&&A!==null&&(En=A=A.return);continue}break}while(!0)}function Gb(){var p=bd.current;return bd.current=md,p===null?md:p}function Wh(){(Fn===0||Fn===3||Fn===2)&&(Fn=4),On===null||(nl&268435455)===0&&(wd&268435455)===0||wo(On,Zn)}function Ed(p,v){var A=Er;Er|=2;var M=Gb();(On!==p||Zn!==v)&&(yo=null,al(p,v));do try{Kb();break}catch(H){Rg(p,H)}while(!0);if(Qf(),Er=A,bd.current=M,En!==null)throw Error(n(261));return On=null,Zn=0,Fn}function Kb(){for(;En!==null;)Mg(En)}function H_(){for(;En!==null&&!Fo();)Mg(En)}function Mg(p){var v=Lg(p.alternate,p,ns);p.memoizedProps=p.pendingProps,v===null?su(p):En=v,xd.current=null}function su(p){var v=p;do{var A=v.alternate;if(p=v.return,(v.flags&32768)===0){if(A=Fb(A,v,ns),A!==null){En=A;return}}else{if(A=Ub(A,v),A!==null){A.flags&=32767,En=A;return}if(p!==null)p.flags|=32768,p.subtreeFlags=0,p.deletions=null;else{Fn=6,En=null;return}}if(v=v.sibling,v!==null){En=v;return}En=v=p}while(v!==null);Fn===0&&(Fn=5)}function ol(p,v,A){var M=gr,H=Cs.transition;try{Cs.transition=null,gr=1,Ig(p,v,A,M)}finally{Cs.transition=H,gr=M}return null}function Ig(p,v,A,M){do Gl();while(il!==null);if((Er&6)!==0)throw Error(n(327));A=p.finishedWork;var H=p.finishedLanes;if(A===null)return null;if(p.finishedWork=null,p.finishedLanes=0,A===p.current)throw Error(n(177));p.callbackNode=null,p.callbackPriority=0;var ee=A.lanes|A.childLanes;if($c(p,ee),p===On&&(En=On=null,Zn=0),(A.subtreeFlags&2064)===0&&(A.flags&2064)===0||kd||(kd=!0,Bg(Et,function(){return Gl(),null})),ee=(A.flags&15990)!==0,(A.subtreeFlags&15990)!==0||ee){ee=Cs.transition,Cs.transition=null;var ue=gr;gr=1;var Se=Er;Er|=4,xd.current=null,Wb(p,A),Ph(A,p),bb(Mf),lo=!!Rf,Mf=Rf=null,p.current=A,Tg(A),Tl(),Er=Se,gr=ue,Cs.transition=ee}else p.current=A;if(kd&&(kd=!1,il=p,Cd=H),ee=p.pendingLanes,ee===0&&(bo=null),mt(A.stateNode),Gi(p,Jr()),v!==null)for(M=p.onRecoverableError,A=0;A<v.length;A++)H=v[A],M(H.value,{componentStack:H.stack,digest:H.digest});if(Sd)throw Sd=!1,p=Lh,Lh=null,p;return(Cd&1)!==0&&p.tag!==0&&Gl(),ee=p.pendingLanes,(ee&1)!==0?p===Bh?nu++:(nu=0,Bh=p):nu=0,ho(),null}function Gl(){if(il!==null){var p=Ft(Cd),v=Cs.transition,A=gr;try{if(Cs.transition=null,gr=16>p?16:p,il===null)var M=!1;else{if(p=il,il=null,Cd=0,(Er&6)!==0)throw Error(n(331));var H=Er;for(Er|=4,Rt=p.current;Rt!==null;){var ee=Rt,ue=ee.child;if((Rt.flags&16)!==0){var Se=ee.deletions;if(Se!==null){for(var Ne=0;Ne<Se.length;Ne++){var Ke=Se[Ne];for(Rt=Ke;Rt!==null;){var dt=Rt;switch(dt.tag){case 0:case 11:case 15:eu(8,dt,ee)}var ht=dt.child;if(ht!==null)ht.return=dt,Rt=ht;else for(;Rt!==null;){dt=Rt;var lt=dt.sibling,Ct=dt.return;if(Cg(dt),dt===Ke){Rt=null;break}if(lt!==null){lt.return=Ct,Rt=lt;break}Rt=Ct}}}var Mt=ee.alternate;if(Mt!==null){var Dt=Mt.child;if(Dt!==null){Mt.child=null;do{var Gr=Dt.sibling;Dt.sibling=null,Dt=Gr}while(Dt!==null)}}Rt=ee}}if((ee.subtreeFlags&2064)!==0&&ue!==null)ue.return=ee,Rt=ue;else e:for(;Rt!==null;){if(ee=Rt,(ee.flags&2048)!==0)switch(ee.tag){case 0:case 11:case 15:eu(9,ee,ee.return)}var qe=ee.sibling;if(qe!==null){qe.return=ee.return,Rt=qe;break e}Rt=ee.return}}var Ie=p.current;for(Rt=Ie;Rt!==null;){ue=Rt;var Xe=ue.child;if((ue.subtreeFlags&2064)!==0&&Xe!==null)Xe.return=ue,Rt=Xe;else e:for(ue=Ie;Rt!==null;){if(Se=Rt,(Se.flags&2048)!==0)try{switch(Se.tag){case 0:case 11:case 15:Ah(9,Se)}}catch(Wt){gn(Se,Se.return,Wt)}if(Se===ue){Rt=null;break e}var yt=Se.sibling;if(yt!==null){yt.return=Se.return,Rt=yt;break e}Rt=Se.return}}if(Er=H,ho(),lr&&typeof lr.onPostCommitFiberRoot=="function")try{lr.onPostCommitFiberRoot(_t,p)}catch{}M=!0}return M}finally{gr=A,Cs.transition=v}}return!1}function Dg(p,v,A){v=ql(A,v),v=dg(p,v,1),p=mo(p,v,1),v=Ai(),p!==null&&(Is(p,1,v),Gi(p,v))}function gn(p,v,A){if(p.tag===3)Dg(p,p,A);else for(;v!==null;){if(v.tag===3){Dg(v,p,A);break}else if(v.tag===1){var M=v.stateNode;if(typeof v.type.getDerivedStateFromError=="function"||typeof M.componentDidCatch=="function"&&(bo===null||!bo.has(M))){p=ql(A,p),p=fg(v,p,1),v=mo(v,p,1),p=Ai(),v!==null&&(Is(v,1,p),Gi(v,p));break}}v=v.return}}function Xb(p,v,A){var M=p.pingCache;M!==null&&M.delete(v),v=Ai(),p.pingedLanes|=p.suspendedLanes&A,On===p&&(Zn&A)===A&&(Fn===4||Fn===3&&(Zn&130023424)===Zn&&500>Jr()-Dh?al(p,0):Ih|=A),Gi(p,v)}function Yb(p,v){v===0&&((p.mode&1)===0?v=1:(v=Rr,Rr<<=1,(Rr&130023424)===0&&(Rr=4194304)));var A=Ai();p=Oa(p,v),p!==null&&(Is(p,v,A),Gi(p,A))}function Jb(p){var v=p.memoizedState,A=0;v!==null&&(A=v.retryLane),Yb(p,A)}function Qb(p,v){var A=0;switch(p.tag){case 13:var M=p.stateNode,H=p.memoizedState;H!==null&&(A=H.retryLane);break;case 19:M=p.stateNode;break;default:throw Error(n(314))}M!==null&&M.delete(v),Yb(p,A)}var Lg;Lg=function(p,v,A){if(p!==null)if(p.memoizedProps!==v.pendingProps||Bi.current)Hi=!0;else{if((p.lanes&A)===0&&(v.flags&128)===0)return Hi=!1,W_(p,v,A);Hi=(p.flags&131072)!==0}else Hi=!1,dn&&(v.flags&1048576)!==0&&Ko(v,sd,v.index);switch(v.lanes=0,v.tag){case 2:var M=v.type;vd(p,v),p=v.pendingProps;var H=Ei(v,ji.current);zl(v,A),H=uh(null,v,M,p,H,A);var ee=dh();return v.flags|=1,typeof H=="object"&&H!==null&&typeof H.render=="function"&&H.$$typeof===void 0?(v.tag=1,v.memoizedState=null,v.updateQueue=null,zi(M)?(ee=!0,rd(v)):ee=!1,v.memoizedState=H.state!==null&&H.state!==void 0?H.state:null,cd(v),H.updater=Ra,v.stateNode=H,H._reactInternals=v,mh(v,M,p,A),v=bh(null,v,M,!0,ee,A)):(v.tag=0,dn&&ee&&An(v),di(null,v,H,A),v=v.child),v;case 16:M=v.elementType;e:{switch(vd(p,v),p=v.pendingProps,H=M._init,M=H(M._payload),v.type=M,H=v.tag=Zb(M),p=Nn(M,p),H){case 0:v=yh(null,v,M,p,A);break e;case 1:v=yg(null,v,M,p,A);break e;case 11:v=pg(null,v,M,p,A);break e;case 14:v=Qc(null,v,M,Nn(M.type,p),A);break e}throw Error(n(306,M,""))}return v;case 0:return M=v.type,H=v.pendingProps,H=v.elementType===M?H:Nn(M,H),yh(p,v,M,H,A);case 1:return M=v.type,H=v.pendingProps,H=v.elementType===M?H:Nn(M,H),yg(p,v,M,H,A);case 3:e:{if(xh(v),p===null)throw Error(n(387));M=v.pendingProps,ee=v.memoizedState,H=ee.element,th(p,v),ud(v,M,null,A);var ue=v.memoizedState;if(M=ue.element,ee.isDehydrated)if(ee={element:M,isDehydrated:!1,cache:ue.cache,pendingSuspenseBoundaries:ue.pendingSuspenseBoundaries,transitions:ue.transitions},v.updateQueue.baseState=ee,v.memoizedState=ee,v.flags&256){H=ql(Error(n(423)),v),v=bg(p,v,M,A,H);break e}else if(M!==H){H=ql(Error(n(424)),v),v=bg(p,v,M,A,H);break e}else for(rs=uo(v.stateNode.containerInfo.firstChild),qi=v,dn=!0,Wi=null,A=Yf(v,null,M,A),v.child=A;A;)A.flags=A.flags&-3|4096,A=A.sibling;else{if(Xo(),M===H){v=Ma(p,v,A);break e}di(p,v,M,A)}v=v.child}return v;case 5:return Um(v),p===null&&Vf(v),M=v.type,H=v.pendingProps,ee=p!==null?p.memoizedProps:null,ue=H.children,If(M,H)?ue=null:ee!==null&&If(M,ee)&&(v.flags|=32),vg(p,v),di(p,v,ue,A),v.child;case 6:return p===null&&Vf(v),null;case 13:return xg(p,v,A);case 4:return rh(v,v.stateNode.containerInfo),M=v.pendingProps,p===null?v.child=Bl(v,null,M,A):di(p,v,M,A),v.child;case 11:return M=v.type,H=v.pendingProps,H=v.elementType===M?H:Nn(M,H),pg(p,v,M,H,A);case 7:return di(p,v,v.pendingProps,A),v.child;case 8:return di(p,v,v.pendingProps.children,A),v.child;case 12:return di(p,v,v.pendingProps.children,A),v.child;case 10:e:{if(M=v.type._context,H=v.pendingProps,ee=v.memoizedProps,ue=H.value,Vr(Yo,M._currentValue),M._currentValue=ue,ee!==null)if(Us(ee.value,ue)){if(ee.children===H.children&&!Bi.current){v=Ma(p,v,A);break e}}else for(ee=v.child,ee!==null&&(ee.return=v);ee!==null;){var Se=ee.dependencies;if(Se!==null){ue=ee.child;for(var Ne=Se.firstContext;Ne!==null;){if(Ne.context===M){if(ee.tag===1){Ne=Pa(-1,A&-A),Ne.tag=2;var Ke=ee.updateQueue;if(Ke!==null){Ke=Ke.shared;var dt=Ke.pending;dt===null?Ne.next=Ne:(Ne.next=dt.next,dt.next=Ne),Ke.pending=Ne}}ee.lanes|=A,Ne=ee.alternate,Ne!==null&&(Ne.lanes|=A),Fm(ee.return,A,v),Se.lanes|=A;break}Ne=Ne.next}}else if(ee.tag===10)ue=ee.type===v.type?null:ee.child;else if(ee.tag===18){if(ue=ee.return,ue===null)throw Error(n(341));ue.lanes|=A,Se=ue.alternate,Se!==null&&(Se.lanes|=A),Fm(ue,A,v),ue=ee.sibling}else ue=ee.child;if(ue!==null)ue.return=ee;else for(ue=ee;ue!==null;){if(ue===v){ue=null;break}if(ee=ue.sibling,ee!==null){ee.return=ue.return,ue=ee;break}ue=ue.return}ee=ue}di(p,v,H.children,A),v=v.child}return v;case 9:return H=v.type,M=v.pendingProps.children,zl(v,A),H=_s(H),M=M(H),v.flags|=1,di(p,v,M,A),v.child;case 14:return M=v.type,H=Nn(M,v.pendingProps),H=Nn(M.type,H),Qc(p,v,M,H,A);case 15:return mg(p,v,v.type,v.pendingProps,A);case 17:return M=v.type,H=v.pendingProps,H=v.elementType===M?H:Nn(M,H),vd(p,v),v.tag=1,zi(M)?(p=!0,rd(v)):p=!1,zl(v,A),cg(v,M,H),mh(v,M,H,A),bh(null,v,M,!0,p,A);case 19:return kh(p,v,A);case 22:return gg(p,v,A)}throw Error(n(156,v.tag))};function Bg(p,v){return xi(p,v)}function V_(p,v,A,M){this.tag=p,this.key=A,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=v,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=M,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function is(p,v,A,M){return new V_(p,v,A,M)}function Hh(p){return p=p.prototype,!(!p||!p.isReactComponent)}function Zb(p){if(typeof p=="function")return Hh(p)?1:0;if(p!=null){if(p=p.$$typeof,p===q)return 11;if(p===G)return 14}return 2}function _o(p,v){var A=p.alternate;return A===null?(A=is(p.tag,v,p.key,p.mode),A.elementType=p.elementType,A.type=p.type,A.stateNode=p.stateNode,A.alternate=p,p.alternate=A):(A.pendingProps=v,A.type=p.type,A.flags=0,A.subtreeFlags=0,A.deletions=null),A.flags=p.flags&14680064,A.childLanes=p.childLanes,A.lanes=p.lanes,A.child=p.child,A.memoizedProps=p.memoizedProps,A.memoizedState=p.memoizedState,A.updateQueue=p.updateQueue,v=p.dependencies,A.dependencies=v===null?null:{lanes:v.lanes,firstContext:v.firstContext},A.sibling=p.sibling,A.index=p.index,A.ref=p.ref,A}function Td(p,v,A,M,H,ee){var ue=2;if(M=p,typeof p=="function")Hh(p)&&(ue=1);else if(typeof p=="string")ue=5;else e:switch(p){case P:return Kl(A.children,H,ee,v);case N:ue=8,H|=8;break;case I:return p=is(12,A,v,H|2),p.elementType=I,p.lanes=ee,p;case F:return p=is(13,A,v,H),p.elementType=F,p.lanes=ee,p;case z:return p=is(19,A,v,H),p.elementType=z,p.lanes=ee,p;case oe:return Ad(A,H,ee,v);default:if(typeof p=="object"&&p!==null)switch(p.$$typeof){case U:ue=10;break e;case V:ue=9;break e;case q:ue=11;break e;case G:ue=14;break e;case Y:ue=16,M=null;break e}throw Error(n(130,p==null?p:typeof p,""))}return v=is(ue,A,v,H),v.elementType=p,v.type=M,v.lanes=ee,v}function Kl(p,v,A,M){return p=is(7,p,M,v),p.lanes=A,p}function Ad(p,v,A,M){return p=is(22,p,M,v),p.elementType=oe,p.lanes=A,p.stateNode={isHidden:!1},p}function Vh(p,v,A){return p=is(6,p,null,v),p.lanes=A,p}function Gh(p,v,A){return v=is(4,p.children!==null?p.children:[],p.key,v),v.lanes=A,v.stateNode={containerInfo:p.containerInfo,pendingChildren:null,implementation:p.implementation},v}function G_(p,v,A,M,H){this.tag=v,this.containerInfo=p,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Qe(0),this.expirationTimes=Qe(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Qe(0),this.identifierPrefix=M,this.onRecoverableError=H,this.mutableSourceEagerHydrationData=null}function Kh(p,v,A,M,H,ee,ue,Se,Ne){return p=new G_(p,v,A,Se,Ne),v===1?(v=1,ee===!0&&(v|=8)):v=0,ee=is(3,null,null,v),p.current=ee,ee.stateNode=p,ee.memoizedState={element:M,isDehydrated:A,cache:null,transitions:null,pendingSuspenseBoundaries:null},cd(ee),p}function K_(p,v,A){var M=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:$,key:M==null?null:""+M,children:p,containerInfo:v,implementation:A}}function zg(p){if(!p)return fo;p=p._reactInternals;e:{if(Nt(p)!==p||p.tag!==1)throw Error(n(170));var v=p;do{switch(v.tag){case 3:v=v.stateNode.context;break e;case 1:if(zi(v.type)){v=v.stateNode.__reactInternalMemoizedMergedChildContext;break e}}v=v.return}while(v!==null);throw Error(n(171))}if(p.tag===1){var A=p.type;if(zi(A))return Im(p,A,v)}return v}function ex(p,v,A,M,H,ee,ue,Se,Ne){return p=Kh(A,M,!0,p,H,ee,ue,Se,Ne),p.context=zg(null),A=p.current,M=Ai(),H=xo(A),ee=Pa(M,H),ee.callback=v??null,mo(A,ee,H),p.current.lanes=H,Is(p,H,M),Gi(p,M),p}function $d(p,v,A,M){var H=v.current,ee=Ai(),ue=xo(H);return A=zg(A),v.context===null?v.context=A:v.pendingContext=A,v=Pa(ee,ue),v.payload={element:p},M=M===void 0?null:M,M!==null&&(v.callback=M),p=mo(H,v,ue),p!==null&&(Gs(p,H,ue,ee),Kc(p,H,ue)),ue}function Nd(p){if(p=p.current,!p.child)return null;switch(p.child.tag){case 5:return p.child.stateNode;default:return p.child.stateNode}}function Fg(p,v){if(p=p.memoizedState,p!==null&&p.dehydrated!==null){var A=p.retryLane;p.retryLane=A!==0&&A<v?A:v}}function Xh(p,v){Fg(p,v),(p=p.alternate)&&Fg(p,v)}function tx(){return null}var rx=typeof reportError=="function"?reportError:function(p){console.error(p)};function Yh(p){this._internalRoot=p}Xl.prototype.render=Yh.prototype.render=function(p){var v=this._internalRoot;if(v===null)throw Error(n(409));$d(p,v,null,null)},Xl.prototype.unmount=Yh.prototype.unmount=function(){var p=this._internalRoot;if(p!==null){this._internalRoot=null;var v=p.containerInfo;sl(function(){$d(null,p,null,null)}),v[ca]=null}};function Xl(p){this._internalRoot=p}Xl.prototype.unstable_scheduleHydration=function(p){if(p){var v=ro();p={blockedOn:null,target:p,priority:v};for(var A=0;A<Ds.length&&v!==0&&v<Ds[A].priority;A++);Ds.splice(A,0,p),A===0&&Nc(p)}};function Jh(p){return!(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11)}function Od(p){return!(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11&&(p.nodeType!==8||p.nodeValue!==" react-mount-point-unstable "))}function nx(){}function ix(p,v,A,M,H){if(H){if(typeof M=="function"){var ee=M;M=function(){var Ke=Nd(ue);ee.call(Ke)}}var ue=ex(v,M,p,0,null,!1,!1,"",nx);return p._reactRootContainer=ue,p[ca]=ue.current,qc(p.nodeType===8?p.parentNode:p),sl(),ue}for(;H=p.lastChild;)p.removeChild(H);if(typeof M=="function"){var Se=M;M=function(){var Ke=Nd(Ne);Se.call(Ke)}}var Ne=Kh(p,0,!1,null,null,!1,!1,"",nx);return p._reactRootContainer=Ne,p[ca]=Ne.current,qc(p.nodeType===8?p.parentNode:p),sl(function(){$d(v,Ne,A,M)}),Ne}function au(p,v,A,M,H){var ee=A._reactRootContainer;if(ee){var ue=ee;if(typeof H=="function"){var Se=H;H=function(){var Ne=Nd(ue);Se.call(Ne)}}$d(v,ue,p,H)}else ue=ix(A,v,p,H,M);return Nd(ue)}na=function(p){switch(p.tag){case 3:var v=p.stateNode;if(v.current.memoizedState.isDehydrated){var A=hs(v.pendingLanes);A!==0&&(Al(v,A|1),Gi(v,Jr()),(Er&6)===0&&(Vl=Jr()+500,ho()))}break;case 13:sl(function(){var M=Oa(p,1);if(M!==null){var H=Ai();Gs(M,p,1,H)}}),Xh(p,1)}},Ca=function(p){if(p.tag===13){var v=Oa(p,134217728);if(v!==null){var A=Ai();Gs(v,p,134217728,A)}Xh(p,134217728)}},ja=function(p){if(p.tag===13){var v=xo(p),A=Oa(p,v);if(A!==null){var M=Ai();Gs(A,p,v,M)}Xh(p,v)}},ro=function(){return gr},qo=function(p,v){var A=gr;try{return gr=p,v()}finally{gr=A}},Ge=function(p,v,A){switch(v){case"input":if(ut(p,A),v=A.name,A.type==="radio"&&v!=null){for(A=p;A.parentNode;)A=A.parentNode;for(A=A.querySelectorAll("input[name="+JSON.stringify(""+v)+'][type="radio"]'),v=0;v<A.length;v++){var M=A[v];if(M!==p&&M.form===p.form){var H=ed(M);if(!H)throw Error(n(90));Re(M),ut(M,H)}}}break;case"textarea":sn(p,A);break;case"select":v=A.value,v!=null&&cr(p,!!A.multiple,v,!1)}},an=Uh,Di=sl;var Ug={usingClientEntryPoint:!1,Events:[Vc,Rl,ed,Pr,Yr,Uh]},Ks={findFiberByHostInstance:Vo,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},sx={bundleType:Ks.bundleType,version:Ks.version,rendererPackageName:Ks.rendererPackageName,rendererConfig:Ks.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:T.ReactCurrentDispatcher,findHostInstanceByFiber:function(p){return p=ds(p),p===null?null:p.stateNode},findFiberByHostInstance:Ks.findFiberByHostInstance||tx,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var ou=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ou.isDisabled&&ou.supportsFiber)try{_t=ou.inject(sx),lr=ou}catch{}}return Xs.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Ug,Xs.createPortal=function(p,v){var A=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Jh(v))throw Error(n(200));return K_(p,v,null,A)},Xs.createRoot=function(p,v){if(!Jh(p))throw Error(n(299));var A=!1,M="",H=rx;return v!=null&&(v.unstable_strictMode===!0&&(A=!0),v.identifierPrefix!==void 0&&(M=v.identifierPrefix),v.onRecoverableError!==void 0&&(H=v.onRecoverableError)),v=Kh(p,1,!1,null,null,A,!1,M,H),p[ca]=v.current,qc(p.nodeType===8?p.parentNode:p),new Yh(v)},Xs.findDOMNode=function(p){if(p==null)return null;if(p.nodeType===1)return p;var v=p._reactInternals;if(v===void 0)throw typeof p.render=="function"?Error(n(188)):(p=Object.keys(p).join(","),Error(n(268,p)));return p=ds(v),p=p===null?null:p.stateNode,p},Xs.flushSync=function(p){return sl(p)},Xs.hydrate=function(p,v,A){if(!Od(v))throw Error(n(200));return au(null,p,v,!0,A)},Xs.hydrateRoot=function(p,v,A){if(!Jh(p))throw Error(n(405));var M=A!=null&&A.hydratedSources||null,H=!1,ee="",ue=rx;if(A!=null&&(A.unstable_strictMode===!0&&(H=!0),A.identifierPrefix!==void 0&&(ee=A.identifierPrefix),A.onRecoverableError!==void 0&&(ue=A.onRecoverableError)),v=ex(v,null,p,1,A??null,H,!1,ee,ue),p[ca]=v.current,qc(p),M)for(p=0;p<M.length;p++)A=M[p],H=A._getVersion,H=H(A._source),v.mutableSourceEagerHydrationData==null?v.mutableSourceEagerHydrationData=[A,H]:v.mutableSourceEagerHydrationData.push(A,H);return new Xl(v)},Xs.render=function(p,v,A){if(!Od(v))throw Error(n(200));return au(null,p,v,!1,A)},Xs.unmountComponentAtNode=function(p){if(!Od(p))throw Error(n(40));return p._reactRootContainer?(sl(function(){au(null,null,p,!1,function(){p._reactRootContainer=null,p[ca]=null})}),!0):!1},Xs.unstable_batchedUpdates=Uh,Xs.unstable_renderSubtreeIntoContainer=function(p,v,A,M){if(!Od(A))throw Error(n(200));if(p==null||p._reactInternals===void 0)throw Error(n(38));return au(p,v,A,!1,M)},Xs.version="18.3.1-next-f1338f8080-20240426",Xs}var d$;function w5(){if(d$)return Z_.exports;d$=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(r){console.error(r)}}return e(),Z_.exports=W8(),Z_.exports}var f$;function H8(){if(f$)return lx;f$=1;var e=w5();return lx.createRoot=e.createRoot,lx.hydrateRoot=e.hydrateRoot,lx}var V8=H8();const G8=nn(V8);var D=hT();const Fe=nn(D),h$=e=>{let r;const n=new Set,i=(f,m)=>{const h=typeof f=="function"?f(r):f;if(!Object.is(h,r)){const y=r;r=m??(typeof h!="object"||h===null)?h:Object.assign({},r,h),n.forEach(x=>x(r,y))}},s=()=>r,o={setState:i,getState:s,getInitialState:()=>u,subscribe:f=>(n.add(f),()=>n.delete(f))},u=r=e(i,s,o);return o},K8=(e=>e?h$(e):h$),X8=e=>e;function Y8(e,r=X8){const n=Fe.useSyncExternalStore(e.subscribe,Fe.useCallback(()=>r(e.getState()),[e,r]),Fe.useCallback(()=>r(e.getInitialState()),[e,r]));return Fe.useDebugValue(n),n}const p$=e=>{const r=K8(e),n=i=>Y8(r,i);return Object.assign(n,r),n},Gn=(e=>e?p$(e):p$);function Io(e){return"'"+e.replace(/'/g,"'\\''")+"'"}const r1=({sessionId:e})=>`claude --dangerously-skip-permissions --session-id ${Io(e)}`,m$=({sessionId:e})=>`claude --session-id ${Io(e)}`,J8=()=>"claude --resume",_5=[{id:"sm-dangerous",label:"Session Manager (skip perms)",description:"claude --dangerously-skip-permissions in this project",category:"build",cwd:"app-cwd",command:r1},{id:"sm-safe",label:"Session Manager (safe)",description:"claude with normal permission prompts in this project",category:"build",cwd:"app-cwd",command:m$},{id:"home-dangerous",label:"Home (skip perms)",description:"claude --dangerously-skip-permissions in ~",category:"build",cwd:"home",command:r1},{id:"pick-dangerous",label:"Pick directory (skip perms)…",description:"Choose a folder, launch claude --dangerously-skip-permissions",category:"build",cwd:"pick",command:r1},{id:"pick-safe",label:"Pick directory (safe)…",description:"Choose a folder, launch claude with normal prompts",category:"build",cwd:"pick",command:m$},{id:"pick-resume",label:"Pick directory + resume…",description:"Choose a folder, then pick a past session to resume",category:"build",cwd:"pick",command:J8},{id:"pick-shell",label:"Pick directory (shell only)…",description:"Bare interactive shell, no claude auto-launch",category:"build",cwd:"pick",command:null}];let Da=null;async function Q8(){if(Da)return Da;try{const e=await window.api.app.engageRulesPath();if(!e)return Da=[],Da;const r=await window.api.config.readJson(e);if(!r.exists||r.parseError||!r.data)return Da=[],Da;const n=r.data;if(!n.presets||!Array.isArray(n.presets))return Da=[],Da;const i=n.projectPath;return Da=n.presets.map(s=>({id:s.id,label:s.label,description:s.description,category:"engage",cwd:i,platform:s.platform,pipeline:s.pipeline,rules:s.rules,command:()=>`cd ${Io(i)} && ${s.cliEntry}`})),Da}catch(e){return console.warn("[presets] Failed to load engage presets:",e),Da=[],Da}}async function S5(e){const r=_5.find(i=>i.id===e);return r||((await Q8()).find(i=>i.id===e)??null)}async function Z8(e){return e.cwd==="app-cwd"?window.api.app.cwd():e.cwd==="home"?window.api.app.homeDir():e.cwd==="pick"?window.api.app.pickDirectory():e.cwd}function k5(e,r){return e.command?e.command(r):null}function eU(e){const r=e.split("/").filter(Boolean);return r[r.length-1]||e}const Jt=Gn((e,r)=>({tabs:[],activeTabId:null,hydrated:!1,addTab:({id:n,cwd:i,startupCommand:s,presetId:a=null,label:l})=>{const o=n??crypto.randomUUID();if(r().tabs.find(m=>m.id===o))return e({activeTabId:o}),o;const f={id:o,claudeSessionId:o,label:l??eU(i),cwd:i,pid:null,status:"spawning",exitCode:null,startupCommand:s,presetId:a,generation:0};return e({tabs:[...r().tabs,f],activeTabId:o}),o},setTabRunning:(n,i)=>e({tabs:r().tabs.map(s=>s.id===n?{...s,pid:i,status:"running"}:s)}),setTabExited:(n,i)=>e({tabs:r().tabs.map(s=>s.id===n?{...s,status:"exited",exitCode:i}:s)}),closeTab:n=>{var a;window.api.pty.kill(n),window.api.watchers.killTab(n).catch(()=>{}),window.api.transcripts.closeTab(n).catch(()=>{});const i=r().tabs.filter(l=>l.id!==n),s=r().activeTabId===n?((a=i[i.length-1])==null?void 0:a.id)??null:r().activeTabId;e({tabs:i,activeTabId:s})},setActive:n=>e({activeTabId:n}),restartTab:n=>{const i=r().tabs.find(l=>l.id===n);if(!i)return;window.api.pty.kill(n);const s=crypto.randomUUID(),a=l=>{e({tabs:r().tabs.map(o=>o.id===n?{...o,claudeSessionId:s,pid:null,status:"spawning",exitCode:null,startupCommand:l,generation:o.generation+1}:o)})};i.presetId?S5(i.presetId).then(l=>{a(l?k5(l,{sessionId:s,cwd:i.cwd}):`claude --dangerously-skip-permissions --session-id ${Io(s)}`)}):a(`claude --dangerously-skip-permissions --session-id ${Io(s)}`)},reorderTab:(n,i)=>{const s=[...r().tabs];if(n<0||n>=s.length||i<0||i>=s.length||n===i)return;const[a]=s.splice(n,1);s.splice(i,0,a),e({tabs:s})},restoreTabs:(n,i)=>e({tabs:n,activeTabId:i,hydrated:!0})}));async function C5(){var n;if(Jt.getState().hydrated)return;try{const{tabs:i,activeTabId:s,freshStart:a}=await window.api.sessions.load();if(i.length>0){const l=await Promise.all(i.map(async u=>{let f=!a;if(f){const h=await window.api.transcripts.pathFor(u.cwd,u.claudeSessionId);f=await window.api.config.exists(h)}const m=f?u.claudeSessionId:crypto.randomUUID();return{id:u.id,claudeSessionId:m,cwd:u.cwd,label:u.label,presetId:u.presetId,pid:null,status:"spawning",exitCode:null,startupCommand:f?`claude --dangerously-skip-permissions --resume ${Io(m)}`:`claude --dangerously-skip-permissions --session-id ${Io(m)}`,generation:0}})),o=s&&l.find(u=>u.id===s)?s:((n=l[0])==null?void 0:n.id)??null;Jt.getState().restoreTabs(l,o)}else Jt.setState({hydrated:!0})}catch(i){console.warn("[sessions] hydrate failed:",i),Jt.setState({hydrated:!0})}const e=()=>{const{tabs:i,activeTabId:s}=Jt.getState(),a=i.map(l=>({id:l.id,claudeSessionId:l.claudeSessionId,cwd:l.cwd,label:l.label,presetId:l.presetId}));window.api.sessions.save({tabs:a,activeTabId:s}).catch(l=>{console.warn("[sessions] save failed:",l)})};let r=null;Jt.subscribe((i,s)=>{i.hydrated&&(i.tabs===s.tabs&&i.activeTabId===s.activeTabId||(r!==null&&window.clearTimeout(r),r=window.setTimeout(e,200)))}),e()}const tU=Object.freeze(Object.defineProperty({__proto__:null,hydrateSessions:C5,useSessions:Jt},Symbol.toStringTag,{value:"Module"})),rU=5,g$=100,nU=5e3,tj=new Map;function v$(e){const r=tj.get(e);r!==void 0&&(clearTimeout(r),tj.delete(e))}function iU(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`t-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}const vp=Gn((e,r)=>({toasts:[],history:[],unreadCount:0,show:(n,i)=>{const s=iU(),a=Date.now();e(o=>{const u=[...o.toasts,{id:s,kind:n,message:i,createdAt:a}];for(;u.length>rU;){const h=u.shift();h&&v$(h.id)}const m=[{id:s,kind:n,message:i,createdAt:a,read:!1},...o.history];return m.length>g$&&(m.length=g$),{toasts:u,history:m,unreadCount:o.unreadCount+1}});const l=setTimeout(()=>r().dismiss(s),nU);return tj.set(s,l),s},dismiss:n=>{v$(n),e(i=>({toasts:i.toasts.filter(s=>s.id!==n)}))},markAllRead:()=>{e(n=>n.unreadCount===0?n:{history:n.history.map(i=>i.read?i:{...i,read:!0}),unreadCount:0})},clearHistory:()=>{e({history:[],unreadCount:0})},dismissHistoryEntry:n=>{e(i=>{const s=i.history.filter(l=>l.id!==n);if(s.length===i.history.length)return i;const a=i.history.find(l=>l.id===n&&!l.read);return{history:s,unreadCount:a?Math.max(0,i.unreadCount-1):i.unreadCount}})}})),ft={info:e=>vp.getState().show("info",e),warn:e=>vp.getState().show("warn",e),error:e=>vp.getState().show("error",e)},j5=Object.freeze(Object.defineProperty({__proto__:null,toast:ft,useToast:vp},Symbol.toStringTag,{value:"Module"})),y$=200,sU=/\x1b\[[0-9;]*m/g;function aU(e){return e.replace(sU,"")}const zv=Gn((e,r)=>({watchers:{},initialized:!1,init:()=>{r().initialized||(e({initialized:!0}),window.api.watchers.onLine(n=>r().ingestLine(n)),window.api.watchers.onClosed(({watcherId:n})=>r().closed(n)))},add:async({tabId:n,label:i,command:s,cwd:a})=>{try{const l=await window.api.watchers.add({tabId:n,label:i,command:s,cwd:a??null}),o={watcherId:l.watcherId,tabId:l.tabId,label:l.label,command:l.command,cwd:l.cwd,pid:l.pid,startedAt:l.startedAt,lineCount:0,lines:[],lastLineAt:null};return e({watchers:{...r().watchers,[o.watcherId]:o}}),o}catch(l){return console.error("[watchers] add failed:",l),ft.error("Failed to add watcher"),null}},remove:async n=>{try{await window.api.watchers.remove(n)}catch(s){console.error("[watchers] remove failed:",s);const a=s instanceof Error?s.message:String(s);ft.error(`Could not remove watcher: ${a}`)}const i={...r().watchers};delete i[n],e({watchers:i})},watchersForTab:n=>Object.values(r().watchers).filter(i=>i.tabId===n),ingestLine:n=>{const i=r().watchers[n.watcherId];if(!i)return;const s=aU(n.line),a=i.lines.length>=y$?[...i.lines.slice(i.lines.length-y$+1),{line:s,ts:n.ts}]:[...i.lines,{line:s,ts:n.ts}];e({watchers:{...r().watchers,[n.watcherId]:{...i,lines:a,lineCount:i.lineCount+1,lastLineAt:n.ts}}})},closed:n=>{if(!r().watchers[n])return;const i={...r().watchers};delete i[n],e({watchers:i})}})),oU=4,b$=40,x$=6;function lU(e){const{onReorder:r,onActivate:n}=e,i=D.useRef(null),s=D.useRef(null),a=D.useRef(0),l=D.useRef(0),[o,u]=D.useState(!1),[,f]=D.useState(0),m=D.useRef(n);m.current=n;const h=D.useCallback(()=>i.current?Array.from(i.current.querySelectorAll("[data-drag-index]")):[],[]),y=D.useCallback((b,w,S)=>{for(let k=0;k<w.length;k++){const T=w[k].left+w[k].width/2;if(b<T)return k<=S?k:k-1}return w.length-1},[]),x=D.useCallback(()=>{const b=s.current,w=i.current;if(!(b!=null&&b.active)||!w)return;const S=w.getBoundingClientRect(),k=b.startX+b.deltaX,T=k-S.left,j=S.right-k;T<b$?w.scrollLeft-=x$:j<b$&&(w.scrollLeft+=x$),a.current=requestAnimationFrame(x)},[]);D.useEffect(()=>{const b=i.current;if(!b)return;let w=!1;const S=()=>{w||(w=!0,l.current=requestAnimationFrame(()=>{w=!1,f(j=>j+1)}))},k=j=>{var U;const $=s.current;if(!$)return;const P=j.clientX-$.startX;if(!$.active&&Math.abs(P)<oU)return;if(!$.active){$.active=!0,$.tabRects=h().map(V=>V.getBoundingClientRect()),u(!0);try{(U=i.current)==null||U.setPointerCapture($.pointerId)}catch{}a.current=requestAnimationFrame(x)}$.deltaX=P;const N=$.tabRects[$.fromIndex],I=N.left+N.width/2+P;$.currentIndex=y(I,$.tabRects,$.fromIndex),S()},T=j=>{const $=s.current;if($&&$.pointerId===j.pointerId){cancelAnimationFrame(a.current),cancelAnimationFrame(l.current);try{b.releasePointerCapture($.pointerId)}catch{}$.active&&$.fromIndex!==$.currentIndex?r($.fromIndex,$.currentIndex):m.current($.fromIndex),s.current=null,u(!1),f(P=>P+1)}};return b.addEventListener("pointermove",k),b.addEventListener("pointerup",T),b.addEventListener("pointercancel",T),()=>{b.removeEventListener("pointermove",k),b.removeEventListener("pointerup",T),b.removeEventListener("pointercancel",T),cancelAnimationFrame(a.current),cancelAnimationFrame(l.current)}},[r,h,y,x]);const C=D.useCallback((b,w)=>{b.button!==0||b.target.closest("button")||(s.current={active:!1,fromIndex:w,currentIndex:w,startX:b.clientX,deltaX:0,tabRects:[],pointerId:b.pointerId})},[]);return{getTabDragProps:D.useCallback(b=>{var k;const w=s.current,S={};if(w!=null&&w.active)if(b===w.fromIndex)S.transform=`translateX(${w.deltaX}px) scale(1.03)`,S.zIndex=10,S.opacity=.85,S.boxShadow="0 2px 8px rgba(0,0,0,0.4)",S.position="relative",S.pointerEvents="none";else{const T=w.fromIndex,j=w.currentIndex,P=(((k=w.tabRects[T])==null?void 0:k.width)??0)+4;S.transition="transform 0.15s ease",T<j&&b>T&&b<=j?S.transform=`translateX(-${P}px)`:T>j&&b>=j&&b<T?S.transform=`translateX(${P}px)`:S.transform="translateX(0)"}return{onPointerDown:T=>C(T,b),style:S,"data-drag-index":b}},[C]),isDragging:o,containerRef:i}}const cU=3e4;function uU(){const e=Jt(x=>x.tabs),r=Jt(x=>x.activeTabId),n=Jt(x=>x.closeTab),i=Jt(x=>x.setActive),s=Jt(x=>x.reorderTab),a=zv(x=>x.watchers),[l,o]=D.useState(()=>Date.now());D.useEffect(()=>{const x=window.setInterval(()=>o(Date.now()),1e3);return()=>window.clearInterval(x)},[]);const u=x=>{for(const C of Object.values(a))if(C.tabId===x&&C.lastLineAt&&l-C.lastLineAt<cU)return!0;return!1},{getTabDragProps:f,isDragging:m,containerRef:h}=lU({tabCount:e.length,onReorder:s,onActivate:x=>{const C=e[x];C&&i(C.id)}}),y=["#6f7d52","#b85c34","#a39079","#7a8466","#5b4a36"];return c.jsxs("div",{className:"h-11 bg-bg-elev border-b border-line flex items-end px-3 gap-0 shrink-0 relative","data-testid":"tour-tabbar",children:[c.jsx("div",{ref:h,className:`flex items-end gap-0.5 overflow-x-auto min-w-0 flex-1 select-none ${m?"cursor-grabbing":""}`,children:e.map((x,C)=>{const _=x.id===r,b=f(C),w=y[C%y.length];return c.jsxs("div",{...b,style:b.style,className:`group flex items-center gap-2 px-3.5 pt-1.5 pb-2 rounded-t-[10px] text-[13px] shrink-0 transition-colors ${m?"":"cursor-grab"} ${_?"bg-bg text-fg font-medium relative z-10 -mb-px border border-b-0 border-line":"text-fg-dim hover:text-fg hover:bg-bg-hi/40"}`,title:x.cwd,"aria-current":_?"true":void 0,children:[c.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:w,boxShadow:"inset 0 0 0 0.5px rgba(0,0,0,0.15)",opacity:x.status==="spawning"?.55:1}}),c.jsx("span",{className:"truncate max-w-[200px]",children:x.label}),x.status==="spawning"&&c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-butter animate-pulse",title:"spawning"}),u(x.id)&&c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent animate-pulse",title:"watcher emitted a line in the last 30s","data-testid":"tab-watcher-dot"}),c.jsx("button",{onClick:S=>{S.stopPropagation(),n(x.id)},className:"text-fg-faint opacity-0 group-hover:opacity-100 hover:text-fg ml-1 leading-none",title:"Close session","aria-label":`Close ${x.label}`,children:"×"})]},x.id)})}),c.jsxs("div",{className:"flex items-center gap-2 pb-2 pl-3 text-[12px] text-fg-faint shrink-0",children:[c.jsx("span",{className:"font-semibold text-fg-dim",children:"Claude Session Manager"}),c.jsxs("span",{className:"font-mono text-[11px] text-fg-faint",children:["v","0.21.3"]})]})]})}function dU(e,r,n){return r?e.map(i=>i.id===r?{...i,lastActivityAt:n}:i):e}function fU(e,r,n){return{tabId:e,sessionUuid:n,cwd:r,path:null,todos:[],lastToolUses:[],plans:[],agents:[],usage:{inputTokens:0,outputTokens:0},lastEventAt:0,activityRing:[],activitySeq:0}}const s0=Gn((e,r)=>({tabs:{},refs:{},unsubs:{},subscribe:(n,i,s)=>{const a={...r().refs};if(a[n]=(a[n]??0)+1,e({refs:a}),a[n]>1)return;e({tabs:{...r().tabs,[n]:fU(n,i,s)}});const l=window.api.transcripts.onEvent(n,o=>r().ingest(n,o));e({unsubs:{...r().unsubs,[n]:l}}),window.api.transcripts.subscribe({tabId:n,cwd:i,sessionUuid:s}).then(async o=>{const u=r().tabs[n];if(!u)return;if(!o.ok){const{toast:m}=await rm(async()=>{const{toast:h}=await Promise.resolve().then(()=>j5);return{toast:h}},void 0,import.meta.url);m.error(`Live view unavailable: ${o.error??"subscribe failed"}`),e({tabs:{...r().tabs,[n]:{...u,path:null}}});return}e({tabs:{...r().tabs,[n]:{...u,path:o.path}}});const f=await window.api.transcripts.buffer(n);for(const m of f)r().ingest(n,m,{replay:!0})}).catch(o=>console.error("[live] transcripts.subscribe failed:",n,o))},unsubscribe:n=>{const i={...r().refs};if(!i[n])return;if(i[n]--,i[n]>0){e({refs:i});return}delete i[n];const s=r().unsubs[n];s==null||s();const a={...r().unsubs};delete a[n];const l={...r().tabs};delete l[n],window.api.transcripts.unsubscribe(n),e({refs:i,unsubs:a,tabs:l})},ingest:(n,i,s)=>{const a=r().tabs[n];if(!a)return;const l=Date.now(),o={...a,lastEventAt:s!=null&&s.replay?a.lastEventAt:l},u=[],f=(m,h)=>m.length>h?m.slice(0,h-1)+"…":m;switch(i.kind){case"todo_write":{const m=Array.isArray(i.data)?i.data:[];o.todos=m,s!=null&&s.replay||u.push({id:0,kind:"todo-update",at:l,label:`Todos · ${m.length} item${m.length!==1?"s":""}`});break}case"tool_use":{const m=i.data,h=m.input,y={};for(const x of["command","file_path","pattern","url","query","subagent_type","description"])h&&x in h&&(y[x]=h[x]);if(o.lastToolUses=[{id:m.id,name:m.name,input:y,at:l},...a.lastToolUses].slice(0,50),!(s!=null&&s.replay)){const x=m.input,C=["Edit","Write","NotebookEdit"].includes(m.name),_=typeof(x==null?void 0:x.file_path)=="string"?x.file_path:void 0,b=typeof(x==null?void 0:x.command)=="string"?x.command:void 0,w=_?_.split("/").pop()??_:b?f(b,28):"";u.push({id:0,kind:"tool-use",at:l,label:w?`${m.name} · ${w}`:m.name,target:_??b,toolName:m.name}),C&&_&&u.push({id:0,kind:"file-edit",at:l,label:`${m.name} · ${f(_.split("/").pop()??_,34)}`,target:_,toolName:m.name})}break}case"plan":{const m=i.data,h=typeof m=="string"?m:(m==null?void 0:m.plan)??JSON.stringify(m);o.plans=[{at:l,content:h??""},...a.plans].slice(0,50),s!=null&&s.replay||u.push({id:0,kind:"plan-revision",at:l,label:"Plan revised"});break}case"agent_spawn":{const m=i.data;o.agents=[{id:m==null?void 0:m.toolUseId,at:l,subagentType:m==null?void 0:m.subagent_type,description:m==null?void 0:m.description,lastActivityAt:l},...a.agents].slice(0,50),s!=null&&s.replay||u.push({id:0,kind:"agent-spawn",at:l,label:m!=null&&m.subagent_type?`Agent: ${f(m.subagent_type,32)}`:"Agent spawned"});break}case"usage":{const m=i.data,h=(a.usage.inputTokens||0)+(a.usage.outputTokens||0),y=m.input_tokens??m.inputTokens??0,x=m.output_tokens??m.outputTokens??0,C=h+y+x;o.usage={inputTokens:(a.usage.inputTokens||0)+y,outputTokens:(a.usage.outputTokens||0)+x,cacheCreationInputTokens:(a.usage.cacheCreationInputTokens||0)+(m.cache_creation_input_tokens??m.cacheCreationInputTokens??0),cacheReadInputTokens:(a.usage.cacheReadInputTokens||0)+(m.cache_read_input_tokens??m.cacheReadInputTokens??0)},!(s!=null&&s.replay)&&Math.floor(C/1e3)>Math.floor(h/1e3)&&u.push({id:0,kind:"usage-tick",at:l,label:`${Math.floor(C/1e3)}k tokens`});break}case"tool_result":{const m=i.data;o.agents=dU(a.agents,m==null?void 0:m.toolUseId,l);break}}if(u.length>0){let m=a.activitySeq;const h=u.map(y=>({...y,id:++m}));o.activitySeq=m,o.activityRing=[...a.activityRing,...h].slice(-32)}e({tabs:{...r().tabs,[n]:o}})}}));function Uy(e){const r=s0(s=>s.subscribe),n=s0(s=>s.unsubscribe),i=s0(s=>e?s.tabs[e.id]:void 0);return D.useEffect(()=>{if(e)return r(e.id,e.cwd,e.claudeSessionId),()=>n(e.id)},[e==null?void 0:e.id,e==null?void 0:e.cwd,e==null?void 0:e.claudeSessionId,r,n]),i}var n1={},Hg={},w$;function E5(){if(w$)return Hg;w$=1,Object.defineProperty(Hg,"__esModule",{value:!0}),Hg.baseAssetPath=void 0;const r=typeof window<"u"&&typeof window.document<"u"?window.document.currentScript:null;let n="/";return r&&(n=r.src.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^/]+$/,"/")),Hg.baseAssetPath=n,Hg}var Vg={},_$;function pT(){if(_$)return Vg;_$=1,Object.defineProperty(Vg,"__esModule",{value:!0}),Vg.defaultModelFetcher=void 0;const e=r=>fetch(r).then(n=>n.arrayBuffer());return Vg.defaultModelFetcher=e,Vg}var Ql={},Gg={},S$;function qy(){if(S$)return Gg;S$=1,Object.defineProperty(Gg,"__esModule",{value:!0}),Gg.log=void 0;const e=r=>n=>{console.log(`VAD | ${r} >`,n)};return Gg.log={error:e("error"),debug:e("debug"),warn:e("warn")},Gg}var Kg={},k$;function Gw(){if(k$)return Kg;k$=1,Object.defineProperty(Kg,"__esModule",{value:!0}),Kg.Message=void 0;var e;return(function(r){r.AudioFrame="AUDIO_FRAME",r.SpeechStart="SPEECH_START",r.VADMisfire="VAD_MISFIRE",r.SpeechEnd="SPEECH_END",r.SpeechStop="SPEECH_STOP",r.SpeechRealStart="SPEECH_REAL_START",r.FrameProcessed="FRAME_PROCESSED"})(e||(Kg.Message=e={})),Kg}var C$;function mT(){if(C$)return Ql;C$=1,Object.defineProperty(Ql,"__esModule",{value:!0}),Ql.FrameProcessor=Ql.validateOptions=Ql.defaultFrameProcessorOptions=void 0;const e=qy(),r=Gw();Ql.defaultFrameProcessorOptions={positiveSpeechThreshold:.3,negativeSpeechThreshold:.25,preSpeechPadMs:800,redemptionMs:1400,minSpeechMs:400,submitUserSpeechOnPause:!1};function n(l){(l.positiveSpeechThreshold<0||l.positiveSpeechThreshold>1)&&e.log.error("positiveSpeechThreshold should be a number between 0 and 1"),(l.negativeSpeechThreshold<0||l.negativeSpeechThreshold>l.positiveSpeechThreshold)&&e.log.error("negativeSpeechThreshold should be between 0 and positiveSpeechThreshold"),l.preSpeechPadMs<0&&e.log.error("preSpeechPadMs should be positive"),l.redemptionMs<0&&e.log.error("redemptionMs should be positive"),l.minSpeechMs<0&&e.log.error("minSpeechMs should be positive")}Ql.validateOptions=n;const i=l=>{const o=l.reduce((f,m)=>(f.push(f.at(-1)+m.length),f),[0]),u=new Float32Array(o.at(-1));return l.forEach((f,m)=>{const h=o[m];u.set(f,h)}),u};function s(l,o){const u=Math.floor(l.redemptionMs/o),f=Math.floor(l.preSpeechPadMs/o),m=Math.floor(l.minSpeechMs/o);return{redemptionFrames:u,preSpeechPadFrames:f,minSpeechFrames:m}}class a{constructor(o,u,f,m){this.modelProcessFunc=o,this.modelResetFunc=u,this.options=f,this.msPerFrame=m,this.speaking=!1,this.redemptionCounter=0,this.speechFrameCount=0,this.active=!1,this.speechRealStartFired=!1,this.setOptions=C=>{this.options={...this.options,...C};const{redemptionFrames:_,preSpeechPadFrames:b,minSpeechFrames:w}=s(this.options,this.msPerFrame);this.redemptionFrames=_,this.preSpeechPadFrames=b,this.minSpeechFrames=w},this.reset=()=>{this.speaking=!1,this.speechRealStartFired=!1,this.audioBuffer=[],this.modelResetFunc(),this.redemptionCounter=0,this.speechFrameCount=0},this.pause=C=>{this.active=!1,this.options.submitUserSpeechOnPause?this.endSegment(C):this.reset()},this.resume=()=>{this.active=!0},this.endSegment=C=>{const _=this.audioBuffer;this.audioBuffer=[];const b=this.speaking;if(this.reset(),b)if(_.reduce((S,k)=>k.isSpeech?S+1:S,0)>=this.minSpeechFrames){const S=i(_.map(k=>k.frame));C({msg:r.Message.SpeechEnd,audio:S})}else C({msg:r.Message.VADMisfire});return{}},this.process=async(C,_)=>{if(!this.active)return;const b=await this.modelProcessFunc(C),w=b.isSpeech>=this.options.positiveSpeechThreshold;if(_({probs:b,msg:r.Message.FrameProcessed,frame:C}),this.audioBuffer.push({frame:C,isSpeech:w}),w&&(this.speechFrameCount++,this.redemptionCounter=0),w&&!this.speaking&&(this.speaking=!0,_({msg:r.Message.SpeechStart})),this.speaking&&this.speechFrameCount===this.minSpeechFrames&&!this.speechRealStartFired&&(this.speechRealStartFired=!0,_({msg:r.Message.SpeechRealStart})),b.isSpeech<this.options.negativeSpeechThreshold&&this.speaking&&++this.redemptionCounter>=this.redemptionFrames){this.redemptionCounter=0,this.speechFrameCount=0,this.speaking=!1,this.speechRealStartFired=!1;const S=this.audioBuffer;if(this.audioBuffer=[],S.reduce((T,j)=>j.isSpeech?T+1:T,0)>=this.minSpeechFrames){const T=i(S.map(j=>j.frame));_({msg:r.Message.SpeechEnd,audio:T})}else _({msg:r.Message.VADMisfire})}if(!this.speaking){for(;this.audioBuffer.length>this.preSpeechPadFrames;)this.audioBuffer.shift();this.speechFrameCount=0}},this.audioBuffer=[];const{redemptionFrames:h,preSpeechPadFrames:y,minSpeechFrames:x}=s(this.options,this.msPerFrame);this.redemptionFrames=h,this.preSpeechPadFrames=y,this.minSpeechFrames=x,this.reset()}}return Ql.FrameProcessor=a,Ql}var Zl={};function Wa(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var i1={exports:{}};/*!
|
|
41
|
+
`+ee.stack}return{value:p,source:v,stack:H,digest:null}}function gh(p,v,A){return{value:p,source:null,stack:A??null,digest:v??null}}function vh(p,v){try{console.error(v.value)}catch(A){setTimeout(function(){throw A})}}var Db=typeof WeakMap=="function"?WeakMap:Map;function dg(p,v,A){A=Pa(-1,A),A.tag=3,A.payload={element:null};var M=v.value;return A.callback=function(){Sd||(Sd=!0,Lh=M),vh(p,v)},A}function fg(p,v,A){A=Pa(-1,A),A.tag=3;var M=p.type.getDerivedStateFromError;if(typeof M=="function"){var H=v.value;A.payload=function(){return M(H)},A.callback=function(){vh(p,v)}}var ee=p.stateNode;return ee!==null&&typeof ee.componentDidCatch=="function"&&(A.callback=function(){vh(p,v),typeof M!="function"&&(bo===null?bo=new Set([this]):bo.add(this));var ue=v.stack;this.componentDidCatch(v.value,{componentStack:ue!==null?ue:""})}),A}function hg(p,v,A){var M=p.pingCache;if(M===null){M=p.pingCache=new Db;var H=new Set;M.set(v,H)}else H=M.get(v),H===void 0&&(H=new Set,M.set(v,H));H.has(A)||(H.add(A),p=Xb.bind(null,p,v,A),v.then(p,p))}function Lb(p){do{var v;if((v=p.tag===13)&&(v=p.memoizedState,v=v!==null?v.dehydrated!==null:!0),v)return p;p=p.return}while(p!==null);return null}function Ti(p,v,A,M,H){return(p.mode&1)===0?(p===v?p.flags|=65536:(p.flags|=128,A.flags|=131072,A.flags&=-52805,A.tag===1&&(A.alternate===null?A.tag=17:(v=Pa(-1,1),v.tag=2,mo(A,v,1))),A.lanes|=1),p):(p.flags|=65536,p.lanes=H,p)}var Bb=T.ReactCurrentOwner,Hi=!1;function di(p,v,A,M){v.child=p===null?Yf(v,null,A,M):Bl(v,p.child,A,M)}function pg(p,v,A,M,H){A=A.render;var ee=v.ref;return zl(v,H),M=uh(p,v,A,M,ee,H),A=dh(),p!==null&&!Hi?(v.updateQueue=p.updateQueue,v.flags&=-2053,p.lanes&=~H,Ma(p,v,H)):(dn&&A&&An(v),v.flags|=1,di(p,v,M,H),v.child)}function Qc(p,v,A,M,H){if(p===null){var ee=A.type;return typeof ee=="function"&&!Hh(ee)&&ee.defaultProps===void 0&&A.compare===null&&A.defaultProps===void 0?(v.tag=15,v.type=ee,mg(p,v,ee,M,H)):(p=Td(A.type,null,M,v,v.mode,H),p.ref=v.ref,p.return=v,v.child=p)}if(ee=p.child,(p.lanes&H)===0){var ue=ee.memoizedProps;if(A=A.compare,A=A!==null?A:Bc,A(ue,M)&&p.ref===v.ref)return Ma(p,v,H)}return v.flags|=1,p=_o(ee,M),p.ref=v.ref,p.return=v,v.child=p}function mg(p,v,A,M,H){if(p!==null){var ee=p.memoizedProps;if(Bc(ee,M)&&p.ref===v.ref)if(Hi=!1,v.pendingProps=M=ee,(p.lanes&H)!==0)(p.flags&131072)!==0&&(Hi=!0);else return v.lanes=p.lanes,Ma(p,v,H)}return yh(p,v,A,M,H)}function gg(p,v,A){var M=v.pendingProps,H=M.children,ee=p!==null?p.memoizedState:null;if(M.mode==="hidden")if((v.mode&1)===0)v.memoizedState={baseLanes:0,cachePool:null,transitions:null},Vr(Hl,ns),ns|=A;else{if((A&1073741824)===0)return p=ee!==null?ee.baseLanes|A:A,v.lanes=v.childLanes=1073741824,v.memoizedState={baseLanes:p,cachePool:null,transitions:null},v.updateQueue=null,Vr(Hl,ns),ns|=p,null;v.memoizedState={baseLanes:0,cachePool:null,transitions:null},M=ee!==null?ee.baseLanes:A,Vr(Hl,ns),ns|=M}else ee!==null?(M=ee.baseLanes|A,v.memoizedState=null):M=A,Vr(Hl,ns),ns|=M;return di(p,v,H,A),v.child}function vg(p,v){var A=v.ref;(p===null&&A!==null||p!==null&&p.ref!==A)&&(v.flags|=512,v.flags|=2097152)}function yh(p,v,A,M,H){var ee=zi(A)?Go:ji.current;return ee=Ei(v,ee),zl(v,H),A=uh(p,v,A,M,ee,H),M=dh(),p!==null&&!Hi?(v.updateQueue=p.updateQueue,v.flags&=-2053,p.lanes&=~H,Ma(p,v,H)):(dn&&M&&An(v),v.flags|=1,di(p,v,A,H),v.child)}function yg(p,v,A,M,H){if(zi(A)){var ee=!0;rd(v)}else ee=!1;if(zl(v,H),v.stateNode===null)vd(p,v),cg(v,A,M),mh(v,A,M,H),M=!0;else if(p===null){var ue=v.stateNode,Se=v.memoizedProps;ue.props=Se;var Ne=ue.context,Ke=A.contextType;typeof Ke=="object"&&Ke!==null?Ke=_s(Ke):(Ke=zi(A)?Go:ji.current,Ke=Ei(v,Ke));var dt=A.getDerivedStateFromProps,ht=typeof dt=="function"||typeof ue.getSnapshotBeforeUpdate=="function";ht||typeof ue.UNSAFE_componentWillReceiveProps!="function"&&typeof ue.componentWillReceiveProps!="function"||(Se!==M||Ne!==Ke)&&ug(v,ue,M,Ke),ua=!1;var lt=v.memoizedState;ue.state=lt,ud(v,M,ue,H),Ne=v.memoizedState,Se!==M||lt!==Ne||Bi.current||ua?(typeof dt=="function"&&(fa(v,A,dt,M),Ne=v.memoizedState),(Se=ua||rl(v,A,Se,M,lt,Ne,Ke))?(ht||typeof ue.UNSAFE_componentWillMount!="function"&&typeof ue.componentWillMount!="function"||(typeof ue.componentWillMount=="function"&&ue.componentWillMount(),typeof ue.UNSAFE_componentWillMount=="function"&&ue.UNSAFE_componentWillMount()),typeof ue.componentDidMount=="function"&&(v.flags|=4194308)):(typeof ue.componentDidMount=="function"&&(v.flags|=4194308),v.memoizedProps=M,v.memoizedState=Ne),ue.props=M,ue.state=Ne,ue.context=Ke,M=Se):(typeof ue.componentDidMount=="function"&&(v.flags|=4194308),M=!1)}else{ue=v.stateNode,th(p,v),Se=v.memoizedProps,Ke=v.type===v.elementType?Se:Nn(v.type,Se),ue.props=Ke,ht=v.pendingProps,lt=ue.context,Ne=A.contextType,typeof Ne=="object"&&Ne!==null?Ne=_s(Ne):(Ne=zi(A)?Go:ji.current,Ne=Ei(v,Ne));var Ct=A.getDerivedStateFromProps;(dt=typeof Ct=="function"||typeof ue.getSnapshotBeforeUpdate=="function")||typeof ue.UNSAFE_componentWillReceiveProps!="function"&&typeof ue.componentWillReceiveProps!="function"||(Se!==ht||lt!==Ne)&&ug(v,ue,M,Ne),ua=!1,lt=v.memoizedState,ue.state=lt,ud(v,M,ue,H);var Mt=v.memoizedState;Se!==ht||lt!==Mt||Bi.current||ua?(typeof Ct=="function"&&(fa(v,A,Ct,M),Mt=v.memoizedState),(Ke=ua||rl(v,A,Ke,M,lt,Mt,Ne)||!1)?(dt||typeof ue.UNSAFE_componentWillUpdate!="function"&&typeof ue.componentWillUpdate!="function"||(typeof ue.componentWillUpdate=="function"&&ue.componentWillUpdate(M,Mt,Ne),typeof ue.UNSAFE_componentWillUpdate=="function"&&ue.UNSAFE_componentWillUpdate(M,Mt,Ne)),typeof ue.componentDidUpdate=="function"&&(v.flags|=4),typeof ue.getSnapshotBeforeUpdate=="function"&&(v.flags|=1024)):(typeof ue.componentDidUpdate!="function"||Se===p.memoizedProps&<===p.memoizedState||(v.flags|=4),typeof ue.getSnapshotBeforeUpdate!="function"||Se===p.memoizedProps&<===p.memoizedState||(v.flags|=1024),v.memoizedProps=M,v.memoizedState=Mt),ue.props=M,ue.state=Mt,ue.context=Ne,M=Ke):(typeof ue.componentDidUpdate!="function"||Se===p.memoizedProps&<===p.memoizedState||(v.flags|=4),typeof ue.getSnapshotBeforeUpdate!="function"||Se===p.memoizedProps&<===p.memoizedState||(v.flags|=1024),M=!1)}return bh(p,v,A,M,ee,H)}function bh(p,v,A,M,H,ee){vg(p,v);var ue=(v.flags&128)!==0;if(!M&&!ue)return H&&Dm(v,A,!1),Ma(p,v,ee);M=v.stateNode,Bb.current=v;var Se=ue&&typeof A.getDerivedStateFromError!="function"?null:M.render();return v.flags|=1,p!==null&&ue?(v.child=Bl(v,p.child,null,ee),v.child=Bl(v,null,Se,ee)):di(p,v,Se,ee),v.memoizedState=M.state,H&&Dm(v,A,!0),v.child}function xh(p){var v=p.stateNode;v.pendingContext?Mm(p,v.pendingContext,v.pendingContext!==v.context):v.context&&Mm(p,v.context,!1),rh(p,v.containerInfo)}function bg(p,v,A,M,H){return Xo(),Kf(H),v.flags|=256,di(p,v,A,M),v.child}var wh={dehydrated:null,treeContext:null,retryLane:0};function _h(p){return{baseLanes:p,cachePool:null,transitions:null}}function xg(p,v,A){var M=v.pendingProps,H=mn.current,ee=!1,ue=(v.flags&128)!==0,Se;if((Se=ue)||(Se=p!==null&&p.memoizedState===null?!1:(H&2)!==0),Se?(ee=!0,v.flags&=-129):(p===null||p.memoizedState!==null)&&(H|=1),Vr(mn,H&1),p===null)return Vf(v),p=v.memoizedState,p!==null&&(p=p.dehydrated,p!==null)?((v.mode&1)===0?v.lanes=1:p.data==="$!"?v.lanes=8:v.lanes=1073741824,null):(ue=M.children,p=M.fallback,ee?(M=v.mode,ee=v.child,ue={mode:"hidden",children:ue},(M&1)===0&&ee!==null?(ee.childLanes=0,ee.pendingProps=ue):ee=Ad(ue,M,0,null),p=Kl(p,M,A,null),ee.return=v,p.return=v,ee.sibling=p,v.child=ee,v.child.memoizedState=_h(A),v.memoizedState=wh,p):Zc(v,ue));if(H=p.memoizedState,H!==null&&(Se=H.dehydrated,Se!==null))return zb(p,v,ue,M,Se,H,A);if(ee){ee=M.fallback,ue=v.mode,H=p.child,Se=H.sibling;var Ne={mode:"hidden",children:M.children};return(ue&1)===0&&v.child!==H?(M=v.child,M.childLanes=0,M.pendingProps=Ne,v.deletions=null):(M=_o(H,Ne),M.subtreeFlags=H.subtreeFlags&14680064),Se!==null?ee=_o(Se,ee):(ee=Kl(ee,ue,A,null),ee.flags|=2),ee.return=v,M.return=v,M.sibling=ee,v.child=M,M=ee,ee=v.child,ue=p.child.memoizedState,ue=ue===null?_h(A):{baseLanes:ue.baseLanes|A,cachePool:null,transitions:ue.transitions},ee.memoizedState=ue,ee.childLanes=p.childLanes&~A,v.memoizedState=wh,M}return ee=p.child,p=ee.sibling,M=_o(ee,{mode:"visible",children:M.children}),(v.mode&1)===0&&(M.lanes=A),M.return=v,M.sibling=null,p!==null&&(A=v.deletions,A===null?(v.deletions=[p],v.flags|=16):A.push(p)),v.child=M,v.memoizedState=null,M}function Zc(p,v){return v=Ad({mode:"visible",children:v},p.mode,0,null),v.return=p,p.child=v}function gd(p,v,A,M){return M!==null&&Kf(M),Bl(v,p.child,null,A),p=Zc(v,v.pendingProps.children),p.flags|=2,v.memoizedState=null,p}function zb(p,v,A,M,H,ee,ue){if(A)return v.flags&256?(v.flags&=-257,M=gh(Error(n(422))),gd(p,v,ue,M)):v.memoizedState!==null?(v.child=p.child,v.flags|=128,null):(ee=M.fallback,H=v.mode,M=Ad({mode:"visible",children:M.children},H,0,null),ee=Kl(ee,H,ue,null),ee.flags|=2,M.return=v,ee.return=v,M.sibling=ee,v.child=M,(v.mode&1)!==0&&Bl(v,p.child,null,ue),v.child.memoizedState=_h(ue),v.memoizedState=wh,ee);if((v.mode&1)===0)return gd(p,v,ue,null);if(H.data==="$!"){if(M=H.nextSibling&&H.nextSibling.dataset,M)var Se=M.dgst;return M=Se,ee=Error(n(419)),M=gh(ee,M,void 0),gd(p,v,ue,M)}if(Se=(ue&p.childLanes)!==0,Hi||Se){if(M=On,M!==null){switch(ue&-ue){case 4:H=2;break;case 16:H=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:H=32;break;case 536870912:H=268435456;break;default:H=0}H=(H&(M.suspendedLanes|ue))!==0?0:H,H!==0&&H!==ee.retryLane&&(ee.retryLane=H,Oa(p,H),Gs(M,p,H,-1))}return Wh(),M=gh(Error(n(421))),gd(p,v,ue,M)}return H.data==="$?"?(v.flags|=128,v.child=p.child,v=Jb.bind(null,p),H._reactRetry=v,null):(p=ee.treeContext,rs=uo(H.nextSibling),qi=v,dn=!0,Wi=null,p!==null&&(xs[qs++]=Fi,xs[qs++]=Ui,xs[qs++]=ws,Fi=p.id,Ui=p.overflow,ws=v),v=Zc(v,M.children),v.flags|=4096,v)}function wg(p,v,A){p.lanes|=v;var M=p.alternate;M!==null&&(M.lanes|=v),Fm(p.return,v,A)}function Sh(p,v,A,M,H){var ee=p.memoizedState;ee===null?p.memoizedState={isBackwards:v,rendering:null,renderingStartTime:0,last:M,tail:A,tailMode:H}:(ee.isBackwards=v,ee.rendering=null,ee.renderingStartTime=0,ee.last=M,ee.tail=A,ee.tailMode=H)}function kh(p,v,A){var M=v.pendingProps,H=M.revealOrder,ee=M.tail;if(di(p,v,M.children,A),M=mn.current,(M&2)!==0)M=M&1|2,v.flags|=128;else{if(p!==null&&(p.flags&128)!==0)e:for(p=v.child;p!==null;){if(p.tag===13)p.memoizedState!==null&&wg(p,A,v);else if(p.tag===19)wg(p,A,v);else if(p.child!==null){p.child.return=p,p=p.child;continue}if(p===v)break e;for(;p.sibling===null;){if(p.return===null||p.return===v)break e;p=p.return}p.sibling.return=p.return,p=p.sibling}M&=1}if(Vr(mn,M),(v.mode&1)===0)v.memoizedState=null;else switch(H){case"forwards":for(A=v.child,H=null;A!==null;)p=A.alternate,p!==null&&dd(p)===null&&(H=A),A=A.sibling;A=H,A===null?(H=v.child,v.child=null):(H=A.sibling,A.sibling=null),Sh(v,!1,H,A,ee);break;case"backwards":for(A=null,H=v.child,v.child=null;H!==null;){if(p=H.alternate,p!==null&&dd(p)===null){v.child=H;break}p=H.sibling,H.sibling=A,A=H,H=p}Sh(v,!0,A,null,ee);break;case"together":Sh(v,!1,null,null,void 0);break;default:v.memoizedState=null}return v.child}function vd(p,v){(v.mode&1)===0&&p!==null&&(p.alternate=null,v.alternate=null,v.flags|=2)}function Ma(p,v,A){if(p!==null&&(v.dependencies=p.dependencies),nl|=v.lanes,(A&v.childLanes)===0)return null;if(p!==null&&v.child!==p.child)throw Error(n(153));if(v.child!==null){for(p=v.child,A=_o(p,p.pendingProps),v.child=A,A.return=v;p.sibling!==null;)p=p.sibling,A=A.sibling=_o(p,p.pendingProps),A.return=v;A.sibling=null}return v.child}function W_(p,v,A){switch(v.tag){case 3:xh(v),Xo();break;case 5:Um(v);break;case 1:zi(v.type)&&rd(v);break;case 4:rh(v,v.stateNode.containerInfo);break;case 10:var M=v.type._context,H=v.memoizedProps.value;Vr(Yo,M._currentValue),M._currentValue=H;break;case 13:if(M=v.memoizedState,M!==null)return M.dehydrated!==null?(Vr(mn,mn.current&1),v.flags|=128,null):(A&v.child.childLanes)!==0?xg(p,v,A):(Vr(mn,mn.current&1),p=Ma(p,v,A),p!==null?p.sibling:null);Vr(mn,mn.current&1);break;case 19:if(M=(A&v.childLanes)!==0,(p.flags&128)!==0){if(M)return kh(p,v,A);v.flags|=128}if(H=v.memoizedState,H!==null&&(H.rendering=null,H.tail=null,H.lastEffect=null),Vr(mn,mn.current),M)break;return null;case 22:case 23:return v.lanes=0,gg(p,v,A)}return Ma(p,v,A)}var Ch,jh,_g,Sg;Ch=function(p,v){for(var A=v.child;A!==null;){if(A.tag===5||A.tag===6)p.appendChild(A.stateNode);else if(A.tag!==4&&A.child!==null){A.child.return=A,A=A.child;continue}if(A===v)break;for(;A.sibling===null;){if(A.return===null||A.return===v)return;A=A.return}A.sibling.return=A.return,A=A.sibling}},jh=function(){},_g=function(p,v,A,M){var H=p.memoizedProps;if(H!==M){p=v.stateNode,Qo(da.current);var ee=null;switch(A){case"input":H=Le(p,H),M=Le(p,M),ee=[];break;case"select":H=K({},H,{value:void 0}),M=K({},M,{value:void 0}),ee=[];break;case"textarea":H=Or(p,H),M=Or(p,M),ee=[];break;default:typeof H.onClick!="function"&&typeof M.onClick=="function"&&(p.onclick=Zu)}Ii(A,M);var ue;A=null;for(Ke in H)if(!M.hasOwnProperty(Ke)&&H.hasOwnProperty(Ke)&&H[Ke]!=null)if(Ke==="style"){var Se=H[Ke];for(ue in Se)Se.hasOwnProperty(ue)&&(A||(A={}),A[ue]="")}else Ke!=="dangerouslySetInnerHTML"&&Ke!=="children"&&Ke!=="suppressContentEditableWarning"&&Ke!=="suppressHydrationWarning"&&Ke!=="autoFocus"&&(s.hasOwnProperty(Ke)?ee||(ee=[]):(ee=ee||[]).push(Ke,null));for(Ke in M){var Ne=M[Ke];if(Se=H!=null?H[Ke]:void 0,M.hasOwnProperty(Ke)&&Ne!==Se&&(Ne!=null||Se!=null))if(Ke==="style")if(Se){for(ue in Se)!Se.hasOwnProperty(ue)||Ne&&Ne.hasOwnProperty(ue)||(A||(A={}),A[ue]="");for(ue in Ne)Ne.hasOwnProperty(ue)&&Se[ue]!==Ne[ue]&&(A||(A={}),A[ue]=Ne[ue])}else A||(ee||(ee=[]),ee.push(Ke,A)),A=Ne;else Ke==="dangerouslySetInnerHTML"?(Ne=Ne?Ne.__html:void 0,Se=Se?Se.__html:void 0,Ne!=null&&Se!==Ne&&(ee=ee||[]).push(Ke,Ne)):Ke==="children"?typeof Ne!="string"&&typeof Ne!="number"||(ee=ee||[]).push(Ke,""+Ne):Ke!=="suppressContentEditableWarning"&&Ke!=="suppressHydrationWarning"&&(s.hasOwnProperty(Ke)?(Ne!=null&&Ke==="onScroll"&&Qr("scroll",p),ee||Se===Ne||(ee=[])):(ee=ee||[]).push(Ke,Ne))}A&&(ee=ee||[]).push("style",A);var Ke=ee;(v.updateQueue=Ke)&&(v.flags|=4)}},Sg=function(p,v,A,M){A!==M&&(v.flags|=4)};function yd(p,v){if(!dn)switch(p.tailMode){case"hidden":v=p.tail;for(var A=null;v!==null;)v.alternate!==null&&(A=v),v=v.sibling;A===null?p.tail=null:A.sibling=null;break;case"collapsed":A=p.tail;for(var M=null;A!==null;)A.alternate!==null&&(M=A),A=A.sibling;M===null?v||p.tail===null?p.tail=null:p.tail.sibling=null:M.sibling=null}}function fi(p){var v=p.alternate!==null&&p.alternate.child===p.child,A=0,M=0;if(v)for(var H=p.child;H!==null;)A|=H.lanes|H.childLanes,M|=H.subtreeFlags&14680064,M|=H.flags&14680064,H.return=p,H=H.sibling;else for(H=p.child;H!==null;)A|=H.lanes|H.childLanes,M|=H.subtreeFlags,M|=H.flags,H.return=p,H=H.sibling;return p.subtreeFlags|=M,p.childLanes=A,v}function Fb(p,v,A){var M=v.pendingProps;switch(Uf(v),v.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return fi(v),null;case 1:return zi(v.type)&&td(),fi(v),null;case 3:return M=v.stateNode,Zo(),Zr(Bi),Zr(ji),sh(),M.pendingContext&&(M.context=M.pendingContext,M.pendingContext=null),(p===null||p.child===null)&&(Gc(v)?v.flags|=4:p===null||p.memoizedState.isDehydrated&&(v.flags&256)===0||(v.flags|=1024,Wi!==null&&(Fh(Wi),Wi=null))),jh(p,v),fi(v),null;case 5:nh(v);var H=Qo(Ul.current);if(A=v.type,p!==null&&v.stateNode!=null)_g(p,v,A,M,H),p.ref!==v.ref&&(v.flags|=512,v.flags|=2097152);else{if(!M){if(v.stateNode===null)throw Error(n(166));return fi(v),null}if(p=Qo(da.current),Gc(v)){M=v.stateNode,A=v.type;var ee=v.memoizedProps;switch(M[la]=v,M[Hc]=ee,p=(v.mode&1)!==0,A){case"dialog":Qr("cancel",M),Qr("close",M);break;case"iframe":case"object":case"embed":Qr("load",M);break;case"video":case"audio":for(H=0;H<Uc.length;H++)Qr(Uc[H],M);break;case"source":Qr("error",M);break;case"img":case"image":case"link":Qr("error",M),Qr("load",M);break;case"details":Qr("toggle",M);break;case"input":Ze(M,ee),Qr("invalid",M);break;case"select":M._wrapperState={wasMultiple:!!ee.multiple},Qr("invalid",M);break;case"textarea":wr(M,ee),Qr("invalid",M)}Ii(A,ee),H=null;for(var ue in ee)if(ee.hasOwnProperty(ue)){var Se=ee[ue];ue==="children"?typeof Se=="string"?M.textContent!==Se&&(ee.suppressHydrationWarning!==!0&&Qu(M.textContent,Se,p),H=["children",Se]):typeof Se=="number"&&M.textContent!==""+Se&&(ee.suppressHydrationWarning!==!0&&Qu(M.textContent,Se,p),H=["children",""+Se]):s.hasOwnProperty(ue)&&Se!=null&&ue==="onScroll"&&Qr("scroll",M)}switch(A){case"input":Ve(M),dr(M,ee,!0);break;case"textarea":Ve(M),Wr(M);break;case"select":case"option":break;default:typeof ee.onClick=="function"&&(M.onclick=Zu)}M=H,v.updateQueue=M,M!==null&&(v.flags|=4)}else{ue=H.nodeType===9?H:H.ownerDocument,p==="http://www.w3.org/1999/xhtml"&&(p=ii(A)),p==="http://www.w3.org/1999/xhtml"?A==="script"?(p=ue.createElement("div"),p.innerHTML="<script><\/script>",p=p.removeChild(p.firstChild)):typeof M.is=="string"?p=ue.createElement(A,{is:M.is}):(p=ue.createElement(A),A==="select"&&(ue=p,M.multiple?ue.multiple=!0:M.size&&(ue.size=M.size))):p=ue.createElementNS(p,A),p[la]=v,p[Hc]=M,Ch(p,v,!1,!1),v.stateNode=p;e:{switch(ue=Cr(A,M),A){case"dialog":Qr("cancel",p),Qr("close",p),H=M;break;case"iframe":case"object":case"embed":Qr("load",p),H=M;break;case"video":case"audio":for(H=0;H<Uc.length;H++)Qr(Uc[H],p);H=M;break;case"source":Qr("error",p),H=M;break;case"img":case"image":case"link":Qr("error",p),Qr("load",p),H=M;break;case"details":Qr("toggle",p),H=M;break;case"input":Ze(p,M),H=Le(p,M),Qr("invalid",p);break;case"option":H=M;break;case"select":p._wrapperState={wasMultiple:!!M.multiple},H=K({},M,{value:void 0}),Qr("invalid",p);break;case"textarea":wr(p,M),H=Or(p,M),Qr("invalid",p);break;default:H=M}Ii(A,H),Se=H;for(ee in Se)if(Se.hasOwnProperty(ee)){var Ne=Se[ee];ee==="style"?yi(p,Ne):ee==="dangerouslySetInnerHTML"?(Ne=Ne?Ne.__html:void 0,Ne!=null&&vt(p,Ne)):ee==="children"?typeof Ne=="string"?(A!=="textarea"||Ne!=="")&&jt(p,Ne):typeof Ne=="number"&&jt(p,""+Ne):ee!=="suppressContentEditableWarning"&&ee!=="suppressHydrationWarning"&&ee!=="autoFocus"&&(s.hasOwnProperty(ee)?Ne!=null&&ee==="onScroll"&&Qr("scroll",p):Ne!=null&&k(p,ee,Ne,ue))}switch(A){case"input":Ve(p),dr(p,M,!1);break;case"textarea":Ve(p),Wr(p);break;case"option":M.value!=null&&p.setAttribute("value",""+se(M.value));break;case"select":p.multiple=!!M.multiple,ee=M.value,ee!=null?cr(p,!!M.multiple,ee,!1):M.defaultValue!=null&&cr(p,!!M.multiple,M.defaultValue,!0);break;default:typeof H.onClick=="function"&&(p.onclick=Zu)}switch(A){case"button":case"input":case"select":case"textarea":M=!!M.autoFocus;break e;case"img":M=!0;break e;default:M=!1}}M&&(v.flags|=4)}v.ref!==null&&(v.flags|=512,v.flags|=2097152)}return fi(v),null;case 6:if(p&&v.stateNode!=null)Sg(p,v,p.memoizedProps,M);else{if(typeof M!="string"&&v.stateNode===null)throw Error(n(166));if(A=Qo(Ul.current),Qo(da.current),Gc(v)){if(M=v.stateNode,A=v.memoizedProps,M[la]=v,(ee=M.nodeValue!==A)&&(p=qi,p!==null))switch(p.tag){case 3:Qu(M.nodeValue,A,(p.mode&1)!==0);break;case 5:p.memoizedProps.suppressHydrationWarning!==!0&&Qu(M.nodeValue,A,(p.mode&1)!==0)}ee&&(v.flags|=4)}else M=(A.nodeType===9?A:A.ownerDocument).createTextNode(M),M[la]=v,v.stateNode=M}return fi(v),null;case 13:if(Zr(mn),M=v.memoizedState,p===null||p.memoizedState!==null&&p.memoizedState.dehydrated!==null){if(dn&&rs!==null&&(v.mode&1)!==0&&(v.flags&128)===0)Bm(),Xo(),v.flags|=98560,ee=!1;else if(ee=Gc(v),M!==null&&M.dehydrated!==null){if(p===null){if(!ee)throw Error(n(318));if(ee=v.memoizedState,ee=ee!==null?ee.dehydrated:null,!ee)throw Error(n(317));ee[la]=v}else Xo(),(v.flags&128)===0&&(v.memoizedState=null),v.flags|=4;fi(v),ee=!1}else Wi!==null&&(Fh(Wi),Wi=null),ee=!0;if(!ee)return v.flags&65536?v:null}return(v.flags&128)!==0?(v.lanes=A,v):(M=M!==null,M!==(p!==null&&p.memoizedState!==null)&&M&&(v.child.flags|=8192,(v.mode&1)!==0&&(p===null||(mn.current&1)!==0?Fn===0&&(Fn=3):Wh())),v.updateQueue!==null&&(v.flags|=4),fi(v),null);case 4:return Zo(),jh(p,v),p===null&&qc(v.stateNode.containerInfo),fi(v),null;case 10:return Zf(v.type._context),fi(v),null;case 17:return zi(v.type)&&td(),fi(v),null;case 19:if(Zr(mn),ee=v.memoizedState,ee===null)return fi(v),null;if(M=(v.flags&128)!==0,ue=ee.rendering,ue===null)if(M)yd(ee,!1);else{if(Fn!==0||p!==null&&(p.flags&128)!==0)for(p=v.child;p!==null;){if(ue=dd(p),ue!==null){for(v.flags|=128,yd(ee,!1),M=ue.updateQueue,M!==null&&(v.updateQueue=M,v.flags|=4),v.subtreeFlags=0,M=A,A=v.child;A!==null;)ee=A,p=M,ee.flags&=14680066,ue=ee.alternate,ue===null?(ee.childLanes=0,ee.lanes=p,ee.child=null,ee.subtreeFlags=0,ee.memoizedProps=null,ee.memoizedState=null,ee.updateQueue=null,ee.dependencies=null,ee.stateNode=null):(ee.childLanes=ue.childLanes,ee.lanes=ue.lanes,ee.child=ue.child,ee.subtreeFlags=0,ee.deletions=null,ee.memoizedProps=ue.memoizedProps,ee.memoizedState=ue.memoizedState,ee.updateQueue=ue.updateQueue,ee.type=ue.type,p=ue.dependencies,ee.dependencies=p===null?null:{lanes:p.lanes,firstContext:p.firstContext}),A=A.sibling;return Vr(mn,mn.current&1|2),v.child}p=p.sibling}ee.tail!==null&&Jr()>Vl&&(v.flags|=128,M=!0,yd(ee,!1),v.lanes=4194304)}else{if(!M)if(p=dd(ue),p!==null){if(v.flags|=128,M=!0,A=p.updateQueue,A!==null&&(v.updateQueue=A,v.flags|=4),yd(ee,!0),ee.tail===null&&ee.tailMode==="hidden"&&!ue.alternate&&!dn)return fi(v),null}else 2*Jr()-ee.renderingStartTime>Vl&&A!==1073741824&&(v.flags|=128,M=!0,yd(ee,!1),v.lanes=4194304);ee.isBackwards?(ue.sibling=v.child,v.child=ue):(A=ee.last,A!==null?A.sibling=ue:v.child=ue,ee.last=ue)}return ee.tail!==null?(v=ee.tail,ee.rendering=v,ee.tail=v.sibling,ee.renderingStartTime=Jr(),v.sibling=null,A=mn.current,Vr(mn,M?A&1|2:A&1),v):(fi(v),null);case 22:case 23:return qh(),M=v.memoizedState!==null,p!==null&&p.memoizedState!==null!==M&&(v.flags|=8192),M&&(v.mode&1)!==0?(ns&1073741824)!==0&&(fi(v),v.subtreeFlags&6&&(v.flags|=8192)):fi(v),null;case 24:return null;case 25:return null}throw Error(n(156,v.tag))}function Ub(p,v){switch(Uf(v),v.tag){case 1:return zi(v.type)&&td(),p=v.flags,p&65536?(v.flags=p&-65537|128,v):null;case 3:return Zo(),Zr(Bi),Zr(ji),sh(),p=v.flags,(p&65536)!==0&&(p&128)===0?(v.flags=p&-65537|128,v):null;case 5:return nh(v),null;case 13:if(Zr(mn),p=v.memoizedState,p!==null&&p.dehydrated!==null){if(v.alternate===null)throw Error(n(340));Xo()}return p=v.flags,p&65536?(v.flags=p&-65537|128,v):null;case 19:return Zr(mn),null;case 4:return Zo(),null;case 10:return Zf(v.type._context),null;case 22:case 23:return qh(),null;case 24:return null;default:return null}}var Eh=!1,hi=!1,qb=typeof WeakSet=="function"?WeakSet:Set,Rt=null;function Wl(p,v){var A=p.ref;if(A!==null)if(typeof A=="function")try{A(null)}catch(M){gn(p,v,M)}else A.current=null}function Th(p,v,A){try{A()}catch(M){gn(p,v,M)}}var kg=!1;function Wb(p,v){if(Rf=lo,p=jf(),Ef(p)){if("selectionStart"in p)var A={start:p.selectionStart,end:p.selectionEnd};else e:{A=(A=p.ownerDocument)&&A.defaultView||window;var M=A.getSelection&&A.getSelection();if(M&&M.rangeCount!==0){A=M.anchorNode;var H=M.anchorOffset,ee=M.focusNode;M=M.focusOffset;try{A.nodeType,ee.nodeType}catch{A=null;break e}var ue=0,Se=-1,Ne=-1,Ke=0,dt=0,ht=p,lt=null;t:for(;;){for(var Ct;ht!==A||H!==0&&ht.nodeType!==3||(Se=ue+H),ht!==ee||M!==0&&ht.nodeType!==3||(Ne=ue+M),ht.nodeType===3&&(ue+=ht.nodeValue.length),(Ct=ht.firstChild)!==null;)lt=ht,ht=Ct;for(;;){if(ht===p)break t;if(lt===A&&++Ke===H&&(Se=ue),lt===ee&&++dt===M&&(Ne=ue),(Ct=ht.nextSibling)!==null)break;ht=lt,lt=ht.parentNode}ht=Ct}A=Se===-1||Ne===-1?null:{start:Se,end:Ne}}else A=null}A=A||{start:0,end:0}}else A=null;for(Mf={focusedElem:p,selectionRange:A},lo=!1,Rt=v;Rt!==null;)if(v=Rt,p=v.child,(v.subtreeFlags&1028)!==0&&p!==null)p.return=v,Rt=p;else for(;Rt!==null;){v=Rt;try{var Mt=v.alternate;if((v.flags&1024)!==0)switch(v.tag){case 0:case 11:case 15:break;case 1:if(Mt!==null){var Dt=Mt.memoizedProps,Gr=Mt.memoizedState,qe=v.stateNode,Ie=qe.getSnapshotBeforeUpdate(v.elementType===v.type?Dt:Nn(v.type,Dt),Gr);qe.__reactInternalSnapshotBeforeUpdate=Ie}break;case 3:var Xe=v.stateNode.containerInfo;Xe.nodeType===1?Xe.textContent="":Xe.nodeType===9&&Xe.documentElement&&Xe.removeChild(Xe.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(yt){gn(v,v.return,yt)}if(p=v.sibling,p!==null){p.return=v.return,Rt=p;break}Rt=v.return}return Mt=kg,kg=!1,Mt}function eu(p,v,A){var M=v.updateQueue;if(M=M!==null?M.lastEffect:null,M!==null){var H=M=M.next;do{if((H.tag&p)===p){var ee=H.destroy;H.destroy=void 0,ee!==void 0&&Th(v,A,ee)}H=H.next}while(H!==M)}}function Ah(p,v){if(v=v.updateQueue,v=v!==null?v.lastEffect:null,v!==null){var A=v=v.next;do{if((A.tag&p)===p){var M=A.create;A.destroy=M()}A=A.next}while(A!==v)}}function $h(p){var v=p.ref;if(v!==null){var A=p.stateNode;switch(p.tag){case 5:p=A;break;default:p=A}typeof v=="function"?v(p):v.current=p}}function Cg(p){var v=p.alternate;v!==null&&(p.alternate=null,Cg(v)),p.child=null,p.deletions=null,p.sibling=null,p.tag===5&&(v=p.stateNode,v!==null&&(delete v[la],delete v[Hc],delete v[Bf],delete v[Pm],delete v[Rm])),p.stateNode=null,p.return=null,p.dependencies=null,p.memoizedProps=null,p.memoizedState=null,p.pendingProps=null,p.stateNode=null,p.updateQueue=null}function jg(p){return p.tag===5||p.tag===3||p.tag===4}function Eg(p){e:for(;;){for(;p.sibling===null;){if(p.return===null||jg(p.return))return null;p=p.return}for(p.sibling.return=p.return,p=p.sibling;p.tag!==5&&p.tag!==6&&p.tag!==18;){if(p.flags&2||p.child===null||p.tag===4)continue e;p.child.return=p,p=p.child}if(!(p.flags&2))return p.stateNode}}function Nh(p,v,A){var M=p.tag;if(M===5||M===6)p=p.stateNode,v?A.nodeType===8?A.parentNode.insertBefore(p,v):A.insertBefore(p,v):(A.nodeType===8?(v=A.parentNode,v.insertBefore(p,A)):(v=A,v.appendChild(p)),A=A._reactRootContainer,A!=null||v.onclick!==null||(v.onclick=Zu));else if(M!==4&&(p=p.child,p!==null))for(Nh(p,v,A),p=p.sibling;p!==null;)Nh(p,v,A),p=p.sibling}function Oh(p,v,A){var M=p.tag;if(M===5||M===6)p=p.stateNode,v?A.insertBefore(p,v):A.appendChild(p);else if(M!==4&&(p=p.child,p!==null))for(Oh(p,v,A),p=p.sibling;p!==null;)Oh(p,v,A),p=p.sibling}var Qn=null,Hs=!1;function vo(p,v,A){for(A=A.child;A!==null;)Hb(p,v,A),A=A.sibling}function Hb(p,v,A){if(lr&&typeof lr.onCommitFiberUnmount=="function")try{lr.onCommitFiberUnmount(_t,A)}catch{}switch(A.tag){case 5:hi||Wl(A,v);case 6:var M=Qn,H=Hs;Qn=null,vo(p,v,A),Qn=M,Hs=H,Qn!==null&&(Hs?(p=Qn,A=A.stateNode,p.nodeType===8?p.parentNode.removeChild(A):p.removeChild(A)):Qn.removeChild(A.stateNode));break;case 18:Qn!==null&&(Hs?(p=Qn,A=A.stateNode,p.nodeType===8?Lf(p.parentNode,A):p.nodeType===1&&Lf(p,A),Ta(p)):Lf(Qn,A.stateNode));break;case 4:M=Qn,H=Hs,Qn=A.stateNode.containerInfo,Hs=!0,vo(p,v,A),Qn=M,Hs=H;break;case 0:case 11:case 14:case 15:if(!hi&&(M=A.updateQueue,M!==null&&(M=M.lastEffect,M!==null))){H=M=M.next;do{var ee=H,ue=ee.destroy;ee=ee.tag,ue!==void 0&&((ee&2)!==0||(ee&4)!==0)&&Th(A,v,ue),H=H.next}while(H!==M)}vo(p,v,A);break;case 1:if(!hi&&(Wl(A,v),M=A.stateNode,typeof M.componentWillUnmount=="function"))try{M.props=A.memoizedProps,M.state=A.memoizedState,M.componentWillUnmount()}catch(Se){gn(A,v,Se)}vo(p,v,A);break;case 21:vo(p,v,A);break;case 22:A.mode&1?(hi=(M=hi)||A.memoizedState!==null,vo(p,v,A),hi=M):vo(p,v,A);break;default:vo(p,v,A)}}function tu(p){var v=p.updateQueue;if(v!==null){p.updateQueue=null;var A=p.stateNode;A===null&&(A=p.stateNode=new qb),v.forEach(function(M){var H=Qb.bind(null,p,M);A.has(M)||(A.add(M),M.then(H,H))})}}function ks(p,v){var A=v.deletions;if(A!==null)for(var M=0;M<A.length;M++){var H=A[M];try{var ee=p,ue=v,Se=ue;e:for(;Se!==null;){switch(Se.tag){case 5:Qn=Se.stateNode,Hs=!1;break e;case 3:Qn=Se.stateNode.containerInfo,Hs=!0;break e;case 4:Qn=Se.stateNode.containerInfo,Hs=!0;break e}Se=Se.return}if(Qn===null)throw Error(n(160));Hb(ee,ue,H),Qn=null,Hs=!1;var Ne=H.alternate;Ne!==null&&(Ne.return=null),H.return=null}catch(Ke){gn(H,v,Ke)}}if(v.subtreeFlags&12854)for(v=v.child;v!==null;)Ph(v,p),v=v.sibling}function Ph(p,v){var A=p.alternate,M=p.flags;switch(p.tag){case 0:case 11:case 14:case 15:if(ks(v,p),Vs(p),M&4){try{eu(3,p,p.return),Ah(3,p)}catch(Dt){gn(p,p.return,Dt)}try{eu(5,p,p.return)}catch(Dt){gn(p,p.return,Dt)}}break;case 1:ks(v,p),Vs(p),M&512&&A!==null&&Wl(A,A.return);break;case 5:if(ks(v,p),Vs(p),M&512&&A!==null&&Wl(A,A.return),p.flags&32){var H=p.stateNode;try{jt(H,"")}catch(Dt){gn(p,p.return,Dt)}}if(M&4&&(H=p.stateNode,H!=null)){var ee=p.memoizedProps,ue=A!==null?A.memoizedProps:ee,Se=p.type,Ne=p.updateQueue;if(p.updateQueue=null,Ne!==null)try{Se==="input"&&ee.type==="radio"&&ee.name!=null&&ct(H,ee),Cr(Se,ue);var Ke=Cr(Se,ee);for(ue=0;ue<Ne.length;ue+=2){var dt=Ne[ue],ht=Ne[ue+1];dt==="style"?yi(H,ht):dt==="dangerouslySetInnerHTML"?vt(H,ht):dt==="children"?jt(H,ht):k(H,dt,ht,Ke)}switch(Se){case"input":ut(H,ee);break;case"textarea":sn(H,ee);break;case"select":var lt=H._wrapperState.wasMultiple;H._wrapperState.wasMultiple=!!ee.multiple;var Ct=ee.value;Ct!=null?cr(H,!!ee.multiple,Ct,!1):lt!==!!ee.multiple&&(ee.defaultValue!=null?cr(H,!!ee.multiple,ee.defaultValue,!0):cr(H,!!ee.multiple,ee.multiple?[]:"",!1))}H[Hc]=ee}catch(Dt){gn(p,p.return,Dt)}}break;case 6:if(ks(v,p),Vs(p),M&4){if(p.stateNode===null)throw Error(n(162));H=p.stateNode,ee=p.memoizedProps;try{H.nodeValue=ee}catch(Dt){gn(p,p.return,Dt)}}break;case 3:if(ks(v,p),Vs(p),M&4&&A!==null&&A.memoizedState.isDehydrated)try{Ta(v.containerInfo)}catch(Dt){gn(p,p.return,Dt)}break;case 4:ks(v,p),Vs(p);break;case 13:ks(v,p),Vs(p),H=p.child,H.flags&8192&&(ee=H.memoizedState!==null,H.stateNode.isHidden=ee,!ee||H.alternate!==null&&H.alternate.memoizedState!==null||(Dh=Jr())),M&4&&tu(p);break;case 22:if(dt=A!==null&&A.memoizedState!==null,p.mode&1?(hi=(Ke=hi)||dt,ks(v,p),hi=Ke):ks(v,p),Vs(p),M&8192){if(Ke=p.memoizedState!==null,(p.stateNode.isHidden=Ke)&&!dt&&(p.mode&1)!==0)for(Rt=p,dt=p.child;dt!==null;){for(ht=Rt=dt;Rt!==null;){switch(lt=Rt,Ct=lt.child,lt.tag){case 0:case 11:case 14:case 15:eu(4,lt,lt.return);break;case 1:Wl(lt,lt.return);var Mt=lt.stateNode;if(typeof Mt.componentWillUnmount=="function"){M=lt,A=lt.return;try{v=M,Mt.props=v.memoizedProps,Mt.state=v.memoizedState,Mt.componentWillUnmount()}catch(Dt){gn(M,A,Dt)}}break;case 5:Wl(lt,lt.return);break;case 22:if(lt.memoizedState!==null){Rh(ht);continue}}Ct!==null?(Ct.return=lt,Rt=Ct):Rh(ht)}dt=dt.sibling}e:for(dt=null,ht=p;;){if(ht.tag===5){if(dt===null){dt=ht;try{H=ht.stateNode,Ke?(ee=H.style,typeof ee.setProperty=="function"?ee.setProperty("display","none","important"):ee.display="none"):(Se=ht.stateNode,Ne=ht.memoizedProps.style,ue=Ne!=null&&Ne.hasOwnProperty("display")?Ne.display:null,Se.style.display=Ir("display",ue))}catch(Dt){gn(p,p.return,Dt)}}}else if(ht.tag===6){if(dt===null)try{ht.stateNode.nodeValue=Ke?"":ht.memoizedProps}catch(Dt){gn(p,p.return,Dt)}}else if((ht.tag!==22&&ht.tag!==23||ht.memoizedState===null||ht===p)&&ht.child!==null){ht.child.return=ht,ht=ht.child;continue}if(ht===p)break e;for(;ht.sibling===null;){if(ht.return===null||ht.return===p)break e;dt===ht&&(dt=null),ht=ht.return}dt===ht&&(dt=null),ht.sibling.return=ht.return,ht=ht.sibling}}break;case 19:ks(v,p),Vs(p),M&4&&tu(p);break;case 21:break;default:ks(v,p),Vs(p)}}function Vs(p){var v=p.flags;if(v&2){try{e:{for(var A=p.return;A!==null;){if(jg(A)){var M=A;break e}A=A.return}throw Error(n(160))}switch(M.tag){case 5:var H=M.stateNode;M.flags&32&&(jt(H,""),M.flags&=-33);var ee=Eg(p);Oh(p,ee,H);break;case 3:case 4:var ue=M.stateNode.containerInfo,Se=Eg(p);Nh(p,Se,ue);break;default:throw Error(n(161))}}catch(Ne){gn(p,p.return,Ne)}p.flags&=-3}v&4096&&(p.flags&=-4097)}function Tg(p,v,A){Rt=p,Ag(p)}function Ag(p,v,A){for(var M=(p.mode&1)!==0;Rt!==null;){var H=Rt,ee=H.child;if(H.tag===22&&M){var ue=H.memoizedState!==null||Eh;if(!ue){var Se=H.alternate,Ne=Se!==null&&Se.memoizedState!==null||hi;Se=Eh;var Ke=hi;if(Eh=ue,(hi=Ne)&&!Ke)for(Rt=H;Rt!==null;)ue=Rt,Ne=ue.child,ue.tag===22&&ue.memoizedState!==null?Mh(H):Ne!==null?(Ne.return=ue,Rt=Ne):Mh(H);for(;ee!==null;)Rt=ee,Ag(ee),ee=ee.sibling;Rt=H,Eh=Se,hi=Ke}$g(p)}else(H.subtreeFlags&8772)!==0&&ee!==null?(ee.return=H,Rt=ee):$g(p)}}function $g(p){for(;Rt!==null;){var v=Rt;if((v.flags&8772)!==0){var A=v.alternate;try{if((v.flags&8772)!==0)switch(v.tag){case 0:case 11:case 15:hi||Ah(5,v);break;case 1:var M=v.stateNode;if(v.flags&4&&!hi)if(A===null)M.componentDidMount();else{var H=v.elementType===v.type?A.memoizedProps:Nn(v.type,A.memoizedProps);M.componentDidUpdate(H,A.memoizedState,M.__reactInternalSnapshotBeforeUpdate)}var ee=v.updateQueue;ee!==null&&Ab(v,ee,M);break;case 3:var ue=v.updateQueue;if(ue!==null){if(A=null,v.child!==null)switch(v.child.tag){case 5:A=v.child.stateNode;break;case 1:A=v.child.stateNode}Ab(v,ue,A)}break;case 5:var Se=v.stateNode;if(A===null&&v.flags&4){A=Se;var Ne=v.memoizedProps;switch(v.type){case"button":case"input":case"select":case"textarea":Ne.autoFocus&&A.focus();break;case"img":Ne.src&&(A.src=Ne.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(v.memoizedState===null){var Ke=v.alternate;if(Ke!==null){var dt=Ke.memoizedState;if(dt!==null){var ht=dt.dehydrated;ht!==null&&Ta(ht)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}hi||v.flags&512&&$h(v)}catch(lt){gn(v,v.return,lt)}}if(v===p){Rt=null;break}if(A=v.sibling,A!==null){A.return=v.return,Rt=A;break}Rt=v.return}}function Rh(p){for(;Rt!==null;){var v=Rt;if(v===p){Rt=null;break}var A=v.sibling;if(A!==null){A.return=v.return,Rt=A;break}Rt=v.return}}function Mh(p){for(;Rt!==null;){var v=Rt;try{switch(v.tag){case 0:case 11:case 15:var A=v.return;try{Ah(4,v)}catch(Ne){gn(v,A,Ne)}break;case 1:var M=v.stateNode;if(typeof M.componentDidMount=="function"){var H=v.return;try{M.componentDidMount()}catch(Ne){gn(v,H,Ne)}}var ee=v.return;try{$h(v)}catch(Ne){gn(v,ee,Ne)}break;case 5:var ue=v.return;try{$h(v)}catch(Ne){gn(v,ue,Ne)}}}catch(Ne){gn(v,v.return,Ne)}if(v===p){Rt=null;break}var Se=v.sibling;if(Se!==null){Se.return=v.return,Rt=Se;break}Rt=v.return}}var Vb=Math.ceil,bd=T.ReactCurrentDispatcher,xd=T.ReactCurrentOwner,Cs=T.ReactCurrentBatchConfig,Er=0,On=null,En=null,Zn=0,ns=0,Hl=$a(0),Fn=0,ru=null,nl=0,wd=0,Ih=0,_d=null,Vi=null,Dh=0,Vl=1/0,yo=null,Sd=!1,Lh=null,bo=null,kd=!1,il=null,Cd=0,nu=0,Bh=null,iu=-1,jd=0;function Ai(){return(Er&6)!==0?Jr():iu!==-1?iu:iu=Jr()}function xo(p){return(p.mode&1)===0?1:(Er&2)!==0&&Zn!==0?Zn&-Zn:Xf.transition!==null?(jd===0&&(jd=ra()),jd):(p=gr,p!==0||(p=window.event,p=p===void 0?16:fe(p.type)),p)}function Gs(p,v,A,M){if(50<nu)throw nu=0,Bh=null,Error(n(185));Is(p,A,M),((Er&2)===0||p!==On)&&(p===On&&((Er&2)===0&&(wd|=A),Fn===4&&wo(p,Zn)),Gi(p,M),A===1&&Er===0&&(v.mode&1)===0&&(Vl=Jr()+500,nd&&ho()))}function Gi(p,v){var A=p.callbackNode;ps(p,v);var M=Ms(p,p===On?Zn:0);if(M===0)A!==null&&Dn(A),p.callbackNode=null,p.callbackPriority=0;else if(v=M&-M,p.callbackPriority!==v){if(A!=null&&Dn(A),v===1)p.tag===0?F_(Pg.bind(null,p)):Lm(Pg.bind(null,p)),Cb(function(){(Er&6)===0&&ho()}),A=null;else{switch(Ft(M)){case 1:A=kn;break;case 4:A=bn;break;case 16:A=Et;break;case 536870912:A=it;break;default:A=Et}A=Bg(A,Ng.bind(null,p))}p.callbackPriority=v,p.callbackNode=A}}function Ng(p,v){if(iu=-1,jd=0,(Er&6)!==0)throw Error(n(327));var A=p.callbackNode;if(Gl()&&p.callbackNode!==A)return null;var M=Ms(p,p===On?Zn:0);if(M===0)return null;if((M&30)!==0||(M&p.expiredLanes)!==0||v)v=Ed(p,M);else{v=M;var H=Er;Er|=2;var ee=Gb();(On!==p||Zn!==v)&&(yo=null,Vl=Jr()+500,al(p,v));do try{H_();break}catch(Se){Rg(p,Se)}while(!0);Qf(),bd.current=ee,Er=H,En!==null?v=0:(On=null,Zn=0,v=Fn)}if(v!==0){if(v===2&&(H=Uo(p),H!==0&&(M=H,v=zh(p,H))),v===1)throw A=ru,al(p,0),wo(p,M),Gi(p,Jr()),A;if(v===6)wo(p,M);else{if(H=p.current.alternate,(M&30)===0&&!Og(H)&&(v=Ed(p,M),v===2&&(ee=Uo(p),ee!==0&&(M=ee,v=zh(p,ee))),v===1))throw A=ru,al(p,0),wo(p,M),Gi(p,Jr()),A;switch(p.finishedWork=H,p.finishedLanes=M,v){case 0:case 1:throw Error(n(345));case 2:ol(p,Vi,yo);break;case 3:if(wo(p,M),(M&130023424)===M&&(v=Dh+500-Jr(),10<v)){if(Ms(p,0)!==0)break;if(H=p.suspendedLanes,(H&M)!==M){Ai(),p.pingedLanes|=p.suspendedLanes&H;break}p.timeoutHandle=Df(ol.bind(null,p,Vi,yo),v);break}ol(p,Vi,yo);break;case 4:if(wo(p,M),(M&4194240)===M)break;for(v=p.eventTimes,H=-1;0<M;){var ue=31-fr(M);ee=1<<ue,ue=v[ue],ue>H&&(H=ue),M&=~ee}if(M=H,M=Jr()-M,M=(120>M?120:480>M?480:1080>M?1080:1920>M?1920:3e3>M?3e3:4320>M?4320:1960*Vb(M/1960))-M,10<M){p.timeoutHandle=Df(ol.bind(null,p,Vi,yo),M);break}ol(p,Vi,yo);break;case 5:ol(p,Vi,yo);break;default:throw Error(n(329))}}}return Gi(p,Jr()),p.callbackNode===A?Ng.bind(null,p):null}function zh(p,v){var A=_d;return p.current.memoizedState.isDehydrated&&(al(p,v).flags|=256),p=Ed(p,v),p!==2&&(v=Vi,Vi=A,v!==null&&Fh(v)),p}function Fh(p){Vi===null?Vi=p:Vi.push.apply(Vi,p)}function Og(p){for(var v=p;;){if(v.flags&16384){var A=v.updateQueue;if(A!==null&&(A=A.stores,A!==null))for(var M=0;M<A.length;M++){var H=A[M],ee=H.getSnapshot;H=H.value;try{if(!Us(ee(),H))return!1}catch{return!1}}}if(A=v.child,v.subtreeFlags&16384&&A!==null)A.return=v,v=A;else{if(v===p)break;for(;v.sibling===null;){if(v.return===null||v.return===p)return!0;v=v.return}v.sibling.return=v.return,v=v.sibling}}return!0}function wo(p,v){for(v&=~Ih,v&=~wd,p.suspendedLanes|=v,p.pingedLanes&=~v,p=p.expirationTimes;0<v;){var A=31-fr(v),M=1<<A;p[A]=-1,v&=~M}}function Pg(p){if((Er&6)!==0)throw Error(n(327));Gl();var v=Ms(p,0);if((v&1)===0)return Gi(p,Jr()),null;var A=Ed(p,v);if(p.tag!==0&&A===2){var M=Uo(p);M!==0&&(v=M,A=zh(p,M))}if(A===1)throw A=ru,al(p,0),wo(p,v),Gi(p,Jr()),A;if(A===6)throw Error(n(345));return p.finishedWork=p.current.alternate,p.finishedLanes=v,ol(p,Vi,yo),Gi(p,Jr()),null}function Uh(p,v){var A=Er;Er|=1;try{return p(v)}finally{Er=A,Er===0&&(Vl=Jr()+500,nd&&ho())}}function sl(p){il!==null&&il.tag===0&&(Er&6)===0&&Gl();var v=Er;Er|=1;var A=Cs.transition,M=gr;try{if(Cs.transition=null,gr=1,p)return p()}finally{gr=M,Cs.transition=A,Er=v,(Er&6)===0&&ho()}}function qh(){ns=Hl.current,Zr(Hl)}function al(p,v){p.finishedWork=null,p.finishedLanes=0;var A=p.timeoutHandle;if(A!==-1&&(p.timeoutHandle=-1,kb(A)),En!==null)for(A=En.return;A!==null;){var M=A;switch(Uf(M),M.tag){case 1:M=M.type.childContextTypes,M!=null&&td();break;case 3:Zo(),Zr(Bi),Zr(ji),sh();break;case 5:nh(M);break;case 4:Zo();break;case 13:Zr(mn);break;case 19:Zr(mn);break;case 10:Zf(M.type._context);break;case 22:case 23:qh()}A=A.return}if(On=p,En=p=_o(p.current,null),Zn=ns=v,Fn=0,ru=null,Ih=wd=nl=0,Vi=_d=null,Fl!==null){for(v=0;v<Fl.length;v++)if(A=Fl[v],M=A.interleaved,M!==null){A.interleaved=null;var H=M.next,ee=A.pending;if(ee!==null){var ue=ee.next;ee.next=H,M.next=ue}A.pending=M}Fl=null}return p}function Rg(p,v){do{var A=En;try{if(Qf(),ah.current=md,lh){for(var M=fn.memoizedState;M!==null;){var H=M.queue;H!==null&&(H.pending=null),M=M.next}lh=!1}if(el=0,zn=$n=fn=null,tl=!1,go=0,xd.current=null,A===null||A.return===null){Fn=1,ru=v,En=null;break}e:{var ee=p,ue=A.return,Se=A,Ne=v;if(v=Zn,Se.flags|=32768,Ne!==null&&typeof Ne=="object"&&typeof Ne.then=="function"){var Ke=Ne,dt=Se,ht=dt.tag;if((dt.mode&1)===0&&(ht===0||ht===11||ht===15)){var lt=dt.alternate;lt?(dt.updateQueue=lt.updateQueue,dt.memoizedState=lt.memoizedState,dt.lanes=lt.lanes):(dt.updateQueue=null,dt.memoizedState=null)}var Ct=Lb(ue);if(Ct!==null){Ct.flags&=-257,Ti(Ct,ue,Se,ee,v),Ct.mode&1&&hg(ee,Ke,v),v=Ct,Ne=Ke;var Mt=v.updateQueue;if(Mt===null){var Dt=new Set;Dt.add(Ne),v.updateQueue=Dt}else Mt.add(Ne);break e}else{if((v&1)===0){hg(ee,Ke,v),Wh();break e}Ne=Error(n(426))}}else if(dn&&Se.mode&1){var Gr=Lb(ue);if(Gr!==null){(Gr.flags&65536)===0&&(Gr.flags|=256),Ti(Gr,ue,Se,ee,v),Kf(ql(Ne,Se));break e}}ee=Ne=ql(Ne,Se),Fn!==4&&(Fn=2),_d===null?_d=[ee]:_d.push(ee),ee=ue;do{switch(ee.tag){case 3:ee.flags|=65536,v&=-v,ee.lanes|=v;var qe=dg(ee,Ne,v);Tb(ee,qe);break e;case 1:Se=Ne;var Ie=ee.type,Xe=ee.stateNode;if((ee.flags&128)===0&&(typeof Ie.getDerivedStateFromError=="function"||Xe!==null&&typeof Xe.componentDidCatch=="function"&&(bo===null||!bo.has(Xe)))){ee.flags|=65536,v&=-v,ee.lanes|=v;var yt=fg(ee,Se,v);Tb(ee,yt);break e}}ee=ee.return}while(ee!==null)}su(A)}catch(Wt){v=Wt,En===A&&A!==null&&(En=A=A.return);continue}break}while(!0)}function Gb(){var p=bd.current;return bd.current=md,p===null?md:p}function Wh(){(Fn===0||Fn===3||Fn===2)&&(Fn=4),On===null||(nl&268435455)===0&&(wd&268435455)===0||wo(On,Zn)}function Ed(p,v){var A=Er;Er|=2;var M=Gb();(On!==p||Zn!==v)&&(yo=null,al(p,v));do try{Kb();break}catch(H){Rg(p,H)}while(!0);if(Qf(),Er=A,bd.current=M,En!==null)throw Error(n(261));return On=null,Zn=0,Fn}function Kb(){for(;En!==null;)Mg(En)}function H_(){for(;En!==null&&!Fo();)Mg(En)}function Mg(p){var v=Lg(p.alternate,p,ns);p.memoizedProps=p.pendingProps,v===null?su(p):En=v,xd.current=null}function su(p){var v=p;do{var A=v.alternate;if(p=v.return,(v.flags&32768)===0){if(A=Fb(A,v,ns),A!==null){En=A;return}}else{if(A=Ub(A,v),A!==null){A.flags&=32767,En=A;return}if(p!==null)p.flags|=32768,p.subtreeFlags=0,p.deletions=null;else{Fn=6,En=null;return}}if(v=v.sibling,v!==null){En=v;return}En=v=p}while(v!==null);Fn===0&&(Fn=5)}function ol(p,v,A){var M=gr,H=Cs.transition;try{Cs.transition=null,gr=1,Ig(p,v,A,M)}finally{Cs.transition=H,gr=M}return null}function Ig(p,v,A,M){do Gl();while(il!==null);if((Er&6)!==0)throw Error(n(327));A=p.finishedWork;var H=p.finishedLanes;if(A===null)return null;if(p.finishedWork=null,p.finishedLanes=0,A===p.current)throw Error(n(177));p.callbackNode=null,p.callbackPriority=0;var ee=A.lanes|A.childLanes;if($c(p,ee),p===On&&(En=On=null,Zn=0),(A.subtreeFlags&2064)===0&&(A.flags&2064)===0||kd||(kd=!0,Bg(Et,function(){return Gl(),null})),ee=(A.flags&15990)!==0,(A.subtreeFlags&15990)!==0||ee){ee=Cs.transition,Cs.transition=null;var ue=gr;gr=1;var Se=Er;Er|=4,xd.current=null,Wb(p,A),Ph(A,p),bb(Mf),lo=!!Rf,Mf=Rf=null,p.current=A,Tg(A),Tl(),Er=Se,gr=ue,Cs.transition=ee}else p.current=A;if(kd&&(kd=!1,il=p,Cd=H),ee=p.pendingLanes,ee===0&&(bo=null),mt(A.stateNode),Gi(p,Jr()),v!==null)for(M=p.onRecoverableError,A=0;A<v.length;A++)H=v[A],M(H.value,{componentStack:H.stack,digest:H.digest});if(Sd)throw Sd=!1,p=Lh,Lh=null,p;return(Cd&1)!==0&&p.tag!==0&&Gl(),ee=p.pendingLanes,(ee&1)!==0?p===Bh?nu++:(nu=0,Bh=p):nu=0,ho(),null}function Gl(){if(il!==null){var p=Ft(Cd),v=Cs.transition,A=gr;try{if(Cs.transition=null,gr=16>p?16:p,il===null)var M=!1;else{if(p=il,il=null,Cd=0,(Er&6)!==0)throw Error(n(331));var H=Er;for(Er|=4,Rt=p.current;Rt!==null;){var ee=Rt,ue=ee.child;if((Rt.flags&16)!==0){var Se=ee.deletions;if(Se!==null){for(var Ne=0;Ne<Se.length;Ne++){var Ke=Se[Ne];for(Rt=Ke;Rt!==null;){var dt=Rt;switch(dt.tag){case 0:case 11:case 15:eu(8,dt,ee)}var ht=dt.child;if(ht!==null)ht.return=dt,Rt=ht;else for(;Rt!==null;){dt=Rt;var lt=dt.sibling,Ct=dt.return;if(Cg(dt),dt===Ke){Rt=null;break}if(lt!==null){lt.return=Ct,Rt=lt;break}Rt=Ct}}}var Mt=ee.alternate;if(Mt!==null){var Dt=Mt.child;if(Dt!==null){Mt.child=null;do{var Gr=Dt.sibling;Dt.sibling=null,Dt=Gr}while(Dt!==null)}}Rt=ee}}if((ee.subtreeFlags&2064)!==0&&ue!==null)ue.return=ee,Rt=ue;else e:for(;Rt!==null;){if(ee=Rt,(ee.flags&2048)!==0)switch(ee.tag){case 0:case 11:case 15:eu(9,ee,ee.return)}var qe=ee.sibling;if(qe!==null){qe.return=ee.return,Rt=qe;break e}Rt=ee.return}}var Ie=p.current;for(Rt=Ie;Rt!==null;){ue=Rt;var Xe=ue.child;if((ue.subtreeFlags&2064)!==0&&Xe!==null)Xe.return=ue,Rt=Xe;else e:for(ue=Ie;Rt!==null;){if(Se=Rt,(Se.flags&2048)!==0)try{switch(Se.tag){case 0:case 11:case 15:Ah(9,Se)}}catch(Wt){gn(Se,Se.return,Wt)}if(Se===ue){Rt=null;break e}var yt=Se.sibling;if(yt!==null){yt.return=Se.return,Rt=yt;break e}Rt=Se.return}}if(Er=H,ho(),lr&&typeof lr.onPostCommitFiberRoot=="function")try{lr.onPostCommitFiberRoot(_t,p)}catch{}M=!0}return M}finally{gr=A,Cs.transition=v}}return!1}function Dg(p,v,A){v=ql(A,v),v=dg(p,v,1),p=mo(p,v,1),v=Ai(),p!==null&&(Is(p,1,v),Gi(p,v))}function gn(p,v,A){if(p.tag===3)Dg(p,p,A);else for(;v!==null;){if(v.tag===3){Dg(v,p,A);break}else if(v.tag===1){var M=v.stateNode;if(typeof v.type.getDerivedStateFromError=="function"||typeof M.componentDidCatch=="function"&&(bo===null||!bo.has(M))){p=ql(A,p),p=fg(v,p,1),v=mo(v,p,1),p=Ai(),v!==null&&(Is(v,1,p),Gi(v,p));break}}v=v.return}}function Xb(p,v,A){var M=p.pingCache;M!==null&&M.delete(v),v=Ai(),p.pingedLanes|=p.suspendedLanes&A,On===p&&(Zn&A)===A&&(Fn===4||Fn===3&&(Zn&130023424)===Zn&&500>Jr()-Dh?al(p,0):Ih|=A),Gi(p,v)}function Yb(p,v){v===0&&((p.mode&1)===0?v=1:(v=Rr,Rr<<=1,(Rr&130023424)===0&&(Rr=4194304)));var A=Ai();p=Oa(p,v),p!==null&&(Is(p,v,A),Gi(p,A))}function Jb(p){var v=p.memoizedState,A=0;v!==null&&(A=v.retryLane),Yb(p,A)}function Qb(p,v){var A=0;switch(p.tag){case 13:var M=p.stateNode,H=p.memoizedState;H!==null&&(A=H.retryLane);break;case 19:M=p.stateNode;break;default:throw Error(n(314))}M!==null&&M.delete(v),Yb(p,A)}var Lg;Lg=function(p,v,A){if(p!==null)if(p.memoizedProps!==v.pendingProps||Bi.current)Hi=!0;else{if((p.lanes&A)===0&&(v.flags&128)===0)return Hi=!1,W_(p,v,A);Hi=(p.flags&131072)!==0}else Hi=!1,dn&&(v.flags&1048576)!==0&&Ko(v,sd,v.index);switch(v.lanes=0,v.tag){case 2:var M=v.type;vd(p,v),p=v.pendingProps;var H=Ei(v,ji.current);zl(v,A),H=uh(null,v,M,p,H,A);var ee=dh();return v.flags|=1,typeof H=="object"&&H!==null&&typeof H.render=="function"&&H.$$typeof===void 0?(v.tag=1,v.memoizedState=null,v.updateQueue=null,zi(M)?(ee=!0,rd(v)):ee=!1,v.memoizedState=H.state!==null&&H.state!==void 0?H.state:null,cd(v),H.updater=Ra,v.stateNode=H,H._reactInternals=v,mh(v,M,p,A),v=bh(null,v,M,!0,ee,A)):(v.tag=0,dn&&ee&&An(v),di(null,v,H,A),v=v.child),v;case 16:M=v.elementType;e:{switch(vd(p,v),p=v.pendingProps,H=M._init,M=H(M._payload),v.type=M,H=v.tag=Zb(M),p=Nn(M,p),H){case 0:v=yh(null,v,M,p,A);break e;case 1:v=yg(null,v,M,p,A);break e;case 11:v=pg(null,v,M,p,A);break e;case 14:v=Qc(null,v,M,Nn(M.type,p),A);break e}throw Error(n(306,M,""))}return v;case 0:return M=v.type,H=v.pendingProps,H=v.elementType===M?H:Nn(M,H),yh(p,v,M,H,A);case 1:return M=v.type,H=v.pendingProps,H=v.elementType===M?H:Nn(M,H),yg(p,v,M,H,A);case 3:e:{if(xh(v),p===null)throw Error(n(387));M=v.pendingProps,ee=v.memoizedState,H=ee.element,th(p,v),ud(v,M,null,A);var ue=v.memoizedState;if(M=ue.element,ee.isDehydrated)if(ee={element:M,isDehydrated:!1,cache:ue.cache,pendingSuspenseBoundaries:ue.pendingSuspenseBoundaries,transitions:ue.transitions},v.updateQueue.baseState=ee,v.memoizedState=ee,v.flags&256){H=ql(Error(n(423)),v),v=bg(p,v,M,A,H);break e}else if(M!==H){H=ql(Error(n(424)),v),v=bg(p,v,M,A,H);break e}else for(rs=uo(v.stateNode.containerInfo.firstChild),qi=v,dn=!0,Wi=null,A=Yf(v,null,M,A),v.child=A;A;)A.flags=A.flags&-3|4096,A=A.sibling;else{if(Xo(),M===H){v=Ma(p,v,A);break e}di(p,v,M,A)}v=v.child}return v;case 5:return Um(v),p===null&&Vf(v),M=v.type,H=v.pendingProps,ee=p!==null?p.memoizedProps:null,ue=H.children,If(M,H)?ue=null:ee!==null&&If(M,ee)&&(v.flags|=32),vg(p,v),di(p,v,ue,A),v.child;case 6:return p===null&&Vf(v),null;case 13:return xg(p,v,A);case 4:return rh(v,v.stateNode.containerInfo),M=v.pendingProps,p===null?v.child=Bl(v,null,M,A):di(p,v,M,A),v.child;case 11:return M=v.type,H=v.pendingProps,H=v.elementType===M?H:Nn(M,H),pg(p,v,M,H,A);case 7:return di(p,v,v.pendingProps,A),v.child;case 8:return di(p,v,v.pendingProps.children,A),v.child;case 12:return di(p,v,v.pendingProps.children,A),v.child;case 10:e:{if(M=v.type._context,H=v.pendingProps,ee=v.memoizedProps,ue=H.value,Vr(Yo,M._currentValue),M._currentValue=ue,ee!==null)if(Us(ee.value,ue)){if(ee.children===H.children&&!Bi.current){v=Ma(p,v,A);break e}}else for(ee=v.child,ee!==null&&(ee.return=v);ee!==null;){var Se=ee.dependencies;if(Se!==null){ue=ee.child;for(var Ne=Se.firstContext;Ne!==null;){if(Ne.context===M){if(ee.tag===1){Ne=Pa(-1,A&-A),Ne.tag=2;var Ke=ee.updateQueue;if(Ke!==null){Ke=Ke.shared;var dt=Ke.pending;dt===null?Ne.next=Ne:(Ne.next=dt.next,dt.next=Ne),Ke.pending=Ne}}ee.lanes|=A,Ne=ee.alternate,Ne!==null&&(Ne.lanes|=A),Fm(ee.return,A,v),Se.lanes|=A;break}Ne=Ne.next}}else if(ee.tag===10)ue=ee.type===v.type?null:ee.child;else if(ee.tag===18){if(ue=ee.return,ue===null)throw Error(n(341));ue.lanes|=A,Se=ue.alternate,Se!==null&&(Se.lanes|=A),Fm(ue,A,v),ue=ee.sibling}else ue=ee.child;if(ue!==null)ue.return=ee;else for(ue=ee;ue!==null;){if(ue===v){ue=null;break}if(ee=ue.sibling,ee!==null){ee.return=ue.return,ue=ee;break}ue=ue.return}ee=ue}di(p,v,H.children,A),v=v.child}return v;case 9:return H=v.type,M=v.pendingProps.children,zl(v,A),H=_s(H),M=M(H),v.flags|=1,di(p,v,M,A),v.child;case 14:return M=v.type,H=Nn(M,v.pendingProps),H=Nn(M.type,H),Qc(p,v,M,H,A);case 15:return mg(p,v,v.type,v.pendingProps,A);case 17:return M=v.type,H=v.pendingProps,H=v.elementType===M?H:Nn(M,H),vd(p,v),v.tag=1,zi(M)?(p=!0,rd(v)):p=!1,zl(v,A),cg(v,M,H),mh(v,M,H,A),bh(null,v,M,!0,p,A);case 19:return kh(p,v,A);case 22:return gg(p,v,A)}throw Error(n(156,v.tag))};function Bg(p,v){return xi(p,v)}function V_(p,v,A,M){this.tag=p,this.key=A,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=v,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=M,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function is(p,v,A,M){return new V_(p,v,A,M)}function Hh(p){return p=p.prototype,!(!p||!p.isReactComponent)}function Zb(p){if(typeof p=="function")return Hh(p)?1:0;if(p!=null){if(p=p.$$typeof,p===q)return 11;if(p===G)return 14}return 2}function _o(p,v){var A=p.alternate;return A===null?(A=is(p.tag,v,p.key,p.mode),A.elementType=p.elementType,A.type=p.type,A.stateNode=p.stateNode,A.alternate=p,p.alternate=A):(A.pendingProps=v,A.type=p.type,A.flags=0,A.subtreeFlags=0,A.deletions=null),A.flags=p.flags&14680064,A.childLanes=p.childLanes,A.lanes=p.lanes,A.child=p.child,A.memoizedProps=p.memoizedProps,A.memoizedState=p.memoizedState,A.updateQueue=p.updateQueue,v=p.dependencies,A.dependencies=v===null?null:{lanes:v.lanes,firstContext:v.firstContext},A.sibling=p.sibling,A.index=p.index,A.ref=p.ref,A}function Td(p,v,A,M,H,ee){var ue=2;if(M=p,typeof p=="function")Hh(p)&&(ue=1);else if(typeof p=="string")ue=5;else e:switch(p){case P:return Kl(A.children,H,ee,v);case N:ue=8,H|=8;break;case I:return p=is(12,A,v,H|2),p.elementType=I,p.lanes=ee,p;case F:return p=is(13,A,v,H),p.elementType=F,p.lanes=ee,p;case z:return p=is(19,A,v,H),p.elementType=z,p.lanes=ee,p;case oe:return Ad(A,H,ee,v);default:if(typeof p=="object"&&p!==null)switch(p.$$typeof){case U:ue=10;break e;case V:ue=9;break e;case q:ue=11;break e;case G:ue=14;break e;case Y:ue=16,M=null;break e}throw Error(n(130,p==null?p:typeof p,""))}return v=is(ue,A,v,H),v.elementType=p,v.type=M,v.lanes=ee,v}function Kl(p,v,A,M){return p=is(7,p,M,v),p.lanes=A,p}function Ad(p,v,A,M){return p=is(22,p,M,v),p.elementType=oe,p.lanes=A,p.stateNode={isHidden:!1},p}function Vh(p,v,A){return p=is(6,p,null,v),p.lanes=A,p}function Gh(p,v,A){return v=is(4,p.children!==null?p.children:[],p.key,v),v.lanes=A,v.stateNode={containerInfo:p.containerInfo,pendingChildren:null,implementation:p.implementation},v}function G_(p,v,A,M,H){this.tag=v,this.containerInfo=p,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Qe(0),this.expirationTimes=Qe(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Qe(0),this.identifierPrefix=M,this.onRecoverableError=H,this.mutableSourceEagerHydrationData=null}function Kh(p,v,A,M,H,ee,ue,Se,Ne){return p=new G_(p,v,A,Se,Ne),v===1?(v=1,ee===!0&&(v|=8)):v=0,ee=is(3,null,null,v),p.current=ee,ee.stateNode=p,ee.memoizedState={element:M,isDehydrated:A,cache:null,transitions:null,pendingSuspenseBoundaries:null},cd(ee),p}function K_(p,v,A){var M=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:$,key:M==null?null:""+M,children:p,containerInfo:v,implementation:A}}function zg(p){if(!p)return fo;p=p._reactInternals;e:{if(Nt(p)!==p||p.tag!==1)throw Error(n(170));var v=p;do{switch(v.tag){case 3:v=v.stateNode.context;break e;case 1:if(zi(v.type)){v=v.stateNode.__reactInternalMemoizedMergedChildContext;break e}}v=v.return}while(v!==null);throw Error(n(171))}if(p.tag===1){var A=p.type;if(zi(A))return Im(p,A,v)}return v}function ex(p,v,A,M,H,ee,ue,Se,Ne){return p=Kh(A,M,!0,p,H,ee,ue,Se,Ne),p.context=zg(null),A=p.current,M=Ai(),H=xo(A),ee=Pa(M,H),ee.callback=v??null,mo(A,ee,H),p.current.lanes=H,Is(p,H,M),Gi(p,M),p}function $d(p,v,A,M){var H=v.current,ee=Ai(),ue=xo(H);return A=zg(A),v.context===null?v.context=A:v.pendingContext=A,v=Pa(ee,ue),v.payload={element:p},M=M===void 0?null:M,M!==null&&(v.callback=M),p=mo(H,v,ue),p!==null&&(Gs(p,H,ue,ee),Kc(p,H,ue)),ue}function Nd(p){if(p=p.current,!p.child)return null;switch(p.child.tag){case 5:return p.child.stateNode;default:return p.child.stateNode}}function Fg(p,v){if(p=p.memoizedState,p!==null&&p.dehydrated!==null){var A=p.retryLane;p.retryLane=A!==0&&A<v?A:v}}function Xh(p,v){Fg(p,v),(p=p.alternate)&&Fg(p,v)}function tx(){return null}var rx=typeof reportError=="function"?reportError:function(p){console.error(p)};function Yh(p){this._internalRoot=p}Xl.prototype.render=Yh.prototype.render=function(p){var v=this._internalRoot;if(v===null)throw Error(n(409));$d(p,v,null,null)},Xl.prototype.unmount=Yh.prototype.unmount=function(){var p=this._internalRoot;if(p!==null){this._internalRoot=null;var v=p.containerInfo;sl(function(){$d(null,p,null,null)}),v[ca]=null}};function Xl(p){this._internalRoot=p}Xl.prototype.unstable_scheduleHydration=function(p){if(p){var v=ro();p={blockedOn:null,target:p,priority:v};for(var A=0;A<Ds.length&&v!==0&&v<Ds[A].priority;A++);Ds.splice(A,0,p),A===0&&Nc(p)}};function Jh(p){return!(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11)}function Od(p){return!(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11&&(p.nodeType!==8||p.nodeValue!==" react-mount-point-unstable "))}function nx(){}function ix(p,v,A,M,H){if(H){if(typeof M=="function"){var ee=M;M=function(){var Ke=Nd(ue);ee.call(Ke)}}var ue=ex(v,M,p,0,null,!1,!1,"",nx);return p._reactRootContainer=ue,p[ca]=ue.current,qc(p.nodeType===8?p.parentNode:p),sl(),ue}for(;H=p.lastChild;)p.removeChild(H);if(typeof M=="function"){var Se=M;M=function(){var Ke=Nd(Ne);Se.call(Ke)}}var Ne=Kh(p,0,!1,null,null,!1,!1,"",nx);return p._reactRootContainer=Ne,p[ca]=Ne.current,qc(p.nodeType===8?p.parentNode:p),sl(function(){$d(v,Ne,A,M)}),Ne}function au(p,v,A,M,H){var ee=A._reactRootContainer;if(ee){var ue=ee;if(typeof H=="function"){var Se=H;H=function(){var Ne=Nd(ue);Se.call(Ne)}}$d(v,ue,p,H)}else ue=ix(A,v,p,H,M);return Nd(ue)}na=function(p){switch(p.tag){case 3:var v=p.stateNode;if(v.current.memoizedState.isDehydrated){var A=hs(v.pendingLanes);A!==0&&(Al(v,A|1),Gi(v,Jr()),(Er&6)===0&&(Vl=Jr()+500,ho()))}break;case 13:sl(function(){var M=Oa(p,1);if(M!==null){var H=Ai();Gs(M,p,1,H)}}),Xh(p,1)}},Ca=function(p){if(p.tag===13){var v=Oa(p,134217728);if(v!==null){var A=Ai();Gs(v,p,134217728,A)}Xh(p,134217728)}},ja=function(p){if(p.tag===13){var v=xo(p),A=Oa(p,v);if(A!==null){var M=Ai();Gs(A,p,v,M)}Xh(p,v)}},ro=function(){return gr},qo=function(p,v){var A=gr;try{return gr=p,v()}finally{gr=A}},Ge=function(p,v,A){switch(v){case"input":if(ut(p,A),v=A.name,A.type==="radio"&&v!=null){for(A=p;A.parentNode;)A=A.parentNode;for(A=A.querySelectorAll("input[name="+JSON.stringify(""+v)+'][type="radio"]'),v=0;v<A.length;v++){var M=A[v];if(M!==p&&M.form===p.form){var H=ed(M);if(!H)throw Error(n(90));Re(M),ut(M,H)}}}break;case"textarea":sn(p,A);break;case"select":v=A.value,v!=null&&cr(p,!!A.multiple,v,!1)}},an=Uh,Di=sl;var Ug={usingClientEntryPoint:!1,Events:[Vc,Rl,ed,Pr,Yr,Uh]},Ks={findFiberByHostInstance:Vo,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},sx={bundleType:Ks.bundleType,version:Ks.version,rendererPackageName:Ks.rendererPackageName,rendererConfig:Ks.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:T.ReactCurrentDispatcher,findHostInstanceByFiber:function(p){return p=ds(p),p===null?null:p.stateNode},findFiberByHostInstance:Ks.findFiberByHostInstance||tx,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var ou=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ou.isDisabled&&ou.supportsFiber)try{_t=ou.inject(sx),lr=ou}catch{}}return Xs.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Ug,Xs.createPortal=function(p,v){var A=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Jh(v))throw Error(n(200));return K_(p,v,null,A)},Xs.createRoot=function(p,v){if(!Jh(p))throw Error(n(299));var A=!1,M="",H=rx;return v!=null&&(v.unstable_strictMode===!0&&(A=!0),v.identifierPrefix!==void 0&&(M=v.identifierPrefix),v.onRecoverableError!==void 0&&(H=v.onRecoverableError)),v=Kh(p,1,!1,null,null,A,!1,M,H),p[ca]=v.current,qc(p.nodeType===8?p.parentNode:p),new Yh(v)},Xs.findDOMNode=function(p){if(p==null)return null;if(p.nodeType===1)return p;var v=p._reactInternals;if(v===void 0)throw typeof p.render=="function"?Error(n(188)):(p=Object.keys(p).join(","),Error(n(268,p)));return p=ds(v),p=p===null?null:p.stateNode,p},Xs.flushSync=function(p){return sl(p)},Xs.hydrate=function(p,v,A){if(!Od(v))throw Error(n(200));return au(null,p,v,!0,A)},Xs.hydrateRoot=function(p,v,A){if(!Jh(p))throw Error(n(405));var M=A!=null&&A.hydratedSources||null,H=!1,ee="",ue=rx;if(A!=null&&(A.unstable_strictMode===!0&&(H=!0),A.identifierPrefix!==void 0&&(ee=A.identifierPrefix),A.onRecoverableError!==void 0&&(ue=A.onRecoverableError)),v=ex(v,null,p,1,A??null,H,!1,ee,ue),p[ca]=v.current,qc(p),M)for(p=0;p<M.length;p++)A=M[p],H=A._getVersion,H=H(A._source),v.mutableSourceEagerHydrationData==null?v.mutableSourceEagerHydrationData=[A,H]:v.mutableSourceEagerHydrationData.push(A,H);return new Xl(v)},Xs.render=function(p,v,A){if(!Od(v))throw Error(n(200));return au(null,p,v,!1,A)},Xs.unmountComponentAtNode=function(p){if(!Od(p))throw Error(n(40));return p._reactRootContainer?(sl(function(){au(null,null,p,!1,function(){p._reactRootContainer=null,p[ca]=null})}),!0):!1},Xs.unstable_batchedUpdates=Uh,Xs.unstable_renderSubtreeIntoContainer=function(p,v,A,M){if(!Od(A))throw Error(n(200));if(p==null||p._reactInternals===void 0)throw Error(n(38));return au(p,v,A,!1,M)},Xs.version="18.3.1-next-f1338f8080-20240426",Xs}var d$;function w5(){if(d$)return Z_.exports;d$=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(r){console.error(r)}}return e(),Z_.exports=W8(),Z_.exports}var f$;function H8(){if(f$)return lx;f$=1;var e=w5();return lx.createRoot=e.createRoot,lx.hydrateRoot=e.hydrateRoot,lx}var V8=H8();const G8=nn(V8);var D=hT();const Fe=nn(D),h$=e=>{let r;const n=new Set,i=(f,m)=>{const h=typeof f=="function"?f(r):f;if(!Object.is(h,r)){const y=r;r=m??(typeof h!="object"||h===null)?h:Object.assign({},r,h),n.forEach(x=>x(r,y))}},s=()=>r,o={setState:i,getState:s,getInitialState:()=>u,subscribe:f=>(n.add(f),()=>n.delete(f))},u=r=e(i,s,o);return o},K8=(e=>e?h$(e):h$),X8=e=>e;function Y8(e,r=X8){const n=Fe.useSyncExternalStore(e.subscribe,Fe.useCallback(()=>r(e.getState()),[e,r]),Fe.useCallback(()=>r(e.getInitialState()),[e,r]));return Fe.useDebugValue(n),n}const p$=e=>{const r=K8(e),n=i=>Y8(r,i);return Object.assign(n,r),n},Gn=(e=>e?p$(e):p$);function Io(e){return"'"+e.replace(/'/g,"'\\''")+"'"}const r1=({sessionId:e})=>`claude --dangerously-skip-permissions --session-id ${Io(e)}`,m$=({sessionId:e})=>`claude --session-id ${Io(e)}`,J8=()=>"claude --resume",_5=[{id:"sm-dangerous",label:"Session Manager (skip perms)",description:"claude --dangerously-skip-permissions in this project",category:"build",cwd:"app-cwd",command:r1},{id:"sm-safe",label:"Session Manager (safe)",description:"claude with normal permission prompts in this project",category:"build",cwd:"app-cwd",command:m$},{id:"home-dangerous",label:"Home (skip perms)",description:"claude --dangerously-skip-permissions in ~",category:"build",cwd:"home",command:r1},{id:"pick-dangerous",label:"Pick directory (skip perms)…",description:"Choose a folder, launch claude --dangerously-skip-permissions",category:"build",cwd:"pick",command:r1},{id:"pick-safe",label:"Pick directory (safe)…",description:"Choose a folder, launch claude with normal prompts",category:"build",cwd:"pick",command:m$},{id:"pick-resume",label:"Pick directory + resume…",description:"Choose a folder, then pick a past session to resume",category:"build",cwd:"pick",command:J8},{id:"pick-shell",label:"Pick directory (shell only)…",description:"Bare interactive shell, no claude auto-launch",category:"build",cwd:"pick",command:null}];let Da=null;async function Q8(){if(Da)return Da;try{const e=await window.api.app.engageRulesPath();if(!e)return Da=[],Da;const r=await window.api.config.readJson(e);if(!r.exists||r.parseError||!r.data)return Da=[],Da;const n=r.data;if(!n.presets||!Array.isArray(n.presets))return Da=[],Da;const i=n.projectPath;return Da=n.presets.map(s=>({id:s.id,label:s.label,description:s.description,category:"engage",cwd:i,platform:s.platform,pipeline:s.pipeline,rules:s.rules,command:()=>`cd ${Io(i)} && ${s.cliEntry}`})),Da}catch(e){return console.warn("[presets] Failed to load engage presets:",e),Da=[],Da}}async function S5(e){const r=_5.find(i=>i.id===e);return r||((await Q8()).find(i=>i.id===e)??null)}async function Z8(e){return e.cwd==="app-cwd"?window.api.app.cwd():e.cwd==="home"?window.api.app.homeDir():e.cwd==="pick"?window.api.app.pickDirectory():e.cwd}function k5(e,r){return e.command?e.command(r):null}function eU(e){const r=e.split("/").filter(Boolean);return r[r.length-1]||e}const Jt=Gn((e,r)=>({tabs:[],activeTabId:null,hydrated:!1,addTab:({id:n,cwd:i,startupCommand:s,presetId:a=null,label:l})=>{const o=n??crypto.randomUUID();if(r().tabs.find(m=>m.id===o))return e({activeTabId:o}),o;const f={id:o,claudeSessionId:o,label:l??eU(i),cwd:i,pid:null,status:"spawning",exitCode:null,startupCommand:s,presetId:a,generation:0};return e({tabs:[...r().tabs,f],activeTabId:o}),o},setTabRunning:(n,i)=>e({tabs:r().tabs.map(s=>s.id===n?{...s,pid:i,status:"running"}:s)}),setTabExited:(n,i)=>e({tabs:r().tabs.map(s=>s.id===n?{...s,status:"exited",exitCode:i}:s)}),closeTab:n=>{var a;window.api.pty.kill(n),window.api.watchers.killTab(n).catch(()=>{}),window.api.transcripts.closeTab(n).catch(()=>{});const i=r().tabs.filter(l=>l.id!==n),s=r().activeTabId===n?((a=i[i.length-1])==null?void 0:a.id)??null:r().activeTabId;e({tabs:i,activeTabId:s})},setActive:n=>e({activeTabId:n}),restartTab:n=>{const i=r().tabs.find(l=>l.id===n);if(!i)return;window.api.pty.kill(n);const s=crypto.randomUUID(),a=l=>{e({tabs:r().tabs.map(o=>o.id===n?{...o,claudeSessionId:s,pid:null,status:"spawning",exitCode:null,startupCommand:l,generation:o.generation+1}:o)})};i.presetId?S5(i.presetId).then(l=>{a(l?k5(l,{sessionId:s,cwd:i.cwd}):`claude --dangerously-skip-permissions --session-id ${Io(s)}`)}):a(`claude --dangerously-skip-permissions --session-id ${Io(s)}`)},reorderTab:(n,i)=>{const s=[...r().tabs];if(n<0||n>=s.length||i<0||i>=s.length||n===i)return;const[a]=s.splice(n,1);s.splice(i,0,a),e({tabs:s})},restoreTabs:(n,i)=>e({tabs:n,activeTabId:i,hydrated:!0})}));async function C5(){var n;if(Jt.getState().hydrated)return;try{const{tabs:i,activeTabId:s,freshStart:a}=await window.api.sessions.load();if(i.length>0){const l=await Promise.all(i.map(async u=>{let f=!a;if(f){const h=await window.api.transcripts.pathFor(u.cwd,u.claudeSessionId);f=await window.api.config.exists(h)}const m=f?u.claudeSessionId:crypto.randomUUID();return{id:u.id,claudeSessionId:m,cwd:u.cwd,label:u.label,presetId:u.presetId,pid:null,status:"spawning",exitCode:null,startupCommand:f?`claude --dangerously-skip-permissions --resume ${Io(m)}`:`claude --dangerously-skip-permissions --session-id ${Io(m)}`,generation:0}})),o=s&&l.find(u=>u.id===s)?s:((n=l[0])==null?void 0:n.id)??null;Jt.getState().restoreTabs(l,o)}else Jt.setState({hydrated:!0})}catch(i){console.warn("[sessions] hydrate failed:",i),Jt.setState({hydrated:!0})}const e=()=>{const{tabs:i,activeTabId:s}=Jt.getState(),a=i.map(l=>({id:l.id,claudeSessionId:l.claudeSessionId,cwd:l.cwd,label:l.label,presetId:l.presetId}));window.api.sessions.save({tabs:a,activeTabId:s}).catch(l=>{console.warn("[sessions] save failed:",l)})};let r=null;Jt.subscribe((i,s)=>{i.hydrated&&(i.tabs===s.tabs&&i.activeTabId===s.activeTabId||(r!==null&&window.clearTimeout(r),r=window.setTimeout(e,200)))}),e()}const tU=Object.freeze(Object.defineProperty({__proto__:null,hydrateSessions:C5,useSessions:Jt},Symbol.toStringTag,{value:"Module"})),rU=5,g$=100,nU=5e3,tj=new Map;function v$(e){const r=tj.get(e);r!==void 0&&(clearTimeout(r),tj.delete(e))}function iU(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`t-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}const vp=Gn((e,r)=>({toasts:[],history:[],unreadCount:0,show:(n,i)=>{const s=iU(),a=Date.now();e(o=>{const u=[...o.toasts,{id:s,kind:n,message:i,createdAt:a}];for(;u.length>rU;){const h=u.shift();h&&v$(h.id)}const m=[{id:s,kind:n,message:i,createdAt:a,read:!1},...o.history];return m.length>g$&&(m.length=g$),{toasts:u,history:m,unreadCount:o.unreadCount+1}});const l=setTimeout(()=>r().dismiss(s),nU);return tj.set(s,l),s},dismiss:n=>{v$(n),e(i=>({toasts:i.toasts.filter(s=>s.id!==n)}))},markAllRead:()=>{e(n=>n.unreadCount===0?n:{history:n.history.map(i=>i.read?i:{...i,read:!0}),unreadCount:0})},clearHistory:()=>{e({history:[],unreadCount:0})},dismissHistoryEntry:n=>{e(i=>{const s=i.history.filter(l=>l.id!==n);if(s.length===i.history.length)return i;const a=i.history.find(l=>l.id===n&&!l.read);return{history:s,unreadCount:a?Math.max(0,i.unreadCount-1):i.unreadCount}})}})),ft={info:e=>vp.getState().show("info",e),warn:e=>vp.getState().show("warn",e),error:e=>vp.getState().show("error",e)},j5=Object.freeze(Object.defineProperty({__proto__:null,toast:ft,useToast:vp},Symbol.toStringTag,{value:"Module"})),y$=200,sU=/\x1b\[[0-9;]*m/g;function aU(e){return e.replace(sU,"")}const zv=Gn((e,r)=>({watchers:{},initialized:!1,init:()=>{r().initialized||(e({initialized:!0}),window.api.watchers.onLine(n=>r().ingestLine(n)),window.api.watchers.onClosed(({watcherId:n})=>r().closed(n)))},add:async({tabId:n,label:i,command:s,cwd:a})=>{try{const l=await window.api.watchers.add({tabId:n,label:i,command:s,cwd:a??null}),o={watcherId:l.watcherId,tabId:l.tabId,label:l.label,command:l.command,cwd:l.cwd,pid:l.pid,startedAt:l.startedAt,lineCount:0,lines:[],lastLineAt:null};return e({watchers:{...r().watchers,[o.watcherId]:o}}),o}catch(l){return console.error("[watchers] add failed:",l),ft.error("Failed to add watcher"),null}},remove:async n=>{try{await window.api.watchers.remove(n)}catch(s){console.error("[watchers] remove failed:",s);const a=s instanceof Error?s.message:String(s);ft.error(`Could not remove watcher: ${a}`)}const i={...r().watchers};delete i[n],e({watchers:i})},watchersForTab:n=>Object.values(r().watchers).filter(i=>i.tabId===n),ingestLine:n=>{const i=r().watchers[n.watcherId];if(!i)return;const s=aU(n.line),a=i.lines.length>=y$?[...i.lines.slice(i.lines.length-y$+1),{line:s,ts:n.ts}]:[...i.lines,{line:s,ts:n.ts}];e({watchers:{...r().watchers,[n.watcherId]:{...i,lines:a,lineCount:i.lineCount+1,lastLineAt:n.ts}}})},closed:n=>{if(!r().watchers[n])return;const i={...r().watchers};delete i[n],e({watchers:i})}})),oU=4,b$=40,x$=6;function lU(e){const{onReorder:r,onActivate:n}=e,i=D.useRef(null),s=D.useRef(null),a=D.useRef(0),l=D.useRef(0),[o,u]=D.useState(!1),[,f]=D.useState(0),m=D.useRef(n);m.current=n;const h=D.useCallback(()=>i.current?Array.from(i.current.querySelectorAll("[data-drag-index]")):[],[]),y=D.useCallback((b,w,S)=>{for(let k=0;k<w.length;k++){const T=w[k].left+w[k].width/2;if(b<T)return k<=S?k:k-1}return w.length-1},[]),x=D.useCallback(()=>{const b=s.current,w=i.current;if(!(b!=null&&b.active)||!w)return;const S=w.getBoundingClientRect(),k=b.startX+b.deltaX,T=k-S.left,j=S.right-k;T<b$?w.scrollLeft-=x$:j<b$&&(w.scrollLeft+=x$),a.current=requestAnimationFrame(x)},[]);D.useEffect(()=>{const b=i.current;if(!b)return;let w=!1;const S=()=>{w||(w=!0,l.current=requestAnimationFrame(()=>{w=!1,f(j=>j+1)}))},k=j=>{var U;const $=s.current;if(!$)return;const P=j.clientX-$.startX;if(!$.active&&Math.abs(P)<oU)return;if(!$.active){$.active=!0,$.tabRects=h().map(V=>V.getBoundingClientRect()),u(!0);try{(U=i.current)==null||U.setPointerCapture($.pointerId)}catch{}a.current=requestAnimationFrame(x)}$.deltaX=P;const N=$.tabRects[$.fromIndex],I=N.left+N.width/2+P;$.currentIndex=y(I,$.tabRects,$.fromIndex),S()},T=j=>{const $=s.current;if($&&$.pointerId===j.pointerId){cancelAnimationFrame(a.current),cancelAnimationFrame(l.current);try{b.releasePointerCapture($.pointerId)}catch{}$.active&&$.fromIndex!==$.currentIndex?r($.fromIndex,$.currentIndex):m.current($.fromIndex),s.current=null,u(!1),f(P=>P+1)}};return b.addEventListener("pointermove",k),b.addEventListener("pointerup",T),b.addEventListener("pointercancel",T),()=>{b.removeEventListener("pointermove",k),b.removeEventListener("pointerup",T),b.removeEventListener("pointercancel",T),cancelAnimationFrame(a.current),cancelAnimationFrame(l.current)}},[r,h,y,x]);const C=D.useCallback((b,w)=>{b.button!==0||b.target.closest("button")||(s.current={active:!1,fromIndex:w,currentIndex:w,startX:b.clientX,deltaX:0,tabRects:[],pointerId:b.pointerId})},[]);return{getTabDragProps:D.useCallback(b=>{var k;const w=s.current,S={};if(w!=null&&w.active)if(b===w.fromIndex)S.transform=`translateX(${w.deltaX}px) scale(1.03)`,S.zIndex=10,S.opacity=.85,S.boxShadow="0 2px 8px rgba(0,0,0,0.4)",S.position="relative",S.pointerEvents="none";else{const T=w.fromIndex,j=w.currentIndex,P=(((k=w.tabRects[T])==null?void 0:k.width)??0)+4;S.transition="transform 0.15s ease",T<j&&b>T&&b<=j?S.transform=`translateX(-${P}px)`:T>j&&b>=j&&b<T?S.transform=`translateX(${P}px)`:S.transform="translateX(0)"}return{onPointerDown:T=>C(T,b),style:S,"data-drag-index":b}},[C]),isDragging:o,containerRef:i}}const cU=3e4;function uU(){const e=Jt(x=>x.tabs),r=Jt(x=>x.activeTabId),n=Jt(x=>x.closeTab),i=Jt(x=>x.setActive),s=Jt(x=>x.reorderTab),a=zv(x=>x.watchers),[l,o]=D.useState(()=>Date.now());D.useEffect(()=>{const x=window.setInterval(()=>o(Date.now()),1e3);return()=>window.clearInterval(x)},[]);const u=x=>{for(const C of Object.values(a))if(C.tabId===x&&C.lastLineAt&&l-C.lastLineAt<cU)return!0;return!1},{getTabDragProps:f,isDragging:m,containerRef:h}=lU({tabCount:e.length,onReorder:s,onActivate:x=>{const C=e[x];C&&i(C.id)}}),y=["#6f7d52","#b85c34","#a39079","#7a8466","#5b4a36"];return c.jsxs("div",{className:"h-11 bg-bg-elev border-b border-line flex items-end px-3 gap-0 shrink-0 relative","data-testid":"tour-tabbar",children:[c.jsx("div",{ref:h,className:`flex items-end gap-0.5 overflow-x-auto min-w-0 flex-1 select-none ${m?"cursor-grabbing":""}`,children:e.map((x,C)=>{const _=x.id===r,b=f(C),w=y[C%y.length];return c.jsxs("div",{...b,style:b.style,className:`group flex items-center gap-2 px-3.5 pt-1.5 pb-2 rounded-t-[10px] text-[13px] shrink-0 transition-colors ${m?"":"cursor-grab"} ${_?"bg-bg text-fg font-medium relative z-10 -mb-px border border-b-0 border-line":"text-fg-dim hover:text-fg hover:bg-bg-hi/40"}`,title:x.cwd,"aria-current":_?"true":void 0,children:[c.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:w,boxShadow:"inset 0 0 0 0.5px rgba(0,0,0,0.15)",opacity:x.status==="spawning"?.55:1}}),c.jsx("span",{className:"truncate max-w-[200px]",children:x.label}),x.status==="spawning"&&c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-butter animate-pulse",title:"spawning"}),u(x.id)&&c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent animate-pulse",title:"watcher emitted a line in the last 30s","data-testid":"tab-watcher-dot"}),c.jsx("button",{onClick:S=>{S.stopPropagation(),n(x.id)},className:"text-fg-faint opacity-0 group-hover:opacity-100 hover:text-fg ml-1 leading-none",title:"Close session","aria-label":`Close ${x.label}`,children:"×"})]},x.id)})}),c.jsxs("div",{className:"flex items-center gap-2 pb-2 pl-3 text-[12px] text-fg-faint shrink-0",children:[c.jsx("span",{className:"font-semibold text-fg-dim",children:"Claude Session Manager"}),c.jsxs("span",{className:"font-mono text-[11px] text-fg-faint",children:["v","0.21.4"]})]})]})}function dU(e,r,n){return r?e.map(i=>i.id===r?{...i,lastActivityAt:n}:i):e}function fU(e,r,n){return{tabId:e,sessionUuid:n,cwd:r,path:null,todos:[],lastToolUses:[],plans:[],agents:[],usage:{inputTokens:0,outputTokens:0},lastEventAt:0,activityRing:[],activitySeq:0}}const s0=Gn((e,r)=>({tabs:{},refs:{},unsubs:{},subscribe:(n,i,s)=>{const a={...r().refs};if(a[n]=(a[n]??0)+1,e({refs:a}),a[n]>1)return;e({tabs:{...r().tabs,[n]:fU(n,i,s)}});const l=window.api.transcripts.onEvent(n,o=>r().ingest(n,o));e({unsubs:{...r().unsubs,[n]:l}}),window.api.transcripts.subscribe({tabId:n,cwd:i,sessionUuid:s}).then(async o=>{const u=r().tabs[n];if(!u)return;if(!o.ok){const{toast:m}=await rm(async()=>{const{toast:h}=await Promise.resolve().then(()=>j5);return{toast:h}},void 0,import.meta.url);m.error(`Live view unavailable: ${o.error??"subscribe failed"}`),e({tabs:{...r().tabs,[n]:{...u,path:null}}});return}e({tabs:{...r().tabs,[n]:{...u,path:o.path}}});const f=await window.api.transcripts.buffer(n);for(const m of f)r().ingest(n,m,{replay:!0})}).catch(o=>console.error("[live] transcripts.subscribe failed:",n,o))},unsubscribe:n=>{const i={...r().refs};if(!i[n])return;if(i[n]--,i[n]>0){e({refs:i});return}delete i[n];const s=r().unsubs[n];s==null||s();const a={...r().unsubs};delete a[n];const l={...r().tabs};delete l[n],window.api.transcripts.unsubscribe(n),e({refs:i,unsubs:a,tabs:l})},ingest:(n,i,s)=>{const a=r().tabs[n];if(!a)return;const l=Date.now(),o={...a,lastEventAt:s!=null&&s.replay?a.lastEventAt:l},u=[],f=(m,h)=>m.length>h?m.slice(0,h-1)+"…":m;switch(i.kind){case"todo_write":{const m=Array.isArray(i.data)?i.data:[];o.todos=m,s!=null&&s.replay||u.push({id:0,kind:"todo-update",at:l,label:`Todos · ${m.length} item${m.length!==1?"s":""}`});break}case"tool_use":{const m=i.data,h=m.input,y={};for(const x of["command","file_path","pattern","url","query","subagent_type","description"])h&&x in h&&(y[x]=h[x]);if(o.lastToolUses=[{id:m.id,name:m.name,input:y,at:l},...a.lastToolUses].slice(0,50),!(s!=null&&s.replay)){const x=m.input,C=["Edit","Write","NotebookEdit"].includes(m.name),_=typeof(x==null?void 0:x.file_path)=="string"?x.file_path:void 0,b=typeof(x==null?void 0:x.command)=="string"?x.command:void 0,w=_?_.split("/").pop()??_:b?f(b,28):"";u.push({id:0,kind:"tool-use",at:l,label:w?`${m.name} · ${w}`:m.name,target:_??b,toolName:m.name}),C&&_&&u.push({id:0,kind:"file-edit",at:l,label:`${m.name} · ${f(_.split("/").pop()??_,34)}`,target:_,toolName:m.name})}break}case"plan":{const m=i.data,h=typeof m=="string"?m:(m==null?void 0:m.plan)??JSON.stringify(m);o.plans=[{at:l,content:h??""},...a.plans].slice(0,50),s!=null&&s.replay||u.push({id:0,kind:"plan-revision",at:l,label:"Plan revised"});break}case"agent_spawn":{const m=i.data;o.agents=[{id:m==null?void 0:m.toolUseId,at:l,subagentType:m==null?void 0:m.subagent_type,description:m==null?void 0:m.description,lastActivityAt:l},...a.agents].slice(0,50),s!=null&&s.replay||u.push({id:0,kind:"agent-spawn",at:l,label:m!=null&&m.subagent_type?`Agent: ${f(m.subagent_type,32)}`:"Agent spawned"});break}case"usage":{const m=i.data,h=(a.usage.inputTokens||0)+(a.usage.outputTokens||0),y=m.input_tokens??m.inputTokens??0,x=m.output_tokens??m.outputTokens??0,C=h+y+x;o.usage={inputTokens:(a.usage.inputTokens||0)+y,outputTokens:(a.usage.outputTokens||0)+x,cacheCreationInputTokens:(a.usage.cacheCreationInputTokens||0)+(m.cache_creation_input_tokens??m.cacheCreationInputTokens??0),cacheReadInputTokens:(a.usage.cacheReadInputTokens||0)+(m.cache_read_input_tokens??m.cacheReadInputTokens??0)},!(s!=null&&s.replay)&&Math.floor(C/1e3)>Math.floor(h/1e3)&&u.push({id:0,kind:"usage-tick",at:l,label:`${Math.floor(C/1e3)}k tokens`});break}case"tool_result":{const m=i.data;o.agents=dU(a.agents,m==null?void 0:m.toolUseId,l);break}}if(u.length>0){let m=a.activitySeq;const h=u.map(y=>({...y,id:++m}));o.activitySeq=m,o.activityRing=[...a.activityRing,...h].slice(-32)}e({tabs:{...r().tabs,[n]:o}})}}));function Uy(e){const r=s0(s=>s.subscribe),n=s0(s=>s.unsubscribe),i=s0(s=>e?s.tabs[e.id]:void 0);return D.useEffect(()=>{if(e)return r(e.id,e.cwd,e.claudeSessionId),()=>n(e.id)},[e==null?void 0:e.id,e==null?void 0:e.cwd,e==null?void 0:e.claudeSessionId,r,n]),i}var n1={},Hg={},w$;function E5(){if(w$)return Hg;w$=1,Object.defineProperty(Hg,"__esModule",{value:!0}),Hg.baseAssetPath=void 0;const r=typeof window<"u"&&typeof window.document<"u"?window.document.currentScript:null;let n="/";return r&&(n=r.src.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^/]+$/,"/")),Hg.baseAssetPath=n,Hg}var Vg={},_$;function pT(){if(_$)return Vg;_$=1,Object.defineProperty(Vg,"__esModule",{value:!0}),Vg.defaultModelFetcher=void 0;const e=r=>fetch(r).then(n=>n.arrayBuffer());return Vg.defaultModelFetcher=e,Vg}var Ql={},Gg={},S$;function qy(){if(S$)return Gg;S$=1,Object.defineProperty(Gg,"__esModule",{value:!0}),Gg.log=void 0;const e=r=>n=>{console.log(`VAD | ${r} >`,n)};return Gg.log={error:e("error"),debug:e("debug"),warn:e("warn")},Gg}var Kg={},k$;function Gw(){if(k$)return Kg;k$=1,Object.defineProperty(Kg,"__esModule",{value:!0}),Kg.Message=void 0;var e;return(function(r){r.AudioFrame="AUDIO_FRAME",r.SpeechStart="SPEECH_START",r.VADMisfire="VAD_MISFIRE",r.SpeechEnd="SPEECH_END",r.SpeechStop="SPEECH_STOP",r.SpeechRealStart="SPEECH_REAL_START",r.FrameProcessed="FRAME_PROCESSED"})(e||(Kg.Message=e={})),Kg}var C$;function mT(){if(C$)return Ql;C$=1,Object.defineProperty(Ql,"__esModule",{value:!0}),Ql.FrameProcessor=Ql.validateOptions=Ql.defaultFrameProcessorOptions=void 0;const e=qy(),r=Gw();Ql.defaultFrameProcessorOptions={positiveSpeechThreshold:.3,negativeSpeechThreshold:.25,preSpeechPadMs:800,redemptionMs:1400,minSpeechMs:400,submitUserSpeechOnPause:!1};function n(l){(l.positiveSpeechThreshold<0||l.positiveSpeechThreshold>1)&&e.log.error("positiveSpeechThreshold should be a number between 0 and 1"),(l.negativeSpeechThreshold<0||l.negativeSpeechThreshold>l.positiveSpeechThreshold)&&e.log.error("negativeSpeechThreshold should be between 0 and positiveSpeechThreshold"),l.preSpeechPadMs<0&&e.log.error("preSpeechPadMs should be positive"),l.redemptionMs<0&&e.log.error("redemptionMs should be positive"),l.minSpeechMs<0&&e.log.error("minSpeechMs should be positive")}Ql.validateOptions=n;const i=l=>{const o=l.reduce((f,m)=>(f.push(f.at(-1)+m.length),f),[0]),u=new Float32Array(o.at(-1));return l.forEach((f,m)=>{const h=o[m];u.set(f,h)}),u};function s(l,o){const u=Math.floor(l.redemptionMs/o),f=Math.floor(l.preSpeechPadMs/o),m=Math.floor(l.minSpeechMs/o);return{redemptionFrames:u,preSpeechPadFrames:f,minSpeechFrames:m}}class a{constructor(o,u,f,m){this.modelProcessFunc=o,this.modelResetFunc=u,this.options=f,this.msPerFrame=m,this.speaking=!1,this.redemptionCounter=0,this.speechFrameCount=0,this.active=!1,this.speechRealStartFired=!1,this.setOptions=C=>{this.options={...this.options,...C};const{redemptionFrames:_,preSpeechPadFrames:b,minSpeechFrames:w}=s(this.options,this.msPerFrame);this.redemptionFrames=_,this.preSpeechPadFrames=b,this.minSpeechFrames=w},this.reset=()=>{this.speaking=!1,this.speechRealStartFired=!1,this.audioBuffer=[],this.modelResetFunc(),this.redemptionCounter=0,this.speechFrameCount=0},this.pause=C=>{this.active=!1,this.options.submitUserSpeechOnPause?this.endSegment(C):this.reset()},this.resume=()=>{this.active=!0},this.endSegment=C=>{const _=this.audioBuffer;this.audioBuffer=[];const b=this.speaking;if(this.reset(),b)if(_.reduce((S,k)=>k.isSpeech?S+1:S,0)>=this.minSpeechFrames){const S=i(_.map(k=>k.frame));C({msg:r.Message.SpeechEnd,audio:S})}else C({msg:r.Message.VADMisfire});return{}},this.process=async(C,_)=>{if(!this.active)return;const b=await this.modelProcessFunc(C),w=b.isSpeech>=this.options.positiveSpeechThreshold;if(_({probs:b,msg:r.Message.FrameProcessed,frame:C}),this.audioBuffer.push({frame:C,isSpeech:w}),w&&(this.speechFrameCount++,this.redemptionCounter=0),w&&!this.speaking&&(this.speaking=!0,_({msg:r.Message.SpeechStart})),this.speaking&&this.speechFrameCount===this.minSpeechFrames&&!this.speechRealStartFired&&(this.speechRealStartFired=!0,_({msg:r.Message.SpeechRealStart})),b.isSpeech<this.options.negativeSpeechThreshold&&this.speaking&&++this.redemptionCounter>=this.redemptionFrames){this.redemptionCounter=0,this.speechFrameCount=0,this.speaking=!1,this.speechRealStartFired=!1;const S=this.audioBuffer;if(this.audioBuffer=[],S.reduce((T,j)=>j.isSpeech?T+1:T,0)>=this.minSpeechFrames){const T=i(S.map(j=>j.frame));_({msg:r.Message.SpeechEnd,audio:T})}else _({msg:r.Message.VADMisfire})}if(!this.speaking){for(;this.audioBuffer.length>this.preSpeechPadFrames;)this.audioBuffer.shift();this.speechFrameCount=0}},this.audioBuffer=[];const{redemptionFrames:h,preSpeechPadFrames:y,minSpeechFrames:x}=s(this.options,this.msPerFrame);this.redemptionFrames=h,this.preSpeechPadFrames=y,this.minSpeechFrames=x,this.reset()}}return Ql.FrameProcessor=a,Ql}var Zl={};function Wa(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var i1={exports:{}};/*!
|
|
42
42
|
* ONNX Runtime Web v1.26.0
|
|
43
43
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
44
44
|
* Licensed under the MIT License.
|
|
@@ -2892,7 +2892,7 @@ ${L}`,W=E.createShaderModule({code:B,label:d.name});hr("verbose",()=>`[WebGPU] $
|
|
|
2892
2892
|
* ONNX Runtime Web v1.26.0
|
|
2893
2893
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2894
2894
|
* Licensed under the MIT License.
|
|
2895
|
-
*/var R$;function bU(){return R$||(R$=1,(function(e,r){var n=(()=>{var i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,l=Object.prototype.hasOwnProperty,o=(ae=>typeof Wa<"u"?Wa:typeof Proxy<"u"?new Proxy(ae,{get:(fe,ye)=>(typeof Wa<"u"?Wa:fe)[ye]}):ae)(function(ae){if(typeof Wa<"u")return Wa.apply(this,arguments);throw Error('Dynamic require of "'+ae+'" is not supported')}),u=(ae,fe)=>()=>(ae&&(fe=ae(ae=0)),fe),f=(ae,fe)=>{for(var ye in fe)i(ae,ye,{get:fe[ye],enumerable:!0})},m=(ae,fe,ye,$e)=>{if(fe&&typeof fe=="object"||typeof fe=="function")for(let je of a(fe))!l.call(ae,je)&&je!==ye&&i(ae,je,{get:()=>fe[je],enumerable:!($e=s(fe,je))||$e.enumerable});return ae},h=ae=>m(i({},"__esModule",{value:!0}),ae),y,x,C,_,b,w=u(()=>{y=new Map,x=[],C=(ae,fe,ye)=>{if(fe&&typeof fe.init=="function"&&typeof fe.createInferenceSessionHandler=="function"){let $e=y.get(ae);if($e===void 0)y.set(ae,{backend:fe,priority:ye});else{if($e.priority>ye)return;if($e.priority===ye&&$e.backend!==fe)throw new Error(`cannot register backend "${ae}" using priority ${ye}`)}if(ye>=0){let je=x.indexOf(ae);je!==-1&&x.splice(je,1);for(let ze=0;ze<x.length;ze++)if(y.get(x[ze]).priority<=ye){x.splice(ze,0,ae);return}x.push(ae)}return}throw new TypeError("not a valid backend")},_=async ae=>{let fe=y.get(ae);if(!fe)return"backend not found.";if(fe.initialized)return fe.backend;if(fe.aborted)return fe.error;{let ye=!!fe.initPromise;try{return ye||(fe.initPromise=fe.backend.init(ae)),await fe.initPromise,fe.initialized=!0,fe.backend}catch($e){return ye||(fe.error=`${$e}`,fe.aborted=!0),fe.error}finally{delete fe.initPromise}}},b=async ae=>{let fe=ae.executionProviders||[],ye=fe.map(Ue=>typeof Ue=="string"?Ue:Ue.name),$e=ye.length===0?x:ye,je,ze=[],Oe=new Set;for(let Ue of $e){let tt=await _(Ue);typeof tt=="string"?ze.push({name:Ue,err:tt}):(je||(je=tt),je===tt&&Oe.add(Ue))}if(!je)throw new Error(`no available backend found. ERR: ${ze.map(Ue=>`[${Ue.name}] ${Ue.err}`).join(", ")}`);for(let{name:Ue,err:tt}of ze)ye.includes(Ue)&&console.warn(`removing requested execution provider "${Ue}" from session options because it is not available: ${tt}`);let Pe=fe.filter(Ue=>Oe.has(typeof Ue=="string"?Ue:Ue.name));return[je,new Proxy(ae,{get:(Ue,tt)=>tt==="executionProviders"?Pe:Reflect.get(Ue,tt)})]}}),S=u(()=>{w()}),k,T=u(()=>{k="1.26.0"}),j,$,P=u(()=>{T(),j="warning",$={wasm:{},webgl:{},webgpu:{},versions:{common:k},set logLevel(ae){if(ae!==void 0){if(typeof ae!="string"||["verbose","info","warning","error","fatal"].indexOf(ae)===-1)throw new Error(`Unsupported logging level: ${ae}`);j=ae}},get logLevel(){return j}},Object.defineProperty($,"logLevel",{enumerable:!0})}),N,I=u(()=>{P(),N=$}),U,V,q=u(()=>{U=(ae,fe)=>{let ye=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);ye.width=ae.dims[3],ye.height=ae.dims[2];let $e=ye.getContext("2d");if($e!=null){let je,ze;(fe==null?void 0:fe.tensorLayout)!==void 0&&fe.tensorLayout==="NHWC"?(je=ae.dims[2],ze=ae.dims[3]):(je=ae.dims[3],ze=ae.dims[2]);let Oe=(fe==null?void 0:fe.format)!==void 0?fe.format:"RGB",Pe=fe==null?void 0:fe.norm,Ue,tt;Pe===void 0||Pe.mean===void 0?Ue=[255,255,255,255]:typeof Pe.mean=="number"?Ue=[Pe.mean,Pe.mean,Pe.mean,Pe.mean]:(Ue=[Pe.mean[0],Pe.mean[1],Pe.mean[2],0],Pe.mean[3]!==void 0&&(Ue[3]=Pe.mean[3])),Pe===void 0||Pe.bias===void 0?tt=[0,0,0,0]:typeof Pe.bias=="number"?tt=[Pe.bias,Pe.bias,Pe.bias,Pe.bias]:(tt=[Pe.bias[0],Pe.bias[1],Pe.bias[2],0],Pe.bias[3]!==void 0&&(tt[3]=Pe.bias[3]));let ot=ze*je,nt=0,Je=ot,Ot=ot*2,Be=-1;Oe==="RGBA"?(nt=0,Je=ot,Ot=ot*2,Be=ot*3):Oe==="RGB"?(nt=0,Je=ot,Ot=ot*2):Oe==="RBG"&&(nt=0,Ot=ot,Je=ot*2);for(let pt=0;pt<ze;pt++)for(let Br=0;Br<je;Br++){let nr=(ae.data[nt++]-tt[0])*Ue[0],ir=(ae.data[Je++]-tt[1])*Ue[1],zr=(ae.data[Ot++]-tt[2])*Ue[2],Ut=Be===-1?255:(ae.data[Be++]-tt[3])*Ue[3];$e.fillStyle="rgba("+nr+","+ir+","+zr+","+Ut+")",$e.fillRect(Br,pt,1,1)}if("toDataURL"in ye)return ye.toDataURL();throw new Error("toDataURL is not supported")}else throw new Error("Can not access image data")},V=(ae,fe)=>{let ye=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),$e;if(ye!=null){let je,ze,Oe;(fe==null?void 0:fe.tensorLayout)!==void 0&&fe.tensorLayout==="NHWC"?(je=ae.dims[2],ze=ae.dims[1],Oe=ae.dims[3]):(je=ae.dims[3],ze=ae.dims[2],Oe=ae.dims[1]);let Pe=fe!==void 0&&fe.format!==void 0?fe.format:"RGB",Ue=fe==null?void 0:fe.norm,tt,ot;Ue===void 0||Ue.mean===void 0?tt=[255,255,255,255]:typeof Ue.mean=="number"?tt=[Ue.mean,Ue.mean,Ue.mean,Ue.mean]:(tt=[Ue.mean[0],Ue.mean[1],Ue.mean[2],255],Ue.mean[3]!==void 0&&(tt[3]=Ue.mean[3])),Ue===void 0||Ue.bias===void 0?ot=[0,0,0,0]:typeof Ue.bias=="number"?ot=[Ue.bias,Ue.bias,Ue.bias,Ue.bias]:(ot=[Ue.bias[0],Ue.bias[1],Ue.bias[2],0],Ue.bias[3]!==void 0&&(ot[3]=Ue.bias[3]));let nt=ze*je;if(fe!==void 0&&(fe.format!==void 0&&Oe===4&&fe.format!=="RGBA"||Oe===3&&fe.format!=="RGB"&&fe.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let Je=4,Ot=0,Be=1,pt=2,Br=3,nr=0,ir=nt,zr=nt*2,Ut=-1;Pe==="RGBA"?(nr=0,ir=nt,zr=nt*2,Ut=nt*3):Pe==="RGB"?(nr=0,ir=nt,zr=nt*2):Pe==="RBG"&&(nr=0,zr=nt,ir=nt*2),$e=ye.createImageData(je,ze);for(let Hr=0;Hr<ze*je;Ot+=Je,Be+=Je,pt+=Je,Br+=Je,Hr++)$e.data[Ot]=(ae.data[nr++]-ot[0])*tt[0],$e.data[Be]=(ae.data[ir++]-ot[1])*tt[1],$e.data[pt]=(ae.data[zr++]-ot[2])*tt[2],$e.data[Br]=Ut===-1?255:(ae.data[Ut++]-ot[3])*tt[3]}else throw new Error("Can not access image data");return $e}}),F,z,G,Y,oe,te,J=u(()=>{ve(),F=(ae,fe)=>{if(ae===void 0)throw new Error("Image buffer must be defined");if(fe.height===void 0||fe.width===void 0)throw new Error("Image height and width must be defined");if(fe.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");let{height:ye,width:$e}=fe,je=fe.norm??{mean:255,bias:0},ze,Oe;typeof je.mean=="number"?ze=[je.mean,je.mean,je.mean,je.mean]:ze=[je.mean[0],je.mean[1],je.mean[2],je.mean[3]??255],typeof je.bias=="number"?Oe=[je.bias,je.bias,je.bias,je.bias]:Oe=[je.bias[0],je.bias[1],je.bias[2],je.bias[3]??0];let Pe=fe.format!==void 0?fe.format:"RGBA",Ue=fe.tensorFormat!==void 0&&fe.tensorFormat!==void 0?fe.tensorFormat:"RGB",tt=ye*$e,ot=Ue==="RGBA"?new Float32Array(tt*4):new Float32Array(tt*3),nt=4,Je=0,Ot=1,Be=2,pt=3,Br=0,nr=tt,ir=tt*2,zr=-1;Pe==="RGB"&&(nt=3,Je=0,Ot=1,Be=2,pt=-1),Ue==="RGBA"?zr=tt*3:Ue==="RBG"?(Br=0,ir=tt,nr=tt*2):Ue==="BGR"&&(ir=0,nr=tt,Br=tt*2);for(let Ut=0;Ut<tt;Ut++,Je+=nt,Be+=nt,Ot+=nt,pt+=nt)ot[Br++]=(ae[Je]+Oe[0])/ze[0],ot[nr++]=(ae[Ot]+Oe[1])/ze[1],ot[ir++]=(ae[Be]+Oe[2])/ze[2],zr!==-1&&pt!==-1&&(ot[zr++]=(ae[pt]+Oe[3])/ze[3]);return Ue==="RGBA"?new se("float32",ot,[1,4,ye,$e]):new se("float32",ot,[1,3,ye,$e])},z=async(ae,fe)=>{let ye=typeof HTMLImageElement<"u"&&ae instanceof HTMLImageElement,$e=typeof ImageData<"u"&&ae instanceof ImageData,je=typeof ImageBitmap<"u"&&ae instanceof ImageBitmap,ze=typeof ae=="string",Oe,Pe=fe??{},Ue=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},tt=ot=>typeof HTMLCanvasElement<"u"&&ot instanceof HTMLCanvasElement||ot instanceof OffscreenCanvas?ot.getContext("2d"):null;if(ye){let ot=Ue();ot.width=ae.width,ot.height=ae.height;let nt=tt(ot);if(nt!=null){let Je=ae.height,Ot=ae.width;if(fe!==void 0&&fe.resizedHeight!==void 0&&fe.resizedWidth!==void 0&&(Je=fe.resizedHeight,Ot=fe.resizedWidth),fe!==void 0){if(Pe=fe,fe.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");Pe.tensorFormat="RGBA",Pe.height=Je,Pe.width=Ot}else Pe.tensorFormat="RGBA",Pe.height=Je,Pe.width=Ot;nt.drawImage(ae,0,0),Oe=nt.getImageData(0,0,Ot,Je).data}else throw new Error("Can not access image data")}else if($e){let ot,nt;if(fe!==void 0&&fe.resizedWidth!==void 0&&fe.resizedHeight!==void 0?(ot=fe.resizedHeight,nt=fe.resizedWidth):(ot=ae.height,nt=ae.width),fe!==void 0&&(Pe=fe),Pe.format="RGBA",Pe.height=ot,Pe.width=nt,fe!==void 0){let Je=Ue();Je.width=nt,Je.height=ot;let Ot=tt(Je);if(Ot!=null)Ot.putImageData(ae,0,0),Oe=Ot.getImageData(0,0,nt,ot).data;else throw new Error("Can not access image data")}else Oe=ae.data}else if(je){if(fe===void 0)throw new Error("Please provide image config with format for Imagebitmap");let ot=Ue();ot.width=ae.width,ot.height=ae.height;let nt=tt(ot);if(nt!=null){let Je=ae.height,Ot=ae.width;return nt.drawImage(ae,0,0,Ot,Je),Oe=nt.getImageData(0,0,Ot,Je).data,Pe.height=Je,Pe.width=Ot,F(Oe,Pe)}else throw new Error("Can not access image data")}else{if(ze)return new Promise((ot,nt)=>{let Je=Ue(),Ot=tt(Je);if(!ae||!Ot)return nt();let Be=new Image;Be.crossOrigin="Anonymous",Be.src=ae,Be.onload=()=>{Je.width=Be.width,Je.height=Be.height,Ot.drawImage(Be,0,0,Je.width,Je.height);let pt=Ot.getImageData(0,0,Je.width,Je.height);Pe.height=Je.height,Pe.width=Je.width,ot(F(pt.data,Pe))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(Oe!==void 0)return F(Oe,Pe);throw new Error("Input data provided is not supported - aborted tensor creation")},G=(ae,fe)=>{let{width:ye,height:$e,download:je,dispose:ze}=fe,Oe=[1,$e,ye,4];return new se({location:"texture",type:"float32",texture:ae,dims:Oe,download:je,dispose:ze})},Y=(ae,fe)=>{let{dataType:ye,dims:$e,download:je,dispose:ze}=fe;return new se({location:"gpu-buffer",type:ye??"float32",gpuBuffer:ae,dims:$e,download:je,dispose:ze})},oe=(ae,fe)=>{let{dataType:ye,dims:$e,download:je,dispose:ze}=fe;return new se({location:"ml-tensor",type:ye??"float32",mlTensor:ae,dims:$e,download:je,dispose:ze})},te=(ae,fe,ye)=>new se({location:"cpu-pinned",type:ae,data:fe,dims:ye??[fe.length]})}),K,Z,re,he,we=u(()=>{K=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),Z=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),re=!1,he=()=>{if(!re){re=!0;let ae=typeof BigInt64Array<"u"&&BigInt64Array.from,fe=typeof BigUint64Array<"u"&&BigUint64Array.from,ye=globalThis.Float16Array,$e=typeof ye<"u"&&ye.from;ae&&(K.set("int64",BigInt64Array),Z.set(BigInt64Array,"int64")),fe&&(K.set("uint64",BigUint64Array),Z.set(BigUint64Array,"uint64")),$e?(K.set("float16",ye),Z.set(ye,"float16")):K.set("float16",Uint16Array)}}}),Ce,Me,be=u(()=>{ve(),Ce=ae=>{let fe=1;for(let ye=0;ye<ae.length;ye++){let $e=ae[ye];if(typeof $e!="number"||!Number.isSafeInteger($e))throw new TypeError(`dims[${ye}] must be an integer, got: ${$e}`);if($e<0)throw new RangeError(`dims[${ye}] must be a non-negative integer, got: ${$e}`);fe*=$e}return fe},Me=(ae,fe)=>{switch(ae.location){case"cpu":return new se(ae.type,ae.data,fe);case"cpu-pinned":return new se({location:"cpu-pinned",data:ae.data,type:ae.type,dims:fe});case"texture":return new se({location:"texture",texture:ae.texture,type:ae.type,dims:fe});case"gpu-buffer":return new se({location:"gpu-buffer",gpuBuffer:ae.gpuBuffer,type:ae.type,dims:fe});case"ml-tensor":return new se({location:"ml-tensor",mlTensor:ae.mlTensor,type:ae.type,dims:fe});default:throw new Error(`tensorReshape: tensor location ${ae.location} is not supported`)}}}),se,ve=u(()=>{q(),J(),we(),be(),se=class{constructor(ae,fe,ye){he();let $e,je;if(typeof ae=="object"&&"location"in ae)switch(this.dataLocation=ae.location,$e=ae.type,je=ae.dims,ae.location){case"cpu-pinned":{let Oe=K.get($e);if(!Oe)throw new TypeError(`unsupported type "${$e}" to create tensor from pinned buffer`);if(!(ae.data instanceof Oe))throw new TypeError(`buffer should be of type ${Oe.name}`);this.cpuData=ae.data;break}case"texture":{if($e!=="float32")throw new TypeError(`unsupported type "${$e}" to create tensor from texture`);this.gpuTextureData=ae.texture,this.downloader=ae.download,this.disposer=ae.dispose;break}case"gpu-buffer":{if($e!=="float32"&&$e!=="float16"&&$e!=="int32"&&$e!=="int64"&&$e!=="uint32"&&$e!=="uint8"&&$e!=="bool"&&$e!=="uint4"&&$e!=="int4")throw new TypeError(`unsupported type "${$e}" to create tensor from gpu buffer`);this.gpuBufferData=ae.gpuBuffer,this.downloader=ae.download,this.disposer=ae.dispose;break}case"ml-tensor":{if($e!=="float32"&&$e!=="float16"&&$e!=="int32"&&$e!=="int64"&&$e!=="uint32"&&$e!=="uint64"&&$e!=="int8"&&$e!=="uint8"&&$e!=="bool"&&$e!=="uint4"&&$e!=="int4")throw new TypeError(`unsupported type "${$e}" to create tensor from MLTensor`);this.mlTensorData=ae.mlTensor,this.downloader=ae.download,this.disposer=ae.dispose;break}default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let Oe,Pe;if(typeof ae=="string")if($e=ae,Pe=ye,ae==="string"){if(!Array.isArray(fe))throw new TypeError("A string tensor's data must be a string array.");Oe=fe}else{let Ue=K.get(ae);if(Ue===void 0)throw new TypeError(`Unsupported tensor type: ${ae}.`);if(Array.isArray(fe)){if(ae==="float16"&&Ue===Uint16Array||ae==="uint4"||ae==="int4")throw new TypeError(`Creating a ${ae} tensor from number array is not supported. Please use ${Ue.name} as data.`);ae==="uint64"||ae==="int64"?Oe=Ue.from(fe,BigInt):Oe=Ue.from(fe)}else if(fe instanceof Ue)Oe=fe;else if(fe instanceof Uint8ClampedArray)if(ae==="uint8")Oe=Uint8Array.from(fe);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else if(ae==="float16"&&fe instanceof Uint16Array&&Ue!==Uint16Array)Oe=new globalThis.Float16Array(fe.buffer,fe.byteOffset,fe.length);else throw new TypeError(`A ${$e} tensor's data must be type of ${Ue}`)}else if(Pe=fe,Array.isArray(ae)){if(ae.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let Ue=typeof ae[0];if(Ue==="string")$e="string",Oe=ae;else if(Ue==="boolean")$e="bool",Oe=Uint8Array.from(ae);else throw new TypeError(`Invalid element type of data array: ${Ue}.`)}else if(ae instanceof Uint8ClampedArray)$e="uint8",Oe=Uint8Array.from(ae);else{let Ue=Z.get(ae.constructor);if(Ue===void 0)throw new TypeError(`Unsupported type for tensor data: ${ae.constructor}.`);$e=Ue,Oe=ae}if(Pe===void 0)Pe=[Oe.length];else if(!Array.isArray(Pe))throw new TypeError("A tensor's dims must be a number array");je=Pe,this.cpuData=Oe,this.dataLocation="cpu"}let ze=Ce(je);if(this.cpuData&&ze!==this.cpuData.length&&!(($e==="uint4"||$e==="int4")&&Math.ceil(ze/2)===this.cpuData.length))throw new Error(`Tensor's size(${ze}) does not match data length(${this.cpuData.length}).`);this.type=$e,this.dims=je,this.size=ze}static async fromImage(ae,fe){return z(ae,fe)}static fromTexture(ae,fe){return G(ae,fe)}static fromGpuBuffer(ae,fe){return Y(ae,fe)}static fromMLTensor(ae,fe){return oe(ae,fe)}static fromPinnedBuffer(ae,fe,ye){return te(ae,fe,ye)}toDataURL(ae){return U(this,ae)}toImageData(ae){return V(this,ae)}get data(){if(this.ensureValid(),!this.cpuData)throw new Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");return this.cpuData}get location(){return this.dataLocation}get texture(){if(this.ensureValid(),!this.gpuTextureData)throw new Error("The data is not stored as a WebGL texture.");return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw new Error("The data is not stored as a WebGPU buffer.");return this.gpuBufferData}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw new Error("The data is not stored as a WebNN MLTensor.");return this.mlTensorData}async getData(ae){switch(this.ensureValid(),this.dataLocation){case"cpu":case"cpu-pinned":return this.data;case"texture":case"gpu-buffer":case"ml-tensor":{if(!this.downloader)throw new Error("The current tensor is not created with a specified data downloader.");if(this.isDownloading)throw new Error("The current tensor is being downloaded.");try{this.isDownloading=!0;let fe=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=fe,ae&&this.disposer&&(this.disposer(),this.disposer=void 0),fe}finally{this.isDownloading=!1}}default:throw new Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw new Error("The current tensor is being downloaded.");this.disposer&&(this.disposer(),this.disposer=void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.mlTensorData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation="none"}ensureValid(){if(this.dataLocation==="none")throw new Error("The tensor is disposed.")}reshape(ae){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return Me(this,ae)}}}),xe,Ve=u(()=>{ve(),xe=se}),Re,We,Le,Ze,ct,ut,dr=u(()=>{P(),Re=(ae,fe)=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||console.timeStamp(`${ae}::ORT::${fe}`)},We=(ae,fe)=>{var je;let ye=((je=new Error().stack)==null?void 0:je.split(/\r\n|\r|\n/g))||[],$e=!1;for(let ze=0;ze<ye.length;ze++){if($e&&!ye[ze].includes("TRACE_FUNC")){let Oe=`FUNC_${ae}::${ye[ze].trim().split(" ")[1]}`;fe&&(Oe+=`::${fe}`),Re("CPU",Oe);return}ye[ze].includes("TRACE_FUNC")&&($e=!0)}},Le=ae=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||We("BEGIN",ae)},Ze=ae=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||We("END",ae)},ct=ae=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||console.time(`ORT::${ae}`)},ut=ae=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||console.timeEnd(`ORT::${ae}`)}}),Xt,Qt=u(()=>{w(),Ve(),dr(),Xt=class O5{constructor(fe){this.handler=fe}async run(fe,ye,$e){Le(),ct("InferenceSession.run");let je={},ze={};if(typeof fe!="object"||fe===null||fe instanceof xe||Array.isArray(fe))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let Oe=!0;if(typeof ye=="object"){if(ye===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(ye instanceof xe)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(ye)){if(ye.length===0)throw new TypeError("'fetches' cannot be an empty array.");Oe=!1;for(let tt of ye){if(typeof tt!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(tt)===-1)throw new RangeError(`'fetches' contains invalid output name: ${tt}.`);je[tt]=null}if(typeof $e=="object"&&$e!==null)ze=$e;else if(typeof $e<"u")throw new TypeError("'options' must be an object.")}else{let tt=!1,ot=Object.getOwnPropertyNames(ye);for(let nt of this.outputNames)if(ot.indexOf(nt)!==-1){let Je=ye[nt];(Je===null||Je instanceof xe)&&(tt=!0,Oe=!1,je[nt]=Je)}if(tt){if(typeof $e=="object"&&$e!==null)ze=$e;else if(typeof $e<"u")throw new TypeError("'options' must be an object.")}else ze=ye}}else if(typeof ye<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let tt of this.inputNames)if(typeof fe[tt]>"u")throw new Error(`input '${tt}' is missing in 'feeds'.`);if(Oe)for(let tt of this.outputNames)je[tt]=null;let Pe=await this.handler.run(fe,je,ze),Ue={};for(let tt in Pe)if(Object.hasOwnProperty.call(Pe,tt)){let ot=Pe[tt];ot instanceof xe?Ue[tt]=ot:Ue[tt]=new xe(ot.type,ot.data,ot.dims)}return ut("InferenceSession.run"),Ze(),Ue}async release(){return this.handler.dispose()}static async create(fe,ye,$e,je){Le(),ct("InferenceSession.create");let ze,Oe={};if(typeof fe=="string"){if(ze=fe,typeof ye=="object"&&ye!==null)Oe=ye;else if(typeof ye<"u")throw new TypeError("'options' must be an object.")}else if(fe instanceof Uint8Array){if(ze=fe,typeof ye=="object"&&ye!==null)Oe=ye;else if(typeof ye<"u")throw new TypeError("'options' must be an object.")}else if(fe instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&fe instanceof SharedArrayBuffer){let ot=fe,nt=0,Je=fe.byteLength;if(typeof ye=="object"&&ye!==null)Oe=ye;else if(typeof ye=="number"){if(nt=ye,!Number.isSafeInteger(nt))throw new RangeError("'byteOffset' must be an integer.");if(nt<0||nt>=ot.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${ot.byteLength}).`);if(Je=fe.byteLength-nt,typeof $e=="number"){if(Je=$e,!Number.isSafeInteger(Je))throw new RangeError("'byteLength' must be an integer.");if(Je<=0||nt+Je>ot.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${ot.byteLength-nt}].`);if(typeof je=="object"&&je!==null)Oe=je;else if(typeof je<"u")throw new TypeError("'options' must be an object.")}else if(typeof $e<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof ye<"u")throw new TypeError("'options' must be an object.");ze=new Uint8Array(ot,nt,Je)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[Pe,Ue]=await b(Oe),tt=await Pe.createInferenceSessionHandler(ze,Ue);return ut("InferenceSession.create"),Ze(),new O5(tt)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}get inputMetadata(){return this.handler.inputMetadata}get outputMetadata(){return this.handler.outputMetadata}}}),cr,Or=u(()=>{Qt(),cr=Xt}),wr=u(()=>{}),sn=u(()=>{}),Wr=u(()=>{}),ii=u(()=>{}),Kn={};f(Kn,{InferenceSession:()=>cr,TRACE:()=>Re,TRACE_EVENT_BEGIN:()=>ct,TRACE_EVENT_END:()=>ut,TRACE_FUNC_BEGIN:()=>Le,TRACE_FUNC_END:()=>Ze,Tensor:()=>xe,env:()=>N,registerBackend:()=>C});var mr=u(()=>{S(),I(),Or(),Ve(),wr(),sn(),dr(),Wr(),ii()}),vt=u(()=>{}),jt={};f(jt,{default:()=>Ir});var It,Pt,Ir,yi=u(()=>{var ae;Al(),bi(),pn(),It="ort-wasm-proxy-worker",Pt=((ae=globalThis.self)==null?void 0:ae.name)===It,Pt&&(self.onmessage=fe=>{let{type:ye,in:$e}=fe.data;try{switch(ye){case"init-wasm":us($e.wasm).then(()=>{Jn($e).then(()=>{postMessage({type:ye})},je=>{postMessage({type:ye,err:je})})},je=>{postMessage({type:ye,err:je})});break;case"init-ep":{let{epName:je,env:ze}=$e;fs(ze,je).then(()=>{postMessage({type:ye})},Oe=>{postMessage({type:ye,err:Oe})});break}case"copy-from":{let{buffer:je}=$e,ze=hr(je);postMessage({type:ye,out:ze});break}case"create":{let{model:je,options:ze}=$e;ps(je,ze).then(Oe=>{postMessage({type:ye,out:Oe})},Oe=>{postMessage({type:ye,err:Oe})});break}case"release":Uo($e),postMessage({type:ye});break;case"run":{let{sessionId:je,inputIndices:ze,inputs:Oe,outputIndices:Pe,options:Ue}=$e;Qe(je,ze,Oe,Pe,new Array(Pe.length).fill(null),Ue).then(tt=>{tt.some(ot=>ot[3]!=="cpu")?postMessage({type:ye,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:ye,out:tt},$c([...Oe,...tt]))},tt=>{postMessage({type:ye,err:tt})});break}case"end-profiling":Is($e),postMessage({type:ye});break;default:}}catch(je){postMessage({type:ye,err:je})}}),Ir=Pt?null:fe=>new Worker(fe??Cr,{type:"classic",name:It})}),Sa,Ii,Cr,si,In,Ge,rt,$t,ur,Pr,Yr,an,Di,pn=u(()=>{vt(),Sa=typeof location>"u"?void 0:location.origin,Ii=()=>{var ae,fe;return typeof document<"u"?(ae=document.currentScript)==null?void 0:ae.src:typeof self<"u"?(fe=self.location)==null?void 0:fe.href:void 0},Cr=Ii(),si=()=>{if(Cr&&!Cr.startsWith("blob:"))return Cr.substring(0,Cr.lastIndexOf("/")+1)},In=(ae,fe)=>{try{let ye=fe??Cr;return(ye?new URL(ae,ye):new URL(ae)).origin===Sa}catch{return!1}},Ge=(ae,fe)=>{let ye=fe??Cr;try{return(ye?new URL(ae,ye):new URL(ae)).href}catch{return}},rt=(ae,fe)=>`${fe??"./"}${ae}`,$t=async ae=>{let fe=await(await fetch(ae,{credentials:"same-origin"})).blob();return URL.createObjectURL(fe)},ur=async ae=>(await import(ae)).default,Pr=(yi(),h(jt)).default,Yr=async()=>{if(!Cr)throw new Error("Failed to load proxy worker: cannot determine the script source URL.");if(In(Cr))return[void 0,Pr()];let ae=await $t(Cr);return[ae,Pr(ae)]},an=void 0,Di=async(ae,fe,ye,$e)=>{let je=an&&!(ae||fe);if(je)if(Cr)je=In(Cr)||$e&&!ye;else if($e&&!ye)je=!0;else throw new Error("cannot determine the script source URL.");if(je)return[void 0,an];{let ze="ort-wasm-simd-threaded.mjs",Oe=ae??Ge(ze,fe),Pe=ye&&Oe&&!In(Oe,fe),Ue=Pe?await $t(Oe):Oe??rt(ze,fe);return[Pe?Ue:void 0,await ur(Ue)]}}}),es,Li,_r,Xn,El,Ps,Rs,us,Kt,bi=u(()=>{pn(),Li=!1,_r=!1,Xn=!1,El=()=>{if(typeof SharedArrayBuffer>"u")return!1;try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch{return!1}},Ps=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch{return!1}},Rs=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,19,1,17,0,65,1,253,15,65,2,253,15,65,3,253,15,253,147,2,11]))}catch{return!1}},us=async ae=>{if(Li)return Promise.resolve();if(_r)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(Xn)throw new Error("previous call to 'initializeWebAssembly()' failed.");_r=!0;let fe=ae.initTimeout,ye=ae.numThreads;if(ae.simd!==!1){if(ae.simd==="relaxed"){if(!Rs())throw new Error("Relaxed WebAssembly SIMD is not supported in the current environment.")}else if(!Ps())throw new Error("WebAssembly SIMD is not supported in the current environment.")}let $e=El();ye>1&&!$e&&(typeof self<"u"&&!self.crossOriginIsolated&&console.warn("env.wasm.numThreads is set to "+ye+", but this will not work unless you enable crossOriginIsolated mode. See https://web.dev/cross-origin-isolation-guide/ for more info."),console.warn("WebAssembly multi-threading is not supported in the current environment. Falling back to single-threading."),ae.numThreads=ye=1);let je=ae.wasmPaths,ze=typeof je=="string"?je:void 0,Oe=je==null?void 0:je.mjs,Pe=(Oe==null?void 0:Oe.href)??Oe,Ue=je==null?void 0:je.wasm,tt=(Ue==null?void 0:Ue.href)??Ue,ot=ae.wasmBinary,[nt,Je]=await Di(Pe,ze,ye>1,!!ot||!!tt),Ot=!1,Be=[];if(fe>0&&Be.push(new Promise(pt=>{setTimeout(()=>{Ot=!0,pt()},fe)})),Be.push(new Promise((pt,Br)=>{let nr={numThreads:ye};if(ot)nr.wasmBinary=ot,nr.locateFile=ir=>ir;else if(tt||ze)nr.locateFile=ir=>tt??ze+ir;else if(Pe&&Pe.indexOf("blob:")!==0)nr.locateFile=ir=>new URL(ir,Pe).href;else if(nt){let ir=si();ir&&(nr.locateFile=zr=>ir+zr)}Je(nr).then(ir=>{_r=!1,Li=!0,es=ir,pt(),nt&&URL.revokeObjectURL(nt)},ir=>{_r=!1,Xn=!0,Br(ir)})})),await Promise.race(Be),Ot)throw new Error(`WebAssembly backend initializing failed due to timeout: ${fe}ms`)},Kt=()=>{if(Li&&es)return es;throw new Error("WebAssembly is not initialized yet.")}}),Sr,ai,Nt,ea=u(()=>{bi(),Sr=(ae,fe)=>{let ye=Kt(),$e=ye.lengthBytesUTF8(ae)+1,je=ye._malloc($e);return ye.stringToUTF8(ae,je,$e),fe.push(je),je},ai=(ae,fe,ye,$e)=>{if(typeof ae=="object"&&ae!==null){if(ye.has(ae))throw new Error("Circular reference in options");ye.add(ae)}Object.entries(ae).forEach(([je,ze])=>{let Oe=fe?fe+je:je;if(typeof ze=="object")ai(ze,Oe+".",ye,$e);else if(typeof ze=="string"||typeof ze=="number")$e(Oe,ze.toString());else if(typeof ze=="boolean")$e(Oe,ze?"1":"0");else throw new Error(`Can't handle extra config type: ${typeof ze}`)})},Nt=ae=>{let fe=Kt(),ye=fe.stackSave();try{let $e=fe.PTR_SIZE,je=fe.stackAlloc(2*$e);fe._OrtGetLastError(je,je+$e);let ze=Number(fe.getValue(je,$e===4?"i32":"i64")),Oe=fe.getValue(je+$e,"*"),Pe=Oe?fe.UTF8ToString(Oe):"";throw new Error(`${ae} ERROR_CODE: ${ze}, ERROR_MESSAGE: ${Pe}`)}finally{fe.stackRestore(ye)}}}),ka,zo=u(()=>{bi(),ea(),ka=ae=>{let fe=Kt(),ye=0,$e=[],je=ae||{};try{if((ae==null?void 0:ae.logSeverityLevel)===void 0)je.logSeverityLevel=2;else if(typeof ae.logSeverityLevel!="number"||!Number.isInteger(ae.logSeverityLevel)||ae.logSeverityLevel<0||ae.logSeverityLevel>4)throw new Error(`log severity level is not valid: ${ae.logSeverityLevel}`);if((ae==null?void 0:ae.logVerbosityLevel)===void 0)je.logVerbosityLevel=0;else if(typeof ae.logVerbosityLevel!="number"||!Number.isInteger(ae.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${ae.logVerbosityLevel}`);(ae==null?void 0:ae.terminate)===void 0&&(je.terminate=!1);let ze=0;return(ae==null?void 0:ae.tag)!==void 0&&(ze=Sr(ae.tag,$e)),ye=fe._OrtCreateRunOptions(je.logSeverityLevel,je.logVerbosityLevel,!!je.terminate,ze),ye===0&&Nt("Can't create run options."),(ae==null?void 0:ae.extra)!==void 0&&ai(ae.extra,"",new WeakSet,(Oe,Pe)=>{let Ue=Sr(Oe,$e),tt=Sr(Pe,$e);fe._OrtAddRunConfigEntry(ye,Ue,tt)!==0&&Nt(`Can't set a run config entry: ${Oe} - ${Pe}.`)}),[ye,$e]}catch(ze){throw ye!==0&&fe._OrtReleaseRunOptions(ye),$e.forEach(Oe=>fe._free(Oe)),ze}}}),ds,ta,xi,Dn,Fo,Tl,Jr=u(()=>{bi(),ea(),ds=ae=>{switch(ae){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"layout":return 3;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${ae}`)}},ta=ae=>{switch(ae){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${ae}`)}},xi=ae=>{ae.extra||(ae.extra={}),ae.extra.session||(ae.extra.session={});let fe=ae.extra.session;fe.use_ort_model_bytes_directly||(fe.use_ort_model_bytes_directly="1"),ae.executionProviders&&ae.executionProviders.some(ye=>(typeof ye=="string"?ye:ye.name)==="webgpu")&&(ae.enableMemPattern=!1)},Dn=(ae,fe,ye,$e)=>{let je=Sr(fe,$e),ze=Sr(ye,$e);Kt()._OrtAddSessionConfigEntry(ae,je,ze)!==0&&Nt(`Can't set a session config entry: ${fe} - ${ye}.`)},Fo=async(ae,fe,ye)=>{let $e=fe.executionProviders;for(let je of $e){let ze=typeof je=="string"?je:je.name,Oe=[];switch(ze){case"webnn":if(ze="WEBNN",Dn(ae,"session.disable_quant_qdq","1",ye),Dn(ae,"session.disable_qdq_constant_folding","1",ye),typeof je!="string"){let nt=je==null?void 0:je.deviceType;nt&&Dn(ae,"deviceType",nt,ye)}break;case"webgpu":if(ze="JS",typeof je!="string"){let nt=je;if(nt!=null&&nt.preferredLayout){if(nt.preferredLayout!=="NCHW"&&nt.preferredLayout!=="NHWC")throw new Error(`preferredLayout must be either 'NCHW' or 'NHWC': ${nt.preferredLayout}`);Dn(ae,"preferredLayout",nt.preferredLayout,ye)}}break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${ze}`)}let Pe=Sr(ze,ye),Ue=Oe.length,tt=0,ot=0;if(Ue>0){tt=Kt()._malloc(Ue*Kt().PTR_SIZE),ye.push(tt),ot=Kt()._malloc(Ue*Kt().PTR_SIZE),ye.push(ot);for(let nt=0;nt<Ue;nt++)Kt().setValue(tt+nt*Kt().PTR_SIZE,Oe[nt][0],"*"),Kt().setValue(ot+nt*Kt().PTR_SIZE,Oe[nt][1],"*")}await Kt()._OrtAppendExecutionProvider(ae,Pe,tt,ot,Ue)!==0&&Nt(`Can't append execution provider: ${ze}.`)}},Tl=async ae=>{let fe=Kt(),ye=0,$e=[],je=ae||{};xi(je);try{let ze=ds(je.graphOptimizationLevel??"all"),Oe=ta(je.executionMode??"sequential"),Pe=typeof je.logId=="string"?Sr(je.logId,$e):0,Ue=je.logSeverityLevel??2;if(!Number.isInteger(Ue)||Ue<0||Ue>4)throw new Error(`log severity level is not valid: ${Ue}`);let tt=je.logVerbosityLevel??0;if(!Number.isInteger(tt)||tt<0||tt>4)throw new Error(`log verbosity level is not valid: ${tt}`);let ot=typeof je.optimizedModelFilePath=="string"?Sr(je.optimizedModelFilePath,$e):0;if(ye=fe._OrtCreateSessionOptions(ze,!!je.enableCpuMemArena,!!je.enableMemPattern,Oe,!!je.enableProfiling,0,Pe,Ue,tt,ot),ye===0&&Nt("Can't create session options."),je.executionProviders&&await Fo(ye,je,$e),je.enableGraphCapture!==void 0){if(typeof je.enableGraphCapture!="boolean")throw new Error(`enableGraphCapture must be a boolean value: ${je.enableGraphCapture}`);Dn(ye,"enableGraphCapture",je.enableGraphCapture.toString(),$e)}if(je.freeDimensionOverrides)for(let[nt,Je]of Object.entries(je.freeDimensionOverrides)){if(typeof nt!="string")throw new Error(`free dimension override name must be a string: ${nt}`);if(typeof Je!="number"||!Number.isInteger(Je)||Je<0)throw new Error(`free dimension override value must be a non-negative integer: ${Je}`);let Ot=Sr(nt,$e);fe._OrtAddFreeDimensionOverride(ye,Ot,Je)!==0&&Nt(`Can't set a free dimension override: ${nt} - ${Je}.`)}return je.extra!==void 0&&ai(je.extra,"",new WeakSet,(nt,Je)=>{Dn(ye,nt,Je,$e)}),[ye,$e]}catch(ze){throw ye!==0&&fe._OrtReleaseSessionOptions(ye)!==0&&Nt("Can't release session options."),$e.forEach(Oe=>fe._free(Oe)),ze}}}),oi,kn,bn,Et,_e,it,_t,lr,mt=u(()=>{oi=ae=>{switch(ae){case"int8":return 3;case"uint8":return 2;case"bool":return 9;case"int16":return 5;case"uint16":return 4;case"int32":return 6;case"uint32":return 12;case"float16":return 10;case"float32":return 1;case"float64":return 11;case"string":return 8;case"int64":return 7;case"uint64":return 13;case"int4":return 22;case"uint4":return 21;default:throw new Error(`unsupported data type: ${ae}`)}},kn=ae=>{switch(ae){case 3:return"int8";case 2:return"uint8";case 9:return"bool";case 5:return"int16";case 4:return"uint16";case 6:return"int32";case 12:return"uint32";case 10:return"float16";case 1:return"float32";case 11:return"float64";case 8:return"string";case 7:return"int64";case 13:return"uint64";case 22:return"int4";case 21:return"uint4";default:throw new Error(`unsupported data type: ${ae}`)}},bn=(ae,fe)=>{let ye=[-1,4,1,1,2,2,4,8,-1,1,2,8,4,8,-1,-1,-1,-1,-1,-1,-1,.5,.5][ae],$e=typeof fe=="number"?fe:fe.reduce((je,ze)=>je*ze,1);return ye>0?Math.ceil($e*ye):void 0},Et=ae=>{switch(ae){case"float16":return typeof Float16Array<"u"&&Float16Array.from?Float16Array:Uint16Array;case"float32":return Float32Array;case"uint8":return Uint8Array;case"int8":return Int8Array;case"uint16":return Uint16Array;case"int16":return Int16Array;case"int32":return Int32Array;case"bool":return Uint8Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw new Error(`unsupported type: ${ae}`)}},_e=ae=>{switch(ae){case"verbose":return 0;case"info":return 1;case"warning":return 2;case"error":return 3;case"fatal":return 4;default:throw new Error(`unsupported logging level: ${ae}`)}},it=ae=>ae==="float32"||ae==="float16"||ae==="int32"||ae==="int64"||ae==="uint32"||ae==="uint8"||ae==="bool"||ae==="uint4"||ae==="int4",_t=ae=>ae==="float32"||ae==="float16"||ae==="int32"||ae==="int64"||ae==="uint32"||ae==="uint64"||ae==="int8"||ae==="uint8"||ae==="bool"||ae==="uint4"||ae==="int4",lr=ae=>{switch(ae){case"none":return 0;case"cpu":return 1;case"cpu-pinned":return 2;case"texture":return 3;case"gpu-buffer":return 4;case"ml-tensor":return 5;default:throw new Error(`unsupported data location: ${ae}`)}}}),fr,on=u(()=>{vt(),fr=async ae=>{if(typeof ae=="string"){let fe=await fetch(ae);if(!fe.ok)throw new Error(`failed to load external data file: ${ae}`);let ye=fe.headers.get("Content-Length"),$e=ye?parseInt(ye,10):0;if($e<1073741824)return new Uint8Array(await fe.arrayBuffer());{if(!fe.body)throw new Error(`failed to load external data file: ${ae}, no response body.`);let je=fe.body.getReader(),ze;try{ze=new ArrayBuffer($e)}catch(Pe){if(Pe instanceof RangeError){let Ue=Math.ceil($e/65536);ze=new WebAssembly.Memory({initial:Ue,maximum:Ue}).buffer}else throw Pe}let Oe=0;for(;;){let{done:Pe,value:Ue}=await je.read();if(Pe)break;let tt=Ue.byteLength;new Uint8Array(ze,Oe,tt).set(Ue),Oe+=tt}return new Uint8Array(ze,0,$e)}}else return ae instanceof Blob?new Uint8Array(await ae.arrayBuffer()):ae instanceof Uint8Array?ae:new Uint8Array(ae)}}),Yn,Jn,fs,Rr,hs,Ms,hr,ps,Uo,ra,Qe,Is,$c,Al=u(()=>{mr(),zo(),Jr(),mt(),bi(),ea(),on(),Yn=(ae,fe)=>{Kt()._OrtInit(ae,fe)!==0&&Nt("Can't initialize onnxruntime.")},Jn=async ae=>{Yn(ae.wasm.numThreads,_e(ae.logLevel))},fs=async(ae,fe)=>{var $e,je;(je=($e=Kt()).asyncInit)==null||je.call($e);let ye=ae.webgpu.adapter;if(fe==="webgpu"){if(typeof navigator>"u"||!navigator.gpu)throw new Error("WebGPU is not supported in current environment");if(ye){if(typeof ye.limits!="object"||typeof ye.features!="object"||typeof ye.requestDevice!="function")throw new Error("Invalid GPU adapter set in `env.webgpu.adapter`. It must be a GPUAdapter object.")}else{let ze=ae.webgpu.powerPreference;if(ze!==void 0&&ze!=="low-power"&&ze!=="high-performance")throw new Error(`Invalid powerPreference setting: "${ze}"`);let Oe=ae.webgpu.forceFallbackAdapter;if(Oe!==void 0&&typeof Oe!="boolean")throw new Error(`Invalid forceFallbackAdapter setting: "${Oe}"`);if(ye=await navigator.gpu.requestAdapter({powerPreference:ze,forceFallbackAdapter:Oe}),!ye)throw new Error('Failed to get GPU adapter. You may need to enable flag "--enable-unsafe-webgpu" if you are using Chrome.')}}if(fe==="webnn"&&(typeof navigator>"u"||!navigator.ml))throw new Error("WebNN is not supported in current environment")},Rr=new Map,hs=ae=>{let fe=Kt(),ye=fe.stackSave();try{let $e=fe.PTR_SIZE,je=fe.stackAlloc(2*$e);fe._OrtGetInputOutputCount(ae,je,je+$e)!==0&&Nt("Can't get session input/output count.");let ze=$e===4?"i32":"i64";return[Number(fe.getValue(je,ze)),Number(fe.getValue(je+$e,ze))]}finally{fe.stackRestore(ye)}},Ms=(ae,fe)=>{let ye=Kt(),$e=ye.stackSave(),je=0;try{let ze=ye.PTR_SIZE,Oe=ye.stackAlloc(2*ze);ye._OrtGetInputOutputMetadata(ae,fe,Oe,Oe+ze)!==0&&Nt("Can't get session input/output metadata.");let Pe=Number(ye.getValue(Oe,"*"));je=Number(ye.getValue(Oe+ze,"*"));let Ue=ye.HEAP32[je/4];if(Ue===0)return[Pe,0];let tt=ye.HEAPU32[je/4+1],ot=[];for(let nt=0;nt<tt;nt++){let Je=Number(ye.getValue(je+8+nt*ze,"*"));ot.push(Je!==0?ye.UTF8ToString(Je):Number(ye.getValue(je+8+(nt+tt)*ze,"*")))}return[Pe,Ue,ot]}finally{ye.stackRestore($e),je!==0&&ye._OrtFree(je)}},hr=ae=>{let fe=Kt(),ye=fe._malloc(ae.byteLength);if(ye===0)throw new Error(`Can't create a session. failed to allocate a buffer of size ${ae.byteLength}.`);return fe.HEAPU8.set(ae,ye),[ye,ae.byteLength]},ps=async(ae,fe)=>{var ot,nt,Je;let ye,$e,je=Kt();Array.isArray(ae)?[ye,$e]=ae:ae.buffer===je.HEAPU8.buffer?[ye,$e]=[ae.byteOffset,ae.byteLength]:[ye,$e]=hr(ae);let ze=0,Oe=0,Pe=[],Ue=[],tt=[];try{if([Oe,Pe]=await Tl(fe),(fe==null?void 0:fe.externalData)&&je.mountExternalData){let Hr=[];for(let yr of fe.externalData){let Ln=typeof yr=="string"?yr:yr.path;Hr.push(fr(typeof yr=="string"?yr:yr.data).then(ci=>{je.mountExternalData(Ln,ci)}))}await Promise.all(Hr)}for(let Hr of(fe==null?void 0:fe.executionProviders)??[])if((typeof Hr=="string"?Hr:Hr.name)==="webnn"){if(je.shouldTransferToMLTensor=!1,typeof Hr!="string"){let yr=Hr,Ln=yr==null?void 0:yr.context,ci=yr==null?void 0:yr.gpuDevice,wi=yr==null?void 0:yr.deviceType,Nl=yr==null?void 0:yr.powerPreference;Ln?je.currentContext=Ln:ci?je.currentContext=await je.webnnCreateMLContext(ci):je.currentContext=await je.webnnCreateMLContext({deviceType:wi,powerPreference:Nl})}else je.currentContext=await je.webnnCreateMLContext();break}ze=await je._OrtCreateSession(ye,$e,Oe),(ot=je.webgpuOnCreateSession)==null||ot.call(je,ze),ze===0&&Nt("Can't create a session."),(nt=je.jsepOnCreateSession)==null||nt.call(je),je.currentContext&&(je.webnnRegisterMLContext(ze,je.currentContext),je.currentContext=void 0,je.shouldTransferToMLTensor=!0);let[Ot,Be]=hs(ze),pt=!!(fe!=null&&fe.enableGraphCapture),Br=[],nr=[],ir=[],zr=[],Ut=[];for(let Hr=0;Hr<Ot;Hr++){let[yr,Ln,ci]=Ms(ze,Hr);yr===0&&Nt("Can't get an input name."),Ue.push(yr);let wi=je.UTF8ToString(yr);Br.push(wi),ir.push(Ln===0?{name:wi,isTensor:!1}:{name:wi,isTensor:!0,type:kn(Ln),shape:ci})}for(let Hr=0;Hr<Be;Hr++){let[yr,Ln,ci]=Ms(ze,Hr+Ot);yr===0&&Nt("Can't get an output name."),tt.push(yr);let wi=je.UTF8ToString(yr);nr.push(wi),zr.push(Ln===0?{name:wi,isTensor:!1}:{name:wi,isTensor:!0,type:kn(Ln),shape:ci})}return Rr.set(ze,[ze,Ue,tt,null,pt,!1]),[ze,Br,nr,ir,zr]}catch(Ot){throw Ue.forEach(Be=>je._OrtFree(Be)),tt.forEach(Be=>je._OrtFree(Be)),ze!==0&&je._OrtReleaseSession(ze)!==0&&Nt("Can't release session."),Ot}finally{je._free(ye),Oe!==0&&je._OrtReleaseSessionOptions(Oe)!==0&&Nt("Can't release session options."),Pe.forEach(Ot=>je._free(Ot)),(Je=je.unmountExternalData)==null||Je.call(je)}},Uo=ae=>{var Ue,tt,ot;let fe=Kt(),ye=Rr.get(ae);if(!ye)throw new Error(`cannot release session. invalid session id: ${ae}`);let[$e,je,ze,Oe,Pe]=ye;Oe&&(Pe&&fe._OrtClearBoundOutputs(Oe.handle)!==0&&Nt("Can't clear bound outputs."),fe._OrtReleaseBinding(Oe.handle)!==0&&Nt("Can't release IO binding.")),(Ue=fe.jsepOnReleaseSession)==null||Ue.call(fe,ae),(tt=fe.webnnOnReleaseSession)==null||tt.call(fe,ae),(ot=fe.webgpuOnReleaseSession)==null||ot.call(fe,ae),je.forEach(nt=>fe._OrtFree(nt)),ze.forEach(nt=>fe._OrtFree(nt)),fe._OrtReleaseSession($e)!==0&&Nt("Can't release session."),Rr.delete(ae)},ra=async(ae,fe,ye,$e,je,ze,Oe=!1)=>{if(!ae){fe.push(0);return}let Pe=Kt(),Ue=Pe.PTR_SIZE,tt=ae[0],ot=ae[1],nt=ae[3],Je=nt,Ot,Be;if(tt==="string"&&(nt==="gpu-buffer"||nt==="ml-tensor"))throw new Error("String tensor is not supported on GPU.");if(Oe&&nt!=="gpu-buffer")throw new Error(`External buffer must be provided for input/output index ${ze} when enableGraphCapture is true.`);if(nt==="gpu-buffer"){let nr=ae[2].gpuBuffer;Be=bn(oi(tt),ot);{let ir=Pe.jsepRegisterBuffer;if(!ir)throw new Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');Ot=ir($e,ze,nr,Be)}}else if(nt==="ml-tensor"){let nr=ae[2].mlTensor;Be=bn(oi(tt),ot);let ir=Pe.webnnRegisterMLTensor;if(!ir)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');Ot=ir($e,nr,oi(tt),ot)}else{let nr=ae[2];if(Array.isArray(nr)){Be=Ue*nr.length,Ot=Pe._malloc(Be),ye.push(Ot);for(let ir=0;ir<nr.length;ir++){if(typeof nr[ir]!="string")throw new TypeError(`tensor data at index ${ir} is not a string`);Pe.setValue(Ot+ir*Ue,Sr(nr[ir],ye),"*")}}else{let ir=Pe.webnnIsGraphInput,zr=Pe.webnnIsGraphOutput;if(tt!=="string"&&ir&&zr){let Ut=Pe.UTF8ToString(je);if(ir($e,Ut)||zr($e,Ut)){let Hr=oi(tt);Be=bn(Hr,ot),Je="ml-tensor";let yr=Pe.webnnCreateTemporaryTensor,Ln=Pe.webnnUploadTensor;if(!yr||!Ln)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');let ci=await yr($e,Hr,ot);Ln(ci,new Uint8Array(nr.buffer,nr.byteOffset,nr.byteLength)),Ot=ci}else Be=nr.byteLength,Ot=Pe._malloc(Be),ye.push(Ot),Pe.HEAPU8.set(new Uint8Array(nr.buffer,nr.byteOffset,Be),Ot)}else Be=nr.byteLength,Ot=Pe._malloc(Be),ye.push(Ot),Pe.HEAPU8.set(new Uint8Array(nr.buffer,nr.byteOffset,Be),Ot)}}let pt=Pe.stackSave(),Br=Pe.stackAlloc(4*ot.length);try{ot.forEach((ir,zr)=>Pe.setValue(Br+zr*Ue,ir,Ue===4?"i32":"i64"));let nr=Pe._OrtCreateTensor(oi(tt),Ot,Be,Br,ot.length,lr(Je));nr===0&&Nt(`Can't create tensor for input/output. session=${$e}, index=${ze}.`),fe.push(nr)}finally{Pe.stackRestore(pt)}},Qe=async(ae,fe,ye,$e,je,ze)=>{var _i,Mc,Fu;let Oe=Kt(),Pe=Oe.PTR_SIZE,Ue=Rr.get(ae);if(!Ue)throw new Error(`cannot run inference. invalid session id: ${ae}`);let tt=Ue[0],ot=Ue[1],nt=Ue[2],Je=Ue[3],Ot=Ue[4];Ue[5];let Be=fe.length,pt=$e.length,Br=0,nr=[],ir=[],zr=[],Ut=[],Hr=[],yr=Oe.stackSave(),Ln=Oe.stackAlloc(Be*Pe),ci=Oe.stackAlloc(Be*Pe),wi=Oe.stackAlloc(pt*Pe),Nl=Oe.stackAlloc(pt*Pe);try{[Br,nr]=ka(ze),ct("wasm prepareInputOutputTensor");for(let pr=0;pr<Be;pr++)await ra(ye[pr],ir,Ut,ae,ot[fe[pr]],fe[pr],Ot);for(let pr=0;pr<pt;pr++)await ra(je[pr],zr,Ut,ae,nt[$e[pr]],Be+$e[pr],Ot);ut("wasm prepareInputOutputTensor");for(let pr=0;pr<Be;pr++)Oe.setValue(Ln+pr*Pe,ir[pr],"*"),Oe.setValue(ci+pr*Pe,ot[fe[pr]],"*");for(let pr=0;pr<pt;pr++)Oe.setValue(wi+pr*Pe,zr[pr],"*"),Oe.setValue(Nl+pr*Pe,nt[$e[pr]],"*");(_i=Oe.jsepOnRunStart)==null||_i.call(Oe,tt),(Mc=Oe.webnnOnRunStart)==null||Mc.call(Oe,tt);let Bn;Bn=await Oe._OrtRun(tt,ci,Ln,Be,Nl,pt,wi,Br),Bn!==0&&Nt("failed to call OrtRun().");let Ls=[],Uu=[];ct("wasm ProcessOutputTensor");for(let pr=0;pr<pt;pr++){let vs=Number(Oe.getValue(wi+pr*Pe,"*"));if(vs===zr[pr]||Hr.includes(zr[pr])){Ls.push(je[pr]),vs!==zr[pr]&&Oe._OrtReleaseTensor(vs)!==0&&Nt("Can't release tensor.");continue}let xf=Oe.stackSave(),aa=Oe.stackAlloc(4*Pe),Wo=!1,Cn,Si=0;try{Oe._OrtGetTensorData(vs,aa,aa+Pe,aa+2*Pe,aa+3*Pe)!==0&&Nt(`Can't access output tensor data on index ${pr}.`);let Ic=Pe===4?"i32":"i64",ki=Number(Oe.getValue(aa,Ic));Si=Oe.getValue(aa+Pe,"*");let qu=Oe.getValue(aa+Pe*2,"*"),wf=Number(Oe.getValue(aa+Pe*3,Ic)),oa=[];for(let jn=0;jn<wf;jn++)oa.push(Number(Oe.getValue(qu+jn*Pe,Ic)));Oe._OrtFree(qu)!==0&&Nt("Can't free memory for tensor dims.");let ys=oa.reduce((jn,ln)=>jn*ln,1);Cn=kn(ki);let Bs=Je==null?void 0:Je.outputPreferredLocations[$e[pr]];if(Cn==="string"){if(Bs==="gpu-buffer"||Bs==="ml-tensor")throw new Error("String tensor is not supported on GPU.");let jn=[];for(let ln=0;ln<ys;ln++){let bs=Oe.getValue(Si+ln*Pe,"*"),Wu=Oe.getValue(Si+(ln+1)*Pe,"*"),Hu=ln===ys-1?void 0:Wu-bs;jn.push(Oe.UTF8ToString(bs,Hu))}Ls.push([Cn,oa,jn,"cpu"])}else if(Bs==="gpu-buffer"&&ys>0){let jn=Oe.jsepGetBuffer;if(!jn)throw new Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');let ln=jn(Si),bs=bn(ki,ys);if(bs===void 0||!it(Cn))throw new Error(`Unsupported data type: ${Cn}`);Wo=!0,Ls.push([Cn,oa,{gpuBuffer:ln,download:Oe.jsepCreateDownloader(ln,bs,Cn),dispose:()=>{Oe._OrtReleaseTensor(vs)!==0&&Nt("Can't release tensor.")}},"gpu-buffer"])}else if(Bs==="ml-tensor"&&ys>0){let jn=Oe.webnnEnsureTensor,ln=Oe.webnnIsGraphInputOutputTypeSupported;if(!jn||!ln)throw new Error('preferredLocation "ml-tensor" is not supported without using WebNN.');if(bn(ki,ys)===void 0||!_t(Cn))throw new Error(`Unsupported data type: ${Cn}`);if(!ln(ae,Cn,!1))throw new Error(`preferredLocation "ml-tensor" for ${Cn} output is not supported by current WebNN Context.`);let bs=await jn(ae,Si,ki,oa,!1);Wo=!0,Ls.push([Cn,oa,{mlTensor:bs,download:Oe.webnnCreateMLTensorDownloader(Si,Cn),dispose:()=>{Oe.webnnReleaseTensorId(Si),Oe._OrtReleaseTensor(vs)}},"ml-tensor"])}else if(Bs==="ml-tensor-cpu-output"&&ys>0){let jn=Oe.webnnCreateMLTensorDownloader(Si,Cn)(),ln=Ls.length;Wo=!0,Uu.push((async()=>{let bs=[ln,await jn];return Oe.webnnReleaseTensorId(Si),Oe._OrtReleaseTensor(vs),bs})()),Ls.push([Cn,oa,[],"cpu"])}else{let jn=Et(Cn),ln=new jn(ys);new Uint8Array(ln.buffer,ln.byteOffset,ln.byteLength).set(Oe.HEAPU8.subarray(Si,Si+ln.byteLength)),Ls.push([Cn,oa,ln,"cpu"])}}finally{Oe.stackRestore(xf),Cn==="string"&&Si&&Oe._free(Si),Wo||Oe._OrtReleaseTensor(vs)}}Je&&!Ot&&(Oe._OrtClearBoundOutputs(Je.handle)!==0&&Nt("Can't clear bound outputs."),Rr.set(ae,[tt,ot,nt,Je,Ot,!1]));for(let[pr,vs]of await Promise.all(Uu))Ls[pr][2]=vs;return ut("wasm ProcessOutputTensor"),Ls}finally{(Fu=Oe.webnnOnRunEnd)==null||Fu.call(Oe,tt),Oe.stackRestore(yr),ir.forEach(Bn=>Oe._OrtReleaseTensor(Bn)),zr.forEach(Bn=>Oe._OrtReleaseTensor(Bn)),Ut.forEach(Bn=>Oe._free(Bn)),Br!==0&&Oe._OrtReleaseRunOptions(Br),nr.forEach(Bn=>Oe._free(Bn))}},Is=ae=>{let fe=Kt(),ye=Rr.get(ae);if(!ye)throw new Error("invalid session id");let $e=ye[0],je=fe._OrtEndProfiling($e);je===0&&Nt("Can't get an profile file name."),fe._OrtFree(je)},$c=ae=>{let fe=[];for(let ye of ae){let $e=ye[2];!Array.isArray($e)&&"buffer"in $e&&fe.push($e.buffer)}return fe}}),gr,Ft,na,Ca,ja,ro,qo,no,ts,li,ms,gs,Ea,io,Ds,bf,so,ao,Lu=u(()=>{mr(),Al(),bi(),pn(),gr=()=>!!N.wasm.proxy&&typeof document<"u",na=!1,Ca=!1,ja=!1,no=new Map,ts=(ae,fe)=>{let ye=no.get(ae);ye?ye.push(fe):no.set(ae,[fe])},li=()=>{if(na||!Ca||ja||!Ft)throw new Error("worker not ready")},ms=ae=>{switch(ae.data.type){case"init-wasm":na=!1,ae.data.err?(ja=!0,qo[1](ae.data.err)):(Ca=!0,qo[0]()),ro&&(URL.revokeObjectURL(ro),ro=void 0);break;case"init-ep":case"copy-from":case"create":case"release":case"run":case"end-profiling":{let fe=no.get(ae.data.type);ae.data.err?fe.shift()[1](ae.data.err):fe.shift()[0](ae.data.out);break}}},gs=async()=>{if(!Ca){if(na)throw new Error("multiple calls to 'initWasm()' detected.");if(ja)throw new Error("previous call to 'initWasm()' failed.");if(na=!0,gr())return new Promise((ae,fe)=>{Ft==null||Ft.terminate(),Yr().then(([ye,$e])=>{try{Ft=$e,Ft.onerror=ze=>fe(ze),Ft.onmessage=ms,qo=[ae,fe];let je={type:"init-wasm",in:N};if(!je.in.wasm.wasmPaths&&ye){let ze=si();ze&&(je.in.wasm.wasmPaths=ze)}Ft.postMessage(je),ro=ye}catch(je){fe(je)}},fe)});try{await us(N.wasm),await Jn(N),Ca=!0}catch(ae){throw ja=!0,ae}finally{na=!1}}},Ea=async ae=>{if(gr())return li(),new Promise((fe,ye)=>{ts("init-ep",[fe,ye]);let $e={type:"init-ep",in:{epName:ae,env:N}};Ft.postMessage($e)});await fs(N,ae)},io=async ae=>gr()?(li(),new Promise((fe,ye)=>{ts("copy-from",[fe,ye]);let $e={type:"copy-from",in:{buffer:ae}};Ft.postMessage($e,[ae.buffer])})):hr(ae),Ds=async(ae,fe)=>{if(gr()){if(fe!=null&&fe.preferredOutputLocation)throw new Error('session option "preferredOutputLocation" is not supported for proxy.');return li(),new Promise((ye,$e)=>{ts("create",[ye,$e]);let je={type:"create",in:{model:ae,options:{...fe}}},ze=[];ae instanceof Uint8Array&&ze.push(ae.buffer),Ft.postMessage(je,ze)})}else return ps(ae,fe)},bf=async ae=>{if(gr())return li(),new Promise((fe,ye)=>{ts("release",[fe,ye]);let $e={type:"release",in:ae};Ft.postMessage($e)});Uo(ae)},so=async(ae,fe,ye,$e,je,ze)=>{if(gr()){if(ye.some(Oe=>Oe[3]!=="cpu"))throw new Error("input tensor on GPU is not supported for proxy.");if(je.some(Oe=>Oe))throw new Error("pre-allocated output tensor is not supported for proxy.");return li(),new Promise((Oe,Pe)=>{ts("run",[Oe,Pe]);let Ue=ye,tt={type:"run",in:{sessionId:ae,inputIndices:fe,inputs:Ue,outputIndices:$e,options:ze}};Ft.postMessage(tt,$c(Ue))})}else return Qe(ae,fe,ye,$e,je,ze)},ao=async ae=>{if(gr())return li(),new Promise((fe,ye)=>{ts("end-profiling",[fe,ye]);let $e={type:"end-profiling",in:ae};Ft.postMessage($e)});Is(ae)}}),Nc,oo,$l,Oc=u(()=>{mr(),Lu(),mt(),vt(),on(),Nc=(ae,fe)=>{switch(ae.location){case"cpu":return[ae.type,ae.dims,ae.data,"cpu"];case"gpu-buffer":return[ae.type,ae.dims,{gpuBuffer:ae.gpuBuffer},"gpu-buffer"];case"ml-tensor":return[ae.type,ae.dims,{mlTensor:ae.mlTensor},"ml-tensor"];default:throw new Error(`invalid data location: ${ae.location} for ${fe()}`)}},oo=ae=>{switch(ae[3]){case"cpu":return new xe(ae[0],ae[2],ae[1]);case"gpu-buffer":{let fe=ae[0];if(!it(fe))throw new Error(`not supported data type: ${fe} for deserializing GPU tensor`);let{gpuBuffer:ye,download:$e,dispose:je}=ae[2];return xe.fromGpuBuffer(ye,{dataType:fe,dims:ae[1],download:$e,dispose:je})}case"ml-tensor":{let fe=ae[0];if(!_t(fe))throw new Error(`not supported data type: ${fe} for deserializing MLTensor tensor`);let{mlTensor:ye,download:$e,dispose:je}=ae[2];return xe.fromMLTensor(ye,{dataType:fe,dims:ae[1],download:$e,dispose:je})}default:throw new Error(`invalid data location: ${ae[3]}`)}},$l=class{async fetchModelAndCopyToWasmMemory(ae){return io(await fr(ae))}async loadModel(ae,fe){Le();let ye;typeof ae=="string"?ye=await this.fetchModelAndCopyToWasmMemory(ae):ye=ae,[this.sessionId,this.inputNames,this.outputNames,this.inputMetadata,this.outputMetadata]=await Ds(ye,fe),Ze()}async dispose(){return bf(this.sessionId)}async run(ae,fe,ye){Le();let $e=[],je=[];Object.entries(ae).forEach(nt=>{let Je=nt[0],Ot=nt[1],Be=this.inputNames.indexOf(Je);if(Be===-1)throw new Error(`invalid input '${Je}'`);$e.push(Ot),je.push(Be)});let ze=[],Oe=[];Object.entries(fe).forEach(nt=>{let Je=nt[0],Ot=nt[1],Be=this.outputNames.indexOf(Je);if(Be===-1)throw new Error(`invalid output '${Je}'`);ze.push(Ot),Oe.push(Be)});let Pe=$e.map((nt,Je)=>Nc(nt,()=>`input "${this.inputNames[je[Je]]}"`)),Ue=ze.map((nt,Je)=>nt?Nc(nt,()=>`output "${this.outputNames[Oe[Je]]}"`):null),tt=await so(this.sessionId,je,Pe,Oe,Ue,ye),ot={};for(let nt=0;nt<tt.length;nt++)ot[this.outputNames[Oe[nt]]]=ze[nt]??oo(tt[nt]);return Ze(),ot}startProfiling(){}endProfiling(){ao(this.sessionId)}}}),ia={};f(ia,{OnnxruntimeWebAssemblyBackend:()=>sa,initializeFlags:()=>Ta,wasmBackend:()=>lo});var Ta,sa,lo,Bu=u(()=>{mr(),Lu(),Oc(),Ta=()=>{(typeof N.wasm.initTimeout!="number"||N.wasm.initTimeout<0)&&(N.wasm.initTimeout=0);let ae=N.wasm.simd;if(typeof ae!="boolean"&&ae!==void 0&&ae!=="fixed"&&ae!=="relaxed"&&(console.warn(`Property "env.wasm.simd" is set to unknown value "${ae}". Reset it to \`false\` and ignore SIMD feature checking.`),N.wasm.simd=!1),typeof N.wasm.proxy!="boolean"&&(N.wasm.proxy=!1),typeof N.wasm.trace!="boolean"&&(N.wasm.trace=!1),typeof N.wasm.numThreads!="number"||!Number.isInteger(N.wasm.numThreads)||N.wasm.numThreads<=0)if(typeof self<"u"&&!self.crossOriginIsolated)N.wasm.numThreads=1;else{let fe=typeof navigator>"u"?o("node:os").cpus().length:navigator.hardwareConcurrency;N.wasm.numThreads=Math.min(4,Math.ceil((fe||1)/2))}},sa=class{async init(ae){Ta(),await gs(),await Ea(ae)}async createInferenceSessionHandler(ae,fe){let ye=new $l;return await ye.loadModel(ae,fe),ye}},lo=new sa}),zu={};f(zu,{InferenceSession:()=>cr,TRACE:()=>Re,TRACE_EVENT_BEGIN:()=>ct,TRACE_EVENT_END:()=>ut,TRACE_FUNC_BEGIN:()=>Le,TRACE_FUNC_END:()=>Ze,Tensor:()=>xe,default:()=>Rc,env:()=>N,registerBackend:()=>C}),mr(),mr(),mr();var Pc="1.26.0",Rc=Kn;{let ae=(Bu(),h(ia)).wasmBackend;C("cpu",ae,10),C("wasm",ae,10)}return Object.defineProperty(N.versions,"web",{value:Pc,enumerable:!0}),h(zu)})();e.exports=n})(a1)),a1.exports}var M$;function xU(){return M$||(M$=1,(function(e){var r=ec&&ec.__createBinding||(Object.create?(function(k,T,j,$){$===void 0&&($=j);var P=Object.getOwnPropertyDescriptor(T,j);(!P||("get"in P?!T.__esModule:P.writable||P.configurable))&&(P={enumerable:!0,get:function(){return T[j]}}),Object.defineProperty(k,$,P)}):(function(k,T,j,$){$===void 0&&($=j),k[$]=T[j]})),n=ec&&ec.__setModuleDefault||(Object.create?(function(k,T){Object.defineProperty(k,"default",{enumerable:!0,value:T})}):function(k,T){k.default=T}),i=ec&&ec.__importStar||function(k){if(k&&k.__esModule)return k;var T={};if(k!=null)for(var j in k)j!=="default"&&Object.prototype.hasOwnProperty.call(k,j)&&r(T,k,j);return n(T,k),T};Object.defineProperty(e,"__esModule",{value:!0}),e.MicVAD=e.getDefaultRealTimeVADOptions=e.ort=e.DEFAULT_MODEL=void 0;const s=i(bU()),a=pT(),l=mT(),o=qy(),u=Gw(),f=$5(),m=N5();e.DEFAULT_MODEL="legacy",e.ort=s;const h="vad.worklet.bundle.min.js",y="silero_vad_v5.onnx",x="silero_vad_legacy.onnx",C=k=>({...l.defaultFrameProcessorOptions,onFrameProcessed:()=>{},onVADMisfire:()=>{o.log.debug("VAD misfire")},onSpeechStart:()=>{o.log.debug("Detected speech start")},onSpeechEnd:()=>{o.log.debug("Detected speech end")},onSpeechRealStart:()=>{o.log.debug("Detected real speech start")},baseAssetPath:"./",onnxWASMBasePath:"./",model:k,workletOptions:{},getStream:async()=>await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}}),pauseStream:async T=>{T.getTracks().forEach(j=>{j.stop()})},resumeStream:async()=>await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}}),ortConfig:T=>{T.env.logLevel="error"},startOnLoad:!0,processorType:"auto"});e.getDefaultRealTimeVADOptions=C;const _=k=>"audioWorklet"in k&&typeof AudioWorkletNode=="function"?"AudioWorklet":"ScriptProcessor";async function b(k,T,j,$,P){await j.audioWorklet.addModule(k),T.processorOptions={...T.processorOptions??{},frameSamples:$};const N=new AudioWorkletNode(j,"vad-helper-worklet",T);return N.port.onmessage=async I=>{const U=I.data;if(!(typeof U=="object"&&U&&"message"in U)){console.error("Invalid message event",U);return}switch(U.message){case u.Message.AudioFrame:{if(!("data"in U&&U.data instanceof ArrayBuffer)){console.log("Audio frame message has no data");return}const V=new Float32Array(U.data);await P(V);break}}},N}async function w(k,T,j){const $=new m.Resampler({nativeSampleRate:k.sampleRate,targetSampleRate:16e3,targetFrameSize:T});o.log.debug("using script processor");const N=k.createScriptProcessor(4096,1,1);let I=!1;return N.onaudioprocess=async U=>{if(!I){I=!0;try{const V=U.inputBuffer.getChannelData(0);U.outputBuffer.getChannelData(0).fill(0);const F=$.process(V);for(const z of F)await j(z)}catch(V){console.error("Error processing audio:",V)}finally{I=!1}}},N.connect(k.destination),N}class S{constructor(T,j,$,P,N=!1,I=null,U=null,V=null,q=null,F=null,z=null,G="uninitialized",Y=!1){this.options=T,this.frameProcessor=j,this.model=$,this.frameSamples=P,this.listening=N,this.errored=I,this._stream=U,this._audioContext=V,this._vadNode=q,this._mediaStreamAudioSourceNode=F,this._audioProcessorAdapterType=z,this.initializationState=G,this.ownsAudioContext=Y,this.getAudioInstances=()=>{if(this._stream===null||this._audioContext===null||this._vadNode==null||this._mediaStreamAudioSourceNode==null)throw new Error("MicVAD has null stream, audio context, or processor adapter");return{stream:this._stream,audioContext:this._audioContext,vadNode:this._vadNode,mediaStreamAudioSourceNode:this._mediaStreamAudioSourceNode}},this.setErrored=oe=>{this.initializationState="errored",this.errored=oe},this.start=async()=>{switch(this.initializationState){case"uninitialized":{o.log.debug("initializing micVAD"),this.initializationState="initializing",this.frameProcessor.resume();try{this._stream=await this.options.getStream()}catch(oe){throw oe instanceof Error?this.setErrored(oe.message):this.setErrored(String(oe)),oe}if(this.options.audioContext?(console.log("using custom audio context"),this._audioContext=this.options.audioContext):(console.log("using default audio context"),this._audioContext=new AudioContext,this.ownsAudioContext=!0),!this._audioContext)throw this.setErrored("Audio context is null"),Error("Audio context is null");switch(this._audioProcessorAdapterType=this.options.processorType=="auto"?_(this._audioContext):this.options.processorType,this._audioProcessorAdapterType){case"AudioWorklet":this._vadNode=await b(this.options.baseAssetPath+h,this.options.workletOptions,this._audioContext,this.frameSamples,this.processFrame);break;case"ScriptProcessor":this._vadNode=await w(this._audioContext,this.frameSamples,this.processFrame);break;default:throw new Error(`Unsupported audio processor adapter type: ${this._audioProcessorAdapterType}`)}this._mediaStreamAudioSourceNode=new MediaStreamAudioSourceNode(this._audioContext,{mediaStream:this._stream}),this._mediaStreamAudioSourceNode.connect(this._vadNode),o.log.debug("started micVAD"),this.listening=!0,this.initializationState="initialized";break}case"initializing":{o.log.warn("start called while initializing");break}case"initialized":{if(this.listening)return;this.listening=!0,this.frameProcessor.resume();const{stream:oe,audioContext:te,vadNode:J}=this.getAudioInstances();this._stream=await this.options.resumeStream(oe);const K=new MediaStreamAudioSourceNode(te,{mediaStream:this._stream});this._mediaStreamAudioSourceNode=K,K.connect(J);break}case"destroyed":{o.log.warn("start called after destroyed");break}case"errored":{o.log.error("start called after errored");break}default:{o.log.warn("weird initialization state");break}}},this.pause=async()=>{if(!this.listening)return;this.listening=!1;const{stream:oe,mediaStreamAudioSourceNode:te}=this.getAudioInstances();await this.options.pauseStream(oe),te.disconnect(),this.frameProcessor.pause(this.handleFrameProcessorEvent)},this.destroy=async()=>{var te;o.log.debug("destroy called"),this.initializationState="destroyed";const{vadNode:oe}=this.getAudioInstances();oe instanceof AudioWorkletNode&&oe.port.postMessage(u.Message.SpeechStop),this.listening&&await this.pause(),await this.model.release(),this.ownsAudioContext&&await((te=this._audioContext)==null?void 0:te.close())},this.setOptions=oe=>{this.frameProcessor.setOptions(oe)},this.processFrame=async oe=>{await this.frameProcessor.process(oe,this.handleFrameProcessorEvent)},this.handleFrameProcessorEvent=oe=>{switch(oe.msg){case u.Message.FrameProcessed:this.options.onFrameProcessed(oe.probs,oe.frame);break;case u.Message.SpeechStart:this.options.onSpeechStart();break;case u.Message.SpeechRealStart:this.options.onSpeechRealStart();break;case u.Message.VADMisfire:this.options.onVADMisfire();break;case u.Message.SpeechEnd:this.options.onSpeechEnd(oe.audio);break}}}static async new(T={}){const j={...(0,e.getDefaultRealTimeVADOptions)(T.model??e.DEFAULT_MODEL),...T};(0,l.validateOptions)(j),e.ort.env.wasm.wasmPaths=j.onnxWASMBasePath,j.ortConfig!==void 0&&j.ortConfig(e.ort);const $=j.model==="v5"?y:x,P=j.baseAssetPath+$,N=j.model==="v5"?f.SileroV5.new:f.SileroLegacy.new;let I;try{I=await N(e.ort,()=>(0,a.defaultModelFetcher)(P))}catch(z){throw console.error(`Encountered an error while loading model file ${P}`),z}const U=j.model==="v5"?512:1536,V=U/16,q=new l.FrameProcessor(I.process,I.reset_state,{positiveSpeechThreshold:j.positiveSpeechThreshold,negativeSpeechThreshold:j.negativeSpeechThreshold,redemptionMs:j.redemptionMs,preSpeechPadMs:j.preSpeechPadMs,minSpeechMs:j.minSpeechMs,submitUserSpeechOnPause:j.submitUserSpeechOnPause},V),F=new S(j,q,I,U);if(j.startOnLoad)try{await F.start()}catch(z){throw console.error("Error starting micVad",z),z}return F}}e.MicVAD=S})(ec)),ec}var I$;function wU(){return I$||(I$=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getDefaultRealTimeVADOptions=e.MicVAD=e.DEFAULT_MODEL=e.utils=e.NonRealTimeVAD=e.Message=e.FrameProcessor=e.defaultModelFetcher=e.baseAssetPath=void 0;var r=E5();Object.defineProperty(e,"baseAssetPath",{enumerable:!0,get:function(){return r.baseAssetPath}});var n=pT();Object.defineProperty(e,"defaultModelFetcher",{enumerable:!0,get:function(){return n.defaultModelFetcher}});var i=mT();Object.defineProperty(e,"FrameProcessor",{enumerable:!0,get:function(){return i.FrameProcessor}});var s=Gw();Object.defineProperty(e,"Message",{enumerable:!0,get:function(){return s.Message}});var a=vU();Object.defineProperty(e,"NonRealTimeVAD",{enumerable:!0,get:function(){return a.NonRealTimeVAD}});const l=yU();e.utils={audioFileToArray:l.audioFileToArray,minFramesForTargetMS:l.minFramesForTargetMS,arrayBufferToBase64:l.arrayBufferToBase64,encodeWAV:l.encodeWAV};var o=xU();Object.defineProperty(e,"DEFAULT_MODEL",{enumerable:!0,get:function(){return o.DEFAULT_MODEL}}),Object.defineProperty(e,"MicVAD",{enumerable:!0,get:function(){return o.MicVAD}}),Object.defineProperty(e,"getDefaultRealTimeVADOptions",{enumerable:!0,get:function(){return o.getDefaultRealTimeVADOptions}})})(n1)),n1}var _U=wU();function cx(e,r,n,i){var a,l;try{(l=(a=window.api)==null?void 0:a.logs)==null||l.write(e,r,n,i)}catch{}const s=r==="error"?console.error:r==="warn"?console.warn:console.log;i!==void 0?s(`[${e}]`,n,i):s(`[${e}]`,n)}const gt={debug:(e,r,n)=>cx(e,"debug",r,n),info:(e,r,n)=>cx(e,"info",r,n),warn:(e,r,n)=>cx(e,"warn",r,n),error:(e,r,n)=>cx(e,"error",r,n)},P5=16e3,SU=6,Qh=P5*SU,kU=400,CU=P5*kU/1e3,D$=300,L$=2e3,B$=1500,z$=3e3,jU=600,R5=.5,M5=.35,F$=.85,U$=.7;let Ys=null,yl=!1,Ts=!1;const rj=new Set;function ux(e){for(const r of Array.from(rj))try{r(e)}catch(n){gt.warn("speech","workerDeath listener threw",{error:n instanceof Error?n.message:String(n)})}}let o1=0;const q$=2;let yp=!1,I5=!1;function D5(e){e.addEventListener("message",r=>{var i;if(((i=r.data)==null?void 0:i.type)!=="log")return;const n=r.data.level||"info";gt[n]("whisperWorker",r.data.message??"",r.data.meta)}),e.addEventListener("error",r=>{gt.error("whisperWorker","worker error event (fatal)",{message:r.message,filename:r.filename,lineno:r.lineno}),EU(`error:${r.message||"unknown"}`)})}function x0(){return Ys||(Ys=new Worker(new URL(""+new URL("whisperWorker-Dbia1OpC.js",import.meta.url).href,import.meta.url),{type:"module"}),D5(Ys),gt.info("speech","worker spawned"),Ys)}let dx=!1;function EU(e){if(!yp){if(dx){gt.warn("speech","respawnWorker: already in flight, ignoring",{reason:e});return}if(dx=!0,o1+=1,I5=!0,gt.warn("speech","respawnWorker: starting",{reason:e,attempt:o1}),ux({reason:e,respawned:!1,finalOnly:!0}),o1>q$){if(yp=!0,gt.error("speech","respawnWorker: limit exceeded, disabling speech",{limit:q$}),Ys)try{Ys.terminate()}catch{}Ys=null,yl=!1,Ts=!1,ux({reason:"respawn-limit-exceeded",respawned:!1,finalOnly:!0}),dx=!1;return}if(Ys)try{Ys.terminate()}catch{}Ys=null,yl=!1,Ts=!1;try{Ys=new Worker(new URL(""+new URL("whisperWorker-Dbia1OpC.js",import.meta.url).href,import.meta.url),{type:"module"}),D5(Ys),Ts=!0,Ys.postMessage({type:"load"}),gt.info("speech","respawnWorker: new worker spawned, load posted"),ux({reason:e,respawned:!0,finalOnly:!0})}catch(r){yp=!0,gt.error("speech","respawnWorker: spawn failed, disabling speech",{error:r instanceof Error?r.message:String(r)}),ux({reason:"spawn-failed",respawned:!1,finalOnly:!0})}finally{dx=!1}}}function TU(e,r){if(yl||Ts)return;Ts=!0;const n=x0();gt.info("speech","preloadModel: posting load");const i=s=>{s.data.type==="status"?(e==null||e(s.data.status,s.data.message),s.data.status==="ready"&&(yl=!0,Ts=!1,gt.info("speech","preloadModel: ready"),n.removeEventListener("message",i))):s.data.type==="progress"?r==null||r(s.data.pct):s.data.type==="error"&&(Ts=!1,gt.error("speech","preloadModel: worker reported error",{error:s.data.error}),e==null||e("error",s.data.error),n.removeEventListener("message",i))};n.addEventListener("message",i),n.postMessage({type:"load"})}function AU(){gt.info("speech","resetModel: clearing load flags"),yl=!1,Ts=!1}function gT(){var e;return typeof Worker<"u"&&!!((e=navigator.mediaDevices)!=null&&e.getUserMedia)&&typeof AudioWorkletNode<"u"}function $U(e){const r=x0();return!yl&&!Ts&&(Ts=!0,r.postMessage({type:"load"})),new Promise((n,i)=>{const s=a=>{var l,o,u;((l=a.data)==null?void 0:l.type)==="result"?(r.removeEventListener("message",s),n((a.data.text??"").trim())):((o=a.data)==null?void 0:o.type)==="error"?(r.removeEventListener("message",s),i(new Error(String(a.data.error??"Transcription failed")))):((u=a.data)==null?void 0:u.type)==="status"&&a.data.status==="ready"&&(yl=!0,Ts=!1)};r.addEventListener("message",s),r.postMessage({type:"transcribe",audio:e},[e.buffer])})}function NU(e){let r=x0(),n=!1,i=null,s=null,a=null,l=null,o=null;const u=[],f=new Set;let m=null,h=0,y=!1,x=0,C=!1,_=!1,b=0,w=0,S=0,k=-1,T=D$,j=0,$=null,P="",N="",I=!1,U=0;function V(he,we){const Ce=Math.min(he.length,we.length);let Me=0;for(;Me<Ce&&he.charCodeAt(Me)===we.charCodeAt(Me);)Me++;return Me}function q(he){const we=V(P,he);return P=he,we>N.length&&(N=he.slice(0,we)),N.length>he.length&&(N=he),N}const F=()=>(m||(m=new Float32Array(Qh)),m),z=()=>{h=0},G=he=>{const we=F(),Ce=he.length;if(Ce>=Qh){we.set(he.subarray(Ce-Qh)),h=Qh;return}if(h+Ce<=Qh){we.set(he,h),h+=Ce;return}const Me=h+Ce-Qh;we.copyWithin(0,Me,h),h-=Me,we.set(he,h),h+=Ce},Y=()=>{$&&(clearTimeout($),$=null)},oe=()=>{Y(),y=!1,C=!1,_=!1,T=D$,P="",N="",I=!1,U=0,z()},te=()=>{if(n||!y||_||C||$)return;if(h<CU){$=setTimeout(()=>{$=null,te()},T);return}const he=performance.now()-b;if(he<T&&b!==0){$=setTimeout(()=>{$=null,te()},T-he);return}if(I5||yp||e.partialsEnabled&&!e.partialsEnabled())return;const we=F(),Ce=new Float32Array(h);Ce.set(we.subarray(0,h)),w+=1,S=w,C=!0,j=performance.now(),b=j,r.postMessage({type:"transcribe-partial",audio:Ce,seq:w},[Ce.buffer])},J=he=>he.length===0?Promise.resolve():yp?(gt.warn("speech","transcribeAudio: speech disabled (worker respawn limit hit)"),n||e.onError("Speech recognition disabled — please reload the app."),Promise.resolve()):new Promise(we=>{u.push(we),w+=1;const Ce=w;k=Ce,r.postMessage({type:"transcribe",audio:he,seq:Ce},[he.buffer])}),K=he=>{const we=J(he);return f.add(we),we.finally(()=>{f.delete(we)}),we},Z=he=>{var we,Ce,Me,be,se;if(he.data.type==="result"){const ve=he.data.text,xe=he.data.seq??0;xe&&xe<k&>.warn("speech","result: seq below latestFinalSeq (delivering anyway)",{seq:xe,latestFinalSeq:k}),!n&&ve&&e.onFinal(ve),(we=u.shift())==null||we()}else if(he.data.type==="partial"){const ve=he.data.seq??0,xe=he.data.text??"",Ve=performance.now()-j;C=!1,Ve>=z$?(_=!0,gt.warn("speech","partials.disabled.budget",{elapsedMs:Math.round(Ve),seq:ve})):Ve>=B$&&(T=Math.min(T*2,L$),gt.warn("speech","partials.slowdown",{elapsedMs:Math.round(Ve),newIntervalMs:T,seq:ve})),I||(I=!0,Ve>jU&&T<500&&(T=500,gt.info("speech","partials.probe.slow_host",{elapsedMs:Math.round(Ve),newIntervalMs:500})));const Re=ve!==S||ve<=k;if(!n&&!Re&&xe){const We=q(xe);We&&((Ce=e.onPartial)==null||Ce.call(e,We),U===0&&(U=performance.now(),gt.info("speech","partial.first",{msSinceSpeechStart:Math.round(U-x)})))}te()}else if(he.data.type==="partial-error"){const ve=performance.now()-j;C=!1,ve>=z$?(_=!0,gt.warn("speech","partials.disabled.budget (after error)",{elapsedMs:Math.round(ve),seq:he.data.seq})):ve>=B$&&(T=Math.min(T*2,L$),gt.warn("speech","partials.slowdown (after error)",{elapsedMs:Math.round(ve),newIntervalMs:T,seq:he.data.seq})),gt.warn("speech","partial encode failed",{error:he.data.error,seq:he.data.seq}),te()}else he.data.type==="error"?(n||e.onError(he.data.error),(Me=u.shift())==null||Me()):he.data.type==="status"?(n||(be=e.onModelStatus)==null||be.call(e,he.data.status,he.data.message),he.data.status==="ready"&&(yl=!0,Ts=!1)):he.data.type==="progress"&&(n||(se=e.onProgress)==null||se.call(e,he.data.pct))};r.addEventListener("message",Z);const re=he=>{var we,Ce;if(!n){for(gt.warn("speech","createRecognition: worker death event",he),(we=e.onStatusChange)==null||we.call(e,"restarting");u.length;)(Ce=u.shift())==null||Ce();if(f.clear(),Y(),C=!1,he.respawned){try{r.removeEventListener("message",Z)}catch{}r=x0(),r.addEventListener("message",Z)}}};return rj.add(re),{start:async()=>{if(!n){if(yp){e.onError("Speech recognition disabled — please reload the app.");return}!yl&&!Ts&&(Ts=!0,gt.info("speech","createRecognition.start: triggering model load"),r.postMessage({type:"load"})),gt.info("speech","createRecognition.start: initializing VAD",{modelReady:yl,modelLoading:Ts});try{const he=new URL("vad/",document.baseURI).href,we=e.inputDeviceId||null,Ce={channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0};we&&(Ce.deviceId={exact:we}),gt.info("speech","getUserMedia",{hasDeviceId:!!we,deviceIdPrefix:we?we.slice(0,8):null});const Me=await navigator.mediaDevices.getUserMedia({audio:Ce});s=Me,a=new AudioContext;for(const be of Me.getAudioTracks())be.addEventListener("ended",()=>{n||(gt.warn("speech","mic track ended (permission revoked or device removed)"),e.onError("Microphone disconnected or permission revoked"))});try{o=a.createMediaStreamSource(s),l=a.createAnalyser(),l.fftSize=2048,l.smoothingTimeConstant=.3,o.connect(l)}catch(be){gt.warn("speech","analyser init failed",{error:be instanceof Error?be.message:String(be)}),o=null,l=null}i=await _U.MicVAD.new({audioContext:a,getStream:async()=>Me,resumeStream:async()=>Me,pauseStream:async()=>{},baseAssetPath:he,onnxWASMBasePath:he,model:"v5",positiveSpeechThreshold:R5,negativeSpeechThreshold:M5,minSpeechMs:300,redemptionMs:1500,preSpeechPadMs:300,submitUserSpeechOnPause:!0,onFrameProcessed:(be,se)=>{var ve;n||((ve=e.onFrame)==null||ve.call(e,be),y&&(G(se),te()))},onSpeechStart:()=>{var be;n||(oe(),y=!0,x=performance.now(),(be=e.onSpeechStart)==null||be.call(e))},onSpeechEnd:be=>{var se;n||((se=e.onStatusChange)==null||se.call(e,"transcribing"),oe(),K(be))},onVADMisfire:()=>{var be,se;n||((be=e.onStatusChange)==null||be.call(e,"idle"),oe(),(se=e.onMisfire)==null||se.call(e))}}),i.start()}catch(he){const we=he instanceof Error?he.message:"Microphone access denied",Ce=he instanceof Error?he.stack:"";if(gt.error("speech","createRecognition.start: VAD init failed",{error:we,stack:Ce}),l){try{l.disconnect()}catch{}l=null}if(o){try{o.disconnect()}catch{}o=null}if(s){try{s.getTracks().forEach(Me=>Me.stop())}catch{}s=null}if(a){try{await a.close()}catch{}a=null}e.onError(we)}}},stop:async()=>{if(i)try{await i.pause()}catch{}for(oe();f.size>0;)await Promise.all(Array.from(f));if(i){try{await i.destroy()}catch{}i=null}if(l){try{l.disconnect()}catch{}l=null}if(o){try{o.disconnect()}catch{}o=null}if(s){try{s.getTracks().forEach(he=>he.stop())}catch{}s=null}if(a){try{await a.close()}catch{}a=null}},setVadThresholds:(he,we)=>{if(i)try{i.setOptions({positiveSpeechThreshold:he,negativeSpeechThreshold:we})}catch(Ce){gt.warn("speech","setVadThresholds failed",{error:Ce instanceof Error?Ce.message:String(Ce)})}},getAnalyser:()=>l,destroy:()=>{if(n=!0,oe(),i){try{i.destroy()}catch{}i=null}if(l){try{l.disconnect()}catch{}l=null}if(o){try{o.disconnect()}catch{}o=null}if(a){try{a.close()}catch{}a=null}if(s){try{s.getTracks().forEach(he=>he.stop())}catch{}s=null}rj.delete(re),r.removeEventListener("message",Z)}}}let Fv=null;const nj=new Set,ij=new Set;function OU(){for(const e of nj)try{e()}catch{}}function sj(){for(const e of ij)try{e()}catch{}}function PU(e){return e.replace(/```[\s\S]*?```/g,"").replace(/`([^`]+)`/g,"$1").replace(/^#{1,6}\s+/gm,"").replace(/\*{1,3}([^*]+)\*{1,3}/g,"$1").replace(/_{1,3}([^_]+)_{1,3}/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/^[-*_]{3,}\s*$/gm,"").replace(/^>\s?/gm,"").replace(/^[\s]*[-*+]\s/gm,"").replace(/^[\s]*\d+\.\s/gm,"").trim()}function RU(e){if(!window.speechSynthesis)return;const r=PU(e);if(!r)return;const n=new SpeechSynthesisUtterance(r);n.rate=1,n.pitch=1,n.onstart=()=>{Fv=performance.now(),OU()},n.onend=()=>{!window.speechSynthesis.speaking&&!window.speechSynthesis.pending&&(Fv=null,sj())},n.onerror=i=>{i.error!=="canceled"&&!window.speechSynthesis.speaking&&!window.speechSynthesis.pending&&(Fv=null,sj())},window.speechSynthesis.speak(n)}function L5(){window.speechSynthesis&&(window.speechSynthesis.cancel(),Fv=null,sj())}function B5(){var e;return((e=window.speechSynthesis)==null?void 0:e.speaking)??!1}function MU(){return Fv}function IU(e){return nj.add(e),()=>{nj.delete(e)}}function DU(e){return ij.add(e),()=>{ij.delete(e)}}function LU(e){B5()&&(e.setVadThresholds(F$,U$),gt.info("voice","tts.duck.on",{reason:"already-speaking-on-attach"}));const r=IU(()=>{e.setVadThresholds(F$,U$),gt.info("voice","tts.duck.on")}),n=DU(()=>{e.setVadThresholds(R5,M5),gt.info("voice","tts.duck.off")});return()=>{r(),n()}}const BU=[{match:/^(send|submit|enter)\.?$/i,data:"\r",label:"send"},{match:/^(cancel|escape)\.?$/i,data:"\x1B",label:"cancel"},{match:/^clear( line)?\.?$/i,data:"",label:"clear"}];function zU(e){const r=e.trim();return BU.find(n=>n.match.test(r))??null}const FU=4e4;let Wd=null;function bp(){Wd&&clearTimeout(Wd),Wd=setTimeout(()=>{Wd=null,Lt.getState().stopRecording()},FU)}function fx(){Wd&&(clearTimeout(Wd),Wd=null)}let Su=null,_u=null;const UU=.04,qU=.3;let w0=0,aj=0;function WU(e){_u!==null&&cancelAnimationFrame(_u);const r=()=>{if(Su===null||Lt.getState().submitCountdownStartAt===null){_u=null;return}const n=performance.now();if(n-aj<200&&w0>qU){const s=n-e;gt.info("voice","submit.preempted_by_voice",{reason:"vad",prob:w0.toFixed(2),msIntoCountdown:Math.round(s)}),yu(),bp();return}const i=z5();if(i){const s=new Uint8Array(i.fftSize);i.getByteTimeDomainData(s);let a=0;for(let o=0;o<s.length;o++){const u=(s[o]-128)/128;a+=u*u}const l=Math.sqrt(a/s.length);if(l>UU){const o=n-e;gt.info("voice","submit.preempted_by_voice",{reason:"rms",rms:l.toFixed(3),msIntoCountdown:Math.round(o)}),yu(),bp();return}}_u=requestAnimationFrame(r)};_u=requestAnimationFrame(r)}function HU(e){Su&&clearTimeout(Su);const r=Lt.getState().submitDelayMs,n=performance.now();Lt.setState({submitCountdownStartAt:n}),Su=setTimeout(()=>{Su=null,Lt.setState({submitCountdownStartAt:null});try{window.api.pty.write({tabId:e,data:"\r"})}catch(i){gt.warn("voice","submit pty.write failed",{error:i instanceof Error?i.message:String(i)})}bp()},r),WU(n)}function yu(){_u!==null&&(cancelAnimationFrame(_u),_u=null),Su&&(clearTimeout(Su),Su=null),Lt.getState().submitCountdownStartAt!==null&&Lt.setState({submitCountdownStartAt:null})}let Ni=null,ss=null;function z5(){var e;return((e=Ni==null?void 0:Ni.getAnalyser)==null?void 0:e.call(Ni))??null}const hx=1e4;let Uv=null;function px(){Uv&&(clearTimeout(Uv),Uv=null)}let o0=null,l0=null;function mx(){o0=null,l0&&(l0(),l0=null)}const VU=1500,GU=9e4;let gx=0,c0=null,oj=-1;function vx(){c0&&(clearTimeout(c0),c0=null,oj=-1)}const KU=new Set(["you","You","Thank you.","Thanks for watching.","Thanks for watching!","Thank you for watching.","Thank you for watching!",".","Bye.","Bye!"]),Lt=Gn((e,r)=>({isRecording:!1,ttsEnabled:!1,autoSubmit:!0,submitDelayMs:8e3,submitCountdownStartAt:null,lastTranscript:"",lastPartial:"",statusPill:"idle",partialsEnabled:!0,error:null,errorKind:null,modelStatus:"idle",loadingProgress:0,permissionState:"unknown",lastBargeInAt:null,hotkeyState:"idle",levelMeterEnabled:!0,turnDetectorState:"disabled",turnDetectorMode:"off",wizardArmed:!1,wizardOpen:!1,initModel:()=>{if(r().modelStatus!=="idle")return;gt.info("voice","initModel: kicking off preload"),e({modelStatus:"loading",error:null,errorKind:null,loadingProgress:0});const n=++gx,i=()=>{n===gx&&(vx(),oj=n,c0=setTimeout(()=>{oj===n&&r().modelStatus==="loading"&&(gt.warn("voice","mic.gate.timeout: no progress within 90s"),e({modelStatus:"error",error:"Model load timed out",errorKind:"timeout"}))},GU))};i(),TU((s,a)=>{n===gx&&(s==="ready"?(vx(),gt.info("voice","modelStatus -> ready"),e({modelStatus:"ready",loadingProgress:100,errorKind:null})):s==="error"?(vx(),gt.error("voice","modelStatus -> error",{msg:a}),e({modelStatus:"error",error:a,errorKind:"load"})):(i(),e({modelStatus:"loading"})))},s=>{n===gx&&(i(),e({loadingProgress:Math.round(s)}))})},resetAndRetryModel:()=>{gt.info("voice","mic.gate.retry"),vx(),AU(),e({modelStatus:"idle",error:null,errorKind:null,loadingProgress:0}),r().initModel()},startRecording:n=>{if(r().isRecording)return;if(Ni){gt.warn("voice","startRecording: prior handle still draining, ignoring");return}if(!gT()){e({error:"Microphone or Web Worker not available",errorKind:"recording"});return}const i=s=>{try{const a=NU({inputDeviceId:s,onStatusChange:l=>{e(l==="transcribing"?{statusPill:"transcribing"}:l==="restarting"?{statusPill:"restarting"}:{statusPill:"idle"})},onPartial:l=>{r().partialsEnabled&&e({lastPartial:l})},partialsEnabled:()=>r().partialsEnabled,onFrame:l=>{w0=l.isSpeech,aj=performance.now()},onSpeechStart:()=>{if(e({statusPill:"listening",lastPartial:""}),fx(),yu(),B5()){const o=MU(),u=o!==null?performance.now()-o:null;L5(),e({lastBargeInAt:performance.now()}),gt.info("voice","barge-in",{tabId:n,utteranceOffsetMs:u})}else gt.debug("voice","barge-in.no-op",{tabId:n})},onMisfire:()=>{e({lastPartial:"",statusPill:"idle"}),bp();const l=r().lastBargeInAt;l!==null&&performance.now()-l<600&>.warn("voice","barge-in.misfire",{tabId:n,sinceBargeInMs:Math.round(performance.now()-l)})},onFinal:l=>{bp();const o=l.trim();if(!o||KU.has(o)){e({lastTranscript:"",lastPartial:"",statusPill:"idle"});return}const u=zU(o);if(u){gt.info("voice","voice-command",{tabId:n,label:u.label,transcript:o}),window.api.pty.write({tabId:n,data:u.data}),e({lastTranscript:"",lastPartial:"",statusPill:"idle"}),yu();const m=window;m.__transcripts&&(m.__transcripts.push({tabId:n,text:o}),m.__transcripts.length>500&&m.__transcripts.shift());return}window.api.pty.write({tabId:n,data:o}),e({lastTranscript:"",lastPartial:"",statusPill:"idle"}),r().autoSubmit&&HU(n);const f=window;f.__transcripts&&(f.__transcripts.push({tabId:n,text:o}),f.__transcripts.length>500&&f.__transcripts.shift())},onError:l=>{gt.error("voice","recognition error",{err:l}),yu(),e({error:l,errorKind:"recording",isRecording:!1,lastPartial:"",statusPill:"idle"}),ss==null||ss(),ss=null,fx(),Ni==null||Ni.destroy(),Ni=null,ft.error(`Microphone error: ${l}`)},onModelStatus:l=>{l==="ready"?e({modelStatus:"ready",loadingProgress:100}):l==="loading"&&e({modelStatus:"loading"})},onProgress:l=>e({loadingProgress:Math.round(l)})});Ni=a,e({isRecording:!0,error:null,lastTranscript:"",lastPartial:"",statusPill:"listening"}),bp(),a.start().then(()=>{Ni===a&&(ss==null||ss(),ss=LU(a))}).catch(l=>{const o=l instanceof Error?l.message:String(l);gt.error("voice","handle.start() failed",{error:o}),ft.error(`Could not start mic: ${o}`)})}catch(a){e({error:a instanceof Error?a.message:"Failed to start recording",errorKind:"recording"})}};Promise.resolve().then(()=>{var s,a,l;return((l=(a=(s=window.api)==null?void 0:s.voice)==null?void 0:a.getDevicePref)==null?void 0:l.call(a))??Promise.resolve(null)}).then(s=>i((s==null?void 0:s.selectedDeviceId)??null)).catch(s=>{gt.warn("voice","getDevicePref failed; using default device",{error:s instanceof Error?s.message:String(s)}),i(null)})},stopRecording:()=>{const n=Ni;n&&(fx(),yu(),w0=0,aj=0,ss==null||ss(),ss=null,e({isRecording:!1,lastTranscript:"",lastPartial:"",statusPill:"idle"}),n.stop().finally(()=>{n.destroy(),Ni===n&&(Ni=null),r().hotkeyState==="stopping"&&(px(),e({hotkeyState:"idle"}))}))},restartWithDevice:async()=>{if(!r().isRecording)return;const n=Ni;if(!n)return;fx(),ss==null||ss(),ss=null,e({isRecording:!1,lastTranscript:"",lastPartial:""});try{await n.stop()}catch(a){gt.warn("voice","restartWithDevice: drain rejected",{error:a instanceof Error?a.message:String(a)})}n.destroy(),Ni===n&&(Ni=null);const{useSessions:i}=await rm(async()=>{const{useSessions:a}=await Promise.resolve().then(()=>tU);return{useSessions:a}},[],import.meta.url),s=i.getState().activeTabId;s&&r().startRecording(s)},toggleTTS:()=>e(n=>({ttsEnabled:!n.ttsEnabled})),setAutoSubmit:n=>e({autoSubmit:n}),setSubmitDelayMs:n=>e({submitDelayMs:Math.max(500,Math.min(13e3,Math.floor(n)))}),cancelSubmit:()=>yu(),setPartialsEnabled:n=>{r().partialsEnabled!==n&&(e({partialsEnabled:n}),n||e({lastPartial:""}))},clearError:()=>e({error:null,errorKind:null}),setPermissionState:n=>{r().permissionState!==n&&(gt.info("voice","mic.gate.permission_changed",{from:r().permissionState,to:n}),e({permissionState:n}))},setLevelMeterEnabled:n=>{r().levelMeterEnabled!==n&&e({levelMeterEnabled:n})},setTurnDetectorRuntimeState:n=>{r().turnDetectorState!==n&&(e({turnDetectorState:n}),n==="load_failed"?gt.warn("voice-turn","voice-turn.load_failed"):n==="runtime_error"?gt.warn("voice-turn","voice-turn.runtime_error"):n==="disabled"&>.info("voice-turn","voice-turn.fallback_to_vad"))},setWizardArmed:n=>{r().wizardArmed!==n&&e({wizardArmed:n})},openWizard:()=>{r().wizardOpen||e({wizardOpen:!0})},closeWizard:()=>{r().wizardOpen&&e({wizardOpen:!1})},armHotkey:({phase:n,source:i,mode:s,tabId:a})=>{const l=r(),{canRecord:o,reason:u}=lj(l);if(n==="down"){if(u==="error"||u==="load-timeout"){l.resetAndRetryModel(),gt.info("voice-hotkey","down.retry",{source:i,reason:u});return}if(!o&&u!=="loading"){gt.warn("voice-hotkey","miss-model-loading",{modelStatus:l.modelStatus,reason:u});return}if(l.hotkeyState==="recording"||l.isRecording){(s==="toggle"||i==="global")&&(e({hotkeyState:"stopping"}),px(),Uv=setTimeout(()=>{r().hotkeyState==="stopping"&&(gt.warn("voice-hotkey","drain-timeout",{durationMs:hx}),e({hotkeyState:"aborted"}),setTimeout(()=>{r().hotkeyState==="aborted"&&e({hotkeyState:"idle"})},0))},hx),l.stopRecording());return}if(u==="loading"){l.hotkeyState!=="armed"&&(e({hotkeyState:"armed"}),gt.info("voice-hotkey","armed",{source:i,modelStatus:l.modelStatus})),mx(),o0={tabId:a,source:i,mode:s},l0=Lt.subscribe((f,m)=>{if(o0&&f.modelStatus==="ready"&&m.modelStatus!=="ready"&&f.hotkeyState==="armed"){const h=o0;if(mx(),!h.tabId){gt.warn("voice-hotkey","armed-promote-no-tab",{source:h.source}),e({hotkeyState:"idle"});return}gt.info("voice-hotkey","armed-promote",h),e({hotkeyState:"recording"}),Lt.getState().startRecording(h.tabId)}});return}if(!a){gt.warn("voice-hotkey","no-active-tab",{source:i});return}gt.info("voice-hotkey","start",{source:i,mode:s,tabId:a}),l.startRecording(a),r().isRecording?e({hotkeyState:"recording"}):(gt.warn("voice-hotkey","start: recording did not engage",{errorKind:r().errorKind}),e({hotkeyState:"idle"}));return}if(!(s!=="hold"||i==="global")){if(l.hotkeyState==="armed"){mx(),gt.info("voice-hotkey","miss-model-loading-armed-up"),e({hotkeyState:"idle"});return}l.hotkeyState==="recording"&&(e({hotkeyState:"stopping"}),px(),Uv=setTimeout(()=>{r().hotkeyState==="stopping"&&(gt.warn("voice-hotkey","drain-timeout",{durationMs:hx}),e({hotkeyState:"aborted"}),setTimeout(()=>{r().hotkeyState==="aborted"&&e({hotkeyState:"idle"})},0))},hx),l.stopRecording())}},destroyHotkey:()=>{const n=r();if(mx(),yu(),n.hotkeyState==="recording"){gt.warn("voice-hotkey","destroyed-mid-recording"),e({hotkeyState:"destroyed"});try{n.stopRecording()}catch{}}else(n.hotkeyState==="armed"||n.hotkeyState==="stopping")&&(px(),e({hotkeyState:"destroyed"}))}})),XU=e=>({isRecording:e.isRecording,statusPill:e.statusPill,lastPartial:e.lastPartial,lastTranscript:e.lastTranscript,submitCountdownStartAt:e.submitCountdownStartAt}),lj=e=>gT()?e.permissionState==="denied"?{canRecord:!1,reason:"permission-denied"}:e.modelStatus==="ready"?{canRecord:!0,reason:"ready"}:e.modelStatus==="loading"?{canRecord:!1,reason:"loading"}:e.modelStatus==="error"?{canRecord:!1,reason:e.errorKind==="timeout"?"load-timeout":"error"}:{canRecord:!1,reason:"idle"}:{canRecord:!1,reason:"unsupported"};if(typeof window<"u"){const e=window;e.__voice=Lt,e.__transcripts=[]}function vT(e,r,n){return new Promise((i,s)=>{const a=setTimeout(()=>s(new Error(`${n} timed out after ${r}ms`)),r);e.then(l=>{clearTimeout(a),i(l)},l=>{clearTimeout(a),s(l)})})}const YU=5e3,yc=Gn(()=>({snapshot:null,loaded:!1}));let W$=!1,H$=!1,Qg;async function JU(){var e;if(!W$){W$=!0;try{const r=await vT(window.api.schedule.state(),YU,"schedule.state");yc.setState({snapshot:r,loaded:!0}),Qg=((e=r.paused)==null?void 0:e.reason)??null}catch(r){if(!H$){H$=!0;const n=r instanceof Error?r.message:String(r);ft.error(`Scheduler state hydrate failed: ${n}`)}Qg=null}window.api.schedule.onState(r=>{var i;const n=((i=r.paused)==null?void 0:i.reason)??null;Qg!==void 0&&n!==Qg&&(n==="auth"?ft.error("Scheduler paused: Claude sign-in expired or invalid. Restart the app or re-run `claude login`, then Resume."):n==="network"&&ft.error("Scheduler paused: billing endpoint unreachable. Will auto-resume in 30 minutes.")),Qg=n,yc.setState({snapshot:r,loaded:!0})})}}const QU=6e4,ZU=5e3,Xd=Gn(()=>({data:null,refreshing:!1}));let V$=!1,u0=null,G$=null,K$=!1;async function yT(){Xd.setState({refreshing:!0});let e=QU;try{const r=await vT(window.api.billing.fetch(),ZU,"billing.fetch");Xd.setState({data:r,refreshing:!1}),r.kind==="transient"?e=G$==="transient"?3e4:5e3:r.kind==="auth"&&(e=3e4),G$=r.kind}catch(r){if(Xd.setState({refreshing:!1}),!K$){K$=!0;const n=r instanceof Error?r.message:String(r);ft.warn(`Billing usage fetch failed: ${n}`)}}u0=setTimeout(yT,e)}function eq(){V$||(V$=!0,yT())}function Wy(e){return e?e.kind==="ok"||e.kind==="ok-stale"?e.data:e.kind==="auth"&&e.cached?e.cached:null:null}function tq(e){var r,n;return((n=(r=Wy(e))==null?void 0:r.usage.five_hour)==null?void 0:n.utilization)??0}function _0(){u0!==null&&(clearTimeout(u0),u0=null),yT()}function Do({name:e,size:r=17,stroke:n=1.6,className:i}){const s={width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round",className:i};switch(e){case"home":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M4 11l8-7 8 7"}),c.jsx("path",{d:"M6 10v9h12v-9"}),c.jsx("path",{d:"M10 19v-5h4v5"})]});case"terminal":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),c.jsx("path",{d:"M7 10l3 2-3 2"}),c.jsx("path",{d:"M13 14h4"})]});case"agents":case"subagents":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"7",cy:"9",r:"2.5"}),c.jsx("circle",{cx:"17",cy:"9",r:"2.5"}),c.jsx("circle",{cx:"12",cy:"17",r:"2.5"}),c.jsx("path",{d:"M8.6 11l2.8 4M15.4 11l-2.8 4M9.5 9h5"})]});case"agent-view":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"12",cy:"12",r:"9"}),c.jsx("circle",{cx:"12",cy:"12",r:"3"}),c.jsx("path",{d:"M3 12h2M19 12h2M12 3v2M12 19v2"})]});case"skills":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M12 3l2.5 5.5L20 9l-4 4 1 6-5-3-5 3 1-6-4-4 5.5-.5z"})});case"history":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"12",cy:"12",r:"8"}),c.jsx("path",{d:"M12 7v5l3 2"}),c.jsx("path",{d:"M4 6l2 2"})]});case"usage":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M4 19V8M10 19V5M16 19v-7M22 19H2"})});case"hive":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M8 4h8l4 7-4 7H8l-4-7z"}),c.jsx("circle",{cx:"12",cy:"11",r:"2.5"})]});case"knowledge-graph":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"6",cy:"7",r:"2.2"}),c.jsx("circle",{cx:"18",cy:"6",r:"2.2"}),c.jsx("circle",{cx:"17",cy:"18",r:"2.2"}),c.jsx("circle",{cx:"7",cy:"17",r:"2.2"}),c.jsx("path",{d:"M8 8l8 8M8 16l8-9M8 7h8"})]});case"plugins":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M9 3v4M15 3v4M5 7h14v6a5 5 0 01-5 5h-4a5 5 0 01-5-5V7z"})});case"mcp":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"3",y:"4",width:"18",height:"6",rx:"1.5"}),c.jsx("rect",{x:"3",y:"14",width:"18",height:"6",rx:"1.5"}),c.jsx("circle",{cx:"6.5",cy:"7",r:".5",fill:"currentColor"}),c.jsx("circle",{cx:"6.5",cy:"17",r:".5",fill:"currentColor"})]});case"hooks":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M12 4v9a3 3 0 003 3h5"}),c.jsx("path",{d:"M9 17l3 3 3-3"})]});case"keys":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"8",cy:"12",r:"4"}),c.jsx("path",{d:"M12 12h9M17 12v3M20 12v2"})]});case"plans":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),c.jsx("path",{d:"M8 9h8M8 13h8M8 17h5"})]});case"tasks":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"3",y:"4",width:"7",height:"7",rx:"1.5"}),c.jsx("rect",{x:"3",y:"13",width:"7",height:"7",rx:"1.5"}),c.jsx("path",{d:"M14 6h7M14 10h5M14 15h7M14 19h5"})]});case"projects":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M3 7l3-3h4l2 2h9v13H3z"})});case"docs":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M6 3h8l4 4v14H6z"}),c.jsx("path",{d:"M14 3v4h4M9 13h6M9 17h6M9 9h3"})]});case"memory":case"agent-memory":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M9 4a4 4 0 00-4 4v1a3 3 0 000 6v1a4 4 0 004 4h6a4 4 0 004-4v-1a3 3 0 000-6V8a4 4 0 00-4-4z"}),c.jsx("path",{d:"M9 9v6M12 6v12M15 9v6"})]});case"search":case"global-search":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"11",cy:"11",r:"6"}),c.jsx("path",{d:"M16 16l4 4"})]});case"chevron":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M9 6l6 6-6 6"})});case"caret":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M6 9l6 6 6-6"})});case"dot":return c.jsx("svg",{...s,children:c.jsx("circle",{cx:"12",cy:"12",r:"3",fill:"currentColor",stroke:"none"})});case"plus":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M12 5v14M5 12h14"})});case"folder":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M3 7l3-3h4l2 2h9v13H3z"})});case"file":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M7 3h7l4 4v14H7z"}),c.jsx("path",{d:"M14 3v4h4"})]});case"play":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M8 5l11 7-11 7z",fill:"currentColor",stroke:"none"})});case"pause":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"7",y:"5",width:"3.5",height:"14",fill:"currentColor",stroke:"none",rx:"0.5"}),c.jsx("rect",{x:"13.5",y:"5",width:"3.5",height:"14",fill:"currentColor",stroke:"none",rx:"0.5"})]});case"sparkle":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M12 4v6M12 14v6M4 12h6M14 12h6"})});case"book":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M4 5a2 2 0 012-2h6v18H6a2 2 0 01-2-2zM12 3h6a2 2 0 012 2v14H12z"})});case"compass":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"12",cy:"12",r:"8"}),c.jsx("path",{d:"M15 9l-2 5-5 2 2-5z",fill:"currentColor",stroke:"none"})]});case"scheduler":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"3",y:"5",width:"18",height:"15",rx:"2"}),c.jsx("path",{d:"M3 10h18M8 3v4M16 3v4"}),c.jsx("path",{d:"M8 14l2 2 4-4"})]});case"settings":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"12",cy:"12",r:"3"}),c.jsx("path",{d:"M12 2v3M12 19v3M4 12H1M23 12h-3M5.6 5.6l2.1 2.1M16.3 16.3l2.1 2.1M5.6 18.4l2.1-2.1M16.3 7.7l2.1-2.1"})]});case"mic":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"9",y:"3",width:"6",height:"12",rx:"3"}),c.jsx("path",{d:"M5 11a7 7 0 0014 0M12 18v3M9 21h6"})]});case"clock":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"12",cy:"12",r:"8"}),c.jsx("path",{d:"M12 7v5l3 2"})]});case"leaf":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M20 4c-9 0-14 5-14 11 0 3 2 5 5 5 6 0 9-5 9-14z"}),c.jsx("path",{d:"M6 20c2-5 5-8 11-11"})]});case"orchestrator":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"12",cy:"6",r:"2.5"}),c.jsx("circle",{cx:"5",cy:"17",r:"2.5"}),c.jsx("circle",{cx:"12",cy:"17",r:"2.5"}),c.jsx("circle",{cx:"19",cy:"17",r:"2.5"}),c.jsx("path",{d:"M12 8.5v6M12 14.5l-7 0M12 14.5l7 0"})]});case"race":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M5 4v16M5 5h7l-1 3h7v6h-7l-1 3H5"})});case"background":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M3 4h18v4H3zM3 10h18v4H3zM3 16h18v4H3z"}),c.jsx("circle",{cx:"6",cy:"6",r:".75",fill:"currentColor",stroke:"none"}),c.jsx("circle",{cx:"6",cy:"12",r:".75",fill:"currentColor",stroke:"none"}),c.jsx("circle",{cx:"6",cy:"18",r:".75",fill:"currentColor",stroke:"none"})]});case"repoviz":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"6",cy:"12",r:"3"}),c.jsx("circle",{cx:"18",cy:"6",r:"3"}),c.jsx("circle",{cx:"18",cy:"18",r:"3"}),c.jsx("path",{d:"M8.5 10.5L15.5 7.5M8.5 13.5L15.5 16.5"})]});case"system-prompt":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"4",y:"4",width:"16",height:"14",rx:"2"}),c.jsx("path",{d:"M8 10h8M8 14h5M9 18l-2 3M15 18l2 3"})]});case"permissions":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"5",y:"11",width:"14",height:"9",rx:"2"}),c.jsx("path",{d:"M8 11V8a4 4 0 018 0v3"}),c.jsx("circle",{cx:"12",cy:"15.5",r:"1.2",fill:"currentColor",stroke:"none"})]});case"tool":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M14 4a4 4 0 014 4l-7 7-4-4 7-7zM7 11l-3 3 6 6 3-3"})});case"quick-open":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),c.jsx("path",{d:"M3 9h18M7 13h10M7 16h6"})]});case"remote":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M5 12.5a7 7 0 0114 0M1.5 9a11 11 0 0121 0M8.5 16a3.5 3.5 0 017 0"}),c.jsx("circle",{cx:"12",cy:"20",r:"1",fill:"currentColor",stroke:"none"})]});default:return null}}const F5=e=>`sm.fileTree.expanded:${e}`;function rq(e){try{const r=localStorage.getItem(F5(e)),n=r?JSON.parse(r):[];return Array.isArray(n)?n.filter(i=>typeof i=="string"):[]}catch{return[]}}function nq(e,r){try{localStorage.setItem(F5(e),JSON.stringify([...r].slice(0,500)))}catch{}}function l1(e,r){const n=r+"/";let i=!1;const s=new Set;for(const a of e){if(a===r||a.startsWith(n)){i=!0;continue}s.add(a)}return i?s:e}const c1={modified:{color:"#e2a93d",label:"M"},added:{color:"#3fb950",label:"A"},deleted:{color:"#f85149",label:"D"},renamed:{color:"#a371f7",label:"R"},untracked:{color:"#8b949e",label:"U"},staged:{color:"#3fb950",label:"S"},conflict:{color:"#f85149",label:"!"}},iq=new Set(["md","txt","json","jsonl","ndjson","js","jsx","ts","tsx","py","go","rs","rb","c","cpp","h","hpp","java","sh","bash","css","scss","html","xml","yaml","yml","toml","ini","conf","env","log","sql","gitignore","png","jpg","jpeg","gif","svg","webp"]);function sq(e){const r=e.toLowerCase().split(".").pop()||"";return iq.has(r)}function aq(e,r){if(r)return"#d97757";switch(e.toLowerCase().split(".").pop()||""){case"ts":case"tsx":return"#3178c6";case"js":case"jsx":return"#f7df1e";case"json":return"#cbcb41";case"md":return"#8a93a0";case"css":case"scss":return"#cc6699";case"py":return"#3776ab";case"go":return"#00add8";case"rs":return"#dea584";case"sh":case"bash":return"#89e051";case"png":case"jpg":case"jpeg":case"gif":case"svg":return"#a4c639";default:return"#8a93a0"}}async function yx(e){var r;try{const n=window.api;return(r=n==null?void 0:n.git)!=null&&r.fileStatus?await n.git.fileStatus(e):{}}catch{return{}}}function oq({cwd:e,onPreviewFile:r,onSendToChat:n,activeTabId:i}){const[s,a]=D.useState([]),[l,o]=D.useState(new Set),u=D.useRef(l);u.current=l;const[f,m]=D.useState(""),[h,y]=D.useState(!1),[x,C]=D.useState(!1),[_,b]=D.useState(null),[w,S]=D.useState({}),[k,T]=D.useState(null),[j,$]=D.useState(null),[P,N]=D.useState(""),[I,U]=D.useState(null),[V,q]=D.useState(""),[F,z]=D.useState(null),G=D.useRef(null),Y=D.useRef(null),oe=D.useRef(0),te=D.useCallback(async()=>{if(!e)return;const Le=++oe.current;C(!0),b(null);const Ze=await window.api.files.list(e,h);oe.current===Le&&(Ze.ok?a(Ze.entries.map(ct=>({...ct}))):(b(Ze.error??"failed to list"),a([])),C(!1))},[e,h]),J=D.useCallback(async Le=>{const Ze=oe.current,ct=new Map;for(const dr of Le){const Xt=dr.split("/").length,Qt=ct.get(Xt);Qt?Qt.push(dr):ct.set(Xt,[dr])}const ut=[];for(const dr of[...ct.keys()].sort((Xt,Qt)=>Xt-Qt)){const Xt=ct.get(dr),Qt=await Promise.all(Xt.map(async cr=>({p:cr,result:await window.api.files.list(cr,h)})));if(oe.current!==Ze)return ut;for(const{p:cr,result:Or}of Qt)Or.ok?a(wr=>d0(wr,cr,Or.entries.map(sn=>({...sn})))):ut.push(cr)}return ut},[h]),K=D.useCallback(async Le=>(await te(),Le.length?J(Le):[]),[te,J]);D.useEffect(()=>{m(""),$(null),T(null),U(null),z(null),S({});const Le=rq(e),Ze=new Set(Le);u.current=Ze,o(Ze);let ct=!1;return(async()=>{const ut=await K(Le);ct||!ut.length||re(dr=>{const Xt=new Set;let Qt=!1;for(const cr of dr){if(ut.some(Or=>cr===Or||cr.startsWith(Or+"/"))){Qt=!0;continue}Xt.add(cr)}return Qt?Xt:dr})})(),yx(e).then(ut=>{ct||S(ut)}),()=>{ct=!0}},[e]);const Z=D.useRef(!0);D.useEffect(()=>{if(Z.current){Z.current=!1;return}K([...u.current])},[h]),D.useEffect(()=>{if(!e)return;const Le=window.setInterval(()=>{yx(e).then(S)},5e3);return()=>window.clearInterval(Le)},[e]),D.useEffect(()=>{if(!k)return;const Le=()=>T(null),Ze=ct=>{ct.key==="Escape"&&T(null)};return window.addEventListener("mousedown",Le),window.addEventListener("keydown",Ze),()=>{window.removeEventListener("mousedown",Le),window.removeEventListener("keydown",Ze)}},[k]),D.useEffect(()=>{j&&setTimeout(()=>{var Le;return(Le=G.current)==null?void 0:Le.select()},30)},[j]),D.useEffect(()=>{I&&setTimeout(()=>{var Le;return(Le=Y.current)==null?void 0:Le.focus()},30)},[I]);const re=D.useCallback(Le=>{const Ze=u.current,ct=Le(Ze);ct!==Ze&&(u.current=ct,o(ct),nq(e,ct))},[e]),he=D.useCallback(async Le=>{if(l.has(Le.path)){re(ct=>l1(ct,Le.path));return}if(re(ct=>new Set(ct).add(Le.path)),Le.children)return;const Ze=await window.api.files.list(Le.path,h);Ze.ok&&a(ct=>d0(ct,Le.path,Ze.entries.map(ut=>({...ut}))))},[l,h,re]),we=D.useCallback(async Le=>{if(Le===e){await te();return}const Ze=await window.api.files.list(Le,h);Ze.ok&&a(ct=>d0(ct,Le,Ze.entries.map(ut=>({...ut}))))},[e,te,h]),Ce=D.useCallback(Le=>{if(Le.isDirectory){he(Le);return}sq(Le.name)&&r?r(Le.path):window.api.files.openExternal(Le.path)},[he,r]),Me=D.useCallback(Le=>{if(n){n(Le);return}if(i){const Ze=Le.startsWith(e+"/")?Le.slice(e.length+1):Le;window.api.pty.write({tabId:i,data:`@${Ze} `})}},[n,i,e]),be=D.useCallback((Le,Ze)=>{Le.preventDefault(),Le.stopPropagation(),T({x:Le.clientX,y:Le.clientY,node:Ze})},[]),se=Le=>{$(Le.path),N(Le.name)},ve=async()=>{if(!j)return;const Le=P.trim();if(!Le){$(null);return}const Ze=await window.api.files.rename(j,Le);if($(null),Ze.ok){const ct=j.slice(0,j.lastIndexOf("/"));re(ut=>l1(ut,j)),await we(ct||e),yx(e).then(S)}else b(Ze.error??"rename failed")},xe=async()=>{if(!I)return;const Le=V.trim();if(!Le){U(null),q("");return}const Ze=await window.api.files.create(I.parent,Le,I.kind);U(null),q(""),Ze.ok?(await we(I.parent),I.kind==="folder"&&re(ct=>new Set(ct).add(I.parent))):b(Ze.error??"create failed")},Ve=async()=>{if(!F)return;const Le=await window.api.files.delete(F.path),Ze=F.path.slice(0,F.path.lastIndexOf("/"));z(null),Le.ok?(re(ct=>l1(ct,F.path)),await we(Ze||e),yx(e).then(S)):b(Le.error??"delete failed")},Re=D.useMemo(()=>{if(!f.trim())return s;const Le=f.toLowerCase();return s.filter(Ze=>Ze.name.toLowerCase().includes(Le))},[s,f]),We=(e==null?void 0:e.split("/").filter(Boolean).pop())||"project";return c.jsxs("div",{className:"w-60 h-full flex flex-col bg-bg-elev border-r border-line text-fg",children:[c.jsxs("div",{className:"p-3 border-b border-line shrink-0",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-2 min-w-0",children:[c.jsx(q5,{size:14,className:"shrink-0 text-accent"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("p",{className:"text-xs font-medium text-fg truncate",children:We}),c.jsx("p",{className:"text-[10px] text-fg-faint truncate",title:e,children:e})]}),c.jsx("button",{onClick:te,className:"p-1 rounded text-fg-faint hover:text-fg hover:bg-bg-hi transition-colors",title:"Refresh",disabled:x,children:c.jsx(hq,{size:12,className:x?"animate-spin":""})})]}),c.jsx("div",{className:"relative",children:c.jsx("input",{value:f,onChange:Le=>m(Le.target.value),placeholder:"Search files…",className:"w-full px-2 py-1 text-xs bg-bg-hi border border-line rounded text-fg placeholder-fg-faint focus:outline-none focus:border-accent/40"})})]}),c.jsxs("div",{className:"flex items-center gap-1 px-3 py-1.5 border-b border-line shrink-0",children:[c.jsx("button",{onClick:()=>U({parent:e,kind:"file"}),className:"p-1.5 rounded text-fg-faint hover:text-fg hover:bg-bg-hi transition-colors",title:"New file",children:c.jsx(pq,{size:12})}),c.jsx("button",{onClick:()=>U({parent:e,kind:"folder"}),className:"p-1.5 rounded text-fg-faint hover:text-fg hover:bg-bg-hi transition-colors",title:"New folder",children:c.jsx(mq,{size:12})}),c.jsx("div",{className:"flex-1"}),c.jsx("button",{onClick:()=>y(Le=>!Le),className:`p-1.5 rounded transition-colors ${h?"text-accent":"text-fg-faint hover:text-fg"} hover:bg-bg-hi`,title:h?"Hide hidden files":"Show hidden files",children:h?c.jsx(gq,{size:12}):c.jsx(vq,{size:12})})]}),c.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[_&&c.jsx("div",{className:"px-3 py-2 text-[11px] text-red-400",children:_}),!_&&Re.length===0&&!x&&c.jsx("div",{className:"p-4 text-center text-[11px] text-fg-faint",children:f?"no matches":"empty folder"}),!_&&c.jsx(U5,{nodes:Re,depth:0,expanded:l,gitStatus:w,renaming:j,renameValue:P,renameInputRef:G,onRenameChange:N,onRenameCommit:ve,onRenameCancel:()=>$(null),onToggleDir:he,onFileClick:Ce,onSendToChat:Me,onContextMenu:be})]}),c.jsx("div",{className:"px-3 py-1.5 border-t border-line text-[10px] text-fg-faint shrink-0",children:"Click to preview · Double-click external · Right-click for more"}),k&&c.jsx(lq,{x:k.x,y:k.y,node:k.node,onClose:()=>T(null),onRename:()=>{se(k.node),T(null)},onDelete:()=>{z(k.node),T(null)},onNewFile:()=>{U({parent:k.node.path,kind:"file"}),T(null)},onNewFolder:()=>{U({parent:k.node.path,kind:"folder"}),T(null)},onOpenExternal:()=>{window.api.files.openExternal(k.node.path),T(null)},onShowInFinder:()=>{window.api.files.showInFinder(k.node.path),T(null)},onCopyPath:()=>{var Le;(Le=navigator.clipboard)==null||Le.writeText(k.node.path),T(null)},onSendToChat:()=>{Me(k.node.path),T(null)}}),I&&c.jsx(X$,{title:`New ${I.kind}`,subtitle:`in ${cq(I.parent)}`,onCancel:()=>{U(null),q("")},onConfirm:xe,confirmLabel:"Create",confirmDisabled:!V.trim(),children:c.jsx("input",{ref:Y,value:V,onChange:Le=>q(Le.target.value),onKeyDown:Le=>{Le.key==="Enter"&&xe(),Le.key==="Escape"&&(U(null),q(""))},placeholder:I.kind==="file"?"filename.txt":"folder-name",className:"w-full px-3 py-2 rounded bg-bg-hi border border-line text-fg text-sm placeholder-fg-faint focus:outline-none focus:border-accent/50"})}),F&&c.jsx(X$,{title:`Delete ${F.isDirectory?"folder":"file"}`,subtitle:null,onCancel:()=>z(null),onConfirm:Ve,confirmLabel:"Delete",danger:!0,children:c.jsxs("p",{className:"text-sm text-fg-dim",children:["Move ",c.jsxs("span",{className:"text-fg font-medium",children:['"',F.name,'"']})," to the trash?",F.isDirectory&&c.jsx("span",{className:"block text-xs text-fg-faint mt-1",children:"All contents will be moved with it."})]})})]})}function U5(e){const{nodes:r,depth:n,expanded:i,gitStatus:s,renaming:a,onContextMenu:l}=e;return c.jsx(c.Fragment,{children:r.map(o=>{const u=i.has(o.path),f=a===o.path,m=s[o.path],h=aq(o.name,o.isDirectory);return c.jsxs("div",{children:[c.jsxs("div",{className:"group flex items-center gap-1.5 py-0.5 pr-2 cursor-pointer transition-colors hover:bg-bg-hi",style:{paddingLeft:`${8+n*14}px`},onClick:()=>{f||(o.isDirectory?e.onToggleDir(o):e.onFileClick(o))},onDoubleClick:()=>{o.isDirectory||window.api.files.openExternal(o.path)},onContextMenu:y=>l(y,o),children:[o.isDirectory?c.jsx(fq,{size:10,className:`shrink-0 text-fg-faint transition-transform ${u?"rotate-90":""}`}):c.jsx("span",{className:"w-[10px] shrink-0"}),o.isDirectory?u?c.jsx(uq,{size:12,color:h}):c.jsx(q5,{size:12,color:h}):c.jsx(dq,{size:12,color:h}),f?c.jsx("input",{ref:e.renameInputRef,value:e.renameValue,onChange:y=>e.onRenameChange(y.target.value),onClick:y=>y.stopPropagation(),onBlur:e.onRenameCommit,onKeyDown:y=>{y.key==="Enter"&&e.onRenameCommit(),y.key==="Escape"&&e.onRenameCancel()},className:"flex-1 min-w-0 px-1 py-0 text-xs bg-bg border border-accent/40 rounded text-fg focus:outline-none"}):c.jsx("span",{className:`flex-1 truncate text-xs ${o.name.startsWith(".")?"text-fg-faint":"text-fg-dim"}`,children:o.name}),m&&c.jsx("span",{className:"shrink-0 text-[9px] font-bold px-1 rounded",style:{color:c1[m].color,backgroundColor:`${c1[m].color}20`},title:m,children:c1[m].label}),!o.isDirectory&&c.jsx("button",{onClick:y=>{y.stopPropagation(),e.onSendToChat(o.path)},title:"Send @path to active terminal",className:"opacity-0 group-hover:opacity-100 p-0.5 rounded text-fg-faint hover:text-accent hover:bg-bg transition-all shrink-0",children:c.jsx(yq,{size:10})})]}),o.isDirectory&&u&&o.children&&c.jsx(U5,{...e,nodes:o.children,depth:n+1})]},o.path)})})}function lq(e){const{x:r,y:n,node:i}=e;return c.jsxs("div",{onMouseDown:s=>s.stopPropagation(),className:"fixed z-[300] w-56 rounded-lg border border-line bg-bg-elev shadow-xl text-xs py-1",style:{left:r,top:n},children:[!i.isDirectory&&c.jsx(uu,{label:"Send to chat",onClick:e.onSendToChat}),c.jsx(uu,{label:"Open in default app",onClick:e.onOpenExternal}),c.jsx(uu,{label:"Reveal in OS",onClick:e.onShowInFinder}),c.jsx(u1,{}),c.jsx(uu,{label:"Copy path",onClick:e.onCopyPath}),c.jsx(uu,{label:"Rename",onClick:e.onRename}),i.isDirectory&&c.jsxs(c.Fragment,{children:[c.jsx(u1,{}),c.jsx(uu,{label:"New file",onClick:e.onNewFile}),c.jsx(uu,{label:"New folder",onClick:e.onNewFolder})]}),c.jsx(u1,{}),c.jsx(uu,{label:"Delete",onClick:e.onDelete,danger:!0})]})}function uu({label:e,onClick:r,danger:n}){return c.jsx("button",{onClick:r,className:`w-full text-left px-3 py-1.5 hover:bg-bg-hi transition-colors ${n?"text-red-400":"text-fg-dim hover:text-fg"}`,children:e})}function u1(){return c.jsx("div",{className:"my-1 border-t border-line"})}function X$(e){return c.jsx("div",{className:"fixed inset-0 z-[400] flex items-center justify-center bg-black/60",onMouseDown:r=>{r.target===r.currentTarget&&e.onCancel()},children:c.jsxs("div",{className:"w-96 rounded-lg border border-line bg-bg-elev p-4 shadow-2xl",children:[c.jsx("h3",{className:"text-sm font-medium text-fg mb-1",children:e.title}),e.subtitle&&c.jsx("p",{className:"text-[11px] text-fg-faint mb-3 truncate",children:e.subtitle}),c.jsx("div",{className:"mb-4",children:e.children}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx("button",{onClick:e.onCancel,className:"px-3 py-1 text-xs text-fg-dim hover:text-fg border border-line rounded transition-colors",children:"Cancel"}),c.jsx("button",{onClick:e.onConfirm,disabled:!!e.confirmDisabled,className:`px-3 py-1 text-xs text-white rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${e.danger?"bg-red-600 hover:bg-red-500":"bg-accent hover:bg-accent/90"}`,children:e.confirmLabel??"OK"})]})]})})}function cq(e){return e.split("/").filter(Boolean).pop()||e}function d0(e,r,n){return e.map(i=>i.path===r?{...i,children:n}:i.children?{...i,children:d0(i.children,r,n)}:i)}function kl({size:e,children:r,className:n,color:i}){return c.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:i||"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:n,children:r})}function q5({size:e,className:r,color:n}){return c.jsx(kl,{size:e,className:r,color:n,children:c.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function uq({size:e,className:r,color:n}){return c.jsx(kl,{size:e,className:r,color:n,children:c.jsx("path",{d:"M6 14l1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.93a2 2 0 0 1 1.66.9l.82 1.2a2 2 0 0 0 1.66.9H18a2 2 0 0 1 2 2v2"})})}function dq({size:e,className:r,color:n}){return c.jsxs(kl,{size:e,className:r,color:n,children:[c.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),c.jsx("polyline",{points:"14 2 14 8 20 8"})]})}function fq({size:e,className:r}){return c.jsx(kl,{size:e,className:r,children:c.jsx("polyline",{points:"9 18 15 12 9 6"})})}function hq({size:e,className:r}){return c.jsxs(kl,{size:e,className:r,children:[c.jsx("polyline",{points:"23 4 23 10 17 10"}),c.jsx("polyline",{points:"1 20 1 14 7 14"}),c.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]})}function pq({size:e,className:r}){return c.jsxs(kl,{size:e,className:r,children:[c.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),c.jsx("polyline",{points:"14 2 14 8 20 8"}),c.jsx("line",{x1:"12",y1:"18",x2:"12",y2:"12"}),c.jsx("line",{x1:"9",y1:"15",x2:"15",y2:"15"})]})}function mq({size:e,className:r}){return c.jsxs(kl,{size:e,className:r,children:[c.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"}),c.jsx("line",{x1:"12",y1:"11",x2:"12",y2:"17"}),c.jsx("line",{x1:"9",y1:"14",x2:"15",y2:"14"})]})}function gq({size:e,className:r}){return c.jsxs(kl,{size:e,className:r,children:[c.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),c.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function vq({size:e,className:r}){return c.jsxs(kl,{size:e,className:r,children:[c.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"}),c.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function yq({size:e,className:r}){return c.jsxs(kl,{size:e,className:r,children:[c.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),c.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})}function bq(e,r={}){switch(e){case"ready":return r.isRecording?"Stop voice input":"Start voice input (local Whisper, offline)";case"idle":return"Microphone — speech model not started";case"loading":return`Microphone — loading speech model, ${typeof r.loadingPct=="number"?Math.round(r.loadingPct):0} percent`;case"error":return r.errorMessage?`Microphone — speech model error: ${r.errorMessage}. Activate to retry.`:"Microphone — speech model error. Activate to retry.";case"load-timeout":return"Microphone — model load timed out. Activate to retry.";case"permission-denied":return"Microphone — permission denied. Open OS settings.";case"unsupported":return"Microphone — voice input not supported in this build."}}const Y$=e=>Symbol.iterator in e,J$=e=>"entries"in e,Q$=(e,r)=>{const n=e instanceof Map?e:new Map(e.entries()),i=r instanceof Map?r:new Map(r.entries());if(n.size!==i.size)return!1;for(const[s,a]of n)if(!i.has(s)||!Object.is(a,i.get(s)))return!1;return!0},xq=(e,r)=>{const n=e[Symbol.iterator](),i=r[Symbol.iterator]();let s=n.next(),a=i.next();for(;!s.done&&!a.done;){if(!Object.is(s.value,a.value))return!1;s=n.next(),a=i.next()}return!!s.done&&!!a.done};function wq(e,r){return Object.is(e,r)?!0:typeof e!="object"||e===null||typeof r!="object"||r===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(r)?!1:Y$(e)&&Y$(r)?J$(e)&&J$(r)?Q$(e,r):xq(e,r):Q$({entries:()=>Object.entries(e)},{entries:()=>Object.entries(r)})}function W5(e){const r=Fe.useRef(void 0);return n=>{const i=e(n);return wq(r.current,i)?r.current:r.current=i}}let Z$=0;const _q=1e3;function Sq(e){const r=performance.now();r-Z$<_q||(Z$=r,gt.debug("voice","mic.gate.click_rejected",{reason:e}))}function H5(){const e=Lt(f=>f.isRecording),r=Lt(f=>f.error),n=Lt(f=>f.loadingProgress),i=Lt(W5(lj)),s=()=>{const f=Lt.getState(),{canRecord:m,reason:h}=lj(f);if(f.isRecording)return f.stopRecording();if(f.wizardArmed&&!f.wizardOpen){f.openWizard();return}if(h==="error"||h==="load-timeout"){f.resetAndRetryModel();return}if(!m)return Sq(h);const y=Jt.getState().activeTabId;y&&f.startRecording(y)},a=bq(i.reason,{loadingPct:n,errorMessage:r,isRecording:e}),l=i.reason==="unsupported",o=!i.canRecord,u=i.reason==="loading"?"text-fg-faint animate-pulse cursor-wait":i.reason==="error"||i.reason==="load-timeout"?"text-red-400 cursor-pointer":i.reason==="permission-denied"?"text-amber-400 cursor-pointer":i.reason==="idle"?"text-fg-faint cursor-pointer":i.reason==="unsupported"?"text-fg-faint cursor-not-allowed":e?"text-red-400 ring-2 ring-red-400 animate-pulse":"text-fg-dim hover:text-fg";return c.jsx("button",{onClick:s,disabled:l,"aria-disabled":o,"aria-label":a,title:a,"data-testid":"mic-button","data-state":i.reason,className:`p-1.5 rounded transition-colors ${u}`,children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("rect",{x:"9",y:"1",width:"6",height:"12",rx:"3"}),c.jsx("path",{d:"M5 10a7 7 0 0 0 14 0"}),c.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"}),c.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"})]})})}function kq(){const e=Lt(n=>n.ttsEnabled),r=Lt(n=>n.toggleTTS);return c.jsxs("button",{onClick:r,title:e?"Read Claude replies aloud: ON":"Read Claude replies aloud: OFF",className:`px-1.5 py-1 rounded transition-colors flex items-center gap-1 ${e?"text-accent":"text-fg-dim hover:text-fg"}`,children:[c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),e?c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),c.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]}):c.jsxs(c.Fragment,{children:[c.jsx("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),c.jsx("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]})]}),c.jsx("span",{className:"text-[10px] font-medium tracking-wide",children:"TTS"})]})}const eN=[{key:"overview",label:"Home",icon:"home",hint:"Today's sessions + the 5-hour window"},{key:"terminal",label:"Terminal",icon:"terminal",hint:"Live Claude Code, in-app"},{key:"agent-view",label:"Agent-View",icon:"agent-view",liveKind:"agentView",hint:"Workshop scene of the active session"},{key:"subagents",label:"Subagents",icon:"hive",liveKind:"subagents",hint:"Sub-agents working in parallel"},{key:"scheduler",label:"Scheduler",icon:"scheduler",liveKind:"scheduler",hint:"Author PRDs + run them as claude -p jobs"},{key:"prompts",label:"Prompts",icon:"book",hint:"Click-to-insert prompt library"},{key:"tasks",label:"Tasks",icon:"tasks",liveKind:"tasks",hint:"Active to-dos across sessions"},{key:"history",label:"History",icon:"history",hint:"Every session, ever — resumable"},{key:"usage",label:"Usage",icon:"usage",hint:"Tokens, cost, sessions per day"},{key:"knowledge-graph",label:"Knowledge Graph",icon:"knowledge-graph",hint:"Distilled graph + Q&A over your prompt log"}],tN=[{key:"skills",label:"Skills",icon:"skills",hint:"Reusable instructions Claude loads"},{key:"plugins",label:"Plugins",icon:"plugins",hint:"Extensions for Claude Code"},{key:"mcp",label:"MCP Servers",icon:"mcp",hint:"External tools and integrations"},{key:"hooks",label:"Hooks",icon:"hooks",hint:"Run scripts on session events"},{key:"keybindings",label:"Keybindings",icon:"keys",hint:"Shortcuts you can override"},{key:"doc-editor",label:"Doc Editor",icon:"docs",hint:"Edit CLAUDE.md and friends"},{key:"memory",label:"Memory",icon:"memory",hint:"Workspace memory store"},{key:"projects",label:"Projects",icon:"projects",hint:"All known project folders"},{key:"system-prompt",label:"System Prompt",icon:"system-prompt",hint:"Personality and behavior"},{key:"permissions",label:"Permissions",icon:"permissions",hint:"Allow / deny rules"},{key:"settings",label:"Settings",icon:"settings",hint:"Theme, voice, billing window"},{key:"remote",label:"Remote",icon:"remote",hint:"Web remote control — disabled by default"}],rN=[{key:"voice",label:"Voice",icon:"mic",hint:"Whisper transcription + push-to-talk"},{key:"dispatch",label:"Dispatch",icon:"orchestrator",hint:"Boss · Orchestrate · Race · Hives"},{key:"repoviz",label:"Repo Viz",icon:"repoviz",hint:"Language + directory map"},{key:"search",label:"Search",icon:"global-search",hint:"⌘P file · ⌘⇧F content"}],cj="sm.almanac.sidebarWidth",V5=180,G5=480,uj=252;function Cq(){try{const e=parseInt(localStorage.getItem(cj)??"",10);if(Number.isFinite(e))return Math.min(G5,Math.max(V5,e))}catch{}return uj}const K5="sm.almanac.sidebarMode";function jq(){try{return localStorage.getItem(K5)==="files"?"files":"nav"}catch{return"nav"}}const X5="sm.almanac.collapsedGroups";function Eq(){try{const e=localStorage.getItem(X5);if(!e)return new Set;const r=JSON.parse(e);return Array.isArray(r)?new Set(r.filter(n=>n==="Workspace"||n==="Configure"||n==="Tools")):new Set}catch{return new Set}}function Tq(){const e=s0(a=>a.tabs),r=yc(a=>{var l;return(((l=a.snapshot)==null?void 0:l.jobs)??[]).some(o=>o.status==="running")}),[n,i]=D.useState(()=>Date.now());D.useEffect(()=>{const a=setInterval(()=>i(Date.now()),5e3);return()=>clearInterval(a)},[]);const s=Object.values(e);return{subagents:s.some(a=>a.agents.some(l=>n-l.at<6e4)),tasks:s.some(a=>a.todos.some(l=>l.status==="in_progress")),agentView:s.some(a=>a.lastEventAt>0&&n-a.lastEventAt<5e3),scheduler:r}}function Aq({active:e,onNavigate:r,onNewSession:n,onOpenFile:i}){const[s,a]=D.useState(()=>jq()),l=D.useCallback(k=>{a(k);try{localStorage.setItem(K5,k)}catch{}},[]),[o,u]=D.useState(()=>Eq()),f=D.useCallback(k=>{u(T=>{const j=new Set(T);j.has(k)?j.delete(k):j.add(k);try{localStorage.setItem(X5,JSON.stringify(Array.from(j)))}catch{}return j})},[]),m=Jt(k=>k.tabs),h=Jt(k=>k.activeTabId),y=m.find(k=>k.id===h)??null,x=Tq(),[C,_]=D.useState(()=>Cq()),b=D.useRef(C);b.current=C;const w=D.useCallback(k=>{k.preventDefault();const T=k.clientX,j=b.current;let $=j;const P=I=>{$=Math.min(G5,Math.max(V5,j+(I.clientX-T))),_($)},N=()=>{window.removeEventListener("pointermove",P),window.removeEventListener("pointerup",N),document.body.style.cursor="",document.body.style.userSelect="";try{localStorage.setItem(cj,String($))}catch{}};window.addEventListener("pointermove",P),window.addEventListener("pointerup",N),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]),S=D.useCallback(()=>{_(uj);try{localStorage.setItem(cj,String(uj))}catch{}},[]);return c.jsxs("aside",{className:"shrink-0 bg-bg-elev border-r border-line flex flex-col relative",style:{width:C},"data-testid":"tour-leftnav","aria-label":"Primary navigation",children:[c.jsx($q,{tab:y,onNewSession:n}),c.jsx("div",{className:"px-3.5 pt-3 pb-2 flex gap-1",children:["nav","files"].map(k=>c.jsx("button",{onClick:()=>l(k),"aria-pressed":s===k,className:`flex-1 py-1.5 rounded-md text-[12px] font-semibold tracking-[0.02em] transition-colors ${s===k?"bg-bg-hi text-fg border border-line":"text-fg-faint hover:text-fg-dim border border-transparent"}`,children:k==="nav"?"Navigate":"Files"},k))}),c.jsx("div",{className:"flex-1 min-h-0 overflow-auto px-2 pb-3",children:s==="nav"?c.jsxs(c.Fragment,{children:[c.jsx(d1,{label:"Workspace",collapsed:o.has("Workspace"),count:eN.length,onToggle:()=>f("Workspace")}),!o.has("Workspace")&&eN.map(k=>c.jsx(nN,{item:k,active:e===k.key,live:k.liveKind?x[k.liveKind]:!1,onClick:()=>r(k.key)},k.key)),c.jsx(d1,{label:"Configure",collapsed:o.has("Configure"),count:tN.length,onToggle:()=>f("Configure")}),!o.has("Configure")&&tN.map(k=>c.jsx(nN,{item:k,active:e===k.key,live:!1,onClick:()=>r(k.key)},k.key)),c.jsx(d1,{label:"Tools",collapsed:o.has("Tools"),count:rN.length,onToggle:()=>f("Tools")}),!o.has("Tools")&&rN.map(k=>c.jsx(Pq,{tool:k,active:e===k.key,onClick:()=>r(k.key)},k.key))]}):c.jsx(Rq,{tab:y,onOpenFile:i})}),c.jsx(Iq,{}),c.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar",title:"Drag to resize · double-click to reset",onPointerDown:w,onDoubleClick:S,className:"absolute top-0 right-0 h-full w-1.5 translate-x-1/2 z-10 cursor-col-resize hover:bg-accent/40 active:bg-accent/60 transition-colors"})]})}function $q({tab:e,onNewSession:r}){const n=(e==null?void 0:e.label)??"no session",i=Oq((e==null?void 0:e.cwd)??null);return c.jsxs("div",{className:"px-[18px] pt-[14px] pb-[10px] border-b border-rule",children:[c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.06em] text-fg-faint uppercase",children:"Project"}),c.jsxs("div",{className:"flex items-baseline gap-2 mt-1",children:[c.jsx("span",{className:"self-center w-2 h-2 rounded-full bg-sage"}),c.jsx("span",{className:"font-serif text-[18px] font-medium text-fg truncate",title:(e==null?void 0:e.cwd)??"",children:n})]}),c.jsx("div",{className:"text-[12px] text-fg-faint font-mono mt-0.5 truncate",children:i?`⌥${i}`:e?e.cwd:"—"}),c.jsxs("div",{className:"mt-3 flex items-stretch gap-1.5",children:[c.jsxs("button",{onClick:r,"data-testid":"tour-new-session",className:"flex-1 px-3 py-1.5 rounded-md bg-bg-hi border border-line text-fg text-[12.5px] font-medium hover:bg-bg-hi/80 hover:border-accent/40 transition-colors flex items-center justify-center gap-1.5",children:[c.jsx(Do,{name:"plus",size:13,stroke:1.8}),"New session"]}),c.jsx("div",{className:"flex items-center rounded-md bg-bg-hi border border-line",children:c.jsx(H5,{})})]})]})}const bx=new Map,Nq=3e4;function Oq(e){const[r,n]=D.useState(()=>{var i;return e?((i=bx.get(e))==null?void 0:i.value)??null:null});return D.useEffect(()=>{if(!e){n(null);return}let i=!1;return(async()=>{const a=bx.get(e);if(a&&Date.now()-a.ts<Nq){i||n(a.value);return}try{const l=await window.api.app.gitBranch(e);if(i)return;bx.set(e,{value:l,ts:Date.now()}),n(l)}catch{if(i)return;bx.set(e,{value:null,ts:Date.now()}),n(null)}})(),()=>{i=!0}},[e]),r}function d1({label:e,collapsed:r,count:n,onToggle:i}){return c.jsxs("button",{onClick:i,"aria-expanded":!r,title:r?`Expand ${e}`:`Collapse ${e}`,className:"group w-full flex items-center gap-1.5 px-3 pt-3.5 pb-1.5 font-serif italic text-[11px] font-bold tracking-[0.07em] uppercase text-fg-faint hover:text-fg-dim transition-colors text-left",children:[c.jsx("span",{"aria-hidden":!0,className:"inline-block w-2 text-[9px] not-italic transition-transform",style:{transform:r?"rotate(-90deg)":"rotate(0deg)"},children:"▾"}),c.jsx("span",{className:"flex-1",children:e}),r&&c.jsx("span",{className:"not-italic text-[10px] font-mono text-fg-faint/70 normal-case tracking-normal",children:n})]})}function nN({item:e,active:r,live:n,onClick:i}){return c.jsxs("button",{onClick:i,title:e.hint,className:`relative w-full flex items-center gap-3 px-3.5 py-[9px] rounded-[10px] text-left text-[14px] mb-0.5 transition-colors ${r?"bg-bg-hi text-fg font-semibold border border-line":"text-fg-dim hover:bg-bg-hi/50 hover:text-fg border border-transparent"}`,children:[r&&c.jsx("span",{"aria-hidden":!0,className:"absolute -left-[10px] top-3 bottom-3 w-[3px] rounded-sm bg-accent"}),c.jsx("span",{className:`inline-flex ${r?"text-accent":"text-fg-faint"}`,children:c.jsx(Do,{name:e.icon,size:17,stroke:1.6})}),c.jsx("span",{className:"flex-1 truncate",children:e.label}),n&&c.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-accent animate-pulse",title:"live activity"})]})}function Pq({tool:e,active:r,onClick:n}){return c.jsxs("button",{onClick:n,title:e.hint,className:`relative w-full flex items-center gap-3 px-3.5 py-[7px] rounded-[10px] text-left text-[13px] mb-0.5 transition-colors ${r?"bg-bg-hi text-fg font-semibold border border-line":"text-fg-dim hover:bg-bg-hi/50 hover:text-fg border border-transparent"}`,children:[r&&c.jsx("span",{"aria-hidden":!0,className:"absolute -left-[10px] top-2 bottom-2 w-[3px] rounded-sm bg-accent"}),c.jsx("span",{className:`inline-flex ${r?"text-accent":"text-fg-faint"}`,children:c.jsx(Do,{name:e.icon,size:15,stroke:1.6})}),c.jsx("span",{className:"flex-1 truncate",children:e.label})]})}function Rq({tab:e,onOpenFile:r}){return e?c.jsxs("div",{className:"pt-1",children:[c.jsx("div",{className:"px-3 pb-2 text-[11.5px] text-fg-faint font-mono truncate",title:e.cwd,children:Mq(e.cwd)}),c.jsx(oq,{cwd:e.cwd,activeTabId:e.id,onPreviewFile:r})]}):c.jsx("div",{className:"px-3 py-6 text-center text-[12px] text-fg-faint",children:"No session selected."})}function Mq(e){const r="/home/";if(e.startsWith(r)){const n=e.slice(r.length).split("/").slice(1).join("/");return n?`~/${n}`:"~"}return e}function Iq(){const e=Lt(l=>l.isRecording),r=Jt(l=>l.tabs),n=Jt(l=>l.activeTabId),i=r.find(l=>l.id===n)??null,[s,a]=D.useState(null);return D.useEffect(()=>{let l=!1;if(!(i!=null&&i.presetId)){a(null);return}return S5(i.presetId).then(o=>{l||a((o==null?void 0:o.model)??null)}).catch(()=>{l||a(null)}),()=>{l=!0}},[i==null?void 0:i.presetId]),c.jsxs("div",{className:"px-3.5 py-2.5 border-t border-rule flex items-center gap-2 text-[11.5px] text-fg-dim font-mono",children:[c.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${e?"bg-red-500 animate-pulse":"bg-sage"}`,title:e?"recording":"idle"}),c.jsx("span",{className:"truncate",title:s??"",children:e?"recording…":s?`Claude · ${Dq(s)}`:"Claude Code"})]})}function Dq(e){var n,i,s,a,l,o;const r=e.toLowerCase();if(r.includes("opus")){const u=(i=(n=e.match(/(\d+[-.]?\d*)/))==null?void 0:n[1])==null?void 0:i.replace("-",".");return u?`Opus ${u}`:"Opus"}if(r.includes("sonnet")){const u=(a=(s=e.match(/(\d+[-.]?\d*)/))==null?void 0:s[1])==null?void 0:a.replace("-",".");return u?`Sonnet ${u}`:"Sonnet"}if(r.includes("haiku")){const u=(o=(l=e.match(/(\d+[-.]?\d*)/))==null?void 0:l[1])==null?void 0:o.replace("-",".");return u?`Haiku ${u}`:"Haiku"}return e}function Lq({onNavigate:e}){const r=Jt(b=>b.tabs),n=Jt(b=>b.activeTabId),i=r.find(b=>b.id===n)??null,s=Uy(i),a=(s==null?void 0:s.lastEventAt)??0,l=Xd(b=>b.data),o=yc(b=>{var w;return((w=b.snapshot)==null?void 0:w.paused)??null}),[u,f]=D.useState(null),[,m]=D.useState(0);D.useEffect(()=>{const b=setInterval(()=>m(w=>w+1),6e4);return()=>clearInterval(b)},[]),D.useEffect(()=>{let b=!1;if(!(i!=null&&i.cwd)){f(null);return}return window.api.app.gitBranch(i.cwd).then(w=>{b||f(w)}).catch(()=>{b||f(null)}),()=>{b=!0}},[i==null?void 0:i.cwd]);const h=Wy(l),y=(h==null?void 0:h.usage.five_hour)??null,x=y?Math.round(y.utilization):null,C=(l==null?void 0:l.kind)==="ok"||(l==null?void 0:l.kind)==="ok-stale",_=a>0?Bq(Date.now()-a):"—";return c.jsxs("div",{className:"h-[30px] shrink-0 bg-bg-elev border-t border-line flex items-center gap-4 px-[18px] font-mono text-[11.5px] text-fg-dim","data-testid":"tour-statusbar",children:[c.jsxs("button",{onClick:()=>e==null?void 0:e("settings"),className:"flex items-center gap-1.5 hover:text-fg transition-colors",title:C?"Connected to Anthropic":"Disconnected",children:[c.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${C?"bg-sage":"bg-fg-faint"}`}),c.jsx("span",{children:C?"connected":"offline"})]}),c.jsx("button",{onClick:()=>e==null?void 0:e("usage"),className:"hover:text-fg transition-colors",title:"Open Usage",children:x!=null?`${x}% of 5h window used`:"5h —"}),o&&c.jsxs("button",{onClick:()=>e==null?void 0:e("scheduler"),title:"Scheduler is paused — click to open Scheduler",className:`flex items-center gap-1 px-1.5 py-0.5 rounded border font-mono text-[10.5px] transition-colors ${o.reason==="auth"||o.reason==="network"?"border-red-700/60 text-red-300 hover:bg-red-900/20":"border-amber-700/60 text-amber-300 hover:bg-amber-900/20"}`,children:[c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current opacity-80"}),"Scheduler paused · ",o.reason]}),i&&c.jsxs("span",{className:"text-fg-faint",title:i.cwd,children:[i.label,u&&c.jsxs("span",{className:"text-fg-dim",children:[" · ⌥",u]})]}),c.jsxs("span",{className:"text-fg-faint",children:["last activity: ",c.jsx("span",{className:"text-fg-dim",children:_})]}),c.jsx("span",{className:"flex-1"}),c.jsxs("span",{className:"text-fg-faint",children:["v","0.21.3"]})]})}function Bq(e){const r=Math.max(0,Math.floor(e/1e3));if(r<60)return`${r}s ago`;const n=Math.floor(r/60);return n<60?`${n}m ago`:`${Math.floor(n/60)}h ago`}var f1={exports:{}},iN;function zq(){return iN||(iN=1,(function(e,r){(function(n,i){e.exports=i()})(globalThis,(()=>(()=>{var n={4567:function(l,o,u){var f=this&&this.__decorate||function(S,k,T,j){var $,P=arguments.length,N=P<3?k:j===null?j=Object.getOwnPropertyDescriptor(k,T):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(S,k,T,j);else for(var I=S.length-1;I>=0;I--)($=S[I])&&(N=(P<3?$(N):P>3?$(k,T,N):$(k,T))||N);return P>3&&N&&Object.defineProperty(k,T,N),N},m=this&&this.__param||function(S,k){return function(T,j){k(T,j,S)}};Object.defineProperty(o,"__esModule",{value:!0}),o.AccessibilityManager=void 0;const h=u(9042),y=u(9924),x=u(844),C=u(4725),_=u(2585),b=u(3656);let w=o.AccessibilityManager=class extends x.Disposable{constructor(S,k,T,j){super(),this._terminal=S,this._coreBrowserService=T,this._renderService=j,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let $=0;$<this._terminal.rows;$++)this._rowElements[$]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[$]);if(this._topBoundaryFocusListener=$=>this._handleBoundaryFocus($,0),this._bottomBoundaryFocusListener=$=>this._handleBoundaryFocus($,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new y.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize(($=>this._handleResize($.rows)))),this.register(this._terminal.onRender(($=>this._refreshRows($.start,$.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar(($=>this._handleChar($)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
2895
|
+
*/var R$;function bU(){return R$||(R$=1,(function(e,r){var n=(()=>{var i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,l=Object.prototype.hasOwnProperty,o=(ae=>typeof Wa<"u"?Wa:typeof Proxy<"u"?new Proxy(ae,{get:(fe,ye)=>(typeof Wa<"u"?Wa:fe)[ye]}):ae)(function(ae){if(typeof Wa<"u")return Wa.apply(this,arguments);throw Error('Dynamic require of "'+ae+'" is not supported')}),u=(ae,fe)=>()=>(ae&&(fe=ae(ae=0)),fe),f=(ae,fe)=>{for(var ye in fe)i(ae,ye,{get:fe[ye],enumerable:!0})},m=(ae,fe,ye,$e)=>{if(fe&&typeof fe=="object"||typeof fe=="function")for(let je of a(fe))!l.call(ae,je)&&je!==ye&&i(ae,je,{get:()=>fe[je],enumerable:!($e=s(fe,je))||$e.enumerable});return ae},h=ae=>m(i({},"__esModule",{value:!0}),ae),y,x,C,_,b,w=u(()=>{y=new Map,x=[],C=(ae,fe,ye)=>{if(fe&&typeof fe.init=="function"&&typeof fe.createInferenceSessionHandler=="function"){let $e=y.get(ae);if($e===void 0)y.set(ae,{backend:fe,priority:ye});else{if($e.priority>ye)return;if($e.priority===ye&&$e.backend!==fe)throw new Error(`cannot register backend "${ae}" using priority ${ye}`)}if(ye>=0){let je=x.indexOf(ae);je!==-1&&x.splice(je,1);for(let ze=0;ze<x.length;ze++)if(y.get(x[ze]).priority<=ye){x.splice(ze,0,ae);return}x.push(ae)}return}throw new TypeError("not a valid backend")},_=async ae=>{let fe=y.get(ae);if(!fe)return"backend not found.";if(fe.initialized)return fe.backend;if(fe.aborted)return fe.error;{let ye=!!fe.initPromise;try{return ye||(fe.initPromise=fe.backend.init(ae)),await fe.initPromise,fe.initialized=!0,fe.backend}catch($e){return ye||(fe.error=`${$e}`,fe.aborted=!0),fe.error}finally{delete fe.initPromise}}},b=async ae=>{let fe=ae.executionProviders||[],ye=fe.map(Ue=>typeof Ue=="string"?Ue:Ue.name),$e=ye.length===0?x:ye,je,ze=[],Oe=new Set;for(let Ue of $e){let tt=await _(Ue);typeof tt=="string"?ze.push({name:Ue,err:tt}):(je||(je=tt),je===tt&&Oe.add(Ue))}if(!je)throw new Error(`no available backend found. ERR: ${ze.map(Ue=>`[${Ue.name}] ${Ue.err}`).join(", ")}`);for(let{name:Ue,err:tt}of ze)ye.includes(Ue)&&console.warn(`removing requested execution provider "${Ue}" from session options because it is not available: ${tt}`);let Pe=fe.filter(Ue=>Oe.has(typeof Ue=="string"?Ue:Ue.name));return[je,new Proxy(ae,{get:(Ue,tt)=>tt==="executionProviders"?Pe:Reflect.get(Ue,tt)})]}}),S=u(()=>{w()}),k,T=u(()=>{k="1.26.0"}),j,$,P=u(()=>{T(),j="warning",$={wasm:{},webgl:{},webgpu:{},versions:{common:k},set logLevel(ae){if(ae!==void 0){if(typeof ae!="string"||["verbose","info","warning","error","fatal"].indexOf(ae)===-1)throw new Error(`Unsupported logging level: ${ae}`);j=ae}},get logLevel(){return j}},Object.defineProperty($,"logLevel",{enumerable:!0})}),N,I=u(()=>{P(),N=$}),U,V,q=u(()=>{U=(ae,fe)=>{let ye=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);ye.width=ae.dims[3],ye.height=ae.dims[2];let $e=ye.getContext("2d");if($e!=null){let je,ze;(fe==null?void 0:fe.tensorLayout)!==void 0&&fe.tensorLayout==="NHWC"?(je=ae.dims[2],ze=ae.dims[3]):(je=ae.dims[3],ze=ae.dims[2]);let Oe=(fe==null?void 0:fe.format)!==void 0?fe.format:"RGB",Pe=fe==null?void 0:fe.norm,Ue,tt;Pe===void 0||Pe.mean===void 0?Ue=[255,255,255,255]:typeof Pe.mean=="number"?Ue=[Pe.mean,Pe.mean,Pe.mean,Pe.mean]:(Ue=[Pe.mean[0],Pe.mean[1],Pe.mean[2],0],Pe.mean[3]!==void 0&&(Ue[3]=Pe.mean[3])),Pe===void 0||Pe.bias===void 0?tt=[0,0,0,0]:typeof Pe.bias=="number"?tt=[Pe.bias,Pe.bias,Pe.bias,Pe.bias]:(tt=[Pe.bias[0],Pe.bias[1],Pe.bias[2],0],Pe.bias[3]!==void 0&&(tt[3]=Pe.bias[3]));let ot=ze*je,nt=0,Je=ot,Ot=ot*2,Be=-1;Oe==="RGBA"?(nt=0,Je=ot,Ot=ot*2,Be=ot*3):Oe==="RGB"?(nt=0,Je=ot,Ot=ot*2):Oe==="RBG"&&(nt=0,Ot=ot,Je=ot*2);for(let pt=0;pt<ze;pt++)for(let Br=0;Br<je;Br++){let nr=(ae.data[nt++]-tt[0])*Ue[0],ir=(ae.data[Je++]-tt[1])*Ue[1],zr=(ae.data[Ot++]-tt[2])*Ue[2],Ut=Be===-1?255:(ae.data[Be++]-tt[3])*Ue[3];$e.fillStyle="rgba("+nr+","+ir+","+zr+","+Ut+")",$e.fillRect(Br,pt,1,1)}if("toDataURL"in ye)return ye.toDataURL();throw new Error("toDataURL is not supported")}else throw new Error("Can not access image data")},V=(ae,fe)=>{let ye=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),$e;if(ye!=null){let je,ze,Oe;(fe==null?void 0:fe.tensorLayout)!==void 0&&fe.tensorLayout==="NHWC"?(je=ae.dims[2],ze=ae.dims[1],Oe=ae.dims[3]):(je=ae.dims[3],ze=ae.dims[2],Oe=ae.dims[1]);let Pe=fe!==void 0&&fe.format!==void 0?fe.format:"RGB",Ue=fe==null?void 0:fe.norm,tt,ot;Ue===void 0||Ue.mean===void 0?tt=[255,255,255,255]:typeof Ue.mean=="number"?tt=[Ue.mean,Ue.mean,Ue.mean,Ue.mean]:(tt=[Ue.mean[0],Ue.mean[1],Ue.mean[2],255],Ue.mean[3]!==void 0&&(tt[3]=Ue.mean[3])),Ue===void 0||Ue.bias===void 0?ot=[0,0,0,0]:typeof Ue.bias=="number"?ot=[Ue.bias,Ue.bias,Ue.bias,Ue.bias]:(ot=[Ue.bias[0],Ue.bias[1],Ue.bias[2],0],Ue.bias[3]!==void 0&&(ot[3]=Ue.bias[3]));let nt=ze*je;if(fe!==void 0&&(fe.format!==void 0&&Oe===4&&fe.format!=="RGBA"||Oe===3&&fe.format!=="RGB"&&fe.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let Je=4,Ot=0,Be=1,pt=2,Br=3,nr=0,ir=nt,zr=nt*2,Ut=-1;Pe==="RGBA"?(nr=0,ir=nt,zr=nt*2,Ut=nt*3):Pe==="RGB"?(nr=0,ir=nt,zr=nt*2):Pe==="RBG"&&(nr=0,zr=nt,ir=nt*2),$e=ye.createImageData(je,ze);for(let Hr=0;Hr<ze*je;Ot+=Je,Be+=Je,pt+=Je,Br+=Je,Hr++)$e.data[Ot]=(ae.data[nr++]-ot[0])*tt[0],$e.data[Be]=(ae.data[ir++]-ot[1])*tt[1],$e.data[pt]=(ae.data[zr++]-ot[2])*tt[2],$e.data[Br]=Ut===-1?255:(ae.data[Ut++]-ot[3])*tt[3]}else throw new Error("Can not access image data");return $e}}),F,z,G,Y,oe,te,J=u(()=>{ve(),F=(ae,fe)=>{if(ae===void 0)throw new Error("Image buffer must be defined");if(fe.height===void 0||fe.width===void 0)throw new Error("Image height and width must be defined");if(fe.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");let{height:ye,width:$e}=fe,je=fe.norm??{mean:255,bias:0},ze,Oe;typeof je.mean=="number"?ze=[je.mean,je.mean,je.mean,je.mean]:ze=[je.mean[0],je.mean[1],je.mean[2],je.mean[3]??255],typeof je.bias=="number"?Oe=[je.bias,je.bias,je.bias,je.bias]:Oe=[je.bias[0],je.bias[1],je.bias[2],je.bias[3]??0];let Pe=fe.format!==void 0?fe.format:"RGBA",Ue=fe.tensorFormat!==void 0&&fe.tensorFormat!==void 0?fe.tensorFormat:"RGB",tt=ye*$e,ot=Ue==="RGBA"?new Float32Array(tt*4):new Float32Array(tt*3),nt=4,Je=0,Ot=1,Be=2,pt=3,Br=0,nr=tt,ir=tt*2,zr=-1;Pe==="RGB"&&(nt=3,Je=0,Ot=1,Be=2,pt=-1),Ue==="RGBA"?zr=tt*3:Ue==="RBG"?(Br=0,ir=tt,nr=tt*2):Ue==="BGR"&&(ir=0,nr=tt,Br=tt*2);for(let Ut=0;Ut<tt;Ut++,Je+=nt,Be+=nt,Ot+=nt,pt+=nt)ot[Br++]=(ae[Je]+Oe[0])/ze[0],ot[nr++]=(ae[Ot]+Oe[1])/ze[1],ot[ir++]=(ae[Be]+Oe[2])/ze[2],zr!==-1&&pt!==-1&&(ot[zr++]=(ae[pt]+Oe[3])/ze[3]);return Ue==="RGBA"?new se("float32",ot,[1,4,ye,$e]):new se("float32",ot,[1,3,ye,$e])},z=async(ae,fe)=>{let ye=typeof HTMLImageElement<"u"&&ae instanceof HTMLImageElement,$e=typeof ImageData<"u"&&ae instanceof ImageData,je=typeof ImageBitmap<"u"&&ae instanceof ImageBitmap,ze=typeof ae=="string",Oe,Pe=fe??{},Ue=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},tt=ot=>typeof HTMLCanvasElement<"u"&&ot instanceof HTMLCanvasElement||ot instanceof OffscreenCanvas?ot.getContext("2d"):null;if(ye){let ot=Ue();ot.width=ae.width,ot.height=ae.height;let nt=tt(ot);if(nt!=null){let Je=ae.height,Ot=ae.width;if(fe!==void 0&&fe.resizedHeight!==void 0&&fe.resizedWidth!==void 0&&(Je=fe.resizedHeight,Ot=fe.resizedWidth),fe!==void 0){if(Pe=fe,fe.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");Pe.tensorFormat="RGBA",Pe.height=Je,Pe.width=Ot}else Pe.tensorFormat="RGBA",Pe.height=Je,Pe.width=Ot;nt.drawImage(ae,0,0),Oe=nt.getImageData(0,0,Ot,Je).data}else throw new Error("Can not access image data")}else if($e){let ot,nt;if(fe!==void 0&&fe.resizedWidth!==void 0&&fe.resizedHeight!==void 0?(ot=fe.resizedHeight,nt=fe.resizedWidth):(ot=ae.height,nt=ae.width),fe!==void 0&&(Pe=fe),Pe.format="RGBA",Pe.height=ot,Pe.width=nt,fe!==void 0){let Je=Ue();Je.width=nt,Je.height=ot;let Ot=tt(Je);if(Ot!=null)Ot.putImageData(ae,0,0),Oe=Ot.getImageData(0,0,nt,ot).data;else throw new Error("Can not access image data")}else Oe=ae.data}else if(je){if(fe===void 0)throw new Error("Please provide image config with format for Imagebitmap");let ot=Ue();ot.width=ae.width,ot.height=ae.height;let nt=tt(ot);if(nt!=null){let Je=ae.height,Ot=ae.width;return nt.drawImage(ae,0,0,Ot,Je),Oe=nt.getImageData(0,0,Ot,Je).data,Pe.height=Je,Pe.width=Ot,F(Oe,Pe)}else throw new Error("Can not access image data")}else{if(ze)return new Promise((ot,nt)=>{let Je=Ue(),Ot=tt(Je);if(!ae||!Ot)return nt();let Be=new Image;Be.crossOrigin="Anonymous",Be.src=ae,Be.onload=()=>{Je.width=Be.width,Je.height=Be.height,Ot.drawImage(Be,0,0,Je.width,Je.height);let pt=Ot.getImageData(0,0,Je.width,Je.height);Pe.height=Je.height,Pe.width=Je.width,ot(F(pt.data,Pe))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(Oe!==void 0)return F(Oe,Pe);throw new Error("Input data provided is not supported - aborted tensor creation")},G=(ae,fe)=>{let{width:ye,height:$e,download:je,dispose:ze}=fe,Oe=[1,$e,ye,4];return new se({location:"texture",type:"float32",texture:ae,dims:Oe,download:je,dispose:ze})},Y=(ae,fe)=>{let{dataType:ye,dims:$e,download:je,dispose:ze}=fe;return new se({location:"gpu-buffer",type:ye??"float32",gpuBuffer:ae,dims:$e,download:je,dispose:ze})},oe=(ae,fe)=>{let{dataType:ye,dims:$e,download:je,dispose:ze}=fe;return new se({location:"ml-tensor",type:ye??"float32",mlTensor:ae,dims:$e,download:je,dispose:ze})},te=(ae,fe,ye)=>new se({location:"cpu-pinned",type:ae,data:fe,dims:ye??[fe.length]})}),K,Z,re,he,we=u(()=>{K=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),Z=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),re=!1,he=()=>{if(!re){re=!0;let ae=typeof BigInt64Array<"u"&&BigInt64Array.from,fe=typeof BigUint64Array<"u"&&BigUint64Array.from,ye=globalThis.Float16Array,$e=typeof ye<"u"&&ye.from;ae&&(K.set("int64",BigInt64Array),Z.set(BigInt64Array,"int64")),fe&&(K.set("uint64",BigUint64Array),Z.set(BigUint64Array,"uint64")),$e?(K.set("float16",ye),Z.set(ye,"float16")):K.set("float16",Uint16Array)}}}),Ce,Me,be=u(()=>{ve(),Ce=ae=>{let fe=1;for(let ye=0;ye<ae.length;ye++){let $e=ae[ye];if(typeof $e!="number"||!Number.isSafeInteger($e))throw new TypeError(`dims[${ye}] must be an integer, got: ${$e}`);if($e<0)throw new RangeError(`dims[${ye}] must be a non-negative integer, got: ${$e}`);fe*=$e}return fe},Me=(ae,fe)=>{switch(ae.location){case"cpu":return new se(ae.type,ae.data,fe);case"cpu-pinned":return new se({location:"cpu-pinned",data:ae.data,type:ae.type,dims:fe});case"texture":return new se({location:"texture",texture:ae.texture,type:ae.type,dims:fe});case"gpu-buffer":return new se({location:"gpu-buffer",gpuBuffer:ae.gpuBuffer,type:ae.type,dims:fe});case"ml-tensor":return new se({location:"ml-tensor",mlTensor:ae.mlTensor,type:ae.type,dims:fe});default:throw new Error(`tensorReshape: tensor location ${ae.location} is not supported`)}}}),se,ve=u(()=>{q(),J(),we(),be(),se=class{constructor(ae,fe,ye){he();let $e,je;if(typeof ae=="object"&&"location"in ae)switch(this.dataLocation=ae.location,$e=ae.type,je=ae.dims,ae.location){case"cpu-pinned":{let Oe=K.get($e);if(!Oe)throw new TypeError(`unsupported type "${$e}" to create tensor from pinned buffer`);if(!(ae.data instanceof Oe))throw new TypeError(`buffer should be of type ${Oe.name}`);this.cpuData=ae.data;break}case"texture":{if($e!=="float32")throw new TypeError(`unsupported type "${$e}" to create tensor from texture`);this.gpuTextureData=ae.texture,this.downloader=ae.download,this.disposer=ae.dispose;break}case"gpu-buffer":{if($e!=="float32"&&$e!=="float16"&&$e!=="int32"&&$e!=="int64"&&$e!=="uint32"&&$e!=="uint8"&&$e!=="bool"&&$e!=="uint4"&&$e!=="int4")throw new TypeError(`unsupported type "${$e}" to create tensor from gpu buffer`);this.gpuBufferData=ae.gpuBuffer,this.downloader=ae.download,this.disposer=ae.dispose;break}case"ml-tensor":{if($e!=="float32"&&$e!=="float16"&&$e!=="int32"&&$e!=="int64"&&$e!=="uint32"&&$e!=="uint64"&&$e!=="int8"&&$e!=="uint8"&&$e!=="bool"&&$e!=="uint4"&&$e!=="int4")throw new TypeError(`unsupported type "${$e}" to create tensor from MLTensor`);this.mlTensorData=ae.mlTensor,this.downloader=ae.download,this.disposer=ae.dispose;break}default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let Oe,Pe;if(typeof ae=="string")if($e=ae,Pe=ye,ae==="string"){if(!Array.isArray(fe))throw new TypeError("A string tensor's data must be a string array.");Oe=fe}else{let Ue=K.get(ae);if(Ue===void 0)throw new TypeError(`Unsupported tensor type: ${ae}.`);if(Array.isArray(fe)){if(ae==="float16"&&Ue===Uint16Array||ae==="uint4"||ae==="int4")throw new TypeError(`Creating a ${ae} tensor from number array is not supported. Please use ${Ue.name} as data.`);ae==="uint64"||ae==="int64"?Oe=Ue.from(fe,BigInt):Oe=Ue.from(fe)}else if(fe instanceof Ue)Oe=fe;else if(fe instanceof Uint8ClampedArray)if(ae==="uint8")Oe=Uint8Array.from(fe);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else if(ae==="float16"&&fe instanceof Uint16Array&&Ue!==Uint16Array)Oe=new globalThis.Float16Array(fe.buffer,fe.byteOffset,fe.length);else throw new TypeError(`A ${$e} tensor's data must be type of ${Ue}`)}else if(Pe=fe,Array.isArray(ae)){if(ae.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let Ue=typeof ae[0];if(Ue==="string")$e="string",Oe=ae;else if(Ue==="boolean")$e="bool",Oe=Uint8Array.from(ae);else throw new TypeError(`Invalid element type of data array: ${Ue}.`)}else if(ae instanceof Uint8ClampedArray)$e="uint8",Oe=Uint8Array.from(ae);else{let Ue=Z.get(ae.constructor);if(Ue===void 0)throw new TypeError(`Unsupported type for tensor data: ${ae.constructor}.`);$e=Ue,Oe=ae}if(Pe===void 0)Pe=[Oe.length];else if(!Array.isArray(Pe))throw new TypeError("A tensor's dims must be a number array");je=Pe,this.cpuData=Oe,this.dataLocation="cpu"}let ze=Ce(je);if(this.cpuData&&ze!==this.cpuData.length&&!(($e==="uint4"||$e==="int4")&&Math.ceil(ze/2)===this.cpuData.length))throw new Error(`Tensor's size(${ze}) does not match data length(${this.cpuData.length}).`);this.type=$e,this.dims=je,this.size=ze}static async fromImage(ae,fe){return z(ae,fe)}static fromTexture(ae,fe){return G(ae,fe)}static fromGpuBuffer(ae,fe){return Y(ae,fe)}static fromMLTensor(ae,fe){return oe(ae,fe)}static fromPinnedBuffer(ae,fe,ye){return te(ae,fe,ye)}toDataURL(ae){return U(this,ae)}toImageData(ae){return V(this,ae)}get data(){if(this.ensureValid(),!this.cpuData)throw new Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");return this.cpuData}get location(){return this.dataLocation}get texture(){if(this.ensureValid(),!this.gpuTextureData)throw new Error("The data is not stored as a WebGL texture.");return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw new Error("The data is not stored as a WebGPU buffer.");return this.gpuBufferData}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw new Error("The data is not stored as a WebNN MLTensor.");return this.mlTensorData}async getData(ae){switch(this.ensureValid(),this.dataLocation){case"cpu":case"cpu-pinned":return this.data;case"texture":case"gpu-buffer":case"ml-tensor":{if(!this.downloader)throw new Error("The current tensor is not created with a specified data downloader.");if(this.isDownloading)throw new Error("The current tensor is being downloaded.");try{this.isDownloading=!0;let fe=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=fe,ae&&this.disposer&&(this.disposer(),this.disposer=void 0),fe}finally{this.isDownloading=!1}}default:throw new Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw new Error("The current tensor is being downloaded.");this.disposer&&(this.disposer(),this.disposer=void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.mlTensorData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation="none"}ensureValid(){if(this.dataLocation==="none")throw new Error("The tensor is disposed.")}reshape(ae){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return Me(this,ae)}}}),xe,Ve=u(()=>{ve(),xe=se}),Re,We,Le,Ze,ct,ut,dr=u(()=>{P(),Re=(ae,fe)=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||console.timeStamp(`${ae}::ORT::${fe}`)},We=(ae,fe)=>{var je;let ye=((je=new Error().stack)==null?void 0:je.split(/\r\n|\r|\n/g))||[],$e=!1;for(let ze=0;ze<ye.length;ze++){if($e&&!ye[ze].includes("TRACE_FUNC")){let Oe=`FUNC_${ae}::${ye[ze].trim().split(" ")[1]}`;fe&&(Oe+=`::${fe}`),Re("CPU",Oe);return}ye[ze].includes("TRACE_FUNC")&&($e=!0)}},Le=ae=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||We("BEGIN",ae)},Ze=ae=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||We("END",ae)},ct=ae=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||console.time(`ORT::${ae}`)},ut=ae=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||console.timeEnd(`ORT::${ae}`)}}),Xt,Qt=u(()=>{w(),Ve(),dr(),Xt=class O5{constructor(fe){this.handler=fe}async run(fe,ye,$e){Le(),ct("InferenceSession.run");let je={},ze={};if(typeof fe!="object"||fe===null||fe instanceof xe||Array.isArray(fe))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let Oe=!0;if(typeof ye=="object"){if(ye===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(ye instanceof xe)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(ye)){if(ye.length===0)throw new TypeError("'fetches' cannot be an empty array.");Oe=!1;for(let tt of ye){if(typeof tt!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(tt)===-1)throw new RangeError(`'fetches' contains invalid output name: ${tt}.`);je[tt]=null}if(typeof $e=="object"&&$e!==null)ze=$e;else if(typeof $e<"u")throw new TypeError("'options' must be an object.")}else{let tt=!1,ot=Object.getOwnPropertyNames(ye);for(let nt of this.outputNames)if(ot.indexOf(nt)!==-1){let Je=ye[nt];(Je===null||Je instanceof xe)&&(tt=!0,Oe=!1,je[nt]=Je)}if(tt){if(typeof $e=="object"&&$e!==null)ze=$e;else if(typeof $e<"u")throw new TypeError("'options' must be an object.")}else ze=ye}}else if(typeof ye<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let tt of this.inputNames)if(typeof fe[tt]>"u")throw new Error(`input '${tt}' is missing in 'feeds'.`);if(Oe)for(let tt of this.outputNames)je[tt]=null;let Pe=await this.handler.run(fe,je,ze),Ue={};for(let tt in Pe)if(Object.hasOwnProperty.call(Pe,tt)){let ot=Pe[tt];ot instanceof xe?Ue[tt]=ot:Ue[tt]=new xe(ot.type,ot.data,ot.dims)}return ut("InferenceSession.run"),Ze(),Ue}async release(){return this.handler.dispose()}static async create(fe,ye,$e,je){Le(),ct("InferenceSession.create");let ze,Oe={};if(typeof fe=="string"){if(ze=fe,typeof ye=="object"&&ye!==null)Oe=ye;else if(typeof ye<"u")throw new TypeError("'options' must be an object.")}else if(fe instanceof Uint8Array){if(ze=fe,typeof ye=="object"&&ye!==null)Oe=ye;else if(typeof ye<"u")throw new TypeError("'options' must be an object.")}else if(fe instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&fe instanceof SharedArrayBuffer){let ot=fe,nt=0,Je=fe.byteLength;if(typeof ye=="object"&&ye!==null)Oe=ye;else if(typeof ye=="number"){if(nt=ye,!Number.isSafeInteger(nt))throw new RangeError("'byteOffset' must be an integer.");if(nt<0||nt>=ot.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${ot.byteLength}).`);if(Je=fe.byteLength-nt,typeof $e=="number"){if(Je=$e,!Number.isSafeInteger(Je))throw new RangeError("'byteLength' must be an integer.");if(Je<=0||nt+Je>ot.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${ot.byteLength-nt}].`);if(typeof je=="object"&&je!==null)Oe=je;else if(typeof je<"u")throw new TypeError("'options' must be an object.")}else if(typeof $e<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof ye<"u")throw new TypeError("'options' must be an object.");ze=new Uint8Array(ot,nt,Je)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[Pe,Ue]=await b(Oe),tt=await Pe.createInferenceSessionHandler(ze,Ue);return ut("InferenceSession.create"),Ze(),new O5(tt)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}get inputMetadata(){return this.handler.inputMetadata}get outputMetadata(){return this.handler.outputMetadata}}}),cr,Or=u(()=>{Qt(),cr=Xt}),wr=u(()=>{}),sn=u(()=>{}),Wr=u(()=>{}),ii=u(()=>{}),Kn={};f(Kn,{InferenceSession:()=>cr,TRACE:()=>Re,TRACE_EVENT_BEGIN:()=>ct,TRACE_EVENT_END:()=>ut,TRACE_FUNC_BEGIN:()=>Le,TRACE_FUNC_END:()=>Ze,Tensor:()=>xe,env:()=>N,registerBackend:()=>C});var mr=u(()=>{S(),I(),Or(),Ve(),wr(),sn(),dr(),Wr(),ii()}),vt=u(()=>{}),jt={};f(jt,{default:()=>Ir});var It,Pt,Ir,yi=u(()=>{var ae;Al(),bi(),pn(),It="ort-wasm-proxy-worker",Pt=((ae=globalThis.self)==null?void 0:ae.name)===It,Pt&&(self.onmessage=fe=>{let{type:ye,in:$e}=fe.data;try{switch(ye){case"init-wasm":us($e.wasm).then(()=>{Jn($e).then(()=>{postMessage({type:ye})},je=>{postMessage({type:ye,err:je})})},je=>{postMessage({type:ye,err:je})});break;case"init-ep":{let{epName:je,env:ze}=$e;fs(ze,je).then(()=>{postMessage({type:ye})},Oe=>{postMessage({type:ye,err:Oe})});break}case"copy-from":{let{buffer:je}=$e,ze=hr(je);postMessage({type:ye,out:ze});break}case"create":{let{model:je,options:ze}=$e;ps(je,ze).then(Oe=>{postMessage({type:ye,out:Oe})},Oe=>{postMessage({type:ye,err:Oe})});break}case"release":Uo($e),postMessage({type:ye});break;case"run":{let{sessionId:je,inputIndices:ze,inputs:Oe,outputIndices:Pe,options:Ue}=$e;Qe(je,ze,Oe,Pe,new Array(Pe.length).fill(null),Ue).then(tt=>{tt.some(ot=>ot[3]!=="cpu")?postMessage({type:ye,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:ye,out:tt},$c([...Oe,...tt]))},tt=>{postMessage({type:ye,err:tt})});break}case"end-profiling":Is($e),postMessage({type:ye});break;default:}}catch(je){postMessage({type:ye,err:je})}}),Ir=Pt?null:fe=>new Worker(fe??Cr,{type:"classic",name:It})}),Sa,Ii,Cr,si,In,Ge,rt,$t,ur,Pr,Yr,an,Di,pn=u(()=>{vt(),Sa=typeof location>"u"?void 0:location.origin,Ii=()=>{var ae,fe;return typeof document<"u"?(ae=document.currentScript)==null?void 0:ae.src:typeof self<"u"?(fe=self.location)==null?void 0:fe.href:void 0},Cr=Ii(),si=()=>{if(Cr&&!Cr.startsWith("blob:"))return Cr.substring(0,Cr.lastIndexOf("/")+1)},In=(ae,fe)=>{try{let ye=fe??Cr;return(ye?new URL(ae,ye):new URL(ae)).origin===Sa}catch{return!1}},Ge=(ae,fe)=>{let ye=fe??Cr;try{return(ye?new URL(ae,ye):new URL(ae)).href}catch{return}},rt=(ae,fe)=>`${fe??"./"}${ae}`,$t=async ae=>{let fe=await(await fetch(ae,{credentials:"same-origin"})).blob();return URL.createObjectURL(fe)},ur=async ae=>(await import(ae)).default,Pr=(yi(),h(jt)).default,Yr=async()=>{if(!Cr)throw new Error("Failed to load proxy worker: cannot determine the script source URL.");if(In(Cr))return[void 0,Pr()];let ae=await $t(Cr);return[ae,Pr(ae)]},an=void 0,Di=async(ae,fe,ye,$e)=>{let je=an&&!(ae||fe);if(je)if(Cr)je=In(Cr)||$e&&!ye;else if($e&&!ye)je=!0;else throw new Error("cannot determine the script source URL.");if(je)return[void 0,an];{let ze="ort-wasm-simd-threaded.mjs",Oe=ae??Ge(ze,fe),Pe=ye&&Oe&&!In(Oe,fe),Ue=Pe?await $t(Oe):Oe??rt(ze,fe);return[Pe?Ue:void 0,await ur(Ue)]}}}),es,Li,_r,Xn,El,Ps,Rs,us,Kt,bi=u(()=>{pn(),Li=!1,_r=!1,Xn=!1,El=()=>{if(typeof SharedArrayBuffer>"u")return!1;try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch{return!1}},Ps=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch{return!1}},Rs=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,19,1,17,0,65,1,253,15,65,2,253,15,65,3,253,15,253,147,2,11]))}catch{return!1}},us=async ae=>{if(Li)return Promise.resolve();if(_r)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(Xn)throw new Error("previous call to 'initializeWebAssembly()' failed.");_r=!0;let fe=ae.initTimeout,ye=ae.numThreads;if(ae.simd!==!1){if(ae.simd==="relaxed"){if(!Rs())throw new Error("Relaxed WebAssembly SIMD is not supported in the current environment.")}else if(!Ps())throw new Error("WebAssembly SIMD is not supported in the current environment.")}let $e=El();ye>1&&!$e&&(typeof self<"u"&&!self.crossOriginIsolated&&console.warn("env.wasm.numThreads is set to "+ye+", but this will not work unless you enable crossOriginIsolated mode. See https://web.dev/cross-origin-isolation-guide/ for more info."),console.warn("WebAssembly multi-threading is not supported in the current environment. Falling back to single-threading."),ae.numThreads=ye=1);let je=ae.wasmPaths,ze=typeof je=="string"?je:void 0,Oe=je==null?void 0:je.mjs,Pe=(Oe==null?void 0:Oe.href)??Oe,Ue=je==null?void 0:je.wasm,tt=(Ue==null?void 0:Ue.href)??Ue,ot=ae.wasmBinary,[nt,Je]=await Di(Pe,ze,ye>1,!!ot||!!tt),Ot=!1,Be=[];if(fe>0&&Be.push(new Promise(pt=>{setTimeout(()=>{Ot=!0,pt()},fe)})),Be.push(new Promise((pt,Br)=>{let nr={numThreads:ye};if(ot)nr.wasmBinary=ot,nr.locateFile=ir=>ir;else if(tt||ze)nr.locateFile=ir=>tt??ze+ir;else if(Pe&&Pe.indexOf("blob:")!==0)nr.locateFile=ir=>new URL(ir,Pe).href;else if(nt){let ir=si();ir&&(nr.locateFile=zr=>ir+zr)}Je(nr).then(ir=>{_r=!1,Li=!0,es=ir,pt(),nt&&URL.revokeObjectURL(nt)},ir=>{_r=!1,Xn=!0,Br(ir)})})),await Promise.race(Be),Ot)throw new Error(`WebAssembly backend initializing failed due to timeout: ${fe}ms`)},Kt=()=>{if(Li&&es)return es;throw new Error("WebAssembly is not initialized yet.")}}),Sr,ai,Nt,ea=u(()=>{bi(),Sr=(ae,fe)=>{let ye=Kt(),$e=ye.lengthBytesUTF8(ae)+1,je=ye._malloc($e);return ye.stringToUTF8(ae,je,$e),fe.push(je),je},ai=(ae,fe,ye,$e)=>{if(typeof ae=="object"&&ae!==null){if(ye.has(ae))throw new Error("Circular reference in options");ye.add(ae)}Object.entries(ae).forEach(([je,ze])=>{let Oe=fe?fe+je:je;if(typeof ze=="object")ai(ze,Oe+".",ye,$e);else if(typeof ze=="string"||typeof ze=="number")$e(Oe,ze.toString());else if(typeof ze=="boolean")$e(Oe,ze?"1":"0");else throw new Error(`Can't handle extra config type: ${typeof ze}`)})},Nt=ae=>{let fe=Kt(),ye=fe.stackSave();try{let $e=fe.PTR_SIZE,je=fe.stackAlloc(2*$e);fe._OrtGetLastError(je,je+$e);let ze=Number(fe.getValue(je,$e===4?"i32":"i64")),Oe=fe.getValue(je+$e,"*"),Pe=Oe?fe.UTF8ToString(Oe):"";throw new Error(`${ae} ERROR_CODE: ${ze}, ERROR_MESSAGE: ${Pe}`)}finally{fe.stackRestore(ye)}}}),ka,zo=u(()=>{bi(),ea(),ka=ae=>{let fe=Kt(),ye=0,$e=[],je=ae||{};try{if((ae==null?void 0:ae.logSeverityLevel)===void 0)je.logSeverityLevel=2;else if(typeof ae.logSeverityLevel!="number"||!Number.isInteger(ae.logSeverityLevel)||ae.logSeverityLevel<0||ae.logSeverityLevel>4)throw new Error(`log severity level is not valid: ${ae.logSeverityLevel}`);if((ae==null?void 0:ae.logVerbosityLevel)===void 0)je.logVerbosityLevel=0;else if(typeof ae.logVerbosityLevel!="number"||!Number.isInteger(ae.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${ae.logVerbosityLevel}`);(ae==null?void 0:ae.terminate)===void 0&&(je.terminate=!1);let ze=0;return(ae==null?void 0:ae.tag)!==void 0&&(ze=Sr(ae.tag,$e)),ye=fe._OrtCreateRunOptions(je.logSeverityLevel,je.logVerbosityLevel,!!je.terminate,ze),ye===0&&Nt("Can't create run options."),(ae==null?void 0:ae.extra)!==void 0&&ai(ae.extra,"",new WeakSet,(Oe,Pe)=>{let Ue=Sr(Oe,$e),tt=Sr(Pe,$e);fe._OrtAddRunConfigEntry(ye,Ue,tt)!==0&&Nt(`Can't set a run config entry: ${Oe} - ${Pe}.`)}),[ye,$e]}catch(ze){throw ye!==0&&fe._OrtReleaseRunOptions(ye),$e.forEach(Oe=>fe._free(Oe)),ze}}}),ds,ta,xi,Dn,Fo,Tl,Jr=u(()=>{bi(),ea(),ds=ae=>{switch(ae){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"layout":return 3;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${ae}`)}},ta=ae=>{switch(ae){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${ae}`)}},xi=ae=>{ae.extra||(ae.extra={}),ae.extra.session||(ae.extra.session={});let fe=ae.extra.session;fe.use_ort_model_bytes_directly||(fe.use_ort_model_bytes_directly="1"),ae.executionProviders&&ae.executionProviders.some(ye=>(typeof ye=="string"?ye:ye.name)==="webgpu")&&(ae.enableMemPattern=!1)},Dn=(ae,fe,ye,$e)=>{let je=Sr(fe,$e),ze=Sr(ye,$e);Kt()._OrtAddSessionConfigEntry(ae,je,ze)!==0&&Nt(`Can't set a session config entry: ${fe} - ${ye}.`)},Fo=async(ae,fe,ye)=>{let $e=fe.executionProviders;for(let je of $e){let ze=typeof je=="string"?je:je.name,Oe=[];switch(ze){case"webnn":if(ze="WEBNN",Dn(ae,"session.disable_quant_qdq","1",ye),Dn(ae,"session.disable_qdq_constant_folding","1",ye),typeof je!="string"){let nt=je==null?void 0:je.deviceType;nt&&Dn(ae,"deviceType",nt,ye)}break;case"webgpu":if(ze="JS",typeof je!="string"){let nt=je;if(nt!=null&&nt.preferredLayout){if(nt.preferredLayout!=="NCHW"&&nt.preferredLayout!=="NHWC")throw new Error(`preferredLayout must be either 'NCHW' or 'NHWC': ${nt.preferredLayout}`);Dn(ae,"preferredLayout",nt.preferredLayout,ye)}}break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${ze}`)}let Pe=Sr(ze,ye),Ue=Oe.length,tt=0,ot=0;if(Ue>0){tt=Kt()._malloc(Ue*Kt().PTR_SIZE),ye.push(tt),ot=Kt()._malloc(Ue*Kt().PTR_SIZE),ye.push(ot);for(let nt=0;nt<Ue;nt++)Kt().setValue(tt+nt*Kt().PTR_SIZE,Oe[nt][0],"*"),Kt().setValue(ot+nt*Kt().PTR_SIZE,Oe[nt][1],"*")}await Kt()._OrtAppendExecutionProvider(ae,Pe,tt,ot,Ue)!==0&&Nt(`Can't append execution provider: ${ze}.`)}},Tl=async ae=>{let fe=Kt(),ye=0,$e=[],je=ae||{};xi(je);try{let ze=ds(je.graphOptimizationLevel??"all"),Oe=ta(je.executionMode??"sequential"),Pe=typeof je.logId=="string"?Sr(je.logId,$e):0,Ue=je.logSeverityLevel??2;if(!Number.isInteger(Ue)||Ue<0||Ue>4)throw new Error(`log severity level is not valid: ${Ue}`);let tt=je.logVerbosityLevel??0;if(!Number.isInteger(tt)||tt<0||tt>4)throw new Error(`log verbosity level is not valid: ${tt}`);let ot=typeof je.optimizedModelFilePath=="string"?Sr(je.optimizedModelFilePath,$e):0;if(ye=fe._OrtCreateSessionOptions(ze,!!je.enableCpuMemArena,!!je.enableMemPattern,Oe,!!je.enableProfiling,0,Pe,Ue,tt,ot),ye===0&&Nt("Can't create session options."),je.executionProviders&&await Fo(ye,je,$e),je.enableGraphCapture!==void 0){if(typeof je.enableGraphCapture!="boolean")throw new Error(`enableGraphCapture must be a boolean value: ${je.enableGraphCapture}`);Dn(ye,"enableGraphCapture",je.enableGraphCapture.toString(),$e)}if(je.freeDimensionOverrides)for(let[nt,Je]of Object.entries(je.freeDimensionOverrides)){if(typeof nt!="string")throw new Error(`free dimension override name must be a string: ${nt}`);if(typeof Je!="number"||!Number.isInteger(Je)||Je<0)throw new Error(`free dimension override value must be a non-negative integer: ${Je}`);let Ot=Sr(nt,$e);fe._OrtAddFreeDimensionOverride(ye,Ot,Je)!==0&&Nt(`Can't set a free dimension override: ${nt} - ${Je}.`)}return je.extra!==void 0&&ai(je.extra,"",new WeakSet,(nt,Je)=>{Dn(ye,nt,Je,$e)}),[ye,$e]}catch(ze){throw ye!==0&&fe._OrtReleaseSessionOptions(ye)!==0&&Nt("Can't release session options."),$e.forEach(Oe=>fe._free(Oe)),ze}}}),oi,kn,bn,Et,_e,it,_t,lr,mt=u(()=>{oi=ae=>{switch(ae){case"int8":return 3;case"uint8":return 2;case"bool":return 9;case"int16":return 5;case"uint16":return 4;case"int32":return 6;case"uint32":return 12;case"float16":return 10;case"float32":return 1;case"float64":return 11;case"string":return 8;case"int64":return 7;case"uint64":return 13;case"int4":return 22;case"uint4":return 21;default:throw new Error(`unsupported data type: ${ae}`)}},kn=ae=>{switch(ae){case 3:return"int8";case 2:return"uint8";case 9:return"bool";case 5:return"int16";case 4:return"uint16";case 6:return"int32";case 12:return"uint32";case 10:return"float16";case 1:return"float32";case 11:return"float64";case 8:return"string";case 7:return"int64";case 13:return"uint64";case 22:return"int4";case 21:return"uint4";default:throw new Error(`unsupported data type: ${ae}`)}},bn=(ae,fe)=>{let ye=[-1,4,1,1,2,2,4,8,-1,1,2,8,4,8,-1,-1,-1,-1,-1,-1,-1,.5,.5][ae],$e=typeof fe=="number"?fe:fe.reduce((je,ze)=>je*ze,1);return ye>0?Math.ceil($e*ye):void 0},Et=ae=>{switch(ae){case"float16":return typeof Float16Array<"u"&&Float16Array.from?Float16Array:Uint16Array;case"float32":return Float32Array;case"uint8":return Uint8Array;case"int8":return Int8Array;case"uint16":return Uint16Array;case"int16":return Int16Array;case"int32":return Int32Array;case"bool":return Uint8Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw new Error(`unsupported type: ${ae}`)}},_e=ae=>{switch(ae){case"verbose":return 0;case"info":return 1;case"warning":return 2;case"error":return 3;case"fatal":return 4;default:throw new Error(`unsupported logging level: ${ae}`)}},it=ae=>ae==="float32"||ae==="float16"||ae==="int32"||ae==="int64"||ae==="uint32"||ae==="uint8"||ae==="bool"||ae==="uint4"||ae==="int4",_t=ae=>ae==="float32"||ae==="float16"||ae==="int32"||ae==="int64"||ae==="uint32"||ae==="uint64"||ae==="int8"||ae==="uint8"||ae==="bool"||ae==="uint4"||ae==="int4",lr=ae=>{switch(ae){case"none":return 0;case"cpu":return 1;case"cpu-pinned":return 2;case"texture":return 3;case"gpu-buffer":return 4;case"ml-tensor":return 5;default:throw new Error(`unsupported data location: ${ae}`)}}}),fr,on=u(()=>{vt(),fr=async ae=>{if(typeof ae=="string"){let fe=await fetch(ae);if(!fe.ok)throw new Error(`failed to load external data file: ${ae}`);let ye=fe.headers.get("Content-Length"),$e=ye?parseInt(ye,10):0;if($e<1073741824)return new Uint8Array(await fe.arrayBuffer());{if(!fe.body)throw new Error(`failed to load external data file: ${ae}, no response body.`);let je=fe.body.getReader(),ze;try{ze=new ArrayBuffer($e)}catch(Pe){if(Pe instanceof RangeError){let Ue=Math.ceil($e/65536);ze=new WebAssembly.Memory({initial:Ue,maximum:Ue}).buffer}else throw Pe}let Oe=0;for(;;){let{done:Pe,value:Ue}=await je.read();if(Pe)break;let tt=Ue.byteLength;new Uint8Array(ze,Oe,tt).set(Ue),Oe+=tt}return new Uint8Array(ze,0,$e)}}else return ae instanceof Blob?new Uint8Array(await ae.arrayBuffer()):ae instanceof Uint8Array?ae:new Uint8Array(ae)}}),Yn,Jn,fs,Rr,hs,Ms,hr,ps,Uo,ra,Qe,Is,$c,Al=u(()=>{mr(),zo(),Jr(),mt(),bi(),ea(),on(),Yn=(ae,fe)=>{Kt()._OrtInit(ae,fe)!==0&&Nt("Can't initialize onnxruntime.")},Jn=async ae=>{Yn(ae.wasm.numThreads,_e(ae.logLevel))},fs=async(ae,fe)=>{var $e,je;(je=($e=Kt()).asyncInit)==null||je.call($e);let ye=ae.webgpu.adapter;if(fe==="webgpu"){if(typeof navigator>"u"||!navigator.gpu)throw new Error("WebGPU is not supported in current environment");if(ye){if(typeof ye.limits!="object"||typeof ye.features!="object"||typeof ye.requestDevice!="function")throw new Error("Invalid GPU adapter set in `env.webgpu.adapter`. It must be a GPUAdapter object.")}else{let ze=ae.webgpu.powerPreference;if(ze!==void 0&&ze!=="low-power"&&ze!=="high-performance")throw new Error(`Invalid powerPreference setting: "${ze}"`);let Oe=ae.webgpu.forceFallbackAdapter;if(Oe!==void 0&&typeof Oe!="boolean")throw new Error(`Invalid forceFallbackAdapter setting: "${Oe}"`);if(ye=await navigator.gpu.requestAdapter({powerPreference:ze,forceFallbackAdapter:Oe}),!ye)throw new Error('Failed to get GPU adapter. You may need to enable flag "--enable-unsafe-webgpu" if you are using Chrome.')}}if(fe==="webnn"&&(typeof navigator>"u"||!navigator.ml))throw new Error("WebNN is not supported in current environment")},Rr=new Map,hs=ae=>{let fe=Kt(),ye=fe.stackSave();try{let $e=fe.PTR_SIZE,je=fe.stackAlloc(2*$e);fe._OrtGetInputOutputCount(ae,je,je+$e)!==0&&Nt("Can't get session input/output count.");let ze=$e===4?"i32":"i64";return[Number(fe.getValue(je,ze)),Number(fe.getValue(je+$e,ze))]}finally{fe.stackRestore(ye)}},Ms=(ae,fe)=>{let ye=Kt(),$e=ye.stackSave(),je=0;try{let ze=ye.PTR_SIZE,Oe=ye.stackAlloc(2*ze);ye._OrtGetInputOutputMetadata(ae,fe,Oe,Oe+ze)!==0&&Nt("Can't get session input/output metadata.");let Pe=Number(ye.getValue(Oe,"*"));je=Number(ye.getValue(Oe+ze,"*"));let Ue=ye.HEAP32[je/4];if(Ue===0)return[Pe,0];let tt=ye.HEAPU32[je/4+1],ot=[];for(let nt=0;nt<tt;nt++){let Je=Number(ye.getValue(je+8+nt*ze,"*"));ot.push(Je!==0?ye.UTF8ToString(Je):Number(ye.getValue(je+8+(nt+tt)*ze,"*")))}return[Pe,Ue,ot]}finally{ye.stackRestore($e),je!==0&&ye._OrtFree(je)}},hr=ae=>{let fe=Kt(),ye=fe._malloc(ae.byteLength);if(ye===0)throw new Error(`Can't create a session. failed to allocate a buffer of size ${ae.byteLength}.`);return fe.HEAPU8.set(ae,ye),[ye,ae.byteLength]},ps=async(ae,fe)=>{var ot,nt,Je;let ye,$e,je=Kt();Array.isArray(ae)?[ye,$e]=ae:ae.buffer===je.HEAPU8.buffer?[ye,$e]=[ae.byteOffset,ae.byteLength]:[ye,$e]=hr(ae);let ze=0,Oe=0,Pe=[],Ue=[],tt=[];try{if([Oe,Pe]=await Tl(fe),(fe==null?void 0:fe.externalData)&&je.mountExternalData){let Hr=[];for(let yr of fe.externalData){let Ln=typeof yr=="string"?yr:yr.path;Hr.push(fr(typeof yr=="string"?yr:yr.data).then(ci=>{je.mountExternalData(Ln,ci)}))}await Promise.all(Hr)}for(let Hr of(fe==null?void 0:fe.executionProviders)??[])if((typeof Hr=="string"?Hr:Hr.name)==="webnn"){if(je.shouldTransferToMLTensor=!1,typeof Hr!="string"){let yr=Hr,Ln=yr==null?void 0:yr.context,ci=yr==null?void 0:yr.gpuDevice,wi=yr==null?void 0:yr.deviceType,Nl=yr==null?void 0:yr.powerPreference;Ln?je.currentContext=Ln:ci?je.currentContext=await je.webnnCreateMLContext(ci):je.currentContext=await je.webnnCreateMLContext({deviceType:wi,powerPreference:Nl})}else je.currentContext=await je.webnnCreateMLContext();break}ze=await je._OrtCreateSession(ye,$e,Oe),(ot=je.webgpuOnCreateSession)==null||ot.call(je,ze),ze===0&&Nt("Can't create a session."),(nt=je.jsepOnCreateSession)==null||nt.call(je),je.currentContext&&(je.webnnRegisterMLContext(ze,je.currentContext),je.currentContext=void 0,je.shouldTransferToMLTensor=!0);let[Ot,Be]=hs(ze),pt=!!(fe!=null&&fe.enableGraphCapture),Br=[],nr=[],ir=[],zr=[],Ut=[];for(let Hr=0;Hr<Ot;Hr++){let[yr,Ln,ci]=Ms(ze,Hr);yr===0&&Nt("Can't get an input name."),Ue.push(yr);let wi=je.UTF8ToString(yr);Br.push(wi),ir.push(Ln===0?{name:wi,isTensor:!1}:{name:wi,isTensor:!0,type:kn(Ln),shape:ci})}for(let Hr=0;Hr<Be;Hr++){let[yr,Ln,ci]=Ms(ze,Hr+Ot);yr===0&&Nt("Can't get an output name."),tt.push(yr);let wi=je.UTF8ToString(yr);nr.push(wi),zr.push(Ln===0?{name:wi,isTensor:!1}:{name:wi,isTensor:!0,type:kn(Ln),shape:ci})}return Rr.set(ze,[ze,Ue,tt,null,pt,!1]),[ze,Br,nr,ir,zr]}catch(Ot){throw Ue.forEach(Be=>je._OrtFree(Be)),tt.forEach(Be=>je._OrtFree(Be)),ze!==0&&je._OrtReleaseSession(ze)!==0&&Nt("Can't release session."),Ot}finally{je._free(ye),Oe!==0&&je._OrtReleaseSessionOptions(Oe)!==0&&Nt("Can't release session options."),Pe.forEach(Ot=>je._free(Ot)),(Je=je.unmountExternalData)==null||Je.call(je)}},Uo=ae=>{var Ue,tt,ot;let fe=Kt(),ye=Rr.get(ae);if(!ye)throw new Error(`cannot release session. invalid session id: ${ae}`);let[$e,je,ze,Oe,Pe]=ye;Oe&&(Pe&&fe._OrtClearBoundOutputs(Oe.handle)!==0&&Nt("Can't clear bound outputs."),fe._OrtReleaseBinding(Oe.handle)!==0&&Nt("Can't release IO binding.")),(Ue=fe.jsepOnReleaseSession)==null||Ue.call(fe,ae),(tt=fe.webnnOnReleaseSession)==null||tt.call(fe,ae),(ot=fe.webgpuOnReleaseSession)==null||ot.call(fe,ae),je.forEach(nt=>fe._OrtFree(nt)),ze.forEach(nt=>fe._OrtFree(nt)),fe._OrtReleaseSession($e)!==0&&Nt("Can't release session."),Rr.delete(ae)},ra=async(ae,fe,ye,$e,je,ze,Oe=!1)=>{if(!ae){fe.push(0);return}let Pe=Kt(),Ue=Pe.PTR_SIZE,tt=ae[0],ot=ae[1],nt=ae[3],Je=nt,Ot,Be;if(tt==="string"&&(nt==="gpu-buffer"||nt==="ml-tensor"))throw new Error("String tensor is not supported on GPU.");if(Oe&&nt!=="gpu-buffer")throw new Error(`External buffer must be provided for input/output index ${ze} when enableGraphCapture is true.`);if(nt==="gpu-buffer"){let nr=ae[2].gpuBuffer;Be=bn(oi(tt),ot);{let ir=Pe.jsepRegisterBuffer;if(!ir)throw new Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');Ot=ir($e,ze,nr,Be)}}else if(nt==="ml-tensor"){let nr=ae[2].mlTensor;Be=bn(oi(tt),ot);let ir=Pe.webnnRegisterMLTensor;if(!ir)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');Ot=ir($e,nr,oi(tt),ot)}else{let nr=ae[2];if(Array.isArray(nr)){Be=Ue*nr.length,Ot=Pe._malloc(Be),ye.push(Ot);for(let ir=0;ir<nr.length;ir++){if(typeof nr[ir]!="string")throw new TypeError(`tensor data at index ${ir} is not a string`);Pe.setValue(Ot+ir*Ue,Sr(nr[ir],ye),"*")}}else{let ir=Pe.webnnIsGraphInput,zr=Pe.webnnIsGraphOutput;if(tt!=="string"&&ir&&zr){let Ut=Pe.UTF8ToString(je);if(ir($e,Ut)||zr($e,Ut)){let Hr=oi(tt);Be=bn(Hr,ot),Je="ml-tensor";let yr=Pe.webnnCreateTemporaryTensor,Ln=Pe.webnnUploadTensor;if(!yr||!Ln)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');let ci=await yr($e,Hr,ot);Ln(ci,new Uint8Array(nr.buffer,nr.byteOffset,nr.byteLength)),Ot=ci}else Be=nr.byteLength,Ot=Pe._malloc(Be),ye.push(Ot),Pe.HEAPU8.set(new Uint8Array(nr.buffer,nr.byteOffset,Be),Ot)}else Be=nr.byteLength,Ot=Pe._malloc(Be),ye.push(Ot),Pe.HEAPU8.set(new Uint8Array(nr.buffer,nr.byteOffset,Be),Ot)}}let pt=Pe.stackSave(),Br=Pe.stackAlloc(4*ot.length);try{ot.forEach((ir,zr)=>Pe.setValue(Br+zr*Ue,ir,Ue===4?"i32":"i64"));let nr=Pe._OrtCreateTensor(oi(tt),Ot,Be,Br,ot.length,lr(Je));nr===0&&Nt(`Can't create tensor for input/output. session=${$e}, index=${ze}.`),fe.push(nr)}finally{Pe.stackRestore(pt)}},Qe=async(ae,fe,ye,$e,je,ze)=>{var _i,Mc,Fu;let Oe=Kt(),Pe=Oe.PTR_SIZE,Ue=Rr.get(ae);if(!Ue)throw new Error(`cannot run inference. invalid session id: ${ae}`);let tt=Ue[0],ot=Ue[1],nt=Ue[2],Je=Ue[3],Ot=Ue[4];Ue[5];let Be=fe.length,pt=$e.length,Br=0,nr=[],ir=[],zr=[],Ut=[],Hr=[],yr=Oe.stackSave(),Ln=Oe.stackAlloc(Be*Pe),ci=Oe.stackAlloc(Be*Pe),wi=Oe.stackAlloc(pt*Pe),Nl=Oe.stackAlloc(pt*Pe);try{[Br,nr]=ka(ze),ct("wasm prepareInputOutputTensor");for(let pr=0;pr<Be;pr++)await ra(ye[pr],ir,Ut,ae,ot[fe[pr]],fe[pr],Ot);for(let pr=0;pr<pt;pr++)await ra(je[pr],zr,Ut,ae,nt[$e[pr]],Be+$e[pr],Ot);ut("wasm prepareInputOutputTensor");for(let pr=0;pr<Be;pr++)Oe.setValue(Ln+pr*Pe,ir[pr],"*"),Oe.setValue(ci+pr*Pe,ot[fe[pr]],"*");for(let pr=0;pr<pt;pr++)Oe.setValue(wi+pr*Pe,zr[pr],"*"),Oe.setValue(Nl+pr*Pe,nt[$e[pr]],"*");(_i=Oe.jsepOnRunStart)==null||_i.call(Oe,tt),(Mc=Oe.webnnOnRunStart)==null||Mc.call(Oe,tt);let Bn;Bn=await Oe._OrtRun(tt,ci,Ln,Be,Nl,pt,wi,Br),Bn!==0&&Nt("failed to call OrtRun().");let Ls=[],Uu=[];ct("wasm ProcessOutputTensor");for(let pr=0;pr<pt;pr++){let vs=Number(Oe.getValue(wi+pr*Pe,"*"));if(vs===zr[pr]||Hr.includes(zr[pr])){Ls.push(je[pr]),vs!==zr[pr]&&Oe._OrtReleaseTensor(vs)!==0&&Nt("Can't release tensor.");continue}let xf=Oe.stackSave(),aa=Oe.stackAlloc(4*Pe),Wo=!1,Cn,Si=0;try{Oe._OrtGetTensorData(vs,aa,aa+Pe,aa+2*Pe,aa+3*Pe)!==0&&Nt(`Can't access output tensor data on index ${pr}.`);let Ic=Pe===4?"i32":"i64",ki=Number(Oe.getValue(aa,Ic));Si=Oe.getValue(aa+Pe,"*");let qu=Oe.getValue(aa+Pe*2,"*"),wf=Number(Oe.getValue(aa+Pe*3,Ic)),oa=[];for(let jn=0;jn<wf;jn++)oa.push(Number(Oe.getValue(qu+jn*Pe,Ic)));Oe._OrtFree(qu)!==0&&Nt("Can't free memory for tensor dims.");let ys=oa.reduce((jn,ln)=>jn*ln,1);Cn=kn(ki);let Bs=Je==null?void 0:Je.outputPreferredLocations[$e[pr]];if(Cn==="string"){if(Bs==="gpu-buffer"||Bs==="ml-tensor")throw new Error("String tensor is not supported on GPU.");let jn=[];for(let ln=0;ln<ys;ln++){let bs=Oe.getValue(Si+ln*Pe,"*"),Wu=Oe.getValue(Si+(ln+1)*Pe,"*"),Hu=ln===ys-1?void 0:Wu-bs;jn.push(Oe.UTF8ToString(bs,Hu))}Ls.push([Cn,oa,jn,"cpu"])}else if(Bs==="gpu-buffer"&&ys>0){let jn=Oe.jsepGetBuffer;if(!jn)throw new Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');let ln=jn(Si),bs=bn(ki,ys);if(bs===void 0||!it(Cn))throw new Error(`Unsupported data type: ${Cn}`);Wo=!0,Ls.push([Cn,oa,{gpuBuffer:ln,download:Oe.jsepCreateDownloader(ln,bs,Cn),dispose:()=>{Oe._OrtReleaseTensor(vs)!==0&&Nt("Can't release tensor.")}},"gpu-buffer"])}else if(Bs==="ml-tensor"&&ys>0){let jn=Oe.webnnEnsureTensor,ln=Oe.webnnIsGraphInputOutputTypeSupported;if(!jn||!ln)throw new Error('preferredLocation "ml-tensor" is not supported without using WebNN.');if(bn(ki,ys)===void 0||!_t(Cn))throw new Error(`Unsupported data type: ${Cn}`);if(!ln(ae,Cn,!1))throw new Error(`preferredLocation "ml-tensor" for ${Cn} output is not supported by current WebNN Context.`);let bs=await jn(ae,Si,ki,oa,!1);Wo=!0,Ls.push([Cn,oa,{mlTensor:bs,download:Oe.webnnCreateMLTensorDownloader(Si,Cn),dispose:()=>{Oe.webnnReleaseTensorId(Si),Oe._OrtReleaseTensor(vs)}},"ml-tensor"])}else if(Bs==="ml-tensor-cpu-output"&&ys>0){let jn=Oe.webnnCreateMLTensorDownloader(Si,Cn)(),ln=Ls.length;Wo=!0,Uu.push((async()=>{let bs=[ln,await jn];return Oe.webnnReleaseTensorId(Si),Oe._OrtReleaseTensor(vs),bs})()),Ls.push([Cn,oa,[],"cpu"])}else{let jn=Et(Cn),ln=new jn(ys);new Uint8Array(ln.buffer,ln.byteOffset,ln.byteLength).set(Oe.HEAPU8.subarray(Si,Si+ln.byteLength)),Ls.push([Cn,oa,ln,"cpu"])}}finally{Oe.stackRestore(xf),Cn==="string"&&Si&&Oe._free(Si),Wo||Oe._OrtReleaseTensor(vs)}}Je&&!Ot&&(Oe._OrtClearBoundOutputs(Je.handle)!==0&&Nt("Can't clear bound outputs."),Rr.set(ae,[tt,ot,nt,Je,Ot,!1]));for(let[pr,vs]of await Promise.all(Uu))Ls[pr][2]=vs;return ut("wasm ProcessOutputTensor"),Ls}finally{(Fu=Oe.webnnOnRunEnd)==null||Fu.call(Oe,tt),Oe.stackRestore(yr),ir.forEach(Bn=>Oe._OrtReleaseTensor(Bn)),zr.forEach(Bn=>Oe._OrtReleaseTensor(Bn)),Ut.forEach(Bn=>Oe._free(Bn)),Br!==0&&Oe._OrtReleaseRunOptions(Br),nr.forEach(Bn=>Oe._free(Bn))}},Is=ae=>{let fe=Kt(),ye=Rr.get(ae);if(!ye)throw new Error("invalid session id");let $e=ye[0],je=fe._OrtEndProfiling($e);je===0&&Nt("Can't get an profile file name."),fe._OrtFree(je)},$c=ae=>{let fe=[];for(let ye of ae){let $e=ye[2];!Array.isArray($e)&&"buffer"in $e&&fe.push($e.buffer)}return fe}}),gr,Ft,na,Ca,ja,ro,qo,no,ts,li,ms,gs,Ea,io,Ds,bf,so,ao,Lu=u(()=>{mr(),Al(),bi(),pn(),gr=()=>!!N.wasm.proxy&&typeof document<"u",na=!1,Ca=!1,ja=!1,no=new Map,ts=(ae,fe)=>{let ye=no.get(ae);ye?ye.push(fe):no.set(ae,[fe])},li=()=>{if(na||!Ca||ja||!Ft)throw new Error("worker not ready")},ms=ae=>{switch(ae.data.type){case"init-wasm":na=!1,ae.data.err?(ja=!0,qo[1](ae.data.err)):(Ca=!0,qo[0]()),ro&&(URL.revokeObjectURL(ro),ro=void 0);break;case"init-ep":case"copy-from":case"create":case"release":case"run":case"end-profiling":{let fe=no.get(ae.data.type);ae.data.err?fe.shift()[1](ae.data.err):fe.shift()[0](ae.data.out);break}}},gs=async()=>{if(!Ca){if(na)throw new Error("multiple calls to 'initWasm()' detected.");if(ja)throw new Error("previous call to 'initWasm()' failed.");if(na=!0,gr())return new Promise((ae,fe)=>{Ft==null||Ft.terminate(),Yr().then(([ye,$e])=>{try{Ft=$e,Ft.onerror=ze=>fe(ze),Ft.onmessage=ms,qo=[ae,fe];let je={type:"init-wasm",in:N};if(!je.in.wasm.wasmPaths&&ye){let ze=si();ze&&(je.in.wasm.wasmPaths=ze)}Ft.postMessage(je),ro=ye}catch(je){fe(je)}},fe)});try{await us(N.wasm),await Jn(N),Ca=!0}catch(ae){throw ja=!0,ae}finally{na=!1}}},Ea=async ae=>{if(gr())return li(),new Promise((fe,ye)=>{ts("init-ep",[fe,ye]);let $e={type:"init-ep",in:{epName:ae,env:N}};Ft.postMessage($e)});await fs(N,ae)},io=async ae=>gr()?(li(),new Promise((fe,ye)=>{ts("copy-from",[fe,ye]);let $e={type:"copy-from",in:{buffer:ae}};Ft.postMessage($e,[ae.buffer])})):hr(ae),Ds=async(ae,fe)=>{if(gr()){if(fe!=null&&fe.preferredOutputLocation)throw new Error('session option "preferredOutputLocation" is not supported for proxy.');return li(),new Promise((ye,$e)=>{ts("create",[ye,$e]);let je={type:"create",in:{model:ae,options:{...fe}}},ze=[];ae instanceof Uint8Array&&ze.push(ae.buffer),Ft.postMessage(je,ze)})}else return ps(ae,fe)},bf=async ae=>{if(gr())return li(),new Promise((fe,ye)=>{ts("release",[fe,ye]);let $e={type:"release",in:ae};Ft.postMessage($e)});Uo(ae)},so=async(ae,fe,ye,$e,je,ze)=>{if(gr()){if(ye.some(Oe=>Oe[3]!=="cpu"))throw new Error("input tensor on GPU is not supported for proxy.");if(je.some(Oe=>Oe))throw new Error("pre-allocated output tensor is not supported for proxy.");return li(),new Promise((Oe,Pe)=>{ts("run",[Oe,Pe]);let Ue=ye,tt={type:"run",in:{sessionId:ae,inputIndices:fe,inputs:Ue,outputIndices:$e,options:ze}};Ft.postMessage(tt,$c(Ue))})}else return Qe(ae,fe,ye,$e,je,ze)},ao=async ae=>{if(gr())return li(),new Promise((fe,ye)=>{ts("end-profiling",[fe,ye]);let $e={type:"end-profiling",in:ae};Ft.postMessage($e)});Is(ae)}}),Nc,oo,$l,Oc=u(()=>{mr(),Lu(),mt(),vt(),on(),Nc=(ae,fe)=>{switch(ae.location){case"cpu":return[ae.type,ae.dims,ae.data,"cpu"];case"gpu-buffer":return[ae.type,ae.dims,{gpuBuffer:ae.gpuBuffer},"gpu-buffer"];case"ml-tensor":return[ae.type,ae.dims,{mlTensor:ae.mlTensor},"ml-tensor"];default:throw new Error(`invalid data location: ${ae.location} for ${fe()}`)}},oo=ae=>{switch(ae[3]){case"cpu":return new xe(ae[0],ae[2],ae[1]);case"gpu-buffer":{let fe=ae[0];if(!it(fe))throw new Error(`not supported data type: ${fe} for deserializing GPU tensor`);let{gpuBuffer:ye,download:$e,dispose:je}=ae[2];return xe.fromGpuBuffer(ye,{dataType:fe,dims:ae[1],download:$e,dispose:je})}case"ml-tensor":{let fe=ae[0];if(!_t(fe))throw new Error(`not supported data type: ${fe} for deserializing MLTensor tensor`);let{mlTensor:ye,download:$e,dispose:je}=ae[2];return xe.fromMLTensor(ye,{dataType:fe,dims:ae[1],download:$e,dispose:je})}default:throw new Error(`invalid data location: ${ae[3]}`)}},$l=class{async fetchModelAndCopyToWasmMemory(ae){return io(await fr(ae))}async loadModel(ae,fe){Le();let ye;typeof ae=="string"?ye=await this.fetchModelAndCopyToWasmMemory(ae):ye=ae,[this.sessionId,this.inputNames,this.outputNames,this.inputMetadata,this.outputMetadata]=await Ds(ye,fe),Ze()}async dispose(){return bf(this.sessionId)}async run(ae,fe,ye){Le();let $e=[],je=[];Object.entries(ae).forEach(nt=>{let Je=nt[0],Ot=nt[1],Be=this.inputNames.indexOf(Je);if(Be===-1)throw new Error(`invalid input '${Je}'`);$e.push(Ot),je.push(Be)});let ze=[],Oe=[];Object.entries(fe).forEach(nt=>{let Je=nt[0],Ot=nt[1],Be=this.outputNames.indexOf(Je);if(Be===-1)throw new Error(`invalid output '${Je}'`);ze.push(Ot),Oe.push(Be)});let Pe=$e.map((nt,Je)=>Nc(nt,()=>`input "${this.inputNames[je[Je]]}"`)),Ue=ze.map((nt,Je)=>nt?Nc(nt,()=>`output "${this.outputNames[Oe[Je]]}"`):null),tt=await so(this.sessionId,je,Pe,Oe,Ue,ye),ot={};for(let nt=0;nt<tt.length;nt++)ot[this.outputNames[Oe[nt]]]=ze[nt]??oo(tt[nt]);return Ze(),ot}startProfiling(){}endProfiling(){ao(this.sessionId)}}}),ia={};f(ia,{OnnxruntimeWebAssemblyBackend:()=>sa,initializeFlags:()=>Ta,wasmBackend:()=>lo});var Ta,sa,lo,Bu=u(()=>{mr(),Lu(),Oc(),Ta=()=>{(typeof N.wasm.initTimeout!="number"||N.wasm.initTimeout<0)&&(N.wasm.initTimeout=0);let ae=N.wasm.simd;if(typeof ae!="boolean"&&ae!==void 0&&ae!=="fixed"&&ae!=="relaxed"&&(console.warn(`Property "env.wasm.simd" is set to unknown value "${ae}". Reset it to \`false\` and ignore SIMD feature checking.`),N.wasm.simd=!1),typeof N.wasm.proxy!="boolean"&&(N.wasm.proxy=!1),typeof N.wasm.trace!="boolean"&&(N.wasm.trace=!1),typeof N.wasm.numThreads!="number"||!Number.isInteger(N.wasm.numThreads)||N.wasm.numThreads<=0)if(typeof self<"u"&&!self.crossOriginIsolated)N.wasm.numThreads=1;else{let fe=typeof navigator>"u"?o("node:os").cpus().length:navigator.hardwareConcurrency;N.wasm.numThreads=Math.min(4,Math.ceil((fe||1)/2))}},sa=class{async init(ae){Ta(),await gs(),await Ea(ae)}async createInferenceSessionHandler(ae,fe){let ye=new $l;return await ye.loadModel(ae,fe),ye}},lo=new sa}),zu={};f(zu,{InferenceSession:()=>cr,TRACE:()=>Re,TRACE_EVENT_BEGIN:()=>ct,TRACE_EVENT_END:()=>ut,TRACE_FUNC_BEGIN:()=>Le,TRACE_FUNC_END:()=>Ze,Tensor:()=>xe,default:()=>Rc,env:()=>N,registerBackend:()=>C}),mr(),mr(),mr();var Pc="1.26.0",Rc=Kn;{let ae=(Bu(),h(ia)).wasmBackend;C("cpu",ae,10),C("wasm",ae,10)}return Object.defineProperty(N.versions,"web",{value:Pc,enumerable:!0}),h(zu)})();e.exports=n})(a1)),a1.exports}var M$;function xU(){return M$||(M$=1,(function(e){var r=ec&&ec.__createBinding||(Object.create?(function(k,T,j,$){$===void 0&&($=j);var P=Object.getOwnPropertyDescriptor(T,j);(!P||("get"in P?!T.__esModule:P.writable||P.configurable))&&(P={enumerable:!0,get:function(){return T[j]}}),Object.defineProperty(k,$,P)}):(function(k,T,j,$){$===void 0&&($=j),k[$]=T[j]})),n=ec&&ec.__setModuleDefault||(Object.create?(function(k,T){Object.defineProperty(k,"default",{enumerable:!0,value:T})}):function(k,T){k.default=T}),i=ec&&ec.__importStar||function(k){if(k&&k.__esModule)return k;var T={};if(k!=null)for(var j in k)j!=="default"&&Object.prototype.hasOwnProperty.call(k,j)&&r(T,k,j);return n(T,k),T};Object.defineProperty(e,"__esModule",{value:!0}),e.MicVAD=e.getDefaultRealTimeVADOptions=e.ort=e.DEFAULT_MODEL=void 0;const s=i(bU()),a=pT(),l=mT(),o=qy(),u=Gw(),f=$5(),m=N5();e.DEFAULT_MODEL="legacy",e.ort=s;const h="vad.worklet.bundle.min.js",y="silero_vad_v5.onnx",x="silero_vad_legacy.onnx",C=k=>({...l.defaultFrameProcessorOptions,onFrameProcessed:()=>{},onVADMisfire:()=>{o.log.debug("VAD misfire")},onSpeechStart:()=>{o.log.debug("Detected speech start")},onSpeechEnd:()=>{o.log.debug("Detected speech end")},onSpeechRealStart:()=>{o.log.debug("Detected real speech start")},baseAssetPath:"./",onnxWASMBasePath:"./",model:k,workletOptions:{},getStream:async()=>await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}}),pauseStream:async T=>{T.getTracks().forEach(j=>{j.stop()})},resumeStream:async()=>await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}}),ortConfig:T=>{T.env.logLevel="error"},startOnLoad:!0,processorType:"auto"});e.getDefaultRealTimeVADOptions=C;const _=k=>"audioWorklet"in k&&typeof AudioWorkletNode=="function"?"AudioWorklet":"ScriptProcessor";async function b(k,T,j,$,P){await j.audioWorklet.addModule(k),T.processorOptions={...T.processorOptions??{},frameSamples:$};const N=new AudioWorkletNode(j,"vad-helper-worklet",T);return N.port.onmessage=async I=>{const U=I.data;if(!(typeof U=="object"&&U&&"message"in U)){console.error("Invalid message event",U);return}switch(U.message){case u.Message.AudioFrame:{if(!("data"in U&&U.data instanceof ArrayBuffer)){console.log("Audio frame message has no data");return}const V=new Float32Array(U.data);await P(V);break}}},N}async function w(k,T,j){const $=new m.Resampler({nativeSampleRate:k.sampleRate,targetSampleRate:16e3,targetFrameSize:T});o.log.debug("using script processor");const N=k.createScriptProcessor(4096,1,1);let I=!1;return N.onaudioprocess=async U=>{if(!I){I=!0;try{const V=U.inputBuffer.getChannelData(0);U.outputBuffer.getChannelData(0).fill(0);const F=$.process(V);for(const z of F)await j(z)}catch(V){console.error("Error processing audio:",V)}finally{I=!1}}},N.connect(k.destination),N}class S{constructor(T,j,$,P,N=!1,I=null,U=null,V=null,q=null,F=null,z=null,G="uninitialized",Y=!1){this.options=T,this.frameProcessor=j,this.model=$,this.frameSamples=P,this.listening=N,this.errored=I,this._stream=U,this._audioContext=V,this._vadNode=q,this._mediaStreamAudioSourceNode=F,this._audioProcessorAdapterType=z,this.initializationState=G,this.ownsAudioContext=Y,this.getAudioInstances=()=>{if(this._stream===null||this._audioContext===null||this._vadNode==null||this._mediaStreamAudioSourceNode==null)throw new Error("MicVAD has null stream, audio context, or processor adapter");return{stream:this._stream,audioContext:this._audioContext,vadNode:this._vadNode,mediaStreamAudioSourceNode:this._mediaStreamAudioSourceNode}},this.setErrored=oe=>{this.initializationState="errored",this.errored=oe},this.start=async()=>{switch(this.initializationState){case"uninitialized":{o.log.debug("initializing micVAD"),this.initializationState="initializing",this.frameProcessor.resume();try{this._stream=await this.options.getStream()}catch(oe){throw oe instanceof Error?this.setErrored(oe.message):this.setErrored(String(oe)),oe}if(this.options.audioContext?(console.log("using custom audio context"),this._audioContext=this.options.audioContext):(console.log("using default audio context"),this._audioContext=new AudioContext,this.ownsAudioContext=!0),!this._audioContext)throw this.setErrored("Audio context is null"),Error("Audio context is null");switch(this._audioProcessorAdapterType=this.options.processorType=="auto"?_(this._audioContext):this.options.processorType,this._audioProcessorAdapterType){case"AudioWorklet":this._vadNode=await b(this.options.baseAssetPath+h,this.options.workletOptions,this._audioContext,this.frameSamples,this.processFrame);break;case"ScriptProcessor":this._vadNode=await w(this._audioContext,this.frameSamples,this.processFrame);break;default:throw new Error(`Unsupported audio processor adapter type: ${this._audioProcessorAdapterType}`)}this._mediaStreamAudioSourceNode=new MediaStreamAudioSourceNode(this._audioContext,{mediaStream:this._stream}),this._mediaStreamAudioSourceNode.connect(this._vadNode),o.log.debug("started micVAD"),this.listening=!0,this.initializationState="initialized";break}case"initializing":{o.log.warn("start called while initializing");break}case"initialized":{if(this.listening)return;this.listening=!0,this.frameProcessor.resume();const{stream:oe,audioContext:te,vadNode:J}=this.getAudioInstances();this._stream=await this.options.resumeStream(oe);const K=new MediaStreamAudioSourceNode(te,{mediaStream:this._stream});this._mediaStreamAudioSourceNode=K,K.connect(J);break}case"destroyed":{o.log.warn("start called after destroyed");break}case"errored":{o.log.error("start called after errored");break}default:{o.log.warn("weird initialization state");break}}},this.pause=async()=>{if(!this.listening)return;this.listening=!1;const{stream:oe,mediaStreamAudioSourceNode:te}=this.getAudioInstances();await this.options.pauseStream(oe),te.disconnect(),this.frameProcessor.pause(this.handleFrameProcessorEvent)},this.destroy=async()=>{var te;o.log.debug("destroy called"),this.initializationState="destroyed";const{vadNode:oe}=this.getAudioInstances();oe instanceof AudioWorkletNode&&oe.port.postMessage(u.Message.SpeechStop),this.listening&&await this.pause(),await this.model.release(),this.ownsAudioContext&&await((te=this._audioContext)==null?void 0:te.close())},this.setOptions=oe=>{this.frameProcessor.setOptions(oe)},this.processFrame=async oe=>{await this.frameProcessor.process(oe,this.handleFrameProcessorEvent)},this.handleFrameProcessorEvent=oe=>{switch(oe.msg){case u.Message.FrameProcessed:this.options.onFrameProcessed(oe.probs,oe.frame);break;case u.Message.SpeechStart:this.options.onSpeechStart();break;case u.Message.SpeechRealStart:this.options.onSpeechRealStart();break;case u.Message.VADMisfire:this.options.onVADMisfire();break;case u.Message.SpeechEnd:this.options.onSpeechEnd(oe.audio);break}}}static async new(T={}){const j={...(0,e.getDefaultRealTimeVADOptions)(T.model??e.DEFAULT_MODEL),...T};(0,l.validateOptions)(j),e.ort.env.wasm.wasmPaths=j.onnxWASMBasePath,j.ortConfig!==void 0&&j.ortConfig(e.ort);const $=j.model==="v5"?y:x,P=j.baseAssetPath+$,N=j.model==="v5"?f.SileroV5.new:f.SileroLegacy.new;let I;try{I=await N(e.ort,()=>(0,a.defaultModelFetcher)(P))}catch(z){throw console.error(`Encountered an error while loading model file ${P}`),z}const U=j.model==="v5"?512:1536,V=U/16,q=new l.FrameProcessor(I.process,I.reset_state,{positiveSpeechThreshold:j.positiveSpeechThreshold,negativeSpeechThreshold:j.negativeSpeechThreshold,redemptionMs:j.redemptionMs,preSpeechPadMs:j.preSpeechPadMs,minSpeechMs:j.minSpeechMs,submitUserSpeechOnPause:j.submitUserSpeechOnPause},V),F=new S(j,q,I,U);if(j.startOnLoad)try{await F.start()}catch(z){throw console.error("Error starting micVad",z),z}return F}}e.MicVAD=S})(ec)),ec}var I$;function wU(){return I$||(I$=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getDefaultRealTimeVADOptions=e.MicVAD=e.DEFAULT_MODEL=e.utils=e.NonRealTimeVAD=e.Message=e.FrameProcessor=e.defaultModelFetcher=e.baseAssetPath=void 0;var r=E5();Object.defineProperty(e,"baseAssetPath",{enumerable:!0,get:function(){return r.baseAssetPath}});var n=pT();Object.defineProperty(e,"defaultModelFetcher",{enumerable:!0,get:function(){return n.defaultModelFetcher}});var i=mT();Object.defineProperty(e,"FrameProcessor",{enumerable:!0,get:function(){return i.FrameProcessor}});var s=Gw();Object.defineProperty(e,"Message",{enumerable:!0,get:function(){return s.Message}});var a=vU();Object.defineProperty(e,"NonRealTimeVAD",{enumerable:!0,get:function(){return a.NonRealTimeVAD}});const l=yU();e.utils={audioFileToArray:l.audioFileToArray,minFramesForTargetMS:l.minFramesForTargetMS,arrayBufferToBase64:l.arrayBufferToBase64,encodeWAV:l.encodeWAV};var o=xU();Object.defineProperty(e,"DEFAULT_MODEL",{enumerable:!0,get:function(){return o.DEFAULT_MODEL}}),Object.defineProperty(e,"MicVAD",{enumerable:!0,get:function(){return o.MicVAD}}),Object.defineProperty(e,"getDefaultRealTimeVADOptions",{enumerable:!0,get:function(){return o.getDefaultRealTimeVADOptions}})})(n1)),n1}var _U=wU();function cx(e,r,n,i){var a,l;try{(l=(a=window.api)==null?void 0:a.logs)==null||l.write(e,r,n,i)}catch{}const s=r==="error"?console.error:r==="warn"?console.warn:console.log;i!==void 0?s(`[${e}]`,n,i):s(`[${e}]`,n)}const gt={debug:(e,r,n)=>cx(e,"debug",r,n),info:(e,r,n)=>cx(e,"info",r,n),warn:(e,r,n)=>cx(e,"warn",r,n),error:(e,r,n)=>cx(e,"error",r,n)},P5=16e3,SU=6,Qh=P5*SU,kU=400,CU=P5*kU/1e3,D$=300,L$=2e3,B$=1500,z$=3e3,jU=600,R5=.5,M5=.35,F$=.85,U$=.7;let Ys=null,yl=!1,Ts=!1;const rj=new Set;function ux(e){for(const r of Array.from(rj))try{r(e)}catch(n){gt.warn("speech","workerDeath listener threw",{error:n instanceof Error?n.message:String(n)})}}let o1=0;const q$=2;let yp=!1,I5=!1;function D5(e){e.addEventListener("message",r=>{var i;if(((i=r.data)==null?void 0:i.type)!=="log")return;const n=r.data.level||"info";gt[n]("whisperWorker",r.data.message??"",r.data.meta)}),e.addEventListener("error",r=>{gt.error("whisperWorker","worker error event (fatal)",{message:r.message,filename:r.filename,lineno:r.lineno}),EU(`error:${r.message||"unknown"}`)})}function x0(){return Ys||(Ys=new Worker(new URL(""+new URL("whisperWorker-Dbia1OpC.js",import.meta.url).href,import.meta.url),{type:"module"}),D5(Ys),gt.info("speech","worker spawned"),Ys)}let dx=!1;function EU(e){if(!yp){if(dx){gt.warn("speech","respawnWorker: already in flight, ignoring",{reason:e});return}if(dx=!0,o1+=1,I5=!0,gt.warn("speech","respawnWorker: starting",{reason:e,attempt:o1}),ux({reason:e,respawned:!1,finalOnly:!0}),o1>q$){if(yp=!0,gt.error("speech","respawnWorker: limit exceeded, disabling speech",{limit:q$}),Ys)try{Ys.terminate()}catch{}Ys=null,yl=!1,Ts=!1,ux({reason:"respawn-limit-exceeded",respawned:!1,finalOnly:!0}),dx=!1;return}if(Ys)try{Ys.terminate()}catch{}Ys=null,yl=!1,Ts=!1;try{Ys=new Worker(new URL(""+new URL("whisperWorker-Dbia1OpC.js",import.meta.url).href,import.meta.url),{type:"module"}),D5(Ys),Ts=!0,Ys.postMessage({type:"load"}),gt.info("speech","respawnWorker: new worker spawned, load posted"),ux({reason:e,respawned:!0,finalOnly:!0})}catch(r){yp=!0,gt.error("speech","respawnWorker: spawn failed, disabling speech",{error:r instanceof Error?r.message:String(r)}),ux({reason:"spawn-failed",respawned:!1,finalOnly:!0})}finally{dx=!1}}}function TU(e,r){if(yl||Ts)return;Ts=!0;const n=x0();gt.info("speech","preloadModel: posting load");const i=s=>{s.data.type==="status"?(e==null||e(s.data.status,s.data.message),s.data.status==="ready"&&(yl=!0,Ts=!1,gt.info("speech","preloadModel: ready"),n.removeEventListener("message",i))):s.data.type==="progress"?r==null||r(s.data.pct):s.data.type==="error"&&(Ts=!1,gt.error("speech","preloadModel: worker reported error",{error:s.data.error}),e==null||e("error",s.data.error),n.removeEventListener("message",i))};n.addEventListener("message",i),n.postMessage({type:"load"})}function AU(){gt.info("speech","resetModel: clearing load flags"),yl=!1,Ts=!1}function gT(){var e;return typeof Worker<"u"&&!!((e=navigator.mediaDevices)!=null&&e.getUserMedia)&&typeof AudioWorkletNode<"u"}function $U(e){const r=x0();return!yl&&!Ts&&(Ts=!0,r.postMessage({type:"load"})),new Promise((n,i)=>{const s=a=>{var l,o,u;((l=a.data)==null?void 0:l.type)==="result"?(r.removeEventListener("message",s),n((a.data.text??"").trim())):((o=a.data)==null?void 0:o.type)==="error"?(r.removeEventListener("message",s),i(new Error(String(a.data.error??"Transcription failed")))):((u=a.data)==null?void 0:u.type)==="status"&&a.data.status==="ready"&&(yl=!0,Ts=!1)};r.addEventListener("message",s),r.postMessage({type:"transcribe",audio:e},[e.buffer])})}function NU(e){let r=x0(),n=!1,i=null,s=null,a=null,l=null,o=null;const u=[],f=new Set;let m=null,h=0,y=!1,x=0,C=!1,_=!1,b=0,w=0,S=0,k=-1,T=D$,j=0,$=null,P="",N="",I=!1,U=0;function V(he,we){const Ce=Math.min(he.length,we.length);let Me=0;for(;Me<Ce&&he.charCodeAt(Me)===we.charCodeAt(Me);)Me++;return Me}function q(he){const we=V(P,he);return P=he,we>N.length&&(N=he.slice(0,we)),N.length>he.length&&(N=he),N}const F=()=>(m||(m=new Float32Array(Qh)),m),z=()=>{h=0},G=he=>{const we=F(),Ce=he.length;if(Ce>=Qh){we.set(he.subarray(Ce-Qh)),h=Qh;return}if(h+Ce<=Qh){we.set(he,h),h+=Ce;return}const Me=h+Ce-Qh;we.copyWithin(0,Me,h),h-=Me,we.set(he,h),h+=Ce},Y=()=>{$&&(clearTimeout($),$=null)},oe=()=>{Y(),y=!1,C=!1,_=!1,T=D$,P="",N="",I=!1,U=0,z()},te=()=>{if(n||!y||_||C||$)return;if(h<CU){$=setTimeout(()=>{$=null,te()},T);return}const he=performance.now()-b;if(he<T&&b!==0){$=setTimeout(()=>{$=null,te()},T-he);return}if(I5||yp||e.partialsEnabled&&!e.partialsEnabled())return;const we=F(),Ce=new Float32Array(h);Ce.set(we.subarray(0,h)),w+=1,S=w,C=!0,j=performance.now(),b=j,r.postMessage({type:"transcribe-partial",audio:Ce,seq:w},[Ce.buffer])},J=he=>he.length===0?Promise.resolve():yp?(gt.warn("speech","transcribeAudio: speech disabled (worker respawn limit hit)"),n||e.onError("Speech recognition disabled — please reload the app."),Promise.resolve()):new Promise(we=>{u.push(we),w+=1;const Ce=w;k=Ce,r.postMessage({type:"transcribe",audio:he,seq:Ce},[he.buffer])}),K=he=>{const we=J(he);return f.add(we),we.finally(()=>{f.delete(we)}),we},Z=he=>{var we,Ce,Me,be,se;if(he.data.type==="result"){const ve=he.data.text,xe=he.data.seq??0;xe&&xe<k&>.warn("speech","result: seq below latestFinalSeq (delivering anyway)",{seq:xe,latestFinalSeq:k}),!n&&ve&&e.onFinal(ve),(we=u.shift())==null||we()}else if(he.data.type==="partial"){const ve=he.data.seq??0,xe=he.data.text??"",Ve=performance.now()-j;C=!1,Ve>=z$?(_=!0,gt.warn("speech","partials.disabled.budget",{elapsedMs:Math.round(Ve),seq:ve})):Ve>=B$&&(T=Math.min(T*2,L$),gt.warn("speech","partials.slowdown",{elapsedMs:Math.round(Ve),newIntervalMs:T,seq:ve})),I||(I=!0,Ve>jU&&T<500&&(T=500,gt.info("speech","partials.probe.slow_host",{elapsedMs:Math.round(Ve),newIntervalMs:500})));const Re=ve!==S||ve<=k;if(!n&&!Re&&xe){const We=q(xe);We&&((Ce=e.onPartial)==null||Ce.call(e,We),U===0&&(U=performance.now(),gt.info("speech","partial.first",{msSinceSpeechStart:Math.round(U-x)})))}te()}else if(he.data.type==="partial-error"){const ve=performance.now()-j;C=!1,ve>=z$?(_=!0,gt.warn("speech","partials.disabled.budget (after error)",{elapsedMs:Math.round(ve),seq:he.data.seq})):ve>=B$&&(T=Math.min(T*2,L$),gt.warn("speech","partials.slowdown (after error)",{elapsedMs:Math.round(ve),newIntervalMs:T,seq:he.data.seq})),gt.warn("speech","partial encode failed",{error:he.data.error,seq:he.data.seq}),te()}else he.data.type==="error"?(n||e.onError(he.data.error),(Me=u.shift())==null||Me()):he.data.type==="status"?(n||(be=e.onModelStatus)==null||be.call(e,he.data.status,he.data.message),he.data.status==="ready"&&(yl=!0,Ts=!1)):he.data.type==="progress"&&(n||(se=e.onProgress)==null||se.call(e,he.data.pct))};r.addEventListener("message",Z);const re=he=>{var we,Ce;if(!n){for(gt.warn("speech","createRecognition: worker death event",he),(we=e.onStatusChange)==null||we.call(e,"restarting");u.length;)(Ce=u.shift())==null||Ce();if(f.clear(),Y(),C=!1,he.respawned){try{r.removeEventListener("message",Z)}catch{}r=x0(),r.addEventListener("message",Z)}}};return rj.add(re),{start:async()=>{if(!n){if(yp){e.onError("Speech recognition disabled — please reload the app.");return}!yl&&!Ts&&(Ts=!0,gt.info("speech","createRecognition.start: triggering model load"),r.postMessage({type:"load"})),gt.info("speech","createRecognition.start: initializing VAD",{modelReady:yl,modelLoading:Ts});try{const he=new URL("vad/",document.baseURI).href,we=e.inputDeviceId||null,Ce={channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0};we&&(Ce.deviceId={exact:we}),gt.info("speech","getUserMedia",{hasDeviceId:!!we,deviceIdPrefix:we?we.slice(0,8):null});const Me=await navigator.mediaDevices.getUserMedia({audio:Ce});s=Me,a=new AudioContext;for(const be of Me.getAudioTracks())be.addEventListener("ended",()=>{n||(gt.warn("speech","mic track ended (permission revoked or device removed)"),e.onError("Microphone disconnected or permission revoked"))});try{o=a.createMediaStreamSource(s),l=a.createAnalyser(),l.fftSize=2048,l.smoothingTimeConstant=.3,o.connect(l)}catch(be){gt.warn("speech","analyser init failed",{error:be instanceof Error?be.message:String(be)}),o=null,l=null}i=await _U.MicVAD.new({audioContext:a,getStream:async()=>Me,resumeStream:async()=>Me,pauseStream:async()=>{},baseAssetPath:he,onnxWASMBasePath:he,model:"v5",positiveSpeechThreshold:R5,negativeSpeechThreshold:M5,minSpeechMs:300,redemptionMs:1500,preSpeechPadMs:300,submitUserSpeechOnPause:!0,onFrameProcessed:(be,se)=>{var ve;n||((ve=e.onFrame)==null||ve.call(e,be),y&&(G(se),te()))},onSpeechStart:()=>{var be;n||(oe(),y=!0,x=performance.now(),(be=e.onSpeechStart)==null||be.call(e))},onSpeechEnd:be=>{var se;n||((se=e.onStatusChange)==null||se.call(e,"transcribing"),oe(),K(be))},onVADMisfire:()=>{var be,se;n||((be=e.onStatusChange)==null||be.call(e,"idle"),oe(),(se=e.onMisfire)==null||se.call(e))}}),i.start()}catch(he){const we=he instanceof Error?he.message:"Microphone access denied",Ce=he instanceof Error?he.stack:"";if(gt.error("speech","createRecognition.start: VAD init failed",{error:we,stack:Ce}),l){try{l.disconnect()}catch{}l=null}if(o){try{o.disconnect()}catch{}o=null}if(s){try{s.getTracks().forEach(Me=>Me.stop())}catch{}s=null}if(a){try{await a.close()}catch{}a=null}e.onError(we)}}},stop:async()=>{if(i)try{await i.pause()}catch{}for(oe();f.size>0;)await Promise.all(Array.from(f));if(i){try{await i.destroy()}catch{}i=null}if(l){try{l.disconnect()}catch{}l=null}if(o){try{o.disconnect()}catch{}o=null}if(s){try{s.getTracks().forEach(he=>he.stop())}catch{}s=null}if(a){try{await a.close()}catch{}a=null}},setVadThresholds:(he,we)=>{if(i)try{i.setOptions({positiveSpeechThreshold:he,negativeSpeechThreshold:we})}catch(Ce){gt.warn("speech","setVadThresholds failed",{error:Ce instanceof Error?Ce.message:String(Ce)})}},getAnalyser:()=>l,destroy:()=>{if(n=!0,oe(),i){try{i.destroy()}catch{}i=null}if(l){try{l.disconnect()}catch{}l=null}if(o){try{o.disconnect()}catch{}o=null}if(a){try{a.close()}catch{}a=null}if(s){try{s.getTracks().forEach(he=>he.stop())}catch{}s=null}rj.delete(re),r.removeEventListener("message",Z)}}}let Fv=null;const nj=new Set,ij=new Set;function OU(){for(const e of nj)try{e()}catch{}}function sj(){for(const e of ij)try{e()}catch{}}function PU(e){return e.replace(/```[\s\S]*?```/g,"").replace(/`([^`]+)`/g,"$1").replace(/^#{1,6}\s+/gm,"").replace(/\*{1,3}([^*]+)\*{1,3}/g,"$1").replace(/_{1,3}([^_]+)_{1,3}/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/^[-*_]{3,}\s*$/gm,"").replace(/^>\s?/gm,"").replace(/^[\s]*[-*+]\s/gm,"").replace(/^[\s]*\d+\.\s/gm,"").trim()}function RU(e){if(!window.speechSynthesis)return;const r=PU(e);if(!r)return;const n=new SpeechSynthesisUtterance(r);n.rate=1,n.pitch=1,n.onstart=()=>{Fv=performance.now(),OU()},n.onend=()=>{!window.speechSynthesis.speaking&&!window.speechSynthesis.pending&&(Fv=null,sj())},n.onerror=i=>{i.error!=="canceled"&&!window.speechSynthesis.speaking&&!window.speechSynthesis.pending&&(Fv=null,sj())},window.speechSynthesis.speak(n)}function L5(){window.speechSynthesis&&(window.speechSynthesis.cancel(),Fv=null,sj())}function B5(){var e;return((e=window.speechSynthesis)==null?void 0:e.speaking)??!1}function MU(){return Fv}function IU(e){return nj.add(e),()=>{nj.delete(e)}}function DU(e){return ij.add(e),()=>{ij.delete(e)}}function LU(e){B5()&&(e.setVadThresholds(F$,U$),gt.info("voice","tts.duck.on",{reason:"already-speaking-on-attach"}));const r=IU(()=>{e.setVadThresholds(F$,U$),gt.info("voice","tts.duck.on")}),n=DU(()=>{e.setVadThresholds(R5,M5),gt.info("voice","tts.duck.off")});return()=>{r(),n()}}const BU=[{match:/^(send|submit|enter)\.?$/i,data:"\r",label:"send"},{match:/^(cancel|escape)\.?$/i,data:"\x1B",label:"cancel"},{match:/^clear( line)?\.?$/i,data:"",label:"clear"}];function zU(e){const r=e.trim();return BU.find(n=>n.match.test(r))??null}const FU=4e4;let Wd=null;function bp(){Wd&&clearTimeout(Wd),Wd=setTimeout(()=>{Wd=null,Lt.getState().stopRecording()},FU)}function fx(){Wd&&(clearTimeout(Wd),Wd=null)}let Su=null,_u=null;const UU=.04,qU=.3;let w0=0,aj=0;function WU(e){_u!==null&&cancelAnimationFrame(_u);const r=()=>{if(Su===null||Lt.getState().submitCountdownStartAt===null){_u=null;return}const n=performance.now();if(n-aj<200&&w0>qU){const s=n-e;gt.info("voice","submit.preempted_by_voice",{reason:"vad",prob:w0.toFixed(2),msIntoCountdown:Math.round(s)}),yu(),bp();return}const i=z5();if(i){const s=new Uint8Array(i.fftSize);i.getByteTimeDomainData(s);let a=0;for(let o=0;o<s.length;o++){const u=(s[o]-128)/128;a+=u*u}const l=Math.sqrt(a/s.length);if(l>UU){const o=n-e;gt.info("voice","submit.preempted_by_voice",{reason:"rms",rms:l.toFixed(3),msIntoCountdown:Math.round(o)}),yu(),bp();return}}_u=requestAnimationFrame(r)};_u=requestAnimationFrame(r)}function HU(e){Su&&clearTimeout(Su);const r=Lt.getState().submitDelayMs,n=performance.now();Lt.setState({submitCountdownStartAt:n}),Su=setTimeout(()=>{Su=null,Lt.setState({submitCountdownStartAt:null});try{window.api.pty.write({tabId:e,data:"\r"})}catch(i){gt.warn("voice","submit pty.write failed",{error:i instanceof Error?i.message:String(i)})}bp()},r),WU(n)}function yu(){_u!==null&&(cancelAnimationFrame(_u),_u=null),Su&&(clearTimeout(Su),Su=null),Lt.getState().submitCountdownStartAt!==null&&Lt.setState({submitCountdownStartAt:null})}let Ni=null,ss=null;function z5(){var e;return((e=Ni==null?void 0:Ni.getAnalyser)==null?void 0:e.call(Ni))??null}const hx=1e4;let Uv=null;function px(){Uv&&(clearTimeout(Uv),Uv=null)}let o0=null,l0=null;function mx(){o0=null,l0&&(l0(),l0=null)}const VU=1500,GU=9e4;let gx=0,c0=null,oj=-1;function vx(){c0&&(clearTimeout(c0),c0=null,oj=-1)}const KU=new Set(["you","You","Thank you.","Thanks for watching.","Thanks for watching!","Thank you for watching.","Thank you for watching!",".","Bye.","Bye!"]),Lt=Gn((e,r)=>({isRecording:!1,ttsEnabled:!1,autoSubmit:!0,submitDelayMs:8e3,submitCountdownStartAt:null,lastTranscript:"",lastPartial:"",statusPill:"idle",partialsEnabled:!0,error:null,errorKind:null,modelStatus:"idle",loadingProgress:0,permissionState:"unknown",lastBargeInAt:null,hotkeyState:"idle",levelMeterEnabled:!0,turnDetectorState:"disabled",turnDetectorMode:"off",wizardArmed:!1,wizardOpen:!1,initModel:()=>{if(r().modelStatus!=="idle")return;gt.info("voice","initModel: kicking off preload"),e({modelStatus:"loading",error:null,errorKind:null,loadingProgress:0});const n=++gx,i=()=>{n===gx&&(vx(),oj=n,c0=setTimeout(()=>{oj===n&&r().modelStatus==="loading"&&(gt.warn("voice","mic.gate.timeout: no progress within 90s"),e({modelStatus:"error",error:"Model load timed out",errorKind:"timeout"}))},GU))};i(),TU((s,a)=>{n===gx&&(s==="ready"?(vx(),gt.info("voice","modelStatus -> ready"),e({modelStatus:"ready",loadingProgress:100,errorKind:null})):s==="error"?(vx(),gt.error("voice","modelStatus -> error",{msg:a}),e({modelStatus:"error",error:a,errorKind:"load"})):(i(),e({modelStatus:"loading"})))},s=>{n===gx&&(i(),e({loadingProgress:Math.round(s)}))})},resetAndRetryModel:()=>{gt.info("voice","mic.gate.retry"),vx(),AU(),e({modelStatus:"idle",error:null,errorKind:null,loadingProgress:0}),r().initModel()},startRecording:n=>{if(r().isRecording)return;if(Ni){gt.warn("voice","startRecording: prior handle still draining, ignoring");return}if(!gT()){e({error:"Microphone or Web Worker not available",errorKind:"recording"});return}const i=s=>{try{const a=NU({inputDeviceId:s,onStatusChange:l=>{e(l==="transcribing"?{statusPill:"transcribing"}:l==="restarting"?{statusPill:"restarting"}:{statusPill:"idle"})},onPartial:l=>{r().partialsEnabled&&e({lastPartial:l})},partialsEnabled:()=>r().partialsEnabled,onFrame:l=>{w0=l.isSpeech,aj=performance.now()},onSpeechStart:()=>{if(e({statusPill:"listening",lastPartial:""}),fx(),yu(),B5()){const o=MU(),u=o!==null?performance.now()-o:null;L5(),e({lastBargeInAt:performance.now()}),gt.info("voice","barge-in",{tabId:n,utteranceOffsetMs:u})}else gt.debug("voice","barge-in.no-op",{tabId:n})},onMisfire:()=>{e({lastPartial:"",statusPill:"idle"}),bp();const l=r().lastBargeInAt;l!==null&&performance.now()-l<600&>.warn("voice","barge-in.misfire",{tabId:n,sinceBargeInMs:Math.round(performance.now()-l)})},onFinal:l=>{bp();const o=l.trim();if(!o||KU.has(o)){e({lastTranscript:"",lastPartial:"",statusPill:"idle"});return}const u=zU(o);if(u){gt.info("voice","voice-command",{tabId:n,label:u.label,transcript:o}),window.api.pty.write({tabId:n,data:u.data}),e({lastTranscript:"",lastPartial:"",statusPill:"idle"}),yu();const m=window;m.__transcripts&&(m.__transcripts.push({tabId:n,text:o}),m.__transcripts.length>500&&m.__transcripts.shift());return}window.api.pty.write({tabId:n,data:o}),e({lastTranscript:"",lastPartial:"",statusPill:"idle"}),r().autoSubmit&&HU(n);const f=window;f.__transcripts&&(f.__transcripts.push({tabId:n,text:o}),f.__transcripts.length>500&&f.__transcripts.shift())},onError:l=>{gt.error("voice","recognition error",{err:l}),yu(),e({error:l,errorKind:"recording",isRecording:!1,lastPartial:"",statusPill:"idle"}),ss==null||ss(),ss=null,fx(),Ni==null||Ni.destroy(),Ni=null,ft.error(`Microphone error: ${l}`)},onModelStatus:l=>{l==="ready"?e({modelStatus:"ready",loadingProgress:100}):l==="loading"&&e({modelStatus:"loading"})},onProgress:l=>e({loadingProgress:Math.round(l)})});Ni=a,e({isRecording:!0,error:null,lastTranscript:"",lastPartial:"",statusPill:"listening"}),bp(),a.start().then(()=>{Ni===a&&(ss==null||ss(),ss=LU(a))}).catch(l=>{const o=l instanceof Error?l.message:String(l);gt.error("voice","handle.start() failed",{error:o}),ft.error(`Could not start mic: ${o}`)})}catch(a){e({error:a instanceof Error?a.message:"Failed to start recording",errorKind:"recording"})}};Promise.resolve().then(()=>{var s,a,l;return((l=(a=(s=window.api)==null?void 0:s.voice)==null?void 0:a.getDevicePref)==null?void 0:l.call(a))??Promise.resolve(null)}).then(s=>i((s==null?void 0:s.selectedDeviceId)??null)).catch(s=>{gt.warn("voice","getDevicePref failed; using default device",{error:s instanceof Error?s.message:String(s)}),i(null)})},stopRecording:()=>{const n=Ni;n&&(fx(),yu(),w0=0,aj=0,ss==null||ss(),ss=null,e({isRecording:!1,lastTranscript:"",lastPartial:"",statusPill:"idle"}),n.stop().finally(()=>{n.destroy(),Ni===n&&(Ni=null),r().hotkeyState==="stopping"&&(px(),e({hotkeyState:"idle"}))}))},restartWithDevice:async()=>{if(!r().isRecording)return;const n=Ni;if(!n)return;fx(),ss==null||ss(),ss=null,e({isRecording:!1,lastTranscript:"",lastPartial:""});try{await n.stop()}catch(a){gt.warn("voice","restartWithDevice: drain rejected",{error:a instanceof Error?a.message:String(a)})}n.destroy(),Ni===n&&(Ni=null);const{useSessions:i}=await rm(async()=>{const{useSessions:a}=await Promise.resolve().then(()=>tU);return{useSessions:a}},[],import.meta.url),s=i.getState().activeTabId;s&&r().startRecording(s)},toggleTTS:()=>e(n=>({ttsEnabled:!n.ttsEnabled})),setAutoSubmit:n=>e({autoSubmit:n}),setSubmitDelayMs:n=>e({submitDelayMs:Math.max(500,Math.min(13e3,Math.floor(n)))}),cancelSubmit:()=>yu(),setPartialsEnabled:n=>{r().partialsEnabled!==n&&(e({partialsEnabled:n}),n||e({lastPartial:""}))},clearError:()=>e({error:null,errorKind:null}),setPermissionState:n=>{r().permissionState!==n&&(gt.info("voice","mic.gate.permission_changed",{from:r().permissionState,to:n}),e({permissionState:n}))},setLevelMeterEnabled:n=>{r().levelMeterEnabled!==n&&e({levelMeterEnabled:n})},setTurnDetectorRuntimeState:n=>{r().turnDetectorState!==n&&(e({turnDetectorState:n}),n==="load_failed"?gt.warn("voice-turn","voice-turn.load_failed"):n==="runtime_error"?gt.warn("voice-turn","voice-turn.runtime_error"):n==="disabled"&>.info("voice-turn","voice-turn.fallback_to_vad"))},setWizardArmed:n=>{r().wizardArmed!==n&&e({wizardArmed:n})},openWizard:()=>{r().wizardOpen||e({wizardOpen:!0})},closeWizard:()=>{r().wizardOpen&&e({wizardOpen:!1})},armHotkey:({phase:n,source:i,mode:s,tabId:a})=>{const l=r(),{canRecord:o,reason:u}=lj(l);if(n==="down"){if(u==="error"||u==="load-timeout"){l.resetAndRetryModel(),gt.info("voice-hotkey","down.retry",{source:i,reason:u});return}if(!o&&u!=="loading"){gt.warn("voice-hotkey","miss-model-loading",{modelStatus:l.modelStatus,reason:u});return}if(l.hotkeyState==="recording"||l.isRecording){(s==="toggle"||i==="global")&&(e({hotkeyState:"stopping"}),px(),Uv=setTimeout(()=>{r().hotkeyState==="stopping"&&(gt.warn("voice-hotkey","drain-timeout",{durationMs:hx}),e({hotkeyState:"aborted"}),setTimeout(()=>{r().hotkeyState==="aborted"&&e({hotkeyState:"idle"})},0))},hx),l.stopRecording());return}if(u==="loading"){l.hotkeyState!=="armed"&&(e({hotkeyState:"armed"}),gt.info("voice-hotkey","armed",{source:i,modelStatus:l.modelStatus})),mx(),o0={tabId:a,source:i,mode:s},l0=Lt.subscribe((f,m)=>{if(o0&&f.modelStatus==="ready"&&m.modelStatus!=="ready"&&f.hotkeyState==="armed"){const h=o0;if(mx(),!h.tabId){gt.warn("voice-hotkey","armed-promote-no-tab",{source:h.source}),e({hotkeyState:"idle"});return}gt.info("voice-hotkey","armed-promote",h),e({hotkeyState:"recording"}),Lt.getState().startRecording(h.tabId)}});return}if(!a){gt.warn("voice-hotkey","no-active-tab",{source:i});return}gt.info("voice-hotkey","start",{source:i,mode:s,tabId:a}),l.startRecording(a),r().isRecording?e({hotkeyState:"recording"}):(gt.warn("voice-hotkey","start: recording did not engage",{errorKind:r().errorKind}),e({hotkeyState:"idle"}));return}if(!(s!=="hold"||i==="global")){if(l.hotkeyState==="armed"){mx(),gt.info("voice-hotkey","miss-model-loading-armed-up"),e({hotkeyState:"idle"});return}l.hotkeyState==="recording"&&(e({hotkeyState:"stopping"}),px(),Uv=setTimeout(()=>{r().hotkeyState==="stopping"&&(gt.warn("voice-hotkey","drain-timeout",{durationMs:hx}),e({hotkeyState:"aborted"}),setTimeout(()=>{r().hotkeyState==="aborted"&&e({hotkeyState:"idle"})},0))},hx),l.stopRecording())}},destroyHotkey:()=>{const n=r();if(mx(),yu(),n.hotkeyState==="recording"){gt.warn("voice-hotkey","destroyed-mid-recording"),e({hotkeyState:"destroyed"});try{n.stopRecording()}catch{}}else(n.hotkeyState==="armed"||n.hotkeyState==="stopping")&&(px(),e({hotkeyState:"destroyed"}))}})),XU=e=>({isRecording:e.isRecording,statusPill:e.statusPill,lastPartial:e.lastPartial,lastTranscript:e.lastTranscript,submitCountdownStartAt:e.submitCountdownStartAt}),lj=e=>gT()?e.permissionState==="denied"?{canRecord:!1,reason:"permission-denied"}:e.modelStatus==="ready"?{canRecord:!0,reason:"ready"}:e.modelStatus==="loading"?{canRecord:!1,reason:"loading"}:e.modelStatus==="error"?{canRecord:!1,reason:e.errorKind==="timeout"?"load-timeout":"error"}:{canRecord:!1,reason:"idle"}:{canRecord:!1,reason:"unsupported"};if(typeof window<"u"){const e=window;e.__voice=Lt,e.__transcripts=[]}function vT(e,r,n){return new Promise((i,s)=>{const a=setTimeout(()=>s(new Error(`${n} timed out after ${r}ms`)),r);e.then(l=>{clearTimeout(a),i(l)},l=>{clearTimeout(a),s(l)})})}const YU=5e3,yc=Gn(()=>({snapshot:null,loaded:!1}));let W$=!1,H$=!1,Qg;async function JU(){var e;if(!W$){W$=!0;try{const r=await vT(window.api.schedule.state(),YU,"schedule.state");yc.setState({snapshot:r,loaded:!0}),Qg=((e=r.paused)==null?void 0:e.reason)??null}catch(r){if(!H$){H$=!0;const n=r instanceof Error?r.message:String(r);ft.error(`Scheduler state hydrate failed: ${n}`)}Qg=null}window.api.schedule.onState(r=>{var i;const n=((i=r.paused)==null?void 0:i.reason)??null;Qg!==void 0&&n!==Qg&&(n==="auth"?ft.error("Scheduler paused: Claude sign-in expired or invalid. Restart the app or re-run `claude login`, then Resume."):n==="network"&&ft.error("Scheduler paused: billing endpoint unreachable. Will auto-resume in 30 minutes.")),Qg=n,yc.setState({snapshot:r,loaded:!0})})}}const QU=6e4,ZU=5e3,Xd=Gn(()=>({data:null,refreshing:!1}));let V$=!1,u0=null,G$=null,K$=!1;async function yT(){Xd.setState({refreshing:!0});let e=QU;try{const r=await vT(window.api.billing.fetch(),ZU,"billing.fetch");Xd.setState({data:r,refreshing:!1}),r.kind==="transient"?e=G$==="transient"?3e4:5e3:r.kind==="auth"&&(e=3e4),G$=r.kind}catch(r){if(Xd.setState({refreshing:!1}),!K$){K$=!0;const n=r instanceof Error?r.message:String(r);ft.warn(`Billing usage fetch failed: ${n}`)}}u0=setTimeout(yT,e)}function eq(){V$||(V$=!0,yT())}function Wy(e){return e?e.kind==="ok"||e.kind==="ok-stale"?e.data:e.kind==="auth"&&e.cached?e.cached:null:null}function tq(e){var r,n;return((n=(r=Wy(e))==null?void 0:r.usage.five_hour)==null?void 0:n.utilization)??0}function _0(){u0!==null&&(clearTimeout(u0),u0=null),yT()}function Do({name:e,size:r=17,stroke:n=1.6,className:i}){const s={width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round",className:i};switch(e){case"home":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M4 11l8-7 8 7"}),c.jsx("path",{d:"M6 10v9h12v-9"}),c.jsx("path",{d:"M10 19v-5h4v5"})]});case"terminal":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),c.jsx("path",{d:"M7 10l3 2-3 2"}),c.jsx("path",{d:"M13 14h4"})]});case"agents":case"subagents":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"7",cy:"9",r:"2.5"}),c.jsx("circle",{cx:"17",cy:"9",r:"2.5"}),c.jsx("circle",{cx:"12",cy:"17",r:"2.5"}),c.jsx("path",{d:"M8.6 11l2.8 4M15.4 11l-2.8 4M9.5 9h5"})]});case"agent-view":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"12",cy:"12",r:"9"}),c.jsx("circle",{cx:"12",cy:"12",r:"3"}),c.jsx("path",{d:"M3 12h2M19 12h2M12 3v2M12 19v2"})]});case"skills":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M12 3l2.5 5.5L20 9l-4 4 1 6-5-3-5 3 1-6-4-4 5.5-.5z"})});case"history":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"12",cy:"12",r:"8"}),c.jsx("path",{d:"M12 7v5l3 2"}),c.jsx("path",{d:"M4 6l2 2"})]});case"usage":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M4 19V8M10 19V5M16 19v-7M22 19H2"})});case"hive":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M8 4h8l4 7-4 7H8l-4-7z"}),c.jsx("circle",{cx:"12",cy:"11",r:"2.5"})]});case"knowledge-graph":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"6",cy:"7",r:"2.2"}),c.jsx("circle",{cx:"18",cy:"6",r:"2.2"}),c.jsx("circle",{cx:"17",cy:"18",r:"2.2"}),c.jsx("circle",{cx:"7",cy:"17",r:"2.2"}),c.jsx("path",{d:"M8 8l8 8M8 16l8-9M8 7h8"})]});case"plugins":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M9 3v4M15 3v4M5 7h14v6a5 5 0 01-5 5h-4a5 5 0 01-5-5V7z"})});case"mcp":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"3",y:"4",width:"18",height:"6",rx:"1.5"}),c.jsx("rect",{x:"3",y:"14",width:"18",height:"6",rx:"1.5"}),c.jsx("circle",{cx:"6.5",cy:"7",r:".5",fill:"currentColor"}),c.jsx("circle",{cx:"6.5",cy:"17",r:".5",fill:"currentColor"})]});case"hooks":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M12 4v9a3 3 0 003 3h5"}),c.jsx("path",{d:"M9 17l3 3 3-3"})]});case"keys":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"8",cy:"12",r:"4"}),c.jsx("path",{d:"M12 12h9M17 12v3M20 12v2"})]});case"plans":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),c.jsx("path",{d:"M8 9h8M8 13h8M8 17h5"})]});case"tasks":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"3",y:"4",width:"7",height:"7",rx:"1.5"}),c.jsx("rect",{x:"3",y:"13",width:"7",height:"7",rx:"1.5"}),c.jsx("path",{d:"M14 6h7M14 10h5M14 15h7M14 19h5"})]});case"projects":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M3 7l3-3h4l2 2h9v13H3z"})});case"docs":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M6 3h8l4 4v14H6z"}),c.jsx("path",{d:"M14 3v4h4M9 13h6M9 17h6M9 9h3"})]});case"memory":case"agent-memory":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M9 4a4 4 0 00-4 4v1a3 3 0 000 6v1a4 4 0 004 4h6a4 4 0 004-4v-1a3 3 0 000-6V8a4 4 0 00-4-4z"}),c.jsx("path",{d:"M9 9v6M12 6v12M15 9v6"})]});case"search":case"global-search":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"11",cy:"11",r:"6"}),c.jsx("path",{d:"M16 16l4 4"})]});case"chevron":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M9 6l6 6-6 6"})});case"caret":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M6 9l6 6 6-6"})});case"dot":return c.jsx("svg",{...s,children:c.jsx("circle",{cx:"12",cy:"12",r:"3",fill:"currentColor",stroke:"none"})});case"plus":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M12 5v14M5 12h14"})});case"folder":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M3 7l3-3h4l2 2h9v13H3z"})});case"file":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M7 3h7l4 4v14H7z"}),c.jsx("path",{d:"M14 3v4h4"})]});case"play":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M8 5l11 7-11 7z",fill:"currentColor",stroke:"none"})});case"pause":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"7",y:"5",width:"3.5",height:"14",fill:"currentColor",stroke:"none",rx:"0.5"}),c.jsx("rect",{x:"13.5",y:"5",width:"3.5",height:"14",fill:"currentColor",stroke:"none",rx:"0.5"})]});case"sparkle":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M12 4v6M12 14v6M4 12h6M14 12h6"})});case"book":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M4 5a2 2 0 012-2h6v18H6a2 2 0 01-2-2zM12 3h6a2 2 0 012 2v14H12z"})});case"compass":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"12",cy:"12",r:"8"}),c.jsx("path",{d:"M15 9l-2 5-5 2 2-5z",fill:"currentColor",stroke:"none"})]});case"scheduler":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"3",y:"5",width:"18",height:"15",rx:"2"}),c.jsx("path",{d:"M3 10h18M8 3v4M16 3v4"}),c.jsx("path",{d:"M8 14l2 2 4-4"})]});case"settings":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"12",cy:"12",r:"3"}),c.jsx("path",{d:"M12 2v3M12 19v3M4 12H1M23 12h-3M5.6 5.6l2.1 2.1M16.3 16.3l2.1 2.1M5.6 18.4l2.1-2.1M16.3 7.7l2.1-2.1"})]});case"mic":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"9",y:"3",width:"6",height:"12",rx:"3"}),c.jsx("path",{d:"M5 11a7 7 0 0014 0M12 18v3M9 21h6"})]});case"clock":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"12",cy:"12",r:"8"}),c.jsx("path",{d:"M12 7v5l3 2"})]});case"leaf":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M20 4c-9 0-14 5-14 11 0 3 2 5 5 5 6 0 9-5 9-14z"}),c.jsx("path",{d:"M6 20c2-5 5-8 11-11"})]});case"orchestrator":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"12",cy:"6",r:"2.5"}),c.jsx("circle",{cx:"5",cy:"17",r:"2.5"}),c.jsx("circle",{cx:"12",cy:"17",r:"2.5"}),c.jsx("circle",{cx:"19",cy:"17",r:"2.5"}),c.jsx("path",{d:"M12 8.5v6M12 14.5l-7 0M12 14.5l7 0"})]});case"race":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M5 4v16M5 5h7l-1 3h7v6h-7l-1 3H5"})});case"background":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M3 4h18v4H3zM3 10h18v4H3zM3 16h18v4H3z"}),c.jsx("circle",{cx:"6",cy:"6",r:".75",fill:"currentColor",stroke:"none"}),c.jsx("circle",{cx:"6",cy:"12",r:".75",fill:"currentColor",stroke:"none"}),c.jsx("circle",{cx:"6",cy:"18",r:".75",fill:"currentColor",stroke:"none"})]});case"repoviz":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"6",cy:"12",r:"3"}),c.jsx("circle",{cx:"18",cy:"6",r:"3"}),c.jsx("circle",{cx:"18",cy:"18",r:"3"}),c.jsx("path",{d:"M8.5 10.5L15.5 7.5M8.5 13.5L15.5 16.5"})]});case"system-prompt":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"4",y:"4",width:"16",height:"14",rx:"2"}),c.jsx("path",{d:"M8 10h8M8 14h5M9 18l-2 3M15 18l2 3"})]});case"permissions":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"5",y:"11",width:"14",height:"9",rx:"2"}),c.jsx("path",{d:"M8 11V8a4 4 0 018 0v3"}),c.jsx("circle",{cx:"12",cy:"15.5",r:"1.2",fill:"currentColor",stroke:"none"})]});case"tool":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M14 4a4 4 0 014 4l-7 7-4-4 7-7zM7 11l-3 3 6 6 3-3"})});case"quick-open":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),c.jsx("path",{d:"M3 9h18M7 13h10M7 16h6"})]});case"remote":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M5 12.5a7 7 0 0114 0M1.5 9a11 11 0 0121 0M8.5 16a3.5 3.5 0 017 0"}),c.jsx("circle",{cx:"12",cy:"20",r:"1",fill:"currentColor",stroke:"none"})]});default:return null}}const F5=e=>`sm.fileTree.expanded:${e}`;function rq(e){try{const r=localStorage.getItem(F5(e)),n=r?JSON.parse(r):[];return Array.isArray(n)?n.filter(i=>typeof i=="string"):[]}catch{return[]}}function nq(e,r){try{localStorage.setItem(F5(e),JSON.stringify([...r].slice(0,500)))}catch{}}function l1(e,r){const n=r+"/";let i=!1;const s=new Set;for(const a of e){if(a===r||a.startsWith(n)){i=!0;continue}s.add(a)}return i?s:e}const c1={modified:{color:"#e2a93d",label:"M"},added:{color:"#3fb950",label:"A"},deleted:{color:"#f85149",label:"D"},renamed:{color:"#a371f7",label:"R"},untracked:{color:"#8b949e",label:"U"},staged:{color:"#3fb950",label:"S"},conflict:{color:"#f85149",label:"!"}},iq=new Set(["md","txt","json","jsonl","ndjson","js","jsx","ts","tsx","py","go","rs","rb","c","cpp","h","hpp","java","sh","bash","css","scss","html","xml","yaml","yml","toml","ini","conf","env","log","sql","gitignore","png","jpg","jpeg","gif","svg","webp"]);function sq(e){const r=e.toLowerCase().split(".").pop()||"";return iq.has(r)}function aq(e,r){if(r)return"#d97757";switch(e.toLowerCase().split(".").pop()||""){case"ts":case"tsx":return"#3178c6";case"js":case"jsx":return"#f7df1e";case"json":return"#cbcb41";case"md":return"#8a93a0";case"css":case"scss":return"#cc6699";case"py":return"#3776ab";case"go":return"#00add8";case"rs":return"#dea584";case"sh":case"bash":return"#89e051";case"png":case"jpg":case"jpeg":case"gif":case"svg":return"#a4c639";default:return"#8a93a0"}}async function yx(e){var r;try{const n=window.api;return(r=n==null?void 0:n.git)!=null&&r.fileStatus?await n.git.fileStatus(e):{}}catch{return{}}}function oq({cwd:e,onPreviewFile:r,onSendToChat:n,activeTabId:i}){const[s,a]=D.useState([]),[l,o]=D.useState(new Set),u=D.useRef(l);u.current=l;const[f,m]=D.useState(""),[h,y]=D.useState(!1),[x,C]=D.useState(!1),[_,b]=D.useState(null),[w,S]=D.useState({}),[k,T]=D.useState(null),[j,$]=D.useState(null),[P,N]=D.useState(""),[I,U]=D.useState(null),[V,q]=D.useState(""),[F,z]=D.useState(null),G=D.useRef(null),Y=D.useRef(null),oe=D.useRef(0),te=D.useCallback(async()=>{if(!e)return;const Le=++oe.current;C(!0),b(null);const Ze=await window.api.files.list(e,h);oe.current===Le&&(Ze.ok?a(Ze.entries.map(ct=>({...ct}))):(b(Ze.error??"failed to list"),a([])),C(!1))},[e,h]),J=D.useCallback(async Le=>{const Ze=oe.current,ct=new Map;for(const dr of Le){const Xt=dr.split("/").length,Qt=ct.get(Xt);Qt?Qt.push(dr):ct.set(Xt,[dr])}const ut=[];for(const dr of[...ct.keys()].sort((Xt,Qt)=>Xt-Qt)){const Xt=ct.get(dr),Qt=await Promise.all(Xt.map(async cr=>({p:cr,result:await window.api.files.list(cr,h)})));if(oe.current!==Ze)return ut;for(const{p:cr,result:Or}of Qt)Or.ok?a(wr=>d0(wr,cr,Or.entries.map(sn=>({...sn})))):ut.push(cr)}return ut},[h]),K=D.useCallback(async Le=>(await te(),Le.length?J(Le):[]),[te,J]);D.useEffect(()=>{m(""),$(null),T(null),U(null),z(null),S({});const Le=rq(e),Ze=new Set(Le);u.current=Ze,o(Ze);let ct=!1;return(async()=>{const ut=await K(Le);ct||!ut.length||re(dr=>{const Xt=new Set;let Qt=!1;for(const cr of dr){if(ut.some(Or=>cr===Or||cr.startsWith(Or+"/"))){Qt=!0;continue}Xt.add(cr)}return Qt?Xt:dr})})(),yx(e).then(ut=>{ct||S(ut)}),()=>{ct=!0}},[e]);const Z=D.useRef(!0);D.useEffect(()=>{if(Z.current){Z.current=!1;return}K([...u.current])},[h]),D.useEffect(()=>{if(!e)return;const Le=window.setInterval(()=>{yx(e).then(S)},5e3);return()=>window.clearInterval(Le)},[e]),D.useEffect(()=>{if(!k)return;const Le=()=>T(null),Ze=ct=>{ct.key==="Escape"&&T(null)};return window.addEventListener("mousedown",Le),window.addEventListener("keydown",Ze),()=>{window.removeEventListener("mousedown",Le),window.removeEventListener("keydown",Ze)}},[k]),D.useEffect(()=>{j&&setTimeout(()=>{var Le;return(Le=G.current)==null?void 0:Le.select()},30)},[j]),D.useEffect(()=>{I&&setTimeout(()=>{var Le;return(Le=Y.current)==null?void 0:Le.focus()},30)},[I]);const re=D.useCallback(Le=>{const Ze=u.current,ct=Le(Ze);ct!==Ze&&(u.current=ct,o(ct),nq(e,ct))},[e]),he=D.useCallback(async Le=>{if(l.has(Le.path)){re(ct=>l1(ct,Le.path));return}if(re(ct=>new Set(ct).add(Le.path)),Le.children)return;const Ze=await window.api.files.list(Le.path,h);Ze.ok&&a(ct=>d0(ct,Le.path,Ze.entries.map(ut=>({...ut}))))},[l,h,re]),we=D.useCallback(async Le=>{if(Le===e){await te();return}const Ze=await window.api.files.list(Le,h);Ze.ok&&a(ct=>d0(ct,Le,Ze.entries.map(ut=>({...ut}))))},[e,te,h]),Ce=D.useCallback(Le=>{if(Le.isDirectory){he(Le);return}sq(Le.name)&&r?r(Le.path):window.api.files.openExternal(Le.path)},[he,r]),Me=D.useCallback(Le=>{if(n){n(Le);return}if(i){const Ze=Le.startsWith(e+"/")?Le.slice(e.length+1):Le;window.api.pty.write({tabId:i,data:`@${Ze} `})}},[n,i,e]),be=D.useCallback((Le,Ze)=>{Le.preventDefault(),Le.stopPropagation(),T({x:Le.clientX,y:Le.clientY,node:Ze})},[]),se=Le=>{$(Le.path),N(Le.name)},ve=async()=>{if(!j)return;const Le=P.trim();if(!Le){$(null);return}const Ze=await window.api.files.rename(j,Le);if($(null),Ze.ok){const ct=j.slice(0,j.lastIndexOf("/"));re(ut=>l1(ut,j)),await we(ct||e),yx(e).then(S)}else b(Ze.error??"rename failed")},xe=async()=>{if(!I)return;const Le=V.trim();if(!Le){U(null),q("");return}const Ze=await window.api.files.create(I.parent,Le,I.kind);U(null),q(""),Ze.ok?(await we(I.parent),I.kind==="folder"&&re(ct=>new Set(ct).add(I.parent))):b(Ze.error??"create failed")},Ve=async()=>{if(!F)return;const Le=await window.api.files.delete(F.path),Ze=F.path.slice(0,F.path.lastIndexOf("/"));z(null),Le.ok?(re(ct=>l1(ct,F.path)),await we(Ze||e),yx(e).then(S)):b(Le.error??"delete failed")},Re=D.useMemo(()=>{if(!f.trim())return s;const Le=f.toLowerCase();return s.filter(Ze=>Ze.name.toLowerCase().includes(Le))},[s,f]),We=(e==null?void 0:e.split("/").filter(Boolean).pop())||"project";return c.jsxs("div",{className:"w-60 h-full flex flex-col bg-bg-elev border-r border-line text-fg",children:[c.jsxs("div",{className:"p-3 border-b border-line shrink-0",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-2 min-w-0",children:[c.jsx(q5,{size:14,className:"shrink-0 text-accent"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("p",{className:"text-xs font-medium text-fg truncate",children:We}),c.jsx("p",{className:"text-[10px] text-fg-faint truncate",title:e,children:e})]}),c.jsx("button",{onClick:te,className:"p-1 rounded text-fg-faint hover:text-fg hover:bg-bg-hi transition-colors",title:"Refresh",disabled:x,children:c.jsx(hq,{size:12,className:x?"animate-spin":""})})]}),c.jsx("div",{className:"relative",children:c.jsx("input",{value:f,onChange:Le=>m(Le.target.value),placeholder:"Search files…",className:"w-full px-2 py-1 text-xs bg-bg-hi border border-line rounded text-fg placeholder-fg-faint focus:outline-none focus:border-accent/40"})})]}),c.jsxs("div",{className:"flex items-center gap-1 px-3 py-1.5 border-b border-line shrink-0",children:[c.jsx("button",{onClick:()=>U({parent:e,kind:"file"}),className:"p-1.5 rounded text-fg-faint hover:text-fg hover:bg-bg-hi transition-colors",title:"New file",children:c.jsx(pq,{size:12})}),c.jsx("button",{onClick:()=>U({parent:e,kind:"folder"}),className:"p-1.5 rounded text-fg-faint hover:text-fg hover:bg-bg-hi transition-colors",title:"New folder",children:c.jsx(mq,{size:12})}),c.jsx("div",{className:"flex-1"}),c.jsx("button",{onClick:()=>y(Le=>!Le),className:`p-1.5 rounded transition-colors ${h?"text-accent":"text-fg-faint hover:text-fg"} hover:bg-bg-hi`,title:h?"Hide hidden files":"Show hidden files",children:h?c.jsx(gq,{size:12}):c.jsx(vq,{size:12})})]}),c.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[_&&c.jsx("div",{className:"px-3 py-2 text-[11px] text-red-400",children:_}),!_&&Re.length===0&&!x&&c.jsx("div",{className:"p-4 text-center text-[11px] text-fg-faint",children:f?"no matches":"empty folder"}),!_&&c.jsx(U5,{nodes:Re,depth:0,expanded:l,gitStatus:w,renaming:j,renameValue:P,renameInputRef:G,onRenameChange:N,onRenameCommit:ve,onRenameCancel:()=>$(null),onToggleDir:he,onFileClick:Ce,onSendToChat:Me,onContextMenu:be})]}),c.jsx("div",{className:"px-3 py-1.5 border-t border-line text-[10px] text-fg-faint shrink-0",children:"Click to preview · Double-click external · Right-click for more"}),k&&c.jsx(lq,{x:k.x,y:k.y,node:k.node,onClose:()=>T(null),onRename:()=>{se(k.node),T(null)},onDelete:()=>{z(k.node),T(null)},onNewFile:()=>{U({parent:k.node.path,kind:"file"}),T(null)},onNewFolder:()=>{U({parent:k.node.path,kind:"folder"}),T(null)},onOpenExternal:()=>{window.api.files.openExternal(k.node.path),T(null)},onShowInFinder:()=>{window.api.files.showInFinder(k.node.path),T(null)},onCopyPath:()=>{var Le;(Le=navigator.clipboard)==null||Le.writeText(k.node.path),T(null)},onSendToChat:()=>{Me(k.node.path),T(null)}}),I&&c.jsx(X$,{title:`New ${I.kind}`,subtitle:`in ${cq(I.parent)}`,onCancel:()=>{U(null),q("")},onConfirm:xe,confirmLabel:"Create",confirmDisabled:!V.trim(),children:c.jsx("input",{ref:Y,value:V,onChange:Le=>q(Le.target.value),onKeyDown:Le=>{Le.key==="Enter"&&xe(),Le.key==="Escape"&&(U(null),q(""))},placeholder:I.kind==="file"?"filename.txt":"folder-name",className:"w-full px-3 py-2 rounded bg-bg-hi border border-line text-fg text-sm placeholder-fg-faint focus:outline-none focus:border-accent/50"})}),F&&c.jsx(X$,{title:`Delete ${F.isDirectory?"folder":"file"}`,subtitle:null,onCancel:()=>z(null),onConfirm:Ve,confirmLabel:"Delete",danger:!0,children:c.jsxs("p",{className:"text-sm text-fg-dim",children:["Move ",c.jsxs("span",{className:"text-fg font-medium",children:['"',F.name,'"']})," to the trash?",F.isDirectory&&c.jsx("span",{className:"block text-xs text-fg-faint mt-1",children:"All contents will be moved with it."})]})})]})}function U5(e){const{nodes:r,depth:n,expanded:i,gitStatus:s,renaming:a,onContextMenu:l}=e;return c.jsx(c.Fragment,{children:r.map(o=>{const u=i.has(o.path),f=a===o.path,m=s[o.path],h=aq(o.name,o.isDirectory);return c.jsxs("div",{children:[c.jsxs("div",{className:"group flex items-center gap-1.5 py-0.5 pr-2 cursor-pointer transition-colors hover:bg-bg-hi",style:{paddingLeft:`${8+n*14}px`},onClick:()=>{f||(o.isDirectory?e.onToggleDir(o):e.onFileClick(o))},onDoubleClick:()=>{o.isDirectory||window.api.files.openExternal(o.path)},onContextMenu:y=>l(y,o),children:[o.isDirectory?c.jsx(fq,{size:10,className:`shrink-0 text-fg-faint transition-transform ${u?"rotate-90":""}`}):c.jsx("span",{className:"w-[10px] shrink-0"}),o.isDirectory?u?c.jsx(uq,{size:12,color:h}):c.jsx(q5,{size:12,color:h}):c.jsx(dq,{size:12,color:h}),f?c.jsx("input",{ref:e.renameInputRef,value:e.renameValue,onChange:y=>e.onRenameChange(y.target.value),onClick:y=>y.stopPropagation(),onBlur:e.onRenameCommit,onKeyDown:y=>{y.key==="Enter"&&e.onRenameCommit(),y.key==="Escape"&&e.onRenameCancel()},className:"flex-1 min-w-0 px-1 py-0 text-xs bg-bg border border-accent/40 rounded text-fg focus:outline-none"}):c.jsx("span",{className:`flex-1 truncate text-xs ${o.name.startsWith(".")?"text-fg-faint":"text-fg-dim"}`,children:o.name}),m&&c.jsx("span",{className:"shrink-0 text-[9px] font-bold px-1 rounded",style:{color:c1[m].color,backgroundColor:`${c1[m].color}20`},title:m,children:c1[m].label}),!o.isDirectory&&c.jsx("button",{onClick:y=>{y.stopPropagation(),e.onSendToChat(o.path)},title:"Send @path to active terminal",className:"opacity-0 group-hover:opacity-100 p-0.5 rounded text-fg-faint hover:text-accent hover:bg-bg transition-all shrink-0",children:c.jsx(yq,{size:10})})]}),o.isDirectory&&u&&o.children&&c.jsx(U5,{...e,nodes:o.children,depth:n+1})]},o.path)})})}function lq(e){const{x:r,y:n,node:i}=e;return c.jsxs("div",{onMouseDown:s=>s.stopPropagation(),className:"fixed z-[300] w-56 rounded-lg border border-line bg-bg-elev shadow-xl text-xs py-1",style:{left:r,top:n},children:[!i.isDirectory&&c.jsx(uu,{label:"Send to chat",onClick:e.onSendToChat}),c.jsx(uu,{label:"Open in default app",onClick:e.onOpenExternal}),c.jsx(uu,{label:"Reveal in OS",onClick:e.onShowInFinder}),c.jsx(u1,{}),c.jsx(uu,{label:"Copy path",onClick:e.onCopyPath}),c.jsx(uu,{label:"Rename",onClick:e.onRename}),i.isDirectory&&c.jsxs(c.Fragment,{children:[c.jsx(u1,{}),c.jsx(uu,{label:"New file",onClick:e.onNewFile}),c.jsx(uu,{label:"New folder",onClick:e.onNewFolder})]}),c.jsx(u1,{}),c.jsx(uu,{label:"Delete",onClick:e.onDelete,danger:!0})]})}function uu({label:e,onClick:r,danger:n}){return c.jsx("button",{onClick:r,className:`w-full text-left px-3 py-1.5 hover:bg-bg-hi transition-colors ${n?"text-red-400":"text-fg-dim hover:text-fg"}`,children:e})}function u1(){return c.jsx("div",{className:"my-1 border-t border-line"})}function X$(e){return c.jsx("div",{className:"fixed inset-0 z-[400] flex items-center justify-center bg-black/60",onMouseDown:r=>{r.target===r.currentTarget&&e.onCancel()},children:c.jsxs("div",{className:"w-96 rounded-lg border border-line bg-bg-elev p-4 shadow-2xl",children:[c.jsx("h3",{className:"text-sm font-medium text-fg mb-1",children:e.title}),e.subtitle&&c.jsx("p",{className:"text-[11px] text-fg-faint mb-3 truncate",children:e.subtitle}),c.jsx("div",{className:"mb-4",children:e.children}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx("button",{onClick:e.onCancel,className:"px-3 py-1 text-xs text-fg-dim hover:text-fg border border-line rounded transition-colors",children:"Cancel"}),c.jsx("button",{onClick:e.onConfirm,disabled:!!e.confirmDisabled,className:`px-3 py-1 text-xs text-white rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${e.danger?"bg-red-600 hover:bg-red-500":"bg-accent hover:bg-accent/90"}`,children:e.confirmLabel??"OK"})]})]})})}function cq(e){return e.split("/").filter(Boolean).pop()||e}function d0(e,r,n){return e.map(i=>i.path===r?{...i,children:n}:i.children?{...i,children:d0(i.children,r,n)}:i)}function kl({size:e,children:r,className:n,color:i}){return c.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:i||"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:n,children:r})}function q5({size:e,className:r,color:n}){return c.jsx(kl,{size:e,className:r,color:n,children:c.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function uq({size:e,className:r,color:n}){return c.jsx(kl,{size:e,className:r,color:n,children:c.jsx("path",{d:"M6 14l1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.93a2 2 0 0 1 1.66.9l.82 1.2a2 2 0 0 0 1.66.9H18a2 2 0 0 1 2 2v2"})})}function dq({size:e,className:r,color:n}){return c.jsxs(kl,{size:e,className:r,color:n,children:[c.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),c.jsx("polyline",{points:"14 2 14 8 20 8"})]})}function fq({size:e,className:r}){return c.jsx(kl,{size:e,className:r,children:c.jsx("polyline",{points:"9 18 15 12 9 6"})})}function hq({size:e,className:r}){return c.jsxs(kl,{size:e,className:r,children:[c.jsx("polyline",{points:"23 4 23 10 17 10"}),c.jsx("polyline",{points:"1 20 1 14 7 14"}),c.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]})}function pq({size:e,className:r}){return c.jsxs(kl,{size:e,className:r,children:[c.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),c.jsx("polyline",{points:"14 2 14 8 20 8"}),c.jsx("line",{x1:"12",y1:"18",x2:"12",y2:"12"}),c.jsx("line",{x1:"9",y1:"15",x2:"15",y2:"15"})]})}function mq({size:e,className:r}){return c.jsxs(kl,{size:e,className:r,children:[c.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"}),c.jsx("line",{x1:"12",y1:"11",x2:"12",y2:"17"}),c.jsx("line",{x1:"9",y1:"14",x2:"15",y2:"14"})]})}function gq({size:e,className:r}){return c.jsxs(kl,{size:e,className:r,children:[c.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),c.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function vq({size:e,className:r}){return c.jsxs(kl,{size:e,className:r,children:[c.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"}),c.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function yq({size:e,className:r}){return c.jsxs(kl,{size:e,className:r,children:[c.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),c.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})}function bq(e,r={}){switch(e){case"ready":return r.isRecording?"Stop voice input":"Start voice input (local Whisper, offline)";case"idle":return"Microphone — speech model not started";case"loading":return`Microphone — loading speech model, ${typeof r.loadingPct=="number"?Math.round(r.loadingPct):0} percent`;case"error":return r.errorMessage?`Microphone — speech model error: ${r.errorMessage}. Activate to retry.`:"Microphone — speech model error. Activate to retry.";case"load-timeout":return"Microphone — model load timed out. Activate to retry.";case"permission-denied":return"Microphone — permission denied. Open OS settings.";case"unsupported":return"Microphone — voice input not supported in this build."}}const Y$=e=>Symbol.iterator in e,J$=e=>"entries"in e,Q$=(e,r)=>{const n=e instanceof Map?e:new Map(e.entries()),i=r instanceof Map?r:new Map(r.entries());if(n.size!==i.size)return!1;for(const[s,a]of n)if(!i.has(s)||!Object.is(a,i.get(s)))return!1;return!0},xq=(e,r)=>{const n=e[Symbol.iterator](),i=r[Symbol.iterator]();let s=n.next(),a=i.next();for(;!s.done&&!a.done;){if(!Object.is(s.value,a.value))return!1;s=n.next(),a=i.next()}return!!s.done&&!!a.done};function wq(e,r){return Object.is(e,r)?!0:typeof e!="object"||e===null||typeof r!="object"||r===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(r)?!1:Y$(e)&&Y$(r)?J$(e)&&J$(r)?Q$(e,r):xq(e,r):Q$({entries:()=>Object.entries(e)},{entries:()=>Object.entries(r)})}function W5(e){const r=Fe.useRef(void 0);return n=>{const i=e(n);return wq(r.current,i)?r.current:r.current=i}}let Z$=0;const _q=1e3;function Sq(e){const r=performance.now();r-Z$<_q||(Z$=r,gt.debug("voice","mic.gate.click_rejected",{reason:e}))}function H5(){const e=Lt(f=>f.isRecording),r=Lt(f=>f.error),n=Lt(f=>f.loadingProgress),i=Lt(W5(lj)),s=()=>{const f=Lt.getState(),{canRecord:m,reason:h}=lj(f);if(f.isRecording)return f.stopRecording();if(f.wizardArmed&&!f.wizardOpen){f.openWizard();return}if(h==="error"||h==="load-timeout"){f.resetAndRetryModel();return}if(!m)return Sq(h);const y=Jt.getState().activeTabId;y&&f.startRecording(y)},a=bq(i.reason,{loadingPct:n,errorMessage:r,isRecording:e}),l=i.reason==="unsupported",o=!i.canRecord,u=i.reason==="loading"?"text-fg-faint animate-pulse cursor-wait":i.reason==="error"||i.reason==="load-timeout"?"text-red-400 cursor-pointer":i.reason==="permission-denied"?"text-amber-400 cursor-pointer":i.reason==="idle"?"text-fg-faint cursor-pointer":i.reason==="unsupported"?"text-fg-faint cursor-not-allowed":e?"text-red-400 ring-2 ring-red-400 animate-pulse":"text-fg-dim hover:text-fg";return c.jsx("button",{onClick:s,disabled:l,"aria-disabled":o,"aria-label":a,title:a,"data-testid":"mic-button","data-state":i.reason,className:`p-1.5 rounded transition-colors ${u}`,children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("rect",{x:"9",y:"1",width:"6",height:"12",rx:"3"}),c.jsx("path",{d:"M5 10a7 7 0 0 0 14 0"}),c.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"}),c.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"})]})})}function kq(){const e=Lt(n=>n.ttsEnabled),r=Lt(n=>n.toggleTTS);return c.jsxs("button",{onClick:r,title:e?"Read Claude replies aloud: ON":"Read Claude replies aloud: OFF",className:`px-1.5 py-1 rounded transition-colors flex items-center gap-1 ${e?"text-accent":"text-fg-dim hover:text-fg"}`,children:[c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),e?c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),c.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]}):c.jsxs(c.Fragment,{children:[c.jsx("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),c.jsx("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]})]}),c.jsx("span",{className:"text-[10px] font-medium tracking-wide",children:"TTS"})]})}const eN=[{key:"overview",label:"Home",icon:"home",hint:"Today's sessions + the 5-hour window"},{key:"terminal",label:"Terminal",icon:"terminal",hint:"Live Claude Code, in-app"},{key:"agent-view",label:"Agent-View",icon:"agent-view",liveKind:"agentView",hint:"Workshop scene of the active session"},{key:"subagents",label:"Subagents",icon:"hive",liveKind:"subagents",hint:"Sub-agents working in parallel"},{key:"scheduler",label:"Scheduler",icon:"scheduler",liveKind:"scheduler",hint:"Author PRDs + run them as claude -p jobs"},{key:"prompts",label:"Prompts",icon:"book",hint:"Click-to-insert prompt library"},{key:"tasks",label:"Tasks",icon:"tasks",liveKind:"tasks",hint:"Active to-dos across sessions"},{key:"history",label:"History",icon:"history",hint:"Every session, ever — resumable"},{key:"usage",label:"Usage",icon:"usage",hint:"Tokens, cost, sessions per day"},{key:"knowledge-graph",label:"Knowledge Graph",icon:"knowledge-graph",hint:"Distilled graph + Q&A over your prompt log"}],tN=[{key:"skills",label:"Skills",icon:"skills",hint:"Reusable instructions Claude loads"},{key:"plugins",label:"Plugins",icon:"plugins",hint:"Extensions for Claude Code"},{key:"mcp",label:"MCP Servers",icon:"mcp",hint:"External tools and integrations"},{key:"hooks",label:"Hooks",icon:"hooks",hint:"Run scripts on session events"},{key:"keybindings",label:"Keybindings",icon:"keys",hint:"Shortcuts you can override"},{key:"doc-editor",label:"Doc Editor",icon:"docs",hint:"Edit CLAUDE.md and friends"},{key:"memory",label:"Memory",icon:"memory",hint:"Workspace memory store"},{key:"projects",label:"Projects",icon:"projects",hint:"All known project folders"},{key:"system-prompt",label:"System Prompt",icon:"system-prompt",hint:"Personality and behavior"},{key:"permissions",label:"Permissions",icon:"permissions",hint:"Allow / deny rules"},{key:"settings",label:"Settings",icon:"settings",hint:"Theme, voice, billing window"},{key:"remote",label:"Remote",icon:"remote",hint:"Web remote control — disabled by default"}],rN=[{key:"voice",label:"Voice",icon:"mic",hint:"Whisper transcription + push-to-talk"},{key:"dispatch",label:"Dispatch",icon:"orchestrator",hint:"Boss · Orchestrate · Race · Hives"},{key:"repoviz",label:"Repo Viz",icon:"repoviz",hint:"Language + directory map"},{key:"search",label:"Search",icon:"global-search",hint:"⌘P file · ⌘⇧F content"}],cj="sm.almanac.sidebarWidth",V5=180,G5=480,uj=252;function Cq(){try{const e=parseInt(localStorage.getItem(cj)??"",10);if(Number.isFinite(e))return Math.min(G5,Math.max(V5,e))}catch{}return uj}const K5="sm.almanac.sidebarMode";function jq(){try{return localStorage.getItem(K5)==="files"?"files":"nav"}catch{return"nav"}}const X5="sm.almanac.collapsedGroups";function Eq(){try{const e=localStorage.getItem(X5);if(!e)return new Set;const r=JSON.parse(e);return Array.isArray(r)?new Set(r.filter(n=>n==="Workspace"||n==="Configure"||n==="Tools")):new Set}catch{return new Set}}function Tq(){const e=s0(a=>a.tabs),r=yc(a=>{var l;return(((l=a.snapshot)==null?void 0:l.jobs)??[]).some(o=>o.status==="running")}),[n,i]=D.useState(()=>Date.now());D.useEffect(()=>{const a=setInterval(()=>i(Date.now()),5e3);return()=>clearInterval(a)},[]);const s=Object.values(e);return{subagents:s.some(a=>a.agents.some(l=>n-l.at<6e4)),tasks:s.some(a=>a.todos.some(l=>l.status==="in_progress")),agentView:s.some(a=>a.lastEventAt>0&&n-a.lastEventAt<5e3),scheduler:r}}function Aq({active:e,onNavigate:r,onNewSession:n,onOpenFile:i}){const[s,a]=D.useState(()=>jq()),l=D.useCallback(k=>{a(k);try{localStorage.setItem(K5,k)}catch{}},[]),[o,u]=D.useState(()=>Eq()),f=D.useCallback(k=>{u(T=>{const j=new Set(T);j.has(k)?j.delete(k):j.add(k);try{localStorage.setItem(X5,JSON.stringify(Array.from(j)))}catch{}return j})},[]),m=Jt(k=>k.tabs),h=Jt(k=>k.activeTabId),y=m.find(k=>k.id===h)??null,x=Tq(),[C,_]=D.useState(()=>Cq()),b=D.useRef(C);b.current=C;const w=D.useCallback(k=>{k.preventDefault();const T=k.clientX,j=b.current;let $=j;const P=I=>{$=Math.min(G5,Math.max(V5,j+(I.clientX-T))),_($)},N=()=>{window.removeEventListener("pointermove",P),window.removeEventListener("pointerup",N),document.body.style.cursor="",document.body.style.userSelect="";try{localStorage.setItem(cj,String($))}catch{}};window.addEventListener("pointermove",P),window.addEventListener("pointerup",N),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]),S=D.useCallback(()=>{_(uj);try{localStorage.setItem(cj,String(uj))}catch{}},[]);return c.jsxs("aside",{className:"shrink-0 bg-bg-elev border-r border-line flex flex-col relative",style:{width:C},"data-testid":"tour-leftnav","aria-label":"Primary navigation",children:[c.jsx($q,{tab:y,onNewSession:n}),c.jsx("div",{className:"px-3.5 pt-3 pb-2 flex gap-1",children:["nav","files"].map(k=>c.jsx("button",{onClick:()=>l(k),"aria-pressed":s===k,className:`flex-1 py-1.5 rounded-md text-[12px] font-semibold tracking-[0.02em] transition-colors ${s===k?"bg-bg-hi text-fg border border-line":"text-fg-faint hover:text-fg-dim border border-transparent"}`,children:k==="nav"?"Navigate":"Files"},k))}),c.jsx("div",{className:"flex-1 min-h-0 overflow-auto px-2 pb-3",children:s==="nav"?c.jsxs(c.Fragment,{children:[c.jsx(d1,{label:"Workspace",collapsed:o.has("Workspace"),count:eN.length,onToggle:()=>f("Workspace")}),!o.has("Workspace")&&eN.map(k=>c.jsx(nN,{item:k,active:e===k.key,live:k.liveKind?x[k.liveKind]:!1,onClick:()=>r(k.key)},k.key)),c.jsx(d1,{label:"Configure",collapsed:o.has("Configure"),count:tN.length,onToggle:()=>f("Configure")}),!o.has("Configure")&&tN.map(k=>c.jsx(nN,{item:k,active:e===k.key,live:!1,onClick:()=>r(k.key)},k.key)),c.jsx(d1,{label:"Tools",collapsed:o.has("Tools"),count:rN.length,onToggle:()=>f("Tools")}),!o.has("Tools")&&rN.map(k=>c.jsx(Pq,{tool:k,active:e===k.key,onClick:()=>r(k.key)},k.key))]}):c.jsx(Rq,{tab:y,onOpenFile:i})}),c.jsx(Iq,{}),c.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar",title:"Drag to resize · double-click to reset",onPointerDown:w,onDoubleClick:S,className:"absolute top-0 right-0 h-full w-1.5 translate-x-1/2 z-10 cursor-col-resize hover:bg-accent/40 active:bg-accent/60 transition-colors"})]})}function $q({tab:e,onNewSession:r}){const n=(e==null?void 0:e.label)??"no session",i=Oq((e==null?void 0:e.cwd)??null);return c.jsxs("div",{className:"px-[18px] pt-[14px] pb-[10px] border-b border-rule",children:[c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.06em] text-fg-faint uppercase",children:"Project"}),c.jsxs("div",{className:"flex items-baseline gap-2 mt-1",children:[c.jsx("span",{className:"self-center w-2 h-2 rounded-full bg-sage"}),c.jsx("span",{className:"font-serif text-[18px] font-medium text-fg truncate",title:(e==null?void 0:e.cwd)??"",children:n})]}),c.jsx("div",{className:"text-[12px] text-fg-faint font-mono mt-0.5 truncate",children:i?`⌥${i}`:e?e.cwd:"—"}),c.jsxs("div",{className:"mt-3 flex items-stretch gap-1.5",children:[c.jsxs("button",{onClick:r,"data-testid":"tour-new-session",className:"flex-1 px-3 py-1.5 rounded-md bg-bg-hi border border-line text-fg text-[12.5px] font-medium hover:bg-bg-hi/80 hover:border-accent/40 transition-colors flex items-center justify-center gap-1.5",children:[c.jsx(Do,{name:"plus",size:13,stroke:1.8}),"New session"]}),c.jsx("div",{className:"flex items-center rounded-md bg-bg-hi border border-line",children:c.jsx(H5,{})})]})]})}const bx=new Map,Nq=3e4;function Oq(e){const[r,n]=D.useState(()=>{var i;return e?((i=bx.get(e))==null?void 0:i.value)??null:null});return D.useEffect(()=>{if(!e){n(null);return}let i=!1;return(async()=>{const a=bx.get(e);if(a&&Date.now()-a.ts<Nq){i||n(a.value);return}try{const l=await window.api.app.gitBranch(e);if(i)return;bx.set(e,{value:l,ts:Date.now()}),n(l)}catch{if(i)return;bx.set(e,{value:null,ts:Date.now()}),n(null)}})(),()=>{i=!0}},[e]),r}function d1({label:e,collapsed:r,count:n,onToggle:i}){return c.jsxs("button",{onClick:i,"aria-expanded":!r,title:r?`Expand ${e}`:`Collapse ${e}`,className:"group w-full flex items-center gap-1.5 px-3 pt-3.5 pb-1.5 font-serif italic text-[11px] font-bold tracking-[0.07em] uppercase text-fg-faint hover:text-fg-dim transition-colors text-left",children:[c.jsx("span",{"aria-hidden":!0,className:"inline-block w-2 text-[9px] not-italic transition-transform",style:{transform:r?"rotate(-90deg)":"rotate(0deg)"},children:"▾"}),c.jsx("span",{className:"flex-1",children:e}),r&&c.jsx("span",{className:"not-italic text-[10px] font-mono text-fg-faint/70 normal-case tracking-normal",children:n})]})}function nN({item:e,active:r,live:n,onClick:i}){return c.jsxs("button",{onClick:i,title:e.hint,className:`relative w-full flex items-center gap-3 px-3.5 py-[9px] rounded-[10px] text-left text-[14px] mb-0.5 transition-colors ${r?"bg-bg-hi text-fg font-semibold border border-line":"text-fg-dim hover:bg-bg-hi/50 hover:text-fg border border-transparent"}`,children:[r&&c.jsx("span",{"aria-hidden":!0,className:"absolute -left-[10px] top-3 bottom-3 w-[3px] rounded-sm bg-accent"}),c.jsx("span",{className:`inline-flex ${r?"text-accent":"text-fg-faint"}`,children:c.jsx(Do,{name:e.icon,size:17,stroke:1.6})}),c.jsx("span",{className:"flex-1 truncate",children:e.label}),n&&c.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-accent animate-pulse",title:"live activity"})]})}function Pq({tool:e,active:r,onClick:n}){return c.jsxs("button",{onClick:n,title:e.hint,className:`relative w-full flex items-center gap-3 px-3.5 py-[7px] rounded-[10px] text-left text-[13px] mb-0.5 transition-colors ${r?"bg-bg-hi text-fg font-semibold border border-line":"text-fg-dim hover:bg-bg-hi/50 hover:text-fg border border-transparent"}`,children:[r&&c.jsx("span",{"aria-hidden":!0,className:"absolute -left-[10px] top-2 bottom-2 w-[3px] rounded-sm bg-accent"}),c.jsx("span",{className:`inline-flex ${r?"text-accent":"text-fg-faint"}`,children:c.jsx(Do,{name:e.icon,size:15,stroke:1.6})}),c.jsx("span",{className:"flex-1 truncate",children:e.label})]})}function Rq({tab:e,onOpenFile:r}){return e?c.jsxs("div",{className:"pt-1",children:[c.jsx("div",{className:"px-3 pb-2 text-[11.5px] text-fg-faint font-mono truncate",title:e.cwd,children:Mq(e.cwd)}),c.jsx(oq,{cwd:e.cwd,activeTabId:e.id,onPreviewFile:r})]}):c.jsx("div",{className:"px-3 py-6 text-center text-[12px] text-fg-faint",children:"No session selected."})}function Mq(e){const r="/home/";if(e.startsWith(r)){const n=e.slice(r.length).split("/").slice(1).join("/");return n?`~/${n}`:"~"}return e}function Iq(){const e=Lt(l=>l.isRecording),r=Jt(l=>l.tabs),n=Jt(l=>l.activeTabId),i=r.find(l=>l.id===n)??null,[s,a]=D.useState(null);return D.useEffect(()=>{let l=!1;if(!(i!=null&&i.presetId)){a(null);return}return S5(i.presetId).then(o=>{l||a((o==null?void 0:o.model)??null)}).catch(()=>{l||a(null)}),()=>{l=!0}},[i==null?void 0:i.presetId]),c.jsxs("div",{className:"px-3.5 py-2.5 border-t border-rule flex items-center gap-2 text-[11.5px] text-fg-dim font-mono",children:[c.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${e?"bg-red-500 animate-pulse":"bg-sage"}`,title:e?"recording":"idle"}),c.jsx("span",{className:"truncate",title:s??"",children:e?"recording…":s?`Claude · ${Dq(s)}`:"Claude Code"})]})}function Dq(e){var n,i,s,a,l,o;const r=e.toLowerCase();if(r.includes("opus")){const u=(i=(n=e.match(/(\d+[-.]?\d*)/))==null?void 0:n[1])==null?void 0:i.replace("-",".");return u?`Opus ${u}`:"Opus"}if(r.includes("sonnet")){const u=(a=(s=e.match(/(\d+[-.]?\d*)/))==null?void 0:s[1])==null?void 0:a.replace("-",".");return u?`Sonnet ${u}`:"Sonnet"}if(r.includes("haiku")){const u=(o=(l=e.match(/(\d+[-.]?\d*)/))==null?void 0:l[1])==null?void 0:o.replace("-",".");return u?`Haiku ${u}`:"Haiku"}return e}function Lq({onNavigate:e}){const r=Jt(b=>b.tabs),n=Jt(b=>b.activeTabId),i=r.find(b=>b.id===n)??null,s=Uy(i),a=(s==null?void 0:s.lastEventAt)??0,l=Xd(b=>b.data),o=yc(b=>{var w;return((w=b.snapshot)==null?void 0:w.paused)??null}),[u,f]=D.useState(null),[,m]=D.useState(0);D.useEffect(()=>{const b=setInterval(()=>m(w=>w+1),6e4);return()=>clearInterval(b)},[]),D.useEffect(()=>{let b=!1;if(!(i!=null&&i.cwd)){f(null);return}return window.api.app.gitBranch(i.cwd).then(w=>{b||f(w)}).catch(()=>{b||f(null)}),()=>{b=!0}},[i==null?void 0:i.cwd]);const h=Wy(l),y=(h==null?void 0:h.usage.five_hour)??null,x=y?Math.round(y.utilization):null,C=(l==null?void 0:l.kind)==="ok"||(l==null?void 0:l.kind)==="ok-stale",_=a>0?Bq(Date.now()-a):"—";return c.jsxs("div",{className:"h-[30px] shrink-0 bg-bg-elev border-t border-line flex items-center gap-4 px-[18px] font-mono text-[11.5px] text-fg-dim","data-testid":"tour-statusbar",children:[c.jsxs("button",{onClick:()=>e==null?void 0:e("settings"),className:"flex items-center gap-1.5 hover:text-fg transition-colors",title:C?"Connected to Anthropic":"Disconnected",children:[c.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${C?"bg-sage":"bg-fg-faint"}`}),c.jsx("span",{children:C?"connected":"offline"})]}),c.jsx("button",{onClick:()=>e==null?void 0:e("usage"),className:"hover:text-fg transition-colors",title:"Open Usage",children:x!=null?`${x}% of 5h window used`:"5h —"}),o&&c.jsxs("button",{onClick:()=>e==null?void 0:e("scheduler"),title:"Scheduler is paused — click to open Scheduler",className:`flex items-center gap-1 px-1.5 py-0.5 rounded border font-mono text-[10.5px] transition-colors ${o.reason==="auth"||o.reason==="network"?"border-red-700/60 text-red-300 hover:bg-red-900/20":"border-amber-700/60 text-amber-300 hover:bg-amber-900/20"}`,children:[c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current opacity-80"}),"Scheduler paused · ",o.reason]}),i&&c.jsxs("span",{className:"text-fg-faint",title:i.cwd,children:[i.label,u&&c.jsxs("span",{className:"text-fg-dim",children:[" · ⌥",u]})]}),c.jsxs("span",{className:"text-fg-faint",children:["last activity: ",c.jsx("span",{className:"text-fg-dim",children:_})]}),c.jsx("span",{className:"flex-1"}),c.jsxs("span",{className:"text-fg-faint",children:["v","0.21.4"]})]})}function Bq(e){const r=Math.max(0,Math.floor(e/1e3));if(r<60)return`${r}s ago`;const n=Math.floor(r/60);return n<60?`${n}m ago`:`${Math.floor(n/60)}h ago`}var f1={exports:{}},iN;function zq(){return iN||(iN=1,(function(e,r){(function(n,i){e.exports=i()})(globalThis,(()=>(()=>{var n={4567:function(l,o,u){var f=this&&this.__decorate||function(S,k,T,j){var $,P=arguments.length,N=P<3?k:j===null?j=Object.getOwnPropertyDescriptor(k,T):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(S,k,T,j);else for(var I=S.length-1;I>=0;I--)($=S[I])&&(N=(P<3?$(N):P>3?$(k,T,N):$(k,T))||N);return P>3&&N&&Object.defineProperty(k,T,N),N},m=this&&this.__param||function(S,k){return function(T,j){k(T,j,S)}};Object.defineProperty(o,"__esModule",{value:!0}),o.AccessibilityManager=void 0;const h=u(9042),y=u(9924),x=u(844),C=u(4725),_=u(2585),b=u(3656);let w=o.AccessibilityManager=class extends x.Disposable{constructor(S,k,T,j){super(),this._terminal=S,this._coreBrowserService=T,this._renderService=j,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let $=0;$<this._terminal.rows;$++)this._rowElements[$]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[$]);if(this._topBoundaryFocusListener=$=>this._handleBoundaryFocus($,0),this._bottomBoundaryFocusListener=$=>this._handleBoundaryFocus($,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new y.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize(($=>this._handleResize($.rows)))),this.register(this._terminal.onRender(($=>this._refreshRows($.start,$.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar(($=>this._handleChar($)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
2896
2896
|
`)))),this.register(this._terminal.onA11yTab(($=>this._handleTab($)))),this.register(this._terminal.onKey(($=>this._handleKey($.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this.register((0,b.addDisposableDomListener)(document,"selectionchange",(()=>this._handleSelectionChange()))),this.register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,x.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(S){for(let k=0;k<S;k++)this._handleChar(" ")}_handleChar(S){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==S&&(this._charsToAnnounce+=S):this._charsToAnnounce+=S,S===`
|
|
2897
2897
|
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=h.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(S){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(S)||this._charsToConsume.push(S)}_refreshRows(S,k){this._liveRegionDebouncer.refresh(S,k,this._terminal.rows)}_renderRows(S,k){const T=this._terminal.buffer,j=T.lines.length.toString();for(let $=S;$<=k;$++){const P=T.lines.get(T.ydisp+$),N=[],I=(P==null?void 0:P.translateToString(!0,void 0,void 0,N))||"",U=(T.ydisp+$+1).toString(),V=this._rowElements[$];V&&(I.length===0?(V.innerText=" ",this._rowColumns.set(V,[0,1])):(V.textContent=I,this._rowColumns.set(V,N)),V.setAttribute("aria-posinset",U),V.setAttribute("aria-setsize",j))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(S,k){const T=S.target,j=this._rowElements[k===0?1:this._rowElements.length-2];if(T.getAttribute("aria-posinset")===(k===0?"1":`${this._terminal.buffer.lines.length}`)||S.relatedTarget!==j)return;let $,P;if(k===0?($=T,P=this._rowElements.pop(),this._rowContainer.removeChild(P)):($=this._rowElements.shift(),P=T,this._rowContainer.removeChild($)),$.removeEventListener("focus",this._topBoundaryFocusListener),P.removeEventListener("focus",this._bottomBoundaryFocusListener),k===0){const N=this._createAccessibilityTreeNode();this._rowElements.unshift(N),this._rowContainer.insertAdjacentElement("afterbegin",N)}else{const N=this._createAccessibilityTreeNode();this._rowElements.push(N),this._rowContainer.appendChild(N)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(k===0?-1:1),this._rowElements[k===0?1:this._rowElements.length-2].focus(),S.preventDefault(),S.stopImmediatePropagation()}_handleSelectionChange(){var I;if(this._rowElements.length===0)return;const S=document.getSelection();if(!S)return;if(S.isCollapsed)return void(this._rowContainer.contains(S.anchorNode)&&this._terminal.clearSelection());if(!S.anchorNode||!S.focusNode)return void console.error("anchorNode and/or focusNode are null");let k={node:S.anchorNode,offset:S.anchorOffset},T={node:S.focusNode,offset:S.focusOffset};if((k.node.compareDocumentPosition(T.node)&Node.DOCUMENT_POSITION_PRECEDING||k.node===T.node&&k.offset>T.offset)&&([k,T]=[T,k]),k.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(k={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(k.node))return;const j=this._rowElements.slice(-1)[0];if(T.node.compareDocumentPosition(j)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(T={node:j,offset:((I=j.textContent)==null?void 0:I.length)??0}),!this._rowContainer.contains(T.node))return;const $=({node:U,offset:V})=>{const q=U instanceof Text?U.parentNode:U;let F=parseInt(q==null?void 0:q.getAttribute("aria-posinset"),10)-1;if(isNaN(F))return console.warn("row is invalid. Race condition?"),null;const z=this._rowColumns.get(q);if(!z)return console.warn("columns is null. Race condition?"),null;let G=V<z.length?z[V]:z.slice(-1)[0]+1;return G>=this._terminal.cols&&(++F,G=0),{row:F,column:G}},P=$(k),N=$(T);if(P&&N){if(P.row>N.row||P.row===N.row&&P.column>=N.column)throw new Error("invalid range");this._terminal.select(P.column,P.row,(N.row-P.row)*this._terminal.cols-P.column+N.column)}}_handleResize(S){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let k=this._rowContainer.children.length;k<this._terminal.rows;k++)this._rowElements[k]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[k]);for(;this._rowElements.length>S;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const S=this._coreBrowserService.mainDocument.createElement("div");return S.setAttribute("role","listitem"),S.tabIndex=-1,this._refreshRowDimensions(S),S}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let S=0;S<this._terminal.rows;S++)this._refreshRowDimensions(this._rowElements[S])}}_refreshRowDimensions(S){S.style.height=`${this._renderService.dimensions.css.cell.height}px`}};o.AccessibilityManager=w=f([m(1,_.IInstantiationService),m(2,C.ICoreBrowserService),m(3,C.IRenderService)],w)},3614:(l,o)=>{function u(y){return y.replace(/\r?\n/g,"\r")}function f(y,x){return x?"\x1B[200~"+y+"\x1B[201~":y}function m(y,x,C,_){y=f(y=u(y),C.decPrivateModes.bracketedPasteMode&&_.rawOptions.ignoreBracketedPasteMode!==!0),C.triggerDataEvent(y,!0),x.value=""}function h(y,x,C){const _=C.getBoundingClientRect(),b=y.clientX-_.left-10,w=y.clientY-_.top-10;x.style.width="20px",x.style.height="20px",x.style.left=`${b}px`,x.style.top=`${w}px`,x.style.zIndex="1000",x.focus()}Object.defineProperty(o,"__esModule",{value:!0}),o.rightClickHandler=o.moveTextAreaUnderMouseCursor=o.paste=o.handlePasteEvent=o.copyHandler=o.bracketTextForPaste=o.prepareTextForTerminal=void 0,o.prepareTextForTerminal=u,o.bracketTextForPaste=f,o.copyHandler=function(y,x){y.clipboardData&&y.clipboardData.setData("text/plain",x.selectionText),y.preventDefault()},o.handlePasteEvent=function(y,x,C,_){y.stopPropagation(),y.clipboardData&&m(y.clipboardData.getData("text/plain"),x,C,_)},o.paste=m,o.moveTextAreaUnderMouseCursor=h,o.rightClickHandler=function(y,x,C,_,b){h(y,x,C),b&&_.rightClickSelect(y),x.value=_.selectionText,x.select()}},7239:(l,o,u)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.ColorContrastCache=void 0;const f=u(1505);o.ColorContrastCache=class{constructor(){this._color=new f.TwoKeyMap,this._css=new f.TwoKeyMap}setCss(m,h,y){this._css.set(m,h,y)}getCss(m,h){return this._css.get(m,h)}setColor(m,h,y){this._color.set(m,h,y)}getColor(m,h){return this._color.get(m,h)}clear(){this._color.clear(),this._css.clear()}}},3656:(l,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.addDisposableDomListener=void 0,o.addDisposableDomListener=function(u,f,m,h){u.addEventListener(f,m,h);let y=!1;return{dispose:()=>{y||(y=!0,u.removeEventListener(f,m,h))}}}},3551:function(l,o,u){var f=this&&this.__decorate||function(w,S,k,T){var j,$=arguments.length,P=$<3?S:T===null?T=Object.getOwnPropertyDescriptor(S,k):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")P=Reflect.decorate(w,S,k,T);else for(var N=w.length-1;N>=0;N--)(j=w[N])&&(P=($<3?j(P):$>3?j(S,k,P):j(S,k))||P);return $>3&&P&&Object.defineProperty(S,k,P),P},m=this&&this.__param||function(w,S){return function(k,T){S(k,T,w)}};Object.defineProperty(o,"__esModule",{value:!0}),o.Linkifier=void 0;const h=u(3656),y=u(8460),x=u(844),C=u(2585),_=u(4725);let b=o.Linkifier=class extends x.Disposable{get currentLink(){return this._currentLink}constructor(w,S,k,T,j){super(),this._element=w,this._mouseService=S,this._renderService=k,this._bufferService=T,this._linkProviderService=j,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new y.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new y.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,x.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,x.toDisposable)((()=>{var $;this._lastMouseEvent=void 0,($=this._activeProviderReplies)==null||$.clear()}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0}))),this.register((0,h.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,h.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,h.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,h.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(w){this._lastMouseEvent=w;const S=this._positionFromMouseEvent(w,this._element,this._mouseService);if(!S)return;this._isMouseOut=!1;const k=w.composedPath();for(let T=0;T<k.length;T++){const j=k[T];if(j.classList.contains("xterm"))break;if(j.classList.contains("xterm-hover"))return}this._lastBufferCell&&S.x===this._lastBufferCell.x&&S.y===this._lastBufferCell.y||(this._handleHover(S),this._lastBufferCell=S)}_handleHover(w){if(this._activeLine!==w.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(w,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,w)||(this._clearCurrentLink(),this._askForLink(w,!0))}_askForLink(w,S){var T,j;this._activeProviderReplies&&S||((T=this._activeProviderReplies)==null||T.forEach(($=>{$==null||$.forEach((P=>{P.link.dispose&&P.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=w.y);let k=!1;for(const[$,P]of this._linkProviderService.linkProviders.entries())S?(j=this._activeProviderReplies)!=null&&j.get($)&&(k=this._checkLinkProviderResult($,w,k)):P.provideLinks(w.y,(N=>{var U,V;if(this._isMouseOut)return;const I=N==null?void 0:N.map((q=>({link:q})));(U=this._activeProviderReplies)==null||U.set($,I),k=this._checkLinkProviderResult($,w,k),((V=this._activeProviderReplies)==null?void 0:V.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(w.y,this._activeProviderReplies)}))}_removeIntersectingLinks(w,S){const k=new Set;for(let T=0;T<S.size;T++){const j=S.get(T);if(j)for(let $=0;$<j.length;$++){const P=j[$],N=P.link.range.start.y<w?0:P.link.range.start.x,I=P.link.range.end.y>w?this._bufferService.cols:P.link.range.end.x;for(let U=N;U<=I;U++){if(k.has(U)){j.splice($--,1);break}k.add(U)}}}}_checkLinkProviderResult(w,S,k){var $;if(!this._activeProviderReplies)return k;const T=this._activeProviderReplies.get(w);let j=!1;for(let P=0;P<w;P++)this._activeProviderReplies.has(P)&&!this._activeProviderReplies.get(P)||(j=!0);if(!j&&T){const P=T.find((N=>this._linkAtPosition(N.link,S)));P&&(k=!0,this._handleNewLink(P))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!k)for(let P=0;P<this._activeProviderReplies.size;P++){const N=($=this._activeProviderReplies.get(P))==null?void 0:$.find((I=>this._linkAtPosition(I.link,S)));if(N){k=!0,this._handleNewLink(N);break}}return k}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(w){if(!this._currentLink)return;const S=this._positionFromMouseEvent(w,this._element,this._mouseService);S&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,S)&&this._currentLink.link.activate(w,this._currentLink.link.text)}_clearCurrentLink(w,S){this._currentLink&&this._lastMouseEvent&&(!w||!S||this._currentLink.link.range.start.y>=w&&this._currentLink.link.range.end.y<=S)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,x.disposeArray)(this._linkCacheDisposables))}_handleNewLink(w){if(!this._lastMouseEvent)return;const S=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);S&&this._linkAtPosition(w.link,S)&&(this._currentLink=w,this._currentLink.state={decorations:{underline:w.link.decorations===void 0||w.link.decorations.underline,pointerCursor:w.link.decorations===void 0||w.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,w.link,this._lastMouseEvent),w.link.decorations={},Object.defineProperties(w.link.decorations,{pointerCursor:{get:()=>{var k,T;return(T=(k=this._currentLink)==null?void 0:k.state)==null?void 0:T.decorations.pointerCursor},set:k=>{var T;(T=this._currentLink)!=null&&T.state&&this._currentLink.state.decorations.pointerCursor!==k&&(this._currentLink.state.decorations.pointerCursor=k,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",k))}},underline:{get:()=>{var k,T;return(T=(k=this._currentLink)==null?void 0:k.state)==null?void 0:T.decorations.underline},set:k=>{var T,j,$;(T=this._currentLink)!=null&&T.state&&(($=(j=this._currentLink)==null?void 0:j.state)==null?void 0:$.decorations.underline)!==k&&(this._currentLink.state.decorations.underline=k,this._currentLink.state.isHovered&&this._fireUnderlineEvent(w.link,k))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((k=>{if(!this._currentLink)return;const T=k.start===0?0:k.start+1+this._bufferService.buffer.ydisp,j=this._bufferService.buffer.ydisp+1+k.end;if(this._currentLink.link.range.start.y>=T&&this._currentLink.link.range.end.y<=j&&(this._clearCurrentLink(T,j),this._lastMouseEvent)){const $=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);$&&this._askForLink($,!1)}}))))}_linkHover(w,S,k){var T;(T=this._currentLink)!=null&&T.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(S,!0),this._currentLink.state.decorations.pointerCursor&&w.classList.add("xterm-cursor-pointer")),S.hover&&S.hover(k,S.text)}_fireUnderlineEvent(w,S){const k=w.range,T=this._bufferService.buffer.ydisp,j=this._createLinkUnderlineEvent(k.start.x-1,k.start.y-T-1,k.end.x,k.end.y-T-1,void 0);(S?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(j)}_linkLeave(w,S,k){var T;(T=this._currentLink)!=null&&T.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(S,!1),this._currentLink.state.decorations.pointerCursor&&w.classList.remove("xterm-cursor-pointer")),S.leave&&S.leave(k,S.text)}_linkAtPosition(w,S){const k=w.range.start.y*this._bufferService.cols+w.range.start.x,T=w.range.end.y*this._bufferService.cols+w.range.end.x,j=S.y*this._bufferService.cols+S.x;return k<=j&&j<=T}_positionFromMouseEvent(w,S,k){const T=k.getCoords(w,S,this._bufferService.cols,this._bufferService.rows);if(T)return{x:T[0],y:T[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(w,S,k,T,j){return{x1:w,y1:S,x2:k,y2:T,cols:this._bufferService.cols,fg:j}}};o.Linkifier=b=f([m(1,_.IMouseService),m(2,_.IRenderService),m(3,C.IBufferService),m(4,_.ILinkProviderService)],b)},9042:(l,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.tooMuchOutput=o.promptLabel=void 0,o.promptLabel="Terminal input",o.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(l,o,u){var f=this&&this.__decorate||function(_,b,w,S){var k,T=arguments.length,j=T<3?b:S===null?S=Object.getOwnPropertyDescriptor(b,w):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(_,b,w,S);else for(var $=_.length-1;$>=0;$--)(k=_[$])&&(j=(T<3?k(j):T>3?k(b,w,j):k(b,w))||j);return T>3&&j&&Object.defineProperty(b,w,j),j},m=this&&this.__param||function(_,b){return function(w,S){b(w,S,_)}};Object.defineProperty(o,"__esModule",{value:!0}),o.OscLinkProvider=void 0;const h=u(511),y=u(2585);let x=o.OscLinkProvider=class{constructor(_,b,w){this._bufferService=_,this._optionsService=b,this._oscLinkService=w}provideLinks(_,b){var I;const w=this._bufferService.buffer.lines.get(_-1);if(!w)return void b(void 0);const S=[],k=this._optionsService.rawOptions.linkHandler,T=new h.CellData,j=w.getTrimmedLength();let $=-1,P=-1,N=!1;for(let U=0;U<j;U++)if(P!==-1||w.hasContent(U)){if(w.loadCell(U,T),T.hasExtendedAttrs()&&T.extended.urlId){if(P===-1){P=U,$=T.extended.urlId;continue}N=T.extended.urlId!==$}else P!==-1&&(N=!0);if(N||P!==-1&&U===j-1){const V=(I=this._oscLinkService.getLinkData($))==null?void 0:I.uri;if(V){const q={start:{x:P+1,y:_},end:{x:U+(N||U!==j-1?0:1),y:_}};let F=!1;if(!(k!=null&&k.allowNonHttpProtocols))try{const z=new URL(V);["http:","https:"].includes(z.protocol)||(F=!0)}catch{F=!0}F||S.push({text:V,range:q,activate:(z,G)=>k?k.activate(z,G,q):C(0,G),hover:(z,G)=>{var Y;return(Y=k==null?void 0:k.hover)==null?void 0:Y.call(k,z,G,q)},leave:(z,G)=>{var Y;return(Y=k==null?void 0:k.leave)==null?void 0:Y.call(k,z,G,q)}})}N=!1,T.hasExtendedAttrs()&&T.extended.urlId?(P=U,$=T.extended.urlId):(P=-1,$=-1)}}b(S)}};function C(_,b){if(confirm(`Do you want to navigate to ${b}?
|
|
2898
2898
|
|
|
@@ -3504,7 +3504,7 @@ Invoke the \`security-review\` skill on the currently staged diff. Walk OWASP To
|
|
|
3504
3504
|
`,Yxe="---\nid: security/secret-credential-scan\ntitle: Secret + credential scan with remediation plan\ncategory: Security\nsendMode: auto-fire\ndescription: Greps the tree for hardcoded secrets, checks git history, and orders rotate → redact → gitignore.\n---\nGrep the working tree for hardcoded secrets — API keys, OAuth tokens, JWTs, private keys, database URLs with embedded passwords, and webhook signing secrets. Use both pattern matching (e.g., `sk-`, `xoxb-`, `AKIA`, `-----BEGIN`, `Bearer `) and entropy heuristics on string literals over 20 chars. For each finding report file:line, the secret type, whether it is in tracked git history (`git log -S`), and a remediation order: rotate first, then redact, then add to `.gitignore`/secret manager. Do not print the secret value in clear — show a masked prefix only.\n",Jxe=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/,Qxe=["id","title","category","sendMode","description"];function g8(e){const r=e.match(Jxe);if(!r)return console.error("[promptFrontmatter] no frontmatter block found"),null;const n=r[1],i=(r[2]??"").trim(),s={};for(const l of n.split(/\r?\n/)){const o=l.indexOf(":");if(o<0||l.startsWith(" ")||l.startsWith(" "))continue;const u=l.slice(0,o).trim(),f=l.slice(o+1).trim();u&&(s[u]=f)}for(const l of Qxe)if(!s[l])return console.error(`[promptFrontmatter] missing required key "${l}" in: ${e.slice(0,120).replace(/\n/g,"\\n")}`),null;const a=s.sendMode==="auto-fire"?"auto-fire":"paste";return{id:s.id,title:s.title,category:s.category,sendMode:a,description:s.description,body:i}}const Zxe=Object.assign({"../../seed/prompts/code-review/ac-coverage-check.md":sxe,"../../seed/prompts/code-review/correctness-only.md":axe,"../../seed/prompts/code-review/full-spectrum-high.md":oxe,"../../seed/prompts/code-review/hallucination-check.md":lxe,"../../seed/prompts/code-review/public-api-compat.md":cxe,"../../seed/prompts/code-review/readability-naming.md":uxe,"../../seed/prompts/debugging/bug-as-failing-test.md":dxe,"../../seed/prompts/debugging/git-bisect-regression.md":fxe,"../../seed/prompts/debugging/instrument-intermittent-bug.md":hxe,"../../seed/prompts/debugging/localize-pipeline-failure.md":pxe,"../../seed/prompts/debugging/reproduce-then-diagnose.md":mxe,"../../seed/prompts/documentation/adr-from-change.md":gxe,"../../seed/prompts/documentation/module-readme.md":vxe,"../../seed/prompts/documentation/onboarding-plan.md":yxe,"../../seed/prompts/documentation/refresh-claude-md.md":bxe,"../../seed/prompts/documentation/tsdoc-public-exports.md":xxe,"../../seed/prompts/git-pr/conventional-commit.md":wxe,"../../seed/prompts/git-pr/draft-pr-title-body.md":_xe,"../../seed/prompts/git-pr/pre-commit-safety-sweep.md":Sxe,"../../seed/prompts/git-pr/release-notes-block.md":kxe,"../../seed/prompts/git-pr/split-large-pr.md":Cxe,"../../seed/prompts/performance/bundle-startup-audit.md":jxe,"../../seed/prompts/performance/complexity-audit.md":Exe,"../../seed/prompts/performance/cpu-profile-hot-path.md":Txe,"../../seed/prompts/performance/db-query-plan-review.md":Axe,"../../seed/prompts/performance/memory-leak-hunt.md":$xe,"../../seed/prompts/qa/api-contract-tests.md":Nxe,"../../seed/prompts/qa/e2e-critical-path.md":Oxe,"../../seed/prompts/qa/failing-test-for-bug.md":Pxe,"../../seed/prompts/qa/find-missing-test-coverage.md":Rxe,"../../seed/prompts/qa/stabilize-flaky-test.md":Mxe,"../../seed/prompts/qa/tdd-red-first.md":Ixe,"../../seed/prompts/qa/visual-regression-review.md":Dxe,"../../seed/prompts/qa/wcag-axe-scan.md":Lxe,"../../seed/prompts/refactoring/dead-code-sweep.md":Bxe,"../../seed/prompts/refactoring/extract-duplicated-pattern.md":zxe,"../../seed/prompts/refactoring/modernize-legacy-file.md":Fxe,"../../seed/prompts/refactoring/reduce-cyclomatic-complexity.md":Uxe,"../../seed/prompts/refactoring/tighten-module-boundaries.md":qxe,"../../seed/prompts/security/authz-audit.md":Wxe,"../../seed/prompts/security/crypto-correctness.md":Hxe,"../../seed/prompts/security/cwe-top-25-hunt.md":Vxe,"../../seed/prompts/security/dependency-audit.md":Gxe,"../../seed/prompts/security/ipc-boundary-hardening.md":Kxe,"../../seed/prompts/security/owasp-top-10-staged-diff.md":Xxe,"../../seed/prompts/security/secret-credential-scan.md":Yxe});function e0e(){const e=[];for(const[,r]of Object.entries(Zxe)){const n=g8(r);n&&e.push(n)}return e}const uc=e0e();let t0=null;async function v8(){return t0||(t0=await window.api.app.homeDir(),t0)}function y8(e,r){return`${e}/.claude/session-manager/prompts/${r}.md`}function t0e(e,r){return["---",`id: ${e.id}`,`title: ${e.title}`,`category: ${e.category}`,`sendMode: ${e.sendMode}`,`description: ${e.description}`,"---",r].join(`
|
|
3505
3505
|
`)}async function GC(e){const r=uc.find(n=>n.id===e);if(!r)throw new Error(`[promptsStore] unknown prompt id: ${e}`);try{const n=await v8(),i=y8(n,e),s=await window.api.config.readText(i);if(s.exists&&s.text){const a=g8(s.text);if(a)return a}}catch{}return r}async function b8(e,r){const n=uc.find(a=>a.id===e);if(!n)throw new Error(`[promptsStore] unknown prompt id: ${e}`);const i=await v8(),s=y8(i,e);await window.api.config.writeText(s,t0e(n,r))}async function r0e(e){const r=uc.find(n=>n.id===e);if(!r)throw new Error(`[promptsStore] unknown prompt id: ${e}`);await b8(e,r.body)}function n0e({prompt:e,open:r,activeTabId:n,onClose:i}){const[s,a]=D.useState(e.body),[l,o]=D.useState(e.sendMode),[u,f]=D.useState(e.id);e.id!==u&&(f(e.id),a(e.body),o(e.sendMode));function m(){if(!n)return;const h=l==="auto-fire"?s+`
|
|
3506
3506
|
`:s;window.api.pty.write({tabId:n,data:h}),i(),ft.info(`Sent to terminal (${l})`)}return c.jsxs(to,{open:r,onClose:i,title:`Tweak: ${e.title}`,size:"lg",children:[c.jsx("textarea",{value:s,onChange:h=>a(h.target.value),rows:12,className:"w-full bg-bg border border-line rounded px-3 py-2 text-xs font-mono text-fg resize-y focus:outline-none focus:border-accent/60","aria-label":"Prompt body"}),c.jsxs("div",{className:"mt-3 flex items-center gap-4 text-xs text-fg-dim",children:[c.jsx("span",{className:"font-medium text-fg",children:"Send mode:"}),["paste","auto-fire"].map(h=>c.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[c.jsx("input",{type:"radio",name:"sendMode",value:h,checked:l===h,onChange:()=>o(h),className:"accent-accent"}),c.jsx("span",{className:l===h?"text-fg":"",children:h})]},h)),l==="paste"&&c.jsx("span",{className:"text-fg-faint italic",children:"— you hit Enter to submit"}),l==="auto-fire"&&c.jsx("span",{className:"text-fg-faint italic",children:"— submits immediately"})]}),c.jsxs("div",{className:"mt-4 flex items-center justify-end gap-3",children:[c.jsx("button",{onClick:i,className:"text-xs text-fg-dim hover:text-fg transition-colors",children:"Cancel"}),c.jsx("button",{onClick:m,disabled:!n,title:n?void 0:"Open a terminal session first",className:"px-4 py-1.5 rounded bg-accent text-white text-xs font-medium hover:bg-accent/80 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:"Send to terminal"})]})]})}const n5=["Security","QA","Performance","Code Review","Debugging","Refactoring","Documentation","Git / PR"],i0e={Security:"bg-red-500/10 text-red-400 border-red-500/20",QA:"bg-green-500/10 text-green-400 border-green-500/20",Performance:"bg-orange-500/10 text-orange-400 border-orange-500/20","Code Review":"bg-blue-500/10 text-blue-400 border-blue-500/20",Debugging:"bg-yellow-500/10 text-yellow-400 border-yellow-500/20",Refactoring:"bg-purple-500/10 text-purple-400 border-purple-500/20",Documentation:"bg-cyan-500/10 text-cyan-400 border-cyan-500/20","Git / PR":"bg-pink-500/10 text-pink-400 border-pink-500/20"},s0e={paste:"bg-fg-faint/10 text-fg-faint border-fg-faint/20","auto-fire":"bg-accent/10 text-accent border-accent/20"};function a0e(){const[e,r]=D.useState(""),[n,i]=D.useState(()=>{var q;return((q=uc[0])==null?void 0:q.id)??null}),[s,a]=D.useState(!1),[l,o]=D.useState(!1),[u,f]=D.useState(null),[m,h]=D.useState(!1),[y,x]=D.useState(""),[C,_]=D.useState(!1),[b,w]=D.useState(!1),[S,k]=D.useState(null),T=Jt(q=>q.activeTabId);D.useEffect(()=>{if(!n){f(null);return}let q=!1;return h(!0),GC(n).then(F=>{q||(f(F),h(!1))}).catch(()=>{if(!q){const F=uc.find(z=>z.id===n)??null;f(F),h(!1)}}),()=>{q=!0}},[n]),D.useEffect(()=>{l&&u&&(x(u.body),_(!1),k(null))},[l,u]);const j=D.useMemo(()=>{var q;return((q=uc.find(F=>F.id===n))==null?void 0:q.body)??null},[n]),$=u!==null&&j!==null&&u.body!==j,P=D.useMemo(()=>{const q=e.toLowerCase();return n5.map(F=>({category:F,items:uc.filter(z=>z.category===F&&(!q||z.title.toLowerCase().includes(q)||z.description.toLowerCase().includes(q)))})).filter(F=>F.items.length>0)},[e]),N=D.useCallback(q=>{q!==n&&(i(q),o(!1),_(!1),k(null))},[n]);async function I(){if(n){w(!0),k(null);try{await b8(n,y);const q=await GC(n);f(q),_(!1),o(!1)}catch(q){k(q instanceof Error?q.message:"save failed")}finally{w(!1)}}}async function U(){if(n){w(!0),k(null);try{await r0e(n);const q=await GC(n);f(q),o(!1),_(!1)}catch(q){k(q instanceof Error?q.message:"reset failed")}finally{w(!1)}}}const V=n?uc.find(q=>q.id===n)??null:null;return c.jsxs(Xr,{toolbar:c.jsxs("span",{className:"text-fg-faint",children:[uc.length," prompts across ",n5.length," categories"]}),footer:l&&n?c.jsx(Nu,{dirty:C,busy:b,parseError:S,lastSavedAt:null,onSave:I,onRevert:()=>{x((u==null?void 0:u.body)??(V==null?void 0:V.body)??""),_(!1),k(null)}}):null,children:[c.jsx(ff,{sidebarWidth:"17rem",sidebar:c.jsxs("div",{className:"py-1",children:[c.jsx("div",{className:"px-2 pb-2 pt-1",children:c.jsx("input",{value:e,onChange:q=>r(q.target.value),placeholder:"filter…",className:"w-full bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"})}),P.length===0?c.jsx("div",{className:"px-3 py-2 text-xs text-fg-faint italic",children:"no matches"}):P.map(({category:q,items:F})=>c.jsxs("div",{className:"mb-2",children:[c.jsx("div",{className:"px-3 py-1 text-[10.5px] uppercase tracking-wider text-fg-faint font-semibold",children:q}),F.map(z=>c.jsx("button",{onClick:()=>N(z.id),title:z.description,className:`w-full px-3 py-1.5 text-xs text-left truncate transition-colors ${n===z.id?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi/50"}`,children:z.title},z.id))]},q))]}),detail:m||!u||!V?c.jsx(Bt,{title:m?"loading…":"select a prompt"}):l?c.jsx(l0e,{draft:y,onChange:q=>{x(q),_(!0)},onCancel:()=>{o(!1),_(!1)}}):c.jsx(o0e,{effective:u,seed:V,isCustomized:$,activeTabId:T,onUsePrompt:()=>a(!0),onEdit:()=>o(!0),onReset:U})}),s&&u&&c.jsx(n0e,{prompt:u,open:s,activeTabId:T,onClose:()=>a(!1)},u.id)]})}function o0e({effective:e,isCustomized:r,activeTabId:n,onUsePrompt:i,onEdit:s,onReset:a}){const l=i0e[e.category]??"bg-fg-faint/10 text-fg-faint border-fg-faint/20",o=s0e[e.sendMode];return c.jsxs("div",{className:"p-4 flex flex-col gap-3",children:[c.jsxs("div",{className:"flex items-start gap-2 flex-wrap",children:[c.jsx("h2",{className:"text-sm font-semibold text-fg flex-1 min-w-0",children:e.title}),c.jsx("span",{className:`shrink-0 text-[10.5px] px-1.5 py-0.5 rounded border font-mono ${l}`,children:e.category}),c.jsx("span",{className:`shrink-0 text-[10.5px] px-1.5 py-0.5 rounded border font-mono ${o}`,children:e.sendMode})]}),c.jsx("p",{className:"text-xs text-fg-dim",children:e.description}),c.jsx("pre",{className:"whitespace-pre-wrap font-mono text-[12.5px] bg-bg-elev border border-line rounded p-3 text-fg overflow-x-auto",children:e.body}),c.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[c.jsxs("button",{onClick:i,className:"px-3 py-1.5 rounded bg-accent text-white text-xs font-medium hover:bg-accent/80 transition-colors",children:["Use prompt",!n&&c.jsx("span",{className:"ml-1 opacity-60 font-normal",children:"(no session)"})]}),c.jsx("button",{onClick:s,className:"px-3 py-1.5 rounded bg-bg-hi border border-line text-fg text-xs hover:bg-bg-hi/70 transition-colors",children:"Edit root template"}),r&&c.jsx("button",{onClick:a,className:"ml-auto px-3 py-1.5 rounded border border-line text-xs text-fg-dim hover:text-fg hover:border-accent/40 transition-colors",children:"Reset to default"})]})]})}function l0e({draft:e,onChange:r,onCancel:n}){return c.jsxs("div",{className:"p-4 flex flex-col gap-3 h-full",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-xs font-medium text-fg",children:"Edit root template"}),c.jsx("button",{onClick:n,className:"text-xs text-fg-dim hover:text-fg transition-colors",children:"Cancel"})]}),c.jsx("textarea",{value:e,onChange:i=>r(i.target.value),className:"flex-1 min-h-[16rem] w-full bg-bg border border-line rounded px-3 py-2 text-xs font-mono text-fg resize-y focus:outline-none focus:border-accent/60","aria-label":"Edit prompt body"}),c.jsxs("p",{className:"text-[11px] text-fg-faint",children:["Saves to ",c.jsx("code",{children:"~/.claude/session-manager/prompts/…"})," — overrides the seed on future opens."]})]})}function c0e(){const e=Za(),r=Uy(e);if(!e)return c.jsx(Xr,{children:c.jsx(Bt,{title:"no active session",hint:"open a terminal tab and run claude to see tasks"})});const n=(r==null?void 0:r.todos)??[],i={completed:n.filter(s=>s.status==="completed").length,in_progress:n.filter(s=>s.status==="in_progress").length,pending:n.filter(s=>s.status==="pending").length};return c.jsx(Xr,{toolbar:c.jsxs(c.Fragment,{children:[c.jsxs("span",{className:"text-fg-faint",children:["session ",e.claudeSessionId.slice(0,8)]}),c.jsx("div",{className:"flex-1"}),c.jsxs("span",{className:"text-fg-faint",children:[c.jsx("span",{className:"text-green-400",children:i.completed})," done ·"," ",c.jsx("span",{className:"text-accent",children:i.in_progress})," active ·"," ",c.jsx("span",{className:"text-fg-dim",children:i.pending})," pending"]})]}),children:n.length===0?c.jsx(Bt,{title:"no todos yet",hint:"todos appear when claude calls TodoWrite"}):c.jsx("ul",{className:"p-4 space-y-1 max-w-3xl",children:n.map((s,a)=>c.jsxs("li",{className:`flex items-start gap-3 py-1.5 px-2 rounded text-xs ${s.status==="in_progress"?"bg-bg-elev":""}`,children:[c.jsx(u0e,{status:s.status}),c.jsx("span",{className:`flex-1 ${s.status==="completed"?"text-fg-faint line-through":s.status==="in_progress"?"text-fg":"text-fg-dim"}`,children:s.status==="in_progress"&&s.activeForm?s.activeForm:s.content})]},a))})})}function u0e({status:e}){return e==="completed"?c.jsx("span",{className:"text-green-400 w-4 shrink-0",children:"✓"}):e==="in_progress"?c.jsx("span",{className:"text-accent w-4 shrink-0",children:c.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-accent animate-pulse"})}):c.jsx("span",{className:"text-fg-faint w-4 shrink-0",children:"○"})}const x8="~/.claude/session-manager/projects-prefs.json",d0e={project:"asc",sessions:"desc",last:"desc",size:"desc"};function pu(e){const r=e(),n={pinned:r.pinned,sort:r.sort,recentFilter:r.recentFilter,hasRemote:r.hasRemote,hasClaudemd:r.hasClaudemd,pinnedOnly:r.pinnedOnly,search:r.search,editor:r.editor};window.api.config.writeJson(x8,n).catch(()=>{})}const i5=Gn((e,r)=>({pinned:{},sort:{col:"last",dir:"desc"},recentFilter:"all",hasRemote:null,hasClaudemd:null,pinnedOnly:!1,search:"",editor:"auto",hydrated:!1,hydrate:async()=>{try{const n=await window.api.config.readJson(x8);if(n.exists&&n.data&&typeof n.data=="object"){const i=n.data;e({pinned:i.pinned??{},sort:i.sort??{col:"last",dir:"desc"},recentFilter:i.recentFilter??"all",hasRemote:i.hasRemote??null,hasClaudemd:i.hasClaudemd??null,pinnedOnly:i.pinnedOnly??!1,search:i.search??"",editor:i.editor??"auto",hydrated:!0});return}}catch{}e({hydrated:!0})},togglePin:n=>{const i={...r().pinned,[n]:!r().pinned[n]};e({pinned:i}),pu(r)},setSort:n=>{const i=r(),s=i.sort.col===n?i.sort.dir==="asc"?"desc":"asc":d0e[n];e({sort:{col:n,dir:s}}),pu(r)},setRecentFilter:n=>{e({recentFilter:n}),pu(r)},setHasRemote:n=>{e({hasRemote:n}),pu(r)},setHasClaudemd:n=>{e({hasClaudemd:n}),pu(r)},setPinnedOnly:n=>{e({pinnedOnly:n}),pu(r)},setSearch:n=>{e({search:n}),pu(r)},setEditor:n=>{e({editor:n}),pu(r)}}));async function f0e(e){const r={};try{const n=await window.api.config.readJson(`${e}/package.json`);if(n.exists&&n.data){const i=n.data.name;typeof i=="string"&&(r.name=i)}}catch{}try{const n=await window.api.config.readText(`${e}/.git/config`);if(n.exists&&n.text){const i=n.text.match(/\[remote "origin"\][^\[]*url\s*=\s*([^\n]+)/);if(i){let s=i[1].trim();s=s.replace(/^git@([^:]+):/,"$1/").replace(/\.git$/,"").replace(/^https?:\/\//,""),r.gitRemote=s}}}catch{}try{const n=await window.api.config.readText(`${e}/.git/HEAD`);if(n.exists&&n.text){const i=n.text.match(/ref: refs\/heads\/(.+)/);i&&(r.lastBranch=i[1].trim())}}catch{}try{const n=await window.api.config.readText(`${e}/CLAUDE.md`);n.exists&&n.text&&(r.claudemdPreview=n.text.slice(0,200))}catch{}if(!r.name){const n=e.split("/");r.name=n[n.length-1]||e}return r}function h0e({cwd:e,projectName:r,onClose:n}){const[i,s]=D.useState(null),[a,l]=D.useState(!0),o=D.useRef(null);D.useEffect(()=>{l(!0),s(null),window.api.config.readText(`${e}/CLAUDE.md`).then(f=>{s(f.exists&&f.text?f.text:null),l(!1)}).catch(()=>{s(null),l(!1)})},[e]),D.useEffect(()=>{const f=m=>{m.key==="Escape"&&(m.stopPropagation(),n())};return document.addEventListener("keydown",f,{capture:!0}),()=>document.removeEventListener("keydown",f,{capture:!0})},[n]);const u=f=>{f.target===o.current&&n()};return c.jsx("div",{ref:o,className:"absolute inset-0 z-20",onClick:u,children:c.jsxs("div",{className:"absolute right-0 top-0 bottom-0 w-2/5 bg-bg-elev border-l border-line shadow-2xl z-30 flex flex-col",onClick:f=>f.stopPropagation(),children:[c.jsxs("header",{className:"shrink-0 flex items-center gap-2 px-3 py-2 border-b border-line bg-bg-elev",children:[c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:"text-fg text-xs font-medium truncate",children:r}),c.jsxs("div",{className:"text-fg-faint text-[10px] font-mono truncate",children:[e,"/CLAUDE.md"]})]}),c.jsx("button",{onClick:n,className:"shrink-0 text-fg-faint hover:text-fg px-1.5 py-0.5 rounded hover:bg-bg-hi text-xs",title:"Close (Escape)",children:"✕"})]}),c.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:a?c.jsx(Bt,{title:"loading…"}):i==null?c.jsx(Bt,{title:"No CLAUDE.md found"}):c.jsx(jc,{value:i,onChange:()=>{},path:`${e}/CLAUDE.md`,readOnly:!0})})]})})}function KC(e){return e.replace(/-/g,"/")}async function XC(e){const n=(await window.api.config.listDir(e,{filesOnly:!0})).entries.filter(i=>i.name.endsWith(".jsonl")).sort((i,s)=>i.size-s.size);for(const i of n){const s=await window.api.config.readText(i.path);if(!(!s.exists||!s.text)){for(const a of s.text.split(`
|
|
3507
|
-
`))if(a.includes('"cwd"'))try{const l=JSON.parse(a);if(typeof l.cwd=="string"&&l.cwd.length>0)return l.cwd}catch{}}}return null}function p0e(e){if(!e)return"—";const n=(Date.now()-e)/864e5;return n<1?"today":n<2?"yesterday":n<7?`${Math.floor(n)}d ago`:n<30?`${Math.floor(n/7)}w ago`:new Date(e).toLocaleDateString()}function YC(){return c.jsx("span",{className:"inline-block h-3 w-12 rounded bg-bg-hi animate-pulse","aria-hidden":!0})}function mu({label:e,active:r,onClick:n,tip:i}){return c.jsx(gl,{content:i,align:"bottom-center",children:c.jsx("button",{onClick:n,title:i,className:`px-2 py-0.5 rounded text-[10px] border transition-colors ${r?"border-blue-500 text-blue-400 bg-blue-500/10":"border-line text-fg-faint hover:text-fg hover:border-fg-faint"}`,children:e})})}function lp({tip:e,onClick:r,disabled:n,danger:i,children:s}){return c.jsx(gl,{content:e,children:c.jsx("button",{onClick:a=>{a.stopPropagation(),n||r()},title:e,disabled:n,className:`px-1.5 py-0.5 rounded text-sm leading-none transition-colors ${n?"text-fg-faint/30 cursor-not-allowed":i?"text-red-400/60 hover:text-red-400 hover:bg-red-950/30":"text-fg-faint hover:text-fg hover:bg-bg-hi"}`,children:s})})}const JC=7*864e5,m0e=30*864e5,g0e=[{value:"auto",label:"auto"},{value:"code",label:"VS Code"},{value:"cursor",label:"Cursor"},{value:"subl",label:"Sublime"},{value:"nano",label:"nano"}];function v0e(){var si,In;const e=Sn(),[r,n]=D.useState([]),[i,s]=D.useState(!0),[a,l]=D.useState({}),[o,u]=D.useState(""),[f,m]=D.useState(""),[h,y]=D.useState(new Set),[x,C]=D.useState(null),[_,b]=D.useState(null),[w,S]=D.useState(!1),[k,T]=D.useState(null),[j,$]=D.useState(null),P=D.useRef(null),N=D.useRef(null),I=Jt(Ge=>Ge.addTab),{hydrated:U,hydrate:V,pinned:q,togglePin:F,sort:z,setSort:G,recentFilter:Y,setRecentFilter:oe,hasRemote:te,setHasRemote:J,hasClaudemd:K,setHasClaudemd:Z,pinnedOnly:re,setPinnedOnly:he,setSearch:we,editor:Ce,setEditor:Me}=i5();D.useEffect(()=>{V()},[]);const be=D.useRef(!1);D.useEffect(()=>{if(U&&!be.current){be.current=!0;const Ge=i5.getState().search;u(Ge),m(Ge)}},[U]),D.useEffect(()=>{if(!be.current)return;const Ge=setTimeout(()=>{m(o),we(o)},200);return()=>clearTimeout(Ge)},[o,we]),D.useEffect(()=>{if(!k)return;const Ge=setTimeout(()=>T(null),3e3);return()=>clearTimeout(Ge)},[k]),D.useEffect(()=>{if(!e)return;let Ge=!1;return(async()=>{s(!0);try{const rt=await window.api.config.listDir(`${e}/.claude/projects`,{dirsOnly:!0});if(Ge)return;const $t=[];for(const ur of rt.entries){if(Ge)return;const Yr=(await window.api.config.listDir(ur.path,{filesOnly:!0})).entries.filter(pn=>pn.name.endsWith(".jsonl")),an=Yr.reduce((pn,es)=>Math.max(pn,es.mtimeMs),0),Di=Yr.reduce((pn,es)=>pn+es.size,0);$t.push({encoded:ur.name,displayPath:KC(ur.name),sessionCount:Yr.length,lastSession:an,path:ur.path,sizeBytes:Di})}$t.sort((ur,Pr)=>Pr.lastSession-ur.lastSession),Ge||(n($t),l({}),y(new Set))}catch(rt){console.error("[Projects] scan failed:",rt)}finally{Ge||s(!1)}})(),()=>{Ge=!0}},[e]),D.useEffect(()=>{if(!r.length)return;let Ge=!1;const rt=r.slice();let $t=0;const ur=()=>{for(;!Ge&&$t<6&&rt.length;){const Pr=rt.shift();$t++,XC(Pr.path).then(async Yr=>{if(Ge)return;const an=Yr?await f0e(Yr):{};Ge||l(Di=>({...Di,[Pr.encoded]:{cwd:Yr??null,...an}}))}).catch(()=>{Ge||l(Yr=>({...Yr,[Pr.encoded]:{cwd:null}}))}).finally(()=>{$t--,Ge||ur()})}};return ur(),()=>{Ge=!0}},[r]);const se=Object.keys(a).length>=r.length,ve=Object.values(a).some(Ge=>Ge.gitRemote),xe=Object.values(a).some(Ge=>Ge.lastBranch),Ve=r.length>0&&(ve||!se),Re=r.length>0&&(xe||!se),We=Date.now(),Le=r.filter(Ge=>{var $t,ur,Pr,Yr;if(Y==="7d"&&We-Ge.lastSession>JC||Y==="30d"&&We-Ge.lastSession>m0e||re&&!q[Ge.encoded])return!1;const rt=a[Ge.encoded];if(rt&&(te===!0&&!rt.gitRemote||te===!1&&rt.gitRemote||K===!0&&!rt.claudemdPreview||K===!1&&rt.claudemdPreview))return!1;if(f){const an=f.toLowerCase();if(!(Ge.displayPath.toLowerCase().includes(an)||((($t=rt==null?void 0:rt.cwd)==null?void 0:$t.toLowerCase().includes(an))??!1)||(((ur=rt==null?void 0:rt.name)==null?void 0:ur.toLowerCase().includes(an))??!1)||(((Pr=rt==null?void 0:rt.gitRemote)==null?void 0:Pr.toLowerCase().includes(an))??!1)||(((Yr=rt==null?void 0:rt.claudemdPreview)==null?void 0:Yr.toLowerCase().includes(an))??!1)))return!1}return!0}),Ze=[...Le].sort((Ge,rt)=>{var Yr,an;const $t=q[Ge.encoded]?1:0,ur=q[rt.encoded]?1:0;if($t!==ur)return ur-$t;let Pr=0;switch(z.col){case"project":{const Di=((Yr=a[Ge.encoded])==null?void 0:Yr.cwd)??Ge.displayPath,pn=((an=a[rt.encoded])==null?void 0:an.cwd)??rt.displayPath;Pr=Di.localeCompare(pn);break}case"sessions":Pr=Ge.sessionCount-rt.sessionCount;break;case"last":Pr=Ge.lastSession-rt.lastSession;break;case"size":Pr=Ge.sizeBytes-rt.sizeBytes;break}return z.dir==="asc"?Pr:-Pr}),ct=Ze.length>0&&Ze.every(Ge=>h.has(Ge.encoded)),ut=Ze.some(Ge=>h.has(Ge.encoded));D.useEffect(()=>{N.current&&(N.current.indeterminate=ut&&!ct)},[ut,ct]);const dr=()=>{y(ct?Ge=>{const rt=new Set(Ge);return Ze.forEach($t=>rt.delete($t.encoded)),rt}:Ge=>{const rt=new Set(Ge);return Ze.forEach($t=>rt.add($t.encoded)),rt})},Xt=async Ge=>{var rt;return((rt=a[Ge.encoded])==null?void 0:rt.cwd)??await XC(Ge.path)},Qt=Ge=>T(Ge),cr=async Ge=>{var ur;let rt=((ur=a[Ge.encoded])==null?void 0:ur.cwd)??null;if(rt||(rt=await XC(Ge.path)),!rt&&(rt=await window.api.app.pickDirectory(),!rt))return;const $t=crypto.randomUUID();I({id:$t,cwd:rt,startupCommand:`claude --dangerously-skip-permissions --session-id ${Io($t)}`,presetId:"projects-tab"})},Or=async Ge=>{const rt=await Xt(Ge);if(!rt){Qt("Project directory not yet resolved");return}const $t=await window.api.app.openInEditor(rt,Ce||null);$t.ok||Qt($t.error??"No editor found")},wr=async Ge=>{const rt=await Xt(Ge);if(!rt){Qt("Project directory not yet resolved");return}const $t=await window.api.app.openInFinder(rt);$t.ok||Qt($t.error??"Failed to open file manager")},sn=async Ge=>{const rt=await Xt(Ge);if(!rt){Qt("Project directory not yet resolved");return}const $t=await window.api.app.openInTerminal(rt);$t.ok||Qt($t.error??"No terminal emulator found")},Wr=Ge=>{C(Ge.encoded)},ii=async Ge=>{b(null),S(!0);const rt=[];for(const $t of Ge)try{const ur=await window.api.app.archiveProject($t);ur.ok?rt.push($t):Qt(ur.error??`Failed to archive ${$t}`)}catch(ur){Qt(ur instanceof Error?ur.message:"Archive failed")}rt.length&&(n($t=>$t.filter(ur=>!rt.includes(ur.encoded))),y($t=>{const ur=new Set($t);return rt.forEach(Pr=>ur.delete(Pr)),ur}),x&&rt.includes(x)&&C(null)),S(!1)},Kn=r.length,mr=r.filter(Ge=>We-Ge.lastSession<JC).length,vt=r.reduce((Ge,rt)=>Ge+rt.sessionCount,0),jt=r.reduce((Ge,rt)=>Ge+rt.sizeBytes,0),It=[...r].filter(Ge=>We-Ge.lastSession<JC).sort((Ge,rt)=>rt.sessionCount-Ge.sessionCount).slice(0,3),Pt=Ge=>{var $t;const rt=($t=P.current)==null?void 0:$t.querySelector(`[data-row-key="${Ge}"]`);rt==null||rt.scrollIntoView({behavior:"smooth",block:"center"}),$(Ge),setTimeout(()=>$(null),2e3)},Ir=(Ge,rt)=>c.jsx(gl,{content:`Sort by ${rt}`,align:"bottom-center",children:c.jsxs("button",{onClick:()=>G(Ge),title:`Sort by ${rt}`,className:"flex items-center gap-1 hover:text-fg w-full uppercase tracking-wider",children:[c.jsx("span",{children:rt}),z.col===Ge&&c.jsx("span",{className:"text-[10px] leading-none",children:z.dir==="asc"?"▲":"▼"})]})}),yi=x?((si=a[x])==null?void 0:si.cwd)??null:null,Sa=x?((In=a[x])==null?void 0:In.cwd)??`/${KC(x)}`:"",Ii=[];Re&&Ii.push({key:"branch",header:"branch",width:"8rem",render:Ge=>{const rt=a[Ge.encoded];return rt?rt.lastBranch?c.jsx("span",{className:"font-mono text-fg-faint truncate block",children:rt.lastBranch}):c.jsx("span",{className:"text-fg-faint",children:"—"}):c.jsx(YC,{})}}),Ve&&Ii.push({key:"remote",header:"remote",render:Ge=>{const rt=a[Ge.encoded];return rt?rt.gitRemote?c.jsx("span",{className:"font-mono text-fg-faint truncate block text-[10px]",children:rt.gitRemote}):c.jsx("span",{className:"text-fg-faint",children:"—"}):c.jsx(YC,{})}});const Cr=[{key:"select",header:c.jsx("input",{ref:N,type:"checkbox",checked:ct,onChange:dr,className:"accent-accent cursor-pointer",title:"Select all visible",onClick:Ge=>Ge.stopPropagation()}),width:"2rem",className:"px-1",render:Ge=>c.jsx("input",{type:"checkbox",checked:h.has(Ge.encoded),onChange:()=>{y(rt=>{const $t=new Set(rt);return $t.has(Ge.encoded)?$t.delete(Ge.encoded):$t.add(Ge.encoded),$t})},onClick:rt=>rt.stopPropagation(),className:"accent-accent cursor-pointer"})},{key:"pin",header:"",width:"2rem",className:"px-1",render:Ge=>c.jsx(gl,{content:q[Ge.encoded]?"Unpin":"Pin to top",children:c.jsx("button",{onClick:rt=>{rt.stopPropagation(),F(Ge.encoded)},title:q[Ge.encoded]?"Unpin":"Pin to top",className:`text-sm leading-none transition-colors ${q[Ge.encoded]?"text-yellow-400":"text-fg-faint hover:text-fg-dim"}`,children:q[Ge.encoded]?"★":"☆"})})},{key:"path",header:Ir("project","project"),render:Ge=>{const rt=a[Ge.encoded],$t=(rt==null?void 0:rt.cwd)??`/${Ge.displayPath}`,ur=c.jsx("span",{className:"font-mono text-fg-dim truncate block max-w-[22rem]",children:$t});return rt!=null&&rt.claudemdPreview?c.jsx(gl,{content:c.jsx("span",{className:"font-mono text-[9px] whitespace-pre-wrap",children:rt.claudemdPreview}),align:"bottom-center",children:ur}):ur}},{key:"name",header:"name",width:"7rem",render:Ge=>{const rt=a[Ge.encoded];return rt?c.jsx("span",{className:"text-fg-dim truncate block",children:rt.name??"—"}):c.jsx(YC,{})}},{key:"sessions",header:Ir("sessions","sessions"),width:"6rem",render:Ge=>c.jsx("span",{className:"text-fg-dim",children:Ge.sessionCount})},{key:"size",header:Ir("size","size"),width:"6rem",render:Ge=>c.jsx("span",{className:"text-fg-faint",children:df(Ge.sizeBytes)})},{key:"last",header:Ir("last","last active"),width:"9rem",render:Ge=>c.jsx("span",{className:"text-fg-faint",children:p0e(Ge.lastSession)})},...Ii,{key:"action",header:"",width:"11rem",render:Ge=>{const rt=a[Ge.encoded],$t=!!(rt!=null&&rt.claudemdPreview);return c.jsxs("div",{className:"flex items-center gap-0.5",children:[c.jsx(lp,{tip:"Open in new terminal session",onClick:()=>cr(Ge),children:"▷"}),c.jsx(lp,{tip:"Open in editor",onClick:()=>Or(Ge),children:"✏"}),c.jsx(lp,{tip:"Open in file manager",onClick:()=>wr(Ge),children:"⌂"}),c.jsx(lp,{tip:"Open in terminal",onClick:()=>sn(Ge),children:"⊞"}),c.jsx(lp,{tip:$t?"Preview CLAUDE.md":"No CLAUDE.md",onClick:()=>Wr(Ge),disabled:!$t,children:"Ⓜ"}),c.jsx(lp,{tip:"Archive project",onClick:()=>b([Ge.encoded]),danger:!0,children:"⊗"})]})}}];return c.jsxs("div",{className:"h-full flex flex-col",children:[!i&&r.length>0&&c.jsxs("div",{className:"shrink-0 border-b border-line bg-bg px-3 py-1.5 flex items-center gap-4 text-[10px] text-fg-faint flex-wrap",children:[c.jsxs("span",{children:[c.jsx("span",{className:"text-fg-dim font-medium",children:Kn})," projects"]}),c.jsxs("span",{children:[c.jsx("span",{className:"text-fg-dim font-medium",children:mr})," active 7d"]}),c.jsxs("span",{children:[c.jsx("span",{className:"text-fg-dim font-medium",children:vt})," sessions"]}),c.jsxs("span",{children:[c.jsx("span",{className:"text-fg-dim font-medium",children:df(jt)})," on disk"]}),It.length>0&&c.jsxs("span",{className:"flex items-center gap-1 flex-wrap",children:[c.jsx("span",{className:"text-fg-faint",children:"most active:"}),It.map(Ge=>{var $t,ur,Pr;const rt=((ur=($t=a[Ge.encoded])==null?void 0:$t.cwd)==null?void 0:ur.split("/").pop())??Ge.displayPath.split("/").pop()??Ge.encoded;return c.jsx("button",{onClick:()=>Pt(Ge.encoded),className:"px-1.5 py-0 rounded border border-line hover:border-fg-faint hover:text-fg transition-colors font-mono",title:((Pr=a[Ge.encoded])==null?void 0:Pr.cwd)??Ge.displayPath,children:rt},Ge.encoded)})]})]}),c.jsx("div",{className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 text-xs",children:c.jsxs("div",{className:"flex flex-col gap-1.5 w-full py-0.5",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:"search",placeholder:"search projects…",value:o,onChange:Ge=>u(Ge.target.value),className:"h-6 px-2 bg-bg border border-line rounded text-xs text-fg placeholder:text-fg-faint focus:outline-none focus:border-fg-faint w-48"}),c.jsx("span",{className:"text-fg-faint",children:Le.length===r.length?`${r.length} projects`:`${Le.length} of ${r.length}`}),c.jsx("div",{className:"flex-1"}),c.jsx(gl,{content:"Preferred editor for 'Open in editor' action",children:c.jsx("select",{value:Ce,onChange:Ge=>Me(Ge.target.value),className:"h-6 bg-bg border border-line rounded text-xs text-fg-dim px-1 focus:outline-none focus:border-fg-faint",children:g0e.map(Ge=>c.jsxs("option",{value:Ge.value,children:["Editor: ",Ge.label]},Ge.value))})}),c.jsx("span",{className:"text-fg-faint font-mono truncate",children:"~/.claude/projects/"})]}),c.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[c.jsx(mu,{label:"All",active:Y==="all",onClick:()=>oe("all"),tip:"Show all projects"}),c.jsx(mu,{label:"≤7d",active:Y==="7d",onClick:()=>oe("7d"),tip:"Active in last 7 days"}),c.jsx(mu,{label:"≤30d",active:Y==="30d",onClick:()=>oe("30d"),tip:"Active in last 30 days"}),c.jsx("span",{className:"w-px h-3 bg-line mx-0.5 shrink-0"}),c.jsx(mu,{label:"Has remote",active:te===!0,onClick:()=>J(te===!0?null:!0),tip:"Only projects with a git remote"}),c.jsx(mu,{label:"No remote",active:te===!1,onClick:()=>J(te===!1?null:!1),tip:"Only projects without a git remote"}),c.jsx("span",{className:"w-px h-3 bg-line mx-0.5 shrink-0"}),c.jsx(mu,{label:"Has CLAUDE.md",active:K===!0,onClick:()=>Z(K===!0?null:!0),tip:"Only projects with a CLAUDE.md"}),c.jsx(mu,{label:"No CLAUDE.md",active:K===!1,onClick:()=>Z(K===!1?null:!1),tip:"Only projects without a CLAUDE.md"}),c.jsx("span",{className:"w-px h-3 bg-line mx-0.5 shrink-0"}),c.jsx(mu,{label:"Pinned",active:re,onClick:()=>he(!re),tip:"Only pinned projects"})]})]})}),c.jsxs("div",{className:"flex-1 min-h-0 flex relative",children:[c.jsx("div",{className:"flex-1 min-w-0 overflow-auto",ref:P,children:i?c.jsx(Bt,{title:"scanning projects…"}):c.jsx(kT,{columns:Cr,rows:Ze,getKey:Ge=>Ge.encoded,activeKey:j,empty:"no projects with claude session history"})}),x&&yi&&c.jsx(h0e,{cwd:yi,projectName:Sa,onClose:()=>C(null)})]}),h.size>0&&c.jsxs("div",{className:"shrink-0 border-t border-line bg-bg-elev px-3 py-2 flex items-center gap-2 text-xs",children:[c.jsxs("span",{className:"text-fg-faint",children:[h.size," selected"]}),c.jsx("div",{className:"flex-1"}),w&&c.jsx("span",{className:"text-fg-faint animate-pulse",children:"archiving…"}),c.jsxs("button",{onClick:()=>b(Array.from(h)),disabled:w,className:"px-2 py-1 border border-red-900/50 text-red-400/80 rounded hover:bg-red-950/30 hover:text-red-400 disabled:opacity-40 transition-colors",children:["Archive ",h.size]}),c.jsx("button",{onClick:async()=>{const Ge=r.filter(rt=>h.has(rt.encoded));for(const rt of Ge)await Or(rt)},disabled:w,className:"px-2 py-1 border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-40 transition-colors",children:"Open all in editor"}),c.jsx("button",{onClick:()=>y(new Set),className:"px-2 py-1 border border-line rounded text-fg-faint hover:text-fg hover:bg-bg-hi transition-colors",children:"Cancel"})]}),c.jsxs(to,{open:!!_,onClose:()=>b(null),title:"Archive projects?",children:[c.jsxs("p",{className:"text-sm text-fg-dim mb-1",children:["Move ",(_==null?void 0:_.length)??0," project",((_==null?void 0:_.length)??0)!==1?"s":""," to"]}),c.jsx("p",{className:"text-xs text-fg-faint font-mono mb-4",children:"~/.claude/projects-archive/"}),_&&_.length<=5&&c.jsx("ul",{className:"mb-4 space-y-0.5 text-[10px] font-mono text-fg-faint",children:_.map(Ge=>{var rt;return c.jsx("li",{className:"truncate",children:((rt=a[Ge])==null?void 0:rt.cwd)??`/${KC(Ge)}`},Ge)})}),c.jsxs("div",{className:"flex gap-2 justify-end",children:[c.jsx("button",{onClick:()=>b(null),className:"px-3 py-1.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"Cancel"}),c.jsx("button",{onClick:()=>_&&ii(_),className:"px-3 py-1.5 text-xs border border-red-900/50 rounded text-red-400 hover:bg-red-950/30",children:"Archive"})]})]}),k&&c.jsx("div",{role:"alert",className:"pointer-events-none fixed bottom-4 right-4 z-50 bg-red-950 border border-red-900/60 text-red-300 text-xs px-3 py-1.5 rounded shadow-lg max-w-xs",children:k})]})}const uT="~/.config/session-manager/doc-editor.json",y0e=20;let QC=null;function Cv(e){QC&&clearTimeout(QC),QC=setTimeout(async()=>{const r=e();try{const n=await window.api.config.readJson(uT).catch(()=>null),i=(n==null?void 0:n.data)??{};await window.api.config.writeJson(uT,{...i,recents:r.recents,openPaths:Object.keys(r.docs),viewModes:r.viewModes})}catch(n){console.warn("[docEditor] persist failed:",n)}},500)}function s5(e,r){return[r,...e.filter(n=>n!==r)].slice(0,y0e)}const ma=Gn((e,r)=>({docs:{},activePath:null,recents:[],viewModes:{},hydrated:!1,open:async n=>{if(r().docs[n]){e({activePath:n});return}const s=await window.api.docEditor.readFile(n);if(!s.ok){ft.warn(`Could not open ${n.split("/").pop()}: ${s.error??"unknown error"}`),e(l=>({recents:l.recents.filter(o=>o!==n)})),Cv(r);return}const a={path:n,diskText:s.text??"",bufferText:s.text??"",mtimeMs:s.mtimeMs??0,loadedAt:Date.now()};e(l=>({docs:{...l.docs,[n]:a},activePath:n,recents:s5(l.recents,n)})),Cv(r)},close:n=>{var o;const i=r(),s=i.docs[n];if(!s)return;if(s.bufferText!==s.diskText){const u=n.split("/").pop()??n;if(!window.confirm(`"${u}" has unsaved changes. Close without saving?`))return}const a={...i.docs};delete a[n];let l=i.activePath;i.activePath===n&&(l=((o=Object.values(a).sort((f,m)=>m.loadedAt-f.loadedAt)[0])==null?void 0:o.path)??null),e({docs:a,activePath:l}),Cv(r)},setActive:n=>{e({activePath:n})},setViewMode:(n,i)=>{e(s=>({viewModes:{...s.viewModes,[n]:i}})),Cv(r)},edit:(n,i)=>{const s=r().docs[n];s&&e(a=>({docs:{...a.docs,[n]:{...s,bufferText:i}}}))},save:async n=>{const i=r().docs[n];if(!i)return;const s=i.bufferText,a=await window.api.docEditor.writeFile(n,s);if(!a.ok){ft.error(`Save failed for ${n.split("/").pop()}: ${a.error??"unknown"}`);return}e(l=>{const o=l.docs[n];return o?{docs:{...l.docs,[n]:{...o,diskText:s,mtimeMs:a.mtimeMs??o.mtimeMs}},recents:s5(l.recents,n)}:{}}),Cv(r)},saveAll:async()=>{const n=Object.values(r().docs).filter(i=>i.bufferText!==i.diskText).map(i=>i.path);await Promise.all(n.map(i=>r().save(i)))},hydrate:async()=>{if(!r().hydrated){e({hydrated:!0});try{const i=(await window.api.config.readJson(uT)).data??{},s=Array.isArray(i.recents)?i.recents:[],a=Array.isArray(i.openPaths)?i.openPaths:[],l=i.viewModes??{},o={};for(const[u,f]of Object.entries(l))(f==="wysiwyg"||f==="source")&&(o[u]=f);e({recents:s,viewModes:o});for(const u of a)await r().open(u)}catch(n){console.warn("[docEditor] hydrate failed:",n)}}}}));window.__docEditor=ma;const b0e={json:"json",ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",cjs:"javascript",mjs:"javascript",py:"python",sh:"shell",bash:"shell",yaml:"yaml",yml:"yaml",toml:"ini",css:"css",html:"html",xml:"xml",sql:"sql",rs:"rust",go:"go",md:"markdown",markdown:"markdown"},a5={Dockerfile:"dockerfile",Makefile:"makefile"};function x0e(e){const r=e.split("/").pop()??e;if(a5[r])return a5[r];const n=r.lastIndexOf(".");if(n===-1)return null;const i=r.slice(n+1);return b0e[i]??null}const w0e=D.lazy(()=>rm(()=>import("./TiptapBody-PdmsfUCQ.js"),__vite__mapDeps([2,0,1]),import.meta.url).then(e=>({default:e.TiptapBody})));function _0e(e){return e.split("/").pop()??e}function S0e(e){return e.endsWith(".md")||e.endsWith(".markdown")}function k0e({docs:e,activePath:r,onSetActive:n,onClose:i}){const s=Object.keys(e);return c.jsx("div",{className:"h-9 bg-bg-elev border-b border-line flex items-center overflow-x-auto shrink-0 px-2 gap-1","data-testid":"doc-tab-strip",children:s.map(a=>{const l=e[a],o=l.bufferText!==l.diskText,u=_0e(a),f=a===r;return c.jsxs("div",{className:`group px-3 py-1 flex items-center gap-1 rounded-t text-xs shrink-0 cursor-pointer transition-colors ${f?"bg-bg-hi text-fg font-semibold border border-b-0 border-accent border-t-2 -mb-px relative z-10":"bg-bg-elev text-fg-dim border border-line hover:text-fg hover:bg-bg"}`,onClick:()=>n(a),title:a,"data-testid":`doc-tab-${u}`,children:[o&&c.jsx("span",{className:"text-amber-400","aria-label":"unsaved changes","data-testid":"doc-tab-dirty",children:"●"}),c.jsx("span",{children:u}),c.jsx("button",{type:"button",onClick:m=>{m.stopPropagation(),i(a)},className:"text-fg-faint opacity-0 group-hover:opacity-100 hover:text-fg ml-1",title:`Close ${u}`,"aria-label":`Close ${u}`,"data-testid":`doc-x-${u}`,children:"×"})]},a)})})}function C0e({path:e,value:r,onChange:n,language:i}){const s=D.useRef(null),a=D.useRef(e);a.current=e;const l=async o=>{s.current=o;const u=await rm(()=>import("./monaco-editor-BW5C4Iv1.js").then(f=>f.b),__vite__mapDeps([0,1]),import.meta.url);o.addCommand(u.KeyMod.CtrlCmd|u.KeyCode.KeyS,()=>{ma.getState().save(a.current)})};return c.jsx(Xw,{path:`file://${e}`,language:i,value:r,onChange:o=>n(o??""),onMount:l,theme:"vs-dark",options:{minimap:{enabled:!1},fontSize:12,fontFamily:"JetBrains Mono, ui-monospace, Menlo, monospace",lineNumbers:"on",renderLineHighlight:"line",scrollBeyondLastLine:!1,tabSize:2,formatOnPaste:!0,automaticLayout:!0,bracketPairColorization:{enabled:!0},wordWrap:"on"}})}function j0e({path:e,value:r,onChange:n}){const i=x0e(e);if(!i){const s=e.split("/").pop()??e;return c.jsx("textarea",{className:"w-full h-full resize-none bg-bg text-fg font-mono text-sm p-3 focus:outline-none leading-relaxed",value:r,onChange:a=>n(a.target.value),spellCheck:!1,"data-testid":"doc-textarea","aria-label":`Edit ${s}`},e)}return c.jsx(C0e,{path:e,value:r,onChange:n,language:i})}function E0e(){const e=ma(b=>b.docs),r=ma(b=>b.activePath),n=ma(b=>b.viewModes),i=ma(b=>b.open),s=ma(b=>b.close),a=ma(b=>b.setActive),l=ma(b=>b.edit),o=ma(b=>b.save),u=ma(b=>b.saveAll),f=ma(b=>b.setViewMode),m=ma(b=>b.hydrate);D.useEffect(()=>{m()},[m]);const h=r?e[r]??null:null,y=Object.values(e).some(b=>b.bufferText!==b.diskText),x=r?n[r]??"wysiwyg":"wysiwyg",C=r?S0e(r):!1,_=async()=>{const b=r?r.split("/").slice(0,-1).join("/"):void 0,w=await window.api.docEditor.pickFile(b?{lastDir:b}:void 0);w.path&&await i(w.path)};return r===null?c.jsx(Bt,{title:"No document open",hint:c.jsxs("span",{children:["Click ",c.jsx("strong",{children:"Open…"})," or use"," ",c.jsx("kbd",{className:"px-1 py-0.5 border border-line rounded font-mono text-[10px]",children:"Cmd-K"})," ","and type ",c.jsx("code",{children:"doc:open"})]})}):c.jsxs("div",{className:"h-full flex flex-col",onKeyDown:b=>{(b.ctrlKey||b.metaKey)&&b.key.toLowerCase()==="s"&&!b.shiftKey&&(b.preventDefault(),r&&o(r)),(b.ctrlKey||b.metaKey)&&b.key.toLowerCase()==="w"&&!b.shiftKey&&(b.preventDefault(),r&&s(r))},"data-testid":"doc-editor-panel",children:[c.jsx(k0e,{docs:e,activePath:r,onSetActive:a,onClose:s}),c.jsxs("div",{className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 flex items-center gap-2 text-xs",children:[c.jsx("button",{type:"button",onClick:_,className:"px-2 py-1 border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi transition-colors","data-testid":"doc-open-btn",children:"Open…"}),c.jsx("button",{type:"button",onClick:()=>r&&o(r),disabled:!h||h.bufferText===h.diskText,className:"px-2 py-1 border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi transition-colors disabled:opacity-40 disabled:cursor-not-allowed","data-testid":"doc-save-btn",children:"Save"}),c.jsx("button",{type:"button",onClick:()=>u(),disabled:!y,className:"px-2 py-1 border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi transition-colors disabled:opacity-40 disabled:cursor-not-allowed","data-testid":"doc-save-all-btn",children:"Save All"}),C&&r&&c.jsxs("div",{className:"flex items-center border border-line rounded overflow-hidden text-[11px]","data-testid":"view-mode-toggle",children:[c.jsx("button",{type:"button",onClick:()=>f(r,"wysiwyg"),className:`px-2 py-0.5 transition-colors ${x==="wysiwyg"?"bg-accent text-bg font-semibold":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,"data-testid":"view-mode-wysiwyg",children:"WYSIWYG"}),c.jsx("button",{type:"button",onClick:()=>f(r,"source"),className:`px-2 py-0.5 transition-colors ${x==="source"?"bg-accent text-bg font-semibold":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,"data-testid":"view-mode-source",children:"Source"})]}),r&&c.jsx("span",{className:"ml-2 text-fg-faint truncate flex-1 font-mono text-[11px]",title:r,children:r})]}),c.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:C&&x==="wysiwyg"&&r&&h?c.jsx(D.Suspense,{fallback:c.jsx("div",{className:"p-4 text-fg-faint text-sm",children:"Loading editor…"}),children:c.jsx(w0e,{value:h.bufferText,onChange:b=>l(r,b)},r)}):C&&r&&h?c.jsx(jc,{path:r,value:h.bufferText,onChange:b=>l(r,b)},r):r&&h?c.jsx(j0e,{path:r,value:h.bufferText,onChange:b=>l(r,b)}):null})]})}const T0e=5e3;let r0=null,jv=null;async function dT(e){const r=Date.now();return!(e!=null&&e.fresh)&&r0&&r-r0.at<T0e?r0.result:jv||(jv=(async()=>{try{const n=await window.api.schedule.lintQueue();return r0={result:n,at:Date.now()},n}finally{jv=null}})(),jv)}const o5=2e3;function A0e(e){return e.is_error===!0||e.error!=null&&e.error!==""||e.type==="result"&&e.subtype!=="success"&&e.subtype!=null}function $0e(e){return typeof e.error=="string"&&e.error?e.error:typeof e.result=="string"&&e.result?e.result:typeof e.subtype=="string"?e.subtype:JSON.stringify(e).slice(0,200)}function N0e(e){if(typeof e.text=="string")return e.text.slice(0,200);if(typeof e.content=="string")return e.content.slice(0,200);if(Array.isArray(e.content)){for(const n of e.content)if(n&&typeof n=="object"&&"text"in n&&typeof n.text=="string")return n.text.slice(0,200)}const r=e.message;if(r&&typeof r=="object"){const n=r;if(typeof n.content=="string")return n.content.slice(0,200);if(Array.isArray(n.content)){for(const i of n.content)if(i&&typeof i=="object"&&"text"in i&&typeof i.text=="string")return i.text.slice(0,200)}}return typeof e.result=="string"&&e.result?e.result.slice(0,200):typeof e.subtype=="string"?e.subtype:JSON.stringify(e).slice(0,200)}function O0e(e){if(!e||!e.trim())return{events:[],errors:{count:0,firstMessage:null},rawLineCount:0,truncated:!1};const n=e.split(`
|
|
3507
|
+
`))if(a.includes('"cwd"'))try{const l=JSON.parse(a);if(typeof l.cwd=="string"&&l.cwd.length>0)return l.cwd}catch{}}}return null}function p0e(e){if(!e)return"—";const n=(Date.now()-e)/864e5;return n<1?"today":n<2?"yesterday":n<7?`${Math.floor(n)}d ago`:n<30?`${Math.floor(n/7)}w ago`:new Date(e).toLocaleDateString()}function YC(){return c.jsx("span",{className:"inline-block h-3 w-12 rounded bg-bg-hi animate-pulse","aria-hidden":!0})}function mu({label:e,active:r,onClick:n,tip:i}){return c.jsx(gl,{content:i,align:"bottom-center",children:c.jsx("button",{onClick:n,title:i,className:`px-2 py-0.5 rounded text-[10px] border transition-colors ${r?"border-blue-500 text-blue-400 bg-blue-500/10":"border-line text-fg-faint hover:text-fg hover:border-fg-faint"}`,children:e})})}function lp({tip:e,onClick:r,disabled:n,danger:i,children:s}){return c.jsx(gl,{content:e,children:c.jsx("button",{onClick:a=>{a.stopPropagation(),n||r()},title:e,disabled:n,className:`px-1.5 py-0.5 rounded text-sm leading-none transition-colors ${n?"text-fg-faint/30 cursor-not-allowed":i?"text-red-400/60 hover:text-red-400 hover:bg-red-950/30":"text-fg-faint hover:text-fg hover:bg-bg-hi"}`,children:s})})}const JC=7*864e5,m0e=30*864e5,g0e=[{value:"auto",label:"auto"},{value:"code",label:"VS Code"},{value:"cursor",label:"Cursor"},{value:"subl",label:"Sublime"},{value:"nano",label:"nano"}];function v0e(){var si,In;const e=Sn(),[r,n]=D.useState([]),[i,s]=D.useState(!0),[a,l]=D.useState({}),[o,u]=D.useState(""),[f,m]=D.useState(""),[h,y]=D.useState(new Set),[x,C]=D.useState(null),[_,b]=D.useState(null),[w,S]=D.useState(!1),[k,T]=D.useState(null),[j,$]=D.useState(null),P=D.useRef(null),N=D.useRef(null),I=Jt(Ge=>Ge.addTab),{hydrated:U,hydrate:V,pinned:q,togglePin:F,sort:z,setSort:G,recentFilter:Y,setRecentFilter:oe,hasRemote:te,setHasRemote:J,hasClaudemd:K,setHasClaudemd:Z,pinnedOnly:re,setPinnedOnly:he,setSearch:we,editor:Ce,setEditor:Me}=i5();D.useEffect(()=>{V()},[]);const be=D.useRef(!1);D.useEffect(()=>{if(U&&!be.current){be.current=!0;const Ge=i5.getState().search;u(Ge),m(Ge)}},[U]),D.useEffect(()=>{if(!be.current)return;const Ge=setTimeout(()=>{m(o),we(o)},200);return()=>clearTimeout(Ge)},[o,we]),D.useEffect(()=>{if(!k)return;const Ge=setTimeout(()=>T(null),3e3);return()=>clearTimeout(Ge)},[k]),D.useEffect(()=>{if(!e)return;let Ge=!1;return(async()=>{s(!0);try{const rt=await window.api.config.listDir(`${e}/.claude/projects`,{dirsOnly:!0});if(Ge)return;const $t=[];for(const ur of rt.entries){if(Ge)return;const Yr=(await window.api.config.listDir(ur.path,{filesOnly:!0})).entries.filter(pn=>pn.name.endsWith(".jsonl")),an=Yr.reduce((pn,es)=>Math.max(pn,es.mtimeMs),0),Di=Yr.reduce((pn,es)=>pn+es.size,0);$t.push({encoded:ur.name,displayPath:KC(ur.name),sessionCount:Yr.length,lastSession:an,path:ur.path,sizeBytes:Di})}$t.sort((ur,Pr)=>Pr.lastSession-ur.lastSession),Ge||(n($t),l({}),y(new Set))}catch(rt){console.error("[Projects] scan failed:",rt)}finally{Ge||s(!1)}})(),()=>{Ge=!0}},[e]),D.useEffect(()=>{if(!r.length)return;let Ge=!1;const rt=r.slice();let $t=0;const ur=()=>{for(;!Ge&&$t<6&&rt.length;){const Pr=rt.shift();$t++,XC(Pr.path).then(async Yr=>{if(Ge)return;const an=Yr?await f0e(Yr):{};Ge||l(Di=>({...Di,[Pr.encoded]:{cwd:Yr??null,...an}}))}).catch(()=>{Ge||l(Yr=>({...Yr,[Pr.encoded]:{cwd:null}}))}).finally(()=>{$t--,Ge||ur()})}};return ur(),()=>{Ge=!0}},[r]);const se=Object.keys(a).length>=r.length,ve=Object.values(a).some(Ge=>Ge.gitRemote),xe=Object.values(a).some(Ge=>Ge.lastBranch),Ve=r.length>0&&(ve||!se),Re=r.length>0&&(xe||!se),We=Date.now(),Le=r.filter(Ge=>{var $t,ur,Pr,Yr;if(Y==="7d"&&We-Ge.lastSession>JC||Y==="30d"&&We-Ge.lastSession>m0e||re&&!q[Ge.encoded])return!1;const rt=a[Ge.encoded];if(rt&&(te===!0&&!rt.gitRemote||te===!1&&rt.gitRemote||K===!0&&!rt.claudemdPreview||K===!1&&rt.claudemdPreview))return!1;if(f){const an=f.toLowerCase();if(!(Ge.displayPath.toLowerCase().includes(an)||((($t=rt==null?void 0:rt.cwd)==null?void 0:$t.toLowerCase().includes(an))??!1)||(((ur=rt==null?void 0:rt.name)==null?void 0:ur.toLowerCase().includes(an))??!1)||(((Pr=rt==null?void 0:rt.gitRemote)==null?void 0:Pr.toLowerCase().includes(an))??!1)||(((Yr=rt==null?void 0:rt.claudemdPreview)==null?void 0:Yr.toLowerCase().includes(an))??!1)))return!1}return!0}),Ze=[...Le].sort((Ge,rt)=>{var Yr,an;const $t=q[Ge.encoded]?1:0,ur=q[rt.encoded]?1:0;if($t!==ur)return ur-$t;let Pr=0;switch(z.col){case"project":{const Di=((Yr=a[Ge.encoded])==null?void 0:Yr.cwd)??Ge.displayPath,pn=((an=a[rt.encoded])==null?void 0:an.cwd)??rt.displayPath;Pr=Di.localeCompare(pn);break}case"sessions":Pr=Ge.sessionCount-rt.sessionCount;break;case"last":Pr=Ge.lastSession-rt.lastSession;break;case"size":Pr=Ge.sizeBytes-rt.sizeBytes;break}return z.dir==="asc"?Pr:-Pr}),ct=Ze.length>0&&Ze.every(Ge=>h.has(Ge.encoded)),ut=Ze.some(Ge=>h.has(Ge.encoded));D.useEffect(()=>{N.current&&(N.current.indeterminate=ut&&!ct)},[ut,ct]);const dr=()=>{y(ct?Ge=>{const rt=new Set(Ge);return Ze.forEach($t=>rt.delete($t.encoded)),rt}:Ge=>{const rt=new Set(Ge);return Ze.forEach($t=>rt.add($t.encoded)),rt})},Xt=async Ge=>{var rt;return((rt=a[Ge.encoded])==null?void 0:rt.cwd)??await XC(Ge.path)},Qt=Ge=>T(Ge),cr=async Ge=>{var ur;let rt=((ur=a[Ge.encoded])==null?void 0:ur.cwd)??null;if(rt||(rt=await XC(Ge.path)),!rt&&(rt=await window.api.app.pickDirectory(),!rt))return;const $t=crypto.randomUUID();I({id:$t,cwd:rt,startupCommand:`claude --dangerously-skip-permissions --session-id ${Io($t)}`,presetId:"projects-tab"})},Or=async Ge=>{const rt=await Xt(Ge);if(!rt){Qt("Project directory not yet resolved");return}const $t=await window.api.app.openInEditor(rt,Ce||null);$t.ok||Qt($t.error??"No editor found")},wr=async Ge=>{const rt=await Xt(Ge);if(!rt){Qt("Project directory not yet resolved");return}const $t=await window.api.app.openInFinder(rt);$t.ok||Qt($t.error??"Failed to open file manager")},sn=async Ge=>{const rt=await Xt(Ge);if(!rt){Qt("Project directory not yet resolved");return}const $t=await window.api.app.openInTerminal(rt);$t.ok||Qt($t.error??"No terminal emulator found")},Wr=Ge=>{C(Ge.encoded)},ii=async Ge=>{b(null),S(!0);const rt=[];for(const $t of Ge)try{const ur=await window.api.app.archiveProject($t);ur.ok?rt.push($t):Qt(ur.error??`Failed to archive ${$t}`)}catch(ur){Qt(ur instanceof Error?ur.message:"Archive failed")}rt.length&&(n($t=>$t.filter(ur=>!rt.includes(ur.encoded))),y($t=>{const ur=new Set($t);return rt.forEach(Pr=>ur.delete(Pr)),ur}),x&&rt.includes(x)&&C(null)),S(!1)},Kn=r.length,mr=r.filter(Ge=>We-Ge.lastSession<JC).length,vt=r.reduce((Ge,rt)=>Ge+rt.sessionCount,0),jt=r.reduce((Ge,rt)=>Ge+rt.sizeBytes,0),It=[...r].filter(Ge=>We-Ge.lastSession<JC).sort((Ge,rt)=>rt.sessionCount-Ge.sessionCount).slice(0,3),Pt=Ge=>{var $t;const rt=($t=P.current)==null?void 0:$t.querySelector(`[data-row-key="${Ge}"]`);rt==null||rt.scrollIntoView({behavior:"smooth",block:"center"}),$(Ge),setTimeout(()=>$(null),2e3)},Ir=(Ge,rt)=>c.jsx(gl,{content:`Sort by ${rt}`,align:"bottom-center",children:c.jsxs("button",{onClick:()=>G(Ge),title:`Sort by ${rt}`,className:"flex items-center gap-1 hover:text-fg w-full uppercase tracking-wider",children:[c.jsx("span",{children:rt}),z.col===Ge&&c.jsx("span",{className:"text-[10px] leading-none",children:z.dir==="asc"?"▲":"▼"})]})}),yi=x?((si=a[x])==null?void 0:si.cwd)??null:null,Sa=x?((In=a[x])==null?void 0:In.cwd)??`/${KC(x)}`:"",Ii=[];Re&&Ii.push({key:"branch",header:"branch",width:"8rem",render:Ge=>{const rt=a[Ge.encoded];return rt?rt.lastBranch?c.jsx("span",{className:"font-mono text-fg-faint truncate block",children:rt.lastBranch}):c.jsx("span",{className:"text-fg-faint",children:"—"}):c.jsx(YC,{})}}),Ve&&Ii.push({key:"remote",header:"remote",render:Ge=>{const rt=a[Ge.encoded];return rt?rt.gitRemote?c.jsx("span",{className:"font-mono text-fg-faint truncate block text-[10px]",children:rt.gitRemote}):c.jsx("span",{className:"text-fg-faint",children:"—"}):c.jsx(YC,{})}});const Cr=[{key:"select",header:c.jsx("input",{ref:N,type:"checkbox",checked:ct,onChange:dr,className:"accent-accent cursor-pointer",title:"Select all visible",onClick:Ge=>Ge.stopPropagation()}),width:"2rem",className:"px-1",render:Ge=>c.jsx("input",{type:"checkbox",checked:h.has(Ge.encoded),onChange:()=>{y(rt=>{const $t=new Set(rt);return $t.has(Ge.encoded)?$t.delete(Ge.encoded):$t.add(Ge.encoded),$t})},onClick:rt=>rt.stopPropagation(),className:"accent-accent cursor-pointer"})},{key:"pin",header:"",width:"2rem",className:"px-1",render:Ge=>c.jsx(gl,{content:q[Ge.encoded]?"Unpin":"Pin to top",children:c.jsx("button",{onClick:rt=>{rt.stopPropagation(),F(Ge.encoded)},title:q[Ge.encoded]?"Unpin":"Pin to top",className:`text-sm leading-none transition-colors ${q[Ge.encoded]?"text-yellow-400":"text-fg-faint hover:text-fg-dim"}`,children:q[Ge.encoded]?"★":"☆"})})},{key:"path",header:Ir("project","project"),render:Ge=>{const rt=a[Ge.encoded],$t=(rt==null?void 0:rt.cwd)??`/${Ge.displayPath}`,ur=c.jsx("span",{className:"font-mono text-fg-dim truncate block max-w-[22rem]",children:$t});return rt!=null&&rt.claudemdPreview?c.jsx(gl,{content:c.jsx("span",{className:"font-mono text-[9px] whitespace-pre-wrap",children:rt.claudemdPreview}),align:"bottom-center",children:ur}):ur}},{key:"name",header:"name",width:"7rem",render:Ge=>{const rt=a[Ge.encoded];return rt?c.jsx("span",{className:"text-fg-dim truncate block",children:rt.name??"—"}):c.jsx(YC,{})}},{key:"sessions",header:Ir("sessions","sessions"),width:"6rem",render:Ge=>c.jsx("span",{className:"text-fg-dim",children:Ge.sessionCount})},{key:"size",header:Ir("size","size"),width:"6rem",render:Ge=>c.jsx("span",{className:"text-fg-faint",children:df(Ge.sizeBytes)})},{key:"last",header:Ir("last","last active"),width:"9rem",render:Ge=>c.jsx("span",{className:"text-fg-faint",children:p0e(Ge.lastSession)})},...Ii,{key:"action",header:"",width:"11rem",render:Ge=>{const rt=a[Ge.encoded],$t=!!(rt!=null&&rt.claudemdPreview);return c.jsxs("div",{className:"flex items-center gap-0.5",children:[c.jsx(lp,{tip:"Open in new terminal session",onClick:()=>cr(Ge),children:"▷"}),c.jsx(lp,{tip:"Open in editor",onClick:()=>Or(Ge),children:"✏"}),c.jsx(lp,{tip:"Open in file manager",onClick:()=>wr(Ge),children:"⌂"}),c.jsx(lp,{tip:"Open in terminal",onClick:()=>sn(Ge),children:"⊞"}),c.jsx(lp,{tip:$t?"Preview CLAUDE.md":"No CLAUDE.md",onClick:()=>Wr(Ge),disabled:!$t,children:"Ⓜ"}),c.jsx(lp,{tip:"Archive project",onClick:()=>b([Ge.encoded]),danger:!0,children:"⊗"})]})}}];return c.jsxs("div",{className:"h-full flex flex-col",children:[!i&&r.length>0&&c.jsxs("div",{className:"shrink-0 border-b border-line bg-bg px-3 py-1.5 flex items-center gap-4 text-[10px] text-fg-faint flex-wrap",children:[c.jsxs("span",{children:[c.jsx("span",{className:"text-fg-dim font-medium",children:Kn})," projects"]}),c.jsxs("span",{children:[c.jsx("span",{className:"text-fg-dim font-medium",children:mr})," active 7d"]}),c.jsxs("span",{children:[c.jsx("span",{className:"text-fg-dim font-medium",children:vt})," sessions"]}),c.jsxs("span",{children:[c.jsx("span",{className:"text-fg-dim font-medium",children:df(jt)})," on disk"]}),It.length>0&&c.jsxs("span",{className:"flex items-center gap-1 flex-wrap",children:[c.jsx("span",{className:"text-fg-faint",children:"most active:"}),It.map(Ge=>{var $t,ur,Pr;const rt=((ur=($t=a[Ge.encoded])==null?void 0:$t.cwd)==null?void 0:ur.split("/").pop())??Ge.displayPath.split("/").pop()??Ge.encoded;return c.jsx("button",{onClick:()=>Pt(Ge.encoded),className:"px-1.5 py-0 rounded border border-line hover:border-fg-faint hover:text-fg transition-colors font-mono",title:((Pr=a[Ge.encoded])==null?void 0:Pr.cwd)??Ge.displayPath,children:rt},Ge.encoded)})]})]}),c.jsx("div",{className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 text-xs",children:c.jsxs("div",{className:"flex flex-col gap-1.5 w-full py-0.5",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:"search",placeholder:"search projects…",value:o,onChange:Ge=>u(Ge.target.value),className:"h-6 px-2 bg-bg border border-line rounded text-xs text-fg placeholder:text-fg-faint focus:outline-none focus:border-fg-faint w-48"}),c.jsx("span",{className:"text-fg-faint",children:Le.length===r.length?`${r.length} projects`:`${Le.length} of ${r.length}`}),c.jsx("div",{className:"flex-1"}),c.jsx(gl,{content:"Preferred editor for 'Open in editor' action",children:c.jsx("select",{value:Ce,onChange:Ge=>Me(Ge.target.value),className:"h-6 bg-bg border border-line rounded text-xs text-fg-dim px-1 focus:outline-none focus:border-fg-faint",children:g0e.map(Ge=>c.jsxs("option",{value:Ge.value,children:["Editor: ",Ge.label]},Ge.value))})}),c.jsx("span",{className:"text-fg-faint font-mono truncate",children:"~/.claude/projects/"})]}),c.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[c.jsx(mu,{label:"All",active:Y==="all",onClick:()=>oe("all"),tip:"Show all projects"}),c.jsx(mu,{label:"≤7d",active:Y==="7d",onClick:()=>oe("7d"),tip:"Active in last 7 days"}),c.jsx(mu,{label:"≤30d",active:Y==="30d",onClick:()=>oe("30d"),tip:"Active in last 30 days"}),c.jsx("span",{className:"w-px h-3 bg-line mx-0.5 shrink-0"}),c.jsx(mu,{label:"Has remote",active:te===!0,onClick:()=>J(te===!0?null:!0),tip:"Only projects with a git remote"}),c.jsx(mu,{label:"No remote",active:te===!1,onClick:()=>J(te===!1?null:!1),tip:"Only projects without a git remote"}),c.jsx("span",{className:"w-px h-3 bg-line mx-0.5 shrink-0"}),c.jsx(mu,{label:"Has CLAUDE.md",active:K===!0,onClick:()=>Z(K===!0?null:!0),tip:"Only projects with a CLAUDE.md"}),c.jsx(mu,{label:"No CLAUDE.md",active:K===!1,onClick:()=>Z(K===!1?null:!1),tip:"Only projects without a CLAUDE.md"}),c.jsx("span",{className:"w-px h-3 bg-line mx-0.5 shrink-0"}),c.jsx(mu,{label:"Pinned",active:re,onClick:()=>he(!re),tip:"Only pinned projects"})]})]})}),c.jsxs("div",{className:"flex-1 min-h-0 flex relative",children:[c.jsx("div",{className:"flex-1 min-w-0 overflow-auto",ref:P,children:i?c.jsx(Bt,{title:"scanning projects…"}):c.jsx(kT,{columns:Cr,rows:Ze,getKey:Ge=>Ge.encoded,activeKey:j,empty:"no projects with claude session history"})}),x&&yi&&c.jsx(h0e,{cwd:yi,projectName:Sa,onClose:()=>C(null)})]}),h.size>0&&c.jsxs("div",{className:"shrink-0 border-t border-line bg-bg-elev px-3 py-2 flex items-center gap-2 text-xs",children:[c.jsxs("span",{className:"text-fg-faint",children:[h.size," selected"]}),c.jsx("div",{className:"flex-1"}),w&&c.jsx("span",{className:"text-fg-faint animate-pulse",children:"archiving…"}),c.jsxs("button",{onClick:()=>b(Array.from(h)),disabled:w,className:"px-2 py-1 border border-red-900/50 text-red-400/80 rounded hover:bg-red-950/30 hover:text-red-400 disabled:opacity-40 transition-colors",children:["Archive ",h.size]}),c.jsx("button",{onClick:async()=>{const Ge=r.filter(rt=>h.has(rt.encoded));for(const rt of Ge)await Or(rt)},disabled:w,className:"px-2 py-1 border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-40 transition-colors",children:"Open all in editor"}),c.jsx("button",{onClick:()=>y(new Set),className:"px-2 py-1 border border-line rounded text-fg-faint hover:text-fg hover:bg-bg-hi transition-colors",children:"Cancel"})]}),c.jsxs(to,{open:!!_,onClose:()=>b(null),title:"Archive projects?",children:[c.jsxs("p",{className:"text-sm text-fg-dim mb-1",children:["Move ",(_==null?void 0:_.length)??0," project",((_==null?void 0:_.length)??0)!==1?"s":""," to"]}),c.jsx("p",{className:"text-xs text-fg-faint font-mono mb-4",children:"~/.claude/projects-archive/"}),_&&_.length<=5&&c.jsx("ul",{className:"mb-4 space-y-0.5 text-[10px] font-mono text-fg-faint",children:_.map(Ge=>{var rt;return c.jsx("li",{className:"truncate",children:((rt=a[Ge])==null?void 0:rt.cwd)??`/${KC(Ge)}`},Ge)})}),c.jsxs("div",{className:"flex gap-2 justify-end",children:[c.jsx("button",{onClick:()=>b(null),className:"px-3 py-1.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"Cancel"}),c.jsx("button",{onClick:()=>_&&ii(_),className:"px-3 py-1.5 text-xs border border-red-900/50 rounded text-red-400 hover:bg-red-950/30",children:"Archive"})]})]}),k&&c.jsx("div",{role:"alert",className:"pointer-events-none fixed bottom-4 right-4 z-50 bg-red-950 border border-red-900/60 text-red-300 text-xs px-3 py-1.5 rounded shadow-lg max-w-xs",children:k})]})}const uT="~/.config/session-manager/doc-editor.json",y0e=20;let QC=null;function Cv(e){QC&&clearTimeout(QC),QC=setTimeout(async()=>{const r=e();try{const n=await window.api.config.readJson(uT).catch(()=>null),i=(n==null?void 0:n.data)??{};await window.api.config.writeJson(uT,{...i,recents:r.recents,openPaths:Object.keys(r.docs),viewModes:r.viewModes})}catch(n){console.warn("[docEditor] persist failed:",n)}},500)}function s5(e,r){return[r,...e.filter(n=>n!==r)].slice(0,y0e)}const ma=Gn((e,r)=>({docs:{},activePath:null,recents:[],viewModes:{},hydrated:!1,open:async n=>{if(r().docs[n]){e({activePath:n});return}const s=await window.api.docEditor.readFile(n);if(!s.ok){ft.warn(`Could not open ${n.split("/").pop()}: ${s.error??"unknown error"}`),e(l=>({recents:l.recents.filter(o=>o!==n)})),Cv(r);return}const a={path:n,diskText:s.text??"",bufferText:s.text??"",mtimeMs:s.mtimeMs??0,loadedAt:Date.now()};e(l=>({docs:{...l.docs,[n]:a},activePath:n,recents:s5(l.recents,n)})),Cv(r)},close:n=>{var o;const i=r(),s=i.docs[n];if(!s)return;if(s.bufferText!==s.diskText){const u=n.split("/").pop()??n;if(!window.confirm(`"${u}" has unsaved changes. Close without saving?`))return}const a={...i.docs};delete a[n];let l=i.activePath;i.activePath===n&&(l=((o=Object.values(a).sort((f,m)=>m.loadedAt-f.loadedAt)[0])==null?void 0:o.path)??null),e({docs:a,activePath:l}),Cv(r)},setActive:n=>{e({activePath:n})},setViewMode:(n,i)=>{e(s=>({viewModes:{...s.viewModes,[n]:i}})),Cv(r)},edit:(n,i)=>{const s=r().docs[n];s&&e(a=>({docs:{...a.docs,[n]:{...s,bufferText:i}}}))},save:async n=>{const i=r().docs[n];if(!i)return;const s=i.bufferText,a=await window.api.docEditor.writeFile(n,s);if(!a.ok){ft.error(`Save failed for ${n.split("/").pop()}: ${a.error??"unknown"}`);return}e(l=>{const o=l.docs[n];return o?{docs:{...l.docs,[n]:{...o,diskText:s,mtimeMs:a.mtimeMs??o.mtimeMs}},recents:s5(l.recents,n)}:{}}),Cv(r)},saveAll:async()=>{const n=Object.values(r().docs).filter(i=>i.bufferText!==i.diskText).map(i=>i.path);await Promise.all(n.map(i=>r().save(i)))},hydrate:async()=>{if(!r().hydrated){e({hydrated:!0});try{const i=(await window.api.config.readJson(uT)).data??{},s=Array.isArray(i.recents)?i.recents:[],a=Array.isArray(i.openPaths)?i.openPaths:[],l=i.viewModes??{},o={};for(const[u,f]of Object.entries(l))(f==="wysiwyg"||f==="source")&&(o[u]=f);e({recents:s,viewModes:o});for(const u of a)await r().open(u)}catch(n){console.warn("[docEditor] hydrate failed:",n)}}}}));window.__docEditor=ma;const b0e={json:"json",ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",cjs:"javascript",mjs:"javascript",py:"python",sh:"shell",bash:"shell",yaml:"yaml",yml:"yaml",toml:"ini",css:"css",html:"html",xml:"xml",sql:"sql",rs:"rust",go:"go",md:"markdown",markdown:"markdown"},a5={Dockerfile:"dockerfile",Makefile:"makefile"};function x0e(e){const r=e.split("/").pop()??e;if(a5[r])return a5[r];const n=r.lastIndexOf(".");if(n===-1)return null;const i=r.slice(n+1);return b0e[i]??null}const w0e=D.lazy(()=>rm(()=>import("./TiptapBody-CZLSQ6pj.js"),__vite__mapDeps([2,0,1]),import.meta.url).then(e=>({default:e.TiptapBody})));function _0e(e){return e.split("/").pop()??e}function S0e(e){return e.endsWith(".md")||e.endsWith(".markdown")}function k0e({docs:e,activePath:r,onSetActive:n,onClose:i}){const s=Object.keys(e);return c.jsx("div",{className:"h-9 bg-bg-elev border-b border-line flex items-center overflow-x-auto shrink-0 px-2 gap-1","data-testid":"doc-tab-strip",children:s.map(a=>{const l=e[a],o=l.bufferText!==l.diskText,u=_0e(a),f=a===r;return c.jsxs("div",{className:`group px-3 py-1 flex items-center gap-1 rounded-t text-xs shrink-0 cursor-pointer transition-colors ${f?"bg-bg-hi text-fg font-semibold border border-b-0 border-accent border-t-2 -mb-px relative z-10":"bg-bg-elev text-fg-dim border border-line hover:text-fg hover:bg-bg"}`,onClick:()=>n(a),title:a,"data-testid":`doc-tab-${u}`,children:[o&&c.jsx("span",{className:"text-amber-400","aria-label":"unsaved changes","data-testid":"doc-tab-dirty",children:"●"}),c.jsx("span",{children:u}),c.jsx("button",{type:"button",onClick:m=>{m.stopPropagation(),i(a)},className:"text-fg-faint opacity-0 group-hover:opacity-100 hover:text-fg ml-1",title:`Close ${u}`,"aria-label":`Close ${u}`,"data-testid":`doc-x-${u}`,children:"×"})]},a)})})}function C0e({path:e,value:r,onChange:n,language:i}){const s=D.useRef(null),a=D.useRef(e);a.current=e;const l=async o=>{s.current=o;const u=await rm(()=>import("./monaco-editor-BW5C4Iv1.js").then(f=>f.b),__vite__mapDeps([0,1]),import.meta.url);o.addCommand(u.KeyMod.CtrlCmd|u.KeyCode.KeyS,()=>{ma.getState().save(a.current)})};return c.jsx(Xw,{path:`file://${e}`,language:i,value:r,onChange:o=>n(o??""),onMount:l,theme:"vs-dark",options:{minimap:{enabled:!1},fontSize:12,fontFamily:"JetBrains Mono, ui-monospace, Menlo, monospace",lineNumbers:"on",renderLineHighlight:"line",scrollBeyondLastLine:!1,tabSize:2,formatOnPaste:!0,automaticLayout:!0,bracketPairColorization:{enabled:!0},wordWrap:"on"}})}function j0e({path:e,value:r,onChange:n}){const i=x0e(e);if(!i){const s=e.split("/").pop()??e;return c.jsx("textarea",{className:"w-full h-full resize-none bg-bg text-fg font-mono text-sm p-3 focus:outline-none leading-relaxed",value:r,onChange:a=>n(a.target.value),spellCheck:!1,"data-testid":"doc-textarea","aria-label":`Edit ${s}`},e)}return c.jsx(C0e,{path:e,value:r,onChange:n,language:i})}function E0e(){const e=ma(b=>b.docs),r=ma(b=>b.activePath),n=ma(b=>b.viewModes),i=ma(b=>b.open),s=ma(b=>b.close),a=ma(b=>b.setActive),l=ma(b=>b.edit),o=ma(b=>b.save),u=ma(b=>b.saveAll),f=ma(b=>b.setViewMode),m=ma(b=>b.hydrate);D.useEffect(()=>{m()},[m]);const h=r?e[r]??null:null,y=Object.values(e).some(b=>b.bufferText!==b.diskText),x=r?n[r]??"wysiwyg":"wysiwyg",C=r?S0e(r):!1,_=async()=>{const b=r?r.split("/").slice(0,-1).join("/"):void 0,w=await window.api.docEditor.pickFile(b?{lastDir:b}:void 0);w.path&&await i(w.path)};return r===null?c.jsx(Bt,{title:"No document open",hint:c.jsxs("span",{children:["Click ",c.jsx("strong",{children:"Open…"})," or use"," ",c.jsx("kbd",{className:"px-1 py-0.5 border border-line rounded font-mono text-[10px]",children:"Cmd-K"})," ","and type ",c.jsx("code",{children:"doc:open"})]})}):c.jsxs("div",{className:"h-full flex flex-col",onKeyDown:b=>{(b.ctrlKey||b.metaKey)&&b.key.toLowerCase()==="s"&&!b.shiftKey&&(b.preventDefault(),r&&o(r)),(b.ctrlKey||b.metaKey)&&b.key.toLowerCase()==="w"&&!b.shiftKey&&(b.preventDefault(),r&&s(r))},"data-testid":"doc-editor-panel",children:[c.jsx(k0e,{docs:e,activePath:r,onSetActive:a,onClose:s}),c.jsxs("div",{className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 flex items-center gap-2 text-xs",children:[c.jsx("button",{type:"button",onClick:_,className:"px-2 py-1 border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi transition-colors","data-testid":"doc-open-btn",children:"Open…"}),c.jsx("button",{type:"button",onClick:()=>r&&o(r),disabled:!h||h.bufferText===h.diskText,className:"px-2 py-1 border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi transition-colors disabled:opacity-40 disabled:cursor-not-allowed","data-testid":"doc-save-btn",children:"Save"}),c.jsx("button",{type:"button",onClick:()=>u(),disabled:!y,className:"px-2 py-1 border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi transition-colors disabled:opacity-40 disabled:cursor-not-allowed","data-testid":"doc-save-all-btn",children:"Save All"}),C&&r&&c.jsxs("div",{className:"flex items-center border border-line rounded overflow-hidden text-[11px]","data-testid":"view-mode-toggle",children:[c.jsx("button",{type:"button",onClick:()=>f(r,"wysiwyg"),className:`px-2 py-0.5 transition-colors ${x==="wysiwyg"?"bg-accent text-bg font-semibold":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,"data-testid":"view-mode-wysiwyg",children:"WYSIWYG"}),c.jsx("button",{type:"button",onClick:()=>f(r,"source"),className:`px-2 py-0.5 transition-colors ${x==="source"?"bg-accent text-bg font-semibold":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,"data-testid":"view-mode-source",children:"Source"})]}),r&&c.jsx("span",{className:"ml-2 text-fg-faint truncate flex-1 font-mono text-[11px]",title:r,children:r})]}),c.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:C&&x==="wysiwyg"&&r&&h?c.jsx(D.Suspense,{fallback:c.jsx("div",{className:"p-4 text-fg-faint text-sm",children:"Loading editor…"}),children:c.jsx(w0e,{value:h.bufferText,onChange:b=>l(r,b)},r)}):C&&r&&h?c.jsx(jc,{path:r,value:h.bufferText,onChange:b=>l(r,b)},r):r&&h?c.jsx(j0e,{path:r,value:h.bufferText,onChange:b=>l(r,b)}):null})]})}const T0e=5e3;let r0=null,jv=null;async function dT(e){const r=Date.now();return!(e!=null&&e.fresh)&&r0&&r-r0.at<T0e?r0.result:jv||(jv=(async()=>{try{const n=await window.api.schedule.lintQueue();return r0={result:n,at:Date.now()},n}finally{jv=null}})(),jv)}const o5=2e3;function A0e(e){return e.is_error===!0||e.error!=null&&e.error!==""||e.type==="result"&&e.subtype!=="success"&&e.subtype!=null}function $0e(e){return typeof e.error=="string"&&e.error?e.error:typeof e.result=="string"&&e.result?e.result:typeof e.subtype=="string"?e.subtype:JSON.stringify(e).slice(0,200)}function N0e(e){if(typeof e.text=="string")return e.text.slice(0,200);if(typeof e.content=="string")return e.content.slice(0,200);if(Array.isArray(e.content)){for(const n of e.content)if(n&&typeof n=="object"&&"text"in n&&typeof n.text=="string")return n.text.slice(0,200)}const r=e.message;if(r&&typeof r=="object"){const n=r;if(typeof n.content=="string")return n.content.slice(0,200);if(Array.isArray(n.content)){for(const i of n.content)if(i&&typeof i=="object"&&"text"in i&&typeof i.text=="string")return i.text.slice(0,200)}}return typeof e.result=="string"&&e.result?e.result.slice(0,200):typeof e.subtype=="string"?e.subtype:JSON.stringify(e).slice(0,200)}function O0e(e){if(!e||!e.trim())return{events:[],errors:{count:0,firstMessage:null},rawLineCount:0,truncated:!1};const n=e.split(`
|
|
3508
3508
|
`).filter(f=>f.trim().length>0),i=n.length,s=i>o5,a=s?n.slice(0,o5):n,l=[];let o=0,u=null;for(const f of a){let m=null;try{const h=JSON.parse(f);h!==null&&typeof h=="object"&&!Array.isArray(h)&&"type"in h&&(m=h)}catch{}if(m!==null){const h=typeof m.type=="string"?m.type:"unknown",y=A0e(m);y&&(o++,u===null&&(u=$0e(m))),l.push({type:h,raw:f,preview:N0e(m),isError:y})}else l.push({type:"raw",raw:f,preview:f.slice(0,200),isError:!1})}return{events:l,errors:{count:o,firstMessage:u},rawLineCount:i,truncated:s}}const P0e={assistant:"accent",user:"default",system:"dim",result:"warn",tool_use:"default",tool_result:"default",raw:"dim"};function R0e(e){return P0e[e]??"default"}function w8({runId:e,slug:r,title:n,onClose:i}){const[s,a]=D.useState(!0),[l,o]=D.useState(null),[u,f]=D.useState(""),[m,h]=D.useState(null),[y,x]=D.useState("parsed");return D.useEffect(()=>{a(!0),o(null),window.api.schedule.readLog(e,r).then(C=>{if(C.ok){const _=C.text??"";f(_),h(O0e(_))}else{const _=C.error??"Failed to read log";o(_),ft.error(`Log read failed: ${_}`)}}).catch(C=>{const _=C instanceof Error?C.message:String(C);o(_),ft.error(`Log read failed: ${_}`)}).finally(()=>a(!1))},[e,r]),c.jsx(to,{open:!0,onClose:i,size:"xl",fillHeight:!0,noPadding:!0,title:n,children:c.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[c.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-4 py-2 border-b border-line",children:[c.jsx("button",{type:"button",onClick:()=>x("parsed"),className:`text-[10px] px-2 py-0.5 rounded border ${y==="parsed"?"bg-accent/20 text-accent border-accent/40":"text-fg-faint border-line hover:text-fg-dim hover:border-fg-faint"}`,children:"Parsed"}),c.jsx("button",{type:"button",onClick:()=>x("raw"),className:`text-[10px] px-2 py-0.5 rounded border ${y==="raw"?"bg-accent/20 text-accent border-accent/40":"text-fg-faint border-line hover:text-fg-dim hover:border-fg-faint"}`,children:"Raw"}),c.jsxs("span",{className:"ml-auto text-[10px] text-fg-faint font-mono",children:[r," · ",e.slice(0,8)]}),c.jsx("button",{type:"button",onClick:i,className:"text-fg-faint hover:text-fg-dim text-sm leading-none ml-1","aria-label":"Close",children:"×"})]}),c.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[s&&c.jsx("div",{className:"flex-1 flex items-center justify-center text-[11px] text-fg-faint",children:"Loading log…"}),!s&&l&&c.jsx("div",{className:"flex-1 flex items-center justify-center",children:c.jsx("div",{className:"text-[11px] text-red-300 px-6 text-center max-w-md",children:l})}),!s&&!l&&y==="raw"&&c.jsx("pre",{className:"flex-1 overflow-auto p-4 text-[10px] font-mono text-fg-dim whitespace-pre-wrap break-all leading-relaxed",children:u||c.jsx("span",{className:"text-fg-faint italic",children:"log is empty"})}),!s&&!l&&y==="parsed"&&m&&c.jsx(M0e,{parsed:m,onSwitchRaw:()=>x("raw")})]})]})})}function M0e({parsed:e,onSwitchRaw:r}){const{events:n,errors:i,rawLineCount:s,truncated:a}=e;return n.length===0?c.jsx("div",{className:"flex-1 flex items-center justify-center text-[11px] text-fg-faint italic",children:"log is empty"}):c.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[c.jsx("div",{className:`shrink-0 px-4 py-2 border-b border-line text-[11px] ${i.count>0?"bg-red-950/20":"bg-bg-elev/50"}`,children:i.count>0?c.jsxs("span",{className:"text-red-300",children:[c.jsxs("span",{className:"font-medium",children:[i.count," error",i.count===1?"":"s"," detected"]}),i.firstMessage&&c.jsx("span",{className:"text-red-300/70 ml-2 font-mono",children:i.firstMessage.slice(0,120)})]}):c.jsx("span",{className:"text-green-400/70",children:"no errors detected"})}),a&&c.jsxs("div",{className:"shrink-0 px-4 py-1.5 border-b border-line bg-yellow-950/20 text-[10px] text-yellow-400/80",children:["showing first ",n.length," of ",s," events —"," ",c.jsx("button",{type:"button",onClick:r,className:"underline hover:text-yellow-300",children:"open Raw for full"})]}),c.jsx("div",{className:"flex-1 overflow-y-auto",children:n.map((l,o)=>c.jsx(I0e,{event:l},o))})]})}function I0e({event:e}){const[r,n]=D.useState(!1),i=e.type==="raw";return c.jsxs("div",{className:`flex items-start gap-2 px-3 py-1 border-b border-line/30 cursor-pointer hover:bg-bg-hi ${e.isError?"bg-red-950/10":""}`,onClick:()=>n(s=>!s),children:[c.jsx("div",{className:"shrink-0 pt-0.5 w-16",children:i?c.jsx("span",{className:"text-[9px] text-fg-faint/50 font-mono",children:"raw"}):c.jsx(Qi,{tone:R0e(e.type),className:"text-[9px]",children:e.type})}),c.jsx("div",{className:"flex-1 min-w-0",children:r?c.jsx("pre",{className:"text-[10px] font-mono text-fg-dim whitespace-pre-wrap break-all",children:e.raw}):c.jsx("span",{className:`text-[10px] truncate block ${i?"text-fg-faint/60 font-mono":"text-fg-dim"}`,children:e.preview||c.jsx("span",{className:"italic text-fg-faint/40",children:"(empty)"})})})]})}function _8({options:e,value:r,onChange:n,pillPadding:i="px-3 py-1.5"}){return c.jsx("div",{className:"flex gap-1.5 flex-wrap",children:e.map(s=>{const a=s.value===r;return c.jsx("button",{type:"button",onClick:()=>n(s.value),className:`rounded-full ${i} text-[12.5px] border transition-colors ${a?"bg-accent text-white border-accent font-semibold":"bg-bg-hi text-fg-dim border-line hover:border-fg-faint font-medium"}`,children:s.label},s.value)})})}const l5=["#6f7d52","#b85c34","#8a7a60","#e4b85a","#5f6f86","#4f7d72","#8a5a6e"];function D0e(e){let r=0;for(let n=0;n<e.length;n++)r=r*31+e.charCodeAt(n)>>>0;return r}function L0e(e,r){const n=e?e.split("/").filter(Boolean).pop()??"":r??"";return l5[D0e(n)%l5.length]}const B0e={running:"bg-accent text-white",pending:"bg-bg text-fg-dim border border-line",completed:"bg-sage/20 text-sage",needs_review:"bg-butter/25 text-fg-dim",failed:"bg-accent/15 text-accent"},z0e={pending:"○",completed:"✓",needs_review:"!",failed:"✕"};function S8({status:e}){const r=z0e[e];return c.jsxs("span",{className:`inline-flex items-center gap-1.5 shrink-0 px-2.5 py-1 rounded-lg min-w-[104px] justify-center text-xs font-semibold tracking-wide ${B0e[e]}`,role:"status","aria-label":`Status: ${e.replace("_"," ")}`,children:[e==="running"?c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-white animate-pulse","aria-hidden":"true"}):r&&c.jsx("span",{"aria-hidden":"true",children:r}),e.replace("_"," ")]})}function ZA({cwd:e,name:r}){const n=r??(e?e.split("/").filter(Boolean).pop()??e:"—"),i=L0e(e,r);return c.jsxs("span",{className:"inline-flex items-center gap-1.5 font-mono text-xs text-fg-faint",children:[c.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{backgroundColor:i},"aria-hidden":"true"}),n]})}function Cu({label:e,children:r}){return c.jsxs("div",{children:[c.jsx("div",{className:"text-[11px] font-bold tracking-[0.7px] uppercase text-fg-faint mb-2",children:e}),c.jsx("div",{className:"grid gap-1.5",children:r})]})}function Pi({k:e,v:r,wrap:n}){return c.jsxs("div",{className:"flex gap-2 font-mono text-xs leading-relaxed",children:[c.jsx("span",{className:"text-fg-faint shrink-0 w-14",children:e}),c.jsx("span",{className:`text-fg ${n?"break-all":""}`,children:r})]})}function ZC({dotClass:e,n:r,label:n}){return c.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[13px] text-fg-dim",children:[c.jsx("span",{className:`w-2 h-2 rounded-full ${e}`,"aria-hidden":"true"}),c.jsx("strong",{className:"text-fg font-mono text-[13.5px]",children:r})," ",n]})}const F0e={running:{bg:"bg-butter/30",text:"text-fg-dim",border:!1,label:"running"},queued:{bg:"bg-sage/25",text:"text-sage",border:!1,label:"queued"},ready:{bg:"bg-bg",text:"text-fg-dim",border:!0,label:"ready to run"},draft:{bg:"bg-bg",text:"text-fg-faint",border:!0,label:"draft"},completed:{bg:"bg-sage/20",text:"text-sage",border:!1,label:"completed"},failed:{bg:"bg-accent/15",text:"text-accent",border:!1,label:"failed"},needs_review:{bg:"bg-butter/25",text:"text-fg-dim",border:!1,label:"needs review"}},U0e=5,q0e=1440*60*1e3,k8="sm.scheduler.hiddenCompletedSlugs",ej="sm.scheduler.focusedJobIndex",C8="sm.scheduler.queueFilter",W0e=["all","running","pending","completed","needs_review","failed"];function H0e(){try{const e=localStorage.getItem(C8);if(!e)return{text:"",status:"all"};const r=JSON.parse(e);return{text:"",status:W0e.includes(r.status)?r.status:"all"}}catch{return{text:"",status:"all"}}}function V0e(e){try{localStorage.setItem(C8,JSON.stringify({status:e.status}))}catch{}}function G0e(e,r){if(r.status==="all"&&!r.text)return e;const n=r.text.toLowerCase();return e.filter(i=>{if(r.status!=="all"&&i.status!==r.status)return!1;if(!n)return!0;const s=X0e(i.cwd)??"";return i.title.toLowerCase().includes(n)||i.slug.toLowerCase().includes(n)||s.toLowerCase().includes(n)})}const c5={halt:"verifier halted",deps_unmet:"dependencies unmet",transcript_errors:"transcript had errors",verify_unavailable:"verify unavailable",uncommitted_changes:"uncommitted changes"};function K0e(){try{const e=localStorage.getItem(k8);if(!e)return new Set;const r=JSON.parse(e);return Array.isArray(r)?new Set(r.filter(n=>typeof n=="string")):new Set}catch{return new Set}}function u5(e){try{localStorage.setItem(k8,JSON.stringify([...e]))}catch{}}function X0e(e){if(!e)return null;const r=e.replace(/\/+$/,"").split("/");return r[r.length-1]||e}function Y0e(){const e=yc(Ce=>Ce.snapshot),[r,n]=D.useState(null),[i,s]=D.useState(!1),[a,l]=D.useState(()=>Date.now()),[o,u]=D.useState(()=>K0e()),[f,m]=D.useState(!1),[h,y]=D.useState(()=>H0e()),[x,C]=D.useState(!1),[_,b]=D.useState("queue"),w=D.useRef(null),[S,k]=D.useState(()=>{try{return Number(localStorage.getItem(ej))||0}catch{return 0}}),[T,j]=D.useState("");D.useEffect(()=>(window.api.schedule.health().then(n).catch(()=>{}),window.api.schedule.onState(()=>{window.api.schedule.health().then(n).catch(()=>{})})),[]),D.useEffect(()=>{const Ce=setInterval(()=>l(Date.now()),1e3);return()=>clearInterval(Ce)},[]);const $=D.useMemo(()=>{if(!e)return 15e4;const Ce=[];for(const Me of e.jobs)if(Me.status==="completed"&&Me.startedAt&&Me.finishedAt){const be=Date.parse(Me.finishedAt)-Date.parse(Me.startedAt);be>0&&Ce.push(be)}return Ce.length===0?15e4:Ce.reduce((Me,be)=>Me+be,0)/Ce.length},[e]),P=D.useRef(new Map);if(D.useEffect(()=>{if(!e)return;const Ce=[];for(const Me of e.jobs){const be=P.current.get(Me.slug);be&&be!==Me.status&&Ce.push(`${Me.title}: ${be} → ${Me.status}`),P.current.set(Me.slug,Me.status)}Ce.length>0&&j(Ce.join("; "))},[e]),!e)return null;if(_==="supervisor")return c.jsx(swe,{supervisorConfig:e.config.supervisor,onSetConfig:Ce=>window.api.schedule.setConfig({supervisor:Ce}),onBack:()=>b("queue")});const{config:N,jobs:I,paused:U,lastRunAt:V,nextReset:q}=e,F={pending:0,running:0,completed:0,needs_review:0,failed:0};for(const Ce of I)Ce.status in F&&F[Ce.status]++;const z=I.filter(Ce=>Ce.status==="running"),G=J0e({snap:e,now:a,avgDurationMs:$,runningJobs:z}),Y=G0e(I,h),oe=Q0e(Y),{inline:te,collapsedCount:J}=Z0e(Y,o,a,f),K=()=>{const Ce=new Set(o);for(const Me of I)(Me.status==="completed"||Me.status==="failed")&&Ce.add(Me.slug);u(Ce),u5(Ce)},Z=async()=>{const Ce=I.filter(se=>se.status!=="running").length;if(Ce===0)return;const Me=`Archive ${Ce} non-running PRD${Ce===1?"":"s"} and remove from the queue?
|
|
3509
3509
|
|
|
3510
3510
|
Files are moved to prds-archived/<timestamp>/ and can be restored from disk. Running jobs are kept.`;if(!window.confirm(Me))return;const be=await window.api.schedule.clearQueue();be.ok||ft.error(`Clear queue failed: ${be.error??"unknown error"}`)},re=()=>{u(new Set),u5(new Set),m(!1)},he=te.some(Ce=>Ce.status==="completed"),we=D.useCallback(Ce=>{var be,se,ve;const Me=(be=w.current)==null?void 0:be.querySelectorAll("[data-job-row]");if(!(!Me||Me.length===0)){if(Ce.key==="ArrowDown"){Ce.preventDefault();const xe=Math.min(S+1,Me.length-1);k(xe);try{localStorage.setItem(ej,String(xe))}catch{}(se=Me[xe])==null||se.focus()}else if(Ce.key==="ArrowUp"){Ce.preventDefault();const xe=Math.max(S-1,0);k(xe);try{localStorage.setItem(ej,String(xe))}catch{}(ve=Me[xe])==null||ve.focus()}}},[S]);return c.jsxs("div",{className:"overflow-y-auto h-full",children:[c.jsx("div",{"aria-live":"polite","aria-atomic":"true",className:"sr-only",children:T}),c.jsxs("div",{className:"px-9 py-6 max-w-[1100px] mx-auto space-y-4",children:[c.jsxs("div",{className:`flex flex-wrap items-center gap-3 px-4 py-3 rounded-xl border ${twe(G.kind)}`,title:G.tooltip,children:[c.jsxs("div",{className:"flex items-center gap-2.5 min-w-0 flex-1",children:[c.jsx(ewe,{kind:G.kind}),c.jsxs("div",{className:"min-w-0",children:[c.jsx("div",{className:"text-[13px] font-medium text-fg truncate",children:G.line1}),G.line2&&c.jsx("div",{className:"text-[11.5px] text-fg-faint font-mono mt-0.5 truncate",children:G.line2})]})]}),G.action&&c.jsx("button",{type:"button",onClick:G.action.onClick,className:"text-[12px] px-3 py-1.5 border border-line hover:border-fg-faint rounded-lg shrink-0 hover:bg-bg-hi text-fg-dim hover:text-fg",title:G.action.title,children:G.action.label})]}),r&&r.consecutiveFailures>5&&r.lastFailureKind==="meter_rate_limited"&&!U&&!x&&c.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-3 bg-amber-400/15 border border-amber-400/30 rounded-xl",children:[c.jsx("span",{className:"text-[12.5px] text-amber-400 font-medium",children:"Meter rate-limited — firing on heuristic"}),c.jsx("button",{type:"button",onClick:()=>C(!0),className:"text-[12px] text-amber-400/70 hover:text-amber-400 shrink-0",title:"Dismiss this banner. The scheduler continues firing normally.",children:"Dismiss"})]}),c.jsxs("div",{className:"flex items-center gap-[18px] flex-wrap bg-bg-elev border border-line rounded-xl px-4 py-3",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-[13px] text-fg-dim",children:"Start jobs"}),c.jsxs("select",{value:N.firePolicy??"when-available",onChange:Ce=>window.api.schedule.setConfig({firePolicy:Ce.target.value}),className:"appearance-none border border-line bg-bg-hi rounded-lg px-2.5 py-1.5 font-sans text-[13px] text-fg font-medium",title:"when-available: poll usage and fire when tokens are below threshold. on-reset: fire after each 5h reset. manual: only on Run now.",children:[c.jsx("option",{value:"when-available",children:"when available"}),c.jsx("option",{value:"on-reset",children:"only on reset"}),c.jsx("option",{value:"manual",children:"manually"})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-[13px] text-fg-dim",children:"Up to"}),c.jsx("input",{type:"number",min:1,max:20,value:N.concurrencyCap,onChange:Ce=>window.api.schedule.setConfig({concurrencyCap:Number(Ce.target.value)}),className:"w-11 text-center border border-line bg-bg-hi rounded-lg py-1.5 font-mono text-[13px] text-fg",title:"Max simultaneous jobs within a parallel group"}),c.jsx("span",{className:"text-[13px] text-fg-dim",children:"at once"})]}),(N.firePolicy??"when-available")==="when-available"&&c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-[13px] text-fg-dim",children:"Pause above"}),c.jsx("input",{type:"number",min:0,max:100,value:N.utilizationThreshold??90,onChange:Ce=>window.api.schedule.setConfig({utilizationThreshold:Number(Ce.target.value)}),className:"w-11 text-center border border-line bg-bg-hi rounded-lg py-1.5 font-mono text-[13px] text-fg",title:"Fire only when 5h utilization is below this percent"}),c.jsx("span",{className:"text-[13px] text-fg-dim",children:"% of window"})]}),c.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[c.jsx("button",{type:"button",onClick:()=>window.api.schedule.forceTick(),disabled:F.pending===0&&F.running===0,className:"bg-accent text-white rounded-lg px-4 py-2 text-[13px] font-semibold whitespace-nowrap disabled:opacity-40 disabled:cursor-not-allowed hover:opacity-90",title:"Bypasses the billing-usage poll. Use when the meter is rate-limited or you want immediate progress.",children:"Fire next batch now"}),c.jsx("button",{type:"button",onClick:()=>window.api.schedule.rescan(),className:"bg-bg-hi border border-line text-fg-dim hover:text-fg rounded-lg px-3.5 py-2 text-[13px] font-medium",title:"Re-scan the prds/ folder. Use when you've added or edited PRDs on disk and want the queue to reflect them immediately.",children:"Refresh"})]})]}),z.length>0&&(()=>{var se;const Ce=N.concurrencyCap??4,Me=(se=z[0])==null?void 0:se.parallelGroup,be=I.filter(ve=>ve.status==="pending"&&ve.parallelGroup===Me).length;return c.jsxs("div",{className:"flex items-center gap-2 text-[12px] font-mono",children:[c.jsxs("span",{className:"px-2 py-0.5 rounded bg-amber-400/20 text-amber-400 shrink-0",children:[z.length,"/",Ce," running"]}),be>0&&c.jsxs("span",{className:"text-fg-faint",children:["+",be," ready in this group"]})]})})(),I.length>0&&c.jsx(iwe,{filter:h,onChange:Ce=>{y(Ce),V0e(Ce)}}),c.jsxs("div",{className:"bg-bg-hi border border-line rounded-2xl overflow-hidden",children:[c.jsxs("div",{className:"flex items-center justify-between px-[18px] py-3 bg-bg-elev",children:[c.jsxs("span",{className:"font-serif text-base font-semibold text-fg",children:[Y.length," job",Y.length!==1?"s":""]}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("span",{className:"font-mono text-[12px] text-fg-faint",children:[F.pending,"p · ",F.running,"r · ",F.completed,"d",F.failed>0&&c.jsxs("span",{className:"text-accent",children:[" · ",F.failed,"f"]})]}),he&&c.jsx("button",{type:"button",onClick:K,className:"text-[12.5px] text-fg-dim hover:text-fg bg-transparent border-0 cursor-pointer font-medium",title:"Hide completed jobs from this view (queue.json unchanged — they remain in history)",children:"Clear completed"}),c.jsx("button",{type:"button",onClick:Z,disabled:I.every(Ce=>Ce.status==="running"),className:"text-[12.5px] text-fg-dim hover:text-accent bg-transparent border-0 cursor-pointer font-medium disabled:opacity-40 disabled:cursor-not-allowed",title:"Archive every non-running PRD (moved to prds-archived/<timestamp>/) and remove them from the queue. Running jobs are kept.",children:"Clear queue"})]})]}),I.length===0&&c.jsxs("div",{className:"px-[18px] py-6 text-[13px] text-fg-faint italic",children:["No PRDs queued. Drop .md files in:",c.jsx("button",{type:"button",onClick:()=>window.api.schedule.openFolder(),className:"block mt-1 text-fg-dim hover:text-fg underline truncate w-full text-left",children:"~/.claude/session-manager/scheduled-plans/prds/"})]}),I.length>0&&te.length===0&&J===0&&c.jsx("div",{className:"px-[18px] py-6 text-[13px] text-fg-faint italic",children:"no matching jobs"}),c.jsx("div",{ref:w,role:"list","aria-label":"Job queue",onKeyDown:we,children:te.map((Ce,Me)=>c.jsx(nwe,{job:Ce,eta:rwe(Ce,I,oe.get(Ce.slug)??0,$,G.kind,a),now:a,avgDurationMs:$,listIndex:Me},Ce.slug))}),J>0&&c.jsxs("button",{type:"button",onClick:()=>m(Ce=>!Ce),className:"w-full text-left text-[12px] text-fg-faint hover:text-fg-dim px-[18px] py-3 border-t border-line",title:f?"Re-collapse old/cleared completed":"Show all completed (incl. cleared and >24h)",children:[f?"▾":"▸"," ",J," more completed",o.size>0&&c.jsx("span",{className:"ml-2 underline",onClick:Ce=>{Ce.stopPropagation(),re()},children:"un-hide"})]})]}),c.jsx(lwe,{snap:e}),c.jsx(owe,{health:r,now:a,showHealth:i,setShowHealth:s}),c.jsxs("div",{className:"flex items-center justify-between text-[12px] text-fg-faint pt-1 border-t border-line",children:[c.jsxs("span",{children:[q&&c.jsxs("span",{title:`next 5h reset: ${q}`,children:["reset ",Ka(Date.parse(q)-a)]}),V&&c.jsxs("span",{className:"ml-2",title:V,children:["last run ",Ka(a-Date.parse(V))," ago"]})]}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("button",{type:"button",onClick:()=>b("supervisor"),className:"hover:text-fg-dim underline",title:"Open supervisor log and settings",children:"supervisor"}),c.jsx("button",{type:"button",onClick:()=>window.api.schedule.openFolder(),className:"hover:text-fg-dim underline",children:"folder"})]})]})]})]})}function J0e({snap:e,now:r,avgDurationMs:n,runningJobs:i}){const{config:s,jobs:a,paused:l,nextReset:o,utilization:u}=e;let f=0,m=0;for(const b of a)b.status==="pending"?f++:b.status==="completed"&&m++;const h=i.length,y=f+h,x=s.concurrencyCap??4;if(h>0){const b=i.reduce((j,$)=>(j.startedAt??"")<($.startedAt??"")?j:$),w=b.startedAt?r-Date.parse(b.startedAt):0,S=m+h,k=m+y,T=h>1?` · ${h}/${x} parallel`:"";return{kind:"running",line1:`Running ${S}/${k}${T} · ${ny(w)}`,line2:h===1?b.title:i.map(j=>j.title).join(", "),tooltip:i.map(j=>`${j.slug} (g${j.parallelGroup})`).join("; ")}}if(l){const b=l.resumeAt?Date.parse(l.resumeAt)-r:null;return{kind:"paused",line1:{rate_limit:"Paused — tokens exhausted",auth:"Paused — authentication failed",network:"Paused — network unreachable",reset_failure:"Paused — billing data unavailable",manual:"Paused — manual"}[l.reason]??`Paused — ${l.reason}`,line2:l.reason==="auth"?"Run `claude` in any terminal to refresh credentials, then Resume":b!==null&&b>0?`auto-resume ${wp(Date.parse(l.resumeAt))} (in ${Ka(b)})`:l.resumeAt?"resuming…":"no auto-resume scheduled",tooltip:l.resumeAt??"",action:{label:"Resume",onClick:()=>window.api.schedule.resume(),title:"Clear the pause and resume queue immediately"}}}if(y===0)return{kind:"idle",line1:"No work queued",line2:null};const C=s.firePolicy??"when-available";if(C==="manual")return{kind:"manual",line1:`Manual · ${f} pending`,line2:"click Fire next batch now to fire",action:{label:"Fire next batch now",onClick:()=>window.api.schedule.forceTick(),title:"Bypasses the billing-usage poll. Use when the meter is rate-limited or you want immediate progress."}};if(C==="on-reset"){if(!o)return{kind:"on-reset",line1:"On-reset · waiting for billing data",line2:null};const b=Date.parse(o)+s.offsetMinutes*6e4,w=b-r;return{kind:"on-reset",line1:`On-reset · ${f} pending`,line2:w>0?`fires ${wp(b)} (in ${Ka(w)})`:"firing now…"}}const _=s.utilizationThreshold??90;if(u==null)return{kind:"auto-soon",line1:`Auto · ${f} pending`,line2:"checking token availability…"};if(u>=_){const b=o?Date.parse(o)-r:null;return{kind:"auto-throttled",line1:`Auto · throttled (util ${u.toFixed(0)}% ≥ ${_}%)`,line2:b&&b>0?`next reset ${wp(Date.parse(o))} (in ${Ka(b)})`:"will fire when usage drops"}}return{kind:"auto-soon",line1:`Auto · ${f} pending · util ${u.toFixed(0)}%`,line2:"fires within 2 min (poll cycle)"}}function Q0e(e){const r=e.filter(i=>i.status==="running"||i.status==="pending").sort((i,s)=>i.parallelGroup-s.parallelGroup||i.slug.localeCompare(s.slug)),n=new Map;return r.forEach((i,s)=>n.set(i.slug,s)),n}function Z0e(e,r,n,i){if(i)return{inline:e,collapsedCount:0};const s=e.filter(f=>f.status==="completed").sort((f,m)=>{const h=f.finishedAt?Date.parse(f.finishedAt):0;return(m.finishedAt?Date.parse(m.finishedAt):0)-h}),a=new Set;let l=0;for(const f of s){if(l>=U0e)break;r.has(f.slug)||f.finishedAt&&n-Date.parse(f.finishedAt)>q0e||(a.add(f.slug),l++)}const o=[];let u=0;for(const f of e){if(f.status==="failed"&&r.has(f.slug)){u++;continue}if(f.status!=="completed"){o.push(f);continue}a.has(f.slug)?o.push(f):u++}return{inline:o,collapsedCount:u}}function ewe({kind:e}){return e==="running"?c.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-400 animate-pulse shrink-0"}):e==="paused"?c.jsx("span",{className:"text-[13px] shrink-0",title:"paused",children:"⏸"}):e==="manual"?c.jsx("span",{className:"text-[13px] shrink-0",title:"manual",children:"✋"}):e==="on-reset"||e==="auto-soon"?c.jsx("span",{className:"text-[13px] shrink-0",title:"auto",children:"⏰"}):e==="auto-throttled"?c.jsx("span",{className:"text-[13px] shrink-0",title:"throttled",children:"⏳"}):c.jsx("span",{className:"w-2 h-2 rounded-full bg-fg-faint/40 shrink-0"})}function twe(e){return e==="running"?"bg-amber-400/10 border-amber-400/25":e==="paused"?"bg-amber-500/10 border-amber-500/25":e==="auto-throttled"?"bg-amber-500/5 border-amber-500/15":"bg-bg-elev border-line"}function rwe(e,r,n,i,s,a){if(e.status!=="pending"||s==="paused"||s==="manual"||s==="auto-throttled")return null;let l=n*i;if(n>0){const o=r.find(u=>u.status==="running"&&u.startedAt);o&&o.startedAt&&(l-=Math.min(i,a-Date.parse(o.startedAt)))}return l<=5e3?"~now":`~${ny(l)}`}function nwe({job:e,eta:r,now:n,avgDurationMs:i,listIndex:s}){const[a,l]=D.useState(!1),[o,u]=D.useState(!1),f=e.status==="running",m=e.status==="failed";let h=null;f&&e.startedAt?h=`${k0(n-Date.parse(e.startedAt))} elapsed`:e.status==="completed"&&e.startedAt&&e.finishedAt?h=`took ${ny(Date.parse(e.finishedAt)-Date.parse(e.startedAt))}`:r&&(h=r);const y=e.error??null,x=m&&y?y.split(`
|