claude-code-session-manager 0.35.17 → 0.35.18

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.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./TiptapBody-BM9Kz1Nm.js","./monaco-editor-BW5C4Iv1.js","./monaco-editor-BTnBOi8r.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./TiptapBody-DgFO_m3g.js","./monaco-editor-BW5C4Iv1.js","./monaco-editor-BTnBOi8r.css"])))=>i.map(i=>d[i]);
2
2
  var uW=Object.defineProperty;var dW=(e,r,n)=>r in e?uW(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n;var Xr=(e,r,n)=>dW(e,typeof r!="symbol"?r+"":r,n);import{_ as ab}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 c of a.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&i(c)}).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 _x=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Zr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var _1={exports:{}},nv={},S1={exports:{}},yr={};/**
3
3
  * @license React
4
4
  * react.production.min.js
@@ -38,7 +38,7 @@ var uW=Object.defineProperty;var dW=(e,r,n)=>r in e?uW(e,r,{enumerable:!0,config
38
38
  `+V[he].replace(" at new "," at ");return p.displayName&&Re.includes("<anonymous>")&&(Re=Re.replace("<anonymous>",p.displayName)),Re}while(1<=he&&0<=ke);break}}}finally{oe=!1,Error.prepareStackTrace=A}return(p=p?p.displayName||p.name:"")?ae(p):""}function ve(p){switch(p.tag){case 5:return ae(p.type);case 16:return ae("Lazy");case 13:return ae("Suspense");case 19:return ae("SuspenseList");case 0:case 2:case 15:return p=de(p.type,!1),p;case 11:return p=de(p.type.render,!1),p;case 1:return p=de(p.type,!0),p;default:return""}}function $e(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 N:return"Fragment";case $:return"Portal";case I:return"Profiler";case P:return"StrictMode";case q:return"Suspense";case z:return"SuspenseList"}if(typeof p=="object")switch(p.$$typeof){case F:return(p.displayName||"Context")+".Consumer";case W:return(p._context.displayName||"Context")+".Provider";case U:var v=p.render;return p=p.displayName,p||(p=v.displayName||v.name||"",p=p!==""?"ForwardRef("+p+")":"ForwardRef"),p;case Y:return v=p.displayName||null,v!==null?v:$e(p.type)||"Memo";case ee:v=p._payload,p=p._init;try{return $e(p(v))}catch{}}return null}function we(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 $e(v);case 8:return v===P?"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 ne(p){switch(typeof p){case"boolean":case"number":case"string":case"undefined":return p;case"object":return p;default:return""}}function ce(p){var v=p.type;return(p=p.nodeName)&&p.toLowerCase()==="input"&&(v==="checkbox"||v==="radio")}function ge(p){var v=ce(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 V=A.get,J=A.set;return Object.defineProperty(p,v,{configurable:!0,get:function(){return V.call(this)},set:function(he){M=""+he,J.call(this,he)}}),Object.defineProperty(p,v,{enumerable:A.enumerable}),{getValue:function(){return M},setValue:function(he){M=""+he},stopTracking:function(){p._valueTracker=null,delete p[v]}}}}function Ae(p){p._valueTracker||(p._valueTracker=ge(p))}function Te(p){if(!p)return!1;var v=p._valueTracker;if(!v)return!0;var A=v.getValue(),M="";return p&&(M=ce(p)?p.checked?"true":"false":p.value),p=M,p!==A?(v.setValue(p),!0):!1}function nt(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 ct(p,v){var A=v.checked;return Q({},v,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:A??p._wrapperState.initialChecked})}function Le(p,v){var A=v.defaultValue==null?"":v.defaultValue,M=v.checked!=null?v.checked:v.defaultChecked;A=ne(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 Me(p,v){v=v.checked,v!=null&&C(p,"checked",v,!1)}function Ue(p,v){Me(p,v);var A=ne(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")?jt(p,v.type,A):v.hasOwnProperty("defaultValue")&&jt(p,v.type,ne(v.defaultValue)),v.checked==null&&v.defaultChecked!=null&&(p.defaultChecked=!!v.defaultChecked)}function mt(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 jt(p,v,A){(v!=="number"||nt(p.ownerDocument)!==p)&&(A==null?p.defaultValue=""+p._wrapperState.initialValue:p.defaultValue!==""+A&&(p.defaultValue=""+A))}var er=Array.isArray;function Yt(p,v,A,M){if(p=p.options,v){v={};for(var V=0;V<A.length;V++)v["$"+A[V]]=!0;for(A=0;A<p.length;A++)V=v.hasOwnProperty("$"+p[A].value),p[A].selected!==V&&(p[A].selected=V),V&&M&&(p[A].defaultSelected=!0)}else{for(A=""+ne(A),v=null,V=0;V<p.length;V++){if(p[V].value===A){p[V].selected=!0,M&&(p[V].defaultSelected=!0);return}v!==null||p[V].disabled||(v=p[V])}v!==null&&(v.selected=!0)}}function mr(p,v){if(v.dangerouslySetInnerHTML!=null)throw Error(n(91));return Q({},v,{value:void 0,defaultValue:void 0,children:""+p._wrapperState.initialValue})}function ur(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(er(A)){if(1<A.length)throw Error(n(93));A=A[0]}v=A}v==null&&(v=""),A=v}p._wrapperState={initialValue:ne(A)}}function Qr(p,v){var A=ne(v.value),M=ne(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 Pr(p){var v=p.textContent;v===p._wrapperState.initialValue&&v!==""&&v!==null&&(p.value=v)}function di(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 Yn(p,v){return p==null||p==="http://www.w3.org/1999/xhtml"?di(v):p==="http://www.w3.org/2000/svg"&&v==="foreignObject"?"http://www.w3.org/1999/xhtml":p}var lt,Ct=(function(p){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(v,A,M,V){MSApp.execUnsafeLocalFunction(function(){return p(v,A,M,V)})}:p})(function(p,v){if(p.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in p)p.innerHTML=v;else{for(lt=lt||document.createElement("div"),lt.innerHTML="<svg>"+v.valueOf().toString()+"</svg>",v=lt.firstChild;p.firstChild;)p.removeChild(p.firstChild);for(;v.firstChild;)p.appendChild(v.firstChild)}});function Pt(p,v){if(v){var A=p.firstChild;if(A&&A===p.lastChild&&A.nodeType===3){A.nodeValue=v;return}}p.textContent=v}var fr={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},ar=["Webkit","ms","Moz","O"];Object.keys(fr).forEach(function(p){ar.forEach(function(v){v=v+p.charAt(0).toUpperCase()+p.substring(1),fr[v]=fr[p]})});function Jn(p,v,A){return v==null||typeof v=="boolean"||v===""?"":A||typeof v!="number"||v===0||fr.hasOwnProperty(p)&&fr[p]?(""+v).trim():v+"px"}function Tl(p,v){p=p.style;for(var A in v)if(v.hasOwnProperty(A)){var M=A.indexOf("--")===0,V=Jn(A,v[A],M);A==="float"&&(A="cssFloat"),M?p.setProperty(A,V):p[A]=V}}var Uo=Q({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 Js(p,v){if(v){if(Uo[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 kr(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 fi=null;function mn(p){return p=p.target||p.srcElement||window,p.correspondingUseElement&&(p=p.correspondingUseElement),p.nodeType===3?p.parentNode:p}var Zs=null,us=null,Ri=null;function ka(p){if(p=Uc(p)){if(typeof Zs!="function")throw Error(n(280));var v=p.stateNode;v&&(v=nd(v),Zs(p.stateNode,p.type,v))}}function Qs(p){us?Ri?Ri.push(p):Ri=[p]:us=p}function ea(){if(us){var p=us,v=Ri;if(Ri=us=null,ka(p),v)for(p=0;p<v.length;p++)ka(v[p])}}function ds(p,v){return p(v)}function Zn(){}var hi=!1;function As(p,v,A){if(hi)return p(v,A);hi=!0;try{return ds(p,v,A)}finally{hi=!1,(us!==null||Ri!==null)&&(Zn(),ea())}}function Qn(p,v){var A=p.stateNode;if(A===null)return null;var M=nd(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 Mi=!1;if(l)try{var ts={};Object.defineProperty(ts,"passive",{get:function(){Mi=!0}}),window.addEventListener("test",ts,ts),window.removeEventListener("test",ts,ts)}catch{Mi=!1}function eo(p,v,A,M,V,J,he,ke,Re){var Xe=Array.prototype.slice.call(arguments,3);try{v.apply(A,Xe)}catch(ft){this.onError(ft)}}var $s=!1,Ns=null,Os=!1,Ut=null,pi={onError:function(p){$s=!0,Ns=p}};function en(p,v,A,M,V,J,he,ke,Re){$s=!1,Ns=null,eo.apply(pi,arguments)}function Tr(p,v,A,M,V,J,he,ke,Re){if(en.apply(this,arguments),$s){if($s){var Xe=Ns;$s=!1,Ns=null}else throw Error(n(198));Os||(Os=!0,Ut=Xe)}}function Et(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 Ca(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 to(p){if(Et(p)!==p)throw Error(n(188))}function Al(p){var v=p.alternate;if(!v){if(v=Et(p),v===null)throw Error(n(188));return v!==p?null:p}for(var A=p,M=v;;){var V=A.return;if(V===null)break;var J=V.alternate;if(J===null){if(M=V.return,M!==null){A=M;continue}break}if(V.child===J.child){for(J=V.child;J;){if(J===A)return to(V),p;if(J===M)return to(V),v;J=J.sibling}throw Error(n(188))}if(A.return!==M.return)A=V,M=J;else{for(var he=!1,ke=V.child;ke;){if(ke===A){he=!0,A=V,M=J;break}if(ke===M){he=!0,M=V,A=J;break}ke=ke.sibling}if(!he){for(ke=J.child;ke;){if(ke===A){he=!0,A=J,M=V;break}if(ke===M){he=!0,M=J,A=V;break}ke=ke.sibling}if(!he)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 ro(p){return p=Al(p),p!==null?no(p):null}function no(p){if(p.tag===5||p.tag===6)return p;for(p=p.child;p!==null;){var v=no(p);if(v!==null)return v;p=p.sibling}return null}var Wo=r.unstable_scheduleCallback,Wn=r.unstable_cancelCallback,$l=r.unstable_shouldYield,Nl=r.unstable_requestPaint,Ar=r.unstable_now,ei=r.unstable_getCurrentPriorityLevel,sn=r.unstable_ImmediatePriority,ti=r.unstable_UserBlockingPriority,Ps=r.unstable_NormalPriority,ja=r.unstable_LowPriority,ta=r.unstable_IdlePriority,Ii=null,Rn=null;function Wt(p){if(Rn&&typeof Rn.onCommitFiberRoot=="function")try{Rn.onCommitFiberRoot(Ii,p,void 0,(p.current.flags&128)===128)}catch{}}var an=Math.clz32?Math.clz32:qo,ra=Math.log,Di=Math.LN2;function qo(p){return p>>>=0,p===0?32:31-(ra(p)/Di|0)|0}var na=64,mi=4194304;function fs(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 ia(p,v){var A=p.pendingLanes;if(A===0)return 0;var M=0,V=p.suspendedLanes,J=p.pingedLanes,he=A&268435455;if(he!==0){var ke=he&~V;ke!==0?M=fs(ke):(J&=he,J!==0&&(M=fs(J)))}else he=A&~V,he!==0?M=fs(he):J!==0&&(M=fs(J));if(M===0)return 0;if(v!==0&&v!==M&&(v&V)===0&&(V=M&-M,J=v&-v,V>=J||V===16&&(J&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-an(v),V=1<<A,M|=p[A],v&=~V;return M}function cr(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 Li(p,v){for(var A=p.suspendedLanes,M=p.pingedLanes,V=p.expirationTimes,J=p.pendingLanes;0<J;){var he=31-an(J),ke=1<<he,Re=V[he];Re===-1?((ke&A)===0||(ke&M)!==0)&&(V[he]=cr(ke,v)):Re<=v&&(p.expiredLanes|=ke),J&=~ke}}function Ea(p){return p=p.pendingLanes&-1073741825,p!==0?p:p&1073741824?1073741824:0}function rs(){var p=na;return na<<=1,(na&4194240)===0&&(na=64),p}function Qe(p){for(var v=[],A=0;31>A;A++)v.push(p);return v}function gi(p,v,A){p.pendingLanes|=v,v!==536870912&&(p.suspendedLanes=0,p.pingedLanes=0),p=p.eventTimes,v=31-an(v),p[v]=A}function yt(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 V=31-an(A),J=1<<V;v[V]=0,M[V]=-1,p[V]=-1,A&=~J}}function Se(p,v){var A=p.entangledLanes|=v;for(p=p.entanglements;A;){var M=31-an(A),V=1<<M;V&v|p[M]&v&&(p[M]|=v),A&=~V}}var ze=0;function tt(p){return p&=-p,1<p?4<p?(p&268435455)!==0?16:536870912:4:1}var At,ir,dr,Br,Dr,gn=!1,Vr=[],wn=null,Lr=null,hs=null,Ta=new Map,io=new Map,Rs=[],Ef="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":wn=null;break;case"dragenter":case"dragleave":Lr=null;break;case"mouseover":case"mouseout":hs=null;break;case"pointerover":case"pointerout":Ta.delete(v.pointerId);break;case"gotpointercapture":case"lostpointercapture":io.delete(v.pointerId)}}function ao(p,v,A,M,V,J){return p===null||p.nativeEvent!==J?(p={blockedOn:v,domEventName:A,eventSystemFlags:M,nativeEvent:J,targetContainers:[V]},v!==null&&(v=Uc(v),v!==null&&ir(v)),p):(p.eventSystemFlags|=M,v=p.targetContainers,V!==null&&v.indexOf(V)===-1&&v.push(V),p)}function Fu(p,v,A,M,V){switch(v){case"focusin":return wn=ao(wn,p,v,A,M,V),!0;case"dragenter":return Lr=ao(Lr,p,v,A,M,V),!0;case"mouseover":return hs=ao(hs,p,v,A,M,V),!0;case"pointerover":var J=V.pointerId;return Ta.set(J,ao(Ta.get(J)||null,p,v,A,M,V)),!0;case"gotpointercapture":return J=V.pointerId,io.set(J,ao(io.get(J)||null,p,v,A,M,V)),!0}return!1}function Ec(p){var v=Go(p.target);if(v!==null){var A=Et(v);if(A!==null){if(v=A.tag,v===13){if(v=Ca(A),v!==null){p.blockedOn=v,Dr(p.priority,function(){dr(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=ie(p.domEventName,p.eventSystemFlags,v[0],p.nativeEvent);if(A===null){A=p.nativeEvent;var M=new A.constructor(A.type,A);fi=M,A.target.dispatchEvent(M),fi=null}else return v=Uc(A),v!==null&&ir(v),p.blockedOn=A,!1;v.shift()}return!0}function Ol(p,v,A){oo(p)&&A.delete(v)}function Tc(){gn=!1,wn!==null&&oo(wn)&&(wn=null),Lr!==null&&oo(Lr)&&(Lr=null),hs!==null&&oo(hs)&&(hs=null),Ta.forEach(Ol),io.forEach(Ol)}function sa(p,v){p.blockedOn===v&&(p.blockedOn=null,gn||(gn=!0,r.unstable_scheduleCallback(r.unstable_NormalPriority,Tc)))}function Aa(p){function v(V){return sa(V,p)}if(0<Vr.length){sa(Vr[0],p);for(var A=1;A<Vr.length;A++){var M=Vr[A];M.blockedOn===p&&(M.blockedOn=null)}}for(wn!==null&&sa(wn,p),Lr!==null&&sa(Lr,p),hs!==null&&sa(hs,p),Ta.forEach(v),io.forEach(v),A=0;A<Rs.length;A++)M=Rs[A],M.blockedOn===p&&(M.blockedOn=null);for(;0<Rs.length&&(A=Rs[0],A.blockedOn===null);)Ec(A),A.blockedOn===null&&Rs.shift()}var aa=T.ReactCurrentBatchConfig,lo=!0;function Uu(p,v,A,M){var V=ze,J=aa.transition;aa.transition=null;try{ze=1,Ac(p,v,A,M)}finally{ze=V,aa.transition=J}}function Wu(p,v,A,M){var V=ze,J=aa.transition;aa.transition=null;try{ze=4,Ac(p,v,A,M)}finally{ze=V,aa.transition=J}}function Ac(p,v,A,M){if(lo){var V=ie(p,v,A,M);if(V===null)Ff(p,v,M,$c,A),so(p,M);else if(Fu(V,p,v,A,M))M.stopPropagation();else if(so(p,M),v&4&&-1<Ef.indexOf(p)){for(;V!==null;){var J=Uc(V);if(J!==null&&At(J),J=ie(p,v,A,M),J===null&&Ff(p,v,M,$c,A),J===V)break;V=J}V!==null&&M.stopPropagation()}else Ff(p,v,M,null,A)}}var $c=null;function ie(p,v,A,M){if($c=null,p=mn(M),p=Go(p),p!==null)if(v=Et(p),v===null)p=null;else if(A=v.tag,A===13){if(p=Ca(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 $c=p,null}function me(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(ei()){case sn:return 1;case ti:return 4;case Ps:case ja:return 16;case ta:return 536870912;default:return 16}default:return 16}}var _e=null,Pe=null,je=null;function qe(){if(je)return je;var p,v=Pe,A=v.length,M,V="value"in _e?_e.value:_e.textContent,J=V.length;for(p=0;p<A&&v[p]===V[p];p++);var he=A-p;for(M=1;M<=he&&v[A-M]===V[J-M];M++);return je=V.slice(p,1<M?1-M:void 0)}function Ie(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 De(){return!0}function Ve(){return!1}function it(p){function v(A,M,V,J,he){this._reactName=A,this._targetInst=V,this.type=M,this.nativeEvent=J,this.target=he,this.currentTarget=null;for(var ke in p)p.hasOwnProperty(ke)&&(A=p[ke],this[ke]=A?A(J):J[ke]);return this.isDefaultPrevented=(J.defaultPrevented!=null?J.defaultPrevented:J.returnValue===!1)?De:Ve,this.isPropagationStopped=Ve,this}return Q(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=De)},stopPropagation:function(){var A=this.nativeEvent;A&&(A.stopPropagation?A.stopPropagation():typeof A.cancelBubble!="unknown"&&(A.cancelBubble=!0),this.isPropagationStopped=De)},persist:function(){},isPersistent:De}),v}var ut={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(p){return p.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},st=it(ut),et=Q({},ut,{view:0,detail:0}),Ot=it(et),We,pt,Rr,tr=Q({},et,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:hr,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!==Rr&&(Rr&&p.type==="mousemove"?(We=p.screenX-Rr.screenX,pt=p.screenY-Rr.screenY):pt=We=0,Rr=p),We)},movementY:function(p){return"movementY"in p?p.movementY:pt}}),rr=it(tr),Mr=Q({},tr,{dataTransfer:0}),zt=it(Mr),Ur=Q({},et,{relatedTarget:0}),gr=it(Ur),Mn=Q({},ut,{animationName:0,elapsedTime:0,pseudoElement:0}),ri=it(Mn),vi=Q({},ut,{clipboardData:function(p){return"clipboardData"in p?p.clipboardData:window.clipboardData}}),Pl=it(vi),yi=Q({},ut,{data:0}),Nc=it(yi),qu={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},In={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"},Ms={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Hu(p){var v=this.nativeEvent;return v.getModifierState?v.getModifierState(p):(p=Ms[p])?!!v[p]:!1}function hr(){return Hu}var ps=Q({},et,{key:function(p){if(p.key){var v=qu[p.key]||p.key;if(v!=="Unidentified")return v}return p.type==="keypress"?(p=Ie(p),p===13?"Enter":String.fromCharCode(p)):p.type==="keydown"||p.type==="keyup"?In[p.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:hr,charCode:function(p){return p.type==="keypress"?Ie(p):0},keyCode:function(p){return p.type==="keydown"||p.type==="keyup"?p.keyCode:0},which:function(p){return p.type==="keypress"?Ie(p):p.type==="keydown"||p.type==="keyup"?p.keyCode:0}}),Tf=it(ps),oa=Q({},tr,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ho=it(oa),_n=Q({},et,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:hr}),bi=it(_n),Oc=Q({},ut,{propertyName:0,elapsedTime:0,pseudoElement:0}),xi=it(Oc),Vu=Q({},tr,{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}),Af=it(Vu),la=[9,13,27,32],ms=l&&"CompositionEvent"in window,Is=null;l&&"documentMode"in document&&(Is=document.documentMode);var Sn=l&&"TextEvent"in window&&!Is,tn=l&&(!ms||Is&&8<Is&&11>=Is),gs=" ",Gu=!1;function Ku(p,v){switch(p){case"keyup":return la.indexOf(v.keyCode)!==-1;case"keydown":return v.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Cb(p){return p=p.detail,typeof p=="object"&&"data"in p?p.data:null}var wi=!1;function jb(p,v){switch(p){case"compositionend":return Cb(v);case"keypress":return v.which!==32?null:(Gu=!0,gs);case"textInput":return p=v.data,p===gs&&Gu?null:p;default:return null}}function $f(p,v){if(wi)return p==="compositionend"||!ms&&Ku(p,v)?(p=qe(),je=Pe=_e=null,wi=!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 tn&&v.locale!=="ko"?null:v.data;default:return null}}var km={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 Ds(p){var v=p&&p.nodeName&&p.nodeName.toLowerCase();return v==="input"?!!km[p.type]:v==="textarea"}function Cm(p,v,A,M){Qs(M),v=Zu(v,"onChange"),0<v.length&&(A=new st("onChange","change",null,A,M),p.push({event:A,listeners:v}))}var Pc=null,Rc=null;function Eb(p){Fm(p,0)}function Xu(p){var v=Il(p);if(Te(v))return p}function Tb(p,v){if(p==="change")return v}var jm=!1;if(l){var Nf;if(l){var Of="oninput"in document;if(!Of){var Em=document.createElement("div");Em.setAttribute("oninput","return;"),Of=typeof Em.oninput=="function"}Nf=Of}else Nf=!1;jm=Nf&&(!document.documentMode||9<document.documentMode)}function Ls(){Pc&&(Pc.detachEvent("onpropertychange",Tm),Rc=Pc=null)}function Tm(p){if(p.propertyName==="value"&&Xu(Rc)){var v=[];Cm(v,Rc,p,mn(p)),As(Eb,v)}}function Ab(p,v,A){p==="focusin"?(Ls(),Pc=v,Rc=A,Pc.attachEvent("onpropertychange",Tm)):p==="focusout"&&Ls()}function $b(p){if(p==="selectionchange"||p==="keyup"||p==="keydown")return Xu(Rc)}function Nb(p,v){if(p==="click")return Xu(v)}function Ob(p,v){if(p==="input"||p==="change")return Xu(v)}function Pb(p,v){return p===v&&(p!==0||1/p===1/v)||p!==p&&v!==v}var Bs=typeof Object.is=="function"?Object.is:Pb;function Mc(p,v){if(Bs(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 V=A[M];if(!u.call(v,V)||!Bs(p[V],v[V]))return!1}return!0}function Am(p){for(;p&&p.firstChild;)p=p.firstChild;return p}function $m(p,v){var A=Am(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=Am(A)}}function Pf(p,v){return p&&v?p===v?!0:p&&p.nodeType===3?!1:v&&v.nodeType===3?Pf(p,v.parentNode):"contains"in p?p.contains(v):p.compareDocumentPosition?!!(p.compareDocumentPosition(v)&16):!1:!1}function Rf(){for(var p=window,v=nt();v instanceof p.HTMLIFrameElement;){try{var A=typeof v.contentWindow.location.href=="string"}catch{A=!1}if(A)p=v.contentWindow;else break;v=nt(p.document)}return v}function Mf(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 Rb(p){var v=Rf(),A=p.focusedElem,M=p.selectionRange;if(v!==A&&A&&A.ownerDocument&&Pf(A.ownerDocument.documentElement,A)){if(M!==null&&Mf(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 V=A.textContent.length,J=Math.min(M.start,V);M=M.end===void 0?J:Math.min(M.end,V),!p.extend&&J>M&&(V=M,M=J,J=V),V=$m(A,J);var he=$m(A,M);V&&he&&(p.rangeCount!==1||p.anchorNode!==V.node||p.anchorOffset!==V.offset||p.focusNode!==he.node||p.focusOffset!==he.offset)&&(v=v.createRange(),v.setStart(V.node,V.offset),p.removeAllRanges(),J>M?(p.addRange(v),p.extend(he.node,he.offset)):(v.setEnd(he.node,he.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 Nm=l&&"documentMode"in document&&11>=document.documentMode,Ic=null,If=null,Vo=null,Df=!1;function Om(p,v,A){var M=A.window===A?A.document:A.nodeType===9?A:A.ownerDocument;Df||Ic==null||Ic!==nt(M)||(M=Ic,"selectionStart"in M&&Mf(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}),Vo&&Mc(Vo,M)||(Vo=M,M=Zu(If,"onSelect"),0<M.length&&(v=new st("onSelect","select",null,v,A),p.push({event:v,listeners:M}),v.target=Ic)))}function Yu(p,v){var A={};return A[p.toLowerCase()]=v.toLowerCase(),A["Webkit"+p]="webkit"+v,A["Moz"+p]="moz"+v,A}var $a={animationend:Yu("Animation","AnimationEnd"),animationiteration:Yu("Animation","AnimationIteration"),animationstart:Yu("Animation","AnimationStart"),transitionend:Yu("Transition","TransitionEnd")},Lf={},Pm={};l&&(Pm=document.createElement("div").style,"AnimationEvent"in window||(delete $a.animationend.animation,delete $a.animationiteration.animation,delete $a.animationstart.animation),"TransitionEvent"in window||delete $a.transitionend.transition);function Dc(p){if(Lf[p])return Lf[p];if(!$a[p])return p;var v=$a[p],A;for(A in v)if(v.hasOwnProperty(A)&&A in Pm)return Lf[p]=v[A];return p}var Rm=Dc("animationend"),Mm=Dc("animationiteration"),Im=Dc("animationstart"),Dm=Dc("transitionend"),Mb=new Map,Lm="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){Mb.set(p,v),a(v,[p])}for(var Bf=0;Bf<Lm.length;Bf++){var Bm=Lm[Bf],Ib=Bm.toLowerCase(),xr=Bm[0].toUpperCase()+Bm.slice(1);co(Ib,"on"+xr)}co(Rm,"onAnimationEnd"),co(Mm,"onAnimationIteration"),co(Im,"onAnimationStart"),co("dblclick","onDoubleClick"),co("focusin","onFocus"),co("focusout","onBlur"),co(Dm,"onTransitionEnd"),c("onMouseEnter",["mouseout","mouseover"]),c("onMouseLeave",["mouseout","mouseover"]),c("onPointerEnter",["pointerout","pointerover"]),c("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 Lc="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(" "),Db=new Set("cancel close invalid load scroll toggle".split(" ").concat(Lc));function zm(p,v,A){var M=p.type||"unknown-event";p.currentTarget=A,Tr(M,v,void 0,p),p.currentTarget=null}function Fm(p,v){v=(v&4)!==0;for(var A=0;A<p.length;A++){var M=p[A],V=M.event;M=M.listeners;e:{var J=void 0;if(v)for(var he=M.length-1;0<=he;he--){var ke=M[he],Re=ke.instance,Xe=ke.currentTarget;if(ke=ke.listener,Re!==J&&V.isPropagationStopped())break e;zm(V,ke,Xe),J=Re}else for(he=0;he<M.length;he++){if(ke=M[he],Re=ke.instance,Xe=ke.currentTarget,ke=ke.listener,Re!==J&&V.isPropagationStopped())break e;zm(V,ke,Xe),J=Re}}}if(Os)throw p=Ut,Os=!1,Ut=null,p}function Gr(p,v){var A=v[Gf];A===void 0&&(A=v[Gf]=new Set);var M=p+"__bubble";A.has(M)||(Um(v,p,2,!1),A.add(M))}function zf(p,v,A){var M=0;v&&(M|=4),Um(A,p,M,v)}var Ju="_reactListening"+Math.random().toString(36).slice(2);function Bc(p){if(!p[Ju]){p[Ju]=!0,i.forEach(function(A){A!=="selectionchange"&&(Db.has(A)||zf(A,!1,p),zf(A,!0,p))});var v=p.nodeType===9?p:p.ownerDocument;v===null||v[Ju]||(v[Ju]=!0,zf("selectionchange",!1,v))}}function Um(p,v,A,M){switch(me(v)){case 1:var V=Uu;break;case 4:V=Wu;break;default:V=Ac}A=V.bind(null,v,A,p),V=void 0,!Mi||v!=="touchstart"&&v!=="touchmove"&&v!=="wheel"||(V=!0),M?V!==void 0?p.addEventListener(v,A,{capture:!0,passive:V}):p.addEventListener(v,A,!0):V!==void 0?p.addEventListener(v,A,{passive:V}):p.addEventListener(v,A,!1)}function Ff(p,v,A,M,V){var J=M;if((v&1)===0&&(v&2)===0&&M!==null)e:for(;;){if(M===null)return;var he=M.tag;if(he===3||he===4){var ke=M.stateNode.containerInfo;if(ke===V||ke.nodeType===8&&ke.parentNode===V)break;if(he===4)for(he=M.return;he!==null;){var Re=he.tag;if((Re===3||Re===4)&&(Re=he.stateNode.containerInfo,Re===V||Re.nodeType===8&&Re.parentNode===V))return;he=he.return}for(;ke!==null;){if(he=Go(ke),he===null)return;if(Re=he.tag,Re===5||Re===6){M=J=he;continue e}ke=ke.parentNode}}M=M.return}As(function(){var Xe=J,ft=mn(A),ht=[];e:{var dt=Mb.get(p);if(dt!==void 0){var Tt=st,It=p;switch(p){case"keypress":if(Ie(A)===0)break e;case"keydown":case"keyup":Tt=Tf;break;case"focusin":It="focus",Tt=gr;break;case"focusout":It="blur",Tt=gr;break;case"beforeblur":case"afterblur":Tt=gr;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":Tt=rr;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Tt=zt;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Tt=bi;break;case Rm:case Mm:case Im:Tt=ri;break;case Dm:Tt=xi;break;case"scroll":Tt=Ot;break;case"wheel":Tt=Af;break;case"copy":case"cut":case"paste":Tt=Pl;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Tt=Ho}var Lt=(v&4)!==0,qr=!Lt&&p==="scroll",Ge=Lt?dt!==null?dt+"Capture":null:dt;Lt=[];for(var Be=Xe,Ye;Be!==null;){Ye=Be;var vt=Ye.stateNode;if(Ye.tag===5&&vt!==null&&(Ye=vt,Ge!==null&&(vt=Qn(Be,Ge),vt!=null&&Lt.push(zc(Be,vt,Ye)))),qr)break;Be=Be.return}0<Lt.length&&(dt=new Tt(dt,It,null,A,ft),ht.push({event:dt,listeners:Lt}))}}if((v&7)===0){e:{if(dt=p==="mouseover"||p==="pointerover",Tt=p==="mouseout"||p==="pointerout",dt&&A!==fi&&(It=A.relatedTarget||A.fromElement)&&(Go(It)||It[ua]))break e;if((Tt||dt)&&(dt=ft.window===ft?ft:(dt=ft.ownerDocument)?dt.defaultView||dt.parentWindow:window,Tt?(It=A.relatedTarget||A.toElement,Tt=Xe,It=It?Go(It):null,It!==null&&(qr=Et(It),It!==qr||It.tag!==5&&It.tag!==6)&&(It=null)):(Tt=null,It=Xe),Tt!==It)){if(Lt=rr,vt="onMouseLeave",Ge="onMouseEnter",Be="mouse",(p==="pointerout"||p==="pointerover")&&(Lt=Ho,vt="onPointerLeave",Ge="onPointerEnter",Be="pointer"),qr=Tt==null?dt:Il(Tt),Ye=It==null?dt:Il(It),dt=new Lt(vt,Be+"leave",Tt,A,ft),dt.target=qr,dt.relatedTarget=Ye,vt=null,Go(ft)===Xe&&(Lt=new Lt(Ge,Be+"enter",It,A,ft),Lt.target=Ye,Lt.relatedTarget=qr,vt=Lt),qr=vt,Tt&&It)t:{for(Lt=Tt,Ge=It,Be=0,Ye=Lt;Ye;Ye=Rl(Ye))Be++;for(Ye=0,vt=Ge;vt;vt=Rl(vt))Ye++;for(;0<Be-Ye;)Lt=Rl(Lt),Be--;for(;0<Ye-Be;)Ge=Rl(Ge),Ye--;for(;Be--;){if(Lt===Ge||Ge!==null&&Lt===Ge.alternate)break t;Lt=Rl(Lt),Ge=Rl(Ge)}Lt=null}else Lt=null;Tt!==null&&Wm(ht,dt,Tt,Lt,!1),It!==null&&qr!==null&&Wm(ht,qr,It,Lt,!0)}}e:{if(dt=Xe?Il(Xe):window,Tt=dt.nodeName&&dt.nodeName.toLowerCase(),Tt==="select"||Tt==="input"&&dt.type==="file")var qt=Tb;else if(Ds(dt))if(jm)qt=Ob;else{qt=$b;var Zt=Ab}else(Tt=dt.nodeName)&&Tt.toLowerCase()==="input"&&(dt.type==="checkbox"||dt.type==="radio")&&(qt=Nb);if(qt&&(qt=qt(p,Xe))){Cm(ht,qt,A,ft);break e}Zt&&Zt(p,dt,Xe),p==="focusout"&&(Zt=dt._wrapperState)&&Zt.controlled&&dt.type==="number"&&jt(dt,"number",dt.value)}switch(Zt=Xe?Il(Xe):window,p){case"focusin":(Ds(Zt)||Zt.contentEditable==="true")&&(Ic=Zt,If=Xe,Vo=null);break;case"focusout":Vo=If=Ic=null;break;case"mousedown":Df=!0;break;case"contextmenu":case"mouseup":case"dragend":Df=!1,Om(ht,A,ft);break;case"selectionchange":if(Nm)break;case"keydown":case"keyup":Om(ht,A,ft)}var Qt;if(ms)e:{switch(p){case"compositionstart":var or="onCompositionStart";break e;case"compositionend":or="onCompositionEnd";break e;case"compositionupdate":or="onCompositionUpdate";break e}or=void 0}else wi?Ku(p,A)&&(or="onCompositionEnd"):p==="keydown"&&A.keyCode===229&&(or="onCompositionStart");or&&(tn&&A.locale!=="ko"&&(wi||or!=="onCompositionStart"?or==="onCompositionEnd"&&wi&&(Qt=qe()):(_e=ft,Pe="value"in _e?_e.value:_e.textContent,wi=!0)),Zt=Zu(Xe,or),0<Zt.length&&(or=new Nc(or,p,null,A,ft),ht.push({event:or,listeners:Zt}),Qt?or.data=Qt:(Qt=Cb(A),Qt!==null&&(or.data=Qt)))),(Qt=Sn?jb(p,A):$f(p,A))&&(Xe=Zu(Xe,"onBeforeInput"),0<Xe.length&&(ft=new Nc("onBeforeInput","beforeinput",null,A,ft),ht.push({event:ft,listeners:Xe}),ft.data=Qt))}Fm(ht,v)})}function zc(p,v,A){return{instance:p,listener:v,currentTarget:A}}function Zu(p,v){for(var A=v+"Capture",M=[];p!==null;){var V=p,J=V.stateNode;V.tag===5&&J!==null&&(V=J,J=Qn(p,A),J!=null&&M.unshift(zc(p,J,V)),J=Qn(p,v),J!=null&&M.push(zc(p,J,V))),p=p.return}return M}function Rl(p){if(p===null)return null;do p=p.return;while(p&&p.tag!==5);return p||null}function Wm(p,v,A,M,V){for(var J=v._reactName,he=[];A!==null&&A!==M;){var ke=A,Re=ke.alternate,Xe=ke.stateNode;if(Re!==null&&Re===M)break;ke.tag===5&&Xe!==null&&(ke=Xe,V?(Re=Qn(A,J),Re!=null&&he.unshift(zc(A,Re,ke))):V||(Re=Qn(A,J),Re!=null&&he.push(zc(A,Re,ke)))),A=A.return}he.length!==0&&p.push({event:v,listeners:he})}var Qu=/\r\n?/g,Lb=/\u0000|\uFFFD/g;function ed(p){return(typeof p=="string"?p:""+p).replace(Qu,`
39
39
  `).replace(Lb,"")}function td(p,v,A){if(v=ed(v),ed(p)!==v&&A)throw Error(n(425))}function rd(){}var Uf=null,Wf=null;function qf(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 Hf=typeof setTimeout=="function"?setTimeout:void 0,Bb=typeof clearTimeout=="function"?clearTimeout:void 0,qm=typeof Promise=="function"?Promise:void 0,zb=typeof queueMicrotask=="function"?queueMicrotask:typeof qm<"u"?function(p){return qm.resolve(null).then(p).catch(Fb)}:Hf;function Fb(p){setTimeout(function(){throw p})}function Vf(p,v){var A=v,M=0;do{var V=A.nextSibling;if(p.removeChild(A),V&&V.nodeType===8)if(A=V.data,A==="/$"){if(M===0){p.removeChild(V),Aa(v);return}M--}else A!=="$"&&A!=="$?"&&A!=="$!"||M++;A=V}while(A);Aa(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 Hm(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 Ml=Math.random().toString(36).slice(2),ca="__reactFiber$"+Ml,Fc="__reactProps$"+Ml,ua="__reactContainer$"+Ml,Gf="__reactEvents$"+Ml,Vm="__reactListeners$"+Ml,Gm="__reactHandles$"+Ml;function Go(p){var v=p[ca];if(v)return v;for(var A=p.parentNode;A;){if(v=A[ua]||A[ca]){if(A=v.alternate,v.child!==null||A!==null&&A.child!==null)for(p=Hm(p);p!==null;){if(A=p[ca])return A;p=Hm(p)}return v}p=A,A=p.parentNode}return null}function Uc(p){return p=p[ca]||p[ua],!p||p.tag!==5&&p.tag!==6&&p.tag!==13&&p.tag!==3?null:p}function Il(p){if(p.tag===5||p.tag===6)return p.stateNode;throw Error(n(33))}function nd(p){return p[Fc]||null}var Kf=[],Dl=-1;function Na(p){return{current:p}}function Kr(p){0>Dl||(p.current=Kf[Dl],Kf[Dl]=null,Dl--)}function Wr(p,v){Dl++,Kf[Dl]=p.current,p.current=v}var fo={},_i=Na(fo),Bi=Na(!1),Ko=fo;function Si(p,v){var A=p.type.contextTypes;if(!A)return fo;var M=p.stateNode;if(M&&M.__reactInternalMemoizedUnmaskedChildContext===v)return M.__reactInternalMemoizedMaskedChildContext;var V={},J;for(J in A)V[J]=v[J];return M&&(p=p.stateNode,p.__reactInternalMemoizedUnmaskedChildContext=v,p.__reactInternalMemoizedMaskedChildContext=V),V}function zi(p){return p=p.childContextTypes,p!=null}function id(){Kr(Bi),Kr(_i)}function Km(p,v,A){if(_i.current!==fo)throw Error(n(168));Wr(_i,v),Wr(Bi,A)}function Xm(p,v,A){var M=p.stateNode;if(v=v.childContextTypes,typeof M.getChildContext!="function")return A;M=M.getChildContext();for(var V in M)if(!(V in v))throw Error(n(108,we(p)||"Unknown",V));return Q({},A,M)}function sd(p){return p=(p=p.stateNode)&&p.__reactInternalMemoizedMergedChildContext||fo,Ko=_i.current,Wr(_i,p),Wr(Bi,Bi.current),!0}function Ym(p,v,A){var M=p.stateNode;if(!M)throw Error(n(169));A?(p=Xm(p,v,Ko),M.__reactInternalMemoizedMergedChildContext=p,Kr(Bi),Kr(_i),Wr(_i,p)):Kr(Bi),Wr(Bi,A)}var Oa=null,ad=!1,Xf=!1;function Jm(p){Oa===null?Oa=[p]:Oa.push(p)}function f1(p){ad=!0,Jm(p)}function ho(){if(!Xf&&Oa!==null){Xf=!0;var p=0,v=ze;try{var A=Oa;for(ze=1;p<A.length;p++){var M=A[p];do M=M(!0);while(M!==null)}Oa=null,ad=!1}catch(V){throw Oa!==null&&(Oa=Oa.slice(p+1)),Wo(sn,ho),V}finally{ze=v,Xf=!1}}return null}var Ll=[],Bl=0,od=null,ld=0,vs=[],zs=0,ys=null,Fi=1,Ui="";function po(p,v){Ll[Bl++]=ld,Ll[Bl++]=od,od=p,ld=v}function Xo(p,v,A){vs[zs++]=Fi,vs[zs++]=Ui,vs[zs++]=ys,ys=p;var M=Fi;p=Ui;var V=32-an(M)-1;M&=~(1<<V),A+=1;var J=32-an(v)+V;if(30<J){var he=V-V%5;J=(M&(1<<he)-1).toString(32),M>>=he,V-=he,Fi=1<<32-an(v)+V|A<<V|M,Ui=J+p}else Fi=1<<J|A<<V|M,Ui=p}function En(p){p.return!==null&&(po(p,1),Xo(p,1,0))}function Yf(p){for(;p===od;)od=Ll[--Bl],Ll[Bl]=null,ld=Ll[--Bl],Ll[Bl]=null;for(;p===ys;)ys=vs[--zs],vs[zs]=null,Ui=vs[--zs],vs[zs]=null,Fi=vs[--zs],vs[zs]=null}var Wi=null,ns=null,on=!1,qi=null;function Jf(p,v){var A=ss(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 Zf(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,Wi=p,ns=uo(v.firstChild),!0):!1;case 6:return v=p.pendingProps===""||v.nodeType!==3?null:v,v!==null?(p.stateNode=v,Wi=p,ns=null,!0):!1;case 13:return v=v.nodeType!==8?null:v,v!==null?(A=ys!==null?{id:Fi,overflow:Ui}:null,p.memoizedState={dehydrated:v,treeContext:A,retryLane:1073741824},A=ss(18,null,null,0),A.stateNode=v,A.return=p,p.child=A,Wi=p,ns=null,!0):!1;default:return!1}}function Qf(p){return(p.mode&1)!==0&&(p.flags&128)===0}function eh(p){if(on){var v=ns;if(v){var A=v;if(!Zf(p,v)){if(Qf(p))throw Error(n(418));v=uo(A.nextSibling);var M=Wi;v&&Zf(p,v)?Jf(M,A):(p.flags=p.flags&-4097|2,on=!1,Wi=p)}}else{if(Qf(p))throw Error(n(418));p.flags=p.flags&-4097|2,on=!1,Wi=p}}}function th(p){for(p=p.return;p!==null&&p.tag!==5&&p.tag!==3&&p.tag!==13;)p=p.return;Wi=p}function Wc(p){if(p!==Wi)return!1;if(!on)return th(p),on=!0,!1;var v;if((v=p.tag!==3)&&!(v=p.tag!==5)&&(v=p.type,v=v!=="head"&&v!=="body"&&!qf(p.type,p.memoizedProps)),v&&(v=ns)){if(Qf(p))throw Zm(),Error(n(418));for(;v;)Jf(p,v),v=uo(v.nextSibling)}if(th(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){ns=uo(p.nextSibling);break e}v--}else A!=="$"&&A!=="$!"&&A!=="$?"||v++}p=p.nextSibling}ns=null}}else ns=Wi?uo(p.stateNode.nextSibling):null;return!0}function Zm(){for(var p=ns;p;)p=uo(p.nextSibling)}function Yo(){ns=Wi=null,on=!1}function rh(p){qi===null?qi=[p]:qi.push(p)}var nh=T.ReactCurrentBatchConfig;function zl(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 V=M,J=""+p;return v!==null&&v.ref!==null&&typeof v.ref=="function"&&v.ref._stringRef===J?v.ref:(v=function(he){var ke=V.refs;he===null?delete ke[J]:ke[J]=he},v._stringRef=J,v)}if(typeof p!="string")throw Error(n(284));if(!A._owner)throw Error(n(290,p))}return p}function cd(p,v){throw p=Object.prototype.toString.call(v),Error(n(31,p==="[object Object]"?"object with keys {"+Object.keys(v).join(", ")+"}":p))}function Qm(p){var v=p._init;return v(p._payload)}function Ub(p){function v(Ge,Be){if(p){var Ye=Ge.deletions;Ye===null?(Ge.deletions=[Be],Ge.flags|=16):Ye.push(Be)}}function A(Ge,Be){if(!p)return null;for(;Be!==null;)v(Ge,Be),Be=Be.sibling;return null}function M(Ge,Be){for(Ge=new Map;Be!==null;)Be.key!==null?Ge.set(Be.key,Be):Ge.set(Be.index,Be),Be=Be.sibling;return Ge}function V(Ge,Be){return Ge=_o(Ge,Be),Ge.index=0,Ge.sibling=null,Ge}function J(Ge,Be,Ye){return Ge.index=Ye,p?(Ye=Ge.alternate,Ye!==null?(Ye=Ye.index,Ye<Be?(Ge.flags|=2,Be):Ye):(Ge.flags|=2,Be)):(Ge.flags|=1048576,Be)}function he(Ge){return p&&Ge.alternate===null&&(Ge.flags|=2),Ge}function ke(Ge,Be,Ye,vt){return Be===null||Be.tag!==6?(Be=ep(Ye,Ge.mode,vt),Be.return=Ge,Be):(Be=V(Be,Ye),Be.return=Ge,Be)}function Re(Ge,Be,Ye,vt){var qt=Ye.type;return qt===N?ft(Ge,Be,Ye.props.children,vt,Ye.key):Be!==null&&(Be.elementType===qt||typeof qt=="object"&&qt!==null&&qt.$$typeof===ee&&Qm(qt)===Be.type)?(vt=V(Be,Ye.props),vt.ref=zl(Ge,Be,Ye),vt.return=Ge,vt):(vt=Nd(Ye.type,Ye.key,Ye.props,null,Ge.mode,vt),vt.ref=zl(Ge,Be,Ye),vt.return=Ge,vt)}function Xe(Ge,Be,Ye,vt){return Be===null||Be.tag!==4||Be.stateNode.containerInfo!==Ye.containerInfo||Be.stateNode.implementation!==Ye.implementation?(Be=tp(Ye,Ge.mode,vt),Be.return=Ge,Be):(Be=V(Be,Ye.children||[]),Be.return=Ge,Be)}function ft(Ge,Be,Ye,vt,qt){return Be===null||Be.tag!==7?(Be=Yl(Ye,Ge.mode,vt,qt),Be.return=Ge,Be):(Be=V(Be,Ye),Be.return=Ge,Be)}function ht(Ge,Be,Ye){if(typeof Be=="string"&&Be!==""||typeof Be=="number")return Be=ep(""+Be,Ge.mode,Ye),Be.return=Ge,Be;if(typeof Be=="object"&&Be!==null){switch(Be.$$typeof){case E:return Ye=Nd(Be.type,Be.key,Be.props,null,Ge.mode,Ye),Ye.ref=zl(Ge,null,Be),Ye.return=Ge,Ye;case $:return Be=tp(Be,Ge.mode,Ye),Be.return=Ge,Be;case ee:var vt=Be._init;return ht(Ge,vt(Be._payload),Ye)}if(er(Be)||X(Be))return Be=Yl(Be,Ge.mode,Ye,null),Be.return=Ge,Be;cd(Ge,Be)}return null}function dt(Ge,Be,Ye,vt){var qt=Be!==null?Be.key:null;if(typeof Ye=="string"&&Ye!==""||typeof Ye=="number")return qt!==null?null:ke(Ge,Be,""+Ye,vt);if(typeof Ye=="object"&&Ye!==null){switch(Ye.$$typeof){case E:return Ye.key===qt?Re(Ge,Be,Ye,vt):null;case $:return Ye.key===qt?Xe(Ge,Be,Ye,vt):null;case ee:return qt=Ye._init,dt(Ge,Be,qt(Ye._payload),vt)}if(er(Ye)||X(Ye))return qt!==null?null:ft(Ge,Be,Ye,vt,null);cd(Ge,Ye)}return null}function Tt(Ge,Be,Ye,vt,qt){if(typeof vt=="string"&&vt!==""||typeof vt=="number")return Ge=Ge.get(Ye)||null,ke(Be,Ge,""+vt,qt);if(typeof vt=="object"&&vt!==null){switch(vt.$$typeof){case E:return Ge=Ge.get(vt.key===null?Ye:vt.key)||null,Re(Be,Ge,vt,qt);case $:return Ge=Ge.get(vt.key===null?Ye:vt.key)||null,Xe(Be,Ge,vt,qt);case ee:var Zt=vt._init;return Tt(Ge,Be,Ye,Zt(vt._payload),qt)}if(er(vt)||X(vt))return Ge=Ge.get(Ye)||null,ft(Be,Ge,vt,qt,null);cd(Be,vt)}return null}function It(Ge,Be,Ye,vt){for(var qt=null,Zt=null,Qt=Be,or=Be=0,Bn=null;Qt!==null&&or<Ye.length;or++){Qt.index>or?(Bn=Qt,Qt=null):Bn=Qt.sibling;var Cr=dt(Ge,Qt,Ye[or],vt);if(Cr===null){Qt===null&&(Qt=Bn);break}p&&Qt&&Cr.alternate===null&&v(Ge,Qt),Be=J(Cr,Be,or),Zt===null?qt=Cr:Zt.sibling=Cr,Zt=Cr,Qt=Bn}if(or===Ye.length)return A(Ge,Qt),on&&po(Ge,or),qt;if(Qt===null){for(;or<Ye.length;or++)Qt=ht(Ge,Ye[or],vt),Qt!==null&&(Be=J(Qt,Be,or),Zt===null?qt=Qt:Zt.sibling=Qt,Zt=Qt);return on&&po(Ge,or),qt}for(Qt=M(Ge,Qt);or<Ye.length;or++)Bn=Tt(Qt,Ge,or,Ye[or],vt),Bn!==null&&(p&&Bn.alternate!==null&&Qt.delete(Bn.key===null?or:Bn.key),Be=J(Bn,Be,or),Zt===null?qt=Bn:Zt.sibling=Bn,Zt=Bn);return p&&Qt.forEach(function(Da){return v(Ge,Da)}),on&&po(Ge,or),qt}function Lt(Ge,Be,Ye,vt){var qt=X(Ye);if(typeof qt!="function")throw Error(n(150));if(Ye=qt.call(Ye),Ye==null)throw Error(n(151));for(var Zt=qt=null,Qt=Be,or=Be=0,Bn=null,Cr=Ye.next();Qt!==null&&!Cr.done;or++,Cr=Ye.next()){Qt.index>or?(Bn=Qt,Qt=null):Bn=Qt.sibling;var Da=dt(Ge,Qt,Cr.value,vt);if(Da===null){Qt===null&&(Qt=Bn);break}p&&Qt&&Da.alternate===null&&v(Ge,Qt),Be=J(Da,Be,or),Zt===null?qt=Da:Zt.sibling=Da,Zt=Da,Qt=Bn}if(Cr.done)return A(Ge,Qt),on&&po(Ge,or),qt;if(Qt===null){for(;!Cr.done;or++,Cr=Ye.next())Cr=ht(Ge,Cr.value,vt),Cr!==null&&(Be=J(Cr,Be,or),Zt===null?qt=Cr:Zt.sibling=Cr,Zt=Cr);return on&&po(Ge,or),qt}for(Qt=M(Ge,Qt);!Cr.done;or++,Cr=Ye.next())Cr=Tt(Qt,Ge,or,Cr.value,vt),Cr!==null&&(p&&Cr.alternate!==null&&Qt.delete(Cr.key===null?or:Cr.key),Be=J(Cr,Be,or),Zt===null?qt=Cr:Zt.sibling=Cr,Zt=Cr);return p&&Qt.forEach(function(wx){return v(Ge,wx)}),on&&po(Ge,or),qt}function qr(Ge,Be,Ye,vt){if(typeof Ye=="object"&&Ye!==null&&Ye.type===N&&Ye.key===null&&(Ye=Ye.props.children),typeof Ye=="object"&&Ye!==null){switch(Ye.$$typeof){case E:e:{for(var qt=Ye.key,Zt=Be;Zt!==null;){if(Zt.key===qt){if(qt=Ye.type,qt===N){if(Zt.tag===7){A(Ge,Zt.sibling),Be=V(Zt,Ye.props.children),Be.return=Ge,Ge=Be;break e}}else if(Zt.elementType===qt||typeof qt=="object"&&qt!==null&&qt.$$typeof===ee&&Qm(qt)===Zt.type){A(Ge,Zt.sibling),Be=V(Zt,Ye.props),Be.ref=zl(Ge,Zt,Ye),Be.return=Ge,Ge=Be;break e}A(Ge,Zt);break}else v(Ge,Zt);Zt=Zt.sibling}Ye.type===N?(Be=Yl(Ye.props.children,Ge.mode,vt,Ye.key),Be.return=Ge,Ge=Be):(vt=Nd(Ye.type,Ye.key,Ye.props,null,Ge.mode,vt),vt.ref=zl(Ge,Be,Ye),vt.return=Ge,Ge=vt)}return he(Ge);case $:e:{for(Zt=Ye.key;Be!==null;){if(Be.key===Zt)if(Be.tag===4&&Be.stateNode.containerInfo===Ye.containerInfo&&Be.stateNode.implementation===Ye.implementation){A(Ge,Be.sibling),Be=V(Be,Ye.children||[]),Be.return=Ge,Ge=Be;break e}else{A(Ge,Be);break}else v(Ge,Be);Be=Be.sibling}Be=tp(Ye,Ge.mode,vt),Be.return=Ge,Ge=Be}return he(Ge);case ee:return Zt=Ye._init,qr(Ge,Be,Zt(Ye._payload),vt)}if(er(Ye))return It(Ge,Be,Ye,vt);if(X(Ye))return Lt(Ge,Be,Ye,vt);cd(Ge,Ye)}return typeof Ye=="string"&&Ye!==""||typeof Ye=="number"?(Ye=""+Ye,Be!==null&&Be.tag===6?(A(Ge,Be.sibling),Be=V(Be,Ye),Be.return=Ge,Ge=Be):(A(Ge,Be),Be=ep(Ye,Ge.mode,vt),Be.return=Ge,Ge=Be),he(Ge)):A(Ge,Be)}return qr}var Fl=Ub(!0),ih=Ub(!1),Jo=Na(null),ud=null,Zo=null,sh=null;function ah(){sh=Zo=ud=null}function oh(p){var v=Jo.current;Kr(Jo),p._currentValue=v}function eg(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 Ul(p,v){ud=p,sh=Zo=null,p=p.dependencies,p!==null&&p.firstContext!==null&&((p.lanes&v)!==0&&(Hi=!0),p.firstContext=null)}function bs(p){var v=p._currentValue;if(sh!==p)if(p={context:p,memoizedValue:v,next:null},Zo===null){if(ud===null)throw Error(n(308));Zo=p,ud.dependencies={lanes:0,firstContext:p}}else Zo=Zo.next=p;return v}var Wl=null;function lh(p){Wl===null?Wl=[p]:Wl.push(p)}function dd(p,v,A,M){var V=v.interleaved;return V===null?(A.next=A,lh(v)):(A.next=V.next,V.next=A),v.interleaved=A,Pa(p,M)}function Pa(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 da=!1;function fd(p){p.updateQueue={baseState:p.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function ch(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 Ra(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,(wr&2)!==0){var V=M.pending;return V===null?v.next=v:(v.next=V.next,V.next=v),M.pending=v,Pa(p,A)}return V=M.interleaved,V===null?(v.next=v,lh(M)):(v.next=V.next,V.next=v),M.interleaved=v,Pa(p,A)}function qc(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,Se(p,A)}}function Wb(p,v){var A=p.updateQueue,M=p.alternate;if(M!==null&&(M=M.updateQueue,A===M)){var V=null,J=null;if(A=A.firstBaseUpdate,A!==null){do{var he={eventTime:A.eventTime,lane:A.lane,tag:A.tag,payload:A.payload,callback:A.callback,next:null};J===null?V=J=he:J=J.next=he,A=A.next}while(A!==null);J===null?V=J=v:J=J.next=v}else V=J=v;A={baseState:M.baseState,firstBaseUpdate:V,lastBaseUpdate:J,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 hd(p,v,A,M){var V=p.updateQueue;da=!1;var J=V.firstBaseUpdate,he=V.lastBaseUpdate,ke=V.shared.pending;if(ke!==null){V.shared.pending=null;var Re=ke,Xe=Re.next;Re.next=null,he===null?J=Xe:he.next=Xe,he=Re;var ft=p.alternate;ft!==null&&(ft=ft.updateQueue,ke=ft.lastBaseUpdate,ke!==he&&(ke===null?ft.firstBaseUpdate=Xe:ke.next=Xe,ft.lastBaseUpdate=Re))}if(J!==null){var ht=V.baseState;he=0,ft=Xe=Re=null,ke=J;do{var dt=ke.lane,Tt=ke.eventTime;if((M&dt)===dt){ft!==null&&(ft=ft.next={eventTime:Tt,lane:0,tag:ke.tag,payload:ke.payload,callback:ke.callback,next:null});e:{var It=p,Lt=ke;switch(dt=v,Tt=A,Lt.tag){case 1:if(It=Lt.payload,typeof It=="function"){ht=It.call(Tt,ht,dt);break e}ht=It;break e;case 3:It.flags=It.flags&-65537|128;case 0:if(It=Lt.payload,dt=typeof It=="function"?It.call(Tt,ht,dt):It,dt==null)break e;ht=Q({},ht,dt);break e;case 2:da=!0}}ke.callback!==null&&ke.lane!==0&&(p.flags|=64,dt=V.effects,dt===null?V.effects=[ke]:dt.push(ke))}else Tt={eventTime:Tt,lane:dt,tag:ke.tag,payload:ke.payload,callback:ke.callback,next:null},ft===null?(Xe=ft=Tt,Re=ht):ft=ft.next=Tt,he|=dt;if(ke=ke.next,ke===null){if(ke=V.shared.pending,ke===null)break;dt=ke,ke=dt.next,dt.next=null,V.lastBaseUpdate=dt,V.shared.pending=null}}while(!0);if(ft===null&&(Re=ht),V.baseState=Re,V.firstBaseUpdate=Xe,V.lastBaseUpdate=ft,v=V.shared.interleaved,v!==null){V=v;do he|=V.lane,V=V.next;while(V!==v)}else J===null&&(V.shared.lanes=0);il|=he,p.lanes=he,p.memoizedState=ht}}function qb(p,v,A){if(p=v.effects,v.effects=null,p!==null)for(v=0;v<p.length;v++){var M=p[v],V=M.callback;if(V!==null){if(M.callback=null,M=A,typeof V!="function")throw Error(n(191,V));V.call(M)}}}var Hc={},fa=Na(Hc),Vc=Na(Hc),ql=Na(Hc);function Qo(p){if(p===Hc)throw Error(n(174));return p}function uh(p,v){switch(Wr(ql,v),Wr(Vc,p),Wr(fa,Hc),p=v.nodeType,p){case 9:case 11:v=(v=v.documentElement)?v.namespaceURI:Yn(null,"");break;default:p=p===8?v.parentNode:v,v=p.namespaceURI||null,p=p.tagName,v=Yn(v,p)}Kr(fa),Wr(fa,v)}function el(){Kr(fa),Kr(Vc),Kr(ql)}function tg(p){Qo(ql.current);var v=Qo(fa.current),A=Yn(v,p.type);v!==A&&(Wr(Vc,p),Wr(fa,A))}function dh(p){Vc.current===p&&(Kr(fa),Kr(Vc))}var dn=Na(0);function pd(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 fh=[];function hh(){for(var p=0;p<fh.length;p++)fh[p]._workInProgressVersionPrimary=null;fh.length=0}var ph=T.ReactCurrentDispatcher,mh=T.ReactCurrentBatchConfig,tl=0,ln=null,Tn=null,Dn=null,gh=!1,rl=!1,go=0,rg=0;function ni(){throw Error(n(321))}function vh(p,v){if(v===null)return!1;for(var A=0;A<v.length&&A<p.length;A++)if(!Bs(p[A],v[A]))return!1;return!0}function yh(p,v,A,M,V,J){if(tl=J,ln=v,v.memoizedState=null,v.updateQueue=null,v.lanes=0,ph.current=p===null||p.memoizedState===null?Yb:Jb,p=A(M,V),rl){J=0;do{if(rl=!1,go=0,25<=J)throw Error(n(301));J+=1,Dn=Tn=null,v.updateQueue=null,ph.current=p1,p=A(M,V)}while(rl)}if(ph.current=yd,v=Tn!==null&&Tn.next!==null,tl=0,Dn=Tn=ln=null,gh=!1,v)throw Error(n(300));return p}function bh(){var p=go!==0;return go=0,p}function Fs(){var p={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Dn===null?ln.memoizedState=Dn=p:Dn=Dn.next=p,Dn}function xs(){if(Tn===null){var p=ln.alternate;p=p!==null?p.memoizedState:null}else p=Tn.next;var v=Dn===null?ln.memoizedState:Dn.next;if(v!==null)Dn=v,Tn=p;else{if(p===null)throw Error(n(310));Tn=p,p={memoizedState:Tn.memoizedState,baseState:Tn.baseState,baseQueue:Tn.baseQueue,queue:Tn.queue,next:null},Dn===null?ln.memoizedState=Dn=p:Dn=Dn.next=p}return Dn}function Gc(p,v){return typeof v=="function"?v(p):v}function xh(p){var v=xs(),A=v.queue;if(A===null)throw Error(n(311));A.lastRenderedReducer=p;var M=Tn,V=M.baseQueue,J=A.pending;if(J!==null){if(V!==null){var he=V.next;V.next=J.next,J.next=he}M.baseQueue=V=J,A.pending=null}if(V!==null){J=V.next,M=M.baseState;var ke=he=null,Re=null,Xe=J;do{var ft=Xe.lane;if((tl&ft)===ft)Re!==null&&(Re=Re.next={lane:0,action:Xe.action,hasEagerState:Xe.hasEagerState,eagerState:Xe.eagerState,next:null}),M=Xe.hasEagerState?Xe.eagerState:p(M,Xe.action);else{var ht={lane:ft,action:Xe.action,hasEagerState:Xe.hasEagerState,eagerState:Xe.eagerState,next:null};Re===null?(ke=Re=ht,he=M):Re=Re.next=ht,ln.lanes|=ft,il|=ft}Xe=Xe.next}while(Xe!==null&&Xe!==J);Re===null?he=M:Re.next=ke,Bs(M,v.memoizedState)||(Hi=!0),v.memoizedState=M,v.baseState=he,v.baseQueue=Re,A.lastRenderedState=M}if(p=A.interleaved,p!==null){V=p;do J=V.lane,ln.lanes|=J,il|=J,V=V.next;while(V!==p)}else V===null&&(A.lanes=0);return[v.memoizedState,A.dispatch]}function ng(p){var v=xs(),A=v.queue;if(A===null)throw Error(n(311));A.lastRenderedReducer=p;var M=A.dispatch,V=A.pending,J=v.memoizedState;if(V!==null){A.pending=null;var he=V=V.next;do J=p(J,he.action),he=he.next;while(he!==V);Bs(J,v.memoizedState)||(Hi=!0),v.memoizedState=J,v.baseQueue===null&&(v.baseState=J),A.lastRenderedState=J}return[J,M]}function ig(){}function wh(p,v){var A=ln,M=xs(),V=v(),J=!Bs(M.memoizedState,V);if(J&&(M.memoizedState=V,Hi=!0),M=M.queue,fg(og.bind(null,A,M,p),[p]),M.getSnapshot!==v||J||Dn!==null&&Dn.memoizedState.tag&1){if(A.flags|=2048,md(9,ag.bind(null,A,M,V,v),void 0,null),$n===null)throw Error(n(349));(tl&30)!==0||sg(A,v,V)}return V}function sg(p,v,A){p.flags|=16384,p={getSnapshot:v,value:A},v=ln.updateQueue,v===null?(v={lastEffect:null,stores:null},ln.updateQueue=v,v.stores=[p]):(A=v.stores,A===null?v.stores=[p]:A.push(p))}function ag(p,v,A,M){v.value=A,v.getSnapshot=M,Hb(v)&&lg(p)}function og(p,v,A){return A(function(){Hb(v)&&lg(p)})}function Hb(p){var v=p.getSnapshot;p=p.value;try{var A=v();return!Bs(p,A)}catch{return!0}}function lg(p){var v=Pa(p,1);v!==null&&qs(v,p,1,-1)}function cg(p){var v=Fs();return typeof p=="function"&&(p=p()),v.memoizedState=v.baseState=p,p={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Gc,lastRenderedState:p},v.queue=p,p=p.dispatch=Kb.bind(null,ln,p),[v.memoizedState,p]}function md(p,v,A,M){return p={tag:p,create:v,destroy:A,deps:M,next:null},v=ln.updateQueue,v===null?(v={lastEffect:null,stores:null},ln.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 ug(){return xs().memoizedState}function gd(p,v,A,M){var V=Fs();ln.flags|=p,V.memoizedState=md(1|v,A,void 0,M===void 0?null:M)}function vd(p,v,A,M){var V=xs();M=M===void 0?null:M;var J=void 0;if(Tn!==null){var he=Tn.memoizedState;if(J=he.destroy,M!==null&&vh(M,he.deps)){V.memoizedState=md(v,A,J,M);return}}ln.flags|=p,V.memoizedState=md(1|v,A,J,M)}function dg(p,v){return gd(8390656,8,p,v)}function fg(p,v){return vd(2048,8,p,v)}function hg(p,v){return vd(4,2,p,v)}function pg(p,v){return vd(4,4,p,v)}function mg(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 Vb(p,v,A){return A=A!=null?A.concat([p]):null,vd(4,4,mg.bind(null,v,p),A)}function _h(){}function gg(p,v){var A=xs();v=v===void 0?null:v;var M=A.memoizedState;return M!==null&&v!==null&&vh(v,M[1])?M[0]:(A.memoizedState=[p,v],p)}function vg(p,v){var A=xs();v=v===void 0?null:v;var M=A.memoizedState;return M!==null&&v!==null&&vh(v,M[1])?M[0]:(p=p(),A.memoizedState=[p,v],p)}function yg(p,v,A){return(tl&21)===0?(p.baseState&&(p.baseState=!1,Hi=!0),p.memoizedState=A):(Bs(A,v)||(A=rs(),ln.lanes|=A,il|=A,p.baseState=!0),v)}function h1(p,v){var A=ze;ze=A!==0&&4>A?A:4,p(!0);var M=mh.transition;mh.transition={};try{p(!1),v()}finally{ze=A,mh.transition=M}}function bg(){return xs().memoizedState}function Gb(p,v,A){var M=xo(p);if(A={lane:M,action:A,hasEagerState:!1,eagerState:null,next:null},xg(p))Xb(v,A);else if(A=dd(p,v,A,M),A!==null){var V=Ci();qs(A,p,M,V),wg(A,v,M)}}function Kb(p,v,A){var M=xo(p),V={lane:M,action:A,hasEagerState:!1,eagerState:null,next:null};if(xg(p))Xb(v,V);else{var J=p.alternate;if(p.lanes===0&&(J===null||J.lanes===0)&&(J=v.lastRenderedReducer,J!==null))try{var he=v.lastRenderedState,ke=J(he,A);if(V.hasEagerState=!0,V.eagerState=ke,Bs(ke,he)){var Re=v.interleaved;Re===null?(V.next=V,lh(v)):(V.next=Re.next,Re.next=V),v.interleaved=V;return}}catch{}finally{}A=dd(p,v,V,M),A!==null&&(V=Ci(),qs(A,p,M,V),wg(A,v,M))}}function xg(p){var v=p.alternate;return p===ln||v!==null&&v===ln}function Xb(p,v){rl=gh=!0;var A=p.pending;A===null?v.next=v:(v.next=A.next,A.next=v),p.pending=v}function wg(p,v,A){if((A&4194240)!==0){var M=v.lanes;M&=p.pendingLanes,A|=M,v.lanes=A,Se(p,A)}}var yd={readContext:bs,useCallback:ni,useContext:ni,useEffect:ni,useImperativeHandle:ni,useInsertionEffect:ni,useLayoutEffect:ni,useMemo:ni,useReducer:ni,useRef:ni,useState:ni,useDebugValue:ni,useDeferredValue:ni,useTransition:ni,useMutableSource:ni,useSyncExternalStore:ni,useId:ni,unstable_isNewReconciler:!1},Yb={readContext:bs,useCallback:function(p,v){return Fs().memoizedState=[p,v===void 0?null:v],p},useContext:bs,useEffect:dg,useImperativeHandle:function(p,v,A){return A=A!=null?A.concat([p]):null,gd(4194308,4,mg.bind(null,v,p),A)},useLayoutEffect:function(p,v){return gd(4194308,4,p,v)},useInsertionEffect:function(p,v){return gd(4,2,p,v)},useMemo:function(p,v){var A=Fs();return v=v===void 0?null:v,p=p(),A.memoizedState=[p,v],p},useReducer:function(p,v,A){var M=Fs();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=Gb.bind(null,ln,p),[M.memoizedState,p]},useRef:function(p){var v=Fs();return p={current:p},v.memoizedState=p},useState:cg,useDebugValue:_h,useDeferredValue:function(p){return Fs().memoizedState=p},useTransition:function(){var p=cg(!1),v=p[0];return p=h1.bind(null,p[1]),Fs().memoizedState=p,[v,p]},useMutableSource:function(){},useSyncExternalStore:function(p,v,A){var M=ln,V=Fs();if(on){if(A===void 0)throw Error(n(407));A=A()}else{if(A=v(),$n===null)throw Error(n(349));(tl&30)!==0||sg(M,v,A)}V.memoizedState=A;var J={value:A,getSnapshot:v};return V.queue=J,dg(og.bind(null,M,J,p),[p]),M.flags|=2048,md(9,ag.bind(null,M,J,A,v),void 0,null),A},useId:function(){var p=Fs(),v=$n.identifierPrefix;if(on){var A=Ui,M=Fi;A=(M&~(1<<32-an(M)-1)).toString(32)+A,v=":"+v+"R"+A,A=go++,0<A&&(v+="H"+A.toString(32)),v+=":"}else A=rg++,v=":"+v+"r"+A.toString(32)+":";return p.memoizedState=v},unstable_isNewReconciler:!1},Jb={readContext:bs,useCallback:gg,useContext:bs,useEffect:fg,useImperativeHandle:Vb,useInsertionEffect:hg,useLayoutEffect:pg,useMemo:vg,useReducer:xh,useRef:ug,useState:function(){return xh(Gc)},useDebugValue:_h,useDeferredValue:function(p){var v=xs();return yg(v,Tn.memoizedState,p)},useTransition:function(){var p=xh(Gc)[0],v=xs().memoizedState;return[p,v]},useMutableSource:ig,useSyncExternalStore:wh,useId:bg,unstable_isNewReconciler:!1},p1={readContext:bs,useCallback:gg,useContext:bs,useEffect:fg,useImperativeHandle:Vb,useInsertionEffect:hg,useLayoutEffect:pg,useMemo:vg,useReducer:ng,useRef:ug,useState:function(){return ng(Gc)},useDebugValue:_h,useDeferredValue:function(p){var v=xs();return Tn===null?v.memoizedState=p:yg(v,Tn.memoizedState,p)},useTransition:function(){var p=ng(Gc)[0],v=xs().memoizedState;return[p,v]},useMutableSource:ig,useSyncExternalStore:wh,useId:bg,unstable_isNewReconciler:!1};function An(p,v){if(p&&p.defaultProps){v=Q({},v),p=p.defaultProps;for(var A in p)v[A]===void 0&&(v[A]=p[A]);return v}return v}function ha(p,v,A,M){v=p.memoizedState,A=A(M,v),A=A==null?v:Q({},v,A),p.memoizedState=A,p.lanes===0&&(p.updateQueue.baseState=A)}var Ma={isMounted:function(p){return(p=p._reactInternals)?Et(p)===p:!1},enqueueSetState:function(p,v,A){p=p._reactInternals;var M=Ci(),V=xo(p),J=Ra(M,V);J.payload=v,A!=null&&(J.callback=A),v=mo(p,J,V),v!==null&&(qs(v,p,V,M),qc(v,p,V))},enqueueReplaceState:function(p,v,A){p=p._reactInternals;var M=Ci(),V=xo(p),J=Ra(M,V);J.tag=1,J.payload=v,A!=null&&(J.callback=A),v=mo(p,J,V),v!==null&&(qs(v,p,V,M),qc(v,p,V))},enqueueForceUpdate:function(p,v){p=p._reactInternals;var A=Ci(),M=xo(p),V=Ra(A,M);V.tag=2,v!=null&&(V.callback=v),v=mo(p,V,M),v!==null&&(qs(v,p,M,A),qc(v,p,M))}};function nl(p,v,A,M,V,J,he){return p=p.stateNode,typeof p.shouldComponentUpdate=="function"?p.shouldComponentUpdate(M,J,he):v.prototype&&v.prototype.isPureReactComponent?!Mc(A,M)||!Mc(V,J):!0}function _g(p,v,A){var M=!1,V=fo,J=v.contextType;return typeof J=="object"&&J!==null?J=bs(J):(V=zi(v)?Ko:_i.current,M=v.contextTypes,J=(M=M!=null)?Si(p,V):fo),v=new v(A,J),p.memoizedState=v.state!==null&&v.state!==void 0?v.state:null,v.updater=Ma,p.stateNode=v,v._reactInternals=p,M&&(p=p.stateNode,p.__reactInternalMemoizedUnmaskedChildContext=V,p.__reactInternalMemoizedMaskedChildContext=J),v}function Sg(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&&Ma.enqueueReplaceState(v,v.state,null)}function Sh(p,v,A,M){var V=p.stateNode;V.props=A,V.state=p.memoizedState,V.refs={},fd(p);var J=v.contextType;typeof J=="object"&&J!==null?V.context=bs(J):(J=zi(v)?Ko:_i.current,V.context=Si(p,J)),V.state=p.memoizedState,J=v.getDerivedStateFromProps,typeof J=="function"&&(ha(p,v,J,A),V.state=p.memoizedState),typeof v.getDerivedStateFromProps=="function"||typeof V.getSnapshotBeforeUpdate=="function"||typeof V.UNSAFE_componentWillMount!="function"&&typeof V.componentWillMount!="function"||(v=V.state,typeof V.componentWillMount=="function"&&V.componentWillMount(),typeof V.UNSAFE_componentWillMount=="function"&&V.UNSAFE_componentWillMount(),v!==V.state&&Ma.enqueueReplaceState(V,V.state,null),hd(p,A,V,M),V.state=p.memoizedState),typeof V.componentDidMount=="function"&&(p.flags|=4194308)}function Hl(p,v){try{var A="",M=v;do A+=ve(M),M=M.return;while(M);var V=A}catch(J){V=`
40
40
  Error generating stack: `+J.message+`
41
- `+J.stack}return{value:p,source:v,stack:V,digest:null}}function kh(p,v,A){return{value:p,source:null,stack:A??null,digest:v??null}}function Ch(p,v){try{console.error(v.value)}catch(A){setTimeout(function(){throw A})}}var Zb=typeof WeakMap=="function"?WeakMap:Map;function kg(p,v,A){A=Ra(-1,A),A.tag=3,A.payload={element:null};var M=v.value;return A.callback=function(){jd||(jd=!0,Vh=M),Ch(p,v)},A}function Cg(p,v,A){A=Ra(-1,A),A.tag=3;var M=p.type.getDerivedStateFromError;if(typeof M=="function"){var V=v.value;A.payload=function(){return M(V)},A.callback=function(){Ch(p,v)}}var J=p.stateNode;return J!==null&&typeof J.componentDidCatch=="function"&&(A.callback=function(){Ch(p,v),typeof M!="function"&&(bo===null?bo=new Set([this]):bo.add(this));var he=v.stack;this.componentDidCatch(v.value,{componentStack:he!==null?he:""})}),A}function jg(p,v,A){var M=p.pingCache;if(M===null){M=p.pingCache=new Zb;var V=new Set;M.set(v,V)}else V=M.get(v),V===void 0&&(V=new Set,M.set(v,V));V.has(A)||(V.add(A),p=ux.bind(null,p,v,A),v.then(p,p))}function Qb(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 ki(p,v,A,M,V){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=Ra(-1,1),v.tag=2,mo(A,v,1))),A.lanes|=1),p):(p.flags|=65536,p.lanes=V,p)}var ex=T.ReactCurrentOwner,Hi=!1;function ii(p,v,A,M){v.child=p===null?ih(v,null,A,M):Fl(v,p.child,A,M)}function Eg(p,v,A,M,V){A=A.render;var J=v.ref;return Ul(v,V),M=yh(p,v,A,M,J,V),A=bh(),p!==null&&!Hi?(v.updateQueue=p.updateQueue,v.flags&=-2053,p.lanes&=~V,Ia(p,v,V)):(on&&A&&En(v),v.flags|=1,ii(p,v,M,V),v.child)}function Kc(p,v,A,M,V){if(p===null){var J=A.type;return typeof J=="function"&&!Qh(J)&&J.defaultProps===void 0&&A.compare===null&&A.defaultProps===void 0?(v.tag=15,v.type=J,Tg(p,v,J,M,V)):(p=Nd(A.type,null,M,v,v.mode,V),p.ref=v.ref,p.return=v,v.child=p)}if(J=p.child,(p.lanes&V)===0){var he=J.memoizedProps;if(A=A.compare,A=A!==null?A:Mc,A(he,M)&&p.ref===v.ref)return Ia(p,v,V)}return v.flags|=1,p=_o(J,M),p.ref=v.ref,p.return=v,v.child=p}function Tg(p,v,A,M,V){if(p!==null){var J=p.memoizedProps;if(Mc(J,M)&&p.ref===v.ref)if(Hi=!1,v.pendingProps=M=J,(p.lanes&V)!==0)(p.flags&131072)!==0&&(Hi=!0);else return v.lanes=p.lanes,Ia(p,v,V)}return jh(p,v,A,M,V)}function Ag(p,v,A){var M=v.pendingProps,V=M.children,J=p!==null?p.memoizedState:null;if(M.mode==="hidden")if((v.mode&1)===0)v.memoizedState={baseLanes:0,cachePool:null,transitions:null},Wr(Gl,is),is|=A;else{if((A&1073741824)===0)return p=J!==null?J.baseLanes|A:A,v.lanes=v.childLanes=1073741824,v.memoizedState={baseLanes:p,cachePool:null,transitions:null},v.updateQueue=null,Wr(Gl,is),is|=p,null;v.memoizedState={baseLanes:0,cachePool:null,transitions:null},M=J!==null?J.baseLanes:A,Wr(Gl,is),is|=M}else J!==null?(M=J.baseLanes|A,v.memoizedState=null):M=A,Wr(Gl,is),is|=M;return ii(p,v,V,A),v.child}function $g(p,v){var A=v.ref;(p===null&&A!==null||p!==null&&p.ref!==A)&&(v.flags|=512,v.flags|=2097152)}function jh(p,v,A,M,V){var J=zi(A)?Ko:_i.current;return J=Si(v,J),Ul(v,V),A=yh(p,v,A,M,J,V),M=bh(),p!==null&&!Hi?(v.updateQueue=p.updateQueue,v.flags&=-2053,p.lanes&=~V,Ia(p,v,V)):(on&&M&&En(v),v.flags|=1,ii(p,v,A,V),v.child)}function Ng(p,v,A,M,V){if(zi(A)){var J=!0;sd(v)}else J=!1;if(Ul(v,V),v.stateNode===null)xd(p,v),_g(v,A,M),Sh(v,A,M,V),M=!0;else if(p===null){var he=v.stateNode,ke=v.memoizedProps;he.props=ke;var Re=he.context,Xe=A.contextType;typeof Xe=="object"&&Xe!==null?Xe=bs(Xe):(Xe=zi(A)?Ko:_i.current,Xe=Si(v,Xe));var ft=A.getDerivedStateFromProps,ht=typeof ft=="function"||typeof he.getSnapshotBeforeUpdate=="function";ht||typeof he.UNSAFE_componentWillReceiveProps!="function"&&typeof he.componentWillReceiveProps!="function"||(ke!==M||Re!==Xe)&&Sg(v,he,M,Xe),da=!1;var dt=v.memoizedState;he.state=dt,hd(v,M,he,V),Re=v.memoizedState,ke!==M||dt!==Re||Bi.current||da?(typeof ft=="function"&&(ha(v,A,ft,M),Re=v.memoizedState),(ke=da||nl(v,A,ke,M,dt,Re,Xe))?(ht||typeof he.UNSAFE_componentWillMount!="function"&&typeof he.componentWillMount!="function"||(typeof he.componentWillMount=="function"&&he.componentWillMount(),typeof he.UNSAFE_componentWillMount=="function"&&he.UNSAFE_componentWillMount()),typeof he.componentDidMount=="function"&&(v.flags|=4194308)):(typeof he.componentDidMount=="function"&&(v.flags|=4194308),v.memoizedProps=M,v.memoizedState=Re),he.props=M,he.state=Re,he.context=Xe,M=ke):(typeof he.componentDidMount=="function"&&(v.flags|=4194308),M=!1)}else{he=v.stateNode,ch(p,v),ke=v.memoizedProps,Xe=v.type===v.elementType?ke:An(v.type,ke),he.props=Xe,ht=v.pendingProps,dt=he.context,Re=A.contextType,typeof Re=="object"&&Re!==null?Re=bs(Re):(Re=zi(A)?Ko:_i.current,Re=Si(v,Re));var Tt=A.getDerivedStateFromProps;(ft=typeof Tt=="function"||typeof he.getSnapshotBeforeUpdate=="function")||typeof he.UNSAFE_componentWillReceiveProps!="function"&&typeof he.componentWillReceiveProps!="function"||(ke!==ht||dt!==Re)&&Sg(v,he,M,Re),da=!1,dt=v.memoizedState,he.state=dt,hd(v,M,he,V);var It=v.memoizedState;ke!==ht||dt!==It||Bi.current||da?(typeof Tt=="function"&&(ha(v,A,Tt,M),It=v.memoizedState),(Xe=da||nl(v,A,Xe,M,dt,It,Re)||!1)?(ft||typeof he.UNSAFE_componentWillUpdate!="function"&&typeof he.componentWillUpdate!="function"||(typeof he.componentWillUpdate=="function"&&he.componentWillUpdate(M,It,Re),typeof he.UNSAFE_componentWillUpdate=="function"&&he.UNSAFE_componentWillUpdate(M,It,Re)),typeof he.componentDidUpdate=="function"&&(v.flags|=4),typeof he.getSnapshotBeforeUpdate=="function"&&(v.flags|=1024)):(typeof he.componentDidUpdate!="function"||ke===p.memoizedProps&&dt===p.memoizedState||(v.flags|=4),typeof he.getSnapshotBeforeUpdate!="function"||ke===p.memoizedProps&&dt===p.memoizedState||(v.flags|=1024),v.memoizedProps=M,v.memoizedState=It),he.props=M,he.state=It,he.context=Re,M=Xe):(typeof he.componentDidUpdate!="function"||ke===p.memoizedProps&&dt===p.memoizedState||(v.flags|=4),typeof he.getSnapshotBeforeUpdate!="function"||ke===p.memoizedProps&&dt===p.memoizedState||(v.flags|=1024),M=!1)}return Eh(p,v,A,M,J,V)}function Eh(p,v,A,M,V,J){$g(p,v);var he=(v.flags&128)!==0;if(!M&&!he)return V&&Ym(v,A,!1),Ia(p,v,J);M=v.stateNode,ex.current=v;var ke=he&&typeof A.getDerivedStateFromError!="function"?null:M.render();return v.flags|=1,p!==null&&he?(v.child=Fl(v,p.child,null,J),v.child=Fl(v,null,ke,J)):ii(p,v,ke,J),v.memoizedState=M.state,V&&Ym(v,A,!0),v.child}function Th(p){var v=p.stateNode;v.pendingContext?Km(p,v.pendingContext,v.pendingContext!==v.context):v.context&&Km(p,v.context,!1),uh(p,v.containerInfo)}function Og(p,v,A,M,V){return Yo(),rh(V),v.flags|=256,ii(p,v,A,M),v.child}var Ah={dehydrated:null,treeContext:null,retryLane:0};function $h(p){return{baseLanes:p,cachePool:null,transitions:null}}function Pg(p,v,A){var M=v.pendingProps,V=dn.current,J=!1,he=(v.flags&128)!==0,ke;if((ke=he)||(ke=p!==null&&p.memoizedState===null?!1:(V&2)!==0),ke?(J=!0,v.flags&=-129):(p===null||p.memoizedState!==null)&&(V|=1),Wr(dn,V&1),p===null)return eh(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):(he=M.children,p=M.fallback,J?(M=v.mode,J=v.child,he={mode:"hidden",children:he},(M&1)===0&&J!==null?(J.childLanes=0,J.pendingProps=he):J=Od(he,M,0,null),p=Yl(p,M,A,null),J.return=v,p.return=v,J.sibling=p,v.child=J,v.child.memoizedState=$h(A),v.memoizedState=Ah,p):Xc(v,he));if(V=p.memoizedState,V!==null&&(ke=V.dehydrated,ke!==null))return tx(p,v,he,M,ke,V,A);if(J){J=M.fallback,he=v.mode,V=p.child,ke=V.sibling;var Re={mode:"hidden",children:M.children};return(he&1)===0&&v.child!==V?(M=v.child,M.childLanes=0,M.pendingProps=Re,v.deletions=null):(M=_o(V,Re),M.subtreeFlags=V.subtreeFlags&14680064),ke!==null?J=_o(ke,J):(J=Yl(J,he,A,null),J.flags|=2),J.return=v,M.return=v,M.sibling=J,v.child=M,M=J,J=v.child,he=p.child.memoizedState,he=he===null?$h(A):{baseLanes:he.baseLanes|A,cachePool:null,transitions:he.transitions},J.memoizedState=he,J.childLanes=p.childLanes&~A,v.memoizedState=Ah,M}return J=p.child,p=J.sibling,M=_o(J,{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 Xc(p,v){return v=Od({mode:"visible",children:v},p.mode,0,null),v.return=p,p.child=v}function bd(p,v,A,M){return M!==null&&rh(M),Fl(v,p.child,null,A),p=Xc(v,v.pendingProps.children),p.flags|=2,v.memoizedState=null,p}function tx(p,v,A,M,V,J,he){if(A)return v.flags&256?(v.flags&=-257,M=kh(Error(n(422))),bd(p,v,he,M)):v.memoizedState!==null?(v.child=p.child,v.flags|=128,null):(J=M.fallback,V=v.mode,M=Od({mode:"visible",children:M.children},V,0,null),J=Yl(J,V,he,null),J.flags|=2,M.return=v,J.return=v,M.sibling=J,v.child=M,(v.mode&1)!==0&&Fl(v,p.child,null,he),v.child.memoizedState=$h(he),v.memoizedState=Ah,J);if((v.mode&1)===0)return bd(p,v,he,null);if(V.data==="$!"){if(M=V.nextSibling&&V.nextSibling.dataset,M)var ke=M.dgst;return M=ke,J=Error(n(419)),M=kh(J,M,void 0),bd(p,v,he,M)}if(ke=(he&p.childLanes)!==0,Hi||ke){if(M=$n,M!==null){switch(he&-he){case 4:V=2;break;case 16:V=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:V=32;break;case 536870912:V=268435456;break;default:V=0}V=(V&(M.suspendedLanes|he))!==0?0:V,V!==0&&V!==J.retryLane&&(J.retryLane=V,Pa(p,V),qs(M,p,V,-1))}return Zh(),M=kh(Error(n(421))),bd(p,v,he,M)}return V.data==="$?"?(v.flags|=128,v.child=p.child,v=fx.bind(null,p),V._reactRetry=v,null):(p=J.treeContext,ns=uo(V.nextSibling),Wi=v,on=!0,qi=null,p!==null&&(vs[zs++]=Fi,vs[zs++]=Ui,vs[zs++]=ys,Fi=p.id,Ui=p.overflow,ys=v),v=Xc(v,M.children),v.flags|=4096,v)}function Rg(p,v,A){p.lanes|=v;var M=p.alternate;M!==null&&(M.lanes|=v),eg(p.return,v,A)}function Nh(p,v,A,M,V){var J=p.memoizedState;J===null?p.memoizedState={isBackwards:v,rendering:null,renderingStartTime:0,last:M,tail:A,tailMode:V}:(J.isBackwards=v,J.rendering=null,J.renderingStartTime=0,J.last=M,J.tail=A,J.tailMode=V)}function Oh(p,v,A){var M=v.pendingProps,V=M.revealOrder,J=M.tail;if(ii(p,v,M.children,A),M=dn.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&&Rg(p,A,v);else if(p.tag===19)Rg(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(Wr(dn,M),(v.mode&1)===0)v.memoizedState=null;else switch(V){case"forwards":for(A=v.child,V=null;A!==null;)p=A.alternate,p!==null&&pd(p)===null&&(V=A),A=A.sibling;A=V,A===null?(V=v.child,v.child=null):(V=A.sibling,A.sibling=null),Nh(v,!1,V,A,J);break;case"backwards":for(A=null,V=v.child,v.child=null;V!==null;){if(p=V.alternate,p!==null&&pd(p)===null){v.child=V;break}p=V.sibling,V.sibling=A,A=V,V=p}Nh(v,!0,A,null,J);break;case"together":Nh(v,!1,null,null,void 0);break;default:v.memoizedState=null}return v.child}function xd(p,v){(v.mode&1)===0&&p!==null&&(p.alternate=null,v.alternate=null,v.flags|=2)}function Ia(p,v,A){if(p!==null&&(v.dependencies=p.dependencies),il|=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 m1(p,v,A){switch(v.tag){case 3:Th(v),Yo();break;case 5:tg(v);break;case 1:zi(v.type)&&sd(v);break;case 4:uh(v,v.stateNode.containerInfo);break;case 10:var M=v.type._context,V=v.memoizedProps.value;Wr(Jo,M._currentValue),M._currentValue=V;break;case 13:if(M=v.memoizedState,M!==null)return M.dehydrated!==null?(Wr(dn,dn.current&1),v.flags|=128,null):(A&v.child.childLanes)!==0?Pg(p,v,A):(Wr(dn,dn.current&1),p=Ia(p,v,A),p!==null?p.sibling:null);Wr(dn,dn.current&1);break;case 19:if(M=(A&v.childLanes)!==0,(p.flags&128)!==0){if(M)return Oh(p,v,A);v.flags|=128}if(V=v.memoizedState,V!==null&&(V.rendering=null,V.tail=null,V.lastEffect=null),Wr(dn,dn.current),M)break;return null;case 22:case 23:return v.lanes=0,Ag(p,v,A)}return Ia(p,v,A)}var Ph,Rh,Mg,Ig;Ph=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}},Rh=function(){},Mg=function(p,v,A,M){var V=p.memoizedProps;if(V!==M){p=v.stateNode,Qo(fa.current);var J=null;switch(A){case"input":V=ct(p,V),M=ct(p,M),J=[];break;case"select":V=Q({},V,{value:void 0}),M=Q({},M,{value:void 0}),J=[];break;case"textarea":V=mr(p,V),M=mr(p,M),J=[];break;default:typeof V.onClick!="function"&&typeof M.onClick=="function"&&(p.onclick=rd)}Js(A,M);var he;A=null;for(Xe in V)if(!M.hasOwnProperty(Xe)&&V.hasOwnProperty(Xe)&&V[Xe]!=null)if(Xe==="style"){var ke=V[Xe];for(he in ke)ke.hasOwnProperty(he)&&(A||(A={}),A[he]="")}else Xe!=="dangerouslySetInnerHTML"&&Xe!=="children"&&Xe!=="suppressContentEditableWarning"&&Xe!=="suppressHydrationWarning"&&Xe!=="autoFocus"&&(s.hasOwnProperty(Xe)?J||(J=[]):(J=J||[]).push(Xe,null));for(Xe in M){var Re=M[Xe];if(ke=V!=null?V[Xe]:void 0,M.hasOwnProperty(Xe)&&Re!==ke&&(Re!=null||ke!=null))if(Xe==="style")if(ke){for(he in ke)!ke.hasOwnProperty(he)||Re&&Re.hasOwnProperty(he)||(A||(A={}),A[he]="");for(he in Re)Re.hasOwnProperty(he)&&ke[he]!==Re[he]&&(A||(A={}),A[he]=Re[he])}else A||(J||(J=[]),J.push(Xe,A)),A=Re;else Xe==="dangerouslySetInnerHTML"?(Re=Re?Re.__html:void 0,ke=ke?ke.__html:void 0,Re!=null&&ke!==Re&&(J=J||[]).push(Xe,Re)):Xe==="children"?typeof Re!="string"&&typeof Re!="number"||(J=J||[]).push(Xe,""+Re):Xe!=="suppressContentEditableWarning"&&Xe!=="suppressHydrationWarning"&&(s.hasOwnProperty(Xe)?(Re!=null&&Xe==="onScroll"&&Gr("scroll",p),J||ke===Re||(J=[])):(J=J||[]).push(Xe,Re))}A&&(J=J||[]).push("style",A);var Xe=J;(v.updateQueue=Xe)&&(v.flags|=4)}},Ig=function(p,v,A,M){A!==M&&(v.flags|=4)};function wd(p,v){if(!on)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 si(p){var v=p.alternate!==null&&p.alternate.child===p.child,A=0,M=0;if(v)for(var V=p.child;V!==null;)A|=V.lanes|V.childLanes,M|=V.subtreeFlags&14680064,M|=V.flags&14680064,V.return=p,V=V.sibling;else for(V=p.child;V!==null;)A|=V.lanes|V.childLanes,M|=V.subtreeFlags,M|=V.flags,V.return=p,V=V.sibling;return p.subtreeFlags|=M,p.childLanes=A,v}function rx(p,v,A){var M=v.pendingProps;switch(Yf(v),v.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return si(v),null;case 1:return zi(v.type)&&id(),si(v),null;case 3:return M=v.stateNode,el(),Kr(Bi),Kr(_i),hh(),M.pendingContext&&(M.context=M.pendingContext,M.pendingContext=null),(p===null||p.child===null)&&(Wc(v)?v.flags|=4:p===null||p.memoizedState.isDehydrated&&(v.flags&256)===0||(v.flags|=1024,qi!==null&&(Xh(qi),qi=null))),Rh(p,v),si(v),null;case 5:dh(v);var V=Qo(ql.current);if(A=v.type,p!==null&&v.stateNode!=null)Mg(p,v,A,M,V),p.ref!==v.ref&&(v.flags|=512,v.flags|=2097152);else{if(!M){if(v.stateNode===null)throw Error(n(166));return si(v),null}if(p=Qo(fa.current),Wc(v)){M=v.stateNode,A=v.type;var J=v.memoizedProps;switch(M[ca]=v,M[Fc]=J,p=(v.mode&1)!==0,A){case"dialog":Gr("cancel",M),Gr("close",M);break;case"iframe":case"object":case"embed":Gr("load",M);break;case"video":case"audio":for(V=0;V<Lc.length;V++)Gr(Lc[V],M);break;case"source":Gr("error",M);break;case"img":case"image":case"link":Gr("error",M),Gr("load",M);break;case"details":Gr("toggle",M);break;case"input":Le(M,J),Gr("invalid",M);break;case"select":M._wrapperState={wasMultiple:!!J.multiple},Gr("invalid",M);break;case"textarea":ur(M,J),Gr("invalid",M)}Js(A,J),V=null;for(var he in J)if(J.hasOwnProperty(he)){var ke=J[he];he==="children"?typeof ke=="string"?M.textContent!==ke&&(J.suppressHydrationWarning!==!0&&td(M.textContent,ke,p),V=["children",ke]):typeof ke=="number"&&M.textContent!==""+ke&&(J.suppressHydrationWarning!==!0&&td(M.textContent,ke,p),V=["children",""+ke]):s.hasOwnProperty(he)&&ke!=null&&he==="onScroll"&&Gr("scroll",M)}switch(A){case"input":Ae(M),mt(M,J,!0);break;case"textarea":Ae(M),Pr(M);break;case"select":case"option":break;default:typeof J.onClick=="function"&&(M.onclick=rd)}M=V,v.updateQueue=M,M!==null&&(v.flags|=4)}else{he=V.nodeType===9?V:V.ownerDocument,p==="http://www.w3.org/1999/xhtml"&&(p=di(A)),p==="http://www.w3.org/1999/xhtml"?A==="script"?(p=he.createElement("div"),p.innerHTML="<script><\/script>",p=p.removeChild(p.firstChild)):typeof M.is=="string"?p=he.createElement(A,{is:M.is}):(p=he.createElement(A),A==="select"&&(he=p,M.multiple?he.multiple=!0:M.size&&(he.size=M.size))):p=he.createElementNS(p,A),p[ca]=v,p[Fc]=M,Ph(p,v,!1,!1),v.stateNode=p;e:{switch(he=kr(A,M),A){case"dialog":Gr("cancel",p),Gr("close",p),V=M;break;case"iframe":case"object":case"embed":Gr("load",p),V=M;break;case"video":case"audio":for(V=0;V<Lc.length;V++)Gr(Lc[V],p);V=M;break;case"source":Gr("error",p),V=M;break;case"img":case"image":case"link":Gr("error",p),Gr("load",p),V=M;break;case"details":Gr("toggle",p),V=M;break;case"input":Le(p,M),V=ct(p,M),Gr("invalid",p);break;case"option":V=M;break;case"select":p._wrapperState={wasMultiple:!!M.multiple},V=Q({},M,{value:void 0}),Gr("invalid",p);break;case"textarea":ur(p,M),V=mr(p,M),Gr("invalid",p);break;default:V=M}Js(A,V),ke=V;for(J in ke)if(ke.hasOwnProperty(J)){var Re=ke[J];J==="style"?Tl(p,Re):J==="dangerouslySetInnerHTML"?(Re=Re?Re.__html:void 0,Re!=null&&Ct(p,Re)):J==="children"?typeof Re=="string"?(A!=="textarea"||Re!=="")&&Pt(p,Re):typeof Re=="number"&&Pt(p,""+Re):J!=="suppressContentEditableWarning"&&J!=="suppressHydrationWarning"&&J!=="autoFocus"&&(s.hasOwnProperty(J)?Re!=null&&J==="onScroll"&&Gr("scroll",p):Re!=null&&C(p,J,Re,he))}switch(A){case"input":Ae(p),mt(p,M,!1);break;case"textarea":Ae(p),Pr(p);break;case"option":M.value!=null&&p.setAttribute("value",""+ne(M.value));break;case"select":p.multiple=!!M.multiple,J=M.value,J!=null?Yt(p,!!M.multiple,J,!1):M.defaultValue!=null&&Yt(p,!!M.multiple,M.defaultValue,!0);break;default:typeof V.onClick=="function"&&(p.onclick=rd)}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 si(v),null;case 6:if(p&&v.stateNode!=null)Ig(p,v,p.memoizedProps,M);else{if(typeof M!="string"&&v.stateNode===null)throw Error(n(166));if(A=Qo(ql.current),Qo(fa.current),Wc(v)){if(M=v.stateNode,A=v.memoizedProps,M[ca]=v,(J=M.nodeValue!==A)&&(p=Wi,p!==null))switch(p.tag){case 3:td(M.nodeValue,A,(p.mode&1)!==0);break;case 5:p.memoizedProps.suppressHydrationWarning!==!0&&td(M.nodeValue,A,(p.mode&1)!==0)}J&&(v.flags|=4)}else M=(A.nodeType===9?A:A.ownerDocument).createTextNode(M),M[ca]=v,v.stateNode=M}return si(v),null;case 13:if(Kr(dn),M=v.memoizedState,p===null||p.memoizedState!==null&&p.memoizedState.dehydrated!==null){if(on&&ns!==null&&(v.mode&1)!==0&&(v.flags&128)===0)Zm(),Yo(),v.flags|=98560,J=!1;else if(J=Wc(v),M!==null&&M.dehydrated!==null){if(p===null){if(!J)throw Error(n(318));if(J=v.memoizedState,J=J!==null?J.dehydrated:null,!J)throw Error(n(317));J[ca]=v}else Yo(),(v.flags&128)===0&&(v.memoizedState=null),v.flags|=4;si(v),J=!1}else qi!==null&&(Xh(qi),qi=null),J=!0;if(!J)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||(dn.current&1)!==0?Ln===0&&(Ln=3):Zh())),v.updateQueue!==null&&(v.flags|=4),si(v),null);case 4:return el(),Rh(p,v),p===null&&Bc(v.stateNode.containerInfo),si(v),null;case 10:return oh(v.type._context),si(v),null;case 17:return zi(v.type)&&id(),si(v),null;case 19:if(Kr(dn),J=v.memoizedState,J===null)return si(v),null;if(M=(v.flags&128)!==0,he=J.rendering,he===null)if(M)wd(J,!1);else{if(Ln!==0||p!==null&&(p.flags&128)!==0)for(p=v.child;p!==null;){if(he=pd(p),he!==null){for(v.flags|=128,wd(J,!1),M=he.updateQueue,M!==null&&(v.updateQueue=M,v.flags|=4),v.subtreeFlags=0,M=A,A=v.child;A!==null;)J=A,p=M,J.flags&=14680066,he=J.alternate,he===null?(J.childLanes=0,J.lanes=p,J.child=null,J.subtreeFlags=0,J.memoizedProps=null,J.memoizedState=null,J.updateQueue=null,J.dependencies=null,J.stateNode=null):(J.childLanes=he.childLanes,J.lanes=he.lanes,J.child=he.child,J.subtreeFlags=0,J.deletions=null,J.memoizedProps=he.memoizedProps,J.memoizedState=he.memoizedState,J.updateQueue=he.updateQueue,J.type=he.type,p=he.dependencies,J.dependencies=p===null?null:{lanes:p.lanes,firstContext:p.firstContext}),A=A.sibling;return Wr(dn,dn.current&1|2),v.child}p=p.sibling}J.tail!==null&&Ar()>Kl&&(v.flags|=128,M=!0,wd(J,!1),v.lanes=4194304)}else{if(!M)if(p=pd(he),p!==null){if(v.flags|=128,M=!0,A=p.updateQueue,A!==null&&(v.updateQueue=A,v.flags|=4),wd(J,!0),J.tail===null&&J.tailMode==="hidden"&&!he.alternate&&!on)return si(v),null}else 2*Ar()-J.renderingStartTime>Kl&&A!==1073741824&&(v.flags|=128,M=!0,wd(J,!1),v.lanes=4194304);J.isBackwards?(he.sibling=v.child,v.child=he):(A=J.last,A!==null?A.sibling=he:v.child=he,J.last=he)}return J.tail!==null?(v=J.tail,J.rendering=v,J.tail=v.sibling,J.renderingStartTime=Ar(),v.sibling=null,A=dn.current,Wr(dn,M?A&1|2:A&1),v):(si(v),null);case 22:case 23:return Jh(),M=v.memoizedState!==null,p!==null&&p.memoizedState!==null!==M&&(v.flags|=8192),M&&(v.mode&1)!==0?(is&1073741824)!==0&&(si(v),v.subtreeFlags&6&&(v.flags|=8192)):si(v),null;case 24:return null;case 25:return null}throw Error(n(156,v.tag))}function nx(p,v){switch(Yf(v),v.tag){case 1:return zi(v.type)&&id(),p=v.flags,p&65536?(v.flags=p&-65537|128,v):null;case 3:return el(),Kr(Bi),Kr(_i),hh(),p=v.flags,(p&65536)!==0&&(p&128)===0?(v.flags=p&-65537|128,v):null;case 5:return dh(v),null;case 13:if(Kr(dn),p=v.memoizedState,p!==null&&p.dehydrated!==null){if(v.alternate===null)throw Error(n(340));Yo()}return p=v.flags,p&65536?(v.flags=p&-65537|128,v):null;case 19:return Kr(dn),null;case 4:return el(),null;case 10:return oh(v.type._context),null;case 22:case 23:return Jh(),null;case 24:return null;default:return null}}var Mh=!1,ai=!1,ix=typeof WeakSet=="function"?WeakSet:Set,Mt=null;function Vl(p,v){var A=p.ref;if(A!==null)if(typeof A=="function")try{A(null)}catch(M){fn(p,v,M)}else A.current=null}function Ih(p,v,A){try{A()}catch(M){fn(p,v,M)}}var Dg=!1;function sx(p,v){if(Uf=lo,p=Rf(),Mf(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 V=M.anchorOffset,J=M.focusNode;M=M.focusOffset;try{A.nodeType,J.nodeType}catch{A=null;break e}var he=0,ke=-1,Re=-1,Xe=0,ft=0,ht=p,dt=null;t:for(;;){for(var Tt;ht!==A||V!==0&&ht.nodeType!==3||(ke=he+V),ht!==J||M!==0&&ht.nodeType!==3||(Re=he+M),ht.nodeType===3&&(he+=ht.nodeValue.length),(Tt=ht.firstChild)!==null;)dt=ht,ht=Tt;for(;;){if(ht===p)break t;if(dt===A&&++Xe===V&&(ke=he),dt===J&&++ft===M&&(Re=he),(Tt=ht.nextSibling)!==null)break;ht=dt,dt=ht.parentNode}ht=Tt}A=ke===-1||Re===-1?null:{start:ke,end:Re}}else A=null}A=A||{start:0,end:0}}else A=null;for(Wf={focusedElem:p,selectionRange:A},lo=!1,Mt=v;Mt!==null;)if(v=Mt,p=v.child,(v.subtreeFlags&1028)!==0&&p!==null)p.return=v,Mt=p;else for(;Mt!==null;){v=Mt;try{var It=v.alternate;if((v.flags&1024)!==0)switch(v.tag){case 0:case 11:case 15:break;case 1:if(It!==null){var Lt=It.memoizedProps,qr=It.memoizedState,Ge=v.stateNode,Be=Ge.getSnapshotBeforeUpdate(v.elementType===v.type?Lt:An(v.type,Lt),qr);Ge.__reactInternalSnapshotBeforeUpdate=Be}break;case 3:var Ye=v.stateNode.containerInfo;Ye.nodeType===1?Ye.textContent="":Ye.nodeType===9&&Ye.documentElement&&Ye.removeChild(Ye.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(vt){fn(v,v.return,vt)}if(p=v.sibling,p!==null){p.return=v.return,Mt=p;break}Mt=v.return}return It=Dg,Dg=!1,It}function Yc(p,v,A){var M=v.updateQueue;if(M=M!==null?M.lastEffect:null,M!==null){var V=M=M.next;do{if((V.tag&p)===p){var J=V.destroy;V.destroy=void 0,J!==void 0&&Ih(v,A,J)}V=V.next}while(V!==M)}}function Dh(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 Lh(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 Lg(p){var v=p.alternate;v!==null&&(p.alternate=null,Lg(v)),p.child=null,p.deletions=null,p.sibling=null,p.tag===5&&(v=p.stateNode,v!==null&&(delete v[ca],delete v[Fc],delete v[Gf],delete v[Vm],delete v[Gm])),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 Bg(p){return p.tag===5||p.tag===3||p.tag===4}function zg(p){e:for(;;){for(;p.sibling===null;){if(p.return===null||Bg(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 Bh(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=rd));else if(M!==4&&(p=p.child,p!==null))for(Bh(p,v,A),p=p.sibling;p!==null;)Bh(p,v,A),p=p.sibling}function zh(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(zh(p,v,A),p=p.sibling;p!==null;)zh(p,v,A),p=p.sibling}var qn=null,Us=!1;function vo(p,v,A){for(A=A.child;A!==null;)ax(p,v,A),A=A.sibling}function ax(p,v,A){if(Rn&&typeof Rn.onCommitFiberUnmount=="function")try{Rn.onCommitFiberUnmount(Ii,A)}catch{}switch(A.tag){case 5:ai||Vl(A,v);case 6:var M=qn,V=Us;qn=null,vo(p,v,A),qn=M,Us=V,qn!==null&&(Us?(p=qn,A=A.stateNode,p.nodeType===8?p.parentNode.removeChild(A):p.removeChild(A)):qn.removeChild(A.stateNode));break;case 18:qn!==null&&(Us?(p=qn,A=A.stateNode,p.nodeType===8?Vf(p.parentNode,A):p.nodeType===1&&Vf(p,A),Aa(p)):Vf(qn,A.stateNode));break;case 4:M=qn,V=Us,qn=A.stateNode.containerInfo,Us=!0,vo(p,v,A),qn=M,Us=V;break;case 0:case 11:case 14:case 15:if(!ai&&(M=A.updateQueue,M!==null&&(M=M.lastEffect,M!==null))){V=M=M.next;do{var J=V,he=J.destroy;J=J.tag,he!==void 0&&((J&2)!==0||(J&4)!==0)&&Ih(A,v,he),V=V.next}while(V!==M)}vo(p,v,A);break;case 1:if(!ai&&(Vl(A,v),M=A.stateNode,typeof M.componentWillUnmount=="function"))try{M.props=A.memoizedProps,M.state=A.memoizedState,M.componentWillUnmount()}catch(ke){fn(A,v,ke)}vo(p,v,A);break;case 21:vo(p,v,A);break;case 22:A.mode&1?(ai=(M=ai)||A.memoizedState!==null,vo(p,v,A),ai=M):vo(p,v,A);break;default:vo(p,v,A)}}function Jc(p){var v=p.updateQueue;if(v!==null){p.updateQueue=null;var A=p.stateNode;A===null&&(A=p.stateNode=new ix),v.forEach(function(M){var V=hx.bind(null,p,M);A.has(M)||(A.add(M),M.then(V,V))})}}function ws(p,v){var A=v.deletions;if(A!==null)for(var M=0;M<A.length;M++){var V=A[M];try{var J=p,he=v,ke=he;e:for(;ke!==null;){switch(ke.tag){case 5:qn=ke.stateNode,Us=!1;break e;case 3:qn=ke.stateNode.containerInfo,Us=!0;break e;case 4:qn=ke.stateNode.containerInfo,Us=!0;break e}ke=ke.return}if(qn===null)throw Error(n(160));ax(J,he,V),qn=null,Us=!1;var Re=V.alternate;Re!==null&&(Re.return=null),V.return=null}catch(Xe){fn(V,v,Xe)}}if(v.subtreeFlags&12854)for(v=v.child;v!==null;)Fh(v,p),v=v.sibling}function Fh(p,v){var A=p.alternate,M=p.flags;switch(p.tag){case 0:case 11:case 14:case 15:if(ws(v,p),Ws(p),M&4){try{Yc(3,p,p.return),Dh(3,p)}catch(Lt){fn(p,p.return,Lt)}try{Yc(5,p,p.return)}catch(Lt){fn(p,p.return,Lt)}}break;case 1:ws(v,p),Ws(p),M&512&&A!==null&&Vl(A,A.return);break;case 5:if(ws(v,p),Ws(p),M&512&&A!==null&&Vl(A,A.return),p.flags&32){var V=p.stateNode;try{Pt(V,"")}catch(Lt){fn(p,p.return,Lt)}}if(M&4&&(V=p.stateNode,V!=null)){var J=p.memoizedProps,he=A!==null?A.memoizedProps:J,ke=p.type,Re=p.updateQueue;if(p.updateQueue=null,Re!==null)try{ke==="input"&&J.type==="radio"&&J.name!=null&&Me(V,J),kr(ke,he);var Xe=kr(ke,J);for(he=0;he<Re.length;he+=2){var ft=Re[he],ht=Re[he+1];ft==="style"?Tl(V,ht):ft==="dangerouslySetInnerHTML"?Ct(V,ht):ft==="children"?Pt(V,ht):C(V,ft,ht,Xe)}switch(ke){case"input":Ue(V,J);break;case"textarea":Qr(V,J);break;case"select":var dt=V._wrapperState.wasMultiple;V._wrapperState.wasMultiple=!!J.multiple;var Tt=J.value;Tt!=null?Yt(V,!!J.multiple,Tt,!1):dt!==!!J.multiple&&(J.defaultValue!=null?Yt(V,!!J.multiple,J.defaultValue,!0):Yt(V,!!J.multiple,J.multiple?[]:"",!1))}V[Fc]=J}catch(Lt){fn(p,p.return,Lt)}}break;case 6:if(ws(v,p),Ws(p),M&4){if(p.stateNode===null)throw Error(n(162));V=p.stateNode,J=p.memoizedProps;try{V.nodeValue=J}catch(Lt){fn(p,p.return,Lt)}}break;case 3:if(ws(v,p),Ws(p),M&4&&A!==null&&A.memoizedState.isDehydrated)try{Aa(v.containerInfo)}catch(Lt){fn(p,p.return,Lt)}break;case 4:ws(v,p),Ws(p);break;case 13:ws(v,p),Ws(p),V=p.child,V.flags&8192&&(J=V.memoizedState!==null,V.stateNode.isHidden=J,!J||V.alternate!==null&&V.alternate.memoizedState!==null||(Hh=Ar())),M&4&&Jc(p);break;case 22:if(ft=A!==null&&A.memoizedState!==null,p.mode&1?(ai=(Xe=ai)||ft,ws(v,p),ai=Xe):ws(v,p),Ws(p),M&8192){if(Xe=p.memoizedState!==null,(p.stateNode.isHidden=Xe)&&!ft&&(p.mode&1)!==0)for(Mt=p,ft=p.child;ft!==null;){for(ht=Mt=ft;Mt!==null;){switch(dt=Mt,Tt=dt.child,dt.tag){case 0:case 11:case 14:case 15:Yc(4,dt,dt.return);break;case 1:Vl(dt,dt.return);var It=dt.stateNode;if(typeof It.componentWillUnmount=="function"){M=dt,A=dt.return;try{v=M,It.props=v.memoizedProps,It.state=v.memoizedState,It.componentWillUnmount()}catch(Lt){fn(M,A,Lt)}}break;case 5:Vl(dt,dt.return);break;case 22:if(dt.memoizedState!==null){Uh(ht);continue}}Tt!==null?(Tt.return=dt,Mt=Tt):Uh(ht)}ft=ft.sibling}e:for(ft=null,ht=p;;){if(ht.tag===5){if(ft===null){ft=ht;try{V=ht.stateNode,Xe?(J=V.style,typeof J.setProperty=="function"?J.setProperty("display","none","important"):J.display="none"):(ke=ht.stateNode,Re=ht.memoizedProps.style,he=Re!=null&&Re.hasOwnProperty("display")?Re.display:null,ke.style.display=Jn("display",he))}catch(Lt){fn(p,p.return,Lt)}}}else if(ht.tag===6){if(ft===null)try{ht.stateNode.nodeValue=Xe?"":ht.memoizedProps}catch(Lt){fn(p,p.return,Lt)}}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;ft===ht&&(ft=null),ht=ht.return}ft===ht&&(ft=null),ht.sibling.return=ht.return,ht=ht.sibling}}break;case 19:ws(v,p),Ws(p),M&4&&Jc(p);break;case 21:break;default:ws(v,p),Ws(p)}}function Ws(p){var v=p.flags;if(v&2){try{e:{for(var A=p.return;A!==null;){if(Bg(A)){var M=A;break e}A=A.return}throw Error(n(160))}switch(M.tag){case 5:var V=M.stateNode;M.flags&32&&(Pt(V,""),M.flags&=-33);var J=zg(p);zh(p,J,V);break;case 3:case 4:var he=M.stateNode.containerInfo,ke=zg(p);Bh(p,ke,he);break;default:throw Error(n(161))}}catch(Re){fn(p,p.return,Re)}p.flags&=-3}v&4096&&(p.flags&=-4097)}function Fg(p,v,A){Mt=p,Ug(p)}function Ug(p,v,A){for(var M=(p.mode&1)!==0;Mt!==null;){var V=Mt,J=V.child;if(V.tag===22&&M){var he=V.memoizedState!==null||Mh;if(!he){var ke=V.alternate,Re=ke!==null&&ke.memoizedState!==null||ai;ke=Mh;var Xe=ai;if(Mh=he,(ai=Re)&&!Xe)for(Mt=V;Mt!==null;)he=Mt,Re=he.child,he.tag===22&&he.memoizedState!==null?Wh(V):Re!==null?(Re.return=he,Mt=Re):Wh(V);for(;J!==null;)Mt=J,Ug(J),J=J.sibling;Mt=V,Mh=ke,ai=Xe}Wg(p)}else(V.subtreeFlags&8772)!==0&&J!==null?(J.return=V,Mt=J):Wg(p)}}function Wg(p){for(;Mt!==null;){var v=Mt;if((v.flags&8772)!==0){var A=v.alternate;try{if((v.flags&8772)!==0)switch(v.tag){case 0:case 11:case 15:ai||Dh(5,v);break;case 1:var M=v.stateNode;if(v.flags&4&&!ai)if(A===null)M.componentDidMount();else{var V=v.elementType===v.type?A.memoizedProps:An(v.type,A.memoizedProps);M.componentDidUpdate(V,A.memoizedState,M.__reactInternalSnapshotBeforeUpdate)}var J=v.updateQueue;J!==null&&qb(v,J,M);break;case 3:var he=v.updateQueue;if(he!==null){if(A=null,v.child!==null)switch(v.child.tag){case 5:A=v.child.stateNode;break;case 1:A=v.child.stateNode}qb(v,he,A)}break;case 5:var ke=v.stateNode;if(A===null&&v.flags&4){A=ke;var Re=v.memoizedProps;switch(v.type){case"button":case"input":case"select":case"textarea":Re.autoFocus&&A.focus();break;case"img":Re.src&&(A.src=Re.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(v.memoizedState===null){var Xe=v.alternate;if(Xe!==null){var ft=Xe.memoizedState;if(ft!==null){var ht=ft.dehydrated;ht!==null&&Aa(ht)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}ai||v.flags&512&&Lh(v)}catch(dt){fn(v,v.return,dt)}}if(v===p){Mt=null;break}if(A=v.sibling,A!==null){A.return=v.return,Mt=A;break}Mt=v.return}}function Uh(p){for(;Mt!==null;){var v=Mt;if(v===p){Mt=null;break}var A=v.sibling;if(A!==null){A.return=v.return,Mt=A;break}Mt=v.return}}function Wh(p){for(;Mt!==null;){var v=Mt;try{switch(v.tag){case 0:case 11:case 15:var A=v.return;try{Dh(4,v)}catch(Re){fn(v,A,Re)}break;case 1:var M=v.stateNode;if(typeof M.componentDidMount=="function"){var V=v.return;try{M.componentDidMount()}catch(Re){fn(v,V,Re)}}var J=v.return;try{Lh(v)}catch(Re){fn(v,J,Re)}break;case 5:var he=v.return;try{Lh(v)}catch(Re){fn(v,he,Re)}}}catch(Re){fn(v,v.return,Re)}if(v===p){Mt=null;break}var ke=v.sibling;if(ke!==null){ke.return=v.return,Mt=ke;break}Mt=v.return}}var ox=Math.ceil,_d=T.ReactCurrentDispatcher,Sd=T.ReactCurrentOwner,_s=T.ReactCurrentBatchConfig,wr=0,$n=null,kn=null,Hn=0,is=0,Gl=Na(0),Ln=0,Zc=null,il=0,kd=0,qh=0,Cd=null,Vi=null,Hh=0,Kl=1/0,yo=null,jd=!1,Vh=null,bo=null,Ed=!1,sl=null,Td=0,Qc=0,Gh=null,eu=-1,Ad=0;function Ci(){return(wr&6)!==0?Ar():eu!==-1?eu:eu=Ar()}function xo(p){return(p.mode&1)===0?1:(wr&2)!==0&&Hn!==0?Hn&-Hn:nh.transition!==null?(Ad===0&&(Ad=rs()),Ad):(p=ze,p!==0||(p=window.event,p=p===void 0?16:me(p.type)),p)}function qs(p,v,A,M){if(50<Qc)throw Qc=0,Gh=null,Error(n(185));gi(p,A,M),((wr&2)===0||p!==$n)&&(p===$n&&((wr&2)===0&&(kd|=A),Ln===4&&wo(p,Hn)),Gi(p,M),A===1&&wr===0&&(v.mode&1)===0&&(Kl=Ar()+500,ad&&ho()))}function Gi(p,v){var A=p.callbackNode;Li(p,v);var M=ia(p,p===$n?Hn:0);if(M===0)A!==null&&Wn(A),p.callbackNode=null,p.callbackPriority=0;else if(v=M&-M,p.callbackPriority!==v){if(A!=null&&Wn(A),v===1)p.tag===0?f1(Vg.bind(null,p)):Jm(Vg.bind(null,p)),zb(function(){(wr&6)===0&&ho()}),A=null;else{switch(tt(M)){case 1:A=sn;break;case 4:A=ti;break;case 16:A=Ps;break;case 536870912:A=ta;break;default:A=Ps}A=Zg(A,qg.bind(null,p))}p.callbackPriority=v,p.callbackNode=A}}function qg(p,v){if(eu=-1,Ad=0,(wr&6)!==0)throw Error(n(327));var A=p.callbackNode;if(Xl()&&p.callbackNode!==A)return null;var M=ia(p,p===$n?Hn:0);if(M===0)return null;if((M&30)!==0||(M&p.expiredLanes)!==0||v)v=$d(p,M);else{v=M;var V=wr;wr|=2;var J=lx();($n!==p||Hn!==v)&&(yo=null,Kl=Ar()+500,ol(p,v));do try{g1();break}catch(ke){Gg(p,ke)}while(!0);ah(),_d.current=J,wr=V,kn!==null?v=0:($n=null,Hn=0,v=Ln)}if(v!==0){if(v===2&&(V=Ea(p),V!==0&&(M=V,v=Kh(p,V))),v===1)throw A=Zc,ol(p,0),wo(p,M),Gi(p,Ar()),A;if(v===6)wo(p,M);else{if(V=p.current.alternate,(M&30)===0&&!Hg(V)&&(v=$d(p,M),v===2&&(J=Ea(p),J!==0&&(M=J,v=Kh(p,J))),v===1))throw A=Zc,ol(p,0),wo(p,M),Gi(p,Ar()),A;switch(p.finishedWork=V,p.finishedLanes=M,v){case 0:case 1:throw Error(n(345));case 2:ll(p,Vi,yo);break;case 3:if(wo(p,M),(M&130023424)===M&&(v=Hh+500-Ar(),10<v)){if(ia(p,0)!==0)break;if(V=p.suspendedLanes,(V&M)!==M){Ci(),p.pingedLanes|=p.suspendedLanes&V;break}p.timeoutHandle=Hf(ll.bind(null,p,Vi,yo),v);break}ll(p,Vi,yo);break;case 4:if(wo(p,M),(M&4194240)===M)break;for(v=p.eventTimes,V=-1;0<M;){var he=31-an(M);J=1<<he,he=v[he],he>V&&(V=he),M&=~J}if(M=V,M=Ar()-M,M=(120>M?120:480>M?480:1080>M?1080:1920>M?1920:3e3>M?3e3:4320>M?4320:1960*ox(M/1960))-M,10<M){p.timeoutHandle=Hf(ll.bind(null,p,Vi,yo),M);break}ll(p,Vi,yo);break;case 5:ll(p,Vi,yo);break;default:throw Error(n(329))}}}return Gi(p,Ar()),p.callbackNode===A?qg.bind(null,p):null}function Kh(p,v){var A=Cd;return p.current.memoizedState.isDehydrated&&(ol(p,v).flags|=256),p=$d(p,v),p!==2&&(v=Vi,Vi=A,v!==null&&Xh(v)),p}function Xh(p){Vi===null?Vi=p:Vi.push.apply(Vi,p)}function Hg(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 V=A[M],J=V.getSnapshot;V=V.value;try{if(!Bs(J(),V))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&=~qh,v&=~kd,p.suspendedLanes|=v,p.pingedLanes&=~v,p=p.expirationTimes;0<v;){var A=31-an(v),M=1<<A;p[A]=-1,v&=~M}}function Vg(p){if((wr&6)!==0)throw Error(n(327));Xl();var v=ia(p,0);if((v&1)===0)return Gi(p,Ar()),null;var A=$d(p,v);if(p.tag!==0&&A===2){var M=Ea(p);M!==0&&(v=M,A=Kh(p,M))}if(A===1)throw A=Zc,ol(p,0),wo(p,v),Gi(p,Ar()),A;if(A===6)throw Error(n(345));return p.finishedWork=p.current.alternate,p.finishedLanes=v,ll(p,Vi,yo),Gi(p,Ar()),null}function Yh(p,v){var A=wr;wr|=1;try{return p(v)}finally{wr=A,wr===0&&(Kl=Ar()+500,ad&&ho())}}function al(p){sl!==null&&sl.tag===0&&(wr&6)===0&&Xl();var v=wr;wr|=1;var A=_s.transition,M=ze;try{if(_s.transition=null,ze=1,p)return p()}finally{ze=M,_s.transition=A,wr=v,(wr&6)===0&&ho()}}function Jh(){is=Gl.current,Kr(Gl)}function ol(p,v){p.finishedWork=null,p.finishedLanes=0;var A=p.timeoutHandle;if(A!==-1&&(p.timeoutHandle=-1,Bb(A)),kn!==null)for(A=kn.return;A!==null;){var M=A;switch(Yf(M),M.tag){case 1:M=M.type.childContextTypes,M!=null&&id();break;case 3:el(),Kr(Bi),Kr(_i),hh();break;case 5:dh(M);break;case 4:el();break;case 13:Kr(dn);break;case 19:Kr(dn);break;case 10:oh(M.type._context);break;case 22:case 23:Jh()}A=A.return}if($n=p,kn=p=_o(p.current,null),Hn=is=v,Ln=0,Zc=null,qh=kd=il=0,Vi=Cd=null,Wl!==null){for(v=0;v<Wl.length;v++)if(A=Wl[v],M=A.interleaved,M!==null){A.interleaved=null;var V=M.next,J=A.pending;if(J!==null){var he=J.next;J.next=V,M.next=he}A.pending=M}Wl=null}return p}function Gg(p,v){do{var A=kn;try{if(ah(),ph.current=yd,gh){for(var M=ln.memoizedState;M!==null;){var V=M.queue;V!==null&&(V.pending=null),M=M.next}gh=!1}if(tl=0,Dn=Tn=ln=null,rl=!1,go=0,Sd.current=null,A===null||A.return===null){Ln=1,Zc=v,kn=null;break}e:{var J=p,he=A.return,ke=A,Re=v;if(v=Hn,ke.flags|=32768,Re!==null&&typeof Re=="object"&&typeof Re.then=="function"){var Xe=Re,ft=ke,ht=ft.tag;if((ft.mode&1)===0&&(ht===0||ht===11||ht===15)){var dt=ft.alternate;dt?(ft.updateQueue=dt.updateQueue,ft.memoizedState=dt.memoizedState,ft.lanes=dt.lanes):(ft.updateQueue=null,ft.memoizedState=null)}var Tt=Qb(he);if(Tt!==null){Tt.flags&=-257,ki(Tt,he,ke,J,v),Tt.mode&1&&jg(J,Xe,v),v=Tt,Re=Xe;var It=v.updateQueue;if(It===null){var Lt=new Set;Lt.add(Re),v.updateQueue=Lt}else It.add(Re);break e}else{if((v&1)===0){jg(J,Xe,v),Zh();break e}Re=Error(n(426))}}else if(on&&ke.mode&1){var qr=Qb(he);if(qr!==null){(qr.flags&65536)===0&&(qr.flags|=256),ki(qr,he,ke,J,v),rh(Hl(Re,ke));break e}}J=Re=Hl(Re,ke),Ln!==4&&(Ln=2),Cd===null?Cd=[J]:Cd.push(J),J=he;do{switch(J.tag){case 3:J.flags|=65536,v&=-v,J.lanes|=v;var Ge=kg(J,Re,v);Wb(J,Ge);break e;case 1:ke=Re;var Be=J.type,Ye=J.stateNode;if((J.flags&128)===0&&(typeof Be.getDerivedStateFromError=="function"||Ye!==null&&typeof Ye.componentDidCatch=="function"&&(bo===null||!bo.has(Ye)))){J.flags|=65536,v&=-v,J.lanes|=v;var vt=Cg(J,ke,v);Wb(J,vt);break e}}J=J.return}while(J!==null)}tu(A)}catch(qt){v=qt,kn===A&&A!==null&&(kn=A=A.return);continue}break}while(!0)}function lx(){var p=_d.current;return _d.current=yd,p===null?yd:p}function Zh(){(Ln===0||Ln===3||Ln===2)&&(Ln=4),$n===null||(il&268435455)===0&&(kd&268435455)===0||wo($n,Hn)}function $d(p,v){var A=wr;wr|=2;var M=lx();($n!==p||Hn!==v)&&(yo=null,ol(p,v));do try{cx();break}catch(V){Gg(p,V)}while(!0);if(ah(),wr=A,_d.current=M,kn!==null)throw Error(n(261));return $n=null,Hn=0,Ln}function cx(){for(;kn!==null;)Kg(kn)}function g1(){for(;kn!==null&&!$l();)Kg(kn)}function Kg(p){var v=Jg(p.alternate,p,is);p.memoizedProps=p.pendingProps,v===null?tu(p):kn=v,Sd.current=null}function tu(p){var v=p;do{var A=v.alternate;if(p=v.return,(v.flags&32768)===0){if(A=rx(A,v,is),A!==null){kn=A;return}}else{if(A=nx(A,v),A!==null){A.flags&=32767,kn=A;return}if(p!==null)p.flags|=32768,p.subtreeFlags=0,p.deletions=null;else{Ln=6,kn=null;return}}if(v=v.sibling,v!==null){kn=v;return}kn=v=p}while(v!==null);Ln===0&&(Ln=5)}function ll(p,v,A){var M=ze,V=_s.transition;try{_s.transition=null,ze=1,Xg(p,v,A,M)}finally{_s.transition=V,ze=M}return null}function Xg(p,v,A,M){do Xl();while(sl!==null);if((wr&6)!==0)throw Error(n(327));A=p.finishedWork;var V=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 J=A.lanes|A.childLanes;if(yt(p,J),p===$n&&(kn=$n=null,Hn=0),(A.subtreeFlags&2064)===0&&(A.flags&2064)===0||Ed||(Ed=!0,Zg(Ps,function(){return Xl(),null})),J=(A.flags&15990)!==0,(A.subtreeFlags&15990)!==0||J){J=_s.transition,_s.transition=null;var he=ze;ze=1;var ke=wr;wr|=4,Sd.current=null,sx(p,A),Fh(A,p),Rb(Wf),lo=!!Uf,Wf=Uf=null,p.current=A,Fg(A),Nl(),wr=ke,ze=he,_s.transition=J}else p.current=A;if(Ed&&(Ed=!1,sl=p,Td=V),J=p.pendingLanes,J===0&&(bo=null),Wt(A.stateNode),Gi(p,Ar()),v!==null)for(M=p.onRecoverableError,A=0;A<v.length;A++)V=v[A],M(V.value,{componentStack:V.stack,digest:V.digest});if(jd)throw jd=!1,p=Vh,Vh=null,p;return(Td&1)!==0&&p.tag!==0&&Xl(),J=p.pendingLanes,(J&1)!==0?p===Gh?Qc++:(Qc=0,Gh=p):Qc=0,ho(),null}function Xl(){if(sl!==null){var p=tt(Td),v=_s.transition,A=ze;try{if(_s.transition=null,ze=16>p?16:p,sl===null)var M=!1;else{if(p=sl,sl=null,Td=0,(wr&6)!==0)throw Error(n(331));var V=wr;for(wr|=4,Mt=p.current;Mt!==null;){var J=Mt,he=J.child;if((Mt.flags&16)!==0){var ke=J.deletions;if(ke!==null){for(var Re=0;Re<ke.length;Re++){var Xe=ke[Re];for(Mt=Xe;Mt!==null;){var ft=Mt;switch(ft.tag){case 0:case 11:case 15:Yc(8,ft,J)}var ht=ft.child;if(ht!==null)ht.return=ft,Mt=ht;else for(;Mt!==null;){ft=Mt;var dt=ft.sibling,Tt=ft.return;if(Lg(ft),ft===Xe){Mt=null;break}if(dt!==null){dt.return=Tt,Mt=dt;break}Mt=Tt}}}var It=J.alternate;if(It!==null){var Lt=It.child;if(Lt!==null){It.child=null;do{var qr=Lt.sibling;Lt.sibling=null,Lt=qr}while(Lt!==null)}}Mt=J}}if((J.subtreeFlags&2064)!==0&&he!==null)he.return=J,Mt=he;else e:for(;Mt!==null;){if(J=Mt,(J.flags&2048)!==0)switch(J.tag){case 0:case 11:case 15:Yc(9,J,J.return)}var Ge=J.sibling;if(Ge!==null){Ge.return=J.return,Mt=Ge;break e}Mt=J.return}}var Be=p.current;for(Mt=Be;Mt!==null;){he=Mt;var Ye=he.child;if((he.subtreeFlags&2064)!==0&&Ye!==null)Ye.return=he,Mt=Ye;else e:for(he=Be;Mt!==null;){if(ke=Mt,(ke.flags&2048)!==0)try{switch(ke.tag){case 0:case 11:case 15:Dh(9,ke)}}catch(qt){fn(ke,ke.return,qt)}if(ke===he){Mt=null;break e}var vt=ke.sibling;if(vt!==null){vt.return=ke.return,Mt=vt;break e}Mt=ke.return}}if(wr=V,ho(),Rn&&typeof Rn.onPostCommitFiberRoot=="function")try{Rn.onPostCommitFiberRoot(Ii,p)}catch{}M=!0}return M}finally{ze=A,_s.transition=v}}return!1}function Yg(p,v,A){v=Hl(A,v),v=kg(p,v,1),p=mo(p,v,1),v=Ci(),p!==null&&(gi(p,1,v),Gi(p,v))}function fn(p,v,A){if(p.tag===3)Yg(p,p,A);else for(;v!==null;){if(v.tag===3){Yg(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=Hl(A,p),p=Cg(v,p,1),v=mo(v,p,1),p=Ci(),v!==null&&(gi(v,1,p),Gi(v,p));break}}v=v.return}}function ux(p,v,A){var M=p.pingCache;M!==null&&M.delete(v),v=Ci(),p.pingedLanes|=p.suspendedLanes&A,$n===p&&(Hn&A)===A&&(Ln===4||Ln===3&&(Hn&130023424)===Hn&&500>Ar()-Hh?ol(p,0):qh|=A),Gi(p,v)}function dx(p,v){v===0&&((p.mode&1)===0?v=1:(v=mi,mi<<=1,(mi&130023424)===0&&(mi=4194304)));var A=Ci();p=Pa(p,v),p!==null&&(gi(p,v,A),Gi(p,A))}function fx(p){var v=p.memoizedState,A=0;v!==null&&(A=v.retryLane),dx(p,A)}function hx(p,v){var A=0;switch(p.tag){case 13:var M=p.stateNode,V=p.memoizedState;V!==null&&(A=V.retryLane);break;case 19:M=p.stateNode;break;default:throw Error(n(314))}M!==null&&M.delete(v),dx(p,A)}var Jg;Jg=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,m1(p,v,A);Hi=(p.flags&131072)!==0}else Hi=!1,on&&(v.flags&1048576)!==0&&Xo(v,ld,v.index);switch(v.lanes=0,v.tag){case 2:var M=v.type;xd(p,v),p=v.pendingProps;var V=Si(v,_i.current);Ul(v,A),V=yh(null,v,M,p,V,A);var J=bh();return v.flags|=1,typeof V=="object"&&V!==null&&typeof V.render=="function"&&V.$$typeof===void 0?(v.tag=1,v.memoizedState=null,v.updateQueue=null,zi(M)?(J=!0,sd(v)):J=!1,v.memoizedState=V.state!==null&&V.state!==void 0?V.state:null,fd(v),V.updater=Ma,v.stateNode=V,V._reactInternals=v,Sh(v,M,p,A),v=Eh(null,v,M,!0,J,A)):(v.tag=0,on&&J&&En(v),ii(null,v,V,A),v=v.child),v;case 16:M=v.elementType;e:{switch(xd(p,v),p=v.pendingProps,V=M._init,M=V(M._payload),v.type=M,V=v.tag=px(M),p=An(M,p),V){case 0:v=jh(null,v,M,p,A);break e;case 1:v=Ng(null,v,M,p,A);break e;case 11:v=Eg(null,v,M,p,A);break e;case 14:v=Kc(null,v,M,An(M.type,p),A);break e}throw Error(n(306,M,""))}return v;case 0:return M=v.type,V=v.pendingProps,V=v.elementType===M?V:An(M,V),jh(p,v,M,V,A);case 1:return M=v.type,V=v.pendingProps,V=v.elementType===M?V:An(M,V),Ng(p,v,M,V,A);case 3:e:{if(Th(v),p===null)throw Error(n(387));M=v.pendingProps,J=v.memoizedState,V=J.element,ch(p,v),hd(v,M,null,A);var he=v.memoizedState;if(M=he.element,J.isDehydrated)if(J={element:M,isDehydrated:!1,cache:he.cache,pendingSuspenseBoundaries:he.pendingSuspenseBoundaries,transitions:he.transitions},v.updateQueue.baseState=J,v.memoizedState=J,v.flags&256){V=Hl(Error(n(423)),v),v=Og(p,v,M,A,V);break e}else if(M!==V){V=Hl(Error(n(424)),v),v=Og(p,v,M,A,V);break e}else for(ns=uo(v.stateNode.containerInfo.firstChild),Wi=v,on=!0,qi=null,A=ih(v,null,M,A),v.child=A;A;)A.flags=A.flags&-3|4096,A=A.sibling;else{if(Yo(),M===V){v=Ia(p,v,A);break e}ii(p,v,M,A)}v=v.child}return v;case 5:return tg(v),p===null&&eh(v),M=v.type,V=v.pendingProps,J=p!==null?p.memoizedProps:null,he=V.children,qf(M,V)?he=null:J!==null&&qf(M,J)&&(v.flags|=32),$g(p,v),ii(p,v,he,A),v.child;case 6:return p===null&&eh(v),null;case 13:return Pg(p,v,A);case 4:return uh(v,v.stateNode.containerInfo),M=v.pendingProps,p===null?v.child=Fl(v,null,M,A):ii(p,v,M,A),v.child;case 11:return M=v.type,V=v.pendingProps,V=v.elementType===M?V:An(M,V),Eg(p,v,M,V,A);case 7:return ii(p,v,v.pendingProps,A),v.child;case 8:return ii(p,v,v.pendingProps.children,A),v.child;case 12:return ii(p,v,v.pendingProps.children,A),v.child;case 10:e:{if(M=v.type._context,V=v.pendingProps,J=v.memoizedProps,he=V.value,Wr(Jo,M._currentValue),M._currentValue=he,J!==null)if(Bs(J.value,he)){if(J.children===V.children&&!Bi.current){v=Ia(p,v,A);break e}}else for(J=v.child,J!==null&&(J.return=v);J!==null;){var ke=J.dependencies;if(ke!==null){he=J.child;for(var Re=ke.firstContext;Re!==null;){if(Re.context===M){if(J.tag===1){Re=Ra(-1,A&-A),Re.tag=2;var Xe=J.updateQueue;if(Xe!==null){Xe=Xe.shared;var ft=Xe.pending;ft===null?Re.next=Re:(Re.next=ft.next,ft.next=Re),Xe.pending=Re}}J.lanes|=A,Re=J.alternate,Re!==null&&(Re.lanes|=A),eg(J.return,A,v),ke.lanes|=A;break}Re=Re.next}}else if(J.tag===10)he=J.type===v.type?null:J.child;else if(J.tag===18){if(he=J.return,he===null)throw Error(n(341));he.lanes|=A,ke=he.alternate,ke!==null&&(ke.lanes|=A),eg(he,A,v),he=J.sibling}else he=J.child;if(he!==null)he.return=J;else for(he=J;he!==null;){if(he===v){he=null;break}if(J=he.sibling,J!==null){J.return=he.return,he=J;break}he=he.return}J=he}ii(p,v,V.children,A),v=v.child}return v;case 9:return V=v.type,M=v.pendingProps.children,Ul(v,A),V=bs(V),M=M(V),v.flags|=1,ii(p,v,M,A),v.child;case 14:return M=v.type,V=An(M,v.pendingProps),V=An(M.type,V),Kc(p,v,M,V,A);case 15:return Tg(p,v,v.type,v.pendingProps,A);case 17:return M=v.type,V=v.pendingProps,V=v.elementType===M?V:An(M,V),xd(p,v),v.tag=1,zi(M)?(p=!0,sd(v)):p=!1,Ul(v,A),_g(v,M,V),Sh(v,M,V,A),Eh(null,v,M,!0,p,A);case 19:return Oh(p,v,A);case 22:return Ag(p,v,A)}throw Error(n(156,v.tag))};function Zg(p,v){return Wo(p,v)}function v1(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 ss(p,v,A,M){return new v1(p,v,A,M)}function Qh(p){return p=p.prototype,!(!p||!p.isReactComponent)}function px(p){if(typeof p=="function")return Qh(p)?1:0;if(p!=null){if(p=p.$$typeof,p===U)return 11;if(p===Y)return 14}return 2}function _o(p,v){var A=p.alternate;return A===null?(A=ss(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 Nd(p,v,A,M,V,J){var he=2;if(M=p,typeof p=="function")Qh(p)&&(he=1);else if(typeof p=="string")he=5;else e:switch(p){case N:return Yl(A.children,V,J,v);case P:he=8,V|=8;break;case I:return p=ss(12,A,v,V|2),p.elementType=I,p.lanes=J,p;case q:return p=ss(13,A,v,V),p.elementType=q,p.lanes=J,p;case z:return p=ss(19,A,v,V),p.elementType=z,p.lanes=J,p;case se:return Od(A,V,J,v);default:if(typeof p=="object"&&p!==null)switch(p.$$typeof){case W:he=10;break e;case F:he=9;break e;case U:he=11;break e;case Y:he=14;break e;case ee:he=16,M=null;break e}throw Error(n(130,p==null?p:typeof p,""))}return v=ss(he,A,v,V),v.elementType=p,v.type=M,v.lanes=J,v}function Yl(p,v,A,M){return p=ss(7,p,M,v),p.lanes=A,p}function Od(p,v,A,M){return p=ss(22,p,M,v),p.elementType=se,p.lanes=A,p.stateNode={isHidden:!1},p}function ep(p,v,A){return p=ss(6,p,null,v),p.lanes=A,p}function tp(p,v,A){return v=ss(4,p.children!==null?p.children:[],p.key,v),v.lanes=A,v.stateNode={containerInfo:p.containerInfo,pendingChildren:null,implementation:p.implementation},v}function y1(p,v,A,M,V){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=V,this.mutableSourceEagerHydrationData=null}function rp(p,v,A,M,V,J,he,ke,Re){return p=new y1(p,v,A,ke,Re),v===1?(v=1,J===!0&&(v|=8)):v=0,J=ss(3,null,null,v),p.current=J,J.stateNode=p,J.memoizedState={element:M,isDehydrated:A,cache:null,transitions:null,pendingSuspenseBoundaries:null},fd(J),p}function b1(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 Qg(p){if(!p)return fo;p=p._reactInternals;e:{if(Et(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 Xm(p,A,v)}return v}function mx(p,v,A,M,V,J,he,ke,Re){return p=rp(A,M,!0,p,V,J,he,ke,Re),p.context=Qg(null),A=p.current,M=Ci(),V=xo(A),J=Ra(M,V),J.callback=v??null,mo(A,J,V),p.current.lanes=V,gi(p,V,M),Gi(p,M),p}function Pd(p,v,A,M){var V=v.current,J=Ci(),he=xo(V);return A=Qg(A),v.context===null?v.context=A:v.pendingContext=A,v=Ra(J,he),v.payload={element:p},M=M===void 0?null:M,M!==null&&(v.callback=M),p=mo(V,v,he),p!==null&&(qs(p,V,he,J),qc(p,V,he)),he}function Rd(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 ev(p,v){if(p=p.memoizedState,p!==null&&p.dehydrated!==null){var A=p.retryLane;p.retryLane=A!==0&&A<v?A:v}}function np(p,v){ev(p,v),(p=p.alternate)&&ev(p,v)}function gx(){return null}var vx=typeof reportError=="function"?reportError:function(p){console.error(p)};function ip(p){this._internalRoot=p}Jl.prototype.render=ip.prototype.render=function(p){var v=this._internalRoot;if(v===null)throw Error(n(409));Pd(p,v,null,null)},Jl.prototype.unmount=ip.prototype.unmount=function(){var p=this._internalRoot;if(p!==null){this._internalRoot=null;var v=p.containerInfo;al(function(){Pd(null,p,null,null)}),v[ua]=null}};function Jl(p){this._internalRoot=p}Jl.prototype.unstable_scheduleHydration=function(p){if(p){var v=Br();p={blockedOn:null,target:p,priority:v};for(var A=0;A<Rs.length&&v!==0&&v<Rs[A].priority;A++);Rs.splice(A,0,p),A===0&&Ec(p)}};function sp(p){return!(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11)}function Md(p){return!(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11&&(p.nodeType!==8||p.nodeValue!==" react-mount-point-unstable "))}function yx(){}function bx(p,v,A,M,V){if(V){if(typeof M=="function"){var J=M;M=function(){var Xe=Rd(he);J.call(Xe)}}var he=mx(v,M,p,0,null,!1,!1,"",yx);return p._reactRootContainer=he,p[ua]=he.current,Bc(p.nodeType===8?p.parentNode:p),al(),he}for(;V=p.lastChild;)p.removeChild(V);if(typeof M=="function"){var ke=M;M=function(){var Xe=Rd(Re);ke.call(Xe)}}var Re=rp(p,0,!1,null,null,!1,!1,"",yx);return p._reactRootContainer=Re,p[ua]=Re.current,Bc(p.nodeType===8?p.parentNode:p),al(function(){Pd(v,Re,A,M)}),Re}function ru(p,v,A,M,V){var J=A._reactRootContainer;if(J){var he=J;if(typeof V=="function"){var ke=V;V=function(){var Re=Rd(he);ke.call(Re)}}Pd(v,he,p,V)}else he=bx(A,v,p,V,M);return Rd(he)}At=function(p){switch(p.tag){case 3:var v=p.stateNode;if(v.current.memoizedState.isDehydrated){var A=fs(v.pendingLanes);A!==0&&(Se(v,A|1),Gi(v,Ar()),(wr&6)===0&&(Kl=Ar()+500,ho()))}break;case 13:al(function(){var M=Pa(p,1);if(M!==null){var V=Ci();qs(M,p,1,V)}}),np(p,1)}},ir=function(p){if(p.tag===13){var v=Pa(p,134217728);if(v!==null){var A=Ci();qs(v,p,134217728,A)}np(p,134217728)}},dr=function(p){if(p.tag===13){var v=xo(p),A=Pa(p,v);if(A!==null){var M=Ci();qs(A,p,v,M)}np(p,v)}},Br=function(){return ze},Dr=function(p,v){var A=ze;try{return ze=p,v()}finally{ze=A}},Zs=function(p,v,A){switch(v){case"input":if(Ue(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 V=nd(M);if(!V)throw Error(n(90));Te(M),Ue(M,V)}}}break;case"textarea":Qr(p,A);break;case"select":v=A.value,v!=null&&Yt(p,!!A.multiple,v,!1)}},ds=Yh,Zn=al;var tv={usingClientEntryPoint:!1,Events:[Uc,Il,nd,Qs,ea,Yh]},Hs={findFiberByHostInstance:Go,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},xx={bundleType:Hs.bundleType,version:Hs.version,rendererPackageName:Hs.rendererPackageName,rendererConfig:Hs.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=ro(p),p===null?null:p.stateNode},findFiberByHostInstance:Hs.findFiberByHostInstance||gx,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 nu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!nu.isDisabled&&nu.supportsFiber)try{Ii=nu.inject(xx),Rn=nu}catch{}}return Vs.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=tv,Vs.createPortal=function(p,v){var A=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!sp(v))throw Error(n(200));return b1(p,v,null,A)},Vs.createRoot=function(p,v){if(!sp(p))throw Error(n(299));var A=!1,M="",V=vx;return v!=null&&(v.unstable_strictMode===!0&&(A=!0),v.identifierPrefix!==void 0&&(M=v.identifierPrefix),v.onRecoverableError!==void 0&&(V=v.onRecoverableError)),v=rp(p,1,!1,null,null,A,!1,M,V),p[ua]=v.current,Bc(p.nodeType===8?p.parentNode:p),new ip(v)},Vs.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=ro(v),p=p===null?null:p.stateNode,p},Vs.flushSync=function(p){return al(p)},Vs.hydrate=function(p,v,A){if(!Md(v))throw Error(n(200));return ru(null,p,v,!0,A)},Vs.hydrateRoot=function(p,v,A){if(!sp(p))throw Error(n(405));var M=A!=null&&A.hydratedSources||null,V=!1,J="",he=vx;if(A!=null&&(A.unstable_strictMode===!0&&(V=!0),A.identifierPrefix!==void 0&&(J=A.identifierPrefix),A.onRecoverableError!==void 0&&(he=A.onRecoverableError)),v=mx(v,null,p,1,A??null,V,!1,J,he),p[ua]=v.current,Bc(p),M)for(p=0;p<M.length;p++)A=M[p],V=A._getVersion,V=V(A._source),v.mutableSourceEagerHydrationData==null?v.mutableSourceEagerHydrationData=[A,V]:v.mutableSourceEagerHydrationData.push(A,V);return new Jl(v)},Vs.render=function(p,v,A){if(!Md(v))throw Error(n(200));return ru(null,p,v,!1,A)},Vs.unmountComponentAtNode=function(p){if(!Md(p))throw Error(n(40));return p._reactRootContainer?(al(function(){ru(null,null,p,!1,function(){p._reactRootContainer=null,p[ua]=null})}),!0):!1},Vs.unstable_batchedUpdates=Yh,Vs.unstable_renderSubtreeIntoContainer=function(p,v,A,M){if(!Md(A))throw Error(n(200));if(p==null||p._reactInternals===void 0)throw Error(n(38));return ru(p,v,A,!1,M)},Vs.version="18.3.1-next-f1338f8080-20240426",Vs}var J$;function S4(){if(J$)return k1.exports;J$=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(),k1.exports=vW(),k1.exports}var Z$;function yW(){if(Z$)return Sx;Z$=1;var e=S4();return Sx.createRoot=e.createRoot,Sx.hydrateRoot=e.hydrateRoot,Sx}var bW=yW();const xW=Zr(bW);var D=GT();const He=Zr(D),Q$=e=>{let r;const n=new Set,i=(f,m)=>{const h=typeof f=="function"?f(r):f;if(!Object.is(h,r)){const b=r;r=m??(typeof h!="object"||h===null)?h:Object.assign({},r,h),n.forEach(w=>w(r,b))}},s=()=>r,l={setState:i,getState:s,getInitialState:()=>u,subscribe:f=>(n.add(f),()=>n.delete(f))},u=r=e(i,s,l);return l},wW=(e=>e?Q$(e):Q$),_W=e=>e;function SW(e,r=_W){const n=He.useSyncExternalStore(e.subscribe,He.useCallback(()=>r(e.getState()),[e,r]),He.useCallback(()=>r(e.getInitialState()),[e,r]));return He.useDebugValue(n),n}const eN=e=>{const r=wW(e),n=i=>SW(r,i);return Object.assign(n,r),n},jn=(e=>e?eN(e):eN);function Lo(e){return"'"+e.replace(/'/g,"'\\''")+"'"}const E1=({sessionId:e})=>`claude --dangerously-skip-permissions --session-id ${Lo(e)}`,tN=({sessionId:e})=>`claude --session-id ${Lo(e)}`,kW=()=>"claude --resume",k4=[{id:"sm-dangerous",label:"Session Manager (skip perms)",description:"claude --dangerously-skip-permissions in this project",category:"build",cwd:"app-cwd",command:E1},{id:"sm-safe",label:"Session Manager (safe)",description:"claude with normal permission prompts in this project",category:"build",cwd:"app-cwd",command:tN},{id:"home-dangerous",label:"Home (skip perms)",description:"claude --dangerously-skip-permissions in ~",category:"build",cwd:"home",command:E1},{id:"pick-dangerous",label:"Pick directory (skip perms)…",description:"Choose a folder, launch claude --dangerously-skip-permissions",category:"build",cwd:"pick",command:E1},{id:"pick-safe",label:"Pick directory (safe)…",description:"Choose a folder, launch claude with normal prompts",category:"build",cwd:"pick",command:tN},{id:"pick-resume",label:"Pick directory + resume…",description:"Choose a folder, then pick a past session to resume",category:"build",cwd:"pick",command:kW},{id:"pick-shell",label:"Pick directory (shell only)…",description:"Bare interactive shell, no claude auto-launch",category:"build",cwd:"pick",command:null}];let La=null;async function CW(){if(La)return La;try{const e=await window.api.app.engageRulesPath();if(!e)return La=[],La;const r=await window.api.config.readJson(e);if(!r.exists||r.parseError||!r.data)return La=[],La;const n=r.data;if(!n.presets||!Array.isArray(n.presets))return La=[],La;const i=n.projectPath;return La=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 ${Lo(i)} && ${s.cliEntry}`})),La}catch(e){return console.warn("[presets] Failed to load engage presets:",e),La=[],La}}async function C4(e){const r=k4.find(i=>i.id===e);return r||((await CW()).find(i=>i.id===e)??null)}async function rN(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 j4(e,r){return e.command?e.command(r):null}const KT=["opus","sonnet","haiku"],E4="sm.rawSessionModel",jW="opus";function EW(e){return KT.includes(e)}function TW(){try{const e=localStorage.getItem(E4);if(e&&EW(e))return e}catch{}return jW}let jp=TW();const kj=new Set;function T4(){return jp}function AW(e){if(e!==jp){jp=e;try{localStorage.setItem(E4,e)}catch{}kj.forEach(r=>r(e))}}function $W(){const[e,r]=D.useState(jp);D.useEffect(()=>{const i=s=>r(s);return kj.add(i),jp!==e&&r(jp),()=>{kj.delete(i)}},[]);const n=D.useCallback(i=>AW(i),[]);return{model:e,setModel:n}}async function A4(e,r){const n=await window.api.transcripts.pathFor(e,r);return window.api.config.exists(n)}function NW(e){const r=e.split("/").filter(Boolean);return r[r.length-1]||e}async function $4(e,r=!1,n=T4()){let i=!r;i&&(i=await A4(e.cwd,e.claudeSessionId));const s=r&&!i?crypto.randomUUID():e.claudeSessionId,a=i?`claude --dangerously-skip-permissions --resume ${Lo(s)} --model ${n}`:`claude --dangerously-skip-permissions --session-id ${Lo(s)} --model ${n}`;return{claudeSessionId:s,startupCommand:a}}const kt=jn((e,r)=>({tabs:[],activeTabId:null,hydrated:!1,addTab:({id:n,cwd:i,startupCommand:s,presetId:a=null,label:c})=>{const l=n??crypto.randomUUID();if(r().tabs.find(m=>m.id===l))return e({activeTabId:l}),l;const f={id:l,claudeSessionId:l,chatSessionId:crypto.randomUUID(),label:c??NW(i),cwd:i,pid:null,status:"spawning",exitCode:null,startupCommand:s,presetId:a,generation:0};return e({tabs:[...r().tabs,f],activeTabId:l}),l},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(c=>c.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(c=>c.id===n);if(!i)return;window.api.pty.kill(n);const s=crypto.randomUUID(),a=c=>{e({tabs:r().tabs.map(l=>l.id===n?{...l,claudeSessionId:s,pid:null,status:"spawning",exitCode:null,startupCommand:c,generation:l.generation+1}:l)})};i.presetId?C4(i.presetId).then(c=>{a(c?j4(c,{sessionId:s,cwd:i.cwd}):`claude --dangerously-skip-permissions --session-id ${Lo(s)}`)}):a(`claude --dangerously-skip-permissions --session-id ${Lo(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}),wakeTab:async(n,i)=>{const s=r().tabs.find(l=>l.id===n);if(!s||s.status!=="dormant")return;const{claudeSessionId:a,startupCommand:c}=await $4({cwd:s.cwd,claudeSessionId:s.claudeSessionId},!1,i??T4());e({tabs:r().tabs.map(l=>l.id===n?{...l,claudeSessionId:a,status:"spawning",startupCommand:c,generation:l.generation+1}:l)})},sleepTab:n=>{const i=r().tabs.find(s=>s.id===n);!i||i.status==="dormant"||(window.api.pty.kill(n),e({tabs:r().tabs.map(s=>s.id===n?{...s,pid:null,status:"dormant"}:s)}))},newChatThread:n=>{r().tabs.find(s=>s.id===n)&&e({tabs:r().tabs.map(s=>s.id===n?{...s,chatSessionId:crypto.randomUUID()}:s)})}}));async function Cj(){var n;if(kt.getState().hydrated)return;try{const{tabs:i,activeTabId:s,freshStart:a}=await window.api.sessions.load();if(i.length>0){const c=await Promise.all(i.map(async u=>{const{claudeSessionId:f}=await $4(u,a);return{id:u.id,claudeSessionId:f,chatSessionId:u.chatSessionId??crypto.randomUUID(),cwd:u.cwd,label:u.label,presetId:u.presetId,pid:null,status:"dormant",exitCode:null,startupCommand:null,generation:0}})),l=s&&c.find(u=>u.id===s)?s:((n=c[0])==null?void 0:n.id)??null;kt.getState().restoreTabs(c,l)}else kt.setState({hydrated:!0})}catch(i){console.warn("[sessions] hydrate failed:",i),kt.setState({hydrated:!0})}const e=()=>{const{tabs:i,activeTabId:s}=kt.getState(),a=i.map(c=>({id:c.id,claudeSessionId:c.claudeSessionId,chatSessionId:c.chatSessionId,cwd:c.cwd,label:c.label,presetId:c.presetId}));window.api.sessions.save({tabs:a,activeTabId:s}).catch(c=>{console.warn("[sessions] save failed:",c)})};let r=null;kt.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 OW=Object.freeze(Object.defineProperty({__proto__:null,hydrateSessions:Cj,useSessions:kt},Symbol.toStringTag,{value:"Module"})),PW=5,nN=100,RW=5e3,jj=new Map;function iN(e){const r=jj.get(e);r!==void 0&&(clearTimeout(r),jj.delete(e))}function MW(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`t-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}const Vd=jn((e,r)=>({toasts:[],history:[],unreadCount:0,show:(n,i)=>{const s=MW(),a=Date.now();e(l=>{const u=[...l.toasts,{id:s,kind:n,message:i,createdAt:a}];for(;u.length>PW;){const h=u.shift();h&&iN(h.id)}const m=[{id:s,kind:n,message:i,createdAt:a,read:!1},...l.history];return m.length>nN&&(m.length=nN),{toasts:u,history:m,unreadCount:l.unreadCount+1}});const c=setTimeout(()=>r().dismiss(s),RW);return jj.set(s,c),s},dismiss:n=>{iN(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(c=>c.id!==n);if(s.length===i.history.length)return i;const a=i.history.find(c=>c.id===n&&!c.read);return{history:s,unreadCount:a?Math.max(0,i.unreadCount-1):i.unreadCount}})}})),Ze={info:e=>Vd.getState().show("info",e),warn:e=>Vd.getState().show("warn",e),error:e=>Vd.getState().show("error",e),fromOutcome:e=>Vd.getState().show(e.kind??(e.ok?"info":"warn"),e.message)},N4=Object.freeze(Object.defineProperty({__proto__:null,toast:Ze,useToast:Vd},Symbol.toStringTag,{value:"Module"})),sN=200,IW=/\x1b\[[0-9;]*m/g;function DW(e){return e.replace(IW,"")}const ry=jn((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 c=await window.api.watchers.add({tabId:n,label:i,command:s,cwd:a??null}),l={watcherId:c.watcherId,tabId:c.tabId,label:c.label,command:c.command,cwd:c.cwd,pid:c.pid,startedAt:c.startedAt,lineCount:0,lines:[],lastLineAt:null};return e({watchers:{...r().watchers,[l.watcherId]:l}}),l}catch(c){return console.error("[watchers] add failed:",c),Ze.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);Ze.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=DW(n.line),a=i.lines.length>=sN?[...i.lines.slice(i.lines.length-sN+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})}})),LW="~/.claude/session-manager/browser/history.json",aN="~/.claude/session-manager/browser/bookmarks.json",BW=.25,zW=3,oN=.1,lN=["#b85c34","#6f7d52","#e4b85a","#5f6f86","#8a5a6e","#4f7d72"];let cN=0;function FW(){const e=lN[cN%lN.length];return cN+=1,e}const Lw=new Map;function UW(e){if(Lw.has(e))return;const r=window.api.browser.onNavState(e,n=>{Rt.setState(i=>({tabs:i.tabs.map(s=>s.viewId===e?{...s,url:n.url,title:n.title||s.title,canGoBack:n.canGoBack,canGoForward:n.canGoForward,loading:n.loading,isSecure:n.isSecure}:s)}))});Lw.set(e,r)}function WW(e){const r=Lw.get(e);r&&(r(),Lw.delete(e))}const Ej=new Map;let ww=null;function uN(e){const r=Ej.get(e);r&&(r(),Ej.delete(e))}function dN(){ww&&(clearInterval(ww),ww=null)}const Tj=new Map;function T1(e){const r=Tj.get(e);r&&(r(),Tj.delete(e))}const Rt=jn((e,r)=>({tabs:[],activeTabId:null,openTab:n=>{const i=crypto.randomUUID(),s=i,a={id:i,viewId:s,title:"New Tab",url:(n==null?void 0:n.url)??"about:blank",color:(n==null?void 0:n.color)??FW(),canGoBack:!1,canGoForward:!1,loading:!1,isSecure:!1,zoomFactor:1};return e(c=>({tabs:[...c.tabs,a],activeTabId:i})),UW(s),window.api.browser.create({viewId:s,partition:"persist:browser"}).then(()=>{n!=null&&n.url&&window.api.browser.navigate({viewId:s,url:n.url}).catch(()=>{})}).catch(c=>{var u,f;const l=c instanceof Error?c.message:String(c);(f=(u=window.api)==null?void 0:u.logs)==null||f.write("browser","error",`browser:create failed for viewId ${s}: ${l}`)}),i},closeTab:n=>{const i=r().tabs.find(s=>s.id===n);i&&(WW(i.viewId),T1(i.viewId),window.api.browser.destroy(i.viewId).catch(()=>{}),e(s=>{const a=s.tabs.filter(l=>l.id!==n),c=s.activeTabId===n?a.length?a[a.length-1].id:null:s.activeTabId;return{tabs:a,activeTabId:c}}))},setActive:n=>{e({activeTabId:n})},navigate:(n,i)=>{const s=r().tabs.find(a=>a.id===n);s&&window.api.browser.navigate({viewId:s.viewId,url:i}).catch(()=>{})},back:n=>{const i=r().tabs.find(s=>s.id===n);i&&window.api.browser.back(i.viewId).catch(()=>{})},forward:n=>{const i=r().tabs.find(s=>s.id===n);i&&window.api.browser.forward(i.viewId).catch(()=>{})},reload:n=>{const i=r().tabs.find(s=>s.id===n);i&&window.api.browser.reload(i.viewId).catch(()=>{})},stop:n=>{const i=r().tabs.find(s=>s.id===n);i&&window.api.browser.stop(i.viewId).catch(()=>{})},mode:"browse",captureMode:"agent",setMode:n=>e(i=>({mode:n,captured:n==="capture"?i.captured:null})),setCaptureMode:n=>e({captureMode:n,captured:null}),onVerb:n=>{const{mode:i}=r();if(n==="shot"){e({mode:"capture",captureMode:"shot",captured:null});return}if(i===n){e({mode:"browse",captured:n==="capture"?null:r().captured});return}e({mode:n,captureMode:n==="capture"?"agent":r().captureMode,captured:n==="capture"?r().captured:null})},captured:null,capture:async n=>{const{activeTabId:i,tabs:s,captureMode:a}=r(),c=s.find(u=>u.id===i);if(!c)throw new Error("No active browser tab");if(a==="shot"){const u=await window.api.browser.captureShot(c.viewId);if(!u.ok)throw new Error(u.error);e({captured:{mode:a,url:u.url,title:u.title,dataUrl:u.dataUrl,at:Date.now()}});return}if(!n||!n.length)throw new Error("No element selected");const l=await window.api.browser.capture({viewId:c.viewId,selectors:n,mode:a});if(!l.ok)throw new Error(l.error);e({captured:{mode:a,url:c.url,title:c.title,text:l.text,meta:l.meta,selectors:n,at:Date.now()}})},recorderActive:!1,recording:!1,recorderElapsedSec:0,recorderSteps:[],startRecording:n=>{if(r().recorderActive)return;e({recorderActive:!0,recording:!0,recorderElapsedSec:0,recorderSteps:[]}),window.api.browser.recordStart(n).catch(()=>{}),uN(n);const i=window.api.browser.onRecordStep(n,s=>{Rt.getState().recording&&Rt.setState(a=>({recorderSteps:[...a.recorderSteps,s]}))});Ej.set(n,i),dN(),ww=setInterval(()=>{Rt.getState().recording&&Rt.setState(s=>({recorderElapsedSec:s.recorderElapsedSec+1}))},1e3)},stopRecording:n=>{r().recorderActive&&(window.api.browser.recordStop(n).catch(()=>{}),uN(n),dN(),e({recorderActive:!1,recording:!1}))},toggleRecordingPause:()=>{r().recorderActive&&e(n=>({recording:!n.recording}))},toggleStepVariable:n=>{e(i=>({recorderSteps:i.recorderSteps.map(s=>s.n===n?{...s,variable:s.variable?null:s.variableSuggestion||"value"}:s)}))},bookmarks:[],bookmarksHydrated:!1,hydrateBookmarks:async()=>{if(!r().bookmarksHydrated)try{const n=await window.api.config.readJson(aN),i=n.exists&&Array.isArray(n.data)?n.data:[];e({bookmarks:i,bookmarksHydrated:!0})}catch{e({bookmarksHydrated:!0})}},toggleBookmark:n=>{const i=r().tabs.find(l=>l.id===n);if(!i||!i.url||i.url==="about:blank")return;const s=r().bookmarks,c=s.some(l=>l.url===i.url)?s.filter(l=>l.url!==i.url):[{url:i.url,title:i.title,ts:Date.now()},...s];e({bookmarks:c}),window.api.config.writeJson(aN,c).catch(()=>{})},historyEntries:[],refreshHistory:async()=>{try{const n=await window.api.config.readJson(LW),i=n.exists&&Array.isArray(n.data)?n.data:[];e({historyEntries:i})}catch{}},setZoom:(n,i)=>{const s=r().tabs.find(c=>c.id===n);if(!s)return;const a=Math.min(zW,Math.max(BW,i));e(c=>({tabs:c.tabs.map(l=>l.id===n?{...l,zoomFactor:a}:l)})),window.api.browser.setZoom({viewId:s.viewId,factor:a}).catch(()=>{})},zoomIn:n=>{const i=r().tabs.find(s=>s.id===n);i&&r().setZoom(n,i.zoomFactor+oN)},zoomOut:n=>{const i=r().tabs.find(s=>s.id===n);i&&r().setZoom(n,i.zoomFactor-oN)},zoomReset:n=>r().setZoom(n,1),findOpen:!1,findText:"",findMatches:null,openFind:n=>{const i=r().tabs.find(a=>a.id===n);if(!i)return;e({findOpen:!0,findText:"",findMatches:null}),T1(i.viewId);const s=window.api.browser.onFindResult(i.viewId,a=>{Rt.setState({findMatches:a})});Tj.set(i.viewId,s)},closeFind:n=>{const i=r().tabs.find(s=>s.id===n);e({findOpen:!1,findText:"",findMatches:null}),i&&(T1(i.viewId),window.api.browser.stopFind(i.viewId).catch(()=>{}))},setFindText:(n,i)=>{const s=r().tabs.find(a=>a.id===n);if(e({findText:i}),!!s){if(!i){window.api.browser.find({viewId:s.viewId,text:""}).catch(()=>{});return}window.api.browser.find({viewId:s.viewId,text:i,forward:!0}).catch(()=>{})}},findNext:n=>{const i=r().tabs.find(a=>a.id===n),{findText:s}=r();!i||!s||window.api.browser.find({viewId:i.viewId,text:s,forward:!0}).catch(()=>{})},findPrev:n=>{const i=r().tabs.find(a=>a.id===n),{findText:s}=r();!i||!s||window.api.browser.find({viewId:i.viewId,text:s,forward:!1}).catch(()=>{})}})),qW=4,fN=40,hN=6;function HW(e){const{onReorder:r,onActivate:n}=e,i=D.useRef(null),s=D.useRef(null),a=D.useRef(0),c=D.useRef(0),[l,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]")):[],[]),b=D.useCallback((y,x,_)=>{for(let C=0;C<x.length;C++){const T=x[C].left+x[C].width/2;if(y<T)return C<=_?C:C-1}return x.length-1},[]),w=D.useCallback(()=>{const y=s.current,x=i.current;if(!(y!=null&&y.active)||!x)return;const _=x.getBoundingClientRect(),C=y.startX+y.deltaX,T=C-_.left,E=_.right-C;T<fN?x.scrollLeft-=hN:E<fN&&(x.scrollLeft+=hN),a.current=requestAnimationFrame(w)},[]);D.useEffect(()=>{const y=i.current;if(!y)return;let x=!1;const _=()=>{x||(x=!0,c.current=requestAnimationFrame(()=>{x=!1,f(E=>E+1)}))},C=E=>{var W;const $=s.current;if(!$)return;const N=E.clientX-$.startX;if(!$.active&&Math.abs(N)<qW)return;if(!$.active){$.active=!0,$.tabRects=h().map(F=>F.getBoundingClientRect()),u(!0);try{(W=i.current)==null||W.setPointerCapture($.pointerId)}catch{}a.current=requestAnimationFrame(w)}$.deltaX=N;const P=$.tabRects[$.fromIndex],I=P.left+P.width/2+N;$.currentIndex=b(I,$.tabRects,$.fromIndex),_()},T=E=>{const $=s.current;if($&&$.pointerId===E.pointerId){cancelAnimationFrame(a.current),cancelAnimationFrame(c.current);try{y.releasePointerCapture($.pointerId)}catch{}$.active&&$.fromIndex!==$.currentIndex?r($.fromIndex,$.currentIndex):m.current($.fromIndex),s.current=null,u(!1),f(N=>N+1)}};return y.addEventListener("pointermove",C),y.addEventListener("pointerup",T),y.addEventListener("pointercancel",T),()=>{y.removeEventListener("pointermove",C),y.removeEventListener("pointerup",T),y.removeEventListener("pointercancel",T),cancelAnimationFrame(a.current),cancelAnimationFrame(c.current)}},[r,h,b,w]);const k=D.useCallback((y,x)=>{y.button!==0||y.target.closest("button")||(s.current={active:!1,fromIndex:x,currentIndex:x,startX:y.clientX,deltaX:0,tabRects:[],pointerId:y.pointerId})},[]);return{getTabDragProps:D.useCallback(y=>{var C;const x=s.current,_={};if(x!=null&&x.active)if(y===x.fromIndex)_.transform=`translateX(${x.deltaX}px) scale(1.03)`,_.zIndex=10,_.opacity=.85,_.boxShadow="0 2px 8px rgba(0,0,0,0.4)",_.position="relative",_.pointerEvents="none";else{const T=x.fromIndex,E=x.currentIndex,N=(((C=x.tabRects[T])==null?void 0:C.width)??0)+4;_.transition="transform 0.15s ease",T<E&&y>T&&y<=E?_.transform=`translateX(-${N}px)`:T>E&&y>=E&&y<T?_.transform=`translateX(${N}px)`:_.transform="translateX(0)"}return{onPointerDown:T=>k(T,y),style:_,"data-drag-index":y}},[k]),isDragging:l,containerRef:i}}const VW=3e4;function GW({onToggleSplitView:e,splitViewActive:r}={}){const n=kt(x=>x.tabs),i=kt(x=>x.activeTabId),s=kt(x=>x.closeTab),a=kt(x=>x.setActive),c=kt(x=>x.reorderTab),l=ry(x=>x.watchers),u=Rt(x=>x.tabs.length>0),f=i!=null&&u,[m,h]=D.useState(()=>Date.now());D.useEffect(()=>{const x=window.setInterval(()=>h(Date.now()),1e3);return()=>window.clearInterval(x)},[]);const b=x=>{for(const _ of Object.values(l))if(_.tabId===x&&_.lastLineAt&&m-_.lastLineAt<VW)return!0;return!1},{getTabDragProps:w,isDragging:k,containerRef:S}=HW({tabCount:n.length,onReorder:c,onActivate:x=>{const _=n[x];_&&a(_.id)}}),y=["#6f7d52","#b85c34","#a39079","#7a8466","#5b4a36"];return o.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:[o.jsx("div",{ref:S,className:`flex items-end gap-0.5 overflow-x-auto min-w-0 flex-1 select-none ${k?"cursor-grabbing":""}`,children:n.map((x,_)=>{const C=x.id===i,T=w(_),E=y[_%y.length];return o.jsxs("div",{...T,style:T.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 ${k?"":"cursor-grab"} ${C?"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":C?"true":void 0,children:[o.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:E,boxShadow:"inset 0 0 0 0.5px rgba(0,0,0,0.15)",opacity:x.status==="spawning"?.55:1}}),o.jsx("span",{className:"truncate max-w-[200px]",children:x.label}),x.status==="spawning"&&o.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-butter animate-pulse",title:"spawning"}),b(x.id)&&o.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"}),o.jsx("button",{onClick:$=>{$.stopPropagation(),s(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)})}),o.jsxs("div",{className:"flex items-center gap-2 pb-2 pl-3 text-[12px] text-fg-faint shrink-0",children:[f&&e&&o.jsxs("button",{onClick:e,className:`flex items-center gap-1 px-2 py-0.5 rounded text-[11px] border border-line hover:bg-bg-hi/40 ${r?"text-accent border-accent":"text-fg-faint hover:text-fg"}`,title:"Split view: agent terminal + browser","aria-pressed":r??!1,children:[o.jsx("span",{"aria-hidden":"true",children:"⇄"}),o.jsx("span",{children:"Split view"})]}),o.jsx("span",{className:"font-semibold text-fg-dim",children:"Claude Session Manager"}),o.jsxs("span",{className:"font-mono text-[11px] text-fg-faint",children:["v","0.35.17"]})]})]})}function KW(e,r,n){return r?e.map(i=>i.id===r?{...i,lastActivityAt:n}:i):e}function XW(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 _w=jn((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]:XW(n,i,s)}});const c=window.api.transcripts.onEvent(n,l=>r().ingest(n,l));e({unsubs:{...r().unsubs,[n]:c}}),window.api.transcripts.subscribe({tabId:n,cwd:i,sessionUuid:s}).then(async l=>{const u=r().tabs[n];if(!u)return;if(!l.ok){const{toast:m}=await ab(async()=>{const{toast:h}=await Promise.resolve().then(()=>N4);return{toast:h}},void 0,import.meta.url);m.error(`Live view unavailable: ${l.error??"subscribe failed"}`),e({tabs:{...r().tabs,[n]:{...u,path:null}}});return}e({tabs:{...r().tabs,[n]:{...u,path:l.path}}});const f=await window.api.transcripts.buffer(n);for(const m of f)r().ingest(n,m,{replay:!0})}).catch(l=>console.error("[live] transcripts.subscribe failed:",n,l))},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 c={...r().tabs};delete c[n],window.api.transcripts.unsubscribe(n),e({refs:i,unsubs:a,tabs:c})},ingest:(n,i,s)=>{const a=r().tabs[n];if(!a)return;const c=Date.now(),l={...a,lastEventAt:s!=null&&s.replay?a.lastEventAt:c},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:[];l.todos=m,s!=null&&s.replay||u.push({id:0,kind:"todo-update",at:c,label:`Todos · ${m.length} item${m.length!==1?"s":""}`});break}case"tool_use":{const m=i.data,h=m.input,b={};for(const w of["command","file_path","pattern","url","query","subagent_type","description"])h&&w in h&&(b[w]=h[w]);if(l.lastToolUses=[{id:m.id,name:m.name,input:b,at:c},...a.lastToolUses].slice(0,50),!(s!=null&&s.replay)){const w=m.input,k=["Edit","Write","NotebookEdit"].includes(m.name),S=typeof(w==null?void 0:w.file_path)=="string"?w.file_path:void 0,y=typeof(w==null?void 0:w.command)=="string"?w.command:void 0,x=S?S.split("/").pop()??S:y?f(y,28):"";u.push({id:0,kind:"tool-use",at:c,label:x?`${m.name} · ${x}`:m.name,target:S??y,toolName:m.name}),k&&S&&u.push({id:0,kind:"file-edit",at:c,label:`${m.name} · ${f(S.split("/").pop()??S,34)}`,target:S,toolName:m.name})}break}case"plan":{const m=i.data,h=typeof m=="string"?m:(m==null?void 0:m.plan)??JSON.stringify(m);l.plans=[{at:c,content:h??""},...a.plans].slice(0,50),s!=null&&s.replay||u.push({id:0,kind:"plan-revision",at:c,label:"Plan revised"});break}case"agent_spawn":{const m=i.data;l.agents=[{id:m==null?void 0:m.toolUseId,at:c,subagentType:m==null?void 0:m.subagent_type,description:m==null?void 0:m.description,lastActivityAt:c},...a.agents].slice(0,50),s!=null&&s.replay||u.push({id:0,kind:"agent-spawn",at:c,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),b=m.input_tokens??m.inputTokens??0,w=m.output_tokens??m.outputTokens??0,k=h+b+w;l.usage={inputTokens:(a.usage.inputTokens||0)+b,outputTokens:(a.usage.outputTokens||0)+w,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(k/1e3)>Math.floor(h/1e3)&&u.push({id:0,kind:"usage-tick",at:c,label:`${Math.floor(k/1e3)}k tokens`});break}case"tool_result":{const m=i.data;l.agents=KW(a.agents,m==null?void 0:m.toolUseId,c);break}}if(u.length>0){let m=a.activitySeq;const h=u.map(b=>({...b,id:++m}));l.activitySeq=m,l.activityRing=[...a.activityRing,...h].slice(-32)}e({tabs:{...r().tabs,[n]:l}})}}));function O4(e){const r=_w(s=>s.subscribe),n=_w(s=>s.unsubscribe),i=_w(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 A1={},iv={},pN;function P4(){if(pN)return iv;pN=1,Object.defineProperty(iv,"__esModule",{value:!0}),iv.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(/\/[^/]+$/,"/")),iv.baseAssetPath=n,iv}var sv={},mN;function XT(){if(mN)return sv;mN=1,Object.defineProperty(sv,"__esModule",{value:!0}),sv.defaultModelFetcher=void 0;const e=r=>fetch(r).then(n=>n.arrayBuffer());return sv.defaultModelFetcher=e,sv}var ec={},av={},gN;function ob(){if(gN)return av;gN=1,Object.defineProperty(av,"__esModule",{value:!0}),av.log=void 0;const e=r=>n=>{console.log(`VAD | ${r} >`,n)};return av.log={error:e("error"),debug:e("debug"),warn:e("warn")},av}var ov={},vN;function g_(){if(vN)return ov;vN=1,Object.defineProperty(ov,"__esModule",{value:!0}),ov.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||(ov.Message=e={})),ov}var yN;function YT(){if(yN)return ec;yN=1,Object.defineProperty(ec,"__esModule",{value:!0}),ec.FrameProcessor=ec.validateOptions=ec.defaultFrameProcessorOptions=void 0;const e=ob(),r=g_();ec.defaultFrameProcessorOptions={positiveSpeechThreshold:.3,negativeSpeechThreshold:.25,preSpeechPadMs:800,redemptionMs:1400,minSpeechMs:400,submitUserSpeechOnPause:!1};function n(c){(c.positiveSpeechThreshold<0||c.positiveSpeechThreshold>1)&&e.log.error("positiveSpeechThreshold should be a number between 0 and 1"),(c.negativeSpeechThreshold<0||c.negativeSpeechThreshold>c.positiveSpeechThreshold)&&e.log.error("negativeSpeechThreshold should be between 0 and positiveSpeechThreshold"),c.preSpeechPadMs<0&&e.log.error("preSpeechPadMs should be positive"),c.redemptionMs<0&&e.log.error("redemptionMs should be positive"),c.minSpeechMs<0&&e.log.error("minSpeechMs should be positive")}ec.validateOptions=n;const i=c=>{const l=c.reduce((f,m)=>(f.push(f.at(-1)+m.length),f),[0]),u=new Float32Array(l.at(-1));return c.forEach((f,m)=>{const h=l[m];u.set(f,h)}),u};function s(c,l){const u=Math.floor(c.redemptionMs/l),f=Math.floor(c.preSpeechPadMs/l),m=Math.floor(c.minSpeechMs/l);return{redemptionFrames:u,preSpeechPadFrames:f,minSpeechFrames:m}}class a{constructor(l,u,f,m){this.modelProcessFunc=l,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=k=>{this.options={...this.options,...k};const{redemptionFrames:S,preSpeechPadFrames:y,minSpeechFrames:x}=s(this.options,this.msPerFrame);this.redemptionFrames=S,this.preSpeechPadFrames=y,this.minSpeechFrames=x},this.reset=()=>{this.speaking=!1,this.speechRealStartFired=!1,this.audioBuffer=[],this.modelResetFunc(),this.redemptionCounter=0,this.speechFrameCount=0},this.pause=k=>{this.active=!1,this.options.submitUserSpeechOnPause?this.endSegment(k):this.reset()},this.resume=()=>{this.active=!0},this.endSegment=k=>{const S=this.audioBuffer;this.audioBuffer=[];const y=this.speaking;if(this.reset(),y)if(S.reduce((_,C)=>C.isSpeech?_+1:_,0)>=this.minSpeechFrames){const _=i(S.map(C=>C.frame));k({msg:r.Message.SpeechEnd,audio:_})}else k({msg:r.Message.VADMisfire});return{}},this.process=async(k,S)=>{if(!this.active)return;const y=await this.modelProcessFunc(k),x=y.isSpeech>=this.options.positiveSpeechThreshold;if(S({probs:y,msg:r.Message.FrameProcessed,frame:k}),this.audioBuffer.push({frame:k,isSpeech:x}),x&&(this.speechFrameCount++,this.redemptionCounter=0),x&&!this.speaking&&(this.speaking=!0,S({msg:r.Message.SpeechStart})),this.speaking&&this.speechFrameCount===this.minSpeechFrames&&!this.speechRealStartFired&&(this.speechRealStartFired=!0,S({msg:r.Message.SpeechRealStart})),y.isSpeech<this.options.negativeSpeechThreshold&&this.speaking&&++this.redemptionCounter>=this.redemptionFrames){this.redemptionCounter=0,this.speechFrameCount=0,this.speaking=!1,this.speechRealStartFired=!1;const _=this.audioBuffer;if(this.audioBuffer=[],_.reduce((T,E)=>E.isSpeech?T+1:T,0)>=this.minSpeechFrames){const T=i(_.map(E=>E.frame));S({msg:r.Message.SpeechEnd,audio:T})}else S({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:b,minSpeechFrames:w}=s(this.options,this.msPerFrame);this.redemptionFrames=h,this.preSpeechPadFrames=b,this.minSpeechFrames=w,this.reset()}}return ec.FrameProcessor=a,ec}var tc={};function Va(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 $1={exports:{}};/*!
41
+ `+J.stack}return{value:p,source:v,stack:V,digest:null}}function kh(p,v,A){return{value:p,source:null,stack:A??null,digest:v??null}}function Ch(p,v){try{console.error(v.value)}catch(A){setTimeout(function(){throw A})}}var Zb=typeof WeakMap=="function"?WeakMap:Map;function kg(p,v,A){A=Ra(-1,A),A.tag=3,A.payload={element:null};var M=v.value;return A.callback=function(){jd||(jd=!0,Vh=M),Ch(p,v)},A}function Cg(p,v,A){A=Ra(-1,A),A.tag=3;var M=p.type.getDerivedStateFromError;if(typeof M=="function"){var V=v.value;A.payload=function(){return M(V)},A.callback=function(){Ch(p,v)}}var J=p.stateNode;return J!==null&&typeof J.componentDidCatch=="function"&&(A.callback=function(){Ch(p,v),typeof M!="function"&&(bo===null?bo=new Set([this]):bo.add(this));var he=v.stack;this.componentDidCatch(v.value,{componentStack:he!==null?he:""})}),A}function jg(p,v,A){var M=p.pingCache;if(M===null){M=p.pingCache=new Zb;var V=new Set;M.set(v,V)}else V=M.get(v),V===void 0&&(V=new Set,M.set(v,V));V.has(A)||(V.add(A),p=ux.bind(null,p,v,A),v.then(p,p))}function Qb(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 ki(p,v,A,M,V){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=Ra(-1,1),v.tag=2,mo(A,v,1))),A.lanes|=1),p):(p.flags|=65536,p.lanes=V,p)}var ex=T.ReactCurrentOwner,Hi=!1;function ii(p,v,A,M){v.child=p===null?ih(v,null,A,M):Fl(v,p.child,A,M)}function Eg(p,v,A,M,V){A=A.render;var J=v.ref;return Ul(v,V),M=yh(p,v,A,M,J,V),A=bh(),p!==null&&!Hi?(v.updateQueue=p.updateQueue,v.flags&=-2053,p.lanes&=~V,Ia(p,v,V)):(on&&A&&En(v),v.flags|=1,ii(p,v,M,V),v.child)}function Kc(p,v,A,M,V){if(p===null){var J=A.type;return typeof J=="function"&&!Qh(J)&&J.defaultProps===void 0&&A.compare===null&&A.defaultProps===void 0?(v.tag=15,v.type=J,Tg(p,v,J,M,V)):(p=Nd(A.type,null,M,v,v.mode,V),p.ref=v.ref,p.return=v,v.child=p)}if(J=p.child,(p.lanes&V)===0){var he=J.memoizedProps;if(A=A.compare,A=A!==null?A:Mc,A(he,M)&&p.ref===v.ref)return Ia(p,v,V)}return v.flags|=1,p=_o(J,M),p.ref=v.ref,p.return=v,v.child=p}function Tg(p,v,A,M,V){if(p!==null){var J=p.memoizedProps;if(Mc(J,M)&&p.ref===v.ref)if(Hi=!1,v.pendingProps=M=J,(p.lanes&V)!==0)(p.flags&131072)!==0&&(Hi=!0);else return v.lanes=p.lanes,Ia(p,v,V)}return jh(p,v,A,M,V)}function Ag(p,v,A){var M=v.pendingProps,V=M.children,J=p!==null?p.memoizedState:null;if(M.mode==="hidden")if((v.mode&1)===0)v.memoizedState={baseLanes:0,cachePool:null,transitions:null},Wr(Gl,is),is|=A;else{if((A&1073741824)===0)return p=J!==null?J.baseLanes|A:A,v.lanes=v.childLanes=1073741824,v.memoizedState={baseLanes:p,cachePool:null,transitions:null},v.updateQueue=null,Wr(Gl,is),is|=p,null;v.memoizedState={baseLanes:0,cachePool:null,transitions:null},M=J!==null?J.baseLanes:A,Wr(Gl,is),is|=M}else J!==null?(M=J.baseLanes|A,v.memoizedState=null):M=A,Wr(Gl,is),is|=M;return ii(p,v,V,A),v.child}function $g(p,v){var A=v.ref;(p===null&&A!==null||p!==null&&p.ref!==A)&&(v.flags|=512,v.flags|=2097152)}function jh(p,v,A,M,V){var J=zi(A)?Ko:_i.current;return J=Si(v,J),Ul(v,V),A=yh(p,v,A,M,J,V),M=bh(),p!==null&&!Hi?(v.updateQueue=p.updateQueue,v.flags&=-2053,p.lanes&=~V,Ia(p,v,V)):(on&&M&&En(v),v.flags|=1,ii(p,v,A,V),v.child)}function Ng(p,v,A,M,V){if(zi(A)){var J=!0;sd(v)}else J=!1;if(Ul(v,V),v.stateNode===null)xd(p,v),_g(v,A,M),Sh(v,A,M,V),M=!0;else if(p===null){var he=v.stateNode,ke=v.memoizedProps;he.props=ke;var Re=he.context,Xe=A.contextType;typeof Xe=="object"&&Xe!==null?Xe=bs(Xe):(Xe=zi(A)?Ko:_i.current,Xe=Si(v,Xe));var ft=A.getDerivedStateFromProps,ht=typeof ft=="function"||typeof he.getSnapshotBeforeUpdate=="function";ht||typeof he.UNSAFE_componentWillReceiveProps!="function"&&typeof he.componentWillReceiveProps!="function"||(ke!==M||Re!==Xe)&&Sg(v,he,M,Xe),da=!1;var dt=v.memoizedState;he.state=dt,hd(v,M,he,V),Re=v.memoizedState,ke!==M||dt!==Re||Bi.current||da?(typeof ft=="function"&&(ha(v,A,ft,M),Re=v.memoizedState),(ke=da||nl(v,A,ke,M,dt,Re,Xe))?(ht||typeof he.UNSAFE_componentWillMount!="function"&&typeof he.componentWillMount!="function"||(typeof he.componentWillMount=="function"&&he.componentWillMount(),typeof he.UNSAFE_componentWillMount=="function"&&he.UNSAFE_componentWillMount()),typeof he.componentDidMount=="function"&&(v.flags|=4194308)):(typeof he.componentDidMount=="function"&&(v.flags|=4194308),v.memoizedProps=M,v.memoizedState=Re),he.props=M,he.state=Re,he.context=Xe,M=ke):(typeof he.componentDidMount=="function"&&(v.flags|=4194308),M=!1)}else{he=v.stateNode,ch(p,v),ke=v.memoizedProps,Xe=v.type===v.elementType?ke:An(v.type,ke),he.props=Xe,ht=v.pendingProps,dt=he.context,Re=A.contextType,typeof Re=="object"&&Re!==null?Re=bs(Re):(Re=zi(A)?Ko:_i.current,Re=Si(v,Re));var Tt=A.getDerivedStateFromProps;(ft=typeof Tt=="function"||typeof he.getSnapshotBeforeUpdate=="function")||typeof he.UNSAFE_componentWillReceiveProps!="function"&&typeof he.componentWillReceiveProps!="function"||(ke!==ht||dt!==Re)&&Sg(v,he,M,Re),da=!1,dt=v.memoizedState,he.state=dt,hd(v,M,he,V);var It=v.memoizedState;ke!==ht||dt!==It||Bi.current||da?(typeof Tt=="function"&&(ha(v,A,Tt,M),It=v.memoizedState),(Xe=da||nl(v,A,Xe,M,dt,It,Re)||!1)?(ft||typeof he.UNSAFE_componentWillUpdate!="function"&&typeof he.componentWillUpdate!="function"||(typeof he.componentWillUpdate=="function"&&he.componentWillUpdate(M,It,Re),typeof he.UNSAFE_componentWillUpdate=="function"&&he.UNSAFE_componentWillUpdate(M,It,Re)),typeof he.componentDidUpdate=="function"&&(v.flags|=4),typeof he.getSnapshotBeforeUpdate=="function"&&(v.flags|=1024)):(typeof he.componentDidUpdate!="function"||ke===p.memoizedProps&&dt===p.memoizedState||(v.flags|=4),typeof he.getSnapshotBeforeUpdate!="function"||ke===p.memoizedProps&&dt===p.memoizedState||(v.flags|=1024),v.memoizedProps=M,v.memoizedState=It),he.props=M,he.state=It,he.context=Re,M=Xe):(typeof he.componentDidUpdate!="function"||ke===p.memoizedProps&&dt===p.memoizedState||(v.flags|=4),typeof he.getSnapshotBeforeUpdate!="function"||ke===p.memoizedProps&&dt===p.memoizedState||(v.flags|=1024),M=!1)}return Eh(p,v,A,M,J,V)}function Eh(p,v,A,M,V,J){$g(p,v);var he=(v.flags&128)!==0;if(!M&&!he)return V&&Ym(v,A,!1),Ia(p,v,J);M=v.stateNode,ex.current=v;var ke=he&&typeof A.getDerivedStateFromError!="function"?null:M.render();return v.flags|=1,p!==null&&he?(v.child=Fl(v,p.child,null,J),v.child=Fl(v,null,ke,J)):ii(p,v,ke,J),v.memoizedState=M.state,V&&Ym(v,A,!0),v.child}function Th(p){var v=p.stateNode;v.pendingContext?Km(p,v.pendingContext,v.pendingContext!==v.context):v.context&&Km(p,v.context,!1),uh(p,v.containerInfo)}function Og(p,v,A,M,V){return Yo(),rh(V),v.flags|=256,ii(p,v,A,M),v.child}var Ah={dehydrated:null,treeContext:null,retryLane:0};function $h(p){return{baseLanes:p,cachePool:null,transitions:null}}function Pg(p,v,A){var M=v.pendingProps,V=dn.current,J=!1,he=(v.flags&128)!==0,ke;if((ke=he)||(ke=p!==null&&p.memoizedState===null?!1:(V&2)!==0),ke?(J=!0,v.flags&=-129):(p===null||p.memoizedState!==null)&&(V|=1),Wr(dn,V&1),p===null)return eh(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):(he=M.children,p=M.fallback,J?(M=v.mode,J=v.child,he={mode:"hidden",children:he},(M&1)===0&&J!==null?(J.childLanes=0,J.pendingProps=he):J=Od(he,M,0,null),p=Yl(p,M,A,null),J.return=v,p.return=v,J.sibling=p,v.child=J,v.child.memoizedState=$h(A),v.memoizedState=Ah,p):Xc(v,he));if(V=p.memoizedState,V!==null&&(ke=V.dehydrated,ke!==null))return tx(p,v,he,M,ke,V,A);if(J){J=M.fallback,he=v.mode,V=p.child,ke=V.sibling;var Re={mode:"hidden",children:M.children};return(he&1)===0&&v.child!==V?(M=v.child,M.childLanes=0,M.pendingProps=Re,v.deletions=null):(M=_o(V,Re),M.subtreeFlags=V.subtreeFlags&14680064),ke!==null?J=_o(ke,J):(J=Yl(J,he,A,null),J.flags|=2),J.return=v,M.return=v,M.sibling=J,v.child=M,M=J,J=v.child,he=p.child.memoizedState,he=he===null?$h(A):{baseLanes:he.baseLanes|A,cachePool:null,transitions:he.transitions},J.memoizedState=he,J.childLanes=p.childLanes&~A,v.memoizedState=Ah,M}return J=p.child,p=J.sibling,M=_o(J,{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 Xc(p,v){return v=Od({mode:"visible",children:v},p.mode,0,null),v.return=p,p.child=v}function bd(p,v,A,M){return M!==null&&rh(M),Fl(v,p.child,null,A),p=Xc(v,v.pendingProps.children),p.flags|=2,v.memoizedState=null,p}function tx(p,v,A,M,V,J,he){if(A)return v.flags&256?(v.flags&=-257,M=kh(Error(n(422))),bd(p,v,he,M)):v.memoizedState!==null?(v.child=p.child,v.flags|=128,null):(J=M.fallback,V=v.mode,M=Od({mode:"visible",children:M.children},V,0,null),J=Yl(J,V,he,null),J.flags|=2,M.return=v,J.return=v,M.sibling=J,v.child=M,(v.mode&1)!==0&&Fl(v,p.child,null,he),v.child.memoizedState=$h(he),v.memoizedState=Ah,J);if((v.mode&1)===0)return bd(p,v,he,null);if(V.data==="$!"){if(M=V.nextSibling&&V.nextSibling.dataset,M)var ke=M.dgst;return M=ke,J=Error(n(419)),M=kh(J,M,void 0),bd(p,v,he,M)}if(ke=(he&p.childLanes)!==0,Hi||ke){if(M=$n,M!==null){switch(he&-he){case 4:V=2;break;case 16:V=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:V=32;break;case 536870912:V=268435456;break;default:V=0}V=(V&(M.suspendedLanes|he))!==0?0:V,V!==0&&V!==J.retryLane&&(J.retryLane=V,Pa(p,V),qs(M,p,V,-1))}return Zh(),M=kh(Error(n(421))),bd(p,v,he,M)}return V.data==="$?"?(v.flags|=128,v.child=p.child,v=fx.bind(null,p),V._reactRetry=v,null):(p=J.treeContext,ns=uo(V.nextSibling),Wi=v,on=!0,qi=null,p!==null&&(vs[zs++]=Fi,vs[zs++]=Ui,vs[zs++]=ys,Fi=p.id,Ui=p.overflow,ys=v),v=Xc(v,M.children),v.flags|=4096,v)}function Rg(p,v,A){p.lanes|=v;var M=p.alternate;M!==null&&(M.lanes|=v),eg(p.return,v,A)}function Nh(p,v,A,M,V){var J=p.memoizedState;J===null?p.memoizedState={isBackwards:v,rendering:null,renderingStartTime:0,last:M,tail:A,tailMode:V}:(J.isBackwards=v,J.rendering=null,J.renderingStartTime=0,J.last=M,J.tail=A,J.tailMode=V)}function Oh(p,v,A){var M=v.pendingProps,V=M.revealOrder,J=M.tail;if(ii(p,v,M.children,A),M=dn.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&&Rg(p,A,v);else if(p.tag===19)Rg(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(Wr(dn,M),(v.mode&1)===0)v.memoizedState=null;else switch(V){case"forwards":for(A=v.child,V=null;A!==null;)p=A.alternate,p!==null&&pd(p)===null&&(V=A),A=A.sibling;A=V,A===null?(V=v.child,v.child=null):(V=A.sibling,A.sibling=null),Nh(v,!1,V,A,J);break;case"backwards":for(A=null,V=v.child,v.child=null;V!==null;){if(p=V.alternate,p!==null&&pd(p)===null){v.child=V;break}p=V.sibling,V.sibling=A,A=V,V=p}Nh(v,!0,A,null,J);break;case"together":Nh(v,!1,null,null,void 0);break;default:v.memoizedState=null}return v.child}function xd(p,v){(v.mode&1)===0&&p!==null&&(p.alternate=null,v.alternate=null,v.flags|=2)}function Ia(p,v,A){if(p!==null&&(v.dependencies=p.dependencies),il|=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 m1(p,v,A){switch(v.tag){case 3:Th(v),Yo();break;case 5:tg(v);break;case 1:zi(v.type)&&sd(v);break;case 4:uh(v,v.stateNode.containerInfo);break;case 10:var M=v.type._context,V=v.memoizedProps.value;Wr(Jo,M._currentValue),M._currentValue=V;break;case 13:if(M=v.memoizedState,M!==null)return M.dehydrated!==null?(Wr(dn,dn.current&1),v.flags|=128,null):(A&v.child.childLanes)!==0?Pg(p,v,A):(Wr(dn,dn.current&1),p=Ia(p,v,A),p!==null?p.sibling:null);Wr(dn,dn.current&1);break;case 19:if(M=(A&v.childLanes)!==0,(p.flags&128)!==0){if(M)return Oh(p,v,A);v.flags|=128}if(V=v.memoizedState,V!==null&&(V.rendering=null,V.tail=null,V.lastEffect=null),Wr(dn,dn.current),M)break;return null;case 22:case 23:return v.lanes=0,Ag(p,v,A)}return Ia(p,v,A)}var Ph,Rh,Mg,Ig;Ph=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}},Rh=function(){},Mg=function(p,v,A,M){var V=p.memoizedProps;if(V!==M){p=v.stateNode,Qo(fa.current);var J=null;switch(A){case"input":V=ct(p,V),M=ct(p,M),J=[];break;case"select":V=Q({},V,{value:void 0}),M=Q({},M,{value:void 0}),J=[];break;case"textarea":V=mr(p,V),M=mr(p,M),J=[];break;default:typeof V.onClick!="function"&&typeof M.onClick=="function"&&(p.onclick=rd)}Js(A,M);var he;A=null;for(Xe in V)if(!M.hasOwnProperty(Xe)&&V.hasOwnProperty(Xe)&&V[Xe]!=null)if(Xe==="style"){var ke=V[Xe];for(he in ke)ke.hasOwnProperty(he)&&(A||(A={}),A[he]="")}else Xe!=="dangerouslySetInnerHTML"&&Xe!=="children"&&Xe!=="suppressContentEditableWarning"&&Xe!=="suppressHydrationWarning"&&Xe!=="autoFocus"&&(s.hasOwnProperty(Xe)?J||(J=[]):(J=J||[]).push(Xe,null));for(Xe in M){var Re=M[Xe];if(ke=V!=null?V[Xe]:void 0,M.hasOwnProperty(Xe)&&Re!==ke&&(Re!=null||ke!=null))if(Xe==="style")if(ke){for(he in ke)!ke.hasOwnProperty(he)||Re&&Re.hasOwnProperty(he)||(A||(A={}),A[he]="");for(he in Re)Re.hasOwnProperty(he)&&ke[he]!==Re[he]&&(A||(A={}),A[he]=Re[he])}else A||(J||(J=[]),J.push(Xe,A)),A=Re;else Xe==="dangerouslySetInnerHTML"?(Re=Re?Re.__html:void 0,ke=ke?ke.__html:void 0,Re!=null&&ke!==Re&&(J=J||[]).push(Xe,Re)):Xe==="children"?typeof Re!="string"&&typeof Re!="number"||(J=J||[]).push(Xe,""+Re):Xe!=="suppressContentEditableWarning"&&Xe!=="suppressHydrationWarning"&&(s.hasOwnProperty(Xe)?(Re!=null&&Xe==="onScroll"&&Gr("scroll",p),J||ke===Re||(J=[])):(J=J||[]).push(Xe,Re))}A&&(J=J||[]).push("style",A);var Xe=J;(v.updateQueue=Xe)&&(v.flags|=4)}},Ig=function(p,v,A,M){A!==M&&(v.flags|=4)};function wd(p,v){if(!on)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 si(p){var v=p.alternate!==null&&p.alternate.child===p.child,A=0,M=0;if(v)for(var V=p.child;V!==null;)A|=V.lanes|V.childLanes,M|=V.subtreeFlags&14680064,M|=V.flags&14680064,V.return=p,V=V.sibling;else for(V=p.child;V!==null;)A|=V.lanes|V.childLanes,M|=V.subtreeFlags,M|=V.flags,V.return=p,V=V.sibling;return p.subtreeFlags|=M,p.childLanes=A,v}function rx(p,v,A){var M=v.pendingProps;switch(Yf(v),v.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return si(v),null;case 1:return zi(v.type)&&id(),si(v),null;case 3:return M=v.stateNode,el(),Kr(Bi),Kr(_i),hh(),M.pendingContext&&(M.context=M.pendingContext,M.pendingContext=null),(p===null||p.child===null)&&(Wc(v)?v.flags|=4:p===null||p.memoizedState.isDehydrated&&(v.flags&256)===0||(v.flags|=1024,qi!==null&&(Xh(qi),qi=null))),Rh(p,v),si(v),null;case 5:dh(v);var V=Qo(ql.current);if(A=v.type,p!==null&&v.stateNode!=null)Mg(p,v,A,M,V),p.ref!==v.ref&&(v.flags|=512,v.flags|=2097152);else{if(!M){if(v.stateNode===null)throw Error(n(166));return si(v),null}if(p=Qo(fa.current),Wc(v)){M=v.stateNode,A=v.type;var J=v.memoizedProps;switch(M[ca]=v,M[Fc]=J,p=(v.mode&1)!==0,A){case"dialog":Gr("cancel",M),Gr("close",M);break;case"iframe":case"object":case"embed":Gr("load",M);break;case"video":case"audio":for(V=0;V<Lc.length;V++)Gr(Lc[V],M);break;case"source":Gr("error",M);break;case"img":case"image":case"link":Gr("error",M),Gr("load",M);break;case"details":Gr("toggle",M);break;case"input":Le(M,J),Gr("invalid",M);break;case"select":M._wrapperState={wasMultiple:!!J.multiple},Gr("invalid",M);break;case"textarea":ur(M,J),Gr("invalid",M)}Js(A,J),V=null;for(var he in J)if(J.hasOwnProperty(he)){var ke=J[he];he==="children"?typeof ke=="string"?M.textContent!==ke&&(J.suppressHydrationWarning!==!0&&td(M.textContent,ke,p),V=["children",ke]):typeof ke=="number"&&M.textContent!==""+ke&&(J.suppressHydrationWarning!==!0&&td(M.textContent,ke,p),V=["children",""+ke]):s.hasOwnProperty(he)&&ke!=null&&he==="onScroll"&&Gr("scroll",M)}switch(A){case"input":Ae(M),mt(M,J,!0);break;case"textarea":Ae(M),Pr(M);break;case"select":case"option":break;default:typeof J.onClick=="function"&&(M.onclick=rd)}M=V,v.updateQueue=M,M!==null&&(v.flags|=4)}else{he=V.nodeType===9?V:V.ownerDocument,p==="http://www.w3.org/1999/xhtml"&&(p=di(A)),p==="http://www.w3.org/1999/xhtml"?A==="script"?(p=he.createElement("div"),p.innerHTML="<script><\/script>",p=p.removeChild(p.firstChild)):typeof M.is=="string"?p=he.createElement(A,{is:M.is}):(p=he.createElement(A),A==="select"&&(he=p,M.multiple?he.multiple=!0:M.size&&(he.size=M.size))):p=he.createElementNS(p,A),p[ca]=v,p[Fc]=M,Ph(p,v,!1,!1),v.stateNode=p;e:{switch(he=kr(A,M),A){case"dialog":Gr("cancel",p),Gr("close",p),V=M;break;case"iframe":case"object":case"embed":Gr("load",p),V=M;break;case"video":case"audio":for(V=0;V<Lc.length;V++)Gr(Lc[V],p);V=M;break;case"source":Gr("error",p),V=M;break;case"img":case"image":case"link":Gr("error",p),Gr("load",p),V=M;break;case"details":Gr("toggle",p),V=M;break;case"input":Le(p,M),V=ct(p,M),Gr("invalid",p);break;case"option":V=M;break;case"select":p._wrapperState={wasMultiple:!!M.multiple},V=Q({},M,{value:void 0}),Gr("invalid",p);break;case"textarea":ur(p,M),V=mr(p,M),Gr("invalid",p);break;default:V=M}Js(A,V),ke=V;for(J in ke)if(ke.hasOwnProperty(J)){var Re=ke[J];J==="style"?Tl(p,Re):J==="dangerouslySetInnerHTML"?(Re=Re?Re.__html:void 0,Re!=null&&Ct(p,Re)):J==="children"?typeof Re=="string"?(A!=="textarea"||Re!=="")&&Pt(p,Re):typeof Re=="number"&&Pt(p,""+Re):J!=="suppressContentEditableWarning"&&J!=="suppressHydrationWarning"&&J!=="autoFocus"&&(s.hasOwnProperty(J)?Re!=null&&J==="onScroll"&&Gr("scroll",p):Re!=null&&C(p,J,Re,he))}switch(A){case"input":Ae(p),mt(p,M,!1);break;case"textarea":Ae(p),Pr(p);break;case"option":M.value!=null&&p.setAttribute("value",""+ne(M.value));break;case"select":p.multiple=!!M.multiple,J=M.value,J!=null?Yt(p,!!M.multiple,J,!1):M.defaultValue!=null&&Yt(p,!!M.multiple,M.defaultValue,!0);break;default:typeof V.onClick=="function"&&(p.onclick=rd)}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 si(v),null;case 6:if(p&&v.stateNode!=null)Ig(p,v,p.memoizedProps,M);else{if(typeof M!="string"&&v.stateNode===null)throw Error(n(166));if(A=Qo(ql.current),Qo(fa.current),Wc(v)){if(M=v.stateNode,A=v.memoizedProps,M[ca]=v,(J=M.nodeValue!==A)&&(p=Wi,p!==null))switch(p.tag){case 3:td(M.nodeValue,A,(p.mode&1)!==0);break;case 5:p.memoizedProps.suppressHydrationWarning!==!0&&td(M.nodeValue,A,(p.mode&1)!==0)}J&&(v.flags|=4)}else M=(A.nodeType===9?A:A.ownerDocument).createTextNode(M),M[ca]=v,v.stateNode=M}return si(v),null;case 13:if(Kr(dn),M=v.memoizedState,p===null||p.memoizedState!==null&&p.memoizedState.dehydrated!==null){if(on&&ns!==null&&(v.mode&1)!==0&&(v.flags&128)===0)Zm(),Yo(),v.flags|=98560,J=!1;else if(J=Wc(v),M!==null&&M.dehydrated!==null){if(p===null){if(!J)throw Error(n(318));if(J=v.memoizedState,J=J!==null?J.dehydrated:null,!J)throw Error(n(317));J[ca]=v}else Yo(),(v.flags&128)===0&&(v.memoizedState=null),v.flags|=4;si(v),J=!1}else qi!==null&&(Xh(qi),qi=null),J=!0;if(!J)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||(dn.current&1)!==0?Ln===0&&(Ln=3):Zh())),v.updateQueue!==null&&(v.flags|=4),si(v),null);case 4:return el(),Rh(p,v),p===null&&Bc(v.stateNode.containerInfo),si(v),null;case 10:return oh(v.type._context),si(v),null;case 17:return zi(v.type)&&id(),si(v),null;case 19:if(Kr(dn),J=v.memoizedState,J===null)return si(v),null;if(M=(v.flags&128)!==0,he=J.rendering,he===null)if(M)wd(J,!1);else{if(Ln!==0||p!==null&&(p.flags&128)!==0)for(p=v.child;p!==null;){if(he=pd(p),he!==null){for(v.flags|=128,wd(J,!1),M=he.updateQueue,M!==null&&(v.updateQueue=M,v.flags|=4),v.subtreeFlags=0,M=A,A=v.child;A!==null;)J=A,p=M,J.flags&=14680066,he=J.alternate,he===null?(J.childLanes=0,J.lanes=p,J.child=null,J.subtreeFlags=0,J.memoizedProps=null,J.memoizedState=null,J.updateQueue=null,J.dependencies=null,J.stateNode=null):(J.childLanes=he.childLanes,J.lanes=he.lanes,J.child=he.child,J.subtreeFlags=0,J.deletions=null,J.memoizedProps=he.memoizedProps,J.memoizedState=he.memoizedState,J.updateQueue=he.updateQueue,J.type=he.type,p=he.dependencies,J.dependencies=p===null?null:{lanes:p.lanes,firstContext:p.firstContext}),A=A.sibling;return Wr(dn,dn.current&1|2),v.child}p=p.sibling}J.tail!==null&&Ar()>Kl&&(v.flags|=128,M=!0,wd(J,!1),v.lanes=4194304)}else{if(!M)if(p=pd(he),p!==null){if(v.flags|=128,M=!0,A=p.updateQueue,A!==null&&(v.updateQueue=A,v.flags|=4),wd(J,!0),J.tail===null&&J.tailMode==="hidden"&&!he.alternate&&!on)return si(v),null}else 2*Ar()-J.renderingStartTime>Kl&&A!==1073741824&&(v.flags|=128,M=!0,wd(J,!1),v.lanes=4194304);J.isBackwards?(he.sibling=v.child,v.child=he):(A=J.last,A!==null?A.sibling=he:v.child=he,J.last=he)}return J.tail!==null?(v=J.tail,J.rendering=v,J.tail=v.sibling,J.renderingStartTime=Ar(),v.sibling=null,A=dn.current,Wr(dn,M?A&1|2:A&1),v):(si(v),null);case 22:case 23:return Jh(),M=v.memoizedState!==null,p!==null&&p.memoizedState!==null!==M&&(v.flags|=8192),M&&(v.mode&1)!==0?(is&1073741824)!==0&&(si(v),v.subtreeFlags&6&&(v.flags|=8192)):si(v),null;case 24:return null;case 25:return null}throw Error(n(156,v.tag))}function nx(p,v){switch(Yf(v),v.tag){case 1:return zi(v.type)&&id(),p=v.flags,p&65536?(v.flags=p&-65537|128,v):null;case 3:return el(),Kr(Bi),Kr(_i),hh(),p=v.flags,(p&65536)!==0&&(p&128)===0?(v.flags=p&-65537|128,v):null;case 5:return dh(v),null;case 13:if(Kr(dn),p=v.memoizedState,p!==null&&p.dehydrated!==null){if(v.alternate===null)throw Error(n(340));Yo()}return p=v.flags,p&65536?(v.flags=p&-65537|128,v):null;case 19:return Kr(dn),null;case 4:return el(),null;case 10:return oh(v.type._context),null;case 22:case 23:return Jh(),null;case 24:return null;default:return null}}var Mh=!1,ai=!1,ix=typeof WeakSet=="function"?WeakSet:Set,Mt=null;function Vl(p,v){var A=p.ref;if(A!==null)if(typeof A=="function")try{A(null)}catch(M){fn(p,v,M)}else A.current=null}function Ih(p,v,A){try{A()}catch(M){fn(p,v,M)}}var Dg=!1;function sx(p,v){if(Uf=lo,p=Rf(),Mf(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 V=M.anchorOffset,J=M.focusNode;M=M.focusOffset;try{A.nodeType,J.nodeType}catch{A=null;break e}var he=0,ke=-1,Re=-1,Xe=0,ft=0,ht=p,dt=null;t:for(;;){for(var Tt;ht!==A||V!==0&&ht.nodeType!==3||(ke=he+V),ht!==J||M!==0&&ht.nodeType!==3||(Re=he+M),ht.nodeType===3&&(he+=ht.nodeValue.length),(Tt=ht.firstChild)!==null;)dt=ht,ht=Tt;for(;;){if(ht===p)break t;if(dt===A&&++Xe===V&&(ke=he),dt===J&&++ft===M&&(Re=he),(Tt=ht.nextSibling)!==null)break;ht=dt,dt=ht.parentNode}ht=Tt}A=ke===-1||Re===-1?null:{start:ke,end:Re}}else A=null}A=A||{start:0,end:0}}else A=null;for(Wf={focusedElem:p,selectionRange:A},lo=!1,Mt=v;Mt!==null;)if(v=Mt,p=v.child,(v.subtreeFlags&1028)!==0&&p!==null)p.return=v,Mt=p;else for(;Mt!==null;){v=Mt;try{var It=v.alternate;if((v.flags&1024)!==0)switch(v.tag){case 0:case 11:case 15:break;case 1:if(It!==null){var Lt=It.memoizedProps,qr=It.memoizedState,Ge=v.stateNode,Be=Ge.getSnapshotBeforeUpdate(v.elementType===v.type?Lt:An(v.type,Lt),qr);Ge.__reactInternalSnapshotBeforeUpdate=Be}break;case 3:var Ye=v.stateNode.containerInfo;Ye.nodeType===1?Ye.textContent="":Ye.nodeType===9&&Ye.documentElement&&Ye.removeChild(Ye.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(vt){fn(v,v.return,vt)}if(p=v.sibling,p!==null){p.return=v.return,Mt=p;break}Mt=v.return}return It=Dg,Dg=!1,It}function Yc(p,v,A){var M=v.updateQueue;if(M=M!==null?M.lastEffect:null,M!==null){var V=M=M.next;do{if((V.tag&p)===p){var J=V.destroy;V.destroy=void 0,J!==void 0&&Ih(v,A,J)}V=V.next}while(V!==M)}}function Dh(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 Lh(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 Lg(p){var v=p.alternate;v!==null&&(p.alternate=null,Lg(v)),p.child=null,p.deletions=null,p.sibling=null,p.tag===5&&(v=p.stateNode,v!==null&&(delete v[ca],delete v[Fc],delete v[Gf],delete v[Vm],delete v[Gm])),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 Bg(p){return p.tag===5||p.tag===3||p.tag===4}function zg(p){e:for(;;){for(;p.sibling===null;){if(p.return===null||Bg(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 Bh(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=rd));else if(M!==4&&(p=p.child,p!==null))for(Bh(p,v,A),p=p.sibling;p!==null;)Bh(p,v,A),p=p.sibling}function zh(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(zh(p,v,A),p=p.sibling;p!==null;)zh(p,v,A),p=p.sibling}var qn=null,Us=!1;function vo(p,v,A){for(A=A.child;A!==null;)ax(p,v,A),A=A.sibling}function ax(p,v,A){if(Rn&&typeof Rn.onCommitFiberUnmount=="function")try{Rn.onCommitFiberUnmount(Ii,A)}catch{}switch(A.tag){case 5:ai||Vl(A,v);case 6:var M=qn,V=Us;qn=null,vo(p,v,A),qn=M,Us=V,qn!==null&&(Us?(p=qn,A=A.stateNode,p.nodeType===8?p.parentNode.removeChild(A):p.removeChild(A)):qn.removeChild(A.stateNode));break;case 18:qn!==null&&(Us?(p=qn,A=A.stateNode,p.nodeType===8?Vf(p.parentNode,A):p.nodeType===1&&Vf(p,A),Aa(p)):Vf(qn,A.stateNode));break;case 4:M=qn,V=Us,qn=A.stateNode.containerInfo,Us=!0,vo(p,v,A),qn=M,Us=V;break;case 0:case 11:case 14:case 15:if(!ai&&(M=A.updateQueue,M!==null&&(M=M.lastEffect,M!==null))){V=M=M.next;do{var J=V,he=J.destroy;J=J.tag,he!==void 0&&((J&2)!==0||(J&4)!==0)&&Ih(A,v,he),V=V.next}while(V!==M)}vo(p,v,A);break;case 1:if(!ai&&(Vl(A,v),M=A.stateNode,typeof M.componentWillUnmount=="function"))try{M.props=A.memoizedProps,M.state=A.memoizedState,M.componentWillUnmount()}catch(ke){fn(A,v,ke)}vo(p,v,A);break;case 21:vo(p,v,A);break;case 22:A.mode&1?(ai=(M=ai)||A.memoizedState!==null,vo(p,v,A),ai=M):vo(p,v,A);break;default:vo(p,v,A)}}function Jc(p){var v=p.updateQueue;if(v!==null){p.updateQueue=null;var A=p.stateNode;A===null&&(A=p.stateNode=new ix),v.forEach(function(M){var V=hx.bind(null,p,M);A.has(M)||(A.add(M),M.then(V,V))})}}function ws(p,v){var A=v.deletions;if(A!==null)for(var M=0;M<A.length;M++){var V=A[M];try{var J=p,he=v,ke=he;e:for(;ke!==null;){switch(ke.tag){case 5:qn=ke.stateNode,Us=!1;break e;case 3:qn=ke.stateNode.containerInfo,Us=!0;break e;case 4:qn=ke.stateNode.containerInfo,Us=!0;break e}ke=ke.return}if(qn===null)throw Error(n(160));ax(J,he,V),qn=null,Us=!1;var Re=V.alternate;Re!==null&&(Re.return=null),V.return=null}catch(Xe){fn(V,v,Xe)}}if(v.subtreeFlags&12854)for(v=v.child;v!==null;)Fh(v,p),v=v.sibling}function Fh(p,v){var A=p.alternate,M=p.flags;switch(p.tag){case 0:case 11:case 14:case 15:if(ws(v,p),Ws(p),M&4){try{Yc(3,p,p.return),Dh(3,p)}catch(Lt){fn(p,p.return,Lt)}try{Yc(5,p,p.return)}catch(Lt){fn(p,p.return,Lt)}}break;case 1:ws(v,p),Ws(p),M&512&&A!==null&&Vl(A,A.return);break;case 5:if(ws(v,p),Ws(p),M&512&&A!==null&&Vl(A,A.return),p.flags&32){var V=p.stateNode;try{Pt(V,"")}catch(Lt){fn(p,p.return,Lt)}}if(M&4&&(V=p.stateNode,V!=null)){var J=p.memoizedProps,he=A!==null?A.memoizedProps:J,ke=p.type,Re=p.updateQueue;if(p.updateQueue=null,Re!==null)try{ke==="input"&&J.type==="radio"&&J.name!=null&&Me(V,J),kr(ke,he);var Xe=kr(ke,J);for(he=0;he<Re.length;he+=2){var ft=Re[he],ht=Re[he+1];ft==="style"?Tl(V,ht):ft==="dangerouslySetInnerHTML"?Ct(V,ht):ft==="children"?Pt(V,ht):C(V,ft,ht,Xe)}switch(ke){case"input":Ue(V,J);break;case"textarea":Qr(V,J);break;case"select":var dt=V._wrapperState.wasMultiple;V._wrapperState.wasMultiple=!!J.multiple;var Tt=J.value;Tt!=null?Yt(V,!!J.multiple,Tt,!1):dt!==!!J.multiple&&(J.defaultValue!=null?Yt(V,!!J.multiple,J.defaultValue,!0):Yt(V,!!J.multiple,J.multiple?[]:"",!1))}V[Fc]=J}catch(Lt){fn(p,p.return,Lt)}}break;case 6:if(ws(v,p),Ws(p),M&4){if(p.stateNode===null)throw Error(n(162));V=p.stateNode,J=p.memoizedProps;try{V.nodeValue=J}catch(Lt){fn(p,p.return,Lt)}}break;case 3:if(ws(v,p),Ws(p),M&4&&A!==null&&A.memoizedState.isDehydrated)try{Aa(v.containerInfo)}catch(Lt){fn(p,p.return,Lt)}break;case 4:ws(v,p),Ws(p);break;case 13:ws(v,p),Ws(p),V=p.child,V.flags&8192&&(J=V.memoizedState!==null,V.stateNode.isHidden=J,!J||V.alternate!==null&&V.alternate.memoizedState!==null||(Hh=Ar())),M&4&&Jc(p);break;case 22:if(ft=A!==null&&A.memoizedState!==null,p.mode&1?(ai=(Xe=ai)||ft,ws(v,p),ai=Xe):ws(v,p),Ws(p),M&8192){if(Xe=p.memoizedState!==null,(p.stateNode.isHidden=Xe)&&!ft&&(p.mode&1)!==0)for(Mt=p,ft=p.child;ft!==null;){for(ht=Mt=ft;Mt!==null;){switch(dt=Mt,Tt=dt.child,dt.tag){case 0:case 11:case 14:case 15:Yc(4,dt,dt.return);break;case 1:Vl(dt,dt.return);var It=dt.stateNode;if(typeof It.componentWillUnmount=="function"){M=dt,A=dt.return;try{v=M,It.props=v.memoizedProps,It.state=v.memoizedState,It.componentWillUnmount()}catch(Lt){fn(M,A,Lt)}}break;case 5:Vl(dt,dt.return);break;case 22:if(dt.memoizedState!==null){Uh(ht);continue}}Tt!==null?(Tt.return=dt,Mt=Tt):Uh(ht)}ft=ft.sibling}e:for(ft=null,ht=p;;){if(ht.tag===5){if(ft===null){ft=ht;try{V=ht.stateNode,Xe?(J=V.style,typeof J.setProperty=="function"?J.setProperty("display","none","important"):J.display="none"):(ke=ht.stateNode,Re=ht.memoizedProps.style,he=Re!=null&&Re.hasOwnProperty("display")?Re.display:null,ke.style.display=Jn("display",he))}catch(Lt){fn(p,p.return,Lt)}}}else if(ht.tag===6){if(ft===null)try{ht.stateNode.nodeValue=Xe?"":ht.memoizedProps}catch(Lt){fn(p,p.return,Lt)}}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;ft===ht&&(ft=null),ht=ht.return}ft===ht&&(ft=null),ht.sibling.return=ht.return,ht=ht.sibling}}break;case 19:ws(v,p),Ws(p),M&4&&Jc(p);break;case 21:break;default:ws(v,p),Ws(p)}}function Ws(p){var v=p.flags;if(v&2){try{e:{for(var A=p.return;A!==null;){if(Bg(A)){var M=A;break e}A=A.return}throw Error(n(160))}switch(M.tag){case 5:var V=M.stateNode;M.flags&32&&(Pt(V,""),M.flags&=-33);var J=zg(p);zh(p,J,V);break;case 3:case 4:var he=M.stateNode.containerInfo,ke=zg(p);Bh(p,ke,he);break;default:throw Error(n(161))}}catch(Re){fn(p,p.return,Re)}p.flags&=-3}v&4096&&(p.flags&=-4097)}function Fg(p,v,A){Mt=p,Ug(p)}function Ug(p,v,A){for(var M=(p.mode&1)!==0;Mt!==null;){var V=Mt,J=V.child;if(V.tag===22&&M){var he=V.memoizedState!==null||Mh;if(!he){var ke=V.alternate,Re=ke!==null&&ke.memoizedState!==null||ai;ke=Mh;var Xe=ai;if(Mh=he,(ai=Re)&&!Xe)for(Mt=V;Mt!==null;)he=Mt,Re=he.child,he.tag===22&&he.memoizedState!==null?Wh(V):Re!==null?(Re.return=he,Mt=Re):Wh(V);for(;J!==null;)Mt=J,Ug(J),J=J.sibling;Mt=V,Mh=ke,ai=Xe}Wg(p)}else(V.subtreeFlags&8772)!==0&&J!==null?(J.return=V,Mt=J):Wg(p)}}function Wg(p){for(;Mt!==null;){var v=Mt;if((v.flags&8772)!==0){var A=v.alternate;try{if((v.flags&8772)!==0)switch(v.tag){case 0:case 11:case 15:ai||Dh(5,v);break;case 1:var M=v.stateNode;if(v.flags&4&&!ai)if(A===null)M.componentDidMount();else{var V=v.elementType===v.type?A.memoizedProps:An(v.type,A.memoizedProps);M.componentDidUpdate(V,A.memoizedState,M.__reactInternalSnapshotBeforeUpdate)}var J=v.updateQueue;J!==null&&qb(v,J,M);break;case 3:var he=v.updateQueue;if(he!==null){if(A=null,v.child!==null)switch(v.child.tag){case 5:A=v.child.stateNode;break;case 1:A=v.child.stateNode}qb(v,he,A)}break;case 5:var ke=v.stateNode;if(A===null&&v.flags&4){A=ke;var Re=v.memoizedProps;switch(v.type){case"button":case"input":case"select":case"textarea":Re.autoFocus&&A.focus();break;case"img":Re.src&&(A.src=Re.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(v.memoizedState===null){var Xe=v.alternate;if(Xe!==null){var ft=Xe.memoizedState;if(ft!==null){var ht=ft.dehydrated;ht!==null&&Aa(ht)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}ai||v.flags&512&&Lh(v)}catch(dt){fn(v,v.return,dt)}}if(v===p){Mt=null;break}if(A=v.sibling,A!==null){A.return=v.return,Mt=A;break}Mt=v.return}}function Uh(p){for(;Mt!==null;){var v=Mt;if(v===p){Mt=null;break}var A=v.sibling;if(A!==null){A.return=v.return,Mt=A;break}Mt=v.return}}function Wh(p){for(;Mt!==null;){var v=Mt;try{switch(v.tag){case 0:case 11:case 15:var A=v.return;try{Dh(4,v)}catch(Re){fn(v,A,Re)}break;case 1:var M=v.stateNode;if(typeof M.componentDidMount=="function"){var V=v.return;try{M.componentDidMount()}catch(Re){fn(v,V,Re)}}var J=v.return;try{Lh(v)}catch(Re){fn(v,J,Re)}break;case 5:var he=v.return;try{Lh(v)}catch(Re){fn(v,he,Re)}}}catch(Re){fn(v,v.return,Re)}if(v===p){Mt=null;break}var ke=v.sibling;if(ke!==null){ke.return=v.return,Mt=ke;break}Mt=v.return}}var ox=Math.ceil,_d=T.ReactCurrentDispatcher,Sd=T.ReactCurrentOwner,_s=T.ReactCurrentBatchConfig,wr=0,$n=null,kn=null,Hn=0,is=0,Gl=Na(0),Ln=0,Zc=null,il=0,kd=0,qh=0,Cd=null,Vi=null,Hh=0,Kl=1/0,yo=null,jd=!1,Vh=null,bo=null,Ed=!1,sl=null,Td=0,Qc=0,Gh=null,eu=-1,Ad=0;function Ci(){return(wr&6)!==0?Ar():eu!==-1?eu:eu=Ar()}function xo(p){return(p.mode&1)===0?1:(wr&2)!==0&&Hn!==0?Hn&-Hn:nh.transition!==null?(Ad===0&&(Ad=rs()),Ad):(p=ze,p!==0||(p=window.event,p=p===void 0?16:me(p.type)),p)}function qs(p,v,A,M){if(50<Qc)throw Qc=0,Gh=null,Error(n(185));gi(p,A,M),((wr&2)===0||p!==$n)&&(p===$n&&((wr&2)===0&&(kd|=A),Ln===4&&wo(p,Hn)),Gi(p,M),A===1&&wr===0&&(v.mode&1)===0&&(Kl=Ar()+500,ad&&ho()))}function Gi(p,v){var A=p.callbackNode;Li(p,v);var M=ia(p,p===$n?Hn:0);if(M===0)A!==null&&Wn(A),p.callbackNode=null,p.callbackPriority=0;else if(v=M&-M,p.callbackPriority!==v){if(A!=null&&Wn(A),v===1)p.tag===0?f1(Vg.bind(null,p)):Jm(Vg.bind(null,p)),zb(function(){(wr&6)===0&&ho()}),A=null;else{switch(tt(M)){case 1:A=sn;break;case 4:A=ti;break;case 16:A=Ps;break;case 536870912:A=ta;break;default:A=Ps}A=Zg(A,qg.bind(null,p))}p.callbackPriority=v,p.callbackNode=A}}function qg(p,v){if(eu=-1,Ad=0,(wr&6)!==0)throw Error(n(327));var A=p.callbackNode;if(Xl()&&p.callbackNode!==A)return null;var M=ia(p,p===$n?Hn:0);if(M===0)return null;if((M&30)!==0||(M&p.expiredLanes)!==0||v)v=$d(p,M);else{v=M;var V=wr;wr|=2;var J=lx();($n!==p||Hn!==v)&&(yo=null,Kl=Ar()+500,ol(p,v));do try{g1();break}catch(ke){Gg(p,ke)}while(!0);ah(),_d.current=J,wr=V,kn!==null?v=0:($n=null,Hn=0,v=Ln)}if(v!==0){if(v===2&&(V=Ea(p),V!==0&&(M=V,v=Kh(p,V))),v===1)throw A=Zc,ol(p,0),wo(p,M),Gi(p,Ar()),A;if(v===6)wo(p,M);else{if(V=p.current.alternate,(M&30)===0&&!Hg(V)&&(v=$d(p,M),v===2&&(J=Ea(p),J!==0&&(M=J,v=Kh(p,J))),v===1))throw A=Zc,ol(p,0),wo(p,M),Gi(p,Ar()),A;switch(p.finishedWork=V,p.finishedLanes=M,v){case 0:case 1:throw Error(n(345));case 2:ll(p,Vi,yo);break;case 3:if(wo(p,M),(M&130023424)===M&&(v=Hh+500-Ar(),10<v)){if(ia(p,0)!==0)break;if(V=p.suspendedLanes,(V&M)!==M){Ci(),p.pingedLanes|=p.suspendedLanes&V;break}p.timeoutHandle=Hf(ll.bind(null,p,Vi,yo),v);break}ll(p,Vi,yo);break;case 4:if(wo(p,M),(M&4194240)===M)break;for(v=p.eventTimes,V=-1;0<M;){var he=31-an(M);J=1<<he,he=v[he],he>V&&(V=he),M&=~J}if(M=V,M=Ar()-M,M=(120>M?120:480>M?480:1080>M?1080:1920>M?1920:3e3>M?3e3:4320>M?4320:1960*ox(M/1960))-M,10<M){p.timeoutHandle=Hf(ll.bind(null,p,Vi,yo),M);break}ll(p,Vi,yo);break;case 5:ll(p,Vi,yo);break;default:throw Error(n(329))}}}return Gi(p,Ar()),p.callbackNode===A?qg.bind(null,p):null}function Kh(p,v){var A=Cd;return p.current.memoizedState.isDehydrated&&(ol(p,v).flags|=256),p=$d(p,v),p!==2&&(v=Vi,Vi=A,v!==null&&Xh(v)),p}function Xh(p){Vi===null?Vi=p:Vi.push.apply(Vi,p)}function Hg(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 V=A[M],J=V.getSnapshot;V=V.value;try{if(!Bs(J(),V))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&=~qh,v&=~kd,p.suspendedLanes|=v,p.pingedLanes&=~v,p=p.expirationTimes;0<v;){var A=31-an(v),M=1<<A;p[A]=-1,v&=~M}}function Vg(p){if((wr&6)!==0)throw Error(n(327));Xl();var v=ia(p,0);if((v&1)===0)return Gi(p,Ar()),null;var A=$d(p,v);if(p.tag!==0&&A===2){var M=Ea(p);M!==0&&(v=M,A=Kh(p,M))}if(A===1)throw A=Zc,ol(p,0),wo(p,v),Gi(p,Ar()),A;if(A===6)throw Error(n(345));return p.finishedWork=p.current.alternate,p.finishedLanes=v,ll(p,Vi,yo),Gi(p,Ar()),null}function Yh(p,v){var A=wr;wr|=1;try{return p(v)}finally{wr=A,wr===0&&(Kl=Ar()+500,ad&&ho())}}function al(p){sl!==null&&sl.tag===0&&(wr&6)===0&&Xl();var v=wr;wr|=1;var A=_s.transition,M=ze;try{if(_s.transition=null,ze=1,p)return p()}finally{ze=M,_s.transition=A,wr=v,(wr&6)===0&&ho()}}function Jh(){is=Gl.current,Kr(Gl)}function ol(p,v){p.finishedWork=null,p.finishedLanes=0;var A=p.timeoutHandle;if(A!==-1&&(p.timeoutHandle=-1,Bb(A)),kn!==null)for(A=kn.return;A!==null;){var M=A;switch(Yf(M),M.tag){case 1:M=M.type.childContextTypes,M!=null&&id();break;case 3:el(),Kr(Bi),Kr(_i),hh();break;case 5:dh(M);break;case 4:el();break;case 13:Kr(dn);break;case 19:Kr(dn);break;case 10:oh(M.type._context);break;case 22:case 23:Jh()}A=A.return}if($n=p,kn=p=_o(p.current,null),Hn=is=v,Ln=0,Zc=null,qh=kd=il=0,Vi=Cd=null,Wl!==null){for(v=0;v<Wl.length;v++)if(A=Wl[v],M=A.interleaved,M!==null){A.interleaved=null;var V=M.next,J=A.pending;if(J!==null){var he=J.next;J.next=V,M.next=he}A.pending=M}Wl=null}return p}function Gg(p,v){do{var A=kn;try{if(ah(),ph.current=yd,gh){for(var M=ln.memoizedState;M!==null;){var V=M.queue;V!==null&&(V.pending=null),M=M.next}gh=!1}if(tl=0,Dn=Tn=ln=null,rl=!1,go=0,Sd.current=null,A===null||A.return===null){Ln=1,Zc=v,kn=null;break}e:{var J=p,he=A.return,ke=A,Re=v;if(v=Hn,ke.flags|=32768,Re!==null&&typeof Re=="object"&&typeof Re.then=="function"){var Xe=Re,ft=ke,ht=ft.tag;if((ft.mode&1)===0&&(ht===0||ht===11||ht===15)){var dt=ft.alternate;dt?(ft.updateQueue=dt.updateQueue,ft.memoizedState=dt.memoizedState,ft.lanes=dt.lanes):(ft.updateQueue=null,ft.memoizedState=null)}var Tt=Qb(he);if(Tt!==null){Tt.flags&=-257,ki(Tt,he,ke,J,v),Tt.mode&1&&jg(J,Xe,v),v=Tt,Re=Xe;var It=v.updateQueue;if(It===null){var Lt=new Set;Lt.add(Re),v.updateQueue=Lt}else It.add(Re);break e}else{if((v&1)===0){jg(J,Xe,v),Zh();break e}Re=Error(n(426))}}else if(on&&ke.mode&1){var qr=Qb(he);if(qr!==null){(qr.flags&65536)===0&&(qr.flags|=256),ki(qr,he,ke,J,v),rh(Hl(Re,ke));break e}}J=Re=Hl(Re,ke),Ln!==4&&(Ln=2),Cd===null?Cd=[J]:Cd.push(J),J=he;do{switch(J.tag){case 3:J.flags|=65536,v&=-v,J.lanes|=v;var Ge=kg(J,Re,v);Wb(J,Ge);break e;case 1:ke=Re;var Be=J.type,Ye=J.stateNode;if((J.flags&128)===0&&(typeof Be.getDerivedStateFromError=="function"||Ye!==null&&typeof Ye.componentDidCatch=="function"&&(bo===null||!bo.has(Ye)))){J.flags|=65536,v&=-v,J.lanes|=v;var vt=Cg(J,ke,v);Wb(J,vt);break e}}J=J.return}while(J!==null)}tu(A)}catch(qt){v=qt,kn===A&&A!==null&&(kn=A=A.return);continue}break}while(!0)}function lx(){var p=_d.current;return _d.current=yd,p===null?yd:p}function Zh(){(Ln===0||Ln===3||Ln===2)&&(Ln=4),$n===null||(il&268435455)===0&&(kd&268435455)===0||wo($n,Hn)}function $d(p,v){var A=wr;wr|=2;var M=lx();($n!==p||Hn!==v)&&(yo=null,ol(p,v));do try{cx();break}catch(V){Gg(p,V)}while(!0);if(ah(),wr=A,_d.current=M,kn!==null)throw Error(n(261));return $n=null,Hn=0,Ln}function cx(){for(;kn!==null;)Kg(kn)}function g1(){for(;kn!==null&&!$l();)Kg(kn)}function Kg(p){var v=Jg(p.alternate,p,is);p.memoizedProps=p.pendingProps,v===null?tu(p):kn=v,Sd.current=null}function tu(p){var v=p;do{var A=v.alternate;if(p=v.return,(v.flags&32768)===0){if(A=rx(A,v,is),A!==null){kn=A;return}}else{if(A=nx(A,v),A!==null){A.flags&=32767,kn=A;return}if(p!==null)p.flags|=32768,p.subtreeFlags=0,p.deletions=null;else{Ln=6,kn=null;return}}if(v=v.sibling,v!==null){kn=v;return}kn=v=p}while(v!==null);Ln===0&&(Ln=5)}function ll(p,v,A){var M=ze,V=_s.transition;try{_s.transition=null,ze=1,Xg(p,v,A,M)}finally{_s.transition=V,ze=M}return null}function Xg(p,v,A,M){do Xl();while(sl!==null);if((wr&6)!==0)throw Error(n(327));A=p.finishedWork;var V=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 J=A.lanes|A.childLanes;if(yt(p,J),p===$n&&(kn=$n=null,Hn=0),(A.subtreeFlags&2064)===0&&(A.flags&2064)===0||Ed||(Ed=!0,Zg(Ps,function(){return Xl(),null})),J=(A.flags&15990)!==0,(A.subtreeFlags&15990)!==0||J){J=_s.transition,_s.transition=null;var he=ze;ze=1;var ke=wr;wr|=4,Sd.current=null,sx(p,A),Fh(A,p),Rb(Wf),lo=!!Uf,Wf=Uf=null,p.current=A,Fg(A),Nl(),wr=ke,ze=he,_s.transition=J}else p.current=A;if(Ed&&(Ed=!1,sl=p,Td=V),J=p.pendingLanes,J===0&&(bo=null),Wt(A.stateNode),Gi(p,Ar()),v!==null)for(M=p.onRecoverableError,A=0;A<v.length;A++)V=v[A],M(V.value,{componentStack:V.stack,digest:V.digest});if(jd)throw jd=!1,p=Vh,Vh=null,p;return(Td&1)!==0&&p.tag!==0&&Xl(),J=p.pendingLanes,(J&1)!==0?p===Gh?Qc++:(Qc=0,Gh=p):Qc=0,ho(),null}function Xl(){if(sl!==null){var p=tt(Td),v=_s.transition,A=ze;try{if(_s.transition=null,ze=16>p?16:p,sl===null)var M=!1;else{if(p=sl,sl=null,Td=0,(wr&6)!==0)throw Error(n(331));var V=wr;for(wr|=4,Mt=p.current;Mt!==null;){var J=Mt,he=J.child;if((Mt.flags&16)!==0){var ke=J.deletions;if(ke!==null){for(var Re=0;Re<ke.length;Re++){var Xe=ke[Re];for(Mt=Xe;Mt!==null;){var ft=Mt;switch(ft.tag){case 0:case 11:case 15:Yc(8,ft,J)}var ht=ft.child;if(ht!==null)ht.return=ft,Mt=ht;else for(;Mt!==null;){ft=Mt;var dt=ft.sibling,Tt=ft.return;if(Lg(ft),ft===Xe){Mt=null;break}if(dt!==null){dt.return=Tt,Mt=dt;break}Mt=Tt}}}var It=J.alternate;if(It!==null){var Lt=It.child;if(Lt!==null){It.child=null;do{var qr=Lt.sibling;Lt.sibling=null,Lt=qr}while(Lt!==null)}}Mt=J}}if((J.subtreeFlags&2064)!==0&&he!==null)he.return=J,Mt=he;else e:for(;Mt!==null;){if(J=Mt,(J.flags&2048)!==0)switch(J.tag){case 0:case 11:case 15:Yc(9,J,J.return)}var Ge=J.sibling;if(Ge!==null){Ge.return=J.return,Mt=Ge;break e}Mt=J.return}}var Be=p.current;for(Mt=Be;Mt!==null;){he=Mt;var Ye=he.child;if((he.subtreeFlags&2064)!==0&&Ye!==null)Ye.return=he,Mt=Ye;else e:for(he=Be;Mt!==null;){if(ke=Mt,(ke.flags&2048)!==0)try{switch(ke.tag){case 0:case 11:case 15:Dh(9,ke)}}catch(qt){fn(ke,ke.return,qt)}if(ke===he){Mt=null;break e}var vt=ke.sibling;if(vt!==null){vt.return=ke.return,Mt=vt;break e}Mt=ke.return}}if(wr=V,ho(),Rn&&typeof Rn.onPostCommitFiberRoot=="function")try{Rn.onPostCommitFiberRoot(Ii,p)}catch{}M=!0}return M}finally{ze=A,_s.transition=v}}return!1}function Yg(p,v,A){v=Hl(A,v),v=kg(p,v,1),p=mo(p,v,1),v=Ci(),p!==null&&(gi(p,1,v),Gi(p,v))}function fn(p,v,A){if(p.tag===3)Yg(p,p,A);else for(;v!==null;){if(v.tag===3){Yg(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=Hl(A,p),p=Cg(v,p,1),v=mo(v,p,1),p=Ci(),v!==null&&(gi(v,1,p),Gi(v,p));break}}v=v.return}}function ux(p,v,A){var M=p.pingCache;M!==null&&M.delete(v),v=Ci(),p.pingedLanes|=p.suspendedLanes&A,$n===p&&(Hn&A)===A&&(Ln===4||Ln===3&&(Hn&130023424)===Hn&&500>Ar()-Hh?ol(p,0):qh|=A),Gi(p,v)}function dx(p,v){v===0&&((p.mode&1)===0?v=1:(v=mi,mi<<=1,(mi&130023424)===0&&(mi=4194304)));var A=Ci();p=Pa(p,v),p!==null&&(gi(p,v,A),Gi(p,A))}function fx(p){var v=p.memoizedState,A=0;v!==null&&(A=v.retryLane),dx(p,A)}function hx(p,v){var A=0;switch(p.tag){case 13:var M=p.stateNode,V=p.memoizedState;V!==null&&(A=V.retryLane);break;case 19:M=p.stateNode;break;default:throw Error(n(314))}M!==null&&M.delete(v),dx(p,A)}var Jg;Jg=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,m1(p,v,A);Hi=(p.flags&131072)!==0}else Hi=!1,on&&(v.flags&1048576)!==0&&Xo(v,ld,v.index);switch(v.lanes=0,v.tag){case 2:var M=v.type;xd(p,v),p=v.pendingProps;var V=Si(v,_i.current);Ul(v,A),V=yh(null,v,M,p,V,A);var J=bh();return v.flags|=1,typeof V=="object"&&V!==null&&typeof V.render=="function"&&V.$$typeof===void 0?(v.tag=1,v.memoizedState=null,v.updateQueue=null,zi(M)?(J=!0,sd(v)):J=!1,v.memoizedState=V.state!==null&&V.state!==void 0?V.state:null,fd(v),V.updater=Ma,v.stateNode=V,V._reactInternals=v,Sh(v,M,p,A),v=Eh(null,v,M,!0,J,A)):(v.tag=0,on&&J&&En(v),ii(null,v,V,A),v=v.child),v;case 16:M=v.elementType;e:{switch(xd(p,v),p=v.pendingProps,V=M._init,M=V(M._payload),v.type=M,V=v.tag=px(M),p=An(M,p),V){case 0:v=jh(null,v,M,p,A);break e;case 1:v=Ng(null,v,M,p,A);break e;case 11:v=Eg(null,v,M,p,A);break e;case 14:v=Kc(null,v,M,An(M.type,p),A);break e}throw Error(n(306,M,""))}return v;case 0:return M=v.type,V=v.pendingProps,V=v.elementType===M?V:An(M,V),jh(p,v,M,V,A);case 1:return M=v.type,V=v.pendingProps,V=v.elementType===M?V:An(M,V),Ng(p,v,M,V,A);case 3:e:{if(Th(v),p===null)throw Error(n(387));M=v.pendingProps,J=v.memoizedState,V=J.element,ch(p,v),hd(v,M,null,A);var he=v.memoizedState;if(M=he.element,J.isDehydrated)if(J={element:M,isDehydrated:!1,cache:he.cache,pendingSuspenseBoundaries:he.pendingSuspenseBoundaries,transitions:he.transitions},v.updateQueue.baseState=J,v.memoizedState=J,v.flags&256){V=Hl(Error(n(423)),v),v=Og(p,v,M,A,V);break e}else if(M!==V){V=Hl(Error(n(424)),v),v=Og(p,v,M,A,V);break e}else for(ns=uo(v.stateNode.containerInfo.firstChild),Wi=v,on=!0,qi=null,A=ih(v,null,M,A),v.child=A;A;)A.flags=A.flags&-3|4096,A=A.sibling;else{if(Yo(),M===V){v=Ia(p,v,A);break e}ii(p,v,M,A)}v=v.child}return v;case 5:return tg(v),p===null&&eh(v),M=v.type,V=v.pendingProps,J=p!==null?p.memoizedProps:null,he=V.children,qf(M,V)?he=null:J!==null&&qf(M,J)&&(v.flags|=32),$g(p,v),ii(p,v,he,A),v.child;case 6:return p===null&&eh(v),null;case 13:return Pg(p,v,A);case 4:return uh(v,v.stateNode.containerInfo),M=v.pendingProps,p===null?v.child=Fl(v,null,M,A):ii(p,v,M,A),v.child;case 11:return M=v.type,V=v.pendingProps,V=v.elementType===M?V:An(M,V),Eg(p,v,M,V,A);case 7:return ii(p,v,v.pendingProps,A),v.child;case 8:return ii(p,v,v.pendingProps.children,A),v.child;case 12:return ii(p,v,v.pendingProps.children,A),v.child;case 10:e:{if(M=v.type._context,V=v.pendingProps,J=v.memoizedProps,he=V.value,Wr(Jo,M._currentValue),M._currentValue=he,J!==null)if(Bs(J.value,he)){if(J.children===V.children&&!Bi.current){v=Ia(p,v,A);break e}}else for(J=v.child,J!==null&&(J.return=v);J!==null;){var ke=J.dependencies;if(ke!==null){he=J.child;for(var Re=ke.firstContext;Re!==null;){if(Re.context===M){if(J.tag===1){Re=Ra(-1,A&-A),Re.tag=2;var Xe=J.updateQueue;if(Xe!==null){Xe=Xe.shared;var ft=Xe.pending;ft===null?Re.next=Re:(Re.next=ft.next,ft.next=Re),Xe.pending=Re}}J.lanes|=A,Re=J.alternate,Re!==null&&(Re.lanes|=A),eg(J.return,A,v),ke.lanes|=A;break}Re=Re.next}}else if(J.tag===10)he=J.type===v.type?null:J.child;else if(J.tag===18){if(he=J.return,he===null)throw Error(n(341));he.lanes|=A,ke=he.alternate,ke!==null&&(ke.lanes|=A),eg(he,A,v),he=J.sibling}else he=J.child;if(he!==null)he.return=J;else for(he=J;he!==null;){if(he===v){he=null;break}if(J=he.sibling,J!==null){J.return=he.return,he=J;break}he=he.return}J=he}ii(p,v,V.children,A),v=v.child}return v;case 9:return V=v.type,M=v.pendingProps.children,Ul(v,A),V=bs(V),M=M(V),v.flags|=1,ii(p,v,M,A),v.child;case 14:return M=v.type,V=An(M,v.pendingProps),V=An(M.type,V),Kc(p,v,M,V,A);case 15:return Tg(p,v,v.type,v.pendingProps,A);case 17:return M=v.type,V=v.pendingProps,V=v.elementType===M?V:An(M,V),xd(p,v),v.tag=1,zi(M)?(p=!0,sd(v)):p=!1,Ul(v,A),_g(v,M,V),Sh(v,M,V,A),Eh(null,v,M,!0,p,A);case 19:return Oh(p,v,A);case 22:return Ag(p,v,A)}throw Error(n(156,v.tag))};function Zg(p,v){return Wo(p,v)}function v1(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 ss(p,v,A,M){return new v1(p,v,A,M)}function Qh(p){return p=p.prototype,!(!p||!p.isReactComponent)}function px(p){if(typeof p=="function")return Qh(p)?1:0;if(p!=null){if(p=p.$$typeof,p===U)return 11;if(p===Y)return 14}return 2}function _o(p,v){var A=p.alternate;return A===null?(A=ss(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 Nd(p,v,A,M,V,J){var he=2;if(M=p,typeof p=="function")Qh(p)&&(he=1);else if(typeof p=="string")he=5;else e:switch(p){case N:return Yl(A.children,V,J,v);case P:he=8,V|=8;break;case I:return p=ss(12,A,v,V|2),p.elementType=I,p.lanes=J,p;case q:return p=ss(13,A,v,V),p.elementType=q,p.lanes=J,p;case z:return p=ss(19,A,v,V),p.elementType=z,p.lanes=J,p;case se:return Od(A,V,J,v);default:if(typeof p=="object"&&p!==null)switch(p.$$typeof){case W:he=10;break e;case F:he=9;break e;case U:he=11;break e;case Y:he=14;break e;case ee:he=16,M=null;break e}throw Error(n(130,p==null?p:typeof p,""))}return v=ss(he,A,v,V),v.elementType=p,v.type=M,v.lanes=J,v}function Yl(p,v,A,M){return p=ss(7,p,M,v),p.lanes=A,p}function Od(p,v,A,M){return p=ss(22,p,M,v),p.elementType=se,p.lanes=A,p.stateNode={isHidden:!1},p}function ep(p,v,A){return p=ss(6,p,null,v),p.lanes=A,p}function tp(p,v,A){return v=ss(4,p.children!==null?p.children:[],p.key,v),v.lanes=A,v.stateNode={containerInfo:p.containerInfo,pendingChildren:null,implementation:p.implementation},v}function y1(p,v,A,M,V){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=V,this.mutableSourceEagerHydrationData=null}function rp(p,v,A,M,V,J,he,ke,Re){return p=new y1(p,v,A,ke,Re),v===1?(v=1,J===!0&&(v|=8)):v=0,J=ss(3,null,null,v),p.current=J,J.stateNode=p,J.memoizedState={element:M,isDehydrated:A,cache:null,transitions:null,pendingSuspenseBoundaries:null},fd(J),p}function b1(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 Qg(p){if(!p)return fo;p=p._reactInternals;e:{if(Et(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 Xm(p,A,v)}return v}function mx(p,v,A,M,V,J,he,ke,Re){return p=rp(A,M,!0,p,V,J,he,ke,Re),p.context=Qg(null),A=p.current,M=Ci(),V=xo(A),J=Ra(M,V),J.callback=v??null,mo(A,J,V),p.current.lanes=V,gi(p,V,M),Gi(p,M),p}function Pd(p,v,A,M){var V=v.current,J=Ci(),he=xo(V);return A=Qg(A),v.context===null?v.context=A:v.pendingContext=A,v=Ra(J,he),v.payload={element:p},M=M===void 0?null:M,M!==null&&(v.callback=M),p=mo(V,v,he),p!==null&&(qs(p,V,he,J),qc(p,V,he)),he}function Rd(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 ev(p,v){if(p=p.memoizedState,p!==null&&p.dehydrated!==null){var A=p.retryLane;p.retryLane=A!==0&&A<v?A:v}}function np(p,v){ev(p,v),(p=p.alternate)&&ev(p,v)}function gx(){return null}var vx=typeof reportError=="function"?reportError:function(p){console.error(p)};function ip(p){this._internalRoot=p}Jl.prototype.render=ip.prototype.render=function(p){var v=this._internalRoot;if(v===null)throw Error(n(409));Pd(p,v,null,null)},Jl.prototype.unmount=ip.prototype.unmount=function(){var p=this._internalRoot;if(p!==null){this._internalRoot=null;var v=p.containerInfo;al(function(){Pd(null,p,null,null)}),v[ua]=null}};function Jl(p){this._internalRoot=p}Jl.prototype.unstable_scheduleHydration=function(p){if(p){var v=Br();p={blockedOn:null,target:p,priority:v};for(var A=0;A<Rs.length&&v!==0&&v<Rs[A].priority;A++);Rs.splice(A,0,p),A===0&&Ec(p)}};function sp(p){return!(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11)}function Md(p){return!(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11&&(p.nodeType!==8||p.nodeValue!==" react-mount-point-unstable "))}function yx(){}function bx(p,v,A,M,V){if(V){if(typeof M=="function"){var J=M;M=function(){var Xe=Rd(he);J.call(Xe)}}var he=mx(v,M,p,0,null,!1,!1,"",yx);return p._reactRootContainer=he,p[ua]=he.current,Bc(p.nodeType===8?p.parentNode:p),al(),he}for(;V=p.lastChild;)p.removeChild(V);if(typeof M=="function"){var ke=M;M=function(){var Xe=Rd(Re);ke.call(Xe)}}var Re=rp(p,0,!1,null,null,!1,!1,"",yx);return p._reactRootContainer=Re,p[ua]=Re.current,Bc(p.nodeType===8?p.parentNode:p),al(function(){Pd(v,Re,A,M)}),Re}function ru(p,v,A,M,V){var J=A._reactRootContainer;if(J){var he=J;if(typeof V=="function"){var ke=V;V=function(){var Re=Rd(he);ke.call(Re)}}Pd(v,he,p,V)}else he=bx(A,v,p,V,M);return Rd(he)}At=function(p){switch(p.tag){case 3:var v=p.stateNode;if(v.current.memoizedState.isDehydrated){var A=fs(v.pendingLanes);A!==0&&(Se(v,A|1),Gi(v,Ar()),(wr&6)===0&&(Kl=Ar()+500,ho()))}break;case 13:al(function(){var M=Pa(p,1);if(M!==null){var V=Ci();qs(M,p,1,V)}}),np(p,1)}},ir=function(p){if(p.tag===13){var v=Pa(p,134217728);if(v!==null){var A=Ci();qs(v,p,134217728,A)}np(p,134217728)}},dr=function(p){if(p.tag===13){var v=xo(p),A=Pa(p,v);if(A!==null){var M=Ci();qs(A,p,v,M)}np(p,v)}},Br=function(){return ze},Dr=function(p,v){var A=ze;try{return ze=p,v()}finally{ze=A}},Zs=function(p,v,A){switch(v){case"input":if(Ue(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 V=nd(M);if(!V)throw Error(n(90));Te(M),Ue(M,V)}}}break;case"textarea":Qr(p,A);break;case"select":v=A.value,v!=null&&Yt(p,!!A.multiple,v,!1)}},ds=Yh,Zn=al;var tv={usingClientEntryPoint:!1,Events:[Uc,Il,nd,Qs,ea,Yh]},Hs={findFiberByHostInstance:Go,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},xx={bundleType:Hs.bundleType,version:Hs.version,rendererPackageName:Hs.rendererPackageName,rendererConfig:Hs.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=ro(p),p===null?null:p.stateNode},findFiberByHostInstance:Hs.findFiberByHostInstance||gx,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 nu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!nu.isDisabled&&nu.supportsFiber)try{Ii=nu.inject(xx),Rn=nu}catch{}}return Vs.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=tv,Vs.createPortal=function(p,v){var A=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!sp(v))throw Error(n(200));return b1(p,v,null,A)},Vs.createRoot=function(p,v){if(!sp(p))throw Error(n(299));var A=!1,M="",V=vx;return v!=null&&(v.unstable_strictMode===!0&&(A=!0),v.identifierPrefix!==void 0&&(M=v.identifierPrefix),v.onRecoverableError!==void 0&&(V=v.onRecoverableError)),v=rp(p,1,!1,null,null,A,!1,M,V),p[ua]=v.current,Bc(p.nodeType===8?p.parentNode:p),new ip(v)},Vs.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=ro(v),p=p===null?null:p.stateNode,p},Vs.flushSync=function(p){return al(p)},Vs.hydrate=function(p,v,A){if(!Md(v))throw Error(n(200));return ru(null,p,v,!0,A)},Vs.hydrateRoot=function(p,v,A){if(!sp(p))throw Error(n(405));var M=A!=null&&A.hydratedSources||null,V=!1,J="",he=vx;if(A!=null&&(A.unstable_strictMode===!0&&(V=!0),A.identifierPrefix!==void 0&&(J=A.identifierPrefix),A.onRecoverableError!==void 0&&(he=A.onRecoverableError)),v=mx(v,null,p,1,A??null,V,!1,J,he),p[ua]=v.current,Bc(p),M)for(p=0;p<M.length;p++)A=M[p],V=A._getVersion,V=V(A._source),v.mutableSourceEagerHydrationData==null?v.mutableSourceEagerHydrationData=[A,V]:v.mutableSourceEagerHydrationData.push(A,V);return new Jl(v)},Vs.render=function(p,v,A){if(!Md(v))throw Error(n(200));return ru(null,p,v,!1,A)},Vs.unmountComponentAtNode=function(p){if(!Md(p))throw Error(n(40));return p._reactRootContainer?(al(function(){ru(null,null,p,!1,function(){p._reactRootContainer=null,p[ua]=null})}),!0):!1},Vs.unstable_batchedUpdates=Yh,Vs.unstable_renderSubtreeIntoContainer=function(p,v,A,M){if(!Md(A))throw Error(n(200));if(p==null||p._reactInternals===void 0)throw Error(n(38));return ru(p,v,A,!1,M)},Vs.version="18.3.1-next-f1338f8080-20240426",Vs}var J$;function S4(){if(J$)return k1.exports;J$=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(),k1.exports=vW(),k1.exports}var Z$;function yW(){if(Z$)return Sx;Z$=1;var e=S4();return Sx.createRoot=e.createRoot,Sx.hydrateRoot=e.hydrateRoot,Sx}var bW=yW();const xW=Zr(bW);var D=GT();const He=Zr(D),Q$=e=>{let r;const n=new Set,i=(f,m)=>{const h=typeof f=="function"?f(r):f;if(!Object.is(h,r)){const b=r;r=m??(typeof h!="object"||h===null)?h:Object.assign({},r,h),n.forEach(w=>w(r,b))}},s=()=>r,l={setState:i,getState:s,getInitialState:()=>u,subscribe:f=>(n.add(f),()=>n.delete(f))},u=r=e(i,s,l);return l},wW=(e=>e?Q$(e):Q$),_W=e=>e;function SW(e,r=_W){const n=He.useSyncExternalStore(e.subscribe,He.useCallback(()=>r(e.getState()),[e,r]),He.useCallback(()=>r(e.getInitialState()),[e,r]));return He.useDebugValue(n),n}const eN=e=>{const r=wW(e),n=i=>SW(r,i);return Object.assign(n,r),n},jn=(e=>e?eN(e):eN);function Lo(e){return"'"+e.replace(/'/g,"'\\''")+"'"}const E1=({sessionId:e})=>`claude --dangerously-skip-permissions --session-id ${Lo(e)}`,tN=({sessionId:e})=>`claude --session-id ${Lo(e)}`,kW=()=>"claude --resume",k4=[{id:"sm-dangerous",label:"Session Manager (skip perms)",description:"claude --dangerously-skip-permissions in this project",category:"build",cwd:"app-cwd",command:E1},{id:"sm-safe",label:"Session Manager (safe)",description:"claude with normal permission prompts in this project",category:"build",cwd:"app-cwd",command:tN},{id:"home-dangerous",label:"Home (skip perms)",description:"claude --dangerously-skip-permissions in ~",category:"build",cwd:"home",command:E1},{id:"pick-dangerous",label:"Pick directory (skip perms)…",description:"Choose a folder, launch claude --dangerously-skip-permissions",category:"build",cwd:"pick",command:E1},{id:"pick-safe",label:"Pick directory (safe)…",description:"Choose a folder, launch claude with normal prompts",category:"build",cwd:"pick",command:tN},{id:"pick-resume",label:"Pick directory + resume…",description:"Choose a folder, then pick a past session to resume",category:"build",cwd:"pick",command:kW},{id:"pick-shell",label:"Pick directory (shell only)…",description:"Bare interactive shell, no claude auto-launch",category:"build",cwd:"pick",command:null}];let La=null;async function CW(){if(La)return La;try{const e=await window.api.app.engageRulesPath();if(!e)return La=[],La;const r=await window.api.config.readJson(e);if(!r.exists||r.parseError||!r.data)return La=[],La;const n=r.data;if(!n.presets||!Array.isArray(n.presets))return La=[],La;const i=n.projectPath;return La=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 ${Lo(i)} && ${s.cliEntry}`})),La}catch(e){return console.warn("[presets] Failed to load engage presets:",e),La=[],La}}async function C4(e){const r=k4.find(i=>i.id===e);return r||((await CW()).find(i=>i.id===e)??null)}async function rN(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 j4(e,r){return e.command?e.command(r):null}const KT=["opus","sonnet","haiku"],E4="sm.rawSessionModel",jW="opus";function EW(e){return KT.includes(e)}function TW(){try{const e=localStorage.getItem(E4);if(e&&EW(e))return e}catch{}return jW}let jp=TW();const kj=new Set;function T4(){return jp}function AW(e){if(e!==jp){jp=e;try{localStorage.setItem(E4,e)}catch{}kj.forEach(r=>r(e))}}function $W(){const[e,r]=D.useState(jp);D.useEffect(()=>{const i=s=>r(s);return kj.add(i),jp!==e&&r(jp),()=>{kj.delete(i)}},[]);const n=D.useCallback(i=>AW(i),[]);return{model:e,setModel:n}}async function A4(e,r){const n=await window.api.transcripts.pathFor(e,r);return window.api.config.exists(n)}function NW(e){const r=e.split("/").filter(Boolean);return r[r.length-1]||e}async function $4(e,r=!1,n=T4()){let i=!r;i&&(i=await A4(e.cwd,e.claudeSessionId));const s=r&&!i?crypto.randomUUID():e.claudeSessionId,a=i?`claude --dangerously-skip-permissions --resume ${Lo(s)} --model ${n}`:`claude --dangerously-skip-permissions --session-id ${Lo(s)} --model ${n}`;return{claudeSessionId:s,startupCommand:a}}const kt=jn((e,r)=>({tabs:[],activeTabId:null,hydrated:!1,addTab:({id:n,cwd:i,startupCommand:s,presetId:a=null,label:c})=>{const l=n??crypto.randomUUID();if(r().tabs.find(m=>m.id===l))return e({activeTabId:l}),l;const f={id:l,claudeSessionId:l,chatSessionId:crypto.randomUUID(),label:c??NW(i),cwd:i,pid:null,status:"spawning",exitCode:null,startupCommand:s,presetId:a,generation:0};return e({tabs:[...r().tabs,f],activeTabId:l}),l},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(c=>c.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(c=>c.id===n);if(!i)return;window.api.pty.kill(n);const s=crypto.randomUUID(),a=c=>{e({tabs:r().tabs.map(l=>l.id===n?{...l,claudeSessionId:s,pid:null,status:"spawning",exitCode:null,startupCommand:c,generation:l.generation+1}:l)})};i.presetId?C4(i.presetId).then(c=>{a(c?j4(c,{sessionId:s,cwd:i.cwd}):`claude --dangerously-skip-permissions --session-id ${Lo(s)}`)}):a(`claude --dangerously-skip-permissions --session-id ${Lo(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}),wakeTab:async(n,i)=>{const s=r().tabs.find(l=>l.id===n);if(!s||s.status!=="dormant")return;const{claudeSessionId:a,startupCommand:c}=await $4({cwd:s.cwd,claudeSessionId:s.claudeSessionId},!1,i??T4());e({tabs:r().tabs.map(l=>l.id===n?{...l,claudeSessionId:a,status:"spawning",startupCommand:c,generation:l.generation+1}:l)})},sleepTab:n=>{const i=r().tabs.find(s=>s.id===n);!i||i.status==="dormant"||(window.api.pty.kill(n),e({tabs:r().tabs.map(s=>s.id===n?{...s,pid:null,status:"dormant"}:s)}))},newChatThread:n=>{r().tabs.find(s=>s.id===n)&&e({tabs:r().tabs.map(s=>s.id===n?{...s,chatSessionId:crypto.randomUUID()}:s)})}}));async function Cj(){var n;if(kt.getState().hydrated)return;try{const{tabs:i,activeTabId:s,freshStart:a}=await window.api.sessions.load();if(i.length>0){const c=await Promise.all(i.map(async u=>{const{claudeSessionId:f}=await $4(u,a);return{id:u.id,claudeSessionId:f,chatSessionId:u.chatSessionId??crypto.randomUUID(),cwd:u.cwd,label:u.label,presetId:u.presetId,pid:null,status:"dormant",exitCode:null,startupCommand:null,generation:0}})),l=s&&c.find(u=>u.id===s)?s:((n=c[0])==null?void 0:n.id)??null;kt.getState().restoreTabs(c,l)}else kt.setState({hydrated:!0})}catch(i){console.warn("[sessions] hydrate failed:",i),kt.setState({hydrated:!0})}const e=()=>{const{tabs:i,activeTabId:s}=kt.getState(),a=i.map(c=>({id:c.id,claudeSessionId:c.claudeSessionId,chatSessionId:c.chatSessionId,cwd:c.cwd,label:c.label,presetId:c.presetId}));window.api.sessions.save({tabs:a,activeTabId:s}).catch(c=>{console.warn("[sessions] save failed:",c)})};let r=null;kt.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 OW=Object.freeze(Object.defineProperty({__proto__:null,hydrateSessions:Cj,useSessions:kt},Symbol.toStringTag,{value:"Module"})),PW=5,nN=100,RW=5e3,jj=new Map;function iN(e){const r=jj.get(e);r!==void 0&&(clearTimeout(r),jj.delete(e))}function MW(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`t-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}const Vd=jn((e,r)=>({toasts:[],history:[],unreadCount:0,show:(n,i)=>{const s=MW(),a=Date.now();e(l=>{const u=[...l.toasts,{id:s,kind:n,message:i,createdAt:a}];for(;u.length>PW;){const h=u.shift();h&&iN(h.id)}const m=[{id:s,kind:n,message:i,createdAt:a,read:!1},...l.history];return m.length>nN&&(m.length=nN),{toasts:u,history:m,unreadCount:l.unreadCount+1}});const c=setTimeout(()=>r().dismiss(s),RW);return jj.set(s,c),s},dismiss:n=>{iN(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(c=>c.id!==n);if(s.length===i.history.length)return i;const a=i.history.find(c=>c.id===n&&!c.read);return{history:s,unreadCount:a?Math.max(0,i.unreadCount-1):i.unreadCount}})}})),Ze={info:e=>Vd.getState().show("info",e),warn:e=>Vd.getState().show("warn",e),error:e=>Vd.getState().show("error",e),fromOutcome:e=>Vd.getState().show(e.kind??(e.ok?"info":"warn"),e.message)},N4=Object.freeze(Object.defineProperty({__proto__:null,toast:Ze,useToast:Vd},Symbol.toStringTag,{value:"Module"})),sN=200,IW=/\x1b\[[0-9;]*m/g;function DW(e){return e.replace(IW,"")}const ry=jn((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 c=await window.api.watchers.add({tabId:n,label:i,command:s,cwd:a??null}),l={watcherId:c.watcherId,tabId:c.tabId,label:c.label,command:c.command,cwd:c.cwd,pid:c.pid,startedAt:c.startedAt,lineCount:0,lines:[],lastLineAt:null};return e({watchers:{...r().watchers,[l.watcherId]:l}}),l}catch(c){return console.error("[watchers] add failed:",c),Ze.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);Ze.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=DW(n.line),a=i.lines.length>=sN?[...i.lines.slice(i.lines.length-sN+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})}})),LW="~/.claude/session-manager/browser/history.json",aN="~/.claude/session-manager/browser/bookmarks.json",BW=.25,zW=3,oN=.1,lN=["#b85c34","#6f7d52","#e4b85a","#5f6f86","#8a5a6e","#4f7d72"];let cN=0;function FW(){const e=lN[cN%lN.length];return cN+=1,e}const Lw=new Map;function UW(e){if(Lw.has(e))return;const r=window.api.browser.onNavState(e,n=>{Rt.setState(i=>({tabs:i.tabs.map(s=>s.viewId===e?{...s,url:n.url,title:n.title||s.title,canGoBack:n.canGoBack,canGoForward:n.canGoForward,loading:n.loading,isSecure:n.isSecure}:s)}))});Lw.set(e,r)}function WW(e){const r=Lw.get(e);r&&(r(),Lw.delete(e))}const Ej=new Map;let ww=null;function uN(e){const r=Ej.get(e);r&&(r(),Ej.delete(e))}function dN(){ww&&(clearInterval(ww),ww=null)}const Tj=new Map;function T1(e){const r=Tj.get(e);r&&(r(),Tj.delete(e))}const Rt=jn((e,r)=>({tabs:[],activeTabId:null,openTab:n=>{const i=crypto.randomUUID(),s=i,a={id:i,viewId:s,title:"New Tab",url:(n==null?void 0:n.url)??"about:blank",color:(n==null?void 0:n.color)??FW(),canGoBack:!1,canGoForward:!1,loading:!1,isSecure:!1,zoomFactor:1};return e(c=>({tabs:[...c.tabs,a],activeTabId:i})),UW(s),window.api.browser.create({viewId:s,partition:"persist:browser"}).then(()=>{n!=null&&n.url&&window.api.browser.navigate({viewId:s,url:n.url}).catch(()=>{})}).catch(c=>{var u,f;const l=c instanceof Error?c.message:String(c);(f=(u=window.api)==null?void 0:u.logs)==null||f.write("browser","error",`browser:create failed for viewId ${s}: ${l}`)}),i},closeTab:n=>{const i=r().tabs.find(s=>s.id===n);i&&(WW(i.viewId),T1(i.viewId),window.api.browser.destroy(i.viewId).catch(()=>{}),e(s=>{const a=s.tabs.filter(l=>l.id!==n),c=s.activeTabId===n?a.length?a[a.length-1].id:null:s.activeTabId;return{tabs:a,activeTabId:c}}))},setActive:n=>{e({activeTabId:n})},navigate:(n,i)=>{const s=r().tabs.find(a=>a.id===n);s&&window.api.browser.navigate({viewId:s.viewId,url:i}).catch(()=>{})},back:n=>{const i=r().tabs.find(s=>s.id===n);i&&window.api.browser.back(i.viewId).catch(()=>{})},forward:n=>{const i=r().tabs.find(s=>s.id===n);i&&window.api.browser.forward(i.viewId).catch(()=>{})},reload:n=>{const i=r().tabs.find(s=>s.id===n);i&&window.api.browser.reload(i.viewId).catch(()=>{})},stop:n=>{const i=r().tabs.find(s=>s.id===n);i&&window.api.browser.stop(i.viewId).catch(()=>{})},mode:"browse",captureMode:"agent",setMode:n=>e(i=>({mode:n,captured:n==="capture"?i.captured:null})),setCaptureMode:n=>e({captureMode:n,captured:null}),onVerb:n=>{const{mode:i}=r();if(n==="shot"){e({mode:"capture",captureMode:"shot",captured:null});return}if(i===n){e({mode:"browse",captured:n==="capture"?null:r().captured});return}e({mode:n,captureMode:n==="capture"?"agent":r().captureMode,captured:n==="capture"?r().captured:null})},captured:null,capture:async n=>{const{activeTabId:i,tabs:s,captureMode:a}=r(),c=s.find(u=>u.id===i);if(!c)throw new Error("No active browser tab");if(a==="shot"){const u=await window.api.browser.captureShot(c.viewId);if(!u.ok)throw new Error(u.error);e({captured:{mode:a,url:u.url,title:u.title,dataUrl:u.dataUrl,at:Date.now()}});return}if(!n||!n.length)throw new Error("No element selected");const l=await window.api.browser.capture({viewId:c.viewId,selectors:n,mode:a});if(!l.ok)throw new Error(l.error);e({captured:{mode:a,url:c.url,title:c.title,text:l.text,meta:l.meta,selectors:n,at:Date.now()}})},recorderActive:!1,recording:!1,recorderElapsedSec:0,recorderSteps:[],startRecording:n=>{if(r().recorderActive)return;e({recorderActive:!0,recording:!0,recorderElapsedSec:0,recorderSteps:[]}),window.api.browser.recordStart(n).catch(()=>{}),uN(n);const i=window.api.browser.onRecordStep(n,s=>{Rt.getState().recording&&Rt.setState(a=>({recorderSteps:[...a.recorderSteps,s]}))});Ej.set(n,i),dN(),ww=setInterval(()=>{Rt.getState().recording&&Rt.setState(s=>({recorderElapsedSec:s.recorderElapsedSec+1}))},1e3)},stopRecording:n=>{r().recorderActive&&(window.api.browser.recordStop(n).catch(()=>{}),uN(n),dN(),e({recorderActive:!1,recording:!1}))},toggleRecordingPause:()=>{r().recorderActive&&e(n=>({recording:!n.recording}))},toggleStepVariable:n=>{e(i=>({recorderSteps:i.recorderSteps.map(s=>s.n===n?{...s,variable:s.variable?null:s.variableSuggestion||"value"}:s)}))},bookmarks:[],bookmarksHydrated:!1,hydrateBookmarks:async()=>{if(!r().bookmarksHydrated)try{const n=await window.api.config.readJson(aN),i=n.exists&&Array.isArray(n.data)?n.data:[];e({bookmarks:i,bookmarksHydrated:!0})}catch{e({bookmarksHydrated:!0})}},toggleBookmark:n=>{const i=r().tabs.find(l=>l.id===n);if(!i||!i.url||i.url==="about:blank")return;const s=r().bookmarks,c=s.some(l=>l.url===i.url)?s.filter(l=>l.url!==i.url):[{url:i.url,title:i.title,ts:Date.now()},...s];e({bookmarks:c}),window.api.config.writeJson(aN,c).catch(()=>{})},historyEntries:[],refreshHistory:async()=>{try{const n=await window.api.config.readJson(LW),i=n.exists&&Array.isArray(n.data)?n.data:[];e({historyEntries:i})}catch{}},setZoom:(n,i)=>{const s=r().tabs.find(c=>c.id===n);if(!s)return;const a=Math.min(zW,Math.max(BW,i));e(c=>({tabs:c.tabs.map(l=>l.id===n?{...l,zoomFactor:a}:l)})),window.api.browser.setZoom({viewId:s.viewId,factor:a}).catch(()=>{})},zoomIn:n=>{const i=r().tabs.find(s=>s.id===n);i&&r().setZoom(n,i.zoomFactor+oN)},zoomOut:n=>{const i=r().tabs.find(s=>s.id===n);i&&r().setZoom(n,i.zoomFactor-oN)},zoomReset:n=>r().setZoom(n,1),findOpen:!1,findText:"",findMatches:null,openFind:n=>{const i=r().tabs.find(a=>a.id===n);if(!i)return;e({findOpen:!0,findText:"",findMatches:null}),T1(i.viewId);const s=window.api.browser.onFindResult(i.viewId,a=>{Rt.setState({findMatches:a})});Tj.set(i.viewId,s)},closeFind:n=>{const i=r().tabs.find(s=>s.id===n);e({findOpen:!1,findText:"",findMatches:null}),i&&(T1(i.viewId),window.api.browser.stopFind(i.viewId).catch(()=>{}))},setFindText:(n,i)=>{const s=r().tabs.find(a=>a.id===n);if(e({findText:i}),!!s){if(!i){window.api.browser.find({viewId:s.viewId,text:""}).catch(()=>{});return}window.api.browser.find({viewId:s.viewId,text:i,forward:!0}).catch(()=>{})}},findNext:n=>{const i=r().tabs.find(a=>a.id===n),{findText:s}=r();!i||!s||window.api.browser.find({viewId:i.viewId,text:s,forward:!0}).catch(()=>{})},findPrev:n=>{const i=r().tabs.find(a=>a.id===n),{findText:s}=r();!i||!s||window.api.browser.find({viewId:i.viewId,text:s,forward:!1}).catch(()=>{})}})),qW=4,fN=40,hN=6;function HW(e){const{onReorder:r,onActivate:n}=e,i=D.useRef(null),s=D.useRef(null),a=D.useRef(0),c=D.useRef(0),[l,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]")):[],[]),b=D.useCallback((y,x,_)=>{for(let C=0;C<x.length;C++){const T=x[C].left+x[C].width/2;if(y<T)return C<=_?C:C-1}return x.length-1},[]),w=D.useCallback(()=>{const y=s.current,x=i.current;if(!(y!=null&&y.active)||!x)return;const _=x.getBoundingClientRect(),C=y.startX+y.deltaX,T=C-_.left,E=_.right-C;T<fN?x.scrollLeft-=hN:E<fN&&(x.scrollLeft+=hN),a.current=requestAnimationFrame(w)},[]);D.useEffect(()=>{const y=i.current;if(!y)return;let x=!1;const _=()=>{x||(x=!0,c.current=requestAnimationFrame(()=>{x=!1,f(E=>E+1)}))},C=E=>{var W;const $=s.current;if(!$)return;const N=E.clientX-$.startX;if(!$.active&&Math.abs(N)<qW)return;if(!$.active){$.active=!0,$.tabRects=h().map(F=>F.getBoundingClientRect()),u(!0);try{(W=i.current)==null||W.setPointerCapture($.pointerId)}catch{}a.current=requestAnimationFrame(w)}$.deltaX=N;const P=$.tabRects[$.fromIndex],I=P.left+P.width/2+N;$.currentIndex=b(I,$.tabRects,$.fromIndex),_()},T=E=>{const $=s.current;if($&&$.pointerId===E.pointerId){cancelAnimationFrame(a.current),cancelAnimationFrame(c.current);try{y.releasePointerCapture($.pointerId)}catch{}$.active&&$.fromIndex!==$.currentIndex?r($.fromIndex,$.currentIndex):m.current($.fromIndex),s.current=null,u(!1),f(N=>N+1)}};return y.addEventListener("pointermove",C),y.addEventListener("pointerup",T),y.addEventListener("pointercancel",T),()=>{y.removeEventListener("pointermove",C),y.removeEventListener("pointerup",T),y.removeEventListener("pointercancel",T),cancelAnimationFrame(a.current),cancelAnimationFrame(c.current)}},[r,h,b,w]);const k=D.useCallback((y,x)=>{y.button!==0||y.target.closest("button")||(s.current={active:!1,fromIndex:x,currentIndex:x,startX:y.clientX,deltaX:0,tabRects:[],pointerId:y.pointerId})},[]);return{getTabDragProps:D.useCallback(y=>{var C;const x=s.current,_={};if(x!=null&&x.active)if(y===x.fromIndex)_.transform=`translateX(${x.deltaX}px) scale(1.03)`,_.zIndex=10,_.opacity=.85,_.boxShadow="0 2px 8px rgba(0,0,0,0.4)",_.position="relative",_.pointerEvents="none";else{const T=x.fromIndex,E=x.currentIndex,N=(((C=x.tabRects[T])==null?void 0:C.width)??0)+4;_.transition="transform 0.15s ease",T<E&&y>T&&y<=E?_.transform=`translateX(-${N}px)`:T>E&&y>=E&&y<T?_.transform=`translateX(${N}px)`:_.transform="translateX(0)"}return{onPointerDown:T=>k(T,y),style:_,"data-drag-index":y}},[k]),isDragging:l,containerRef:i}}const VW=3e4;function GW({onToggleSplitView:e,splitViewActive:r}={}){const n=kt(x=>x.tabs),i=kt(x=>x.activeTabId),s=kt(x=>x.closeTab),a=kt(x=>x.setActive),c=kt(x=>x.reorderTab),l=ry(x=>x.watchers),u=Rt(x=>x.tabs.length>0),f=i!=null&&u,[m,h]=D.useState(()=>Date.now());D.useEffect(()=>{const x=window.setInterval(()=>h(Date.now()),1e3);return()=>window.clearInterval(x)},[]);const b=x=>{for(const _ of Object.values(l))if(_.tabId===x&&_.lastLineAt&&m-_.lastLineAt<VW)return!0;return!1},{getTabDragProps:w,isDragging:k,containerRef:S}=HW({tabCount:n.length,onReorder:c,onActivate:x=>{const _=n[x];_&&a(_.id)}}),y=["#6f7d52","#b85c34","#a39079","#7a8466","#5b4a36"];return o.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:[o.jsx("div",{ref:S,className:`flex items-end gap-0.5 overflow-x-auto min-w-0 flex-1 select-none ${k?"cursor-grabbing":""}`,children:n.map((x,_)=>{const C=x.id===i,T=w(_),E=y[_%y.length];return o.jsxs("div",{...T,style:T.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 ${k?"":"cursor-grab"} ${C?"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":C?"true":void 0,children:[o.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:E,boxShadow:"inset 0 0 0 0.5px rgba(0,0,0,0.15)",opacity:x.status==="spawning"?.55:1}}),o.jsx("span",{className:"truncate max-w-[200px]",children:x.label}),x.status==="spawning"&&o.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-butter animate-pulse",title:"spawning"}),b(x.id)&&o.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"}),o.jsx("button",{onClick:$=>{$.stopPropagation(),s(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)})}),o.jsxs("div",{className:"flex items-center gap-2 pb-2 pl-3 text-[12px] text-fg-faint shrink-0",children:[f&&e&&o.jsxs("button",{onClick:e,className:`flex items-center gap-1 px-2 py-0.5 rounded text-[11px] border border-line hover:bg-bg-hi/40 ${r?"text-accent border-accent":"text-fg-faint hover:text-fg"}`,title:"Split view: agent terminal + browser","aria-pressed":r??!1,children:[o.jsx("span",{"aria-hidden":"true",children:"⇄"}),o.jsx("span",{children:"Split view"})]}),o.jsx("span",{className:"font-semibold text-fg-dim",children:"Claude Session Manager"}),o.jsxs("span",{className:"font-mono text-[11px] text-fg-faint",children:["v","0.35.18"]})]})]})}function KW(e,r,n){return r?e.map(i=>i.id===r?{...i,lastActivityAt:n}:i):e}function XW(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 _w=jn((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]:XW(n,i,s)}});const c=window.api.transcripts.onEvent(n,l=>r().ingest(n,l));e({unsubs:{...r().unsubs,[n]:c}}),window.api.transcripts.subscribe({tabId:n,cwd:i,sessionUuid:s}).then(async l=>{const u=r().tabs[n];if(!u)return;if(!l.ok){const{toast:m}=await ab(async()=>{const{toast:h}=await Promise.resolve().then(()=>N4);return{toast:h}},void 0,import.meta.url);m.error(`Live view unavailable: ${l.error??"subscribe failed"}`),e({tabs:{...r().tabs,[n]:{...u,path:null}}});return}e({tabs:{...r().tabs,[n]:{...u,path:l.path}}});const f=await window.api.transcripts.buffer(n);for(const m of f)r().ingest(n,m,{replay:!0})}).catch(l=>console.error("[live] transcripts.subscribe failed:",n,l))},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 c={...r().tabs};delete c[n],window.api.transcripts.unsubscribe(n),e({refs:i,unsubs:a,tabs:c})},ingest:(n,i,s)=>{const a=r().tabs[n];if(!a)return;const c=Date.now(),l={...a,lastEventAt:s!=null&&s.replay?a.lastEventAt:c},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:[];l.todos=m,s!=null&&s.replay||u.push({id:0,kind:"todo-update",at:c,label:`Todos · ${m.length} item${m.length!==1?"s":""}`});break}case"tool_use":{const m=i.data,h=m.input,b={};for(const w of["command","file_path","pattern","url","query","subagent_type","description"])h&&w in h&&(b[w]=h[w]);if(l.lastToolUses=[{id:m.id,name:m.name,input:b,at:c},...a.lastToolUses].slice(0,50),!(s!=null&&s.replay)){const w=m.input,k=["Edit","Write","NotebookEdit"].includes(m.name),S=typeof(w==null?void 0:w.file_path)=="string"?w.file_path:void 0,y=typeof(w==null?void 0:w.command)=="string"?w.command:void 0,x=S?S.split("/").pop()??S:y?f(y,28):"";u.push({id:0,kind:"tool-use",at:c,label:x?`${m.name} · ${x}`:m.name,target:S??y,toolName:m.name}),k&&S&&u.push({id:0,kind:"file-edit",at:c,label:`${m.name} · ${f(S.split("/").pop()??S,34)}`,target:S,toolName:m.name})}break}case"plan":{const m=i.data,h=typeof m=="string"?m:(m==null?void 0:m.plan)??JSON.stringify(m);l.plans=[{at:c,content:h??""},...a.plans].slice(0,50),s!=null&&s.replay||u.push({id:0,kind:"plan-revision",at:c,label:"Plan revised"});break}case"agent_spawn":{const m=i.data;l.agents=[{id:m==null?void 0:m.toolUseId,at:c,subagentType:m==null?void 0:m.subagent_type,description:m==null?void 0:m.description,lastActivityAt:c},...a.agents].slice(0,50),s!=null&&s.replay||u.push({id:0,kind:"agent-spawn",at:c,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),b=m.input_tokens??m.inputTokens??0,w=m.output_tokens??m.outputTokens??0,k=h+b+w;l.usage={inputTokens:(a.usage.inputTokens||0)+b,outputTokens:(a.usage.outputTokens||0)+w,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(k/1e3)>Math.floor(h/1e3)&&u.push({id:0,kind:"usage-tick",at:c,label:`${Math.floor(k/1e3)}k tokens`});break}case"tool_result":{const m=i.data;l.agents=KW(a.agents,m==null?void 0:m.toolUseId,c);break}}if(u.length>0){let m=a.activitySeq;const h=u.map(b=>({...b,id:++m}));l.activitySeq=m,l.activityRing=[...a.activityRing,...h].slice(-32)}e({tabs:{...r().tabs,[n]:l}})}}));function O4(e){const r=_w(s=>s.subscribe),n=_w(s=>s.unsubscribe),i=_w(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 A1={},iv={},pN;function P4(){if(pN)return iv;pN=1,Object.defineProperty(iv,"__esModule",{value:!0}),iv.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(/\/[^/]+$/,"/")),iv.baseAssetPath=n,iv}var sv={},mN;function XT(){if(mN)return sv;mN=1,Object.defineProperty(sv,"__esModule",{value:!0}),sv.defaultModelFetcher=void 0;const e=r=>fetch(r).then(n=>n.arrayBuffer());return sv.defaultModelFetcher=e,sv}var ec={},av={},gN;function ob(){if(gN)return av;gN=1,Object.defineProperty(av,"__esModule",{value:!0}),av.log=void 0;const e=r=>n=>{console.log(`VAD | ${r} >`,n)};return av.log={error:e("error"),debug:e("debug"),warn:e("warn")},av}var ov={},vN;function g_(){if(vN)return ov;vN=1,Object.defineProperty(ov,"__esModule",{value:!0}),ov.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||(ov.Message=e={})),ov}var yN;function YT(){if(yN)return ec;yN=1,Object.defineProperty(ec,"__esModule",{value:!0}),ec.FrameProcessor=ec.validateOptions=ec.defaultFrameProcessorOptions=void 0;const e=ob(),r=g_();ec.defaultFrameProcessorOptions={positiveSpeechThreshold:.3,negativeSpeechThreshold:.25,preSpeechPadMs:800,redemptionMs:1400,minSpeechMs:400,submitUserSpeechOnPause:!1};function n(c){(c.positiveSpeechThreshold<0||c.positiveSpeechThreshold>1)&&e.log.error("positiveSpeechThreshold should be a number between 0 and 1"),(c.negativeSpeechThreshold<0||c.negativeSpeechThreshold>c.positiveSpeechThreshold)&&e.log.error("negativeSpeechThreshold should be between 0 and positiveSpeechThreshold"),c.preSpeechPadMs<0&&e.log.error("preSpeechPadMs should be positive"),c.redemptionMs<0&&e.log.error("redemptionMs should be positive"),c.minSpeechMs<0&&e.log.error("minSpeechMs should be positive")}ec.validateOptions=n;const i=c=>{const l=c.reduce((f,m)=>(f.push(f.at(-1)+m.length),f),[0]),u=new Float32Array(l.at(-1));return c.forEach((f,m)=>{const h=l[m];u.set(f,h)}),u};function s(c,l){const u=Math.floor(c.redemptionMs/l),f=Math.floor(c.preSpeechPadMs/l),m=Math.floor(c.minSpeechMs/l);return{redemptionFrames:u,preSpeechPadFrames:f,minSpeechFrames:m}}class a{constructor(l,u,f,m){this.modelProcessFunc=l,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=k=>{this.options={...this.options,...k};const{redemptionFrames:S,preSpeechPadFrames:y,minSpeechFrames:x}=s(this.options,this.msPerFrame);this.redemptionFrames=S,this.preSpeechPadFrames=y,this.minSpeechFrames=x},this.reset=()=>{this.speaking=!1,this.speechRealStartFired=!1,this.audioBuffer=[],this.modelResetFunc(),this.redemptionCounter=0,this.speechFrameCount=0},this.pause=k=>{this.active=!1,this.options.submitUserSpeechOnPause?this.endSegment(k):this.reset()},this.resume=()=>{this.active=!0},this.endSegment=k=>{const S=this.audioBuffer;this.audioBuffer=[];const y=this.speaking;if(this.reset(),y)if(S.reduce((_,C)=>C.isSpeech?_+1:_,0)>=this.minSpeechFrames){const _=i(S.map(C=>C.frame));k({msg:r.Message.SpeechEnd,audio:_})}else k({msg:r.Message.VADMisfire});return{}},this.process=async(k,S)=>{if(!this.active)return;const y=await this.modelProcessFunc(k),x=y.isSpeech>=this.options.positiveSpeechThreshold;if(S({probs:y,msg:r.Message.FrameProcessed,frame:k}),this.audioBuffer.push({frame:k,isSpeech:x}),x&&(this.speechFrameCount++,this.redemptionCounter=0),x&&!this.speaking&&(this.speaking=!0,S({msg:r.Message.SpeechStart})),this.speaking&&this.speechFrameCount===this.minSpeechFrames&&!this.speechRealStartFired&&(this.speechRealStartFired=!0,S({msg:r.Message.SpeechRealStart})),y.isSpeech<this.options.negativeSpeechThreshold&&this.speaking&&++this.redemptionCounter>=this.redemptionFrames){this.redemptionCounter=0,this.speechFrameCount=0,this.speaking=!1,this.speechRealStartFired=!1;const _=this.audioBuffer;if(this.audioBuffer=[],_.reduce((T,E)=>E.isSpeech?T+1:T,0)>=this.minSpeechFrames){const T=i(_.map(E=>E.frame));S({msg:r.Message.SpeechEnd,audio:T})}else S({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:b,minSpeechFrames:w}=s(this.options,this.msPerFrame);this.redemptionFrames=h,this.preSpeechPadFrames=b,this.minSpeechFrames=w,this.reset()}}return ec.FrameProcessor=a,ec}var tc={};function Va(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 $1={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}`,H=j.createShaderModule({code:B,label:d.name});cr("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 EN;function rq(){return EN||(EN=1,(function(e,r){var n=(()=>{var i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,l=(ie=>typeof Va<"u"?Va:typeof Proxy<"u"?new Proxy(ie,{get:(me,_e)=>(typeof Va<"u"?Va:me)[_e]}):ie)(function(ie){if(typeof Va<"u")return Va.apply(this,arguments);throw Error('Dynamic require of "'+ie+'" is not supported')}),u=(ie,me)=>()=>(ie&&(me=ie(ie=0)),me),f=(ie,me)=>{for(var _e in me)i(ie,_e,{get:me[_e],enumerable:!0})},m=(ie,me,_e,Pe)=>{if(me&&typeof me=="object"||typeof me=="function")for(let je of a(me))!c.call(ie,je)&&je!==_e&&i(ie,je,{get:()=>me[je],enumerable:!(Pe=s(me,je))||Pe.enumerable});return ie},h=ie=>m(i({},"__esModule",{value:!0}),ie),b,w,k,S,y,x=u(()=>{b=new Map,w=[],k=(ie,me,_e)=>{if(me&&typeof me.init=="function"&&typeof me.createInferenceSessionHandler=="function"){let Pe=b.get(ie);if(Pe===void 0)b.set(ie,{backend:me,priority:_e});else{if(Pe.priority>_e)return;if(Pe.priority===_e&&Pe.backend!==me)throw new Error(`cannot register backend "${ie}" using priority ${_e}`)}if(_e>=0){let je=w.indexOf(ie);je!==-1&&w.splice(je,1);for(let qe=0;qe<w.length;qe++)if(b.get(w[qe]).priority<=_e){w.splice(qe,0,ie);return}w.push(ie)}return}throw new TypeError("not a valid backend")},S=async ie=>{let me=b.get(ie);if(!me)return"backend not found.";if(me.initialized)return me.backend;if(me.aborted)return me.error;{let _e=!!me.initPromise;try{return _e||(me.initPromise=me.backend.init(ie)),await me.initPromise,me.initialized=!0,me.backend}catch(Pe){return _e||(me.error=`${Pe}`,me.aborted=!0),me.error}finally{delete me.initPromise}}},y=async ie=>{let me=ie.executionProviders||[],_e=me.map(Ve=>typeof Ve=="string"?Ve:Ve.name),Pe=_e.length===0?w:_e,je,qe=[],Ie=new Set;for(let Ve of Pe){let it=await S(Ve);typeof it=="string"?qe.push({name:Ve,err:it}):(je||(je=it),je===it&&Ie.add(Ve))}if(!je)throw new Error(`no available backend found. ERR: ${qe.map(Ve=>`[${Ve.name}] ${Ve.err}`).join(", ")}`);for(let{name:Ve,err:it}of qe)_e.includes(Ve)&&console.warn(`removing requested execution provider "${Ve}" from session options because it is not available: ${it}`);let De=me.filter(Ve=>Ie.has(typeof Ve=="string"?Ve:Ve.name));return[je,new Proxy(ie,{get:(Ve,it)=>it==="executionProviders"?De:Reflect.get(Ve,it)})]}}),_=u(()=>{x()}),C,T=u(()=>{C="1.26.0"}),E,$,N=u(()=>{T(),E="warning",$={wasm:{},webgl:{},webgpu:{},versions:{common:C},set logLevel(ie){if(ie!==void 0){if(typeof ie!="string"||["verbose","info","warning","error","fatal"].indexOf(ie)===-1)throw new Error(`Unsupported logging level: ${ie}`);E=ie}},get logLevel(){return E}},Object.defineProperty($,"logLevel",{enumerable:!0})}),P,I=u(()=>{N(),P=$}),W,F,U=u(()=>{W=(ie,me)=>{let _e=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);_e.width=ie.dims[3],_e.height=ie.dims[2];let Pe=_e.getContext("2d");if(Pe!=null){let je,qe;(me==null?void 0:me.tensorLayout)!==void 0&&me.tensorLayout==="NHWC"?(je=ie.dims[2],qe=ie.dims[3]):(je=ie.dims[3],qe=ie.dims[2]);let Ie=(me==null?void 0:me.format)!==void 0?me.format:"RGB",De=me==null?void 0:me.norm,Ve,it;De===void 0||De.mean===void 0?Ve=[255,255,255,255]:typeof De.mean=="number"?Ve=[De.mean,De.mean,De.mean,De.mean]:(Ve=[De.mean[0],De.mean[1],De.mean[2],0],De.mean[3]!==void 0&&(Ve[3]=De.mean[3])),De===void 0||De.bias===void 0?it=[0,0,0,0]:typeof De.bias=="number"?it=[De.bias,De.bias,De.bias,De.bias]:(it=[De.bias[0],De.bias[1],De.bias[2],0],De.bias[3]!==void 0&&(it[3]=De.bias[3]));let ut=qe*je,st=0,et=ut,Ot=ut*2,We=-1;Ie==="RGBA"?(st=0,et=ut,Ot=ut*2,We=ut*3):Ie==="RGB"?(st=0,et=ut,Ot=ut*2):Ie==="RBG"&&(st=0,Ot=ut,et=ut*2);for(let pt=0;pt<qe;pt++)for(let Rr=0;Rr<je;Rr++){let tr=(ie.data[st++]-it[0])*Ve[0],rr=(ie.data[et++]-it[1])*Ve[1],Mr=(ie.data[Ot++]-it[2])*Ve[2],zt=We===-1?255:(ie.data[We++]-it[3])*Ve[3];Pe.fillStyle="rgba("+tr+","+rr+","+Mr+","+zt+")",Pe.fillRect(Rr,pt,1,1)}if("toDataURL"in _e)return _e.toDataURL();throw new Error("toDataURL is not supported")}else throw new Error("Can not access image data")},F=(ie,me)=>{let _e=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),Pe;if(_e!=null){let je,qe,Ie;(me==null?void 0:me.tensorLayout)!==void 0&&me.tensorLayout==="NHWC"?(je=ie.dims[2],qe=ie.dims[1],Ie=ie.dims[3]):(je=ie.dims[3],qe=ie.dims[2],Ie=ie.dims[1]);let De=me!==void 0&&me.format!==void 0?me.format:"RGB",Ve=me==null?void 0:me.norm,it,ut;Ve===void 0||Ve.mean===void 0?it=[255,255,255,255]:typeof Ve.mean=="number"?it=[Ve.mean,Ve.mean,Ve.mean,Ve.mean]:(it=[Ve.mean[0],Ve.mean[1],Ve.mean[2],255],Ve.mean[3]!==void 0&&(it[3]=Ve.mean[3])),Ve===void 0||Ve.bias===void 0?ut=[0,0,0,0]:typeof Ve.bias=="number"?ut=[Ve.bias,Ve.bias,Ve.bias,Ve.bias]:(ut=[Ve.bias[0],Ve.bias[1],Ve.bias[2],0],Ve.bias[3]!==void 0&&(ut[3]=Ve.bias[3]));let st=qe*je;if(me!==void 0&&(me.format!==void 0&&Ie===4&&me.format!=="RGBA"||Ie===3&&me.format!=="RGB"&&me.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let et=4,Ot=0,We=1,pt=2,Rr=3,tr=0,rr=st,Mr=st*2,zt=-1;De==="RGBA"?(tr=0,rr=st,Mr=st*2,zt=st*3):De==="RGB"?(tr=0,rr=st,Mr=st*2):De==="RBG"&&(tr=0,Mr=st,rr=st*2),Pe=_e.createImageData(je,qe);for(let Ur=0;Ur<qe*je;Ot+=et,We+=et,pt+=et,Rr+=et,Ur++)Pe.data[Ot]=(ie.data[tr++]-ut[0])*it[0],Pe.data[We]=(ie.data[rr++]-ut[1])*it[1],Pe.data[pt]=(ie.data[Mr++]-ut[2])*it[2],Pe.data[Rr]=zt===-1?255:(ie.data[zt++]-ut[3])*it[3]}else throw new Error("Can not access image data");return Pe}}),q,z,Y,ee,se,ue,X=u(()=>{ce(),q=(ie,me)=>{if(ie===void 0)throw new Error("Image buffer must be defined");if(me.height===void 0||me.width===void 0)throw new Error("Image height and width must be defined");if(me.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");let{height:_e,width:Pe}=me,je=me.norm??{mean:255,bias:0},qe,Ie;typeof je.mean=="number"?qe=[je.mean,je.mean,je.mean,je.mean]:qe=[je.mean[0],je.mean[1],je.mean[2],je.mean[3]??255],typeof je.bias=="number"?Ie=[je.bias,je.bias,je.bias,je.bias]:Ie=[je.bias[0],je.bias[1],je.bias[2],je.bias[3]??0];let De=me.format!==void 0?me.format:"RGBA",Ve=me.tensorFormat!==void 0&&me.tensorFormat!==void 0?me.tensorFormat:"RGB",it=_e*Pe,ut=Ve==="RGBA"?new Float32Array(it*4):new Float32Array(it*3),st=4,et=0,Ot=1,We=2,pt=3,Rr=0,tr=it,rr=it*2,Mr=-1;De==="RGB"&&(st=3,et=0,Ot=1,We=2,pt=-1),Ve==="RGBA"?Mr=it*3:Ve==="RBG"?(Rr=0,rr=it,tr=it*2):Ve==="BGR"&&(rr=0,tr=it,Rr=it*2);for(let zt=0;zt<it;zt++,et+=st,We+=st,Ot+=st,pt+=st)ut[Rr++]=(ie[et]+Ie[0])/qe[0],ut[tr++]=(ie[Ot]+Ie[1])/qe[1],ut[rr++]=(ie[We]+Ie[2])/qe[2],Mr!==-1&&pt!==-1&&(ut[Mr++]=(ie[pt]+Ie[3])/qe[3]);return Ve==="RGBA"?new ne("float32",ut,[1,4,_e,Pe]):new ne("float32",ut,[1,3,_e,Pe])},z=async(ie,me)=>{let _e=typeof HTMLImageElement<"u"&&ie instanceof HTMLImageElement,Pe=typeof ImageData<"u"&&ie instanceof ImageData,je=typeof ImageBitmap<"u"&&ie instanceof ImageBitmap,qe=typeof ie=="string",Ie,De=me??{},Ve=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},it=ut=>typeof HTMLCanvasElement<"u"&&ut instanceof HTMLCanvasElement||ut instanceof OffscreenCanvas?ut.getContext("2d"):null;if(_e){let ut=Ve();ut.width=ie.width,ut.height=ie.height;let st=it(ut);if(st!=null){let et=ie.height,Ot=ie.width;if(me!==void 0&&me.resizedHeight!==void 0&&me.resizedWidth!==void 0&&(et=me.resizedHeight,Ot=me.resizedWidth),me!==void 0){if(De=me,me.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");De.tensorFormat="RGBA",De.height=et,De.width=Ot}else De.tensorFormat="RGBA",De.height=et,De.width=Ot;st.drawImage(ie,0,0),Ie=st.getImageData(0,0,Ot,et).data}else throw new Error("Can not access image data")}else if(Pe){let ut,st;if(me!==void 0&&me.resizedWidth!==void 0&&me.resizedHeight!==void 0?(ut=me.resizedHeight,st=me.resizedWidth):(ut=ie.height,st=ie.width),me!==void 0&&(De=me),De.format="RGBA",De.height=ut,De.width=st,me!==void 0){let et=Ve();et.width=st,et.height=ut;let Ot=it(et);if(Ot!=null)Ot.putImageData(ie,0,0),Ie=Ot.getImageData(0,0,st,ut).data;else throw new Error("Can not access image data")}else Ie=ie.data}else if(je){if(me===void 0)throw new Error("Please provide image config with format for Imagebitmap");let ut=Ve();ut.width=ie.width,ut.height=ie.height;let st=it(ut);if(st!=null){let et=ie.height,Ot=ie.width;return st.drawImage(ie,0,0,Ot,et),Ie=st.getImageData(0,0,Ot,et).data,De.height=et,De.width=Ot,q(Ie,De)}else throw new Error("Can not access image data")}else{if(qe)return new Promise((ut,st)=>{let et=Ve(),Ot=it(et);if(!ie||!Ot)return st();let We=new Image;We.crossOrigin="Anonymous",We.src=ie,We.onload=()=>{et.width=We.width,et.height=We.height,Ot.drawImage(We,0,0,et.width,et.height);let pt=Ot.getImageData(0,0,et.width,et.height);De.height=et.height,De.width=et.width,ut(q(pt.data,De))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(Ie!==void 0)return q(Ie,De);throw new Error("Input data provided is not supported - aborted tensor creation")},Y=(ie,me)=>{let{width:_e,height:Pe,download:je,dispose:qe}=me,Ie=[1,Pe,_e,4];return new ne({location:"texture",type:"float32",texture:ie,dims:Ie,download:je,dispose:qe})},ee=(ie,me)=>{let{dataType:_e,dims:Pe,download:je,dispose:qe}=me;return new ne({location:"gpu-buffer",type:_e??"float32",gpuBuffer:ie,dims:Pe,download:je,dispose:qe})},se=(ie,me)=>{let{dataType:_e,dims:Pe,download:je,dispose:qe}=me;return new ne({location:"ml-tensor",type:_e??"float32",mlTensor:ie,dims:Pe,download:je,dispose:qe})},ue=(ie,me,_e)=>new ne({location:"cpu-pinned",type:ie,data:me,dims:_e??[me.length]})}),Q,Z,ae,oe,de=u(()=>{Q=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"]]),ae=!1,oe=()=>{if(!ae){ae=!0;let ie=typeof BigInt64Array<"u"&&BigInt64Array.from,me=typeof BigUint64Array<"u"&&BigUint64Array.from,_e=globalThis.Float16Array,Pe=typeof _e<"u"&&_e.from;ie&&(Q.set("int64",BigInt64Array),Z.set(BigInt64Array,"int64")),me&&(Q.set("uint64",BigUint64Array),Z.set(BigUint64Array,"uint64")),Pe?(Q.set("float16",_e),Z.set(_e,"float16")):Q.set("float16",Uint16Array)}}}),ve,$e,we=u(()=>{ce(),ve=ie=>{let me=1;for(let _e=0;_e<ie.length;_e++){let Pe=ie[_e];if(typeof Pe!="number"||!Number.isSafeInteger(Pe))throw new TypeError(`dims[${_e}] must be an integer, got: ${Pe}`);if(Pe<0)throw new RangeError(`dims[${_e}] must be a non-negative integer, got: ${Pe}`);me*=Pe}return me},$e=(ie,me)=>{switch(ie.location){case"cpu":return new ne(ie.type,ie.data,me);case"cpu-pinned":return new ne({location:"cpu-pinned",data:ie.data,type:ie.type,dims:me});case"texture":return new ne({location:"texture",texture:ie.texture,type:ie.type,dims:me});case"gpu-buffer":return new ne({location:"gpu-buffer",gpuBuffer:ie.gpuBuffer,type:ie.type,dims:me});case"ml-tensor":return new ne({location:"ml-tensor",mlTensor:ie.mlTensor,type:ie.type,dims:me});default:throw new Error(`tensorReshape: tensor location ${ie.location} is not supported`)}}}),ne,ce=u(()=>{U(),X(),de(),we(),ne=class{constructor(ie,me,_e){oe();let Pe,je;if(typeof ie=="object"&&"location"in ie)switch(this.dataLocation=ie.location,Pe=ie.type,je=ie.dims,ie.location){case"cpu-pinned":{let Ie=Q.get(Pe);if(!Ie)throw new TypeError(`unsupported type "${Pe}" to create tensor from pinned buffer`);if(!(ie.data instanceof Ie))throw new TypeError(`buffer should be of type ${Ie.name}`);this.cpuData=ie.data;break}case"texture":{if(Pe!=="float32")throw new TypeError(`unsupported type "${Pe}" to create tensor from texture`);this.gpuTextureData=ie.texture,this.downloader=ie.download,this.disposer=ie.dispose;break}case"gpu-buffer":{if(Pe!=="float32"&&Pe!=="float16"&&Pe!=="int32"&&Pe!=="int64"&&Pe!=="uint32"&&Pe!=="uint8"&&Pe!=="bool"&&Pe!=="uint4"&&Pe!=="int4")throw new TypeError(`unsupported type "${Pe}" to create tensor from gpu buffer`);this.gpuBufferData=ie.gpuBuffer,this.downloader=ie.download,this.disposer=ie.dispose;break}case"ml-tensor":{if(Pe!=="float32"&&Pe!=="float16"&&Pe!=="int32"&&Pe!=="int64"&&Pe!=="uint32"&&Pe!=="uint64"&&Pe!=="int8"&&Pe!=="uint8"&&Pe!=="bool"&&Pe!=="uint4"&&Pe!=="int4")throw new TypeError(`unsupported type "${Pe}" to create tensor from MLTensor`);this.mlTensorData=ie.mlTensor,this.downloader=ie.download,this.disposer=ie.dispose;break}default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let Ie,De;if(typeof ie=="string")if(Pe=ie,De=_e,ie==="string"){if(!Array.isArray(me))throw new TypeError("A string tensor's data must be a string array.");Ie=me}else{let Ve=Q.get(ie);if(Ve===void 0)throw new TypeError(`Unsupported tensor type: ${ie}.`);if(Array.isArray(me)){if(ie==="float16"&&Ve===Uint16Array||ie==="uint4"||ie==="int4")throw new TypeError(`Creating a ${ie} tensor from number array is not supported. Please use ${Ve.name} as data.`);ie==="uint64"||ie==="int64"?Ie=Ve.from(me,BigInt):Ie=Ve.from(me)}else if(me instanceof Ve)Ie=me;else if(me instanceof Uint8ClampedArray)if(ie==="uint8")Ie=Uint8Array.from(me);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else if(ie==="float16"&&me instanceof Uint16Array&&Ve!==Uint16Array)Ie=new globalThis.Float16Array(me.buffer,me.byteOffset,me.length);else throw new TypeError(`A ${Pe} tensor's data must be type of ${Ve}`)}else if(De=me,Array.isArray(ie)){if(ie.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let Ve=typeof ie[0];if(Ve==="string")Pe="string",Ie=ie;else if(Ve==="boolean")Pe="bool",Ie=Uint8Array.from(ie);else throw new TypeError(`Invalid element type of data array: ${Ve}.`)}else if(ie instanceof Uint8ClampedArray)Pe="uint8",Ie=Uint8Array.from(ie);else{let Ve=Z.get(ie.constructor);if(Ve===void 0)throw new TypeError(`Unsupported type for tensor data: ${ie.constructor}.`);Pe=Ve,Ie=ie}if(De===void 0)De=[Ie.length];else if(!Array.isArray(De))throw new TypeError("A tensor's dims must be a number array");je=De,this.cpuData=Ie,this.dataLocation="cpu"}let qe=ve(je);if(this.cpuData&&qe!==this.cpuData.length&&!((Pe==="uint4"||Pe==="int4")&&Math.ceil(qe/2)===this.cpuData.length))throw new Error(`Tensor's size(${qe}) does not match data length(${this.cpuData.length}).`);this.type=Pe,this.dims=je,this.size=qe}static async fromImage(ie,me){return z(ie,me)}static fromTexture(ie,me){return Y(ie,me)}static fromGpuBuffer(ie,me){return ee(ie,me)}static fromMLTensor(ie,me){return se(ie,me)}static fromPinnedBuffer(ie,me,_e){return ue(ie,me,_e)}toDataURL(ie){return W(this,ie)}toImageData(ie){return F(this,ie)}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(ie){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 me=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=me,ie&&this.disposer&&(this.disposer(),this.disposer=void 0),me}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(ie){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return $e(this,ie)}}}),ge,Ae=u(()=>{ce(),ge=ne}),Te,nt,ct,Le,Me,Ue,mt=u(()=>{N(),Te=(ie,me)=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||console.timeStamp(`${ie}::ORT::${me}`)},nt=(ie,me)=>{var je;let _e=((je=new Error().stack)==null?void 0:je.split(/\r\n|\r|\n/g))||[],Pe=!1;for(let qe=0;qe<_e.length;qe++){if(Pe&&!_e[qe].includes("TRACE_FUNC")){let Ie=`FUNC_${ie}::${_e[qe].trim().split(" ")[1]}`;me&&(Ie+=`::${me}`),Te("CPU",Ie);return}_e[qe].includes("TRACE_FUNC")&&(Pe=!0)}},ct=ie=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||nt("BEGIN",ie)},Le=ie=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||nt("END",ie)},Me=ie=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||console.time(`ORT::${ie}`)},Ue=ie=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||console.timeEnd(`ORT::${ie}`)}}),jt,er=u(()=>{x(),Ae(),mt(),jt=class L4{constructor(me){this.handler=me}async run(me,_e,Pe){ct(),Me("InferenceSession.run");let je={},qe={};if(typeof me!="object"||me===null||me instanceof ge||Array.isArray(me))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let Ie=!0;if(typeof _e=="object"){if(_e===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(_e instanceof ge)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(_e)){if(_e.length===0)throw new TypeError("'fetches' cannot be an empty array.");Ie=!1;for(let it of _e){if(typeof it!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(it)===-1)throw new RangeError(`'fetches' contains invalid output name: ${it}.`);je[it]=null}if(typeof Pe=="object"&&Pe!==null)qe=Pe;else if(typeof Pe<"u")throw new TypeError("'options' must be an object.")}else{let it=!1,ut=Object.getOwnPropertyNames(_e);for(let st of this.outputNames)if(ut.indexOf(st)!==-1){let et=_e[st];(et===null||et instanceof ge)&&(it=!0,Ie=!1,je[st]=et)}if(it){if(typeof Pe=="object"&&Pe!==null)qe=Pe;else if(typeof Pe<"u")throw new TypeError("'options' must be an object.")}else qe=_e}}else if(typeof _e<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let it of this.inputNames)if(typeof me[it]>"u")throw new Error(`input '${it}' is missing in 'feeds'.`);if(Ie)for(let it of this.outputNames)je[it]=null;let De=await this.handler.run(me,je,qe),Ve={};for(let it in De)if(Object.hasOwnProperty.call(De,it)){let ut=De[it];ut instanceof ge?Ve[it]=ut:Ve[it]=new ge(ut.type,ut.data,ut.dims)}return Ue("InferenceSession.run"),Le(),Ve}async release(){return this.handler.dispose()}static async create(me,_e,Pe,je){ct(),Me("InferenceSession.create");let qe,Ie={};if(typeof me=="string"){if(qe=me,typeof _e=="object"&&_e!==null)Ie=_e;else if(typeof _e<"u")throw new TypeError("'options' must be an object.")}else if(me instanceof Uint8Array){if(qe=me,typeof _e=="object"&&_e!==null)Ie=_e;else if(typeof _e<"u")throw new TypeError("'options' must be an object.")}else if(me instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&me instanceof SharedArrayBuffer){let ut=me,st=0,et=me.byteLength;if(typeof _e=="object"&&_e!==null)Ie=_e;else if(typeof _e=="number"){if(st=_e,!Number.isSafeInteger(st))throw new RangeError("'byteOffset' must be an integer.");if(st<0||st>=ut.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${ut.byteLength}).`);if(et=me.byteLength-st,typeof Pe=="number"){if(et=Pe,!Number.isSafeInteger(et))throw new RangeError("'byteLength' must be an integer.");if(et<=0||st+et>ut.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${ut.byteLength-st}].`);if(typeof je=="object"&&je!==null)Ie=je;else if(typeof je<"u")throw new TypeError("'options' must be an object.")}else if(typeof Pe<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof _e<"u")throw new TypeError("'options' must be an object.");qe=new Uint8Array(ut,st,et)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[De,Ve]=await y(Ie),it=await De.createInferenceSessionHandler(qe,Ve);return Ue("InferenceSession.create"),Le(),new L4(it)}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}}}),Yt,mr=u(()=>{er(),Yt=jt}),ur=u(()=>{}),Qr=u(()=>{}),Pr=u(()=>{}),di=u(()=>{}),Yn={};f(Yn,{InferenceSession:()=>Yt,TRACE:()=>Te,TRACE_EVENT_BEGIN:()=>Me,TRACE_EVENT_END:()=>Ue,TRACE_FUNC_BEGIN:()=>ct,TRACE_FUNC_END:()=>Le,Tensor:()=>ge,env:()=>P,registerBackend:()=>k});var lt=u(()=>{_(),I(),mr(),Ae(),ur(),Qr(),mt(),Pr(),di()}),Ct=u(()=>{}),Pt={};f(Pt,{default:()=>Jn});var fr,ar,Jn,Tl=u(()=>{var ie;Se(),pi(),hi(),fr="ort-wasm-proxy-worker",ar=((ie=globalThis.self)==null?void 0:ie.name)===fr,ar&&(self.onmessage=me=>{let{type:_e,in:Pe}=me.data;try{switch(_e){case"init-wasm":Os(Pe.wasm).then(()=>{qo(Pe).then(()=>{postMessage({type:_e})},je=>{postMessage({type:_e,err:je})})},je=>{postMessage({type:_e,err:je})});break;case"init-ep":{let{epName:je,env:qe}=Pe;na(qe,je).then(()=>{postMessage({type:_e})},Ie=>{postMessage({type:_e,err:Ie})});break}case"copy-from":{let{buffer:je}=Pe,qe=cr(je);postMessage({type:_e,out:qe});break}case"create":{let{model:je,options:qe}=Pe;Li(je,qe).then(Ie=>{postMessage({type:_e,out:Ie})},Ie=>{postMessage({type:_e,err:Ie})});break}case"release":Ea(Pe),postMessage({type:_e});break;case"run":{let{sessionId:je,inputIndices:qe,inputs:Ie,outputIndices:De,options:Ve}=Pe;Qe(je,qe,Ie,De,new Array(De.length).fill(null),Ve).then(it=>{it.some(ut=>ut[3]!=="cpu")?postMessage({type:_e,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:_e,out:it},yt([...Ie,...it]))},it=>{postMessage({type:_e,err:it})});break}case"end-profiling":gi(Pe),postMessage({type:_e});break;default:}}catch(je){postMessage({type:_e,err:je})}}),Jn=ar?null:me=>new Worker(me??kr,{type:"classic",name:fr})}),Uo,Js,kr,fi,mn,Zs,us,Ri,ka,Qs,ea,ds,Zn,hi=u(()=>{Ct(),Uo=typeof location>"u"?void 0:location.origin,Js=()=>{var ie,me;return typeof document<"u"?(ie=document.currentScript)==null?void 0:ie.src:typeof self<"u"?(me=self.location)==null?void 0:me.href:void 0},kr=Js(),fi=()=>{if(kr&&!kr.startsWith("blob:"))return kr.substring(0,kr.lastIndexOf("/")+1)},mn=(ie,me)=>{try{let _e=me??kr;return(_e?new URL(ie,_e):new URL(ie)).origin===Uo}catch{return!1}},Zs=(ie,me)=>{let _e=me??kr;try{return(_e?new URL(ie,_e):new URL(ie)).href}catch{return}},us=(ie,me)=>`${me??"./"}${ie}`,Ri=async ie=>{let me=await(await fetch(ie,{credentials:"same-origin"})).blob();return URL.createObjectURL(me)},ka=async ie=>(await import(ie)).default,Qs=(Tl(),h(Pt)).default,ea=async()=>{if(!kr)throw new Error("Failed to load proxy worker: cannot determine the script source URL.");if(mn(kr))return[void 0,Qs()];let ie=await Ri(kr);return[ie,Qs(ie)]},ds=void 0,Zn=async(ie,me,_e,Pe)=>{let je=ds&&!(ie||me);if(je)if(kr)je=mn(kr)||Pe&&!_e;else if(Pe&&!_e)je=!0;else throw new Error("cannot determine the script source URL.");if(je)return[void 0,ds];{let qe="ort-wasm-simd-threaded.mjs",Ie=ie??Zs(qe,me),De=_e&&Ie&&!mn(Ie,me),Ve=De?await Ri(Ie):Ie??us(qe,me);return[De?Ve:void 0,await ka(Ve)]}}}),As,Qn,Mi,ts,eo,$s,Ns,Os,Ut,pi=u(()=>{hi(),Qn=!1,Mi=!1,ts=!1,eo=()=>{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}},$s=()=>{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}},Ns=()=>{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}},Os=async ie=>{if(Qn)return Promise.resolve();if(Mi)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(ts)throw new Error("previous call to 'initializeWebAssembly()' failed.");Mi=!0;let me=ie.initTimeout,_e=ie.numThreads;if(ie.simd!==!1){if(ie.simd==="relaxed"){if(!Ns())throw new Error("Relaxed WebAssembly SIMD is not supported in the current environment.")}else if(!$s())throw new Error("WebAssembly SIMD is not supported in the current environment.")}let Pe=eo();_e>1&&!Pe&&(typeof self<"u"&&!self.crossOriginIsolated&&console.warn("env.wasm.numThreads is set to "+_e+", 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."),ie.numThreads=_e=1);let je=ie.wasmPaths,qe=typeof je=="string"?je:void 0,Ie=je==null?void 0:je.mjs,De=(Ie==null?void 0:Ie.href)??Ie,Ve=je==null?void 0:je.wasm,it=(Ve==null?void 0:Ve.href)??Ve,ut=ie.wasmBinary,[st,et]=await Zn(De,qe,_e>1,!!ut||!!it),Ot=!1,We=[];if(me>0&&We.push(new Promise(pt=>{setTimeout(()=>{Ot=!0,pt()},me)})),We.push(new Promise((pt,Rr)=>{let tr={numThreads:_e};if(ut)tr.wasmBinary=ut,tr.locateFile=rr=>rr;else if(it||qe)tr.locateFile=rr=>it??qe+rr;else if(De&&De.indexOf("blob:")!==0)tr.locateFile=rr=>new URL(rr,De).href;else if(st){let rr=fi();rr&&(tr.locateFile=Mr=>rr+Mr)}et(tr).then(rr=>{Mi=!1,Qn=!0,As=rr,pt(),st&&URL.revokeObjectURL(st)},rr=>{Mi=!1,ts=!0,Rr(rr)})})),await Promise.race(We),Ot)throw new Error(`WebAssembly backend initializing failed due to timeout: ${me}ms`)},Ut=()=>{if(Qn&&As)return As;throw new Error("WebAssembly is not initialized yet.")}}),en,Tr,Et,Ca=u(()=>{pi(),en=(ie,me)=>{let _e=Ut(),Pe=_e.lengthBytesUTF8(ie)+1,je=_e._malloc(Pe);return _e.stringToUTF8(ie,je,Pe),me.push(je),je},Tr=(ie,me,_e,Pe)=>{if(typeof ie=="object"&&ie!==null){if(_e.has(ie))throw new Error("Circular reference in options");_e.add(ie)}Object.entries(ie).forEach(([je,qe])=>{let Ie=me?me+je:je;if(typeof qe=="object")Tr(qe,Ie+".",_e,Pe);else if(typeof qe=="string"||typeof qe=="number")Pe(Ie,qe.toString());else if(typeof qe=="boolean")Pe(Ie,qe?"1":"0");else throw new Error(`Can't handle extra config type: ${typeof qe}`)})},Et=ie=>{let me=Ut(),_e=me.stackSave();try{let Pe=me.PTR_SIZE,je=me.stackAlloc(2*Pe);me._OrtGetLastError(je,je+Pe);let qe=Number(me.getValue(je,Pe===4?"i32":"i64")),Ie=me.getValue(je+Pe,"*"),De=Ie?me.UTF8ToString(Ie):"";throw new Error(`${ie} ERROR_CODE: ${qe}, ERROR_MESSAGE: ${De}`)}finally{me.stackRestore(_e)}}}),to,Al=u(()=>{pi(),Ca(),to=ie=>{let me=Ut(),_e=0,Pe=[],je=ie||{};try{if((ie==null?void 0:ie.logSeverityLevel)===void 0)je.logSeverityLevel=2;else if(typeof ie.logSeverityLevel!="number"||!Number.isInteger(ie.logSeverityLevel)||ie.logSeverityLevel<0||ie.logSeverityLevel>4)throw new Error(`log severity level is not valid: ${ie.logSeverityLevel}`);if((ie==null?void 0:ie.logVerbosityLevel)===void 0)je.logVerbosityLevel=0;else if(typeof ie.logVerbosityLevel!="number"||!Number.isInteger(ie.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${ie.logVerbosityLevel}`);(ie==null?void 0:ie.terminate)===void 0&&(je.terminate=!1);let qe=0;return(ie==null?void 0:ie.tag)!==void 0&&(qe=en(ie.tag,Pe)),_e=me._OrtCreateRunOptions(je.logSeverityLevel,je.logVerbosityLevel,!!je.terminate,qe),_e===0&&Et("Can't create run options."),(ie==null?void 0:ie.extra)!==void 0&&Tr(ie.extra,"",new WeakSet,(Ie,De)=>{let Ve=en(Ie,Pe),it=en(De,Pe);me._OrtAddRunConfigEntry(_e,Ve,it)!==0&&Et(`Can't set a run config entry: ${Ie} - ${De}.`)}),[_e,Pe]}catch(qe){throw _e!==0&&me._OrtReleaseRunOptions(_e),Pe.forEach(Ie=>me._free(Ie)),qe}}}),ro,no,Wo,Wn,$l,Nl,Ar=u(()=>{pi(),Ca(),ro=ie=>{switch(ie){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: ${ie}`)}},no=ie=>{switch(ie){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${ie}`)}},Wo=ie=>{ie.extra||(ie.extra={}),ie.extra.session||(ie.extra.session={});let me=ie.extra.session;me.use_ort_model_bytes_directly||(me.use_ort_model_bytes_directly="1"),ie.executionProviders&&ie.executionProviders.some(_e=>(typeof _e=="string"?_e:_e.name)==="webgpu")&&(ie.enableMemPattern=!1)},Wn=(ie,me,_e,Pe)=>{let je=en(me,Pe),qe=en(_e,Pe);Ut()._OrtAddSessionConfigEntry(ie,je,qe)!==0&&Et(`Can't set a session config entry: ${me} - ${_e}.`)},$l=async(ie,me,_e)=>{let Pe=me.executionProviders;for(let je of Pe){let qe=typeof je=="string"?je:je.name,Ie=[];switch(qe){case"webnn":if(qe="WEBNN",Wn(ie,"session.disable_quant_qdq","1",_e),Wn(ie,"session.disable_qdq_constant_folding","1",_e),typeof je!="string"){let st=je==null?void 0:je.deviceType;st&&Wn(ie,"deviceType",st,_e)}break;case"webgpu":if(qe="JS",typeof je!="string"){let st=je;if(st!=null&&st.preferredLayout){if(st.preferredLayout!=="NCHW"&&st.preferredLayout!=="NHWC")throw new Error(`preferredLayout must be either 'NCHW' or 'NHWC': ${st.preferredLayout}`);Wn(ie,"preferredLayout",st.preferredLayout,_e)}}break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${qe}`)}let De=en(qe,_e),Ve=Ie.length,it=0,ut=0;if(Ve>0){it=Ut()._malloc(Ve*Ut().PTR_SIZE),_e.push(it),ut=Ut()._malloc(Ve*Ut().PTR_SIZE),_e.push(ut);for(let st=0;st<Ve;st++)Ut().setValue(it+st*Ut().PTR_SIZE,Ie[st][0],"*"),Ut().setValue(ut+st*Ut().PTR_SIZE,Ie[st][1],"*")}await Ut()._OrtAppendExecutionProvider(ie,De,it,ut,Ve)!==0&&Et(`Can't append execution provider: ${qe}.`)}},Nl=async ie=>{let me=Ut(),_e=0,Pe=[],je=ie||{};Wo(je);try{let qe=ro(je.graphOptimizationLevel??"all"),Ie=no(je.executionMode??"sequential"),De=typeof je.logId=="string"?en(je.logId,Pe):0,Ve=je.logSeverityLevel??2;if(!Number.isInteger(Ve)||Ve<0||Ve>4)throw new Error(`log severity level is not valid: ${Ve}`);let it=je.logVerbosityLevel??0;if(!Number.isInteger(it)||it<0||it>4)throw new Error(`log verbosity level is not valid: ${it}`);let ut=typeof je.optimizedModelFilePath=="string"?en(je.optimizedModelFilePath,Pe):0;if(_e=me._OrtCreateSessionOptions(qe,!!je.enableCpuMemArena,!!je.enableMemPattern,Ie,!!je.enableProfiling,0,De,Ve,it,ut),_e===0&&Et("Can't create session options."),je.executionProviders&&await $l(_e,je,Pe),je.enableGraphCapture!==void 0){if(typeof je.enableGraphCapture!="boolean")throw new Error(`enableGraphCapture must be a boolean value: ${je.enableGraphCapture}`);Wn(_e,"enableGraphCapture",je.enableGraphCapture.toString(),Pe)}if(je.freeDimensionOverrides)for(let[st,et]of Object.entries(je.freeDimensionOverrides)){if(typeof st!="string")throw new Error(`free dimension override name must be a string: ${st}`);if(typeof et!="number"||!Number.isInteger(et)||et<0)throw new Error(`free dimension override value must be a non-negative integer: ${et}`);let Ot=en(st,Pe);me._OrtAddFreeDimensionOverride(_e,Ot,et)!==0&&Et(`Can't set a free dimension override: ${st} - ${et}.`)}return je.extra!==void 0&&Tr(je.extra,"",new WeakSet,(st,et)=>{Wn(_e,st,et,Pe)}),[_e,Pe]}catch(qe){throw _e!==0&&me._OrtReleaseSessionOptions(_e)!==0&&Et("Can't release session options."),Pe.forEach(Ie=>me._free(Ie)),qe}}}),ei,sn,ti,Ps,ja,ta,Ii,Rn,Wt=u(()=>{ei=ie=>{switch(ie){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: ${ie}`)}},sn=ie=>{switch(ie){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: ${ie}`)}},ti=(ie,me)=>{let _e=[-1,4,1,1,2,2,4,8,-1,1,2,8,4,8,-1,-1,-1,-1,-1,-1,-1,.5,.5][ie],Pe=typeof me=="number"?me:me.reduce((je,qe)=>je*qe,1);return _e>0?Math.ceil(Pe*_e):void 0},Ps=ie=>{switch(ie){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: ${ie}`)}},ja=ie=>{switch(ie){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: ${ie}`)}},ta=ie=>ie==="float32"||ie==="float16"||ie==="int32"||ie==="int64"||ie==="uint32"||ie==="uint8"||ie==="bool"||ie==="uint4"||ie==="int4",Ii=ie=>ie==="float32"||ie==="float16"||ie==="int32"||ie==="int64"||ie==="uint32"||ie==="uint64"||ie==="int8"||ie==="uint8"||ie==="bool"||ie==="uint4"||ie==="int4",Rn=ie=>{switch(ie){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: ${ie}`)}}}),an,ra=u(()=>{Ct(),an=async ie=>{if(typeof ie=="string"){let me=await fetch(ie);if(!me.ok)throw new Error(`failed to load external data file: ${ie}`);let _e=me.headers.get("Content-Length"),Pe=_e?parseInt(_e,10):0;if(Pe<1073741824)return new Uint8Array(await me.arrayBuffer());{if(!me.body)throw new Error(`failed to load external data file: ${ie}, no response body.`);let je=me.body.getReader(),qe;try{qe=new ArrayBuffer(Pe)}catch(De){if(De instanceof RangeError){let Ve=Math.ceil(Pe/65536);qe=new WebAssembly.Memory({initial:Ve,maximum:Ve}).buffer}else throw De}let Ie=0;for(;;){let{done:De,value:Ve}=await je.read();if(De)break;let it=Ve.byteLength;new Uint8Array(qe,Ie,it).set(Ve),Ie+=it}return new Uint8Array(qe,0,Pe)}}else return ie instanceof Blob?new Uint8Array(await ie.arrayBuffer()):ie instanceof Uint8Array?ie:new Uint8Array(ie)}}),Di,qo,na,mi,fs,ia,cr,Li,Ea,rs,Qe,gi,yt,Se=u(()=>{lt(),Al(),Ar(),Wt(),pi(),Ca(),ra(),Di=(ie,me)=>{Ut()._OrtInit(ie,me)!==0&&Et("Can't initialize onnxruntime.")},qo=async ie=>{Di(ie.wasm.numThreads,ja(ie.logLevel))},na=async(ie,me)=>{var Pe,je;(je=(Pe=Ut()).asyncInit)==null||je.call(Pe);let _e=ie.webgpu.adapter;if(me==="webgpu"){if(typeof navigator>"u"||!navigator.gpu)throw new Error("WebGPU is not supported in current environment");if(_e){if(typeof _e.limits!="object"||typeof _e.features!="object"||typeof _e.requestDevice!="function")throw new Error("Invalid GPU adapter set in `env.webgpu.adapter`. It must be a GPUAdapter object.")}else{let qe=ie.webgpu.powerPreference;if(qe!==void 0&&qe!=="low-power"&&qe!=="high-performance")throw new Error(`Invalid powerPreference setting: "${qe}"`);let Ie=ie.webgpu.forceFallbackAdapter;if(Ie!==void 0&&typeof Ie!="boolean")throw new Error(`Invalid forceFallbackAdapter setting: "${Ie}"`);if(_e=await navigator.gpu.requestAdapter({powerPreference:qe,forceFallbackAdapter:Ie}),!_e)throw new Error('Failed to get GPU adapter. You may need to enable flag "--enable-unsafe-webgpu" if you are using Chrome.')}}if(me==="webnn"&&(typeof navigator>"u"||!navigator.ml))throw new Error("WebNN is not supported in current environment")},mi=new Map,fs=ie=>{let me=Ut(),_e=me.stackSave();try{let Pe=me.PTR_SIZE,je=me.stackAlloc(2*Pe);me._OrtGetInputOutputCount(ie,je,je+Pe)!==0&&Et("Can't get session input/output count.");let qe=Pe===4?"i32":"i64";return[Number(me.getValue(je,qe)),Number(me.getValue(je+Pe,qe))]}finally{me.stackRestore(_e)}},ia=(ie,me)=>{let _e=Ut(),Pe=_e.stackSave(),je=0;try{let qe=_e.PTR_SIZE,Ie=_e.stackAlloc(2*qe);_e._OrtGetInputOutputMetadata(ie,me,Ie,Ie+qe)!==0&&Et("Can't get session input/output metadata.");let De=Number(_e.getValue(Ie,"*"));je=Number(_e.getValue(Ie+qe,"*"));let Ve=_e.HEAP32[je/4];if(Ve===0)return[De,0];let it=_e.HEAPU32[je/4+1],ut=[];for(let st=0;st<it;st++){let et=Number(_e.getValue(je+8+st*qe,"*"));ut.push(et!==0?_e.UTF8ToString(et):Number(_e.getValue(je+8+(st+it)*qe,"*")))}return[De,Ve,ut]}finally{_e.stackRestore(Pe),je!==0&&_e._OrtFree(je)}},cr=ie=>{let me=Ut(),_e=me._malloc(ie.byteLength);if(_e===0)throw new Error(`Can't create a session. failed to allocate a buffer of size ${ie.byteLength}.`);return me.HEAPU8.set(ie,_e),[_e,ie.byteLength]},Li=async(ie,me)=>{var ut,st,et;let _e,Pe,je=Ut();Array.isArray(ie)?[_e,Pe]=ie:ie.buffer===je.HEAPU8.buffer?[_e,Pe]=[ie.byteOffset,ie.byteLength]:[_e,Pe]=cr(ie);let qe=0,Ie=0,De=[],Ve=[],it=[];try{if([Ie,De]=await Nl(me),(me==null?void 0:me.externalData)&&je.mountExternalData){let Ur=[];for(let gr of me.externalData){let Mn=typeof gr=="string"?gr:gr.path;Ur.push(an(typeof gr=="string"?gr:gr.data).then(ri=>{je.mountExternalData(Mn,ri)}))}await Promise.all(Ur)}for(let Ur of(me==null?void 0:me.executionProviders)??[])if((typeof Ur=="string"?Ur:Ur.name)==="webnn"){if(je.shouldTransferToMLTensor=!1,typeof Ur!="string"){let gr=Ur,Mn=gr==null?void 0:gr.context,ri=gr==null?void 0:gr.gpuDevice,vi=gr==null?void 0:gr.deviceType,Pl=gr==null?void 0:gr.powerPreference;Mn?je.currentContext=Mn:ri?je.currentContext=await je.webnnCreateMLContext(ri):je.currentContext=await je.webnnCreateMLContext({deviceType:vi,powerPreference:Pl})}else je.currentContext=await je.webnnCreateMLContext();break}qe=await je._OrtCreateSession(_e,Pe,Ie),(ut=je.webgpuOnCreateSession)==null||ut.call(je,qe),qe===0&&Et("Can't create a session."),(st=je.jsepOnCreateSession)==null||st.call(je),je.currentContext&&(je.webnnRegisterMLContext(qe,je.currentContext),je.currentContext=void 0,je.shouldTransferToMLTensor=!0);let[Ot,We]=fs(qe),pt=!!(me!=null&&me.enableGraphCapture),Rr=[],tr=[],rr=[],Mr=[],zt=[];for(let Ur=0;Ur<Ot;Ur++){let[gr,Mn,ri]=ia(qe,Ur);gr===0&&Et("Can't get an input name."),Ve.push(gr);let vi=je.UTF8ToString(gr);Rr.push(vi),rr.push(Mn===0?{name:vi,isTensor:!1}:{name:vi,isTensor:!0,type:sn(Mn),shape:ri})}for(let Ur=0;Ur<We;Ur++){let[gr,Mn,ri]=ia(qe,Ur+Ot);gr===0&&Et("Can't get an output name."),it.push(gr);let vi=je.UTF8ToString(gr);tr.push(vi),Mr.push(Mn===0?{name:vi,isTensor:!1}:{name:vi,isTensor:!0,type:sn(Mn),shape:ri})}return mi.set(qe,[qe,Ve,it,null,pt,!1]),[qe,Rr,tr,rr,Mr]}catch(Ot){throw Ve.forEach(We=>je._OrtFree(We)),it.forEach(We=>je._OrtFree(We)),qe!==0&&je._OrtReleaseSession(qe)!==0&&Et("Can't release session."),Ot}finally{je._free(_e),Ie!==0&&je._OrtReleaseSessionOptions(Ie)!==0&&Et("Can't release session options."),De.forEach(Ot=>je._free(Ot)),(et=je.unmountExternalData)==null||et.call(je)}},Ea=ie=>{var Ve,it,ut;let me=Ut(),_e=mi.get(ie);if(!_e)throw new Error(`cannot release session. invalid session id: ${ie}`);let[Pe,je,qe,Ie,De]=_e;Ie&&(De&&me._OrtClearBoundOutputs(Ie.handle)!==0&&Et("Can't clear bound outputs."),me._OrtReleaseBinding(Ie.handle)!==0&&Et("Can't release IO binding.")),(Ve=me.jsepOnReleaseSession)==null||Ve.call(me,ie),(it=me.webnnOnReleaseSession)==null||it.call(me,ie),(ut=me.webgpuOnReleaseSession)==null||ut.call(me,ie),je.forEach(st=>me._OrtFree(st)),qe.forEach(st=>me._OrtFree(st)),me._OrtReleaseSession(Pe)!==0&&Et("Can't release session."),mi.delete(ie)},rs=async(ie,me,_e,Pe,je,qe,Ie=!1)=>{if(!ie){me.push(0);return}let De=Ut(),Ve=De.PTR_SIZE,it=ie[0],ut=ie[1],st=ie[3],et=st,Ot,We;if(it==="string"&&(st==="gpu-buffer"||st==="ml-tensor"))throw new Error("String tensor is not supported on GPU.");if(Ie&&st!=="gpu-buffer")throw new Error(`External buffer must be provided for input/output index ${qe} when enableGraphCapture is true.`);if(st==="gpu-buffer"){let tr=ie[2].gpuBuffer;We=ti(ei(it),ut);{let rr=De.jsepRegisterBuffer;if(!rr)throw new Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');Ot=rr(Pe,qe,tr,We)}}else if(st==="ml-tensor"){let tr=ie[2].mlTensor;We=ti(ei(it),ut);let rr=De.webnnRegisterMLTensor;if(!rr)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');Ot=rr(Pe,tr,ei(it),ut)}else{let tr=ie[2];if(Array.isArray(tr)){We=Ve*tr.length,Ot=De._malloc(We),_e.push(Ot);for(let rr=0;rr<tr.length;rr++){if(typeof tr[rr]!="string")throw new TypeError(`tensor data at index ${rr} is not a string`);De.setValue(Ot+rr*Ve,en(tr[rr],_e),"*")}}else{let rr=De.webnnIsGraphInput,Mr=De.webnnIsGraphOutput;if(it!=="string"&&rr&&Mr){let zt=De.UTF8ToString(je);if(rr(Pe,zt)||Mr(Pe,zt)){let Ur=ei(it);We=ti(Ur,ut),et="ml-tensor";let gr=De.webnnCreateTemporaryTensor,Mn=De.webnnUploadTensor;if(!gr||!Mn)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');let ri=await gr(Pe,Ur,ut);Mn(ri,new Uint8Array(tr.buffer,tr.byteOffset,tr.byteLength)),Ot=ri}else We=tr.byteLength,Ot=De._malloc(We),_e.push(Ot),De.HEAPU8.set(new Uint8Array(tr.buffer,tr.byteOffset,We),Ot)}else We=tr.byteLength,Ot=De._malloc(We),_e.push(Ot),De.HEAPU8.set(new Uint8Array(tr.buffer,tr.byteOffset,We),Ot)}}let pt=De.stackSave(),Rr=De.stackAlloc(4*ut.length);try{ut.forEach((rr,Mr)=>De.setValue(Rr+Mr*Ve,rr,Ve===4?"i32":"i64"));let tr=De._OrtCreateTensor(ei(it),Ot,We,Rr,ut.length,Rn(et));tr===0&&Et(`Can't create tensor for input/output. session=${Pe}, index=${qe}.`),me.push(tr)}finally{De.stackRestore(pt)}},Qe=async(ie,me,_e,Pe,je,qe)=>{var yi,Nc,qu;let Ie=Ut(),De=Ie.PTR_SIZE,Ve=mi.get(ie);if(!Ve)throw new Error(`cannot run inference. invalid session id: ${ie}`);let it=Ve[0],ut=Ve[1],st=Ve[2],et=Ve[3],Ot=Ve[4];Ve[5];let We=me.length,pt=Pe.length,Rr=0,tr=[],rr=[],Mr=[],zt=[],Ur=[],gr=Ie.stackSave(),Mn=Ie.stackAlloc(We*De),ri=Ie.stackAlloc(We*De),vi=Ie.stackAlloc(pt*De),Pl=Ie.stackAlloc(pt*De);try{[Rr,tr]=to(qe),Me("wasm prepareInputOutputTensor");for(let hr=0;hr<We;hr++)await rs(_e[hr],rr,zt,ie,ut[me[hr]],me[hr],Ot);for(let hr=0;hr<pt;hr++)await rs(je[hr],Mr,zt,ie,st[Pe[hr]],We+Pe[hr],Ot);Ue("wasm prepareInputOutputTensor");for(let hr=0;hr<We;hr++)Ie.setValue(Mn+hr*De,rr[hr],"*"),Ie.setValue(ri+hr*De,ut[me[hr]],"*");for(let hr=0;hr<pt;hr++)Ie.setValue(vi+hr*De,Mr[hr],"*"),Ie.setValue(Pl+hr*De,st[Pe[hr]],"*");(yi=Ie.jsepOnRunStart)==null||yi.call(Ie,it),(Nc=Ie.webnnOnRunStart)==null||Nc.call(Ie,it);let In;In=await Ie._OrtRun(it,ri,Mn,We,Pl,pt,vi,Rr),In!==0&&Et("failed to call OrtRun().");let Ms=[],Hu=[];Me("wasm ProcessOutputTensor");for(let hr=0;hr<pt;hr++){let ps=Number(Ie.getValue(vi+hr*De,"*"));if(ps===Mr[hr]||Ur.includes(Mr[hr])){Ms.push(je[hr]),ps!==Mr[hr]&&Ie._OrtReleaseTensor(ps)!==0&&Et("Can't release tensor.");continue}let Tf=Ie.stackSave(),oa=Ie.stackAlloc(4*De),Ho=!1,_n,bi=0;try{Ie._OrtGetTensorData(ps,oa,oa+De,oa+2*De,oa+3*De)!==0&&Et(`Can't access output tensor data on index ${hr}.`);let Oc=De===4?"i32":"i64",xi=Number(Ie.getValue(oa,Oc));bi=Ie.getValue(oa+De,"*");let Vu=Ie.getValue(oa+De*2,"*"),Af=Number(Ie.getValue(oa+De*3,Oc)),la=[];for(let Sn=0;Sn<Af;Sn++)la.push(Number(Ie.getValue(Vu+Sn*De,Oc)));Ie._OrtFree(Vu)!==0&&Et("Can't free memory for tensor dims.");let ms=la.reduce((Sn,tn)=>Sn*tn,1);_n=sn(xi);let Is=et==null?void 0:et.outputPreferredLocations[Pe[hr]];if(_n==="string"){if(Is==="gpu-buffer"||Is==="ml-tensor")throw new Error("String tensor is not supported on GPU.");let Sn=[];for(let tn=0;tn<ms;tn++){let gs=Ie.getValue(bi+tn*De,"*"),Gu=Ie.getValue(bi+(tn+1)*De,"*"),Ku=tn===ms-1?void 0:Gu-gs;Sn.push(Ie.UTF8ToString(gs,Ku))}Ms.push([_n,la,Sn,"cpu"])}else if(Is==="gpu-buffer"&&ms>0){let Sn=Ie.jsepGetBuffer;if(!Sn)throw new Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');let tn=Sn(bi),gs=ti(xi,ms);if(gs===void 0||!ta(_n))throw new Error(`Unsupported data type: ${_n}`);Ho=!0,Ms.push([_n,la,{gpuBuffer:tn,download:Ie.jsepCreateDownloader(tn,gs,_n),dispose:()=>{Ie._OrtReleaseTensor(ps)!==0&&Et("Can't release tensor.")}},"gpu-buffer"])}else if(Is==="ml-tensor"&&ms>0){let Sn=Ie.webnnEnsureTensor,tn=Ie.webnnIsGraphInputOutputTypeSupported;if(!Sn||!tn)throw new Error('preferredLocation "ml-tensor" is not supported without using WebNN.');if(ti(xi,ms)===void 0||!Ii(_n))throw new Error(`Unsupported data type: ${_n}`);if(!tn(ie,_n,!1))throw new Error(`preferredLocation "ml-tensor" for ${_n} output is not supported by current WebNN Context.`);let gs=await Sn(ie,bi,xi,la,!1);Ho=!0,Ms.push([_n,la,{mlTensor:gs,download:Ie.webnnCreateMLTensorDownloader(bi,_n),dispose:()=>{Ie.webnnReleaseTensorId(bi),Ie._OrtReleaseTensor(ps)}},"ml-tensor"])}else if(Is==="ml-tensor-cpu-output"&&ms>0){let Sn=Ie.webnnCreateMLTensorDownloader(bi,_n)(),tn=Ms.length;Ho=!0,Hu.push((async()=>{let gs=[tn,await Sn];return Ie.webnnReleaseTensorId(bi),Ie._OrtReleaseTensor(ps),gs})()),Ms.push([_n,la,[],"cpu"])}else{let Sn=Ps(_n),tn=new Sn(ms);new Uint8Array(tn.buffer,tn.byteOffset,tn.byteLength).set(Ie.HEAPU8.subarray(bi,bi+tn.byteLength)),Ms.push([_n,la,tn,"cpu"])}}finally{Ie.stackRestore(Tf),_n==="string"&&bi&&Ie._free(bi),Ho||Ie._OrtReleaseTensor(ps)}}et&&!Ot&&(Ie._OrtClearBoundOutputs(et.handle)!==0&&Et("Can't clear bound outputs."),mi.set(ie,[it,ut,st,et,Ot,!1]));for(let[hr,ps]of await Promise.all(Hu))Ms[hr][2]=ps;return Ue("wasm ProcessOutputTensor"),Ms}finally{(qu=Ie.webnnOnRunEnd)==null||qu.call(Ie,it),Ie.stackRestore(gr),rr.forEach(In=>Ie._OrtReleaseTensor(In)),Mr.forEach(In=>Ie._OrtReleaseTensor(In)),zt.forEach(In=>Ie._free(In)),Rr!==0&&Ie._OrtReleaseRunOptions(Rr),tr.forEach(In=>Ie._free(In))}},gi=ie=>{let me=Ut(),_e=mi.get(ie);if(!_e)throw new Error("invalid session id");let Pe=_e[0],je=me._OrtEndProfiling(Pe);je===0&&Et("Can't get an profile file name."),me._OrtFree(je)},yt=ie=>{let me=[];for(let _e of ie){let Pe=_e[2];!Array.isArray(Pe)&&"buffer"in Pe&&me.push(Pe.buffer)}return me}}),ze,tt,At,ir,dr,Br,Dr,gn,Vr,wn,Lr,hs,Ta,io,Rs,Ef,so,ao,Fu=u(()=>{lt(),Se(),pi(),hi(),ze=()=>!!P.wasm.proxy&&typeof document<"u",At=!1,ir=!1,dr=!1,gn=new Map,Vr=(ie,me)=>{let _e=gn.get(ie);_e?_e.push(me):gn.set(ie,[me])},wn=()=>{if(At||!ir||dr||!tt)throw new Error("worker not ready")},Lr=ie=>{switch(ie.data.type){case"init-wasm":At=!1,ie.data.err?(dr=!0,Dr[1](ie.data.err)):(ir=!0,Dr[0]()),Br&&(URL.revokeObjectURL(Br),Br=void 0);break;case"init-ep":case"copy-from":case"create":case"release":case"run":case"end-profiling":{let me=gn.get(ie.data.type);ie.data.err?me.shift()[1](ie.data.err):me.shift()[0](ie.data.out);break}}},hs=async()=>{if(!ir){if(At)throw new Error("multiple calls to 'initWasm()' detected.");if(dr)throw new Error("previous call to 'initWasm()' failed.");if(At=!0,ze())return new Promise((ie,me)=>{tt==null||tt.terminate(),ea().then(([_e,Pe])=>{try{tt=Pe,tt.onerror=qe=>me(qe),tt.onmessage=Lr,Dr=[ie,me];let je={type:"init-wasm",in:P};if(!je.in.wasm.wasmPaths&&_e){let qe=fi();qe&&(je.in.wasm.wasmPaths=qe)}tt.postMessage(je),Br=_e}catch(je){me(je)}},me)});try{await Os(P.wasm),await qo(P),ir=!0}catch(ie){throw dr=!0,ie}finally{At=!1}}},Ta=async ie=>{if(ze())return wn(),new Promise((me,_e)=>{Vr("init-ep",[me,_e]);let Pe={type:"init-ep",in:{epName:ie,env:P}};tt.postMessage(Pe)});await na(P,ie)},io=async ie=>ze()?(wn(),new Promise((me,_e)=>{Vr("copy-from",[me,_e]);let Pe={type:"copy-from",in:{buffer:ie}};tt.postMessage(Pe,[ie.buffer])})):cr(ie),Rs=async(ie,me)=>{if(ze()){if(me!=null&&me.preferredOutputLocation)throw new Error('session option "preferredOutputLocation" is not supported for proxy.');return wn(),new Promise((_e,Pe)=>{Vr("create",[_e,Pe]);let je={type:"create",in:{model:ie,options:{...me}}},qe=[];ie instanceof Uint8Array&&qe.push(ie.buffer),tt.postMessage(je,qe)})}else return Li(ie,me)},Ef=async ie=>{if(ze())return wn(),new Promise((me,_e)=>{Vr("release",[me,_e]);let Pe={type:"release",in:ie};tt.postMessage(Pe)});Ea(ie)},so=async(ie,me,_e,Pe,je,qe)=>{if(ze()){if(_e.some(Ie=>Ie[3]!=="cpu"))throw new Error("input tensor on GPU is not supported for proxy.");if(je.some(Ie=>Ie))throw new Error("pre-allocated output tensor is not supported for proxy.");return wn(),new Promise((Ie,De)=>{Vr("run",[Ie,De]);let Ve=_e,it={type:"run",in:{sessionId:ie,inputIndices:me,inputs:Ve,outputIndices:Pe,options:qe}};tt.postMessage(it,yt(Ve))})}else return Qe(ie,me,_e,Pe,je,qe)},ao=async ie=>{if(ze())return wn(),new Promise((me,_e)=>{Vr("end-profiling",[me,_e]);let Pe={type:"end-profiling",in:ie};tt.postMessage(Pe)});gi(ie)}}),Ec,oo,Ol,Tc=u(()=>{lt(),Fu(),Wt(),Ct(),ra(),Ec=(ie,me)=>{switch(ie.location){case"cpu":return[ie.type,ie.dims,ie.data,"cpu"];case"gpu-buffer":return[ie.type,ie.dims,{gpuBuffer:ie.gpuBuffer},"gpu-buffer"];case"ml-tensor":return[ie.type,ie.dims,{mlTensor:ie.mlTensor},"ml-tensor"];default:throw new Error(`invalid data location: ${ie.location} for ${me()}`)}},oo=ie=>{switch(ie[3]){case"cpu":return new ge(ie[0],ie[2],ie[1]);case"gpu-buffer":{let me=ie[0];if(!ta(me))throw new Error(`not supported data type: ${me} for deserializing GPU tensor`);let{gpuBuffer:_e,download:Pe,dispose:je}=ie[2];return ge.fromGpuBuffer(_e,{dataType:me,dims:ie[1],download:Pe,dispose:je})}case"ml-tensor":{let me=ie[0];if(!Ii(me))throw new Error(`not supported data type: ${me} for deserializing MLTensor tensor`);let{mlTensor:_e,download:Pe,dispose:je}=ie[2];return ge.fromMLTensor(_e,{dataType:me,dims:ie[1],download:Pe,dispose:je})}default:throw new Error(`invalid data location: ${ie[3]}`)}},Ol=class{async fetchModelAndCopyToWasmMemory(ie){return io(await an(ie))}async loadModel(ie,me){ct();let _e;typeof ie=="string"?_e=await this.fetchModelAndCopyToWasmMemory(ie):_e=ie,[this.sessionId,this.inputNames,this.outputNames,this.inputMetadata,this.outputMetadata]=await Rs(_e,me),Le()}async dispose(){return Ef(this.sessionId)}async run(ie,me,_e){ct();let Pe=[],je=[];Object.entries(ie).forEach(st=>{let et=st[0],Ot=st[1],We=this.inputNames.indexOf(et);if(We===-1)throw new Error(`invalid input '${et}'`);Pe.push(Ot),je.push(We)});let qe=[],Ie=[];Object.entries(me).forEach(st=>{let et=st[0],Ot=st[1],We=this.outputNames.indexOf(et);if(We===-1)throw new Error(`invalid output '${et}'`);qe.push(Ot),Ie.push(We)});let De=Pe.map((st,et)=>Ec(st,()=>`input "${this.inputNames[je[et]]}"`)),Ve=qe.map((st,et)=>st?Ec(st,()=>`output "${this.outputNames[Ie[et]]}"`):null),it=await so(this.sessionId,je,De,Ie,Ve,_e),ut={};for(let st=0;st<it.length;st++)ut[this.outputNames[Ie[st]]]=qe[st]??oo(it[st]);return Le(),ut}startProfiling(){}endProfiling(){ao(this.sessionId)}}}),sa={};f(sa,{OnnxruntimeWebAssemblyBackend:()=>aa,initializeFlags:()=>Aa,wasmBackend:()=>lo});var Aa,aa,lo,Uu=u(()=>{lt(),Fu(),Tc(),Aa=()=>{(typeof P.wasm.initTimeout!="number"||P.wasm.initTimeout<0)&&(P.wasm.initTimeout=0);let ie=P.wasm.simd;if(typeof ie!="boolean"&&ie!==void 0&&ie!=="fixed"&&ie!=="relaxed"&&(console.warn(`Property "env.wasm.simd" is set to unknown value "${ie}". Reset it to \`false\` and ignore SIMD feature checking.`),P.wasm.simd=!1),typeof P.wasm.proxy!="boolean"&&(P.wasm.proxy=!1),typeof P.wasm.trace!="boolean"&&(P.wasm.trace=!1),typeof P.wasm.numThreads!="number"||!Number.isInteger(P.wasm.numThreads)||P.wasm.numThreads<=0)if(typeof self<"u"&&!self.crossOriginIsolated)P.wasm.numThreads=1;else{let me=typeof navigator>"u"?l("node:os").cpus().length:navigator.hardwareConcurrency;P.wasm.numThreads=Math.min(4,Math.ceil((me||1)/2))}},aa=class{async init(ie){Aa(),await hs(),await Ta(ie)}async createInferenceSessionHandler(ie,me){let _e=new Ol;return await _e.loadModel(ie,me),_e}},lo=new aa}),Wu={};f(Wu,{InferenceSession:()=>Yt,TRACE:()=>Te,TRACE_EVENT_BEGIN:()=>Me,TRACE_EVENT_END:()=>Ue,TRACE_FUNC_BEGIN:()=>ct,TRACE_FUNC_END:()=>Le,Tensor:()=>ge,default:()=>$c,env:()=>P,registerBackend:()=>k}),lt(),lt(),lt();var Ac="1.26.0",$c=Yn;{let ie=(Uu(),h(sa)).wasmBackend;k("cpu",ie,10),k("wasm",ie,10)}return Object.defineProperty(P.versions,"web",{value:Ac,enumerable:!0}),h(Wu)})();e.exports=n})(O1)),O1.exports}var TN;function nq(){return TN||(TN=1,(function(e){var r=rc&&rc.__createBinding||(Object.create?(function(C,T,E,$){$===void 0&&($=E);var N=Object.getOwnPropertyDescriptor(T,E);(!N||("get"in N?!T.__esModule:N.writable||N.configurable))&&(N={enumerable:!0,get:function(){return T[E]}}),Object.defineProperty(C,$,N)}):(function(C,T,E,$){$===void 0&&($=E),C[$]=T[E]})),n=rc&&rc.__setModuleDefault||(Object.create?(function(C,T){Object.defineProperty(C,"default",{enumerable:!0,value:T})}):function(C,T){C.default=T}),i=rc&&rc.__importStar||function(C){if(C&&C.__esModule)return C;var T={};if(C!=null)for(var E in C)E!=="default"&&Object.prototype.hasOwnProperty.call(C,E)&&r(T,C,E);return n(T,C),T};Object.defineProperty(e,"__esModule",{value:!0}),e.MicVAD=e.getDefaultRealTimeVADOptions=e.ort=e.DEFAULT_MODEL=void 0;const s=i(rq()),a=XT(),c=YT(),l=ob(),u=g_(),f=I4(),m=D4();e.DEFAULT_MODEL="legacy",e.ort=s;const h="vad.worklet.bundle.min.js",b="silero_vad_v5.onnx",w="silero_vad_legacy.onnx",k=C=>({...c.defaultFrameProcessorOptions,onFrameProcessed:()=>{},onVADMisfire:()=>{l.log.debug("VAD misfire")},onSpeechStart:()=>{l.log.debug("Detected speech start")},onSpeechEnd:()=>{l.log.debug("Detected speech end")},onSpeechRealStart:()=>{l.log.debug("Detected real speech start")},baseAssetPath:"./",onnxWASMBasePath:"./",model:C,workletOptions:{},getStream:async()=>await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}}),pauseStream:async T=>{T.getTracks().forEach(E=>{E.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=k;const S=C=>"audioWorklet"in C&&typeof AudioWorkletNode=="function"?"AudioWorklet":"ScriptProcessor";async function y(C,T,E,$,N){await E.audioWorklet.addModule(C),T.processorOptions={...T.processorOptions??{},frameSamples:$};const P=new AudioWorkletNode(E,"vad-helper-worklet",T);return P.port.onmessage=async I=>{const W=I.data;if(!(typeof W=="object"&&W&&"message"in W)){console.error("Invalid message event",W);return}switch(W.message){case u.Message.AudioFrame:{if(!("data"in W&&W.data instanceof ArrayBuffer)){console.log("Audio frame message has no data");return}const F=new Float32Array(W.data);await N(F);break}}},P}async function x(C,T,E){const $=new m.Resampler({nativeSampleRate:C.sampleRate,targetSampleRate:16e3,targetFrameSize:T});l.log.debug("using script processor");const P=C.createScriptProcessor(4096,1,1);let I=!1;return P.onaudioprocess=async W=>{if(!I){I=!0;try{const F=W.inputBuffer.getChannelData(0);W.outputBuffer.getChannelData(0).fill(0);const q=$.process(F);for(const z of q)await E(z)}catch(F){console.error("Error processing audio:",F)}finally{I=!1}}},P.connect(C.destination),P}class _{constructor(T,E,$,N,P=!1,I=null,W=null,F=null,U=null,q=null,z=null,Y="uninitialized",ee=!1){this.options=T,this.frameProcessor=E,this.model=$,this.frameSamples=N,this.listening=P,this.errored=I,this._stream=W,this._audioContext=F,this._vadNode=U,this._mediaStreamAudioSourceNode=q,this._audioProcessorAdapterType=z,this.initializationState=Y,this.ownsAudioContext=ee,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=se=>{this.initializationState="errored",this.errored=se},this.start=async()=>{switch(this.initializationState){case"uninitialized":{l.log.debug("initializing micVAD"),this.initializationState="initializing",this.frameProcessor.resume();try{this._stream=await this.options.getStream()}catch(se){throw se instanceof Error?this.setErrored(se.message):this.setErrored(String(se)),se}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"?S(this._audioContext):this.options.processorType,this._audioProcessorAdapterType){case"AudioWorklet":this._vadNode=await y(this.options.baseAssetPath+h,this.options.workletOptions,this._audioContext,this.frameSamples,this.processFrame);break;case"ScriptProcessor":this._vadNode=await x(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),l.log.debug("started micVAD"),this.listening=!0,this.initializationState="initialized";break}case"initializing":{l.log.warn("start called while initializing");break}case"initialized":{if(this.listening)return;this.listening=!0,this.frameProcessor.resume();const{stream:se,audioContext:ue,vadNode:X}=this.getAudioInstances();this._stream=await this.options.resumeStream(se);const Q=new MediaStreamAudioSourceNode(ue,{mediaStream:this._stream});this._mediaStreamAudioSourceNode=Q,Q.connect(X);break}case"destroyed":{l.log.warn("start called after destroyed");break}case"errored":{l.log.error("start called after errored");break}default:{l.log.warn("weird initialization state");break}}},this.pause=async()=>{if(!this.listening)return;this.listening=!1;const{stream:se,mediaStreamAudioSourceNode:ue}=this.getAudioInstances();await this.options.pauseStream(se),ue.disconnect(),this.frameProcessor.pause(this.handleFrameProcessorEvent)},this.destroy=async()=>{var ue;l.log.debug("destroy called"),this.initializationState="destroyed";const{vadNode:se}=this.getAudioInstances();se instanceof AudioWorkletNode&&se.port.postMessage(u.Message.SpeechStop),this.listening&&await this.pause(),await this.model.release(),this.ownsAudioContext&&await((ue=this._audioContext)==null?void 0:ue.close())},this.setOptions=se=>{this.frameProcessor.setOptions(se)},this.processFrame=async se=>{await this.frameProcessor.process(se,this.handleFrameProcessorEvent)},this.handleFrameProcessorEvent=se=>{switch(se.msg){case u.Message.FrameProcessed:this.options.onFrameProcessed(se.probs,se.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(se.audio);break}}}static async new(T={}){const E={...(0,e.getDefaultRealTimeVADOptions)(T.model??e.DEFAULT_MODEL),...T};(0,c.validateOptions)(E),e.ort.env.wasm.wasmPaths=E.onnxWASMBasePath,E.ortConfig!==void 0&&E.ortConfig(e.ort);const $=E.model==="v5"?b:w,N=E.baseAssetPath+$,P=E.model==="v5"?f.SileroV5.new:f.SileroLegacy.new;let I;try{I=await P(e.ort,()=>(0,a.defaultModelFetcher)(N))}catch(z){throw console.error(`Encountered an error while loading model file ${N}`),z}const W=E.model==="v5"?512:1536,F=W/16,U=new c.FrameProcessor(I.process,I.reset_state,{positiveSpeechThreshold:E.positiveSpeechThreshold,negativeSpeechThreshold:E.negativeSpeechThreshold,redemptionMs:E.redemptionMs,preSpeechPadMs:E.preSpeechPadMs,minSpeechMs:E.minSpeechMs,submitUserSpeechOnPause:E.submitUserSpeechOnPause},F),q=new _(E,U,I,W);if(E.startOnLoad)try{await q.start()}catch(z){throw console.error("Error starting micVad",z),z}return q}}e.MicVAD=_})(rc)),rc}var AN;function iq(){return AN||(AN=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=P4();Object.defineProperty(e,"baseAssetPath",{enumerable:!0,get:function(){return r.baseAssetPath}});var n=XT();Object.defineProperty(e,"defaultModelFetcher",{enumerable:!0,get:function(){return n.defaultModelFetcher}});var i=YT();Object.defineProperty(e,"FrameProcessor",{enumerable:!0,get:function(){return i.FrameProcessor}});var s=g_();Object.defineProperty(e,"Message",{enumerable:!0,get:function(){return s.Message}});var a=eq();Object.defineProperty(e,"NonRealTimeVAD",{enumerable:!0,get:function(){return a.NonRealTimeVAD}});const c=tq();e.utils={audioFileToArray:c.audioFileToArray,minFramesForTargetMS:c.minFramesForTargetMS,arrayBufferToBase64:c.arrayBufferToBase64,encodeWAV:c.encodeWAV};var l=nq();Object.defineProperty(e,"DEFAULT_MODEL",{enumerable:!0,get:function(){return l.DEFAULT_MODEL}}),Object.defineProperty(e,"MicVAD",{enumerable:!0,get:function(){return l.MicVAD}}),Object.defineProperty(e,"getDefaultRealTimeVADOptions",{enumerable:!0,get:function(){return l.getDefaultRealTimeVADOptions}})})(A1)),A1}var sq=iq();function kx(e,r,n,i){var a,c;try{(c=(a=window.api)==null?void 0:a.logs)==null||c.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)=>kx(e,"debug",r,n),info:(e,r,n)=>kx(e,"info",r,n),warn:(e,r,n)=>kx(e,"warn",r,n),error:(e,r,n)=>kx(e,"error",r,n)},B4=16e3,aq=6,ap=B4*aq,oq=400,lq=B4*oq/1e3,$N=300,NN=2e3,ON=1500,PN=3e3,cq=600,z4=.5,F4=.35,RN=.85,MN=.7;let Gs=null,yl=!1,Cs=!1;const Aj=new Set;function Cx(e){for(const r of Array.from(Aj))try{r(e)}catch(n){gt.warn("speech","workerDeath listener threw",{error:n instanceof Error?n.message:String(n)})}}let P1=0;const IN=2;let Ep=!1,U4=!1;function W4(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}),uq(`error:${r.message||"unknown"}`)})}function Bw(){return Gs||(Gs=new Worker(new URL(""+new URL("whisperWorker-Dbia1OpC.js",import.meta.url).href,import.meta.url),{type:"module"}),W4(Gs),gt.info("speech","worker spawned"),Gs)}let jx=!1;function uq(e){if(!Ep){if(jx){gt.warn("speech","respawnWorker: already in flight, ignoring",{reason:e});return}if(jx=!0,P1+=1,U4=!0,gt.warn("speech","respawnWorker: starting",{reason:e,attempt:P1}),Cx({reason:e,respawned:!1,finalOnly:!0}),P1>IN){if(Ep=!0,gt.error("speech","respawnWorker: limit exceeded, disabling speech",{limit:IN}),Gs)try{Gs.terminate()}catch{}Gs=null,yl=!1,Cs=!1,Cx({reason:"respawn-limit-exceeded",respawned:!1,finalOnly:!0}),jx=!1;return}if(Gs)try{Gs.terminate()}catch{}Gs=null,yl=!1,Cs=!1;try{Gs=new Worker(new URL(""+new URL("whisperWorker-Dbia1OpC.js",import.meta.url).href,import.meta.url),{type:"module"}),W4(Gs),Cs=!0,Gs.postMessage({type:"load"}),gt.info("speech","respawnWorker: new worker spawned, load posted"),Cx({reason:e,respawned:!0,finalOnly:!0})}catch(r){Ep=!0,gt.error("speech","respawnWorker: spawn failed, disabling speech",{error:r instanceof Error?r.message:String(r)}),Cx({reason:"spawn-failed",respawned:!1,finalOnly:!0})}finally{jx=!1}}}function dq(e,r){if(yl||Cs)return;Cs=!0;const n=Bw();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,Cs=!1,gt.info("speech","preloadModel: ready"),n.removeEventListener("message",i))):s.data.type==="progress"?r==null||r(s.data.pct):s.data.type==="error"&&(Cs=!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 fq(){gt.info("speech","resetModel: clearing load flags"),yl=!1,Cs=!1}function JT(){var e;return typeof Worker<"u"&&!!((e=navigator.mediaDevices)!=null&&e.getUserMedia)&&typeof AudioWorkletNode<"u"}function hq(e){const r=Bw();return!yl&&!Cs&&(Cs=!0,r.postMessage({type:"load"})),new Promise((n,i)=>{const s=a=>{var c,l,u;((c=a.data)==null?void 0:c.type)==="result"?(r.removeEventListener("message",s),n((a.data.text??"").trim())):((l=a.data)==null?void 0:l.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,Cs=!1)};r.addEventListener("message",s),r.postMessage({type:"transcribe",audio:e},[e.buffer])})}function pq(e){let r=Bw(),n=!1,i=null,s=null,a=null,c=null,l=null;const u=[],f=new Set;let m=null,h=0,b=!1,w=0,k=!1,S=!1,y=0,x=0,_=0,C=-1,T=$N,E=0,$=null,N="",P="",I=!1,W=0;function F(oe,de){const ve=Math.min(oe.length,de.length);let $e=0;for(;$e<ve&&oe.charCodeAt($e)===de.charCodeAt($e);)$e++;return $e}function U(oe){const de=F(N,oe);return N=oe,de>P.length&&(P=oe.slice(0,de)),P.length>oe.length&&(P=oe),P}const q=()=>(m||(m=new Float32Array(ap)),m),z=()=>{h=0},Y=oe=>{const de=q(),ve=oe.length;if(ve>=ap){de.set(oe.subarray(ve-ap)),h=ap;return}if(h+ve<=ap){de.set(oe,h),h+=ve;return}const $e=h+ve-ap;de.copyWithin(0,$e,h),h-=$e,de.set(oe,h),h+=ve},ee=()=>{$&&(clearTimeout($),$=null)},se=()=>{ee(),b=!1,k=!1,S=!1,T=$N,N="",P="",I=!1,W=0,z()},ue=()=>{if(n||!b||S||k||$)return;if(h<lq){$=setTimeout(()=>{$=null,ue()},T);return}const oe=performance.now()-y;if(oe<T&&y!==0){$=setTimeout(()=>{$=null,ue()},T-oe);return}if(U4||Ep||e.partialsEnabled&&!e.partialsEnabled())return;const de=q(),ve=new Float32Array(h);ve.set(de.subarray(0,h)),x+=1,_=x,k=!0,E=performance.now(),y=E,r.postMessage({type:"transcribe-partial",audio:ve,seq:x},[ve.buffer])},X=oe=>oe.length===0?Promise.resolve():Ep?(gt.warn("speech","transcribeAudio: speech disabled (worker respawn limit hit)"),n||e.onError("Speech recognition disabled — please reload the app."),Promise.resolve()):new Promise(de=>{u.push(de),x+=1;const ve=x;C=ve,r.postMessage({type:"transcribe",audio:oe,seq:ve},[oe.buffer])}),Q=oe=>{const de=X(oe);return f.add(de),de.finally(()=>{f.delete(de)}),de},Z=oe=>{var de,ve,$e,we,ne;if(oe.data.type==="result"){const ce=oe.data.text,ge=oe.data.seq??0;ge&&ge<C&&gt.warn("speech","result: seq below latestFinalSeq (delivering anyway)",{seq:ge,latestFinalSeq:C}),!n&&ce&&e.onFinal(ce),(de=u.shift())==null||de()}else if(oe.data.type==="partial"){const ce=oe.data.seq??0,ge=oe.data.text??"",Ae=performance.now()-E;k=!1,Ae>=PN?(S=!0,gt.warn("speech","partials.disabled.budget",{elapsedMs:Math.round(Ae),seq:ce})):Ae>=ON&&(T=Math.min(T*2,NN),gt.warn("speech","partials.slowdown",{elapsedMs:Math.round(Ae),newIntervalMs:T,seq:ce})),I||(I=!0,Ae>cq&&T<500&&(T=500,gt.info("speech","partials.probe.slow_host",{elapsedMs:Math.round(Ae),newIntervalMs:500})));const Te=ce!==_||ce<=C;if(!n&&!Te&&ge){const nt=U(ge);nt&&((ve=e.onPartial)==null||ve.call(e,nt),W===0&&(W=performance.now(),gt.info("speech","partial.first",{msSinceSpeechStart:Math.round(W-w)})))}ue()}else if(oe.data.type==="partial-error"){const ce=performance.now()-E;k=!1,ce>=PN?(S=!0,gt.warn("speech","partials.disabled.budget (after error)",{elapsedMs:Math.round(ce),seq:oe.data.seq})):ce>=ON&&(T=Math.min(T*2,NN),gt.warn("speech","partials.slowdown (after error)",{elapsedMs:Math.round(ce),newIntervalMs:T,seq:oe.data.seq})),gt.warn("speech","partial encode failed",{error:oe.data.error,seq:oe.data.seq}),ue()}else oe.data.type==="error"?(n||e.onError(oe.data.error),($e=u.shift())==null||$e()):oe.data.type==="status"?(n||(we=e.onModelStatus)==null||we.call(e,oe.data.status,oe.data.message),oe.data.status==="ready"&&(yl=!0,Cs=!1)):oe.data.type==="progress"&&(n||(ne=e.onProgress)==null||ne.call(e,oe.data.pct))};r.addEventListener("message",Z);const ae=oe=>{var de,ve;if(!n){for(gt.warn("speech","createRecognition: worker death event",oe),(de=e.onStatusChange)==null||de.call(e,"restarting");u.length;)(ve=u.shift())==null||ve();if(f.clear(),ee(),k=!1,oe.respawned){try{r.removeEventListener("message",Z)}catch{}r=Bw(),r.addEventListener("message",Z)}}};return Aj.add(ae),{start:async()=>{if(!n){if(Ep){e.onError("Speech recognition disabled — please reload the app.");return}!yl&&!Cs&&(Cs=!0,gt.info("speech","createRecognition.start: triggering model load"),r.postMessage({type:"load"})),gt.info("speech","createRecognition.start: initializing VAD",{modelReady:yl,modelLoading:Cs});try{const oe=new URL("vad/",document.baseURI).href,de=e.inputDeviceId||null,ve={channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0};de&&(ve.deviceId={exact:de}),gt.info("speech","getUserMedia",{hasDeviceId:!!de,deviceIdPrefix:de?de.slice(0,8):null});const $e=await navigator.mediaDevices.getUserMedia({audio:ve});s=$e,a=new AudioContext;for(const we of $e.getAudioTracks())we.addEventListener("ended",()=>{n||(gt.warn("speech","mic track ended (permission revoked or device removed)"),e.onError("Microphone disconnected or permission revoked"))});try{l=a.createMediaStreamSource(s),c=a.createAnalyser(),c.fftSize=2048,c.smoothingTimeConstant=.3,l.connect(c)}catch(we){gt.warn("speech","analyser init failed",{error:we instanceof Error?we.message:String(we)}),l=null,c=null}i=await sq.MicVAD.new({audioContext:a,getStream:async()=>$e,resumeStream:async()=>$e,pauseStream:async()=>{},baseAssetPath:oe,onnxWASMBasePath:oe,model:"v5",positiveSpeechThreshold:z4,negativeSpeechThreshold:F4,minSpeechMs:300,redemptionMs:1500,preSpeechPadMs:300,submitUserSpeechOnPause:!0,onFrameProcessed:(we,ne)=>{var ce;n||((ce=e.onFrame)==null||ce.call(e,we),b&&(Y(ne),ue()))},onSpeechStart:()=>{var we;n||(se(),b=!0,w=performance.now(),(we=e.onSpeechStart)==null||we.call(e))},onSpeechEnd:we=>{var ne;n||((ne=e.onStatusChange)==null||ne.call(e,"transcribing"),se(),Q(we))},onVADMisfire:()=>{var we,ne;n||((we=e.onStatusChange)==null||we.call(e,"idle"),se(),(ne=e.onMisfire)==null||ne.call(e))}}),i.start()}catch(oe){const de=oe instanceof Error?oe.message:"Microphone access denied",ve=oe instanceof Error?oe.stack:"";if(gt.error("speech","createRecognition.start: VAD init failed",{error:de,stack:ve}),c){try{c.disconnect()}catch{}c=null}if(l){try{l.disconnect()}catch{}l=null}if(s){try{s.getTracks().forEach($e=>$e.stop())}catch{}s=null}if(a){try{await a.close()}catch{}a=null}e.onError(de)}}},stop:async()=>{if(i)try{await i.pause()}catch{}for(se();f.size>0;)await Promise.all(Array.from(f));if(i){try{await i.destroy()}catch{}i=null}if(c){try{c.disconnect()}catch{}c=null}if(l){try{l.disconnect()}catch{}l=null}if(s){try{s.getTracks().forEach(oe=>oe.stop())}catch{}s=null}if(a){try{await a.close()}catch{}a=null}},setVadThresholds:(oe,de)=>{if(i)try{i.setOptions({positiveSpeechThreshold:oe,negativeSpeechThreshold:de})}catch(ve){gt.warn("speech","setVadThresholds failed",{error:ve instanceof Error?ve.message:String(ve)})}},getAnalyser:()=>c,destroy:()=>{if(n=!0,se(),i){try{i.destroy()}catch{}i=null}if(c){try{c.disconnect()}catch{}c=null}if(l){try{l.disconnect()}catch{}l=null}if(a){try{a.close()}catch{}a=null}if(s){try{s.getTracks().forEach(oe=>oe.stop())}catch{}s=null}Aj.delete(ae),r.removeEventListener("message",Z)}}}let ny=null;const $j=new Set,Nj=new Set;function mq(){for(const e of $j)try{e()}catch{}}function Oj(){for(const e of Nj)try{e()}catch{}}function gq(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 vq(e){if(!window.speechSynthesis)return;const r=gq(e);if(!r)return;const n=new SpeechSynthesisUtterance(r);n.rate=1,n.pitch=1,n.onstart=()=>{ny=performance.now(),mq()},n.onend=()=>{!window.speechSynthesis.speaking&&!window.speechSynthesis.pending&&(ny=null,Oj())},n.onerror=i=>{i.error!=="canceled"&&!window.speechSynthesis.speaking&&!window.speechSynthesis.pending&&(ny=null,Oj())},window.speechSynthesis.speak(n)}function q4(){window.speechSynthesis&&(window.speechSynthesis.cancel(),ny=null,Oj())}function H4(){var e;return((e=window.speechSynthesis)==null?void 0:e.speaking)??!1}function yq(){return ny}function bq(e){return $j.add(e),()=>{$j.delete(e)}}function xq(e){return Nj.add(e),()=>{Nj.delete(e)}}function wq(e){H4()&&(e.setVadThresholds(RN,MN),gt.info("voice","tts.duck.on",{reason:"already-speaking-on-attach"}));const r=bq(()=>{e.setVadThresholds(RN,MN),gt.info("voice","tts.duck.on")}),n=xq(()=>{e.setVadThresholds(z4,F4),gt.info("voice","tts.duck.off")});return()=>{r(),n()}}const _q=[{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 Sq(e){const r=e.trim();return _q.find(n=>n.match.test(r))??null}const kq=4e4;let Gd=null;function Tp(){Gd&&clearTimeout(Gd),Gd=setTimeout(()=>{Gd=null,Dt.getState().stopRecording()},kq)}function Ex(){Gd&&(clearTimeout(Gd),Gd=null)}let Cu=null,wu=null;const Cq=.04,jq=.3;let zw=0,Pj=0;function Eq(e){wu!==null&&cancelAnimationFrame(wu);const r=()=>{if(Cu===null||Dt.getState().submitCountdownStartAt===null){wu=null;return}const n=performance.now();if(n-Pj<200&&zw>jq){const s=n-e;gt.info("voice","submit.preempted_by_voice",{reason:"vad",prob:zw.toFixed(2),msIntoCountdown:Math.round(s)}),mu(),Tp();return}const i=V4();if(i){const s=new Uint8Array(i.fftSize);i.getByteTimeDomainData(s);let a=0;for(let l=0;l<s.length;l++){const u=(s[l]-128)/128;a+=u*u}const c=Math.sqrt(a/s.length);if(c>Cq){const l=n-e;gt.info("voice","submit.preempted_by_voice",{reason:"rms",rms:c.toFixed(3),msIntoCountdown:Math.round(l)}),mu(),Tp();return}}wu=requestAnimationFrame(r)};wu=requestAnimationFrame(r)}function Tq(e){Cu&&clearTimeout(Cu);const r=Dt.getState().submitDelayMs,n=performance.now();Dt.setState({submitCountdownStartAt:n}),Cu=setTimeout(()=>{Cu=null,Dt.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)})}Tp()},r),Eq(n)}function mu(){wu!==null&&(cancelAnimationFrame(wu),wu=null),Cu&&(clearTimeout(Cu),Cu=null),Dt.getState().submitCountdownStartAt!==null&&Dt.setState({submitCountdownStartAt:null})}let Ti=null,as=null;function V4(){var e;return((e=Ti==null?void 0:Ti.getAnalyser)==null?void 0:e.call(Ti))??null}const Tx=1e4;let iy=null;function Ax(){iy&&(clearTimeout(iy),iy=null)}let kw=null,Cw=null;function $x(){kw=null,Cw&&(Cw(),Cw=null)}const Aq=1500,$q=9e4;let Nx=0,jw=null,Rj=-1;function Ox(){jw&&(clearTimeout(jw),jw=null,Rj=-1)}const Nq=new Set(["you","You","Thank you.","Thanks for watching.","Thanks for watching!","Thank you for watching.","Thank you for watching!",".","Bye.","Bye!"]),Dt=jn((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=++Nx,i=()=>{n===Nx&&(Ox(),Rj=n,jw=setTimeout(()=>{Rj===n&&r().modelStatus==="loading"&&(gt.warn("voice","mic.gate.timeout: no progress within 90s"),e({modelStatus:"error",error:"Model load timed out",errorKind:"timeout"}))},$q))};i(),dq((s,a)=>{n===Nx&&(s==="ready"?(Ox(),gt.info("voice","modelStatus -> ready"),e({modelStatus:"ready",loadingProgress:100,errorKind:null})):s==="error"?(Ox(),gt.error("voice","modelStatus -> error",{msg:a}),e({modelStatus:"error",error:a,errorKind:"load"})):(i(),e({modelStatus:"loading"})))},s=>{n===Nx&&(i(),e({loadingProgress:Math.round(s)}))})},resetAndRetryModel:()=>{gt.info("voice","mic.gate.retry"),Ox(),fq(),e({modelStatus:"idle",error:null,errorKind:null,loadingProgress:0}),r().initModel()},startRecording:n=>{if(r().isRecording)return;if(Ti){gt.warn("voice","startRecording: prior handle still draining, ignoring");return}if(!JT()){e({error:"Microphone or Web Worker not available",errorKind:"recording"});return}const i=s=>{try{const a=pq({inputDeviceId:s,onStatusChange:c=>{e(c==="transcribing"?{statusPill:"transcribing"}:c==="restarting"?{statusPill:"restarting"}:{statusPill:"idle"})},onPartial:c=>{r().partialsEnabled&&e({lastPartial:c})},partialsEnabled:()=>r().partialsEnabled,onFrame:c=>{zw=c.isSpeech,Pj=performance.now()},onSpeechStart:()=>{if(e({statusPill:"listening",lastPartial:""}),Ex(),mu(),H4()){const l=yq(),u=l!==null?performance.now()-l:null;q4(),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"}),Tp();const c=r().lastBargeInAt;c!==null&&performance.now()-c<600&&gt.warn("voice","barge-in.misfire",{tabId:n,sinceBargeInMs:Math.round(performance.now()-c)})},onFinal:c=>{Tp();const l=c.trim();if(!l||Nq.has(l)){e({lastTranscript:"",lastPartial:"",statusPill:"idle"});return}const u=Sq(l);if(u){gt.info("voice","voice-command",{tabId:n,label:u.label,transcript:l}),window.api.pty.write({tabId:n,data:u.data}),e({lastTranscript:"",lastPartial:"",statusPill:"idle"}),mu();const m=window;m.__transcripts&&(m.__transcripts.push({tabId:n,text:l}),m.__transcripts.length>500&&m.__transcripts.shift());return}window.api.pty.write({tabId:n,data:l}),e({lastTranscript:"",lastPartial:"",statusPill:"idle"}),r().autoSubmit&&Tq(n);const f=window;f.__transcripts&&(f.__transcripts.push({tabId:n,text:l}),f.__transcripts.length>500&&f.__transcripts.shift())},onError:c=>{gt.error("voice","recognition error",{err:c}),mu(),e({error:c,errorKind:"recording",isRecording:!1,lastPartial:"",statusPill:"idle"}),as==null||as(),as=null,Ex(),Ti==null||Ti.destroy(),Ti=null,Ze.error(`Microphone error: ${c}`)},onModelStatus:c=>{c==="ready"?e({modelStatus:"ready",loadingProgress:100}):c==="loading"&&e({modelStatus:"loading"})},onProgress:c=>e({loadingProgress:Math.round(c)})});Ti=a,e({isRecording:!0,error:null,lastTranscript:"",lastPartial:"",statusPill:"listening"}),Tp(),a.start().then(()=>{Ti===a&&(as==null||as(),as=wq(a))}).catch(c=>{const l=c instanceof Error?c.message:String(c);gt.error("voice","handle.start() failed",{error:l}),Ze.error(`Could not start mic: ${l}`)})}catch(a){e({error:a instanceof Error?a.message:"Failed to start recording",errorKind:"recording"})}};Promise.resolve().then(()=>{var s,a,c;return((c=(a=(s=window.api)==null?void 0:s.voice)==null?void 0:a.getDevicePref)==null?void 0:c.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=Ti;n&&(Ex(),mu(),zw=0,Pj=0,as==null||as(),as=null,e({isRecording:!1,lastTranscript:"",lastPartial:"",statusPill:"idle"}),n.stop().finally(()=>{n.destroy(),Ti===n&&(Ti=null),r().hotkeyState==="stopping"&&(Ax(),e({hotkeyState:"idle"}))}))},restartWithDevice:async()=>{if(!r().isRecording)return;const n=Ti;if(!n)return;Ex(),as==null||as(),as=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(),Ti===n&&(Ti=null);const{useSessions:i}=await ab(async()=>{const{useSessions:a}=await Promise.resolve().then(()=>OW);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:()=>mu(),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"&&gt.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 c=r(),{canRecord:l,reason:u}=Mj(c);if(n==="down"){if(u==="error"||u==="load-timeout"){c.resetAndRetryModel(),gt.info("voice-hotkey","down.retry",{source:i,reason:u});return}if(!l&&u!=="loading"){gt.warn("voice-hotkey","miss-model-loading",{modelStatus:c.modelStatus,reason:u});return}if(c.hotkeyState==="recording"||c.isRecording){(s==="toggle"||i==="global")&&(e({hotkeyState:"stopping"}),Ax(),iy=setTimeout(()=>{r().hotkeyState==="stopping"&&(gt.warn("voice-hotkey","drain-timeout",{durationMs:Tx}),e({hotkeyState:"aborted"}),setTimeout(()=>{r().hotkeyState==="aborted"&&e({hotkeyState:"idle"})},0))},Tx),c.stopRecording());return}if(u==="loading"){c.hotkeyState!=="armed"&&(e({hotkeyState:"armed"}),gt.info("voice-hotkey","armed",{source:i,modelStatus:c.modelStatus})),$x(),kw={tabId:a,source:i,mode:s},Cw=Dt.subscribe((f,m)=>{if(kw&&f.modelStatus==="ready"&&m.modelStatus!=="ready"&&f.hotkeyState==="armed"){const h=kw;if($x(),!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"}),Dt.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}),c.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(c.hotkeyState==="armed"){$x(),gt.info("voice-hotkey","miss-model-loading-armed-up"),e({hotkeyState:"idle"});return}c.hotkeyState==="recording"&&(e({hotkeyState:"stopping"}),Ax(),iy=setTimeout(()=>{r().hotkeyState==="stopping"&&(gt.warn("voice-hotkey","drain-timeout",{durationMs:Tx}),e({hotkeyState:"aborted"}),setTimeout(()=>{r().hotkeyState==="aborted"&&e({hotkeyState:"idle"})},0))},Tx),c.stopRecording())}},destroyHotkey:()=>{const n=r();if($x(),mu(),n.hotkeyState==="recording"){gt.warn("voice-hotkey","destroyed-mid-recording"),e({hotkeyState:"destroyed"});try{n.stopRecording()}catch{}}else(n.hotkeyState==="armed"||n.hotkeyState==="stopping")&&(Ax(),e({hotkeyState:"destroyed"}))}})),Oq=e=>({isRecording:e.isRecording,statusPill:e.statusPill,lastPartial:e.lastPartial,lastTranscript:e.lastTranscript,submitCountdownStartAt:e.submitCountdownStartAt}),Mj=e=>JT()?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=Dt,e.__transcripts=[]}function ZT(e,r,n){return new Promise((i,s)=>{const a=setTimeout(()=>s(new Error(`${n} timed out after ${r}ms`)),r);e.then(c=>{clearTimeout(a),i(c)},c=>{clearTimeout(a),s(c)})})}const Pq=5e3,Ou=jn(()=>({snapshot:null,loaded:!1}));let DN=!1,LN=!1,dv;async function Rq(){var e;if(!DN){DN=!0;try{const r=await ZT(window.api.schedule.state(),Pq,"schedule.state");Ou.setState({snapshot:r,loaded:!0}),dv=((e=r.paused)==null?void 0:e.reason)??null}catch(r){if(!LN){LN=!0;const n=r instanceof Error?r.message:String(r);Ze.error(`Scheduler state hydrate failed: ${n}`)}dv=null}window.api.schedule.onState(r=>{var i;const n=((i=r.paused)==null?void 0:i.reason)??null;dv!==void 0&&n!==dv&&(n==="auth"?Ze.error("Scheduler paused: Claude sign-in expired or invalid. Restart the app or re-run `claude login`, then Resume."):n==="network"&&Ze.error("Scheduler paused: billing endpoint unreachable. Will auto-resume in 30 minutes.")),dv=n,Ou.setState({snapshot:r,loaded:!0})})}}const Mq=6e4,Iq=5e3,Ap=jn(()=>({data:null,refreshing:!1}));let BN=!1,Ew=null,zN=null,FN=!1;async function QT(){Ap.setState({refreshing:!0});let e=Mq;try{const r=await ZT(window.api.billing.fetch(),Iq,"billing.fetch");Ap.setState({data:r,refreshing:!1}),r.kind==="transient"?e=zN==="transient"?3e4:5e3:(r.kind==="auth"||r.kind==="meter_rate_limited")&&(e=3e4),zN=r.kind}catch(r){if(Ap.setState({refreshing:!1}),!FN){FN=!0;const n=r instanceof Error?r.message:String(r);Ze.warn(`Billing usage fetch failed: ${n}`)}}Ew=setTimeout(QT,e)}function Dq(){BN||(BN=!0,QT())}function v_(e){return e?e.kind==="ok"||e.kind==="ok-stale"?e.data:(e.kind==="auth"||e.kind==="meter_rate_limited")&&e.cached?e.cached:null:null}function Fw(){Ew!==null&&(clearTimeout(Ew),Ew=null),QT()}function pr({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 o.jsxs("svg",{...s,children:[o.jsx("path",{d:"M4 11l8-7 8 7"}),o.jsx("path",{d:"M6 10v9h12v-9"}),o.jsx("path",{d:"M10 19v-5h4v5"})]});case"terminal":return o.jsxs("svg",{...s,children:[o.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),o.jsx("path",{d:"M7 10l3 2-3 2"}),o.jsx("path",{d:"M13 14h4"})]});case"agents":case"subagents":return o.jsxs("svg",{...s,children:[o.jsx("circle",{cx:"7",cy:"9",r:"2.5"}),o.jsx("circle",{cx:"17",cy:"9",r:"2.5"}),o.jsx("circle",{cx:"12",cy:"17",r:"2.5"}),o.jsx("path",{d:"M8.6 11l2.8 4M15.4 11l-2.8 4M9.5 9h5"})]});case"skills":return o.jsx("svg",{...s,children:o.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 o.jsxs("svg",{...s,children:[o.jsx("circle",{cx:"12",cy:"12",r:"8"}),o.jsx("path",{d:"M12 7v5l3 2"}),o.jsx("path",{d:"M4 6l2 2"})]});case"usage":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M4 19V8M10 19V5M16 19v-7M22 19H2"})});case"hive":return o.jsxs("svg",{...s,children:[o.jsx("path",{d:"M8 4h8l4 7-4 7H8l-4-7z"}),o.jsx("circle",{cx:"12",cy:"11",r:"2.5"})]});case"plugins":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M9 3v4M15 3v4M5 7h14v6a5 5 0 01-5 5h-4a5 5 0 01-5-5V7z"})});case"mcp":return o.jsxs("svg",{...s,children:[o.jsx("rect",{x:"3",y:"4",width:"18",height:"6",rx:"1.5"}),o.jsx("rect",{x:"3",y:"14",width:"18",height:"6",rx:"1.5"}),o.jsx("circle",{cx:"6.5",cy:"7",r:".5",fill:"currentColor"}),o.jsx("circle",{cx:"6.5",cy:"17",r:".5",fill:"currentColor"})]});case"hooks":return o.jsxs("svg",{...s,children:[o.jsx("path",{d:"M12 4v9a3 3 0 003 3h5"}),o.jsx("path",{d:"M9 17l3 3 3-3"})]});case"keys":return o.jsxs("svg",{...s,children:[o.jsx("circle",{cx:"8",cy:"12",r:"4"}),o.jsx("path",{d:"M12 12h9M17 12v3M20 12v2"})]});case"plans":return o.jsxs("svg",{...s,children:[o.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),o.jsx("path",{d:"M8 9h8M8 13h8M8 17h5"})]});case"tasks":return o.jsxs("svg",{...s,children:[o.jsx("rect",{x:"3",y:"4",width:"7",height:"7",rx:"1.5"}),o.jsx("rect",{x:"3",y:"13",width:"7",height:"7",rx:"1.5"}),o.jsx("path",{d:"M14 6h7M14 10h5M14 15h7M14 19h5"})]});case"projects":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M3 7l3-3h4l2 2h9v13H3z"})});case"memory":case"agent-memory":return o.jsxs("svg",{...s,children:[o.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"}),o.jsx("path",{d:"M9 9v6M12 6v12M15 9v6"})]});case"search":case"global-search":return o.jsxs("svg",{...s,children:[o.jsx("circle",{cx:"11",cy:"11",r:"6"}),o.jsx("path",{d:"M16 16l4 4"})]});case"chevron":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M9 6l6 6-6 6"})});case"caret":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M6 9l6 6 6-6"})});case"dot":return o.jsx("svg",{...s,children:o.jsx("circle",{cx:"12",cy:"12",r:"3",fill:"currentColor",stroke:"none"})});case"plus":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M12 5v14M5 12h14"})});case"folder":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M3 7l3-3h4l2 2h9v13H3z"})});case"file":return o.jsxs("svg",{...s,children:[o.jsx("path",{d:"M7 3h7l4 4v14H7z"}),o.jsx("path",{d:"M14 3v4h4"})]});case"play":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M8 5l11 7-11 7z",fill:"currentColor",stroke:"none"})});case"pause":return o.jsxs("svg",{...s,children:[o.jsx("rect",{x:"7",y:"5",width:"3.5",height:"14",fill:"currentColor",stroke:"none",rx:"0.5"}),o.jsx("rect",{x:"13.5",y:"5",width:"3.5",height:"14",fill:"currentColor",stroke:"none",rx:"0.5"})]});case"sparkle":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M12 4v6M12 14v6M4 12h6M14 12h6"})});case"book":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M4 5a2 2 0 012-2h6v18H6a2 2 0 01-2-2zM12 3h6a2 2 0 012 2v14H12z"})});case"compass":return o.jsxs("svg",{...s,children:[o.jsx("circle",{cx:"12",cy:"12",r:"8"}),o.jsx("path",{d:"M15 9l-2 5-5 2 2-5z",fill:"currentColor",stroke:"none"})]});case"scheduler":return o.jsxs("svg",{...s,children:[o.jsx("rect",{x:"3",y:"5",width:"18",height:"15",rx:"2"}),o.jsx("path",{d:"M3 10h18M8 3v4M16 3v4"}),o.jsx("path",{d:"M8 14l2 2 4-4"})]});case"settings":return o.jsxs("svg",{...s,children:[o.jsx("circle",{cx:"12",cy:"12",r:"3"}),o.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 o.jsxs("svg",{...s,children:[o.jsx("rect",{x:"9",y:"3",width:"6",height:"12",rx:"3"}),o.jsx("path",{d:"M5 11a7 7 0 0014 0M12 18v3M9 21h6"})]});case"clock":return o.jsxs("svg",{...s,children:[o.jsx("circle",{cx:"12",cy:"12",r:"8"}),o.jsx("path",{d:"M12 7v5l3 2"})]});case"leaf":return o.jsxs("svg",{...s,children:[o.jsx("path",{d:"M20 4c-9 0-14 5-14 11 0 3 2 5 5 5 6 0 9-5 9-14z"}),o.jsx("path",{d:"M6 20c2-5 5-8 11-11"})]});case"orchestrator":return o.jsxs("svg",{...s,children:[o.jsx("circle",{cx:"12",cy:"6",r:"2.5"}),o.jsx("circle",{cx:"5",cy:"17",r:"2.5"}),o.jsx("circle",{cx:"12",cy:"17",r:"2.5"}),o.jsx("circle",{cx:"19",cy:"17",r:"2.5"}),o.jsx("path",{d:"M12 8.5v6M12 14.5l-7 0M12 14.5l7 0"})]});case"race":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M5 4v16M5 5h7l-1 3h7v6h-7l-1 3H5"})});case"background":return o.jsxs("svg",{...s,children:[o.jsx("path",{d:"M3 4h18v4H3zM3 10h18v4H3zM3 16h18v4H3z"}),o.jsx("circle",{cx:"6",cy:"6",r:".75",fill:"currentColor",stroke:"none"}),o.jsx("circle",{cx:"6",cy:"12",r:".75",fill:"currentColor",stroke:"none"}),o.jsx("circle",{cx:"6",cy:"18",r:".75",fill:"currentColor",stroke:"none"})]});case"repoviz":return o.jsxs("svg",{...s,children:[o.jsx("circle",{cx:"6",cy:"12",r:"3"}),o.jsx("circle",{cx:"18",cy:"6",r:"3"}),o.jsx("circle",{cx:"18",cy:"18",r:"3"}),o.jsx("path",{d:"M8.5 10.5L15.5 7.5M8.5 13.5L15.5 16.5"})]});case"system-prompt":return o.jsxs("svg",{...s,children:[o.jsx("rect",{x:"4",y:"4",width:"16",height:"14",rx:"2"}),o.jsx("path",{d:"M8 10h8M8 14h5M9 18l-2 3M15 18l2 3"})]});case"permissions":return o.jsxs("svg",{...s,children:[o.jsx("rect",{x:"5",y:"11",width:"14",height:"9",rx:"2"}),o.jsx("path",{d:"M8 11V8a4 4 0 018 0v3"}),o.jsx("circle",{cx:"12",cy:"15.5",r:"1.2",fill:"currentColor",stroke:"none"})]});case"tool":return o.jsx("svg",{...s,children:o.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 o.jsxs("svg",{...s,children:[o.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),o.jsx("path",{d:"M3 9h18M7 13h10M7 16h6"})]});case"remote":return o.jsxs("svg",{...s,children:[o.jsx("path",{d:"M5 12.5a7 7 0 0114 0M1.5 9a11 11 0 0121 0M8.5 16a3.5 3.5 0 017 0"}),o.jsx("circle",{cx:"12",cy:"20",r:"1",fill:"currentColor",stroke:"none"})]});case"wifi":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M5 12.5a10 10 0 0114 0M8 15.5a6 6 0 018 0M12 18.5h.01"})});case"shield":return o.jsxs("svg",{...s,children:[o.jsx("path",{d:"M12 3l7 3v5c0 4.5-3 8-7 10-4-2-7-5.5-7-10V6z"}),o.jsx("path",{d:"M9 12l2 2 4-4"})]});case"link":return o.jsxs("svg",{...s,children:[o.jsx("path",{d:"M9 12h6"}),o.jsx("path",{d:"M10 8H7a4 4 0 000 8h3M14 8h3a4 4 0 010 8h-3"})]});case"copy":return o.jsxs("svg",{...s,children:[o.jsx("rect",{x:"9",y:"9",width:"11",height:"11",rx:"2"}),o.jsx("path",{d:"M5 15V5a2 2 0 012-2h8"})]});case"check":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M5 12l5 5 9-10"})});case"x":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M6 6l12 12M18 6L6 18"})});case"send":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M4 11l17-7-7 17-3-7z"})});case"browser":return o.jsxs("svg",{...s,children:[o.jsx("circle",{cx:"12",cy:"12",r:"8"}),o.jsx("ellipse",{cx:"12",cy:"12",rx:"3.2",ry:"8"}),o.jsx("path",{d:"M4 12h16"})]});case"target":return o.jsxs("svg",{...s,children:[o.jsx("circle",{cx:"12",cy:"12",r:"8"}),o.jsx("circle",{cx:"12",cy:"12",r:"3.5"}),o.jsx("path",{d:"M12 2v3M12 19v3M2 12h3M19 12h3"})]});case"record":return o.jsx("svg",{...s,children:o.jsx("circle",{cx:"12",cy:"12",r:"7",fill:"currentColor",stroke:"none"})});case"eye":return o.jsxs("svg",{...s,children:[o.jsx("path",{d:"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7z"}),o.jsx("circle",{cx:"12",cy:"12",r:"3"})]});case"camera":return o.jsxs("svg",{...s,children:[o.jsx("path",{d:"M4 8h3l2-2h6l2 2h3v11H4z"}),o.jsx("circle",{cx:"12",cy:"13.5",r:"3.5"})]});case"arrowleft":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M19 12H5M11 6l-6 6 6 6"})});case"arrowright":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M5 12h14M13 6l6 6-6 6"})});case"reload":return o.jsxs("svg",{...s,children:[o.jsx("path",{d:"M4 12a8 8 0 0114-5.3M20 12a8 8 0 01-14 5.3"}),o.jsx("path",{d:"M18 3v4h-4M6 21v-4h4"})]});case"lock":return o.jsxs("svg",{...s,children:[o.jsx("rect",{x:"5",y:"11",width:"14",height:"9",rx:"2"}),o.jsx("path",{d:"M8 11V8a4 4 0 018 0v3"})]});case"stop":return o.jsx("svg",{...s,children:o.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1.5",fill:"currentColor",stroke:"none"})});case"star":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M12 3l2.6 5.6 6.1.6-4.6 4.1 1.3 6-5.4-3.2-5.4 3.2 1.3-6-4.6-4.1 6.1-.6z"})});case"minus":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M5 12h14"})});default:return null}}function Lq(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 UN=e=>Symbol.iterator in e,WN=e=>"entries"in e,qN=(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},Bq=(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 zq(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:UN(e)&&UN(r)?WN(e)&&WN(r)?qN(e,r):Bq(e,r):qN({entries:()=>Object.entries(e)},{entries:()=>Object.entries(r)})}function G4(e){const r=He.useRef(void 0);return n=>{const i=e(n);return zq(r.current,i)?r.current:r.current=i}}let HN=0;const Fq=1e3;function Uq(e){const r=performance.now();r-HN<Fq||(HN=r,gt.debug("voice","mic.gate.click_rejected",{reason:e}))}function K4(){const e=Dt(f=>f.isRecording),r=Dt(f=>f.error),n=Dt(f=>f.loadingProgress),i=Dt(G4(Mj)),s=()=>{const f=Dt.getState(),{canRecord:m,reason:h}=Mj(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 Uq(h);const b=kt.getState().activeTabId;b&&f.startRecording(b)},a=Lq(i.reason,{loadingPct:n,errorMessage:r,isRecording:e}),c=i.reason==="unsupported",l=!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 o.jsx("button",{onClick:s,disabled:c,"aria-disabled":l,"aria-label":a,title:a,"data-testid":"mic-button","data-state":i.reason,className:`p-1.5 rounded transition-colors ${u}`,children:o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("rect",{x:"9",y:"1",width:"6",height:"12",rx:"3"}),o.jsx("path",{d:"M5 10a7 7 0 0 0 14 0"}),o.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"}),o.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"})]})})}function Wq(){const e=Dt(n=>n.ttsEnabled),r=Dt(n=>n.toggleTTS);return o.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:[o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),e?o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),o.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]}):o.jsxs(o.Fragment,{children:[o.jsx("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),o.jsx("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]})]}),o.jsx("span",{className:"text-[10px] font-medium tracking-wide",children:"TTS"})]})}function qq(e){if(!e||e==="—"||e==="unknown")return e;const r=/\[(\dm)\]/.exec(e),n=/(opus|sonnet|haiku)[-_](\d+)[-_.]?(\d+)?/i.exec(e);if(!n)return e;const i=n[1].charAt(0).toUpperCase()+n[1].slice(1).toLowerCase(),s=n[3]?`${n[2]}.${n[3]}`:n[2];return r?`${i} ${s} ${r[1]}`:`${i} ${s}`}const Px=new Map,Hq=3e4;function X4(e){const[r,n]=D.useState(()=>{var i;return e?((i=Px.get(e))==null?void 0:i.value)??null:null});return D.useEffect(()=>{if(!e){n(null);return}let i=!1;return(async()=>{const a=Px.get(e);if(a&&Date.now()-a.ts<Hq){i||n(a.value);return}try{const c=await window.api.app.gitBranch(e);if(i)return;Px.set(e,{value:c,ts:Date.now()}),n(c)}catch{if(i)return;Px.set(e,{value:null,ts:Date.now()}),n(null)}})(),()=>{i=!0}},[e]),r}const y_=[{key:"overview",group:"Workspace",label:"Home",icon:"home",hint:"Today's sessions + the 5-hour window"},{key:"terminal",group:"Workspace",label:"Terminal",icon:"terminal",hint:"Live Claude Code, in-app"},{key:"browser",group:"Workspace",label:"Browser",icon:"browser",hint:"Embedded dev browser — capture DOM, record click-sequences"},{key:"projects",group:"Workspace",label:"File Explorer",icon:"projects",hint:"Browse files + edit, per project"},{key:"subagents",group:"Workspace",label:"Subagents",icon:"hive",liveKind:"subagents",hint:"Fan out work: Hive · Orchestrate · Race · Boss"},{key:"scheduler",group:"Workspace",label:"Scheduler",icon:"scheduler",liveKind:"scheduler",hint:"Author PRDs + run them as claude -p jobs"},{key:"history",group:"Workspace",label:"History",icon:"history",hint:"Every session, ever — resumable"},{key:"usage",group:"Workspace",label:"Usage",icon:"usage",hint:"Tokens, cost, sessions per day"},{key:"skills",group:"Configure",label:"Skills",icon:"skills",hint:"Reusable instructions Claude loads"},{key:"plugins",group:"Configure",label:"Plugins",icon:"plugins",hint:"Extensions for Claude Code"},{key:"mcp",group:"Configure",label:"MCP Servers",icon:"mcp",hint:"External tools and integrations"},{key:"hooks",group:"Configure",label:"Hooks",icon:"hooks",hint:"Run scripts on session events"},{key:"keybindings",group:"Configure",label:"Keybindings",icon:"keys",hint:"Shortcuts you can override"},{key:"memory",group:"Configure",label:"Memory",icon:"memory",hint:"Workspace memory store"},{key:"system-prompt",group:"Configure",label:"System Prompt",icon:"system-prompt",hint:"Personality and behavior"},{key:"permissions",group:"Configure",label:"Permissions",icon:"permissions",hint:"Allow / deny rules"},{key:"settings",group:"Configure",label:"Settings",icon:"settings",hint:"Theme, voice, billing window"},{key:"remote",group:"Configure",label:"Remote",icon:"remote",hint:"Web remote control — disabled by default"},{key:"voice",group:"Tools",label:"Voice",icon:"mic",hint:"Whisper transcription + push-to-talk"},{key:"repoviz",group:"Tools",label:"Repo Viz",icon:"repoviz",hint:"Language + directory map"},{key:"search",group:"Tools",label:"Search",icon:"global-search",hint:"⌘P file · ⌘⇧F content"}],Vq=Object.fromEntries(y_.map(e=>[e.key,e.group])),VN=y_.filter(e=>e.group==="Workspace"),GN=y_.filter(e=>e.group==="Configure"),KN=y_.filter(e=>e.group==="Tools").map(({key:e,label:r,icon:n,hint:i})=>({key:e,label:r,icon:n,hint:i})),Ij="sm.almanac.sidebarWidth",Y4=180,J4=480,Dj=252;function Gq(){try{const e=parseInt(localStorage.getItem(Ij)??"",10);if(Number.isFinite(e))return Math.min(J4,Math.max(Y4,e))}catch{}return Dj}const Kq=52,Z4="sm.almanac.sidebarCollapsed";function Xq(){try{return localStorage.getItem(Z4)==="1"}catch{}return!1}const Q4="sm.almanac.collapsedGroups";function Yq(){try{const e=localStorage.getItem(Q4);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 Jq(){const e=_w(a=>a.tabs),r=Ou(a=>{var c;return(((c=a.snapshot)==null?void 0:c.jobs)??[]).some(l=>l.status==="running")}),[n,i]=D.useState(()=>Date.now());return D.useEffect(()=>{const a=setInterval(()=>i(Date.now()),5e3);return()=>clearInterval(a)},[]),{subagents:Object.values(e).some(a=>a.agents.some(c=>n-c.at<6e4)),scheduler:r}}function Zq({active:e,onNavigate:r,onNewSession:n}){const[i,s]=D.useState(()=>Yq()),a=D.useCallback(_=>{s(C=>{const T=new Set(C);T.has(_)?T.delete(_):T.add(_);try{localStorage.setItem(Q4,JSON.stringify(Array.from(T)))}catch{}return T})},[]),[c,l]=D.useState(()=>Xq()),u=D.useCallback(()=>{l(_=>{const C=!_;try{localStorage.setItem(Z4,C?"1":"0")}catch{}return C})},[]),f=kt(_=>_.tabs),m=kt(_=>_.activeTabId),h=f.find(_=>_.id===m)??null,b=Jq(),[w,k]=D.useState(()=>Gq()),S=D.useRef(w);S.current=w;const y=D.useCallback(_=>{_.preventDefault();const C=_.clientX,T=S.current;let E=T;const $=P=>{E=Math.min(J4,Math.max(Y4,T+(P.clientX-C))),k(E)},N=()=>{window.removeEventListener("pointermove",$),window.removeEventListener("pointerup",N),document.body.style.cursor="",document.body.style.userSelect="";try{localStorage.setItem(Ij,String(E))}catch{}};window.addEventListener("pointermove",$),window.addEventListener("pointerup",N),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]),x=D.useCallback(()=>{k(Dj);try{localStorage.setItem(Ij,String(Dj))}catch{}},[]);return o.jsxs("aside",{className:"shrink-0 bg-bg-elev border-r border-line flex flex-col relative transition-[width] duration-150",style:{width:c?Kq:w},"data-testid":"tour-leftnav","aria-label":"Primary navigation",children:[o.jsx(Qq,{tab:h,onNewSession:n,rail:c,onToggleRail:u}),o.jsx("div",{className:"flex-1 min-h-0 overflow-auto pb-3",style:{paddingInline:c?"4px":"8px"},children:o.jsxs(o.Fragment,{children:[!c&&o.jsx(R1,{label:"Workspace",collapsed:i.has("Workspace"),count:VN.length,onToggle:()=>a("Workspace")}),(c||!i.has("Workspace"))&&VN.map(_=>o.jsx(XN,{item:_,active:e===_.key,live:_.liveKind?b[_.liveKind]:!1,onClick:()=>r(_.key),rail:c},_.key)),!c&&o.jsx(R1,{label:"Configure",collapsed:i.has("Configure"),count:GN.length,onToggle:()=>a("Configure")}),(c||!i.has("Configure"))&&GN.map(_=>o.jsx(XN,{item:_,active:e===_.key,live:!1,onClick:()=>r(_.key),rail:c},_.key)),!c&&o.jsx(R1,{label:"Tools",collapsed:i.has("Tools"),count:KN.length,onToggle:()=>a("Tools")}),(c||!i.has("Tools"))&&KN.map(_=>o.jsx(eH,{tool:_,active:e===_.key,onClick:()=>r(_.key),rail:c},_.key))]})}),o.jsx(tH,{rail:c}),!c&&o.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar",title:"Drag to resize · double-click to reset",onPointerDown:y,onDoubleClick:x,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 Qq({tab:e,onNewSession:r,rail:n,onToggleRail:i}){const s=(e==null?void 0:e.label)??"no session",a=X4((e==null?void 0:e.cwd)??null);return n?o.jsxs("div",{className:"flex flex-col items-center gap-1.5 pt-2 pb-2 border-b border-rule",children:[o.jsx("button",{onClick:r,"data-testid":"tour-new-session",title:"New session",className:"w-9 h-9 rounded-md bg-bg-hi border border-line text-fg hover:bg-bg-hi/80 hover:border-accent/40 transition-colors flex items-center justify-center",children:o.jsx(pr,{name:"plus",size:15,stroke:1.8})}),o.jsx("button",{onClick:i,title:"Expand sidebar","data-testid":"sidebar-rail-toggle",className:"w-9 h-9 rounded-md text-fg-faint hover:text-fg hover:bg-bg-hi/50 transition-colors flex items-center justify-center",children:o.jsx("span",{style:{display:"inline-flex",transform:"rotate(0deg)"},children:o.jsx(pr,{name:"chevron",size:15,stroke:1.8})})})]}):o.jsxs("div",{className:"px-[18px] pt-[14px] pb-[10px] border-b border-rule",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("div",{className:"text-[11px] font-semibold tracking-[0.06em] text-fg-faint uppercase",children:"Project"}),o.jsx("button",{onClick:i,title:"Collapse sidebar","data-testid":"sidebar-rail-toggle",className:"w-6 h-6 rounded-md text-fg-faint hover:text-fg hover:bg-bg-hi/50 transition-colors flex items-center justify-center",children:o.jsx("span",{style:{display:"inline-flex",transform:"rotate(180deg)"},children:o.jsx(pr,{name:"chevron",size:13,stroke:1.8})})})]}),o.jsxs("div",{className:"flex items-baseline gap-2 mt-1",children:[o.jsx("span",{className:"self-center w-2 h-2 rounded-full bg-sage"}),o.jsx("span",{className:"font-serif text-[18px] font-medium text-fg truncate",title:(e==null?void 0:e.cwd)??"",children:s})]}),o.jsx("div",{className:"text-[12px] text-fg-faint font-mono mt-0.5 truncate",children:a?`⌥${a}`:e?e.cwd:"—"}),o.jsxs("div",{className:"mt-3 flex items-stretch gap-1.5",children:[o.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:[o.jsx(pr,{name:"plus",size:13,stroke:1.8}),"New session"]}),o.jsx("div",{className:"flex items-center rounded-md bg-bg-hi border border-line",children:o.jsx(K4,{})})]})]})}function R1({label:e,collapsed:r,count:n,onToggle:i}){return o.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:[o.jsx("span",{"aria-hidden":!0,className:"inline-block w-2 text-[9px] not-italic transition-transform",style:{transform:r?"rotate(-90deg)":"rotate(0deg)"},children:"▾"}),o.jsx("span",{className:"flex-1",children:e}),r&&o.jsx("span",{className:"not-italic text-[10px] font-mono text-fg-faint/70 normal-case tracking-normal",children:n})]})}function XN({item:e,active:r,live:n,onClick:i,rail:s}){return o.jsxs("button",{onClick:i,title:e.hint,"data-testid":e.key==="scheduler"?"tour-scheduler":void 0,className:`relative w-full flex items-center rounded-[10px] text-left mb-0.5 transition-colors ${s?"justify-center px-0 py-[9px]":"gap-3 px-3.5 py-[9px] text-[14px]"} ${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&&o.jsx("span",{"aria-hidden":!0,className:`absolute top-3 bottom-3 w-[3px] rounded-sm bg-accent ${s?"-left-[4px]":"-left-[10px]"}`}),o.jsx("span",{className:`inline-flex ${r?"text-accent":"text-fg-faint"}`,children:o.jsx(pr,{name:e.icon,size:17,stroke:1.6})}),!s&&o.jsx("span",{className:"flex-1 truncate",children:e.label}),!s&&n&&o.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-accent animate-pulse",title:"live activity"}),s&&n&&o.jsx("span",{className:"absolute top-1.5 right-1.5 w-1.5 h-1.5 rounded-full bg-accent animate-pulse",title:"live activity"})]})}function eH({tool:e,active:r,onClick:n,rail:i}){return o.jsxs("button",{onClick:n,title:e.hint,className:`relative w-full flex items-center rounded-[10px] text-left mb-0.5 transition-colors ${i?"justify-center px-0 py-[7px]":"gap-3 px-3.5 py-[7px] text-[13px]"} ${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&&o.jsx("span",{"aria-hidden":!0,className:`absolute top-2 bottom-2 w-[3px] rounded-sm bg-accent ${i?"-left-[4px]":"-left-[10px]"}`}),o.jsx("span",{className:`inline-flex ${r?"text-accent":"text-fg-faint"}`,children:o.jsx(pr,{name:e.icon,size:15,stroke:1.6})}),!i&&o.jsx("span",{className:"flex-1 truncate",children:e.label})]})}function tH({rail:e}){const r=Dt(l=>l.isRecording),n=kt(l=>l.tabs),i=kt(l=>l.activeTabId),s=n.find(l=>l.id===i)??null,[a,c]=D.useState(null);return D.useEffect(()=>{let l=!1;if(!(s!=null&&s.presetId)){c(null);return}return C4(s.presetId).then(u=>{l||c((u==null?void 0:u.model)??null)}).catch(()=>{l||c(null)}),()=>{l=!0}},[s==null?void 0:s.presetId]),e?o.jsx("div",{className:"py-2.5 border-t border-rule flex justify-center",children:o.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${r?"bg-red-500 animate-pulse":"bg-sage"}`,title:r?"recording":"idle"})}):o.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:[o.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${r?"bg-red-500 animate-pulse":"bg-sage"}`,title:r?"recording":"idle"}),o.jsx("span",{className:"truncate",title:a??"",children:r?"recording…":a?`Claude · ${qq(a)}`:"Claude Code"})]})}function rH({onNavigate:e}){const r=kt(C=>C.tabs),n=kt(C=>C.activeTabId),i=r.find(C=>C.id===n)??null,s=O4(i),a=(s==null?void 0:s.lastEventAt)??0,c=Ap(C=>C.data),l=Ou(C=>{var T;return((T=C.snapshot)==null?void 0:T.paused)??null}),u=X4((i==null?void 0:i.cwd)??null),[,f]=D.useState(0);D.useEffect(()=>{const C=setInterval(()=>f(T=>T+1),6e4);return()=>clearInterval(C)},[]);const m=(s==null?void 0:s.todos)??[],[h,b]=D.useState(!1),w=D.useRef(null);D.useEffect(()=>{if(!h)return;const C=T=>{w.current&&!w.current.contains(T.target)&&b(!1)};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[h]),D.useEffect(()=>{m.length===0&&b(!1)},[m.length]);const k=v_(c),S=(k==null?void 0:k.usage.five_hour)??null,y=S?Math.round(S.utilization):null,x=(c==null?void 0:c.kind)==="ok"||(c==null?void 0:c.kind)==="ok-stale",_=a>0?sH(Date.now()-a):"—";return o.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:[o.jsxs("button",{onClick:()=>e==null?void 0:e("settings"),className:"flex items-center gap-1.5 hover:text-fg transition-colors",title:x?"Connected to Anthropic":"Disconnected",children:[o.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${x?"bg-sage":"bg-fg-faint"}`}),o.jsx("span",{children:x?"connected":"offline"})]}),o.jsx("button",{onClick:()=>e==null?void 0:e("usage"),className:"hover:text-fg transition-colors",title:"Open Usage",children:y!=null?`${y}% of 5h window used`:"5h —"}),l&&o.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 ${l.reason==="auth"||l.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:[o.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current opacity-80"}),"Scheduler paused · ",l.reason]}),i&&o.jsxs("span",{className:"text-fg-faint",title:i.cwd,children:[i.label,u&&o.jsxs("span",{className:"text-fg-dim",children:[" · ⌥",u]})]}),o.jsxs("span",{className:"text-fg-faint",children:["last activity: ",o.jsx("span",{className:"text-fg-dim",children:_})]}),m.length>0&&o.jsx(nH,{ref:w,todos:m,open:h,onToggle:()=>b(C=>!C)}),o.jsx("span",{className:"flex-1"}),o.jsxs("span",{className:"text-fg-faint",children:["v","0.35.17"]})]})}const nH=D.forwardRef(function({todos:r,open:n,onToggle:i},s){const a={completed:r.filter(c=>c.status==="completed").length,in_progress:r.filter(c=>c.status==="in_progress").length,pending:r.filter(c=>c.status==="pending").length};return o.jsxs("div",{ref:s,className:"relative",children:[o.jsxs("button",{onClick:i,className:"flex items-center gap-1.5 hover:text-fg transition-colors",title:"Live to-dos for this session","data-testid":"footer-todos",children:[o.jsxs("span",{className:"text-green-400",children:["✓",a.completed]}),o.jsxs("span",{className:"text-accent",children:["●",a.in_progress]}),o.jsxs("span",{className:"text-fg-dim",children:["○",a.pending]}),o.jsxs("span",{className:"text-fg-faint",children:["todos ",n?"▾":"▴"]})]}),n&&o.jsx("div",{className:"absolute bottom-full left-0 mb-1.5 w-80 max-h-72 overflow-auto bg-bg-elev border border-line rounded shadow-xl p-2 z-50","data-testid":"footer-todos-popover",children:o.jsx("ul",{className:"space-y-0.5",children:r.map((c,l)=>o.jsxs("li",{className:`flex items-start gap-2 py-1 px-1.5 rounded ${c.status==="in_progress"?"bg-bg-hi":""}`,children:[o.jsx(iH,{status:c.status}),o.jsx("span",{className:c.status==="completed"?"text-fg-faint line-through":c.status==="in_progress"?"text-fg":"text-fg-dim",children:c.status==="in_progress"&&c.activeForm?c.activeForm:c.content})]},l))})})]})});function iH({status:e}){return e==="completed"?o.jsx("span",{className:"text-green-400 w-3 shrink-0",children:"✓"}):e==="in_progress"?o.jsx("span",{className:"w-3 shrink-0",children:o.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-accent animate-pulse"})}):o.jsx("span",{className:"text-fg-faint w-3 shrink-0",children:"○"})}function sH(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 M1={exports:{}},YN;function aH(){return YN||(YN=1,(function(e,r){(function(n,i){e.exports=i()})(globalThis,(()=>(()=>{var n={4567:function(c,l,u){var f=this&&this.__decorate||function(_,C,T,E){var $,N=arguments.length,P=N<3?C:E===null?E=Object.getOwnPropertyDescriptor(C,T):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")P=Reflect.decorate(_,C,T,E);else for(var I=_.length-1;I>=0;I--)($=_[I])&&(P=(N<3?$(P):N>3?$(C,T,P):$(C,T))||P);return N>3&&P&&Object.defineProperty(C,T,P),P},m=this&&this.__param||function(_,C){return function(T,E){C(T,E,_)}};Object.defineProperty(l,"__esModule",{value:!0}),l.AccessibilityManager=void 0;const h=u(9042),b=u(9924),w=u(844),k=u(4725),S=u(2585),y=u(3656);let x=l.AccessibilityManager=class extends w.Disposable{constructor(_,C,T,E){super(),this._terminal=_,this._coreBrowserService=T,this._renderService=E,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 b.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 EN;function rq(){return EN||(EN=1,(function(e,r){var n=(()=>{var i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,l=(ie=>typeof Va<"u"?Va:typeof Proxy<"u"?new Proxy(ie,{get:(me,_e)=>(typeof Va<"u"?Va:me)[_e]}):ie)(function(ie){if(typeof Va<"u")return Va.apply(this,arguments);throw Error('Dynamic require of "'+ie+'" is not supported')}),u=(ie,me)=>()=>(ie&&(me=ie(ie=0)),me),f=(ie,me)=>{for(var _e in me)i(ie,_e,{get:me[_e],enumerable:!0})},m=(ie,me,_e,Pe)=>{if(me&&typeof me=="object"||typeof me=="function")for(let je of a(me))!c.call(ie,je)&&je!==_e&&i(ie,je,{get:()=>me[je],enumerable:!(Pe=s(me,je))||Pe.enumerable});return ie},h=ie=>m(i({},"__esModule",{value:!0}),ie),b,w,k,S,y,x=u(()=>{b=new Map,w=[],k=(ie,me,_e)=>{if(me&&typeof me.init=="function"&&typeof me.createInferenceSessionHandler=="function"){let Pe=b.get(ie);if(Pe===void 0)b.set(ie,{backend:me,priority:_e});else{if(Pe.priority>_e)return;if(Pe.priority===_e&&Pe.backend!==me)throw new Error(`cannot register backend "${ie}" using priority ${_e}`)}if(_e>=0){let je=w.indexOf(ie);je!==-1&&w.splice(je,1);for(let qe=0;qe<w.length;qe++)if(b.get(w[qe]).priority<=_e){w.splice(qe,0,ie);return}w.push(ie)}return}throw new TypeError("not a valid backend")},S=async ie=>{let me=b.get(ie);if(!me)return"backend not found.";if(me.initialized)return me.backend;if(me.aborted)return me.error;{let _e=!!me.initPromise;try{return _e||(me.initPromise=me.backend.init(ie)),await me.initPromise,me.initialized=!0,me.backend}catch(Pe){return _e||(me.error=`${Pe}`,me.aborted=!0),me.error}finally{delete me.initPromise}}},y=async ie=>{let me=ie.executionProviders||[],_e=me.map(Ve=>typeof Ve=="string"?Ve:Ve.name),Pe=_e.length===0?w:_e,je,qe=[],Ie=new Set;for(let Ve of Pe){let it=await S(Ve);typeof it=="string"?qe.push({name:Ve,err:it}):(je||(je=it),je===it&&Ie.add(Ve))}if(!je)throw new Error(`no available backend found. ERR: ${qe.map(Ve=>`[${Ve.name}] ${Ve.err}`).join(", ")}`);for(let{name:Ve,err:it}of qe)_e.includes(Ve)&&console.warn(`removing requested execution provider "${Ve}" from session options because it is not available: ${it}`);let De=me.filter(Ve=>Ie.has(typeof Ve=="string"?Ve:Ve.name));return[je,new Proxy(ie,{get:(Ve,it)=>it==="executionProviders"?De:Reflect.get(Ve,it)})]}}),_=u(()=>{x()}),C,T=u(()=>{C="1.26.0"}),E,$,N=u(()=>{T(),E="warning",$={wasm:{},webgl:{},webgpu:{},versions:{common:C},set logLevel(ie){if(ie!==void 0){if(typeof ie!="string"||["verbose","info","warning","error","fatal"].indexOf(ie)===-1)throw new Error(`Unsupported logging level: ${ie}`);E=ie}},get logLevel(){return E}},Object.defineProperty($,"logLevel",{enumerable:!0})}),P,I=u(()=>{N(),P=$}),W,F,U=u(()=>{W=(ie,me)=>{let _e=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);_e.width=ie.dims[3],_e.height=ie.dims[2];let Pe=_e.getContext("2d");if(Pe!=null){let je,qe;(me==null?void 0:me.tensorLayout)!==void 0&&me.tensorLayout==="NHWC"?(je=ie.dims[2],qe=ie.dims[3]):(je=ie.dims[3],qe=ie.dims[2]);let Ie=(me==null?void 0:me.format)!==void 0?me.format:"RGB",De=me==null?void 0:me.norm,Ve,it;De===void 0||De.mean===void 0?Ve=[255,255,255,255]:typeof De.mean=="number"?Ve=[De.mean,De.mean,De.mean,De.mean]:(Ve=[De.mean[0],De.mean[1],De.mean[2],0],De.mean[3]!==void 0&&(Ve[3]=De.mean[3])),De===void 0||De.bias===void 0?it=[0,0,0,0]:typeof De.bias=="number"?it=[De.bias,De.bias,De.bias,De.bias]:(it=[De.bias[0],De.bias[1],De.bias[2],0],De.bias[3]!==void 0&&(it[3]=De.bias[3]));let ut=qe*je,st=0,et=ut,Ot=ut*2,We=-1;Ie==="RGBA"?(st=0,et=ut,Ot=ut*2,We=ut*3):Ie==="RGB"?(st=0,et=ut,Ot=ut*2):Ie==="RBG"&&(st=0,Ot=ut,et=ut*2);for(let pt=0;pt<qe;pt++)for(let Rr=0;Rr<je;Rr++){let tr=(ie.data[st++]-it[0])*Ve[0],rr=(ie.data[et++]-it[1])*Ve[1],Mr=(ie.data[Ot++]-it[2])*Ve[2],zt=We===-1?255:(ie.data[We++]-it[3])*Ve[3];Pe.fillStyle="rgba("+tr+","+rr+","+Mr+","+zt+")",Pe.fillRect(Rr,pt,1,1)}if("toDataURL"in _e)return _e.toDataURL();throw new Error("toDataURL is not supported")}else throw new Error("Can not access image data")},F=(ie,me)=>{let _e=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),Pe;if(_e!=null){let je,qe,Ie;(me==null?void 0:me.tensorLayout)!==void 0&&me.tensorLayout==="NHWC"?(je=ie.dims[2],qe=ie.dims[1],Ie=ie.dims[3]):(je=ie.dims[3],qe=ie.dims[2],Ie=ie.dims[1]);let De=me!==void 0&&me.format!==void 0?me.format:"RGB",Ve=me==null?void 0:me.norm,it,ut;Ve===void 0||Ve.mean===void 0?it=[255,255,255,255]:typeof Ve.mean=="number"?it=[Ve.mean,Ve.mean,Ve.mean,Ve.mean]:(it=[Ve.mean[0],Ve.mean[1],Ve.mean[2],255],Ve.mean[3]!==void 0&&(it[3]=Ve.mean[3])),Ve===void 0||Ve.bias===void 0?ut=[0,0,0,0]:typeof Ve.bias=="number"?ut=[Ve.bias,Ve.bias,Ve.bias,Ve.bias]:(ut=[Ve.bias[0],Ve.bias[1],Ve.bias[2],0],Ve.bias[3]!==void 0&&(ut[3]=Ve.bias[3]));let st=qe*je;if(me!==void 0&&(me.format!==void 0&&Ie===4&&me.format!=="RGBA"||Ie===3&&me.format!=="RGB"&&me.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let et=4,Ot=0,We=1,pt=2,Rr=3,tr=0,rr=st,Mr=st*2,zt=-1;De==="RGBA"?(tr=0,rr=st,Mr=st*2,zt=st*3):De==="RGB"?(tr=0,rr=st,Mr=st*2):De==="RBG"&&(tr=0,Mr=st,rr=st*2),Pe=_e.createImageData(je,qe);for(let Ur=0;Ur<qe*je;Ot+=et,We+=et,pt+=et,Rr+=et,Ur++)Pe.data[Ot]=(ie.data[tr++]-ut[0])*it[0],Pe.data[We]=(ie.data[rr++]-ut[1])*it[1],Pe.data[pt]=(ie.data[Mr++]-ut[2])*it[2],Pe.data[Rr]=zt===-1?255:(ie.data[zt++]-ut[3])*it[3]}else throw new Error("Can not access image data");return Pe}}),q,z,Y,ee,se,ue,X=u(()=>{ce(),q=(ie,me)=>{if(ie===void 0)throw new Error("Image buffer must be defined");if(me.height===void 0||me.width===void 0)throw new Error("Image height and width must be defined");if(me.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");let{height:_e,width:Pe}=me,je=me.norm??{mean:255,bias:0},qe,Ie;typeof je.mean=="number"?qe=[je.mean,je.mean,je.mean,je.mean]:qe=[je.mean[0],je.mean[1],je.mean[2],je.mean[3]??255],typeof je.bias=="number"?Ie=[je.bias,je.bias,je.bias,je.bias]:Ie=[je.bias[0],je.bias[1],je.bias[2],je.bias[3]??0];let De=me.format!==void 0?me.format:"RGBA",Ve=me.tensorFormat!==void 0&&me.tensorFormat!==void 0?me.tensorFormat:"RGB",it=_e*Pe,ut=Ve==="RGBA"?new Float32Array(it*4):new Float32Array(it*3),st=4,et=0,Ot=1,We=2,pt=3,Rr=0,tr=it,rr=it*2,Mr=-1;De==="RGB"&&(st=3,et=0,Ot=1,We=2,pt=-1),Ve==="RGBA"?Mr=it*3:Ve==="RBG"?(Rr=0,rr=it,tr=it*2):Ve==="BGR"&&(rr=0,tr=it,Rr=it*2);for(let zt=0;zt<it;zt++,et+=st,We+=st,Ot+=st,pt+=st)ut[Rr++]=(ie[et]+Ie[0])/qe[0],ut[tr++]=(ie[Ot]+Ie[1])/qe[1],ut[rr++]=(ie[We]+Ie[2])/qe[2],Mr!==-1&&pt!==-1&&(ut[Mr++]=(ie[pt]+Ie[3])/qe[3]);return Ve==="RGBA"?new ne("float32",ut,[1,4,_e,Pe]):new ne("float32",ut,[1,3,_e,Pe])},z=async(ie,me)=>{let _e=typeof HTMLImageElement<"u"&&ie instanceof HTMLImageElement,Pe=typeof ImageData<"u"&&ie instanceof ImageData,je=typeof ImageBitmap<"u"&&ie instanceof ImageBitmap,qe=typeof ie=="string",Ie,De=me??{},Ve=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},it=ut=>typeof HTMLCanvasElement<"u"&&ut instanceof HTMLCanvasElement||ut instanceof OffscreenCanvas?ut.getContext("2d"):null;if(_e){let ut=Ve();ut.width=ie.width,ut.height=ie.height;let st=it(ut);if(st!=null){let et=ie.height,Ot=ie.width;if(me!==void 0&&me.resizedHeight!==void 0&&me.resizedWidth!==void 0&&(et=me.resizedHeight,Ot=me.resizedWidth),me!==void 0){if(De=me,me.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");De.tensorFormat="RGBA",De.height=et,De.width=Ot}else De.tensorFormat="RGBA",De.height=et,De.width=Ot;st.drawImage(ie,0,0),Ie=st.getImageData(0,0,Ot,et).data}else throw new Error("Can not access image data")}else if(Pe){let ut,st;if(me!==void 0&&me.resizedWidth!==void 0&&me.resizedHeight!==void 0?(ut=me.resizedHeight,st=me.resizedWidth):(ut=ie.height,st=ie.width),me!==void 0&&(De=me),De.format="RGBA",De.height=ut,De.width=st,me!==void 0){let et=Ve();et.width=st,et.height=ut;let Ot=it(et);if(Ot!=null)Ot.putImageData(ie,0,0),Ie=Ot.getImageData(0,0,st,ut).data;else throw new Error("Can not access image data")}else Ie=ie.data}else if(je){if(me===void 0)throw new Error("Please provide image config with format for Imagebitmap");let ut=Ve();ut.width=ie.width,ut.height=ie.height;let st=it(ut);if(st!=null){let et=ie.height,Ot=ie.width;return st.drawImage(ie,0,0,Ot,et),Ie=st.getImageData(0,0,Ot,et).data,De.height=et,De.width=Ot,q(Ie,De)}else throw new Error("Can not access image data")}else{if(qe)return new Promise((ut,st)=>{let et=Ve(),Ot=it(et);if(!ie||!Ot)return st();let We=new Image;We.crossOrigin="Anonymous",We.src=ie,We.onload=()=>{et.width=We.width,et.height=We.height,Ot.drawImage(We,0,0,et.width,et.height);let pt=Ot.getImageData(0,0,et.width,et.height);De.height=et.height,De.width=et.width,ut(q(pt.data,De))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(Ie!==void 0)return q(Ie,De);throw new Error("Input data provided is not supported - aborted tensor creation")},Y=(ie,me)=>{let{width:_e,height:Pe,download:je,dispose:qe}=me,Ie=[1,Pe,_e,4];return new ne({location:"texture",type:"float32",texture:ie,dims:Ie,download:je,dispose:qe})},ee=(ie,me)=>{let{dataType:_e,dims:Pe,download:je,dispose:qe}=me;return new ne({location:"gpu-buffer",type:_e??"float32",gpuBuffer:ie,dims:Pe,download:je,dispose:qe})},se=(ie,me)=>{let{dataType:_e,dims:Pe,download:je,dispose:qe}=me;return new ne({location:"ml-tensor",type:_e??"float32",mlTensor:ie,dims:Pe,download:je,dispose:qe})},ue=(ie,me,_e)=>new ne({location:"cpu-pinned",type:ie,data:me,dims:_e??[me.length]})}),Q,Z,ae,oe,de=u(()=>{Q=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"]]),ae=!1,oe=()=>{if(!ae){ae=!0;let ie=typeof BigInt64Array<"u"&&BigInt64Array.from,me=typeof BigUint64Array<"u"&&BigUint64Array.from,_e=globalThis.Float16Array,Pe=typeof _e<"u"&&_e.from;ie&&(Q.set("int64",BigInt64Array),Z.set(BigInt64Array,"int64")),me&&(Q.set("uint64",BigUint64Array),Z.set(BigUint64Array,"uint64")),Pe?(Q.set("float16",_e),Z.set(_e,"float16")):Q.set("float16",Uint16Array)}}}),ve,$e,we=u(()=>{ce(),ve=ie=>{let me=1;for(let _e=0;_e<ie.length;_e++){let Pe=ie[_e];if(typeof Pe!="number"||!Number.isSafeInteger(Pe))throw new TypeError(`dims[${_e}] must be an integer, got: ${Pe}`);if(Pe<0)throw new RangeError(`dims[${_e}] must be a non-negative integer, got: ${Pe}`);me*=Pe}return me},$e=(ie,me)=>{switch(ie.location){case"cpu":return new ne(ie.type,ie.data,me);case"cpu-pinned":return new ne({location:"cpu-pinned",data:ie.data,type:ie.type,dims:me});case"texture":return new ne({location:"texture",texture:ie.texture,type:ie.type,dims:me});case"gpu-buffer":return new ne({location:"gpu-buffer",gpuBuffer:ie.gpuBuffer,type:ie.type,dims:me});case"ml-tensor":return new ne({location:"ml-tensor",mlTensor:ie.mlTensor,type:ie.type,dims:me});default:throw new Error(`tensorReshape: tensor location ${ie.location} is not supported`)}}}),ne,ce=u(()=>{U(),X(),de(),we(),ne=class{constructor(ie,me,_e){oe();let Pe,je;if(typeof ie=="object"&&"location"in ie)switch(this.dataLocation=ie.location,Pe=ie.type,je=ie.dims,ie.location){case"cpu-pinned":{let Ie=Q.get(Pe);if(!Ie)throw new TypeError(`unsupported type "${Pe}" to create tensor from pinned buffer`);if(!(ie.data instanceof Ie))throw new TypeError(`buffer should be of type ${Ie.name}`);this.cpuData=ie.data;break}case"texture":{if(Pe!=="float32")throw new TypeError(`unsupported type "${Pe}" to create tensor from texture`);this.gpuTextureData=ie.texture,this.downloader=ie.download,this.disposer=ie.dispose;break}case"gpu-buffer":{if(Pe!=="float32"&&Pe!=="float16"&&Pe!=="int32"&&Pe!=="int64"&&Pe!=="uint32"&&Pe!=="uint8"&&Pe!=="bool"&&Pe!=="uint4"&&Pe!=="int4")throw new TypeError(`unsupported type "${Pe}" to create tensor from gpu buffer`);this.gpuBufferData=ie.gpuBuffer,this.downloader=ie.download,this.disposer=ie.dispose;break}case"ml-tensor":{if(Pe!=="float32"&&Pe!=="float16"&&Pe!=="int32"&&Pe!=="int64"&&Pe!=="uint32"&&Pe!=="uint64"&&Pe!=="int8"&&Pe!=="uint8"&&Pe!=="bool"&&Pe!=="uint4"&&Pe!=="int4")throw new TypeError(`unsupported type "${Pe}" to create tensor from MLTensor`);this.mlTensorData=ie.mlTensor,this.downloader=ie.download,this.disposer=ie.dispose;break}default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let Ie,De;if(typeof ie=="string")if(Pe=ie,De=_e,ie==="string"){if(!Array.isArray(me))throw new TypeError("A string tensor's data must be a string array.");Ie=me}else{let Ve=Q.get(ie);if(Ve===void 0)throw new TypeError(`Unsupported tensor type: ${ie}.`);if(Array.isArray(me)){if(ie==="float16"&&Ve===Uint16Array||ie==="uint4"||ie==="int4")throw new TypeError(`Creating a ${ie} tensor from number array is not supported. Please use ${Ve.name} as data.`);ie==="uint64"||ie==="int64"?Ie=Ve.from(me,BigInt):Ie=Ve.from(me)}else if(me instanceof Ve)Ie=me;else if(me instanceof Uint8ClampedArray)if(ie==="uint8")Ie=Uint8Array.from(me);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else if(ie==="float16"&&me instanceof Uint16Array&&Ve!==Uint16Array)Ie=new globalThis.Float16Array(me.buffer,me.byteOffset,me.length);else throw new TypeError(`A ${Pe} tensor's data must be type of ${Ve}`)}else if(De=me,Array.isArray(ie)){if(ie.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let Ve=typeof ie[0];if(Ve==="string")Pe="string",Ie=ie;else if(Ve==="boolean")Pe="bool",Ie=Uint8Array.from(ie);else throw new TypeError(`Invalid element type of data array: ${Ve}.`)}else if(ie instanceof Uint8ClampedArray)Pe="uint8",Ie=Uint8Array.from(ie);else{let Ve=Z.get(ie.constructor);if(Ve===void 0)throw new TypeError(`Unsupported type for tensor data: ${ie.constructor}.`);Pe=Ve,Ie=ie}if(De===void 0)De=[Ie.length];else if(!Array.isArray(De))throw new TypeError("A tensor's dims must be a number array");je=De,this.cpuData=Ie,this.dataLocation="cpu"}let qe=ve(je);if(this.cpuData&&qe!==this.cpuData.length&&!((Pe==="uint4"||Pe==="int4")&&Math.ceil(qe/2)===this.cpuData.length))throw new Error(`Tensor's size(${qe}) does not match data length(${this.cpuData.length}).`);this.type=Pe,this.dims=je,this.size=qe}static async fromImage(ie,me){return z(ie,me)}static fromTexture(ie,me){return Y(ie,me)}static fromGpuBuffer(ie,me){return ee(ie,me)}static fromMLTensor(ie,me){return se(ie,me)}static fromPinnedBuffer(ie,me,_e){return ue(ie,me,_e)}toDataURL(ie){return W(this,ie)}toImageData(ie){return F(this,ie)}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(ie){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 me=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=me,ie&&this.disposer&&(this.disposer(),this.disposer=void 0),me}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(ie){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return $e(this,ie)}}}),ge,Ae=u(()=>{ce(),ge=ne}),Te,nt,ct,Le,Me,Ue,mt=u(()=>{N(),Te=(ie,me)=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||console.timeStamp(`${ie}::ORT::${me}`)},nt=(ie,me)=>{var je;let _e=((je=new Error().stack)==null?void 0:je.split(/\r\n|\r|\n/g))||[],Pe=!1;for(let qe=0;qe<_e.length;qe++){if(Pe&&!_e[qe].includes("TRACE_FUNC")){let Ie=`FUNC_${ie}::${_e[qe].trim().split(" ")[1]}`;me&&(Ie+=`::${me}`),Te("CPU",Ie);return}_e[qe].includes("TRACE_FUNC")&&(Pe=!0)}},ct=ie=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||nt("BEGIN",ie)},Le=ie=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||nt("END",ie)},Me=ie=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||console.time(`ORT::${ie}`)},Ue=ie=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||console.timeEnd(`ORT::${ie}`)}}),jt,er=u(()=>{x(),Ae(),mt(),jt=class L4{constructor(me){this.handler=me}async run(me,_e,Pe){ct(),Me("InferenceSession.run");let je={},qe={};if(typeof me!="object"||me===null||me instanceof ge||Array.isArray(me))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let Ie=!0;if(typeof _e=="object"){if(_e===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(_e instanceof ge)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(_e)){if(_e.length===0)throw new TypeError("'fetches' cannot be an empty array.");Ie=!1;for(let it of _e){if(typeof it!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(it)===-1)throw new RangeError(`'fetches' contains invalid output name: ${it}.`);je[it]=null}if(typeof Pe=="object"&&Pe!==null)qe=Pe;else if(typeof Pe<"u")throw new TypeError("'options' must be an object.")}else{let it=!1,ut=Object.getOwnPropertyNames(_e);for(let st of this.outputNames)if(ut.indexOf(st)!==-1){let et=_e[st];(et===null||et instanceof ge)&&(it=!0,Ie=!1,je[st]=et)}if(it){if(typeof Pe=="object"&&Pe!==null)qe=Pe;else if(typeof Pe<"u")throw new TypeError("'options' must be an object.")}else qe=_e}}else if(typeof _e<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let it of this.inputNames)if(typeof me[it]>"u")throw new Error(`input '${it}' is missing in 'feeds'.`);if(Ie)for(let it of this.outputNames)je[it]=null;let De=await this.handler.run(me,je,qe),Ve={};for(let it in De)if(Object.hasOwnProperty.call(De,it)){let ut=De[it];ut instanceof ge?Ve[it]=ut:Ve[it]=new ge(ut.type,ut.data,ut.dims)}return Ue("InferenceSession.run"),Le(),Ve}async release(){return this.handler.dispose()}static async create(me,_e,Pe,je){ct(),Me("InferenceSession.create");let qe,Ie={};if(typeof me=="string"){if(qe=me,typeof _e=="object"&&_e!==null)Ie=_e;else if(typeof _e<"u")throw new TypeError("'options' must be an object.")}else if(me instanceof Uint8Array){if(qe=me,typeof _e=="object"&&_e!==null)Ie=_e;else if(typeof _e<"u")throw new TypeError("'options' must be an object.")}else if(me instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&me instanceof SharedArrayBuffer){let ut=me,st=0,et=me.byteLength;if(typeof _e=="object"&&_e!==null)Ie=_e;else if(typeof _e=="number"){if(st=_e,!Number.isSafeInteger(st))throw new RangeError("'byteOffset' must be an integer.");if(st<0||st>=ut.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${ut.byteLength}).`);if(et=me.byteLength-st,typeof Pe=="number"){if(et=Pe,!Number.isSafeInteger(et))throw new RangeError("'byteLength' must be an integer.");if(et<=0||st+et>ut.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${ut.byteLength-st}].`);if(typeof je=="object"&&je!==null)Ie=je;else if(typeof je<"u")throw new TypeError("'options' must be an object.")}else if(typeof Pe<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof _e<"u")throw new TypeError("'options' must be an object.");qe=new Uint8Array(ut,st,et)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[De,Ve]=await y(Ie),it=await De.createInferenceSessionHandler(qe,Ve);return Ue("InferenceSession.create"),Le(),new L4(it)}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}}}),Yt,mr=u(()=>{er(),Yt=jt}),ur=u(()=>{}),Qr=u(()=>{}),Pr=u(()=>{}),di=u(()=>{}),Yn={};f(Yn,{InferenceSession:()=>Yt,TRACE:()=>Te,TRACE_EVENT_BEGIN:()=>Me,TRACE_EVENT_END:()=>Ue,TRACE_FUNC_BEGIN:()=>ct,TRACE_FUNC_END:()=>Le,Tensor:()=>ge,env:()=>P,registerBackend:()=>k});var lt=u(()=>{_(),I(),mr(),Ae(),ur(),Qr(),mt(),Pr(),di()}),Ct=u(()=>{}),Pt={};f(Pt,{default:()=>Jn});var fr,ar,Jn,Tl=u(()=>{var ie;Se(),pi(),hi(),fr="ort-wasm-proxy-worker",ar=((ie=globalThis.self)==null?void 0:ie.name)===fr,ar&&(self.onmessage=me=>{let{type:_e,in:Pe}=me.data;try{switch(_e){case"init-wasm":Os(Pe.wasm).then(()=>{qo(Pe).then(()=>{postMessage({type:_e})},je=>{postMessage({type:_e,err:je})})},je=>{postMessage({type:_e,err:je})});break;case"init-ep":{let{epName:je,env:qe}=Pe;na(qe,je).then(()=>{postMessage({type:_e})},Ie=>{postMessage({type:_e,err:Ie})});break}case"copy-from":{let{buffer:je}=Pe,qe=cr(je);postMessage({type:_e,out:qe});break}case"create":{let{model:je,options:qe}=Pe;Li(je,qe).then(Ie=>{postMessage({type:_e,out:Ie})},Ie=>{postMessage({type:_e,err:Ie})});break}case"release":Ea(Pe),postMessage({type:_e});break;case"run":{let{sessionId:je,inputIndices:qe,inputs:Ie,outputIndices:De,options:Ve}=Pe;Qe(je,qe,Ie,De,new Array(De.length).fill(null),Ve).then(it=>{it.some(ut=>ut[3]!=="cpu")?postMessage({type:_e,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:_e,out:it},yt([...Ie,...it]))},it=>{postMessage({type:_e,err:it})});break}case"end-profiling":gi(Pe),postMessage({type:_e});break;default:}}catch(je){postMessage({type:_e,err:je})}}),Jn=ar?null:me=>new Worker(me??kr,{type:"classic",name:fr})}),Uo,Js,kr,fi,mn,Zs,us,Ri,ka,Qs,ea,ds,Zn,hi=u(()=>{Ct(),Uo=typeof location>"u"?void 0:location.origin,Js=()=>{var ie,me;return typeof document<"u"?(ie=document.currentScript)==null?void 0:ie.src:typeof self<"u"?(me=self.location)==null?void 0:me.href:void 0},kr=Js(),fi=()=>{if(kr&&!kr.startsWith("blob:"))return kr.substring(0,kr.lastIndexOf("/")+1)},mn=(ie,me)=>{try{let _e=me??kr;return(_e?new URL(ie,_e):new URL(ie)).origin===Uo}catch{return!1}},Zs=(ie,me)=>{let _e=me??kr;try{return(_e?new URL(ie,_e):new URL(ie)).href}catch{return}},us=(ie,me)=>`${me??"./"}${ie}`,Ri=async ie=>{let me=await(await fetch(ie,{credentials:"same-origin"})).blob();return URL.createObjectURL(me)},ka=async ie=>(await import(ie)).default,Qs=(Tl(),h(Pt)).default,ea=async()=>{if(!kr)throw new Error("Failed to load proxy worker: cannot determine the script source URL.");if(mn(kr))return[void 0,Qs()];let ie=await Ri(kr);return[ie,Qs(ie)]},ds=void 0,Zn=async(ie,me,_e,Pe)=>{let je=ds&&!(ie||me);if(je)if(kr)je=mn(kr)||Pe&&!_e;else if(Pe&&!_e)je=!0;else throw new Error("cannot determine the script source URL.");if(je)return[void 0,ds];{let qe="ort-wasm-simd-threaded.mjs",Ie=ie??Zs(qe,me),De=_e&&Ie&&!mn(Ie,me),Ve=De?await Ri(Ie):Ie??us(qe,me);return[De?Ve:void 0,await ka(Ve)]}}}),As,Qn,Mi,ts,eo,$s,Ns,Os,Ut,pi=u(()=>{hi(),Qn=!1,Mi=!1,ts=!1,eo=()=>{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}},$s=()=>{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}},Ns=()=>{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}},Os=async ie=>{if(Qn)return Promise.resolve();if(Mi)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(ts)throw new Error("previous call to 'initializeWebAssembly()' failed.");Mi=!0;let me=ie.initTimeout,_e=ie.numThreads;if(ie.simd!==!1){if(ie.simd==="relaxed"){if(!Ns())throw new Error("Relaxed WebAssembly SIMD is not supported in the current environment.")}else if(!$s())throw new Error("WebAssembly SIMD is not supported in the current environment.")}let Pe=eo();_e>1&&!Pe&&(typeof self<"u"&&!self.crossOriginIsolated&&console.warn("env.wasm.numThreads is set to "+_e+", 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."),ie.numThreads=_e=1);let je=ie.wasmPaths,qe=typeof je=="string"?je:void 0,Ie=je==null?void 0:je.mjs,De=(Ie==null?void 0:Ie.href)??Ie,Ve=je==null?void 0:je.wasm,it=(Ve==null?void 0:Ve.href)??Ve,ut=ie.wasmBinary,[st,et]=await Zn(De,qe,_e>1,!!ut||!!it),Ot=!1,We=[];if(me>0&&We.push(new Promise(pt=>{setTimeout(()=>{Ot=!0,pt()},me)})),We.push(new Promise((pt,Rr)=>{let tr={numThreads:_e};if(ut)tr.wasmBinary=ut,tr.locateFile=rr=>rr;else if(it||qe)tr.locateFile=rr=>it??qe+rr;else if(De&&De.indexOf("blob:")!==0)tr.locateFile=rr=>new URL(rr,De).href;else if(st){let rr=fi();rr&&(tr.locateFile=Mr=>rr+Mr)}et(tr).then(rr=>{Mi=!1,Qn=!0,As=rr,pt(),st&&URL.revokeObjectURL(st)},rr=>{Mi=!1,ts=!0,Rr(rr)})})),await Promise.race(We),Ot)throw new Error(`WebAssembly backend initializing failed due to timeout: ${me}ms`)},Ut=()=>{if(Qn&&As)return As;throw new Error("WebAssembly is not initialized yet.")}}),en,Tr,Et,Ca=u(()=>{pi(),en=(ie,me)=>{let _e=Ut(),Pe=_e.lengthBytesUTF8(ie)+1,je=_e._malloc(Pe);return _e.stringToUTF8(ie,je,Pe),me.push(je),je},Tr=(ie,me,_e,Pe)=>{if(typeof ie=="object"&&ie!==null){if(_e.has(ie))throw new Error("Circular reference in options");_e.add(ie)}Object.entries(ie).forEach(([je,qe])=>{let Ie=me?me+je:je;if(typeof qe=="object")Tr(qe,Ie+".",_e,Pe);else if(typeof qe=="string"||typeof qe=="number")Pe(Ie,qe.toString());else if(typeof qe=="boolean")Pe(Ie,qe?"1":"0");else throw new Error(`Can't handle extra config type: ${typeof qe}`)})},Et=ie=>{let me=Ut(),_e=me.stackSave();try{let Pe=me.PTR_SIZE,je=me.stackAlloc(2*Pe);me._OrtGetLastError(je,je+Pe);let qe=Number(me.getValue(je,Pe===4?"i32":"i64")),Ie=me.getValue(je+Pe,"*"),De=Ie?me.UTF8ToString(Ie):"";throw new Error(`${ie} ERROR_CODE: ${qe}, ERROR_MESSAGE: ${De}`)}finally{me.stackRestore(_e)}}}),to,Al=u(()=>{pi(),Ca(),to=ie=>{let me=Ut(),_e=0,Pe=[],je=ie||{};try{if((ie==null?void 0:ie.logSeverityLevel)===void 0)je.logSeverityLevel=2;else if(typeof ie.logSeverityLevel!="number"||!Number.isInteger(ie.logSeverityLevel)||ie.logSeverityLevel<0||ie.logSeverityLevel>4)throw new Error(`log severity level is not valid: ${ie.logSeverityLevel}`);if((ie==null?void 0:ie.logVerbosityLevel)===void 0)je.logVerbosityLevel=0;else if(typeof ie.logVerbosityLevel!="number"||!Number.isInteger(ie.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${ie.logVerbosityLevel}`);(ie==null?void 0:ie.terminate)===void 0&&(je.terminate=!1);let qe=0;return(ie==null?void 0:ie.tag)!==void 0&&(qe=en(ie.tag,Pe)),_e=me._OrtCreateRunOptions(je.logSeverityLevel,je.logVerbosityLevel,!!je.terminate,qe),_e===0&&Et("Can't create run options."),(ie==null?void 0:ie.extra)!==void 0&&Tr(ie.extra,"",new WeakSet,(Ie,De)=>{let Ve=en(Ie,Pe),it=en(De,Pe);me._OrtAddRunConfigEntry(_e,Ve,it)!==0&&Et(`Can't set a run config entry: ${Ie} - ${De}.`)}),[_e,Pe]}catch(qe){throw _e!==0&&me._OrtReleaseRunOptions(_e),Pe.forEach(Ie=>me._free(Ie)),qe}}}),ro,no,Wo,Wn,$l,Nl,Ar=u(()=>{pi(),Ca(),ro=ie=>{switch(ie){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: ${ie}`)}},no=ie=>{switch(ie){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${ie}`)}},Wo=ie=>{ie.extra||(ie.extra={}),ie.extra.session||(ie.extra.session={});let me=ie.extra.session;me.use_ort_model_bytes_directly||(me.use_ort_model_bytes_directly="1"),ie.executionProviders&&ie.executionProviders.some(_e=>(typeof _e=="string"?_e:_e.name)==="webgpu")&&(ie.enableMemPattern=!1)},Wn=(ie,me,_e,Pe)=>{let je=en(me,Pe),qe=en(_e,Pe);Ut()._OrtAddSessionConfigEntry(ie,je,qe)!==0&&Et(`Can't set a session config entry: ${me} - ${_e}.`)},$l=async(ie,me,_e)=>{let Pe=me.executionProviders;for(let je of Pe){let qe=typeof je=="string"?je:je.name,Ie=[];switch(qe){case"webnn":if(qe="WEBNN",Wn(ie,"session.disable_quant_qdq","1",_e),Wn(ie,"session.disable_qdq_constant_folding","1",_e),typeof je!="string"){let st=je==null?void 0:je.deviceType;st&&Wn(ie,"deviceType",st,_e)}break;case"webgpu":if(qe="JS",typeof je!="string"){let st=je;if(st!=null&&st.preferredLayout){if(st.preferredLayout!=="NCHW"&&st.preferredLayout!=="NHWC")throw new Error(`preferredLayout must be either 'NCHW' or 'NHWC': ${st.preferredLayout}`);Wn(ie,"preferredLayout",st.preferredLayout,_e)}}break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${qe}`)}let De=en(qe,_e),Ve=Ie.length,it=0,ut=0;if(Ve>0){it=Ut()._malloc(Ve*Ut().PTR_SIZE),_e.push(it),ut=Ut()._malloc(Ve*Ut().PTR_SIZE),_e.push(ut);for(let st=0;st<Ve;st++)Ut().setValue(it+st*Ut().PTR_SIZE,Ie[st][0],"*"),Ut().setValue(ut+st*Ut().PTR_SIZE,Ie[st][1],"*")}await Ut()._OrtAppendExecutionProvider(ie,De,it,ut,Ve)!==0&&Et(`Can't append execution provider: ${qe}.`)}},Nl=async ie=>{let me=Ut(),_e=0,Pe=[],je=ie||{};Wo(je);try{let qe=ro(je.graphOptimizationLevel??"all"),Ie=no(je.executionMode??"sequential"),De=typeof je.logId=="string"?en(je.logId,Pe):0,Ve=je.logSeverityLevel??2;if(!Number.isInteger(Ve)||Ve<0||Ve>4)throw new Error(`log severity level is not valid: ${Ve}`);let it=je.logVerbosityLevel??0;if(!Number.isInteger(it)||it<0||it>4)throw new Error(`log verbosity level is not valid: ${it}`);let ut=typeof je.optimizedModelFilePath=="string"?en(je.optimizedModelFilePath,Pe):0;if(_e=me._OrtCreateSessionOptions(qe,!!je.enableCpuMemArena,!!je.enableMemPattern,Ie,!!je.enableProfiling,0,De,Ve,it,ut),_e===0&&Et("Can't create session options."),je.executionProviders&&await $l(_e,je,Pe),je.enableGraphCapture!==void 0){if(typeof je.enableGraphCapture!="boolean")throw new Error(`enableGraphCapture must be a boolean value: ${je.enableGraphCapture}`);Wn(_e,"enableGraphCapture",je.enableGraphCapture.toString(),Pe)}if(je.freeDimensionOverrides)for(let[st,et]of Object.entries(je.freeDimensionOverrides)){if(typeof st!="string")throw new Error(`free dimension override name must be a string: ${st}`);if(typeof et!="number"||!Number.isInteger(et)||et<0)throw new Error(`free dimension override value must be a non-negative integer: ${et}`);let Ot=en(st,Pe);me._OrtAddFreeDimensionOverride(_e,Ot,et)!==0&&Et(`Can't set a free dimension override: ${st} - ${et}.`)}return je.extra!==void 0&&Tr(je.extra,"",new WeakSet,(st,et)=>{Wn(_e,st,et,Pe)}),[_e,Pe]}catch(qe){throw _e!==0&&me._OrtReleaseSessionOptions(_e)!==0&&Et("Can't release session options."),Pe.forEach(Ie=>me._free(Ie)),qe}}}),ei,sn,ti,Ps,ja,ta,Ii,Rn,Wt=u(()=>{ei=ie=>{switch(ie){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: ${ie}`)}},sn=ie=>{switch(ie){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: ${ie}`)}},ti=(ie,me)=>{let _e=[-1,4,1,1,2,2,4,8,-1,1,2,8,4,8,-1,-1,-1,-1,-1,-1,-1,.5,.5][ie],Pe=typeof me=="number"?me:me.reduce((je,qe)=>je*qe,1);return _e>0?Math.ceil(Pe*_e):void 0},Ps=ie=>{switch(ie){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: ${ie}`)}},ja=ie=>{switch(ie){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: ${ie}`)}},ta=ie=>ie==="float32"||ie==="float16"||ie==="int32"||ie==="int64"||ie==="uint32"||ie==="uint8"||ie==="bool"||ie==="uint4"||ie==="int4",Ii=ie=>ie==="float32"||ie==="float16"||ie==="int32"||ie==="int64"||ie==="uint32"||ie==="uint64"||ie==="int8"||ie==="uint8"||ie==="bool"||ie==="uint4"||ie==="int4",Rn=ie=>{switch(ie){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: ${ie}`)}}}),an,ra=u(()=>{Ct(),an=async ie=>{if(typeof ie=="string"){let me=await fetch(ie);if(!me.ok)throw new Error(`failed to load external data file: ${ie}`);let _e=me.headers.get("Content-Length"),Pe=_e?parseInt(_e,10):0;if(Pe<1073741824)return new Uint8Array(await me.arrayBuffer());{if(!me.body)throw new Error(`failed to load external data file: ${ie}, no response body.`);let je=me.body.getReader(),qe;try{qe=new ArrayBuffer(Pe)}catch(De){if(De instanceof RangeError){let Ve=Math.ceil(Pe/65536);qe=new WebAssembly.Memory({initial:Ve,maximum:Ve}).buffer}else throw De}let Ie=0;for(;;){let{done:De,value:Ve}=await je.read();if(De)break;let it=Ve.byteLength;new Uint8Array(qe,Ie,it).set(Ve),Ie+=it}return new Uint8Array(qe,0,Pe)}}else return ie instanceof Blob?new Uint8Array(await ie.arrayBuffer()):ie instanceof Uint8Array?ie:new Uint8Array(ie)}}),Di,qo,na,mi,fs,ia,cr,Li,Ea,rs,Qe,gi,yt,Se=u(()=>{lt(),Al(),Ar(),Wt(),pi(),Ca(),ra(),Di=(ie,me)=>{Ut()._OrtInit(ie,me)!==0&&Et("Can't initialize onnxruntime.")},qo=async ie=>{Di(ie.wasm.numThreads,ja(ie.logLevel))},na=async(ie,me)=>{var Pe,je;(je=(Pe=Ut()).asyncInit)==null||je.call(Pe);let _e=ie.webgpu.adapter;if(me==="webgpu"){if(typeof navigator>"u"||!navigator.gpu)throw new Error("WebGPU is not supported in current environment");if(_e){if(typeof _e.limits!="object"||typeof _e.features!="object"||typeof _e.requestDevice!="function")throw new Error("Invalid GPU adapter set in `env.webgpu.adapter`. It must be a GPUAdapter object.")}else{let qe=ie.webgpu.powerPreference;if(qe!==void 0&&qe!=="low-power"&&qe!=="high-performance")throw new Error(`Invalid powerPreference setting: "${qe}"`);let Ie=ie.webgpu.forceFallbackAdapter;if(Ie!==void 0&&typeof Ie!="boolean")throw new Error(`Invalid forceFallbackAdapter setting: "${Ie}"`);if(_e=await navigator.gpu.requestAdapter({powerPreference:qe,forceFallbackAdapter:Ie}),!_e)throw new Error('Failed to get GPU adapter. You may need to enable flag "--enable-unsafe-webgpu" if you are using Chrome.')}}if(me==="webnn"&&(typeof navigator>"u"||!navigator.ml))throw new Error("WebNN is not supported in current environment")},mi=new Map,fs=ie=>{let me=Ut(),_e=me.stackSave();try{let Pe=me.PTR_SIZE,je=me.stackAlloc(2*Pe);me._OrtGetInputOutputCount(ie,je,je+Pe)!==0&&Et("Can't get session input/output count.");let qe=Pe===4?"i32":"i64";return[Number(me.getValue(je,qe)),Number(me.getValue(je+Pe,qe))]}finally{me.stackRestore(_e)}},ia=(ie,me)=>{let _e=Ut(),Pe=_e.stackSave(),je=0;try{let qe=_e.PTR_SIZE,Ie=_e.stackAlloc(2*qe);_e._OrtGetInputOutputMetadata(ie,me,Ie,Ie+qe)!==0&&Et("Can't get session input/output metadata.");let De=Number(_e.getValue(Ie,"*"));je=Number(_e.getValue(Ie+qe,"*"));let Ve=_e.HEAP32[je/4];if(Ve===0)return[De,0];let it=_e.HEAPU32[je/4+1],ut=[];for(let st=0;st<it;st++){let et=Number(_e.getValue(je+8+st*qe,"*"));ut.push(et!==0?_e.UTF8ToString(et):Number(_e.getValue(je+8+(st+it)*qe,"*")))}return[De,Ve,ut]}finally{_e.stackRestore(Pe),je!==0&&_e._OrtFree(je)}},cr=ie=>{let me=Ut(),_e=me._malloc(ie.byteLength);if(_e===0)throw new Error(`Can't create a session. failed to allocate a buffer of size ${ie.byteLength}.`);return me.HEAPU8.set(ie,_e),[_e,ie.byteLength]},Li=async(ie,me)=>{var ut,st,et;let _e,Pe,je=Ut();Array.isArray(ie)?[_e,Pe]=ie:ie.buffer===je.HEAPU8.buffer?[_e,Pe]=[ie.byteOffset,ie.byteLength]:[_e,Pe]=cr(ie);let qe=0,Ie=0,De=[],Ve=[],it=[];try{if([Ie,De]=await Nl(me),(me==null?void 0:me.externalData)&&je.mountExternalData){let Ur=[];for(let gr of me.externalData){let Mn=typeof gr=="string"?gr:gr.path;Ur.push(an(typeof gr=="string"?gr:gr.data).then(ri=>{je.mountExternalData(Mn,ri)}))}await Promise.all(Ur)}for(let Ur of(me==null?void 0:me.executionProviders)??[])if((typeof Ur=="string"?Ur:Ur.name)==="webnn"){if(je.shouldTransferToMLTensor=!1,typeof Ur!="string"){let gr=Ur,Mn=gr==null?void 0:gr.context,ri=gr==null?void 0:gr.gpuDevice,vi=gr==null?void 0:gr.deviceType,Pl=gr==null?void 0:gr.powerPreference;Mn?je.currentContext=Mn:ri?je.currentContext=await je.webnnCreateMLContext(ri):je.currentContext=await je.webnnCreateMLContext({deviceType:vi,powerPreference:Pl})}else je.currentContext=await je.webnnCreateMLContext();break}qe=await je._OrtCreateSession(_e,Pe,Ie),(ut=je.webgpuOnCreateSession)==null||ut.call(je,qe),qe===0&&Et("Can't create a session."),(st=je.jsepOnCreateSession)==null||st.call(je),je.currentContext&&(je.webnnRegisterMLContext(qe,je.currentContext),je.currentContext=void 0,je.shouldTransferToMLTensor=!0);let[Ot,We]=fs(qe),pt=!!(me!=null&&me.enableGraphCapture),Rr=[],tr=[],rr=[],Mr=[],zt=[];for(let Ur=0;Ur<Ot;Ur++){let[gr,Mn,ri]=ia(qe,Ur);gr===0&&Et("Can't get an input name."),Ve.push(gr);let vi=je.UTF8ToString(gr);Rr.push(vi),rr.push(Mn===0?{name:vi,isTensor:!1}:{name:vi,isTensor:!0,type:sn(Mn),shape:ri})}for(let Ur=0;Ur<We;Ur++){let[gr,Mn,ri]=ia(qe,Ur+Ot);gr===0&&Et("Can't get an output name."),it.push(gr);let vi=je.UTF8ToString(gr);tr.push(vi),Mr.push(Mn===0?{name:vi,isTensor:!1}:{name:vi,isTensor:!0,type:sn(Mn),shape:ri})}return mi.set(qe,[qe,Ve,it,null,pt,!1]),[qe,Rr,tr,rr,Mr]}catch(Ot){throw Ve.forEach(We=>je._OrtFree(We)),it.forEach(We=>je._OrtFree(We)),qe!==0&&je._OrtReleaseSession(qe)!==0&&Et("Can't release session."),Ot}finally{je._free(_e),Ie!==0&&je._OrtReleaseSessionOptions(Ie)!==0&&Et("Can't release session options."),De.forEach(Ot=>je._free(Ot)),(et=je.unmountExternalData)==null||et.call(je)}},Ea=ie=>{var Ve,it,ut;let me=Ut(),_e=mi.get(ie);if(!_e)throw new Error(`cannot release session. invalid session id: ${ie}`);let[Pe,je,qe,Ie,De]=_e;Ie&&(De&&me._OrtClearBoundOutputs(Ie.handle)!==0&&Et("Can't clear bound outputs."),me._OrtReleaseBinding(Ie.handle)!==0&&Et("Can't release IO binding.")),(Ve=me.jsepOnReleaseSession)==null||Ve.call(me,ie),(it=me.webnnOnReleaseSession)==null||it.call(me,ie),(ut=me.webgpuOnReleaseSession)==null||ut.call(me,ie),je.forEach(st=>me._OrtFree(st)),qe.forEach(st=>me._OrtFree(st)),me._OrtReleaseSession(Pe)!==0&&Et("Can't release session."),mi.delete(ie)},rs=async(ie,me,_e,Pe,je,qe,Ie=!1)=>{if(!ie){me.push(0);return}let De=Ut(),Ve=De.PTR_SIZE,it=ie[0],ut=ie[1],st=ie[3],et=st,Ot,We;if(it==="string"&&(st==="gpu-buffer"||st==="ml-tensor"))throw new Error("String tensor is not supported on GPU.");if(Ie&&st!=="gpu-buffer")throw new Error(`External buffer must be provided for input/output index ${qe} when enableGraphCapture is true.`);if(st==="gpu-buffer"){let tr=ie[2].gpuBuffer;We=ti(ei(it),ut);{let rr=De.jsepRegisterBuffer;if(!rr)throw new Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');Ot=rr(Pe,qe,tr,We)}}else if(st==="ml-tensor"){let tr=ie[2].mlTensor;We=ti(ei(it),ut);let rr=De.webnnRegisterMLTensor;if(!rr)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');Ot=rr(Pe,tr,ei(it),ut)}else{let tr=ie[2];if(Array.isArray(tr)){We=Ve*tr.length,Ot=De._malloc(We),_e.push(Ot);for(let rr=0;rr<tr.length;rr++){if(typeof tr[rr]!="string")throw new TypeError(`tensor data at index ${rr} is not a string`);De.setValue(Ot+rr*Ve,en(tr[rr],_e),"*")}}else{let rr=De.webnnIsGraphInput,Mr=De.webnnIsGraphOutput;if(it!=="string"&&rr&&Mr){let zt=De.UTF8ToString(je);if(rr(Pe,zt)||Mr(Pe,zt)){let Ur=ei(it);We=ti(Ur,ut),et="ml-tensor";let gr=De.webnnCreateTemporaryTensor,Mn=De.webnnUploadTensor;if(!gr||!Mn)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');let ri=await gr(Pe,Ur,ut);Mn(ri,new Uint8Array(tr.buffer,tr.byteOffset,tr.byteLength)),Ot=ri}else We=tr.byteLength,Ot=De._malloc(We),_e.push(Ot),De.HEAPU8.set(new Uint8Array(tr.buffer,tr.byteOffset,We),Ot)}else We=tr.byteLength,Ot=De._malloc(We),_e.push(Ot),De.HEAPU8.set(new Uint8Array(tr.buffer,tr.byteOffset,We),Ot)}}let pt=De.stackSave(),Rr=De.stackAlloc(4*ut.length);try{ut.forEach((rr,Mr)=>De.setValue(Rr+Mr*Ve,rr,Ve===4?"i32":"i64"));let tr=De._OrtCreateTensor(ei(it),Ot,We,Rr,ut.length,Rn(et));tr===0&&Et(`Can't create tensor for input/output. session=${Pe}, index=${qe}.`),me.push(tr)}finally{De.stackRestore(pt)}},Qe=async(ie,me,_e,Pe,je,qe)=>{var yi,Nc,qu;let Ie=Ut(),De=Ie.PTR_SIZE,Ve=mi.get(ie);if(!Ve)throw new Error(`cannot run inference. invalid session id: ${ie}`);let it=Ve[0],ut=Ve[1],st=Ve[2],et=Ve[3],Ot=Ve[4];Ve[5];let We=me.length,pt=Pe.length,Rr=0,tr=[],rr=[],Mr=[],zt=[],Ur=[],gr=Ie.stackSave(),Mn=Ie.stackAlloc(We*De),ri=Ie.stackAlloc(We*De),vi=Ie.stackAlloc(pt*De),Pl=Ie.stackAlloc(pt*De);try{[Rr,tr]=to(qe),Me("wasm prepareInputOutputTensor");for(let hr=0;hr<We;hr++)await rs(_e[hr],rr,zt,ie,ut[me[hr]],me[hr],Ot);for(let hr=0;hr<pt;hr++)await rs(je[hr],Mr,zt,ie,st[Pe[hr]],We+Pe[hr],Ot);Ue("wasm prepareInputOutputTensor");for(let hr=0;hr<We;hr++)Ie.setValue(Mn+hr*De,rr[hr],"*"),Ie.setValue(ri+hr*De,ut[me[hr]],"*");for(let hr=0;hr<pt;hr++)Ie.setValue(vi+hr*De,Mr[hr],"*"),Ie.setValue(Pl+hr*De,st[Pe[hr]],"*");(yi=Ie.jsepOnRunStart)==null||yi.call(Ie,it),(Nc=Ie.webnnOnRunStart)==null||Nc.call(Ie,it);let In;In=await Ie._OrtRun(it,ri,Mn,We,Pl,pt,vi,Rr),In!==0&&Et("failed to call OrtRun().");let Ms=[],Hu=[];Me("wasm ProcessOutputTensor");for(let hr=0;hr<pt;hr++){let ps=Number(Ie.getValue(vi+hr*De,"*"));if(ps===Mr[hr]||Ur.includes(Mr[hr])){Ms.push(je[hr]),ps!==Mr[hr]&&Ie._OrtReleaseTensor(ps)!==0&&Et("Can't release tensor.");continue}let Tf=Ie.stackSave(),oa=Ie.stackAlloc(4*De),Ho=!1,_n,bi=0;try{Ie._OrtGetTensorData(ps,oa,oa+De,oa+2*De,oa+3*De)!==0&&Et(`Can't access output tensor data on index ${hr}.`);let Oc=De===4?"i32":"i64",xi=Number(Ie.getValue(oa,Oc));bi=Ie.getValue(oa+De,"*");let Vu=Ie.getValue(oa+De*2,"*"),Af=Number(Ie.getValue(oa+De*3,Oc)),la=[];for(let Sn=0;Sn<Af;Sn++)la.push(Number(Ie.getValue(Vu+Sn*De,Oc)));Ie._OrtFree(Vu)!==0&&Et("Can't free memory for tensor dims.");let ms=la.reduce((Sn,tn)=>Sn*tn,1);_n=sn(xi);let Is=et==null?void 0:et.outputPreferredLocations[Pe[hr]];if(_n==="string"){if(Is==="gpu-buffer"||Is==="ml-tensor")throw new Error("String tensor is not supported on GPU.");let Sn=[];for(let tn=0;tn<ms;tn++){let gs=Ie.getValue(bi+tn*De,"*"),Gu=Ie.getValue(bi+(tn+1)*De,"*"),Ku=tn===ms-1?void 0:Gu-gs;Sn.push(Ie.UTF8ToString(gs,Ku))}Ms.push([_n,la,Sn,"cpu"])}else if(Is==="gpu-buffer"&&ms>0){let Sn=Ie.jsepGetBuffer;if(!Sn)throw new Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');let tn=Sn(bi),gs=ti(xi,ms);if(gs===void 0||!ta(_n))throw new Error(`Unsupported data type: ${_n}`);Ho=!0,Ms.push([_n,la,{gpuBuffer:tn,download:Ie.jsepCreateDownloader(tn,gs,_n),dispose:()=>{Ie._OrtReleaseTensor(ps)!==0&&Et("Can't release tensor.")}},"gpu-buffer"])}else if(Is==="ml-tensor"&&ms>0){let Sn=Ie.webnnEnsureTensor,tn=Ie.webnnIsGraphInputOutputTypeSupported;if(!Sn||!tn)throw new Error('preferredLocation "ml-tensor" is not supported without using WebNN.');if(ti(xi,ms)===void 0||!Ii(_n))throw new Error(`Unsupported data type: ${_n}`);if(!tn(ie,_n,!1))throw new Error(`preferredLocation "ml-tensor" for ${_n} output is not supported by current WebNN Context.`);let gs=await Sn(ie,bi,xi,la,!1);Ho=!0,Ms.push([_n,la,{mlTensor:gs,download:Ie.webnnCreateMLTensorDownloader(bi,_n),dispose:()=>{Ie.webnnReleaseTensorId(bi),Ie._OrtReleaseTensor(ps)}},"ml-tensor"])}else if(Is==="ml-tensor-cpu-output"&&ms>0){let Sn=Ie.webnnCreateMLTensorDownloader(bi,_n)(),tn=Ms.length;Ho=!0,Hu.push((async()=>{let gs=[tn,await Sn];return Ie.webnnReleaseTensorId(bi),Ie._OrtReleaseTensor(ps),gs})()),Ms.push([_n,la,[],"cpu"])}else{let Sn=Ps(_n),tn=new Sn(ms);new Uint8Array(tn.buffer,tn.byteOffset,tn.byteLength).set(Ie.HEAPU8.subarray(bi,bi+tn.byteLength)),Ms.push([_n,la,tn,"cpu"])}}finally{Ie.stackRestore(Tf),_n==="string"&&bi&&Ie._free(bi),Ho||Ie._OrtReleaseTensor(ps)}}et&&!Ot&&(Ie._OrtClearBoundOutputs(et.handle)!==0&&Et("Can't clear bound outputs."),mi.set(ie,[it,ut,st,et,Ot,!1]));for(let[hr,ps]of await Promise.all(Hu))Ms[hr][2]=ps;return Ue("wasm ProcessOutputTensor"),Ms}finally{(qu=Ie.webnnOnRunEnd)==null||qu.call(Ie,it),Ie.stackRestore(gr),rr.forEach(In=>Ie._OrtReleaseTensor(In)),Mr.forEach(In=>Ie._OrtReleaseTensor(In)),zt.forEach(In=>Ie._free(In)),Rr!==0&&Ie._OrtReleaseRunOptions(Rr),tr.forEach(In=>Ie._free(In))}},gi=ie=>{let me=Ut(),_e=mi.get(ie);if(!_e)throw new Error("invalid session id");let Pe=_e[0],je=me._OrtEndProfiling(Pe);je===0&&Et("Can't get an profile file name."),me._OrtFree(je)},yt=ie=>{let me=[];for(let _e of ie){let Pe=_e[2];!Array.isArray(Pe)&&"buffer"in Pe&&me.push(Pe.buffer)}return me}}),ze,tt,At,ir,dr,Br,Dr,gn,Vr,wn,Lr,hs,Ta,io,Rs,Ef,so,ao,Fu=u(()=>{lt(),Se(),pi(),hi(),ze=()=>!!P.wasm.proxy&&typeof document<"u",At=!1,ir=!1,dr=!1,gn=new Map,Vr=(ie,me)=>{let _e=gn.get(ie);_e?_e.push(me):gn.set(ie,[me])},wn=()=>{if(At||!ir||dr||!tt)throw new Error("worker not ready")},Lr=ie=>{switch(ie.data.type){case"init-wasm":At=!1,ie.data.err?(dr=!0,Dr[1](ie.data.err)):(ir=!0,Dr[0]()),Br&&(URL.revokeObjectURL(Br),Br=void 0);break;case"init-ep":case"copy-from":case"create":case"release":case"run":case"end-profiling":{let me=gn.get(ie.data.type);ie.data.err?me.shift()[1](ie.data.err):me.shift()[0](ie.data.out);break}}},hs=async()=>{if(!ir){if(At)throw new Error("multiple calls to 'initWasm()' detected.");if(dr)throw new Error("previous call to 'initWasm()' failed.");if(At=!0,ze())return new Promise((ie,me)=>{tt==null||tt.terminate(),ea().then(([_e,Pe])=>{try{tt=Pe,tt.onerror=qe=>me(qe),tt.onmessage=Lr,Dr=[ie,me];let je={type:"init-wasm",in:P};if(!je.in.wasm.wasmPaths&&_e){let qe=fi();qe&&(je.in.wasm.wasmPaths=qe)}tt.postMessage(je),Br=_e}catch(je){me(je)}},me)});try{await Os(P.wasm),await qo(P),ir=!0}catch(ie){throw dr=!0,ie}finally{At=!1}}},Ta=async ie=>{if(ze())return wn(),new Promise((me,_e)=>{Vr("init-ep",[me,_e]);let Pe={type:"init-ep",in:{epName:ie,env:P}};tt.postMessage(Pe)});await na(P,ie)},io=async ie=>ze()?(wn(),new Promise((me,_e)=>{Vr("copy-from",[me,_e]);let Pe={type:"copy-from",in:{buffer:ie}};tt.postMessage(Pe,[ie.buffer])})):cr(ie),Rs=async(ie,me)=>{if(ze()){if(me!=null&&me.preferredOutputLocation)throw new Error('session option "preferredOutputLocation" is not supported for proxy.');return wn(),new Promise((_e,Pe)=>{Vr("create",[_e,Pe]);let je={type:"create",in:{model:ie,options:{...me}}},qe=[];ie instanceof Uint8Array&&qe.push(ie.buffer),tt.postMessage(je,qe)})}else return Li(ie,me)},Ef=async ie=>{if(ze())return wn(),new Promise((me,_e)=>{Vr("release",[me,_e]);let Pe={type:"release",in:ie};tt.postMessage(Pe)});Ea(ie)},so=async(ie,me,_e,Pe,je,qe)=>{if(ze()){if(_e.some(Ie=>Ie[3]!=="cpu"))throw new Error("input tensor on GPU is not supported for proxy.");if(je.some(Ie=>Ie))throw new Error("pre-allocated output tensor is not supported for proxy.");return wn(),new Promise((Ie,De)=>{Vr("run",[Ie,De]);let Ve=_e,it={type:"run",in:{sessionId:ie,inputIndices:me,inputs:Ve,outputIndices:Pe,options:qe}};tt.postMessage(it,yt(Ve))})}else return Qe(ie,me,_e,Pe,je,qe)},ao=async ie=>{if(ze())return wn(),new Promise((me,_e)=>{Vr("end-profiling",[me,_e]);let Pe={type:"end-profiling",in:ie};tt.postMessage(Pe)});gi(ie)}}),Ec,oo,Ol,Tc=u(()=>{lt(),Fu(),Wt(),Ct(),ra(),Ec=(ie,me)=>{switch(ie.location){case"cpu":return[ie.type,ie.dims,ie.data,"cpu"];case"gpu-buffer":return[ie.type,ie.dims,{gpuBuffer:ie.gpuBuffer},"gpu-buffer"];case"ml-tensor":return[ie.type,ie.dims,{mlTensor:ie.mlTensor},"ml-tensor"];default:throw new Error(`invalid data location: ${ie.location} for ${me()}`)}},oo=ie=>{switch(ie[3]){case"cpu":return new ge(ie[0],ie[2],ie[1]);case"gpu-buffer":{let me=ie[0];if(!ta(me))throw new Error(`not supported data type: ${me} for deserializing GPU tensor`);let{gpuBuffer:_e,download:Pe,dispose:je}=ie[2];return ge.fromGpuBuffer(_e,{dataType:me,dims:ie[1],download:Pe,dispose:je})}case"ml-tensor":{let me=ie[0];if(!Ii(me))throw new Error(`not supported data type: ${me} for deserializing MLTensor tensor`);let{mlTensor:_e,download:Pe,dispose:je}=ie[2];return ge.fromMLTensor(_e,{dataType:me,dims:ie[1],download:Pe,dispose:je})}default:throw new Error(`invalid data location: ${ie[3]}`)}},Ol=class{async fetchModelAndCopyToWasmMemory(ie){return io(await an(ie))}async loadModel(ie,me){ct();let _e;typeof ie=="string"?_e=await this.fetchModelAndCopyToWasmMemory(ie):_e=ie,[this.sessionId,this.inputNames,this.outputNames,this.inputMetadata,this.outputMetadata]=await Rs(_e,me),Le()}async dispose(){return Ef(this.sessionId)}async run(ie,me,_e){ct();let Pe=[],je=[];Object.entries(ie).forEach(st=>{let et=st[0],Ot=st[1],We=this.inputNames.indexOf(et);if(We===-1)throw new Error(`invalid input '${et}'`);Pe.push(Ot),je.push(We)});let qe=[],Ie=[];Object.entries(me).forEach(st=>{let et=st[0],Ot=st[1],We=this.outputNames.indexOf(et);if(We===-1)throw new Error(`invalid output '${et}'`);qe.push(Ot),Ie.push(We)});let De=Pe.map((st,et)=>Ec(st,()=>`input "${this.inputNames[je[et]]}"`)),Ve=qe.map((st,et)=>st?Ec(st,()=>`output "${this.outputNames[Ie[et]]}"`):null),it=await so(this.sessionId,je,De,Ie,Ve,_e),ut={};for(let st=0;st<it.length;st++)ut[this.outputNames[Ie[st]]]=qe[st]??oo(it[st]);return Le(),ut}startProfiling(){}endProfiling(){ao(this.sessionId)}}}),sa={};f(sa,{OnnxruntimeWebAssemblyBackend:()=>aa,initializeFlags:()=>Aa,wasmBackend:()=>lo});var Aa,aa,lo,Uu=u(()=>{lt(),Fu(),Tc(),Aa=()=>{(typeof P.wasm.initTimeout!="number"||P.wasm.initTimeout<0)&&(P.wasm.initTimeout=0);let ie=P.wasm.simd;if(typeof ie!="boolean"&&ie!==void 0&&ie!=="fixed"&&ie!=="relaxed"&&(console.warn(`Property "env.wasm.simd" is set to unknown value "${ie}". Reset it to \`false\` and ignore SIMD feature checking.`),P.wasm.simd=!1),typeof P.wasm.proxy!="boolean"&&(P.wasm.proxy=!1),typeof P.wasm.trace!="boolean"&&(P.wasm.trace=!1),typeof P.wasm.numThreads!="number"||!Number.isInteger(P.wasm.numThreads)||P.wasm.numThreads<=0)if(typeof self<"u"&&!self.crossOriginIsolated)P.wasm.numThreads=1;else{let me=typeof navigator>"u"?l("node:os").cpus().length:navigator.hardwareConcurrency;P.wasm.numThreads=Math.min(4,Math.ceil((me||1)/2))}},aa=class{async init(ie){Aa(),await hs(),await Ta(ie)}async createInferenceSessionHandler(ie,me){let _e=new Ol;return await _e.loadModel(ie,me),_e}},lo=new aa}),Wu={};f(Wu,{InferenceSession:()=>Yt,TRACE:()=>Te,TRACE_EVENT_BEGIN:()=>Me,TRACE_EVENT_END:()=>Ue,TRACE_FUNC_BEGIN:()=>ct,TRACE_FUNC_END:()=>Le,Tensor:()=>ge,default:()=>$c,env:()=>P,registerBackend:()=>k}),lt(),lt(),lt();var Ac="1.26.0",$c=Yn;{let ie=(Uu(),h(sa)).wasmBackend;k("cpu",ie,10),k("wasm",ie,10)}return Object.defineProperty(P.versions,"web",{value:Ac,enumerable:!0}),h(Wu)})();e.exports=n})(O1)),O1.exports}var TN;function nq(){return TN||(TN=1,(function(e){var r=rc&&rc.__createBinding||(Object.create?(function(C,T,E,$){$===void 0&&($=E);var N=Object.getOwnPropertyDescriptor(T,E);(!N||("get"in N?!T.__esModule:N.writable||N.configurable))&&(N={enumerable:!0,get:function(){return T[E]}}),Object.defineProperty(C,$,N)}):(function(C,T,E,$){$===void 0&&($=E),C[$]=T[E]})),n=rc&&rc.__setModuleDefault||(Object.create?(function(C,T){Object.defineProperty(C,"default",{enumerable:!0,value:T})}):function(C,T){C.default=T}),i=rc&&rc.__importStar||function(C){if(C&&C.__esModule)return C;var T={};if(C!=null)for(var E in C)E!=="default"&&Object.prototype.hasOwnProperty.call(C,E)&&r(T,C,E);return n(T,C),T};Object.defineProperty(e,"__esModule",{value:!0}),e.MicVAD=e.getDefaultRealTimeVADOptions=e.ort=e.DEFAULT_MODEL=void 0;const s=i(rq()),a=XT(),c=YT(),l=ob(),u=g_(),f=I4(),m=D4();e.DEFAULT_MODEL="legacy",e.ort=s;const h="vad.worklet.bundle.min.js",b="silero_vad_v5.onnx",w="silero_vad_legacy.onnx",k=C=>({...c.defaultFrameProcessorOptions,onFrameProcessed:()=>{},onVADMisfire:()=>{l.log.debug("VAD misfire")},onSpeechStart:()=>{l.log.debug("Detected speech start")},onSpeechEnd:()=>{l.log.debug("Detected speech end")},onSpeechRealStart:()=>{l.log.debug("Detected real speech start")},baseAssetPath:"./",onnxWASMBasePath:"./",model:C,workletOptions:{},getStream:async()=>await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}}),pauseStream:async T=>{T.getTracks().forEach(E=>{E.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=k;const S=C=>"audioWorklet"in C&&typeof AudioWorkletNode=="function"?"AudioWorklet":"ScriptProcessor";async function y(C,T,E,$,N){await E.audioWorklet.addModule(C),T.processorOptions={...T.processorOptions??{},frameSamples:$};const P=new AudioWorkletNode(E,"vad-helper-worklet",T);return P.port.onmessage=async I=>{const W=I.data;if(!(typeof W=="object"&&W&&"message"in W)){console.error("Invalid message event",W);return}switch(W.message){case u.Message.AudioFrame:{if(!("data"in W&&W.data instanceof ArrayBuffer)){console.log("Audio frame message has no data");return}const F=new Float32Array(W.data);await N(F);break}}},P}async function x(C,T,E){const $=new m.Resampler({nativeSampleRate:C.sampleRate,targetSampleRate:16e3,targetFrameSize:T});l.log.debug("using script processor");const P=C.createScriptProcessor(4096,1,1);let I=!1;return P.onaudioprocess=async W=>{if(!I){I=!0;try{const F=W.inputBuffer.getChannelData(0);W.outputBuffer.getChannelData(0).fill(0);const q=$.process(F);for(const z of q)await E(z)}catch(F){console.error("Error processing audio:",F)}finally{I=!1}}},P.connect(C.destination),P}class _{constructor(T,E,$,N,P=!1,I=null,W=null,F=null,U=null,q=null,z=null,Y="uninitialized",ee=!1){this.options=T,this.frameProcessor=E,this.model=$,this.frameSamples=N,this.listening=P,this.errored=I,this._stream=W,this._audioContext=F,this._vadNode=U,this._mediaStreamAudioSourceNode=q,this._audioProcessorAdapterType=z,this.initializationState=Y,this.ownsAudioContext=ee,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=se=>{this.initializationState="errored",this.errored=se},this.start=async()=>{switch(this.initializationState){case"uninitialized":{l.log.debug("initializing micVAD"),this.initializationState="initializing",this.frameProcessor.resume();try{this._stream=await this.options.getStream()}catch(se){throw se instanceof Error?this.setErrored(se.message):this.setErrored(String(se)),se}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"?S(this._audioContext):this.options.processorType,this._audioProcessorAdapterType){case"AudioWorklet":this._vadNode=await y(this.options.baseAssetPath+h,this.options.workletOptions,this._audioContext,this.frameSamples,this.processFrame);break;case"ScriptProcessor":this._vadNode=await x(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),l.log.debug("started micVAD"),this.listening=!0,this.initializationState="initialized";break}case"initializing":{l.log.warn("start called while initializing");break}case"initialized":{if(this.listening)return;this.listening=!0,this.frameProcessor.resume();const{stream:se,audioContext:ue,vadNode:X}=this.getAudioInstances();this._stream=await this.options.resumeStream(se);const Q=new MediaStreamAudioSourceNode(ue,{mediaStream:this._stream});this._mediaStreamAudioSourceNode=Q,Q.connect(X);break}case"destroyed":{l.log.warn("start called after destroyed");break}case"errored":{l.log.error("start called after errored");break}default:{l.log.warn("weird initialization state");break}}},this.pause=async()=>{if(!this.listening)return;this.listening=!1;const{stream:se,mediaStreamAudioSourceNode:ue}=this.getAudioInstances();await this.options.pauseStream(se),ue.disconnect(),this.frameProcessor.pause(this.handleFrameProcessorEvent)},this.destroy=async()=>{var ue;l.log.debug("destroy called"),this.initializationState="destroyed";const{vadNode:se}=this.getAudioInstances();se instanceof AudioWorkletNode&&se.port.postMessage(u.Message.SpeechStop),this.listening&&await this.pause(),await this.model.release(),this.ownsAudioContext&&await((ue=this._audioContext)==null?void 0:ue.close())},this.setOptions=se=>{this.frameProcessor.setOptions(se)},this.processFrame=async se=>{await this.frameProcessor.process(se,this.handleFrameProcessorEvent)},this.handleFrameProcessorEvent=se=>{switch(se.msg){case u.Message.FrameProcessed:this.options.onFrameProcessed(se.probs,se.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(se.audio);break}}}static async new(T={}){const E={...(0,e.getDefaultRealTimeVADOptions)(T.model??e.DEFAULT_MODEL),...T};(0,c.validateOptions)(E),e.ort.env.wasm.wasmPaths=E.onnxWASMBasePath,E.ortConfig!==void 0&&E.ortConfig(e.ort);const $=E.model==="v5"?b:w,N=E.baseAssetPath+$,P=E.model==="v5"?f.SileroV5.new:f.SileroLegacy.new;let I;try{I=await P(e.ort,()=>(0,a.defaultModelFetcher)(N))}catch(z){throw console.error(`Encountered an error while loading model file ${N}`),z}const W=E.model==="v5"?512:1536,F=W/16,U=new c.FrameProcessor(I.process,I.reset_state,{positiveSpeechThreshold:E.positiveSpeechThreshold,negativeSpeechThreshold:E.negativeSpeechThreshold,redemptionMs:E.redemptionMs,preSpeechPadMs:E.preSpeechPadMs,minSpeechMs:E.minSpeechMs,submitUserSpeechOnPause:E.submitUserSpeechOnPause},F),q=new _(E,U,I,W);if(E.startOnLoad)try{await q.start()}catch(z){throw console.error("Error starting micVad",z),z}return q}}e.MicVAD=_})(rc)),rc}var AN;function iq(){return AN||(AN=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=P4();Object.defineProperty(e,"baseAssetPath",{enumerable:!0,get:function(){return r.baseAssetPath}});var n=XT();Object.defineProperty(e,"defaultModelFetcher",{enumerable:!0,get:function(){return n.defaultModelFetcher}});var i=YT();Object.defineProperty(e,"FrameProcessor",{enumerable:!0,get:function(){return i.FrameProcessor}});var s=g_();Object.defineProperty(e,"Message",{enumerable:!0,get:function(){return s.Message}});var a=eq();Object.defineProperty(e,"NonRealTimeVAD",{enumerable:!0,get:function(){return a.NonRealTimeVAD}});const c=tq();e.utils={audioFileToArray:c.audioFileToArray,minFramesForTargetMS:c.minFramesForTargetMS,arrayBufferToBase64:c.arrayBufferToBase64,encodeWAV:c.encodeWAV};var l=nq();Object.defineProperty(e,"DEFAULT_MODEL",{enumerable:!0,get:function(){return l.DEFAULT_MODEL}}),Object.defineProperty(e,"MicVAD",{enumerable:!0,get:function(){return l.MicVAD}}),Object.defineProperty(e,"getDefaultRealTimeVADOptions",{enumerable:!0,get:function(){return l.getDefaultRealTimeVADOptions}})})(A1)),A1}var sq=iq();function kx(e,r,n,i){var a,c;try{(c=(a=window.api)==null?void 0:a.logs)==null||c.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)=>kx(e,"debug",r,n),info:(e,r,n)=>kx(e,"info",r,n),warn:(e,r,n)=>kx(e,"warn",r,n),error:(e,r,n)=>kx(e,"error",r,n)},B4=16e3,aq=6,ap=B4*aq,oq=400,lq=B4*oq/1e3,$N=300,NN=2e3,ON=1500,PN=3e3,cq=600,z4=.5,F4=.35,RN=.85,MN=.7;let Gs=null,yl=!1,Cs=!1;const Aj=new Set;function Cx(e){for(const r of Array.from(Aj))try{r(e)}catch(n){gt.warn("speech","workerDeath listener threw",{error:n instanceof Error?n.message:String(n)})}}let P1=0;const IN=2;let Ep=!1,U4=!1;function W4(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}),uq(`error:${r.message||"unknown"}`)})}function Bw(){return Gs||(Gs=new Worker(new URL(""+new URL("whisperWorker-Dbia1OpC.js",import.meta.url).href,import.meta.url),{type:"module"}),W4(Gs),gt.info("speech","worker spawned"),Gs)}let jx=!1;function uq(e){if(!Ep){if(jx){gt.warn("speech","respawnWorker: already in flight, ignoring",{reason:e});return}if(jx=!0,P1+=1,U4=!0,gt.warn("speech","respawnWorker: starting",{reason:e,attempt:P1}),Cx({reason:e,respawned:!1,finalOnly:!0}),P1>IN){if(Ep=!0,gt.error("speech","respawnWorker: limit exceeded, disabling speech",{limit:IN}),Gs)try{Gs.terminate()}catch{}Gs=null,yl=!1,Cs=!1,Cx({reason:"respawn-limit-exceeded",respawned:!1,finalOnly:!0}),jx=!1;return}if(Gs)try{Gs.terminate()}catch{}Gs=null,yl=!1,Cs=!1;try{Gs=new Worker(new URL(""+new URL("whisperWorker-Dbia1OpC.js",import.meta.url).href,import.meta.url),{type:"module"}),W4(Gs),Cs=!0,Gs.postMessage({type:"load"}),gt.info("speech","respawnWorker: new worker spawned, load posted"),Cx({reason:e,respawned:!0,finalOnly:!0})}catch(r){Ep=!0,gt.error("speech","respawnWorker: spawn failed, disabling speech",{error:r instanceof Error?r.message:String(r)}),Cx({reason:"spawn-failed",respawned:!1,finalOnly:!0})}finally{jx=!1}}}function dq(e,r){if(yl||Cs)return;Cs=!0;const n=Bw();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,Cs=!1,gt.info("speech","preloadModel: ready"),n.removeEventListener("message",i))):s.data.type==="progress"?r==null||r(s.data.pct):s.data.type==="error"&&(Cs=!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 fq(){gt.info("speech","resetModel: clearing load flags"),yl=!1,Cs=!1}function JT(){var e;return typeof Worker<"u"&&!!((e=navigator.mediaDevices)!=null&&e.getUserMedia)&&typeof AudioWorkletNode<"u"}function hq(e){const r=Bw();return!yl&&!Cs&&(Cs=!0,r.postMessage({type:"load"})),new Promise((n,i)=>{const s=a=>{var c,l,u;((c=a.data)==null?void 0:c.type)==="result"?(r.removeEventListener("message",s),n((a.data.text??"").trim())):((l=a.data)==null?void 0:l.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,Cs=!1)};r.addEventListener("message",s),r.postMessage({type:"transcribe",audio:e},[e.buffer])})}function pq(e){let r=Bw(),n=!1,i=null,s=null,a=null,c=null,l=null;const u=[],f=new Set;let m=null,h=0,b=!1,w=0,k=!1,S=!1,y=0,x=0,_=0,C=-1,T=$N,E=0,$=null,N="",P="",I=!1,W=0;function F(oe,de){const ve=Math.min(oe.length,de.length);let $e=0;for(;$e<ve&&oe.charCodeAt($e)===de.charCodeAt($e);)$e++;return $e}function U(oe){const de=F(N,oe);return N=oe,de>P.length&&(P=oe.slice(0,de)),P.length>oe.length&&(P=oe),P}const q=()=>(m||(m=new Float32Array(ap)),m),z=()=>{h=0},Y=oe=>{const de=q(),ve=oe.length;if(ve>=ap){de.set(oe.subarray(ve-ap)),h=ap;return}if(h+ve<=ap){de.set(oe,h),h+=ve;return}const $e=h+ve-ap;de.copyWithin(0,$e,h),h-=$e,de.set(oe,h),h+=ve},ee=()=>{$&&(clearTimeout($),$=null)},se=()=>{ee(),b=!1,k=!1,S=!1,T=$N,N="",P="",I=!1,W=0,z()},ue=()=>{if(n||!b||S||k||$)return;if(h<lq){$=setTimeout(()=>{$=null,ue()},T);return}const oe=performance.now()-y;if(oe<T&&y!==0){$=setTimeout(()=>{$=null,ue()},T-oe);return}if(U4||Ep||e.partialsEnabled&&!e.partialsEnabled())return;const de=q(),ve=new Float32Array(h);ve.set(de.subarray(0,h)),x+=1,_=x,k=!0,E=performance.now(),y=E,r.postMessage({type:"transcribe-partial",audio:ve,seq:x},[ve.buffer])},X=oe=>oe.length===0?Promise.resolve():Ep?(gt.warn("speech","transcribeAudio: speech disabled (worker respawn limit hit)"),n||e.onError("Speech recognition disabled — please reload the app."),Promise.resolve()):new Promise(de=>{u.push(de),x+=1;const ve=x;C=ve,r.postMessage({type:"transcribe",audio:oe,seq:ve},[oe.buffer])}),Q=oe=>{const de=X(oe);return f.add(de),de.finally(()=>{f.delete(de)}),de},Z=oe=>{var de,ve,$e,we,ne;if(oe.data.type==="result"){const ce=oe.data.text,ge=oe.data.seq??0;ge&&ge<C&&gt.warn("speech","result: seq below latestFinalSeq (delivering anyway)",{seq:ge,latestFinalSeq:C}),!n&&ce&&e.onFinal(ce),(de=u.shift())==null||de()}else if(oe.data.type==="partial"){const ce=oe.data.seq??0,ge=oe.data.text??"",Ae=performance.now()-E;k=!1,Ae>=PN?(S=!0,gt.warn("speech","partials.disabled.budget",{elapsedMs:Math.round(Ae),seq:ce})):Ae>=ON&&(T=Math.min(T*2,NN),gt.warn("speech","partials.slowdown",{elapsedMs:Math.round(Ae),newIntervalMs:T,seq:ce})),I||(I=!0,Ae>cq&&T<500&&(T=500,gt.info("speech","partials.probe.slow_host",{elapsedMs:Math.round(Ae),newIntervalMs:500})));const Te=ce!==_||ce<=C;if(!n&&!Te&&ge){const nt=U(ge);nt&&((ve=e.onPartial)==null||ve.call(e,nt),W===0&&(W=performance.now(),gt.info("speech","partial.first",{msSinceSpeechStart:Math.round(W-w)})))}ue()}else if(oe.data.type==="partial-error"){const ce=performance.now()-E;k=!1,ce>=PN?(S=!0,gt.warn("speech","partials.disabled.budget (after error)",{elapsedMs:Math.round(ce),seq:oe.data.seq})):ce>=ON&&(T=Math.min(T*2,NN),gt.warn("speech","partials.slowdown (after error)",{elapsedMs:Math.round(ce),newIntervalMs:T,seq:oe.data.seq})),gt.warn("speech","partial encode failed",{error:oe.data.error,seq:oe.data.seq}),ue()}else oe.data.type==="error"?(n||e.onError(oe.data.error),($e=u.shift())==null||$e()):oe.data.type==="status"?(n||(we=e.onModelStatus)==null||we.call(e,oe.data.status,oe.data.message),oe.data.status==="ready"&&(yl=!0,Cs=!1)):oe.data.type==="progress"&&(n||(ne=e.onProgress)==null||ne.call(e,oe.data.pct))};r.addEventListener("message",Z);const ae=oe=>{var de,ve;if(!n){for(gt.warn("speech","createRecognition: worker death event",oe),(de=e.onStatusChange)==null||de.call(e,"restarting");u.length;)(ve=u.shift())==null||ve();if(f.clear(),ee(),k=!1,oe.respawned){try{r.removeEventListener("message",Z)}catch{}r=Bw(),r.addEventListener("message",Z)}}};return Aj.add(ae),{start:async()=>{if(!n){if(Ep){e.onError("Speech recognition disabled — please reload the app.");return}!yl&&!Cs&&(Cs=!0,gt.info("speech","createRecognition.start: triggering model load"),r.postMessage({type:"load"})),gt.info("speech","createRecognition.start: initializing VAD",{modelReady:yl,modelLoading:Cs});try{const oe=new URL("vad/",document.baseURI).href,de=e.inputDeviceId||null,ve={channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0};de&&(ve.deviceId={exact:de}),gt.info("speech","getUserMedia",{hasDeviceId:!!de,deviceIdPrefix:de?de.slice(0,8):null});const $e=await navigator.mediaDevices.getUserMedia({audio:ve});s=$e,a=new AudioContext;for(const we of $e.getAudioTracks())we.addEventListener("ended",()=>{n||(gt.warn("speech","mic track ended (permission revoked or device removed)"),e.onError("Microphone disconnected or permission revoked"))});try{l=a.createMediaStreamSource(s),c=a.createAnalyser(),c.fftSize=2048,c.smoothingTimeConstant=.3,l.connect(c)}catch(we){gt.warn("speech","analyser init failed",{error:we instanceof Error?we.message:String(we)}),l=null,c=null}i=await sq.MicVAD.new({audioContext:a,getStream:async()=>$e,resumeStream:async()=>$e,pauseStream:async()=>{},baseAssetPath:oe,onnxWASMBasePath:oe,model:"v5",positiveSpeechThreshold:z4,negativeSpeechThreshold:F4,minSpeechMs:300,redemptionMs:1500,preSpeechPadMs:300,submitUserSpeechOnPause:!0,onFrameProcessed:(we,ne)=>{var ce;n||((ce=e.onFrame)==null||ce.call(e,we),b&&(Y(ne),ue()))},onSpeechStart:()=>{var we;n||(se(),b=!0,w=performance.now(),(we=e.onSpeechStart)==null||we.call(e))},onSpeechEnd:we=>{var ne;n||((ne=e.onStatusChange)==null||ne.call(e,"transcribing"),se(),Q(we))},onVADMisfire:()=>{var we,ne;n||((we=e.onStatusChange)==null||we.call(e,"idle"),se(),(ne=e.onMisfire)==null||ne.call(e))}}),i.start()}catch(oe){const de=oe instanceof Error?oe.message:"Microphone access denied",ve=oe instanceof Error?oe.stack:"";if(gt.error("speech","createRecognition.start: VAD init failed",{error:de,stack:ve}),c){try{c.disconnect()}catch{}c=null}if(l){try{l.disconnect()}catch{}l=null}if(s){try{s.getTracks().forEach($e=>$e.stop())}catch{}s=null}if(a){try{await a.close()}catch{}a=null}e.onError(de)}}},stop:async()=>{if(i)try{await i.pause()}catch{}for(se();f.size>0;)await Promise.all(Array.from(f));if(i){try{await i.destroy()}catch{}i=null}if(c){try{c.disconnect()}catch{}c=null}if(l){try{l.disconnect()}catch{}l=null}if(s){try{s.getTracks().forEach(oe=>oe.stop())}catch{}s=null}if(a){try{await a.close()}catch{}a=null}},setVadThresholds:(oe,de)=>{if(i)try{i.setOptions({positiveSpeechThreshold:oe,negativeSpeechThreshold:de})}catch(ve){gt.warn("speech","setVadThresholds failed",{error:ve instanceof Error?ve.message:String(ve)})}},getAnalyser:()=>c,destroy:()=>{if(n=!0,se(),i){try{i.destroy()}catch{}i=null}if(c){try{c.disconnect()}catch{}c=null}if(l){try{l.disconnect()}catch{}l=null}if(a){try{a.close()}catch{}a=null}if(s){try{s.getTracks().forEach(oe=>oe.stop())}catch{}s=null}Aj.delete(ae),r.removeEventListener("message",Z)}}}let ny=null;const $j=new Set,Nj=new Set;function mq(){for(const e of $j)try{e()}catch{}}function Oj(){for(const e of Nj)try{e()}catch{}}function gq(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 vq(e){if(!window.speechSynthesis)return;const r=gq(e);if(!r)return;const n=new SpeechSynthesisUtterance(r);n.rate=1,n.pitch=1,n.onstart=()=>{ny=performance.now(),mq()},n.onend=()=>{!window.speechSynthesis.speaking&&!window.speechSynthesis.pending&&(ny=null,Oj())},n.onerror=i=>{i.error!=="canceled"&&!window.speechSynthesis.speaking&&!window.speechSynthesis.pending&&(ny=null,Oj())},window.speechSynthesis.speak(n)}function q4(){window.speechSynthesis&&(window.speechSynthesis.cancel(),ny=null,Oj())}function H4(){var e;return((e=window.speechSynthesis)==null?void 0:e.speaking)??!1}function yq(){return ny}function bq(e){return $j.add(e),()=>{$j.delete(e)}}function xq(e){return Nj.add(e),()=>{Nj.delete(e)}}function wq(e){H4()&&(e.setVadThresholds(RN,MN),gt.info("voice","tts.duck.on",{reason:"already-speaking-on-attach"}));const r=bq(()=>{e.setVadThresholds(RN,MN),gt.info("voice","tts.duck.on")}),n=xq(()=>{e.setVadThresholds(z4,F4),gt.info("voice","tts.duck.off")});return()=>{r(),n()}}const _q=[{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 Sq(e){const r=e.trim();return _q.find(n=>n.match.test(r))??null}const kq=4e4;let Gd=null;function Tp(){Gd&&clearTimeout(Gd),Gd=setTimeout(()=>{Gd=null,Dt.getState().stopRecording()},kq)}function Ex(){Gd&&(clearTimeout(Gd),Gd=null)}let Cu=null,wu=null;const Cq=.04,jq=.3;let zw=0,Pj=0;function Eq(e){wu!==null&&cancelAnimationFrame(wu);const r=()=>{if(Cu===null||Dt.getState().submitCountdownStartAt===null){wu=null;return}const n=performance.now();if(n-Pj<200&&zw>jq){const s=n-e;gt.info("voice","submit.preempted_by_voice",{reason:"vad",prob:zw.toFixed(2),msIntoCountdown:Math.round(s)}),mu(),Tp();return}const i=V4();if(i){const s=new Uint8Array(i.fftSize);i.getByteTimeDomainData(s);let a=0;for(let l=0;l<s.length;l++){const u=(s[l]-128)/128;a+=u*u}const c=Math.sqrt(a/s.length);if(c>Cq){const l=n-e;gt.info("voice","submit.preempted_by_voice",{reason:"rms",rms:c.toFixed(3),msIntoCountdown:Math.round(l)}),mu(),Tp();return}}wu=requestAnimationFrame(r)};wu=requestAnimationFrame(r)}function Tq(e){Cu&&clearTimeout(Cu);const r=Dt.getState().submitDelayMs,n=performance.now();Dt.setState({submitCountdownStartAt:n}),Cu=setTimeout(()=>{Cu=null,Dt.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)})}Tp()},r),Eq(n)}function mu(){wu!==null&&(cancelAnimationFrame(wu),wu=null),Cu&&(clearTimeout(Cu),Cu=null),Dt.getState().submitCountdownStartAt!==null&&Dt.setState({submitCountdownStartAt:null})}let Ti=null,as=null;function V4(){var e;return((e=Ti==null?void 0:Ti.getAnalyser)==null?void 0:e.call(Ti))??null}const Tx=1e4;let iy=null;function Ax(){iy&&(clearTimeout(iy),iy=null)}let kw=null,Cw=null;function $x(){kw=null,Cw&&(Cw(),Cw=null)}const Aq=1500,$q=9e4;let Nx=0,jw=null,Rj=-1;function Ox(){jw&&(clearTimeout(jw),jw=null,Rj=-1)}const Nq=new Set(["you","You","Thank you.","Thanks for watching.","Thanks for watching!","Thank you for watching.","Thank you for watching!",".","Bye.","Bye!"]),Dt=jn((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=++Nx,i=()=>{n===Nx&&(Ox(),Rj=n,jw=setTimeout(()=>{Rj===n&&r().modelStatus==="loading"&&(gt.warn("voice","mic.gate.timeout: no progress within 90s"),e({modelStatus:"error",error:"Model load timed out",errorKind:"timeout"}))},$q))};i(),dq((s,a)=>{n===Nx&&(s==="ready"?(Ox(),gt.info("voice","modelStatus -> ready"),e({modelStatus:"ready",loadingProgress:100,errorKind:null})):s==="error"?(Ox(),gt.error("voice","modelStatus -> error",{msg:a}),e({modelStatus:"error",error:a,errorKind:"load"})):(i(),e({modelStatus:"loading"})))},s=>{n===Nx&&(i(),e({loadingProgress:Math.round(s)}))})},resetAndRetryModel:()=>{gt.info("voice","mic.gate.retry"),Ox(),fq(),e({modelStatus:"idle",error:null,errorKind:null,loadingProgress:0}),r().initModel()},startRecording:n=>{if(r().isRecording)return;if(Ti){gt.warn("voice","startRecording: prior handle still draining, ignoring");return}if(!JT()){e({error:"Microphone or Web Worker not available",errorKind:"recording"});return}const i=s=>{try{const a=pq({inputDeviceId:s,onStatusChange:c=>{e(c==="transcribing"?{statusPill:"transcribing"}:c==="restarting"?{statusPill:"restarting"}:{statusPill:"idle"})},onPartial:c=>{r().partialsEnabled&&e({lastPartial:c})},partialsEnabled:()=>r().partialsEnabled,onFrame:c=>{zw=c.isSpeech,Pj=performance.now()},onSpeechStart:()=>{if(e({statusPill:"listening",lastPartial:""}),Ex(),mu(),H4()){const l=yq(),u=l!==null?performance.now()-l:null;q4(),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"}),Tp();const c=r().lastBargeInAt;c!==null&&performance.now()-c<600&&gt.warn("voice","barge-in.misfire",{tabId:n,sinceBargeInMs:Math.round(performance.now()-c)})},onFinal:c=>{Tp();const l=c.trim();if(!l||Nq.has(l)){e({lastTranscript:"",lastPartial:"",statusPill:"idle"});return}const u=Sq(l);if(u){gt.info("voice","voice-command",{tabId:n,label:u.label,transcript:l}),window.api.pty.write({tabId:n,data:u.data}),e({lastTranscript:"",lastPartial:"",statusPill:"idle"}),mu();const m=window;m.__transcripts&&(m.__transcripts.push({tabId:n,text:l}),m.__transcripts.length>500&&m.__transcripts.shift());return}window.api.pty.write({tabId:n,data:l}),e({lastTranscript:"",lastPartial:"",statusPill:"idle"}),r().autoSubmit&&Tq(n);const f=window;f.__transcripts&&(f.__transcripts.push({tabId:n,text:l}),f.__transcripts.length>500&&f.__transcripts.shift())},onError:c=>{gt.error("voice","recognition error",{err:c}),mu(),e({error:c,errorKind:"recording",isRecording:!1,lastPartial:"",statusPill:"idle"}),as==null||as(),as=null,Ex(),Ti==null||Ti.destroy(),Ti=null,Ze.error(`Microphone error: ${c}`)},onModelStatus:c=>{c==="ready"?e({modelStatus:"ready",loadingProgress:100}):c==="loading"&&e({modelStatus:"loading"})},onProgress:c=>e({loadingProgress:Math.round(c)})});Ti=a,e({isRecording:!0,error:null,lastTranscript:"",lastPartial:"",statusPill:"listening"}),Tp(),a.start().then(()=>{Ti===a&&(as==null||as(),as=wq(a))}).catch(c=>{const l=c instanceof Error?c.message:String(c);gt.error("voice","handle.start() failed",{error:l}),Ze.error(`Could not start mic: ${l}`)})}catch(a){e({error:a instanceof Error?a.message:"Failed to start recording",errorKind:"recording"})}};Promise.resolve().then(()=>{var s,a,c;return((c=(a=(s=window.api)==null?void 0:s.voice)==null?void 0:a.getDevicePref)==null?void 0:c.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=Ti;n&&(Ex(),mu(),zw=0,Pj=0,as==null||as(),as=null,e({isRecording:!1,lastTranscript:"",lastPartial:"",statusPill:"idle"}),n.stop().finally(()=>{n.destroy(),Ti===n&&(Ti=null),r().hotkeyState==="stopping"&&(Ax(),e({hotkeyState:"idle"}))}))},restartWithDevice:async()=>{if(!r().isRecording)return;const n=Ti;if(!n)return;Ex(),as==null||as(),as=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(),Ti===n&&(Ti=null);const{useSessions:i}=await ab(async()=>{const{useSessions:a}=await Promise.resolve().then(()=>OW);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:()=>mu(),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"&&gt.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 c=r(),{canRecord:l,reason:u}=Mj(c);if(n==="down"){if(u==="error"||u==="load-timeout"){c.resetAndRetryModel(),gt.info("voice-hotkey","down.retry",{source:i,reason:u});return}if(!l&&u!=="loading"){gt.warn("voice-hotkey","miss-model-loading",{modelStatus:c.modelStatus,reason:u});return}if(c.hotkeyState==="recording"||c.isRecording){(s==="toggle"||i==="global")&&(e({hotkeyState:"stopping"}),Ax(),iy=setTimeout(()=>{r().hotkeyState==="stopping"&&(gt.warn("voice-hotkey","drain-timeout",{durationMs:Tx}),e({hotkeyState:"aborted"}),setTimeout(()=>{r().hotkeyState==="aborted"&&e({hotkeyState:"idle"})},0))},Tx),c.stopRecording());return}if(u==="loading"){c.hotkeyState!=="armed"&&(e({hotkeyState:"armed"}),gt.info("voice-hotkey","armed",{source:i,modelStatus:c.modelStatus})),$x(),kw={tabId:a,source:i,mode:s},Cw=Dt.subscribe((f,m)=>{if(kw&&f.modelStatus==="ready"&&m.modelStatus!=="ready"&&f.hotkeyState==="armed"){const h=kw;if($x(),!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"}),Dt.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}),c.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(c.hotkeyState==="armed"){$x(),gt.info("voice-hotkey","miss-model-loading-armed-up"),e({hotkeyState:"idle"});return}c.hotkeyState==="recording"&&(e({hotkeyState:"stopping"}),Ax(),iy=setTimeout(()=>{r().hotkeyState==="stopping"&&(gt.warn("voice-hotkey","drain-timeout",{durationMs:Tx}),e({hotkeyState:"aborted"}),setTimeout(()=>{r().hotkeyState==="aborted"&&e({hotkeyState:"idle"})},0))},Tx),c.stopRecording())}},destroyHotkey:()=>{const n=r();if($x(),mu(),n.hotkeyState==="recording"){gt.warn("voice-hotkey","destroyed-mid-recording"),e({hotkeyState:"destroyed"});try{n.stopRecording()}catch{}}else(n.hotkeyState==="armed"||n.hotkeyState==="stopping")&&(Ax(),e({hotkeyState:"destroyed"}))}})),Oq=e=>({isRecording:e.isRecording,statusPill:e.statusPill,lastPartial:e.lastPartial,lastTranscript:e.lastTranscript,submitCountdownStartAt:e.submitCountdownStartAt}),Mj=e=>JT()?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=Dt,e.__transcripts=[]}function ZT(e,r,n){return new Promise((i,s)=>{const a=setTimeout(()=>s(new Error(`${n} timed out after ${r}ms`)),r);e.then(c=>{clearTimeout(a),i(c)},c=>{clearTimeout(a),s(c)})})}const Pq=5e3,Ou=jn(()=>({snapshot:null,loaded:!1}));let DN=!1,LN=!1,dv;async function Rq(){var e;if(!DN){DN=!0;try{const r=await ZT(window.api.schedule.state(),Pq,"schedule.state");Ou.setState({snapshot:r,loaded:!0}),dv=((e=r.paused)==null?void 0:e.reason)??null}catch(r){if(!LN){LN=!0;const n=r instanceof Error?r.message:String(r);Ze.error(`Scheduler state hydrate failed: ${n}`)}dv=null}window.api.schedule.onState(r=>{var i;const n=((i=r.paused)==null?void 0:i.reason)??null;dv!==void 0&&n!==dv&&(n==="auth"?Ze.error("Scheduler paused: Claude sign-in expired or invalid. Restart the app or re-run `claude login`, then Resume."):n==="network"&&Ze.error("Scheduler paused: billing endpoint unreachable. Will auto-resume in 30 minutes.")),dv=n,Ou.setState({snapshot:r,loaded:!0})})}}const Mq=6e4,Iq=5e3,Ap=jn(()=>({data:null,refreshing:!1}));let BN=!1,Ew=null,zN=null,FN=!1;async function QT(){Ap.setState({refreshing:!0});let e=Mq;try{const r=await ZT(window.api.billing.fetch(),Iq,"billing.fetch");Ap.setState({data:r,refreshing:!1}),r.kind==="transient"?e=zN==="transient"?3e4:5e3:(r.kind==="auth"||r.kind==="meter_rate_limited")&&(e=3e4),zN=r.kind}catch(r){if(Ap.setState({refreshing:!1}),!FN){FN=!0;const n=r instanceof Error?r.message:String(r);Ze.warn(`Billing usage fetch failed: ${n}`)}}Ew=setTimeout(QT,e)}function Dq(){BN||(BN=!0,QT())}function v_(e){return e?e.kind==="ok"||e.kind==="ok-stale"?e.data:(e.kind==="auth"||e.kind==="meter_rate_limited")&&e.cached?e.cached:null:null}function Fw(){Ew!==null&&(clearTimeout(Ew),Ew=null),QT()}function pr({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 o.jsxs("svg",{...s,children:[o.jsx("path",{d:"M4 11l8-7 8 7"}),o.jsx("path",{d:"M6 10v9h12v-9"}),o.jsx("path",{d:"M10 19v-5h4v5"})]});case"terminal":return o.jsxs("svg",{...s,children:[o.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),o.jsx("path",{d:"M7 10l3 2-3 2"}),o.jsx("path",{d:"M13 14h4"})]});case"agents":case"subagents":return o.jsxs("svg",{...s,children:[o.jsx("circle",{cx:"7",cy:"9",r:"2.5"}),o.jsx("circle",{cx:"17",cy:"9",r:"2.5"}),o.jsx("circle",{cx:"12",cy:"17",r:"2.5"}),o.jsx("path",{d:"M8.6 11l2.8 4M15.4 11l-2.8 4M9.5 9h5"})]});case"skills":return o.jsx("svg",{...s,children:o.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 o.jsxs("svg",{...s,children:[o.jsx("circle",{cx:"12",cy:"12",r:"8"}),o.jsx("path",{d:"M12 7v5l3 2"}),o.jsx("path",{d:"M4 6l2 2"})]});case"usage":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M4 19V8M10 19V5M16 19v-7M22 19H2"})});case"hive":return o.jsxs("svg",{...s,children:[o.jsx("path",{d:"M8 4h8l4 7-4 7H8l-4-7z"}),o.jsx("circle",{cx:"12",cy:"11",r:"2.5"})]});case"plugins":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M9 3v4M15 3v4M5 7h14v6a5 5 0 01-5 5h-4a5 5 0 01-5-5V7z"})});case"mcp":return o.jsxs("svg",{...s,children:[o.jsx("rect",{x:"3",y:"4",width:"18",height:"6",rx:"1.5"}),o.jsx("rect",{x:"3",y:"14",width:"18",height:"6",rx:"1.5"}),o.jsx("circle",{cx:"6.5",cy:"7",r:".5",fill:"currentColor"}),o.jsx("circle",{cx:"6.5",cy:"17",r:".5",fill:"currentColor"})]});case"hooks":return o.jsxs("svg",{...s,children:[o.jsx("path",{d:"M12 4v9a3 3 0 003 3h5"}),o.jsx("path",{d:"M9 17l3 3 3-3"})]});case"keys":return o.jsxs("svg",{...s,children:[o.jsx("circle",{cx:"8",cy:"12",r:"4"}),o.jsx("path",{d:"M12 12h9M17 12v3M20 12v2"})]});case"plans":return o.jsxs("svg",{...s,children:[o.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),o.jsx("path",{d:"M8 9h8M8 13h8M8 17h5"})]});case"tasks":return o.jsxs("svg",{...s,children:[o.jsx("rect",{x:"3",y:"4",width:"7",height:"7",rx:"1.5"}),o.jsx("rect",{x:"3",y:"13",width:"7",height:"7",rx:"1.5"}),o.jsx("path",{d:"M14 6h7M14 10h5M14 15h7M14 19h5"})]});case"projects":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M3 7l3-3h4l2 2h9v13H3z"})});case"memory":case"agent-memory":return o.jsxs("svg",{...s,children:[o.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"}),o.jsx("path",{d:"M9 9v6M12 6v12M15 9v6"})]});case"search":case"global-search":return o.jsxs("svg",{...s,children:[o.jsx("circle",{cx:"11",cy:"11",r:"6"}),o.jsx("path",{d:"M16 16l4 4"})]});case"chevron":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M9 6l6 6-6 6"})});case"caret":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M6 9l6 6 6-6"})});case"dot":return o.jsx("svg",{...s,children:o.jsx("circle",{cx:"12",cy:"12",r:"3",fill:"currentColor",stroke:"none"})});case"plus":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M12 5v14M5 12h14"})});case"folder":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M3 7l3-3h4l2 2h9v13H3z"})});case"file":return o.jsxs("svg",{...s,children:[o.jsx("path",{d:"M7 3h7l4 4v14H7z"}),o.jsx("path",{d:"M14 3v4h4"})]});case"play":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M8 5l11 7-11 7z",fill:"currentColor",stroke:"none"})});case"pause":return o.jsxs("svg",{...s,children:[o.jsx("rect",{x:"7",y:"5",width:"3.5",height:"14",fill:"currentColor",stroke:"none",rx:"0.5"}),o.jsx("rect",{x:"13.5",y:"5",width:"3.5",height:"14",fill:"currentColor",stroke:"none",rx:"0.5"})]});case"sparkle":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M12 4v6M12 14v6M4 12h6M14 12h6"})});case"book":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M4 5a2 2 0 012-2h6v18H6a2 2 0 01-2-2zM12 3h6a2 2 0 012 2v14H12z"})});case"compass":return o.jsxs("svg",{...s,children:[o.jsx("circle",{cx:"12",cy:"12",r:"8"}),o.jsx("path",{d:"M15 9l-2 5-5 2 2-5z",fill:"currentColor",stroke:"none"})]});case"scheduler":return o.jsxs("svg",{...s,children:[o.jsx("rect",{x:"3",y:"5",width:"18",height:"15",rx:"2"}),o.jsx("path",{d:"M3 10h18M8 3v4M16 3v4"}),o.jsx("path",{d:"M8 14l2 2 4-4"})]});case"settings":return o.jsxs("svg",{...s,children:[o.jsx("circle",{cx:"12",cy:"12",r:"3"}),o.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 o.jsxs("svg",{...s,children:[o.jsx("rect",{x:"9",y:"3",width:"6",height:"12",rx:"3"}),o.jsx("path",{d:"M5 11a7 7 0 0014 0M12 18v3M9 21h6"})]});case"clock":return o.jsxs("svg",{...s,children:[o.jsx("circle",{cx:"12",cy:"12",r:"8"}),o.jsx("path",{d:"M12 7v5l3 2"})]});case"leaf":return o.jsxs("svg",{...s,children:[o.jsx("path",{d:"M20 4c-9 0-14 5-14 11 0 3 2 5 5 5 6 0 9-5 9-14z"}),o.jsx("path",{d:"M6 20c2-5 5-8 11-11"})]});case"orchestrator":return o.jsxs("svg",{...s,children:[o.jsx("circle",{cx:"12",cy:"6",r:"2.5"}),o.jsx("circle",{cx:"5",cy:"17",r:"2.5"}),o.jsx("circle",{cx:"12",cy:"17",r:"2.5"}),o.jsx("circle",{cx:"19",cy:"17",r:"2.5"}),o.jsx("path",{d:"M12 8.5v6M12 14.5l-7 0M12 14.5l7 0"})]});case"race":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M5 4v16M5 5h7l-1 3h7v6h-7l-1 3H5"})});case"background":return o.jsxs("svg",{...s,children:[o.jsx("path",{d:"M3 4h18v4H3zM3 10h18v4H3zM3 16h18v4H3z"}),o.jsx("circle",{cx:"6",cy:"6",r:".75",fill:"currentColor",stroke:"none"}),o.jsx("circle",{cx:"6",cy:"12",r:".75",fill:"currentColor",stroke:"none"}),o.jsx("circle",{cx:"6",cy:"18",r:".75",fill:"currentColor",stroke:"none"})]});case"repoviz":return o.jsxs("svg",{...s,children:[o.jsx("circle",{cx:"6",cy:"12",r:"3"}),o.jsx("circle",{cx:"18",cy:"6",r:"3"}),o.jsx("circle",{cx:"18",cy:"18",r:"3"}),o.jsx("path",{d:"M8.5 10.5L15.5 7.5M8.5 13.5L15.5 16.5"})]});case"system-prompt":return o.jsxs("svg",{...s,children:[o.jsx("rect",{x:"4",y:"4",width:"16",height:"14",rx:"2"}),o.jsx("path",{d:"M8 10h8M8 14h5M9 18l-2 3M15 18l2 3"})]});case"permissions":return o.jsxs("svg",{...s,children:[o.jsx("rect",{x:"5",y:"11",width:"14",height:"9",rx:"2"}),o.jsx("path",{d:"M8 11V8a4 4 0 018 0v3"}),o.jsx("circle",{cx:"12",cy:"15.5",r:"1.2",fill:"currentColor",stroke:"none"})]});case"tool":return o.jsx("svg",{...s,children:o.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 o.jsxs("svg",{...s,children:[o.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),o.jsx("path",{d:"M3 9h18M7 13h10M7 16h6"})]});case"remote":return o.jsxs("svg",{...s,children:[o.jsx("path",{d:"M5 12.5a7 7 0 0114 0M1.5 9a11 11 0 0121 0M8.5 16a3.5 3.5 0 017 0"}),o.jsx("circle",{cx:"12",cy:"20",r:"1",fill:"currentColor",stroke:"none"})]});case"wifi":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M5 12.5a10 10 0 0114 0M8 15.5a6 6 0 018 0M12 18.5h.01"})});case"shield":return o.jsxs("svg",{...s,children:[o.jsx("path",{d:"M12 3l7 3v5c0 4.5-3 8-7 10-4-2-7-5.5-7-10V6z"}),o.jsx("path",{d:"M9 12l2 2 4-4"})]});case"link":return o.jsxs("svg",{...s,children:[o.jsx("path",{d:"M9 12h6"}),o.jsx("path",{d:"M10 8H7a4 4 0 000 8h3M14 8h3a4 4 0 010 8h-3"})]});case"copy":return o.jsxs("svg",{...s,children:[o.jsx("rect",{x:"9",y:"9",width:"11",height:"11",rx:"2"}),o.jsx("path",{d:"M5 15V5a2 2 0 012-2h8"})]});case"check":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M5 12l5 5 9-10"})});case"x":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M6 6l12 12M18 6L6 18"})});case"send":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M4 11l17-7-7 17-3-7z"})});case"browser":return o.jsxs("svg",{...s,children:[o.jsx("circle",{cx:"12",cy:"12",r:"8"}),o.jsx("ellipse",{cx:"12",cy:"12",rx:"3.2",ry:"8"}),o.jsx("path",{d:"M4 12h16"})]});case"target":return o.jsxs("svg",{...s,children:[o.jsx("circle",{cx:"12",cy:"12",r:"8"}),o.jsx("circle",{cx:"12",cy:"12",r:"3.5"}),o.jsx("path",{d:"M12 2v3M12 19v3M2 12h3M19 12h3"})]});case"record":return o.jsx("svg",{...s,children:o.jsx("circle",{cx:"12",cy:"12",r:"7",fill:"currentColor",stroke:"none"})});case"eye":return o.jsxs("svg",{...s,children:[o.jsx("path",{d:"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7z"}),o.jsx("circle",{cx:"12",cy:"12",r:"3"})]});case"camera":return o.jsxs("svg",{...s,children:[o.jsx("path",{d:"M4 8h3l2-2h6l2 2h3v11H4z"}),o.jsx("circle",{cx:"12",cy:"13.5",r:"3.5"})]});case"arrowleft":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M19 12H5M11 6l-6 6 6 6"})});case"arrowright":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M5 12h14M13 6l6 6-6 6"})});case"reload":return o.jsxs("svg",{...s,children:[o.jsx("path",{d:"M4 12a8 8 0 0114-5.3M20 12a8 8 0 01-14 5.3"}),o.jsx("path",{d:"M18 3v4h-4M6 21v-4h4"})]});case"lock":return o.jsxs("svg",{...s,children:[o.jsx("rect",{x:"5",y:"11",width:"14",height:"9",rx:"2"}),o.jsx("path",{d:"M8 11V8a4 4 0 018 0v3"})]});case"stop":return o.jsx("svg",{...s,children:o.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1.5",fill:"currentColor",stroke:"none"})});case"star":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M12 3l2.6 5.6 6.1.6-4.6 4.1 1.3 6-5.4-3.2-5.4 3.2 1.3-6-4.6-4.1 6.1-.6z"})});case"minus":return o.jsx("svg",{...s,children:o.jsx("path",{d:"M5 12h14"})});default:return null}}function Lq(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 UN=e=>Symbol.iterator in e,WN=e=>"entries"in e,qN=(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},Bq=(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 zq(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:UN(e)&&UN(r)?WN(e)&&WN(r)?qN(e,r):Bq(e,r):qN({entries:()=>Object.entries(e)},{entries:()=>Object.entries(r)})}function G4(e){const r=He.useRef(void 0);return n=>{const i=e(n);return zq(r.current,i)?r.current:r.current=i}}let HN=0;const Fq=1e3;function Uq(e){const r=performance.now();r-HN<Fq||(HN=r,gt.debug("voice","mic.gate.click_rejected",{reason:e}))}function K4(){const e=Dt(f=>f.isRecording),r=Dt(f=>f.error),n=Dt(f=>f.loadingProgress),i=Dt(G4(Mj)),s=()=>{const f=Dt.getState(),{canRecord:m,reason:h}=Mj(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 Uq(h);const b=kt.getState().activeTabId;b&&f.startRecording(b)},a=Lq(i.reason,{loadingPct:n,errorMessage:r,isRecording:e}),c=i.reason==="unsupported",l=!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 o.jsx("button",{onClick:s,disabled:c,"aria-disabled":l,"aria-label":a,title:a,"data-testid":"mic-button","data-state":i.reason,className:`p-1.5 rounded transition-colors ${u}`,children:o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("rect",{x:"9",y:"1",width:"6",height:"12",rx:"3"}),o.jsx("path",{d:"M5 10a7 7 0 0 0 14 0"}),o.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"}),o.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"})]})})}function Wq(){const e=Dt(n=>n.ttsEnabled),r=Dt(n=>n.toggleTTS);return o.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:[o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),e?o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),o.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]}):o.jsxs(o.Fragment,{children:[o.jsx("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),o.jsx("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]})]}),o.jsx("span",{className:"text-[10px] font-medium tracking-wide",children:"TTS"})]})}function qq(e){if(!e||e==="—"||e==="unknown")return e;const r=/\[(\dm)\]/.exec(e),n=/(opus|sonnet|haiku)[-_](\d+)[-_.]?(\d+)?/i.exec(e);if(!n)return e;const i=n[1].charAt(0).toUpperCase()+n[1].slice(1).toLowerCase(),s=n[3]?`${n[2]}.${n[3]}`:n[2];return r?`${i} ${s} ${r[1]}`:`${i} ${s}`}const Px=new Map,Hq=3e4;function X4(e){const[r,n]=D.useState(()=>{var i;return e?((i=Px.get(e))==null?void 0:i.value)??null:null});return D.useEffect(()=>{if(!e){n(null);return}let i=!1;return(async()=>{const a=Px.get(e);if(a&&Date.now()-a.ts<Hq){i||n(a.value);return}try{const c=await window.api.app.gitBranch(e);if(i)return;Px.set(e,{value:c,ts:Date.now()}),n(c)}catch{if(i)return;Px.set(e,{value:null,ts:Date.now()}),n(null)}})(),()=>{i=!0}},[e]),r}const y_=[{key:"overview",group:"Workspace",label:"Home",icon:"home",hint:"Today's sessions + the 5-hour window"},{key:"terminal",group:"Workspace",label:"Terminal",icon:"terminal",hint:"Live Claude Code, in-app"},{key:"browser",group:"Workspace",label:"Browser",icon:"browser",hint:"Embedded dev browser — capture DOM, record click-sequences"},{key:"projects",group:"Workspace",label:"File Explorer",icon:"projects",hint:"Browse files + edit, per project"},{key:"subagents",group:"Workspace",label:"Subagents",icon:"hive",liveKind:"subagents",hint:"Fan out work: Hive · Orchestrate · Race · Boss"},{key:"scheduler",group:"Workspace",label:"Scheduler",icon:"scheduler",liveKind:"scheduler",hint:"Author PRDs + run them as claude -p jobs"},{key:"history",group:"Workspace",label:"History",icon:"history",hint:"Every session, ever — resumable"},{key:"usage",group:"Workspace",label:"Usage",icon:"usage",hint:"Tokens, cost, sessions per day"},{key:"skills",group:"Configure",label:"Skills",icon:"skills",hint:"Reusable instructions Claude loads"},{key:"plugins",group:"Configure",label:"Plugins",icon:"plugins",hint:"Extensions for Claude Code"},{key:"mcp",group:"Configure",label:"MCP Servers",icon:"mcp",hint:"External tools and integrations"},{key:"hooks",group:"Configure",label:"Hooks",icon:"hooks",hint:"Run scripts on session events"},{key:"keybindings",group:"Configure",label:"Keybindings",icon:"keys",hint:"Shortcuts you can override"},{key:"memory",group:"Configure",label:"Memory",icon:"memory",hint:"Workspace memory store"},{key:"system-prompt",group:"Configure",label:"System Prompt",icon:"system-prompt",hint:"Personality and behavior"},{key:"permissions",group:"Configure",label:"Permissions",icon:"permissions",hint:"Allow / deny rules"},{key:"settings",group:"Configure",label:"Settings",icon:"settings",hint:"Theme, voice, billing window"},{key:"remote",group:"Configure",label:"Remote",icon:"remote",hint:"Web remote control — disabled by default"},{key:"voice",group:"Tools",label:"Voice",icon:"mic",hint:"Whisper transcription + push-to-talk"},{key:"repoviz",group:"Tools",label:"Repo Viz",icon:"repoviz",hint:"Language + directory map"},{key:"search",group:"Tools",label:"Search",icon:"global-search",hint:"⌘P file · ⌘⇧F content"}],Vq=Object.fromEntries(y_.map(e=>[e.key,e.group])),VN=y_.filter(e=>e.group==="Workspace"),GN=y_.filter(e=>e.group==="Configure"),KN=y_.filter(e=>e.group==="Tools").map(({key:e,label:r,icon:n,hint:i})=>({key:e,label:r,icon:n,hint:i})),Ij="sm.almanac.sidebarWidth",Y4=180,J4=480,Dj=252;function Gq(){try{const e=parseInt(localStorage.getItem(Ij)??"",10);if(Number.isFinite(e))return Math.min(J4,Math.max(Y4,e))}catch{}return Dj}const Kq=52,Z4="sm.almanac.sidebarCollapsed";function Xq(){try{return localStorage.getItem(Z4)==="1"}catch{}return!1}const Q4="sm.almanac.collapsedGroups";function Yq(){try{const e=localStorage.getItem(Q4);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 Jq(){const e=_w(a=>a.tabs),r=Ou(a=>{var c;return(((c=a.snapshot)==null?void 0:c.jobs)??[]).some(l=>l.status==="running")}),[n,i]=D.useState(()=>Date.now());return D.useEffect(()=>{const a=setInterval(()=>i(Date.now()),5e3);return()=>clearInterval(a)},[]),{subagents:Object.values(e).some(a=>a.agents.some(c=>n-c.at<6e4)),scheduler:r}}function Zq({active:e,onNavigate:r,onNewSession:n}){const[i,s]=D.useState(()=>Yq()),a=D.useCallback(_=>{s(C=>{const T=new Set(C);T.has(_)?T.delete(_):T.add(_);try{localStorage.setItem(Q4,JSON.stringify(Array.from(T)))}catch{}return T})},[]),[c,l]=D.useState(()=>Xq()),u=D.useCallback(()=>{l(_=>{const C=!_;try{localStorage.setItem(Z4,C?"1":"0")}catch{}return C})},[]),f=kt(_=>_.tabs),m=kt(_=>_.activeTabId),h=f.find(_=>_.id===m)??null,b=Jq(),[w,k]=D.useState(()=>Gq()),S=D.useRef(w);S.current=w;const y=D.useCallback(_=>{_.preventDefault();const C=_.clientX,T=S.current;let E=T;const $=P=>{E=Math.min(J4,Math.max(Y4,T+(P.clientX-C))),k(E)},N=()=>{window.removeEventListener("pointermove",$),window.removeEventListener("pointerup",N),document.body.style.cursor="",document.body.style.userSelect="";try{localStorage.setItem(Ij,String(E))}catch{}};window.addEventListener("pointermove",$),window.addEventListener("pointerup",N),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]),x=D.useCallback(()=>{k(Dj);try{localStorage.setItem(Ij,String(Dj))}catch{}},[]);return o.jsxs("aside",{className:"shrink-0 bg-bg-elev border-r border-line flex flex-col relative transition-[width] duration-150",style:{width:c?Kq:w},"data-testid":"tour-leftnav","aria-label":"Primary navigation",children:[o.jsx(Qq,{tab:h,onNewSession:n,rail:c,onToggleRail:u}),o.jsx("div",{className:"flex-1 min-h-0 overflow-auto pb-3",style:{paddingInline:c?"4px":"8px"},children:o.jsxs(o.Fragment,{children:[!c&&o.jsx(R1,{label:"Workspace",collapsed:i.has("Workspace"),count:VN.length,onToggle:()=>a("Workspace")}),(c||!i.has("Workspace"))&&VN.map(_=>o.jsx(XN,{item:_,active:e===_.key,live:_.liveKind?b[_.liveKind]:!1,onClick:()=>r(_.key),rail:c},_.key)),!c&&o.jsx(R1,{label:"Configure",collapsed:i.has("Configure"),count:GN.length,onToggle:()=>a("Configure")}),(c||!i.has("Configure"))&&GN.map(_=>o.jsx(XN,{item:_,active:e===_.key,live:!1,onClick:()=>r(_.key),rail:c},_.key)),!c&&o.jsx(R1,{label:"Tools",collapsed:i.has("Tools"),count:KN.length,onToggle:()=>a("Tools")}),(c||!i.has("Tools"))&&KN.map(_=>o.jsx(eH,{tool:_,active:e===_.key,onClick:()=>r(_.key),rail:c},_.key))]})}),o.jsx(tH,{rail:c}),!c&&o.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar",title:"Drag to resize · double-click to reset",onPointerDown:y,onDoubleClick:x,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 Qq({tab:e,onNewSession:r,rail:n,onToggleRail:i}){const s=(e==null?void 0:e.label)??"no session",a=X4((e==null?void 0:e.cwd)??null);return n?o.jsxs("div",{className:"flex flex-col items-center gap-1.5 pt-2 pb-2 border-b border-rule",children:[o.jsx("button",{onClick:r,"data-testid":"tour-new-session",title:"New session",className:"w-9 h-9 rounded-md bg-bg-hi border border-line text-fg hover:bg-bg-hi/80 hover:border-accent/40 transition-colors flex items-center justify-center",children:o.jsx(pr,{name:"plus",size:15,stroke:1.8})}),o.jsx("button",{onClick:i,title:"Expand sidebar","data-testid":"sidebar-rail-toggle",className:"w-9 h-9 rounded-md text-fg-faint hover:text-fg hover:bg-bg-hi/50 transition-colors flex items-center justify-center",children:o.jsx("span",{style:{display:"inline-flex",transform:"rotate(0deg)"},children:o.jsx(pr,{name:"chevron",size:15,stroke:1.8})})})]}):o.jsxs("div",{className:"px-[18px] pt-[14px] pb-[10px] border-b border-rule",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("div",{className:"text-[11px] font-semibold tracking-[0.06em] text-fg-faint uppercase",children:"Project"}),o.jsx("button",{onClick:i,title:"Collapse sidebar","data-testid":"sidebar-rail-toggle",className:"w-6 h-6 rounded-md text-fg-faint hover:text-fg hover:bg-bg-hi/50 transition-colors flex items-center justify-center",children:o.jsx("span",{style:{display:"inline-flex",transform:"rotate(180deg)"},children:o.jsx(pr,{name:"chevron",size:13,stroke:1.8})})})]}),o.jsxs("div",{className:"flex items-baseline gap-2 mt-1",children:[o.jsx("span",{className:"self-center w-2 h-2 rounded-full bg-sage"}),o.jsx("span",{className:"font-serif text-[18px] font-medium text-fg truncate",title:(e==null?void 0:e.cwd)??"",children:s})]}),o.jsx("div",{className:"text-[12px] text-fg-faint font-mono mt-0.5 truncate",children:a?`⌥${a}`:e?e.cwd:"—"}),o.jsxs("div",{className:"mt-3 flex items-stretch gap-1.5",children:[o.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:[o.jsx(pr,{name:"plus",size:13,stroke:1.8}),"New session"]}),o.jsx("div",{className:"flex items-center rounded-md bg-bg-hi border border-line",children:o.jsx(K4,{})})]})]})}function R1({label:e,collapsed:r,count:n,onToggle:i}){return o.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:[o.jsx("span",{"aria-hidden":!0,className:"inline-block w-2 text-[9px] not-italic transition-transform",style:{transform:r?"rotate(-90deg)":"rotate(0deg)"},children:"▾"}),o.jsx("span",{className:"flex-1",children:e}),r&&o.jsx("span",{className:"not-italic text-[10px] font-mono text-fg-faint/70 normal-case tracking-normal",children:n})]})}function XN({item:e,active:r,live:n,onClick:i,rail:s}){return o.jsxs("button",{onClick:i,title:e.hint,"data-testid":e.key==="scheduler"?"tour-scheduler":void 0,className:`relative w-full flex items-center rounded-[10px] text-left mb-0.5 transition-colors ${s?"justify-center px-0 py-[9px]":"gap-3 px-3.5 py-[9px] text-[14px]"} ${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&&o.jsx("span",{"aria-hidden":!0,className:`absolute top-3 bottom-3 w-[3px] rounded-sm bg-accent ${s?"-left-[4px]":"-left-[10px]"}`}),o.jsx("span",{className:`inline-flex ${r?"text-accent":"text-fg-faint"}`,children:o.jsx(pr,{name:e.icon,size:17,stroke:1.6})}),!s&&o.jsx("span",{className:"flex-1 truncate",children:e.label}),!s&&n&&o.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-accent animate-pulse",title:"live activity"}),s&&n&&o.jsx("span",{className:"absolute top-1.5 right-1.5 w-1.5 h-1.5 rounded-full bg-accent animate-pulse",title:"live activity"})]})}function eH({tool:e,active:r,onClick:n,rail:i}){return o.jsxs("button",{onClick:n,title:e.hint,className:`relative w-full flex items-center rounded-[10px] text-left mb-0.5 transition-colors ${i?"justify-center px-0 py-[7px]":"gap-3 px-3.5 py-[7px] text-[13px]"} ${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&&o.jsx("span",{"aria-hidden":!0,className:`absolute top-2 bottom-2 w-[3px] rounded-sm bg-accent ${i?"-left-[4px]":"-left-[10px]"}`}),o.jsx("span",{className:`inline-flex ${r?"text-accent":"text-fg-faint"}`,children:o.jsx(pr,{name:e.icon,size:15,stroke:1.6})}),!i&&o.jsx("span",{className:"flex-1 truncate",children:e.label})]})}function tH({rail:e}){const r=Dt(l=>l.isRecording),n=kt(l=>l.tabs),i=kt(l=>l.activeTabId),s=n.find(l=>l.id===i)??null,[a,c]=D.useState(null);return D.useEffect(()=>{let l=!1;if(!(s!=null&&s.presetId)){c(null);return}return C4(s.presetId).then(u=>{l||c((u==null?void 0:u.model)??null)}).catch(()=>{l||c(null)}),()=>{l=!0}},[s==null?void 0:s.presetId]),e?o.jsx("div",{className:"py-2.5 border-t border-rule flex justify-center",children:o.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${r?"bg-red-500 animate-pulse":"bg-sage"}`,title:r?"recording":"idle"})}):o.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:[o.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${r?"bg-red-500 animate-pulse":"bg-sage"}`,title:r?"recording":"idle"}),o.jsx("span",{className:"truncate",title:a??"",children:r?"recording…":a?`Claude · ${qq(a)}`:"Claude Code"})]})}function rH({onNavigate:e}){const r=kt(C=>C.tabs),n=kt(C=>C.activeTabId),i=r.find(C=>C.id===n)??null,s=O4(i),a=(s==null?void 0:s.lastEventAt)??0,c=Ap(C=>C.data),l=Ou(C=>{var T;return((T=C.snapshot)==null?void 0:T.paused)??null}),u=X4((i==null?void 0:i.cwd)??null),[,f]=D.useState(0);D.useEffect(()=>{const C=setInterval(()=>f(T=>T+1),6e4);return()=>clearInterval(C)},[]);const m=(s==null?void 0:s.todos)??[],[h,b]=D.useState(!1),w=D.useRef(null);D.useEffect(()=>{if(!h)return;const C=T=>{w.current&&!w.current.contains(T.target)&&b(!1)};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[h]),D.useEffect(()=>{m.length===0&&b(!1)},[m.length]);const k=v_(c),S=(k==null?void 0:k.usage.five_hour)??null,y=S?Math.round(S.utilization):null,x=(c==null?void 0:c.kind)==="ok"||(c==null?void 0:c.kind)==="ok-stale",_=a>0?sH(Date.now()-a):"—";return o.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:[o.jsxs("button",{onClick:()=>e==null?void 0:e("settings"),className:"flex items-center gap-1.5 hover:text-fg transition-colors",title:x?"Connected to Anthropic":"Disconnected",children:[o.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${x?"bg-sage":"bg-fg-faint"}`}),o.jsx("span",{children:x?"connected":"offline"})]}),o.jsx("button",{onClick:()=>e==null?void 0:e("usage"),className:"hover:text-fg transition-colors",title:"Open Usage",children:y!=null?`${y}% of 5h window used`:"5h —"}),l&&o.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 ${l.reason==="auth"||l.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:[o.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current opacity-80"}),"Scheduler paused · ",l.reason]}),i&&o.jsxs("span",{className:"text-fg-faint",title:i.cwd,children:[i.label,u&&o.jsxs("span",{className:"text-fg-dim",children:[" · ⌥",u]})]}),o.jsxs("span",{className:"text-fg-faint",children:["last activity: ",o.jsx("span",{className:"text-fg-dim",children:_})]}),m.length>0&&o.jsx(nH,{ref:w,todos:m,open:h,onToggle:()=>b(C=>!C)}),o.jsx("span",{className:"flex-1"}),o.jsxs("span",{className:"text-fg-faint",children:["v","0.35.18"]})]})}const nH=D.forwardRef(function({todos:r,open:n,onToggle:i},s){const a={completed:r.filter(c=>c.status==="completed").length,in_progress:r.filter(c=>c.status==="in_progress").length,pending:r.filter(c=>c.status==="pending").length};return o.jsxs("div",{ref:s,className:"relative",children:[o.jsxs("button",{onClick:i,className:"flex items-center gap-1.5 hover:text-fg transition-colors",title:"Live to-dos for this session","data-testid":"footer-todos",children:[o.jsxs("span",{className:"text-green-400",children:["✓",a.completed]}),o.jsxs("span",{className:"text-accent",children:["●",a.in_progress]}),o.jsxs("span",{className:"text-fg-dim",children:["○",a.pending]}),o.jsxs("span",{className:"text-fg-faint",children:["todos ",n?"▾":"▴"]})]}),n&&o.jsx("div",{className:"absolute bottom-full left-0 mb-1.5 w-80 max-h-72 overflow-auto bg-bg-elev border border-line rounded shadow-xl p-2 z-50","data-testid":"footer-todos-popover",children:o.jsx("ul",{className:"space-y-0.5",children:r.map((c,l)=>o.jsxs("li",{className:`flex items-start gap-2 py-1 px-1.5 rounded ${c.status==="in_progress"?"bg-bg-hi":""}`,children:[o.jsx(iH,{status:c.status}),o.jsx("span",{className:c.status==="completed"?"text-fg-faint line-through":c.status==="in_progress"?"text-fg":"text-fg-dim",children:c.status==="in_progress"&&c.activeForm?c.activeForm:c.content})]},l))})})]})});function iH({status:e}){return e==="completed"?o.jsx("span",{className:"text-green-400 w-3 shrink-0",children:"✓"}):e==="in_progress"?o.jsx("span",{className:"w-3 shrink-0",children:o.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-accent animate-pulse"})}):o.jsx("span",{className:"text-fg-faint w-3 shrink-0",children:"○"})}function sH(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 M1={exports:{}},YN;function aH(){return YN||(YN=1,(function(e,r){(function(n,i){e.exports=i()})(globalThis,(()=>(()=>{var n={4567:function(c,l,u){var f=this&&this.__decorate||function(_,C,T,E){var $,N=arguments.length,P=N<3?C:E===null?E=Object.getOwnPropertyDescriptor(C,T):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")P=Reflect.decorate(_,C,T,E);else for(var I=_.length-1;I>=0;I--)($=_[I])&&(P=(N<3?$(P):N>3?$(C,T,P):$(C,T))||P);return N>3&&P&&Object.defineProperty(C,T,P),P},m=this&&this.__param||function(_,C){return function(T,E){C(T,E,_)}};Object.defineProperty(l,"__esModule",{value:!0}),l.AccessibilityManager=void 0;const h=u(9042),b=u(9924),w=u(844),k=u(4725),S=u(2585),y=u(3656);let x=l.AccessibilityManager=class extends w.Disposable{constructor(_,C,T,E){super(),this._terminal=_,this._coreBrowserService=T,this._renderService=E,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 b.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,y.addDisposableDomListener)(document,"selectionchange",(()=>this._handleSelectionChange()))),this.register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,w.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(_){for(let C=0;C<_;C++)this._handleChar(" ")}_handleChar(_){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==_&&(this._charsToAnnounce+=_):this._charsToAnnounce+=_,_===`
2897
2897
  `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=h.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(_){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(_)||this._charsToConsume.push(_)}_refreshRows(_,C){this._liveRegionDebouncer.refresh(_,C,this._terminal.rows)}_renderRows(_,C){const T=this._terminal.buffer,E=T.lines.length.toString();for(let $=_;$<=C;$++){const N=T.lines.get(T.ydisp+$),P=[],I=(N==null?void 0:N.translateToString(!0,void 0,void 0,P))||"",W=(T.ydisp+$+1).toString(),F=this._rowElements[$];F&&(I.length===0?(F.innerText=" ",this._rowColumns.set(F,[0,1])):(F.textContent=I,this._rowColumns.set(F,P)),F.setAttribute("aria-posinset",W),F.setAttribute("aria-setsize",E))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(_,C){const T=_.target,E=this._rowElements[C===0?1:this._rowElements.length-2];if(T.getAttribute("aria-posinset")===(C===0?"1":`${this._terminal.buffer.lines.length}`)||_.relatedTarget!==E)return;let $,N;if(C===0?($=T,N=this._rowElements.pop(),this._rowContainer.removeChild(N)):($=this._rowElements.shift(),N=T,this._rowContainer.removeChild($)),$.removeEventListener("focus",this._topBoundaryFocusListener),N.removeEventListener("focus",this._bottomBoundaryFocusListener),C===0){const P=this._createAccessibilityTreeNode();this._rowElements.unshift(P),this._rowContainer.insertAdjacentElement("afterbegin",P)}else{const P=this._createAccessibilityTreeNode();this._rowElements.push(P),this._rowContainer.appendChild(P)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(C===0?-1:1),this._rowElements[C===0?1:this._rowElements.length-2].focus(),_.preventDefault(),_.stopImmediatePropagation()}_handleSelectionChange(){var I;if(this._rowElements.length===0)return;const _=document.getSelection();if(!_)return;if(_.isCollapsed)return void(this._rowContainer.contains(_.anchorNode)&&this._terminal.clearSelection());if(!_.anchorNode||!_.focusNode)return void console.error("anchorNode and/or focusNode are null");let C={node:_.anchorNode,offset:_.anchorOffset},T={node:_.focusNode,offset:_.focusOffset};if((C.node.compareDocumentPosition(T.node)&Node.DOCUMENT_POSITION_PRECEDING||C.node===T.node&&C.offset>T.offset)&&([C,T]=[T,C]),C.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(C={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(C.node))return;const E=this._rowElements.slice(-1)[0];if(T.node.compareDocumentPosition(E)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(T={node:E,offset:((I=E.textContent)==null?void 0:I.length)??0}),!this._rowContainer.contains(T.node))return;const $=({node:W,offset:F})=>{const U=W instanceof Text?W.parentNode:W;let q=parseInt(U==null?void 0:U.getAttribute("aria-posinset"),10)-1;if(isNaN(q))return console.warn("row is invalid. Race condition?"),null;const z=this._rowColumns.get(U);if(!z)return console.warn("columns is null. Race condition?"),null;let Y=F<z.length?z[F]:z.slice(-1)[0]+1;return Y>=this._terminal.cols&&(++q,Y=0),{row:q,column:Y}},N=$(C),P=$(T);if(N&&P){if(N.row>P.row||N.row===P.row&&N.column>=P.column)throw new Error("invalid range");this._terminal.select(N.column,N.row,(P.row-N.row)*this._terminal.cols-N.column+P.column)}}_handleResize(_){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let C=this._rowContainer.children.length;C<this._terminal.rows;C++)this._rowElements[C]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[C]);for(;this._rowElements.length>_;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const _=this._coreBrowserService.mainDocument.createElement("div");return _.setAttribute("role","listitem"),_.tabIndex=-1,this._refreshRowDimensions(_),_}_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 _=0;_<this._terminal.rows;_++)this._refreshRowDimensions(this._rowElements[_])}}_refreshRowDimensions(_){_.style.height=`${this._renderService.dimensions.css.cell.height}px`}};l.AccessibilityManager=x=f([m(1,S.IInstantiationService),m(2,k.ICoreBrowserService),m(3,k.IRenderService)],x)},3614:(c,l)=>{function u(b){return b.replace(/\r?\n/g,"\r")}function f(b,w){return w?"\x1B[200~"+b+"\x1B[201~":b}function m(b,w,k,S){b=f(b=u(b),k.decPrivateModes.bracketedPasteMode&&S.rawOptions.ignoreBracketedPasteMode!==!0),k.triggerDataEvent(b,!0),w.value=""}function h(b,w,k){const S=k.getBoundingClientRect(),y=b.clientX-S.left-10,x=b.clientY-S.top-10;w.style.width="20px",w.style.height="20px",w.style.left=`${y}px`,w.style.top=`${x}px`,w.style.zIndex="1000",w.focus()}Object.defineProperty(l,"__esModule",{value:!0}),l.rightClickHandler=l.moveTextAreaUnderMouseCursor=l.paste=l.handlePasteEvent=l.copyHandler=l.bracketTextForPaste=l.prepareTextForTerminal=void 0,l.prepareTextForTerminal=u,l.bracketTextForPaste=f,l.copyHandler=function(b,w){b.clipboardData&&b.clipboardData.setData("text/plain",w.selectionText),b.preventDefault()},l.handlePasteEvent=function(b,w,k,S){b.stopPropagation(),b.clipboardData&&m(b.clipboardData.getData("text/plain"),w,k,S)},l.paste=m,l.moveTextAreaUnderMouseCursor=h,l.rightClickHandler=function(b,w,k,S,y){h(b,w,k),y&&S.rightClickSelect(b),w.value=S.selectionText,w.select()}},7239:(c,l,u)=>{Object.defineProperty(l,"__esModule",{value:!0}),l.ColorContrastCache=void 0;const f=u(1505);l.ColorContrastCache=class{constructor(){this._color=new f.TwoKeyMap,this._css=new f.TwoKeyMap}setCss(m,h,b){this._css.set(m,h,b)}getCss(m,h){return this._css.get(m,h)}setColor(m,h,b){this._color.set(m,h,b)}getColor(m,h){return this._color.get(m,h)}clear(){this._color.clear(),this._css.clear()}}},3656:(c,l)=>{Object.defineProperty(l,"__esModule",{value:!0}),l.addDisposableDomListener=void 0,l.addDisposableDomListener=function(u,f,m,h){u.addEventListener(f,m,h);let b=!1;return{dispose:()=>{b||(b=!0,u.removeEventListener(f,m,h))}}}},3551:function(c,l,u){var f=this&&this.__decorate||function(x,_,C,T){var E,$=arguments.length,N=$<3?_:T===null?T=Object.getOwnPropertyDescriptor(_,C):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(x,_,C,T);else for(var P=x.length-1;P>=0;P--)(E=x[P])&&(N=($<3?E(N):$>3?E(_,C,N):E(_,C))||N);return $>3&&N&&Object.defineProperty(_,C,N),N},m=this&&this.__param||function(x,_){return function(C,T){_(C,T,x)}};Object.defineProperty(l,"__esModule",{value:!0}),l.Linkifier=void 0;const h=u(3656),b=u(8460),w=u(844),k=u(2585),S=u(4725);let y=l.Linkifier=class extends w.Disposable{get currentLink(){return this._currentLink}constructor(x,_,C,T,E){super(),this._element=x,this._mouseService=_,this._renderService=C,this._bufferService=T,this._linkProviderService=E,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new b.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new b.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,w.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,w.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(x){this._lastMouseEvent=x;const _=this._positionFromMouseEvent(x,this._element,this._mouseService);if(!_)return;this._isMouseOut=!1;const C=x.composedPath();for(let T=0;T<C.length;T++){const E=C[T];if(E.classList.contains("xterm"))break;if(E.classList.contains("xterm-hover"))return}this._lastBufferCell&&_.x===this._lastBufferCell.x&&_.y===this._lastBufferCell.y||(this._handleHover(_),this._lastBufferCell=_)}_handleHover(x){if(this._activeLine!==x.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(x,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,x)||(this._clearCurrentLink(),this._askForLink(x,!0))}_askForLink(x,_){var T,E;this._activeProviderReplies&&_||((T=this._activeProviderReplies)==null||T.forEach(($=>{$==null||$.forEach((N=>{N.link.dispose&&N.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=x.y);let C=!1;for(const[$,N]of this._linkProviderService.linkProviders.entries())_?(E=this._activeProviderReplies)!=null&&E.get($)&&(C=this._checkLinkProviderResult($,x,C)):N.provideLinks(x.y,(P=>{var W,F;if(this._isMouseOut)return;const I=P==null?void 0:P.map((U=>({link:U})));(W=this._activeProviderReplies)==null||W.set($,I),C=this._checkLinkProviderResult($,x,C),((F=this._activeProviderReplies)==null?void 0:F.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(x.y,this._activeProviderReplies)}))}_removeIntersectingLinks(x,_){const C=new Set;for(let T=0;T<_.size;T++){const E=_.get(T);if(E)for(let $=0;$<E.length;$++){const N=E[$],P=N.link.range.start.y<x?0:N.link.range.start.x,I=N.link.range.end.y>x?this._bufferService.cols:N.link.range.end.x;for(let W=P;W<=I;W++){if(C.has(W)){E.splice($--,1);break}C.add(W)}}}}_checkLinkProviderResult(x,_,C){var $;if(!this._activeProviderReplies)return C;const T=this._activeProviderReplies.get(x);let E=!1;for(let N=0;N<x;N++)this._activeProviderReplies.has(N)&&!this._activeProviderReplies.get(N)||(E=!0);if(!E&&T){const N=T.find((P=>this._linkAtPosition(P.link,_)));N&&(C=!0,this._handleNewLink(N))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!C)for(let N=0;N<this._activeProviderReplies.size;N++){const P=($=this._activeProviderReplies.get(N))==null?void 0:$.find((I=>this._linkAtPosition(I.link,_)));if(P){C=!0,this._handleNewLink(P);break}}return C}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(x){if(!this._currentLink)return;const _=this._positionFromMouseEvent(x,this._element,this._mouseService);_&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,_)&&this._currentLink.link.activate(x,this._currentLink.link.text)}_clearCurrentLink(x,_){this._currentLink&&this._lastMouseEvent&&(!x||!_||this._currentLink.link.range.start.y>=x&&this._currentLink.link.range.end.y<=_)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,w.disposeArray)(this._linkCacheDisposables))}_handleNewLink(x){if(!this._lastMouseEvent)return;const _=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);_&&this._linkAtPosition(x.link,_)&&(this._currentLink=x,this._currentLink.state={decorations:{underline:x.link.decorations===void 0||x.link.decorations.underline,pointerCursor:x.link.decorations===void 0||x.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,x.link,this._lastMouseEvent),x.link.decorations={},Object.defineProperties(x.link.decorations,{pointerCursor:{get:()=>{var C,T;return(T=(C=this._currentLink)==null?void 0:C.state)==null?void 0:T.decorations.pointerCursor},set:C=>{var T;(T=this._currentLink)!=null&&T.state&&this._currentLink.state.decorations.pointerCursor!==C&&(this._currentLink.state.decorations.pointerCursor=C,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",C))}},underline:{get:()=>{var C,T;return(T=(C=this._currentLink)==null?void 0:C.state)==null?void 0:T.decorations.underline},set:C=>{var T,E,$;(T=this._currentLink)!=null&&T.state&&(($=(E=this._currentLink)==null?void 0:E.state)==null?void 0:$.decorations.underline)!==C&&(this._currentLink.state.decorations.underline=C,this._currentLink.state.isHovered&&this._fireUnderlineEvent(x.link,C))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((C=>{if(!this._currentLink)return;const T=C.start===0?0:C.start+1+this._bufferService.buffer.ydisp,E=this._bufferService.buffer.ydisp+1+C.end;if(this._currentLink.link.range.start.y>=T&&this._currentLink.link.range.end.y<=E&&(this._clearCurrentLink(T,E),this._lastMouseEvent)){const $=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);$&&this._askForLink($,!1)}}))))}_linkHover(x,_,C){var T;(T=this._currentLink)!=null&&T.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(_,!0),this._currentLink.state.decorations.pointerCursor&&x.classList.add("xterm-cursor-pointer")),_.hover&&_.hover(C,_.text)}_fireUnderlineEvent(x,_){const C=x.range,T=this._bufferService.buffer.ydisp,E=this._createLinkUnderlineEvent(C.start.x-1,C.start.y-T-1,C.end.x,C.end.y-T-1,void 0);(_?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(E)}_linkLeave(x,_,C){var T;(T=this._currentLink)!=null&&T.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(_,!1),this._currentLink.state.decorations.pointerCursor&&x.classList.remove("xterm-cursor-pointer")),_.leave&&_.leave(C,_.text)}_linkAtPosition(x,_){const C=x.range.start.y*this._bufferService.cols+x.range.start.x,T=x.range.end.y*this._bufferService.cols+x.range.end.x,E=_.y*this._bufferService.cols+_.x;return C<=E&&E<=T}_positionFromMouseEvent(x,_,C){const T=C.getCoords(x,_,this._bufferService.cols,this._bufferService.rows);if(T)return{x:T[0],y:T[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(x,_,C,T,E){return{x1:x,y1:_,x2:C,y2:T,cols:this._bufferService.cols,fg:E}}};l.Linkifier=y=f([m(1,S.IMouseService),m(2,S.IRenderService),m(3,k.IBufferService),m(4,S.ILinkProviderService)],y)},9042:(c,l)=>{Object.defineProperty(l,"__esModule",{value:!0}),l.tooMuchOutput=l.promptLabel=void 0,l.promptLabel="Terminal input",l.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(c,l,u){var f=this&&this.__decorate||function(S,y,x,_){var C,T=arguments.length,E=T<3?y:_===null?_=Object.getOwnPropertyDescriptor(y,x):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(S,y,x,_);else for(var $=S.length-1;$>=0;$--)(C=S[$])&&(E=(T<3?C(E):T>3?C(y,x,E):C(y,x))||E);return T>3&&E&&Object.defineProperty(y,x,E),E},m=this&&this.__param||function(S,y){return function(x,_){y(x,_,S)}};Object.defineProperty(l,"__esModule",{value:!0}),l.OscLinkProvider=void 0;const h=u(511),b=u(2585);let w=l.OscLinkProvider=class{constructor(S,y,x){this._bufferService=S,this._optionsService=y,this._oscLinkService=x}provideLinks(S,y){var I;const x=this._bufferService.buffer.lines.get(S-1);if(!x)return void y(void 0);const _=[],C=this._optionsService.rawOptions.linkHandler,T=new h.CellData,E=x.getTrimmedLength();let $=-1,N=-1,P=!1;for(let W=0;W<E;W++)if(N!==-1||x.hasContent(W)){if(x.loadCell(W,T),T.hasExtendedAttrs()&&T.extended.urlId){if(N===-1){N=W,$=T.extended.urlId;continue}P=T.extended.urlId!==$}else N!==-1&&(P=!0);if(P||N!==-1&&W===E-1){const F=(I=this._oscLinkService.getLinkData($))==null?void 0:I.uri;if(F){const U={start:{x:N+1,y:S},end:{x:W+(P||W!==E-1?0:1),y:S}};let q=!1;if(!(C!=null&&C.allowNonHttpProtocols))try{const z=new URL(F);["http:","https:"].includes(z.protocol)||(q=!0)}catch{q=!0}q||_.push({text:F,range:U,activate:(z,Y)=>C?C.activate(z,Y,U):k(0,Y),hover:(z,Y)=>{var ee;return(ee=C==null?void 0:C.hover)==null?void 0:ee.call(C,z,Y,U)},leave:(z,Y)=>{var ee;return(ee=C==null?void 0:C.leave)==null?void 0:ee.call(C,z,Y,U)}})}P=!1,T.hasExtendedAttrs()&&T.extended.urlId?(N=W,$=T.extended.urlId):(N=-1,$=-1)}}y(_)}};function k(S,y){if(confirm(`Do you want to navigate to ${y}?
2898
2898
 
@@ -3446,7 +3446,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
3446
3446
  `)),y=E=>{c(E.line),m(null),u(E.error?E.raw:JSON.stringify(E.value,null,2))},x=E=>{let $;try{$=JSON.stringify(JSON.parse(l))}catch(P){m(P.message);return}const N=k();N[E]=$,S(N),c(null)},_=E=>{const $=k();$.splice(E,1),S($),a===E?(c(null),m(null)):a!==null&&a>E&&c(a-1),s(N=>{const P=new Set;for(const I of N)I!==E&&P.add(I>E?I-1:I);return P})},C=()=>{const E=k();let $=E.length;for(;$>0&&E[$-1].trim()==="";)$--;if(E.splice($,0,"{}"),S(E),w){Ze.info("Record added at end of file — switch to Edit to see it.");return}c($),u(`{
3447
3447
 
3448
3448
  }`),m(null),s(N=>new Set(N).add($))},T=E=>s($=>{const N=new Set($);return N.has(E)?N.delete(E):N.add(E),N});return o.jsxs("div",{className:"h-full overflow-auto bg-bg text-xs",children:[o.jsxs("div",{className:"sticky top-0 z-10 flex items-center gap-3 px-3 py-1.5 bg-bg-elev border-b border-line",children:[o.jsxs("span",{className:"text-fg-faint tabular-nums",children:[b.length.toLocaleString()," record",b.length===1?"":"s"]}),o.jsx("button",{onClick:C,className:"px-2 py-0.5 text-[11px] text-fg-dim hover:text-fg border border-line rounded",children:"+ Add record"}),w&&o.jsxs("span",{className:"text-[10px] text-amber-700",children:["Showing first ",yT.toLocaleString()," — switch to Edit for the full file."]})]}),b.length===0?o.jsx("div",{className:"p-6 text-fg-faint",children:"empty file"}):o.jsx("ul",{className:"divide-y divide-line",children:b.map((E,$)=>{const N=i.has(E.line)||a===E.line;return o.jsxs("li",{className:E.error?"bg-red-500/5":"",children:[o.jsxs("div",{className:"flex items-start gap-2 px-3 py-1.5",children:[o.jsx("span",{className:"w-10 shrink-0 text-right text-fg-faint tabular-nums select-none",children:$+1}),o.jsxs("button",{onClick:()=>T(E.line),className:"flex-1 min-w-0 text-left",title:N?"Collapse":"Expand",children:[o.jsx("span",{className:`mr-1 inline-block transition-transform ${N?"rotate-90":""}`,children:"›"}),o.jsx("span",{className:E.error?"text-red-400":"text-fg-dim",children:vhe(E)})]}),o.jsxs("div",{className:"flex shrink-0 gap-2",children:[a!==E.line&&o.jsx("button",{onClick:()=>y(E),className:"text-fg-faint hover:text-fg",children:"Edit"}),o.jsx("button",{onClick:()=>_(E.line),className:"text-fg-faint hover:text-red-400",children:"Delete"})]})]}),N&&a===E.line&&o.jsxs("div",{className:"px-3 pb-2 pl-12",children:[o.jsx("textarea",{value:l,onChange:P=>{u(P.target.value),m(null)},spellCheck:!1,rows:Math.min(20,l.split(`
3449
- `).length+1),className:"w-full font-mono text-[11px] bg-bg border border-line rounded p-2 text-fg outline-none focus:border-fg-faint resize-y"}),f&&o.jsxs("div",{className:"mt-1 text-[10px] text-red-400",children:["Invalid JSON: ",f]}),o.jsxs("div",{className:"mt-1 flex gap-2",children:[o.jsx("button",{onClick:()=>x(E.line),className:"px-2 py-0.5 text-[11px] text-white bg-blue-600 hover:bg-blue-500 rounded",children:"Save record"}),o.jsx("button",{onClick:()=>{c(null),m(null)},className:"px-2 py-0.5 text-[11px] text-fg-dim hover:text-fg border border-line rounded",children:"Cancel"})]})]}),N&&a!==E.line&&o.jsx("pre",{className:"px-3 pb-2 pl-12 font-mono text-[11px] text-fg-dim whitespace-pre-wrap break-all",children:E.error?E.raw:JSON.stringify(E.value,null,2)})]},E.line)})})]})}function bhe(e){if(!e)return"0 B";const r=["B","KB","MB","GB"],n=Math.min(r.length-1,Math.floor(Math.log(e)/Math.log(1024)));return`${(e/1024**n).toFixed(n?1:0)} ${r[n]}`}function xhe({path:e,name:r,size:n,mime:i,reason:s}){return o.jsx("div",{className:"h-full flex items-center justify-center bg-bg",children:o.jsxs("div",{className:"text-center max-w-sm px-6",children:[o.jsx("div",{className:"mx-auto mb-4 w-12 h-12 rounded-lg border border-line flex items-center justify-center text-fg-faint",children:o.jsxs("svg",{width:22,height:22,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),o.jsx("path",{d:"M14 2v6h6"})]})}),o.jsx("div",{className:"text-sm font-medium text-fg truncate",children:r}),o.jsxs("div",{className:"mt-1 text-[11px] text-fg-faint",children:[s," · ",i," · ",bhe(n)]}),o.jsxs("div",{className:"mt-5 flex items-center justify-center gap-2",children:[o.jsx("button",{onClick:()=>window.api.shell.open({as:"openPath",path:e}),className:"px-3 py-1 text-xs text-fg rounded bg-bg-hi border border-line hover:bg-bg-elev",children:"Open in default app"}),o.jsx("button",{onClick:()=>window.api.shell.open({as:"revealPath",path:e}),className:"px-3 py-1 text-xs text-fg-dim hover:text-fg border border-line rounded",children:"Reveal"})]})]})})}const whe=D.lazy(()=>ab(()=>import("./TiptapBody-BM9Kz1Nm.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(e=>({default:e.TiptapBody})));function ow(e){return e.split("/").filter(Boolean).pop()||e}function qL(e,r){if(!r.length)return e;const n=new Set(r),i={};for(const[s,a]of Object.entries(e))n.has(s)||(i[s]=a);return i}function lw(e){return nB(e)||iB(e)}function bT(){const e=cn(Me=>Me.openFiles),r=cn(Me=>Me.activeFilePath),n=cn(Me=>Me.dirty),i=cn(Me=>Me.viewMode),s=cn(Me=>Me.buffers),a=cn(Me=>Me.setActive),c=cn(Me=>Me.closeFile),l=cn(Me=>Me.closeOthers),u=cn(Me=>Me.closeToTheRight),f=cn(Me=>Me.closeAll),m=cn(Me=>Me.loadBuffer),h=cn(Me=>Me.setBuffer),b=cn(Me=>Me.markSaved),w=cn(Me=>Me.setViewMode),k=Yv(),[S,y]=D.useState({}),[x,_]=D.useState({}),[C,T]=D.useState(null),[E,$]=D.useState(null),[N,P]=D.useState(!1),[I,W]=D.useState(!1),[F,U]=D.useState(!0),q=D.useRef(null),z=D.useRef(null),Y=D.useRef(void 0),ee=D.useCallback(Me=>{q.current=Me},[]),se=D.useCallback(()=>q.current,[]);D.useEffect(()=>{const Me=r;if(!Me||lw(Me))return;if(cn.getState().hasBuffer(Me)){y(mt=>mt[Me]==="ready"?mt:{...mt,[Me]:"ready"});return}let Ue=!1;return y(mt=>({...mt,[Me]:"loading"})),window.api.files.read(Me).then(mt=>{Ue||(mt.binary?y(jt=>({...jt,[Me]:{binary:!0,size:mt.size??0,mime:mt.mime??"application/octet-stream",reason:mt.error??"Binary file"}})):mt.ok?(m(Me,mt.text),y(jt=>({...jt,[Me]:"ready"}))):y(jt=>({...jt,[Me]:{error:mt.error??"failed to read"}})))}),()=>{Ue=!0}},[r,m]),D.useEffect(()=>{$(null)},[r]);const ue=D.useCallback(async(Me,Ue=!1)=>{const mt=cn.getState().buffers[Me];if(mt==null)return;Ue&&P(!0);const jt=await window.api.files.write(Me,mt);jt.ok?(b(Me),_(er=>({...er,[Me]:(er[Me]??0)+1})),Ue||Ze.info(`Saved ${ow(Me)}`)):Ze.error(jt.error??`Couldn't save ${ow(Me)}`),Ue&&P(!1)},[b]);D.useEffect(()=>{if(!k.autosave)return;const Me=r;if(!(!Me||lw(Me)||!n[Me]))return window.clearTimeout(Y.current),Y.current=window.setTimeout(()=>{ue(Me,!0)},1200),()=>window.clearTimeout(Y.current)},[k.autosave,r,n,s,ue]);const X=D.useCallback(Me=>{Me.length&&(y(Ue=>qL(Ue,Me)),_(Ue=>qL(Ue,Me)))},[]),Q=D.useCallback(Me=>{n[Me]?T({kind:"one",path:Me}):(c(Me),X([Me]))},[n,c,X]),Z=D.useCallback(Me=>{e.some(mt=>mt.path!==Me&&n[mt.path])?T({kind:"others",path:Me}):(l(Me),X(e.filter(mt=>mt.path!==Me).map(mt=>mt.path)))},[e,n,l,X]),ae=D.useCallback(Me=>{const Ue=e.findIndex(jt=>jt.path===Me);Ue!==-1&&e.slice(Ue+1).some(jt=>n[jt.path])?T({kind:"right",path:Me}):(u(Me),X(Ue!==-1?e.slice(Ue+1).map(jt=>jt.path):[]))},[e,n,u,X]);D.useEffect(()=>{const Me=Ue=>{if((Ue.metaKey||Ue.ctrlKey)&&(Ue.key==="s"||Ue.key==="S")){const mt=cn.getState().activeFilePath;mt&&!lw(mt)&&(Ue.preventDefault(),ue(mt))}else if((Ue.metaKey||Ue.ctrlKey)&&Ue.shiftKey&&(Ue.key==="f"||Ue.key==="F"))Ue.preventDefault(),W(mt=>!mt);else if((Ue.metaKey||Ue.ctrlKey)&&Ue.shiftKey&&(Ue.key==="w"||Ue.key==="W")){const mt=cn.getState().activeFilePath;mt&&cn.getState().openFiles.length>1&&(Ue.preventDefault(),Z(mt))}else Ue.key==="Escape"&&I&&W(!1)};return window.addEventListener("keydown",Me),()=>window.removeEventListener("keydown",Me)},[ue,I,Z]);const oe=D.useCallback(()=>{e.some(Ue=>n[Ue.path])?T({kind:"all",path:""}):(f(),y({}),_({}))},[e,n,f]),de=()=>{if(C){if(C.kind==="one")c(C.path),X([C.path]);else if(C.kind==="others"){const Me=e.filter(Ue=>Ue.path!==C.path).map(Ue=>Ue.path);l(C.path),X(Me)}else if(C.kind==="right"){const Me=e.findIndex(mt=>mt.path===C.path),Ue=Me!==-1?e.slice(Me+1).map(mt=>mt.path):[];u(C.path),X(Ue)}else f(),y({}),_({});T(null)}};if(e.length===0)return o.jsx("div",{className:"h-full flex items-center justify-center text-fg-faint text-xs",children:o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"mb-2",children:"no file open"}),o.jsxs("div",{children:["open the ",o.jsx("span",{className:"text-fg-dim",children:"File Explorer"})," tab and click a file to edit it here"]})]})});const ve=r,$e=ve?ow(ve):"",we=ve?S[ve]:void 0,ne=ve?oB(ve):!1,ce=ve?yH(ve):!1,ge=ve&&ne?i[ve]??bH(ve):"edit",Ae=!!ve&&!lw(ve)&&we==="ready",Te=Ae,nt=ce?["edit","wysiwyg","preview","split"]:ne?["edit","preview"]:[],ct=ve&&o.jsx(nhe,{path:ve,name:$e,value:s[ve]??"",onChange:Me=>h(ve,Me),onSave:()=>void ue(ve),onReady:ee,onCursor:$}),Le=N?"Saving…":ve&&n[ve]?k.autosave?"Editing…":"Unsaved":"All changes saved";return o.jsxs("div",{className:"relative flex flex-col h-full bg-bg",children:[!I&&o.jsx(Qfe,{openFiles:e,activeFilePath:r,dirty:n,onSelectFile:a,onCloseFile:Q,onCloseOthers:Z,onCloseToTheRight:ae,onCloseAll:oe}),ve&&!I&&o.jsxs("div",{className:"flex items-center px-3 h-8 border-b border-line shrink-0 bg-bg-elev",children:[o.jsx("span",{className:"text-xs font-medium text-fg truncate",children:$e}),o.jsx("span",{className:"ml-3 text-[10px] text-fg-faint truncate",children:ve}),Ae&&o.jsxs("span",{className:"ml-3 text-[10px] text-fg-faint shrink-0",children:["· ",Le]}),o.jsx("div",{className:"flex-1"}),Hd(ve)&&(ge==="preview"||ge==="split")&&o.jsx("button",{onClick:()=>U(Me=>!Me),className:`px-2 py-0.5 text-[10px] border border-line rounded mr-1 ${F?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Toggle document outline",children:"Outline"}),Ae&&o.jsxs("div",{className:"flex items-center mr-2 rounded border border-line overflow-hidden",children:[o.jsx("button",{onClick:()=>k.bumpFontSize(-1),className:"px-1.5 py-0.5 text-[11px] text-fg-faint hover:text-fg",title:"Zoom out",children:"A−"}),o.jsx("button",{onClick:()=>k.bumpFontSize(1),className:"px-1.5 py-0.5 text-[11px] text-fg-faint hover:text-fg",title:"Zoom in",children:"A+"}),o.jsx("button",{onClick:k.toggleWordWrap,className:`px-1.5 py-0.5 text-[10px] ${k.wordWrap?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Word wrap",children:"Wrap"}),o.jsx("button",{onClick:k.toggleMinimap,className:`px-1.5 py-0.5 text-[10px] ${k.minimap?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Minimap",children:"Map"}),o.jsx("button",{onClick:()=>k.setTheme(k.theme==="dark"?"paper":"dark"),className:"px-1.5 py-0.5 text-[10px] text-fg-faint hover:text-fg",title:"Toggle editor theme",children:k.theme==="dark"?"Dark":"Paper"}),o.jsx("button",{onClick:k.toggleAutosave,className:`px-1.5 py-0.5 text-[10px] ${k.autosave?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Autosave",children:"Auto"})]}),nt.length>0&&o.jsx("div",{className:"flex items-center mr-2 rounded border border-line overflow-hidden",children:nt.map(Me=>o.jsx("button",{onClick:()=>w(ve,Me),className:`px-2 py-0.5 text-[10px] capitalize transition-colors ${ge===Me?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,children:Me},Me))}),o.jsx("button",{onClick:()=>W(!0),className:"px-2 py-0.5 text-[10px] text-fg-faint hover:text-fg border border-line rounded mr-1",title:"Focus mode (Cmd/Ctrl-Shift-F)",children:"Focus"}),o.jsx("button",{onClick:()=>window.api.shell.open({as:"openPath",path:ve}),className:"px-2 py-0.5 text-[10px] text-fg-faint hover:text-fg border border-line rounded mr-1",title:"Open in default app",children:"Open"}),o.jsx("button",{onClick:()=>window.api.shell.open({as:"revealPath",path:ve}),className:"px-2 py-0.5 text-[10px] text-fg-faint hover:text-fg border border-line rounded",title:"Reveal in OS",children:"Reveal"})]}),I&&o.jsx("button",{onClick:()=>W(!1),className:"absolute top-2 right-3 z-10 px-2 py-0.5 text-[10px] text-fg-faint hover:text-fg border border-line rounded bg-bg-elev/80",title:"Exit focus mode (Esc)",children:"Exit focus"}),o.jsx("div",{className:"flex-1 min-h-0",children:ve?nB(ve)?o.jsx(fhe,{path:ve,name:$e}):iB(ve)?o.jsx(hhe,{path:ve}):we&&typeof we=="object"&&"binary"in we?o.jsx(xhe,{path:ve,name:$e,size:we.size,mime:we.mime,reason:we.reason}):we&&typeof we=="object"&&"error"in we?o.jsx("div",{className:"p-6 text-xs text-red-400",children:we.error}):we!=="ready"?o.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"loading…"}):ge==="wysiwyg"&&Hd(ve)?o.jsx(D.Suspense,{fallback:o.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"Loading editor…"}),children:o.jsx(whe,{value:s[ve]??"",onChange:Me=>h(ve,Me)},ve)}):ge==="split"&&Hd(ve)?o.jsxs("div",{className:"flex h-full",children:[F&&o.jsx(WL,{text:s[ve]??"",scrollRef:z}),o.jsxs("div",{className:"flex-1 min-w-0 flex flex-col border-r border-line",children:[o.jsx(UL,{getEditor:se}),o.jsx("div",{className:"flex-1 min-h-0",children:ct})]}),o.jsx("div",{className:"flex-1 min-w-0",children:o.jsx(FL,{ref:z,text:s[ve]??"",flush:!0})})]}):ge==="preview"&&Hd(ve)?o.jsxs("div",{className:"flex h-full",children:[F&&o.jsx(WL,{text:s[ve]??"",scrollRef:z}),o.jsx("div",{className:"flex-1 min-w-0",children:o.jsx(FL,{ref:z,text:s[ve]??""})})]}):ge==="preview"&&rB(ve)?o.jsx(uhe,{path:ve,dirty:!!n[ve],reloadToken:x[ve]??0}):ge==="preview"&&sB(ve)?o.jsx(mhe,{path:ve,text:s[ve]??""}):ge==="preview"&&aB(ve)?o.jsx(yhe,{path:ve,text:s[ve]??""}):Hd(ve)?o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsx(UL,{getEditor:se}),o.jsx("div",{className:"flex-1 min-h-0",children:ct})]}):ct:null}),Te&&o.jsx(che,{text:s[ve]??"",cursor:E,language:wa(ve)||void 0}),C&&o.jsx(_he,{message:C.kind==="one"?`Discard unsaved changes to ${ow(C.path)}?`:C.kind==="others"?"Discard unsaved changes in the other open files?":C.kind==="right"?"Discard unsaved changes in the files to the right?":"Discard unsaved changes in all open files?",onCancel:()=>T(null),onConfirm:de})]})}function _he({message:e,onCancel:r,onConfirm:n}){return o.jsx("div",{className:"fixed inset-0 z-[400] flex items-center justify-center bg-black/60",onMouseDown:i=>{i.target===i.currentTarget&&r()},children:o.jsxs("div",{className:"w-96 rounded-lg border border-line bg-bg-elev p-4 shadow-2xl",children:[o.jsx("h3",{className:"text-sm font-medium text-fg mb-3",children:e}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx("button",{onClick:r,className:"px-3 py-1 text-xs text-fg-dim hover:text-fg border border-line rounded",children:"Cancel"}),o.jsx("button",{onClick:n,className:"px-3 py-1 text-xs text-white rounded bg-red-600 hover:bg-red-500",children:"Discard"})]})]})})}const HL={ts:"#3178c6",tsx:"#61dafb",js:"#f7df1e",jsx:"#61dafb",cjs:"#f7df1e",mjs:"#f7df1e",json:"#5d5d5d",css:"#264de4",scss:"#cd6799",less:"#1d365d",html:"#e34c26",md:"#083fa1",mdx:"#083fa1",py:"#3776ab",go:"#00add8",rs:"#dea584",java:"#b07219",kt:"#a97bff",c:"#555555",cpp:"#f34b7d",cc:"#f34b7d",h:"#555555",hpp:"#f34b7d",swift:"#fa7343",rb:"#cc342d",php:"#4f5d95",sql:"#e38c00",sh:"#89e051",bash:"#89e051",zsh:"#89e051",yaml:"#cb171e",yml:"#cb171e",toml:"#9c4221",xml:"#0060ac",svg:"#ff9900",vue:"#41b883",svelte:"#ff3e00",other:"#6b7280"},She={ts:"TypeScript",tsx:"TSX",js:"JavaScript",jsx:"JSX",cjs:"CommonJS",mjs:"ES Module",json:"JSON",css:"CSS",scss:"SCSS",less:"Less",html:"HTML",md:"Markdown",mdx:"MDX",py:"Python",go:"Go",rs:"Rust",java:"Java",kt:"Kotlin",c:"C",cpp:"C++",cc:"C++",h:"C/C++ Header",hpp:"C++ Header",swift:"Swift",rb:"Ruby",php:"PHP",sql:"SQL",sh:"Shell",bash:"Shell",zsh:"Shell",yaml:"YAML",yml:"YAML",toml:"TOML",xml:"XML",svg:"SVG",vue:"Vue",svelte:"Svelte",other:"Other"};function ej(e){return e>=1e6?(e/1e6).toFixed(1)+"M":e>=1e3?(e/1e3).toFixed(1)+"K":String(e)}function khe({open:e,onClose:r,variant:n="overlay"}){const i=kt(E=>E.tabs.find($=>$.id===E.activeTabId)??null),s=(i==null?void 0:i.cwd)??null,[a,c]=D.useState(null),[l,u]=D.useState(!1),[f,m]=D.useState(null),h=D.useRef(null),b=D.useCallback(async E=>{u(!0),m(null);try{const $=await window.api.repo.analyze(E);$.ok?c($):(m($.error||"Analysis failed"),c(null))}catch($){m($ instanceof Error?$.message:String($)),c(null)}finally{u(!1)}},[]);D.useEffect(()=>{if(e){if(!s){m("No active session — open a tab in a folder first.");return}b(s)}},[e,s,b]),D.useEffect(()=>{var $;if(!e)return;const E=N=>{N.key==="Escape"&&(N.stopPropagation(),r())};return window.addEventListener("keydown",E),($=h.current)==null||$.focus(),()=>window.removeEventListener("keydown",E)},[e,r]);const w=D.useCallback(()=>{s&&b(s)},[s,b]),k=D.useMemo(()=>a?Object.entries(a.languageBreakdown).map(([$,N])=>[$,N.files,N.lines]).sort(($,N)=>N[1]-$[1]).slice(0,12):[],[a]),S=D.useMemo(()=>k.length===0?1:k[0][1],[k]),y=D.useMemo(()=>{if(!a)return[];const E=a.topDirectories;if(E.length===0)return[];const $=E.map(P=>Math.sqrt(Math.max(1,P.fileCount))),N=$.reduce((P,I)=>P+I,0)||1;return E.map((P,I)=>({path:P.path,fileCount:P.fileCount,totalLines:P.totalLines,basis:$[I]/N*100}))},[a]);if(!e)return null;const x=E=>{E.target===E.currentTarget&&r()},_=s?s.split("/").filter(Boolean).pop()||s:"no folder",C=n==="page",T=o.jsx("div",{className:C?"h-full w-full flex flex-col bg-bg":"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:C?void 0:x,"data-testid":"repoviz-backdrop",children:o.jsxs("div",{ref:h,role:C?void 0:"dialog","aria-modal":C?void 0:"true","aria-label":"Repository Visualization",tabIndex:-1,className:C?"h-full w-full flex flex-col outline-none bg-bg":"bg-bg-elev border border-line rounded-lg shadow-xl w-[900px] max-w-[95vw] max-h-[85vh] flex flex-col outline-none","data-testid":"repoviz-dialog",children:[o.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-line",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[o.jsx("span",{className:"text-lg","aria-hidden":!0,children:"🗺"}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("h2",{className:"text-base font-medium text-fg leading-tight",children:"Repository Visualization"}),o.jsxs("div",{className:"text-xs text-fg-dim truncate",title:s??"",children:[_,(a==null?void 0:a.gitStatus.branch)&&o.jsxs("span",{className:"ml-2 font-mono text-fg-faint",children:["(",a.gitStatus.branch,")"]}),(a==null?void 0:a.truncated)&&o.jsx("span",{className:"ml-2 text-amber-400",children:"truncated"})]})]})]}),o.jsxs("div",{className:"flex items-center gap-1",children:[a&&a.gitStatus.uncommitted>0&&o.jsxs("span",{className:"px-2 py-0.5 rounded-full bg-amber-500/20 text-amber-400 text-[11px] font-mono",title:`${a.gitStatus.uncommitted} uncommitted files`,children:[a.gitStatus.uncommitted," uncommitted"]}),o.jsxs("button",{type:"button",onClick:w,disabled:l||!s,className:"px-2 py-1 rounded text-fg-dim hover:bg-bg-hi hover:text-fg text-xs disabled:opacity-40 disabled:cursor-not-allowed",title:"Re-run analysis",children:[l?"…":"↻"," Refresh"]}),o.jsx("button",{type:"button",onClick:r,className:"px-2 py-1 rounded text-fg-dim hover:bg-bg-hi hover:text-fg text-xs","aria-label":"Close",children:"✕"})]})]}),o.jsx("div",{className:"flex-1 overflow-y-auto p-5 space-y-6",children:l&&!a?o.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-fg-dim",children:[o.jsx("div",{className:"text-3xl mb-3 animate-pulse","aria-hidden":!0,children:"⟳"}),o.jsx("div",{className:"text-sm",children:"Analyzing repository…"}),o.jsx("div",{className:"text-xs text-fg-faint mt-1",children:"Walking files, counting lines, reading git status"})]}):f?o.jsxs("div",{className:"py-16 text-center",children:[o.jsx("div",{className:"text-3xl mb-3 text-red-400","aria-hidden":!0,children:"⚠"}),o.jsx("div",{className:"text-sm text-red-400",children:f})]}):a?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[o.jsx(tj,{label:"Files",value:ej(a.totalFiles)}),o.jsx(tj,{label:"Lines of code",value:ej(a.totalLines)}),o.jsx(tj,{label:"Uncommitted",value:String(a.gitStatus.uncommitted),tone:a.gitStatus.uncommitted>0?"warn":"neutral"})]}),o.jsxs("section",{children:[o.jsx("h3",{className:"text-xs uppercase tracking-wider text-fg-faint mb-2",children:"Languages"}),k.length===0?o.jsx("div",{className:"text-xs text-fg-dim",children:"No files detected."}):o.jsx("div",{className:"space-y-1.5",children:k.map(([E,$,N])=>{const P=HL[E]??HL.other,I=She[E]??E,W=$/S*100;return o.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[o.jsx("span",{className:"w-24 text-fg-dim truncate",title:I,children:I}),o.jsx("div",{className:"flex-1 h-4 bg-bg rounded overflow-hidden",children:o.jsx("div",{className:"h-full rounded",style:{width:`${W}%`,backgroundColor:P}})}),o.jsxs("span",{className:"w-16 text-right text-fg-dim font-mono",children:[$," files"]}),o.jsxs("span",{className:"w-20 text-right text-fg-faint font-mono",children:[ej(N)," L"]})]},E)})})]}),o.jsxs("section",{children:[o.jsx("h3",{className:"text-xs uppercase tracking-wider text-fg-faint mb-2",children:"Top directories"}),y.length===0?o.jsx("div",{className:"text-xs text-fg-dim",children:"No directories."}):o.jsx("div",{className:"flex flex-wrap gap-1 min-h-[140px]",children:y.map(E=>o.jsxs("div",{className:"relative rounded bg-bg-hi border border-line hover:border-accent transition-colors cursor-default flex flex-col justify-end p-2 min-w-[80px] min-h-[60px]",style:{flexBasis:`${Math.max(E.basis,6)}%`,flexGrow:E.basis>15?1:0},title:`${E.path} — ${E.fileCount} files, ${E.totalLines.toLocaleString()} lines`,children:[o.jsx("div",{className:"text-[11px] font-mono text-fg truncate",children:E.path}),o.jsxs("div",{className:"text-[10px] text-fg-dim font-mono",children:[E.fileCount," files"]})]},E.path))})]}),o.jsxs("div",{className:"text-[10px] text-fg-faint text-right",children:["Analyzed in ",a.durationMs,"ms",a.truncated&&" — stopped early (5000-file cap or 30s timeout)"]})]}):o.jsx("div",{className:"py-16 text-center text-fg-dim text-sm",children:"No analysis yet. Click Refresh."})})]})});return!C&&typeof document<"u"&&document.body?xf.createPortal(T,document.body):T}function tj({label:e,value:r,tone:n="neutral"}){const i=n==="warn"?"text-amber-400":"text-fg";return o.jsxs("div",{className:"bg-bg-hi/40 border border-line rounded-lg p-3",children:[o.jsx("div",{className:`text-xl font-medium ${i}`,children:r}),o.jsx("div",{className:"text-xs text-fg-dim mt-0.5",children:e})]})}function jf({options:e,active:r,onChange:n}){return o.jsx("div",{className:"flex rounded border border-line overflow-hidden",children:e.map(({key:i,label:s})=>o.jsx("button",{onClick:()=>n(i),className:`px-2 py-0.5 text-xs ${r===i?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:s},i))})}const VL=e=>/[/\\\-_.\s]/.test(e),GL=e=>e>="A"&&e<="Z";function Che(e,r,n){if(!e)return{match:!0,score:0,matched:[]};const i=e.toLowerCase(),s=r.toLowerCase(),a=(n||r).toLowerCase(),c=r.split("/").pop()||r,l=c.toLowerCase();if(l===i)return{match:!0,score:1e3,matched:Array.from({length:c.length},(x,_)=>_)};if(l.startsWith(i))return{match:!0,score:900,matched:Array.from({length:e.length},(x,_)=>_)};let u=0;for(const x of a.split("/")){if(x===i)return{match:!0,score:800,matched:[]};x.startsWith(i)&&(u=Math.max(u,700))}const f=l.indexOf(i);if(f!==-1)return{match:!0,score:f===0||VL(l[f-1])||GL(c[f])?650:600,matched:Array.from({length:e.length},(_,C)=>f+C)};if(a.includes(i))return{match:!0,score:Math.max(500,u),matched:[]};let m=0,h=0,b=0,w=-1,k=0;const S=[];for(let x=0;x<s.length&&m<i.length;x++)s[x]===i[m]&&(S.push(x),h+=10,w===x-1?(b++,h+=b*8):b=0,(x===0||VL(s[x-1])||GL(r[x]))&&(k++,h+=15,x===0&&(h+=10)),w=x,m++);if(m!==i.length)return{match:!1,score:0,matched:[]};const y=Math.max(0,50-(s.length-i.length));if(h+=y,k>=i.length*.5&&(h+=30),S.length>1){const x=S[S.length-1]-S[0];x>i.length*3&&(h-=Math.min(50,(x-i.length*3)*2))}return{match:!0,score:Math.max(1,h),matched:S}}function rj(e,r){return e.startsWith(r+"/")?e.slice(r.length+1):e===r?"":e}function KL(e){const r=e.lastIndexOf("/");return r<0?"":e.slice(0,r)}const XL="session-manager.quickopen.recent",jhe=8;function Ehe({open:e,onClose:r,variant:n="overlay"}){const i=kt(I=>I.tabs.find(W=>W.id===I.activeTabId)??null),s=(i==null?void 0:i.cwd)??"",[a,c]=D.useState(""),[l,u]=D.useState([]),[f,m]=D.useState(!1),[h,b]=D.useState(0),[w,k]=D.useState([]),S=D.useRef(null),y=D.useRef(null);D.useEffect(()=>{if(e)try{const I=localStorage.getItem(XL);I&&k(JSON.parse(I))}catch{}},[e]),D.useEffect(()=>{if(!e){c(""),b(0);return}const I=setTimeout(()=>{var W;return(W=S.current)==null?void 0:W.focus()},0);return()=>clearTimeout(I)},[e]),D.useEffect(()=>{if(!e||!s)return;let I=!1;return m(!0),window.api.search.files(s,"",{limit:5e3}).then(W=>{if(!I){if(!W.ok){Ze.error(`File search failed: ${W.error??"unknown error"}`),u([]);return}u(W.files)}}).catch(W=>{const F=W instanceof Error?W.message:String(W);gt.error("quick-open","search.files threw",{error:F}),Ze.error(`File search failed: ${F}`),u([])}).finally(()=>{I||m(!1)}),()=>{I=!0}},[e,s]);const x=D.useMemo(()=>{if(!a.trim())return[...l].sort((U,q)=>U.name.localeCompare(q.name)).slice(0,100).map(U=>({file:U,score:0,matched:[]}));const I=a.trim(),W=[];for(const F of l){const U=Che(I,F.name,F.path);U.match&&W.push({file:F,score:U.score,matched:U.matched})}return W.sort((F,U)=>U.score-F.score),W.slice(0,100)},[l,a]),_=D.useMemo(()=>a.trim()?[]:w.map(I=>l.find(W=>W.path===I)||null).filter(I=>I!==null).slice(0,5),[w,l,a]);D.useEffect(()=>{const I=_.length+x.length;h>=I&&b(Math.max(0,I-1))},[_.length,x.length,h]),D.useEffect(()=>{if(!y.current)return;const I=y.current.querySelector(`[data-row="${h}"]`);I&&I.scrollIntoView({block:"nearest"})},[h]);const C=D.useCallback(I=>{try{const q=[I,...w.filter(z=>z!==I)].slice(0,jhe);k(q),localStorage.setItem(XL,JSON.stringify(q))}catch{}const W=i==null?void 0:i.id;if(!W){Ze.error("No active tab to receive file path");return}const U=(s?rj(I,s):I)||I;try{window.api.pty.write({tabId:W,data:U})}catch(q){const z=q instanceof Error?q.message:String(q);gt.error("quick-open","pty.write failed",{error:z}),Ze.error(`Failed to write to terminal: ${z}`);return}r()},[i==null?void 0:i.id,s,w,r]),T=D.useCallback(I=>{const W=_.length+x.length;if(I.key==="Escape"){I.preventDefault(),r();return}if(I.key==="ArrowDown"){if(I.preventDefault(),W===0)return;b(F=>Math.min(W-1,F+1));return}if(I.key==="ArrowUp"){if(I.preventDefault(),W===0)return;b(F=>Math.max(0,F-1));return}if(I.key==="Enter"){if(I.preventDefault(),h<_.length){const q=_[h];q&&C(q.path);return}const F=h-_.length,U=x[F];U&&C(U.file.path)}},[h,x,_,C,r]);if(!e)return null;const E=(I,W)=>{if(W.length===0)return I;const F=new Set(W);return I.split("").map((U,q)=>o.jsx("span",{className:F.has(q)?"text-accent font-semibold":"",children:U},q))};let $=-1;const N=n==="page",P=o.jsx("div",{className:N?"h-full w-full flex flex-col bg-bg":"fixed inset-0 z-[55] flex items-start justify-center bg-black/60 pt-[12vh]",onClick:N?void 0:I=>{I.target===I.currentTarget&&r()},"data-testid":"quick-open-backdrop",children:o.jsxs("div",{role:N?void 0:"dialog","aria-modal":N?void 0:"true","aria-label":"Quick Open",className:N?"h-full w-full flex flex-col":"w-[640px] max-w-[90vw] max-h-[70vh] bg-bg-elev border border-line rounded shadow-xl flex flex-col","data-testid":"quick-open",onKeyDown:T,children:[o.jsx("div",{className:"border-b border-line p-2",children:o.jsx("input",{ref:S,type:"text",value:a,onChange:I=>{c(I.target.value),b(0)},placeholder:s?"Search files in this project…":"No active tab — open a terminal first",disabled:!s,spellCheck:!1,autoComplete:"off",className:"w-full bg-transparent text-fg placeholder:text-fg-dim outline-none px-2 py-1.5 text-sm","aria-label":"Search files"})}),o.jsx("div",{ref:y,className:"flex-1 min-h-0 overflow-y-auto",role:"listbox",children:f?o.jsx("div",{className:"px-4 py-6 text-sm text-fg-dim",children:"Loading…"}):s?_.length===0&&x.length===0?o.jsx("div",{className:"px-4 py-6 text-sm text-fg-dim",children:a?"No files match.":"No files found in this project."}):o.jsxs(o.Fragment,{children:[_.length>0&&o.jsxs("div",{children:[o.jsx("div",{className:"px-3 pt-2 pb-1 text-[10px] uppercase tracking-wider text-fg-dim",children:"Recent"}),_.map(I=>{$++;const W=$,F=W===h;return o.jsxs("button",{"data-row":W,role:"option","aria-selected":F,onClick:()=>C(I.path),onMouseEnter:()=>b(W),className:`w-full text-left px-3 py-1.5 text-sm flex flex-col gap-0.5 ${F?"bg-bg-hi text-fg":"hover:bg-bg-hi/50 text-fg"}`,children:[o.jsx("span",{className:"truncate",children:I.name}),o.jsx("span",{className:"text-xs text-fg-dim truncate",children:rj(KL(I.path),s)})]},`r:${I.path}`)})]}),x.length>0&&o.jsxs("div",{children:[_.length>0&&o.jsx("div",{className:"px-3 pt-2 pb-1 text-[10px] uppercase tracking-wider text-fg-dim border-t border-line",children:"Files"}),x.map(({file:I,matched:W})=>{$++;const F=$,U=F===h;return o.jsxs("button",{"data-row":F,role:"option","aria-selected":U,onClick:()=>C(I.path),onMouseEnter:()=>b(F),className:`w-full text-left px-3 py-1.5 text-sm flex flex-col gap-0.5 ${U?"bg-bg-hi text-fg":"hover:bg-bg-hi/50 text-fg"}`,children:[o.jsx("span",{className:"truncate",children:E(I.name,W)}),o.jsx("span",{className:"text-xs text-fg-dim truncate",children:rj(KL(I.path),s)})]},I.path)})]})]}):o.jsx("div",{className:"px-4 py-6 text-sm text-fg-dim",children:"Open a terminal tab to enable Quick Open."})}),o.jsxs("div",{className:"border-t border-line px-3 py-1.5 flex items-center justify-between text-[10px] text-fg-dim",children:[o.jsxs("span",{children:[o.jsx("kbd",{className:"px-1 py-0.5 rounded bg-bg-hi border border-line",children:"↑↓"})," navigate"," ",o.jsx("kbd",{className:"ml-2 px-1 py-0.5 rounded bg-bg-hi border border-line",children:"↵"})," insert into terminal"," ",o.jsx("kbd",{className:"ml-2 px-1 py-0.5 rounded bg-bg-hi border border-line",children:"Esc"})," close"]}),o.jsxs("span",{children:[x.length+_.length," ",x.length+_.length===1?"file":"files"]})]})]})});return!N&&typeof document<"u"&&document.body?xf.createPortal(P,document.body):P}function YL(e,r){return e.startsWith(r+"/")?e.slice(r.length+1):e===r?"":e}function The(e,r,n){if(!r)return e;const i=n?e:e.toLowerCase(),s=n?r:r.toLowerCase(),a=i.indexOf(s);return a<0?e:o.jsxs(o.Fragment,{children:[e.slice(0,a),o.jsx("span",{className:"text-accent font-semibold",children:e.slice(a,a+r.length)}),e.slice(a+r.length)]})}function Ahe({open:e,onClose:r,variant:n="overlay"}){const i=kt(q=>q.tabs.find(z=>z.id===q.activeTabId)??null),s=(i==null?void 0:i.cwd)??"",[a,c]=D.useState(""),[l,u]=D.useState(!1),[f,m]=D.useState([]),[h,b]=D.useState(!1),[w,k]=D.useState(null),[S,y]=D.useState(0),[x,_]=D.useState(null),C=D.useRef(null),T=D.useRef(null),E=D.useRef(0);D.useEffect(()=>{if(!e){c(""),m([]),k(null),y(0);return}const q=setTimeout(()=>{var z;return(z=C.current)==null?void 0:z.focus()},0);return()=>clearTimeout(q)},[e]),D.useEffect(()=>{if(!e||!s)return;const q=a.trim();if(!q){m([]),k(null),b(!1);return}const z=++E.current;b(!0);const Y=setTimeout(()=>{window.api.search.text(s,q,{caseSensitive:l,limit:500}).then(ee=>{z===E.current&&(ee.ok?(m(ee.matches),k(null)):(k(ee.error??"unknown error"),m([])),_(ee.usedRipgrep))}).catch(ee=>{if(z!==E.current)return;const se=ee instanceof Error?ee.message:String(ee);gt.error("global-search","search.text threw",{error:se}),k(se),m([])}).finally(()=>{z===E.current&&b(!1)})},250);return()=>clearTimeout(Y)},[e,s,a,l]);const $=D.useMemo(()=>{const q=new Map;for(const Y of f){const ee=q.get(Y.path);ee?ee.push(Y):q.set(Y.path,[Y])}const z=[];for(const[Y,ee]of q)z.push({path:Y,matches:ee});return z.sort((Y,ee)=>ee.matches.length-Y.matches.length||Y.path.localeCompare(ee.path)),z},[f]),N=D.useMemo(()=>f,[f]);D.useEffect(()=>{S>=N.length&&y(Math.max(0,N.length-1))},[N.length,S]),D.useEffect(()=>{if(!T.current)return;const q=T.current.querySelector(`[data-match="${S}"]`);q&&q.scrollIntoView({block:"nearest"})},[S]);const P=D.useCallback(q=>{const z=i==null?void 0:i.id;if(!z){Ze.error("No active tab to receive path");return}const ee=`${(s?YL(q.path,s):q.path)||q.path}:${q.line}`;try{window.api.pty.write({tabId:z,data:ee})}catch(se){const ue=se instanceof Error?se.message:String(se);gt.error("global-search","pty.write failed",{error:ue}),Ze.error(`Failed to write to terminal: ${ue}`);return}r()},[i==null?void 0:i.id,s,r]),I=D.useCallback(q=>{if(q.key==="Escape"){q.preventDefault(),r();return}if(q.key==="ArrowDown"){if(q.preventDefault(),N.length===0)return;y(z=>Math.min(N.length-1,z+1));return}if(q.key==="ArrowUp"){if(q.preventDefault(),N.length===0)return;y(z=>Math.max(0,z-1));return}if(q.key==="Enter"){q.preventDefault();const z=N[S];z&&P(z)}},[N,S,P,r]);if(!e)return null;const W=n==="page";let F=-1;const U=o.jsx("div",{className:W?"h-full w-full flex flex-col bg-bg":"fixed inset-0 z-[55] flex items-start justify-center bg-black/60 pt-[8vh]",onClick:W?void 0:q=>{q.target===q.currentTarget&&r()},"data-testid":"global-search-backdrop",children:o.jsxs("div",{role:W?void 0:"dialog","aria-modal":W?void 0:"true","aria-label":"Search in project",className:W?"h-full w-full flex flex-col":"w-[840px] max-w-[95vw] h-[80vh] bg-bg-elev border border-line rounded shadow-xl flex flex-col","data-testid":"global-search",onKeyDown:I,children:[o.jsxs("div",{className:"border-b border-line p-2 flex items-center gap-2",children:[o.jsx("input",{ref:C,type:"text",value:a,onChange:q=>{c(q.target.value),y(0)},placeholder:s?"Search in this project…":"No active tab — open a terminal first",disabled:!s,spellCheck:!1,autoComplete:"off",className:"flex-1 bg-transparent text-fg placeholder:text-fg-dim outline-none px-2 py-1.5 text-sm","aria-label":"Search query"}),o.jsx("button",{type:"button",onClick:()=>u(q=>!q),className:`px-2 py-1 text-xs rounded border ${l?"bg-accent/20 border-accent text-accent":"bg-bg border-line text-fg-dim hover:text-fg"}`,title:"Match case","aria-pressed":l,children:"Aa"})]}),o.jsx("div",{ref:T,className:"flex-1 min-h-0 overflow-y-auto",role:"listbox",children:s?a.trim()?h?o.jsx("div",{className:"px-4 py-6 text-sm text-fg-dim",children:"Searching…"}):w?o.jsx("div",{className:"px-4 py-6 text-sm text-red-400",children:w}):N.length===0?o.jsxs("div",{className:"px-4 py-6 text-sm text-fg-dim",children:["No matches for ",JSON.stringify(a),"."]}):o.jsx("div",{children:$.map(q=>o.jsxs("div",{children:[o.jsxs("div",{className:"sticky top-0 bg-bg-elev border-b border-line px-3 py-1 text-xs text-fg-dim font-mono truncate",children:[YL(q.path,s)," ",o.jsxs("span",{className:"text-fg-faint",children:["(",q.matches.length,")"]})]}),q.matches.map(z=>{F++;const Y=F,ee=Y===S;return o.jsxs("button",{"data-match":Y,role:"option","aria-selected":ee,onClick:()=>P(z),onMouseEnter:()=>y(Y),className:`w-full text-left px-3 py-1 text-xs font-mono flex gap-3 ${ee?"bg-bg-hi text-fg":"hover:bg-bg-hi/50 text-fg"}`,children:[o.jsx("span",{className:"text-fg-dim shrink-0 w-12 text-right",children:z.line}),o.jsx("span",{className:"truncate",children:The(z.text,a,l)})]},`${z.path}:${z.line}:${z.column}:${Y}`)})]},q.path))}):o.jsxs("div",{className:"px-4 py-6 text-sm text-fg-dim",children:["Type to search files in ",o.jsx("span",{className:"font-mono",children:s}),"."]}):o.jsx("div",{className:"px-4 py-6 text-sm text-fg-dim",children:"Open a terminal tab to enable project search."})}),o.jsxs("div",{className:"border-t border-line px-3 py-1.5 flex items-center justify-between text-[10px] text-fg-dim",children:[o.jsxs("span",{children:[o.jsx("kbd",{className:"px-1 py-0.5 rounded bg-bg-hi border border-line",children:"↑↓"})," navigate"," ",o.jsx("kbd",{className:"ml-2 px-1 py-0.5 rounded bg-bg-hi border border-line",children:"↵"})," insert path"," ",o.jsx("kbd",{className:"ml-2 px-1 py-0.5 rounded bg-bg-hi border border-line",children:"Esc"})," close"]}),o.jsxs("span",{children:[N.length," ",N.length===1?"match":"matches",x===!1&&" · fs walk (rg missing)"]})]})]})});return!W&&typeof document<"u"&&document.body?xf.createPortal(U,document.body):U}const $he=[{key:"files",label:"Files"},{key:"content",label:"Content"}];function Nhe({open:e,onClose:r,variant:n="page",initialMode:i="files"}){const[s,a]=D.useState(i);return D.useEffect(()=>{a(i)},[i]),e?o.jsxs("div",{className:"h-full w-full flex flex-col bg-bg",children:[o.jsxs("div",{className:"shrink-0 flex items-center gap-3 px-3 py-2 border-b border-line",children:[o.jsx(jf,{options:$he,active:s,onChange:a}),o.jsx("span",{className:"text-[11px] text-fg-faint",children:s==="files"?"⌘P · fuzzy-find a file in the active project":"⌘⇧F · ripgrep across the active project"})]}),o.jsx("div",{className:"flex-1 min-h-0",children:s==="files"?o.jsx(Ehe,{open:!0,onClose:r,variant:"page"}):o.jsx(Ahe,{open:!0,onClose:r,variant:"page"})})]}):null}class y8 extends D.Component{constructor(){super(...arguments);Xr(this,"state",{error:null});Xr(this,"reset",()=>this.setState({error:null}))}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,i){console.error("[ErrorBoundary]",n,i)}render(){return this.state.error?this.props.fallback?this.props.fallback(this.state.error,this.reset):o.jsxs("div",{className:"p-6 text-xs",children:[o.jsx("div",{className:"text-red-400 mb-2",children:"something broke in this panel"}),o.jsx("pre",{className:"text-fg-faint whitespace-pre-wrap mb-3",children:this.state.error.message}),o.jsx("button",{onClick:this.reset,className:"px-2 py-0.5 border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"retry"})]}):this.props.children}}function Ohe({open:e,onClose:r,title:n,children:i,variant:s="overlay"}){return o.jsxs(wf,{open:e,onClose:r,size:"xl",fillHeight:!0,noPadding:!0,title:void 0,variant:s,children:[s==="overlay"&&o.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-line shrink-0",children:[o.jsx("h2",{className:"text-xs uppercase tracking-wider text-fg-dim",children:n}),o.jsx("button",{type:"button",onClick:r,"aria-label":"Close",className:"px-2 py-0.5 text-fg-dim hover:text-fg hover:bg-bg-hi rounded text-base leading-none",children:"✕"})]}),o.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:o.jsx(y8,{children:i})})]})}function Phe(e){return/^monitor of /i.test(e.trim())}function JL(e){return e.replace(/\s*\([^)]*\)\s*$/,"").replace(/\s*#\d+\s*$/,"").replace(/\s+/g," ").trim().toLowerCase()}function ZL(e,r,n){if(e){const c=n.find(l=>l.deviceId===e);if(c)return c}if(!r)return null;const i=n.filter(c=>c.label===r);if(i.length===1)return i[0];if(i.length>1)return null;const s=JL(r),a=n.filter(c=>c.label&&JL(c.label)===s);return a.length===1?a[0]:null}async function QL(e){var n;return(n=navigator.mediaDevices)!=null&&n.enumerateDevices?(await navigator.mediaDevices.enumerateDevices()).filter(i=>!(i.kind!=="audioinput"||i.label&&Phe(i.label))):[]}const e5=!1;function b8(){const e=Dt(f=>f.isRecording);Dt(f=>f.startRecording),Dt(f=>f.stopRecording);const[r,n]=D.useState([]),[i,s]=D.useState(null),[a,c]=D.useState(null);D.useEffect(()=>{let f=!1;return(async()=>{try{const m=await window.api.voice.getDevicePref();if(f)return;const h=await QL(e5);if(f)return;n(h),c(m.selectedLabel);const b=ZL(m.selectedDeviceId,m.selectedLabel,h);b?(s(b.deviceId),m.selectedDeviceId&&b.deviceId!==m.selectedDeviceId&&(gt.info("voice","device-picker rebind-by-label",{fromIdPrefix:m.selectedDeviceId.slice(0,8),toIdPrefix:b.deviceId.slice(0,8)}),await window.api.voice.setDevicePref({selectedDeviceId:b.deviceId,selectedLabel:b.label||m.selectedLabel}).catch(()=>{}))):((m.selectedDeviceId||m.selectedLabel)&&(console.warn("[MicDevicePicker] previously-selected device unavailable; falling back to OS default",{savedLabel:m.selectedLabel,hadId:!!m.selectedDeviceId}),gt.warn("voice","device-picker selected-unavailable",{hadId:!!m.selectedDeviceId})),s(null))}catch(m){gt.warn("voice","device-picker init failed",{error:m instanceof Error?m.message:String(m)})}})(),()=>{f=!0}},[]);const l=D.useCallback(async()=>{try{const f=await QL(e5);if(n(f),i&&!f.some(m=>m.deviceId===i)){const m=ZL(null,a,f);m?(s(m.deviceId),await window.api.voice.setDevicePref({selectedDeviceId:m.deviceId,selectedLabel:m.label||a}).catch(()=>{})):s(null)}}catch(f){gt.warn("voice","device-picker refresh failed",{error:f instanceof Error?f.message:String(f)})}},[i,a]);D.useEffect(()=>{const f=()=>{l()};return window.addEventListener("mic-device-change",f),()=>window.removeEventListener("mic-device-change",f)},[l]);const u=async f=>{var w;const m=f.target.value,h=m===""?null:m,b=h?((w=r.find(k=>k.deviceId===h))==null?void 0:w.label)??null:null;s(h),c(b);try{await window.api.voice.setDevicePref({selectedDeviceId:h,selectedLabel:b}),gt.info("voice","device-picker selected",{deviceIdPrefix:h?h.slice(0,8):null})}catch(k){gt.warn("voice","setDevicePref failed",{error:k instanceof Error?k.message:String(k)})}if(e)try{await Dt.getState().restartWithDevice()}catch(k){gt.warn("voice","device-picker restart failed",{error:k instanceof Error?k.message:String(k)})}};return o.jsxs("select",{value:i??"",onChange:u,onFocus:()=>{l()},title:"Microphone input device","data-testid":"mic-device-picker",className:"text-[10px] bg-bg border border-line text-fg-dim hover:text-fg rounded px-1.5 py-1 max-w-[8rem] truncate",children:[o.jsx("option",{value:"",children:"Default"}),r.map(f=>o.jsx("option",{value:f.deviceId,children:f.label||`Mic ${f.deviceId.slice(0,6)}`},f.deviceId))]})}function Rhe(){const e=Dt(w=>w.isRecording),r=Dt(w=>w.levelMeterEnabled),[n,i]=D.useState(0),[s,a]=D.useState(0),c=D.useRef(0);c.current=s;const[l,u]=D.useState(0),[f,m]=D.useState(!1),h=D.useRef(null);if(D.useEffect(()=>{if(!e||!r){i(0),a(0);return}let w=0,k=!1,S=null,y=null;const x=()=>{if(k)return;const C=y??V4();if(!C){w=requestAnimationFrame(x);return}y!==C&&(y=C,S=new Uint8Array(new ArrayBuffer(C.fftSize)));const T=S;C.getByteTimeDomainData(T);let E=0;for(let I=0;I<T.length;I++){const W=T[I]-128;E+=W*W}const $=Math.sqrt(E/T.length)/128,N=$>0?20*Math.log10($):-60,P=Math.max(0,Math.min(1,(N+60)/60));a($),i(P),$>=.95&&(m(!0),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>m(!1),150)),w=requestAnimationFrame(x)};w=requestAnimationFrame(x);const _=setInterval(()=>{k||u(Math.round(c.current*100))},250);return()=>{k=!0,cancelAnimationFrame(w),clearInterval(_),h.current&&(clearTimeout(h.current),h.current=null)}},[e,r]),!e||!r)return null;const b=f?"bg-red-500":s>=.7?"bg-amber-400":"bg-green-500";return o.jsx("div",{role:"meter","aria-label":"Microphone input level","aria-valuenow":l,"aria-valuemin":0,"aria-valuemax":100,"data-testid":"mic-level-meter",className:`mx-3 mb-2 h-1 rounded bg-bg overflow-hidden ${f?"ring-1 ring-red-500":""}`,children:o.jsx("div",{className:`h-full ${b} transition-[width] duration-75 ease-out`,style:{width:`${n*100}%`}})})}function Mhe({open:e,onClose:r,variant:n="overlay"}){return o.jsx(Ohe,{open:e,onClose:r,title:"Voice / Microphone",variant:n,children:o.jsxs("div",{className:"p-4 space-y-4",children:[o.jsx(Bhe,{}),o.jsx(PB,{}),o.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[o.jsx(K4,{}),o.jsx(b8,{}),o.jsx(Wq,{})]}),o.jsx(Ihe,{}),o.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[o.jsx("button",{type:"button",onClick:()=>Dt.getState().openWizard(),className:"text-xs text-fg-faint hover:text-fg-dim underline","data-testid":"run-mic-check",children:"Run mic check"}),o.jsx(Lhe,{})]}),o.jsx(Rhe,{})]})})}function Ihe(){const e=Dt(a=>a.isRecording),[r,n]=D.useState(null);if(D.useEffect(()=>{let a=!1;window.api.voice.getHotkeyConfig().then(l=>{a||n(l)}).catch(()=>{});const c=window.api.voice.onHotkeyConfigChanged(l=>n(l));return()=>{a=!0,c()}},[]),e||!r)return null;const i=r.mode==="hold"?"Hold":"Press",s=Dhe(r.accelerator);return o.jsxs("div",{className:"text-[11px] text-fg-faint",children:[o.jsxs("span",{children:[i," "]}),o.jsx("kbd",{className:"px-1 py-0.5 rounded border border-line bg-bg font-mono text-fg-dim",children:s}),o.jsx("span",{children:" to record"})]})}function Dhe(e){const r=typeof navigator<"u"&&/Mac/.test(navigator.platform);return e.replace(/CommandOrControl/g,r?"⌘":"Ctrl").replace(/CmdOrCtrl/g,r?"⌘":"Ctrl").replace(/Command/g,"⌘").replace(/Control/g,"Ctrl").replace(/Option/g,r?"⌥":"Alt").replace(/Shift/g,r?"⇧":"Shift")}function Lhe(){const[e,r]=D.useState(null);if(D.useEffect(()=>{let i=!1;window.api.voice.getHotkeyConfig().then(a=>{i||r(a)}).catch(a=>gt.warn("voice-hotkey","getHotkeyConfig (toggle) failed",{error:String(a)}));const s=window.api.voice.onHotkeyConfigChanged(a=>{r(a)});return()=>{i=!0,s()}},[]),!e)return null;const n=async i=>{if(e.mode===i)return;const s={...e,mode:i};r(s);try{await window.api.voice.setHotkeyConfig(s)}catch(a){gt.warn("voice-hotkey","setHotkeyConfig (toggle) failed",{error:a instanceof Error?a.message:String(a)})}};return o.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-fg-faint select-none",title:"Mic hotkey behavior. Tap on/off: press once to start, again to stop. Hold to talk: record only while held (push-to-talk).",children:[o.jsxs("label",{className:"flex items-center gap-1 cursor-pointer hover:text-fg-dim",children:[o.jsx("input",{type:"radio",name:"hotkey-mode",checked:e.mode==="toggle",onChange:()=>n("toggle"),className:"cursor-pointer","data-testid":"hotkey-mode-toggle"}),o.jsx("span",{children:"Tap on/off"})]}),o.jsxs("label",{className:"flex items-center gap-1 cursor-pointer hover:text-fg-dim",children:[o.jsx("input",{type:"radio",name:"hotkey-mode",checked:e.mode==="hold",onChange:()=>n("hold"),className:"cursor-pointer","data-testid":"hotkey-mode-hold"}),o.jsx("span",{children:"Hold to talk"})]})]})}function Bhe(){const e=Dt(a=>a.isRecording),r=Dt(a=>a.lastTranscript),n=Dt(a=>a.error),i=Dt(a=>a.modelStatus),s=Dt(a=>a.loadingProgress);return n?o.jsxs("div",{className:"text-[11px] text-red-400",title:n,children:["⚠ ",n]}):e?o.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-fg-dim border border-line rounded px-2 py-1.5",children:[o.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-red-400 animate-pulse shrink-0"}),o.jsx("span",{className:"truncate",title:r,children:r||"Listening…"})]}):i==="loading"?o.jsxs("div",{className:"text-[11px] text-fg-faint",children:[o.jsxs("div",{className:"flex items-center justify-between mb-1",children:[o.jsx("span",{children:"Loading speech model"}),o.jsxs("span",{className:"font-mono",children:[s,"%"]})]}),o.jsx("div",{className:"h-1 rounded bg-bg overflow-hidden",children:o.jsx("div",{className:"h-full bg-accent transition-[width] duration-200",style:{width:`${s}%`}})})]}):null}let nj=null;function zhe(){return nj||(nj=ab(()=>import("./monaco-editor-BW5C4Iv1.js").then(e=>e.b),__vite__mapDeps([1,2]),import.meta.url).then(e=>(uA.config({monaco:e}),e))),nj}function x8({value:e,onChange:r,path:n,readOnly:i}){const s=D.useRef(null),a=c=>{s.current=c};return o.jsx(dA,{path:`file://${n}`,defaultLanguage:"json",value:e,onChange:c=>r(c??""),onMount:a,theme:"vs",options:{minimap:{enabled:!1},fontSize:12,fontFamily:'"IBM Plex Mono", JetBrains Mono, ui-monospace, Menlo, monospace',lineNumbers:"on",renderLineHighlight:"line",scrollBeyondLastLine:!1,tabSize:2,formatOnPaste:!0,readOnly:i,automaticLayout:!0,bracketPairColorization:{enabled:!0},wordWrap:"on"}})}let t5=!1;async function Fhe(e){if(t5)return;const r=await zhe(),n=await Promise.all(e.map(async s=>{let a=s.schema;if(!a){const c=["https://json.schemastore.org","https://www.schemastore.org","https://code.claude.com"];try{const l=new URL(s.uri).origin;if(!c.includes(l))throw new Error("untrusted origin");const u=await fetch(s.uri);u.ok&&(a=await u.json())}catch{}}return{uri:s.uri,fileMatch:s.fileMatch,schema:a}}));r.languages.json.jsonDefaults.setDiagnosticsOptions({validate:!0,allowComments:!1,schemas:n.filter(s=>s.schema),enableSchemaRequest:!0}),t5=!0}function m$({node:e,targetScope:r,onOverride:n,schema:i,rootLabel:s}){const[a,c]=D.useState(""),[l,u]=D.useState(!0),f=[],m=e.kind==="object"&&Object.keys(e.children).length===0,b=((i==null?void 0:i.rootKeys())??[]).length>0;return o.jsxs("div",{className:"h-full flex flex-col",children:[o.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:[o.jsxs("span",{className:"text-fg-faint",children:["merged · overrides → ",o.jsx("span",{className:"text-fg-dim",children:Oi[r].label})]}),b&&o.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:l,onChange:w=>u(w.target.checked),className:"accent-accent"}),"show unset keys"]}),o.jsx("div",{className:"flex-1"}),o.jsx("input",{value:a,onChange:w=>c(w.target.value),placeholder:"filter keys or descriptions…",className:"bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg w-56"})]}),o.jsx("div",{className:"flex-1 overflow-auto px-3 py-2 font-mono text-xs",children:m&&!l?o.jsx("div",{className:"text-fg-faint italic px-2 py-4",children:"no settings resolved — all scope files empty or missing"}):o.jsx(w8,{node:e,path:f,label:s??"(root)",targetScope:r,onOverride:n,filter:a,depth:0,schema:i,showGhosts:l,defaultOpen:!0})})]})}function w8(e){return e.node.kind==="object"?o.jsx(Uhe,{...e,node:e.node}):e.node.kind==="array"?o.jsx(Whe,{...e,node:e.node}):o.jsx(qhe,{...e,node:e.node})}function r5(e,r){return r.trim()?e.toLowerCase().includes(r.toLowerCase()):!0}function um(e,r,n){return!!(!n.trim()||e.some(i=>r5(i,n))||r!=null&&r.description&&r5(r.description,n))}function Uhe({node:e,path:r,label:n,targetScope:i,onOverride:s,filter:a,depth:c,schema:l,showGhosts:u,defaultOpen:f}){const[m,h]=D.useState(f??c<2),b=(l==null?void 0:l.at(r))??null,w=new Set(Object.keys(e.children)),k=u?(b==null?void 0:b.knownChildren)??[]:[],S=Array.from(new Set([...w,...k])).sort(),y=D.useMemo(()=>a.trim()?S.filter(_=>{const C=(l==null?void 0:l.at([...r,_]))??null;return um([...r,_],C,a)?!0:w.has(_)?_8(e.children[_],[...r,_],a,l):!1}):S,[S.join(","),a,e,r.join("."),l]);if(a.trim()&&y.length===0&&!um(r,b,a))return null;if(r.length===0)return o.jsx("div",{children:y.map(_=>x(_))});return o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-1 py-0.5 hover:bg-bg-elev/50 rounded cursor-pointer",style:{paddingLeft:c*14},onClick:()=>h(!m),children:[o.jsx("span",{className:"text-fg-faint w-3 shrink-0",children:m?"▾":"▸"}),o.jsx("span",{className:"text-fg",children:n}),o.jsxs("span",{className:"text-fg-faint",children:[" {",w.size,k.length>w.size?`/${new Set([...w,...k]).size}`:"","}"]}),(b==null?void 0:b.description)&&o.jsxs("span",{className:"text-fg-faint truncate max-w-md",title:b.description,children:["— ",b.description]})]}),m&&y.map(_=>x(_))]});function x(_){if(w.has(_))return o.jsx(w8,{node:e.children[_],path:[...r,_],label:_,targetScope:i,onOverride:s,filter:a,depth:c+1,schema:l,showGhosts:u},_);const C=(l==null?void 0:l.at([...r,_]))??null;return C?o.jsx(Hhe,{path:[...r,_],label:_,info:C,targetScope:i,onSet:s,depth:c+1,filter:a},_):null}}function _8(e,r,n,i){const s=(i==null?void 0:i.at(r))??null;if(um(r,s,n))return!0;if(e.kind!=="object")return!1;for(const a of Object.keys(e.children))if(_8(e.children[a],[...r,a],n,i))return!0;return!1}function Whe({node:e,path:r,label:n,filter:i,depth:s,schema:a}){const[c,l]=D.useState(!0),u=(a==null?void 0:a.at(r))??null;return um(r,u,i)?o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-1 py-0.5 hover:bg-bg-elev/50 rounded cursor-pointer",style:{paddingLeft:s*14},onClick:()=>l(!c),children:[o.jsx("span",{className:"text-fg-faint w-3 shrink-0",children:c?"▾":"▸"}),o.jsx("span",{className:"text-fg",children:n}),o.jsxs("span",{className:"text-fg-faint",children:[" [",e.items.length,"]"]}),o.jsx(eb,{tone:"warn",children:"accumulated"}),(u==null?void 0:u.description)&&o.jsxs("span",{className:"text-fg-faint truncate max-w-md",title:u.description,children:["— ",u.description]})]}),c&&e.items.map((f,m)=>o.jsxs("div",{className:"flex items-start gap-2 py-0.5",style:{paddingLeft:(s+1)*14},children:[o.jsx("span",{className:"text-fg-faint w-3 shrink-0"}),o.jsxs("span",{className:"text-fg-faint",children:[m,":"]}),o.jsx("span",{className:"text-fg-dim truncate max-w-xl",children:e_(f.value)}),o.jsx(xT,{scope:f.fromScope})]},m))]}):null}function qhe({node:e,path:r,label:n,targetScope:i,onOverride:s,filter:a,depth:c,schema:l}){const[u,f]=D.useState(!1),m=(l==null?void 0:l.at(r))??null;if(!um(r,m,a))return null;const h=e.winner!==i,b=e.shadowed.length>0;return o.jsxs("div",{children:[o.jsxs("div",{className:"group flex items-center gap-2 py-0.5 hover:bg-bg-elev/50 rounded",style:{paddingLeft:c*14},children:[o.jsx("span",{className:`w-3 shrink-0 ${b?"text-fg-faint cursor-pointer":""}`,onClick:()=>b&&f(!u),children:b?u?"▾":"▸":""}),o.jsxs("span",{className:"text-fg",children:[n,":"]}),o.jsx("span",{className:"text-fg-dim truncate max-w-md",children:e_(e.value)}),o.jsx(xT,{scope:e.winner}),(m==null?void 0:m.deprecated)&&o.jsx(eb,{tone:"warn",children:"deprecated"}),(m==null?void 0:m.default)!==void 0&&Vhe(e.value,m.default)&&o.jsx(eb,{tone:"dim",children:"= default"}),e.typeMismatch&&o.jsx("span",{className:"text-yellow-500/80",title:"shadowed scopes have a different value type",children:"⚠"}),(m==null?void 0:m.description)&&o.jsxs("span",{className:"text-fg-faint truncate max-w-md",title:m.description,children:["— ",m.description]}),o.jsx("div",{className:"flex-1"}),(m==null?void 0:m.enum)&&o.jsx(S8,{values:m.enum}),o.jsx("button",{disabled:!h,onClick:()=>s(r,e.value),className:`opacity-0 group-hover:opacity-100 px-1.5 py-0 text-[10px] border rounded transition-opacity ${h?"border-accent/50 text-accent hover:bg-accent hover:text-bg":"border-line text-fg-faint cursor-not-allowed"}`,title:h?`copy into ${Oi[i].label} draft`:`already winning in ${Oi[i].label}`,children:"override"})]}),u&&e.shadowed.map((w,k)=>o.jsxs("div",{className:"flex items-center gap-2 py-0.5 text-fg-faint line-through",style:{paddingLeft:(c+1)*14+12},children:[o.jsx("span",{children:"shadowed:"}),o.jsx("span",{className:"truncate max-w-xl",children:e_(w.value)}),o.jsx(xT,{scope:w.scope,dim:!0})]},k))]})}function Hhe({path:e,label:r,info:n,targetScope:i,onSet:s,depth:a,filter:c}){if(!um(e,n,c))return null;const l=n.default!==void 0?n.default:Ghe(n.type),u=Array.isArray(n.type)?n.type.join("|"):n.type??"?";return o.jsxs("div",{className:"group flex items-center gap-2 py-0.5 hover:bg-bg-elev/50 rounded opacity-60",style:{paddingLeft:a*14},children:[o.jsx("span",{className:"w-3 shrink-0"}),o.jsx("span",{className:"text-fg-dim",children:r}),o.jsx(eb,{tone:"dim",children:u}),n.required&&o.jsx(eb,{tone:"warn",children:"required"}),n.default!==void 0&&o.jsxs("span",{className:"text-fg-faint",children:["default: ",e_(n.default)]}),n.description&&o.jsxs("span",{className:"text-fg-faint truncate max-w-md",title:n.description,children:["— ",n.description]}),o.jsx("div",{className:"flex-1"}),n.enum&&o.jsx(S8,{values:n.enum}),o.jsx("button",{onClick:()=>s(e,l),className:"opacity-0 group-hover:opacity-100 px-1.5 py-0 text-[10px] border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg transition-opacity",title:`write to ${Oi[i].label} draft`,children:"set"})]})}function Vhe(e,r){return e===r?!0:typeof e!=typeof r?!1:e&&r&&typeof e=="object"?JSON.stringify(e)===JSON.stringify(r):!1}function Ghe(e){switch(Array.isArray(e)?e[0]:e){case"boolean":return!1;case"integer":case"number":return 0;case"string":return"";case"array":return[];case"object":return{};case"null":return null;default:return null}}function e_(e){if(typeof e=="string")return JSON.stringify(e);if(e===null)return"null";if(typeof e=="object"){const r=JSON.stringify(e);return r.length>100?r.slice(0,100)+"…":r}return String(e)}function xT({scope:e,dim:r}){const n=e==="user"?"bg-bg-hi text-fg-dim border-line":e==="project"?"bg-blue-950/30 text-blue-400/80 border-blue-900/40":"bg-purple-950/30 text-purple-400/80 border-purple-900/40";return o.jsx("span",{className:`text-[10px] px-1 py-0 rounded border uppercase tracking-wide shrink-0 ${n} ${r?"opacity-60":""}`,children:Oi[e].label})}function eb({children:e,tone:r="default"}){const n={default:"bg-bg-hi text-fg-dim border-line",warn:"bg-yellow-950/30 text-yellow-500/80 border-yellow-900/40",dim:"bg-bg-elev text-fg-faint border-line"}[r];return o.jsx("span",{className:`text-[10px] px-1 py-0 rounded border uppercase tracking-wide shrink-0 ${n}`,children:e})}function S8({values:e}){const r=e.map(n=>String(n)).join(" | ");return o.jsxs("span",{className:"text-[10px] text-fg-faint truncate max-w-xs",title:`allowed: ${r}`,children:["∈ ",r.length>30?r.slice(0,30)+"…":r]})}const Khe=[{id:"essentials",title:"Essentials",summary:"The knobs you reach for first.",keys:["model","language","outputStyle","permissions"]},{id:"git",title:"Git & Commits",summary:"How Claude writes commits and pull requests on your behalf.",keys:["attribution","includeGitInstructions","includeCoAuthoredBy"]},{id:"memory",title:"Memory & Plans",summary:"Context Claude keeps between sessions and where it files plans.",keys:["autoMemoryEnabled","plansDirectory","claudeMdExcludes","respectGitignore"]},{id:"model",title:"Model & Reasoning",summary:"Which model runs, how hard it thinks, and fast-mode toggles.",keys:["availableModels","modelOverrides","effortLevel","fastMode","fastModePerSessionOptIn","alwaysThinkingEnabled"]},{id:"interface",title:"Interface",summary:"Visual polish — spinners, progress bars, motion.",keys:["spinnerTipsEnabled","spinnerTipsOverride","spinnerVerbs","terminalProgressBarEnabled","showTurnDuration","prefersReducedMotion","companyAnnouncements","statusLine","teammateMode"]},{id:"updates",title:"Updates & Cleanup",summary:"Release channel and how long transcripts stick around.",keys:["autoUpdatesChannel","cleanupPeriodDays"]},{id:"env",title:"Environment & Auth",summary:"Environment variables and auth-helper scripts.",keys:["env","apiKeyHelper","awsCredentialExport","awsAuthRefresh"]},{id:"hooks",title:"Hooks",summary:"Scripts Claude runs before/after tool use.",keys:["hooks","disableAllHooks","allowedHttpHookUrls","httpHookAllowedEnvVars"]},{id:"mcp",title:"MCP Servers",summary:"External tool providers Claude can talk to.",keys:["enableAllProjectMcpServers","enabledMcpjsonServers","disabledMcpjsonServers"]},{id:"plugins",title:"Plugins",summary:"Installed plugins, marketplaces, and per-plugin configuration.",keys:["enabledPlugins","extraKnownMarketplaces","skippedPlugins","skippedMarketplaces","pluginConfigs"]},{id:"filesystem",title:"File Picker & Sandbox",summary:"How Claude browses files and the sandbox it runs in.",keys:["fileSuggestion","sandbox","worktree"]},{id:"login",title:"Login",summary:"Which login method to force on startup.",keys:["forceLoginMethod","forceLoginOrgUUID"]},{id:"feedback",title:"Feedback",summary:"Session-quality surveys.",keys:["feedbackSurveyRate"]},{id:"advanced",title:"Advanced / Enterprise",summary:"Managed-settings-only keys and enterprise allow/denylists.",advanced:!0,keys:["allowedMcpServers","deniedMcpServers","allowManagedHooksOnly","allowManagedPermissionRulesOnly","allowManagedMcpServersOnly","strictKnownMarketplaces","blockedMarketplaces","pluginTrustMessage","otelHeadersHelper","skipWebFetchPreflight"]}],Xhe={mcp:"MCP",url:"URL",urls:"URLs",http:"HTTP",ui:"UI",id:"ID",uuid:"UUID",api:"API",aws:"AWS",otel:"OTel",json:"JSON"};function k8(e){return e.replace(/^\$/,"").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").toLowerCase().split(/\s+/).filter(Boolean).map((i,s)=>{const a=Xhe[i];return a||(s===0?i.charAt(0).toUpperCase()+i.slice(1):i)}).join(" ")}function Yhe(e){const r=new Set,n=[];for(const s of Khe){const a=s.keys.filter(c=>e.has(c));a.forEach(c=>r.add(c)),a.length!==0&&n.push({id:s.id,title:s.title,summary:s.summary,advanced:!!s.advanced,keys:a})}const i=Array.from(e).filter(s=>!r.has(s)&&s!=="$schema").sort();return i.length>0&&n.push({id:"other",title:"Other",summary:"Keys not yet grouped.",advanced:!1,keys:i}),n}const Jhe=["user","project","local","default"],Zhe={user:"user",project:"project",local:"local",default:"default"};function Qhe({node:e,targetScope:r,onOverride:n,schema:i}){const[s,a]=D.useState(""),[c,l]=D.useState(!1),[u,f]=D.useState(!0),m=e.kind==="object"?e:null,h=m?Object.keys(m.children):[],b=i.rootKeys(),w=new Set([...h,...b]),k=D.useMemo(()=>Yhe(w),[Array.from(w).sort().join(",")]),S=D.useMemo(()=>k.filter(y=>c||!y.advanced).map(y=>({...y,keys:y.keys.filter(x=>{const _=(m==null?void 0:m.children[x])!==void 0;if(!u&&!_)return!1;if(!s.trim())return!0;const C=i.at([x]);return[x,k8(x),(C==null?void 0:C.description)??""].join(" ").toLowerCase().includes(s.toLowerCase())})})).filter(y=>y.keys.length>0),[k,s,c,u,m,i]);return o.jsxs("div",{className:"h-full flex flex-col",children:[o.jsxs("div",{className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 flex items-center gap-3 text-xs",children:[o.jsxs("span",{className:"text-fg-faint",children:["writing overrides to"," ",o.jsx("span",{className:"text-fg-dim font-medium",children:Oi[r].label})]}),o.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:u,onChange:y=>f(y.target.checked),className:"accent-accent"}),"show not-yet-configured"]}),o.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:c,onChange:y=>l(y.target.checked),className:"accent-accent"}),"show advanced"]}),o.jsx("div",{className:"flex-1"}),o.jsx("input",{value:s,onChange:y=>a(y.target.value),placeholder:"search settings…",className:"bg-bg border border-line rounded px-2 py-1 text-xs text-fg w-64"})]}),o.jsxs("div",{className:"flex-1 overflow-auto",children:[S.map(y=>o.jsx(epe,{title:y.title,summary:y.summary,advanced:y.advanced,children:y.keys.map(x=>{const _=m==null?void 0:m.children[x],C=i.at([x]);return o.jsx(tpe,{keyName:x,node:_,info:C,targetScope:r,onOverride:(T,E)=>n([x],T,E)},x)})},y.id)),S.length===0&&o.jsxs("div",{className:"px-6 py-12 text-center text-fg-faint text-sm",children:['no settings match "',s,'"']})]})]})}function epe({title:e,summary:r,advanced:n,children:i}){const[s,a]=D.useState(!0);return o.jsxs("section",{className:"border-b border-line",children:[o.jsxs("header",{className:"px-4 py-2.5 bg-bg-elev/40 cursor-pointer hover:bg-bg-elev flex items-center gap-3",onClick:()=>a(!s),children:[o.jsx("span",{className:"text-fg-faint w-3",children:s?"▾":"▸"}),o.jsxs("div",{className:"flex-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("h2",{className:"text-fg text-sm font-medium",children:e}),n&&o.jsx("span",{className:"text-[9px] px-1.5 py-0 rounded border border-yellow-900/40 bg-yellow-950/30 text-yellow-500/80 uppercase tracking-wide",children:"advanced"})]}),o.jsx("p",{className:"text-fg-faint text-xs",children:r})]})]}),s&&o.jsx("div",{className:"divide-y divide-line/60",children:i})]})}function tpe({keyName:e,node:r,info:n,targetScope:i,onOverride:s}){const[a,c]=D.useState(!1),[l,u]=D.useState(!1),f=k8(e),m=r!==void 0,b=(r==null?void 0:r.kind)==="leaf"?r:null,w=(r==null?void 0:r.kind)==="object"||(r==null?void 0:r.kind)==="array",k=n==null?void 0:n.default,S=b&&k!==void 0&&j8(b.value,k),y=cpe({isSet:m,leafNode:b,defaultVal:k,isDefault:!!S,node:r}),x=rpe(b,k),_=x.length>=2,C=!!b&&!S;return o.jsx("div",{className:"px-4 py-3 hover:bg-bg-elev/20",children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("button",{onClick:()=>c(!a),className:"text-fg-faint hover:text-fg w-3 mt-0.5",title:a?"collapse":"expand",children:a?"▾":"▸"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-baseline gap-2 flex-wrap",children:[o.jsx("h3",{className:"text-fg text-sm",children:f}),o.jsx(upe,{kind:y.kind,label:y.label}),_&&o.jsxs("button",{onClick:T=>{T.stopPropagation(),a||c(!0),u(E=>!E)},className:"text-[9px] px-1.5 py-0 rounded border border-blue-900/40 bg-blue-950/30 text-blue-300/90 uppercase tracking-wide hover:bg-blue-900/40",title:"this key is defined in multiple scopes — click to expand",children:["drift · ",x.map(T=>Zhe[T]).join(" · ")]}),C&&b&&o.jsx("button",{onClick:T=>{T.stopPropagation(),s(void 0,b.winner)},className:"text-[9px] px-1.5 py-0 rounded border border-line bg-bg-elev text-fg-faint uppercase tracking-wide hover:text-fg hover:bg-bg-hi",title:`reset · delete from ${Oi[b.winner].label}`,children:"↺ reset"}),(n==null?void 0:n.deprecated)&&o.jsx("span",{className:"text-[9px] px-1 py-0 rounded border border-yellow-900/40 bg-yellow-950/30 text-yellow-500/80 uppercase tracking-wide",children:"deprecated"}),(n==null?void 0:n.required)&&!m&&o.jsx("span",{className:"text-[9px] px-1 py-0 rounded border border-red-900/40 bg-red-950/30 text-red-400/80 uppercase tracking-wide",children:"required"})]}),(n==null?void 0:n.description)&&o.jsx("p",{className:"text-fg-dim text-xs mt-0.5 leading-relaxed",children:dpe(n.description)}),a&&l&&b&&o.jsx(npe,{leaf:b,defaultVal:k,onReset:T=>s(void 0,T)}),a&&o.jsx(ipe,{keyName:e,node:r,info:n,targetScope:i,onOverride:T=>s(T)})]}),o.jsx("div",{className:"shrink-0",children:!a&&o.jsx(lpe,{node:r,info:n,onSet:T=>{s(T)},disabled:w&&m})})]})})}function rpe(e,r){if(!e)return[];const n=new Set;n.add(e.winner);for(const i of e.shadowed)n.add(i.scope);return r!==void 0&&n.add("default"),Jhe.filter(i=>n.has(i))}function npe({leaf:e,defaultVal:r,onReset:n}){const i={};i[e.winner]={value:e.value,winner:!0};for(const s of e.shadowed)i[s.scope]={value:s.value,winner:!1};return o.jsxs("div",{className:"mt-2 border border-line rounded bg-bg-elev/40 text-xs",children:[o.jsx("div",{className:"px-2 py-1 text-fg-faint border-b border-line/60",children:"Values across all scopes (winner highlighted · reset removes that scope's value):"}),o.jsxs("div",{className:"divide-y divide-line/60",children:[["user","project","local"].map(s=>{const a=i[s],c=a!==void 0;return o.jsxs("div",{className:"grid grid-cols-[5rem_1fr_auto] gap-2 px-2 py-1 items-center",children:[o.jsx("span",{className:"text-fg-faint",children:Oi[s].label}),o.jsx("span",{className:`font-mono truncate ${a!=null&&a.winner?"text-accent":"text-fg-dim"}`,children:c?Ip(a.value):o.jsx("span",{className:"text-fg-faint",children:"—"})}),c?o.jsx("button",{onClick:()=>n(s),className:"text-[9px] px-1.5 py-0 rounded border border-line text-fg-faint uppercase tracking-wide hover:text-fg hover:bg-bg-hi",title:`delete this key from ${Oi[s].label}`,children:"↺"}):o.jsx("span",{})]},s)}),o.jsxs("div",{className:"grid grid-cols-[5rem_1fr_auto] gap-2 px-2 py-1 items-center",children:[o.jsx("span",{className:"text-fg-faint",children:"Default"}),o.jsx("span",{className:"font-mono text-fg-dim truncate",children:r!==void 0?Ip(r):o.jsx("span",{className:"text-fg-faint",children:"—"})}),o.jsx("span",{})]})]})]})}function ipe({keyName:e,node:r,info:n,targetScope:i,onOverride:s}){const c=(r==null?void 0:r.kind)==="leaf"?r:null;return o.jsxs("div",{className:"mt-3 space-y-2 text-xs",children:[(n==null?void 0:n.description)&&o.jsx("p",{className:"text-fg-dim leading-relaxed whitespace-pre-wrap",children:n.description}),o.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-fg-faint",children:[(n==null?void 0:n.type)&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"Type"}),o.jsx("dd",{className:"text-fg-dim font-mono",children:Array.isArray(n.type)?n.type.join(" | "):n.type})]}),(n==null?void 0:n.default)!==void 0&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"Default"}),o.jsx("dd",{className:"text-fg-dim font-mono",children:Ip(n.default)})]}),(n==null?void 0:n.enum)&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"Options"}),o.jsx("dd",{className:"text-fg-dim font-mono",children:n.enum.map(l=>String(l)).join(" | ")})]}),c&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"Current"}),o.jsxs("dd",{className:"font-mono",children:[o.jsx("span",{className:"text-fg-dim",children:Ip(c.value)}),o.jsxs("span",{className:"ml-2 text-fg-faint",children:["from ",Oi[c.winner].label]})]})]}),c&&c.shadowed.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"Shadowed"}),o.jsx("dd",{className:"space-y-0.5",children:c.shadowed.map((l,u)=>o.jsxs("div",{className:"font-mono text-fg-faint line-through",children:[Ip(l.value)," —"," ",o.jsx("span",{className:"no-underline",children:Oi[l.scope].label})]},u))})]}),(r==null?void 0:r.kind)==="array"&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"Accumulated"}),o.jsxs("dd",{className:"text-fg-dim",children:[r.items.length," items across all scopes"]})]})]}),o.jsx("div",{className:"pt-2 flex items-center gap-2 flex-wrap border-t border-line/60",children:o.jsx(spe,{keyName:e,node:r,info:n,onChange:s,targetScope:i})})]})}function spe({node:e,info:r,onChange:n,targetScope:i}){const a=(e==null?void 0:e.kind)==="leaf"?e.value:r==null?void 0:r.default,c=C8(r==null?void 0:r.type);if(c==="boolean"){const l=a===!0;return o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-fg-faint",children:"Set to:"}),o.jsx("div",{className:"inline-flex rounded border border-line overflow-hidden",children:[{v:!0,label:"on"},{v:!1,label:"off"}].map(({v:u,label:f})=>o.jsx("button",{onClick:()=>n(u),className:`px-3 py-0.5 text-xs transition-colors ${l===u?"bg-accent text-bg":"bg-bg-elev text-fg-dim hover:bg-bg-hi hover:text-fg"}`,children:f},f))}),o.jsxs("span",{className:"text-fg-faint",children:["→ ",Oi[i].label]})]})}return r!=null&&r.enum?o.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[o.jsx("span",{className:"text-fg-faint",children:"Choose:"}),r.enum.map(l=>{const u=j8(a,l);return o.jsx("button",{onClick:()=>n(l),className:`px-2 py-0.5 text-xs rounded border ${u?"bg-accent text-bg border-accent":"bg-bg-elev text-fg-dim border-line hover:text-fg hover:bg-bg-hi"}`,children:String(l)},String(l))}),o.jsxs("span",{className:"text-fg-faint",children:["→ ",Oi[i].label]})]}):c==="integer"||c==="number"?o.jsx(ape,{value:typeof a=="number"?a:void 0,integer:c==="integer",onCommit:n,target:Oi[i].label}):c==="string"?o.jsx(ope,{value:typeof a=="string"?a:"",onCommit:n,target:Oi[i].label}):o.jsxs("div",{className:"text-fg-faint",children:["Complex value (",c??"object/array",") — use the"," ",o.jsx("span",{className:"text-fg-dim",children:"Raw"})," tab to edit."]})}function ape({value:e,integer:r,onCommit:n,target:i}){const[s,a]=D.useState(e!==void 0?String(e):""),c=()=>{const l=r?parseInt(s,10):parseFloat(s);Number.isNaN(l)||n(l)};return o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-fg-faint",children:"Set to:"}),o.jsx("input",{type:"number",value:s,onChange:l=>a(l.target.value),onBlur:c,onKeyDown:l=>{l.key==="Enter"&&l.target.blur()},className:"w-24 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"}),o.jsxs("button",{onClick:c,className:"px-2 py-0.5 text-xs border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg",children:["save → ",i]})]})}function ope({value:e,onCommit:r,target:n}){const[i,s]=D.useState(e);return o.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[o.jsx("span",{className:"text-fg-faint shrink-0",children:"Set to:"}),o.jsx("input",{type:"text",value:i,onChange:a=>s(a.target.value),onKeyDown:a=>{a.key==="Enter"&&r(i)},className:"flex-1 min-w-0 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"}),o.jsxs("button",{onClick:()=>r(i),className:"shrink-0 px-2 py-0.5 text-xs border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg",children:["save → ",n]})]})}function lpe({node:e,info:r,onSet:n,disabled:i}){const s=(e==null?void 0:e.kind)==="leaf",a=C8(r==null?void 0:r.type);if(i)return null;if(a==="boolean"){const c=s&&e.value===!0;return o.jsx("button",{onClick:()=>n(!c),className:`px-2.5 py-0.5 text-xs rounded border transition-colors ${c?"bg-accent/15 text-accent border-accent/40 hover:bg-accent hover:text-bg":"bg-bg-elev text-fg-dim border-line hover:text-fg hover:bg-bg-hi"}`,title:"toggle",children:c?"on":"off"})}return null}function cpe({isSet:e,leafNode:r,defaultVal:n,isDefault:i,node:s}){return e?(s==null?void 0:s.kind)==="array"?{kind:"accumulated",label:`${s.items.length} items`}:(s==null?void 0:s.kind)==="object"?{kind:"set",label:"configured"}:r?i?{kind:"default",label:`= default · ${Oi[r.winner].label}`}:r.shadowed.length>0?{kind:"override",label:`overriding ${r.shadowed.length} scope(s)`}:{kind:"set",label:`set in ${Oi[r.winner].label}`}:{kind:"set",label:"configured"}:n!==void 0?{kind:"default",label:`using default: ${Ip(n)}`}:{kind:"unset",label:"not configured"}}function upe({kind:e,label:r}){const n={set:"bg-accent/15 text-accent border-accent/30",default:"bg-bg-hi text-fg-dim border-line",unset:"bg-bg-elev text-fg-faint border-line",override:"bg-purple-950/30 text-purple-400/80 border-purple-900/40",accumulated:"bg-blue-950/30 text-blue-400/80 border-blue-900/40"}[e];return o.jsx("span",{className:`text-[9px] px-1.5 py-0 rounded border uppercase tracking-wide ${n}`,children:r})}function C8(e){if(e)return Array.isArray(e)?e.find(n=>n!=="null")??e[0]:e}function j8(e,r){return e===r?!0:typeof e!=typeof r?!1:e&&r&&typeof e=="object"?JSON.stringify(e)===JSON.stringify(r):!1}function dpe(e){const r=e.trim().split(`
3449
+ `).length+1),className:"w-full font-mono text-[11px] bg-bg border border-line rounded p-2 text-fg outline-none focus:border-fg-faint resize-y"}),f&&o.jsxs("div",{className:"mt-1 text-[10px] text-red-400",children:["Invalid JSON: ",f]}),o.jsxs("div",{className:"mt-1 flex gap-2",children:[o.jsx("button",{onClick:()=>x(E.line),className:"px-2 py-0.5 text-[11px] text-white bg-blue-600 hover:bg-blue-500 rounded",children:"Save record"}),o.jsx("button",{onClick:()=>{c(null),m(null)},className:"px-2 py-0.5 text-[11px] text-fg-dim hover:text-fg border border-line rounded",children:"Cancel"})]})]}),N&&a!==E.line&&o.jsx("pre",{className:"px-3 pb-2 pl-12 font-mono text-[11px] text-fg-dim whitespace-pre-wrap break-all",children:E.error?E.raw:JSON.stringify(E.value,null,2)})]},E.line)})})]})}function bhe(e){if(!e)return"0 B";const r=["B","KB","MB","GB"],n=Math.min(r.length-1,Math.floor(Math.log(e)/Math.log(1024)));return`${(e/1024**n).toFixed(n?1:0)} ${r[n]}`}function xhe({path:e,name:r,size:n,mime:i,reason:s}){return o.jsx("div",{className:"h-full flex items-center justify-center bg-bg",children:o.jsxs("div",{className:"text-center max-w-sm px-6",children:[o.jsx("div",{className:"mx-auto mb-4 w-12 h-12 rounded-lg border border-line flex items-center justify-center text-fg-faint",children:o.jsxs("svg",{width:22,height:22,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),o.jsx("path",{d:"M14 2v6h6"})]})}),o.jsx("div",{className:"text-sm font-medium text-fg truncate",children:r}),o.jsxs("div",{className:"mt-1 text-[11px] text-fg-faint",children:[s," · ",i," · ",bhe(n)]}),o.jsxs("div",{className:"mt-5 flex items-center justify-center gap-2",children:[o.jsx("button",{onClick:()=>window.api.shell.open({as:"openPath",path:e}),className:"px-3 py-1 text-xs text-fg rounded bg-bg-hi border border-line hover:bg-bg-elev",children:"Open in default app"}),o.jsx("button",{onClick:()=>window.api.shell.open({as:"revealPath",path:e}),className:"px-3 py-1 text-xs text-fg-dim hover:text-fg border border-line rounded",children:"Reveal"})]})]})})}const whe=D.lazy(()=>ab(()=>import("./TiptapBody-DgFO_m3g.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(e=>({default:e.TiptapBody})));function ow(e){return e.split("/").filter(Boolean).pop()||e}function qL(e,r){if(!r.length)return e;const n=new Set(r),i={};for(const[s,a]of Object.entries(e))n.has(s)||(i[s]=a);return i}function lw(e){return nB(e)||iB(e)}function bT(){const e=cn(Me=>Me.openFiles),r=cn(Me=>Me.activeFilePath),n=cn(Me=>Me.dirty),i=cn(Me=>Me.viewMode),s=cn(Me=>Me.buffers),a=cn(Me=>Me.setActive),c=cn(Me=>Me.closeFile),l=cn(Me=>Me.closeOthers),u=cn(Me=>Me.closeToTheRight),f=cn(Me=>Me.closeAll),m=cn(Me=>Me.loadBuffer),h=cn(Me=>Me.setBuffer),b=cn(Me=>Me.markSaved),w=cn(Me=>Me.setViewMode),k=Yv(),[S,y]=D.useState({}),[x,_]=D.useState({}),[C,T]=D.useState(null),[E,$]=D.useState(null),[N,P]=D.useState(!1),[I,W]=D.useState(!1),[F,U]=D.useState(!0),q=D.useRef(null),z=D.useRef(null),Y=D.useRef(void 0),ee=D.useCallback(Me=>{q.current=Me},[]),se=D.useCallback(()=>q.current,[]);D.useEffect(()=>{const Me=r;if(!Me||lw(Me))return;if(cn.getState().hasBuffer(Me)){y(mt=>mt[Me]==="ready"?mt:{...mt,[Me]:"ready"});return}let Ue=!1;return y(mt=>({...mt,[Me]:"loading"})),window.api.files.read(Me).then(mt=>{Ue||(mt.binary?y(jt=>({...jt,[Me]:{binary:!0,size:mt.size??0,mime:mt.mime??"application/octet-stream",reason:mt.error??"Binary file"}})):mt.ok?(m(Me,mt.text),y(jt=>({...jt,[Me]:"ready"}))):y(jt=>({...jt,[Me]:{error:mt.error??"failed to read"}})))}),()=>{Ue=!0}},[r,m]),D.useEffect(()=>{$(null)},[r]);const ue=D.useCallback(async(Me,Ue=!1)=>{const mt=cn.getState().buffers[Me];if(mt==null)return;Ue&&P(!0);const jt=await window.api.files.write(Me,mt);jt.ok?(b(Me),_(er=>({...er,[Me]:(er[Me]??0)+1})),Ue||Ze.info(`Saved ${ow(Me)}`)):Ze.error(jt.error??`Couldn't save ${ow(Me)}`),Ue&&P(!1)},[b]);D.useEffect(()=>{if(!k.autosave)return;const Me=r;if(!(!Me||lw(Me)||!n[Me]))return window.clearTimeout(Y.current),Y.current=window.setTimeout(()=>{ue(Me,!0)},1200),()=>window.clearTimeout(Y.current)},[k.autosave,r,n,s,ue]);const X=D.useCallback(Me=>{Me.length&&(y(Ue=>qL(Ue,Me)),_(Ue=>qL(Ue,Me)))},[]),Q=D.useCallback(Me=>{n[Me]?T({kind:"one",path:Me}):(c(Me),X([Me]))},[n,c,X]),Z=D.useCallback(Me=>{e.some(mt=>mt.path!==Me&&n[mt.path])?T({kind:"others",path:Me}):(l(Me),X(e.filter(mt=>mt.path!==Me).map(mt=>mt.path)))},[e,n,l,X]),ae=D.useCallback(Me=>{const Ue=e.findIndex(jt=>jt.path===Me);Ue!==-1&&e.slice(Ue+1).some(jt=>n[jt.path])?T({kind:"right",path:Me}):(u(Me),X(Ue!==-1?e.slice(Ue+1).map(jt=>jt.path):[]))},[e,n,u,X]);D.useEffect(()=>{const Me=Ue=>{if((Ue.metaKey||Ue.ctrlKey)&&(Ue.key==="s"||Ue.key==="S")){const mt=cn.getState().activeFilePath;mt&&!lw(mt)&&(Ue.preventDefault(),ue(mt))}else if((Ue.metaKey||Ue.ctrlKey)&&Ue.shiftKey&&(Ue.key==="f"||Ue.key==="F"))Ue.preventDefault(),W(mt=>!mt);else if((Ue.metaKey||Ue.ctrlKey)&&Ue.shiftKey&&(Ue.key==="w"||Ue.key==="W")){const mt=cn.getState().activeFilePath;mt&&cn.getState().openFiles.length>1&&(Ue.preventDefault(),Z(mt))}else Ue.key==="Escape"&&I&&W(!1)};return window.addEventListener("keydown",Me),()=>window.removeEventListener("keydown",Me)},[ue,I,Z]);const oe=D.useCallback(()=>{e.some(Ue=>n[Ue.path])?T({kind:"all",path:""}):(f(),y({}),_({}))},[e,n,f]),de=()=>{if(C){if(C.kind==="one")c(C.path),X([C.path]);else if(C.kind==="others"){const Me=e.filter(Ue=>Ue.path!==C.path).map(Ue=>Ue.path);l(C.path),X(Me)}else if(C.kind==="right"){const Me=e.findIndex(mt=>mt.path===C.path),Ue=Me!==-1?e.slice(Me+1).map(mt=>mt.path):[];u(C.path),X(Ue)}else f(),y({}),_({});T(null)}};if(e.length===0)return o.jsx("div",{className:"h-full flex items-center justify-center text-fg-faint text-xs",children:o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"mb-2",children:"no file open"}),o.jsxs("div",{children:["open the ",o.jsx("span",{className:"text-fg-dim",children:"File Explorer"})," tab and click a file to edit it here"]})]})});const ve=r,$e=ve?ow(ve):"",we=ve?S[ve]:void 0,ne=ve?oB(ve):!1,ce=ve?yH(ve):!1,ge=ve&&ne?i[ve]??bH(ve):"edit",Ae=!!ve&&!lw(ve)&&we==="ready",Te=Ae,nt=ce?["edit","wysiwyg","preview","split"]:ne?["edit","preview"]:[],ct=ve&&o.jsx(nhe,{path:ve,name:$e,value:s[ve]??"",onChange:Me=>h(ve,Me),onSave:()=>void ue(ve),onReady:ee,onCursor:$}),Le=N?"Saving…":ve&&n[ve]?k.autosave?"Editing…":"Unsaved":"All changes saved";return o.jsxs("div",{className:"relative flex flex-col h-full bg-bg",children:[!I&&o.jsx(Qfe,{openFiles:e,activeFilePath:r,dirty:n,onSelectFile:a,onCloseFile:Q,onCloseOthers:Z,onCloseToTheRight:ae,onCloseAll:oe}),ve&&!I&&o.jsxs("div",{className:"flex items-center px-3 h-8 border-b border-line shrink-0 bg-bg-elev",children:[o.jsx("span",{className:"text-xs font-medium text-fg truncate",children:$e}),o.jsx("span",{className:"ml-3 text-[10px] text-fg-faint truncate",children:ve}),Ae&&o.jsxs("span",{className:"ml-3 text-[10px] text-fg-faint shrink-0",children:["· ",Le]}),o.jsx("div",{className:"flex-1"}),Hd(ve)&&(ge==="preview"||ge==="split")&&o.jsx("button",{onClick:()=>U(Me=>!Me),className:`px-2 py-0.5 text-[10px] border border-line rounded mr-1 ${F?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Toggle document outline",children:"Outline"}),Ae&&o.jsxs("div",{className:"flex items-center mr-2 rounded border border-line overflow-hidden",children:[o.jsx("button",{onClick:()=>k.bumpFontSize(-1),className:"px-1.5 py-0.5 text-[11px] text-fg-faint hover:text-fg",title:"Zoom out",children:"A−"}),o.jsx("button",{onClick:()=>k.bumpFontSize(1),className:"px-1.5 py-0.5 text-[11px] text-fg-faint hover:text-fg",title:"Zoom in",children:"A+"}),o.jsx("button",{onClick:k.toggleWordWrap,className:`px-1.5 py-0.5 text-[10px] ${k.wordWrap?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Word wrap",children:"Wrap"}),o.jsx("button",{onClick:k.toggleMinimap,className:`px-1.5 py-0.5 text-[10px] ${k.minimap?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Minimap",children:"Map"}),o.jsx("button",{onClick:()=>k.setTheme(k.theme==="dark"?"paper":"dark"),className:"px-1.5 py-0.5 text-[10px] text-fg-faint hover:text-fg",title:"Toggle editor theme",children:k.theme==="dark"?"Dark":"Paper"}),o.jsx("button",{onClick:k.toggleAutosave,className:`px-1.5 py-0.5 text-[10px] ${k.autosave?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Autosave",children:"Auto"})]}),nt.length>0&&o.jsx("div",{className:"flex items-center mr-2 rounded border border-line overflow-hidden",children:nt.map(Me=>o.jsx("button",{onClick:()=>w(ve,Me),className:`px-2 py-0.5 text-[10px] capitalize transition-colors ${ge===Me?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,children:Me},Me))}),o.jsx("button",{onClick:()=>W(!0),className:"px-2 py-0.5 text-[10px] text-fg-faint hover:text-fg border border-line rounded mr-1",title:"Focus mode (Cmd/Ctrl-Shift-F)",children:"Focus"}),o.jsx("button",{onClick:()=>window.api.shell.open({as:"openPath",path:ve}),className:"px-2 py-0.5 text-[10px] text-fg-faint hover:text-fg border border-line rounded mr-1",title:"Open in default app",children:"Open"}),o.jsx("button",{onClick:()=>window.api.shell.open({as:"revealPath",path:ve}),className:"px-2 py-0.5 text-[10px] text-fg-faint hover:text-fg border border-line rounded",title:"Reveal in OS",children:"Reveal"})]}),I&&o.jsx("button",{onClick:()=>W(!1),className:"absolute top-2 right-3 z-10 px-2 py-0.5 text-[10px] text-fg-faint hover:text-fg border border-line rounded bg-bg-elev/80",title:"Exit focus mode (Esc)",children:"Exit focus"}),o.jsx("div",{className:"flex-1 min-h-0",children:ve?nB(ve)?o.jsx(fhe,{path:ve,name:$e}):iB(ve)?o.jsx(hhe,{path:ve}):we&&typeof we=="object"&&"binary"in we?o.jsx(xhe,{path:ve,name:$e,size:we.size,mime:we.mime,reason:we.reason}):we&&typeof we=="object"&&"error"in we?o.jsx("div",{className:"p-6 text-xs text-red-400",children:we.error}):we!=="ready"?o.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"loading…"}):ge==="wysiwyg"&&Hd(ve)?o.jsx(D.Suspense,{fallback:o.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"Loading editor…"}),children:o.jsx(whe,{value:s[ve]??"",onChange:Me=>h(ve,Me)},ve)}):ge==="split"&&Hd(ve)?o.jsxs("div",{className:"flex h-full",children:[F&&o.jsx(WL,{text:s[ve]??"",scrollRef:z}),o.jsxs("div",{className:"flex-1 min-w-0 flex flex-col border-r border-line",children:[o.jsx(UL,{getEditor:se}),o.jsx("div",{className:"flex-1 min-h-0",children:ct})]}),o.jsx("div",{className:"flex-1 min-w-0",children:o.jsx(FL,{ref:z,text:s[ve]??"",flush:!0})})]}):ge==="preview"&&Hd(ve)?o.jsxs("div",{className:"flex h-full",children:[F&&o.jsx(WL,{text:s[ve]??"",scrollRef:z}),o.jsx("div",{className:"flex-1 min-w-0",children:o.jsx(FL,{ref:z,text:s[ve]??""})})]}):ge==="preview"&&rB(ve)?o.jsx(uhe,{path:ve,dirty:!!n[ve],reloadToken:x[ve]??0}):ge==="preview"&&sB(ve)?o.jsx(mhe,{path:ve,text:s[ve]??""}):ge==="preview"&&aB(ve)?o.jsx(yhe,{path:ve,text:s[ve]??""}):Hd(ve)?o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsx(UL,{getEditor:se}),o.jsx("div",{className:"flex-1 min-h-0",children:ct})]}):ct:null}),Te&&o.jsx(che,{text:s[ve]??"",cursor:E,language:wa(ve)||void 0}),C&&o.jsx(_he,{message:C.kind==="one"?`Discard unsaved changes to ${ow(C.path)}?`:C.kind==="others"?"Discard unsaved changes in the other open files?":C.kind==="right"?"Discard unsaved changes in the files to the right?":"Discard unsaved changes in all open files?",onCancel:()=>T(null),onConfirm:de})]})}function _he({message:e,onCancel:r,onConfirm:n}){return o.jsx("div",{className:"fixed inset-0 z-[400] flex items-center justify-center bg-black/60",onMouseDown:i=>{i.target===i.currentTarget&&r()},children:o.jsxs("div",{className:"w-96 rounded-lg border border-line bg-bg-elev p-4 shadow-2xl",children:[o.jsx("h3",{className:"text-sm font-medium text-fg mb-3",children:e}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx("button",{onClick:r,className:"px-3 py-1 text-xs text-fg-dim hover:text-fg border border-line rounded",children:"Cancel"}),o.jsx("button",{onClick:n,className:"px-3 py-1 text-xs text-white rounded bg-red-600 hover:bg-red-500",children:"Discard"})]})]})})}const HL={ts:"#3178c6",tsx:"#61dafb",js:"#f7df1e",jsx:"#61dafb",cjs:"#f7df1e",mjs:"#f7df1e",json:"#5d5d5d",css:"#264de4",scss:"#cd6799",less:"#1d365d",html:"#e34c26",md:"#083fa1",mdx:"#083fa1",py:"#3776ab",go:"#00add8",rs:"#dea584",java:"#b07219",kt:"#a97bff",c:"#555555",cpp:"#f34b7d",cc:"#f34b7d",h:"#555555",hpp:"#f34b7d",swift:"#fa7343",rb:"#cc342d",php:"#4f5d95",sql:"#e38c00",sh:"#89e051",bash:"#89e051",zsh:"#89e051",yaml:"#cb171e",yml:"#cb171e",toml:"#9c4221",xml:"#0060ac",svg:"#ff9900",vue:"#41b883",svelte:"#ff3e00",other:"#6b7280"},She={ts:"TypeScript",tsx:"TSX",js:"JavaScript",jsx:"JSX",cjs:"CommonJS",mjs:"ES Module",json:"JSON",css:"CSS",scss:"SCSS",less:"Less",html:"HTML",md:"Markdown",mdx:"MDX",py:"Python",go:"Go",rs:"Rust",java:"Java",kt:"Kotlin",c:"C",cpp:"C++",cc:"C++",h:"C/C++ Header",hpp:"C++ Header",swift:"Swift",rb:"Ruby",php:"PHP",sql:"SQL",sh:"Shell",bash:"Shell",zsh:"Shell",yaml:"YAML",yml:"YAML",toml:"TOML",xml:"XML",svg:"SVG",vue:"Vue",svelte:"Svelte",other:"Other"};function ej(e){return e>=1e6?(e/1e6).toFixed(1)+"M":e>=1e3?(e/1e3).toFixed(1)+"K":String(e)}function khe({open:e,onClose:r,variant:n="overlay"}){const i=kt(E=>E.tabs.find($=>$.id===E.activeTabId)??null),s=(i==null?void 0:i.cwd)??null,[a,c]=D.useState(null),[l,u]=D.useState(!1),[f,m]=D.useState(null),h=D.useRef(null),b=D.useCallback(async E=>{u(!0),m(null);try{const $=await window.api.repo.analyze(E);$.ok?c($):(m($.error||"Analysis failed"),c(null))}catch($){m($ instanceof Error?$.message:String($)),c(null)}finally{u(!1)}},[]);D.useEffect(()=>{if(e){if(!s){m("No active session — open a tab in a folder first.");return}b(s)}},[e,s,b]),D.useEffect(()=>{var $;if(!e)return;const E=N=>{N.key==="Escape"&&(N.stopPropagation(),r())};return window.addEventListener("keydown",E),($=h.current)==null||$.focus(),()=>window.removeEventListener("keydown",E)},[e,r]);const w=D.useCallback(()=>{s&&b(s)},[s,b]),k=D.useMemo(()=>a?Object.entries(a.languageBreakdown).map(([$,N])=>[$,N.files,N.lines]).sort(($,N)=>N[1]-$[1]).slice(0,12):[],[a]),S=D.useMemo(()=>k.length===0?1:k[0][1],[k]),y=D.useMemo(()=>{if(!a)return[];const E=a.topDirectories;if(E.length===0)return[];const $=E.map(P=>Math.sqrt(Math.max(1,P.fileCount))),N=$.reduce((P,I)=>P+I,0)||1;return E.map((P,I)=>({path:P.path,fileCount:P.fileCount,totalLines:P.totalLines,basis:$[I]/N*100}))},[a]);if(!e)return null;const x=E=>{E.target===E.currentTarget&&r()},_=s?s.split("/").filter(Boolean).pop()||s:"no folder",C=n==="page",T=o.jsx("div",{className:C?"h-full w-full flex flex-col bg-bg":"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:C?void 0:x,"data-testid":"repoviz-backdrop",children:o.jsxs("div",{ref:h,role:C?void 0:"dialog","aria-modal":C?void 0:"true","aria-label":"Repository Visualization",tabIndex:-1,className:C?"h-full w-full flex flex-col outline-none bg-bg":"bg-bg-elev border border-line rounded-lg shadow-xl w-[900px] max-w-[95vw] max-h-[85vh] flex flex-col outline-none","data-testid":"repoviz-dialog",children:[o.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-line",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[o.jsx("span",{className:"text-lg","aria-hidden":!0,children:"🗺"}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("h2",{className:"text-base font-medium text-fg leading-tight",children:"Repository Visualization"}),o.jsxs("div",{className:"text-xs text-fg-dim truncate",title:s??"",children:[_,(a==null?void 0:a.gitStatus.branch)&&o.jsxs("span",{className:"ml-2 font-mono text-fg-faint",children:["(",a.gitStatus.branch,")"]}),(a==null?void 0:a.truncated)&&o.jsx("span",{className:"ml-2 text-amber-400",children:"truncated"})]})]})]}),o.jsxs("div",{className:"flex items-center gap-1",children:[a&&a.gitStatus.uncommitted>0&&o.jsxs("span",{className:"px-2 py-0.5 rounded-full bg-amber-500/20 text-amber-400 text-[11px] font-mono",title:`${a.gitStatus.uncommitted} uncommitted files`,children:[a.gitStatus.uncommitted," uncommitted"]}),o.jsxs("button",{type:"button",onClick:w,disabled:l||!s,className:"px-2 py-1 rounded text-fg-dim hover:bg-bg-hi hover:text-fg text-xs disabled:opacity-40 disabled:cursor-not-allowed",title:"Re-run analysis",children:[l?"…":"↻"," Refresh"]}),o.jsx("button",{type:"button",onClick:r,className:"px-2 py-1 rounded text-fg-dim hover:bg-bg-hi hover:text-fg text-xs","aria-label":"Close",children:"✕"})]})]}),o.jsx("div",{className:"flex-1 overflow-y-auto p-5 space-y-6",children:l&&!a?o.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-fg-dim",children:[o.jsx("div",{className:"text-3xl mb-3 animate-pulse","aria-hidden":!0,children:"⟳"}),o.jsx("div",{className:"text-sm",children:"Analyzing repository…"}),o.jsx("div",{className:"text-xs text-fg-faint mt-1",children:"Walking files, counting lines, reading git status"})]}):f?o.jsxs("div",{className:"py-16 text-center",children:[o.jsx("div",{className:"text-3xl mb-3 text-red-400","aria-hidden":!0,children:"⚠"}),o.jsx("div",{className:"text-sm text-red-400",children:f})]}):a?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[o.jsx(tj,{label:"Files",value:ej(a.totalFiles)}),o.jsx(tj,{label:"Lines of code",value:ej(a.totalLines)}),o.jsx(tj,{label:"Uncommitted",value:String(a.gitStatus.uncommitted),tone:a.gitStatus.uncommitted>0?"warn":"neutral"})]}),o.jsxs("section",{children:[o.jsx("h3",{className:"text-xs uppercase tracking-wider text-fg-faint mb-2",children:"Languages"}),k.length===0?o.jsx("div",{className:"text-xs text-fg-dim",children:"No files detected."}):o.jsx("div",{className:"space-y-1.5",children:k.map(([E,$,N])=>{const P=HL[E]??HL.other,I=She[E]??E,W=$/S*100;return o.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[o.jsx("span",{className:"w-24 text-fg-dim truncate",title:I,children:I}),o.jsx("div",{className:"flex-1 h-4 bg-bg rounded overflow-hidden",children:o.jsx("div",{className:"h-full rounded",style:{width:`${W}%`,backgroundColor:P}})}),o.jsxs("span",{className:"w-16 text-right text-fg-dim font-mono",children:[$," files"]}),o.jsxs("span",{className:"w-20 text-right text-fg-faint font-mono",children:[ej(N)," L"]})]},E)})})]}),o.jsxs("section",{children:[o.jsx("h3",{className:"text-xs uppercase tracking-wider text-fg-faint mb-2",children:"Top directories"}),y.length===0?o.jsx("div",{className:"text-xs text-fg-dim",children:"No directories."}):o.jsx("div",{className:"flex flex-wrap gap-1 min-h-[140px]",children:y.map(E=>o.jsxs("div",{className:"relative rounded bg-bg-hi border border-line hover:border-accent transition-colors cursor-default flex flex-col justify-end p-2 min-w-[80px] min-h-[60px]",style:{flexBasis:`${Math.max(E.basis,6)}%`,flexGrow:E.basis>15?1:0},title:`${E.path} — ${E.fileCount} files, ${E.totalLines.toLocaleString()} lines`,children:[o.jsx("div",{className:"text-[11px] font-mono text-fg truncate",children:E.path}),o.jsxs("div",{className:"text-[10px] text-fg-dim font-mono",children:[E.fileCount," files"]})]},E.path))})]}),o.jsxs("div",{className:"text-[10px] text-fg-faint text-right",children:["Analyzed in ",a.durationMs,"ms",a.truncated&&" — stopped early (5000-file cap or 30s timeout)"]})]}):o.jsx("div",{className:"py-16 text-center text-fg-dim text-sm",children:"No analysis yet. Click Refresh."})})]})});return!C&&typeof document<"u"&&document.body?xf.createPortal(T,document.body):T}function tj({label:e,value:r,tone:n="neutral"}){const i=n==="warn"?"text-amber-400":"text-fg";return o.jsxs("div",{className:"bg-bg-hi/40 border border-line rounded-lg p-3",children:[o.jsx("div",{className:`text-xl font-medium ${i}`,children:r}),o.jsx("div",{className:"text-xs text-fg-dim mt-0.5",children:e})]})}function jf({options:e,active:r,onChange:n}){return o.jsx("div",{className:"flex rounded border border-line overflow-hidden",children:e.map(({key:i,label:s})=>o.jsx("button",{onClick:()=>n(i),className:`px-2 py-0.5 text-xs ${r===i?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:s},i))})}const VL=e=>/[/\\\-_.\s]/.test(e),GL=e=>e>="A"&&e<="Z";function Che(e,r,n){if(!e)return{match:!0,score:0,matched:[]};const i=e.toLowerCase(),s=r.toLowerCase(),a=(n||r).toLowerCase(),c=r.split("/").pop()||r,l=c.toLowerCase();if(l===i)return{match:!0,score:1e3,matched:Array.from({length:c.length},(x,_)=>_)};if(l.startsWith(i))return{match:!0,score:900,matched:Array.from({length:e.length},(x,_)=>_)};let u=0;for(const x of a.split("/")){if(x===i)return{match:!0,score:800,matched:[]};x.startsWith(i)&&(u=Math.max(u,700))}const f=l.indexOf(i);if(f!==-1)return{match:!0,score:f===0||VL(l[f-1])||GL(c[f])?650:600,matched:Array.from({length:e.length},(_,C)=>f+C)};if(a.includes(i))return{match:!0,score:Math.max(500,u),matched:[]};let m=0,h=0,b=0,w=-1,k=0;const S=[];for(let x=0;x<s.length&&m<i.length;x++)s[x]===i[m]&&(S.push(x),h+=10,w===x-1?(b++,h+=b*8):b=0,(x===0||VL(s[x-1])||GL(r[x]))&&(k++,h+=15,x===0&&(h+=10)),w=x,m++);if(m!==i.length)return{match:!1,score:0,matched:[]};const y=Math.max(0,50-(s.length-i.length));if(h+=y,k>=i.length*.5&&(h+=30),S.length>1){const x=S[S.length-1]-S[0];x>i.length*3&&(h-=Math.min(50,(x-i.length*3)*2))}return{match:!0,score:Math.max(1,h),matched:S}}function rj(e,r){return e.startsWith(r+"/")?e.slice(r.length+1):e===r?"":e}function KL(e){const r=e.lastIndexOf("/");return r<0?"":e.slice(0,r)}const XL="session-manager.quickopen.recent",jhe=8;function Ehe({open:e,onClose:r,variant:n="overlay"}){const i=kt(I=>I.tabs.find(W=>W.id===I.activeTabId)??null),s=(i==null?void 0:i.cwd)??"",[a,c]=D.useState(""),[l,u]=D.useState([]),[f,m]=D.useState(!1),[h,b]=D.useState(0),[w,k]=D.useState([]),S=D.useRef(null),y=D.useRef(null);D.useEffect(()=>{if(e)try{const I=localStorage.getItem(XL);I&&k(JSON.parse(I))}catch{}},[e]),D.useEffect(()=>{if(!e){c(""),b(0);return}const I=setTimeout(()=>{var W;return(W=S.current)==null?void 0:W.focus()},0);return()=>clearTimeout(I)},[e]),D.useEffect(()=>{if(!e||!s)return;let I=!1;return m(!0),window.api.search.files(s,"",{limit:5e3}).then(W=>{if(!I){if(!W.ok){Ze.error(`File search failed: ${W.error??"unknown error"}`),u([]);return}u(W.files)}}).catch(W=>{const F=W instanceof Error?W.message:String(W);gt.error("quick-open","search.files threw",{error:F}),Ze.error(`File search failed: ${F}`),u([])}).finally(()=>{I||m(!1)}),()=>{I=!0}},[e,s]);const x=D.useMemo(()=>{if(!a.trim())return[...l].sort((U,q)=>U.name.localeCompare(q.name)).slice(0,100).map(U=>({file:U,score:0,matched:[]}));const I=a.trim(),W=[];for(const F of l){const U=Che(I,F.name,F.path);U.match&&W.push({file:F,score:U.score,matched:U.matched})}return W.sort((F,U)=>U.score-F.score),W.slice(0,100)},[l,a]),_=D.useMemo(()=>a.trim()?[]:w.map(I=>l.find(W=>W.path===I)||null).filter(I=>I!==null).slice(0,5),[w,l,a]);D.useEffect(()=>{const I=_.length+x.length;h>=I&&b(Math.max(0,I-1))},[_.length,x.length,h]),D.useEffect(()=>{if(!y.current)return;const I=y.current.querySelector(`[data-row="${h}"]`);I&&I.scrollIntoView({block:"nearest"})},[h]);const C=D.useCallback(I=>{try{const q=[I,...w.filter(z=>z!==I)].slice(0,jhe);k(q),localStorage.setItem(XL,JSON.stringify(q))}catch{}const W=i==null?void 0:i.id;if(!W){Ze.error("No active tab to receive file path");return}const U=(s?rj(I,s):I)||I;try{window.api.pty.write({tabId:W,data:U})}catch(q){const z=q instanceof Error?q.message:String(q);gt.error("quick-open","pty.write failed",{error:z}),Ze.error(`Failed to write to terminal: ${z}`);return}r()},[i==null?void 0:i.id,s,w,r]),T=D.useCallback(I=>{const W=_.length+x.length;if(I.key==="Escape"){I.preventDefault(),r();return}if(I.key==="ArrowDown"){if(I.preventDefault(),W===0)return;b(F=>Math.min(W-1,F+1));return}if(I.key==="ArrowUp"){if(I.preventDefault(),W===0)return;b(F=>Math.max(0,F-1));return}if(I.key==="Enter"){if(I.preventDefault(),h<_.length){const q=_[h];q&&C(q.path);return}const F=h-_.length,U=x[F];U&&C(U.file.path)}},[h,x,_,C,r]);if(!e)return null;const E=(I,W)=>{if(W.length===0)return I;const F=new Set(W);return I.split("").map((U,q)=>o.jsx("span",{className:F.has(q)?"text-accent font-semibold":"",children:U},q))};let $=-1;const N=n==="page",P=o.jsx("div",{className:N?"h-full w-full flex flex-col bg-bg":"fixed inset-0 z-[55] flex items-start justify-center bg-black/60 pt-[12vh]",onClick:N?void 0:I=>{I.target===I.currentTarget&&r()},"data-testid":"quick-open-backdrop",children:o.jsxs("div",{role:N?void 0:"dialog","aria-modal":N?void 0:"true","aria-label":"Quick Open",className:N?"h-full w-full flex flex-col":"w-[640px] max-w-[90vw] max-h-[70vh] bg-bg-elev border border-line rounded shadow-xl flex flex-col","data-testid":"quick-open",onKeyDown:T,children:[o.jsx("div",{className:"border-b border-line p-2",children:o.jsx("input",{ref:S,type:"text",value:a,onChange:I=>{c(I.target.value),b(0)},placeholder:s?"Search files in this project…":"No active tab — open a terminal first",disabled:!s,spellCheck:!1,autoComplete:"off",className:"w-full bg-transparent text-fg placeholder:text-fg-dim outline-none px-2 py-1.5 text-sm","aria-label":"Search files"})}),o.jsx("div",{ref:y,className:"flex-1 min-h-0 overflow-y-auto",role:"listbox",children:f?o.jsx("div",{className:"px-4 py-6 text-sm text-fg-dim",children:"Loading…"}):s?_.length===0&&x.length===0?o.jsx("div",{className:"px-4 py-6 text-sm text-fg-dim",children:a?"No files match.":"No files found in this project."}):o.jsxs(o.Fragment,{children:[_.length>0&&o.jsxs("div",{children:[o.jsx("div",{className:"px-3 pt-2 pb-1 text-[10px] uppercase tracking-wider text-fg-dim",children:"Recent"}),_.map(I=>{$++;const W=$,F=W===h;return o.jsxs("button",{"data-row":W,role:"option","aria-selected":F,onClick:()=>C(I.path),onMouseEnter:()=>b(W),className:`w-full text-left px-3 py-1.5 text-sm flex flex-col gap-0.5 ${F?"bg-bg-hi text-fg":"hover:bg-bg-hi/50 text-fg"}`,children:[o.jsx("span",{className:"truncate",children:I.name}),o.jsx("span",{className:"text-xs text-fg-dim truncate",children:rj(KL(I.path),s)})]},`r:${I.path}`)})]}),x.length>0&&o.jsxs("div",{children:[_.length>0&&o.jsx("div",{className:"px-3 pt-2 pb-1 text-[10px] uppercase tracking-wider text-fg-dim border-t border-line",children:"Files"}),x.map(({file:I,matched:W})=>{$++;const F=$,U=F===h;return o.jsxs("button",{"data-row":F,role:"option","aria-selected":U,onClick:()=>C(I.path),onMouseEnter:()=>b(F),className:`w-full text-left px-3 py-1.5 text-sm flex flex-col gap-0.5 ${U?"bg-bg-hi text-fg":"hover:bg-bg-hi/50 text-fg"}`,children:[o.jsx("span",{className:"truncate",children:E(I.name,W)}),o.jsx("span",{className:"text-xs text-fg-dim truncate",children:rj(KL(I.path),s)})]},I.path)})]})]}):o.jsx("div",{className:"px-4 py-6 text-sm text-fg-dim",children:"Open a terminal tab to enable Quick Open."})}),o.jsxs("div",{className:"border-t border-line px-3 py-1.5 flex items-center justify-between text-[10px] text-fg-dim",children:[o.jsxs("span",{children:[o.jsx("kbd",{className:"px-1 py-0.5 rounded bg-bg-hi border border-line",children:"↑↓"})," navigate"," ",o.jsx("kbd",{className:"ml-2 px-1 py-0.5 rounded bg-bg-hi border border-line",children:"↵"})," insert into terminal"," ",o.jsx("kbd",{className:"ml-2 px-1 py-0.5 rounded bg-bg-hi border border-line",children:"Esc"})," close"]}),o.jsxs("span",{children:[x.length+_.length," ",x.length+_.length===1?"file":"files"]})]})]})});return!N&&typeof document<"u"&&document.body?xf.createPortal(P,document.body):P}function YL(e,r){return e.startsWith(r+"/")?e.slice(r.length+1):e===r?"":e}function The(e,r,n){if(!r)return e;const i=n?e:e.toLowerCase(),s=n?r:r.toLowerCase(),a=i.indexOf(s);return a<0?e:o.jsxs(o.Fragment,{children:[e.slice(0,a),o.jsx("span",{className:"text-accent font-semibold",children:e.slice(a,a+r.length)}),e.slice(a+r.length)]})}function Ahe({open:e,onClose:r,variant:n="overlay"}){const i=kt(q=>q.tabs.find(z=>z.id===q.activeTabId)??null),s=(i==null?void 0:i.cwd)??"",[a,c]=D.useState(""),[l,u]=D.useState(!1),[f,m]=D.useState([]),[h,b]=D.useState(!1),[w,k]=D.useState(null),[S,y]=D.useState(0),[x,_]=D.useState(null),C=D.useRef(null),T=D.useRef(null),E=D.useRef(0);D.useEffect(()=>{if(!e){c(""),m([]),k(null),y(0);return}const q=setTimeout(()=>{var z;return(z=C.current)==null?void 0:z.focus()},0);return()=>clearTimeout(q)},[e]),D.useEffect(()=>{if(!e||!s)return;const q=a.trim();if(!q){m([]),k(null),b(!1);return}const z=++E.current;b(!0);const Y=setTimeout(()=>{window.api.search.text(s,q,{caseSensitive:l,limit:500}).then(ee=>{z===E.current&&(ee.ok?(m(ee.matches),k(null)):(k(ee.error??"unknown error"),m([])),_(ee.usedRipgrep))}).catch(ee=>{if(z!==E.current)return;const se=ee instanceof Error?ee.message:String(ee);gt.error("global-search","search.text threw",{error:se}),k(se),m([])}).finally(()=>{z===E.current&&b(!1)})},250);return()=>clearTimeout(Y)},[e,s,a,l]);const $=D.useMemo(()=>{const q=new Map;for(const Y of f){const ee=q.get(Y.path);ee?ee.push(Y):q.set(Y.path,[Y])}const z=[];for(const[Y,ee]of q)z.push({path:Y,matches:ee});return z.sort((Y,ee)=>ee.matches.length-Y.matches.length||Y.path.localeCompare(ee.path)),z},[f]),N=D.useMemo(()=>f,[f]);D.useEffect(()=>{S>=N.length&&y(Math.max(0,N.length-1))},[N.length,S]),D.useEffect(()=>{if(!T.current)return;const q=T.current.querySelector(`[data-match="${S}"]`);q&&q.scrollIntoView({block:"nearest"})},[S]);const P=D.useCallback(q=>{const z=i==null?void 0:i.id;if(!z){Ze.error("No active tab to receive path");return}const ee=`${(s?YL(q.path,s):q.path)||q.path}:${q.line}`;try{window.api.pty.write({tabId:z,data:ee})}catch(se){const ue=se instanceof Error?se.message:String(se);gt.error("global-search","pty.write failed",{error:ue}),Ze.error(`Failed to write to terminal: ${ue}`);return}r()},[i==null?void 0:i.id,s,r]),I=D.useCallback(q=>{if(q.key==="Escape"){q.preventDefault(),r();return}if(q.key==="ArrowDown"){if(q.preventDefault(),N.length===0)return;y(z=>Math.min(N.length-1,z+1));return}if(q.key==="ArrowUp"){if(q.preventDefault(),N.length===0)return;y(z=>Math.max(0,z-1));return}if(q.key==="Enter"){q.preventDefault();const z=N[S];z&&P(z)}},[N,S,P,r]);if(!e)return null;const W=n==="page";let F=-1;const U=o.jsx("div",{className:W?"h-full w-full flex flex-col bg-bg":"fixed inset-0 z-[55] flex items-start justify-center bg-black/60 pt-[8vh]",onClick:W?void 0:q=>{q.target===q.currentTarget&&r()},"data-testid":"global-search-backdrop",children:o.jsxs("div",{role:W?void 0:"dialog","aria-modal":W?void 0:"true","aria-label":"Search in project",className:W?"h-full w-full flex flex-col":"w-[840px] max-w-[95vw] h-[80vh] bg-bg-elev border border-line rounded shadow-xl flex flex-col","data-testid":"global-search",onKeyDown:I,children:[o.jsxs("div",{className:"border-b border-line p-2 flex items-center gap-2",children:[o.jsx("input",{ref:C,type:"text",value:a,onChange:q=>{c(q.target.value),y(0)},placeholder:s?"Search in this project…":"No active tab — open a terminal first",disabled:!s,spellCheck:!1,autoComplete:"off",className:"flex-1 bg-transparent text-fg placeholder:text-fg-dim outline-none px-2 py-1.5 text-sm","aria-label":"Search query"}),o.jsx("button",{type:"button",onClick:()=>u(q=>!q),className:`px-2 py-1 text-xs rounded border ${l?"bg-accent/20 border-accent text-accent":"bg-bg border-line text-fg-dim hover:text-fg"}`,title:"Match case","aria-pressed":l,children:"Aa"})]}),o.jsx("div",{ref:T,className:"flex-1 min-h-0 overflow-y-auto",role:"listbox",children:s?a.trim()?h?o.jsx("div",{className:"px-4 py-6 text-sm text-fg-dim",children:"Searching…"}):w?o.jsx("div",{className:"px-4 py-6 text-sm text-red-400",children:w}):N.length===0?o.jsxs("div",{className:"px-4 py-6 text-sm text-fg-dim",children:["No matches for ",JSON.stringify(a),"."]}):o.jsx("div",{children:$.map(q=>o.jsxs("div",{children:[o.jsxs("div",{className:"sticky top-0 bg-bg-elev border-b border-line px-3 py-1 text-xs text-fg-dim font-mono truncate",children:[YL(q.path,s)," ",o.jsxs("span",{className:"text-fg-faint",children:["(",q.matches.length,")"]})]}),q.matches.map(z=>{F++;const Y=F,ee=Y===S;return o.jsxs("button",{"data-match":Y,role:"option","aria-selected":ee,onClick:()=>P(z),onMouseEnter:()=>y(Y),className:`w-full text-left px-3 py-1 text-xs font-mono flex gap-3 ${ee?"bg-bg-hi text-fg":"hover:bg-bg-hi/50 text-fg"}`,children:[o.jsx("span",{className:"text-fg-dim shrink-0 w-12 text-right",children:z.line}),o.jsx("span",{className:"truncate",children:The(z.text,a,l)})]},`${z.path}:${z.line}:${z.column}:${Y}`)})]},q.path))}):o.jsxs("div",{className:"px-4 py-6 text-sm text-fg-dim",children:["Type to search files in ",o.jsx("span",{className:"font-mono",children:s}),"."]}):o.jsx("div",{className:"px-4 py-6 text-sm text-fg-dim",children:"Open a terminal tab to enable project search."})}),o.jsxs("div",{className:"border-t border-line px-3 py-1.5 flex items-center justify-between text-[10px] text-fg-dim",children:[o.jsxs("span",{children:[o.jsx("kbd",{className:"px-1 py-0.5 rounded bg-bg-hi border border-line",children:"↑↓"})," navigate"," ",o.jsx("kbd",{className:"ml-2 px-1 py-0.5 rounded bg-bg-hi border border-line",children:"↵"})," insert path"," ",o.jsx("kbd",{className:"ml-2 px-1 py-0.5 rounded bg-bg-hi border border-line",children:"Esc"})," close"]}),o.jsxs("span",{children:[N.length," ",N.length===1?"match":"matches",x===!1&&" · fs walk (rg missing)"]})]})]})});return!W&&typeof document<"u"&&document.body?xf.createPortal(U,document.body):U}const $he=[{key:"files",label:"Files"},{key:"content",label:"Content"}];function Nhe({open:e,onClose:r,variant:n="page",initialMode:i="files"}){const[s,a]=D.useState(i);return D.useEffect(()=>{a(i)},[i]),e?o.jsxs("div",{className:"h-full w-full flex flex-col bg-bg",children:[o.jsxs("div",{className:"shrink-0 flex items-center gap-3 px-3 py-2 border-b border-line",children:[o.jsx(jf,{options:$he,active:s,onChange:a}),o.jsx("span",{className:"text-[11px] text-fg-faint",children:s==="files"?"⌘P · fuzzy-find a file in the active project":"⌘⇧F · ripgrep across the active project"})]}),o.jsx("div",{className:"flex-1 min-h-0",children:s==="files"?o.jsx(Ehe,{open:!0,onClose:r,variant:"page"}):o.jsx(Ahe,{open:!0,onClose:r,variant:"page"})})]}):null}class y8 extends D.Component{constructor(){super(...arguments);Xr(this,"state",{error:null});Xr(this,"reset",()=>this.setState({error:null}))}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,i){console.error("[ErrorBoundary]",n,i)}render(){return this.state.error?this.props.fallback?this.props.fallback(this.state.error,this.reset):o.jsxs("div",{className:"p-6 text-xs",children:[o.jsx("div",{className:"text-red-400 mb-2",children:"something broke in this panel"}),o.jsx("pre",{className:"text-fg-faint whitespace-pre-wrap mb-3",children:this.state.error.message}),o.jsx("button",{onClick:this.reset,className:"px-2 py-0.5 border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"retry"})]}):this.props.children}}function Ohe({open:e,onClose:r,title:n,children:i,variant:s="overlay"}){return o.jsxs(wf,{open:e,onClose:r,size:"xl",fillHeight:!0,noPadding:!0,title:void 0,variant:s,children:[s==="overlay"&&o.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-line shrink-0",children:[o.jsx("h2",{className:"text-xs uppercase tracking-wider text-fg-dim",children:n}),o.jsx("button",{type:"button",onClick:r,"aria-label":"Close",className:"px-2 py-0.5 text-fg-dim hover:text-fg hover:bg-bg-hi rounded text-base leading-none",children:"✕"})]}),o.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:o.jsx(y8,{children:i})})]})}function Phe(e){return/^monitor of /i.test(e.trim())}function JL(e){return e.replace(/\s*\([^)]*\)\s*$/,"").replace(/\s*#\d+\s*$/,"").replace(/\s+/g," ").trim().toLowerCase()}function ZL(e,r,n){if(e){const c=n.find(l=>l.deviceId===e);if(c)return c}if(!r)return null;const i=n.filter(c=>c.label===r);if(i.length===1)return i[0];if(i.length>1)return null;const s=JL(r),a=n.filter(c=>c.label&&JL(c.label)===s);return a.length===1?a[0]:null}async function QL(e){var n;return(n=navigator.mediaDevices)!=null&&n.enumerateDevices?(await navigator.mediaDevices.enumerateDevices()).filter(i=>!(i.kind!=="audioinput"||i.label&&Phe(i.label))):[]}const e5=!1;function b8(){const e=Dt(f=>f.isRecording);Dt(f=>f.startRecording),Dt(f=>f.stopRecording);const[r,n]=D.useState([]),[i,s]=D.useState(null),[a,c]=D.useState(null);D.useEffect(()=>{let f=!1;return(async()=>{try{const m=await window.api.voice.getDevicePref();if(f)return;const h=await QL(e5);if(f)return;n(h),c(m.selectedLabel);const b=ZL(m.selectedDeviceId,m.selectedLabel,h);b?(s(b.deviceId),m.selectedDeviceId&&b.deviceId!==m.selectedDeviceId&&(gt.info("voice","device-picker rebind-by-label",{fromIdPrefix:m.selectedDeviceId.slice(0,8),toIdPrefix:b.deviceId.slice(0,8)}),await window.api.voice.setDevicePref({selectedDeviceId:b.deviceId,selectedLabel:b.label||m.selectedLabel}).catch(()=>{}))):((m.selectedDeviceId||m.selectedLabel)&&(console.warn("[MicDevicePicker] previously-selected device unavailable; falling back to OS default",{savedLabel:m.selectedLabel,hadId:!!m.selectedDeviceId}),gt.warn("voice","device-picker selected-unavailable",{hadId:!!m.selectedDeviceId})),s(null))}catch(m){gt.warn("voice","device-picker init failed",{error:m instanceof Error?m.message:String(m)})}})(),()=>{f=!0}},[]);const l=D.useCallback(async()=>{try{const f=await QL(e5);if(n(f),i&&!f.some(m=>m.deviceId===i)){const m=ZL(null,a,f);m?(s(m.deviceId),await window.api.voice.setDevicePref({selectedDeviceId:m.deviceId,selectedLabel:m.label||a}).catch(()=>{})):s(null)}}catch(f){gt.warn("voice","device-picker refresh failed",{error:f instanceof Error?f.message:String(f)})}},[i,a]);D.useEffect(()=>{const f=()=>{l()};return window.addEventListener("mic-device-change",f),()=>window.removeEventListener("mic-device-change",f)},[l]);const u=async f=>{var w;const m=f.target.value,h=m===""?null:m,b=h?((w=r.find(k=>k.deviceId===h))==null?void 0:w.label)??null:null;s(h),c(b);try{await window.api.voice.setDevicePref({selectedDeviceId:h,selectedLabel:b}),gt.info("voice","device-picker selected",{deviceIdPrefix:h?h.slice(0,8):null})}catch(k){gt.warn("voice","setDevicePref failed",{error:k instanceof Error?k.message:String(k)})}if(e)try{await Dt.getState().restartWithDevice()}catch(k){gt.warn("voice","device-picker restart failed",{error:k instanceof Error?k.message:String(k)})}};return o.jsxs("select",{value:i??"",onChange:u,onFocus:()=>{l()},title:"Microphone input device","data-testid":"mic-device-picker",className:"text-[10px] bg-bg border border-line text-fg-dim hover:text-fg rounded px-1.5 py-1 max-w-[8rem] truncate",children:[o.jsx("option",{value:"",children:"Default"}),r.map(f=>o.jsx("option",{value:f.deviceId,children:f.label||`Mic ${f.deviceId.slice(0,6)}`},f.deviceId))]})}function Rhe(){const e=Dt(w=>w.isRecording),r=Dt(w=>w.levelMeterEnabled),[n,i]=D.useState(0),[s,a]=D.useState(0),c=D.useRef(0);c.current=s;const[l,u]=D.useState(0),[f,m]=D.useState(!1),h=D.useRef(null);if(D.useEffect(()=>{if(!e||!r){i(0),a(0);return}let w=0,k=!1,S=null,y=null;const x=()=>{if(k)return;const C=y??V4();if(!C){w=requestAnimationFrame(x);return}y!==C&&(y=C,S=new Uint8Array(new ArrayBuffer(C.fftSize)));const T=S;C.getByteTimeDomainData(T);let E=0;for(let I=0;I<T.length;I++){const W=T[I]-128;E+=W*W}const $=Math.sqrt(E/T.length)/128,N=$>0?20*Math.log10($):-60,P=Math.max(0,Math.min(1,(N+60)/60));a($),i(P),$>=.95&&(m(!0),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>m(!1),150)),w=requestAnimationFrame(x)};w=requestAnimationFrame(x);const _=setInterval(()=>{k||u(Math.round(c.current*100))},250);return()=>{k=!0,cancelAnimationFrame(w),clearInterval(_),h.current&&(clearTimeout(h.current),h.current=null)}},[e,r]),!e||!r)return null;const b=f?"bg-red-500":s>=.7?"bg-amber-400":"bg-green-500";return o.jsx("div",{role:"meter","aria-label":"Microphone input level","aria-valuenow":l,"aria-valuemin":0,"aria-valuemax":100,"data-testid":"mic-level-meter",className:`mx-3 mb-2 h-1 rounded bg-bg overflow-hidden ${f?"ring-1 ring-red-500":""}`,children:o.jsx("div",{className:`h-full ${b} transition-[width] duration-75 ease-out`,style:{width:`${n*100}%`}})})}function Mhe({open:e,onClose:r,variant:n="overlay"}){return o.jsx(Ohe,{open:e,onClose:r,title:"Voice / Microphone",variant:n,children:o.jsxs("div",{className:"p-4 space-y-4",children:[o.jsx(Bhe,{}),o.jsx(PB,{}),o.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[o.jsx(K4,{}),o.jsx(b8,{}),o.jsx(Wq,{})]}),o.jsx(Ihe,{}),o.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[o.jsx("button",{type:"button",onClick:()=>Dt.getState().openWizard(),className:"text-xs text-fg-faint hover:text-fg-dim underline","data-testid":"run-mic-check",children:"Run mic check"}),o.jsx(Lhe,{})]}),o.jsx(Rhe,{})]})})}function Ihe(){const e=Dt(a=>a.isRecording),[r,n]=D.useState(null);if(D.useEffect(()=>{let a=!1;window.api.voice.getHotkeyConfig().then(l=>{a||n(l)}).catch(()=>{});const c=window.api.voice.onHotkeyConfigChanged(l=>n(l));return()=>{a=!0,c()}},[]),e||!r)return null;const i=r.mode==="hold"?"Hold":"Press",s=Dhe(r.accelerator);return o.jsxs("div",{className:"text-[11px] text-fg-faint",children:[o.jsxs("span",{children:[i," "]}),o.jsx("kbd",{className:"px-1 py-0.5 rounded border border-line bg-bg font-mono text-fg-dim",children:s}),o.jsx("span",{children:" to record"})]})}function Dhe(e){const r=typeof navigator<"u"&&/Mac/.test(navigator.platform);return e.replace(/CommandOrControl/g,r?"⌘":"Ctrl").replace(/CmdOrCtrl/g,r?"⌘":"Ctrl").replace(/Command/g,"⌘").replace(/Control/g,"Ctrl").replace(/Option/g,r?"⌥":"Alt").replace(/Shift/g,r?"⇧":"Shift")}function Lhe(){const[e,r]=D.useState(null);if(D.useEffect(()=>{let i=!1;window.api.voice.getHotkeyConfig().then(a=>{i||r(a)}).catch(a=>gt.warn("voice-hotkey","getHotkeyConfig (toggle) failed",{error:String(a)}));const s=window.api.voice.onHotkeyConfigChanged(a=>{r(a)});return()=>{i=!0,s()}},[]),!e)return null;const n=async i=>{if(e.mode===i)return;const s={...e,mode:i};r(s);try{await window.api.voice.setHotkeyConfig(s)}catch(a){gt.warn("voice-hotkey","setHotkeyConfig (toggle) failed",{error:a instanceof Error?a.message:String(a)})}};return o.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-fg-faint select-none",title:"Mic hotkey behavior. Tap on/off: press once to start, again to stop. Hold to talk: record only while held (push-to-talk).",children:[o.jsxs("label",{className:"flex items-center gap-1 cursor-pointer hover:text-fg-dim",children:[o.jsx("input",{type:"radio",name:"hotkey-mode",checked:e.mode==="toggle",onChange:()=>n("toggle"),className:"cursor-pointer","data-testid":"hotkey-mode-toggle"}),o.jsx("span",{children:"Tap on/off"})]}),o.jsxs("label",{className:"flex items-center gap-1 cursor-pointer hover:text-fg-dim",children:[o.jsx("input",{type:"radio",name:"hotkey-mode",checked:e.mode==="hold",onChange:()=>n("hold"),className:"cursor-pointer","data-testid":"hotkey-mode-hold"}),o.jsx("span",{children:"Hold to talk"})]})]})}function Bhe(){const e=Dt(a=>a.isRecording),r=Dt(a=>a.lastTranscript),n=Dt(a=>a.error),i=Dt(a=>a.modelStatus),s=Dt(a=>a.loadingProgress);return n?o.jsxs("div",{className:"text-[11px] text-red-400",title:n,children:["⚠ ",n]}):e?o.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-fg-dim border border-line rounded px-2 py-1.5",children:[o.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-red-400 animate-pulse shrink-0"}),o.jsx("span",{className:"truncate",title:r,children:r||"Listening…"})]}):i==="loading"?o.jsxs("div",{className:"text-[11px] text-fg-faint",children:[o.jsxs("div",{className:"flex items-center justify-between mb-1",children:[o.jsx("span",{children:"Loading speech model"}),o.jsxs("span",{className:"font-mono",children:[s,"%"]})]}),o.jsx("div",{className:"h-1 rounded bg-bg overflow-hidden",children:o.jsx("div",{className:"h-full bg-accent transition-[width] duration-200",style:{width:`${s}%`}})})]}):null}let nj=null;function zhe(){return nj||(nj=ab(()=>import("./monaco-editor-BW5C4Iv1.js").then(e=>e.b),__vite__mapDeps([1,2]),import.meta.url).then(e=>(uA.config({monaco:e}),e))),nj}function x8({value:e,onChange:r,path:n,readOnly:i}){const s=D.useRef(null),a=c=>{s.current=c};return o.jsx(dA,{path:`file://${n}`,defaultLanguage:"json",value:e,onChange:c=>r(c??""),onMount:a,theme:"vs",options:{minimap:{enabled:!1},fontSize:12,fontFamily:'"IBM Plex Mono", JetBrains Mono, ui-monospace, Menlo, monospace',lineNumbers:"on",renderLineHighlight:"line",scrollBeyondLastLine:!1,tabSize:2,formatOnPaste:!0,readOnly:i,automaticLayout:!0,bracketPairColorization:{enabled:!0},wordWrap:"on"}})}let t5=!1;async function Fhe(e){if(t5)return;const r=await zhe(),n=await Promise.all(e.map(async s=>{let a=s.schema;if(!a){const c=["https://json.schemastore.org","https://www.schemastore.org","https://code.claude.com"];try{const l=new URL(s.uri).origin;if(!c.includes(l))throw new Error("untrusted origin");const u=await fetch(s.uri);u.ok&&(a=await u.json())}catch{}}return{uri:s.uri,fileMatch:s.fileMatch,schema:a}}));r.languages.json.jsonDefaults.setDiagnosticsOptions({validate:!0,allowComments:!1,schemas:n.filter(s=>s.schema),enableSchemaRequest:!0}),t5=!0}function m$({node:e,targetScope:r,onOverride:n,schema:i,rootLabel:s}){const[a,c]=D.useState(""),[l,u]=D.useState(!0),f=[],m=e.kind==="object"&&Object.keys(e.children).length===0,b=((i==null?void 0:i.rootKeys())??[]).length>0;return o.jsxs("div",{className:"h-full flex flex-col",children:[o.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:[o.jsxs("span",{className:"text-fg-faint",children:["merged · overrides → ",o.jsx("span",{className:"text-fg-dim",children:Oi[r].label})]}),b&&o.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:l,onChange:w=>u(w.target.checked),className:"accent-accent"}),"show unset keys"]}),o.jsx("div",{className:"flex-1"}),o.jsx("input",{value:a,onChange:w=>c(w.target.value),placeholder:"filter keys or descriptions…",className:"bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg w-56"})]}),o.jsx("div",{className:"flex-1 overflow-auto px-3 py-2 font-mono text-xs",children:m&&!l?o.jsx("div",{className:"text-fg-faint italic px-2 py-4",children:"no settings resolved — all scope files empty or missing"}):o.jsx(w8,{node:e,path:f,label:s??"(root)",targetScope:r,onOverride:n,filter:a,depth:0,schema:i,showGhosts:l,defaultOpen:!0})})]})}function w8(e){return e.node.kind==="object"?o.jsx(Uhe,{...e,node:e.node}):e.node.kind==="array"?o.jsx(Whe,{...e,node:e.node}):o.jsx(qhe,{...e,node:e.node})}function r5(e,r){return r.trim()?e.toLowerCase().includes(r.toLowerCase()):!0}function um(e,r,n){return!!(!n.trim()||e.some(i=>r5(i,n))||r!=null&&r.description&&r5(r.description,n))}function Uhe({node:e,path:r,label:n,targetScope:i,onOverride:s,filter:a,depth:c,schema:l,showGhosts:u,defaultOpen:f}){const[m,h]=D.useState(f??c<2),b=(l==null?void 0:l.at(r))??null,w=new Set(Object.keys(e.children)),k=u?(b==null?void 0:b.knownChildren)??[]:[],S=Array.from(new Set([...w,...k])).sort(),y=D.useMemo(()=>a.trim()?S.filter(_=>{const C=(l==null?void 0:l.at([...r,_]))??null;return um([...r,_],C,a)?!0:w.has(_)?_8(e.children[_],[...r,_],a,l):!1}):S,[S.join(","),a,e,r.join("."),l]);if(a.trim()&&y.length===0&&!um(r,b,a))return null;if(r.length===0)return o.jsx("div",{children:y.map(_=>x(_))});return o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-1 py-0.5 hover:bg-bg-elev/50 rounded cursor-pointer",style:{paddingLeft:c*14},onClick:()=>h(!m),children:[o.jsx("span",{className:"text-fg-faint w-3 shrink-0",children:m?"▾":"▸"}),o.jsx("span",{className:"text-fg",children:n}),o.jsxs("span",{className:"text-fg-faint",children:[" {",w.size,k.length>w.size?`/${new Set([...w,...k]).size}`:"","}"]}),(b==null?void 0:b.description)&&o.jsxs("span",{className:"text-fg-faint truncate max-w-md",title:b.description,children:["— ",b.description]})]}),m&&y.map(_=>x(_))]});function x(_){if(w.has(_))return o.jsx(w8,{node:e.children[_],path:[...r,_],label:_,targetScope:i,onOverride:s,filter:a,depth:c+1,schema:l,showGhosts:u},_);const C=(l==null?void 0:l.at([...r,_]))??null;return C?o.jsx(Hhe,{path:[...r,_],label:_,info:C,targetScope:i,onSet:s,depth:c+1,filter:a},_):null}}function _8(e,r,n,i){const s=(i==null?void 0:i.at(r))??null;if(um(r,s,n))return!0;if(e.kind!=="object")return!1;for(const a of Object.keys(e.children))if(_8(e.children[a],[...r,a],n,i))return!0;return!1}function Whe({node:e,path:r,label:n,filter:i,depth:s,schema:a}){const[c,l]=D.useState(!0),u=(a==null?void 0:a.at(r))??null;return um(r,u,i)?o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-1 py-0.5 hover:bg-bg-elev/50 rounded cursor-pointer",style:{paddingLeft:s*14},onClick:()=>l(!c),children:[o.jsx("span",{className:"text-fg-faint w-3 shrink-0",children:c?"▾":"▸"}),o.jsx("span",{className:"text-fg",children:n}),o.jsxs("span",{className:"text-fg-faint",children:[" [",e.items.length,"]"]}),o.jsx(eb,{tone:"warn",children:"accumulated"}),(u==null?void 0:u.description)&&o.jsxs("span",{className:"text-fg-faint truncate max-w-md",title:u.description,children:["— ",u.description]})]}),c&&e.items.map((f,m)=>o.jsxs("div",{className:"flex items-start gap-2 py-0.5",style:{paddingLeft:(s+1)*14},children:[o.jsx("span",{className:"text-fg-faint w-3 shrink-0"}),o.jsxs("span",{className:"text-fg-faint",children:[m,":"]}),o.jsx("span",{className:"text-fg-dim truncate max-w-xl",children:e_(f.value)}),o.jsx(xT,{scope:f.fromScope})]},m))]}):null}function qhe({node:e,path:r,label:n,targetScope:i,onOverride:s,filter:a,depth:c,schema:l}){const[u,f]=D.useState(!1),m=(l==null?void 0:l.at(r))??null;if(!um(r,m,a))return null;const h=e.winner!==i,b=e.shadowed.length>0;return o.jsxs("div",{children:[o.jsxs("div",{className:"group flex items-center gap-2 py-0.5 hover:bg-bg-elev/50 rounded",style:{paddingLeft:c*14},children:[o.jsx("span",{className:`w-3 shrink-0 ${b?"text-fg-faint cursor-pointer":""}`,onClick:()=>b&&f(!u),children:b?u?"▾":"▸":""}),o.jsxs("span",{className:"text-fg",children:[n,":"]}),o.jsx("span",{className:"text-fg-dim truncate max-w-md",children:e_(e.value)}),o.jsx(xT,{scope:e.winner}),(m==null?void 0:m.deprecated)&&o.jsx(eb,{tone:"warn",children:"deprecated"}),(m==null?void 0:m.default)!==void 0&&Vhe(e.value,m.default)&&o.jsx(eb,{tone:"dim",children:"= default"}),e.typeMismatch&&o.jsx("span",{className:"text-yellow-500/80",title:"shadowed scopes have a different value type",children:"⚠"}),(m==null?void 0:m.description)&&o.jsxs("span",{className:"text-fg-faint truncate max-w-md",title:m.description,children:["— ",m.description]}),o.jsx("div",{className:"flex-1"}),(m==null?void 0:m.enum)&&o.jsx(S8,{values:m.enum}),o.jsx("button",{disabled:!h,onClick:()=>s(r,e.value),className:`opacity-0 group-hover:opacity-100 px-1.5 py-0 text-[10px] border rounded transition-opacity ${h?"border-accent/50 text-accent hover:bg-accent hover:text-bg":"border-line text-fg-faint cursor-not-allowed"}`,title:h?`copy into ${Oi[i].label} draft`:`already winning in ${Oi[i].label}`,children:"override"})]}),u&&e.shadowed.map((w,k)=>o.jsxs("div",{className:"flex items-center gap-2 py-0.5 text-fg-faint line-through",style:{paddingLeft:(c+1)*14+12},children:[o.jsx("span",{children:"shadowed:"}),o.jsx("span",{className:"truncate max-w-xl",children:e_(w.value)}),o.jsx(xT,{scope:w.scope,dim:!0})]},k))]})}function Hhe({path:e,label:r,info:n,targetScope:i,onSet:s,depth:a,filter:c}){if(!um(e,n,c))return null;const l=n.default!==void 0?n.default:Ghe(n.type),u=Array.isArray(n.type)?n.type.join("|"):n.type??"?";return o.jsxs("div",{className:"group flex items-center gap-2 py-0.5 hover:bg-bg-elev/50 rounded opacity-60",style:{paddingLeft:a*14},children:[o.jsx("span",{className:"w-3 shrink-0"}),o.jsx("span",{className:"text-fg-dim",children:r}),o.jsx(eb,{tone:"dim",children:u}),n.required&&o.jsx(eb,{tone:"warn",children:"required"}),n.default!==void 0&&o.jsxs("span",{className:"text-fg-faint",children:["default: ",e_(n.default)]}),n.description&&o.jsxs("span",{className:"text-fg-faint truncate max-w-md",title:n.description,children:["— ",n.description]}),o.jsx("div",{className:"flex-1"}),n.enum&&o.jsx(S8,{values:n.enum}),o.jsx("button",{onClick:()=>s(e,l),className:"opacity-0 group-hover:opacity-100 px-1.5 py-0 text-[10px] border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg transition-opacity",title:`write to ${Oi[i].label} draft`,children:"set"})]})}function Vhe(e,r){return e===r?!0:typeof e!=typeof r?!1:e&&r&&typeof e=="object"?JSON.stringify(e)===JSON.stringify(r):!1}function Ghe(e){switch(Array.isArray(e)?e[0]:e){case"boolean":return!1;case"integer":case"number":return 0;case"string":return"";case"array":return[];case"object":return{};case"null":return null;default:return null}}function e_(e){if(typeof e=="string")return JSON.stringify(e);if(e===null)return"null";if(typeof e=="object"){const r=JSON.stringify(e);return r.length>100?r.slice(0,100)+"…":r}return String(e)}function xT({scope:e,dim:r}){const n=e==="user"?"bg-bg-hi text-fg-dim border-line":e==="project"?"bg-blue-950/30 text-blue-400/80 border-blue-900/40":"bg-purple-950/30 text-purple-400/80 border-purple-900/40";return o.jsx("span",{className:`text-[10px] px-1 py-0 rounded border uppercase tracking-wide shrink-0 ${n} ${r?"opacity-60":""}`,children:Oi[e].label})}function eb({children:e,tone:r="default"}){const n={default:"bg-bg-hi text-fg-dim border-line",warn:"bg-yellow-950/30 text-yellow-500/80 border-yellow-900/40",dim:"bg-bg-elev text-fg-faint border-line"}[r];return o.jsx("span",{className:`text-[10px] px-1 py-0 rounded border uppercase tracking-wide shrink-0 ${n}`,children:e})}function S8({values:e}){const r=e.map(n=>String(n)).join(" | ");return o.jsxs("span",{className:"text-[10px] text-fg-faint truncate max-w-xs",title:`allowed: ${r}`,children:["∈ ",r.length>30?r.slice(0,30)+"…":r]})}const Khe=[{id:"essentials",title:"Essentials",summary:"The knobs you reach for first.",keys:["model","language","outputStyle","permissions"]},{id:"git",title:"Git & Commits",summary:"How Claude writes commits and pull requests on your behalf.",keys:["attribution","includeGitInstructions","includeCoAuthoredBy"]},{id:"memory",title:"Memory & Plans",summary:"Context Claude keeps between sessions and where it files plans.",keys:["autoMemoryEnabled","plansDirectory","claudeMdExcludes","respectGitignore"]},{id:"model",title:"Model & Reasoning",summary:"Which model runs, how hard it thinks, and fast-mode toggles.",keys:["availableModels","modelOverrides","effortLevel","fastMode","fastModePerSessionOptIn","alwaysThinkingEnabled"]},{id:"interface",title:"Interface",summary:"Visual polish — spinners, progress bars, motion.",keys:["spinnerTipsEnabled","spinnerTipsOverride","spinnerVerbs","terminalProgressBarEnabled","showTurnDuration","prefersReducedMotion","companyAnnouncements","statusLine","teammateMode"]},{id:"updates",title:"Updates & Cleanup",summary:"Release channel and how long transcripts stick around.",keys:["autoUpdatesChannel","cleanupPeriodDays"]},{id:"env",title:"Environment & Auth",summary:"Environment variables and auth-helper scripts.",keys:["env","apiKeyHelper","awsCredentialExport","awsAuthRefresh"]},{id:"hooks",title:"Hooks",summary:"Scripts Claude runs before/after tool use.",keys:["hooks","disableAllHooks","allowedHttpHookUrls","httpHookAllowedEnvVars"]},{id:"mcp",title:"MCP Servers",summary:"External tool providers Claude can talk to.",keys:["enableAllProjectMcpServers","enabledMcpjsonServers","disabledMcpjsonServers"]},{id:"plugins",title:"Plugins",summary:"Installed plugins, marketplaces, and per-plugin configuration.",keys:["enabledPlugins","extraKnownMarketplaces","skippedPlugins","skippedMarketplaces","pluginConfigs"]},{id:"filesystem",title:"File Picker & Sandbox",summary:"How Claude browses files and the sandbox it runs in.",keys:["fileSuggestion","sandbox","worktree"]},{id:"login",title:"Login",summary:"Which login method to force on startup.",keys:["forceLoginMethod","forceLoginOrgUUID"]},{id:"feedback",title:"Feedback",summary:"Session-quality surveys.",keys:["feedbackSurveyRate"]},{id:"advanced",title:"Advanced / Enterprise",summary:"Managed-settings-only keys and enterprise allow/denylists.",advanced:!0,keys:["allowedMcpServers","deniedMcpServers","allowManagedHooksOnly","allowManagedPermissionRulesOnly","allowManagedMcpServersOnly","strictKnownMarketplaces","blockedMarketplaces","pluginTrustMessage","otelHeadersHelper","skipWebFetchPreflight"]}],Xhe={mcp:"MCP",url:"URL",urls:"URLs",http:"HTTP",ui:"UI",id:"ID",uuid:"UUID",api:"API",aws:"AWS",otel:"OTel",json:"JSON"};function k8(e){return e.replace(/^\$/,"").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").toLowerCase().split(/\s+/).filter(Boolean).map((i,s)=>{const a=Xhe[i];return a||(s===0?i.charAt(0).toUpperCase()+i.slice(1):i)}).join(" ")}function Yhe(e){const r=new Set,n=[];for(const s of Khe){const a=s.keys.filter(c=>e.has(c));a.forEach(c=>r.add(c)),a.length!==0&&n.push({id:s.id,title:s.title,summary:s.summary,advanced:!!s.advanced,keys:a})}const i=Array.from(e).filter(s=>!r.has(s)&&s!=="$schema").sort();return i.length>0&&n.push({id:"other",title:"Other",summary:"Keys not yet grouped.",advanced:!1,keys:i}),n}const Jhe=["user","project","local","default"],Zhe={user:"user",project:"project",local:"local",default:"default"};function Qhe({node:e,targetScope:r,onOverride:n,schema:i}){const[s,a]=D.useState(""),[c,l]=D.useState(!1),[u,f]=D.useState(!0),m=e.kind==="object"?e:null,h=m?Object.keys(m.children):[],b=i.rootKeys(),w=new Set([...h,...b]),k=D.useMemo(()=>Yhe(w),[Array.from(w).sort().join(",")]),S=D.useMemo(()=>k.filter(y=>c||!y.advanced).map(y=>({...y,keys:y.keys.filter(x=>{const _=(m==null?void 0:m.children[x])!==void 0;if(!u&&!_)return!1;if(!s.trim())return!0;const C=i.at([x]);return[x,k8(x),(C==null?void 0:C.description)??""].join(" ").toLowerCase().includes(s.toLowerCase())})})).filter(y=>y.keys.length>0),[k,s,c,u,m,i]);return o.jsxs("div",{className:"h-full flex flex-col",children:[o.jsxs("div",{className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 flex items-center gap-3 text-xs",children:[o.jsxs("span",{className:"text-fg-faint",children:["writing overrides to"," ",o.jsx("span",{className:"text-fg-dim font-medium",children:Oi[r].label})]}),o.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:u,onChange:y=>f(y.target.checked),className:"accent-accent"}),"show not-yet-configured"]}),o.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:c,onChange:y=>l(y.target.checked),className:"accent-accent"}),"show advanced"]}),o.jsx("div",{className:"flex-1"}),o.jsx("input",{value:s,onChange:y=>a(y.target.value),placeholder:"search settings…",className:"bg-bg border border-line rounded px-2 py-1 text-xs text-fg w-64"})]}),o.jsxs("div",{className:"flex-1 overflow-auto",children:[S.map(y=>o.jsx(epe,{title:y.title,summary:y.summary,advanced:y.advanced,children:y.keys.map(x=>{const _=m==null?void 0:m.children[x],C=i.at([x]);return o.jsx(tpe,{keyName:x,node:_,info:C,targetScope:r,onOverride:(T,E)=>n([x],T,E)},x)})},y.id)),S.length===0&&o.jsxs("div",{className:"px-6 py-12 text-center text-fg-faint text-sm",children:['no settings match "',s,'"']})]})]})}function epe({title:e,summary:r,advanced:n,children:i}){const[s,a]=D.useState(!0);return o.jsxs("section",{className:"border-b border-line",children:[o.jsxs("header",{className:"px-4 py-2.5 bg-bg-elev/40 cursor-pointer hover:bg-bg-elev flex items-center gap-3",onClick:()=>a(!s),children:[o.jsx("span",{className:"text-fg-faint w-3",children:s?"▾":"▸"}),o.jsxs("div",{className:"flex-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("h2",{className:"text-fg text-sm font-medium",children:e}),n&&o.jsx("span",{className:"text-[9px] px-1.5 py-0 rounded border border-yellow-900/40 bg-yellow-950/30 text-yellow-500/80 uppercase tracking-wide",children:"advanced"})]}),o.jsx("p",{className:"text-fg-faint text-xs",children:r})]})]}),s&&o.jsx("div",{className:"divide-y divide-line/60",children:i})]})}function tpe({keyName:e,node:r,info:n,targetScope:i,onOverride:s}){const[a,c]=D.useState(!1),[l,u]=D.useState(!1),f=k8(e),m=r!==void 0,b=(r==null?void 0:r.kind)==="leaf"?r:null,w=(r==null?void 0:r.kind)==="object"||(r==null?void 0:r.kind)==="array",k=n==null?void 0:n.default,S=b&&k!==void 0&&j8(b.value,k),y=cpe({isSet:m,leafNode:b,defaultVal:k,isDefault:!!S,node:r}),x=rpe(b,k),_=x.length>=2,C=!!b&&!S;return o.jsx("div",{className:"px-4 py-3 hover:bg-bg-elev/20",children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("button",{onClick:()=>c(!a),className:"text-fg-faint hover:text-fg w-3 mt-0.5",title:a?"collapse":"expand",children:a?"▾":"▸"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-baseline gap-2 flex-wrap",children:[o.jsx("h3",{className:"text-fg text-sm",children:f}),o.jsx(upe,{kind:y.kind,label:y.label}),_&&o.jsxs("button",{onClick:T=>{T.stopPropagation(),a||c(!0),u(E=>!E)},className:"text-[9px] px-1.5 py-0 rounded border border-blue-900/40 bg-blue-950/30 text-blue-300/90 uppercase tracking-wide hover:bg-blue-900/40",title:"this key is defined in multiple scopes — click to expand",children:["drift · ",x.map(T=>Zhe[T]).join(" · ")]}),C&&b&&o.jsx("button",{onClick:T=>{T.stopPropagation(),s(void 0,b.winner)},className:"text-[9px] px-1.5 py-0 rounded border border-line bg-bg-elev text-fg-faint uppercase tracking-wide hover:text-fg hover:bg-bg-hi",title:`reset · delete from ${Oi[b.winner].label}`,children:"↺ reset"}),(n==null?void 0:n.deprecated)&&o.jsx("span",{className:"text-[9px] px-1 py-0 rounded border border-yellow-900/40 bg-yellow-950/30 text-yellow-500/80 uppercase tracking-wide",children:"deprecated"}),(n==null?void 0:n.required)&&!m&&o.jsx("span",{className:"text-[9px] px-1 py-0 rounded border border-red-900/40 bg-red-950/30 text-red-400/80 uppercase tracking-wide",children:"required"})]}),(n==null?void 0:n.description)&&o.jsx("p",{className:"text-fg-dim text-xs mt-0.5 leading-relaxed",children:dpe(n.description)}),a&&l&&b&&o.jsx(npe,{leaf:b,defaultVal:k,onReset:T=>s(void 0,T)}),a&&o.jsx(ipe,{keyName:e,node:r,info:n,targetScope:i,onOverride:T=>s(T)})]}),o.jsx("div",{className:"shrink-0",children:!a&&o.jsx(lpe,{node:r,info:n,onSet:T=>{s(T)},disabled:w&&m})})]})})}function rpe(e,r){if(!e)return[];const n=new Set;n.add(e.winner);for(const i of e.shadowed)n.add(i.scope);return r!==void 0&&n.add("default"),Jhe.filter(i=>n.has(i))}function npe({leaf:e,defaultVal:r,onReset:n}){const i={};i[e.winner]={value:e.value,winner:!0};for(const s of e.shadowed)i[s.scope]={value:s.value,winner:!1};return o.jsxs("div",{className:"mt-2 border border-line rounded bg-bg-elev/40 text-xs",children:[o.jsx("div",{className:"px-2 py-1 text-fg-faint border-b border-line/60",children:"Values across all scopes (winner highlighted · reset removes that scope's value):"}),o.jsxs("div",{className:"divide-y divide-line/60",children:[["user","project","local"].map(s=>{const a=i[s],c=a!==void 0;return o.jsxs("div",{className:"grid grid-cols-[5rem_1fr_auto] gap-2 px-2 py-1 items-center",children:[o.jsx("span",{className:"text-fg-faint",children:Oi[s].label}),o.jsx("span",{className:`font-mono truncate ${a!=null&&a.winner?"text-accent":"text-fg-dim"}`,children:c?Ip(a.value):o.jsx("span",{className:"text-fg-faint",children:"—"})}),c?o.jsx("button",{onClick:()=>n(s),className:"text-[9px] px-1.5 py-0 rounded border border-line text-fg-faint uppercase tracking-wide hover:text-fg hover:bg-bg-hi",title:`delete this key from ${Oi[s].label}`,children:"↺"}):o.jsx("span",{})]},s)}),o.jsxs("div",{className:"grid grid-cols-[5rem_1fr_auto] gap-2 px-2 py-1 items-center",children:[o.jsx("span",{className:"text-fg-faint",children:"Default"}),o.jsx("span",{className:"font-mono text-fg-dim truncate",children:r!==void 0?Ip(r):o.jsx("span",{className:"text-fg-faint",children:"—"})}),o.jsx("span",{})]})]})]})}function ipe({keyName:e,node:r,info:n,targetScope:i,onOverride:s}){const c=(r==null?void 0:r.kind)==="leaf"?r:null;return o.jsxs("div",{className:"mt-3 space-y-2 text-xs",children:[(n==null?void 0:n.description)&&o.jsx("p",{className:"text-fg-dim leading-relaxed whitespace-pre-wrap",children:n.description}),o.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-fg-faint",children:[(n==null?void 0:n.type)&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"Type"}),o.jsx("dd",{className:"text-fg-dim font-mono",children:Array.isArray(n.type)?n.type.join(" | "):n.type})]}),(n==null?void 0:n.default)!==void 0&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"Default"}),o.jsx("dd",{className:"text-fg-dim font-mono",children:Ip(n.default)})]}),(n==null?void 0:n.enum)&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"Options"}),o.jsx("dd",{className:"text-fg-dim font-mono",children:n.enum.map(l=>String(l)).join(" | ")})]}),c&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"Current"}),o.jsxs("dd",{className:"font-mono",children:[o.jsx("span",{className:"text-fg-dim",children:Ip(c.value)}),o.jsxs("span",{className:"ml-2 text-fg-faint",children:["from ",Oi[c.winner].label]})]})]}),c&&c.shadowed.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"Shadowed"}),o.jsx("dd",{className:"space-y-0.5",children:c.shadowed.map((l,u)=>o.jsxs("div",{className:"font-mono text-fg-faint line-through",children:[Ip(l.value)," —"," ",o.jsx("span",{className:"no-underline",children:Oi[l.scope].label})]},u))})]}),(r==null?void 0:r.kind)==="array"&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"Accumulated"}),o.jsxs("dd",{className:"text-fg-dim",children:[r.items.length," items across all scopes"]})]})]}),o.jsx("div",{className:"pt-2 flex items-center gap-2 flex-wrap border-t border-line/60",children:o.jsx(spe,{keyName:e,node:r,info:n,onChange:s,targetScope:i})})]})}function spe({node:e,info:r,onChange:n,targetScope:i}){const a=(e==null?void 0:e.kind)==="leaf"?e.value:r==null?void 0:r.default,c=C8(r==null?void 0:r.type);if(c==="boolean"){const l=a===!0;return o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-fg-faint",children:"Set to:"}),o.jsx("div",{className:"inline-flex rounded border border-line overflow-hidden",children:[{v:!0,label:"on"},{v:!1,label:"off"}].map(({v:u,label:f})=>o.jsx("button",{onClick:()=>n(u),className:`px-3 py-0.5 text-xs transition-colors ${l===u?"bg-accent text-bg":"bg-bg-elev text-fg-dim hover:bg-bg-hi hover:text-fg"}`,children:f},f))}),o.jsxs("span",{className:"text-fg-faint",children:["→ ",Oi[i].label]})]})}return r!=null&&r.enum?o.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[o.jsx("span",{className:"text-fg-faint",children:"Choose:"}),r.enum.map(l=>{const u=j8(a,l);return o.jsx("button",{onClick:()=>n(l),className:`px-2 py-0.5 text-xs rounded border ${u?"bg-accent text-bg border-accent":"bg-bg-elev text-fg-dim border-line hover:text-fg hover:bg-bg-hi"}`,children:String(l)},String(l))}),o.jsxs("span",{className:"text-fg-faint",children:["→ ",Oi[i].label]})]}):c==="integer"||c==="number"?o.jsx(ape,{value:typeof a=="number"?a:void 0,integer:c==="integer",onCommit:n,target:Oi[i].label}):c==="string"?o.jsx(ope,{value:typeof a=="string"?a:"",onCommit:n,target:Oi[i].label}):o.jsxs("div",{className:"text-fg-faint",children:["Complex value (",c??"object/array",") — use the"," ",o.jsx("span",{className:"text-fg-dim",children:"Raw"})," tab to edit."]})}function ape({value:e,integer:r,onCommit:n,target:i}){const[s,a]=D.useState(e!==void 0?String(e):""),c=()=>{const l=r?parseInt(s,10):parseFloat(s);Number.isNaN(l)||n(l)};return o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-fg-faint",children:"Set to:"}),o.jsx("input",{type:"number",value:s,onChange:l=>a(l.target.value),onBlur:c,onKeyDown:l=>{l.key==="Enter"&&l.target.blur()},className:"w-24 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"}),o.jsxs("button",{onClick:c,className:"px-2 py-0.5 text-xs border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg",children:["save → ",i]})]})}function ope({value:e,onCommit:r,target:n}){const[i,s]=D.useState(e);return o.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[o.jsx("span",{className:"text-fg-faint shrink-0",children:"Set to:"}),o.jsx("input",{type:"text",value:i,onChange:a=>s(a.target.value),onKeyDown:a=>{a.key==="Enter"&&r(i)},className:"flex-1 min-w-0 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"}),o.jsxs("button",{onClick:()=>r(i),className:"shrink-0 px-2 py-0.5 text-xs border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg",children:["save → ",n]})]})}function lpe({node:e,info:r,onSet:n,disabled:i}){const s=(e==null?void 0:e.kind)==="leaf",a=C8(r==null?void 0:r.type);if(i)return null;if(a==="boolean"){const c=s&&e.value===!0;return o.jsx("button",{onClick:()=>n(!c),className:`px-2.5 py-0.5 text-xs rounded border transition-colors ${c?"bg-accent/15 text-accent border-accent/40 hover:bg-accent hover:text-bg":"bg-bg-elev text-fg-dim border-line hover:text-fg hover:bg-bg-hi"}`,title:"toggle",children:c?"on":"off"})}return null}function cpe({isSet:e,leafNode:r,defaultVal:n,isDefault:i,node:s}){return e?(s==null?void 0:s.kind)==="array"?{kind:"accumulated",label:`${s.items.length} items`}:(s==null?void 0:s.kind)==="object"?{kind:"set",label:"configured"}:r?i?{kind:"default",label:`= default · ${Oi[r.winner].label}`}:r.shadowed.length>0?{kind:"override",label:`overriding ${r.shadowed.length} scope(s)`}:{kind:"set",label:`set in ${Oi[r.winner].label}`}:{kind:"set",label:"configured"}:n!==void 0?{kind:"default",label:`using default: ${Ip(n)}`}:{kind:"unset",label:"not configured"}}function upe({kind:e,label:r}){const n={set:"bg-accent/15 text-accent border-accent/30",default:"bg-bg-hi text-fg-dim border-line",unset:"bg-bg-elev text-fg-faint border-line",override:"bg-purple-950/30 text-purple-400/80 border-purple-900/40",accumulated:"bg-blue-950/30 text-blue-400/80 border-blue-900/40"}[e];return o.jsx("span",{className:`text-[9px] px-1.5 py-0 rounded border uppercase tracking-wide ${n}`,children:r})}function C8(e){if(e)return Array.isArray(e)?e.find(n=>n!=="null")??e[0]:e}function j8(e,r){return e===r?!0:typeof e!=typeof r?!1:e&&r&&typeof e=="object"?JSON.stringify(e)===JSON.stringify(r):!1}function dpe(e){const r=e.trim().split(`
3450
3450
  `)[0],n=r.match(/^([^.!?]+[.!?])/);return n?n[1]:r.length>120?r.slice(0,120)+"…":r}function Ip(e){if(typeof e=="string")return e===""?'""':JSON.stringify(e);if(e===null)return"null";if(e===void 0)return"—";if(typeof e=="object"){const r=JSON.stringify(e);return r.length>60?r.slice(0,60)+"…":r}return String(e)}function g$(e,r,n){const i=sr(u=>u.files),s=sr(u=>u.loadJson),a=sr(u=>u.watchFile),c=sr(u=>u.unwatchFile),l=D.useMemo(()=>{const u={};for(const f of e.scopes){const m=e.resolve(f,r??"",n);m&&(u[f]=m)}return u},[e,r,n]);return D.useEffect(()=>{const u=Object.values(l).filter(Boolean);return u.forEach(f=>{i[f]||s(f),a(f)}),()=>{u.forEach(f=>c(f))}},[JSON.stringify(l)]),l}const fpe=[];function cw(e){return Array.isArray(e)?"array":e!==null&&typeof e=="object"?"object":"scalar"}function v$(e){const r=e.filter(n=>n.data!==void 0);return r.length===0?{kind:"object",children:{}}:E8(r,[])}function E8(e,r){const n=fpe.includes(r.join(".")),i=e.every(m=>cw(m.data)==="object"),s=e.every(m=>cw(m.data)==="array");if(i){const m=new Set;for(const b of e)for(const w of Object.keys(b.data))m.add(w);const h={};for(const b of m){const w=e.filter(k=>b in k.data).map(k=>({scope:k.scope,data:k.data[b]}));h[b]=E8(w,[...r,b])}return{kind:"object",children:h}}if(s&&!n){const m=[];for(const h of[...e].reverse())for(const b of h.data)m.push({value:b,fromScope:h.scope,index:m.length});return{kind:"array",items:m}}const a=[...e].reverse(),c=a[0],l=a.slice(1).map(m=>({scope:m.scope,value:m.data})),u=cw(c.data),f=l.some(m=>cw(m.value)!==u);return{kind:"leaf",value:c.data,winner:c.scope,shadowed:l,...f?{typeMismatch:!0}:{}}}function y$(e,r){if(r.length===0)return e;if(e.kind!=="object")return null;const[n,...i]=r,s=e.children[n];return s?y$(s,i):null}function i1(e,r,n){if(r.length===0)return n;const[i,...s]=r,a=e&&typeof e=="object"&&!Array.isArray(e)?{...e}:{};return a[i]=i1(a[i],s,n),a}const hpe=["user","project","local"];function b$(e,r){const n=[];for(const i of hpe){const s=r[i];if(!s)continue;const a=e[s];if(!a||!a.exists)continue;const c=a.draftRaw??"";if(c.trim())try{n.push({scope:i,data:JSON.parse(c)})}catch{}}return n}const ppe="http://json-schema.org/draft-07/schema#",mpe="https://json.schemastore.org/claude-code-settings.json",gpe={permissionRule:{type:"string",description:`Tool permission rule.
3451
3451
  See https://code.claude.com/docs/en/settings#permission-rule-syntax
3452
3452
  See https://code.claude.com/docs/en/settings#tools-available-to-claude for full list of tools available to Claude.`,pattern:"^((Agent|Bash|Edit|ExitPlanMode|Glob|Grep|KillShell|LSP|NotebookEdit|Read|Skill|TaskCreate|TaskGet|TaskList|TaskOutput|TaskStop|TaskUpdate|TodoWrite|ToolSearch|WebFetch|WebSearch|Write)(\\((?=.*[^)*?])[^)]+\\))?|mcp__.*)$",examples:["Bash","Bash(npm run build)","Bash(git commit *)","Bash(npm run *)","Bash(ls*)","Bash(git * main)","Edit","Edit(/src/**/*.ts)","Read(./.env)","Read(./secrets/**)","Read(//Users/alice/secrets/**)","Read(~/Documents/*.pdf)","Agent(Explore)","WebFetch","WebFetch(domain:example.com)","mcp__puppeteer","mcp__github__search_repositories"]},hookCommand:{anyOf:[{type:"object",description:"Bash command hook",additionalProperties:!1,required:["type","command"],properties:{type:{type:"string",description:"Hook type",const:"command"},command:{type:"string",description:"Shell command to execute",minLength:1},timeout:{type:"number",description:"Optional timeout in seconds",exclusiveMinimum:0},async:{type:"boolean",description:"Run this hook asynchronously without blocking Claude Code"},statusMessage:{type:"string",description:"Custom spinner message displayed while the hook runs"}}},{type:"object",description:"LLM prompt hook. See https://code.claude.com/docs/en/hooks#prompt-based-hooks",additionalProperties:!1,required:["type","prompt"],properties:{type:{type:"string",description:"Hook type",const:"prompt"},prompt:{type:"string",description:"Prompt to evaluate with LLM. Use $ARGUMENTS placeholder for hook input JSON.",minLength:1},model:{type:"string",description:"Model to use for evaluation. Defaults to a fast model"},timeout:{type:"number",description:"Optional timeout in seconds (default: 30)",exclusiveMinimum:0},statusMessage:{type:"string",description:"Custom spinner message displayed while the hook runs"}}},{type:"object",description:"Agent hook with multi-turn tool access for verification. See https://code.claude.com/docs/en/hooks#agent-based-hooks",additionalProperties:!1,required:["type","prompt"],properties:{type:{type:"string",description:"Hook type",const:"agent"},prompt:{type:"string",description:"Prompt describing what to verify. Use $ARGUMENTS placeholder for hook input JSON.",minLength:1},model:{type:"string",description:"Model to use for evaluation. Defaults to a fast model"},timeout:{type:"number",description:"Optional timeout in seconds (default: 60)",exclusiveMinimum:0},statusMessage:{type:"string",description:"Custom spinner message displayed while the hook runs"}}},{type:"object",description:"HTTP webhook hook. POST JSON to a URL and receive JSON response. See https://code.claude.com/docs/en/hooks#http-hooks",additionalProperties:!1,required:["type","url"],properties:{type:{type:"string",description:"Hook type",const:"http"},url:{type:"string",description:"URL to POST hook input JSON to. Endpoint must accept POST requests and return JSON.",minLength:1},headers:{type:"object",additionalProperties:{type:"string"},description:"Custom HTTP headers (e.g., Authorization: Bearer token). Values support $VAR_NAME or ${VAR_NAME} interpolation."},allowedEnvVars:{type:"array",items:{type:"string",minLength:1},description:"List of environment variable names permitted for interpolation in headers. If not set, no env var interpolation is allowed."},timeout:{type:"number",description:"Optional timeout in seconds (default: 30)",exclusiveMinimum:0},statusMessage:{type:"string",description:"Custom spinner message displayed while the hook runs"}}}]},hookMatcher:{type:"object",description:"Hook matcher configuration with multiple hooks",additionalProperties:!1,required:["hooks"],properties:{matcher:{type:"string",description:"Optional pattern to match event contexts, case-sensitive. Behavior depends on event type. See https://code.claude.com/docs/en/hooks#matcher-patterns for event-specific details and examples"},hooks:{type:"array",description:"Array of hooks to execute",items:{$ref:"#/$defs/hookCommand"}}}}},vpe="Configuration settings for Claude Code. Learn more: https://code.claude.com/docs/en/settings",ype=!0,bpe=!0,xpe="object",wpe=JSON.parse(`{"$schema":{"type":"string","description":"JSON Schema reference for Claude Code settings"},"apiKeyHelper":{"type":"string","description":"Path to a script that outputs authentication values","examples":["/bin/generate_temp_api_key.sh"],"minLength":1},"autoMemoryEnabled":{"type":"boolean","description":"Enable automatic memory saves that capture useful context to .claude/memory/. Also configurable via CLAUDE_CODE_DISABLE_AUTO_MEMORY environment variable (set to 1 to disable, 0 to enable). See https://code.claude.com/docs/en/memory#auto-memory","default":true},"autoUpdatesChannel":{"type":"string","enum":["stable","latest"],"description":"Release channel to follow for updates. Use \\"stable\\" for a version that is typically about one week old and skips versions with major regressions, or \\"latest\\" (default) for the most recent release. Set DISABLE_AUTOUPDATER=1 to disable updates entirely.","default":"latest"},"awsCredentialExport":{"type":"string","description":"Path to a script that exports AWS credentials","examples":["/bin/generate_aws_grant.sh"],"minLength":1},"awsAuthRefresh":{"type":"string","description":"Path to a script that refreshes AWS authentication","examples":["aws sso login --profile myprofile"],"minLength":1},"claudeMdExcludes":{"type":"array","items":{"type":"string","minLength":1},"description":"Glob patterns for CLAUDE.md files to exclude from loading. Useful in monorepos to skip irrelevant instructions from other teams. Patterns match against absolute file paths. Arrays merge across settings layers. Managed policy CLAUDE.md files cannot be excluded. See https://code.claude.com/docs/en/memory#exclude-specific-claudemd-files","examples":[["**/monorepo/CLAUDE.md","/home/user/monorepo/other-team/.claude/rules/**"]]},"cleanupPeriodDays":{"type":"integer","minimum":0,"description":"Number of days to retain chat transcripts (0 to disable cleanup)","examples":[20,30,60],"default":30},"env":{"type":"object","additionalProperties":false,"description":"Environment variables to set for Claude Code sessions. Many environment variables provide settings dimensions not available as dedicated settings.json properties (e.g., thinking tokens, prompt caching, bash timeouts, shell configuration). See https://code.claude.com/docs/en/settings#environment-variables for the full list.\\nUNDOCUMENTED: CLAUDE_CODE_PLUGIN_GIT_TIMEOUT_MS (plugin marketplace git timeout in ms, default 120000, see https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md#2151).\\nUNDOCUMENTED: ENABLE_CLAUDEAI_MCP_SERVERS (set to false to opt out of claude.ai MCP servers, see https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md#2163).","examples":[{"ANTHROPIC_MODEL":"claude-opus-4-1","ANTHROPIC_SMALL_FAST_MODEL":"claude-3-5-haiku-latest"}],"default":{},"patternProperties":{"^[A-Z_][A-Z0-9_]*$":{"type":"string","description":"Environment variable value"}}},"attribution":{"type":"object","description":"Customize attribution for git commits and pull requests. See https://code.claude.com/docs/en/settings#attribution-settings","additionalProperties":false,"properties":{"commit":{"type":"string","description":"Attribution for git commits, including any trailers. Empty string hides commit attribution"},"pr":{"type":"string","description":"Attribution for pull request descriptions. Empty string hides pull request attribution"}}},"includeGitInstructions":{"type":"boolean","description":"Include built-in git commit and PR workflow instructions in Claude's system prompt. Also configurable via CLAUDE_CODE_DISABLE_GIT_INSTRUCTIONS environment variable (set to 1 to disable). See https://code.claude.com/docs/en/settings#available-settings","default":true},"includeCoAuthoredBy":{"type":"boolean","description":"DEPRECATED. Use 'attribution' instead. Whether to include the co-authored-by Claude byline in git commits and pull requests (default: true)","default":true},"plansDirectory":{"type":"string","description":"Customize where plan files are stored. Path is relative to project root (default: ~/.claude/plans)","default":"~/.claude/plans","examples":["./plans"]},"respectGitignore":{"type":"boolean","description":"Control whether the @ file picker respects .gitignore patterns. When true (default), files matching .gitignore patterns are excluded from suggestions","default":true},"permissions":{"type":"object","properties":{"allow":{"type":"array","items":{"$ref":"#/$defs/permissionRule"},"description":"List of permission rules for allowed operations","uniqueItems":true},"deny":{"type":"array","items":{"$ref":"#/$defs/permissionRule"},"description":"List of permission rules for denied operations","uniqueItems":true},"ask":{"type":"array","items":{"$ref":"#/$defs/permissionRule"},"description":"List of permission rules that should always prompt for confirmation","uniqueItems":true},"defaultMode":{"type":"string","enum":["acceptEdits","bypassPermissions","default","delegate","dontAsk","plan"],"description":"Default permission mode.\\n\\"default\\": prompts on first use.\\n\\"acceptEdits\\": auto-accepts file edits.\\n\\"plan\\": read-only, no modifications.\\nUNDOCUMENTED. \\"delegate\\": coordination-only for agent team leads (agent teams are experimental; enable via CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS).\\n\\"dontAsk\\": auto-denies unless pre-approved via permissions.\\n\\"bypassPermissions\\": skips all prompts (use only in isolated environments).\\nSee https://code.claude.com/docs/en/permissions"},"disableBypassPermissionsMode":{"type":"string","enum":["disable"],"description":"Disable the ability to bypass permission prompts"},"additionalDirectories":{"type":"array","items":{"type":"string","minLength":1},"description":"Additional directories to include in the permission scope","examples":[["//Users/alice/Documents","~/projects"]],"uniqueItems":true}},"additionalProperties":false,"description":"Tool usage permissions configuration.\\nSee https://code.claude.com/docs/en/permissions and https://code.claude.com/docs/en/settings#permission-settings\\nSee https://code.claude.com/docs/en/settings#tools-available-to-claude for full list of tools available to Claude.","examples":[{"allow":["Bash(git add:*)"],"ask":["Bash(gh pr create:*)","Bash(git commit:*)"],"deny":["Read(*.env)","Bash(rm:*)","Bash(curl:*)"],"defaultMode":"default"}]},"language":{"type":"string","description":"Preferred language for Claude's responses","examples":["japanese","spanish","french"]},"model":{"type":"string","enum":["opus","sonnet","haiku","default"],"description":"Override the default model used by Claude Code. Accepts a short alias (opus|sonnet|haiku) or a full model ID. For finer control, use environment variables: ANTHROPIC_MODEL (runtime override), ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL, ANTHROPIC_DEFAULT_HAIKU_MODEL (per-class pinning), CLAUDE_CODE_SUBAGENT_MODEL (subagent model). See https://code.claude.com/docs/en/model-config"},"availableModels":{"type":"array","items":{"type":"string"},"description":"Restrict which models users can select. When defined at multiple settings levels (user, project, etc.), arrays are merged and deduplicated. See https://code.claude.com/docs/en/model-config#restrict-model-selection","examples":[["sonnet","haiku"]]},"modelOverrides":{"type":"object","additionalProperties":{"type":"string"},"description":"Map Anthropic model IDs to provider-specific model IDs such as Bedrock inference profile ARNs, Vertex AI version names, or Foundry deployment names. Each model picker entry uses its mapped value when calling the provider API. Unknown keys are ignored. See https://code.claude.com/docs/en/model-config#override-model-ids-per-version","examples":[{"claude-opus-4-6":"arn:aws:bedrock:us-east-2:123456789012:application-inference-profile/opus-prod"}]},"effortLevel":{"type":"string","enum":["low","medium","high"],"description":"Control Opus 4.6 adaptive reasoning effort. Lower effort is faster and cheaper for straightforward tasks, higher effort provides deeper reasoning. Defaults vary by model and plan (Opus 4.6 defaults to medium for Max and Team subscribers). Use /effort auto to reset to model default. Also configurable via CLAUDE_CODE_EFFORT_LEVEL environment variable. See https://code.claude.com/docs/en/model-config#adjust-effort-level"},"fastMode":{"type":"boolean","description":"Enable fast mode for Opus 4.6 (research preview). Fast mode uses the same model with 2.5x faster output at higher per-token cost. Requires extra usage enabled. Alternatively, toggle with /fast command. See https://code.claude.com/docs/en/fast-mode","default":false},"fastModePerSessionOptIn":{"type":"boolean","description":"Require per-session opt-in for fast mode. When true, fast mode does not persist across sessions and users must enable it with /fast each session. Useful for controlling costs. See https://code.claude.com/docs/en/fast-mode","default":false},"feedbackSurveyRate":{"type":"number","minimum":0,"maximum":1,"description":"Probability (0–1) that the session quality survey appears when eligible. A value of 0.05 means 5% of eligible sessions. See https://code.claude.com/docs/en/settings","examples":[0.05]},"editorMode":{"type":"string","enum":["normal","vim"],"default":"normal","description":"Editor input mode for the Claude Code terminal prompt. 'vim' enables modal editing (Esc for normal mode, i for insert). See https://code.claude.com/docs/en/settings"},"skillOverrides":{"type":"object","additionalProperties":{"type":"string","enum":["on","name-only","user-invocable-only","off"]},"description":"Per-skill availability override map. Keys are skill names; values are one of 'on' (default), 'name-only' (skill name listed but not auto-loaded), 'user-invocable-only' (load only when user explicitly invokes), or 'off' (hidden). Requires Claude Code v2.1.129+. See https://code.claude.com/docs/en/settings","examples":[{"playwright-debug":"user-invocable-only","init":"off"}]},"disableAgentView":{"type":"boolean","default":false,"description":"Disable the Agent View feature (read-only inspection of sub-agent activity). Useful when administering managed deployments. Requires Claude Code v2.1.139+. See https://code.claude.com/docs/en/settings"},"disableRemoteControl":{"type":"boolean","default":false,"description":"Block the \`claude remote-control\` channel that allows external clients to drive this Claude Code instance. Recommended default for shared/CI environments. Requires Claude Code v2.1.128+. See https://code.claude.com/docs/en/settings"},"enableAllProjectMcpServers":{"type":"boolean","description":"Whether to automatically approve all MCP servers in the project. See https://code.claude.com/docs/en/mcp","examples":[true]},"enabledMcpjsonServers":{"type":"array","items":{"type":"string","minLength":1},"description":"List of approved MCP servers from .mcp.json. See https://code.claude.com/docs/en/mcp","examples":[["memory","github"]]},"disabledMcpjsonServers":{"type":"array","items":{"type":"string","minLength":1},"description":"List of rejected MCP servers from .mcp.json. See https://code.claude.com/docs/en/mcp","examples":[["filesystem"]]},"allowedMcpServers":{"type":"array","items":{"anyOf":[{"type":"object","properties":{"serverName":{"type":"string","pattern":"^[a-zA-Z0-9_-]+$","description":"Name of the MCP server that users are allowed to configure"}},"required":["serverName"],"additionalProperties":false},{"type":"object","properties":{"serverCommand":{"type":"array","items":{"type":"string"},"description":"Exact command and arguments used to start stdio servers"}},"required":["serverCommand"],"additionalProperties":false},{"type":"object","properties":{"serverUrl":{"type":"string","description":"URL pattern for remote servers, supports wildcards (e.g., https://*.example.com/*)"}},"required":["serverUrl"],"additionalProperties":false}]},"description":"Enterprise allowlist of MCP servers that can be used. Applies to all scopes including enterprise servers from managed-mcp.json. If undefined, all servers are allowed. If empty array, no servers are allowed. Denylist takes precedence - if a server is on both lists, it is denied. See https://code.claude.com/docs/en/mcp#restriction-options"},"deniedMcpServers":{"type":"array","items":{"anyOf":[{"type":"object","properties":{"serverName":{"type":"string","pattern":"^[a-zA-Z0-9_-]+$","description":"Name of the MCP server that is explicitly blocked"}},"required":["serverName"],"additionalProperties":false},{"type":"object","properties":{"serverCommand":{"type":"array","items":{"type":"string"},"description":"Exact command and arguments used to start stdio servers"}},"required":["serverCommand"],"additionalProperties":false},{"type":"object","properties":{"serverUrl":{"type":"string","description":"URL pattern for remote servers, supports wildcards (e.g., https://*.example.com/*)"}},"required":["serverUrl"],"additionalProperties":false}]},"description":"Enterprise denylist of MCP servers that are explicitly blocked. If a server is on the denylist, it will be blocked across all scopes including enterprise. Denylist takes precedence over allowlist - if a server is on both lists, it is denied. See https://code.claude.com/docs/en/mcp#restriction-options"},"httpHookAllowedEnvVars":{"type":"array","items":{"type":"string","minLength":1},"description":"Allowlist of environment variable names HTTP hooks may interpolate into headers. When set, each hook's effective allowedEnvVars is the intersection with this list. Undefined = no restriction. Arrays merge across settings sources. See https://code.claude.com/docs/en/settings#hook-configuration","examples":[["MY_TOKEN","HOOK_SECRET"]]},"hooks":{"type":"object","additionalProperties":false,"description":"Custom commands to run before/after tool executions. See https://code.claude.com/docs/en/hooks","examples":[{"PostToolUse":[{"matcher":"Edit|Write","hooks":[{"type":"command","command":"prettier --write","timeout":5}]}]}],"properties":{"PreToolUse":{"type":"array","description":"Hooks that run before tool calls","items":{"$ref":"#/$defs/hookMatcher"}},"PostToolUse":{"type":"array","description":"Hooks that run after tool completion","items":{"$ref":"#/$defs/hookMatcher"}},"PostToolUseFailure":{"type":"array","description":"Hooks that run after a tool fails","items":{"$ref":"#/$defs/hookMatcher"}},"PermissionRequest":{"type":"array","description":"Hooks that run when a permission dialog appears","items":{"$ref":"#/$defs/hookMatcher"}},"Notification":{"type":"array","description":"Hooks that trigger on notifications","items":{"$ref":"#/$defs/hookMatcher"}},"UserPromptSubmit":{"type":"array","description":"Hooks that run when a user submits a prompt","items":{"$ref":"#/$defs/hookMatcher"}},"Stop":{"type":"array","description":"Hooks that run when agents finish responding. Does not run on user interrupt","items":{"$ref":"#/$defs/hookMatcher"}},"SubagentStart":{"type":"array","description":"Hooks that run when a subagent is spawned","items":{"$ref":"#/$defs/hookMatcher"}},"SubagentStop":{"type":"array","description":"Hooks that run when subagents finish responding","items":{"$ref":"#/$defs/hookMatcher"}},"PreCompact":{"type":"array","description":"Hooks that run before the context is compacted","items":{"$ref":"#/$defs/hookMatcher"}},"PostCompact":{"type":"array","description":"Hooks that run after the context is compacted. See https://code.claude.com/docs/en/hooks","items":{"$ref":"#/$defs/hookMatcher"}},"Elicitation":{"type":"array","description":"Hooks that run when an MCP server requests user input during a tool call. See https://code.claude.com/docs/en/hooks","items":{"$ref":"#/$defs/hookMatcher"}},"ElicitationResult":{"type":"array","description":"Hooks that run after a user responds to an MCP elicitation, before the response is sent back to the server. See https://code.claude.com/docs/en/hooks","items":{"$ref":"#/$defs/hookMatcher"}},"TeammateIdle":{"type":"array","description":"Hooks that run when an agent team teammate is about to go idle. Exit code 2 sends feedback and keeps the teammate working. Does not support matchers. Agent teams are experimental. See https://code.claude.com/docs/en/hooks#teammateidle","items":{"$ref":"#/$defs/hookMatcher"}},"TaskCompleted":{"type":"array","description":"Hooks that run when a task is being marked as completed. Exit code 2 prevents completion and sends feedback. Does not support matchers. See https://code.claude.com/docs/en/hooks#taskcompleted","items":{"$ref":"#/$defs/hookMatcher"}},"Setup":{"type":"array","description":"UNDOCUMENTED. Hooks that run during repository initialization (--init, --init-only) or maintenance (--maintenance)","items":{"$ref":"#/$defs/hookMatcher"}},"InstructionsLoaded":{"type":"array","description":"Hooks that run when a CLAUDE.md or .claude/rules/*.md file is loaded into context. Fires at session start and when files are lazily loaded (e.g., nested traversal, path glob match). No decision control; used for audit logging and observability. Does not support matchers. See https://code.claude.com/docs/en/hooks#instructionsloaded","items":{"$ref":"#/$defs/hookMatcher"}},"ConfigChange":{"type":"array","description":"Hooks that run when settings, managed settings, or skill files change during a session. Supports matchers: user_settings, project_settings, local_settings, policy_settings, skills. Command handlers only. Exit code 2 blocks the change (except policy_settings which is audit-only). See https://code.claude.com/docs/en/hooks#configchange","items":{"$ref":"#/$defs/hookMatcher"}},"WorktreeCreate":{"type":"array","description":"Hooks that run when a worktree is created via --worktree or isolation: \\"worktree\\" in subagents. Command handlers only, no matchers. Hook must print absolute path to created worktree on stdout; non-zero exit fails creation. See https://code.claude.com/docs/en/hooks#worktreecreate","items":{"$ref":"#/$defs/hookMatcher"}},"WorktreeRemove":{"type":"array","description":"Hooks that run when a worktree is being removed at session exit or when a subagent finishes. Command handlers only, no matchers. Used for cleanup tasks; cannot block removal. See https://code.claude.com/docs/en/hooks#worktreeremove","items":{"$ref":"#/$defs/hookMatcher"}},"SessionStart":{"type":"array","description":"Hooks that run when a new session starts","items":{"$ref":"#/$defs/hookMatcher"}},"SessionEnd":{"type":"array","description":"Hooks that run when a session ends","items":{"$ref":"#/$defs/hookMatcher"}}}},"disableAllHooks":{"type":"boolean","description":"Disable all hooks and statusLine execution. When true in managed settings, user and project-level disableAllHooks cannot override it. See https://code.claude.com/docs/en/hooks#disable-or-remove-hooks"},"allowedHttpHookUrls":{"type":"array","items":{"type":"string","minLength":1},"description":"Allowlist of URL patterns that HTTP hooks may target. Supports * as a wildcard. When set, hooks with non-matching URLs are blocked. Undefined = no restriction, empty array = block all HTTP hooks. Arrays merge across settings sources. See https://code.claude.com/docs/en/settings#hook-configuration","examples":[["https://hooks.example.com/*","http://localhost:*"]]},"allowManagedHooksOnly":{"type":"boolean","description":"(Managed settings only) Prevent loading of user, project, and plugin hooks. Only allows managed hooks and SDK hooks. See https://code.claude.com/docs/en/settings#hook-configuration"},"allowManagedPermissionRulesOnly":{"type":"boolean","description":"(Managed settings only) Prevent user and project settings from defining allow, ask, or deny permission rules. Only rules in managed settings apply. See https://code.claude.com/docs/en/settings#permission-settings"},"statusLine":{"type":"object","properties":{"type":{"type":"string","description":"The type of status line handler; must be set to \\"command\\" to run a custom shell script that receives JSON session data via stdin.","const":"command"},"command":{"type":"string","description":"A shell command or path to a script that displays session information (context usage, costs, git status, etc.) by reading JSON data from stdin and writing output to stdout. See https://code.claude.com/docs/en/statusline"},"padding":{"type":"number","description":"Optional number of extra horizontal spacing characters added to the status line content; defaults to 0."}},"required":["type","command"],"additionalProperties":false,"description":"Custom status line display configuration. See https://code.claude.com/docs/en/statusline","examples":[{"type":"command","command":"~/.claude/statusline.sh"}]},"fileSuggestion":{"type":"object","properties":{"type":{"type":"string","description":"The type of file suggestion handler; must be set to \\"command\\" to execute a custom shell script that generates file suggestions for the @ file picker.","const":"command"},"command":{"type":"string","description":"Shell command to execute for file suggestions"}},"required":["type","command"],"additionalProperties":false,"description":"Configure a custom script for @ file autocomplete. See https://code.claude.com/docs/en/settings#file-suggestion-settings","examples":[{"type":"command","command":"~/.claude/file-suggestion.sh"}]},"enabledPlugins":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"boolean"},{"not":{}}]},"description":"Enabled plugins using plugin-id@marketplace-id format. Example: { \\"formatter@anthropic-tools\\": true }. See https://code.claude.com/docs/en/plugins"},"extraKnownMarketplaces":{"type":"object","additionalProperties":{"type":"object","properties":{"source":{"anyOf":[{"type":"object","properties":{"source":{"type":"string","description":"Identifies the marketplace source type","const":"url"},"url":{"type":"string","format":"uri","description":"Direct URL to marketplace.json file"}},"required":["source","url"],"additionalProperties":false},{"type":"object","properties":{"source":{"type":"string","description":"Identifies the marketplace source type","const":"hostPattern"},"hostPattern":{"type":"string","description":"Git host pattern to trust for repositories in source specifications"}},"required":["source","hostPattern"],"additionalProperties":false},{"type":"object","properties":{"source":{"type":"string","description":"Identifies the marketplace source type","const":"github"},"repo":{"type":"string","description":"GitHub repository in owner/repo format"},"ref":{"type":"string","description":"Git branch or tag to use (e.g., \\"main\\", \\"v1.0.0\\"). Defaults to repository default branch."},"path":{"type":"string","description":"Path to marketplace.json within repo (defaults to .claude-plugin/marketplace.json)"}},"required":["source","repo"],"additionalProperties":false},{"type":"object","properties":{"source":{"type":"string","description":"Identifies the marketplace source type","const":"git"},"url":{"type":"string","pattern":"\\\\.git$","description":"Full git repository URL"},"ref":{"type":"string","description":"Git branch or tag to use (e.g., \\"main\\", \\"v1.0.0\\"). Defaults to repository default branch."},"path":{"type":"string","description":"Path to marketplace.json within repo (defaults to .claude-plugin/marketplace.json)"}},"required":["source","url"],"additionalProperties":false},{"type":"object","properties":{"source":{"type":"string","description":"Identifies the marketplace source type","const":"npm"},"package":{"type":"string","description":"NPM package containing marketplace.json"}},"required":["source","package"],"additionalProperties":false},{"type":"object","properties":{"source":{"type":"string","description":"Identifies the marketplace source type","const":"file"},"path":{"type":"string","description":"Local file path to marketplace.json"}},"required":["source","path"],"additionalProperties":false},{"type":"object","properties":{"source":{"type":"string","description":"Identifies the marketplace source type","const":"directory"},"path":{"type":"string","description":"Local directory containing .claude-plugin/marketplace.json"}},"required":["source","path"],"additionalProperties":false}],"description":"Where to fetch the marketplace from"},"installLocation":{"type":"string","description":"Local cache path where marketplace manifest is stored (auto-generated if not provided)"}},"required":["source"],"additionalProperties":false},"description":"Additional marketplaces to make available for this repository. Typically used in repository .claude/settings.json to ensure team members have required plugin sources. See https://code.claude.com/docs/en/plugin-marketplaces"},"strictKnownMarketplaces":{"type":"array","description":"(Managed settings only) Allowlist of plugin marketplaces users can add. Undefined = no restrictions, empty array = lockdown. Uses exact matching for source specifications. See https://code.claude.com/docs/en/settings#strictknownmarketplaces","items":{"anyOf":[{"type":"object","properties":{"source":{"type":"string","description":"Identifies the marketplace source type","const":"hostPattern"},"hostPattern":{"type":"string","description":"Git host pattern to trust for repositories in source specifications"}},"required":["source","hostPattern"],"additionalProperties":false},{"type":"object","properties":{"source":{"type":"string","description":"Identifies the marketplace source type","const":"github"},"repo":{"type":"string","description":"GitHub repository in owner/repo format"},"ref":{"type":"string","description":"Git branch, tag, or SHA"},"path":{"type":"string","description":"Subdirectory path"}},"required":["source","repo"],"additionalProperties":false},{"type":"object","properties":{"source":{"type":"string","description":"Identifies the marketplace source type","const":"git"},"url":{"type":"string","description":"Full git repository URL"},"ref":{"type":"string","description":"Git branch, tag, or SHA"},"path":{"type":"string","description":"Subdirectory path"}},"required":["source","url"],"additionalProperties":false},{"type":"object","properties":{"source":{"type":"string","description":"Identifies the marketplace source type","const":"url"},"url":{"type":"string","format":"uri","description":"Direct URL to marketplace.json"},"headers":{"type":"object","additionalProperties":{"type":"string"},"description":"HTTP headers for authenticated access"}},"required":["source","url"],"additionalProperties":false},{"type":"object","properties":{"source":{"type":"string","description":"Identifies the marketplace source type","const":"npm"},"package":{"type":"string","description":"NPM package name (supports scoped packages)"}},"required":["source","package"],"additionalProperties":false},{"type":"object","properties":{"source":{"type":"string","description":"Identifies the marketplace source type","const":"file"},"path":{"type":"string","description":"Absolute path to marketplace.json file"}},"required":["source","path"],"additionalProperties":false},{"type":"object","properties":{"source":{"type":"string","description":"Identifies the marketplace source type","const":"directory"},"path":{"type":"string","description":"Absolute path to directory containing .claude-plugin/marketplace.json"}},"required":["source","path"],"additionalProperties":false},{"type":"object","properties":{"source":{"type":"string","description":"Identifies the marketplace source type","const":"pathPattern"},"pathPattern":{"type":"string","description":"Regex pattern to match file or directory paths for marketplace sources"}},"required":["source","pathPattern"],"additionalProperties":false}]},"examples":[[{"source":"github","repo":"acme-corp/approved-plugins"},{"source":"npm","package":"@acme-corp/compliance-plugins"}]]},"skippedMarketplaces":{"type":"array","items":{"type":"string","minLength":1},"description":"List of marketplace names the user has chosen not to install when prompted"},"skippedPlugins":{"type":"array","items":{"type":"string","minLength":1},"description":"List of plugin IDs (plugin@marketplace format) the user has chosen not to install when prompted"},"forceLoginMethod":{"type":"string","enum":["claudeai","console"],"description":"Force a specific login method: \\"claudeai\\" for Claude Pro/Max, \\"console\\" for Console billing","examples":["claudeai"]},"forceLoginOrgUUID":{"type":"string","description":"Organization UUID to use for OAuth login","examples":["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"],"minLength":1},"otelHeadersHelper":{"type":"string","description":"Path to a script that outputs OpenTelemetry headers","minLength":1},"outputStyle":{"type":"string","description":"Controls the output style for assistant responses. Built-in styles: default, Explanatory, Learning. Custom styles can be added in ~/.claude/output-styles/ or .claude/output-styles/. See https://code.claude.com/docs/en/output-styles","examples":["default","Explanatory","Learning"],"minLength":1},"skipWebFetchPreflight":{"type":"boolean","description":"Skip the WebFetch blocklist check for enterprise environments with restrictive security policies"},"sandbox":{"type":"object","description":"Sandbox execution configuration. See https://code.claude.com/docs/en/sandboxing","properties":{"network":{"type":"object","description":"Configures network isolation settings for the sandboxed bash environment, including domain restrictions, Unix socket access, and custom proxy configuration.","properties":{"allowUnixSockets":{"type":"array","items":{"type":"string"},"description":"Allow Unix domain sockets for local IPC (SSH agent, Docker, etc.). Provide an array of specific paths. Defaults to blocking if not specified"},"allowLocalBinding":{"type":"boolean","description":"Allow binding to local network addresses (e.g., localhost ports). Defaults to false if not specified"},"httpProxyPort":{"type":"integer","minimum":1,"maximum":65535,"description":"HTTP proxy port to use for network filtering. If not specified, a proxy server will be started automatically"},"socksProxyPort":{"type":"integer","minimum":1,"maximum":65535,"description":"SOCKS proxy port to use for network filtering. If not specified, a proxy server will be started automatically"},"allowAllUnixSockets":{"type":"boolean","description":"Allow all Unix domain socket connections. If true, this overrides allowUnixSockets"},"allowedDomains":{"type":"array","items":{"type":"string","minLength":1},"description":"Allowlist of network domains for sandboxed commands. Supports wildcard patterns like *.example.com"},"allowManagedDomainsOnly":{"type":"boolean","description":"(Managed settings only) Only allowedDomains and WebFetch(domain:...) allow rules from managed settings are respected. User, project, local, and flag settings domains are ignored. Denied domains are still respected from all sources. Non-allowed domains are automatically blocked without user prompts."}},"additionalProperties":false},"ignoreViolations":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"},"description":"List of filesystem paths to ignore sandbox violations for when this command pattern matches"},"description":"Map of command patterns to filesystem paths to ignore violations for. Use \\"*\\" to match all commands"},"excludedCommands":{"type":"array","items":{"type":"string"},"description":"Commands that should never run in the sandbox (e.g., [\\"git\\", \\"docker\\"])"},"autoAllowBashIfSandboxed":{"type":"boolean","description":"Automatically allow bash commands without prompting when they run in the sandbox. Only applies to commands that will run sandboxed.","default":true},"enableWeakerNetworkIsolation":{"type":"boolean","description":"macOS only. Allow access to the system TLS trust service (com.apple.trustd.agent) in the sandbox. Required for Go-based tools like gh, gcloud, and terraform to verify TLS certificates when using httpProxyPort with a MITM proxy and custom CA. Reduces security by opening a potential data exfiltration path. Default: false. See https://code.claude.com/docs/en/settings#sandbox-settings","default":false},"enableWeakerNestedSandbox":{"type":"boolean","description":"Enable weaker sandbox mode for unprivileged docker environments where --proc mounting fails. This significantly reduces the strength of the sandbox and should only be used when this risk is acceptable.Default: false (secure)."},"allowUnsandboxedCommands":{"type":"boolean","description":"Allow commands to run outside the sandbox via the dangerouslyDisableSandbox parameter. When false, the dangerouslyDisableSandbox parameter is completely ignored and all commands must run sandboxed. Default: true."},"enabled":{"type":"boolean","description":"Enable sandboxed bash"},"filesystem":{"type":"object","description":"Filesystem access control for sandboxed commands. See https://code.claude.com/docs/en/sandboxing#filesystem-isolation","properties":{"allowWrite":{"type":"array","items":{"type":"string","minLength":1},"description":"Paths where subprocesses are allowed to write. Supports prefixes: // (absolute), ~/ (home directory), / (relative to settings file), ./ or no prefix (relative path)"},"denyWrite":{"type":"array","items":{"type":"string","minLength":1},"description":"Paths where subprocesses are explicitly denied write access. Takes precedence over allowWrite"},"denyRead":{"type":"array","items":{"type":"string","minLength":1},"description":"Paths where subprocesses are explicitly denied read access"},"allowRead":{"type":"array","items":{"type":"string","minLength":1},"description":"Paths to re-allow reading within denyRead regions. Takes precedence over denyRead for matching paths"},"allowManagedReadPathsOnly":{"type":"boolean","description":"When true (managed settings only), only allowRead paths from managed settings are used"}},"additionalProperties":false}},"additionalProperties":false},"spinnerVerbs":{"type":"object","description":"Customize the verbs shown in spinner progress messages","properties":{"mode":{"type":"string","enum":["append","replace"],"description":"How to combine custom verbs with default spinner verbs: 'append' adds custom verbs to the default list, 'replace' uses only custom verbs"},"verbs":{"type":"array","items":{"type":"string","minLength":1},"minItems":1,"description":"Custom verbs used in spinner progress text"}},"required":["verbs"],"additionalProperties":false},"spinnerTipsEnabled":{"type":"boolean","description":"Show tips in the spinner while Claude is working. Set to false to disable tips (default: true)","default":true},"spinnerTipsOverride":{"type":"object","description":"Customize the tips displayed in the spinner while Claude is working. See https://code.claude.com/docs/en/settings#available-settings","properties":{"excludeDefault":{"type":"boolean","description":"If true, only show custom tips. If false or absent, custom tips merge with built-in tips","default":false},"tips":{"type":"array","items":{"type":"string","minLength":1},"description":"Custom tip strings to display in the spinner","minItems":1}},"required":["tips"],"additionalProperties":false},"terminalProgressBarEnabled":{"type":"boolean","description":"Enable the terminal progress bar that shows progress in supported terminals like Windows Terminal and iTerm2 (default: true)","default":true},"showTurnDuration":{"type":"boolean","description":"Show turn duration messages after responses (e.g., \\"Cooked for 1m 6s\\"). Set to false to hide these messages (default: true)","default":true},"prefersReducedMotion":{"type":"boolean","description":"Reduce or disable UI animations (spinners, shimmer, flash effects) for accessibility","default":false},"alwaysThinkingEnabled":{"type":"boolean","description":"Enable extended thinking by default for all sessions. Typically configured via the /config command rather than editing directly. See https://code.claude.com/docs/en/common-workflows#use-extended-thinking-thinking-mode"},"companyAnnouncements":{"type":"array","items":{"type":"string","minLength":1},"description":"Company announcements to display at startup (one will be randomly selected if multiple are provided)"},"teammateMode":{"type":"string","enum":["auto","in-process","tmux"],"description":"How agent team teammates display: \\"auto\\" picks split panes in tmux or iTerm2, in-process otherwise. Agent teams are experimental and disabled by default. Enable them by adding CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS to your settings.json or environment. See https://code.claude.com/docs/en/agent-teams","default":"auto"},"worktree":{"type":"object","additionalProperties":false,"description":"Configuration for --worktree sessions. See https://code.claude.com/docs/en/settings","properties":{"sparsePaths":{"type":"array","items":{"type":"string","minLength":1},"description":"Directories to check out in each worktree via git sparse-checkout (cone mode). Only the listed paths are written to disk, which is faster in large monorepos.","examples":[["packages/my-app","shared/utils"]]}}},"pluginTrustMessage":{"type":"string","description":"(Managed settings only) Custom message appended to the plugin trust warning shown before installation. Use to provide organization-specific context about approved plugins. See https://code.claude.com/docs/en/settings#plugin-settings","minLength":1},"pluginConfigs":{"type":"object","additionalProperties":{"type":"object","properties":{"mcpServers":{"type":"object","additionalProperties":{"type":"object","additionalProperties":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"boolean"},{"type":"array","items":{"type":"string"}}]}},"description":"User configuration values for MCP servers keyed by server name"}},"additionalProperties":false},"description":"Per-plugin configuration including MCP server user configs, keyed by plugin ID (plugin@marketplace format). See https://code.claude.com/docs/en/plugins"},"allowManagedMcpServersOnly":{"type":"boolean","description":"(Managed settings only) Only allowedMcpServers from managed settings are respected. deniedMcpServers still merges from all sources. Users can still add their own MCP servers, but only the admin-defined allowlist applies."},"blockedMarketplaces":{"type":"array","description":"(Managed settings only) Blocklist of marketplace sources. These exact sources are blocked from being added as marketplaces. The check happens before downloading, so blocked sources never touch the filesystem.","items":{"anyOf":[{"type":"object","additionalProperties":false,"properties":{"source":{"type":"string","const":"url","description":"Block marketplace fetched from direct URL"},"url":{"type":"string","format":"uri","description":"Direct URL to marketplace.json file"},"headers":{"type":"object","additionalProperties":{"type":"string"},"description":"Custom HTTP headers (e.g., for authentication)"}},"required":["source","url"]},{"type":"object","additionalProperties":false,"properties":{"source":{"type":"string","const":"github","description":"Block marketplace from GitHub repository"},"repo":{"type":"string","description":"GitHub repository in owner/repo format"},"ref":{"type":"string","description":"Git branch or tag to use"},"path":{"type":"string","description":"Path to marketplace.json within repo"}},"required":["source","repo"]},{"type":"object","additionalProperties":false,"properties":{"source":{"type":"string","const":"git","description":"Block marketplace from git repository URL"},"url":{"type":"string","pattern":".*\\\\.git$","description":"Full git repository URL"},"ref":{"type":"string","description":"Git branch or tag to use"},"path":{"type":"string","description":"Path to marketplace.json within repo"}},"required":["source","url"]},{"type":"object","additionalProperties":false,"properties":{"source":{"type":"string","const":"npm","description":"Block marketplace from NPM package"},"package":{"type":"string","description":"NPM package containing marketplace.json"}},"required":["source","package"]},{"type":"object","additionalProperties":false,"properties":{"source":{"type":"string","const":"file","description":"Block marketplace from local file"},"path":{"type":"string","description":"Local file path to marketplace.json"}},"required":["source","path"]},{"type":"object","additionalProperties":false,"properties":{"source":{"type":"string","const":"directory","description":"Block marketplace from local directory"},"path":{"type":"string","description":"Local directory containing .claude-plugin/marketplace.json"}},"required":["source","path"]},{"type":"object","additionalProperties":false,"properties":{"source":{"type":"string","const":"hostPattern","description":"Block marketplace by host pattern matching"},"hostPattern":{"type":"string","description":"Regex pattern to match the host/domain extracted from any marketplace source type"}},"required":["source","hostPattern"]},{"type":"object","additionalProperties":false,"properties":{"source":{"type":"string","const":"pathPattern","description":"Block marketplace by file/directory path pattern matching"},"pathPattern":{"type":"string","description":"Regex pattern to match file or directory paths for marketplace sources"}},"required":["source","pathPattern"]}]}}}`),_pe="Claude Code Settings",Spe={$schema:ppe,$id:mpe,$defs:gpe,description:vpe,allowTrailingCommas:ype,additionalProperties:bpe,type:xpe,properties:wpe,title:_pe};function kpe(e){const r=e??{},n={...r.$defs??{},...r.definitions??{}},i=w=>{if(!w)return{};if(!w.$ref)return c(w);const k=/^#\/(\$defs|definitions)\/(.+)$/.exec(w.$ref);if(!k)return c(w);const S=n[k[2]];return S?i({...S,...l(w)}):c(w)},s=new Set(["__proto__","constructor","prototype"]),a=w=>{if(!w)return{};const k={};for(const[S,y]of Object.entries(w))s.has(S)||(k[S]=y);return k},c=w=>{if(!w.allOf||w.allOf.length===0)return w;const k={...w};delete k.allOf;for(const S of w.allOf){const y=i(S);Object.assign(k,{properties:{...a(k.properties),...a(y.properties)},required:Cpe([...k.required??[],...y.required??[]])}),!k.description&&y.description&&(k.description=y.description),k.default===void 0&&y.default!==void 0&&(k.default=y.default),!k.type&&y.type&&(k.type=y.type)}return k},l=w=>{const{$ref:k,...S}=w;return S},u=(w,k)=>{let S=i(w);for(const y of k){if(!S)return null;if(/^\d+$/.test(y)){const C=Array.isArray(S.items)?S.items[Number(y)]:S.items;S=C?i(C):null;continue}const x=S.properties;if(x&&!s.has(y)&&y in x){S=i(x[y]);continue}const _=S.additionalProperties;if(_&&typeof _=="object"){S=i(_);continue}return null}return S},f=(w,k,S)=>{if(!w)return null;const y={};if(w.description&&(y.description=w.description),w.type&&(y.type=w.type),w.default!==void 0&&(y.default=w.default),w.enum&&(y.enum=w.enum),w.const!==void 0&&(y.const=w.const),w.deprecated&&(y.deprecated=!0),w.examples&&(y.examples=w.examples),w.properties&&(y.knownChildren=Object.keys(w.properties)),S&&(k!=null&&k.includes(S))&&(y.required=!0),w.items&&!Array.isArray(w.items)){const x=i(w.items),_=f(x,void 0,null);_&&(y.itemsInfo=_)}return(w.additionalProperties===!0||typeof w.additionalProperties=="object")&&(y.open=!0),y},m=w=>k=>{if(k.length===0)return f(i(w),void 0,null);const S=u(w,k.slice(0,-1));if(!S)return null;const y=k[k.length-1],x=u(S,[y]);return f(x,S.required,y)},h=w=>{const k=i(w);return Object.keys(k.properties??{})},b=w=>({at:m(w),rootKeys:()=>h(w),rootedAt:k=>{const S=u(w,k);return b(S??{})}});return b(r)}function Cpe(e){return Array.from(new Set(e))}let ij=null;function t_(){return ij||(ij=kpe(Spe)),ij}function jpe(){const[e,r]=D.useState(null),[n,i]=D.useState(null),[s,a]=D.useState(null),[c,l]=D.useState(null),[u,f]=D.useState(!1),[m,h]=D.useState(null),[b,w]=D.useState(null);if(D.useEffect(()=>{let _=!1;return Promise.all([window.api.otel.getConfig(),window.api.otel.status(),window.api.otel.configPath()]).then(([C,T,E])=>{_||(r(C),a(C),i(T),l(E))}).catch(C=>{console.warn("[telemetry] load failed:",C==null?void 0:C.message)}),()=>{_=!0}},[]),!s||!e)return o.jsx(Kt,{title:"loading…"});const k=JSON.stringify(s)!==JSON.stringify(e),S=(_,C)=>{h(null),a({...s,[_]:C})},y=async()=>{f(!0),h(null);try{const _=await window.api.otel.setConfig(s);!_.ok&&_.error&&h(_.error),r(_.config),a(_.config),i(_.status),w(Date.now())}catch(_){h(_ instanceof Error?_.message:String(_))}finally{f(!1)}},x=()=>{h(null),a(e)};return o.jsxs("div",{className:"p-4 max-w-3xl space-y-5 text-sm",children:[o.jsxs("header",{className:"space-y-1",children:[o.jsx("h2",{className:"text-fg text-base font-medium",children:"Telemetry — OpenTelemetry export"}),o.jsx("p",{className:"text-fg-dim text-xs leading-relaxed",children:"When enabled, every classified transcript event (tool_use, todo_write, plan, usage, agent_spawn) is mirrored as a 0-duration OTLP/HTTP span. Point this at a local collector (Jaeger, Grafana Tempo, SigNoz, Honeycomb) for cross-session analysis."}),c&&o.jsxs("p",{className:"text-fg-faint text-[11px]",children:["stored at ",o.jsx("span",{className:"font-mono",children:c})]})]}),o.jsxs("section",{className:"border border-line rounded p-3 space-y-3",children:[o.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-fg",children:"Export transcripts to OTEL"}),o.jsx("div",{className:"text-fg-faint text-xs",children:"Toggle off to disable all span emission immediately."})]}),o.jsx(Xw,{checked:s.enabled,onChange:_=>S("enabled",_),label:s.enabled?"on":"off"})]}),o.jsxs("label",{className:"block space-y-1",children:[o.jsx("span",{className:"text-fg-dim text-xs",children:"OTLP/HTTP traces endpoint"}),o.jsx("input",{type:"text",value:s.endpoint,onChange:_=>S("endpoint",_.target.value),placeholder:"http://localhost:4318/v1/traces",className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),o.jsxs("label",{className:"block space-y-1",children:[o.jsxs("span",{className:"text-fg-dim text-xs",children:["Headers (newline-separated ",o.jsx("span",{className:"font-mono",children:"Key: Value"}),")"]}),o.jsx("textarea",{value:s.headers,onChange:_=>S("headers",_.target.value),placeholder:"x-honeycomb-team: YOUR_API_KEY",rows:3,className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),o.jsxs("label",{className:"block space-y-1",children:[o.jsx("span",{className:"text-fg-dim text-xs",children:"Service name"}),o.jsx("input",{type:"text",value:s.serviceName,onChange:_=>S("serviceName",_.target.value),placeholder:"session-manager",className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),o.jsxs("div",{className:"flex items-start justify-between gap-3 pt-1",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-fg",children:"Include content (PII)"}),o.jsxs("div",{className:"text-fg-faint text-xs leading-relaxed",children:["Adds tool inputs, plan text, and agent prompts to span attributes. Off by default — matches upstream Claude Code's ",o.jsx("span",{className:"font-mono",children:"OTEL_LOG_USER_PROMPTS"})," opt-in."]})]}),o.jsx(Xw,{checked:s.includeContent,onChange:_=>S("includeContent",_),label:s.includeContent?"on":"off"})]})]}),n&&o.jsxs("section",{className:"border border-line rounded p-3 text-xs space-y-1",children:[o.jsx("div",{className:"text-fg-dim",children:"Runtime status"}),o.jsxs("div",{children:[o.jsx("span",{className:"text-fg-faint",children:"enabled:"})," ",o.jsx("span",{className:n.enabled?"text-accent":"text-fg-dim",children:String(n.enabled)})]}),n.error&&o.jsxs("div",{className:"text-red-400 break-words",children:[o.jsx("span",{className:"text-fg-faint",children:"error:"})," ",n.error]}),!n.error&&n.enabled&&o.jsx("div",{className:"text-fg-faint",children:"spans batched and exported in the background. Verify by enabling and pointing at a local Jaeger."})]}),o.jsxs("footer",{className:"flex items-center gap-3 pt-2 border-t border-line",children:[o.jsx("button",{onClick:y,disabled:!k||u,className:"px-3 py-1 text-xs rounded bg-accent text-bg disabled:opacity-50 disabled:cursor-not-allowed",children:u?"saving…":"Save"}),o.jsx("button",{onClick:x,disabled:!k||u,className:"px-3 py-1 text-xs rounded border border-line text-fg-dim hover:text-fg disabled:opacity-50 disabled:cursor-not-allowed",children:"Revert"}),m&&o.jsx("span",{className:"text-red-400 text-xs",children:m}),!m&&b&&!k&&o.jsx("span",{className:"text-fg-faint text-xs",children:"saved"})]})]})}function Epe(){const{model:e,setModel:r}=$W();return o.jsxs("div",{className:"p-4 max-w-3xl space-y-5 text-sm",children:[o.jsxs("header",{className:"space-y-1",children:[o.jsx("h2",{className:"text-fg text-base font-medium",children:"Session Manager preferences"}),o.jsx("p",{className:"text-fg-dim text-xs leading-relaxed",children:"Native app preferences, stored locally — not part of Claude Code's own settings."})]}),o.jsx("section",{className:"border border-line rounded p-3 space-y-3",children:o.jsxs("label",{className:"block space-y-1",children:[o.jsx("span",{className:"text-fg-dim text-xs",children:"Default model for raw sessions"}),o.jsx("select",{value:e,onChange:n=>r(n.target.value),className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs",children:KT.map(n=>o.jsx("option",{value:n,children:n.charAt(0).toUpperCase()+n.slice(1)},n))}),o.jsx("span",{className:"text-fg-faint text-[11px]",children:"Used when opening a raw interactive session without an explicit per-launch override."})]})})]})}function Tpe(){const e=xn(),r=kt(E=>E.tabs),n=kt(E=>E.activeTabId),i=r.find(E=>E.id===n)??null,s=(i==null?void 0:i.cwd)??null,[a,c]=D.useState("user"),[l,u]=D.useState("effective"),f=g$(Kw,e,s),m=f[a]??null,h=sr(E=>E.files),b=sr(E=>E.setDraft),w=sr(E=>E.saveJson),k=sr(E=>E.revert),[S,y]=D.useState(null),x=D.useMemo(()=>v$(b$(h,f)),[h,f]),_=(E,$,N)=>{var q;const I=f[N??a];if(!I)return;y(null);const W=((q=h[I])==null?void 0:q.draftRaw)??"";let F={};if(W.trim())try{F=JSON.parse(W)}catch{F={}}const U=i1(F,E,$);b(I,JSON.stringify(U,null,2)+`