claude-code-session-manager 0.35.10 → 0.35.13

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-CxSS_K2x.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-B_2hT1QJ.js","./monaco-editor-BW5C4Iv1.js","./monaco-editor-BTnBOi8r.css"])))=>i.map(i=>d[i]);
2
2
  var XU=Object.defineProperty;var YU=(e,r,n)=>r in e?XU(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n;var Yr=(e,r,n)=>YU(e,typeof r!="symbol"?r+"":r,n);import{_ as sb}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 wx=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Qr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var g1={exports:{}},rv={},v1={exports:{}},gr={};/**
3
3
  * @license React
4
4
  * react.production.min.js
@@ -38,7 +38,7 @@ var XU=Object.defineProperty;var YU=(e,r,n)=>r in e?XU(e,r,{enumerable:!0,config
38
38
  `+W[de].replace(" at new "," at ");return p.displayName&&Re.includes("<anonymous>")&&(Re=Re.replace("<anonymous>",p.displayName)),Re}while(1<=de&&0<=ke);break}}}finally{ae=!1,Error.prepareStackTrace=A}return(p=p?p.displayName||p.name:"")?ee(p):""}function _e(p){switch(p.tag){case 5:return ee(p.type);case 16:return ee("Lazy");case 13:return ee("Suspense");case 19:return ee("SuspenseList");case 0:case 2:case 15:return p=me(p.type,!1),p;case 11:return p=me(p.type.render,!1),p;case 1:return p=me(p.type,!0),p;default:return""}}function Ne(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 M:return"Profiler";case O:return"StrictMode";case z:return"Suspense";case F:return"SuspenseList"}if(typeof p=="object")switch(p.$$typeof){case H:return(p.displayName||"Context")+".Consumer";case U:return(p._context.displayName||"Context")+".Provider";case V: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:Ne(p.type)||"Memo";case te:v=p._payload,p=p._init;try{return Ne(p(v))}catch{}}return null}function xe(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 Ne(v);case 8:return v===O?"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 ie(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),I=""+p[v];if(!p.hasOwnProperty(v)&&typeof A<"u"&&typeof A.get=="function"&&typeof A.set=="function"){var W=A.get,Z=A.set;return Object.defineProperty(p,v,{configurable:!0,get:function(){return W.call(this)},set:function(de){I=""+de,Z.call(this,de)}}),Object.defineProperty(p,v,{enumerable:A.enumerable}),{getValue:function(){return I},setValue:function(de){I=""+de},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(),I="";return p&&(I=ce(p)?p.checked?"true":"false":p.value),p=I,p!==A?(v.setValue(p),!0):!1}function Me(p){if(p=p||(typeof document<"u"?document:void 0),typeof p>"u")return null;try{return p.activeElement||p.body}catch{return p.body}}function Le(p,v){var A=v.checked;return Q({},v,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:A??p._wrapperState.initialChecked})}function Ue(p,v){var A=v.defaultValue==null?"":v.defaultValue,I=v.checked!=null?v.checked:v.defaultChecked;A=ie(v.value!=null?v.value:A),p._wrapperState={initialChecked:I,initialValue:A,controlled:v.type==="checkbox"||v.type==="radio"?v.checked!=null:v.value!=null}}function st(p,v){v=v.checked,v!=null&&C(p,"checked",v,!1)}function lt(p,v){st(p,v);var A=ie(v.value),I=v.type;if(A!=null)I==="number"?(A===0&&p.value===""||p.value!=A)&&(p.value=""+A):p.value!==""+A&&(p.value=""+A);else if(I==="submit"||I==="reset"){p.removeAttribute("value");return}v.hasOwnProperty("value")?Kt(p,v.type,A):v.hasOwnProperty("defaultValue")&&Kt(p,v.type,ie(v.defaultValue)),v.checked==null&&v.defaultChecked!=null&&(p.defaultChecked=!!v.defaultChecked)}function Zt(p,v,A){if(v.hasOwnProperty("value")||v.hasOwnProperty("defaultValue")){var I=v.type;if(!(I!=="submit"&&I!=="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 Kt(p,v,A){(v!=="number"||Me(p.ownerDocument)!==p)&&(A==null?p.defaultValue=""+p._wrapperState.initialValue:p.defaultValue!==""+A&&(p.defaultValue=""+A))}var sr=Array.isArray;function Vt(p,v,A,I){if(p=p.options,v){v={};for(var W=0;W<A.length;W++)v["$"+A[W]]=!0;for(A=0;A<p.length;A++)W=v.hasOwnProperty("$"+p[A].value),p[A].selected!==W&&(p[A].selected=W),W&&I&&(p[A].defaultSelected=!0)}else{for(A=""+ie(A),v=null,W=0;W<p.length;W++){if(p[W].value===A){p[W].selected=!0,I&&(p[W].defaultSelected=!0);return}v!==null||p[W].disabled||(v=p[W])}v!==null&&(v.selected=!0)}}function jr(p,v){if(v.dangerouslySetInnerHTML!=null)throw Error(n(91));return Q({},v,{value:void 0,defaultValue:void 0,children:""+p._wrapperState.initialValue})}function fr(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(sr(A)){if(1<A.length)throw Error(n(93));A=A[0]}v=A}v==null&&(v=""),A=v}p._wrapperState={initialValue:ie(A)}}function Ur(p,v){var A=ie(v.value),I=ie(v.defaultValue);A!=null&&(A=""+A,A!==p.value&&(p.value=A),v.defaultValue==null&&p.defaultValue!==A&&(p.defaultValue=A)),I!=null&&(p.defaultValue=""+I)}function Ir(p){var v=p.textContent;v===p._wrapperState.initialValue&&v!==""&&v!==null&&(p.value=v)}function fi(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 Zn(p,v){return p==null||p==="http://www.w3.org/1999/xhtml"?fi(v):p==="http://www.w3.org/2000/svg"&&v==="foreignObject"?"http://www.w3.org/1999/xhtml":p}var hr,Rn=(function(p){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(v,A,I,W){MSApp.execUnsafeLocalFunction(function(){return p(v,A,I,W)})}:p})(function(p,v){if(p.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in p)p.innerHTML=v;else{for(hr=hr||document.createElement("div"),hr.innerHTML="<svg>"+v.valueOf().toString()+"</svg>",v=hr.firstChild;p.firstChild;)p.removeChild(p.firstChild);for(;v.firstChild;)p.appendChild(v.firstChild)}});function ut(p,v){if(v){var A=p.firstChild;if(A&&A===p.lastChild&&A.nodeType===3){A.nodeValue=v;return}}p.textContent=v}var wt={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},_t=["Webkit","ms","Moz","O"];Object.keys(wt).forEach(function(p){_t.forEach(function(v){v=v+p.charAt(0).toUpperCase()+p.substring(1),wt[v]=wt[p]})});function _r(p,v,A){return v==null||typeof v=="boolean"||v===""?"":A||typeof v!="number"||v===0||wt.hasOwnProperty(p)&&wt[p]?(""+v).trim():v+"px"}function xn(p,v){p=p.style;for(var A in v)if(v.hasOwnProperty(A)){var I=A.indexOf("--")===0,W=_r(A,v[A],I);A==="float"&&(A="cssFloat"),I?p.setProperty(A,W):p[A]=W}}var rs=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 fs(p,v){if(v){if(rs[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 Sr(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 hi=null;function pn(p){return p=p.target||p.srcElement||window,p.correspondingUseElement&&(p=p.correspondingUseElement),p.nodeType===3?p.parentNode:p}var ea=null,hs=null,Mi=null;function Ca(p){if(p=Uc(p)){if(typeof ea!="function")throw Error(n(280));var v=p.stateNode;v&&(v=td(v),ea(p.stateNode,p.type,v))}}function ta(p){hs?Mi?Mi.push(p):Mi=[p]:hs=p}function ra(){if(hs){var p=hs,v=Mi;if(Mi=hs=null,Ca(p),v)for(p=0;p<v.length;p++)Ca(v[p])}}function ps(p,v){return p(v)}function Qn(){}var pi=!1;function Os(p,v,A){if(pi)return p(v,A);pi=!0;try{return ps(p,v,A)}finally{pi=!1,(hs!==null||Mi!==null)&&(Qn(),ra())}}function ei(p,v){var A=p.stateNode;if(A===null)return null;var I=td(A);if(I===null)return null;A=I[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":(I=!I.disabled)||(p=p.type,I=!(p==="button"||p==="input"||p==="select"||p==="textarea")),p=!I;break e;default:p=!1}if(p)return null;if(A&&typeof A!="function")throw Error(n(231,v,typeof A));return A}var Ii=!1;if(l)try{var ns={};Object.defineProperty(ns,"passive",{get:function(){Ii=!0}}),window.addEventListener("test",ns,ns),window.removeEventListener("test",ns,ns)}catch{Ii=!1}function to(p,v,A,I,W,Z,de,ke,Re){var Xe=Array.prototype.slice.call(arguments,3);try{v.apply(A,Xe)}catch(ft){this.onError(ft)}}var Ps=!1,Rs=null,Ms=!1,zt=null,mi={onError:function(p){Ps=!0,Rs=p}};function en(p,v,A,I,W,Z,de,ke,Re){Ps=!1,Rs=null,to.apply(mi,arguments)}function Er(p,v,A,I,W,Z,de,ke,Re){if(en.apply(this,arguments),Ps){if(Ps){var Xe=Rs;Ps=!1,Rs=null}else throw Error(n(198));Ms||(Ms=!0,zt=Xe)}}function Ct(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 ja(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 ro(p){if(Ct(p)!==p)throw Error(n(188))}function El(p){var v=p.alternate;if(!v){if(v=Ct(p),v===null)throw Error(n(188));return v!==p?null:p}for(var A=p,I=v;;){var W=A.return;if(W===null)break;var Z=W.alternate;if(Z===null){if(I=W.return,I!==null){A=I;continue}break}if(W.child===Z.child){for(Z=W.child;Z;){if(Z===A)return ro(W),p;if(Z===I)return ro(W),v;Z=Z.sibling}throw Error(n(188))}if(A.return!==I.return)A=W,I=Z;else{for(var de=!1,ke=W.child;ke;){if(ke===A){de=!0,A=W,I=Z;break}if(ke===I){de=!0,I=W,A=Z;break}ke=ke.sibling}if(!de){for(ke=Z.child;ke;){if(ke===A){de=!0,A=Z,I=W;break}if(ke===I){de=!0,I=Z,A=W;break}ke=ke.sibling}if(!de)throw Error(n(189))}}if(A.alternate!==I)throw Error(n(190))}if(A.tag!==3)throw Error(n(188));return A.stateNode.current===A?p:v}function no(p){return p=El(p),p!==null?io(p):null}function io(p){if(p.tag===5||p.tag===6)return p;for(p=p.child;p!==null;){var v=io(p);if(v!==null)return v;p=p.sibling}return null}var Uo=r.unstable_scheduleCallback,Hn=r.unstable_cancelCallback,Tl=r.unstable_shouldYield,Al=r.unstable_requestPaint,Tr=r.unstable_now,ti=r.unstable_getCurrentPriorityLevel,sn=r.unstable_ImmediatePriority,ri=r.unstable_UserBlockingPriority,Is=r.unstable_NormalPriority,Ea=r.unstable_LowPriority,na=r.unstable_IdlePriority,Di=null,Mn=null;function Ft(p){if(Mn&&typeof Mn.onCommitFiberRoot=="function")try{Mn.onCommitFiberRoot(Di,p,void 0,(p.current.flags&128)===128)}catch{}}var an=Math.clz32?Math.clz32:qo,ia=Math.log,Li=Math.LN2;function qo(p){return p>>>=0,p===0?32:31-(ia(p)/Li|0)|0}var sa=64,gi=4194304;function ms(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 aa(p,v){var A=p.pendingLanes;if(A===0)return 0;var I=0,W=p.suspendedLanes,Z=p.pingedLanes,de=A&268435455;if(de!==0){var ke=de&~W;ke!==0?I=ms(ke):(Z&=de,Z!==0&&(I=ms(Z)))}else de=A&~W,de!==0?I=ms(de):Z!==0&&(I=ms(Z));if(I===0)return 0;if(v!==0&&v!==I&&(v&W)===0&&(W=I&-I,Z=v&-v,W>=Z||W===16&&(Z&4194240)!==0))return v;if((I&4)!==0&&(I|=A&16),v=p.entangledLanes,v!==0)for(p=p.entanglements,v&=I;0<v;)A=31-an(v),W=1<<A,I|=p[A],v&=~W;return I}function lr(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 Bi(p,v){for(var A=p.suspendedLanes,I=p.pingedLanes,W=p.expirationTimes,Z=p.pendingLanes;0<Z;){var de=31-an(Z),ke=1<<de,Re=W[de];Re===-1?((ke&A)===0||(ke&I)!==0)&&(W[de]=lr(ke,v)):Re<=v&&(p.expiredLanes|=ke),Z&=~ke}}function Ta(p){return p=p.pendingLanes&-1073741825,p!==0?p:p&1073741824?1073741824:0}function is(){var p=sa;return sa<<=1,(sa&4194240)===0&&(sa=64),p}function Ze(p){for(var v=[],A=0;31>A;A++)v.push(p);return v}function vi(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 vt(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 I=p.eventTimes;for(p=p.expirationTimes;0<A;){var W=31-an(A),Z=1<<W;v[W]=0,I[W]=-1,p[W]=-1,A&=~Z}}function Se(p,v){var A=p.entangledLanes|=v;for(p=p.entanglements;A;){var I=31-an(A),W=1<<I;W&v|p[I]&v&&(p[I]|=v),A&=~W}}var ze=0;function et(p){return p&=-p,1<p?4<p?(p&268435455)!==0?16:536870912:4:1}var Et,ir,cr,Br,Dr,mn=!1,Gr=[],wn=null,Lr=null,gs=null,Aa=new Map,so=new Map,Ds=[],Cf="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 ao(p,v){switch(p){case"focusin":case"focusout":wn=null;break;case"dragenter":case"dragleave":Lr=null;break;case"mouseover":case"mouseout":gs=null;break;case"pointerover":case"pointerout":Aa.delete(v.pointerId);break;case"gotpointercapture":case"lostpointercapture":so.delete(v.pointerId)}}function oo(p,v,A,I,W,Z){return p===null||p.nativeEvent!==Z?(p={blockedOn:v,domEventName:A,eventSystemFlags:I,nativeEvent:Z,targetContainers:[W]},v!==null&&(v=Uc(v),v!==null&&ir(v)),p):(p.eventSystemFlags|=I,v=p.targetContainers,W!==null&&v.indexOf(W)===-1&&v.push(W),p)}function Bu(p,v,A,I,W){switch(v){case"focusin":return wn=oo(wn,p,v,A,I,W),!0;case"dragenter":return Lr=oo(Lr,p,v,A,I,W),!0;case"mouseover":return gs=oo(gs,p,v,A,I,W),!0;case"pointerover":var Z=W.pointerId;return Aa.set(Z,oo(Aa.get(Z)||null,p,v,A,I,W)),!0;case"gotpointercapture":return Z=W.pointerId,so.set(Z,oo(so.get(Z)||null,p,v,A,I,W)),!0}return!1}function Ec(p){var v=Vo(p.target);if(v!==null){var A=Ct(v);if(A!==null){if(v=A.tag,v===13){if(v=ja(A),v!==null){p.blockedOn=v,Dr(p.priority,function(){cr(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 lo(p){if(p.blockedOn!==null)return!1;for(var v=p.targetContainers;0<v.length;){var A=se(p.domEventName,p.eventSystemFlags,v[0],p.nativeEvent);if(A===null){A=p.nativeEvent;var I=new A.constructor(A.type,A);hi=I,A.target.dispatchEvent(I),hi=null}else return v=Uc(A),v!==null&&ir(v),p.blockedOn=A,!1;v.shift()}return!0}function $l(p,v,A){lo(p)&&A.delete(v)}function Tc(){mn=!1,wn!==null&&lo(wn)&&(wn=null),Lr!==null&&lo(Lr)&&(Lr=null),gs!==null&&lo(gs)&&(gs=null),Aa.forEach($l),so.forEach($l)}function oa(p,v){p.blockedOn===v&&(p.blockedOn=null,mn||(mn=!0,r.unstable_scheduleCallback(r.unstable_NormalPriority,Tc)))}function $a(p){function v(W){return oa(W,p)}if(0<Gr.length){oa(Gr[0],p);for(var A=1;A<Gr.length;A++){var I=Gr[A];I.blockedOn===p&&(I.blockedOn=null)}}for(wn!==null&&oa(wn,p),Lr!==null&&oa(Lr,p),gs!==null&&oa(gs,p),Aa.forEach(v),so.forEach(v),A=0;A<Ds.length;A++)I=Ds[A],I.blockedOn===p&&(I.blockedOn=null);for(;0<Ds.length&&(A=Ds[0],A.blockedOn===null);)Ec(A),A.blockedOn===null&&Ds.shift()}var la=E.ReactCurrentBatchConfig,co=!0;function zu(p,v,A,I){var W=ze,Z=la.transition;la.transition=null;try{ze=1,Ac(p,v,A,I)}finally{ze=W,la.transition=Z}}function Fu(p,v,A,I){var W=ze,Z=la.transition;la.transition=null;try{ze=4,Ac(p,v,A,I)}finally{ze=W,la.transition=Z}}function Ac(p,v,A,I){if(co){var W=se(p,v,A,I);if(W===null)Bf(p,v,I,$c,A),ao(p,I);else if(Bu(W,p,v,A,I))I.stopPropagation();else if(ao(p,I),v&4&&-1<Cf.indexOf(p)){for(;W!==null;){var Z=Uc(W);if(Z!==null&&Et(Z),Z=se(p,v,A,I),Z===null&&Bf(p,v,I,$c,A),Z===W)break;W=Z}W!==null&&I.stopPropagation()}else Bf(p,v,I,null,A)}}var $c=null;function se(p,v,A,I){if($c=null,p=pn(I),p=Vo(p),p!==null)if(v=Ct(p),v===null)p=null;else if(A=v.tag,A===13){if(p=ja(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 he(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(ti()){case sn:return 1;case ri:return 4;case Is:case Ea:return 16;case na:return 536870912;default:return 16}default:return 16}}var we=null,Pe=null,je=null;function We(){if(je)return je;var p,v=Pe,A=v.length,I,W="value"in we?we.value:we.textContent,Z=W.length;for(p=0;p<A&&v[p]===W[p];p++);var de=A-p;for(I=1;I<=de&&v[A-I]===W[Z-I];I++);return je=W.slice(p,1<I?1-I: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 nt(p){function v(A,I,W,Z,de){this._reactName=A,this._targetInst=W,this.type=I,this.nativeEvent=Z,this.target=de,this.currentTarget=null;for(var ke in p)p.hasOwnProperty(ke)&&(A=p[ke],this[ke]=A?A(Z):Z[ke]);return this.isDefaultPrevented=(Z.defaultPrevented!=null?Z.defaultPrevented:Z.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 ct={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(p){return p.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},it=nt(ct),Qe=Q({},ct,{view:0,detail:0}),$t=nt(Qe),qe,pt,Pr,tr=Q({},Qe,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ur,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!==Pr&&(Pr&&p.type==="mousemove"?(qe=p.screenX-Pr.screenX,pt=p.screenY-Pr.screenY):pt=qe=0,Pr=p),qe)},movementY:function(p){return"movementY"in p?p.movementY:pt}}),rr=nt(tr),Rr=Q({},tr,{dataTransfer:0}),Lt=nt(Rr),qr=Q({},Qe,{relatedTarget:0}),pr=nt(qr),In=Q({},ct,{animationName:0,elapsedTime:0,pseudoElement:0}),ni=nt(In),yi=Q({},ct,{clipboardData:function(p){return"clipboardData"in p?p.clipboardData:window.clipboardData}}),Nl=nt(yi),bi=Q({},ct,{data:0}),Nc=nt(bi),Uu={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Dn={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},Ls={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function qu(p){var v=this.nativeEvent;return v.getModifierState?v.getModifierState(p):(p=Ls[p])?!!v[p]:!1}function ur(){return qu}var vs=Q({},Qe,{key:function(p){if(p.key){var v=Uu[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"?Dn[p.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ur,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}}),jf=nt(vs),ca=Q({},tr,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Wo=nt(ca),_n=Q({},Qe,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ur}),xi=nt(_n),Oc=Q({},ct,{propertyName:0,elapsedTime:0,pseudoElement:0}),wi=nt(Oc),Wu=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}),Ef=nt(Wu),ua=[9,13,27,32],ys=l&&"CompositionEvent"in window,Bs=null;l&&"documentMode"in document&&(Bs=document.documentMode);var Sn=l&&"TextEvent"in window&&!Bs,tn=l&&(!ys||Bs&&8<Bs&&11>=Bs),bs=" ",Hu=!1;function Vu(p,v){switch(p){case"keyup":return ua.indexOf(v.keyCode)!==-1;case"keydown":return v.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function kb(p){return p=p.detail,typeof p=="object"&&"data"in p?p.data:null}var _i=!1;function Cb(p,v){switch(p){case"compositionend":return kb(v);case"keypress":return v.which!==32?null:(Hu=!0,bs);case"textInput":return p=v.data,p===bs&&Hu?null:p;default:return null}}function Tf(p,v){if(_i)return p==="compositionend"||!ys&&Vu(p,v)?(p=We(),je=Pe=we=null,_i=!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 Sm={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function zs(p){var v=p&&p.nodeName&&p.nodeName.toLowerCase();return v==="input"?!!Sm[p.type]:v==="textarea"}function km(p,v,A,I){ta(I),v=Yu(v,"onChange"),0<v.length&&(A=new it("onChange","change",null,A,I),p.push({event:A,listeners:v}))}var Pc=null,Rc=null;function jb(p){zm(p,0)}function Gu(p){var v=Rl(p);if(Te(v))return p}function Eb(p,v){if(p==="change")return v}var Cm=!1;if(l){var Af;if(l){var $f="oninput"in document;if(!$f){var jm=document.createElement("div");jm.setAttribute("oninput","return;"),$f=typeof jm.oninput=="function"}Af=$f}else Af=!1;Cm=Af&&(!document.documentMode||9<document.documentMode)}function Fs(){Pc&&(Pc.detachEvent("onpropertychange",Em),Rc=Pc=null)}function Em(p){if(p.propertyName==="value"&&Gu(Rc)){var v=[];km(v,Rc,p,pn(p)),Os(jb,v)}}function Tb(p,v,A){p==="focusin"?(Fs(),Pc=v,Rc=A,Pc.attachEvent("onpropertychange",Em)):p==="focusout"&&Fs()}function Ab(p){if(p==="selectionchange"||p==="keyup"||p==="keydown")return Gu(Rc)}function $b(p,v){if(p==="click")return Gu(v)}function Nb(p,v){if(p==="input"||p==="change")return Gu(v)}function Ob(p,v){return p===v&&(p!==0||1/p===1/v)||p!==p&&v!==v}var Us=typeof Object.is=="function"?Object.is:Ob;function Mc(p,v){if(Us(p,v))return!0;if(typeof p!="object"||p===null||typeof v!="object"||v===null)return!1;var A=Object.keys(p),I=Object.keys(v);if(A.length!==I.length)return!1;for(I=0;I<A.length;I++){var W=A[I];if(!u.call(v,W)||!Us(p[W],v[W]))return!1}return!0}function Tm(p){for(;p&&p.firstChild;)p=p.firstChild;return p}function Am(p,v){var A=Tm(p);p=0;for(var I;A;){if(A.nodeType===3){if(I=p+A.textContent.length,p<=v&&I>=v)return{node:A,offset:v-p};p=I}e:{for(;A;){if(A.nextSibling){A=A.nextSibling;break e}A=A.parentNode}A=void 0}A=Tm(A)}}function Nf(p,v){return p&&v?p===v?!0:p&&p.nodeType===3?!1:v&&v.nodeType===3?Nf(p,v.parentNode):"contains"in p?p.contains(v):p.compareDocumentPosition?!!(p.compareDocumentPosition(v)&16):!1:!1}function Of(){for(var p=window,v=Me();v instanceof p.HTMLIFrameElement;){try{var A=typeof v.contentWindow.location.href=="string"}catch{A=!1}if(A)p=v.contentWindow;else break;v=Me(p.document)}return v}function Pf(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 Pb(p){var v=Of(),A=p.focusedElem,I=p.selectionRange;if(v!==A&&A&&A.ownerDocument&&Nf(A.ownerDocument.documentElement,A)){if(I!==null&&Pf(A)){if(v=I.start,p=I.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 W=A.textContent.length,Z=Math.min(I.start,W);I=I.end===void 0?Z:Math.min(I.end,W),!p.extend&&Z>I&&(W=I,I=Z,Z=W),W=Am(A,Z);var de=Am(A,I);W&&de&&(p.rangeCount!==1||p.anchorNode!==W.node||p.anchorOffset!==W.offset||p.focusNode!==de.node||p.focusOffset!==de.offset)&&(v=v.createRange(),v.setStart(W.node,W.offset),p.removeAllRanges(),Z>I?(p.addRange(v),p.extend(de.node,de.offset)):(v.setEnd(de.node,de.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 $m=l&&"documentMode"in document&&11>=document.documentMode,Ic=null,Rf=null,Ho=null,Mf=!1;function Nm(p,v,A){var I=A.window===A?A.document:A.nodeType===9?A:A.ownerDocument;Mf||Ic==null||Ic!==Me(I)||(I=Ic,"selectionStart"in I&&Pf(I)?I={start:I.selectionStart,end:I.selectionEnd}:(I=(I.ownerDocument&&I.ownerDocument.defaultView||window).getSelection(),I={anchorNode:I.anchorNode,anchorOffset:I.anchorOffset,focusNode:I.focusNode,focusOffset:I.focusOffset}),Ho&&Mc(Ho,I)||(Ho=I,I=Yu(Rf,"onSelect"),0<I.length&&(v=new it("onSelect","select",null,v,A),p.push({event:v,listeners:I}),v.target=Ic)))}function Ku(p,v){var A={};return A[p.toLowerCase()]=v.toLowerCase(),A["Webkit"+p]="webkit"+v,A["Moz"+p]="moz"+v,A}var Na={animationend:Ku("Animation","AnimationEnd"),animationiteration:Ku("Animation","AnimationIteration"),animationstart:Ku("Animation","AnimationStart"),transitionend:Ku("Transition","TransitionEnd")},If={},Om={};l&&(Om=document.createElement("div").style,"AnimationEvent"in window||(delete Na.animationend.animation,delete Na.animationiteration.animation,delete Na.animationstart.animation),"TransitionEvent"in window||delete Na.transitionend.transition);function Dc(p){if(If[p])return If[p];if(!Na[p])return p;var v=Na[p],A;for(A in v)if(v.hasOwnProperty(A)&&A in Om)return If[p]=v[A];return p}var Pm=Dc("animationend"),Rm=Dc("animationiteration"),Mm=Dc("animationstart"),Im=Dc("transitionend"),Rb=new Map,Dm="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 uo(p,v){Rb.set(p,v),a(v,[p])}for(var Df=0;Df<Dm.length;Df++){var Lm=Dm[Df],Mb=Lm.toLowerCase(),yr=Lm[0].toUpperCase()+Lm.slice(1);uo(Mb,"on"+yr)}uo(Pm,"onAnimationEnd"),uo(Rm,"onAnimationIteration"),uo(Mm,"onAnimationStart"),uo("dblclick","onDoubleClick"),uo("focusin","onFocus"),uo("focusout","onBlur"),uo(Im,"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(" "),Ib=new Set("cancel close invalid load scroll toggle".split(" ").concat(Lc));function Bm(p,v,A){var I=p.type||"unknown-event";p.currentTarget=A,Er(I,v,void 0,p),p.currentTarget=null}function zm(p,v){v=(v&4)!==0;for(var A=0;A<p.length;A++){var I=p[A],W=I.event;I=I.listeners;e:{var Z=void 0;if(v)for(var de=I.length-1;0<=de;de--){var ke=I[de],Re=ke.instance,Xe=ke.currentTarget;if(ke=ke.listener,Re!==Z&&W.isPropagationStopped())break e;Bm(W,ke,Xe),Z=Re}else for(de=0;de<I.length;de++){if(ke=I[de],Re=ke.instance,Xe=ke.currentTarget,ke=ke.listener,Re!==Z&&W.isPropagationStopped())break e;Bm(W,ke,Xe),Z=Re}}}if(Ms)throw p=zt,Ms=!1,zt=null,p}function Kr(p,v){var A=v[Hf];A===void 0&&(A=v[Hf]=new Set);var I=p+"__bubble";A.has(I)||(Fm(v,p,2,!1),A.add(I))}function Lf(p,v,A){var I=0;v&&(I|=4),Fm(A,p,I,v)}var Xu="_reactListening"+Math.random().toString(36).slice(2);function Bc(p){if(!p[Xu]){p[Xu]=!0,i.forEach(function(A){A!=="selectionchange"&&(Ib.has(A)||Lf(A,!1,p),Lf(A,!0,p))});var v=p.nodeType===9?p:p.ownerDocument;v===null||v[Xu]||(v[Xu]=!0,Lf("selectionchange",!1,v))}}function Fm(p,v,A,I){switch(he(v)){case 1:var W=zu;break;case 4:W=Fu;break;default:W=Ac}A=W.bind(null,v,A,p),W=void 0,!Ii||v!=="touchstart"&&v!=="touchmove"&&v!=="wheel"||(W=!0),I?W!==void 0?p.addEventListener(v,A,{capture:!0,passive:W}):p.addEventListener(v,A,!0):W!==void 0?p.addEventListener(v,A,{passive:W}):p.addEventListener(v,A,!1)}function Bf(p,v,A,I,W){var Z=I;if((v&1)===0&&(v&2)===0&&I!==null)e:for(;;){if(I===null)return;var de=I.tag;if(de===3||de===4){var ke=I.stateNode.containerInfo;if(ke===W||ke.nodeType===8&&ke.parentNode===W)break;if(de===4)for(de=I.return;de!==null;){var Re=de.tag;if((Re===3||Re===4)&&(Re=de.stateNode.containerInfo,Re===W||Re.nodeType===8&&Re.parentNode===W))return;de=de.return}for(;ke!==null;){if(de=Vo(ke),de===null)return;if(Re=de.tag,Re===5||Re===6){I=Z=de;continue e}ke=ke.parentNode}}I=I.return}Os(function(){var Xe=Z,ft=pn(A),ht=[];e:{var dt=Rb.get(p);if(dt!==void 0){var jt=it,Rt=p;switch(p){case"keypress":if(Ie(A)===0)break e;case"keydown":case"keyup":jt=jf;break;case"focusin":Rt="focus",jt=pr;break;case"focusout":Rt="blur",jt=pr;break;case"beforeblur":case"afterblur":jt=pr;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":jt=rr;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":jt=Lt;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":jt=xi;break;case Pm:case Rm:case Mm:jt=ni;break;case Im:jt=wi;break;case"scroll":jt=$t;break;case"wheel":jt=Ef;break;case"copy":case"cut":case"paste":jt=Nl;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":jt=Wo}var It=(v&4)!==0,Hr=!It&&p==="scroll",Ge=It?dt!==null?dt+"Capture":null:dt;It=[];for(var Be=Xe,Ye;Be!==null;){Ye=Be;var gt=Ye.stateNode;if(Ye.tag===5&&gt!==null&&(Ye=gt,Ge!==null&&(gt=ei(Be,Ge),gt!=null&&It.push(zc(Be,gt,Ye)))),Hr)break;Be=Be.return}0<It.length&&(dt=new jt(dt,Rt,null,A,ft),ht.push({event:dt,listeners:It}))}}if((v&7)===0){e:{if(dt=p==="mouseover"||p==="pointerover",jt=p==="mouseout"||p==="pointerout",dt&&A!==hi&&(Rt=A.relatedTarget||A.fromElement)&&(Vo(Rt)||Rt[fa]))break e;if((jt||dt)&&(dt=ft.window===ft?ft:(dt=ft.ownerDocument)?dt.defaultView||dt.parentWindow:window,jt?(Rt=A.relatedTarget||A.toElement,jt=Xe,Rt=Rt?Vo(Rt):null,Rt!==null&&(Hr=Ct(Rt),Rt!==Hr||Rt.tag!==5&&Rt.tag!==6)&&(Rt=null)):(jt=null,Rt=Xe),jt!==Rt)){if(It=rr,gt="onMouseLeave",Ge="onMouseEnter",Be="mouse",(p==="pointerout"||p==="pointerover")&&(It=Wo,gt="onPointerLeave",Ge="onPointerEnter",Be="pointer"),Hr=jt==null?dt:Rl(jt),Ye=Rt==null?dt:Rl(Rt),dt=new It(gt,Be+"leave",jt,A,ft),dt.target=Hr,dt.relatedTarget=Ye,gt=null,Vo(ft)===Xe&&(It=new It(Ge,Be+"enter",Rt,A,ft),It.target=Ye,It.relatedTarget=Hr,gt=It),Hr=gt,jt&&Rt)t:{for(It=jt,Ge=Rt,Be=0,Ye=It;Ye;Ye=Ol(Ye))Be++;for(Ye=0,gt=Ge;gt;gt=Ol(gt))Ye++;for(;0<Be-Ye;)It=Ol(It),Be--;for(;0<Ye-Be;)Ge=Ol(Ge),Ye--;for(;Be--;){if(It===Ge||Ge!==null&&It===Ge.alternate)break t;It=Ol(It),Ge=Ol(Ge)}It=null}else It=null;jt!==null&&Um(ht,dt,jt,It,!1),Rt!==null&&Hr!==null&&Um(ht,Hr,Rt,It,!0)}}e:{if(dt=Xe?Rl(Xe):window,jt=dt.nodeName&&dt.nodeName.toLowerCase(),jt==="select"||jt==="input"&&dt.type==="file")var Ut=Eb;else if(zs(dt))if(Cm)Ut=Nb;else{Ut=Ab;var Qt=Tb}else(jt=dt.nodeName)&&jt.toLowerCase()==="input"&&(dt.type==="checkbox"||dt.type==="radio")&&(Ut=$b);if(Ut&&(Ut=Ut(p,Xe))){km(ht,Ut,A,ft);break e}Qt&&Qt(p,dt,Xe),p==="focusout"&&(Qt=dt._wrapperState)&&Qt.controlled&&dt.type==="number"&&Kt(dt,"number",dt.value)}switch(Qt=Xe?Rl(Xe):window,p){case"focusin":(zs(Qt)||Qt.contentEditable==="true")&&(Ic=Qt,Rf=Xe,Ho=null);break;case"focusout":Ho=Rf=Ic=null;break;case"mousedown":Mf=!0;break;case"contextmenu":case"mouseup":case"dragend":Mf=!1,Nm(ht,A,ft);break;case"selectionchange":if($m)break;case"keydown":case"keyup":Nm(ht,A,ft)}var er;if(ys)e:{switch(p){case"compositionstart":var ar="onCompositionStart";break e;case"compositionend":ar="onCompositionEnd";break e;case"compositionupdate":ar="onCompositionUpdate";break e}ar=void 0}else _i?Vu(p,A)&&(ar="onCompositionEnd"):p==="keydown"&&A.keyCode===229&&(ar="onCompositionStart");ar&&(tn&&A.locale!=="ko"&&(_i||ar!=="onCompositionStart"?ar==="onCompositionEnd"&&_i&&(er=We()):(we=ft,Pe="value"in we?we.value:we.textContent,_i=!0)),Qt=Yu(Xe,ar),0<Qt.length&&(ar=new Nc(ar,p,null,A,ft),ht.push({event:ar,listeners:Qt}),er?ar.data=er:(er=kb(A),er!==null&&(ar.data=er)))),(er=Sn?Cb(p,A):Tf(p,A))&&(Xe=Yu(Xe,"onBeforeInput"),0<Xe.length&&(ft=new Nc("onBeforeInput","beforeinput",null,A,ft),ht.push({event:ft,listeners:Xe}),ft.data=er))}zm(ht,v)})}function zc(p,v,A){return{instance:p,listener:v,currentTarget:A}}function Yu(p,v){for(var A=v+"Capture",I=[];p!==null;){var W=p,Z=W.stateNode;W.tag===5&&Z!==null&&(W=Z,Z=ei(p,A),Z!=null&&I.unshift(zc(p,Z,W)),Z=ei(p,v),Z!=null&&I.push(zc(p,Z,W))),p=p.return}return I}function Ol(p){if(p===null)return null;do p=p.return;while(p&&p.tag!==5);return p||null}function Um(p,v,A,I,W){for(var Z=v._reactName,de=[];A!==null&&A!==I;){var ke=A,Re=ke.alternate,Xe=ke.stateNode;if(Re!==null&&Re===I)break;ke.tag===5&&Xe!==null&&(ke=Xe,W?(Re=ei(A,Z),Re!=null&&de.unshift(zc(A,Re,ke))):W||(Re=ei(A,Z),Re!=null&&de.push(zc(A,Re,ke)))),A=A.return}de.length!==0&&p.push({event:v,listeners:de})}var Ju=/\r\n?/g,Db=/\u0000|\uFFFD/g;function Zu(p){return(typeof p=="string"?p:""+p).replace(Ju,`
39
39
  `).replace(Db,"")}function Qu(p,v,A){if(v=Zu(v),Zu(p)!==v&&A)throw Error(n(425))}function ed(){}var zf=null,Ff=null;function Uf(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 qf=typeof setTimeout=="function"?setTimeout:void 0,Lb=typeof clearTimeout=="function"?clearTimeout:void 0,qm=typeof Promise=="function"?Promise:void 0,Bb=typeof queueMicrotask=="function"?queueMicrotask:typeof qm<"u"?function(p){return qm.resolve(null).then(p).catch(zb)}:qf;function zb(p){setTimeout(function(){throw p})}function Wf(p,v){var A=v,I=0;do{var W=A.nextSibling;if(p.removeChild(A),W&&W.nodeType===8)if(A=W.data,A==="/$"){if(I===0){p.removeChild(W),$a(v);return}I--}else A!=="$"&&A!=="$?"&&A!=="$!"||I++;A=W}while(A);$a(v)}function fo(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 Wm(p){p=p.previousSibling;for(var v=0;p;){if(p.nodeType===8){var A=p.data;if(A==="$"||A==="$!"||A==="$?"){if(v===0)return p;v--}else A==="/$"&&v++}p=p.previousSibling}return null}var Pl=Math.random().toString(36).slice(2),da="__reactFiber$"+Pl,Fc="__reactProps$"+Pl,fa="__reactContainer$"+Pl,Hf="__reactEvents$"+Pl,Hm="__reactListeners$"+Pl,Vm="__reactHandles$"+Pl;function Vo(p){var v=p[da];if(v)return v;for(var A=p.parentNode;A;){if(v=A[fa]||A[da]){if(A=v.alternate,v.child!==null||A!==null&&A.child!==null)for(p=Wm(p);p!==null;){if(A=p[da])return A;p=Wm(p)}return v}p=A,A=p.parentNode}return null}function Uc(p){return p=p[da]||p[fa],!p||p.tag!==5&&p.tag!==6&&p.tag!==13&&p.tag!==3?null:p}function Rl(p){if(p.tag===5||p.tag===6)return p.stateNode;throw Error(n(33))}function td(p){return p[Fc]||null}var Vf=[],Ml=-1;function Oa(p){return{current:p}}function Xr(p){0>Ml||(p.current=Vf[Ml],Vf[Ml]=null,Ml--)}function Wr(p,v){Ml++,Vf[Ml]=p.current,p.current=v}var ho={},Si=Oa(ho),zi=Oa(!1),Go=ho;function ki(p,v){var A=p.type.contextTypes;if(!A)return ho;var I=p.stateNode;if(I&&I.__reactInternalMemoizedUnmaskedChildContext===v)return I.__reactInternalMemoizedMaskedChildContext;var W={},Z;for(Z in A)W[Z]=v[Z];return I&&(p=p.stateNode,p.__reactInternalMemoizedUnmaskedChildContext=v,p.__reactInternalMemoizedMaskedChildContext=W),W}function Fi(p){return p=p.childContextTypes,p!=null}function rd(){Xr(zi),Xr(Si)}function Gm(p,v,A){if(Si.current!==ho)throw Error(n(168));Wr(Si,v),Wr(zi,A)}function Km(p,v,A){var I=p.stateNode;if(v=v.childContextTypes,typeof I.getChildContext!="function")return A;I=I.getChildContext();for(var W in I)if(!(W in v))throw Error(n(108,xe(p)||"Unknown",W));return Q({},A,I)}function nd(p){return p=(p=p.stateNode)&&p.__reactInternalMemoizedMergedChildContext||ho,Go=Si.current,Wr(Si,p),Wr(zi,zi.current),!0}function Xm(p,v,A){var I=p.stateNode;if(!I)throw Error(n(169));A?(p=Km(p,v,Go),I.__reactInternalMemoizedMergedChildContext=p,Xr(zi),Xr(Si),Wr(Si,p)):Xr(zi),Wr(zi,A)}var Pa=null,id=!1,Gf=!1;function Ym(p){Pa===null?Pa=[p]:Pa.push(p)}function a1(p){id=!0,Ym(p)}function po(){if(!Gf&&Pa!==null){Gf=!0;var p=0,v=ze;try{var A=Pa;for(ze=1;p<A.length;p++){var I=A[p];do I=I(!0);while(I!==null)}Pa=null,id=!1}catch(W){throw Pa!==null&&(Pa=Pa.slice(p+1)),Uo(sn,po),W}finally{ze=v,Gf=!1}}return null}var Il=[],Dl=0,sd=null,ad=0,xs=[],qs=0,ws=null,Ui=1,qi="";function mo(p,v){Il[Dl++]=ad,Il[Dl++]=sd,sd=p,ad=v}function Ko(p,v,A){xs[qs++]=Ui,xs[qs++]=qi,xs[qs++]=ws,ws=p;var I=Ui;p=qi;var W=32-an(I)-1;I&=~(1<<W),A+=1;var Z=32-an(v)+W;if(30<Z){var de=W-W%5;Z=(I&(1<<de)-1).toString(32),I>>=de,W-=de,Ui=1<<32-an(v)+W|A<<W|I,qi=Z+p}else Ui=1<<Z|A<<W|I,qi=p}function Tn(p){p.return!==null&&(mo(p,1),Ko(p,1,0))}function Kf(p){for(;p===sd;)sd=Il[--Dl],Il[Dl]=null,ad=Il[--Dl],Il[Dl]=null;for(;p===ws;)ws=xs[--qs],xs[qs]=null,qi=xs[--qs],xs[qs]=null,Ui=xs[--qs],xs[qs]=null}var Wi=null,ss=null,on=!1,Hi=null;function Xf(p,v){var A=os(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 Yf(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,ss=fo(v.firstChild),!0):!1;case 6:return v=p.pendingProps===""||v.nodeType!==3?null:v,v!==null?(p.stateNode=v,Wi=p,ss=null,!0):!1;case 13:return v=v.nodeType!==8?null:v,v!==null?(A=ws!==null?{id:Ui,overflow:qi}:null,p.memoizedState={dehydrated:v,treeContext:A,retryLane:1073741824},A=os(18,null,null,0),A.stateNode=v,A.return=p,p.child=A,Wi=p,ss=null,!0):!1;default:return!1}}function Jf(p){return(p.mode&1)!==0&&(p.flags&128)===0}function Zf(p){if(on){var v=ss;if(v){var A=v;if(!Yf(p,v)){if(Jf(p))throw Error(n(418));v=fo(A.nextSibling);var I=Wi;v&&Yf(p,v)?Xf(I,A):(p.flags=p.flags&-4097|2,on=!1,Wi=p)}}else{if(Jf(p))throw Error(n(418));p.flags=p.flags&-4097|2,on=!1,Wi=p}}}function Qf(p){for(p=p.return;p!==null&&p.tag!==5&&p.tag!==3&&p.tag!==13;)p=p.return;Wi=p}function qc(p){if(p!==Wi)return!1;if(!on)return Qf(p),on=!0,!1;var v;if((v=p.tag!==3)&&!(v=p.tag!==5)&&(v=p.type,v=v!=="head"&&v!=="body"&&!Uf(p.type,p.memoizedProps)),v&&(v=ss)){if(Jf(p))throw Jm(),Error(n(418));for(;v;)Xf(p,v),v=fo(v.nextSibling)}if(Qf(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){ss=fo(p.nextSibling);break e}v--}else A!=="$"&&A!=="$!"&&A!=="$?"||v++}p=p.nextSibling}ss=null}}else ss=Wi?fo(p.stateNode.nextSibling):null;return!0}function Jm(){for(var p=ss;p;)p=fo(p.nextSibling)}function Xo(){ss=Wi=null,on=!1}function eh(p){Hi===null?Hi=[p]:Hi.push(p)}var th=E.ReactCurrentBatchConfig;function Ll(p,v,A){if(p=A.ref,p!==null&&typeof p!="function"&&typeof p!="object"){if(A._owner){if(A=A._owner,A){if(A.tag!==1)throw Error(n(309));var I=A.stateNode}if(!I)throw Error(n(147,p));var W=I,Z=""+p;return v!==null&&v.ref!==null&&typeof v.ref=="function"&&v.ref._stringRef===Z?v.ref:(v=function(de){var ke=W.refs;de===null?delete ke[Z]:ke[Z]=de},v._stringRef=Z,v)}if(typeof p!="string")throw Error(n(284));if(!A._owner)throw Error(n(290,p))}return p}function od(p,v){throw p=Object.prototype.toString.call(v),Error(n(31,p==="[object Object]"?"object with keys {"+Object.keys(v).join(", ")+"}":p))}function Zm(p){var v=p._init;return v(p._payload)}function Fb(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 I(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 W(Ge,Be){return Ge=So(Ge,Be),Ge.index=0,Ge.sibling=null,Ge}function Z(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 de(Ge){return p&&Ge.alternate===null&&(Ge.flags|=2),Ge}function ke(Ge,Be,Ye,gt){return Be===null||Be.tag!==6?(Be=Zh(Ye,Ge.mode,gt),Be.return=Ge,Be):(Be=W(Be,Ye),Be.return=Ge,Be)}function Re(Ge,Be,Ye,gt){var Ut=Ye.type;return Ut===N?ft(Ge,Be,Ye.props.children,gt,Ye.key):Be!==null&&(Be.elementType===Ut||typeof Ut=="object"&&Ut!==null&&Ut.$$typeof===te&&Zm(Ut)===Be.type)?(gt=W(Be,Ye.props),gt.ref=Ll(Ge,Be,Ye),gt.return=Ge,gt):(gt=Ad(Ye.type,Ye.key,Ye.props,null,Ge.mode,gt),gt.ref=Ll(Ge,Be,Ye),gt.return=Ge,gt)}function Xe(Ge,Be,Ye,gt){return Be===null||Be.tag!==4||Be.stateNode.containerInfo!==Ye.containerInfo||Be.stateNode.implementation!==Ye.implementation?(Be=Qh(Ye,Ge.mode,gt),Be.return=Ge,Be):(Be=W(Be,Ye.children||[]),Be.return=Ge,Be)}function ft(Ge,Be,Ye,gt,Ut){return Be===null||Be.tag!==7?(Be=Kl(Ye,Ge.mode,gt,Ut),Be.return=Ge,Be):(Be=W(Be,Ye),Be.return=Ge,Be)}function ht(Ge,Be,Ye){if(typeof Be=="string"&&Be!==""||typeof Be=="number")return Be=Zh(""+Be,Ge.mode,Ye),Be.return=Ge,Be;if(typeof Be=="object"&&Be!==null){switch(Be.$$typeof){case T:return Ye=Ad(Be.type,Be.key,Be.props,null,Ge.mode,Ye),Ye.ref=Ll(Ge,null,Be),Ye.return=Ge,Ye;case $:return Be=Qh(Be,Ge.mode,Ye),Be.return=Ge,Be;case te:var gt=Be._init;return ht(Ge,gt(Be._payload),Ye)}if(sr(Be)||X(Be))return Be=Kl(Be,Ge.mode,Ye,null),Be.return=Ge,Be;od(Ge,Be)}return null}function dt(Ge,Be,Ye,gt){var Ut=Be!==null?Be.key:null;if(typeof Ye=="string"&&Ye!==""||typeof Ye=="number")return Ut!==null?null:ke(Ge,Be,""+Ye,gt);if(typeof Ye=="object"&&Ye!==null){switch(Ye.$$typeof){case T:return Ye.key===Ut?Re(Ge,Be,Ye,gt):null;case $:return Ye.key===Ut?Xe(Ge,Be,Ye,gt):null;case te:return Ut=Ye._init,dt(Ge,Be,Ut(Ye._payload),gt)}if(sr(Ye)||X(Ye))return Ut!==null?null:ft(Ge,Be,Ye,gt,null);od(Ge,Ye)}return null}function jt(Ge,Be,Ye,gt,Ut){if(typeof gt=="string"&&gt!==""||typeof gt=="number")return Ge=Ge.get(Ye)||null,ke(Be,Ge,""+gt,Ut);if(typeof gt=="object"&&gt!==null){switch(gt.$$typeof){case T:return Ge=Ge.get(gt.key===null?Ye:gt.key)||null,Re(Be,Ge,gt,Ut);case $:return Ge=Ge.get(gt.key===null?Ye:gt.key)||null,Xe(Be,Ge,gt,Ut);case te:var Qt=gt._init;return jt(Ge,Be,Ye,Qt(gt._payload),Ut)}if(sr(gt)||X(gt))return Ge=Ge.get(Ye)||null,ft(Be,Ge,gt,Ut,null);od(Be,gt)}return null}function Rt(Ge,Be,Ye,gt){for(var Ut=null,Qt=null,er=Be,ar=Be=0,zn=null;er!==null&&ar<Ye.length;ar++){er.index>ar?(zn=er,er=null):zn=er.sibling;var kr=dt(Ge,er,Ye[ar],gt);if(kr===null){er===null&&(er=zn);break}p&&er&&kr.alternate===null&&v(Ge,er),Be=Z(kr,Be,ar),Qt===null?Ut=kr:Qt.sibling=kr,Qt=kr,er=zn}if(ar===Ye.length)return A(Ge,er),on&&mo(Ge,ar),Ut;if(er===null){for(;ar<Ye.length;ar++)er=ht(Ge,Ye[ar],gt),er!==null&&(Be=Z(er,Be,ar),Qt===null?Ut=er:Qt.sibling=er,Qt=er);return on&&mo(Ge,ar),Ut}for(er=I(Ge,er);ar<Ye.length;ar++)zn=jt(er,Ge,ar,Ye[ar],gt),zn!==null&&(p&&zn.alternate!==null&&er.delete(zn.key===null?ar:zn.key),Be=Z(zn,Be,ar),Qt===null?Ut=zn:Qt.sibling=zn,Qt=zn);return p&&er.forEach(function(La){return v(Ge,La)}),on&&mo(Ge,ar),Ut}function It(Ge,Be,Ye,gt){var Ut=X(Ye);if(typeof Ut!="function")throw Error(n(150));if(Ye=Ut.call(Ye),Ye==null)throw Error(n(151));for(var Qt=Ut=null,er=Be,ar=Be=0,zn=null,kr=Ye.next();er!==null&&!kr.done;ar++,kr=Ye.next()){er.index>ar?(zn=er,er=null):zn=er.sibling;var La=dt(Ge,er,kr.value,gt);if(La===null){er===null&&(er=zn);break}p&&er&&La.alternate===null&&v(Ge,er),Be=Z(La,Be,ar),Qt===null?Ut=La:Qt.sibling=La,Qt=La,er=zn}if(kr.done)return A(Ge,er),on&&mo(Ge,ar),Ut;if(er===null){for(;!kr.done;ar++,kr=Ye.next())kr=ht(Ge,kr.value,gt),kr!==null&&(Be=Z(kr,Be,ar),Qt===null?Ut=kr:Qt.sibling=kr,Qt=kr);return on&&mo(Ge,ar),Ut}for(er=I(Ge,er);!kr.done;ar++,kr=Ye.next())kr=jt(er,Ge,ar,kr.value,gt),kr!==null&&(p&&kr.alternate!==null&&er.delete(kr.key===null?ar:kr.key),Be=Z(kr,Be,ar),Qt===null?Ut=kr:Qt.sibling=kr,Qt=kr);return p&&er.forEach(function(xx){return v(Ge,xx)}),on&&mo(Ge,ar),Ut}function Hr(Ge,Be,Ye,gt){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 T:e:{for(var Ut=Ye.key,Qt=Be;Qt!==null;){if(Qt.key===Ut){if(Ut=Ye.type,Ut===N){if(Qt.tag===7){A(Ge,Qt.sibling),Be=W(Qt,Ye.props.children),Be.return=Ge,Ge=Be;break e}}else if(Qt.elementType===Ut||typeof Ut=="object"&&Ut!==null&&Ut.$$typeof===te&&Zm(Ut)===Qt.type){A(Ge,Qt.sibling),Be=W(Qt,Ye.props),Be.ref=Ll(Ge,Qt,Ye),Be.return=Ge,Ge=Be;break e}A(Ge,Qt);break}else v(Ge,Qt);Qt=Qt.sibling}Ye.type===N?(Be=Kl(Ye.props.children,Ge.mode,gt,Ye.key),Be.return=Ge,Ge=Be):(gt=Ad(Ye.type,Ye.key,Ye.props,null,Ge.mode,gt),gt.ref=Ll(Ge,Be,Ye),gt.return=Ge,Ge=gt)}return de(Ge);case $:e:{for(Qt=Ye.key;Be!==null;){if(Be.key===Qt)if(Be.tag===4&&Be.stateNode.containerInfo===Ye.containerInfo&&Be.stateNode.implementation===Ye.implementation){A(Ge,Be.sibling),Be=W(Be,Ye.children||[]),Be.return=Ge,Ge=Be;break e}else{A(Ge,Be);break}else v(Ge,Be);Be=Be.sibling}Be=Qh(Ye,Ge.mode,gt),Be.return=Ge,Ge=Be}return de(Ge);case te:return Qt=Ye._init,Hr(Ge,Be,Qt(Ye._payload),gt)}if(sr(Ye))return Rt(Ge,Be,Ye,gt);if(X(Ye))return It(Ge,Be,Ye,gt);od(Ge,Ye)}return typeof Ye=="string"&&Ye!==""||typeof Ye=="number"?(Ye=""+Ye,Be!==null&&Be.tag===6?(A(Ge,Be.sibling),Be=W(Be,Ye),Be.return=Ge,Ge=Be):(A(Ge,Be),Be=Zh(Ye,Ge.mode,gt),Be.return=Ge,Ge=Be),de(Ge)):A(Ge,Be)}return Hr}var Bl=Fb(!0),rh=Fb(!1),Yo=Oa(null),ld=null,Jo=null,nh=null;function ih(){nh=Jo=ld=null}function sh(p){var v=Yo.current;Xr(Yo),p._currentValue=v}function Qm(p,v,A){for(;p!==null;){var I=p.alternate;if((p.childLanes&v)!==v?(p.childLanes|=v,I!==null&&(I.childLanes|=v)):I!==null&&(I.childLanes&v)!==v&&(I.childLanes|=v),p===A)break;p=p.return}}function zl(p,v){ld=p,nh=Jo=null,p=p.dependencies,p!==null&&p.firstContext!==null&&((p.lanes&v)!==0&&(Vi=!0),p.firstContext=null)}function _s(p){var v=p._currentValue;if(nh!==p)if(p={context:p,memoizedValue:v,next:null},Jo===null){if(ld===null)throw Error(n(308));Jo=p,ld.dependencies={lanes:0,firstContext:p}}else Jo=Jo.next=p;return v}var Fl=null;function ah(p){Fl===null?Fl=[p]:Fl.push(p)}function cd(p,v,A,I){var W=v.interleaved;return W===null?(A.next=A,ah(v)):(A.next=W.next,W.next=A),v.interleaved=A,Ra(p,I)}function Ra(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 ha=!1;function ud(p){p.updateQueue={baseState:p.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function oh(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 Ma(p,v){return{eventTime:p,lane:v,tag:0,payload:null,callback:null,next:null}}function go(p,v,A){var I=p.updateQueue;if(I===null)return null;if(I=I.shared,(br&2)!==0){var W=I.pending;return W===null?v.next=v:(v.next=W.next,W.next=v),I.pending=v,Ra(p,A)}return W=I.interleaved,W===null?(v.next=v,ah(I)):(v.next=W.next,W.next=v),I.interleaved=v,Ra(p,A)}function Wc(p,v,A){if(v=v.updateQueue,v!==null&&(v=v.shared,(A&4194240)!==0)){var I=v.lanes;I&=p.pendingLanes,A|=I,v.lanes=A,Se(p,A)}}function Ub(p,v){var A=p.updateQueue,I=p.alternate;if(I!==null&&(I=I.updateQueue,A===I)){var W=null,Z=null;if(A=A.firstBaseUpdate,A!==null){do{var de={eventTime:A.eventTime,lane:A.lane,tag:A.tag,payload:A.payload,callback:A.callback,next:null};Z===null?W=Z=de:Z=Z.next=de,A=A.next}while(A!==null);Z===null?W=Z=v:Z=Z.next=v}else W=Z=v;A={baseState:I.baseState,firstBaseUpdate:W,lastBaseUpdate:Z,shared:I.shared,effects:I.effects},p.updateQueue=A;return}p=A.lastBaseUpdate,p===null?A.firstBaseUpdate=v:p.next=v,A.lastBaseUpdate=v}function dd(p,v,A,I){var W=p.updateQueue;ha=!1;var Z=W.firstBaseUpdate,de=W.lastBaseUpdate,ke=W.shared.pending;if(ke!==null){W.shared.pending=null;var Re=ke,Xe=Re.next;Re.next=null,de===null?Z=Xe:de.next=Xe,de=Re;var ft=p.alternate;ft!==null&&(ft=ft.updateQueue,ke=ft.lastBaseUpdate,ke!==de&&(ke===null?ft.firstBaseUpdate=Xe:ke.next=Xe,ft.lastBaseUpdate=Re))}if(Z!==null){var ht=W.baseState;de=0,ft=Xe=Re=null,ke=Z;do{var dt=ke.lane,jt=ke.eventTime;if((I&dt)===dt){ft!==null&&(ft=ft.next={eventTime:jt,lane:0,tag:ke.tag,payload:ke.payload,callback:ke.callback,next:null});e:{var Rt=p,It=ke;switch(dt=v,jt=A,It.tag){case 1:if(Rt=It.payload,typeof Rt=="function"){ht=Rt.call(jt,ht,dt);break e}ht=Rt;break e;case 3:Rt.flags=Rt.flags&-65537|128;case 0:if(Rt=It.payload,dt=typeof Rt=="function"?Rt.call(jt,ht,dt):Rt,dt==null)break e;ht=Q({},ht,dt);break e;case 2:ha=!0}}ke.callback!==null&&ke.lane!==0&&(p.flags|=64,dt=W.effects,dt===null?W.effects=[ke]:dt.push(ke))}else jt={eventTime:jt,lane:dt,tag:ke.tag,payload:ke.payload,callback:ke.callback,next:null},ft===null?(Xe=ft=jt,Re=ht):ft=ft.next=jt,de|=dt;if(ke=ke.next,ke===null){if(ke=W.shared.pending,ke===null)break;dt=ke,ke=dt.next,dt.next=null,W.lastBaseUpdate=dt,W.shared.pending=null}}while(!0);if(ft===null&&(Re=ht),W.baseState=Re,W.firstBaseUpdate=Xe,W.lastBaseUpdate=ft,v=W.shared.interleaved,v!==null){W=v;do de|=W.lane,W=W.next;while(W!==v)}else Z===null&&(W.shared.lanes=0);nl|=de,p.lanes=de,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 I=p[v],W=I.callback;if(W!==null){if(I.callback=null,I=A,typeof W!="function")throw Error(n(191,W));W.call(I)}}}var Hc={},pa=Oa(Hc),Vc=Oa(Hc),Ul=Oa(Hc);function Zo(p){if(p===Hc)throw Error(n(174));return p}function lh(p,v){switch(Wr(Ul,v),Wr(Vc,p),Wr(pa,Hc),p=v.nodeType,p){case 9:case 11:v=(v=v.documentElement)?v.namespaceURI:Zn(null,"");break;default:p=p===8?v.parentNode:v,v=p.namespaceURI||null,p=p.tagName,v=Zn(v,p)}Xr(pa),Wr(pa,v)}function Qo(){Xr(pa),Xr(Vc),Xr(Ul)}function eg(p){Zo(Ul.current);var v=Zo(pa.current),A=Zn(v,p.type);v!==A&&(Wr(Vc,p),Wr(pa,A))}function ch(p){Vc.current===p&&(Xr(pa),Xr(Vc))}var un=Oa(0);function fd(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 uh=[];function dh(){for(var p=0;p<uh.length;p++)uh[p]._workInProgressVersionPrimary=null;uh.length=0}var fh=E.ReactCurrentDispatcher,hh=E.ReactCurrentBatchConfig,el=0,ln=null,An=null,Ln=null,ph=!1,tl=!1,vo=0,tg=0;function ii(){throw Error(n(321))}function mh(p,v){if(v===null)return!1;for(var A=0;A<v.length&&A<p.length;A++)if(!Us(p[A],v[A]))return!1;return!0}function gh(p,v,A,I,W,Z){if(el=Z,ln=v,v.memoizedState=null,v.updateQueue=null,v.lanes=0,fh.current=p===null||p.memoizedState===null?Xb:Yb,p=A(I,W),tl){Z=0;do{if(tl=!1,vo=0,25<=Z)throw Error(n(301));Z+=1,Ln=An=null,v.updateQueue=null,fh.current=l1,p=A(I,W)}while(tl)}if(fh.current=gd,v=An!==null&&An.next!==null,el=0,Ln=An=ln=null,ph=!1,v)throw Error(n(300));return p}function vh(){var p=vo!==0;return vo=0,p}function Ws(){var p={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ln===null?ln.memoizedState=Ln=p:Ln=Ln.next=p,Ln}function Ss(){if(An===null){var p=ln.alternate;p=p!==null?p.memoizedState:null}else p=An.next;var v=Ln===null?ln.memoizedState:Ln.next;if(v!==null)Ln=v,An=p;else{if(p===null)throw Error(n(310));An=p,p={memoizedState:An.memoizedState,baseState:An.baseState,baseQueue:An.baseQueue,queue:An.queue,next:null},Ln===null?ln.memoizedState=Ln=p:Ln=Ln.next=p}return Ln}function Gc(p,v){return typeof v=="function"?v(p):v}function yh(p){var v=Ss(),A=v.queue;if(A===null)throw Error(n(311));A.lastRenderedReducer=p;var I=An,W=I.baseQueue,Z=A.pending;if(Z!==null){if(W!==null){var de=W.next;W.next=Z.next,Z.next=de}I.baseQueue=W=Z,A.pending=null}if(W!==null){Z=W.next,I=I.baseState;var ke=de=null,Re=null,Xe=Z;do{var ft=Xe.lane;if((el&ft)===ft)Re!==null&&(Re=Re.next={lane:0,action:Xe.action,hasEagerState:Xe.hasEagerState,eagerState:Xe.eagerState,next:null}),I=Xe.hasEagerState?Xe.eagerState:p(I,Xe.action);else{var ht={lane:ft,action:Xe.action,hasEagerState:Xe.hasEagerState,eagerState:Xe.eagerState,next:null};Re===null?(ke=Re=ht,de=I):Re=Re.next=ht,ln.lanes|=ft,nl|=ft}Xe=Xe.next}while(Xe!==null&&Xe!==Z);Re===null?de=I:Re.next=ke,Us(I,v.memoizedState)||(Vi=!0),v.memoizedState=I,v.baseState=de,v.baseQueue=Re,A.lastRenderedState=I}if(p=A.interleaved,p!==null){W=p;do Z=W.lane,ln.lanes|=Z,nl|=Z,W=W.next;while(W!==p)}else W===null&&(A.lanes=0);return[v.memoizedState,A.dispatch]}function rg(p){var v=Ss(),A=v.queue;if(A===null)throw Error(n(311));A.lastRenderedReducer=p;var I=A.dispatch,W=A.pending,Z=v.memoizedState;if(W!==null){A.pending=null;var de=W=W.next;do Z=p(Z,de.action),de=de.next;while(de!==W);Us(Z,v.memoizedState)||(Vi=!0),v.memoizedState=Z,v.baseQueue===null&&(v.baseState=Z),A.lastRenderedState=Z}return[Z,I]}function ng(){}function bh(p,v){var A=ln,I=Ss(),W=v(),Z=!Us(I.memoizedState,W);if(Z&&(I.memoizedState=W,Vi=!0),I=I.queue,dg(ag.bind(null,A,I,p),[p]),I.getSnapshot!==v||Z||Ln!==null&&Ln.memoizedState.tag&1){if(A.flags|=2048,hd(9,sg.bind(null,A,I,W,v),void 0,null),Nn===null)throw Error(n(349));(el&30)!==0||ig(A,v,W)}return W}function ig(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 sg(p,v,A,I){v.value=A,v.getSnapshot=I,Wb(v)&&og(p)}function ag(p,v,A){return A(function(){Wb(v)&&og(p)})}function Wb(p){var v=p.getSnapshot;p=p.value;try{var A=v();return!Us(p,A)}catch{return!0}}function og(p){var v=Ra(p,1);v!==null&&Gs(v,p,1,-1)}function lg(p){var v=Ws();return typeof p=="function"&&(p=p()),v.memoizedState=v.baseState=p,p={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Gc,lastRenderedState:p},v.queue=p,p=p.dispatch=Gb.bind(null,ln,p),[v.memoizedState,p]}function hd(p,v,A,I){return p={tag:p,create:v,destroy:A,deps:I,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:(I=A.next,A.next=p,p.next=I,v.lastEffect=p)),p}function cg(){return Ss().memoizedState}function pd(p,v,A,I){var W=Ws();ln.flags|=p,W.memoizedState=hd(1|v,A,void 0,I===void 0?null:I)}function md(p,v,A,I){var W=Ss();I=I===void 0?null:I;var Z=void 0;if(An!==null){var de=An.memoizedState;if(Z=de.destroy,I!==null&&mh(I,de.deps)){W.memoizedState=hd(v,A,Z,I);return}}ln.flags|=p,W.memoizedState=hd(1|v,A,Z,I)}function ug(p,v){return pd(8390656,8,p,v)}function dg(p,v){return md(2048,8,p,v)}function fg(p,v){return md(4,2,p,v)}function hg(p,v){return md(4,4,p,v)}function pg(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 Hb(p,v,A){return A=A!=null?A.concat([p]):null,md(4,4,pg.bind(null,v,p),A)}function xh(){}function mg(p,v){var A=Ss();v=v===void 0?null:v;var I=A.memoizedState;return I!==null&&v!==null&&mh(v,I[1])?I[0]:(A.memoizedState=[p,v],p)}function gg(p,v){var A=Ss();v=v===void 0?null:v;var I=A.memoizedState;return I!==null&&v!==null&&mh(v,I[1])?I[0]:(p=p(),A.memoizedState=[p,v],p)}function vg(p,v,A){return(el&21)===0?(p.baseState&&(p.baseState=!1,Vi=!0),p.memoizedState=A):(Us(A,v)||(A=is(),ln.lanes|=A,nl|=A,p.baseState=!0),v)}function o1(p,v){var A=ze;ze=A!==0&&4>A?A:4,p(!0);var I=hh.transition;hh.transition={};try{p(!1),v()}finally{ze=A,hh.transition=I}}function yg(){return Ss().memoizedState}function Vb(p,v,A){var I=wo(p);if(A={lane:I,action:A,hasEagerState:!1,eagerState:null,next:null},bg(p))Kb(v,A);else if(A=cd(p,v,A,I),A!==null){var W=ji();Gs(A,p,I,W),xg(A,v,I)}}function Gb(p,v,A){var I=wo(p),W={lane:I,action:A,hasEagerState:!1,eagerState:null,next:null};if(bg(p))Kb(v,W);else{var Z=p.alternate;if(p.lanes===0&&(Z===null||Z.lanes===0)&&(Z=v.lastRenderedReducer,Z!==null))try{var de=v.lastRenderedState,ke=Z(de,A);if(W.hasEagerState=!0,W.eagerState=ke,Us(ke,de)){var Re=v.interleaved;Re===null?(W.next=W,ah(v)):(W.next=Re.next,Re.next=W),v.interleaved=W;return}}catch{}finally{}A=cd(p,v,W,I),A!==null&&(W=ji(),Gs(A,p,I,W),xg(A,v,I))}}function bg(p){var v=p.alternate;return p===ln||v!==null&&v===ln}function Kb(p,v){tl=ph=!0;var A=p.pending;A===null?v.next=v:(v.next=A.next,A.next=v),p.pending=v}function xg(p,v,A){if((A&4194240)!==0){var I=v.lanes;I&=p.pendingLanes,A|=I,v.lanes=A,Se(p,A)}}var gd={readContext:_s,useCallback:ii,useContext:ii,useEffect:ii,useImperativeHandle:ii,useInsertionEffect:ii,useLayoutEffect:ii,useMemo:ii,useReducer:ii,useRef:ii,useState:ii,useDebugValue:ii,useDeferredValue:ii,useTransition:ii,useMutableSource:ii,useSyncExternalStore:ii,useId:ii,unstable_isNewReconciler:!1},Xb={readContext:_s,useCallback:function(p,v){return Ws().memoizedState=[p,v===void 0?null:v],p},useContext:_s,useEffect:ug,useImperativeHandle:function(p,v,A){return A=A!=null?A.concat([p]):null,pd(4194308,4,pg.bind(null,v,p),A)},useLayoutEffect:function(p,v){return pd(4194308,4,p,v)},useInsertionEffect:function(p,v){return pd(4,2,p,v)},useMemo:function(p,v){var A=Ws();return v=v===void 0?null:v,p=p(),A.memoizedState=[p,v],p},useReducer:function(p,v,A){var I=Ws();return v=A!==void 0?A(v):v,I.memoizedState=I.baseState=v,p={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:p,lastRenderedState:v},I.queue=p,p=p.dispatch=Vb.bind(null,ln,p),[I.memoizedState,p]},useRef:function(p){var v=Ws();return p={current:p},v.memoizedState=p},useState:lg,useDebugValue:xh,useDeferredValue:function(p){return Ws().memoizedState=p},useTransition:function(){var p=lg(!1),v=p[0];return p=o1.bind(null,p[1]),Ws().memoizedState=p,[v,p]},useMutableSource:function(){},useSyncExternalStore:function(p,v,A){var I=ln,W=Ws();if(on){if(A===void 0)throw Error(n(407));A=A()}else{if(A=v(),Nn===null)throw Error(n(349));(el&30)!==0||ig(I,v,A)}W.memoizedState=A;var Z={value:A,getSnapshot:v};return W.queue=Z,ug(ag.bind(null,I,Z,p),[p]),I.flags|=2048,hd(9,sg.bind(null,I,Z,A,v),void 0,null),A},useId:function(){var p=Ws(),v=Nn.identifierPrefix;if(on){var A=qi,I=Ui;A=(I&~(1<<32-an(I)-1)).toString(32)+A,v=":"+v+"R"+A,A=vo++,0<A&&(v+="H"+A.toString(32)),v+=":"}else A=tg++,v=":"+v+"r"+A.toString(32)+":";return p.memoizedState=v},unstable_isNewReconciler:!1},Yb={readContext:_s,useCallback:mg,useContext:_s,useEffect:dg,useImperativeHandle:Hb,useInsertionEffect:fg,useLayoutEffect:hg,useMemo:gg,useReducer:yh,useRef:cg,useState:function(){return yh(Gc)},useDebugValue:xh,useDeferredValue:function(p){var v=Ss();return vg(v,An.memoizedState,p)},useTransition:function(){var p=yh(Gc)[0],v=Ss().memoizedState;return[p,v]},useMutableSource:ng,useSyncExternalStore:bh,useId:yg,unstable_isNewReconciler:!1},l1={readContext:_s,useCallback:mg,useContext:_s,useEffect:dg,useImperativeHandle:Hb,useInsertionEffect:fg,useLayoutEffect:hg,useMemo:gg,useReducer:rg,useRef:cg,useState:function(){return rg(Gc)},useDebugValue:xh,useDeferredValue:function(p){var v=Ss();return An===null?v.memoizedState=p:vg(v,An.memoizedState,p)},useTransition:function(){var p=rg(Gc)[0],v=Ss().memoizedState;return[p,v]},useMutableSource:ng,useSyncExternalStore:bh,useId:yg,unstable_isNewReconciler:!1};function $n(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 ma(p,v,A,I){v=p.memoizedState,A=A(I,v),A=A==null?v:Q({},v,A),p.memoizedState=A,p.lanes===0&&(p.updateQueue.baseState=A)}var Ia={isMounted:function(p){return(p=p._reactInternals)?Ct(p)===p:!1},enqueueSetState:function(p,v,A){p=p._reactInternals;var I=ji(),W=wo(p),Z=Ma(I,W);Z.payload=v,A!=null&&(Z.callback=A),v=go(p,Z,W),v!==null&&(Gs(v,p,W,I),Wc(v,p,W))},enqueueReplaceState:function(p,v,A){p=p._reactInternals;var I=ji(),W=wo(p),Z=Ma(I,W);Z.tag=1,Z.payload=v,A!=null&&(Z.callback=A),v=go(p,Z,W),v!==null&&(Gs(v,p,W,I),Wc(v,p,W))},enqueueForceUpdate:function(p,v){p=p._reactInternals;var A=ji(),I=wo(p),W=Ma(A,I);W.tag=2,v!=null&&(W.callback=v),v=go(p,W,I),v!==null&&(Gs(v,p,I,A),Wc(v,p,I))}};function rl(p,v,A,I,W,Z,de){return p=p.stateNode,typeof p.shouldComponentUpdate=="function"?p.shouldComponentUpdate(I,Z,de):v.prototype&&v.prototype.isPureReactComponent?!Mc(A,I)||!Mc(W,Z):!0}function wg(p,v,A){var I=!1,W=ho,Z=v.contextType;return typeof Z=="object"&&Z!==null?Z=_s(Z):(W=Fi(v)?Go:Si.current,I=v.contextTypes,Z=(I=I!=null)?ki(p,W):ho),v=new v(A,Z),p.memoizedState=v.state!==null&&v.state!==void 0?v.state:null,v.updater=Ia,p.stateNode=v,v._reactInternals=p,I&&(p=p.stateNode,p.__reactInternalMemoizedUnmaskedChildContext=W,p.__reactInternalMemoizedMaskedChildContext=Z),v}function _g(p,v,A,I){p=v.state,typeof v.componentWillReceiveProps=="function"&&v.componentWillReceiveProps(A,I),typeof v.UNSAFE_componentWillReceiveProps=="function"&&v.UNSAFE_componentWillReceiveProps(A,I),v.state!==p&&Ia.enqueueReplaceState(v,v.state,null)}function wh(p,v,A,I){var W=p.stateNode;W.props=A,W.state=p.memoizedState,W.refs={},ud(p);var Z=v.contextType;typeof Z=="object"&&Z!==null?W.context=_s(Z):(Z=Fi(v)?Go:Si.current,W.context=ki(p,Z)),W.state=p.memoizedState,Z=v.getDerivedStateFromProps,typeof Z=="function"&&(ma(p,v,Z,A),W.state=p.memoizedState),typeof v.getDerivedStateFromProps=="function"||typeof W.getSnapshotBeforeUpdate=="function"||typeof W.UNSAFE_componentWillMount!="function"&&typeof W.componentWillMount!="function"||(v=W.state,typeof W.componentWillMount=="function"&&W.componentWillMount(),typeof W.UNSAFE_componentWillMount=="function"&&W.UNSAFE_componentWillMount(),v!==W.state&&Ia.enqueueReplaceState(W,W.state,null),dd(p,A,W,I),W.state=p.memoizedState),typeof W.componentDidMount=="function"&&(p.flags|=4194308)}function ql(p,v){try{var A="",I=v;do A+=_e(I),I=I.return;while(I);var W=A}catch(Z){W=`
40
40
  Error generating stack: `+Z.message+`
41
- `+Z.stack}return{value:p,source:v,stack:W,digest:null}}function _h(p,v,A){return{value:p,source:null,stack:A??null,digest:v??null}}function Sh(p,v){try{console.error(v.value)}catch(A){setTimeout(function(){throw A})}}var Jb=typeof WeakMap=="function"?WeakMap:Map;function Sg(p,v,A){A=Ma(-1,A),A.tag=3,A.payload={element:null};var I=v.value;return A.callback=function(){kd||(kd=!0,Wh=I),Sh(p,v)},A}function kg(p,v,A){A=Ma(-1,A),A.tag=3;var I=p.type.getDerivedStateFromError;if(typeof I=="function"){var W=v.value;A.payload=function(){return I(W)},A.callback=function(){Sh(p,v)}}var Z=p.stateNode;return Z!==null&&typeof Z.componentDidCatch=="function"&&(A.callback=function(){Sh(p,v),typeof I!="function"&&(xo===null?xo=new Set([this]):xo.add(this));var de=v.stack;this.componentDidCatch(v.value,{componentStack:de!==null?de:""})}),A}function Cg(p,v,A){var I=p.pingCache;if(I===null){I=p.pingCache=new Jb;var W=new Set;I.set(v,W)}else W=I.get(v),W===void 0&&(W=new Set,I.set(v,W));W.has(A)||(W.add(A),p=cx.bind(null,p,v,A),v.then(p,p))}function Zb(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 Ci(p,v,A,I,W){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=Ma(-1,1),v.tag=2,go(A,v,1))),A.lanes|=1),p):(p.flags|=65536,p.lanes=W,p)}var Qb=E.ReactCurrentOwner,Vi=!1;function si(p,v,A,I){v.child=p===null?rh(v,null,A,I):Bl(v,p.child,A,I)}function jg(p,v,A,I,W){A=A.render;var Z=v.ref;return zl(v,W),I=gh(p,v,A,I,Z,W),A=vh(),p!==null&&!Vi?(v.updateQueue=p.updateQueue,v.flags&=-2053,p.lanes&=~W,Da(p,v,W)):(on&&A&&Tn(v),v.flags|=1,si(p,v,I,W),v.child)}function Kc(p,v,A,I,W){if(p===null){var Z=A.type;return typeof Z=="function"&&!Jh(Z)&&Z.defaultProps===void 0&&A.compare===null&&A.defaultProps===void 0?(v.tag=15,v.type=Z,Eg(p,v,Z,I,W)):(p=Ad(A.type,null,I,v,v.mode,W),p.ref=v.ref,p.return=v,v.child=p)}if(Z=p.child,(p.lanes&W)===0){var de=Z.memoizedProps;if(A=A.compare,A=A!==null?A:Mc,A(de,I)&&p.ref===v.ref)return Da(p,v,W)}return v.flags|=1,p=So(Z,I),p.ref=v.ref,p.return=v,v.child=p}function Eg(p,v,A,I,W){if(p!==null){var Z=p.memoizedProps;if(Mc(Z,I)&&p.ref===v.ref)if(Vi=!1,v.pendingProps=I=Z,(p.lanes&W)!==0)(p.flags&131072)!==0&&(Vi=!0);else return v.lanes=p.lanes,Da(p,v,W)}return kh(p,v,A,I,W)}function Tg(p,v,A){var I=v.pendingProps,W=I.children,Z=p!==null?p.memoizedState:null;if(I.mode==="hidden")if((v.mode&1)===0)v.memoizedState={baseLanes:0,cachePool:null,transitions:null},Wr(Hl,as),as|=A;else{if((A&1073741824)===0)return p=Z!==null?Z.baseLanes|A:A,v.lanes=v.childLanes=1073741824,v.memoizedState={baseLanes:p,cachePool:null,transitions:null},v.updateQueue=null,Wr(Hl,as),as|=p,null;v.memoizedState={baseLanes:0,cachePool:null,transitions:null},I=Z!==null?Z.baseLanes:A,Wr(Hl,as),as|=I}else Z!==null?(I=Z.baseLanes|A,v.memoizedState=null):I=A,Wr(Hl,as),as|=I;return si(p,v,W,A),v.child}function Ag(p,v){var A=v.ref;(p===null&&A!==null||p!==null&&p.ref!==A)&&(v.flags|=512,v.flags|=2097152)}function kh(p,v,A,I,W){var Z=Fi(A)?Go:Si.current;return Z=ki(v,Z),zl(v,W),A=gh(p,v,A,I,Z,W),I=vh(),p!==null&&!Vi?(v.updateQueue=p.updateQueue,v.flags&=-2053,p.lanes&=~W,Da(p,v,W)):(on&&I&&Tn(v),v.flags|=1,si(p,v,A,W),v.child)}function $g(p,v,A,I,W){if(Fi(A)){var Z=!0;nd(v)}else Z=!1;if(zl(v,W),v.stateNode===null)yd(p,v),wg(v,A,I),wh(v,A,I,W),I=!0;else if(p===null){var de=v.stateNode,ke=v.memoizedProps;de.props=ke;var Re=de.context,Xe=A.contextType;typeof Xe=="object"&&Xe!==null?Xe=_s(Xe):(Xe=Fi(A)?Go:Si.current,Xe=ki(v,Xe));var ft=A.getDerivedStateFromProps,ht=typeof ft=="function"||typeof de.getSnapshotBeforeUpdate=="function";ht||typeof de.UNSAFE_componentWillReceiveProps!="function"&&typeof de.componentWillReceiveProps!="function"||(ke!==I||Re!==Xe)&&_g(v,de,I,Xe),ha=!1;var dt=v.memoizedState;de.state=dt,dd(v,I,de,W),Re=v.memoizedState,ke!==I||dt!==Re||zi.current||ha?(typeof ft=="function"&&(ma(v,A,ft,I),Re=v.memoizedState),(ke=ha||rl(v,A,ke,I,dt,Re,Xe))?(ht||typeof de.UNSAFE_componentWillMount!="function"&&typeof de.componentWillMount!="function"||(typeof de.componentWillMount=="function"&&de.componentWillMount(),typeof de.UNSAFE_componentWillMount=="function"&&de.UNSAFE_componentWillMount()),typeof de.componentDidMount=="function"&&(v.flags|=4194308)):(typeof de.componentDidMount=="function"&&(v.flags|=4194308),v.memoizedProps=I,v.memoizedState=Re),de.props=I,de.state=Re,de.context=Xe,I=ke):(typeof de.componentDidMount=="function"&&(v.flags|=4194308),I=!1)}else{de=v.stateNode,oh(p,v),ke=v.memoizedProps,Xe=v.type===v.elementType?ke:$n(v.type,ke),de.props=Xe,ht=v.pendingProps,dt=de.context,Re=A.contextType,typeof Re=="object"&&Re!==null?Re=_s(Re):(Re=Fi(A)?Go:Si.current,Re=ki(v,Re));var jt=A.getDerivedStateFromProps;(ft=typeof jt=="function"||typeof de.getSnapshotBeforeUpdate=="function")||typeof de.UNSAFE_componentWillReceiveProps!="function"&&typeof de.componentWillReceiveProps!="function"||(ke!==ht||dt!==Re)&&_g(v,de,I,Re),ha=!1,dt=v.memoizedState,de.state=dt,dd(v,I,de,W);var Rt=v.memoizedState;ke!==ht||dt!==Rt||zi.current||ha?(typeof jt=="function"&&(ma(v,A,jt,I),Rt=v.memoizedState),(Xe=ha||rl(v,A,Xe,I,dt,Rt,Re)||!1)?(ft||typeof de.UNSAFE_componentWillUpdate!="function"&&typeof de.componentWillUpdate!="function"||(typeof de.componentWillUpdate=="function"&&de.componentWillUpdate(I,Rt,Re),typeof de.UNSAFE_componentWillUpdate=="function"&&de.UNSAFE_componentWillUpdate(I,Rt,Re)),typeof de.componentDidUpdate=="function"&&(v.flags|=4),typeof de.getSnapshotBeforeUpdate=="function"&&(v.flags|=1024)):(typeof de.componentDidUpdate!="function"||ke===p.memoizedProps&&dt===p.memoizedState||(v.flags|=4),typeof de.getSnapshotBeforeUpdate!="function"||ke===p.memoizedProps&&dt===p.memoizedState||(v.flags|=1024),v.memoizedProps=I,v.memoizedState=Rt),de.props=I,de.state=Rt,de.context=Re,I=Xe):(typeof de.componentDidUpdate!="function"||ke===p.memoizedProps&&dt===p.memoizedState||(v.flags|=4),typeof de.getSnapshotBeforeUpdate!="function"||ke===p.memoizedProps&&dt===p.memoizedState||(v.flags|=1024),I=!1)}return Ch(p,v,A,I,Z,W)}function Ch(p,v,A,I,W,Z){Ag(p,v);var de=(v.flags&128)!==0;if(!I&&!de)return W&&Xm(v,A,!1),Da(p,v,Z);I=v.stateNode,Qb.current=v;var ke=de&&typeof A.getDerivedStateFromError!="function"?null:I.render();return v.flags|=1,p!==null&&de?(v.child=Bl(v,p.child,null,Z),v.child=Bl(v,null,ke,Z)):si(p,v,ke,Z),v.memoizedState=I.state,W&&Xm(v,A,!0),v.child}function jh(p){var v=p.stateNode;v.pendingContext?Gm(p,v.pendingContext,v.pendingContext!==v.context):v.context&&Gm(p,v.context,!1),lh(p,v.containerInfo)}function Ng(p,v,A,I,W){return Xo(),eh(W),v.flags|=256,si(p,v,A,I),v.child}var Eh={dehydrated:null,treeContext:null,retryLane:0};function Th(p){return{baseLanes:p,cachePool:null,transitions:null}}function Og(p,v,A){var I=v.pendingProps,W=un.current,Z=!1,de=(v.flags&128)!==0,ke;if((ke=de)||(ke=p!==null&&p.memoizedState===null?!1:(W&2)!==0),ke?(Z=!0,v.flags&=-129):(p===null||p.memoizedState!==null)&&(W|=1),Wr(un,W&1),p===null)return Zf(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):(de=I.children,p=I.fallback,Z?(I=v.mode,Z=v.child,de={mode:"hidden",children:de},(I&1)===0&&Z!==null?(Z.childLanes=0,Z.pendingProps=de):Z=$d(de,I,0,null),p=Kl(p,I,A,null),Z.return=v,p.return=v,Z.sibling=p,v.child=Z,v.child.memoizedState=Th(A),v.memoizedState=Eh,p):Xc(v,de));if(W=p.memoizedState,W!==null&&(ke=W.dehydrated,ke!==null))return ex(p,v,de,I,ke,W,A);if(Z){Z=I.fallback,de=v.mode,W=p.child,ke=W.sibling;var Re={mode:"hidden",children:I.children};return(de&1)===0&&v.child!==W?(I=v.child,I.childLanes=0,I.pendingProps=Re,v.deletions=null):(I=So(W,Re),I.subtreeFlags=W.subtreeFlags&14680064),ke!==null?Z=So(ke,Z):(Z=Kl(Z,de,A,null),Z.flags|=2),Z.return=v,I.return=v,I.sibling=Z,v.child=I,I=Z,Z=v.child,de=p.child.memoizedState,de=de===null?Th(A):{baseLanes:de.baseLanes|A,cachePool:null,transitions:de.transitions},Z.memoizedState=de,Z.childLanes=p.childLanes&~A,v.memoizedState=Eh,I}return Z=p.child,p=Z.sibling,I=So(Z,{mode:"visible",children:I.children}),(v.mode&1)===0&&(I.lanes=A),I.return=v,I.sibling=null,p!==null&&(A=v.deletions,A===null?(v.deletions=[p],v.flags|=16):A.push(p)),v.child=I,v.memoizedState=null,I}function Xc(p,v){return v=$d({mode:"visible",children:v},p.mode,0,null),v.return=p,p.child=v}function vd(p,v,A,I){return I!==null&&eh(I),Bl(v,p.child,null,A),p=Xc(v,v.pendingProps.children),p.flags|=2,v.memoizedState=null,p}function ex(p,v,A,I,W,Z,de){if(A)return v.flags&256?(v.flags&=-257,I=_h(Error(n(422))),vd(p,v,de,I)):v.memoizedState!==null?(v.child=p.child,v.flags|=128,null):(Z=I.fallback,W=v.mode,I=$d({mode:"visible",children:I.children},W,0,null),Z=Kl(Z,W,de,null),Z.flags|=2,I.return=v,Z.return=v,I.sibling=Z,v.child=I,(v.mode&1)!==0&&Bl(v,p.child,null,de),v.child.memoizedState=Th(de),v.memoizedState=Eh,Z);if((v.mode&1)===0)return vd(p,v,de,null);if(W.data==="$!"){if(I=W.nextSibling&&W.nextSibling.dataset,I)var ke=I.dgst;return I=ke,Z=Error(n(419)),I=_h(Z,I,void 0),vd(p,v,de,I)}if(ke=(de&p.childLanes)!==0,Vi||ke){if(I=Nn,I!==null){switch(de&-de){case 4:W=2;break;case 16:W=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:W=32;break;case 536870912:W=268435456;break;default:W=0}W=(W&(I.suspendedLanes|de))!==0?0:W,W!==0&&W!==Z.retryLane&&(Z.retryLane=W,Ra(p,W),Gs(I,p,W,-1))}return Yh(),I=_h(Error(n(421))),vd(p,v,de,I)}return W.data==="$?"?(v.flags|=128,v.child=p.child,v=dx.bind(null,p),W._reactRetry=v,null):(p=Z.treeContext,ss=fo(W.nextSibling),Wi=v,on=!0,Hi=null,p!==null&&(xs[qs++]=Ui,xs[qs++]=qi,xs[qs++]=ws,Ui=p.id,qi=p.overflow,ws=v),v=Xc(v,I.children),v.flags|=4096,v)}function Pg(p,v,A){p.lanes|=v;var I=p.alternate;I!==null&&(I.lanes|=v),Qm(p.return,v,A)}function Ah(p,v,A,I,W){var Z=p.memoizedState;Z===null?p.memoizedState={isBackwards:v,rendering:null,renderingStartTime:0,last:I,tail:A,tailMode:W}:(Z.isBackwards=v,Z.rendering=null,Z.renderingStartTime=0,Z.last=I,Z.tail=A,Z.tailMode=W)}function $h(p,v,A){var I=v.pendingProps,W=I.revealOrder,Z=I.tail;if(si(p,v,I.children,A),I=un.current,(I&2)!==0)I=I&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&&Pg(p,A,v);else if(p.tag===19)Pg(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}I&=1}if(Wr(un,I),(v.mode&1)===0)v.memoizedState=null;else switch(W){case"forwards":for(A=v.child,W=null;A!==null;)p=A.alternate,p!==null&&fd(p)===null&&(W=A),A=A.sibling;A=W,A===null?(W=v.child,v.child=null):(W=A.sibling,A.sibling=null),Ah(v,!1,W,A,Z);break;case"backwards":for(A=null,W=v.child,v.child=null;W!==null;){if(p=W.alternate,p!==null&&fd(p)===null){v.child=W;break}p=W.sibling,W.sibling=A,A=W,W=p}Ah(v,!0,A,null,Z);break;case"together":Ah(v,!1,null,null,void 0);break;default:v.memoizedState=null}return v.child}function yd(p,v){(v.mode&1)===0&&p!==null&&(p.alternate=null,v.alternate=null,v.flags|=2)}function Da(p,v,A){if(p!==null&&(v.dependencies=p.dependencies),nl|=v.lanes,(A&v.childLanes)===0)return null;if(p!==null&&v.child!==p.child)throw Error(n(153));if(v.child!==null){for(p=v.child,A=So(p,p.pendingProps),v.child=A,A.return=v;p.sibling!==null;)p=p.sibling,A=A.sibling=So(p,p.pendingProps),A.return=v;A.sibling=null}return v.child}function c1(p,v,A){switch(v.tag){case 3:jh(v),Xo();break;case 5:eg(v);break;case 1:Fi(v.type)&&nd(v);break;case 4:lh(v,v.stateNode.containerInfo);break;case 10:var I=v.type._context,W=v.memoizedProps.value;Wr(Yo,I._currentValue),I._currentValue=W;break;case 13:if(I=v.memoizedState,I!==null)return I.dehydrated!==null?(Wr(un,un.current&1),v.flags|=128,null):(A&v.child.childLanes)!==0?Og(p,v,A):(Wr(un,un.current&1),p=Da(p,v,A),p!==null?p.sibling:null);Wr(un,un.current&1);break;case 19:if(I=(A&v.childLanes)!==0,(p.flags&128)!==0){if(I)return $h(p,v,A);v.flags|=128}if(W=v.memoizedState,W!==null&&(W.rendering=null,W.tail=null,W.lastEffect=null),Wr(un,un.current),I)break;return null;case 22:case 23:return v.lanes=0,Tg(p,v,A)}return Da(p,v,A)}var Nh,Oh,Rg,Mg;Nh=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}},Oh=function(){},Rg=function(p,v,A,I){var W=p.memoizedProps;if(W!==I){p=v.stateNode,Zo(pa.current);var Z=null;switch(A){case"input":W=Le(p,W),I=Le(p,I),Z=[];break;case"select":W=Q({},W,{value:void 0}),I=Q({},I,{value:void 0}),Z=[];break;case"textarea":W=jr(p,W),I=jr(p,I),Z=[];break;default:typeof W.onClick!="function"&&typeof I.onClick=="function"&&(p.onclick=ed)}fs(A,I);var de;A=null;for(Xe in W)if(!I.hasOwnProperty(Xe)&&W.hasOwnProperty(Xe)&&W[Xe]!=null)if(Xe==="style"){var ke=W[Xe];for(de in ke)ke.hasOwnProperty(de)&&(A||(A={}),A[de]="")}else Xe!=="dangerouslySetInnerHTML"&&Xe!=="children"&&Xe!=="suppressContentEditableWarning"&&Xe!=="suppressHydrationWarning"&&Xe!=="autoFocus"&&(s.hasOwnProperty(Xe)?Z||(Z=[]):(Z=Z||[]).push(Xe,null));for(Xe in I){var Re=I[Xe];if(ke=W!=null?W[Xe]:void 0,I.hasOwnProperty(Xe)&&Re!==ke&&(Re!=null||ke!=null))if(Xe==="style")if(ke){for(de in ke)!ke.hasOwnProperty(de)||Re&&Re.hasOwnProperty(de)||(A||(A={}),A[de]="");for(de in Re)Re.hasOwnProperty(de)&&ke[de]!==Re[de]&&(A||(A={}),A[de]=Re[de])}else A||(Z||(Z=[]),Z.push(Xe,A)),A=Re;else Xe==="dangerouslySetInnerHTML"?(Re=Re?Re.__html:void 0,ke=ke?ke.__html:void 0,Re!=null&&ke!==Re&&(Z=Z||[]).push(Xe,Re)):Xe==="children"?typeof Re!="string"&&typeof Re!="number"||(Z=Z||[]).push(Xe,""+Re):Xe!=="suppressContentEditableWarning"&&Xe!=="suppressHydrationWarning"&&(s.hasOwnProperty(Xe)?(Re!=null&&Xe==="onScroll"&&Kr("scroll",p),Z||ke===Re||(Z=[])):(Z=Z||[]).push(Xe,Re))}A&&(Z=Z||[]).push("style",A);var Xe=Z;(v.updateQueue=Xe)&&(v.flags|=4)}},Mg=function(p,v,A,I){A!==I&&(v.flags|=4)};function bd(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 I=null;A!==null;)A.alternate!==null&&(I=A),A=A.sibling;I===null?v||p.tail===null?p.tail=null:p.tail.sibling=null:I.sibling=null}}function ai(p){var v=p.alternate!==null&&p.alternate.child===p.child,A=0,I=0;if(v)for(var W=p.child;W!==null;)A|=W.lanes|W.childLanes,I|=W.subtreeFlags&14680064,I|=W.flags&14680064,W.return=p,W=W.sibling;else for(W=p.child;W!==null;)A|=W.lanes|W.childLanes,I|=W.subtreeFlags,I|=W.flags,W.return=p,W=W.sibling;return p.subtreeFlags|=I,p.childLanes=A,v}function tx(p,v,A){var I=v.pendingProps;switch(Kf(v),v.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ai(v),null;case 1:return Fi(v.type)&&rd(),ai(v),null;case 3:return I=v.stateNode,Qo(),Xr(zi),Xr(Si),dh(),I.pendingContext&&(I.context=I.pendingContext,I.pendingContext=null),(p===null||p.child===null)&&(qc(v)?v.flags|=4:p===null||p.memoizedState.isDehydrated&&(v.flags&256)===0||(v.flags|=1024,Hi!==null&&(Gh(Hi),Hi=null))),Oh(p,v),ai(v),null;case 5:ch(v);var W=Zo(Ul.current);if(A=v.type,p!==null&&v.stateNode!=null)Rg(p,v,A,I,W),p.ref!==v.ref&&(v.flags|=512,v.flags|=2097152);else{if(!I){if(v.stateNode===null)throw Error(n(166));return ai(v),null}if(p=Zo(pa.current),qc(v)){I=v.stateNode,A=v.type;var Z=v.memoizedProps;switch(I[da]=v,I[Fc]=Z,p=(v.mode&1)!==0,A){case"dialog":Kr("cancel",I),Kr("close",I);break;case"iframe":case"object":case"embed":Kr("load",I);break;case"video":case"audio":for(W=0;W<Lc.length;W++)Kr(Lc[W],I);break;case"source":Kr("error",I);break;case"img":case"image":case"link":Kr("error",I),Kr("load",I);break;case"details":Kr("toggle",I);break;case"input":Ue(I,Z),Kr("invalid",I);break;case"select":I._wrapperState={wasMultiple:!!Z.multiple},Kr("invalid",I);break;case"textarea":fr(I,Z),Kr("invalid",I)}fs(A,Z),W=null;for(var de in Z)if(Z.hasOwnProperty(de)){var ke=Z[de];de==="children"?typeof ke=="string"?I.textContent!==ke&&(Z.suppressHydrationWarning!==!0&&Qu(I.textContent,ke,p),W=["children",ke]):typeof ke=="number"&&I.textContent!==""+ke&&(Z.suppressHydrationWarning!==!0&&Qu(I.textContent,ke,p),W=["children",""+ke]):s.hasOwnProperty(de)&&ke!=null&&de==="onScroll"&&Kr("scroll",I)}switch(A){case"input":Ae(I),Zt(I,Z,!0);break;case"textarea":Ae(I),Ir(I);break;case"select":case"option":break;default:typeof Z.onClick=="function"&&(I.onclick=ed)}I=W,v.updateQueue=I,I!==null&&(v.flags|=4)}else{de=W.nodeType===9?W:W.ownerDocument,p==="http://www.w3.org/1999/xhtml"&&(p=fi(A)),p==="http://www.w3.org/1999/xhtml"?A==="script"?(p=de.createElement("div"),p.innerHTML="<script><\/script>",p=p.removeChild(p.firstChild)):typeof I.is=="string"?p=de.createElement(A,{is:I.is}):(p=de.createElement(A),A==="select"&&(de=p,I.multiple?de.multiple=!0:I.size&&(de.size=I.size))):p=de.createElementNS(p,A),p[da]=v,p[Fc]=I,Nh(p,v,!1,!1),v.stateNode=p;e:{switch(de=Sr(A,I),A){case"dialog":Kr("cancel",p),Kr("close",p),W=I;break;case"iframe":case"object":case"embed":Kr("load",p),W=I;break;case"video":case"audio":for(W=0;W<Lc.length;W++)Kr(Lc[W],p);W=I;break;case"source":Kr("error",p),W=I;break;case"img":case"image":case"link":Kr("error",p),Kr("load",p),W=I;break;case"details":Kr("toggle",p),W=I;break;case"input":Ue(p,I),W=Le(p,I),Kr("invalid",p);break;case"option":W=I;break;case"select":p._wrapperState={wasMultiple:!!I.multiple},W=Q({},I,{value:void 0}),Kr("invalid",p);break;case"textarea":fr(p,I),W=jr(p,I),Kr("invalid",p);break;default:W=I}fs(A,W),ke=W;for(Z in ke)if(ke.hasOwnProperty(Z)){var Re=ke[Z];Z==="style"?xn(p,Re):Z==="dangerouslySetInnerHTML"?(Re=Re?Re.__html:void 0,Re!=null&&Rn(p,Re)):Z==="children"?typeof Re=="string"?(A!=="textarea"||Re!=="")&&ut(p,Re):typeof Re=="number"&&ut(p,""+Re):Z!=="suppressContentEditableWarning"&&Z!=="suppressHydrationWarning"&&Z!=="autoFocus"&&(s.hasOwnProperty(Z)?Re!=null&&Z==="onScroll"&&Kr("scroll",p):Re!=null&&C(p,Z,Re,de))}switch(A){case"input":Ae(p),Zt(p,I,!1);break;case"textarea":Ae(p),Ir(p);break;case"option":I.value!=null&&p.setAttribute("value",""+ie(I.value));break;case"select":p.multiple=!!I.multiple,Z=I.value,Z!=null?Vt(p,!!I.multiple,Z,!1):I.defaultValue!=null&&Vt(p,!!I.multiple,I.defaultValue,!0);break;default:typeof W.onClick=="function"&&(p.onclick=ed)}switch(A){case"button":case"input":case"select":case"textarea":I=!!I.autoFocus;break e;case"img":I=!0;break e;default:I=!1}}I&&(v.flags|=4)}v.ref!==null&&(v.flags|=512,v.flags|=2097152)}return ai(v),null;case 6:if(p&&v.stateNode!=null)Mg(p,v,p.memoizedProps,I);else{if(typeof I!="string"&&v.stateNode===null)throw Error(n(166));if(A=Zo(Ul.current),Zo(pa.current),qc(v)){if(I=v.stateNode,A=v.memoizedProps,I[da]=v,(Z=I.nodeValue!==A)&&(p=Wi,p!==null))switch(p.tag){case 3:Qu(I.nodeValue,A,(p.mode&1)!==0);break;case 5:p.memoizedProps.suppressHydrationWarning!==!0&&Qu(I.nodeValue,A,(p.mode&1)!==0)}Z&&(v.flags|=4)}else I=(A.nodeType===9?A:A.ownerDocument).createTextNode(I),I[da]=v,v.stateNode=I}return ai(v),null;case 13:if(Xr(un),I=v.memoizedState,p===null||p.memoizedState!==null&&p.memoizedState.dehydrated!==null){if(on&&ss!==null&&(v.mode&1)!==0&&(v.flags&128)===0)Jm(),Xo(),v.flags|=98560,Z=!1;else if(Z=qc(v),I!==null&&I.dehydrated!==null){if(p===null){if(!Z)throw Error(n(318));if(Z=v.memoizedState,Z=Z!==null?Z.dehydrated:null,!Z)throw Error(n(317));Z[da]=v}else Xo(),(v.flags&128)===0&&(v.memoizedState=null),v.flags|=4;ai(v),Z=!1}else Hi!==null&&(Gh(Hi),Hi=null),Z=!0;if(!Z)return v.flags&65536?v:null}return(v.flags&128)!==0?(v.lanes=A,v):(I=I!==null,I!==(p!==null&&p.memoizedState!==null)&&I&&(v.child.flags|=8192,(v.mode&1)!==0&&(p===null||(un.current&1)!==0?Bn===0&&(Bn=3):Yh())),v.updateQueue!==null&&(v.flags|=4),ai(v),null);case 4:return Qo(),Oh(p,v),p===null&&Bc(v.stateNode.containerInfo),ai(v),null;case 10:return sh(v.type._context),ai(v),null;case 17:return Fi(v.type)&&rd(),ai(v),null;case 19:if(Xr(un),Z=v.memoizedState,Z===null)return ai(v),null;if(I=(v.flags&128)!==0,de=Z.rendering,de===null)if(I)bd(Z,!1);else{if(Bn!==0||p!==null&&(p.flags&128)!==0)for(p=v.child;p!==null;){if(de=fd(p),de!==null){for(v.flags|=128,bd(Z,!1),I=de.updateQueue,I!==null&&(v.updateQueue=I,v.flags|=4),v.subtreeFlags=0,I=A,A=v.child;A!==null;)Z=A,p=I,Z.flags&=14680066,de=Z.alternate,de===null?(Z.childLanes=0,Z.lanes=p,Z.child=null,Z.subtreeFlags=0,Z.memoizedProps=null,Z.memoizedState=null,Z.updateQueue=null,Z.dependencies=null,Z.stateNode=null):(Z.childLanes=de.childLanes,Z.lanes=de.lanes,Z.child=de.child,Z.subtreeFlags=0,Z.deletions=null,Z.memoizedProps=de.memoizedProps,Z.memoizedState=de.memoizedState,Z.updateQueue=de.updateQueue,Z.type=de.type,p=de.dependencies,Z.dependencies=p===null?null:{lanes:p.lanes,firstContext:p.firstContext}),A=A.sibling;return Wr(un,un.current&1|2),v.child}p=p.sibling}Z.tail!==null&&Tr()>Vl&&(v.flags|=128,I=!0,bd(Z,!1),v.lanes=4194304)}else{if(!I)if(p=fd(de),p!==null){if(v.flags|=128,I=!0,A=p.updateQueue,A!==null&&(v.updateQueue=A,v.flags|=4),bd(Z,!0),Z.tail===null&&Z.tailMode==="hidden"&&!de.alternate&&!on)return ai(v),null}else 2*Tr()-Z.renderingStartTime>Vl&&A!==1073741824&&(v.flags|=128,I=!0,bd(Z,!1),v.lanes=4194304);Z.isBackwards?(de.sibling=v.child,v.child=de):(A=Z.last,A!==null?A.sibling=de:v.child=de,Z.last=de)}return Z.tail!==null?(v=Z.tail,Z.rendering=v,Z.tail=v.sibling,Z.renderingStartTime=Tr(),v.sibling=null,A=un.current,Wr(un,I?A&1|2:A&1),v):(ai(v),null);case 22:case 23:return Xh(),I=v.memoizedState!==null,p!==null&&p.memoizedState!==null!==I&&(v.flags|=8192),I&&(v.mode&1)!==0?(as&1073741824)!==0&&(ai(v),v.subtreeFlags&6&&(v.flags|=8192)):ai(v),null;case 24:return null;case 25:return null}throw Error(n(156,v.tag))}function rx(p,v){switch(Kf(v),v.tag){case 1:return Fi(v.type)&&rd(),p=v.flags,p&65536?(v.flags=p&-65537|128,v):null;case 3:return Qo(),Xr(zi),Xr(Si),dh(),p=v.flags,(p&65536)!==0&&(p&128)===0?(v.flags=p&-65537|128,v):null;case 5:return ch(v),null;case 13:if(Xr(un),p=v.memoizedState,p!==null&&p.dehydrated!==null){if(v.alternate===null)throw Error(n(340));Xo()}return p=v.flags,p&65536?(v.flags=p&-65537|128,v):null;case 19:return Xr(un),null;case 4:return Qo(),null;case 10:return sh(v.type._context),null;case 22:case 23:return Xh(),null;case 24:return null;default:return null}}var Ph=!1,oi=!1,nx=typeof WeakSet=="function"?WeakSet:Set,Pt=null;function Wl(p,v){var A=p.ref;if(A!==null)if(typeof A=="function")try{A(null)}catch(I){dn(p,v,I)}else A.current=null}function Rh(p,v,A){try{A()}catch(I){dn(p,v,I)}}var Ig=!1;function ix(p,v){if(zf=co,p=Of(),Pf(p)){if("selectionStart"in p)var A={start:p.selectionStart,end:p.selectionEnd};else e:{A=(A=p.ownerDocument)&&A.defaultView||window;var I=A.getSelection&&A.getSelection();if(I&&I.rangeCount!==0){A=I.anchorNode;var W=I.anchorOffset,Z=I.focusNode;I=I.focusOffset;try{A.nodeType,Z.nodeType}catch{A=null;break e}var de=0,ke=-1,Re=-1,Xe=0,ft=0,ht=p,dt=null;t:for(;;){for(var jt;ht!==A||W!==0&&ht.nodeType!==3||(ke=de+W),ht!==Z||I!==0&&ht.nodeType!==3||(Re=de+I),ht.nodeType===3&&(de+=ht.nodeValue.length),(jt=ht.firstChild)!==null;)dt=ht,ht=jt;for(;;){if(ht===p)break t;if(dt===A&&++Xe===W&&(ke=de),dt===Z&&++ft===I&&(Re=de),(jt=ht.nextSibling)!==null)break;ht=dt,dt=ht.parentNode}ht=jt}A=ke===-1||Re===-1?null:{start:ke,end:Re}}else A=null}A=A||{start:0,end:0}}else A=null;for(Ff={focusedElem:p,selectionRange:A},co=!1,Pt=v;Pt!==null;)if(v=Pt,p=v.child,(v.subtreeFlags&1028)!==0&&p!==null)p.return=v,Pt=p;else for(;Pt!==null;){v=Pt;try{var Rt=v.alternate;if((v.flags&1024)!==0)switch(v.tag){case 0:case 11:case 15:break;case 1:if(Rt!==null){var It=Rt.memoizedProps,Hr=Rt.memoizedState,Ge=v.stateNode,Be=Ge.getSnapshotBeforeUpdate(v.elementType===v.type?It:$n(v.type,It),Hr);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(gt){dn(v,v.return,gt)}if(p=v.sibling,p!==null){p.return=v.return,Pt=p;break}Pt=v.return}return Rt=Ig,Ig=!1,Rt}function Yc(p,v,A){var I=v.updateQueue;if(I=I!==null?I.lastEffect:null,I!==null){var W=I=I.next;do{if((W.tag&p)===p){var Z=W.destroy;W.destroy=void 0,Z!==void 0&&Rh(v,A,Z)}W=W.next}while(W!==I)}}function Mh(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 I=A.create;A.destroy=I()}A=A.next}while(A!==v)}}function Ih(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 Dg(p){var v=p.alternate;v!==null&&(p.alternate=null,Dg(v)),p.child=null,p.deletions=null,p.sibling=null,p.tag===5&&(v=p.stateNode,v!==null&&(delete v[da],delete v[Fc],delete v[Hf],delete v[Hm],delete v[Vm])),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 Lg(p){return p.tag===5||p.tag===3||p.tag===4}function Bg(p){e:for(;;){for(;p.sibling===null;){if(p.return===null||Lg(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 Dh(p,v,A){var I=p.tag;if(I===5||I===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=ed));else if(I!==4&&(p=p.child,p!==null))for(Dh(p,v,A),p=p.sibling;p!==null;)Dh(p,v,A),p=p.sibling}function Lh(p,v,A){var I=p.tag;if(I===5||I===6)p=p.stateNode,v?A.insertBefore(p,v):A.appendChild(p);else if(I!==4&&(p=p.child,p!==null))for(Lh(p,v,A),p=p.sibling;p!==null;)Lh(p,v,A),p=p.sibling}var Vn=null,Hs=!1;function yo(p,v,A){for(A=A.child;A!==null;)sx(p,v,A),A=A.sibling}function sx(p,v,A){if(Mn&&typeof Mn.onCommitFiberUnmount=="function")try{Mn.onCommitFiberUnmount(Di,A)}catch{}switch(A.tag){case 5:oi||Wl(A,v);case 6:var I=Vn,W=Hs;Vn=null,yo(p,v,A),Vn=I,Hs=W,Vn!==null&&(Hs?(p=Vn,A=A.stateNode,p.nodeType===8?p.parentNode.removeChild(A):p.removeChild(A)):Vn.removeChild(A.stateNode));break;case 18:Vn!==null&&(Hs?(p=Vn,A=A.stateNode,p.nodeType===8?Wf(p.parentNode,A):p.nodeType===1&&Wf(p,A),$a(p)):Wf(Vn,A.stateNode));break;case 4:I=Vn,W=Hs,Vn=A.stateNode.containerInfo,Hs=!0,yo(p,v,A),Vn=I,Hs=W;break;case 0:case 11:case 14:case 15:if(!oi&&(I=A.updateQueue,I!==null&&(I=I.lastEffect,I!==null))){W=I=I.next;do{var Z=W,de=Z.destroy;Z=Z.tag,de!==void 0&&((Z&2)!==0||(Z&4)!==0)&&Rh(A,v,de),W=W.next}while(W!==I)}yo(p,v,A);break;case 1:if(!oi&&(Wl(A,v),I=A.stateNode,typeof I.componentWillUnmount=="function"))try{I.props=A.memoizedProps,I.state=A.memoizedState,I.componentWillUnmount()}catch(ke){dn(A,v,ke)}yo(p,v,A);break;case 21:yo(p,v,A);break;case 22:A.mode&1?(oi=(I=oi)||A.memoizedState!==null,yo(p,v,A),oi=I):yo(p,v,A);break;default:yo(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 nx),v.forEach(function(I){var W=fx.bind(null,p,I);A.has(I)||(A.add(I),I.then(W,W))})}}function ks(p,v){var A=v.deletions;if(A!==null)for(var I=0;I<A.length;I++){var W=A[I];try{var Z=p,de=v,ke=de;e:for(;ke!==null;){switch(ke.tag){case 5:Vn=ke.stateNode,Hs=!1;break e;case 3:Vn=ke.stateNode.containerInfo,Hs=!0;break e;case 4:Vn=ke.stateNode.containerInfo,Hs=!0;break e}ke=ke.return}if(Vn===null)throw Error(n(160));sx(Z,de,W),Vn=null,Hs=!1;var Re=W.alternate;Re!==null&&(Re.return=null),W.return=null}catch(Xe){dn(W,v,Xe)}}if(v.subtreeFlags&12854)for(v=v.child;v!==null;)Bh(v,p),v=v.sibling}function Bh(p,v){var A=p.alternate,I=p.flags;switch(p.tag){case 0:case 11:case 14:case 15:if(ks(v,p),Vs(p),I&4){try{Yc(3,p,p.return),Mh(3,p)}catch(It){dn(p,p.return,It)}try{Yc(5,p,p.return)}catch(It){dn(p,p.return,It)}}break;case 1:ks(v,p),Vs(p),I&512&&A!==null&&Wl(A,A.return);break;case 5:if(ks(v,p),Vs(p),I&512&&A!==null&&Wl(A,A.return),p.flags&32){var W=p.stateNode;try{ut(W,"")}catch(It){dn(p,p.return,It)}}if(I&4&&(W=p.stateNode,W!=null)){var Z=p.memoizedProps,de=A!==null?A.memoizedProps:Z,ke=p.type,Re=p.updateQueue;if(p.updateQueue=null,Re!==null)try{ke==="input"&&Z.type==="radio"&&Z.name!=null&&st(W,Z),Sr(ke,de);var Xe=Sr(ke,Z);for(de=0;de<Re.length;de+=2){var ft=Re[de],ht=Re[de+1];ft==="style"?xn(W,ht):ft==="dangerouslySetInnerHTML"?Rn(W,ht):ft==="children"?ut(W,ht):C(W,ft,ht,Xe)}switch(ke){case"input":lt(W,Z);break;case"textarea":Ur(W,Z);break;case"select":var dt=W._wrapperState.wasMultiple;W._wrapperState.wasMultiple=!!Z.multiple;var jt=Z.value;jt!=null?Vt(W,!!Z.multiple,jt,!1):dt!==!!Z.multiple&&(Z.defaultValue!=null?Vt(W,!!Z.multiple,Z.defaultValue,!0):Vt(W,!!Z.multiple,Z.multiple?[]:"",!1))}W[Fc]=Z}catch(It){dn(p,p.return,It)}}break;case 6:if(ks(v,p),Vs(p),I&4){if(p.stateNode===null)throw Error(n(162));W=p.stateNode,Z=p.memoizedProps;try{W.nodeValue=Z}catch(It){dn(p,p.return,It)}}break;case 3:if(ks(v,p),Vs(p),I&4&&A!==null&&A.memoizedState.isDehydrated)try{$a(v.containerInfo)}catch(It){dn(p,p.return,It)}break;case 4:ks(v,p),Vs(p);break;case 13:ks(v,p),Vs(p),W=p.child,W.flags&8192&&(Z=W.memoizedState!==null,W.stateNode.isHidden=Z,!Z||W.alternate!==null&&W.alternate.memoizedState!==null||(qh=Tr())),I&4&&Jc(p);break;case 22:if(ft=A!==null&&A.memoizedState!==null,p.mode&1?(oi=(Xe=oi)||ft,ks(v,p),oi=Xe):ks(v,p),Vs(p),I&8192){if(Xe=p.memoizedState!==null,(p.stateNode.isHidden=Xe)&&!ft&&(p.mode&1)!==0)for(Pt=p,ft=p.child;ft!==null;){for(ht=Pt=ft;Pt!==null;){switch(dt=Pt,jt=dt.child,dt.tag){case 0:case 11:case 14:case 15:Yc(4,dt,dt.return);break;case 1:Wl(dt,dt.return);var Rt=dt.stateNode;if(typeof Rt.componentWillUnmount=="function"){I=dt,A=dt.return;try{v=I,Rt.props=v.memoizedProps,Rt.state=v.memoizedState,Rt.componentWillUnmount()}catch(It){dn(I,A,It)}}break;case 5:Wl(dt,dt.return);break;case 22:if(dt.memoizedState!==null){zh(ht);continue}}jt!==null?(jt.return=dt,Pt=jt):zh(ht)}ft=ft.sibling}e:for(ft=null,ht=p;;){if(ht.tag===5){if(ft===null){ft=ht;try{W=ht.stateNode,Xe?(Z=W.style,typeof Z.setProperty=="function"?Z.setProperty("display","none","important"):Z.display="none"):(ke=ht.stateNode,Re=ht.memoizedProps.style,de=Re!=null&&Re.hasOwnProperty("display")?Re.display:null,ke.style.display=_r("display",de))}catch(It){dn(p,p.return,It)}}}else if(ht.tag===6){if(ft===null)try{ht.stateNode.nodeValue=Xe?"":ht.memoizedProps}catch(It){dn(p,p.return,It)}}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:ks(v,p),Vs(p),I&4&&Jc(p);break;case 21:break;default:ks(v,p),Vs(p)}}function Vs(p){var v=p.flags;if(v&2){try{e:{for(var A=p.return;A!==null;){if(Lg(A)){var I=A;break e}A=A.return}throw Error(n(160))}switch(I.tag){case 5:var W=I.stateNode;I.flags&32&&(ut(W,""),I.flags&=-33);var Z=Bg(p);Lh(p,Z,W);break;case 3:case 4:var de=I.stateNode.containerInfo,ke=Bg(p);Dh(p,ke,de);break;default:throw Error(n(161))}}catch(Re){dn(p,p.return,Re)}p.flags&=-3}v&4096&&(p.flags&=-4097)}function zg(p,v,A){Pt=p,Fg(p)}function Fg(p,v,A){for(var I=(p.mode&1)!==0;Pt!==null;){var W=Pt,Z=W.child;if(W.tag===22&&I){var de=W.memoizedState!==null||Ph;if(!de){var ke=W.alternate,Re=ke!==null&&ke.memoizedState!==null||oi;ke=Ph;var Xe=oi;if(Ph=de,(oi=Re)&&!Xe)for(Pt=W;Pt!==null;)de=Pt,Re=de.child,de.tag===22&&de.memoizedState!==null?Fh(W):Re!==null?(Re.return=de,Pt=Re):Fh(W);for(;Z!==null;)Pt=Z,Fg(Z),Z=Z.sibling;Pt=W,Ph=ke,oi=Xe}Ug(p)}else(W.subtreeFlags&8772)!==0&&Z!==null?(Z.return=W,Pt=Z):Ug(p)}}function Ug(p){for(;Pt!==null;){var v=Pt;if((v.flags&8772)!==0){var A=v.alternate;try{if((v.flags&8772)!==0)switch(v.tag){case 0:case 11:case 15:oi||Mh(5,v);break;case 1:var I=v.stateNode;if(v.flags&4&&!oi)if(A===null)I.componentDidMount();else{var W=v.elementType===v.type?A.memoizedProps:$n(v.type,A.memoizedProps);I.componentDidUpdate(W,A.memoizedState,I.__reactInternalSnapshotBeforeUpdate)}var Z=v.updateQueue;Z!==null&&qb(v,Z,I);break;case 3:var de=v.updateQueue;if(de!==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,de,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&&$a(ht)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}oi||v.flags&512&&Ih(v)}catch(dt){dn(v,v.return,dt)}}if(v===p){Pt=null;break}if(A=v.sibling,A!==null){A.return=v.return,Pt=A;break}Pt=v.return}}function zh(p){for(;Pt!==null;){var v=Pt;if(v===p){Pt=null;break}var A=v.sibling;if(A!==null){A.return=v.return,Pt=A;break}Pt=v.return}}function Fh(p){for(;Pt!==null;){var v=Pt;try{switch(v.tag){case 0:case 11:case 15:var A=v.return;try{Mh(4,v)}catch(Re){dn(v,A,Re)}break;case 1:var I=v.stateNode;if(typeof I.componentDidMount=="function"){var W=v.return;try{I.componentDidMount()}catch(Re){dn(v,W,Re)}}var Z=v.return;try{Ih(v)}catch(Re){dn(v,Z,Re)}break;case 5:var de=v.return;try{Ih(v)}catch(Re){dn(v,de,Re)}}}catch(Re){dn(v,v.return,Re)}if(v===p){Pt=null;break}var ke=v.sibling;if(ke!==null){ke.return=v.return,Pt=ke;break}Pt=v.return}}var ax=Math.ceil,xd=E.ReactCurrentDispatcher,wd=E.ReactCurrentOwner,Cs=E.ReactCurrentBatchConfig,br=0,Nn=null,kn=null,Gn=0,as=0,Hl=Oa(0),Bn=0,Zc=null,nl=0,_d=0,Uh=0,Sd=null,Gi=null,qh=0,Vl=1/0,bo=null,kd=!1,Wh=null,xo=null,Cd=!1,il=null,jd=0,Qc=0,Hh=null,eu=-1,Ed=0;function ji(){return(br&6)!==0?Tr():eu!==-1?eu:eu=Tr()}function wo(p){return(p.mode&1)===0?1:(br&2)!==0&&Gn!==0?Gn&-Gn:th.transition!==null?(Ed===0&&(Ed=is()),Ed):(p=ze,p!==0||(p=window.event,p=p===void 0?16:he(p.type)),p)}function Gs(p,v,A,I){if(50<Qc)throw Qc=0,Hh=null,Error(n(185));vi(p,A,I),((br&2)===0||p!==Nn)&&(p===Nn&&((br&2)===0&&(_d|=A),Bn===4&&_o(p,Gn)),Ki(p,I),A===1&&br===0&&(v.mode&1)===0&&(Vl=Tr()+500,id&&po()))}function Ki(p,v){var A=p.callbackNode;Bi(p,v);var I=aa(p,p===Nn?Gn:0);if(I===0)A!==null&&Hn(A),p.callbackNode=null,p.callbackPriority=0;else if(v=I&-I,p.callbackPriority!==v){if(A!=null&&Hn(A),v===1)p.tag===0?a1(Hg.bind(null,p)):Ym(Hg.bind(null,p)),Bb(function(){(br&6)===0&&po()}),A=null;else{switch(et(I)){case 1:A=sn;break;case 4:A=ri;break;case 16:A=Is;break;case 536870912:A=na;break;default:A=Is}A=Jg(A,qg.bind(null,p))}p.callbackPriority=v,p.callbackNode=A}}function qg(p,v){if(eu=-1,Ed=0,(br&6)!==0)throw Error(n(327));var A=p.callbackNode;if(Gl()&&p.callbackNode!==A)return null;var I=aa(p,p===Nn?Gn:0);if(I===0)return null;if((I&30)!==0||(I&p.expiredLanes)!==0||v)v=Td(p,I);else{v=I;var W=br;br|=2;var Z=ox();(Nn!==p||Gn!==v)&&(bo=null,Vl=Tr()+500,al(p,v));do try{u1();break}catch(ke){Vg(p,ke)}while(!0);ih(),xd.current=Z,br=W,kn!==null?v=0:(Nn=null,Gn=0,v=Bn)}if(v!==0){if(v===2&&(W=Ta(p),W!==0&&(I=W,v=Vh(p,W))),v===1)throw A=Zc,al(p,0),_o(p,I),Ki(p,Tr()),A;if(v===6)_o(p,I);else{if(W=p.current.alternate,(I&30)===0&&!Wg(W)&&(v=Td(p,I),v===2&&(Z=Ta(p),Z!==0&&(I=Z,v=Vh(p,Z))),v===1))throw A=Zc,al(p,0),_o(p,I),Ki(p,Tr()),A;switch(p.finishedWork=W,p.finishedLanes=I,v){case 0:case 1:throw Error(n(345));case 2:ol(p,Gi,bo);break;case 3:if(_o(p,I),(I&130023424)===I&&(v=qh+500-Tr(),10<v)){if(aa(p,0)!==0)break;if(W=p.suspendedLanes,(W&I)!==I){ji(),p.pingedLanes|=p.suspendedLanes&W;break}p.timeoutHandle=qf(ol.bind(null,p,Gi,bo),v);break}ol(p,Gi,bo);break;case 4:if(_o(p,I),(I&4194240)===I)break;for(v=p.eventTimes,W=-1;0<I;){var de=31-an(I);Z=1<<de,de=v[de],de>W&&(W=de),I&=~Z}if(I=W,I=Tr()-I,I=(120>I?120:480>I?480:1080>I?1080:1920>I?1920:3e3>I?3e3:4320>I?4320:1960*ax(I/1960))-I,10<I){p.timeoutHandle=qf(ol.bind(null,p,Gi,bo),I);break}ol(p,Gi,bo);break;case 5:ol(p,Gi,bo);break;default:throw Error(n(329))}}}return Ki(p,Tr()),p.callbackNode===A?qg.bind(null,p):null}function Vh(p,v){var A=Sd;return p.current.memoizedState.isDehydrated&&(al(p,v).flags|=256),p=Td(p,v),p!==2&&(v=Gi,Gi=A,v!==null&&Gh(v)),p}function Gh(p){Gi===null?Gi=p:Gi.push.apply(Gi,p)}function Wg(p){for(var v=p;;){if(v.flags&16384){var A=v.updateQueue;if(A!==null&&(A=A.stores,A!==null))for(var I=0;I<A.length;I++){var W=A[I],Z=W.getSnapshot;W=W.value;try{if(!Us(Z(),W))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 _o(p,v){for(v&=~Uh,v&=~_d,p.suspendedLanes|=v,p.pingedLanes&=~v,p=p.expirationTimes;0<v;){var A=31-an(v),I=1<<A;p[A]=-1,v&=~I}}function Hg(p){if((br&6)!==0)throw Error(n(327));Gl();var v=aa(p,0);if((v&1)===0)return Ki(p,Tr()),null;var A=Td(p,v);if(p.tag!==0&&A===2){var I=Ta(p);I!==0&&(v=I,A=Vh(p,I))}if(A===1)throw A=Zc,al(p,0),_o(p,v),Ki(p,Tr()),A;if(A===6)throw Error(n(345));return p.finishedWork=p.current.alternate,p.finishedLanes=v,ol(p,Gi,bo),Ki(p,Tr()),null}function Kh(p,v){var A=br;br|=1;try{return p(v)}finally{br=A,br===0&&(Vl=Tr()+500,id&&po())}}function sl(p){il!==null&&il.tag===0&&(br&6)===0&&Gl();var v=br;br|=1;var A=Cs.transition,I=ze;try{if(Cs.transition=null,ze=1,p)return p()}finally{ze=I,Cs.transition=A,br=v,(br&6)===0&&po()}}function Xh(){as=Hl.current,Xr(Hl)}function al(p,v){p.finishedWork=null,p.finishedLanes=0;var A=p.timeoutHandle;if(A!==-1&&(p.timeoutHandle=-1,Lb(A)),kn!==null)for(A=kn.return;A!==null;){var I=A;switch(Kf(I),I.tag){case 1:I=I.type.childContextTypes,I!=null&&rd();break;case 3:Qo(),Xr(zi),Xr(Si),dh();break;case 5:ch(I);break;case 4:Qo();break;case 13:Xr(un);break;case 19:Xr(un);break;case 10:sh(I.type._context);break;case 22:case 23:Xh()}A=A.return}if(Nn=p,kn=p=So(p.current,null),Gn=as=v,Bn=0,Zc=null,Uh=_d=nl=0,Gi=Sd=null,Fl!==null){for(v=0;v<Fl.length;v++)if(A=Fl[v],I=A.interleaved,I!==null){A.interleaved=null;var W=I.next,Z=A.pending;if(Z!==null){var de=Z.next;Z.next=W,I.next=de}A.pending=I}Fl=null}return p}function Vg(p,v){do{var A=kn;try{if(ih(),fh.current=gd,ph){for(var I=ln.memoizedState;I!==null;){var W=I.queue;W!==null&&(W.pending=null),I=I.next}ph=!1}if(el=0,Ln=An=ln=null,tl=!1,vo=0,wd.current=null,A===null||A.return===null){Bn=1,Zc=v,kn=null;break}e:{var Z=p,de=A.return,ke=A,Re=v;if(v=Gn,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 jt=Zb(de);if(jt!==null){jt.flags&=-257,Ci(jt,de,ke,Z,v),jt.mode&1&&Cg(Z,Xe,v),v=jt,Re=Xe;var Rt=v.updateQueue;if(Rt===null){var It=new Set;It.add(Re),v.updateQueue=It}else Rt.add(Re);break e}else{if((v&1)===0){Cg(Z,Xe,v),Yh();break e}Re=Error(n(426))}}else if(on&&ke.mode&1){var Hr=Zb(de);if(Hr!==null){(Hr.flags&65536)===0&&(Hr.flags|=256),Ci(Hr,de,ke,Z,v),eh(ql(Re,ke));break e}}Z=Re=ql(Re,ke),Bn!==4&&(Bn=2),Sd===null?Sd=[Z]:Sd.push(Z),Z=de;do{switch(Z.tag){case 3:Z.flags|=65536,v&=-v,Z.lanes|=v;var Ge=Sg(Z,Re,v);Ub(Z,Ge);break e;case 1:ke=Re;var Be=Z.type,Ye=Z.stateNode;if((Z.flags&128)===0&&(typeof Be.getDerivedStateFromError=="function"||Ye!==null&&typeof Ye.componentDidCatch=="function"&&(xo===null||!xo.has(Ye)))){Z.flags|=65536,v&=-v,Z.lanes|=v;var gt=kg(Z,ke,v);Ub(Z,gt);break e}}Z=Z.return}while(Z!==null)}tu(A)}catch(Ut){v=Ut,kn===A&&A!==null&&(kn=A=A.return);continue}break}while(!0)}function ox(){var p=xd.current;return xd.current=gd,p===null?gd:p}function Yh(){(Bn===0||Bn===3||Bn===2)&&(Bn=4),Nn===null||(nl&268435455)===0&&(_d&268435455)===0||_o(Nn,Gn)}function Td(p,v){var A=br;br|=2;var I=ox();(Nn!==p||Gn!==v)&&(bo=null,al(p,v));do try{lx();break}catch(W){Vg(p,W)}while(!0);if(ih(),br=A,xd.current=I,kn!==null)throw Error(n(261));return Nn=null,Gn=0,Bn}function lx(){for(;kn!==null;)Gg(kn)}function u1(){for(;kn!==null&&!Tl();)Gg(kn)}function Gg(p){var v=Yg(p.alternate,p,as);p.memoizedProps=p.pendingProps,v===null?tu(p):kn=v,wd.current=null}function tu(p){var v=p;do{var A=v.alternate;if(p=v.return,(v.flags&32768)===0){if(A=tx(A,v,as),A!==null){kn=A;return}}else{if(A=rx(A,v),A!==null){A.flags&=32767,kn=A;return}if(p!==null)p.flags|=32768,p.subtreeFlags=0,p.deletions=null;else{Bn=6,kn=null;return}}if(v=v.sibling,v!==null){kn=v;return}kn=v=p}while(v!==null);Bn===0&&(Bn=5)}function ol(p,v,A){var I=ze,W=Cs.transition;try{Cs.transition=null,ze=1,Kg(p,v,A,I)}finally{Cs.transition=W,ze=I}return null}function Kg(p,v,A,I){do Gl();while(il!==null);if((br&6)!==0)throw Error(n(327));A=p.finishedWork;var W=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 Z=A.lanes|A.childLanes;if(vt(p,Z),p===Nn&&(kn=Nn=null,Gn=0),(A.subtreeFlags&2064)===0&&(A.flags&2064)===0||Cd||(Cd=!0,Jg(Is,function(){return Gl(),null})),Z=(A.flags&15990)!==0,(A.subtreeFlags&15990)!==0||Z){Z=Cs.transition,Cs.transition=null;var de=ze;ze=1;var ke=br;br|=4,wd.current=null,ix(p,A),Bh(A,p),Pb(Ff),co=!!zf,Ff=zf=null,p.current=A,zg(A),Al(),br=ke,ze=de,Cs.transition=Z}else p.current=A;if(Cd&&(Cd=!1,il=p,jd=W),Z=p.pendingLanes,Z===0&&(xo=null),Ft(A.stateNode),Ki(p,Tr()),v!==null)for(I=p.onRecoverableError,A=0;A<v.length;A++)W=v[A],I(W.value,{componentStack:W.stack,digest:W.digest});if(kd)throw kd=!1,p=Wh,Wh=null,p;return(jd&1)!==0&&p.tag!==0&&Gl(),Z=p.pendingLanes,(Z&1)!==0?p===Hh?Qc++:(Qc=0,Hh=p):Qc=0,po(),null}function Gl(){if(il!==null){var p=et(jd),v=Cs.transition,A=ze;try{if(Cs.transition=null,ze=16>p?16:p,il===null)var I=!1;else{if(p=il,il=null,jd=0,(br&6)!==0)throw Error(n(331));var W=br;for(br|=4,Pt=p.current;Pt!==null;){var Z=Pt,de=Z.child;if((Pt.flags&16)!==0){var ke=Z.deletions;if(ke!==null){for(var Re=0;Re<ke.length;Re++){var Xe=ke[Re];for(Pt=Xe;Pt!==null;){var ft=Pt;switch(ft.tag){case 0:case 11:case 15:Yc(8,ft,Z)}var ht=ft.child;if(ht!==null)ht.return=ft,Pt=ht;else for(;Pt!==null;){ft=Pt;var dt=ft.sibling,jt=ft.return;if(Dg(ft),ft===Xe){Pt=null;break}if(dt!==null){dt.return=jt,Pt=dt;break}Pt=jt}}}var Rt=Z.alternate;if(Rt!==null){var It=Rt.child;if(It!==null){Rt.child=null;do{var Hr=It.sibling;It.sibling=null,It=Hr}while(It!==null)}}Pt=Z}}if((Z.subtreeFlags&2064)!==0&&de!==null)de.return=Z,Pt=de;else e:for(;Pt!==null;){if(Z=Pt,(Z.flags&2048)!==0)switch(Z.tag){case 0:case 11:case 15:Yc(9,Z,Z.return)}var Ge=Z.sibling;if(Ge!==null){Ge.return=Z.return,Pt=Ge;break e}Pt=Z.return}}var Be=p.current;for(Pt=Be;Pt!==null;){de=Pt;var Ye=de.child;if((de.subtreeFlags&2064)!==0&&Ye!==null)Ye.return=de,Pt=Ye;else e:for(de=Be;Pt!==null;){if(ke=Pt,(ke.flags&2048)!==0)try{switch(ke.tag){case 0:case 11:case 15:Mh(9,ke)}}catch(Ut){dn(ke,ke.return,Ut)}if(ke===de){Pt=null;break e}var gt=ke.sibling;if(gt!==null){gt.return=ke.return,Pt=gt;break e}Pt=ke.return}}if(br=W,po(),Mn&&typeof Mn.onPostCommitFiberRoot=="function")try{Mn.onPostCommitFiberRoot(Di,p)}catch{}I=!0}return I}finally{ze=A,Cs.transition=v}}return!1}function Xg(p,v,A){v=ql(A,v),v=Sg(p,v,1),p=go(p,v,1),v=ji(),p!==null&&(vi(p,1,v),Ki(p,v))}function dn(p,v,A){if(p.tag===3)Xg(p,p,A);else for(;v!==null;){if(v.tag===3){Xg(v,p,A);break}else if(v.tag===1){var I=v.stateNode;if(typeof v.type.getDerivedStateFromError=="function"||typeof I.componentDidCatch=="function"&&(xo===null||!xo.has(I))){p=ql(A,p),p=kg(v,p,1),v=go(v,p,1),p=ji(),v!==null&&(vi(v,1,p),Ki(v,p));break}}v=v.return}}function cx(p,v,A){var I=p.pingCache;I!==null&&I.delete(v),v=ji(),p.pingedLanes|=p.suspendedLanes&A,Nn===p&&(Gn&A)===A&&(Bn===4||Bn===3&&(Gn&130023424)===Gn&&500>Tr()-qh?al(p,0):Uh|=A),Ki(p,v)}function ux(p,v){v===0&&((p.mode&1)===0?v=1:(v=gi,gi<<=1,(gi&130023424)===0&&(gi=4194304)));var A=ji();p=Ra(p,v),p!==null&&(vi(p,v,A),Ki(p,A))}function dx(p){var v=p.memoizedState,A=0;v!==null&&(A=v.retryLane),ux(p,A)}function fx(p,v){var A=0;switch(p.tag){case 13:var I=p.stateNode,W=p.memoizedState;W!==null&&(A=W.retryLane);break;case 19:I=p.stateNode;break;default:throw Error(n(314))}I!==null&&I.delete(v),ux(p,A)}var Yg;Yg=function(p,v,A){if(p!==null)if(p.memoizedProps!==v.pendingProps||zi.current)Vi=!0;else{if((p.lanes&A)===0&&(v.flags&128)===0)return Vi=!1,c1(p,v,A);Vi=(p.flags&131072)!==0}else Vi=!1,on&&(v.flags&1048576)!==0&&Ko(v,ad,v.index);switch(v.lanes=0,v.tag){case 2:var I=v.type;yd(p,v),p=v.pendingProps;var W=ki(v,Si.current);zl(v,A),W=gh(null,v,I,p,W,A);var Z=vh();return v.flags|=1,typeof W=="object"&&W!==null&&typeof W.render=="function"&&W.$$typeof===void 0?(v.tag=1,v.memoizedState=null,v.updateQueue=null,Fi(I)?(Z=!0,nd(v)):Z=!1,v.memoizedState=W.state!==null&&W.state!==void 0?W.state:null,ud(v),W.updater=Ia,v.stateNode=W,W._reactInternals=v,wh(v,I,p,A),v=Ch(null,v,I,!0,Z,A)):(v.tag=0,on&&Z&&Tn(v),si(null,v,W,A),v=v.child),v;case 16:I=v.elementType;e:{switch(yd(p,v),p=v.pendingProps,W=I._init,I=W(I._payload),v.type=I,W=v.tag=hx(I),p=$n(I,p),W){case 0:v=kh(null,v,I,p,A);break e;case 1:v=$g(null,v,I,p,A);break e;case 11:v=jg(null,v,I,p,A);break e;case 14:v=Kc(null,v,I,$n(I.type,p),A);break e}throw Error(n(306,I,""))}return v;case 0:return I=v.type,W=v.pendingProps,W=v.elementType===I?W:$n(I,W),kh(p,v,I,W,A);case 1:return I=v.type,W=v.pendingProps,W=v.elementType===I?W:$n(I,W),$g(p,v,I,W,A);case 3:e:{if(jh(v),p===null)throw Error(n(387));I=v.pendingProps,Z=v.memoizedState,W=Z.element,oh(p,v),dd(v,I,null,A);var de=v.memoizedState;if(I=de.element,Z.isDehydrated)if(Z={element:I,isDehydrated:!1,cache:de.cache,pendingSuspenseBoundaries:de.pendingSuspenseBoundaries,transitions:de.transitions},v.updateQueue.baseState=Z,v.memoizedState=Z,v.flags&256){W=ql(Error(n(423)),v),v=Ng(p,v,I,A,W);break e}else if(I!==W){W=ql(Error(n(424)),v),v=Ng(p,v,I,A,W);break e}else for(ss=fo(v.stateNode.containerInfo.firstChild),Wi=v,on=!0,Hi=null,A=rh(v,null,I,A),v.child=A;A;)A.flags=A.flags&-3|4096,A=A.sibling;else{if(Xo(),I===W){v=Da(p,v,A);break e}si(p,v,I,A)}v=v.child}return v;case 5:return eg(v),p===null&&Zf(v),I=v.type,W=v.pendingProps,Z=p!==null?p.memoizedProps:null,de=W.children,Uf(I,W)?de=null:Z!==null&&Uf(I,Z)&&(v.flags|=32),Ag(p,v),si(p,v,de,A),v.child;case 6:return p===null&&Zf(v),null;case 13:return Og(p,v,A);case 4:return lh(v,v.stateNode.containerInfo),I=v.pendingProps,p===null?v.child=Bl(v,null,I,A):si(p,v,I,A),v.child;case 11:return I=v.type,W=v.pendingProps,W=v.elementType===I?W:$n(I,W),jg(p,v,I,W,A);case 7:return si(p,v,v.pendingProps,A),v.child;case 8:return si(p,v,v.pendingProps.children,A),v.child;case 12:return si(p,v,v.pendingProps.children,A),v.child;case 10:e:{if(I=v.type._context,W=v.pendingProps,Z=v.memoizedProps,de=W.value,Wr(Yo,I._currentValue),I._currentValue=de,Z!==null)if(Us(Z.value,de)){if(Z.children===W.children&&!zi.current){v=Da(p,v,A);break e}}else for(Z=v.child,Z!==null&&(Z.return=v);Z!==null;){var ke=Z.dependencies;if(ke!==null){de=Z.child;for(var Re=ke.firstContext;Re!==null;){if(Re.context===I){if(Z.tag===1){Re=Ma(-1,A&-A),Re.tag=2;var Xe=Z.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}}Z.lanes|=A,Re=Z.alternate,Re!==null&&(Re.lanes|=A),Qm(Z.return,A,v),ke.lanes|=A;break}Re=Re.next}}else if(Z.tag===10)de=Z.type===v.type?null:Z.child;else if(Z.tag===18){if(de=Z.return,de===null)throw Error(n(341));de.lanes|=A,ke=de.alternate,ke!==null&&(ke.lanes|=A),Qm(de,A,v),de=Z.sibling}else de=Z.child;if(de!==null)de.return=Z;else for(de=Z;de!==null;){if(de===v){de=null;break}if(Z=de.sibling,Z!==null){Z.return=de.return,de=Z;break}de=de.return}Z=de}si(p,v,W.children,A),v=v.child}return v;case 9:return W=v.type,I=v.pendingProps.children,zl(v,A),W=_s(W),I=I(W),v.flags|=1,si(p,v,I,A),v.child;case 14:return I=v.type,W=$n(I,v.pendingProps),W=$n(I.type,W),Kc(p,v,I,W,A);case 15:return Eg(p,v,v.type,v.pendingProps,A);case 17:return I=v.type,W=v.pendingProps,W=v.elementType===I?W:$n(I,W),yd(p,v),v.tag=1,Fi(I)?(p=!0,nd(v)):p=!1,zl(v,A),wg(v,I,W),wh(v,I,W,A),Ch(null,v,I,!0,p,A);case 19:return $h(p,v,A);case 22:return Tg(p,v,A)}throw Error(n(156,v.tag))};function Jg(p,v){return Uo(p,v)}function d1(p,v,A,I){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=I,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function os(p,v,A,I){return new d1(p,v,A,I)}function Jh(p){return p=p.prototype,!(!p||!p.isReactComponent)}function hx(p){if(typeof p=="function")return Jh(p)?1:0;if(p!=null){if(p=p.$$typeof,p===V)return 11;if(p===Y)return 14}return 2}function So(p,v){var A=p.alternate;return A===null?(A=os(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 Ad(p,v,A,I,W,Z){var de=2;if(I=p,typeof p=="function")Jh(p)&&(de=1);else if(typeof p=="string")de=5;else e:switch(p){case N:return Kl(A.children,W,Z,v);case O:de=8,W|=8;break;case M:return p=os(12,A,v,W|2),p.elementType=M,p.lanes=Z,p;case z:return p=os(13,A,v,W),p.elementType=z,p.lanes=Z,p;case F:return p=os(19,A,v,W),p.elementType=F,p.lanes=Z,p;case le:return $d(A,W,Z,v);default:if(typeof p=="object"&&p!==null)switch(p.$$typeof){case U:de=10;break e;case H:de=9;break e;case V:de=11;break e;case Y:de=14;break e;case te:de=16,I=null;break e}throw Error(n(130,p==null?p:typeof p,""))}return v=os(de,A,v,W),v.elementType=p,v.type=I,v.lanes=Z,v}function Kl(p,v,A,I){return p=os(7,p,I,v),p.lanes=A,p}function $d(p,v,A,I){return p=os(22,p,I,v),p.elementType=le,p.lanes=A,p.stateNode={isHidden:!1},p}function Zh(p,v,A){return p=os(6,p,null,v),p.lanes=A,p}function Qh(p,v,A){return v=os(4,p.children!==null?p.children:[],p.key,v),v.lanes=A,v.stateNode={containerInfo:p.containerInfo,pendingChildren:null,implementation:p.implementation},v}function f1(p,v,A,I,W){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=Ze(0),this.expirationTimes=Ze(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ze(0),this.identifierPrefix=I,this.onRecoverableError=W,this.mutableSourceEagerHydrationData=null}function ep(p,v,A,I,W,Z,de,ke,Re){return p=new f1(p,v,A,ke,Re),v===1?(v=1,Z===!0&&(v|=8)):v=0,Z=os(3,null,null,v),p.current=Z,Z.stateNode=p,Z.memoizedState={element:I,isDehydrated:A,cache:null,transitions:null,pendingSuspenseBoundaries:null},ud(Z),p}function h1(p,v,A){var I=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:$,key:I==null?null:""+I,children:p,containerInfo:v,implementation:A}}function Zg(p){if(!p)return ho;p=p._reactInternals;e:{if(Ct(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(Fi(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(Fi(A))return Km(p,A,v)}return v}function px(p,v,A,I,W,Z,de,ke,Re){return p=ep(A,I,!0,p,W,Z,de,ke,Re),p.context=Zg(null),A=p.current,I=ji(),W=wo(A),Z=Ma(I,W),Z.callback=v??null,go(A,Z,W),p.current.lanes=W,vi(p,W,I),Ki(p,I),p}function Nd(p,v,A,I){var W=v.current,Z=ji(),de=wo(W);return A=Zg(A),v.context===null?v.context=A:v.pendingContext=A,v=Ma(Z,de),v.payload={element:p},I=I===void 0?null:I,I!==null&&(v.callback=I),p=go(W,v,de),p!==null&&(Gs(p,W,de,Z),Wc(p,W,de)),de}function Od(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 Qg(p,v){if(p=p.memoizedState,p!==null&&p.dehydrated!==null){var A=p.retryLane;p.retryLane=A!==0&&A<v?A:v}}function tp(p,v){Qg(p,v),(p=p.alternate)&&Qg(p,v)}function mx(){return null}var gx=typeof reportError=="function"?reportError:function(p){console.error(p)};function rp(p){this._internalRoot=p}Xl.prototype.render=rp.prototype.render=function(p){var v=this._internalRoot;if(v===null)throw Error(n(409));Nd(p,v,null,null)},Xl.prototype.unmount=rp.prototype.unmount=function(){var p=this._internalRoot;if(p!==null){this._internalRoot=null;var v=p.containerInfo;sl(function(){Nd(null,p,null,null)}),v[fa]=null}};function Xl(p){this._internalRoot=p}Xl.prototype.unstable_scheduleHydration=function(p){if(p){var v=Br();p={blockedOn:null,target:p,priority:v};for(var A=0;A<Ds.length&&v!==0&&v<Ds[A].priority;A++);Ds.splice(A,0,p),A===0&&Ec(p)}};function np(p){return!(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11)}function Pd(p){return!(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11&&(p.nodeType!==8||p.nodeValue!==" react-mount-point-unstable "))}function vx(){}function yx(p,v,A,I,W){if(W){if(typeof I=="function"){var Z=I;I=function(){var Xe=Od(de);Z.call(Xe)}}var de=px(v,I,p,0,null,!1,!1,"",vx);return p._reactRootContainer=de,p[fa]=de.current,Bc(p.nodeType===8?p.parentNode:p),sl(),de}for(;W=p.lastChild;)p.removeChild(W);if(typeof I=="function"){var ke=I;I=function(){var Xe=Od(Re);ke.call(Xe)}}var Re=ep(p,0,!1,null,null,!1,!1,"",vx);return p._reactRootContainer=Re,p[fa]=Re.current,Bc(p.nodeType===8?p.parentNode:p),sl(function(){Nd(v,Re,A,I)}),Re}function ru(p,v,A,I,W){var Z=A._reactRootContainer;if(Z){var de=Z;if(typeof W=="function"){var ke=W;W=function(){var Re=Od(de);ke.call(Re)}}Nd(v,de,p,W)}else de=yx(A,v,p,W,I);return Od(de)}Et=function(p){switch(p.tag){case 3:var v=p.stateNode;if(v.current.memoizedState.isDehydrated){var A=ms(v.pendingLanes);A!==0&&(Se(v,A|1),Ki(v,Tr()),(br&6)===0&&(Vl=Tr()+500,po()))}break;case 13:sl(function(){var I=Ra(p,1);if(I!==null){var W=ji();Gs(I,p,1,W)}}),tp(p,1)}},ir=function(p){if(p.tag===13){var v=Ra(p,134217728);if(v!==null){var A=ji();Gs(v,p,134217728,A)}tp(p,134217728)}},cr=function(p){if(p.tag===13){var v=wo(p),A=Ra(p,v);if(A!==null){var I=ji();Gs(A,p,v,I)}tp(p,v)}},Br=function(){return ze},Dr=function(p,v){var A=ze;try{return ze=p,v()}finally{ze=A}},ea=function(p,v,A){switch(v){case"input":if(lt(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 I=A[v];if(I!==p&&I.form===p.form){var W=td(I);if(!W)throw Error(n(90));Te(I),lt(I,W)}}}break;case"textarea":Ur(p,A);break;case"select":v=A.value,v!=null&&Vt(p,!!A.multiple,v,!1)}},ps=Kh,Qn=sl;var ev={usingClientEntryPoint:!1,Events:[Uc,Rl,td,ta,ra,Kh]},Ks={findFiberByHostInstance:Vo,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},bx={bundleType:Ks.bundleType,version:Ks.version,rendererPackageName:Ks.rendererPackageName,rendererConfig:Ks.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:E.ReactCurrentDispatcher,findHostInstanceByFiber:function(p){return p=no(p),p===null?null:p.stateNode},findFiberByHostInstance:Ks.findFiberByHostInstance||mx,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{Di=nu.inject(bx),Mn=nu}catch{}}return Xs.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ev,Xs.createPortal=function(p,v){var A=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!np(v))throw Error(n(200));return h1(p,v,null,A)},Xs.createRoot=function(p,v){if(!np(p))throw Error(n(299));var A=!1,I="",W=gx;return v!=null&&(v.unstable_strictMode===!0&&(A=!0),v.identifierPrefix!==void 0&&(I=v.identifierPrefix),v.onRecoverableError!==void 0&&(W=v.onRecoverableError)),v=ep(p,1,!1,null,null,A,!1,I,W),p[fa]=v.current,Bc(p.nodeType===8?p.parentNode:p),new rp(v)},Xs.findDOMNode=function(p){if(p==null)return null;if(p.nodeType===1)return p;var v=p._reactInternals;if(v===void 0)throw typeof p.render=="function"?Error(n(188)):(p=Object.keys(p).join(","),Error(n(268,p)));return p=no(v),p=p===null?null:p.stateNode,p},Xs.flushSync=function(p){return sl(p)},Xs.hydrate=function(p,v,A){if(!Pd(v))throw Error(n(200));return ru(null,p,v,!0,A)},Xs.hydrateRoot=function(p,v,A){if(!np(p))throw Error(n(405));var I=A!=null&&A.hydratedSources||null,W=!1,Z="",de=gx;if(A!=null&&(A.unstable_strictMode===!0&&(W=!0),A.identifierPrefix!==void 0&&(Z=A.identifierPrefix),A.onRecoverableError!==void 0&&(de=A.onRecoverableError)),v=px(v,null,p,1,A??null,W,!1,Z,de),p[fa]=v.current,Bc(p),I)for(p=0;p<I.length;p++)A=I[p],W=A._getVersion,W=W(A._source),v.mutableSourceEagerHydrationData==null?v.mutableSourceEagerHydrationData=[A,W]:v.mutableSourceEagerHydrationData.push(A,W);return new Xl(v)},Xs.render=function(p,v,A){if(!Pd(v))throw Error(n(200));return ru(null,p,v,!1,A)},Xs.unmountComponentAtNode=function(p){if(!Pd(p))throw Error(n(40));return p._reactRootContainer?(sl(function(){ru(null,null,p,!1,function(){p._reactRootContainer=null,p[fa]=null})}),!0):!1},Xs.unstable_batchedUpdates=Kh,Xs.unstable_renderSubtreeIntoContainer=function(p,v,A,I){if(!Pd(A))throw Error(n(200));if(p==null||p._reactInternals===void 0)throw Error(n(38));return ru(p,v,A,!1,I)},Xs.version="18.3.1-next-f1338f8080-20240426",Xs}var U$;function p4(){if(U$)return y1.exports;U$=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(),y1.exports=rq(),y1.exports}var q$;function nq(){if(q$)return _x;q$=1;var e=p4();return _x.createRoot=e.createRoot,_x.hydrateRoot=e.hydrateRoot,_x}var iq=nq();const sq=Qr(iq);var D=BT();const He=Qr(D),W$=e=>{let r;const n=new Set,i=(f,m)=>{const h=typeof f=="function"?f(r):f;if(!Object.is(h,r)){const y=r;r=m??(typeof h!="object"||h===null)?h:Object.assign({},r,h),n.forEach(x=>x(r,y))}},s=()=>r,l={setState:i,getState:s,getInitialState:()=>u,subscribe:f=>(n.add(f),()=>n.delete(f))},u=r=e(i,s,l);return l},aq=(e=>e?W$(e):W$),oq=e=>e;function lq(e,r=oq){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 H$=e=>{const r=aq(e),n=i=>lq(r,i);return Object.assign(n,r),n},En=(e=>e?H$(e):H$);function bl(e){return"'"+e.replace(/'/g,"'\\''")+"'"}const w1=({sessionId:e})=>`claude --dangerously-skip-permissions --session-id ${bl(e)}`,V$=({sessionId:e})=>`claude --session-id ${bl(e)}`,cq=()=>"claude --resume",m4=[{id:"sm-dangerous",label:"Session Manager (skip perms)",description:"claude --dangerously-skip-permissions in this project",category:"build",cwd:"app-cwd",command:w1},{id:"sm-safe",label:"Session Manager (safe)",description:"claude with normal permission prompts in this project",category:"build",cwd:"app-cwd",command:V$},{id:"home-dangerous",label:"Home (skip perms)",description:"claude --dangerously-skip-permissions in ~",category:"build",cwd:"home",command:w1},{id:"pick-dangerous",label:"Pick directory (skip perms)…",description:"Choose a folder, launch claude --dangerously-skip-permissions",category:"build",cwd:"pick",command:w1},{id:"pick-safe",label:"Pick directory (safe)…",description:"Choose a folder, launch claude with normal prompts",category:"build",cwd:"pick",command:V$},{id:"pick-resume",label:"Pick directory + resume…",description:"Choose a folder, then pick a past session to resume",category:"build",cwd:"pick",command:cq},{id:"pick-shell",label:"Pick directory (shell only)…",description:"Bare interactive shell, no claude auto-launch",category:"build",cwd:"pick",command:null}];let Ba=null;async function uq(){if(Ba)return Ba;try{const e=await window.api.app.engageRulesPath();if(!e)return Ba=[],Ba;const r=await window.api.config.readJson(e);if(!r.exists||r.parseError||!r.data)return Ba=[],Ba;const n=r.data;if(!n.presets||!Array.isArray(n.presets))return Ba=[],Ba;const i=n.projectPath;return Ba=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 ${bl(i)} && ${s.cliEntry}`})),Ba}catch(e){return console.warn("[presets] Failed to load engage presets:",e),Ba=[],Ba}}async function g4(e){const r=m4.find(i=>i.id===e);return r||((await uq()).find(i=>i.id===e)??null)}async function G$(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 v4(e,r){return e.command?e.command(r):null}const zT=["opus","sonnet","haiku"],y4="sm.rawSessionModel",dq="opus";function fq(e){return zT.includes(e)}function hq(){try{const e=localStorage.getItem(y4);if(e&&fq(e))return e}catch{}return dq}let Sp=hq();const bj=new Set;function b4(){return Sp}function pq(e){if(e!==Sp){Sp=e;try{localStorage.setItem(y4,e)}catch{}bj.forEach(r=>r(e))}}function mq(){const[e,r]=D.useState(Sp);D.useEffect(()=>{const i=s=>r(s);return bj.add(i),Sp!==e&&r(Sp),()=>{bj.delete(i)}},[]);const n=D.useCallback(i=>pq(i),[]);return{model:e,setModel:n}}async function x4(e,r){const n=await window.api.transcripts.pathFor(e,r);return window.api.config.exists(n)}function gq(e){const r=e.split("/").filter(Boolean);return r[r.length-1]||e}async function w4(e,r=!1,n=b4()){let i=!r;i&&(i=await x4(e.cwd,e.claudeSessionId));const s=r&&!i?crypto.randomUUID():e.claudeSessionId,a=i?`claude --dangerously-skip-permissions --resume ${bl(s)} --model ${n}`:`claude --dangerously-skip-permissions --session-id ${bl(s)} --model ${n}`;return{claudeSessionId:s,startupCommand:a}}const Nt=En((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??gq(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?g4(i.presetId).then(c=>{a(c?v4(c,{sessionId:s,cwd:i.cwd}):`claude --dangerously-skip-permissions --session-id ${bl(s)}`)}):a(`claude --dangerously-skip-permissions --session-id ${bl(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 w4({cwd:s.cwd,claudeSessionId:s.claudeSessionId},!1,i??b4());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 xj(){var n;if(Nt.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 w4(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;Nt.getState().restoreTabs(c,l)}else Nt.setState({hydrated:!0})}catch(i){console.warn("[sessions] hydrate failed:",i),Nt.setState({hydrated:!0})}const e=()=>{const{tabs:i,activeTabId:s}=Nt.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;Nt.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 vq=Object.freeze(Object.defineProperty({__proto__:null,hydrateSessions:xj,useSessions:Nt},Symbol.toStringTag,{value:"Module"})),yq=5,K$=100,bq=5e3,wj=new Map;function X$(e){const r=wj.get(e);r!==void 0&&(clearTimeout(r),wj.delete(e))}function xq(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`t-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}const kp=En((e,r)=>({toasts:[],history:[],unreadCount:0,show:(n,i)=>{const s=xq(),a=Date.now();e(l=>{const u=[...l.toasts,{id:s,kind:n,message:i,createdAt:a}];for(;u.length>yq;){const h=u.shift();h&&X$(h.id)}const m=[{id:s,kind:n,message:i,createdAt:a,read:!1},...l.history];return m.length>K$&&(m.length=K$),{toasts:u,history:m,unreadCount:l.unreadCount+1}});const c=setTimeout(()=>r().dismiss(s),bq);return wj.set(s,c),s},dismiss:n=>{X$(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}})}})),rt={info:e=>kp.getState().show("info",e),warn:e=>kp.getState().show("warn",e),error:e=>kp.getState().show("error",e)},_4=Object.freeze(Object.defineProperty({__proto__:null,toast:rt,useToast:kp},Symbol.toStringTag,{value:"Module"})),Y$=200,wq=/\x1b\[[0-9;]*m/g;function _q(e){return e.replace(wq,"")}const ry=En((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),rt.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);rt.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=_q(n.line),a=i.lines.length>=Y$?[...i.lines.slice(i.lines.length-Y$+1),{line:s,ts:n.ts}]:[...i.lines,{line:s,ts:n.ts}];e({watchers:{...r().watchers,[n.watcherId]:{...i,lines:a,lineCount:i.lineCount+1,lastLineAt:n.ts}}})},closed:n=>{if(!r().watchers[n])return;const i={...r().watchers};delete i[n],e({watchers:i})}})),Sq=4,J$=40,Z$=6;function kq(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]")):[],[]),y=D.useCallback((b,_,w)=>{for(let C=0;C<_.length;C++){const E=_[C].left+_[C].width/2;if(b<E)return C<=w?C:C-1}return _.length-1},[]),x=D.useCallback(()=>{const b=s.current,_=i.current;if(!(b!=null&&b.active)||!_)return;const w=_.getBoundingClientRect(),C=b.startX+b.deltaX,E=C-w.left,T=w.right-C;E<J$?_.scrollLeft-=Z$:T<J$&&(_.scrollLeft+=Z$),a.current=requestAnimationFrame(x)},[]);D.useEffect(()=>{const b=i.current;if(!b)return;let _=!1;const w=()=>{_||(_=!0,c.current=requestAnimationFrame(()=>{_=!1,f(T=>T+1)}))},C=T=>{var U;const $=s.current;if(!$)return;const N=T.clientX-$.startX;if(!$.active&&Math.abs(N)<Sq)return;if(!$.active){$.active=!0,$.tabRects=h().map(H=>H.getBoundingClientRect()),u(!0);try{(U=i.current)==null||U.setPointerCapture($.pointerId)}catch{}a.current=requestAnimationFrame(x)}$.deltaX=N;const O=$.tabRects[$.fromIndex],M=O.left+O.width/2+N;$.currentIndex=y(M,$.tabRects,$.fromIndex),w()},E=T=>{const $=s.current;if($&&$.pointerId===T.pointerId){cancelAnimationFrame(a.current),cancelAnimationFrame(c.current);try{b.releasePointerCapture($.pointerId)}catch{}$.active&&$.fromIndex!==$.currentIndex?r($.fromIndex,$.currentIndex):m.current($.fromIndex),s.current=null,u(!1),f(N=>N+1)}};return b.addEventListener("pointermove",C),b.addEventListener("pointerup",E),b.addEventListener("pointercancel",E),()=>{b.removeEventListener("pointermove",C),b.removeEventListener("pointerup",E),b.removeEventListener("pointercancel",E),cancelAnimationFrame(a.current),cancelAnimationFrame(c.current)}},[r,h,y,x]);const k=D.useCallback((b,_)=>{b.button!==0||b.target.closest("button")||(s.current={active:!1,fromIndex:_,currentIndex:_,startX:b.clientX,deltaX:0,tabRects:[],pointerId:b.pointerId})},[]);return{getTabDragProps:D.useCallback(b=>{var C;const _=s.current,w={};if(_!=null&&_.active)if(b===_.fromIndex)w.transform=`translateX(${_.deltaX}px) scale(1.03)`,w.zIndex=10,w.opacity=.85,w.boxShadow="0 2px 8px rgba(0,0,0,0.4)",w.position="relative",w.pointerEvents="none";else{const E=_.fromIndex,T=_.currentIndex,N=(((C=_.tabRects[E])==null?void 0:C.width)??0)+4;w.transition="transform 0.15s ease",E<T&&b>E&&b<=T?w.transform=`translateX(-${N}px)`:E>T&&b>=T&&b<E?w.transform=`translateX(${N}px)`:w.transform="translateX(0)"}return{onPointerDown:E=>k(E,b),style:w,"data-drag-index":b}},[k]),isDragging:l,containerRef:i}}const Cq=3e4;function jq(){const e=Nt(x=>x.tabs),r=Nt(x=>x.activeTabId),n=Nt(x=>x.closeTab),i=Nt(x=>x.setActive),s=Nt(x=>x.reorderTab),a=ry(x=>x.watchers),[c,l]=D.useState(()=>Date.now());D.useEffect(()=>{const x=window.setInterval(()=>l(Date.now()),1e3);return()=>window.clearInterval(x)},[]);const u=x=>{for(const k of Object.values(a))if(k.tabId===x&&k.lastLineAt&&c-k.lastLineAt<Cq)return!0;return!1},{getTabDragProps:f,isDragging:m,containerRef:h}=kq({tabCount:e.length,onReorder:s,onActivate:x=>{const k=e[x];k&&i(k.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:h,className:`flex items-end gap-0.5 overflow-x-auto min-w-0 flex-1 select-none ${m?"cursor-grabbing":""}`,children:e.map((x,k)=>{const S=x.id===r,b=f(k),_=y[k%y.length];return o.jsxs("div",{...b,style:b.style,className:`group flex items-center gap-2 px-3.5 pt-1.5 pb-2 rounded-t-[10px] text-[13px] shrink-0 transition-colors ${m?"":"cursor-grab"} ${S?"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":S?"true":void 0,children:[o.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:_,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"}),u(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:w=>{w.stopPropagation(),n(x.id)},className:"text-fg-faint opacity-0 group-hover:opacity-100 hover:text-fg ml-1 leading-none",title:"Close session","aria-label":`Close ${x.label}`,children:"×"})]},x.id)})}),o.jsxs("div",{className:"flex items-center gap-2 pb-2 pl-3 text-[12px] text-fg-faint shrink-0",children:[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.10"]})]})]})}function Eq(e,r,n){return r?e.map(i=>i.id===r?{...i,lastActivityAt:n}:i):e}function Tq(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 xw=En((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]:Tq(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 sb(async()=>{const{toast:h}=await Promise.resolve().then(()=>_4);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,y={};for(const x of["command","file_path","pattern","url","query","subagent_type","description"])h&&x in h&&(y[x]=h[x]);if(l.lastToolUses=[{id:m.id,name:m.name,input:y,at:c},...a.lastToolUses].slice(0,50),!(s!=null&&s.replay)){const x=m.input,k=["Edit","Write","NotebookEdit"].includes(m.name),S=typeof(x==null?void 0:x.file_path)=="string"?x.file_path:void 0,b=typeof(x==null?void 0:x.command)=="string"?x.command:void 0,_=S?S.split("/").pop()??S:b?f(b,28):"";u.push({id:0,kind:"tool-use",at:c,label:_?`${m.name} · ${_}`:m.name,target:S??b,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),y=m.input_tokens??m.inputTokens??0,x=m.output_tokens??m.outputTokens??0,k=h+y+x;l.usage={inputTokens:(a.usage.inputTokens||0)+y,outputTokens:(a.usage.outputTokens||0)+x,cacheCreationInputTokens:(a.usage.cacheCreationInputTokens||0)+(m.cache_creation_input_tokens??m.cacheCreationInputTokens??0),cacheReadInputTokens:(a.usage.cacheReadInputTokens||0)+(m.cache_read_input_tokens??m.cacheReadInputTokens??0)},!(s!=null&&s.replay)&&Math.floor(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=Eq(a.agents,m==null?void 0:m.toolUseId,c);break}}if(u.length>0){let m=a.activitySeq;const h=u.map(y=>({...y,id:++m}));l.activitySeq=m,l.activityRing=[...a.activityRing,...h].slice(-32)}e({tabs:{...r().tabs,[n]:l}})}}));function S4(e){const r=xw(s=>s.subscribe),n=xw(s=>s.unsubscribe),i=xw(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 _1={},nv={},Q$;function k4(){if(Q$)return nv;Q$=1,Object.defineProperty(nv,"__esModule",{value:!0}),nv.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(/\/[^/]+$/,"/")),nv.baseAssetPath=n,nv}var iv={},eN;function FT(){if(eN)return iv;eN=1,Object.defineProperty(iv,"__esModule",{value:!0}),iv.defaultModelFetcher=void 0;const e=r=>fetch(r).then(n=>n.arrayBuffer());return iv.defaultModelFetcher=e,iv}var Zl={},sv={},tN;function ab(){if(tN)return sv;tN=1,Object.defineProperty(sv,"__esModule",{value:!0}),sv.log=void 0;const e=r=>n=>{console.log(`VAD | ${r} >`,n)};return sv.log={error:e("error"),debug:e("debug"),warn:e("warn")},sv}var av={},rN;function f_(){if(rN)return av;rN=1,Object.defineProperty(av,"__esModule",{value:!0}),av.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||(av.Message=e={})),av}var nN;function UT(){if(nN)return Zl;nN=1,Object.defineProperty(Zl,"__esModule",{value:!0}),Zl.FrameProcessor=Zl.validateOptions=Zl.defaultFrameProcessorOptions=void 0;const e=ab(),r=f_();Zl.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")}Zl.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:b,minSpeechFrames:_}=s(this.options,this.msPerFrame);this.redemptionFrames=S,this.preSpeechPadFrames=b,this.minSpeechFrames=_},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 b=this.speaking;if(this.reset(),b)if(S.reduce((w,C)=>C.isSpeech?w+1:w,0)>=this.minSpeechFrames){const w=i(S.map(C=>C.frame));k({msg:r.Message.SpeechEnd,audio:w})}else k({msg:r.Message.VADMisfire});return{}},this.process=async(k,S)=>{if(!this.active)return;const b=await this.modelProcessFunc(k),_=b.isSpeech>=this.options.positiveSpeechThreshold;if(S({probs:b,msg:r.Message.FrameProcessed,frame:k}),this.audioBuffer.push({frame:k,isSpeech:_}),_&&(this.speechFrameCount++,this.redemptionCounter=0),_&&!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})),b.isSpeech<this.options.negativeSpeechThreshold&&this.speaking&&++this.redemptionCounter>=this.redemptionFrames){this.redemptionCounter=0,this.speechFrameCount=0,this.speaking=!1,this.speechRealStartFired=!1;const w=this.audioBuffer;if(this.audioBuffer=[],w.reduce((E,T)=>T.isSpeech?E+1:E,0)>=this.minSpeechFrames){const E=i(w.map(T=>T.frame));S({msg:r.Message.SpeechEnd,audio:E})}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:y,minSpeechFrames:x}=s(this.options,this.msPerFrame);this.redemptionFrames=h,this.preSpeechPadFrames=y,this.minSpeechFrames=x,this.reset()}}return Zl.FrameProcessor=a,Zl}var Ql={};function Ga(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 S1={exports:{}};/*!
41
+ `+Z.stack}return{value:p,source:v,stack:W,digest:null}}function _h(p,v,A){return{value:p,source:null,stack:A??null,digest:v??null}}function Sh(p,v){try{console.error(v.value)}catch(A){setTimeout(function(){throw A})}}var Jb=typeof WeakMap=="function"?WeakMap:Map;function Sg(p,v,A){A=Ma(-1,A),A.tag=3,A.payload={element:null};var I=v.value;return A.callback=function(){kd||(kd=!0,Wh=I),Sh(p,v)},A}function kg(p,v,A){A=Ma(-1,A),A.tag=3;var I=p.type.getDerivedStateFromError;if(typeof I=="function"){var W=v.value;A.payload=function(){return I(W)},A.callback=function(){Sh(p,v)}}var Z=p.stateNode;return Z!==null&&typeof Z.componentDidCatch=="function"&&(A.callback=function(){Sh(p,v),typeof I!="function"&&(xo===null?xo=new Set([this]):xo.add(this));var de=v.stack;this.componentDidCatch(v.value,{componentStack:de!==null?de:""})}),A}function Cg(p,v,A){var I=p.pingCache;if(I===null){I=p.pingCache=new Jb;var W=new Set;I.set(v,W)}else W=I.get(v),W===void 0&&(W=new Set,I.set(v,W));W.has(A)||(W.add(A),p=cx.bind(null,p,v,A),v.then(p,p))}function Zb(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 Ci(p,v,A,I,W){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=Ma(-1,1),v.tag=2,go(A,v,1))),A.lanes|=1),p):(p.flags|=65536,p.lanes=W,p)}var Qb=E.ReactCurrentOwner,Vi=!1;function si(p,v,A,I){v.child=p===null?rh(v,null,A,I):Bl(v,p.child,A,I)}function jg(p,v,A,I,W){A=A.render;var Z=v.ref;return zl(v,W),I=gh(p,v,A,I,Z,W),A=vh(),p!==null&&!Vi?(v.updateQueue=p.updateQueue,v.flags&=-2053,p.lanes&=~W,Da(p,v,W)):(on&&A&&Tn(v),v.flags|=1,si(p,v,I,W),v.child)}function Kc(p,v,A,I,W){if(p===null){var Z=A.type;return typeof Z=="function"&&!Jh(Z)&&Z.defaultProps===void 0&&A.compare===null&&A.defaultProps===void 0?(v.tag=15,v.type=Z,Eg(p,v,Z,I,W)):(p=Ad(A.type,null,I,v,v.mode,W),p.ref=v.ref,p.return=v,v.child=p)}if(Z=p.child,(p.lanes&W)===0){var de=Z.memoizedProps;if(A=A.compare,A=A!==null?A:Mc,A(de,I)&&p.ref===v.ref)return Da(p,v,W)}return v.flags|=1,p=So(Z,I),p.ref=v.ref,p.return=v,v.child=p}function Eg(p,v,A,I,W){if(p!==null){var Z=p.memoizedProps;if(Mc(Z,I)&&p.ref===v.ref)if(Vi=!1,v.pendingProps=I=Z,(p.lanes&W)!==0)(p.flags&131072)!==0&&(Vi=!0);else return v.lanes=p.lanes,Da(p,v,W)}return kh(p,v,A,I,W)}function Tg(p,v,A){var I=v.pendingProps,W=I.children,Z=p!==null?p.memoizedState:null;if(I.mode==="hidden")if((v.mode&1)===0)v.memoizedState={baseLanes:0,cachePool:null,transitions:null},Wr(Hl,as),as|=A;else{if((A&1073741824)===0)return p=Z!==null?Z.baseLanes|A:A,v.lanes=v.childLanes=1073741824,v.memoizedState={baseLanes:p,cachePool:null,transitions:null},v.updateQueue=null,Wr(Hl,as),as|=p,null;v.memoizedState={baseLanes:0,cachePool:null,transitions:null},I=Z!==null?Z.baseLanes:A,Wr(Hl,as),as|=I}else Z!==null?(I=Z.baseLanes|A,v.memoizedState=null):I=A,Wr(Hl,as),as|=I;return si(p,v,W,A),v.child}function Ag(p,v){var A=v.ref;(p===null&&A!==null||p!==null&&p.ref!==A)&&(v.flags|=512,v.flags|=2097152)}function kh(p,v,A,I,W){var Z=Fi(A)?Go:Si.current;return Z=ki(v,Z),zl(v,W),A=gh(p,v,A,I,Z,W),I=vh(),p!==null&&!Vi?(v.updateQueue=p.updateQueue,v.flags&=-2053,p.lanes&=~W,Da(p,v,W)):(on&&I&&Tn(v),v.flags|=1,si(p,v,A,W),v.child)}function $g(p,v,A,I,W){if(Fi(A)){var Z=!0;nd(v)}else Z=!1;if(zl(v,W),v.stateNode===null)yd(p,v),wg(v,A,I),wh(v,A,I,W),I=!0;else if(p===null){var de=v.stateNode,ke=v.memoizedProps;de.props=ke;var Re=de.context,Xe=A.contextType;typeof Xe=="object"&&Xe!==null?Xe=_s(Xe):(Xe=Fi(A)?Go:Si.current,Xe=ki(v,Xe));var ft=A.getDerivedStateFromProps,ht=typeof ft=="function"||typeof de.getSnapshotBeforeUpdate=="function";ht||typeof de.UNSAFE_componentWillReceiveProps!="function"&&typeof de.componentWillReceiveProps!="function"||(ke!==I||Re!==Xe)&&_g(v,de,I,Xe),ha=!1;var dt=v.memoizedState;de.state=dt,dd(v,I,de,W),Re=v.memoizedState,ke!==I||dt!==Re||zi.current||ha?(typeof ft=="function"&&(ma(v,A,ft,I),Re=v.memoizedState),(ke=ha||rl(v,A,ke,I,dt,Re,Xe))?(ht||typeof de.UNSAFE_componentWillMount!="function"&&typeof de.componentWillMount!="function"||(typeof de.componentWillMount=="function"&&de.componentWillMount(),typeof de.UNSAFE_componentWillMount=="function"&&de.UNSAFE_componentWillMount()),typeof de.componentDidMount=="function"&&(v.flags|=4194308)):(typeof de.componentDidMount=="function"&&(v.flags|=4194308),v.memoizedProps=I,v.memoizedState=Re),de.props=I,de.state=Re,de.context=Xe,I=ke):(typeof de.componentDidMount=="function"&&(v.flags|=4194308),I=!1)}else{de=v.stateNode,oh(p,v),ke=v.memoizedProps,Xe=v.type===v.elementType?ke:$n(v.type,ke),de.props=Xe,ht=v.pendingProps,dt=de.context,Re=A.contextType,typeof Re=="object"&&Re!==null?Re=_s(Re):(Re=Fi(A)?Go:Si.current,Re=ki(v,Re));var jt=A.getDerivedStateFromProps;(ft=typeof jt=="function"||typeof de.getSnapshotBeforeUpdate=="function")||typeof de.UNSAFE_componentWillReceiveProps!="function"&&typeof de.componentWillReceiveProps!="function"||(ke!==ht||dt!==Re)&&_g(v,de,I,Re),ha=!1,dt=v.memoizedState,de.state=dt,dd(v,I,de,W);var Rt=v.memoizedState;ke!==ht||dt!==Rt||zi.current||ha?(typeof jt=="function"&&(ma(v,A,jt,I),Rt=v.memoizedState),(Xe=ha||rl(v,A,Xe,I,dt,Rt,Re)||!1)?(ft||typeof de.UNSAFE_componentWillUpdate!="function"&&typeof de.componentWillUpdate!="function"||(typeof de.componentWillUpdate=="function"&&de.componentWillUpdate(I,Rt,Re),typeof de.UNSAFE_componentWillUpdate=="function"&&de.UNSAFE_componentWillUpdate(I,Rt,Re)),typeof de.componentDidUpdate=="function"&&(v.flags|=4),typeof de.getSnapshotBeforeUpdate=="function"&&(v.flags|=1024)):(typeof de.componentDidUpdate!="function"||ke===p.memoizedProps&&dt===p.memoizedState||(v.flags|=4),typeof de.getSnapshotBeforeUpdate!="function"||ke===p.memoizedProps&&dt===p.memoizedState||(v.flags|=1024),v.memoizedProps=I,v.memoizedState=Rt),de.props=I,de.state=Rt,de.context=Re,I=Xe):(typeof de.componentDidUpdate!="function"||ke===p.memoizedProps&&dt===p.memoizedState||(v.flags|=4),typeof de.getSnapshotBeforeUpdate!="function"||ke===p.memoizedProps&&dt===p.memoizedState||(v.flags|=1024),I=!1)}return Ch(p,v,A,I,Z,W)}function Ch(p,v,A,I,W,Z){Ag(p,v);var de=(v.flags&128)!==0;if(!I&&!de)return W&&Xm(v,A,!1),Da(p,v,Z);I=v.stateNode,Qb.current=v;var ke=de&&typeof A.getDerivedStateFromError!="function"?null:I.render();return v.flags|=1,p!==null&&de?(v.child=Bl(v,p.child,null,Z),v.child=Bl(v,null,ke,Z)):si(p,v,ke,Z),v.memoizedState=I.state,W&&Xm(v,A,!0),v.child}function jh(p){var v=p.stateNode;v.pendingContext?Gm(p,v.pendingContext,v.pendingContext!==v.context):v.context&&Gm(p,v.context,!1),lh(p,v.containerInfo)}function Ng(p,v,A,I,W){return Xo(),eh(W),v.flags|=256,si(p,v,A,I),v.child}var Eh={dehydrated:null,treeContext:null,retryLane:0};function Th(p){return{baseLanes:p,cachePool:null,transitions:null}}function Og(p,v,A){var I=v.pendingProps,W=un.current,Z=!1,de=(v.flags&128)!==0,ke;if((ke=de)||(ke=p!==null&&p.memoizedState===null?!1:(W&2)!==0),ke?(Z=!0,v.flags&=-129):(p===null||p.memoizedState!==null)&&(W|=1),Wr(un,W&1),p===null)return Zf(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):(de=I.children,p=I.fallback,Z?(I=v.mode,Z=v.child,de={mode:"hidden",children:de},(I&1)===0&&Z!==null?(Z.childLanes=0,Z.pendingProps=de):Z=$d(de,I,0,null),p=Kl(p,I,A,null),Z.return=v,p.return=v,Z.sibling=p,v.child=Z,v.child.memoizedState=Th(A),v.memoizedState=Eh,p):Xc(v,de));if(W=p.memoizedState,W!==null&&(ke=W.dehydrated,ke!==null))return ex(p,v,de,I,ke,W,A);if(Z){Z=I.fallback,de=v.mode,W=p.child,ke=W.sibling;var Re={mode:"hidden",children:I.children};return(de&1)===0&&v.child!==W?(I=v.child,I.childLanes=0,I.pendingProps=Re,v.deletions=null):(I=So(W,Re),I.subtreeFlags=W.subtreeFlags&14680064),ke!==null?Z=So(ke,Z):(Z=Kl(Z,de,A,null),Z.flags|=2),Z.return=v,I.return=v,I.sibling=Z,v.child=I,I=Z,Z=v.child,de=p.child.memoizedState,de=de===null?Th(A):{baseLanes:de.baseLanes|A,cachePool:null,transitions:de.transitions},Z.memoizedState=de,Z.childLanes=p.childLanes&~A,v.memoizedState=Eh,I}return Z=p.child,p=Z.sibling,I=So(Z,{mode:"visible",children:I.children}),(v.mode&1)===0&&(I.lanes=A),I.return=v,I.sibling=null,p!==null&&(A=v.deletions,A===null?(v.deletions=[p],v.flags|=16):A.push(p)),v.child=I,v.memoizedState=null,I}function Xc(p,v){return v=$d({mode:"visible",children:v},p.mode,0,null),v.return=p,p.child=v}function vd(p,v,A,I){return I!==null&&eh(I),Bl(v,p.child,null,A),p=Xc(v,v.pendingProps.children),p.flags|=2,v.memoizedState=null,p}function ex(p,v,A,I,W,Z,de){if(A)return v.flags&256?(v.flags&=-257,I=_h(Error(n(422))),vd(p,v,de,I)):v.memoizedState!==null?(v.child=p.child,v.flags|=128,null):(Z=I.fallback,W=v.mode,I=$d({mode:"visible",children:I.children},W,0,null),Z=Kl(Z,W,de,null),Z.flags|=2,I.return=v,Z.return=v,I.sibling=Z,v.child=I,(v.mode&1)!==0&&Bl(v,p.child,null,de),v.child.memoizedState=Th(de),v.memoizedState=Eh,Z);if((v.mode&1)===0)return vd(p,v,de,null);if(W.data==="$!"){if(I=W.nextSibling&&W.nextSibling.dataset,I)var ke=I.dgst;return I=ke,Z=Error(n(419)),I=_h(Z,I,void 0),vd(p,v,de,I)}if(ke=(de&p.childLanes)!==0,Vi||ke){if(I=Nn,I!==null){switch(de&-de){case 4:W=2;break;case 16:W=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:W=32;break;case 536870912:W=268435456;break;default:W=0}W=(W&(I.suspendedLanes|de))!==0?0:W,W!==0&&W!==Z.retryLane&&(Z.retryLane=W,Ra(p,W),Gs(I,p,W,-1))}return Yh(),I=_h(Error(n(421))),vd(p,v,de,I)}return W.data==="$?"?(v.flags|=128,v.child=p.child,v=dx.bind(null,p),W._reactRetry=v,null):(p=Z.treeContext,ss=fo(W.nextSibling),Wi=v,on=!0,Hi=null,p!==null&&(xs[qs++]=Ui,xs[qs++]=qi,xs[qs++]=ws,Ui=p.id,qi=p.overflow,ws=v),v=Xc(v,I.children),v.flags|=4096,v)}function Pg(p,v,A){p.lanes|=v;var I=p.alternate;I!==null&&(I.lanes|=v),Qm(p.return,v,A)}function Ah(p,v,A,I,W){var Z=p.memoizedState;Z===null?p.memoizedState={isBackwards:v,rendering:null,renderingStartTime:0,last:I,tail:A,tailMode:W}:(Z.isBackwards=v,Z.rendering=null,Z.renderingStartTime=0,Z.last=I,Z.tail=A,Z.tailMode=W)}function $h(p,v,A){var I=v.pendingProps,W=I.revealOrder,Z=I.tail;if(si(p,v,I.children,A),I=un.current,(I&2)!==0)I=I&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&&Pg(p,A,v);else if(p.tag===19)Pg(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}I&=1}if(Wr(un,I),(v.mode&1)===0)v.memoizedState=null;else switch(W){case"forwards":for(A=v.child,W=null;A!==null;)p=A.alternate,p!==null&&fd(p)===null&&(W=A),A=A.sibling;A=W,A===null?(W=v.child,v.child=null):(W=A.sibling,A.sibling=null),Ah(v,!1,W,A,Z);break;case"backwards":for(A=null,W=v.child,v.child=null;W!==null;){if(p=W.alternate,p!==null&&fd(p)===null){v.child=W;break}p=W.sibling,W.sibling=A,A=W,W=p}Ah(v,!0,A,null,Z);break;case"together":Ah(v,!1,null,null,void 0);break;default:v.memoizedState=null}return v.child}function yd(p,v){(v.mode&1)===0&&p!==null&&(p.alternate=null,v.alternate=null,v.flags|=2)}function Da(p,v,A){if(p!==null&&(v.dependencies=p.dependencies),nl|=v.lanes,(A&v.childLanes)===0)return null;if(p!==null&&v.child!==p.child)throw Error(n(153));if(v.child!==null){for(p=v.child,A=So(p,p.pendingProps),v.child=A,A.return=v;p.sibling!==null;)p=p.sibling,A=A.sibling=So(p,p.pendingProps),A.return=v;A.sibling=null}return v.child}function c1(p,v,A){switch(v.tag){case 3:jh(v),Xo();break;case 5:eg(v);break;case 1:Fi(v.type)&&nd(v);break;case 4:lh(v,v.stateNode.containerInfo);break;case 10:var I=v.type._context,W=v.memoizedProps.value;Wr(Yo,I._currentValue),I._currentValue=W;break;case 13:if(I=v.memoizedState,I!==null)return I.dehydrated!==null?(Wr(un,un.current&1),v.flags|=128,null):(A&v.child.childLanes)!==0?Og(p,v,A):(Wr(un,un.current&1),p=Da(p,v,A),p!==null?p.sibling:null);Wr(un,un.current&1);break;case 19:if(I=(A&v.childLanes)!==0,(p.flags&128)!==0){if(I)return $h(p,v,A);v.flags|=128}if(W=v.memoizedState,W!==null&&(W.rendering=null,W.tail=null,W.lastEffect=null),Wr(un,un.current),I)break;return null;case 22:case 23:return v.lanes=0,Tg(p,v,A)}return Da(p,v,A)}var Nh,Oh,Rg,Mg;Nh=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}},Oh=function(){},Rg=function(p,v,A,I){var W=p.memoizedProps;if(W!==I){p=v.stateNode,Zo(pa.current);var Z=null;switch(A){case"input":W=Le(p,W),I=Le(p,I),Z=[];break;case"select":W=Q({},W,{value:void 0}),I=Q({},I,{value:void 0}),Z=[];break;case"textarea":W=jr(p,W),I=jr(p,I),Z=[];break;default:typeof W.onClick!="function"&&typeof I.onClick=="function"&&(p.onclick=ed)}fs(A,I);var de;A=null;for(Xe in W)if(!I.hasOwnProperty(Xe)&&W.hasOwnProperty(Xe)&&W[Xe]!=null)if(Xe==="style"){var ke=W[Xe];for(de in ke)ke.hasOwnProperty(de)&&(A||(A={}),A[de]="")}else Xe!=="dangerouslySetInnerHTML"&&Xe!=="children"&&Xe!=="suppressContentEditableWarning"&&Xe!=="suppressHydrationWarning"&&Xe!=="autoFocus"&&(s.hasOwnProperty(Xe)?Z||(Z=[]):(Z=Z||[]).push(Xe,null));for(Xe in I){var Re=I[Xe];if(ke=W!=null?W[Xe]:void 0,I.hasOwnProperty(Xe)&&Re!==ke&&(Re!=null||ke!=null))if(Xe==="style")if(ke){for(de in ke)!ke.hasOwnProperty(de)||Re&&Re.hasOwnProperty(de)||(A||(A={}),A[de]="");for(de in Re)Re.hasOwnProperty(de)&&ke[de]!==Re[de]&&(A||(A={}),A[de]=Re[de])}else A||(Z||(Z=[]),Z.push(Xe,A)),A=Re;else Xe==="dangerouslySetInnerHTML"?(Re=Re?Re.__html:void 0,ke=ke?ke.__html:void 0,Re!=null&&ke!==Re&&(Z=Z||[]).push(Xe,Re)):Xe==="children"?typeof Re!="string"&&typeof Re!="number"||(Z=Z||[]).push(Xe,""+Re):Xe!=="suppressContentEditableWarning"&&Xe!=="suppressHydrationWarning"&&(s.hasOwnProperty(Xe)?(Re!=null&&Xe==="onScroll"&&Kr("scroll",p),Z||ke===Re||(Z=[])):(Z=Z||[]).push(Xe,Re))}A&&(Z=Z||[]).push("style",A);var Xe=Z;(v.updateQueue=Xe)&&(v.flags|=4)}},Mg=function(p,v,A,I){A!==I&&(v.flags|=4)};function bd(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 I=null;A!==null;)A.alternate!==null&&(I=A),A=A.sibling;I===null?v||p.tail===null?p.tail=null:p.tail.sibling=null:I.sibling=null}}function ai(p){var v=p.alternate!==null&&p.alternate.child===p.child,A=0,I=0;if(v)for(var W=p.child;W!==null;)A|=W.lanes|W.childLanes,I|=W.subtreeFlags&14680064,I|=W.flags&14680064,W.return=p,W=W.sibling;else for(W=p.child;W!==null;)A|=W.lanes|W.childLanes,I|=W.subtreeFlags,I|=W.flags,W.return=p,W=W.sibling;return p.subtreeFlags|=I,p.childLanes=A,v}function tx(p,v,A){var I=v.pendingProps;switch(Kf(v),v.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ai(v),null;case 1:return Fi(v.type)&&rd(),ai(v),null;case 3:return I=v.stateNode,Qo(),Xr(zi),Xr(Si),dh(),I.pendingContext&&(I.context=I.pendingContext,I.pendingContext=null),(p===null||p.child===null)&&(qc(v)?v.flags|=4:p===null||p.memoizedState.isDehydrated&&(v.flags&256)===0||(v.flags|=1024,Hi!==null&&(Gh(Hi),Hi=null))),Oh(p,v),ai(v),null;case 5:ch(v);var W=Zo(Ul.current);if(A=v.type,p!==null&&v.stateNode!=null)Rg(p,v,A,I,W),p.ref!==v.ref&&(v.flags|=512,v.flags|=2097152);else{if(!I){if(v.stateNode===null)throw Error(n(166));return ai(v),null}if(p=Zo(pa.current),qc(v)){I=v.stateNode,A=v.type;var Z=v.memoizedProps;switch(I[da]=v,I[Fc]=Z,p=(v.mode&1)!==0,A){case"dialog":Kr("cancel",I),Kr("close",I);break;case"iframe":case"object":case"embed":Kr("load",I);break;case"video":case"audio":for(W=0;W<Lc.length;W++)Kr(Lc[W],I);break;case"source":Kr("error",I);break;case"img":case"image":case"link":Kr("error",I),Kr("load",I);break;case"details":Kr("toggle",I);break;case"input":Ue(I,Z),Kr("invalid",I);break;case"select":I._wrapperState={wasMultiple:!!Z.multiple},Kr("invalid",I);break;case"textarea":fr(I,Z),Kr("invalid",I)}fs(A,Z),W=null;for(var de in Z)if(Z.hasOwnProperty(de)){var ke=Z[de];de==="children"?typeof ke=="string"?I.textContent!==ke&&(Z.suppressHydrationWarning!==!0&&Qu(I.textContent,ke,p),W=["children",ke]):typeof ke=="number"&&I.textContent!==""+ke&&(Z.suppressHydrationWarning!==!0&&Qu(I.textContent,ke,p),W=["children",""+ke]):s.hasOwnProperty(de)&&ke!=null&&de==="onScroll"&&Kr("scroll",I)}switch(A){case"input":Ae(I),Zt(I,Z,!0);break;case"textarea":Ae(I),Ir(I);break;case"select":case"option":break;default:typeof Z.onClick=="function"&&(I.onclick=ed)}I=W,v.updateQueue=I,I!==null&&(v.flags|=4)}else{de=W.nodeType===9?W:W.ownerDocument,p==="http://www.w3.org/1999/xhtml"&&(p=fi(A)),p==="http://www.w3.org/1999/xhtml"?A==="script"?(p=de.createElement("div"),p.innerHTML="<script><\/script>",p=p.removeChild(p.firstChild)):typeof I.is=="string"?p=de.createElement(A,{is:I.is}):(p=de.createElement(A),A==="select"&&(de=p,I.multiple?de.multiple=!0:I.size&&(de.size=I.size))):p=de.createElementNS(p,A),p[da]=v,p[Fc]=I,Nh(p,v,!1,!1),v.stateNode=p;e:{switch(de=Sr(A,I),A){case"dialog":Kr("cancel",p),Kr("close",p),W=I;break;case"iframe":case"object":case"embed":Kr("load",p),W=I;break;case"video":case"audio":for(W=0;W<Lc.length;W++)Kr(Lc[W],p);W=I;break;case"source":Kr("error",p),W=I;break;case"img":case"image":case"link":Kr("error",p),Kr("load",p),W=I;break;case"details":Kr("toggle",p),W=I;break;case"input":Ue(p,I),W=Le(p,I),Kr("invalid",p);break;case"option":W=I;break;case"select":p._wrapperState={wasMultiple:!!I.multiple},W=Q({},I,{value:void 0}),Kr("invalid",p);break;case"textarea":fr(p,I),W=jr(p,I),Kr("invalid",p);break;default:W=I}fs(A,W),ke=W;for(Z in ke)if(ke.hasOwnProperty(Z)){var Re=ke[Z];Z==="style"?xn(p,Re):Z==="dangerouslySetInnerHTML"?(Re=Re?Re.__html:void 0,Re!=null&&Rn(p,Re)):Z==="children"?typeof Re=="string"?(A!=="textarea"||Re!=="")&&ut(p,Re):typeof Re=="number"&&ut(p,""+Re):Z!=="suppressContentEditableWarning"&&Z!=="suppressHydrationWarning"&&Z!=="autoFocus"&&(s.hasOwnProperty(Z)?Re!=null&&Z==="onScroll"&&Kr("scroll",p):Re!=null&&C(p,Z,Re,de))}switch(A){case"input":Ae(p),Zt(p,I,!1);break;case"textarea":Ae(p),Ir(p);break;case"option":I.value!=null&&p.setAttribute("value",""+ie(I.value));break;case"select":p.multiple=!!I.multiple,Z=I.value,Z!=null?Vt(p,!!I.multiple,Z,!1):I.defaultValue!=null&&Vt(p,!!I.multiple,I.defaultValue,!0);break;default:typeof W.onClick=="function"&&(p.onclick=ed)}switch(A){case"button":case"input":case"select":case"textarea":I=!!I.autoFocus;break e;case"img":I=!0;break e;default:I=!1}}I&&(v.flags|=4)}v.ref!==null&&(v.flags|=512,v.flags|=2097152)}return ai(v),null;case 6:if(p&&v.stateNode!=null)Mg(p,v,p.memoizedProps,I);else{if(typeof I!="string"&&v.stateNode===null)throw Error(n(166));if(A=Zo(Ul.current),Zo(pa.current),qc(v)){if(I=v.stateNode,A=v.memoizedProps,I[da]=v,(Z=I.nodeValue!==A)&&(p=Wi,p!==null))switch(p.tag){case 3:Qu(I.nodeValue,A,(p.mode&1)!==0);break;case 5:p.memoizedProps.suppressHydrationWarning!==!0&&Qu(I.nodeValue,A,(p.mode&1)!==0)}Z&&(v.flags|=4)}else I=(A.nodeType===9?A:A.ownerDocument).createTextNode(I),I[da]=v,v.stateNode=I}return ai(v),null;case 13:if(Xr(un),I=v.memoizedState,p===null||p.memoizedState!==null&&p.memoizedState.dehydrated!==null){if(on&&ss!==null&&(v.mode&1)!==0&&(v.flags&128)===0)Jm(),Xo(),v.flags|=98560,Z=!1;else if(Z=qc(v),I!==null&&I.dehydrated!==null){if(p===null){if(!Z)throw Error(n(318));if(Z=v.memoizedState,Z=Z!==null?Z.dehydrated:null,!Z)throw Error(n(317));Z[da]=v}else Xo(),(v.flags&128)===0&&(v.memoizedState=null),v.flags|=4;ai(v),Z=!1}else Hi!==null&&(Gh(Hi),Hi=null),Z=!0;if(!Z)return v.flags&65536?v:null}return(v.flags&128)!==0?(v.lanes=A,v):(I=I!==null,I!==(p!==null&&p.memoizedState!==null)&&I&&(v.child.flags|=8192,(v.mode&1)!==0&&(p===null||(un.current&1)!==0?Bn===0&&(Bn=3):Yh())),v.updateQueue!==null&&(v.flags|=4),ai(v),null);case 4:return Qo(),Oh(p,v),p===null&&Bc(v.stateNode.containerInfo),ai(v),null;case 10:return sh(v.type._context),ai(v),null;case 17:return Fi(v.type)&&rd(),ai(v),null;case 19:if(Xr(un),Z=v.memoizedState,Z===null)return ai(v),null;if(I=(v.flags&128)!==0,de=Z.rendering,de===null)if(I)bd(Z,!1);else{if(Bn!==0||p!==null&&(p.flags&128)!==0)for(p=v.child;p!==null;){if(de=fd(p),de!==null){for(v.flags|=128,bd(Z,!1),I=de.updateQueue,I!==null&&(v.updateQueue=I,v.flags|=4),v.subtreeFlags=0,I=A,A=v.child;A!==null;)Z=A,p=I,Z.flags&=14680066,de=Z.alternate,de===null?(Z.childLanes=0,Z.lanes=p,Z.child=null,Z.subtreeFlags=0,Z.memoizedProps=null,Z.memoizedState=null,Z.updateQueue=null,Z.dependencies=null,Z.stateNode=null):(Z.childLanes=de.childLanes,Z.lanes=de.lanes,Z.child=de.child,Z.subtreeFlags=0,Z.deletions=null,Z.memoizedProps=de.memoizedProps,Z.memoizedState=de.memoizedState,Z.updateQueue=de.updateQueue,Z.type=de.type,p=de.dependencies,Z.dependencies=p===null?null:{lanes:p.lanes,firstContext:p.firstContext}),A=A.sibling;return Wr(un,un.current&1|2),v.child}p=p.sibling}Z.tail!==null&&Tr()>Vl&&(v.flags|=128,I=!0,bd(Z,!1),v.lanes=4194304)}else{if(!I)if(p=fd(de),p!==null){if(v.flags|=128,I=!0,A=p.updateQueue,A!==null&&(v.updateQueue=A,v.flags|=4),bd(Z,!0),Z.tail===null&&Z.tailMode==="hidden"&&!de.alternate&&!on)return ai(v),null}else 2*Tr()-Z.renderingStartTime>Vl&&A!==1073741824&&(v.flags|=128,I=!0,bd(Z,!1),v.lanes=4194304);Z.isBackwards?(de.sibling=v.child,v.child=de):(A=Z.last,A!==null?A.sibling=de:v.child=de,Z.last=de)}return Z.tail!==null?(v=Z.tail,Z.rendering=v,Z.tail=v.sibling,Z.renderingStartTime=Tr(),v.sibling=null,A=un.current,Wr(un,I?A&1|2:A&1),v):(ai(v),null);case 22:case 23:return Xh(),I=v.memoizedState!==null,p!==null&&p.memoizedState!==null!==I&&(v.flags|=8192),I&&(v.mode&1)!==0?(as&1073741824)!==0&&(ai(v),v.subtreeFlags&6&&(v.flags|=8192)):ai(v),null;case 24:return null;case 25:return null}throw Error(n(156,v.tag))}function rx(p,v){switch(Kf(v),v.tag){case 1:return Fi(v.type)&&rd(),p=v.flags,p&65536?(v.flags=p&-65537|128,v):null;case 3:return Qo(),Xr(zi),Xr(Si),dh(),p=v.flags,(p&65536)!==0&&(p&128)===0?(v.flags=p&-65537|128,v):null;case 5:return ch(v),null;case 13:if(Xr(un),p=v.memoizedState,p!==null&&p.dehydrated!==null){if(v.alternate===null)throw Error(n(340));Xo()}return p=v.flags,p&65536?(v.flags=p&-65537|128,v):null;case 19:return Xr(un),null;case 4:return Qo(),null;case 10:return sh(v.type._context),null;case 22:case 23:return Xh(),null;case 24:return null;default:return null}}var Ph=!1,oi=!1,nx=typeof WeakSet=="function"?WeakSet:Set,Pt=null;function Wl(p,v){var A=p.ref;if(A!==null)if(typeof A=="function")try{A(null)}catch(I){dn(p,v,I)}else A.current=null}function Rh(p,v,A){try{A()}catch(I){dn(p,v,I)}}var Ig=!1;function ix(p,v){if(zf=co,p=Of(),Pf(p)){if("selectionStart"in p)var A={start:p.selectionStart,end:p.selectionEnd};else e:{A=(A=p.ownerDocument)&&A.defaultView||window;var I=A.getSelection&&A.getSelection();if(I&&I.rangeCount!==0){A=I.anchorNode;var W=I.anchorOffset,Z=I.focusNode;I=I.focusOffset;try{A.nodeType,Z.nodeType}catch{A=null;break e}var de=0,ke=-1,Re=-1,Xe=0,ft=0,ht=p,dt=null;t:for(;;){for(var jt;ht!==A||W!==0&&ht.nodeType!==3||(ke=de+W),ht!==Z||I!==0&&ht.nodeType!==3||(Re=de+I),ht.nodeType===3&&(de+=ht.nodeValue.length),(jt=ht.firstChild)!==null;)dt=ht,ht=jt;for(;;){if(ht===p)break t;if(dt===A&&++Xe===W&&(ke=de),dt===Z&&++ft===I&&(Re=de),(jt=ht.nextSibling)!==null)break;ht=dt,dt=ht.parentNode}ht=jt}A=ke===-1||Re===-1?null:{start:ke,end:Re}}else A=null}A=A||{start:0,end:0}}else A=null;for(Ff={focusedElem:p,selectionRange:A},co=!1,Pt=v;Pt!==null;)if(v=Pt,p=v.child,(v.subtreeFlags&1028)!==0&&p!==null)p.return=v,Pt=p;else for(;Pt!==null;){v=Pt;try{var Rt=v.alternate;if((v.flags&1024)!==0)switch(v.tag){case 0:case 11:case 15:break;case 1:if(Rt!==null){var It=Rt.memoizedProps,Hr=Rt.memoizedState,Ge=v.stateNode,Be=Ge.getSnapshotBeforeUpdate(v.elementType===v.type?It:$n(v.type,It),Hr);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(gt){dn(v,v.return,gt)}if(p=v.sibling,p!==null){p.return=v.return,Pt=p;break}Pt=v.return}return Rt=Ig,Ig=!1,Rt}function Yc(p,v,A){var I=v.updateQueue;if(I=I!==null?I.lastEffect:null,I!==null){var W=I=I.next;do{if((W.tag&p)===p){var Z=W.destroy;W.destroy=void 0,Z!==void 0&&Rh(v,A,Z)}W=W.next}while(W!==I)}}function Mh(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 I=A.create;A.destroy=I()}A=A.next}while(A!==v)}}function Ih(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 Dg(p){var v=p.alternate;v!==null&&(p.alternate=null,Dg(v)),p.child=null,p.deletions=null,p.sibling=null,p.tag===5&&(v=p.stateNode,v!==null&&(delete v[da],delete v[Fc],delete v[Hf],delete v[Hm],delete v[Vm])),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 Lg(p){return p.tag===5||p.tag===3||p.tag===4}function Bg(p){e:for(;;){for(;p.sibling===null;){if(p.return===null||Lg(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 Dh(p,v,A){var I=p.tag;if(I===5||I===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=ed));else if(I!==4&&(p=p.child,p!==null))for(Dh(p,v,A),p=p.sibling;p!==null;)Dh(p,v,A),p=p.sibling}function Lh(p,v,A){var I=p.tag;if(I===5||I===6)p=p.stateNode,v?A.insertBefore(p,v):A.appendChild(p);else if(I!==4&&(p=p.child,p!==null))for(Lh(p,v,A),p=p.sibling;p!==null;)Lh(p,v,A),p=p.sibling}var Vn=null,Hs=!1;function yo(p,v,A){for(A=A.child;A!==null;)sx(p,v,A),A=A.sibling}function sx(p,v,A){if(Mn&&typeof Mn.onCommitFiberUnmount=="function")try{Mn.onCommitFiberUnmount(Di,A)}catch{}switch(A.tag){case 5:oi||Wl(A,v);case 6:var I=Vn,W=Hs;Vn=null,yo(p,v,A),Vn=I,Hs=W,Vn!==null&&(Hs?(p=Vn,A=A.stateNode,p.nodeType===8?p.parentNode.removeChild(A):p.removeChild(A)):Vn.removeChild(A.stateNode));break;case 18:Vn!==null&&(Hs?(p=Vn,A=A.stateNode,p.nodeType===8?Wf(p.parentNode,A):p.nodeType===1&&Wf(p,A),$a(p)):Wf(Vn,A.stateNode));break;case 4:I=Vn,W=Hs,Vn=A.stateNode.containerInfo,Hs=!0,yo(p,v,A),Vn=I,Hs=W;break;case 0:case 11:case 14:case 15:if(!oi&&(I=A.updateQueue,I!==null&&(I=I.lastEffect,I!==null))){W=I=I.next;do{var Z=W,de=Z.destroy;Z=Z.tag,de!==void 0&&((Z&2)!==0||(Z&4)!==0)&&Rh(A,v,de),W=W.next}while(W!==I)}yo(p,v,A);break;case 1:if(!oi&&(Wl(A,v),I=A.stateNode,typeof I.componentWillUnmount=="function"))try{I.props=A.memoizedProps,I.state=A.memoizedState,I.componentWillUnmount()}catch(ke){dn(A,v,ke)}yo(p,v,A);break;case 21:yo(p,v,A);break;case 22:A.mode&1?(oi=(I=oi)||A.memoizedState!==null,yo(p,v,A),oi=I):yo(p,v,A);break;default:yo(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 nx),v.forEach(function(I){var W=fx.bind(null,p,I);A.has(I)||(A.add(I),I.then(W,W))})}}function ks(p,v){var A=v.deletions;if(A!==null)for(var I=0;I<A.length;I++){var W=A[I];try{var Z=p,de=v,ke=de;e:for(;ke!==null;){switch(ke.tag){case 5:Vn=ke.stateNode,Hs=!1;break e;case 3:Vn=ke.stateNode.containerInfo,Hs=!0;break e;case 4:Vn=ke.stateNode.containerInfo,Hs=!0;break e}ke=ke.return}if(Vn===null)throw Error(n(160));sx(Z,de,W),Vn=null,Hs=!1;var Re=W.alternate;Re!==null&&(Re.return=null),W.return=null}catch(Xe){dn(W,v,Xe)}}if(v.subtreeFlags&12854)for(v=v.child;v!==null;)Bh(v,p),v=v.sibling}function Bh(p,v){var A=p.alternate,I=p.flags;switch(p.tag){case 0:case 11:case 14:case 15:if(ks(v,p),Vs(p),I&4){try{Yc(3,p,p.return),Mh(3,p)}catch(It){dn(p,p.return,It)}try{Yc(5,p,p.return)}catch(It){dn(p,p.return,It)}}break;case 1:ks(v,p),Vs(p),I&512&&A!==null&&Wl(A,A.return);break;case 5:if(ks(v,p),Vs(p),I&512&&A!==null&&Wl(A,A.return),p.flags&32){var W=p.stateNode;try{ut(W,"")}catch(It){dn(p,p.return,It)}}if(I&4&&(W=p.stateNode,W!=null)){var Z=p.memoizedProps,de=A!==null?A.memoizedProps:Z,ke=p.type,Re=p.updateQueue;if(p.updateQueue=null,Re!==null)try{ke==="input"&&Z.type==="radio"&&Z.name!=null&&st(W,Z),Sr(ke,de);var Xe=Sr(ke,Z);for(de=0;de<Re.length;de+=2){var ft=Re[de],ht=Re[de+1];ft==="style"?xn(W,ht):ft==="dangerouslySetInnerHTML"?Rn(W,ht):ft==="children"?ut(W,ht):C(W,ft,ht,Xe)}switch(ke){case"input":lt(W,Z);break;case"textarea":Ur(W,Z);break;case"select":var dt=W._wrapperState.wasMultiple;W._wrapperState.wasMultiple=!!Z.multiple;var jt=Z.value;jt!=null?Vt(W,!!Z.multiple,jt,!1):dt!==!!Z.multiple&&(Z.defaultValue!=null?Vt(W,!!Z.multiple,Z.defaultValue,!0):Vt(W,!!Z.multiple,Z.multiple?[]:"",!1))}W[Fc]=Z}catch(It){dn(p,p.return,It)}}break;case 6:if(ks(v,p),Vs(p),I&4){if(p.stateNode===null)throw Error(n(162));W=p.stateNode,Z=p.memoizedProps;try{W.nodeValue=Z}catch(It){dn(p,p.return,It)}}break;case 3:if(ks(v,p),Vs(p),I&4&&A!==null&&A.memoizedState.isDehydrated)try{$a(v.containerInfo)}catch(It){dn(p,p.return,It)}break;case 4:ks(v,p),Vs(p);break;case 13:ks(v,p),Vs(p),W=p.child,W.flags&8192&&(Z=W.memoizedState!==null,W.stateNode.isHidden=Z,!Z||W.alternate!==null&&W.alternate.memoizedState!==null||(qh=Tr())),I&4&&Jc(p);break;case 22:if(ft=A!==null&&A.memoizedState!==null,p.mode&1?(oi=(Xe=oi)||ft,ks(v,p),oi=Xe):ks(v,p),Vs(p),I&8192){if(Xe=p.memoizedState!==null,(p.stateNode.isHidden=Xe)&&!ft&&(p.mode&1)!==0)for(Pt=p,ft=p.child;ft!==null;){for(ht=Pt=ft;Pt!==null;){switch(dt=Pt,jt=dt.child,dt.tag){case 0:case 11:case 14:case 15:Yc(4,dt,dt.return);break;case 1:Wl(dt,dt.return);var Rt=dt.stateNode;if(typeof Rt.componentWillUnmount=="function"){I=dt,A=dt.return;try{v=I,Rt.props=v.memoizedProps,Rt.state=v.memoizedState,Rt.componentWillUnmount()}catch(It){dn(I,A,It)}}break;case 5:Wl(dt,dt.return);break;case 22:if(dt.memoizedState!==null){zh(ht);continue}}jt!==null?(jt.return=dt,Pt=jt):zh(ht)}ft=ft.sibling}e:for(ft=null,ht=p;;){if(ht.tag===5){if(ft===null){ft=ht;try{W=ht.stateNode,Xe?(Z=W.style,typeof Z.setProperty=="function"?Z.setProperty("display","none","important"):Z.display="none"):(ke=ht.stateNode,Re=ht.memoizedProps.style,de=Re!=null&&Re.hasOwnProperty("display")?Re.display:null,ke.style.display=_r("display",de))}catch(It){dn(p,p.return,It)}}}else if(ht.tag===6){if(ft===null)try{ht.stateNode.nodeValue=Xe?"":ht.memoizedProps}catch(It){dn(p,p.return,It)}}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:ks(v,p),Vs(p),I&4&&Jc(p);break;case 21:break;default:ks(v,p),Vs(p)}}function Vs(p){var v=p.flags;if(v&2){try{e:{for(var A=p.return;A!==null;){if(Lg(A)){var I=A;break e}A=A.return}throw Error(n(160))}switch(I.tag){case 5:var W=I.stateNode;I.flags&32&&(ut(W,""),I.flags&=-33);var Z=Bg(p);Lh(p,Z,W);break;case 3:case 4:var de=I.stateNode.containerInfo,ke=Bg(p);Dh(p,ke,de);break;default:throw Error(n(161))}}catch(Re){dn(p,p.return,Re)}p.flags&=-3}v&4096&&(p.flags&=-4097)}function zg(p,v,A){Pt=p,Fg(p)}function Fg(p,v,A){for(var I=(p.mode&1)!==0;Pt!==null;){var W=Pt,Z=W.child;if(W.tag===22&&I){var de=W.memoizedState!==null||Ph;if(!de){var ke=W.alternate,Re=ke!==null&&ke.memoizedState!==null||oi;ke=Ph;var Xe=oi;if(Ph=de,(oi=Re)&&!Xe)for(Pt=W;Pt!==null;)de=Pt,Re=de.child,de.tag===22&&de.memoizedState!==null?Fh(W):Re!==null?(Re.return=de,Pt=Re):Fh(W);for(;Z!==null;)Pt=Z,Fg(Z),Z=Z.sibling;Pt=W,Ph=ke,oi=Xe}Ug(p)}else(W.subtreeFlags&8772)!==0&&Z!==null?(Z.return=W,Pt=Z):Ug(p)}}function Ug(p){for(;Pt!==null;){var v=Pt;if((v.flags&8772)!==0){var A=v.alternate;try{if((v.flags&8772)!==0)switch(v.tag){case 0:case 11:case 15:oi||Mh(5,v);break;case 1:var I=v.stateNode;if(v.flags&4&&!oi)if(A===null)I.componentDidMount();else{var W=v.elementType===v.type?A.memoizedProps:$n(v.type,A.memoizedProps);I.componentDidUpdate(W,A.memoizedState,I.__reactInternalSnapshotBeforeUpdate)}var Z=v.updateQueue;Z!==null&&qb(v,Z,I);break;case 3:var de=v.updateQueue;if(de!==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,de,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&&$a(ht)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}oi||v.flags&512&&Ih(v)}catch(dt){dn(v,v.return,dt)}}if(v===p){Pt=null;break}if(A=v.sibling,A!==null){A.return=v.return,Pt=A;break}Pt=v.return}}function zh(p){for(;Pt!==null;){var v=Pt;if(v===p){Pt=null;break}var A=v.sibling;if(A!==null){A.return=v.return,Pt=A;break}Pt=v.return}}function Fh(p){for(;Pt!==null;){var v=Pt;try{switch(v.tag){case 0:case 11:case 15:var A=v.return;try{Mh(4,v)}catch(Re){dn(v,A,Re)}break;case 1:var I=v.stateNode;if(typeof I.componentDidMount=="function"){var W=v.return;try{I.componentDidMount()}catch(Re){dn(v,W,Re)}}var Z=v.return;try{Ih(v)}catch(Re){dn(v,Z,Re)}break;case 5:var de=v.return;try{Ih(v)}catch(Re){dn(v,de,Re)}}}catch(Re){dn(v,v.return,Re)}if(v===p){Pt=null;break}var ke=v.sibling;if(ke!==null){ke.return=v.return,Pt=ke;break}Pt=v.return}}var ax=Math.ceil,xd=E.ReactCurrentDispatcher,wd=E.ReactCurrentOwner,Cs=E.ReactCurrentBatchConfig,br=0,Nn=null,kn=null,Gn=0,as=0,Hl=Oa(0),Bn=0,Zc=null,nl=0,_d=0,Uh=0,Sd=null,Gi=null,qh=0,Vl=1/0,bo=null,kd=!1,Wh=null,xo=null,Cd=!1,il=null,jd=0,Qc=0,Hh=null,eu=-1,Ed=0;function ji(){return(br&6)!==0?Tr():eu!==-1?eu:eu=Tr()}function wo(p){return(p.mode&1)===0?1:(br&2)!==0&&Gn!==0?Gn&-Gn:th.transition!==null?(Ed===0&&(Ed=is()),Ed):(p=ze,p!==0||(p=window.event,p=p===void 0?16:he(p.type)),p)}function Gs(p,v,A,I){if(50<Qc)throw Qc=0,Hh=null,Error(n(185));vi(p,A,I),((br&2)===0||p!==Nn)&&(p===Nn&&((br&2)===0&&(_d|=A),Bn===4&&_o(p,Gn)),Ki(p,I),A===1&&br===0&&(v.mode&1)===0&&(Vl=Tr()+500,id&&po()))}function Ki(p,v){var A=p.callbackNode;Bi(p,v);var I=aa(p,p===Nn?Gn:0);if(I===0)A!==null&&Hn(A),p.callbackNode=null,p.callbackPriority=0;else if(v=I&-I,p.callbackPriority!==v){if(A!=null&&Hn(A),v===1)p.tag===0?a1(Hg.bind(null,p)):Ym(Hg.bind(null,p)),Bb(function(){(br&6)===0&&po()}),A=null;else{switch(et(I)){case 1:A=sn;break;case 4:A=ri;break;case 16:A=Is;break;case 536870912:A=na;break;default:A=Is}A=Jg(A,qg.bind(null,p))}p.callbackPriority=v,p.callbackNode=A}}function qg(p,v){if(eu=-1,Ed=0,(br&6)!==0)throw Error(n(327));var A=p.callbackNode;if(Gl()&&p.callbackNode!==A)return null;var I=aa(p,p===Nn?Gn:0);if(I===0)return null;if((I&30)!==0||(I&p.expiredLanes)!==0||v)v=Td(p,I);else{v=I;var W=br;br|=2;var Z=ox();(Nn!==p||Gn!==v)&&(bo=null,Vl=Tr()+500,al(p,v));do try{u1();break}catch(ke){Vg(p,ke)}while(!0);ih(),xd.current=Z,br=W,kn!==null?v=0:(Nn=null,Gn=0,v=Bn)}if(v!==0){if(v===2&&(W=Ta(p),W!==0&&(I=W,v=Vh(p,W))),v===1)throw A=Zc,al(p,0),_o(p,I),Ki(p,Tr()),A;if(v===6)_o(p,I);else{if(W=p.current.alternate,(I&30)===0&&!Wg(W)&&(v=Td(p,I),v===2&&(Z=Ta(p),Z!==0&&(I=Z,v=Vh(p,Z))),v===1))throw A=Zc,al(p,0),_o(p,I),Ki(p,Tr()),A;switch(p.finishedWork=W,p.finishedLanes=I,v){case 0:case 1:throw Error(n(345));case 2:ol(p,Gi,bo);break;case 3:if(_o(p,I),(I&130023424)===I&&(v=qh+500-Tr(),10<v)){if(aa(p,0)!==0)break;if(W=p.suspendedLanes,(W&I)!==I){ji(),p.pingedLanes|=p.suspendedLanes&W;break}p.timeoutHandle=qf(ol.bind(null,p,Gi,bo),v);break}ol(p,Gi,bo);break;case 4:if(_o(p,I),(I&4194240)===I)break;for(v=p.eventTimes,W=-1;0<I;){var de=31-an(I);Z=1<<de,de=v[de],de>W&&(W=de),I&=~Z}if(I=W,I=Tr()-I,I=(120>I?120:480>I?480:1080>I?1080:1920>I?1920:3e3>I?3e3:4320>I?4320:1960*ax(I/1960))-I,10<I){p.timeoutHandle=qf(ol.bind(null,p,Gi,bo),I);break}ol(p,Gi,bo);break;case 5:ol(p,Gi,bo);break;default:throw Error(n(329))}}}return Ki(p,Tr()),p.callbackNode===A?qg.bind(null,p):null}function Vh(p,v){var A=Sd;return p.current.memoizedState.isDehydrated&&(al(p,v).flags|=256),p=Td(p,v),p!==2&&(v=Gi,Gi=A,v!==null&&Gh(v)),p}function Gh(p){Gi===null?Gi=p:Gi.push.apply(Gi,p)}function Wg(p){for(var v=p;;){if(v.flags&16384){var A=v.updateQueue;if(A!==null&&(A=A.stores,A!==null))for(var I=0;I<A.length;I++){var W=A[I],Z=W.getSnapshot;W=W.value;try{if(!Us(Z(),W))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 _o(p,v){for(v&=~Uh,v&=~_d,p.suspendedLanes|=v,p.pingedLanes&=~v,p=p.expirationTimes;0<v;){var A=31-an(v),I=1<<A;p[A]=-1,v&=~I}}function Hg(p){if((br&6)!==0)throw Error(n(327));Gl();var v=aa(p,0);if((v&1)===0)return Ki(p,Tr()),null;var A=Td(p,v);if(p.tag!==0&&A===2){var I=Ta(p);I!==0&&(v=I,A=Vh(p,I))}if(A===1)throw A=Zc,al(p,0),_o(p,v),Ki(p,Tr()),A;if(A===6)throw Error(n(345));return p.finishedWork=p.current.alternate,p.finishedLanes=v,ol(p,Gi,bo),Ki(p,Tr()),null}function Kh(p,v){var A=br;br|=1;try{return p(v)}finally{br=A,br===0&&(Vl=Tr()+500,id&&po())}}function sl(p){il!==null&&il.tag===0&&(br&6)===0&&Gl();var v=br;br|=1;var A=Cs.transition,I=ze;try{if(Cs.transition=null,ze=1,p)return p()}finally{ze=I,Cs.transition=A,br=v,(br&6)===0&&po()}}function Xh(){as=Hl.current,Xr(Hl)}function al(p,v){p.finishedWork=null,p.finishedLanes=0;var A=p.timeoutHandle;if(A!==-1&&(p.timeoutHandle=-1,Lb(A)),kn!==null)for(A=kn.return;A!==null;){var I=A;switch(Kf(I),I.tag){case 1:I=I.type.childContextTypes,I!=null&&rd();break;case 3:Qo(),Xr(zi),Xr(Si),dh();break;case 5:ch(I);break;case 4:Qo();break;case 13:Xr(un);break;case 19:Xr(un);break;case 10:sh(I.type._context);break;case 22:case 23:Xh()}A=A.return}if(Nn=p,kn=p=So(p.current,null),Gn=as=v,Bn=0,Zc=null,Uh=_d=nl=0,Gi=Sd=null,Fl!==null){for(v=0;v<Fl.length;v++)if(A=Fl[v],I=A.interleaved,I!==null){A.interleaved=null;var W=I.next,Z=A.pending;if(Z!==null){var de=Z.next;Z.next=W,I.next=de}A.pending=I}Fl=null}return p}function Vg(p,v){do{var A=kn;try{if(ih(),fh.current=gd,ph){for(var I=ln.memoizedState;I!==null;){var W=I.queue;W!==null&&(W.pending=null),I=I.next}ph=!1}if(el=0,Ln=An=ln=null,tl=!1,vo=0,wd.current=null,A===null||A.return===null){Bn=1,Zc=v,kn=null;break}e:{var Z=p,de=A.return,ke=A,Re=v;if(v=Gn,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 jt=Zb(de);if(jt!==null){jt.flags&=-257,Ci(jt,de,ke,Z,v),jt.mode&1&&Cg(Z,Xe,v),v=jt,Re=Xe;var Rt=v.updateQueue;if(Rt===null){var It=new Set;It.add(Re),v.updateQueue=It}else Rt.add(Re);break e}else{if((v&1)===0){Cg(Z,Xe,v),Yh();break e}Re=Error(n(426))}}else if(on&&ke.mode&1){var Hr=Zb(de);if(Hr!==null){(Hr.flags&65536)===0&&(Hr.flags|=256),Ci(Hr,de,ke,Z,v),eh(ql(Re,ke));break e}}Z=Re=ql(Re,ke),Bn!==4&&(Bn=2),Sd===null?Sd=[Z]:Sd.push(Z),Z=de;do{switch(Z.tag){case 3:Z.flags|=65536,v&=-v,Z.lanes|=v;var Ge=Sg(Z,Re,v);Ub(Z,Ge);break e;case 1:ke=Re;var Be=Z.type,Ye=Z.stateNode;if((Z.flags&128)===0&&(typeof Be.getDerivedStateFromError=="function"||Ye!==null&&typeof Ye.componentDidCatch=="function"&&(xo===null||!xo.has(Ye)))){Z.flags|=65536,v&=-v,Z.lanes|=v;var gt=kg(Z,ke,v);Ub(Z,gt);break e}}Z=Z.return}while(Z!==null)}tu(A)}catch(Ut){v=Ut,kn===A&&A!==null&&(kn=A=A.return);continue}break}while(!0)}function ox(){var p=xd.current;return xd.current=gd,p===null?gd:p}function Yh(){(Bn===0||Bn===3||Bn===2)&&(Bn=4),Nn===null||(nl&268435455)===0&&(_d&268435455)===0||_o(Nn,Gn)}function Td(p,v){var A=br;br|=2;var I=ox();(Nn!==p||Gn!==v)&&(bo=null,al(p,v));do try{lx();break}catch(W){Vg(p,W)}while(!0);if(ih(),br=A,xd.current=I,kn!==null)throw Error(n(261));return Nn=null,Gn=0,Bn}function lx(){for(;kn!==null;)Gg(kn)}function u1(){for(;kn!==null&&!Tl();)Gg(kn)}function Gg(p){var v=Yg(p.alternate,p,as);p.memoizedProps=p.pendingProps,v===null?tu(p):kn=v,wd.current=null}function tu(p){var v=p;do{var A=v.alternate;if(p=v.return,(v.flags&32768)===0){if(A=tx(A,v,as),A!==null){kn=A;return}}else{if(A=rx(A,v),A!==null){A.flags&=32767,kn=A;return}if(p!==null)p.flags|=32768,p.subtreeFlags=0,p.deletions=null;else{Bn=6,kn=null;return}}if(v=v.sibling,v!==null){kn=v;return}kn=v=p}while(v!==null);Bn===0&&(Bn=5)}function ol(p,v,A){var I=ze,W=Cs.transition;try{Cs.transition=null,ze=1,Kg(p,v,A,I)}finally{Cs.transition=W,ze=I}return null}function Kg(p,v,A,I){do Gl();while(il!==null);if((br&6)!==0)throw Error(n(327));A=p.finishedWork;var W=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 Z=A.lanes|A.childLanes;if(vt(p,Z),p===Nn&&(kn=Nn=null,Gn=0),(A.subtreeFlags&2064)===0&&(A.flags&2064)===0||Cd||(Cd=!0,Jg(Is,function(){return Gl(),null})),Z=(A.flags&15990)!==0,(A.subtreeFlags&15990)!==0||Z){Z=Cs.transition,Cs.transition=null;var de=ze;ze=1;var ke=br;br|=4,wd.current=null,ix(p,A),Bh(A,p),Pb(Ff),co=!!zf,Ff=zf=null,p.current=A,zg(A),Al(),br=ke,ze=de,Cs.transition=Z}else p.current=A;if(Cd&&(Cd=!1,il=p,jd=W),Z=p.pendingLanes,Z===0&&(xo=null),Ft(A.stateNode),Ki(p,Tr()),v!==null)for(I=p.onRecoverableError,A=0;A<v.length;A++)W=v[A],I(W.value,{componentStack:W.stack,digest:W.digest});if(kd)throw kd=!1,p=Wh,Wh=null,p;return(jd&1)!==0&&p.tag!==0&&Gl(),Z=p.pendingLanes,(Z&1)!==0?p===Hh?Qc++:(Qc=0,Hh=p):Qc=0,po(),null}function Gl(){if(il!==null){var p=et(jd),v=Cs.transition,A=ze;try{if(Cs.transition=null,ze=16>p?16:p,il===null)var I=!1;else{if(p=il,il=null,jd=0,(br&6)!==0)throw Error(n(331));var W=br;for(br|=4,Pt=p.current;Pt!==null;){var Z=Pt,de=Z.child;if((Pt.flags&16)!==0){var ke=Z.deletions;if(ke!==null){for(var Re=0;Re<ke.length;Re++){var Xe=ke[Re];for(Pt=Xe;Pt!==null;){var ft=Pt;switch(ft.tag){case 0:case 11:case 15:Yc(8,ft,Z)}var ht=ft.child;if(ht!==null)ht.return=ft,Pt=ht;else for(;Pt!==null;){ft=Pt;var dt=ft.sibling,jt=ft.return;if(Dg(ft),ft===Xe){Pt=null;break}if(dt!==null){dt.return=jt,Pt=dt;break}Pt=jt}}}var Rt=Z.alternate;if(Rt!==null){var It=Rt.child;if(It!==null){Rt.child=null;do{var Hr=It.sibling;It.sibling=null,It=Hr}while(It!==null)}}Pt=Z}}if((Z.subtreeFlags&2064)!==0&&de!==null)de.return=Z,Pt=de;else e:for(;Pt!==null;){if(Z=Pt,(Z.flags&2048)!==0)switch(Z.tag){case 0:case 11:case 15:Yc(9,Z,Z.return)}var Ge=Z.sibling;if(Ge!==null){Ge.return=Z.return,Pt=Ge;break e}Pt=Z.return}}var Be=p.current;for(Pt=Be;Pt!==null;){de=Pt;var Ye=de.child;if((de.subtreeFlags&2064)!==0&&Ye!==null)Ye.return=de,Pt=Ye;else e:for(de=Be;Pt!==null;){if(ke=Pt,(ke.flags&2048)!==0)try{switch(ke.tag){case 0:case 11:case 15:Mh(9,ke)}}catch(Ut){dn(ke,ke.return,Ut)}if(ke===de){Pt=null;break e}var gt=ke.sibling;if(gt!==null){gt.return=ke.return,Pt=gt;break e}Pt=ke.return}}if(br=W,po(),Mn&&typeof Mn.onPostCommitFiberRoot=="function")try{Mn.onPostCommitFiberRoot(Di,p)}catch{}I=!0}return I}finally{ze=A,Cs.transition=v}}return!1}function Xg(p,v,A){v=ql(A,v),v=Sg(p,v,1),p=go(p,v,1),v=ji(),p!==null&&(vi(p,1,v),Ki(p,v))}function dn(p,v,A){if(p.tag===3)Xg(p,p,A);else for(;v!==null;){if(v.tag===3){Xg(v,p,A);break}else if(v.tag===1){var I=v.stateNode;if(typeof v.type.getDerivedStateFromError=="function"||typeof I.componentDidCatch=="function"&&(xo===null||!xo.has(I))){p=ql(A,p),p=kg(v,p,1),v=go(v,p,1),p=ji(),v!==null&&(vi(v,1,p),Ki(v,p));break}}v=v.return}}function cx(p,v,A){var I=p.pingCache;I!==null&&I.delete(v),v=ji(),p.pingedLanes|=p.suspendedLanes&A,Nn===p&&(Gn&A)===A&&(Bn===4||Bn===3&&(Gn&130023424)===Gn&&500>Tr()-qh?al(p,0):Uh|=A),Ki(p,v)}function ux(p,v){v===0&&((p.mode&1)===0?v=1:(v=gi,gi<<=1,(gi&130023424)===0&&(gi=4194304)));var A=ji();p=Ra(p,v),p!==null&&(vi(p,v,A),Ki(p,A))}function dx(p){var v=p.memoizedState,A=0;v!==null&&(A=v.retryLane),ux(p,A)}function fx(p,v){var A=0;switch(p.tag){case 13:var I=p.stateNode,W=p.memoizedState;W!==null&&(A=W.retryLane);break;case 19:I=p.stateNode;break;default:throw Error(n(314))}I!==null&&I.delete(v),ux(p,A)}var Yg;Yg=function(p,v,A){if(p!==null)if(p.memoizedProps!==v.pendingProps||zi.current)Vi=!0;else{if((p.lanes&A)===0&&(v.flags&128)===0)return Vi=!1,c1(p,v,A);Vi=(p.flags&131072)!==0}else Vi=!1,on&&(v.flags&1048576)!==0&&Ko(v,ad,v.index);switch(v.lanes=0,v.tag){case 2:var I=v.type;yd(p,v),p=v.pendingProps;var W=ki(v,Si.current);zl(v,A),W=gh(null,v,I,p,W,A);var Z=vh();return v.flags|=1,typeof W=="object"&&W!==null&&typeof W.render=="function"&&W.$$typeof===void 0?(v.tag=1,v.memoizedState=null,v.updateQueue=null,Fi(I)?(Z=!0,nd(v)):Z=!1,v.memoizedState=W.state!==null&&W.state!==void 0?W.state:null,ud(v),W.updater=Ia,v.stateNode=W,W._reactInternals=v,wh(v,I,p,A),v=Ch(null,v,I,!0,Z,A)):(v.tag=0,on&&Z&&Tn(v),si(null,v,W,A),v=v.child),v;case 16:I=v.elementType;e:{switch(yd(p,v),p=v.pendingProps,W=I._init,I=W(I._payload),v.type=I,W=v.tag=hx(I),p=$n(I,p),W){case 0:v=kh(null,v,I,p,A);break e;case 1:v=$g(null,v,I,p,A);break e;case 11:v=jg(null,v,I,p,A);break e;case 14:v=Kc(null,v,I,$n(I.type,p),A);break e}throw Error(n(306,I,""))}return v;case 0:return I=v.type,W=v.pendingProps,W=v.elementType===I?W:$n(I,W),kh(p,v,I,W,A);case 1:return I=v.type,W=v.pendingProps,W=v.elementType===I?W:$n(I,W),$g(p,v,I,W,A);case 3:e:{if(jh(v),p===null)throw Error(n(387));I=v.pendingProps,Z=v.memoizedState,W=Z.element,oh(p,v),dd(v,I,null,A);var de=v.memoizedState;if(I=de.element,Z.isDehydrated)if(Z={element:I,isDehydrated:!1,cache:de.cache,pendingSuspenseBoundaries:de.pendingSuspenseBoundaries,transitions:de.transitions},v.updateQueue.baseState=Z,v.memoizedState=Z,v.flags&256){W=ql(Error(n(423)),v),v=Ng(p,v,I,A,W);break e}else if(I!==W){W=ql(Error(n(424)),v),v=Ng(p,v,I,A,W);break e}else for(ss=fo(v.stateNode.containerInfo.firstChild),Wi=v,on=!0,Hi=null,A=rh(v,null,I,A),v.child=A;A;)A.flags=A.flags&-3|4096,A=A.sibling;else{if(Xo(),I===W){v=Da(p,v,A);break e}si(p,v,I,A)}v=v.child}return v;case 5:return eg(v),p===null&&Zf(v),I=v.type,W=v.pendingProps,Z=p!==null?p.memoizedProps:null,de=W.children,Uf(I,W)?de=null:Z!==null&&Uf(I,Z)&&(v.flags|=32),Ag(p,v),si(p,v,de,A),v.child;case 6:return p===null&&Zf(v),null;case 13:return Og(p,v,A);case 4:return lh(v,v.stateNode.containerInfo),I=v.pendingProps,p===null?v.child=Bl(v,null,I,A):si(p,v,I,A),v.child;case 11:return I=v.type,W=v.pendingProps,W=v.elementType===I?W:$n(I,W),jg(p,v,I,W,A);case 7:return si(p,v,v.pendingProps,A),v.child;case 8:return si(p,v,v.pendingProps.children,A),v.child;case 12:return si(p,v,v.pendingProps.children,A),v.child;case 10:e:{if(I=v.type._context,W=v.pendingProps,Z=v.memoizedProps,de=W.value,Wr(Yo,I._currentValue),I._currentValue=de,Z!==null)if(Us(Z.value,de)){if(Z.children===W.children&&!zi.current){v=Da(p,v,A);break e}}else for(Z=v.child,Z!==null&&(Z.return=v);Z!==null;){var ke=Z.dependencies;if(ke!==null){de=Z.child;for(var Re=ke.firstContext;Re!==null;){if(Re.context===I){if(Z.tag===1){Re=Ma(-1,A&-A),Re.tag=2;var Xe=Z.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}}Z.lanes|=A,Re=Z.alternate,Re!==null&&(Re.lanes|=A),Qm(Z.return,A,v),ke.lanes|=A;break}Re=Re.next}}else if(Z.tag===10)de=Z.type===v.type?null:Z.child;else if(Z.tag===18){if(de=Z.return,de===null)throw Error(n(341));de.lanes|=A,ke=de.alternate,ke!==null&&(ke.lanes|=A),Qm(de,A,v),de=Z.sibling}else de=Z.child;if(de!==null)de.return=Z;else for(de=Z;de!==null;){if(de===v){de=null;break}if(Z=de.sibling,Z!==null){Z.return=de.return,de=Z;break}de=de.return}Z=de}si(p,v,W.children,A),v=v.child}return v;case 9:return W=v.type,I=v.pendingProps.children,zl(v,A),W=_s(W),I=I(W),v.flags|=1,si(p,v,I,A),v.child;case 14:return I=v.type,W=$n(I,v.pendingProps),W=$n(I.type,W),Kc(p,v,I,W,A);case 15:return Eg(p,v,v.type,v.pendingProps,A);case 17:return I=v.type,W=v.pendingProps,W=v.elementType===I?W:$n(I,W),yd(p,v),v.tag=1,Fi(I)?(p=!0,nd(v)):p=!1,zl(v,A),wg(v,I,W),wh(v,I,W,A),Ch(null,v,I,!0,p,A);case 19:return $h(p,v,A);case 22:return Tg(p,v,A)}throw Error(n(156,v.tag))};function Jg(p,v){return Uo(p,v)}function d1(p,v,A,I){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=I,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function os(p,v,A,I){return new d1(p,v,A,I)}function Jh(p){return p=p.prototype,!(!p||!p.isReactComponent)}function hx(p){if(typeof p=="function")return Jh(p)?1:0;if(p!=null){if(p=p.$$typeof,p===V)return 11;if(p===Y)return 14}return 2}function So(p,v){var A=p.alternate;return A===null?(A=os(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 Ad(p,v,A,I,W,Z){var de=2;if(I=p,typeof p=="function")Jh(p)&&(de=1);else if(typeof p=="string")de=5;else e:switch(p){case N:return Kl(A.children,W,Z,v);case O:de=8,W|=8;break;case M:return p=os(12,A,v,W|2),p.elementType=M,p.lanes=Z,p;case z:return p=os(13,A,v,W),p.elementType=z,p.lanes=Z,p;case F:return p=os(19,A,v,W),p.elementType=F,p.lanes=Z,p;case le:return $d(A,W,Z,v);default:if(typeof p=="object"&&p!==null)switch(p.$$typeof){case U:de=10;break e;case H:de=9;break e;case V:de=11;break e;case Y:de=14;break e;case te:de=16,I=null;break e}throw Error(n(130,p==null?p:typeof p,""))}return v=os(de,A,v,W),v.elementType=p,v.type=I,v.lanes=Z,v}function Kl(p,v,A,I){return p=os(7,p,I,v),p.lanes=A,p}function $d(p,v,A,I){return p=os(22,p,I,v),p.elementType=le,p.lanes=A,p.stateNode={isHidden:!1},p}function Zh(p,v,A){return p=os(6,p,null,v),p.lanes=A,p}function Qh(p,v,A){return v=os(4,p.children!==null?p.children:[],p.key,v),v.lanes=A,v.stateNode={containerInfo:p.containerInfo,pendingChildren:null,implementation:p.implementation},v}function f1(p,v,A,I,W){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=Ze(0),this.expirationTimes=Ze(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ze(0),this.identifierPrefix=I,this.onRecoverableError=W,this.mutableSourceEagerHydrationData=null}function ep(p,v,A,I,W,Z,de,ke,Re){return p=new f1(p,v,A,ke,Re),v===1?(v=1,Z===!0&&(v|=8)):v=0,Z=os(3,null,null,v),p.current=Z,Z.stateNode=p,Z.memoizedState={element:I,isDehydrated:A,cache:null,transitions:null,pendingSuspenseBoundaries:null},ud(Z),p}function h1(p,v,A){var I=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:$,key:I==null?null:""+I,children:p,containerInfo:v,implementation:A}}function Zg(p){if(!p)return ho;p=p._reactInternals;e:{if(Ct(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(Fi(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(Fi(A))return Km(p,A,v)}return v}function px(p,v,A,I,W,Z,de,ke,Re){return p=ep(A,I,!0,p,W,Z,de,ke,Re),p.context=Zg(null),A=p.current,I=ji(),W=wo(A),Z=Ma(I,W),Z.callback=v??null,go(A,Z,W),p.current.lanes=W,vi(p,W,I),Ki(p,I),p}function Nd(p,v,A,I){var W=v.current,Z=ji(),de=wo(W);return A=Zg(A),v.context===null?v.context=A:v.pendingContext=A,v=Ma(Z,de),v.payload={element:p},I=I===void 0?null:I,I!==null&&(v.callback=I),p=go(W,v,de),p!==null&&(Gs(p,W,de,Z),Wc(p,W,de)),de}function Od(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 Qg(p,v){if(p=p.memoizedState,p!==null&&p.dehydrated!==null){var A=p.retryLane;p.retryLane=A!==0&&A<v?A:v}}function tp(p,v){Qg(p,v),(p=p.alternate)&&Qg(p,v)}function mx(){return null}var gx=typeof reportError=="function"?reportError:function(p){console.error(p)};function rp(p){this._internalRoot=p}Xl.prototype.render=rp.prototype.render=function(p){var v=this._internalRoot;if(v===null)throw Error(n(409));Nd(p,v,null,null)},Xl.prototype.unmount=rp.prototype.unmount=function(){var p=this._internalRoot;if(p!==null){this._internalRoot=null;var v=p.containerInfo;sl(function(){Nd(null,p,null,null)}),v[fa]=null}};function Xl(p){this._internalRoot=p}Xl.prototype.unstable_scheduleHydration=function(p){if(p){var v=Br();p={blockedOn:null,target:p,priority:v};for(var A=0;A<Ds.length&&v!==0&&v<Ds[A].priority;A++);Ds.splice(A,0,p),A===0&&Ec(p)}};function np(p){return!(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11)}function Pd(p){return!(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11&&(p.nodeType!==8||p.nodeValue!==" react-mount-point-unstable "))}function vx(){}function yx(p,v,A,I,W){if(W){if(typeof I=="function"){var Z=I;I=function(){var Xe=Od(de);Z.call(Xe)}}var de=px(v,I,p,0,null,!1,!1,"",vx);return p._reactRootContainer=de,p[fa]=de.current,Bc(p.nodeType===8?p.parentNode:p),sl(),de}for(;W=p.lastChild;)p.removeChild(W);if(typeof I=="function"){var ke=I;I=function(){var Xe=Od(Re);ke.call(Xe)}}var Re=ep(p,0,!1,null,null,!1,!1,"",vx);return p._reactRootContainer=Re,p[fa]=Re.current,Bc(p.nodeType===8?p.parentNode:p),sl(function(){Nd(v,Re,A,I)}),Re}function ru(p,v,A,I,W){var Z=A._reactRootContainer;if(Z){var de=Z;if(typeof W=="function"){var ke=W;W=function(){var Re=Od(de);ke.call(Re)}}Nd(v,de,p,W)}else de=yx(A,v,p,W,I);return Od(de)}Et=function(p){switch(p.tag){case 3:var v=p.stateNode;if(v.current.memoizedState.isDehydrated){var A=ms(v.pendingLanes);A!==0&&(Se(v,A|1),Ki(v,Tr()),(br&6)===0&&(Vl=Tr()+500,po()))}break;case 13:sl(function(){var I=Ra(p,1);if(I!==null){var W=ji();Gs(I,p,1,W)}}),tp(p,1)}},ir=function(p){if(p.tag===13){var v=Ra(p,134217728);if(v!==null){var A=ji();Gs(v,p,134217728,A)}tp(p,134217728)}},cr=function(p){if(p.tag===13){var v=wo(p),A=Ra(p,v);if(A!==null){var I=ji();Gs(A,p,v,I)}tp(p,v)}},Br=function(){return ze},Dr=function(p,v){var A=ze;try{return ze=p,v()}finally{ze=A}},ea=function(p,v,A){switch(v){case"input":if(lt(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 I=A[v];if(I!==p&&I.form===p.form){var W=td(I);if(!W)throw Error(n(90));Te(I),lt(I,W)}}}break;case"textarea":Ur(p,A);break;case"select":v=A.value,v!=null&&Vt(p,!!A.multiple,v,!1)}},ps=Kh,Qn=sl;var ev={usingClientEntryPoint:!1,Events:[Uc,Rl,td,ta,ra,Kh]},Ks={findFiberByHostInstance:Vo,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},bx={bundleType:Ks.bundleType,version:Ks.version,rendererPackageName:Ks.rendererPackageName,rendererConfig:Ks.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:E.ReactCurrentDispatcher,findHostInstanceByFiber:function(p){return p=no(p),p===null?null:p.stateNode},findFiberByHostInstance:Ks.findFiberByHostInstance||mx,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{Di=nu.inject(bx),Mn=nu}catch{}}return Xs.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ev,Xs.createPortal=function(p,v){var A=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!np(v))throw Error(n(200));return h1(p,v,null,A)},Xs.createRoot=function(p,v){if(!np(p))throw Error(n(299));var A=!1,I="",W=gx;return v!=null&&(v.unstable_strictMode===!0&&(A=!0),v.identifierPrefix!==void 0&&(I=v.identifierPrefix),v.onRecoverableError!==void 0&&(W=v.onRecoverableError)),v=ep(p,1,!1,null,null,A,!1,I,W),p[fa]=v.current,Bc(p.nodeType===8?p.parentNode:p),new rp(v)},Xs.findDOMNode=function(p){if(p==null)return null;if(p.nodeType===1)return p;var v=p._reactInternals;if(v===void 0)throw typeof p.render=="function"?Error(n(188)):(p=Object.keys(p).join(","),Error(n(268,p)));return p=no(v),p=p===null?null:p.stateNode,p},Xs.flushSync=function(p){return sl(p)},Xs.hydrate=function(p,v,A){if(!Pd(v))throw Error(n(200));return ru(null,p,v,!0,A)},Xs.hydrateRoot=function(p,v,A){if(!np(p))throw Error(n(405));var I=A!=null&&A.hydratedSources||null,W=!1,Z="",de=gx;if(A!=null&&(A.unstable_strictMode===!0&&(W=!0),A.identifierPrefix!==void 0&&(Z=A.identifierPrefix),A.onRecoverableError!==void 0&&(de=A.onRecoverableError)),v=px(v,null,p,1,A??null,W,!1,Z,de),p[fa]=v.current,Bc(p),I)for(p=0;p<I.length;p++)A=I[p],W=A._getVersion,W=W(A._source),v.mutableSourceEagerHydrationData==null?v.mutableSourceEagerHydrationData=[A,W]:v.mutableSourceEagerHydrationData.push(A,W);return new Xl(v)},Xs.render=function(p,v,A){if(!Pd(v))throw Error(n(200));return ru(null,p,v,!1,A)},Xs.unmountComponentAtNode=function(p){if(!Pd(p))throw Error(n(40));return p._reactRootContainer?(sl(function(){ru(null,null,p,!1,function(){p._reactRootContainer=null,p[fa]=null})}),!0):!1},Xs.unstable_batchedUpdates=Kh,Xs.unstable_renderSubtreeIntoContainer=function(p,v,A,I){if(!Pd(A))throw Error(n(200));if(p==null||p._reactInternals===void 0)throw Error(n(38));return ru(p,v,A,!1,I)},Xs.version="18.3.1-next-f1338f8080-20240426",Xs}var U$;function p4(){if(U$)return y1.exports;U$=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(),y1.exports=rq(),y1.exports}var q$;function nq(){if(q$)return _x;q$=1;var e=p4();return _x.createRoot=e.createRoot,_x.hydrateRoot=e.hydrateRoot,_x}var iq=nq();const sq=Qr(iq);var D=BT();const He=Qr(D),W$=e=>{let r;const n=new Set,i=(f,m)=>{const h=typeof f=="function"?f(r):f;if(!Object.is(h,r)){const y=r;r=m??(typeof h!="object"||h===null)?h:Object.assign({},r,h),n.forEach(x=>x(r,y))}},s=()=>r,l={setState:i,getState:s,getInitialState:()=>u,subscribe:f=>(n.add(f),()=>n.delete(f))},u=r=e(i,s,l);return l},aq=(e=>e?W$(e):W$),oq=e=>e;function lq(e,r=oq){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 H$=e=>{const r=aq(e),n=i=>lq(r,i);return Object.assign(n,r),n},En=(e=>e?H$(e):H$);function bl(e){return"'"+e.replace(/'/g,"'\\''")+"'"}const w1=({sessionId:e})=>`claude --dangerously-skip-permissions --session-id ${bl(e)}`,V$=({sessionId:e})=>`claude --session-id ${bl(e)}`,cq=()=>"claude --resume",m4=[{id:"sm-dangerous",label:"Session Manager (skip perms)",description:"claude --dangerously-skip-permissions in this project",category:"build",cwd:"app-cwd",command:w1},{id:"sm-safe",label:"Session Manager (safe)",description:"claude with normal permission prompts in this project",category:"build",cwd:"app-cwd",command:V$},{id:"home-dangerous",label:"Home (skip perms)",description:"claude --dangerously-skip-permissions in ~",category:"build",cwd:"home",command:w1},{id:"pick-dangerous",label:"Pick directory (skip perms)…",description:"Choose a folder, launch claude --dangerously-skip-permissions",category:"build",cwd:"pick",command:w1},{id:"pick-safe",label:"Pick directory (safe)…",description:"Choose a folder, launch claude with normal prompts",category:"build",cwd:"pick",command:V$},{id:"pick-resume",label:"Pick directory + resume…",description:"Choose a folder, then pick a past session to resume",category:"build",cwd:"pick",command:cq},{id:"pick-shell",label:"Pick directory (shell only)…",description:"Bare interactive shell, no claude auto-launch",category:"build",cwd:"pick",command:null}];let Ba=null;async function uq(){if(Ba)return Ba;try{const e=await window.api.app.engageRulesPath();if(!e)return Ba=[],Ba;const r=await window.api.config.readJson(e);if(!r.exists||r.parseError||!r.data)return Ba=[],Ba;const n=r.data;if(!n.presets||!Array.isArray(n.presets))return Ba=[],Ba;const i=n.projectPath;return Ba=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 ${bl(i)} && ${s.cliEntry}`})),Ba}catch(e){return console.warn("[presets] Failed to load engage presets:",e),Ba=[],Ba}}async function g4(e){const r=m4.find(i=>i.id===e);return r||((await uq()).find(i=>i.id===e)??null)}async function G$(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 v4(e,r){return e.command?e.command(r):null}const zT=["opus","sonnet","haiku"],y4="sm.rawSessionModel",dq="opus";function fq(e){return zT.includes(e)}function hq(){try{const e=localStorage.getItem(y4);if(e&&fq(e))return e}catch{}return dq}let Sp=hq();const bj=new Set;function b4(){return Sp}function pq(e){if(e!==Sp){Sp=e;try{localStorage.setItem(y4,e)}catch{}bj.forEach(r=>r(e))}}function mq(){const[e,r]=D.useState(Sp);D.useEffect(()=>{const i=s=>r(s);return bj.add(i),Sp!==e&&r(Sp),()=>{bj.delete(i)}},[]);const n=D.useCallback(i=>pq(i),[]);return{model:e,setModel:n}}async function x4(e,r){const n=await window.api.transcripts.pathFor(e,r);return window.api.config.exists(n)}function gq(e){const r=e.split("/").filter(Boolean);return r[r.length-1]||e}async function w4(e,r=!1,n=b4()){let i=!r;i&&(i=await x4(e.cwd,e.claudeSessionId));const s=r&&!i?crypto.randomUUID():e.claudeSessionId,a=i?`claude --dangerously-skip-permissions --resume ${bl(s)} --model ${n}`:`claude --dangerously-skip-permissions --session-id ${bl(s)} --model ${n}`;return{claudeSessionId:s,startupCommand:a}}const Nt=En((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??gq(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?g4(i.presetId).then(c=>{a(c?v4(c,{sessionId:s,cwd:i.cwd}):`claude --dangerously-skip-permissions --session-id ${bl(s)}`)}):a(`claude --dangerously-skip-permissions --session-id ${bl(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 w4({cwd:s.cwd,claudeSessionId:s.claudeSessionId},!1,i??b4());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 xj(){var n;if(Nt.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 w4(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;Nt.getState().restoreTabs(c,l)}else Nt.setState({hydrated:!0})}catch(i){console.warn("[sessions] hydrate failed:",i),Nt.setState({hydrated:!0})}const e=()=>{const{tabs:i,activeTabId:s}=Nt.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;Nt.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 vq=Object.freeze(Object.defineProperty({__proto__:null,hydrateSessions:xj,useSessions:Nt},Symbol.toStringTag,{value:"Module"})),yq=5,K$=100,bq=5e3,wj=new Map;function X$(e){const r=wj.get(e);r!==void 0&&(clearTimeout(r),wj.delete(e))}function xq(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`t-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}const kp=En((e,r)=>({toasts:[],history:[],unreadCount:0,show:(n,i)=>{const s=xq(),a=Date.now();e(l=>{const u=[...l.toasts,{id:s,kind:n,message:i,createdAt:a}];for(;u.length>yq;){const h=u.shift();h&&X$(h.id)}const m=[{id:s,kind:n,message:i,createdAt:a,read:!1},...l.history];return m.length>K$&&(m.length=K$),{toasts:u,history:m,unreadCount:l.unreadCount+1}});const c=setTimeout(()=>r().dismiss(s),bq);return wj.set(s,c),s},dismiss:n=>{X$(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}})}})),rt={info:e=>kp.getState().show("info",e),warn:e=>kp.getState().show("warn",e),error:e=>kp.getState().show("error",e)},_4=Object.freeze(Object.defineProperty({__proto__:null,toast:rt,useToast:kp},Symbol.toStringTag,{value:"Module"})),Y$=200,wq=/\x1b\[[0-9;]*m/g;function _q(e){return e.replace(wq,"")}const ry=En((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),rt.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);rt.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=_q(n.line),a=i.lines.length>=Y$?[...i.lines.slice(i.lines.length-Y$+1),{line:s,ts:n.ts}]:[...i.lines,{line:s,ts:n.ts}];e({watchers:{...r().watchers,[n.watcherId]:{...i,lines:a,lineCount:i.lineCount+1,lastLineAt:n.ts}}})},closed:n=>{if(!r().watchers[n])return;const i={...r().watchers};delete i[n],e({watchers:i})}})),Sq=4,J$=40,Z$=6;function kq(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]")):[],[]),y=D.useCallback((b,_,w)=>{for(let C=0;C<_.length;C++){const E=_[C].left+_[C].width/2;if(b<E)return C<=w?C:C-1}return _.length-1},[]),x=D.useCallback(()=>{const b=s.current,_=i.current;if(!(b!=null&&b.active)||!_)return;const w=_.getBoundingClientRect(),C=b.startX+b.deltaX,E=C-w.left,T=w.right-C;E<J$?_.scrollLeft-=Z$:T<J$&&(_.scrollLeft+=Z$),a.current=requestAnimationFrame(x)},[]);D.useEffect(()=>{const b=i.current;if(!b)return;let _=!1;const w=()=>{_||(_=!0,c.current=requestAnimationFrame(()=>{_=!1,f(T=>T+1)}))},C=T=>{var U;const $=s.current;if(!$)return;const N=T.clientX-$.startX;if(!$.active&&Math.abs(N)<Sq)return;if(!$.active){$.active=!0,$.tabRects=h().map(H=>H.getBoundingClientRect()),u(!0);try{(U=i.current)==null||U.setPointerCapture($.pointerId)}catch{}a.current=requestAnimationFrame(x)}$.deltaX=N;const O=$.tabRects[$.fromIndex],M=O.left+O.width/2+N;$.currentIndex=y(M,$.tabRects,$.fromIndex),w()},E=T=>{const $=s.current;if($&&$.pointerId===T.pointerId){cancelAnimationFrame(a.current),cancelAnimationFrame(c.current);try{b.releasePointerCapture($.pointerId)}catch{}$.active&&$.fromIndex!==$.currentIndex?r($.fromIndex,$.currentIndex):m.current($.fromIndex),s.current=null,u(!1),f(N=>N+1)}};return b.addEventListener("pointermove",C),b.addEventListener("pointerup",E),b.addEventListener("pointercancel",E),()=>{b.removeEventListener("pointermove",C),b.removeEventListener("pointerup",E),b.removeEventListener("pointercancel",E),cancelAnimationFrame(a.current),cancelAnimationFrame(c.current)}},[r,h,y,x]);const k=D.useCallback((b,_)=>{b.button!==0||b.target.closest("button")||(s.current={active:!1,fromIndex:_,currentIndex:_,startX:b.clientX,deltaX:0,tabRects:[],pointerId:b.pointerId})},[]);return{getTabDragProps:D.useCallback(b=>{var C;const _=s.current,w={};if(_!=null&&_.active)if(b===_.fromIndex)w.transform=`translateX(${_.deltaX}px) scale(1.03)`,w.zIndex=10,w.opacity=.85,w.boxShadow="0 2px 8px rgba(0,0,0,0.4)",w.position="relative",w.pointerEvents="none";else{const E=_.fromIndex,T=_.currentIndex,N=(((C=_.tabRects[E])==null?void 0:C.width)??0)+4;w.transition="transform 0.15s ease",E<T&&b>E&&b<=T?w.transform=`translateX(-${N}px)`:E>T&&b>=T&&b<E?w.transform=`translateX(${N}px)`:w.transform="translateX(0)"}return{onPointerDown:E=>k(E,b),style:w,"data-drag-index":b}},[k]),isDragging:l,containerRef:i}}const Cq=3e4;function jq(){const e=Nt(x=>x.tabs),r=Nt(x=>x.activeTabId),n=Nt(x=>x.closeTab),i=Nt(x=>x.setActive),s=Nt(x=>x.reorderTab),a=ry(x=>x.watchers),[c,l]=D.useState(()=>Date.now());D.useEffect(()=>{const x=window.setInterval(()=>l(Date.now()),1e3);return()=>window.clearInterval(x)},[]);const u=x=>{for(const k of Object.values(a))if(k.tabId===x&&k.lastLineAt&&c-k.lastLineAt<Cq)return!0;return!1},{getTabDragProps:f,isDragging:m,containerRef:h}=kq({tabCount:e.length,onReorder:s,onActivate:x=>{const k=e[x];k&&i(k.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:h,className:`flex items-end gap-0.5 overflow-x-auto min-w-0 flex-1 select-none ${m?"cursor-grabbing":""}`,children:e.map((x,k)=>{const S=x.id===r,b=f(k),_=y[k%y.length];return o.jsxs("div",{...b,style:b.style,className:`group flex items-center gap-2 px-3.5 pt-1.5 pb-2 rounded-t-[10px] text-[13px] shrink-0 transition-colors ${m?"":"cursor-grab"} ${S?"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":S?"true":void 0,children:[o.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:_,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"}),u(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:w=>{w.stopPropagation(),n(x.id)},className:"text-fg-faint opacity-0 group-hover:opacity-100 hover:text-fg ml-1 leading-none",title:"Close session","aria-label":`Close ${x.label}`,children:"×"})]},x.id)})}),o.jsxs("div",{className:"flex items-center gap-2 pb-2 pl-3 text-[12px] text-fg-faint shrink-0",children:[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.12"]})]})]})}function Eq(e,r,n){return r?e.map(i=>i.id===r?{...i,lastActivityAt:n}:i):e}function Tq(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 xw=En((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]:Tq(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 sb(async()=>{const{toast:h}=await Promise.resolve().then(()=>_4);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,y={};for(const x of["command","file_path","pattern","url","query","subagent_type","description"])h&&x in h&&(y[x]=h[x]);if(l.lastToolUses=[{id:m.id,name:m.name,input:y,at:c},...a.lastToolUses].slice(0,50),!(s!=null&&s.replay)){const x=m.input,k=["Edit","Write","NotebookEdit"].includes(m.name),S=typeof(x==null?void 0:x.file_path)=="string"?x.file_path:void 0,b=typeof(x==null?void 0:x.command)=="string"?x.command:void 0,_=S?S.split("/").pop()??S:b?f(b,28):"";u.push({id:0,kind:"tool-use",at:c,label:_?`${m.name} · ${_}`:m.name,target:S??b,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),y=m.input_tokens??m.inputTokens??0,x=m.output_tokens??m.outputTokens??0,k=h+y+x;l.usage={inputTokens:(a.usage.inputTokens||0)+y,outputTokens:(a.usage.outputTokens||0)+x,cacheCreationInputTokens:(a.usage.cacheCreationInputTokens||0)+(m.cache_creation_input_tokens??m.cacheCreationInputTokens??0),cacheReadInputTokens:(a.usage.cacheReadInputTokens||0)+(m.cache_read_input_tokens??m.cacheReadInputTokens??0)},!(s!=null&&s.replay)&&Math.floor(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=Eq(a.agents,m==null?void 0:m.toolUseId,c);break}}if(u.length>0){let m=a.activitySeq;const h=u.map(y=>({...y,id:++m}));l.activitySeq=m,l.activityRing=[...a.activityRing,...h].slice(-32)}e({tabs:{...r().tabs,[n]:l}})}}));function S4(e){const r=xw(s=>s.subscribe),n=xw(s=>s.unsubscribe),i=xw(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 _1={},nv={},Q$;function k4(){if(Q$)return nv;Q$=1,Object.defineProperty(nv,"__esModule",{value:!0}),nv.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(/\/[^/]+$/,"/")),nv.baseAssetPath=n,nv}var iv={},eN;function FT(){if(eN)return iv;eN=1,Object.defineProperty(iv,"__esModule",{value:!0}),iv.defaultModelFetcher=void 0;const e=r=>fetch(r).then(n=>n.arrayBuffer());return iv.defaultModelFetcher=e,iv}var Zl={},sv={},tN;function ab(){if(tN)return sv;tN=1,Object.defineProperty(sv,"__esModule",{value:!0}),sv.log=void 0;const e=r=>n=>{console.log(`VAD | ${r} >`,n)};return sv.log={error:e("error"),debug:e("debug"),warn:e("warn")},sv}var av={},rN;function f_(){if(rN)return av;rN=1,Object.defineProperty(av,"__esModule",{value:!0}),av.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||(av.Message=e={})),av}var nN;function UT(){if(nN)return Zl;nN=1,Object.defineProperty(Zl,"__esModule",{value:!0}),Zl.FrameProcessor=Zl.validateOptions=Zl.defaultFrameProcessorOptions=void 0;const e=ab(),r=f_();Zl.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")}Zl.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:b,minSpeechFrames:_}=s(this.options,this.msPerFrame);this.redemptionFrames=S,this.preSpeechPadFrames=b,this.minSpeechFrames=_},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 b=this.speaking;if(this.reset(),b)if(S.reduce((w,C)=>C.isSpeech?w+1:w,0)>=this.minSpeechFrames){const w=i(S.map(C=>C.frame));k({msg:r.Message.SpeechEnd,audio:w})}else k({msg:r.Message.VADMisfire});return{}},this.process=async(k,S)=>{if(!this.active)return;const b=await this.modelProcessFunc(k),_=b.isSpeech>=this.options.positiveSpeechThreshold;if(S({probs:b,msg:r.Message.FrameProcessed,frame:k}),this.audioBuffer.push({frame:k,isSpeech:_}),_&&(this.speechFrameCount++,this.redemptionCounter=0),_&&!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})),b.isSpeech<this.options.negativeSpeechThreshold&&this.speaking&&++this.redemptionCounter>=this.redemptionFrames){this.redemptionCounter=0,this.speechFrameCount=0,this.speaking=!1,this.speechRealStartFired=!1;const w=this.audioBuffer;if(this.audioBuffer=[],w.reduce((E,T)=>T.isSpeech?E+1:E,0)>=this.minSpeechFrames){const E=i(w.map(T=>T.frame));S({msg:r.Message.SpeechEnd,audio:E})}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:y,minSpeechFrames:x}=s(this.options,this.msPerFrame);this.redemptionFrames=h,this.preSpeechPadFrames=y,this.minSpeechFrames=x,this.reset()}}return Zl.FrameProcessor=a,Zl}var Ql={};function Ga(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 S1={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}`,q=j.createShaderModule({code:B,label:d.name});lr("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 fN;function Mq(){return fN||(fN=1,(function(e,r){var n=(()=>{var i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,l=(se=>typeof Ga<"u"?Ga:typeof Proxy<"u"?new Proxy(se,{get:(he,we)=>(typeof Ga<"u"?Ga:he)[we]}):se)(function(se){if(typeof Ga<"u")return Ga.apply(this,arguments);throw Error('Dynamic require of "'+se+'" is not supported')}),u=(se,he)=>()=>(se&&(he=se(se=0)),he),f=(se,he)=>{for(var we in he)i(se,we,{get:he[we],enumerable:!0})},m=(se,he,we,Pe)=>{if(he&&typeof he=="object"||typeof he=="function")for(let je of a(he))!c.call(se,je)&&je!==we&&i(se,je,{get:()=>he[je],enumerable:!(Pe=s(he,je))||Pe.enumerable});return se},h=se=>m(i({},"__esModule",{value:!0}),se),y,x,k,S,b,_=u(()=>{y=new Map,x=[],k=(se,he,we)=>{if(he&&typeof he.init=="function"&&typeof he.createInferenceSessionHandler=="function"){let Pe=y.get(se);if(Pe===void 0)y.set(se,{backend:he,priority:we});else{if(Pe.priority>we)return;if(Pe.priority===we&&Pe.backend!==he)throw new Error(`cannot register backend "${se}" using priority ${we}`)}if(we>=0){let je=x.indexOf(se);je!==-1&&x.splice(je,1);for(let We=0;We<x.length;We++)if(y.get(x[We]).priority<=we){x.splice(We,0,se);return}x.push(se)}return}throw new TypeError("not a valid backend")},S=async se=>{let he=y.get(se);if(!he)return"backend not found.";if(he.initialized)return he.backend;if(he.aborted)return he.error;{let we=!!he.initPromise;try{return we||(he.initPromise=he.backend.init(se)),await he.initPromise,he.initialized=!0,he.backend}catch(Pe){return we||(he.error=`${Pe}`,he.aborted=!0),he.error}finally{delete he.initPromise}}},b=async se=>{let he=se.executionProviders||[],we=he.map(Ve=>typeof Ve=="string"?Ve:Ve.name),Pe=we.length===0?x:we,je,We=[],Ie=new Set;for(let Ve of Pe){let nt=await S(Ve);typeof nt=="string"?We.push({name:Ve,err:nt}):(je||(je=nt),je===nt&&Ie.add(Ve))}if(!je)throw new Error(`no available backend found. ERR: ${We.map(Ve=>`[${Ve.name}] ${Ve.err}`).join(", ")}`);for(let{name:Ve,err:nt}of We)we.includes(Ve)&&console.warn(`removing requested execution provider "${Ve}" from session options because it is not available: ${nt}`);let De=he.filter(Ve=>Ie.has(typeof Ve=="string"?Ve:Ve.name));return[je,new Proxy(se,{get:(Ve,nt)=>nt==="executionProviders"?De:Reflect.get(Ve,nt)})]}}),w=u(()=>{_()}),C,E=u(()=>{C="1.26.0"}),T,$,N=u(()=>{E(),T="warning",$={wasm:{},webgl:{},webgpu:{},versions:{common:C},set logLevel(se){if(se!==void 0){if(typeof se!="string"||["verbose","info","warning","error","fatal"].indexOf(se)===-1)throw new Error(`Unsupported logging level: ${se}`);T=se}},get logLevel(){return T}},Object.defineProperty($,"logLevel",{enumerable:!0})}),O,M=u(()=>{N(),O=$}),U,H,V=u(()=>{U=(se,he)=>{let we=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);we.width=se.dims[3],we.height=se.dims[2];let Pe=we.getContext("2d");if(Pe!=null){let je,We;(he==null?void 0:he.tensorLayout)!==void 0&&he.tensorLayout==="NHWC"?(je=se.dims[2],We=se.dims[3]):(je=se.dims[3],We=se.dims[2]);let Ie=(he==null?void 0:he.format)!==void 0?he.format:"RGB",De=he==null?void 0:he.norm,Ve,nt;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?nt=[0,0,0,0]:typeof De.bias=="number"?nt=[De.bias,De.bias,De.bias,De.bias]:(nt=[De.bias[0],De.bias[1],De.bias[2],0],De.bias[3]!==void 0&&(nt[3]=De.bias[3]));let ct=We*je,it=0,Qe=ct,$t=ct*2,qe=-1;Ie==="RGBA"?(it=0,Qe=ct,$t=ct*2,qe=ct*3):Ie==="RGB"?(it=0,Qe=ct,$t=ct*2):Ie==="RBG"&&(it=0,$t=ct,Qe=ct*2);for(let pt=0;pt<We;pt++)for(let Pr=0;Pr<je;Pr++){let tr=(se.data[it++]-nt[0])*Ve[0],rr=(se.data[Qe++]-nt[1])*Ve[1],Rr=(se.data[$t++]-nt[2])*Ve[2],Lt=qe===-1?255:(se.data[qe++]-nt[3])*Ve[3];Pe.fillStyle="rgba("+tr+","+rr+","+Rr+","+Lt+")",Pe.fillRect(Pr,pt,1,1)}if("toDataURL"in we)return we.toDataURL();throw new Error("toDataURL is not supported")}else throw new Error("Can not access image data")},H=(se,he)=>{let we=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),Pe;if(we!=null){let je,We,Ie;(he==null?void 0:he.tensorLayout)!==void 0&&he.tensorLayout==="NHWC"?(je=se.dims[2],We=se.dims[1],Ie=se.dims[3]):(je=se.dims[3],We=se.dims[2],Ie=se.dims[1]);let De=he!==void 0&&he.format!==void 0?he.format:"RGB",Ve=he==null?void 0:he.norm,nt,ct;Ve===void 0||Ve.mean===void 0?nt=[255,255,255,255]:typeof Ve.mean=="number"?nt=[Ve.mean,Ve.mean,Ve.mean,Ve.mean]:(nt=[Ve.mean[0],Ve.mean[1],Ve.mean[2],255],Ve.mean[3]!==void 0&&(nt[3]=Ve.mean[3])),Ve===void 0||Ve.bias===void 0?ct=[0,0,0,0]:typeof Ve.bias=="number"?ct=[Ve.bias,Ve.bias,Ve.bias,Ve.bias]:(ct=[Ve.bias[0],Ve.bias[1],Ve.bias[2],0],Ve.bias[3]!==void 0&&(ct[3]=Ve.bias[3]));let it=We*je;if(he!==void 0&&(he.format!==void 0&&Ie===4&&he.format!=="RGBA"||Ie===3&&he.format!=="RGB"&&he.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let Qe=4,$t=0,qe=1,pt=2,Pr=3,tr=0,rr=it,Rr=it*2,Lt=-1;De==="RGBA"?(tr=0,rr=it,Rr=it*2,Lt=it*3):De==="RGB"?(tr=0,rr=it,Rr=it*2):De==="RBG"&&(tr=0,Rr=it,rr=it*2),Pe=we.createImageData(je,We);for(let qr=0;qr<We*je;$t+=Qe,qe+=Qe,pt+=Qe,Pr+=Qe,qr++)Pe.data[$t]=(se.data[tr++]-ct[0])*nt[0],Pe.data[qe]=(se.data[rr++]-ct[1])*nt[1],Pe.data[pt]=(se.data[Rr++]-ct[2])*nt[2],Pe.data[Pr]=Lt===-1?255:(se.data[Lt++]-ct[3])*nt[3]}else throw new Error("Can not access image data");return Pe}}),z,F,Y,te,le,pe,X=u(()=>{ce(),z=(se,he)=>{if(se===void 0)throw new Error("Image buffer must be defined");if(he.height===void 0||he.width===void 0)throw new Error("Image height and width must be defined");if(he.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");let{height:we,width:Pe}=he,je=he.norm??{mean:255,bias:0},We,Ie;typeof je.mean=="number"?We=[je.mean,je.mean,je.mean,je.mean]:We=[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=he.format!==void 0?he.format:"RGBA",Ve=he.tensorFormat!==void 0&&he.tensorFormat!==void 0?he.tensorFormat:"RGB",nt=we*Pe,ct=Ve==="RGBA"?new Float32Array(nt*4):new Float32Array(nt*3),it=4,Qe=0,$t=1,qe=2,pt=3,Pr=0,tr=nt,rr=nt*2,Rr=-1;De==="RGB"&&(it=3,Qe=0,$t=1,qe=2,pt=-1),Ve==="RGBA"?Rr=nt*3:Ve==="RBG"?(Pr=0,rr=nt,tr=nt*2):Ve==="BGR"&&(rr=0,tr=nt,Pr=nt*2);for(let Lt=0;Lt<nt;Lt++,Qe+=it,qe+=it,$t+=it,pt+=it)ct[Pr++]=(se[Qe]+Ie[0])/We[0],ct[tr++]=(se[$t]+Ie[1])/We[1],ct[rr++]=(se[qe]+Ie[2])/We[2],Rr!==-1&&pt!==-1&&(ct[Rr++]=(se[pt]+Ie[3])/We[3]);return Ve==="RGBA"?new ie("float32",ct,[1,4,we,Pe]):new ie("float32",ct,[1,3,we,Pe])},F=async(se,he)=>{let we=typeof HTMLImageElement<"u"&&se instanceof HTMLImageElement,Pe=typeof ImageData<"u"&&se instanceof ImageData,je=typeof ImageBitmap<"u"&&se instanceof ImageBitmap,We=typeof se=="string",Ie,De=he??{},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")},nt=ct=>typeof HTMLCanvasElement<"u"&&ct instanceof HTMLCanvasElement||ct instanceof OffscreenCanvas?ct.getContext("2d"):null;if(we){let ct=Ve();ct.width=se.width,ct.height=se.height;let it=nt(ct);if(it!=null){let Qe=se.height,$t=se.width;if(he!==void 0&&he.resizedHeight!==void 0&&he.resizedWidth!==void 0&&(Qe=he.resizedHeight,$t=he.resizedWidth),he!==void 0){if(De=he,he.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");De.tensorFormat="RGBA",De.height=Qe,De.width=$t}else De.tensorFormat="RGBA",De.height=Qe,De.width=$t;it.drawImage(se,0,0),Ie=it.getImageData(0,0,$t,Qe).data}else throw new Error("Can not access image data")}else if(Pe){let ct,it;if(he!==void 0&&he.resizedWidth!==void 0&&he.resizedHeight!==void 0?(ct=he.resizedHeight,it=he.resizedWidth):(ct=se.height,it=se.width),he!==void 0&&(De=he),De.format="RGBA",De.height=ct,De.width=it,he!==void 0){let Qe=Ve();Qe.width=it,Qe.height=ct;let $t=nt(Qe);if($t!=null)$t.putImageData(se,0,0),Ie=$t.getImageData(0,0,it,ct).data;else throw new Error("Can not access image data")}else Ie=se.data}else if(je){if(he===void 0)throw new Error("Please provide image config with format for Imagebitmap");let ct=Ve();ct.width=se.width,ct.height=se.height;let it=nt(ct);if(it!=null){let Qe=se.height,$t=se.width;return it.drawImage(se,0,0,$t,Qe),Ie=it.getImageData(0,0,$t,Qe).data,De.height=Qe,De.width=$t,z(Ie,De)}else throw new Error("Can not access image data")}else{if(We)return new Promise((ct,it)=>{let Qe=Ve(),$t=nt(Qe);if(!se||!$t)return it();let qe=new Image;qe.crossOrigin="Anonymous",qe.src=se,qe.onload=()=>{Qe.width=qe.width,Qe.height=qe.height,$t.drawImage(qe,0,0,Qe.width,Qe.height);let pt=$t.getImageData(0,0,Qe.width,Qe.height);De.height=Qe.height,De.width=Qe.width,ct(z(pt.data,De))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(Ie!==void 0)return z(Ie,De);throw new Error("Input data provided is not supported - aborted tensor creation")},Y=(se,he)=>{let{width:we,height:Pe,download:je,dispose:We}=he,Ie=[1,Pe,we,4];return new ie({location:"texture",type:"float32",texture:se,dims:Ie,download:je,dispose:We})},te=(se,he)=>{let{dataType:we,dims:Pe,download:je,dispose:We}=he;return new ie({location:"gpu-buffer",type:we??"float32",gpuBuffer:se,dims:Pe,download:je,dispose:We})},le=(se,he)=>{let{dataType:we,dims:Pe,download:je,dispose:We}=he;return new ie({location:"ml-tensor",type:we??"float32",mlTensor:se,dims:Pe,download:je,dispose:We})},pe=(se,he,we)=>new ie({location:"cpu-pinned",type:se,data:he,dims:we??[he.length]})}),Q,J,ee,ae,me=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]]),J=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),ee=!1,ae=()=>{if(!ee){ee=!0;let se=typeof BigInt64Array<"u"&&BigInt64Array.from,he=typeof BigUint64Array<"u"&&BigUint64Array.from,we=globalThis.Float16Array,Pe=typeof we<"u"&&we.from;se&&(Q.set("int64",BigInt64Array),J.set(BigInt64Array,"int64")),he&&(Q.set("uint64",BigUint64Array),J.set(BigUint64Array,"uint64")),Pe?(Q.set("float16",we),J.set(we,"float16")):Q.set("float16",Uint16Array)}}}),_e,Ne,xe=u(()=>{ce(),_e=se=>{let he=1;for(let we=0;we<se.length;we++){let Pe=se[we];if(typeof Pe!="number"||!Number.isSafeInteger(Pe))throw new TypeError(`dims[${we}] must be an integer, got: ${Pe}`);if(Pe<0)throw new RangeError(`dims[${we}] must be a non-negative integer, got: ${Pe}`);he*=Pe}return he},Ne=(se,he)=>{switch(se.location){case"cpu":return new ie(se.type,se.data,he);case"cpu-pinned":return new ie({location:"cpu-pinned",data:se.data,type:se.type,dims:he});case"texture":return new ie({location:"texture",texture:se.texture,type:se.type,dims:he});case"gpu-buffer":return new ie({location:"gpu-buffer",gpuBuffer:se.gpuBuffer,type:se.type,dims:he});case"ml-tensor":return new ie({location:"ml-tensor",mlTensor:se.mlTensor,type:se.type,dims:he});default:throw new Error(`tensorReshape: tensor location ${se.location} is not supported`)}}}),ie,ce=u(()=>{V(),X(),me(),xe(),ie=class{constructor(se,he,we){ae();let Pe,je;if(typeof se=="object"&&"location"in se)switch(this.dataLocation=se.location,Pe=se.type,je=se.dims,se.location){case"cpu-pinned":{let Ie=Q.get(Pe);if(!Ie)throw new TypeError(`unsupported type "${Pe}" to create tensor from pinned buffer`);if(!(se.data instanceof Ie))throw new TypeError(`buffer should be of type ${Ie.name}`);this.cpuData=se.data;break}case"texture":{if(Pe!=="float32")throw new TypeError(`unsupported type "${Pe}" to create tensor from texture`);this.gpuTextureData=se.texture,this.downloader=se.download,this.disposer=se.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=se.gpuBuffer,this.downloader=se.download,this.disposer=se.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=se.mlTensor,this.downloader=se.download,this.disposer=se.dispose;break}default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let Ie,De;if(typeof se=="string")if(Pe=se,De=we,se==="string"){if(!Array.isArray(he))throw new TypeError("A string tensor's data must be a string array.");Ie=he}else{let Ve=Q.get(se);if(Ve===void 0)throw new TypeError(`Unsupported tensor type: ${se}.`);if(Array.isArray(he)){if(se==="float16"&&Ve===Uint16Array||se==="uint4"||se==="int4")throw new TypeError(`Creating a ${se} tensor from number array is not supported. Please use ${Ve.name} as data.`);se==="uint64"||se==="int64"?Ie=Ve.from(he,BigInt):Ie=Ve.from(he)}else if(he instanceof Ve)Ie=he;else if(he instanceof Uint8ClampedArray)if(se==="uint8")Ie=Uint8Array.from(he);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else if(se==="float16"&&he instanceof Uint16Array&&Ve!==Uint16Array)Ie=new globalThis.Float16Array(he.buffer,he.byteOffset,he.length);else throw new TypeError(`A ${Pe} tensor's data must be type of ${Ve}`)}else if(De=he,Array.isArray(se)){if(se.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let Ve=typeof se[0];if(Ve==="string")Pe="string",Ie=se;else if(Ve==="boolean")Pe="bool",Ie=Uint8Array.from(se);else throw new TypeError(`Invalid element type of data array: ${Ve}.`)}else if(se instanceof Uint8ClampedArray)Pe="uint8",Ie=Uint8Array.from(se);else{let Ve=J.get(se.constructor);if(Ve===void 0)throw new TypeError(`Unsupported type for tensor data: ${se.constructor}.`);Pe=Ve,Ie=se}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 We=_e(je);if(this.cpuData&&We!==this.cpuData.length&&!((Pe==="uint4"||Pe==="int4")&&Math.ceil(We/2)===this.cpuData.length))throw new Error(`Tensor's size(${We}) does not match data length(${this.cpuData.length}).`);this.type=Pe,this.dims=je,this.size=We}static async fromImage(se,he){return F(se,he)}static fromTexture(se,he){return Y(se,he)}static fromGpuBuffer(se,he){return te(se,he)}static fromMLTensor(se,he){return le(se,he)}static fromPinnedBuffer(se,he,we){return pe(se,he,we)}toDataURL(se){return U(this,se)}toImageData(se){return H(this,se)}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(se){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 he=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=he,se&&this.disposer&&(this.disposer(),this.disposer=void 0),he}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(se){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return Ne(this,se)}}}),ge,Ae=u(()=>{ce(),ge=ie}),Te,Me,Le,Ue,st,lt,Zt=u(()=>{N(),Te=(se,he)=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||console.timeStamp(`${se}::ORT::${he}`)},Me=(se,he)=>{var je;let we=((je=new Error().stack)==null?void 0:je.split(/\r\n|\r|\n/g))||[],Pe=!1;for(let We=0;We<we.length;We++){if(Pe&&!we[We].includes("TRACE_FUNC")){let Ie=`FUNC_${se}::${we[We].trim().split(" ")[1]}`;he&&(Ie+=`::${he}`),Te("CPU",Ie);return}we[We].includes("TRACE_FUNC")&&(Pe=!0)}},Le=se=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||Me("BEGIN",se)},Ue=se=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||Me("END",se)},st=se=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||console.time(`ORT::${se}`)},lt=se=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||console.timeEnd(`ORT::${se}`)}}),Kt,sr=u(()=>{_(),Ae(),Zt(),Kt=class A4{constructor(he){this.handler=he}async run(he,we,Pe){Le(),st("InferenceSession.run");let je={},We={};if(typeof he!="object"||he===null||he instanceof ge||Array.isArray(he))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let Ie=!0;if(typeof we=="object"){if(we===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(we instanceof ge)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(we)){if(we.length===0)throw new TypeError("'fetches' cannot be an empty array.");Ie=!1;for(let nt of we){if(typeof nt!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(nt)===-1)throw new RangeError(`'fetches' contains invalid output name: ${nt}.`);je[nt]=null}if(typeof Pe=="object"&&Pe!==null)We=Pe;else if(typeof Pe<"u")throw new TypeError("'options' must be an object.")}else{let nt=!1,ct=Object.getOwnPropertyNames(we);for(let it of this.outputNames)if(ct.indexOf(it)!==-1){let Qe=we[it];(Qe===null||Qe instanceof ge)&&(nt=!0,Ie=!1,je[it]=Qe)}if(nt){if(typeof Pe=="object"&&Pe!==null)We=Pe;else if(typeof Pe<"u")throw new TypeError("'options' must be an object.")}else We=we}}else if(typeof we<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let nt of this.inputNames)if(typeof he[nt]>"u")throw new Error(`input '${nt}' is missing in 'feeds'.`);if(Ie)for(let nt of this.outputNames)je[nt]=null;let De=await this.handler.run(he,je,We),Ve={};for(let nt in De)if(Object.hasOwnProperty.call(De,nt)){let ct=De[nt];ct instanceof ge?Ve[nt]=ct:Ve[nt]=new ge(ct.type,ct.data,ct.dims)}return lt("InferenceSession.run"),Ue(),Ve}async release(){return this.handler.dispose()}static async create(he,we,Pe,je){Le(),st("InferenceSession.create");let We,Ie={};if(typeof he=="string"){if(We=he,typeof we=="object"&&we!==null)Ie=we;else if(typeof we<"u")throw new TypeError("'options' must be an object.")}else if(he instanceof Uint8Array){if(We=he,typeof we=="object"&&we!==null)Ie=we;else if(typeof we<"u")throw new TypeError("'options' must be an object.")}else if(he instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&he instanceof SharedArrayBuffer){let ct=he,it=0,Qe=he.byteLength;if(typeof we=="object"&&we!==null)Ie=we;else if(typeof we=="number"){if(it=we,!Number.isSafeInteger(it))throw new RangeError("'byteOffset' must be an integer.");if(it<0||it>=ct.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${ct.byteLength}).`);if(Qe=he.byteLength-it,typeof Pe=="number"){if(Qe=Pe,!Number.isSafeInteger(Qe))throw new RangeError("'byteLength' must be an integer.");if(Qe<=0||it+Qe>ct.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${ct.byteLength-it}].`);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 we<"u")throw new TypeError("'options' must be an object.");We=new Uint8Array(ct,it,Qe)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[De,Ve]=await b(Ie),nt=await De.createInferenceSessionHandler(We,Ve);return lt("InferenceSession.create"),Ue(),new A4(nt)}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}}}),Vt,jr=u(()=>{sr(),Vt=Kt}),fr=u(()=>{}),Ur=u(()=>{}),Ir=u(()=>{}),fi=u(()=>{}),Zn={};f(Zn,{InferenceSession:()=>Vt,TRACE:()=>Te,TRACE_EVENT_BEGIN:()=>st,TRACE_EVENT_END:()=>lt,TRACE_FUNC_BEGIN:()=>Le,TRACE_FUNC_END:()=>Ue,Tensor:()=>ge,env:()=>O,registerBackend:()=>k});var hr=u(()=>{w(),M(),jr(),Ae(),fr(),Ur(),Zt(),Ir(),fi()}),Rn=u(()=>{}),ut={};f(ut,{default:()=>_r});var wt,_t,_r,xn=u(()=>{var se;Se(),mi(),pi(),wt="ort-wasm-proxy-worker",_t=((se=globalThis.self)==null?void 0:se.name)===wt,_t&&(self.onmessage=he=>{let{type:we,in:Pe}=he.data;try{switch(we){case"init-wasm":Ms(Pe.wasm).then(()=>{qo(Pe).then(()=>{postMessage({type:we})},je=>{postMessage({type:we,err:je})})},je=>{postMessage({type:we,err:je})});break;case"init-ep":{let{epName:je,env:We}=Pe;sa(We,je).then(()=>{postMessage({type:we})},Ie=>{postMessage({type:we,err:Ie})});break}case"copy-from":{let{buffer:je}=Pe,We=lr(je);postMessage({type:we,out:We});break}case"create":{let{model:je,options:We}=Pe;Bi(je,We).then(Ie=>{postMessage({type:we,out:Ie})},Ie=>{postMessage({type:we,err:Ie})});break}case"release":Ta(Pe),postMessage({type:we});break;case"run":{let{sessionId:je,inputIndices:We,inputs:Ie,outputIndices:De,options:Ve}=Pe;Ze(je,We,Ie,De,new Array(De.length).fill(null),Ve).then(nt=>{nt.some(ct=>ct[3]!=="cpu")?postMessage({type:we,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:we,out:nt},vt([...Ie,...nt]))},nt=>{postMessage({type:we,err:nt})});break}case"end-profiling":vi(Pe),postMessage({type:we});break;default:}}catch(je){postMessage({type:we,err:je})}}),_r=_t?null:he=>new Worker(he??Sr,{type:"classic",name:wt})}),rs,fs,Sr,hi,pn,ea,hs,Mi,Ca,ta,ra,ps,Qn,pi=u(()=>{Rn(),rs=typeof location>"u"?void 0:location.origin,fs=()=>{var se,he;return typeof document<"u"?(se=document.currentScript)==null?void 0:se.src:typeof self<"u"?(he=self.location)==null?void 0:he.href:void 0},Sr=fs(),hi=()=>{if(Sr&&!Sr.startsWith("blob:"))return Sr.substring(0,Sr.lastIndexOf("/")+1)},pn=(se,he)=>{try{let we=he??Sr;return(we?new URL(se,we):new URL(se)).origin===rs}catch{return!1}},ea=(se,he)=>{let we=he??Sr;try{return(we?new URL(se,we):new URL(se)).href}catch{return}},hs=(se,he)=>`${he??"./"}${se}`,Mi=async se=>{let he=await(await fetch(se,{credentials:"same-origin"})).blob();return URL.createObjectURL(he)},Ca=async se=>(await import(se)).default,ta=(xn(),h(ut)).default,ra=async()=>{if(!Sr)throw new Error("Failed to load proxy worker: cannot determine the script source URL.");if(pn(Sr))return[void 0,ta()];let se=await Mi(Sr);return[se,ta(se)]},ps=void 0,Qn=async(se,he,we,Pe)=>{let je=ps&&!(se||he);if(je)if(Sr)je=pn(Sr)||Pe&&!we;else if(Pe&&!we)je=!0;else throw new Error("cannot determine the script source URL.");if(je)return[void 0,ps];{let We="ort-wasm-simd-threaded.mjs",Ie=se??ea(We,he),De=we&&Ie&&!pn(Ie,he),Ve=De?await Mi(Ie):Ie??hs(We,he);return[De?Ve:void 0,await Ca(Ve)]}}}),Os,ei,Ii,ns,to,Ps,Rs,Ms,zt,mi=u(()=>{pi(),ei=!1,Ii=!1,ns=!1,to=()=>{if(typeof SharedArrayBuffer>"u")return!1;try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch{return!1}},Ps=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch{return!1}},Rs=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,19,1,17,0,65,1,253,15,65,2,253,15,65,3,253,15,253,147,2,11]))}catch{return!1}},Ms=async se=>{if(ei)return Promise.resolve();if(Ii)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(ns)throw new Error("previous call to 'initializeWebAssembly()' failed.");Ii=!0;let he=se.initTimeout,we=se.numThreads;if(se.simd!==!1){if(se.simd==="relaxed"){if(!Rs())throw new Error("Relaxed WebAssembly SIMD is not supported in the current environment.")}else if(!Ps())throw new Error("WebAssembly SIMD is not supported in the current environment.")}let Pe=to();we>1&&!Pe&&(typeof self<"u"&&!self.crossOriginIsolated&&console.warn("env.wasm.numThreads is set to "+we+", 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."),se.numThreads=we=1);let je=se.wasmPaths,We=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,nt=(Ve==null?void 0:Ve.href)??Ve,ct=se.wasmBinary,[it,Qe]=await Qn(De,We,we>1,!!ct||!!nt),$t=!1,qe=[];if(he>0&&qe.push(new Promise(pt=>{setTimeout(()=>{$t=!0,pt()},he)})),qe.push(new Promise((pt,Pr)=>{let tr={numThreads:we};if(ct)tr.wasmBinary=ct,tr.locateFile=rr=>rr;else if(nt||We)tr.locateFile=rr=>nt??We+rr;else if(De&&De.indexOf("blob:")!==0)tr.locateFile=rr=>new URL(rr,De).href;else if(it){let rr=hi();rr&&(tr.locateFile=Rr=>rr+Rr)}Qe(tr).then(rr=>{Ii=!1,ei=!0,Os=rr,pt(),it&&URL.revokeObjectURL(it)},rr=>{Ii=!1,ns=!0,Pr(rr)})})),await Promise.race(qe),$t)throw new Error(`WebAssembly backend initializing failed due to timeout: ${he}ms`)},zt=()=>{if(ei&&Os)return Os;throw new Error("WebAssembly is not initialized yet.")}}),en,Er,Ct,ja=u(()=>{mi(),en=(se,he)=>{let we=zt(),Pe=we.lengthBytesUTF8(se)+1,je=we._malloc(Pe);return we.stringToUTF8(se,je,Pe),he.push(je),je},Er=(se,he,we,Pe)=>{if(typeof se=="object"&&se!==null){if(we.has(se))throw new Error("Circular reference in options");we.add(se)}Object.entries(se).forEach(([je,We])=>{let Ie=he?he+je:je;if(typeof We=="object")Er(We,Ie+".",we,Pe);else if(typeof We=="string"||typeof We=="number")Pe(Ie,We.toString());else if(typeof We=="boolean")Pe(Ie,We?"1":"0");else throw new Error(`Can't handle extra config type: ${typeof We}`)})},Ct=se=>{let he=zt(),we=he.stackSave();try{let Pe=he.PTR_SIZE,je=he.stackAlloc(2*Pe);he._OrtGetLastError(je,je+Pe);let We=Number(he.getValue(je,Pe===4?"i32":"i64")),Ie=he.getValue(je+Pe,"*"),De=Ie?he.UTF8ToString(Ie):"";throw new Error(`${se} ERROR_CODE: ${We}, ERROR_MESSAGE: ${De}`)}finally{he.stackRestore(we)}}}),ro,El=u(()=>{mi(),ja(),ro=se=>{let he=zt(),we=0,Pe=[],je=se||{};try{if((se==null?void 0:se.logSeverityLevel)===void 0)je.logSeverityLevel=2;else if(typeof se.logSeverityLevel!="number"||!Number.isInteger(se.logSeverityLevel)||se.logSeverityLevel<0||se.logSeverityLevel>4)throw new Error(`log severity level is not valid: ${se.logSeverityLevel}`);if((se==null?void 0:se.logVerbosityLevel)===void 0)je.logVerbosityLevel=0;else if(typeof se.logVerbosityLevel!="number"||!Number.isInteger(se.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${se.logVerbosityLevel}`);(se==null?void 0:se.terminate)===void 0&&(je.terminate=!1);let We=0;return(se==null?void 0:se.tag)!==void 0&&(We=en(se.tag,Pe)),we=he._OrtCreateRunOptions(je.logSeverityLevel,je.logVerbosityLevel,!!je.terminate,We),we===0&&Ct("Can't create run options."),(se==null?void 0:se.extra)!==void 0&&Er(se.extra,"",new WeakSet,(Ie,De)=>{let Ve=en(Ie,Pe),nt=en(De,Pe);he._OrtAddRunConfigEntry(we,Ve,nt)!==0&&Ct(`Can't set a run config entry: ${Ie} - ${De}.`)}),[we,Pe]}catch(We){throw we!==0&&he._OrtReleaseRunOptions(we),Pe.forEach(Ie=>he._free(Ie)),We}}}),no,io,Uo,Hn,Tl,Al,Tr=u(()=>{mi(),ja(),no=se=>{switch(se){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: ${se}`)}},io=se=>{switch(se){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${se}`)}},Uo=se=>{se.extra||(se.extra={}),se.extra.session||(se.extra.session={});let he=se.extra.session;he.use_ort_model_bytes_directly||(he.use_ort_model_bytes_directly="1"),se.executionProviders&&se.executionProviders.some(we=>(typeof we=="string"?we:we.name)==="webgpu")&&(se.enableMemPattern=!1)},Hn=(se,he,we,Pe)=>{let je=en(he,Pe),We=en(we,Pe);zt()._OrtAddSessionConfigEntry(se,je,We)!==0&&Ct(`Can't set a session config entry: ${he} - ${we}.`)},Tl=async(se,he,we)=>{let Pe=he.executionProviders;for(let je of Pe){let We=typeof je=="string"?je:je.name,Ie=[];switch(We){case"webnn":if(We="WEBNN",Hn(se,"session.disable_quant_qdq","1",we),Hn(se,"session.disable_qdq_constant_folding","1",we),typeof je!="string"){let it=je==null?void 0:je.deviceType;it&&Hn(se,"deviceType",it,we)}break;case"webgpu":if(We="JS",typeof je!="string"){let it=je;if(it!=null&&it.preferredLayout){if(it.preferredLayout!=="NCHW"&&it.preferredLayout!=="NHWC")throw new Error(`preferredLayout must be either 'NCHW' or 'NHWC': ${it.preferredLayout}`);Hn(se,"preferredLayout",it.preferredLayout,we)}}break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${We}`)}let De=en(We,we),Ve=Ie.length,nt=0,ct=0;if(Ve>0){nt=zt()._malloc(Ve*zt().PTR_SIZE),we.push(nt),ct=zt()._malloc(Ve*zt().PTR_SIZE),we.push(ct);for(let it=0;it<Ve;it++)zt().setValue(nt+it*zt().PTR_SIZE,Ie[it][0],"*"),zt().setValue(ct+it*zt().PTR_SIZE,Ie[it][1],"*")}await zt()._OrtAppendExecutionProvider(se,De,nt,ct,Ve)!==0&&Ct(`Can't append execution provider: ${We}.`)}},Al=async se=>{let he=zt(),we=0,Pe=[],je=se||{};Uo(je);try{let We=no(je.graphOptimizationLevel??"all"),Ie=io(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 nt=je.logVerbosityLevel??0;if(!Number.isInteger(nt)||nt<0||nt>4)throw new Error(`log verbosity level is not valid: ${nt}`);let ct=typeof je.optimizedModelFilePath=="string"?en(je.optimizedModelFilePath,Pe):0;if(we=he._OrtCreateSessionOptions(We,!!je.enableCpuMemArena,!!je.enableMemPattern,Ie,!!je.enableProfiling,0,De,Ve,nt,ct),we===0&&Ct("Can't create session options."),je.executionProviders&&await Tl(we,je,Pe),je.enableGraphCapture!==void 0){if(typeof je.enableGraphCapture!="boolean")throw new Error(`enableGraphCapture must be a boolean value: ${je.enableGraphCapture}`);Hn(we,"enableGraphCapture",je.enableGraphCapture.toString(),Pe)}if(je.freeDimensionOverrides)for(let[it,Qe]of Object.entries(je.freeDimensionOverrides)){if(typeof it!="string")throw new Error(`free dimension override name must be a string: ${it}`);if(typeof Qe!="number"||!Number.isInteger(Qe)||Qe<0)throw new Error(`free dimension override value must be a non-negative integer: ${Qe}`);let $t=en(it,Pe);he._OrtAddFreeDimensionOverride(we,$t,Qe)!==0&&Ct(`Can't set a free dimension override: ${it} - ${Qe}.`)}return je.extra!==void 0&&Er(je.extra,"",new WeakSet,(it,Qe)=>{Hn(we,it,Qe,Pe)}),[we,Pe]}catch(We){throw we!==0&&he._OrtReleaseSessionOptions(we)!==0&&Ct("Can't release session options."),Pe.forEach(Ie=>he._free(Ie)),We}}}),ti,sn,ri,Is,Ea,na,Di,Mn,Ft=u(()=>{ti=se=>{switch(se){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: ${se}`)}},sn=se=>{switch(se){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: ${se}`)}},ri=(se,he)=>{let we=[-1,4,1,1,2,2,4,8,-1,1,2,8,4,8,-1,-1,-1,-1,-1,-1,-1,.5,.5][se],Pe=typeof he=="number"?he:he.reduce((je,We)=>je*We,1);return we>0?Math.ceil(Pe*we):void 0},Is=se=>{switch(se){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: ${se}`)}},Ea=se=>{switch(se){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: ${se}`)}},na=se=>se==="float32"||se==="float16"||se==="int32"||se==="int64"||se==="uint32"||se==="uint8"||se==="bool"||se==="uint4"||se==="int4",Di=se=>se==="float32"||se==="float16"||se==="int32"||se==="int64"||se==="uint32"||se==="uint64"||se==="int8"||se==="uint8"||se==="bool"||se==="uint4"||se==="int4",Mn=se=>{switch(se){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: ${se}`)}}}),an,ia=u(()=>{Rn(),an=async se=>{if(typeof se=="string"){let he=await fetch(se);if(!he.ok)throw new Error(`failed to load external data file: ${se}`);let we=he.headers.get("Content-Length"),Pe=we?parseInt(we,10):0;if(Pe<1073741824)return new Uint8Array(await he.arrayBuffer());{if(!he.body)throw new Error(`failed to load external data file: ${se}, no response body.`);let je=he.body.getReader(),We;try{We=new ArrayBuffer(Pe)}catch(De){if(De instanceof RangeError){let Ve=Math.ceil(Pe/65536);We=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 nt=Ve.byteLength;new Uint8Array(We,Ie,nt).set(Ve),Ie+=nt}return new Uint8Array(We,0,Pe)}}else return se instanceof Blob?new Uint8Array(await se.arrayBuffer()):se instanceof Uint8Array?se:new Uint8Array(se)}}),Li,qo,sa,gi,ms,aa,lr,Bi,Ta,is,Ze,vi,vt,Se=u(()=>{hr(),El(),Tr(),Ft(),mi(),ja(),ia(),Li=(se,he)=>{zt()._OrtInit(se,he)!==0&&Ct("Can't initialize onnxruntime.")},qo=async se=>{Li(se.wasm.numThreads,Ea(se.logLevel))},sa=async(se,he)=>{var Pe,je;(je=(Pe=zt()).asyncInit)==null||je.call(Pe);let we=se.webgpu.adapter;if(he==="webgpu"){if(typeof navigator>"u"||!navigator.gpu)throw new Error("WebGPU is not supported in current environment");if(we){if(typeof we.limits!="object"||typeof we.features!="object"||typeof we.requestDevice!="function")throw new Error("Invalid GPU adapter set in `env.webgpu.adapter`. It must be a GPUAdapter object.")}else{let We=se.webgpu.powerPreference;if(We!==void 0&&We!=="low-power"&&We!=="high-performance")throw new Error(`Invalid powerPreference setting: "${We}"`);let Ie=se.webgpu.forceFallbackAdapter;if(Ie!==void 0&&typeof Ie!="boolean")throw new Error(`Invalid forceFallbackAdapter setting: "${Ie}"`);if(we=await navigator.gpu.requestAdapter({powerPreference:We,forceFallbackAdapter:Ie}),!we)throw new Error('Failed to get GPU adapter. You may need to enable flag "--enable-unsafe-webgpu" if you are using Chrome.')}}if(he==="webnn"&&(typeof navigator>"u"||!navigator.ml))throw new Error("WebNN is not supported in current environment")},gi=new Map,ms=se=>{let he=zt(),we=he.stackSave();try{let Pe=he.PTR_SIZE,je=he.stackAlloc(2*Pe);he._OrtGetInputOutputCount(se,je,je+Pe)!==0&&Ct("Can't get session input/output count.");let We=Pe===4?"i32":"i64";return[Number(he.getValue(je,We)),Number(he.getValue(je+Pe,We))]}finally{he.stackRestore(we)}},aa=(se,he)=>{let we=zt(),Pe=we.stackSave(),je=0;try{let We=we.PTR_SIZE,Ie=we.stackAlloc(2*We);we._OrtGetInputOutputMetadata(se,he,Ie,Ie+We)!==0&&Ct("Can't get session input/output metadata.");let De=Number(we.getValue(Ie,"*"));je=Number(we.getValue(Ie+We,"*"));let Ve=we.HEAP32[je/4];if(Ve===0)return[De,0];let nt=we.HEAPU32[je/4+1],ct=[];for(let it=0;it<nt;it++){let Qe=Number(we.getValue(je+8+it*We,"*"));ct.push(Qe!==0?we.UTF8ToString(Qe):Number(we.getValue(je+8+(it+nt)*We,"*")))}return[De,Ve,ct]}finally{we.stackRestore(Pe),je!==0&&we._OrtFree(je)}},lr=se=>{let he=zt(),we=he._malloc(se.byteLength);if(we===0)throw new Error(`Can't create a session. failed to allocate a buffer of size ${se.byteLength}.`);return he.HEAPU8.set(se,we),[we,se.byteLength]},Bi=async(se,he)=>{var ct,it,Qe;let we,Pe,je=zt();Array.isArray(se)?[we,Pe]=se:se.buffer===je.HEAPU8.buffer?[we,Pe]=[se.byteOffset,se.byteLength]:[we,Pe]=lr(se);let We=0,Ie=0,De=[],Ve=[],nt=[];try{if([Ie,De]=await Al(he),(he==null?void 0:he.externalData)&&je.mountExternalData){let qr=[];for(let pr of he.externalData){let In=typeof pr=="string"?pr:pr.path;qr.push(an(typeof pr=="string"?pr:pr.data).then(ni=>{je.mountExternalData(In,ni)}))}await Promise.all(qr)}for(let qr of(he==null?void 0:he.executionProviders)??[])if((typeof qr=="string"?qr:qr.name)==="webnn"){if(je.shouldTransferToMLTensor=!1,typeof qr!="string"){let pr=qr,In=pr==null?void 0:pr.context,ni=pr==null?void 0:pr.gpuDevice,yi=pr==null?void 0:pr.deviceType,Nl=pr==null?void 0:pr.powerPreference;In?je.currentContext=In:ni?je.currentContext=await je.webnnCreateMLContext(ni):je.currentContext=await je.webnnCreateMLContext({deviceType:yi,powerPreference:Nl})}else je.currentContext=await je.webnnCreateMLContext();break}We=await je._OrtCreateSession(we,Pe,Ie),(ct=je.webgpuOnCreateSession)==null||ct.call(je,We),We===0&&Ct("Can't create a session."),(it=je.jsepOnCreateSession)==null||it.call(je),je.currentContext&&(je.webnnRegisterMLContext(We,je.currentContext),je.currentContext=void 0,je.shouldTransferToMLTensor=!0);let[$t,qe]=ms(We),pt=!!(he!=null&&he.enableGraphCapture),Pr=[],tr=[],rr=[],Rr=[],Lt=[];for(let qr=0;qr<$t;qr++){let[pr,In,ni]=aa(We,qr);pr===0&&Ct("Can't get an input name."),Ve.push(pr);let yi=je.UTF8ToString(pr);Pr.push(yi),rr.push(In===0?{name:yi,isTensor:!1}:{name:yi,isTensor:!0,type:sn(In),shape:ni})}for(let qr=0;qr<qe;qr++){let[pr,In,ni]=aa(We,qr+$t);pr===0&&Ct("Can't get an output name."),nt.push(pr);let yi=je.UTF8ToString(pr);tr.push(yi),Rr.push(In===0?{name:yi,isTensor:!1}:{name:yi,isTensor:!0,type:sn(In),shape:ni})}return gi.set(We,[We,Ve,nt,null,pt,!1]),[We,Pr,tr,rr,Rr]}catch($t){throw Ve.forEach(qe=>je._OrtFree(qe)),nt.forEach(qe=>je._OrtFree(qe)),We!==0&&je._OrtReleaseSession(We)!==0&&Ct("Can't release session."),$t}finally{je._free(we),Ie!==0&&je._OrtReleaseSessionOptions(Ie)!==0&&Ct("Can't release session options."),De.forEach($t=>je._free($t)),(Qe=je.unmountExternalData)==null||Qe.call(je)}},Ta=se=>{var Ve,nt,ct;let he=zt(),we=gi.get(se);if(!we)throw new Error(`cannot release session. invalid session id: ${se}`);let[Pe,je,We,Ie,De]=we;Ie&&(De&&he._OrtClearBoundOutputs(Ie.handle)!==0&&Ct("Can't clear bound outputs."),he._OrtReleaseBinding(Ie.handle)!==0&&Ct("Can't release IO binding.")),(Ve=he.jsepOnReleaseSession)==null||Ve.call(he,se),(nt=he.webnnOnReleaseSession)==null||nt.call(he,se),(ct=he.webgpuOnReleaseSession)==null||ct.call(he,se),je.forEach(it=>he._OrtFree(it)),We.forEach(it=>he._OrtFree(it)),he._OrtReleaseSession(Pe)!==0&&Ct("Can't release session."),gi.delete(se)},is=async(se,he,we,Pe,je,We,Ie=!1)=>{if(!se){he.push(0);return}let De=zt(),Ve=De.PTR_SIZE,nt=se[0],ct=se[1],it=se[3],Qe=it,$t,qe;if(nt==="string"&&(it==="gpu-buffer"||it==="ml-tensor"))throw new Error("String tensor is not supported on GPU.");if(Ie&&it!=="gpu-buffer")throw new Error(`External buffer must be provided for input/output index ${We} when enableGraphCapture is true.`);if(it==="gpu-buffer"){let tr=se[2].gpuBuffer;qe=ri(ti(nt),ct);{let rr=De.jsepRegisterBuffer;if(!rr)throw new Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');$t=rr(Pe,We,tr,qe)}}else if(it==="ml-tensor"){let tr=se[2].mlTensor;qe=ri(ti(nt),ct);let rr=De.webnnRegisterMLTensor;if(!rr)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');$t=rr(Pe,tr,ti(nt),ct)}else{let tr=se[2];if(Array.isArray(tr)){qe=Ve*tr.length,$t=De._malloc(qe),we.push($t);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($t+rr*Ve,en(tr[rr],we),"*")}}else{let rr=De.webnnIsGraphInput,Rr=De.webnnIsGraphOutput;if(nt!=="string"&&rr&&Rr){let Lt=De.UTF8ToString(je);if(rr(Pe,Lt)||Rr(Pe,Lt)){let qr=ti(nt);qe=ri(qr,ct),Qe="ml-tensor";let pr=De.webnnCreateTemporaryTensor,In=De.webnnUploadTensor;if(!pr||!In)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');let ni=await pr(Pe,qr,ct);In(ni,new Uint8Array(tr.buffer,tr.byteOffset,tr.byteLength)),$t=ni}else qe=tr.byteLength,$t=De._malloc(qe),we.push($t),De.HEAPU8.set(new Uint8Array(tr.buffer,tr.byteOffset,qe),$t)}else qe=tr.byteLength,$t=De._malloc(qe),we.push($t),De.HEAPU8.set(new Uint8Array(tr.buffer,tr.byteOffset,qe),$t)}}let pt=De.stackSave(),Pr=De.stackAlloc(4*ct.length);try{ct.forEach((rr,Rr)=>De.setValue(Pr+Rr*Ve,rr,Ve===4?"i32":"i64"));let tr=De._OrtCreateTensor(ti(nt),$t,qe,Pr,ct.length,Mn(Qe));tr===0&&Ct(`Can't create tensor for input/output. session=${Pe}, index=${We}.`),he.push(tr)}finally{De.stackRestore(pt)}},Ze=async(se,he,we,Pe,je,We)=>{var bi,Nc,Uu;let Ie=zt(),De=Ie.PTR_SIZE,Ve=gi.get(se);if(!Ve)throw new Error(`cannot run inference. invalid session id: ${se}`);let nt=Ve[0],ct=Ve[1],it=Ve[2],Qe=Ve[3],$t=Ve[4];Ve[5];let qe=he.length,pt=Pe.length,Pr=0,tr=[],rr=[],Rr=[],Lt=[],qr=[],pr=Ie.stackSave(),In=Ie.stackAlloc(qe*De),ni=Ie.stackAlloc(qe*De),yi=Ie.stackAlloc(pt*De),Nl=Ie.stackAlloc(pt*De);try{[Pr,tr]=ro(We),st("wasm prepareInputOutputTensor");for(let ur=0;ur<qe;ur++)await is(we[ur],rr,Lt,se,ct[he[ur]],he[ur],$t);for(let ur=0;ur<pt;ur++)await is(je[ur],Rr,Lt,se,it[Pe[ur]],qe+Pe[ur],$t);lt("wasm prepareInputOutputTensor");for(let ur=0;ur<qe;ur++)Ie.setValue(In+ur*De,rr[ur],"*"),Ie.setValue(ni+ur*De,ct[he[ur]],"*");for(let ur=0;ur<pt;ur++)Ie.setValue(yi+ur*De,Rr[ur],"*"),Ie.setValue(Nl+ur*De,it[Pe[ur]],"*");(bi=Ie.jsepOnRunStart)==null||bi.call(Ie,nt),(Nc=Ie.webnnOnRunStart)==null||Nc.call(Ie,nt);let Dn;Dn=await Ie._OrtRun(nt,ni,In,qe,Nl,pt,yi,Pr),Dn!==0&&Ct("failed to call OrtRun().");let Ls=[],qu=[];st("wasm ProcessOutputTensor");for(let ur=0;ur<pt;ur++){let vs=Number(Ie.getValue(yi+ur*De,"*"));if(vs===Rr[ur]||qr.includes(Rr[ur])){Ls.push(je[ur]),vs!==Rr[ur]&&Ie._OrtReleaseTensor(vs)!==0&&Ct("Can't release tensor.");continue}let jf=Ie.stackSave(),ca=Ie.stackAlloc(4*De),Wo=!1,_n,xi=0;try{Ie._OrtGetTensorData(vs,ca,ca+De,ca+2*De,ca+3*De)!==0&&Ct(`Can't access output tensor data on index ${ur}.`);let Oc=De===4?"i32":"i64",wi=Number(Ie.getValue(ca,Oc));xi=Ie.getValue(ca+De,"*");let Wu=Ie.getValue(ca+De*2,"*"),Ef=Number(Ie.getValue(ca+De*3,Oc)),ua=[];for(let Sn=0;Sn<Ef;Sn++)ua.push(Number(Ie.getValue(Wu+Sn*De,Oc)));Ie._OrtFree(Wu)!==0&&Ct("Can't free memory for tensor dims.");let ys=ua.reduce((Sn,tn)=>Sn*tn,1);_n=sn(wi);let Bs=Qe==null?void 0:Qe.outputPreferredLocations[Pe[ur]];if(_n==="string"){if(Bs==="gpu-buffer"||Bs==="ml-tensor")throw new Error("String tensor is not supported on GPU.");let Sn=[];for(let tn=0;tn<ys;tn++){let bs=Ie.getValue(xi+tn*De,"*"),Hu=Ie.getValue(xi+(tn+1)*De,"*"),Vu=tn===ys-1?void 0:Hu-bs;Sn.push(Ie.UTF8ToString(bs,Vu))}Ls.push([_n,ua,Sn,"cpu"])}else if(Bs==="gpu-buffer"&&ys>0){let Sn=Ie.jsepGetBuffer;if(!Sn)throw new Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');let tn=Sn(xi),bs=ri(wi,ys);if(bs===void 0||!na(_n))throw new Error(`Unsupported data type: ${_n}`);Wo=!0,Ls.push([_n,ua,{gpuBuffer:tn,download:Ie.jsepCreateDownloader(tn,bs,_n),dispose:()=>{Ie._OrtReleaseTensor(vs)!==0&&Ct("Can't release tensor.")}},"gpu-buffer"])}else if(Bs==="ml-tensor"&&ys>0){let Sn=Ie.webnnEnsureTensor,tn=Ie.webnnIsGraphInputOutputTypeSupported;if(!Sn||!tn)throw new Error('preferredLocation "ml-tensor" is not supported without using WebNN.');if(ri(wi,ys)===void 0||!Di(_n))throw new Error(`Unsupported data type: ${_n}`);if(!tn(se,_n,!1))throw new Error(`preferredLocation "ml-tensor" for ${_n} output is not supported by current WebNN Context.`);let bs=await Sn(se,xi,wi,ua,!1);Wo=!0,Ls.push([_n,ua,{mlTensor:bs,download:Ie.webnnCreateMLTensorDownloader(xi,_n),dispose:()=>{Ie.webnnReleaseTensorId(xi),Ie._OrtReleaseTensor(vs)}},"ml-tensor"])}else if(Bs==="ml-tensor-cpu-output"&&ys>0){let Sn=Ie.webnnCreateMLTensorDownloader(xi,_n)(),tn=Ls.length;Wo=!0,qu.push((async()=>{let bs=[tn,await Sn];return Ie.webnnReleaseTensorId(xi),Ie._OrtReleaseTensor(vs),bs})()),Ls.push([_n,ua,[],"cpu"])}else{let Sn=Is(_n),tn=new Sn(ys);new Uint8Array(tn.buffer,tn.byteOffset,tn.byteLength).set(Ie.HEAPU8.subarray(xi,xi+tn.byteLength)),Ls.push([_n,ua,tn,"cpu"])}}finally{Ie.stackRestore(jf),_n==="string"&&xi&&Ie._free(xi),Wo||Ie._OrtReleaseTensor(vs)}}Qe&&!$t&&(Ie._OrtClearBoundOutputs(Qe.handle)!==0&&Ct("Can't clear bound outputs."),gi.set(se,[nt,ct,it,Qe,$t,!1]));for(let[ur,vs]of await Promise.all(qu))Ls[ur][2]=vs;return lt("wasm ProcessOutputTensor"),Ls}finally{(Uu=Ie.webnnOnRunEnd)==null||Uu.call(Ie,nt),Ie.stackRestore(pr),rr.forEach(Dn=>Ie._OrtReleaseTensor(Dn)),Rr.forEach(Dn=>Ie._OrtReleaseTensor(Dn)),Lt.forEach(Dn=>Ie._free(Dn)),Pr!==0&&Ie._OrtReleaseRunOptions(Pr),tr.forEach(Dn=>Ie._free(Dn))}},vi=se=>{let he=zt(),we=gi.get(se);if(!we)throw new Error("invalid session id");let Pe=we[0],je=he._OrtEndProfiling(Pe);je===0&&Ct("Can't get an profile file name."),he._OrtFree(je)},vt=se=>{let he=[];for(let we of se){let Pe=we[2];!Array.isArray(Pe)&&"buffer"in Pe&&he.push(Pe.buffer)}return he}}),ze,et,Et,ir,cr,Br,Dr,mn,Gr,wn,Lr,gs,Aa,so,Ds,Cf,ao,oo,Bu=u(()=>{hr(),Se(),mi(),pi(),ze=()=>!!O.wasm.proxy&&typeof document<"u",Et=!1,ir=!1,cr=!1,mn=new Map,Gr=(se,he)=>{let we=mn.get(se);we?we.push(he):mn.set(se,[he])},wn=()=>{if(Et||!ir||cr||!et)throw new Error("worker not ready")},Lr=se=>{switch(se.data.type){case"init-wasm":Et=!1,se.data.err?(cr=!0,Dr[1](se.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 he=mn.get(se.data.type);se.data.err?he.shift()[1](se.data.err):he.shift()[0](se.data.out);break}}},gs=async()=>{if(!ir){if(Et)throw new Error("multiple calls to 'initWasm()' detected.");if(cr)throw new Error("previous call to 'initWasm()' failed.");if(Et=!0,ze())return new Promise((se,he)=>{et==null||et.terminate(),ra().then(([we,Pe])=>{try{et=Pe,et.onerror=We=>he(We),et.onmessage=Lr,Dr=[se,he];let je={type:"init-wasm",in:O};if(!je.in.wasm.wasmPaths&&we){let We=hi();We&&(je.in.wasm.wasmPaths=We)}et.postMessage(je),Br=we}catch(je){he(je)}},he)});try{await Ms(O.wasm),await qo(O),ir=!0}catch(se){throw cr=!0,se}finally{Et=!1}}},Aa=async se=>{if(ze())return wn(),new Promise((he,we)=>{Gr("init-ep",[he,we]);let Pe={type:"init-ep",in:{epName:se,env:O}};et.postMessage(Pe)});await sa(O,se)},so=async se=>ze()?(wn(),new Promise((he,we)=>{Gr("copy-from",[he,we]);let Pe={type:"copy-from",in:{buffer:se}};et.postMessage(Pe,[se.buffer])})):lr(se),Ds=async(se,he)=>{if(ze()){if(he!=null&&he.preferredOutputLocation)throw new Error('session option "preferredOutputLocation" is not supported for proxy.');return wn(),new Promise((we,Pe)=>{Gr("create",[we,Pe]);let je={type:"create",in:{model:se,options:{...he}}},We=[];se instanceof Uint8Array&&We.push(se.buffer),et.postMessage(je,We)})}else return Bi(se,he)},Cf=async se=>{if(ze())return wn(),new Promise((he,we)=>{Gr("release",[he,we]);let Pe={type:"release",in:se};et.postMessage(Pe)});Ta(se)},ao=async(se,he,we,Pe,je,We)=>{if(ze()){if(we.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)=>{Gr("run",[Ie,De]);let Ve=we,nt={type:"run",in:{sessionId:se,inputIndices:he,inputs:Ve,outputIndices:Pe,options:We}};et.postMessage(nt,vt(Ve))})}else return Ze(se,he,we,Pe,je,We)},oo=async se=>{if(ze())return wn(),new Promise((he,we)=>{Gr("end-profiling",[he,we]);let Pe={type:"end-profiling",in:se};et.postMessage(Pe)});vi(se)}}),Ec,lo,$l,Tc=u(()=>{hr(),Bu(),Ft(),Rn(),ia(),Ec=(se,he)=>{switch(se.location){case"cpu":return[se.type,se.dims,se.data,"cpu"];case"gpu-buffer":return[se.type,se.dims,{gpuBuffer:se.gpuBuffer},"gpu-buffer"];case"ml-tensor":return[se.type,se.dims,{mlTensor:se.mlTensor},"ml-tensor"];default:throw new Error(`invalid data location: ${se.location} for ${he()}`)}},lo=se=>{switch(se[3]){case"cpu":return new ge(se[0],se[2],se[1]);case"gpu-buffer":{let he=se[0];if(!na(he))throw new Error(`not supported data type: ${he} for deserializing GPU tensor`);let{gpuBuffer:we,download:Pe,dispose:je}=se[2];return ge.fromGpuBuffer(we,{dataType:he,dims:se[1],download:Pe,dispose:je})}case"ml-tensor":{let he=se[0];if(!Di(he))throw new Error(`not supported data type: ${he} for deserializing MLTensor tensor`);let{mlTensor:we,download:Pe,dispose:je}=se[2];return ge.fromMLTensor(we,{dataType:he,dims:se[1],download:Pe,dispose:je})}default:throw new Error(`invalid data location: ${se[3]}`)}},$l=class{async fetchModelAndCopyToWasmMemory(se){return so(await an(se))}async loadModel(se,he){Le();let we;typeof se=="string"?we=await this.fetchModelAndCopyToWasmMemory(se):we=se,[this.sessionId,this.inputNames,this.outputNames,this.inputMetadata,this.outputMetadata]=await Ds(we,he),Ue()}async dispose(){return Cf(this.sessionId)}async run(se,he,we){Le();let Pe=[],je=[];Object.entries(se).forEach(it=>{let Qe=it[0],$t=it[1],qe=this.inputNames.indexOf(Qe);if(qe===-1)throw new Error(`invalid input '${Qe}'`);Pe.push($t),je.push(qe)});let We=[],Ie=[];Object.entries(he).forEach(it=>{let Qe=it[0],$t=it[1],qe=this.outputNames.indexOf(Qe);if(qe===-1)throw new Error(`invalid output '${Qe}'`);We.push($t),Ie.push(qe)});let De=Pe.map((it,Qe)=>Ec(it,()=>`input "${this.inputNames[je[Qe]]}"`)),Ve=We.map((it,Qe)=>it?Ec(it,()=>`output "${this.outputNames[Ie[Qe]]}"`):null),nt=await ao(this.sessionId,je,De,Ie,Ve,we),ct={};for(let it=0;it<nt.length;it++)ct[this.outputNames[Ie[it]]]=We[it]??lo(nt[it]);return Ue(),ct}startProfiling(){}endProfiling(){oo(this.sessionId)}}}),oa={};f(oa,{OnnxruntimeWebAssemblyBackend:()=>la,initializeFlags:()=>$a,wasmBackend:()=>co});var $a,la,co,zu=u(()=>{hr(),Bu(),Tc(),$a=()=>{(typeof O.wasm.initTimeout!="number"||O.wasm.initTimeout<0)&&(O.wasm.initTimeout=0);let se=O.wasm.simd;if(typeof se!="boolean"&&se!==void 0&&se!=="fixed"&&se!=="relaxed"&&(console.warn(`Property "env.wasm.simd" is set to unknown value "${se}". Reset it to \`false\` and ignore SIMD feature checking.`),O.wasm.simd=!1),typeof O.wasm.proxy!="boolean"&&(O.wasm.proxy=!1),typeof O.wasm.trace!="boolean"&&(O.wasm.trace=!1),typeof O.wasm.numThreads!="number"||!Number.isInteger(O.wasm.numThreads)||O.wasm.numThreads<=0)if(typeof self<"u"&&!self.crossOriginIsolated)O.wasm.numThreads=1;else{let he=typeof navigator>"u"?l("node:os").cpus().length:navigator.hardwareConcurrency;O.wasm.numThreads=Math.min(4,Math.ceil((he||1)/2))}},la=class{async init(se){$a(),await gs(),await Aa(se)}async createInferenceSessionHandler(se,he){let we=new $l;return await we.loadModel(se,he),we}},co=new la}),Fu={};f(Fu,{InferenceSession:()=>Vt,TRACE:()=>Te,TRACE_EVENT_BEGIN:()=>st,TRACE_EVENT_END:()=>lt,TRACE_FUNC_BEGIN:()=>Le,TRACE_FUNC_END:()=>Ue,Tensor:()=>ge,default:()=>$c,env:()=>O,registerBackend:()=>k}),hr(),hr(),hr();var Ac="1.26.0",$c=Zn;{let se=(zu(),h(oa)).wasmBackend;k("cpu",se,10),k("wasm",se,10)}return Object.defineProperty(O.versions,"web",{value:Ac,enumerable:!0}),h(Fu)})();e.exports=n})(C1)),C1.exports}var hN;function Iq(){return hN||(hN=1,(function(e){var r=ec&&ec.__createBinding||(Object.create?(function(C,E,T,$){$===void 0&&($=T);var N=Object.getOwnPropertyDescriptor(E,T);(!N||("get"in N?!E.__esModule:N.writable||N.configurable))&&(N={enumerable:!0,get:function(){return E[T]}}),Object.defineProperty(C,$,N)}):(function(C,E,T,$){$===void 0&&($=T),C[$]=E[T]})),n=ec&&ec.__setModuleDefault||(Object.create?(function(C,E){Object.defineProperty(C,"default",{enumerable:!0,value:E})}):function(C,E){C.default=E}),i=ec&&ec.__importStar||function(C){if(C&&C.__esModule)return C;var E={};if(C!=null)for(var T in C)T!=="default"&&Object.prototype.hasOwnProperty.call(C,T)&&r(E,C,T);return n(E,C),E};Object.defineProperty(e,"__esModule",{value:!0}),e.MicVAD=e.getDefaultRealTimeVADOptions=e.ort=e.DEFAULT_MODEL=void 0;const s=i(Mq()),a=FT(),c=UT(),l=ab(),u=f_(),f=E4(),m=T4();e.DEFAULT_MODEL="legacy",e.ort=s;const h="vad.worklet.bundle.min.js",y="silero_vad_v5.onnx",x="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 E=>{E.getTracks().forEach(T=>{T.stop()})},resumeStream:async()=>await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}}),ortConfig:E=>{E.env.logLevel="error"},startOnLoad:!0,processorType:"auto"});e.getDefaultRealTimeVADOptions=k;const S=C=>"audioWorklet"in C&&typeof AudioWorkletNode=="function"?"AudioWorklet":"ScriptProcessor";async function b(C,E,T,$,N){await T.audioWorklet.addModule(C),E.processorOptions={...E.processorOptions??{},frameSamples:$};const O=new AudioWorkletNode(T,"vad-helper-worklet",E);return O.port.onmessage=async M=>{const U=M.data;if(!(typeof U=="object"&&U&&"message"in U)){console.error("Invalid message event",U);return}switch(U.message){case u.Message.AudioFrame:{if(!("data"in U&&U.data instanceof ArrayBuffer)){console.log("Audio frame message has no data");return}const H=new Float32Array(U.data);await N(H);break}}},O}async function _(C,E,T){const $=new m.Resampler({nativeSampleRate:C.sampleRate,targetSampleRate:16e3,targetFrameSize:E});l.log.debug("using script processor");const O=C.createScriptProcessor(4096,1,1);let M=!1;return O.onaudioprocess=async U=>{if(!M){M=!0;try{const H=U.inputBuffer.getChannelData(0);U.outputBuffer.getChannelData(0).fill(0);const z=$.process(H);for(const F of z)await T(F)}catch(H){console.error("Error processing audio:",H)}finally{M=!1}}},O.connect(C.destination),O}class w{constructor(E,T,$,N,O=!1,M=null,U=null,H=null,V=null,z=null,F=null,Y="uninitialized",te=!1){this.options=E,this.frameProcessor=T,this.model=$,this.frameSamples=N,this.listening=O,this.errored=M,this._stream=U,this._audioContext=H,this._vadNode=V,this._mediaStreamAudioSourceNode=z,this._audioProcessorAdapterType=F,this.initializationState=Y,this.ownsAudioContext=te,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=le=>{this.initializationState="errored",this.errored=le},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(le){throw le instanceof Error?this.setErrored(le.message):this.setErrored(String(le)),le}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 b(this.options.baseAssetPath+h,this.options.workletOptions,this._audioContext,this.frameSamples,this.processFrame);break;case"ScriptProcessor":this._vadNode=await _(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:le,audioContext:pe,vadNode:X}=this.getAudioInstances();this._stream=await this.options.resumeStream(le);const Q=new MediaStreamAudioSourceNode(pe,{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:le,mediaStreamAudioSourceNode:pe}=this.getAudioInstances();await this.options.pauseStream(le),pe.disconnect(),this.frameProcessor.pause(this.handleFrameProcessorEvent)},this.destroy=async()=>{var pe;l.log.debug("destroy called"),this.initializationState="destroyed";const{vadNode:le}=this.getAudioInstances();le instanceof AudioWorkletNode&&le.port.postMessage(u.Message.SpeechStop),this.listening&&await this.pause(),await this.model.release(),this.ownsAudioContext&&await((pe=this._audioContext)==null?void 0:pe.close())},this.setOptions=le=>{this.frameProcessor.setOptions(le)},this.processFrame=async le=>{await this.frameProcessor.process(le,this.handleFrameProcessorEvent)},this.handleFrameProcessorEvent=le=>{switch(le.msg){case u.Message.FrameProcessed:this.options.onFrameProcessed(le.probs,le.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(le.audio);break}}}static async new(E={}){const T={...(0,e.getDefaultRealTimeVADOptions)(E.model??e.DEFAULT_MODEL),...E};(0,c.validateOptions)(T),e.ort.env.wasm.wasmPaths=T.onnxWASMBasePath,T.ortConfig!==void 0&&T.ortConfig(e.ort);const $=T.model==="v5"?y:x,N=T.baseAssetPath+$,O=T.model==="v5"?f.SileroV5.new:f.SileroLegacy.new;let M;try{M=await O(e.ort,()=>(0,a.defaultModelFetcher)(N))}catch(F){throw console.error(`Encountered an error while loading model file ${N}`),F}const U=T.model==="v5"?512:1536,H=U/16,V=new c.FrameProcessor(M.process,M.reset_state,{positiveSpeechThreshold:T.positiveSpeechThreshold,negativeSpeechThreshold:T.negativeSpeechThreshold,redemptionMs:T.redemptionMs,preSpeechPadMs:T.preSpeechPadMs,minSpeechMs:T.minSpeechMs,submitUserSpeechOnPause:T.submitUserSpeechOnPause},H),z=new w(T,V,M,U);if(T.startOnLoad)try{await z.start()}catch(F){throw console.error("Error starting micVad",F),F}return z}}e.MicVAD=w})(ec)),ec}var pN;function Dq(){return pN||(pN=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=k4();Object.defineProperty(e,"baseAssetPath",{enumerable:!0,get:function(){return r.baseAssetPath}});var n=FT();Object.defineProperty(e,"defaultModelFetcher",{enumerable:!0,get:function(){return n.defaultModelFetcher}});var i=UT();Object.defineProperty(e,"FrameProcessor",{enumerable:!0,get:function(){return i.FrameProcessor}});var s=f_();Object.defineProperty(e,"Message",{enumerable:!0,get:function(){return s.Message}});var a=Pq();Object.defineProperty(e,"NonRealTimeVAD",{enumerable:!0,get:function(){return a.NonRealTimeVAD}});const c=Rq();e.utils={audioFileToArray:c.audioFileToArray,minFramesForTargetMS:c.minFramesForTargetMS,arrayBufferToBase64:c.arrayBufferToBase64,encodeWAV:c.encodeWAV};var l=Iq();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}})})(_1)),_1}var Lq=Dq();function Sx(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 mt={debug:(e,r,n)=>Sx(e,"debug",r,n),info:(e,r,n)=>Sx(e,"info",r,n),warn:(e,r,n)=>Sx(e,"warn",r,n),error:(e,r,n)=>Sx(e,"error",r,n)},$4=16e3,Bq=6,ip=$4*Bq,zq=400,Fq=$4*zq/1e3,mN=300,gN=2e3,vN=1500,yN=3e3,Uq=600,N4=.5,O4=.35,bN=.85,xN=.7;let Ys=null,gl=!1,Ts=!1;const _j=new Set;function kx(e){for(const r of Array.from(_j))try{r(e)}catch(n){mt.warn("speech","workerDeath listener threw",{error:n instanceof Error?n.message:String(n)})}}let j1=0;const wN=2;let Cp=!1,P4=!1;function R4(e){e.addEventListener("message",r=>{var i;if(((i=r.data)==null?void 0:i.type)!=="log")return;const n=r.data.level||"info";mt[n]("whisperWorker",r.data.message??"",r.data.meta)}),e.addEventListener("error",r=>{mt.error("whisperWorker","worker error event (fatal)",{message:r.message,filename:r.filename,lineno:r.lineno}),qq(`error:${r.message||"unknown"}`)})}function Dw(){return Ys||(Ys=new Worker(new URL(""+new URL("whisperWorker-Dbia1OpC.js",import.meta.url).href,import.meta.url),{type:"module"}),R4(Ys),mt.info("speech","worker spawned"),Ys)}let Cx=!1;function qq(e){if(!Cp){if(Cx){mt.warn("speech","respawnWorker: already in flight, ignoring",{reason:e});return}if(Cx=!0,j1+=1,P4=!0,mt.warn("speech","respawnWorker: starting",{reason:e,attempt:j1}),kx({reason:e,respawned:!1,finalOnly:!0}),j1>wN){if(Cp=!0,mt.error("speech","respawnWorker: limit exceeded, disabling speech",{limit:wN}),Ys)try{Ys.terminate()}catch{}Ys=null,gl=!1,Ts=!1,kx({reason:"respawn-limit-exceeded",respawned:!1,finalOnly:!0}),Cx=!1;return}if(Ys)try{Ys.terminate()}catch{}Ys=null,gl=!1,Ts=!1;try{Ys=new Worker(new URL(""+new URL("whisperWorker-Dbia1OpC.js",import.meta.url).href,import.meta.url),{type:"module"}),R4(Ys),Ts=!0,Ys.postMessage({type:"load"}),mt.info("speech","respawnWorker: new worker spawned, load posted"),kx({reason:e,respawned:!0,finalOnly:!0})}catch(r){Cp=!0,mt.error("speech","respawnWorker: spawn failed, disabling speech",{error:r instanceof Error?r.message:String(r)}),kx({reason:"spawn-failed",respawned:!1,finalOnly:!0})}finally{Cx=!1}}}function Wq(e,r){if(gl||Ts)return;Ts=!0;const n=Dw();mt.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"&&(gl=!0,Ts=!1,mt.info("speech","preloadModel: ready"),n.removeEventListener("message",i))):s.data.type==="progress"?r==null||r(s.data.pct):s.data.type==="error"&&(Ts=!1,mt.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 Hq(){mt.info("speech","resetModel: clearing load flags"),gl=!1,Ts=!1}function qT(){var e;return typeof Worker<"u"&&!!((e=navigator.mediaDevices)!=null&&e.getUserMedia)&&typeof AudioWorkletNode<"u"}function Vq(e){const r=Dw();return!gl&&!Ts&&(Ts=!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"&&(gl=!0,Ts=!1)};r.addEventListener("message",s),r.postMessage({type:"transcribe",audio:e},[e.buffer])})}function Gq(e){let r=Dw(),n=!1,i=null,s=null,a=null,c=null,l=null;const u=[],f=new Set;let m=null,h=0,y=!1,x=0,k=!1,S=!1,b=0,_=0,w=0,C=-1,E=mN,T=0,$=null,N="",O="",M=!1,U=0;function H(ae,me){const _e=Math.min(ae.length,me.length);let Ne=0;for(;Ne<_e&&ae.charCodeAt(Ne)===me.charCodeAt(Ne);)Ne++;return Ne}function V(ae){const me=H(N,ae);return N=ae,me>O.length&&(O=ae.slice(0,me)),O.length>ae.length&&(O=ae),O}const z=()=>(m||(m=new Float32Array(ip)),m),F=()=>{h=0},Y=ae=>{const me=z(),_e=ae.length;if(_e>=ip){me.set(ae.subarray(_e-ip)),h=ip;return}if(h+_e<=ip){me.set(ae,h),h+=_e;return}const Ne=h+_e-ip;me.copyWithin(0,Ne,h),h-=Ne,me.set(ae,h),h+=_e},te=()=>{$&&(clearTimeout($),$=null)},le=()=>{te(),y=!1,k=!1,S=!1,E=mN,N="",O="",M=!1,U=0,F()},pe=()=>{if(n||!y||S||k||$)return;if(h<Fq){$=setTimeout(()=>{$=null,pe()},E);return}const ae=performance.now()-b;if(ae<E&&b!==0){$=setTimeout(()=>{$=null,pe()},E-ae);return}if(P4||Cp||e.partialsEnabled&&!e.partialsEnabled())return;const me=z(),_e=new Float32Array(h);_e.set(me.subarray(0,h)),_+=1,w=_,k=!0,T=performance.now(),b=T,r.postMessage({type:"transcribe-partial",audio:_e,seq:_},[_e.buffer])},X=ae=>ae.length===0?Promise.resolve():Cp?(mt.warn("speech","transcribeAudio: speech disabled (worker respawn limit hit)"),n||e.onError("Speech recognition disabled — please reload the app."),Promise.resolve()):new Promise(me=>{u.push(me),_+=1;const _e=_;C=_e,r.postMessage({type:"transcribe",audio:ae,seq:_e},[ae.buffer])}),Q=ae=>{const me=X(ae);return f.add(me),me.finally(()=>{f.delete(me)}),me},J=ae=>{var me,_e,Ne,xe,ie;if(ae.data.type==="result"){const ce=ae.data.text,ge=ae.data.seq??0;ge&&ge<C&&mt.warn("speech","result: seq below latestFinalSeq (delivering anyway)",{seq:ge,latestFinalSeq:C}),!n&&ce&&e.onFinal(ce),(me=u.shift())==null||me()}else if(ae.data.type==="partial"){const ce=ae.data.seq??0,ge=ae.data.text??"",Ae=performance.now()-T;k=!1,Ae>=yN?(S=!0,mt.warn("speech","partials.disabled.budget",{elapsedMs:Math.round(Ae),seq:ce})):Ae>=vN&&(E=Math.min(E*2,gN),mt.warn("speech","partials.slowdown",{elapsedMs:Math.round(Ae),newIntervalMs:E,seq:ce})),M||(M=!0,Ae>Uq&&E<500&&(E=500,mt.info("speech","partials.probe.slow_host",{elapsedMs:Math.round(Ae),newIntervalMs:500})));const Te=ce!==w||ce<=C;if(!n&&!Te&&ge){const Me=V(ge);Me&&((_e=e.onPartial)==null||_e.call(e,Me),U===0&&(U=performance.now(),mt.info("speech","partial.first",{msSinceSpeechStart:Math.round(U-x)})))}pe()}else if(ae.data.type==="partial-error"){const ce=performance.now()-T;k=!1,ce>=yN?(S=!0,mt.warn("speech","partials.disabled.budget (after error)",{elapsedMs:Math.round(ce),seq:ae.data.seq})):ce>=vN&&(E=Math.min(E*2,gN),mt.warn("speech","partials.slowdown (after error)",{elapsedMs:Math.round(ce),newIntervalMs:E,seq:ae.data.seq})),mt.warn("speech","partial encode failed",{error:ae.data.error,seq:ae.data.seq}),pe()}else ae.data.type==="error"?(n||e.onError(ae.data.error),(Ne=u.shift())==null||Ne()):ae.data.type==="status"?(n||(xe=e.onModelStatus)==null||xe.call(e,ae.data.status,ae.data.message),ae.data.status==="ready"&&(gl=!0,Ts=!1)):ae.data.type==="progress"&&(n||(ie=e.onProgress)==null||ie.call(e,ae.data.pct))};r.addEventListener("message",J);const ee=ae=>{var me,_e;if(!n){for(mt.warn("speech","createRecognition: worker death event",ae),(me=e.onStatusChange)==null||me.call(e,"restarting");u.length;)(_e=u.shift())==null||_e();if(f.clear(),te(),k=!1,ae.respawned){try{r.removeEventListener("message",J)}catch{}r=Dw(),r.addEventListener("message",J)}}};return _j.add(ee),{start:async()=>{if(!n){if(Cp){e.onError("Speech recognition disabled — please reload the app.");return}!gl&&!Ts&&(Ts=!0,mt.info("speech","createRecognition.start: triggering model load"),r.postMessage({type:"load"})),mt.info("speech","createRecognition.start: initializing VAD",{modelReady:gl,modelLoading:Ts});try{const ae=new URL("vad/",document.baseURI).href,me=e.inputDeviceId||null,_e={channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0};me&&(_e.deviceId={exact:me}),mt.info("speech","getUserMedia",{hasDeviceId:!!me,deviceIdPrefix:me?me.slice(0,8):null});const Ne=await navigator.mediaDevices.getUserMedia({audio:_e});s=Ne,a=new AudioContext;for(const xe of Ne.getAudioTracks())xe.addEventListener("ended",()=>{n||(mt.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(xe){mt.warn("speech","analyser init failed",{error:xe instanceof Error?xe.message:String(xe)}),l=null,c=null}i=await Lq.MicVAD.new({audioContext:a,getStream:async()=>Ne,resumeStream:async()=>Ne,pauseStream:async()=>{},baseAssetPath:ae,onnxWASMBasePath:ae,model:"v5",positiveSpeechThreshold:N4,negativeSpeechThreshold:O4,minSpeechMs:300,redemptionMs:1500,preSpeechPadMs:300,submitUserSpeechOnPause:!0,onFrameProcessed:(xe,ie)=>{var ce;n||((ce=e.onFrame)==null||ce.call(e,xe),y&&(Y(ie),pe()))},onSpeechStart:()=>{var xe;n||(le(),y=!0,x=performance.now(),(xe=e.onSpeechStart)==null||xe.call(e))},onSpeechEnd:xe=>{var ie;n||((ie=e.onStatusChange)==null||ie.call(e,"transcribing"),le(),Q(xe))},onVADMisfire:()=>{var xe,ie;n||((xe=e.onStatusChange)==null||xe.call(e,"idle"),le(),(ie=e.onMisfire)==null||ie.call(e))}}),i.start()}catch(ae){const me=ae instanceof Error?ae.message:"Microphone access denied",_e=ae instanceof Error?ae.stack:"";if(mt.error("speech","createRecognition.start: VAD init failed",{error:me,stack:_e}),c){try{c.disconnect()}catch{}c=null}if(l){try{l.disconnect()}catch{}l=null}if(s){try{s.getTracks().forEach(Ne=>Ne.stop())}catch{}s=null}if(a){try{await a.close()}catch{}a=null}e.onError(me)}}},stop:async()=>{if(i)try{await i.pause()}catch{}for(le();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(ae=>ae.stop())}catch{}s=null}if(a){try{await a.close()}catch{}a=null}},setVadThresholds:(ae,me)=>{if(i)try{i.setOptions({positiveSpeechThreshold:ae,negativeSpeechThreshold:me})}catch(_e){mt.warn("speech","setVadThresholds failed",{error:_e instanceof Error?_e.message:String(_e)})}},getAnalyser:()=>c,destroy:()=>{if(n=!0,le(),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(ae=>ae.stop())}catch{}s=null}_j.delete(ee),r.removeEventListener("message",J)}}}let ny=null;const Sj=new Set,kj=new Set;function Kq(){for(const e of Sj)try{e()}catch{}}function Cj(){for(const e of kj)try{e()}catch{}}function Xq(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 Yq(e){if(!window.speechSynthesis)return;const r=Xq(e);if(!r)return;const n=new SpeechSynthesisUtterance(r);n.rate=1,n.pitch=1,n.onstart=()=>{ny=performance.now(),Kq()},n.onend=()=>{!window.speechSynthesis.speaking&&!window.speechSynthesis.pending&&(ny=null,Cj())},n.onerror=i=>{i.error!=="canceled"&&!window.speechSynthesis.speaking&&!window.speechSynthesis.pending&&(ny=null,Cj())},window.speechSynthesis.speak(n)}function M4(){window.speechSynthesis&&(window.speechSynthesis.cancel(),ny=null,Cj())}function I4(){var e;return((e=window.speechSynthesis)==null?void 0:e.speaking)??!1}function Jq(){return ny}function Zq(e){return Sj.add(e),()=>{Sj.delete(e)}}function Qq(e){return kj.add(e),()=>{kj.delete(e)}}function eW(e){I4()&&(e.setVadThresholds(bN,xN),mt.info("voice","tts.duck.on",{reason:"already-speaking-on-attach"}));const r=Zq(()=>{e.setVadThresholds(bN,xN),mt.info("voice","tts.duck.on")}),n=Qq(()=>{e.setVadThresholds(N4,O4),mt.info("voice","tts.duck.off")});return()=>{r(),n()}}const tW=[{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 rW(e){const r=e.trim();return tW.find(n=>n.match.test(r))??null}const nW=4e4;let Vd=null;function jp(){Vd&&clearTimeout(Vd),Vd=setTimeout(()=>{Vd=null,Mt.getState().stopRecording()},nW)}function jx(){Vd&&(clearTimeout(Vd),Vd=null)}let Su=null,xu=null;const iW=.04,sW=.3;let Lw=0,jj=0;function aW(e){xu!==null&&cancelAnimationFrame(xu);const r=()=>{if(Su===null||Mt.getState().submitCountdownStartAt===null){xu=null;return}const n=performance.now();if(n-jj<200&&Lw>sW){const s=n-e;mt.info("voice","submit.preempted_by_voice",{reason:"vad",prob:Lw.toFixed(2),msIntoCountdown:Math.round(s)}),mu(),jp();return}const i=D4();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>iW){const l=n-e;mt.info("voice","submit.preempted_by_voice",{reason:"rms",rms:c.toFixed(3),msIntoCountdown:Math.round(l)}),mu(),jp();return}}xu=requestAnimationFrame(r)};xu=requestAnimationFrame(r)}function oW(e){Su&&clearTimeout(Su);const r=Mt.getState().submitDelayMs,n=performance.now();Mt.setState({submitCountdownStartAt:n}),Su=setTimeout(()=>{Su=null,Mt.setState({submitCountdownStartAt:null});try{window.api.pty.write({tabId:e,data:"\r"})}catch(i){mt.warn("voice","submit pty.write failed",{error:i instanceof Error?i.message:String(i)})}jp()},r),aW(n)}function mu(){xu!==null&&(cancelAnimationFrame(xu),xu=null),Su&&(clearTimeout(Su),Su=null),Mt.getState().submitCountdownStartAt!==null&&Mt.setState({submitCountdownStartAt:null})}let Ai=null,ls=null;function D4(){var e;return((e=Ai==null?void 0:Ai.getAnalyser)==null?void 0:e.call(Ai))??null}const Ex=1e4;let iy=null;function Tx(){iy&&(clearTimeout(iy),iy=null)}let _w=null,Sw=null;function Ax(){_w=null,Sw&&(Sw(),Sw=null)}const lW=1500,cW=9e4;let $x=0,kw=null,Ej=-1;function Nx(){kw&&(clearTimeout(kw),kw=null,Ej=-1)}const uW=new Set(["you","You","Thank you.","Thanks for watching.","Thanks for watching!","Thank you for watching.","Thank you for watching!",".","Bye.","Bye!"]),Mt=En((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;mt.info("voice","initModel: kicking off preload"),e({modelStatus:"loading",error:null,errorKind:null,loadingProgress:0});const n=++$x,i=()=>{n===$x&&(Nx(),Ej=n,kw=setTimeout(()=>{Ej===n&&r().modelStatus==="loading"&&(mt.warn("voice","mic.gate.timeout: no progress within 90s"),e({modelStatus:"error",error:"Model load timed out",errorKind:"timeout"}))},cW))};i(),Wq((s,a)=>{n===$x&&(s==="ready"?(Nx(),mt.info("voice","modelStatus -> ready"),e({modelStatus:"ready",loadingProgress:100,errorKind:null})):s==="error"?(Nx(),mt.error("voice","modelStatus -> error",{msg:a}),e({modelStatus:"error",error:a,errorKind:"load"})):(i(),e({modelStatus:"loading"})))},s=>{n===$x&&(i(),e({loadingProgress:Math.round(s)}))})},resetAndRetryModel:()=>{mt.info("voice","mic.gate.retry"),Nx(),Hq(),e({modelStatus:"idle",error:null,errorKind:null,loadingProgress:0}),r().initModel()},startRecording:n=>{if(r().isRecording)return;if(Ai){mt.warn("voice","startRecording: prior handle still draining, ignoring");return}if(!qT()){e({error:"Microphone or Web Worker not available",errorKind:"recording"});return}const i=s=>{try{const a=Gq({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=>{Lw=c.isSpeech,jj=performance.now()},onSpeechStart:()=>{if(e({statusPill:"listening",lastPartial:""}),jx(),mu(),I4()){const l=Jq(),u=l!==null?performance.now()-l:null;M4(),e({lastBargeInAt:performance.now()}),mt.info("voice","barge-in",{tabId:n,utteranceOffsetMs:u})}else mt.debug("voice","barge-in.no-op",{tabId:n})},onMisfire:()=>{e({lastPartial:"",statusPill:"idle"}),jp();const c=r().lastBargeInAt;c!==null&&performance.now()-c<600&&mt.warn("voice","barge-in.misfire",{tabId:n,sinceBargeInMs:Math.round(performance.now()-c)})},onFinal:c=>{jp();const l=c.trim();if(!l||uW.has(l)){e({lastTranscript:"",lastPartial:"",statusPill:"idle"});return}const u=rW(l);if(u){mt.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&&oW(n);const f=window;f.__transcripts&&(f.__transcripts.push({tabId:n,text:l}),f.__transcripts.length>500&&f.__transcripts.shift())},onError:c=>{mt.error("voice","recognition error",{err:c}),mu(),e({error:c,errorKind:"recording",isRecording:!1,lastPartial:"",statusPill:"idle"}),ls==null||ls(),ls=null,jx(),Ai==null||Ai.destroy(),Ai=null,rt.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)})});Ai=a,e({isRecording:!0,error:null,lastTranscript:"",lastPartial:"",statusPill:"listening"}),jp(),a.start().then(()=>{Ai===a&&(ls==null||ls(),ls=eW(a))}).catch(c=>{const l=c instanceof Error?c.message:String(c);mt.error("voice","handle.start() failed",{error:l}),rt.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=>{mt.warn("voice","getDevicePref failed; using default device",{error:s instanceof Error?s.message:String(s)}),i(null)})},stopRecording:()=>{const n=Ai;n&&(jx(),mu(),Lw=0,jj=0,ls==null||ls(),ls=null,e({isRecording:!1,lastTranscript:"",lastPartial:"",statusPill:"idle"}),n.stop().finally(()=>{n.destroy(),Ai===n&&(Ai=null),r().hotkeyState==="stopping"&&(Tx(),e({hotkeyState:"idle"}))}))},restartWithDevice:async()=>{if(!r().isRecording)return;const n=Ai;if(!n)return;jx(),ls==null||ls(),ls=null,e({isRecording:!1,lastTranscript:"",lastPartial:""});try{await n.stop()}catch(a){mt.warn("voice","restartWithDevice: drain rejected",{error:a instanceof Error?a.message:String(a)})}n.destroy(),Ai===n&&(Ai=null);const{useSessions:i}=await sb(async()=>{const{useSessions:a}=await Promise.resolve().then(()=>vq);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&&(mt.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"?mt.warn("voice-turn","voice-turn.load_failed"):n==="runtime_error"?mt.warn("voice-turn","voice-turn.runtime_error"):n==="disabled"&&mt.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}=Tj(c);if(n==="down"){if(u==="error"||u==="load-timeout"){c.resetAndRetryModel(),mt.info("voice-hotkey","down.retry",{source:i,reason:u});return}if(!l&&u!=="loading"){mt.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"}),Tx(),iy=setTimeout(()=>{r().hotkeyState==="stopping"&&(mt.warn("voice-hotkey","drain-timeout",{durationMs:Ex}),e({hotkeyState:"aborted"}),setTimeout(()=>{r().hotkeyState==="aborted"&&e({hotkeyState:"idle"})},0))},Ex),c.stopRecording());return}if(u==="loading"){c.hotkeyState!=="armed"&&(e({hotkeyState:"armed"}),mt.info("voice-hotkey","armed",{source:i,modelStatus:c.modelStatus})),Ax(),_w={tabId:a,source:i,mode:s},Sw=Mt.subscribe((f,m)=>{if(_w&&f.modelStatus==="ready"&&m.modelStatus!=="ready"&&f.hotkeyState==="armed"){const h=_w;if(Ax(),!h.tabId){mt.warn("voice-hotkey","armed-promote-no-tab",{source:h.source}),e({hotkeyState:"idle"});return}mt.info("voice-hotkey","armed-promote",h),e({hotkeyState:"recording"}),Mt.getState().startRecording(h.tabId)}});return}if(!a){mt.warn("voice-hotkey","no-active-tab",{source:i});return}mt.info("voice-hotkey","start",{source:i,mode:s,tabId:a}),c.startRecording(a),r().isRecording?e({hotkeyState:"recording"}):(mt.warn("voice-hotkey","start: recording did not engage",{errorKind:r().errorKind}),e({hotkeyState:"idle"}));return}if(!(s!=="hold"||i==="global")){if(c.hotkeyState==="armed"){Ax(),mt.info("voice-hotkey","miss-model-loading-armed-up"),e({hotkeyState:"idle"});return}c.hotkeyState==="recording"&&(e({hotkeyState:"stopping"}),Tx(),iy=setTimeout(()=>{r().hotkeyState==="stopping"&&(mt.warn("voice-hotkey","drain-timeout",{durationMs:Ex}),e({hotkeyState:"aborted"}),setTimeout(()=>{r().hotkeyState==="aborted"&&e({hotkeyState:"idle"})},0))},Ex),c.stopRecording())}},destroyHotkey:()=>{const n=r();if(Ax(),mu(),n.hotkeyState==="recording"){mt.warn("voice-hotkey","destroyed-mid-recording"),e({hotkeyState:"destroyed"});try{n.stopRecording()}catch{}}else(n.hotkeyState==="armed"||n.hotkeyState==="stopping")&&(Tx(),e({hotkeyState:"destroyed"}))}})),dW=e=>({isRecording:e.isRecording,statusPill:e.statusPill,lastPartial:e.lastPartial,lastTranscript:e.lastTranscript,submitCountdownStartAt:e.submitCountdownStartAt}),Tj=e=>qT()?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=Mt,e.__transcripts=[]}function WT(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 fW=5e3,$u=En(()=>({snapshot:null,loaded:!1}));let _N=!1,SN=!1,uv;async function hW(){var e;if(!_N){_N=!0;try{const r=await WT(window.api.schedule.state(),fW,"schedule.state");$u.setState({snapshot:r,loaded:!0}),uv=((e=r.paused)==null?void 0:e.reason)??null}catch(r){if(!SN){SN=!0;const n=r instanceof Error?r.message:String(r);rt.error(`Scheduler state hydrate failed: ${n}`)}uv=null}window.api.schedule.onState(r=>{var i;const n=((i=r.paused)==null?void 0:i.reason)??null;uv!==void 0&&n!==uv&&(n==="auth"?rt.error("Scheduler paused: Claude sign-in expired or invalid. Restart the app or re-run `claude login`, then Resume."):n==="network"&&rt.error("Scheduler paused: billing endpoint unreachable. Will auto-resume in 30 minutes.")),uv=n,$u.setState({snapshot:r,loaded:!0})})}}const pW=6e4,mW=5e3,Ep=En(()=>({data:null,refreshing:!1}));let kN=!1,Cw=null,CN=null,jN=!1;async function HT(){Ep.setState({refreshing:!0});let e=pW;try{const r=await WT(window.api.billing.fetch(),mW,"billing.fetch");Ep.setState({data:r,refreshing:!1}),r.kind==="transient"?e=CN==="transient"?3e4:5e3:r.kind==="auth"&&(e=3e4),CN=r.kind}catch(r){if(Ep.setState({refreshing:!1}),!jN){jN=!0;const n=r instanceof Error?r.message:String(r);rt.warn(`Billing usage fetch failed: ${n}`)}}Cw=setTimeout(HT,e)}function gW(){kN||(kN=!0,HT())}function h_(e){return e?e.kind==="ok"||e.kind==="ok-stale"?e.data:e.kind==="auth"&&e.cached?e.cached:null:null}function Bw(){Cw!==null&&(clearTimeout(Cw),Cw=null),HT()}function dr({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 vW(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 EN=e=>Symbol.iterator in e,TN=e=>"entries"in e,AN=(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},yW=(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 bW(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:EN(e)&&EN(r)?TN(e)&&TN(r)?AN(e,r):yW(e,r):AN({entries:()=>Object.entries(e)},{entries:()=>Object.entries(r)})}function L4(e){const r=He.useRef(void 0);return n=>{const i=e(n);return bW(r.current,i)?r.current:r.current=i}}let $N=0;const xW=1e3;function wW(e){const r=performance.now();r-$N<xW||($N=r,mt.debug("voice","mic.gate.click_rejected",{reason:e}))}function B4(){const e=Mt(f=>f.isRecording),r=Mt(f=>f.error),n=Mt(f=>f.loadingProgress),i=Mt(L4(Tj)),s=()=>{const f=Mt.getState(),{canRecord:m,reason:h}=Tj(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 wW(h);const y=Nt.getState().activeTabId;y&&f.startRecording(y)},a=vW(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 _W(){const e=Mt(n=>n.ttsEnabled),r=Mt(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"})]})}const NN=[{key:"overview",label:"Home",icon:"home",hint:"Today's sessions + the 5-hour window"},{key:"terminal",label:"Terminal",icon:"terminal",hint:"Live Claude Code, in-app"},{key:"browser",label:"Browser",icon:"browser",hint:"Embedded dev browser — capture DOM, record click-sequences"},{key:"projects",label:"File Explorer",icon:"projects",hint:"Browse files + edit, per project"},{key:"subagents",label:"Subagents",icon:"hive",liveKind:"subagents",hint:"Fan out work: Hive · Orchestrate · Race · Boss"},{key:"scheduler",label:"Scheduler",icon:"scheduler",liveKind:"scheduler",hint:"Author PRDs + run them as claude -p jobs"},{key:"history",label:"History",icon:"history",hint:"Every session, ever — resumable"},{key:"usage",label:"Usage",icon:"usage",hint:"Tokens, cost, sessions per day"}],ON=[{key:"skills",label:"Skills",icon:"skills",hint:"Reusable instructions Claude loads"},{key:"plugins",label:"Plugins",icon:"plugins",hint:"Extensions for Claude Code"},{key:"mcp",label:"MCP Servers",icon:"mcp",hint:"External tools and integrations"},{key:"hooks",label:"Hooks",icon:"hooks",hint:"Run scripts on session events"},{key:"keybindings",label:"Keybindings",icon:"keys",hint:"Shortcuts you can override"},{key:"memory",label:"Memory",icon:"memory",hint:"Workspace memory store"},{key:"system-prompt",label:"System Prompt",icon:"system-prompt",hint:"Personality and behavior"},{key:"permissions",label:"Permissions",icon:"permissions",hint:"Allow / deny rules"},{key:"settings",label:"Settings",icon:"settings",hint:"Theme, voice, billing window"},{key:"remote",label:"Remote",icon:"remote",hint:"Web remote control — disabled by default"}],PN=[{key:"voice",label:"Voice",icon:"mic",hint:"Whisper transcription + push-to-talk"},{key:"repoviz",label:"Repo Viz",icon:"repoviz",hint:"Language + directory map"},{key:"search",label:"Search",icon:"global-search",hint:"⌘P file · ⌘⇧F content"}],Aj="sm.almanac.sidebarWidth",z4=180,F4=480,$j=252;function SW(){try{const e=parseInt(localStorage.getItem(Aj)??"",10);if(Number.isFinite(e))return Math.min(F4,Math.max(z4,e))}catch{}return $j}const kW=52,U4="sm.almanac.sidebarCollapsed";function CW(){try{return localStorage.getItem(U4)==="1"}catch{}return!1}const q4="sm.almanac.collapsedGroups";function jW(){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 EW(){const e=xw(a=>a.tabs),r=$u(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 TW({active:e,onNavigate:r,onNewSession:n}){const[i,s]=D.useState(()=>jW()),a=D.useCallback(w=>{s(C=>{const E=new Set(C);E.has(w)?E.delete(w):E.add(w);try{localStorage.setItem(q4,JSON.stringify(Array.from(E)))}catch{}return E})},[]),[c,l]=D.useState(()=>CW()),u=D.useCallback(()=>{l(w=>{const C=!w;try{localStorage.setItem(U4,C?"1":"0")}catch{}return C})},[]),f=Nt(w=>w.tabs),m=Nt(w=>w.activeTabId),h=f.find(w=>w.id===m)??null,y=EW(),[x,k]=D.useState(()=>SW()),S=D.useRef(x);S.current=x;const b=D.useCallback(w=>{w.preventDefault();const C=w.clientX,E=S.current;let T=E;const $=O=>{T=Math.min(F4,Math.max(z4,E+(O.clientX-C))),k(T)},N=()=>{window.removeEventListener("pointermove",$),window.removeEventListener("pointerup",N),document.body.style.cursor="",document.body.style.userSelect="";try{localStorage.setItem(Aj,String(T))}catch{}};window.addEventListener("pointermove",$),window.addEventListener("pointerup",N),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]),_=D.useCallback(()=>{k($j);try{localStorage.setItem(Aj,String($j))}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?kW:x},"data-testid":"tour-leftnav","aria-label":"Primary navigation",children:[o.jsx(AW,{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(E1,{label:"Workspace",collapsed:i.has("Workspace"),count:NN.length,onToggle:()=>a("Workspace")}),(c||!i.has("Workspace"))&&NN.map(w=>o.jsx(RN,{item:w,active:e===w.key,live:w.liveKind?y[w.liveKind]:!1,onClick:()=>r(w.key),rail:c},w.key)),!c&&o.jsx(E1,{label:"Configure",collapsed:i.has("Configure"),count:ON.length,onToggle:()=>a("Configure")}),(c||!i.has("Configure"))&&ON.map(w=>o.jsx(RN,{item:w,active:e===w.key,live:!1,onClick:()=>r(w.key),rail:c},w.key)),!c&&o.jsx(E1,{label:"Tools",collapsed:i.has("Tools"),count:PN.length,onToggle:()=>a("Tools")}),(c||!i.has("Tools"))&&PN.map(w=>o.jsx(OW,{tool:w,active:e===w.key,onClick:()=>r(w.key),rail:c},w.key))]})}),o.jsx(PW,{rail:c}),!c&&o.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar",title:"Drag to resize · double-click to reset",onPointerDown:b,onDoubleClick:_,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 AW({tab:e,onNewSession:r,rail:n,onToggleRail:i}){const s=(e==null?void 0:e.label)??"no session",a=NW((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(dr,{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(dr,{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(dr,{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(dr,{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(B4,{})})]})]})}const Ox=new Map,$W=3e4;function NW(e){const[r,n]=D.useState(()=>{var i;return e?((i=Ox.get(e))==null?void 0:i.value)??null:null});return D.useEffect(()=>{if(!e){n(null);return}let i=!1;return(async()=>{const a=Ox.get(e);if(a&&Date.now()-a.ts<$W){i||n(a.value);return}try{const c=await window.api.app.gitBranch(e);if(i)return;Ox.set(e,{value:c,ts:Date.now()}),n(c)}catch{if(i)return;Ox.set(e,{value:null,ts:Date.now()}),n(null)}})(),()=>{i=!0}},[e]),r}function E1({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 RN({item:e,active:r,live:n,onClick:i,rail:s}){return o.jsxs("button",{onClick:i,title:e.hint,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(dr,{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 OW({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(dr,{name:e.icon,size:15,stroke:1.6})}),!i&&o.jsx("span",{className:"flex-1 truncate",children:e.label})]})}function PW({rail:e}){const r=Mt(l=>l.isRecording),n=Nt(l=>l.tabs),i=Nt(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 g4(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 · ${RW(a)}`:"Claude Code"})]})}function RW(e){var n,i,s,a,c,l;const r=e.toLowerCase();if(r.includes("opus")){const u=(i=(n=e.match(/(\d+[-.]?\d*)/))==null?void 0:n[1])==null?void 0:i.replace("-",".");return u?`Opus ${u}`:"Opus"}if(r.includes("sonnet")){const u=(a=(s=e.match(/(\d+[-.]?\d*)/))==null?void 0:s[1])==null?void 0:a.replace("-",".");return u?`Sonnet ${u}`:"Sonnet"}if(r.includes("haiku")){const u=(l=(c=e.match(/(\d+[-.]?\d*)/))==null?void 0:c[1])==null?void 0:l.replace("-",".");return u?`Haiku ${u}`:"Haiku"}return e}function MW({onNavigate:e}){const r=Nt(E=>E.tabs),n=Nt(E=>E.activeTabId),i=r.find(E=>E.id===n)??null,s=S4(i),a=(s==null?void 0:s.lastEventAt)??0,c=Ep(E=>E.data),l=$u(E=>{var T;return((T=E.snapshot)==null?void 0:T.paused)??null}),[u,f]=D.useState(null),[,m]=D.useState(0);D.useEffect(()=>{const E=setInterval(()=>m(T=>T+1),6e4);return()=>clearInterval(E)},[]),D.useEffect(()=>{let E=!1;if(!(i!=null&&i.cwd)){f(null);return}return window.api.app.gitBranch(i.cwd).then(T=>{E||f(T)}).catch(()=>{E||f(null)}),()=>{E=!0}},[i==null?void 0:i.cwd]);const h=(s==null?void 0:s.todos)??[],[y,x]=D.useState(!1),k=D.useRef(null);D.useEffect(()=>{if(!y)return;const E=T=>{k.current&&!k.current.contains(T.target)&&x(!1)};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[y]),D.useEffect(()=>{h.length===0&&x(!1)},[h.length]);const S=h_(c),b=(S==null?void 0:S.usage.five_hour)??null,_=b?Math.round(b.utilization):null,w=(c==null?void 0:c.kind)==="ok"||(c==null?void 0:c.kind)==="ok-stale",C=a>0?LW(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:w?"Connected to Anthropic":"Disconnected",children:[o.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${w?"bg-sage":"bg-fg-faint"}`}),o.jsx("span",{children:w?"connected":"offline"})]}),o.jsx("button",{onClick:()=>e==null?void 0:e("usage"),className:"hover:text-fg transition-colors",title:"Open Usage",children:_!=null?`${_}% 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:C})]}),h.length>0&&o.jsx(IW,{ref:k,todos:h,open:y,onToggle:()=>x(E=>!E)}),o.jsx("span",{className:"flex-1"}),o.jsxs("span",{className:"text-fg-faint",children:["v","0.35.10"]})]})}const IW=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(DW,{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 DW({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 LW(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 T1={exports:{}},MN;function BW(){return MN||(MN=1,(function(e,r){(function(n,i){e.exports=i()})(globalThis,(()=>(()=>{var n={4567:function(c,l,u){var f=this&&this.__decorate||function(w,C,E,T){var $,N=arguments.length,O=N<3?C:T===null?T=Object.getOwnPropertyDescriptor(C,E):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")O=Reflect.decorate(w,C,E,T);else for(var M=w.length-1;M>=0;M--)($=w[M])&&(O=(N<3?$(O):N>3?$(C,E,O):$(C,E))||O);return N>3&&O&&Object.defineProperty(C,E,O),O},m=this&&this.__param||function(w,C){return function(E,T){C(E,T,w)}};Object.defineProperty(l,"__esModule",{value:!0}),l.AccessibilityManager=void 0;const h=u(9042),y=u(9924),x=u(844),k=u(4725),S=u(2585),b=u(3656);let _=l.AccessibilityManager=class extends x.Disposable{constructor(w,C,E,T){super(),this._terminal=w,this._coreBrowserService=E,this._renderService=T,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let $=0;$<this._terminal.rows;$++)this._rowElements[$]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[$]);if(this._topBoundaryFocusListener=$=>this._handleBoundaryFocus($,0),this._bottomBoundaryFocusListener=$=>this._handleBoundaryFocus($,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new y.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize(($=>this._handleResize($.rows)))),this.register(this._terminal.onRender(($=>this._refreshRows($.start,$.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar(($=>this._handleChar($)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
2895
+ */var fN;function Mq(){return fN||(fN=1,(function(e,r){var n=(()=>{var i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,l=(se=>typeof Ga<"u"?Ga:typeof Proxy<"u"?new Proxy(se,{get:(he,we)=>(typeof Ga<"u"?Ga:he)[we]}):se)(function(se){if(typeof Ga<"u")return Ga.apply(this,arguments);throw Error('Dynamic require of "'+se+'" is not supported')}),u=(se,he)=>()=>(se&&(he=se(se=0)),he),f=(se,he)=>{for(var we in he)i(se,we,{get:he[we],enumerable:!0})},m=(se,he,we,Pe)=>{if(he&&typeof he=="object"||typeof he=="function")for(let je of a(he))!c.call(se,je)&&je!==we&&i(se,je,{get:()=>he[je],enumerable:!(Pe=s(he,je))||Pe.enumerable});return se},h=se=>m(i({},"__esModule",{value:!0}),se),y,x,k,S,b,_=u(()=>{y=new Map,x=[],k=(se,he,we)=>{if(he&&typeof he.init=="function"&&typeof he.createInferenceSessionHandler=="function"){let Pe=y.get(se);if(Pe===void 0)y.set(se,{backend:he,priority:we});else{if(Pe.priority>we)return;if(Pe.priority===we&&Pe.backend!==he)throw new Error(`cannot register backend "${se}" using priority ${we}`)}if(we>=0){let je=x.indexOf(se);je!==-1&&x.splice(je,1);for(let We=0;We<x.length;We++)if(y.get(x[We]).priority<=we){x.splice(We,0,se);return}x.push(se)}return}throw new TypeError("not a valid backend")},S=async se=>{let he=y.get(se);if(!he)return"backend not found.";if(he.initialized)return he.backend;if(he.aborted)return he.error;{let we=!!he.initPromise;try{return we||(he.initPromise=he.backend.init(se)),await he.initPromise,he.initialized=!0,he.backend}catch(Pe){return we||(he.error=`${Pe}`,he.aborted=!0),he.error}finally{delete he.initPromise}}},b=async se=>{let he=se.executionProviders||[],we=he.map(Ve=>typeof Ve=="string"?Ve:Ve.name),Pe=we.length===0?x:we,je,We=[],Ie=new Set;for(let Ve of Pe){let nt=await S(Ve);typeof nt=="string"?We.push({name:Ve,err:nt}):(je||(je=nt),je===nt&&Ie.add(Ve))}if(!je)throw new Error(`no available backend found. ERR: ${We.map(Ve=>`[${Ve.name}] ${Ve.err}`).join(", ")}`);for(let{name:Ve,err:nt}of We)we.includes(Ve)&&console.warn(`removing requested execution provider "${Ve}" from session options because it is not available: ${nt}`);let De=he.filter(Ve=>Ie.has(typeof Ve=="string"?Ve:Ve.name));return[je,new Proxy(se,{get:(Ve,nt)=>nt==="executionProviders"?De:Reflect.get(Ve,nt)})]}}),w=u(()=>{_()}),C,E=u(()=>{C="1.26.0"}),T,$,N=u(()=>{E(),T="warning",$={wasm:{},webgl:{},webgpu:{},versions:{common:C},set logLevel(se){if(se!==void 0){if(typeof se!="string"||["verbose","info","warning","error","fatal"].indexOf(se)===-1)throw new Error(`Unsupported logging level: ${se}`);T=se}},get logLevel(){return T}},Object.defineProperty($,"logLevel",{enumerable:!0})}),O,M=u(()=>{N(),O=$}),U,H,V=u(()=>{U=(se,he)=>{let we=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);we.width=se.dims[3],we.height=se.dims[2];let Pe=we.getContext("2d");if(Pe!=null){let je,We;(he==null?void 0:he.tensorLayout)!==void 0&&he.tensorLayout==="NHWC"?(je=se.dims[2],We=se.dims[3]):(je=se.dims[3],We=se.dims[2]);let Ie=(he==null?void 0:he.format)!==void 0?he.format:"RGB",De=he==null?void 0:he.norm,Ve,nt;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?nt=[0,0,0,0]:typeof De.bias=="number"?nt=[De.bias,De.bias,De.bias,De.bias]:(nt=[De.bias[0],De.bias[1],De.bias[2],0],De.bias[3]!==void 0&&(nt[3]=De.bias[3]));let ct=We*je,it=0,Qe=ct,$t=ct*2,qe=-1;Ie==="RGBA"?(it=0,Qe=ct,$t=ct*2,qe=ct*3):Ie==="RGB"?(it=0,Qe=ct,$t=ct*2):Ie==="RBG"&&(it=0,$t=ct,Qe=ct*2);for(let pt=0;pt<We;pt++)for(let Pr=0;Pr<je;Pr++){let tr=(se.data[it++]-nt[0])*Ve[0],rr=(se.data[Qe++]-nt[1])*Ve[1],Rr=(se.data[$t++]-nt[2])*Ve[2],Lt=qe===-1?255:(se.data[qe++]-nt[3])*Ve[3];Pe.fillStyle="rgba("+tr+","+rr+","+Rr+","+Lt+")",Pe.fillRect(Pr,pt,1,1)}if("toDataURL"in we)return we.toDataURL();throw new Error("toDataURL is not supported")}else throw new Error("Can not access image data")},H=(se,he)=>{let we=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),Pe;if(we!=null){let je,We,Ie;(he==null?void 0:he.tensorLayout)!==void 0&&he.tensorLayout==="NHWC"?(je=se.dims[2],We=se.dims[1],Ie=se.dims[3]):(je=se.dims[3],We=se.dims[2],Ie=se.dims[1]);let De=he!==void 0&&he.format!==void 0?he.format:"RGB",Ve=he==null?void 0:he.norm,nt,ct;Ve===void 0||Ve.mean===void 0?nt=[255,255,255,255]:typeof Ve.mean=="number"?nt=[Ve.mean,Ve.mean,Ve.mean,Ve.mean]:(nt=[Ve.mean[0],Ve.mean[1],Ve.mean[2],255],Ve.mean[3]!==void 0&&(nt[3]=Ve.mean[3])),Ve===void 0||Ve.bias===void 0?ct=[0,0,0,0]:typeof Ve.bias=="number"?ct=[Ve.bias,Ve.bias,Ve.bias,Ve.bias]:(ct=[Ve.bias[0],Ve.bias[1],Ve.bias[2],0],Ve.bias[3]!==void 0&&(ct[3]=Ve.bias[3]));let it=We*je;if(he!==void 0&&(he.format!==void 0&&Ie===4&&he.format!=="RGBA"||Ie===3&&he.format!=="RGB"&&he.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let Qe=4,$t=0,qe=1,pt=2,Pr=3,tr=0,rr=it,Rr=it*2,Lt=-1;De==="RGBA"?(tr=0,rr=it,Rr=it*2,Lt=it*3):De==="RGB"?(tr=0,rr=it,Rr=it*2):De==="RBG"&&(tr=0,Rr=it,rr=it*2),Pe=we.createImageData(je,We);for(let qr=0;qr<We*je;$t+=Qe,qe+=Qe,pt+=Qe,Pr+=Qe,qr++)Pe.data[$t]=(se.data[tr++]-ct[0])*nt[0],Pe.data[qe]=(se.data[rr++]-ct[1])*nt[1],Pe.data[pt]=(se.data[Rr++]-ct[2])*nt[2],Pe.data[Pr]=Lt===-1?255:(se.data[Lt++]-ct[3])*nt[3]}else throw new Error("Can not access image data");return Pe}}),z,F,Y,te,le,pe,X=u(()=>{ce(),z=(se,he)=>{if(se===void 0)throw new Error("Image buffer must be defined");if(he.height===void 0||he.width===void 0)throw new Error("Image height and width must be defined");if(he.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");let{height:we,width:Pe}=he,je=he.norm??{mean:255,bias:0},We,Ie;typeof je.mean=="number"?We=[je.mean,je.mean,je.mean,je.mean]:We=[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=he.format!==void 0?he.format:"RGBA",Ve=he.tensorFormat!==void 0&&he.tensorFormat!==void 0?he.tensorFormat:"RGB",nt=we*Pe,ct=Ve==="RGBA"?new Float32Array(nt*4):new Float32Array(nt*3),it=4,Qe=0,$t=1,qe=2,pt=3,Pr=0,tr=nt,rr=nt*2,Rr=-1;De==="RGB"&&(it=3,Qe=0,$t=1,qe=2,pt=-1),Ve==="RGBA"?Rr=nt*3:Ve==="RBG"?(Pr=0,rr=nt,tr=nt*2):Ve==="BGR"&&(rr=0,tr=nt,Pr=nt*2);for(let Lt=0;Lt<nt;Lt++,Qe+=it,qe+=it,$t+=it,pt+=it)ct[Pr++]=(se[Qe]+Ie[0])/We[0],ct[tr++]=(se[$t]+Ie[1])/We[1],ct[rr++]=(se[qe]+Ie[2])/We[2],Rr!==-1&&pt!==-1&&(ct[Rr++]=(se[pt]+Ie[3])/We[3]);return Ve==="RGBA"?new ie("float32",ct,[1,4,we,Pe]):new ie("float32",ct,[1,3,we,Pe])},F=async(se,he)=>{let we=typeof HTMLImageElement<"u"&&se instanceof HTMLImageElement,Pe=typeof ImageData<"u"&&se instanceof ImageData,je=typeof ImageBitmap<"u"&&se instanceof ImageBitmap,We=typeof se=="string",Ie,De=he??{},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")},nt=ct=>typeof HTMLCanvasElement<"u"&&ct instanceof HTMLCanvasElement||ct instanceof OffscreenCanvas?ct.getContext("2d"):null;if(we){let ct=Ve();ct.width=se.width,ct.height=se.height;let it=nt(ct);if(it!=null){let Qe=se.height,$t=se.width;if(he!==void 0&&he.resizedHeight!==void 0&&he.resizedWidth!==void 0&&(Qe=he.resizedHeight,$t=he.resizedWidth),he!==void 0){if(De=he,he.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");De.tensorFormat="RGBA",De.height=Qe,De.width=$t}else De.tensorFormat="RGBA",De.height=Qe,De.width=$t;it.drawImage(se,0,0),Ie=it.getImageData(0,0,$t,Qe).data}else throw new Error("Can not access image data")}else if(Pe){let ct,it;if(he!==void 0&&he.resizedWidth!==void 0&&he.resizedHeight!==void 0?(ct=he.resizedHeight,it=he.resizedWidth):(ct=se.height,it=se.width),he!==void 0&&(De=he),De.format="RGBA",De.height=ct,De.width=it,he!==void 0){let Qe=Ve();Qe.width=it,Qe.height=ct;let $t=nt(Qe);if($t!=null)$t.putImageData(se,0,0),Ie=$t.getImageData(0,0,it,ct).data;else throw new Error("Can not access image data")}else Ie=se.data}else if(je){if(he===void 0)throw new Error("Please provide image config with format for Imagebitmap");let ct=Ve();ct.width=se.width,ct.height=se.height;let it=nt(ct);if(it!=null){let Qe=se.height,$t=se.width;return it.drawImage(se,0,0,$t,Qe),Ie=it.getImageData(0,0,$t,Qe).data,De.height=Qe,De.width=$t,z(Ie,De)}else throw new Error("Can not access image data")}else{if(We)return new Promise((ct,it)=>{let Qe=Ve(),$t=nt(Qe);if(!se||!$t)return it();let qe=new Image;qe.crossOrigin="Anonymous",qe.src=se,qe.onload=()=>{Qe.width=qe.width,Qe.height=qe.height,$t.drawImage(qe,0,0,Qe.width,Qe.height);let pt=$t.getImageData(0,0,Qe.width,Qe.height);De.height=Qe.height,De.width=Qe.width,ct(z(pt.data,De))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(Ie!==void 0)return z(Ie,De);throw new Error("Input data provided is not supported - aborted tensor creation")},Y=(se,he)=>{let{width:we,height:Pe,download:je,dispose:We}=he,Ie=[1,Pe,we,4];return new ie({location:"texture",type:"float32",texture:se,dims:Ie,download:je,dispose:We})},te=(se,he)=>{let{dataType:we,dims:Pe,download:je,dispose:We}=he;return new ie({location:"gpu-buffer",type:we??"float32",gpuBuffer:se,dims:Pe,download:je,dispose:We})},le=(se,he)=>{let{dataType:we,dims:Pe,download:je,dispose:We}=he;return new ie({location:"ml-tensor",type:we??"float32",mlTensor:se,dims:Pe,download:je,dispose:We})},pe=(se,he,we)=>new ie({location:"cpu-pinned",type:se,data:he,dims:we??[he.length]})}),Q,J,ee,ae,me=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]]),J=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),ee=!1,ae=()=>{if(!ee){ee=!0;let se=typeof BigInt64Array<"u"&&BigInt64Array.from,he=typeof BigUint64Array<"u"&&BigUint64Array.from,we=globalThis.Float16Array,Pe=typeof we<"u"&&we.from;se&&(Q.set("int64",BigInt64Array),J.set(BigInt64Array,"int64")),he&&(Q.set("uint64",BigUint64Array),J.set(BigUint64Array,"uint64")),Pe?(Q.set("float16",we),J.set(we,"float16")):Q.set("float16",Uint16Array)}}}),_e,Ne,xe=u(()=>{ce(),_e=se=>{let he=1;for(let we=0;we<se.length;we++){let Pe=se[we];if(typeof Pe!="number"||!Number.isSafeInteger(Pe))throw new TypeError(`dims[${we}] must be an integer, got: ${Pe}`);if(Pe<0)throw new RangeError(`dims[${we}] must be a non-negative integer, got: ${Pe}`);he*=Pe}return he},Ne=(se,he)=>{switch(se.location){case"cpu":return new ie(se.type,se.data,he);case"cpu-pinned":return new ie({location:"cpu-pinned",data:se.data,type:se.type,dims:he});case"texture":return new ie({location:"texture",texture:se.texture,type:se.type,dims:he});case"gpu-buffer":return new ie({location:"gpu-buffer",gpuBuffer:se.gpuBuffer,type:se.type,dims:he});case"ml-tensor":return new ie({location:"ml-tensor",mlTensor:se.mlTensor,type:se.type,dims:he});default:throw new Error(`tensorReshape: tensor location ${se.location} is not supported`)}}}),ie,ce=u(()=>{V(),X(),me(),xe(),ie=class{constructor(se,he,we){ae();let Pe,je;if(typeof se=="object"&&"location"in se)switch(this.dataLocation=se.location,Pe=se.type,je=se.dims,se.location){case"cpu-pinned":{let Ie=Q.get(Pe);if(!Ie)throw new TypeError(`unsupported type "${Pe}" to create tensor from pinned buffer`);if(!(se.data instanceof Ie))throw new TypeError(`buffer should be of type ${Ie.name}`);this.cpuData=se.data;break}case"texture":{if(Pe!=="float32")throw new TypeError(`unsupported type "${Pe}" to create tensor from texture`);this.gpuTextureData=se.texture,this.downloader=se.download,this.disposer=se.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=se.gpuBuffer,this.downloader=se.download,this.disposer=se.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=se.mlTensor,this.downloader=se.download,this.disposer=se.dispose;break}default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let Ie,De;if(typeof se=="string")if(Pe=se,De=we,se==="string"){if(!Array.isArray(he))throw new TypeError("A string tensor's data must be a string array.");Ie=he}else{let Ve=Q.get(se);if(Ve===void 0)throw new TypeError(`Unsupported tensor type: ${se}.`);if(Array.isArray(he)){if(se==="float16"&&Ve===Uint16Array||se==="uint4"||se==="int4")throw new TypeError(`Creating a ${se} tensor from number array is not supported. Please use ${Ve.name} as data.`);se==="uint64"||se==="int64"?Ie=Ve.from(he,BigInt):Ie=Ve.from(he)}else if(he instanceof Ve)Ie=he;else if(he instanceof Uint8ClampedArray)if(se==="uint8")Ie=Uint8Array.from(he);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else if(se==="float16"&&he instanceof Uint16Array&&Ve!==Uint16Array)Ie=new globalThis.Float16Array(he.buffer,he.byteOffset,he.length);else throw new TypeError(`A ${Pe} tensor's data must be type of ${Ve}`)}else if(De=he,Array.isArray(se)){if(se.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let Ve=typeof se[0];if(Ve==="string")Pe="string",Ie=se;else if(Ve==="boolean")Pe="bool",Ie=Uint8Array.from(se);else throw new TypeError(`Invalid element type of data array: ${Ve}.`)}else if(se instanceof Uint8ClampedArray)Pe="uint8",Ie=Uint8Array.from(se);else{let Ve=J.get(se.constructor);if(Ve===void 0)throw new TypeError(`Unsupported type for tensor data: ${se.constructor}.`);Pe=Ve,Ie=se}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 We=_e(je);if(this.cpuData&&We!==this.cpuData.length&&!((Pe==="uint4"||Pe==="int4")&&Math.ceil(We/2)===this.cpuData.length))throw new Error(`Tensor's size(${We}) does not match data length(${this.cpuData.length}).`);this.type=Pe,this.dims=je,this.size=We}static async fromImage(se,he){return F(se,he)}static fromTexture(se,he){return Y(se,he)}static fromGpuBuffer(se,he){return te(se,he)}static fromMLTensor(se,he){return le(se,he)}static fromPinnedBuffer(se,he,we){return pe(se,he,we)}toDataURL(se){return U(this,se)}toImageData(se){return H(this,se)}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(se){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 he=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=he,se&&this.disposer&&(this.disposer(),this.disposer=void 0),he}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(se){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return Ne(this,se)}}}),ge,Ae=u(()=>{ce(),ge=ie}),Te,Me,Le,Ue,st,lt,Zt=u(()=>{N(),Te=(se,he)=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||console.timeStamp(`${se}::ORT::${he}`)},Me=(se,he)=>{var je;let we=((je=new Error().stack)==null?void 0:je.split(/\r\n|\r|\n/g))||[],Pe=!1;for(let We=0;We<we.length;We++){if(Pe&&!we[We].includes("TRACE_FUNC")){let Ie=`FUNC_${se}::${we[We].trim().split(" ")[1]}`;he&&(Ie+=`::${he}`),Te("CPU",Ie);return}we[We].includes("TRACE_FUNC")&&(Pe=!0)}},Le=se=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||Me("BEGIN",se)},Ue=se=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||Me("END",se)},st=se=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||console.time(`ORT::${se}`)},lt=se=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||console.timeEnd(`ORT::${se}`)}}),Kt,sr=u(()=>{_(),Ae(),Zt(),Kt=class A4{constructor(he){this.handler=he}async run(he,we,Pe){Le(),st("InferenceSession.run");let je={},We={};if(typeof he!="object"||he===null||he instanceof ge||Array.isArray(he))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let Ie=!0;if(typeof we=="object"){if(we===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(we instanceof ge)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(we)){if(we.length===0)throw new TypeError("'fetches' cannot be an empty array.");Ie=!1;for(let nt of we){if(typeof nt!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(nt)===-1)throw new RangeError(`'fetches' contains invalid output name: ${nt}.`);je[nt]=null}if(typeof Pe=="object"&&Pe!==null)We=Pe;else if(typeof Pe<"u")throw new TypeError("'options' must be an object.")}else{let nt=!1,ct=Object.getOwnPropertyNames(we);for(let it of this.outputNames)if(ct.indexOf(it)!==-1){let Qe=we[it];(Qe===null||Qe instanceof ge)&&(nt=!0,Ie=!1,je[it]=Qe)}if(nt){if(typeof Pe=="object"&&Pe!==null)We=Pe;else if(typeof Pe<"u")throw new TypeError("'options' must be an object.")}else We=we}}else if(typeof we<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let nt of this.inputNames)if(typeof he[nt]>"u")throw new Error(`input '${nt}' is missing in 'feeds'.`);if(Ie)for(let nt of this.outputNames)je[nt]=null;let De=await this.handler.run(he,je,We),Ve={};for(let nt in De)if(Object.hasOwnProperty.call(De,nt)){let ct=De[nt];ct instanceof ge?Ve[nt]=ct:Ve[nt]=new ge(ct.type,ct.data,ct.dims)}return lt("InferenceSession.run"),Ue(),Ve}async release(){return this.handler.dispose()}static async create(he,we,Pe,je){Le(),st("InferenceSession.create");let We,Ie={};if(typeof he=="string"){if(We=he,typeof we=="object"&&we!==null)Ie=we;else if(typeof we<"u")throw new TypeError("'options' must be an object.")}else if(he instanceof Uint8Array){if(We=he,typeof we=="object"&&we!==null)Ie=we;else if(typeof we<"u")throw new TypeError("'options' must be an object.")}else if(he instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&he instanceof SharedArrayBuffer){let ct=he,it=0,Qe=he.byteLength;if(typeof we=="object"&&we!==null)Ie=we;else if(typeof we=="number"){if(it=we,!Number.isSafeInteger(it))throw new RangeError("'byteOffset' must be an integer.");if(it<0||it>=ct.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${ct.byteLength}).`);if(Qe=he.byteLength-it,typeof Pe=="number"){if(Qe=Pe,!Number.isSafeInteger(Qe))throw new RangeError("'byteLength' must be an integer.");if(Qe<=0||it+Qe>ct.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${ct.byteLength-it}].`);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 we<"u")throw new TypeError("'options' must be an object.");We=new Uint8Array(ct,it,Qe)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[De,Ve]=await b(Ie),nt=await De.createInferenceSessionHandler(We,Ve);return lt("InferenceSession.create"),Ue(),new A4(nt)}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}}}),Vt,jr=u(()=>{sr(),Vt=Kt}),fr=u(()=>{}),Ur=u(()=>{}),Ir=u(()=>{}),fi=u(()=>{}),Zn={};f(Zn,{InferenceSession:()=>Vt,TRACE:()=>Te,TRACE_EVENT_BEGIN:()=>st,TRACE_EVENT_END:()=>lt,TRACE_FUNC_BEGIN:()=>Le,TRACE_FUNC_END:()=>Ue,Tensor:()=>ge,env:()=>O,registerBackend:()=>k});var hr=u(()=>{w(),M(),jr(),Ae(),fr(),Ur(),Zt(),Ir(),fi()}),Rn=u(()=>{}),ut={};f(ut,{default:()=>_r});var wt,_t,_r,xn=u(()=>{var se;Se(),mi(),pi(),wt="ort-wasm-proxy-worker",_t=((se=globalThis.self)==null?void 0:se.name)===wt,_t&&(self.onmessage=he=>{let{type:we,in:Pe}=he.data;try{switch(we){case"init-wasm":Ms(Pe.wasm).then(()=>{qo(Pe).then(()=>{postMessage({type:we})},je=>{postMessage({type:we,err:je})})},je=>{postMessage({type:we,err:je})});break;case"init-ep":{let{epName:je,env:We}=Pe;sa(We,je).then(()=>{postMessage({type:we})},Ie=>{postMessage({type:we,err:Ie})});break}case"copy-from":{let{buffer:je}=Pe,We=lr(je);postMessage({type:we,out:We});break}case"create":{let{model:je,options:We}=Pe;Bi(je,We).then(Ie=>{postMessage({type:we,out:Ie})},Ie=>{postMessage({type:we,err:Ie})});break}case"release":Ta(Pe),postMessage({type:we});break;case"run":{let{sessionId:je,inputIndices:We,inputs:Ie,outputIndices:De,options:Ve}=Pe;Ze(je,We,Ie,De,new Array(De.length).fill(null),Ve).then(nt=>{nt.some(ct=>ct[3]!=="cpu")?postMessage({type:we,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:we,out:nt},vt([...Ie,...nt]))},nt=>{postMessage({type:we,err:nt})});break}case"end-profiling":vi(Pe),postMessage({type:we});break;default:}}catch(je){postMessage({type:we,err:je})}}),_r=_t?null:he=>new Worker(he??Sr,{type:"classic",name:wt})}),rs,fs,Sr,hi,pn,ea,hs,Mi,Ca,ta,ra,ps,Qn,pi=u(()=>{Rn(),rs=typeof location>"u"?void 0:location.origin,fs=()=>{var se,he;return typeof document<"u"?(se=document.currentScript)==null?void 0:se.src:typeof self<"u"?(he=self.location)==null?void 0:he.href:void 0},Sr=fs(),hi=()=>{if(Sr&&!Sr.startsWith("blob:"))return Sr.substring(0,Sr.lastIndexOf("/")+1)},pn=(se,he)=>{try{let we=he??Sr;return(we?new URL(se,we):new URL(se)).origin===rs}catch{return!1}},ea=(se,he)=>{let we=he??Sr;try{return(we?new URL(se,we):new URL(se)).href}catch{return}},hs=(se,he)=>`${he??"./"}${se}`,Mi=async se=>{let he=await(await fetch(se,{credentials:"same-origin"})).blob();return URL.createObjectURL(he)},Ca=async se=>(await import(se)).default,ta=(xn(),h(ut)).default,ra=async()=>{if(!Sr)throw new Error("Failed to load proxy worker: cannot determine the script source URL.");if(pn(Sr))return[void 0,ta()];let se=await Mi(Sr);return[se,ta(se)]},ps=void 0,Qn=async(se,he,we,Pe)=>{let je=ps&&!(se||he);if(je)if(Sr)je=pn(Sr)||Pe&&!we;else if(Pe&&!we)je=!0;else throw new Error("cannot determine the script source URL.");if(je)return[void 0,ps];{let We="ort-wasm-simd-threaded.mjs",Ie=se??ea(We,he),De=we&&Ie&&!pn(Ie,he),Ve=De?await Mi(Ie):Ie??hs(We,he);return[De?Ve:void 0,await Ca(Ve)]}}}),Os,ei,Ii,ns,to,Ps,Rs,Ms,zt,mi=u(()=>{pi(),ei=!1,Ii=!1,ns=!1,to=()=>{if(typeof SharedArrayBuffer>"u")return!1;try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch{return!1}},Ps=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch{return!1}},Rs=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,19,1,17,0,65,1,253,15,65,2,253,15,65,3,253,15,253,147,2,11]))}catch{return!1}},Ms=async se=>{if(ei)return Promise.resolve();if(Ii)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(ns)throw new Error("previous call to 'initializeWebAssembly()' failed.");Ii=!0;let he=se.initTimeout,we=se.numThreads;if(se.simd!==!1){if(se.simd==="relaxed"){if(!Rs())throw new Error("Relaxed WebAssembly SIMD is not supported in the current environment.")}else if(!Ps())throw new Error("WebAssembly SIMD is not supported in the current environment.")}let Pe=to();we>1&&!Pe&&(typeof self<"u"&&!self.crossOriginIsolated&&console.warn("env.wasm.numThreads is set to "+we+", 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."),se.numThreads=we=1);let je=se.wasmPaths,We=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,nt=(Ve==null?void 0:Ve.href)??Ve,ct=se.wasmBinary,[it,Qe]=await Qn(De,We,we>1,!!ct||!!nt),$t=!1,qe=[];if(he>0&&qe.push(new Promise(pt=>{setTimeout(()=>{$t=!0,pt()},he)})),qe.push(new Promise((pt,Pr)=>{let tr={numThreads:we};if(ct)tr.wasmBinary=ct,tr.locateFile=rr=>rr;else if(nt||We)tr.locateFile=rr=>nt??We+rr;else if(De&&De.indexOf("blob:")!==0)tr.locateFile=rr=>new URL(rr,De).href;else if(it){let rr=hi();rr&&(tr.locateFile=Rr=>rr+Rr)}Qe(tr).then(rr=>{Ii=!1,ei=!0,Os=rr,pt(),it&&URL.revokeObjectURL(it)},rr=>{Ii=!1,ns=!0,Pr(rr)})})),await Promise.race(qe),$t)throw new Error(`WebAssembly backend initializing failed due to timeout: ${he}ms`)},zt=()=>{if(ei&&Os)return Os;throw new Error("WebAssembly is not initialized yet.")}}),en,Er,Ct,ja=u(()=>{mi(),en=(se,he)=>{let we=zt(),Pe=we.lengthBytesUTF8(se)+1,je=we._malloc(Pe);return we.stringToUTF8(se,je,Pe),he.push(je),je},Er=(se,he,we,Pe)=>{if(typeof se=="object"&&se!==null){if(we.has(se))throw new Error("Circular reference in options");we.add(se)}Object.entries(se).forEach(([je,We])=>{let Ie=he?he+je:je;if(typeof We=="object")Er(We,Ie+".",we,Pe);else if(typeof We=="string"||typeof We=="number")Pe(Ie,We.toString());else if(typeof We=="boolean")Pe(Ie,We?"1":"0");else throw new Error(`Can't handle extra config type: ${typeof We}`)})},Ct=se=>{let he=zt(),we=he.stackSave();try{let Pe=he.PTR_SIZE,je=he.stackAlloc(2*Pe);he._OrtGetLastError(je,je+Pe);let We=Number(he.getValue(je,Pe===4?"i32":"i64")),Ie=he.getValue(je+Pe,"*"),De=Ie?he.UTF8ToString(Ie):"";throw new Error(`${se} ERROR_CODE: ${We}, ERROR_MESSAGE: ${De}`)}finally{he.stackRestore(we)}}}),ro,El=u(()=>{mi(),ja(),ro=se=>{let he=zt(),we=0,Pe=[],je=se||{};try{if((se==null?void 0:se.logSeverityLevel)===void 0)je.logSeverityLevel=2;else if(typeof se.logSeverityLevel!="number"||!Number.isInteger(se.logSeverityLevel)||se.logSeverityLevel<0||se.logSeverityLevel>4)throw new Error(`log severity level is not valid: ${se.logSeverityLevel}`);if((se==null?void 0:se.logVerbosityLevel)===void 0)je.logVerbosityLevel=0;else if(typeof se.logVerbosityLevel!="number"||!Number.isInteger(se.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${se.logVerbosityLevel}`);(se==null?void 0:se.terminate)===void 0&&(je.terminate=!1);let We=0;return(se==null?void 0:se.tag)!==void 0&&(We=en(se.tag,Pe)),we=he._OrtCreateRunOptions(je.logSeverityLevel,je.logVerbosityLevel,!!je.terminate,We),we===0&&Ct("Can't create run options."),(se==null?void 0:se.extra)!==void 0&&Er(se.extra,"",new WeakSet,(Ie,De)=>{let Ve=en(Ie,Pe),nt=en(De,Pe);he._OrtAddRunConfigEntry(we,Ve,nt)!==0&&Ct(`Can't set a run config entry: ${Ie} - ${De}.`)}),[we,Pe]}catch(We){throw we!==0&&he._OrtReleaseRunOptions(we),Pe.forEach(Ie=>he._free(Ie)),We}}}),no,io,Uo,Hn,Tl,Al,Tr=u(()=>{mi(),ja(),no=se=>{switch(se){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: ${se}`)}},io=se=>{switch(se){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${se}`)}},Uo=se=>{se.extra||(se.extra={}),se.extra.session||(se.extra.session={});let he=se.extra.session;he.use_ort_model_bytes_directly||(he.use_ort_model_bytes_directly="1"),se.executionProviders&&se.executionProviders.some(we=>(typeof we=="string"?we:we.name)==="webgpu")&&(se.enableMemPattern=!1)},Hn=(se,he,we,Pe)=>{let je=en(he,Pe),We=en(we,Pe);zt()._OrtAddSessionConfigEntry(se,je,We)!==0&&Ct(`Can't set a session config entry: ${he} - ${we}.`)},Tl=async(se,he,we)=>{let Pe=he.executionProviders;for(let je of Pe){let We=typeof je=="string"?je:je.name,Ie=[];switch(We){case"webnn":if(We="WEBNN",Hn(se,"session.disable_quant_qdq","1",we),Hn(se,"session.disable_qdq_constant_folding","1",we),typeof je!="string"){let it=je==null?void 0:je.deviceType;it&&Hn(se,"deviceType",it,we)}break;case"webgpu":if(We="JS",typeof je!="string"){let it=je;if(it!=null&&it.preferredLayout){if(it.preferredLayout!=="NCHW"&&it.preferredLayout!=="NHWC")throw new Error(`preferredLayout must be either 'NCHW' or 'NHWC': ${it.preferredLayout}`);Hn(se,"preferredLayout",it.preferredLayout,we)}}break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${We}`)}let De=en(We,we),Ve=Ie.length,nt=0,ct=0;if(Ve>0){nt=zt()._malloc(Ve*zt().PTR_SIZE),we.push(nt),ct=zt()._malloc(Ve*zt().PTR_SIZE),we.push(ct);for(let it=0;it<Ve;it++)zt().setValue(nt+it*zt().PTR_SIZE,Ie[it][0],"*"),zt().setValue(ct+it*zt().PTR_SIZE,Ie[it][1],"*")}await zt()._OrtAppendExecutionProvider(se,De,nt,ct,Ve)!==0&&Ct(`Can't append execution provider: ${We}.`)}},Al=async se=>{let he=zt(),we=0,Pe=[],je=se||{};Uo(je);try{let We=no(je.graphOptimizationLevel??"all"),Ie=io(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 nt=je.logVerbosityLevel??0;if(!Number.isInteger(nt)||nt<0||nt>4)throw new Error(`log verbosity level is not valid: ${nt}`);let ct=typeof je.optimizedModelFilePath=="string"?en(je.optimizedModelFilePath,Pe):0;if(we=he._OrtCreateSessionOptions(We,!!je.enableCpuMemArena,!!je.enableMemPattern,Ie,!!je.enableProfiling,0,De,Ve,nt,ct),we===0&&Ct("Can't create session options."),je.executionProviders&&await Tl(we,je,Pe),je.enableGraphCapture!==void 0){if(typeof je.enableGraphCapture!="boolean")throw new Error(`enableGraphCapture must be a boolean value: ${je.enableGraphCapture}`);Hn(we,"enableGraphCapture",je.enableGraphCapture.toString(),Pe)}if(je.freeDimensionOverrides)for(let[it,Qe]of Object.entries(je.freeDimensionOverrides)){if(typeof it!="string")throw new Error(`free dimension override name must be a string: ${it}`);if(typeof Qe!="number"||!Number.isInteger(Qe)||Qe<0)throw new Error(`free dimension override value must be a non-negative integer: ${Qe}`);let $t=en(it,Pe);he._OrtAddFreeDimensionOverride(we,$t,Qe)!==0&&Ct(`Can't set a free dimension override: ${it} - ${Qe}.`)}return je.extra!==void 0&&Er(je.extra,"",new WeakSet,(it,Qe)=>{Hn(we,it,Qe,Pe)}),[we,Pe]}catch(We){throw we!==0&&he._OrtReleaseSessionOptions(we)!==0&&Ct("Can't release session options."),Pe.forEach(Ie=>he._free(Ie)),We}}}),ti,sn,ri,Is,Ea,na,Di,Mn,Ft=u(()=>{ti=se=>{switch(se){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: ${se}`)}},sn=se=>{switch(se){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: ${se}`)}},ri=(se,he)=>{let we=[-1,4,1,1,2,2,4,8,-1,1,2,8,4,8,-1,-1,-1,-1,-1,-1,-1,.5,.5][se],Pe=typeof he=="number"?he:he.reduce((je,We)=>je*We,1);return we>0?Math.ceil(Pe*we):void 0},Is=se=>{switch(se){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: ${se}`)}},Ea=se=>{switch(se){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: ${se}`)}},na=se=>se==="float32"||se==="float16"||se==="int32"||se==="int64"||se==="uint32"||se==="uint8"||se==="bool"||se==="uint4"||se==="int4",Di=se=>se==="float32"||se==="float16"||se==="int32"||se==="int64"||se==="uint32"||se==="uint64"||se==="int8"||se==="uint8"||se==="bool"||se==="uint4"||se==="int4",Mn=se=>{switch(se){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: ${se}`)}}}),an,ia=u(()=>{Rn(),an=async se=>{if(typeof se=="string"){let he=await fetch(se);if(!he.ok)throw new Error(`failed to load external data file: ${se}`);let we=he.headers.get("Content-Length"),Pe=we?parseInt(we,10):0;if(Pe<1073741824)return new Uint8Array(await he.arrayBuffer());{if(!he.body)throw new Error(`failed to load external data file: ${se}, no response body.`);let je=he.body.getReader(),We;try{We=new ArrayBuffer(Pe)}catch(De){if(De instanceof RangeError){let Ve=Math.ceil(Pe/65536);We=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 nt=Ve.byteLength;new Uint8Array(We,Ie,nt).set(Ve),Ie+=nt}return new Uint8Array(We,0,Pe)}}else return se instanceof Blob?new Uint8Array(await se.arrayBuffer()):se instanceof Uint8Array?se:new Uint8Array(se)}}),Li,qo,sa,gi,ms,aa,lr,Bi,Ta,is,Ze,vi,vt,Se=u(()=>{hr(),El(),Tr(),Ft(),mi(),ja(),ia(),Li=(se,he)=>{zt()._OrtInit(se,he)!==0&&Ct("Can't initialize onnxruntime.")},qo=async se=>{Li(se.wasm.numThreads,Ea(se.logLevel))},sa=async(se,he)=>{var Pe,je;(je=(Pe=zt()).asyncInit)==null||je.call(Pe);let we=se.webgpu.adapter;if(he==="webgpu"){if(typeof navigator>"u"||!navigator.gpu)throw new Error("WebGPU is not supported in current environment");if(we){if(typeof we.limits!="object"||typeof we.features!="object"||typeof we.requestDevice!="function")throw new Error("Invalid GPU adapter set in `env.webgpu.adapter`. It must be a GPUAdapter object.")}else{let We=se.webgpu.powerPreference;if(We!==void 0&&We!=="low-power"&&We!=="high-performance")throw new Error(`Invalid powerPreference setting: "${We}"`);let Ie=se.webgpu.forceFallbackAdapter;if(Ie!==void 0&&typeof Ie!="boolean")throw new Error(`Invalid forceFallbackAdapter setting: "${Ie}"`);if(we=await navigator.gpu.requestAdapter({powerPreference:We,forceFallbackAdapter:Ie}),!we)throw new Error('Failed to get GPU adapter. You may need to enable flag "--enable-unsafe-webgpu" if you are using Chrome.')}}if(he==="webnn"&&(typeof navigator>"u"||!navigator.ml))throw new Error("WebNN is not supported in current environment")},gi=new Map,ms=se=>{let he=zt(),we=he.stackSave();try{let Pe=he.PTR_SIZE,je=he.stackAlloc(2*Pe);he._OrtGetInputOutputCount(se,je,je+Pe)!==0&&Ct("Can't get session input/output count.");let We=Pe===4?"i32":"i64";return[Number(he.getValue(je,We)),Number(he.getValue(je+Pe,We))]}finally{he.stackRestore(we)}},aa=(se,he)=>{let we=zt(),Pe=we.stackSave(),je=0;try{let We=we.PTR_SIZE,Ie=we.stackAlloc(2*We);we._OrtGetInputOutputMetadata(se,he,Ie,Ie+We)!==0&&Ct("Can't get session input/output metadata.");let De=Number(we.getValue(Ie,"*"));je=Number(we.getValue(Ie+We,"*"));let Ve=we.HEAP32[je/4];if(Ve===0)return[De,0];let nt=we.HEAPU32[je/4+1],ct=[];for(let it=0;it<nt;it++){let Qe=Number(we.getValue(je+8+it*We,"*"));ct.push(Qe!==0?we.UTF8ToString(Qe):Number(we.getValue(je+8+(it+nt)*We,"*")))}return[De,Ve,ct]}finally{we.stackRestore(Pe),je!==0&&we._OrtFree(je)}},lr=se=>{let he=zt(),we=he._malloc(se.byteLength);if(we===0)throw new Error(`Can't create a session. failed to allocate a buffer of size ${se.byteLength}.`);return he.HEAPU8.set(se,we),[we,se.byteLength]},Bi=async(se,he)=>{var ct,it,Qe;let we,Pe,je=zt();Array.isArray(se)?[we,Pe]=se:se.buffer===je.HEAPU8.buffer?[we,Pe]=[se.byteOffset,se.byteLength]:[we,Pe]=lr(se);let We=0,Ie=0,De=[],Ve=[],nt=[];try{if([Ie,De]=await Al(he),(he==null?void 0:he.externalData)&&je.mountExternalData){let qr=[];for(let pr of he.externalData){let In=typeof pr=="string"?pr:pr.path;qr.push(an(typeof pr=="string"?pr:pr.data).then(ni=>{je.mountExternalData(In,ni)}))}await Promise.all(qr)}for(let qr of(he==null?void 0:he.executionProviders)??[])if((typeof qr=="string"?qr:qr.name)==="webnn"){if(je.shouldTransferToMLTensor=!1,typeof qr!="string"){let pr=qr,In=pr==null?void 0:pr.context,ni=pr==null?void 0:pr.gpuDevice,yi=pr==null?void 0:pr.deviceType,Nl=pr==null?void 0:pr.powerPreference;In?je.currentContext=In:ni?je.currentContext=await je.webnnCreateMLContext(ni):je.currentContext=await je.webnnCreateMLContext({deviceType:yi,powerPreference:Nl})}else je.currentContext=await je.webnnCreateMLContext();break}We=await je._OrtCreateSession(we,Pe,Ie),(ct=je.webgpuOnCreateSession)==null||ct.call(je,We),We===0&&Ct("Can't create a session."),(it=je.jsepOnCreateSession)==null||it.call(je),je.currentContext&&(je.webnnRegisterMLContext(We,je.currentContext),je.currentContext=void 0,je.shouldTransferToMLTensor=!0);let[$t,qe]=ms(We),pt=!!(he!=null&&he.enableGraphCapture),Pr=[],tr=[],rr=[],Rr=[],Lt=[];for(let qr=0;qr<$t;qr++){let[pr,In,ni]=aa(We,qr);pr===0&&Ct("Can't get an input name."),Ve.push(pr);let yi=je.UTF8ToString(pr);Pr.push(yi),rr.push(In===0?{name:yi,isTensor:!1}:{name:yi,isTensor:!0,type:sn(In),shape:ni})}for(let qr=0;qr<qe;qr++){let[pr,In,ni]=aa(We,qr+$t);pr===0&&Ct("Can't get an output name."),nt.push(pr);let yi=je.UTF8ToString(pr);tr.push(yi),Rr.push(In===0?{name:yi,isTensor:!1}:{name:yi,isTensor:!0,type:sn(In),shape:ni})}return gi.set(We,[We,Ve,nt,null,pt,!1]),[We,Pr,tr,rr,Rr]}catch($t){throw Ve.forEach(qe=>je._OrtFree(qe)),nt.forEach(qe=>je._OrtFree(qe)),We!==0&&je._OrtReleaseSession(We)!==0&&Ct("Can't release session."),$t}finally{je._free(we),Ie!==0&&je._OrtReleaseSessionOptions(Ie)!==0&&Ct("Can't release session options."),De.forEach($t=>je._free($t)),(Qe=je.unmountExternalData)==null||Qe.call(je)}},Ta=se=>{var Ve,nt,ct;let he=zt(),we=gi.get(se);if(!we)throw new Error(`cannot release session. invalid session id: ${se}`);let[Pe,je,We,Ie,De]=we;Ie&&(De&&he._OrtClearBoundOutputs(Ie.handle)!==0&&Ct("Can't clear bound outputs."),he._OrtReleaseBinding(Ie.handle)!==0&&Ct("Can't release IO binding.")),(Ve=he.jsepOnReleaseSession)==null||Ve.call(he,se),(nt=he.webnnOnReleaseSession)==null||nt.call(he,se),(ct=he.webgpuOnReleaseSession)==null||ct.call(he,se),je.forEach(it=>he._OrtFree(it)),We.forEach(it=>he._OrtFree(it)),he._OrtReleaseSession(Pe)!==0&&Ct("Can't release session."),gi.delete(se)},is=async(se,he,we,Pe,je,We,Ie=!1)=>{if(!se){he.push(0);return}let De=zt(),Ve=De.PTR_SIZE,nt=se[0],ct=se[1],it=se[3],Qe=it,$t,qe;if(nt==="string"&&(it==="gpu-buffer"||it==="ml-tensor"))throw new Error("String tensor is not supported on GPU.");if(Ie&&it!=="gpu-buffer")throw new Error(`External buffer must be provided for input/output index ${We} when enableGraphCapture is true.`);if(it==="gpu-buffer"){let tr=se[2].gpuBuffer;qe=ri(ti(nt),ct);{let rr=De.jsepRegisterBuffer;if(!rr)throw new Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');$t=rr(Pe,We,tr,qe)}}else if(it==="ml-tensor"){let tr=se[2].mlTensor;qe=ri(ti(nt),ct);let rr=De.webnnRegisterMLTensor;if(!rr)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');$t=rr(Pe,tr,ti(nt),ct)}else{let tr=se[2];if(Array.isArray(tr)){qe=Ve*tr.length,$t=De._malloc(qe),we.push($t);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($t+rr*Ve,en(tr[rr],we),"*")}}else{let rr=De.webnnIsGraphInput,Rr=De.webnnIsGraphOutput;if(nt!=="string"&&rr&&Rr){let Lt=De.UTF8ToString(je);if(rr(Pe,Lt)||Rr(Pe,Lt)){let qr=ti(nt);qe=ri(qr,ct),Qe="ml-tensor";let pr=De.webnnCreateTemporaryTensor,In=De.webnnUploadTensor;if(!pr||!In)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');let ni=await pr(Pe,qr,ct);In(ni,new Uint8Array(tr.buffer,tr.byteOffset,tr.byteLength)),$t=ni}else qe=tr.byteLength,$t=De._malloc(qe),we.push($t),De.HEAPU8.set(new Uint8Array(tr.buffer,tr.byteOffset,qe),$t)}else qe=tr.byteLength,$t=De._malloc(qe),we.push($t),De.HEAPU8.set(new Uint8Array(tr.buffer,tr.byteOffset,qe),$t)}}let pt=De.stackSave(),Pr=De.stackAlloc(4*ct.length);try{ct.forEach((rr,Rr)=>De.setValue(Pr+Rr*Ve,rr,Ve===4?"i32":"i64"));let tr=De._OrtCreateTensor(ti(nt),$t,qe,Pr,ct.length,Mn(Qe));tr===0&&Ct(`Can't create tensor for input/output. session=${Pe}, index=${We}.`),he.push(tr)}finally{De.stackRestore(pt)}},Ze=async(se,he,we,Pe,je,We)=>{var bi,Nc,Uu;let Ie=zt(),De=Ie.PTR_SIZE,Ve=gi.get(se);if(!Ve)throw new Error(`cannot run inference. invalid session id: ${se}`);let nt=Ve[0],ct=Ve[1],it=Ve[2],Qe=Ve[3],$t=Ve[4];Ve[5];let qe=he.length,pt=Pe.length,Pr=0,tr=[],rr=[],Rr=[],Lt=[],qr=[],pr=Ie.stackSave(),In=Ie.stackAlloc(qe*De),ni=Ie.stackAlloc(qe*De),yi=Ie.stackAlloc(pt*De),Nl=Ie.stackAlloc(pt*De);try{[Pr,tr]=ro(We),st("wasm prepareInputOutputTensor");for(let ur=0;ur<qe;ur++)await is(we[ur],rr,Lt,se,ct[he[ur]],he[ur],$t);for(let ur=0;ur<pt;ur++)await is(je[ur],Rr,Lt,se,it[Pe[ur]],qe+Pe[ur],$t);lt("wasm prepareInputOutputTensor");for(let ur=0;ur<qe;ur++)Ie.setValue(In+ur*De,rr[ur],"*"),Ie.setValue(ni+ur*De,ct[he[ur]],"*");for(let ur=0;ur<pt;ur++)Ie.setValue(yi+ur*De,Rr[ur],"*"),Ie.setValue(Nl+ur*De,it[Pe[ur]],"*");(bi=Ie.jsepOnRunStart)==null||bi.call(Ie,nt),(Nc=Ie.webnnOnRunStart)==null||Nc.call(Ie,nt);let Dn;Dn=await Ie._OrtRun(nt,ni,In,qe,Nl,pt,yi,Pr),Dn!==0&&Ct("failed to call OrtRun().");let Ls=[],qu=[];st("wasm ProcessOutputTensor");for(let ur=0;ur<pt;ur++){let vs=Number(Ie.getValue(yi+ur*De,"*"));if(vs===Rr[ur]||qr.includes(Rr[ur])){Ls.push(je[ur]),vs!==Rr[ur]&&Ie._OrtReleaseTensor(vs)!==0&&Ct("Can't release tensor.");continue}let jf=Ie.stackSave(),ca=Ie.stackAlloc(4*De),Wo=!1,_n,xi=0;try{Ie._OrtGetTensorData(vs,ca,ca+De,ca+2*De,ca+3*De)!==0&&Ct(`Can't access output tensor data on index ${ur}.`);let Oc=De===4?"i32":"i64",wi=Number(Ie.getValue(ca,Oc));xi=Ie.getValue(ca+De,"*");let Wu=Ie.getValue(ca+De*2,"*"),Ef=Number(Ie.getValue(ca+De*3,Oc)),ua=[];for(let Sn=0;Sn<Ef;Sn++)ua.push(Number(Ie.getValue(Wu+Sn*De,Oc)));Ie._OrtFree(Wu)!==0&&Ct("Can't free memory for tensor dims.");let ys=ua.reduce((Sn,tn)=>Sn*tn,1);_n=sn(wi);let Bs=Qe==null?void 0:Qe.outputPreferredLocations[Pe[ur]];if(_n==="string"){if(Bs==="gpu-buffer"||Bs==="ml-tensor")throw new Error("String tensor is not supported on GPU.");let Sn=[];for(let tn=0;tn<ys;tn++){let bs=Ie.getValue(xi+tn*De,"*"),Hu=Ie.getValue(xi+(tn+1)*De,"*"),Vu=tn===ys-1?void 0:Hu-bs;Sn.push(Ie.UTF8ToString(bs,Vu))}Ls.push([_n,ua,Sn,"cpu"])}else if(Bs==="gpu-buffer"&&ys>0){let Sn=Ie.jsepGetBuffer;if(!Sn)throw new Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');let tn=Sn(xi),bs=ri(wi,ys);if(bs===void 0||!na(_n))throw new Error(`Unsupported data type: ${_n}`);Wo=!0,Ls.push([_n,ua,{gpuBuffer:tn,download:Ie.jsepCreateDownloader(tn,bs,_n),dispose:()=>{Ie._OrtReleaseTensor(vs)!==0&&Ct("Can't release tensor.")}},"gpu-buffer"])}else if(Bs==="ml-tensor"&&ys>0){let Sn=Ie.webnnEnsureTensor,tn=Ie.webnnIsGraphInputOutputTypeSupported;if(!Sn||!tn)throw new Error('preferredLocation "ml-tensor" is not supported without using WebNN.');if(ri(wi,ys)===void 0||!Di(_n))throw new Error(`Unsupported data type: ${_n}`);if(!tn(se,_n,!1))throw new Error(`preferredLocation "ml-tensor" for ${_n} output is not supported by current WebNN Context.`);let bs=await Sn(se,xi,wi,ua,!1);Wo=!0,Ls.push([_n,ua,{mlTensor:bs,download:Ie.webnnCreateMLTensorDownloader(xi,_n),dispose:()=>{Ie.webnnReleaseTensorId(xi),Ie._OrtReleaseTensor(vs)}},"ml-tensor"])}else if(Bs==="ml-tensor-cpu-output"&&ys>0){let Sn=Ie.webnnCreateMLTensorDownloader(xi,_n)(),tn=Ls.length;Wo=!0,qu.push((async()=>{let bs=[tn,await Sn];return Ie.webnnReleaseTensorId(xi),Ie._OrtReleaseTensor(vs),bs})()),Ls.push([_n,ua,[],"cpu"])}else{let Sn=Is(_n),tn=new Sn(ys);new Uint8Array(tn.buffer,tn.byteOffset,tn.byteLength).set(Ie.HEAPU8.subarray(xi,xi+tn.byteLength)),Ls.push([_n,ua,tn,"cpu"])}}finally{Ie.stackRestore(jf),_n==="string"&&xi&&Ie._free(xi),Wo||Ie._OrtReleaseTensor(vs)}}Qe&&!$t&&(Ie._OrtClearBoundOutputs(Qe.handle)!==0&&Ct("Can't clear bound outputs."),gi.set(se,[nt,ct,it,Qe,$t,!1]));for(let[ur,vs]of await Promise.all(qu))Ls[ur][2]=vs;return lt("wasm ProcessOutputTensor"),Ls}finally{(Uu=Ie.webnnOnRunEnd)==null||Uu.call(Ie,nt),Ie.stackRestore(pr),rr.forEach(Dn=>Ie._OrtReleaseTensor(Dn)),Rr.forEach(Dn=>Ie._OrtReleaseTensor(Dn)),Lt.forEach(Dn=>Ie._free(Dn)),Pr!==0&&Ie._OrtReleaseRunOptions(Pr),tr.forEach(Dn=>Ie._free(Dn))}},vi=se=>{let he=zt(),we=gi.get(se);if(!we)throw new Error("invalid session id");let Pe=we[0],je=he._OrtEndProfiling(Pe);je===0&&Ct("Can't get an profile file name."),he._OrtFree(je)},vt=se=>{let he=[];for(let we of se){let Pe=we[2];!Array.isArray(Pe)&&"buffer"in Pe&&he.push(Pe.buffer)}return he}}),ze,et,Et,ir,cr,Br,Dr,mn,Gr,wn,Lr,gs,Aa,so,Ds,Cf,ao,oo,Bu=u(()=>{hr(),Se(),mi(),pi(),ze=()=>!!O.wasm.proxy&&typeof document<"u",Et=!1,ir=!1,cr=!1,mn=new Map,Gr=(se,he)=>{let we=mn.get(se);we?we.push(he):mn.set(se,[he])},wn=()=>{if(Et||!ir||cr||!et)throw new Error("worker not ready")},Lr=se=>{switch(se.data.type){case"init-wasm":Et=!1,se.data.err?(cr=!0,Dr[1](se.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 he=mn.get(se.data.type);se.data.err?he.shift()[1](se.data.err):he.shift()[0](se.data.out);break}}},gs=async()=>{if(!ir){if(Et)throw new Error("multiple calls to 'initWasm()' detected.");if(cr)throw new Error("previous call to 'initWasm()' failed.");if(Et=!0,ze())return new Promise((se,he)=>{et==null||et.terminate(),ra().then(([we,Pe])=>{try{et=Pe,et.onerror=We=>he(We),et.onmessage=Lr,Dr=[se,he];let je={type:"init-wasm",in:O};if(!je.in.wasm.wasmPaths&&we){let We=hi();We&&(je.in.wasm.wasmPaths=We)}et.postMessage(je),Br=we}catch(je){he(je)}},he)});try{await Ms(O.wasm),await qo(O),ir=!0}catch(se){throw cr=!0,se}finally{Et=!1}}},Aa=async se=>{if(ze())return wn(),new Promise((he,we)=>{Gr("init-ep",[he,we]);let Pe={type:"init-ep",in:{epName:se,env:O}};et.postMessage(Pe)});await sa(O,se)},so=async se=>ze()?(wn(),new Promise((he,we)=>{Gr("copy-from",[he,we]);let Pe={type:"copy-from",in:{buffer:se}};et.postMessage(Pe,[se.buffer])})):lr(se),Ds=async(se,he)=>{if(ze()){if(he!=null&&he.preferredOutputLocation)throw new Error('session option "preferredOutputLocation" is not supported for proxy.');return wn(),new Promise((we,Pe)=>{Gr("create",[we,Pe]);let je={type:"create",in:{model:se,options:{...he}}},We=[];se instanceof Uint8Array&&We.push(se.buffer),et.postMessage(je,We)})}else return Bi(se,he)},Cf=async se=>{if(ze())return wn(),new Promise((he,we)=>{Gr("release",[he,we]);let Pe={type:"release",in:se};et.postMessage(Pe)});Ta(se)},ao=async(se,he,we,Pe,je,We)=>{if(ze()){if(we.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)=>{Gr("run",[Ie,De]);let Ve=we,nt={type:"run",in:{sessionId:se,inputIndices:he,inputs:Ve,outputIndices:Pe,options:We}};et.postMessage(nt,vt(Ve))})}else return Ze(se,he,we,Pe,je,We)},oo=async se=>{if(ze())return wn(),new Promise((he,we)=>{Gr("end-profiling",[he,we]);let Pe={type:"end-profiling",in:se};et.postMessage(Pe)});vi(se)}}),Ec,lo,$l,Tc=u(()=>{hr(),Bu(),Ft(),Rn(),ia(),Ec=(se,he)=>{switch(se.location){case"cpu":return[se.type,se.dims,se.data,"cpu"];case"gpu-buffer":return[se.type,se.dims,{gpuBuffer:se.gpuBuffer},"gpu-buffer"];case"ml-tensor":return[se.type,se.dims,{mlTensor:se.mlTensor},"ml-tensor"];default:throw new Error(`invalid data location: ${se.location} for ${he()}`)}},lo=se=>{switch(se[3]){case"cpu":return new ge(se[0],se[2],se[1]);case"gpu-buffer":{let he=se[0];if(!na(he))throw new Error(`not supported data type: ${he} for deserializing GPU tensor`);let{gpuBuffer:we,download:Pe,dispose:je}=se[2];return ge.fromGpuBuffer(we,{dataType:he,dims:se[1],download:Pe,dispose:je})}case"ml-tensor":{let he=se[0];if(!Di(he))throw new Error(`not supported data type: ${he} for deserializing MLTensor tensor`);let{mlTensor:we,download:Pe,dispose:je}=se[2];return ge.fromMLTensor(we,{dataType:he,dims:se[1],download:Pe,dispose:je})}default:throw new Error(`invalid data location: ${se[3]}`)}},$l=class{async fetchModelAndCopyToWasmMemory(se){return so(await an(se))}async loadModel(se,he){Le();let we;typeof se=="string"?we=await this.fetchModelAndCopyToWasmMemory(se):we=se,[this.sessionId,this.inputNames,this.outputNames,this.inputMetadata,this.outputMetadata]=await Ds(we,he),Ue()}async dispose(){return Cf(this.sessionId)}async run(se,he,we){Le();let Pe=[],je=[];Object.entries(se).forEach(it=>{let Qe=it[0],$t=it[1],qe=this.inputNames.indexOf(Qe);if(qe===-1)throw new Error(`invalid input '${Qe}'`);Pe.push($t),je.push(qe)});let We=[],Ie=[];Object.entries(he).forEach(it=>{let Qe=it[0],$t=it[1],qe=this.outputNames.indexOf(Qe);if(qe===-1)throw new Error(`invalid output '${Qe}'`);We.push($t),Ie.push(qe)});let De=Pe.map((it,Qe)=>Ec(it,()=>`input "${this.inputNames[je[Qe]]}"`)),Ve=We.map((it,Qe)=>it?Ec(it,()=>`output "${this.outputNames[Ie[Qe]]}"`):null),nt=await ao(this.sessionId,je,De,Ie,Ve,we),ct={};for(let it=0;it<nt.length;it++)ct[this.outputNames[Ie[it]]]=We[it]??lo(nt[it]);return Ue(),ct}startProfiling(){}endProfiling(){oo(this.sessionId)}}}),oa={};f(oa,{OnnxruntimeWebAssemblyBackend:()=>la,initializeFlags:()=>$a,wasmBackend:()=>co});var $a,la,co,zu=u(()=>{hr(),Bu(),Tc(),$a=()=>{(typeof O.wasm.initTimeout!="number"||O.wasm.initTimeout<0)&&(O.wasm.initTimeout=0);let se=O.wasm.simd;if(typeof se!="boolean"&&se!==void 0&&se!=="fixed"&&se!=="relaxed"&&(console.warn(`Property "env.wasm.simd" is set to unknown value "${se}". Reset it to \`false\` and ignore SIMD feature checking.`),O.wasm.simd=!1),typeof O.wasm.proxy!="boolean"&&(O.wasm.proxy=!1),typeof O.wasm.trace!="boolean"&&(O.wasm.trace=!1),typeof O.wasm.numThreads!="number"||!Number.isInteger(O.wasm.numThreads)||O.wasm.numThreads<=0)if(typeof self<"u"&&!self.crossOriginIsolated)O.wasm.numThreads=1;else{let he=typeof navigator>"u"?l("node:os").cpus().length:navigator.hardwareConcurrency;O.wasm.numThreads=Math.min(4,Math.ceil((he||1)/2))}},la=class{async init(se){$a(),await gs(),await Aa(se)}async createInferenceSessionHandler(se,he){let we=new $l;return await we.loadModel(se,he),we}},co=new la}),Fu={};f(Fu,{InferenceSession:()=>Vt,TRACE:()=>Te,TRACE_EVENT_BEGIN:()=>st,TRACE_EVENT_END:()=>lt,TRACE_FUNC_BEGIN:()=>Le,TRACE_FUNC_END:()=>Ue,Tensor:()=>ge,default:()=>$c,env:()=>O,registerBackend:()=>k}),hr(),hr(),hr();var Ac="1.26.0",$c=Zn;{let se=(zu(),h(oa)).wasmBackend;k("cpu",se,10),k("wasm",se,10)}return Object.defineProperty(O.versions,"web",{value:Ac,enumerable:!0}),h(Fu)})();e.exports=n})(C1)),C1.exports}var hN;function Iq(){return hN||(hN=1,(function(e){var r=ec&&ec.__createBinding||(Object.create?(function(C,E,T,$){$===void 0&&($=T);var N=Object.getOwnPropertyDescriptor(E,T);(!N||("get"in N?!E.__esModule:N.writable||N.configurable))&&(N={enumerable:!0,get:function(){return E[T]}}),Object.defineProperty(C,$,N)}):(function(C,E,T,$){$===void 0&&($=T),C[$]=E[T]})),n=ec&&ec.__setModuleDefault||(Object.create?(function(C,E){Object.defineProperty(C,"default",{enumerable:!0,value:E})}):function(C,E){C.default=E}),i=ec&&ec.__importStar||function(C){if(C&&C.__esModule)return C;var E={};if(C!=null)for(var T in C)T!=="default"&&Object.prototype.hasOwnProperty.call(C,T)&&r(E,C,T);return n(E,C),E};Object.defineProperty(e,"__esModule",{value:!0}),e.MicVAD=e.getDefaultRealTimeVADOptions=e.ort=e.DEFAULT_MODEL=void 0;const s=i(Mq()),a=FT(),c=UT(),l=ab(),u=f_(),f=E4(),m=T4();e.DEFAULT_MODEL="legacy",e.ort=s;const h="vad.worklet.bundle.min.js",y="silero_vad_v5.onnx",x="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 E=>{E.getTracks().forEach(T=>{T.stop()})},resumeStream:async()=>await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}}),ortConfig:E=>{E.env.logLevel="error"},startOnLoad:!0,processorType:"auto"});e.getDefaultRealTimeVADOptions=k;const S=C=>"audioWorklet"in C&&typeof AudioWorkletNode=="function"?"AudioWorklet":"ScriptProcessor";async function b(C,E,T,$,N){await T.audioWorklet.addModule(C),E.processorOptions={...E.processorOptions??{},frameSamples:$};const O=new AudioWorkletNode(T,"vad-helper-worklet",E);return O.port.onmessage=async M=>{const U=M.data;if(!(typeof U=="object"&&U&&"message"in U)){console.error("Invalid message event",U);return}switch(U.message){case u.Message.AudioFrame:{if(!("data"in U&&U.data instanceof ArrayBuffer)){console.log("Audio frame message has no data");return}const H=new Float32Array(U.data);await N(H);break}}},O}async function _(C,E,T){const $=new m.Resampler({nativeSampleRate:C.sampleRate,targetSampleRate:16e3,targetFrameSize:E});l.log.debug("using script processor");const O=C.createScriptProcessor(4096,1,1);let M=!1;return O.onaudioprocess=async U=>{if(!M){M=!0;try{const H=U.inputBuffer.getChannelData(0);U.outputBuffer.getChannelData(0).fill(0);const z=$.process(H);for(const F of z)await T(F)}catch(H){console.error("Error processing audio:",H)}finally{M=!1}}},O.connect(C.destination),O}class w{constructor(E,T,$,N,O=!1,M=null,U=null,H=null,V=null,z=null,F=null,Y="uninitialized",te=!1){this.options=E,this.frameProcessor=T,this.model=$,this.frameSamples=N,this.listening=O,this.errored=M,this._stream=U,this._audioContext=H,this._vadNode=V,this._mediaStreamAudioSourceNode=z,this._audioProcessorAdapterType=F,this.initializationState=Y,this.ownsAudioContext=te,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=le=>{this.initializationState="errored",this.errored=le},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(le){throw le instanceof Error?this.setErrored(le.message):this.setErrored(String(le)),le}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 b(this.options.baseAssetPath+h,this.options.workletOptions,this._audioContext,this.frameSamples,this.processFrame);break;case"ScriptProcessor":this._vadNode=await _(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:le,audioContext:pe,vadNode:X}=this.getAudioInstances();this._stream=await this.options.resumeStream(le);const Q=new MediaStreamAudioSourceNode(pe,{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:le,mediaStreamAudioSourceNode:pe}=this.getAudioInstances();await this.options.pauseStream(le),pe.disconnect(),this.frameProcessor.pause(this.handleFrameProcessorEvent)},this.destroy=async()=>{var pe;l.log.debug("destroy called"),this.initializationState="destroyed";const{vadNode:le}=this.getAudioInstances();le instanceof AudioWorkletNode&&le.port.postMessage(u.Message.SpeechStop),this.listening&&await this.pause(),await this.model.release(),this.ownsAudioContext&&await((pe=this._audioContext)==null?void 0:pe.close())},this.setOptions=le=>{this.frameProcessor.setOptions(le)},this.processFrame=async le=>{await this.frameProcessor.process(le,this.handleFrameProcessorEvent)},this.handleFrameProcessorEvent=le=>{switch(le.msg){case u.Message.FrameProcessed:this.options.onFrameProcessed(le.probs,le.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(le.audio);break}}}static async new(E={}){const T={...(0,e.getDefaultRealTimeVADOptions)(E.model??e.DEFAULT_MODEL),...E};(0,c.validateOptions)(T),e.ort.env.wasm.wasmPaths=T.onnxWASMBasePath,T.ortConfig!==void 0&&T.ortConfig(e.ort);const $=T.model==="v5"?y:x,N=T.baseAssetPath+$,O=T.model==="v5"?f.SileroV5.new:f.SileroLegacy.new;let M;try{M=await O(e.ort,()=>(0,a.defaultModelFetcher)(N))}catch(F){throw console.error(`Encountered an error while loading model file ${N}`),F}const U=T.model==="v5"?512:1536,H=U/16,V=new c.FrameProcessor(M.process,M.reset_state,{positiveSpeechThreshold:T.positiveSpeechThreshold,negativeSpeechThreshold:T.negativeSpeechThreshold,redemptionMs:T.redemptionMs,preSpeechPadMs:T.preSpeechPadMs,minSpeechMs:T.minSpeechMs,submitUserSpeechOnPause:T.submitUserSpeechOnPause},H),z=new w(T,V,M,U);if(T.startOnLoad)try{await z.start()}catch(F){throw console.error("Error starting micVad",F),F}return z}}e.MicVAD=w})(ec)),ec}var pN;function Dq(){return pN||(pN=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=k4();Object.defineProperty(e,"baseAssetPath",{enumerable:!0,get:function(){return r.baseAssetPath}});var n=FT();Object.defineProperty(e,"defaultModelFetcher",{enumerable:!0,get:function(){return n.defaultModelFetcher}});var i=UT();Object.defineProperty(e,"FrameProcessor",{enumerable:!0,get:function(){return i.FrameProcessor}});var s=f_();Object.defineProperty(e,"Message",{enumerable:!0,get:function(){return s.Message}});var a=Pq();Object.defineProperty(e,"NonRealTimeVAD",{enumerable:!0,get:function(){return a.NonRealTimeVAD}});const c=Rq();e.utils={audioFileToArray:c.audioFileToArray,minFramesForTargetMS:c.minFramesForTargetMS,arrayBufferToBase64:c.arrayBufferToBase64,encodeWAV:c.encodeWAV};var l=Iq();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}})})(_1)),_1}var Lq=Dq();function Sx(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 mt={debug:(e,r,n)=>Sx(e,"debug",r,n),info:(e,r,n)=>Sx(e,"info",r,n),warn:(e,r,n)=>Sx(e,"warn",r,n),error:(e,r,n)=>Sx(e,"error",r,n)},$4=16e3,Bq=6,ip=$4*Bq,zq=400,Fq=$4*zq/1e3,mN=300,gN=2e3,vN=1500,yN=3e3,Uq=600,N4=.5,O4=.35,bN=.85,xN=.7;let Ys=null,gl=!1,Ts=!1;const _j=new Set;function kx(e){for(const r of Array.from(_j))try{r(e)}catch(n){mt.warn("speech","workerDeath listener threw",{error:n instanceof Error?n.message:String(n)})}}let j1=0;const wN=2;let Cp=!1,P4=!1;function R4(e){e.addEventListener("message",r=>{var i;if(((i=r.data)==null?void 0:i.type)!=="log")return;const n=r.data.level||"info";mt[n]("whisperWorker",r.data.message??"",r.data.meta)}),e.addEventListener("error",r=>{mt.error("whisperWorker","worker error event (fatal)",{message:r.message,filename:r.filename,lineno:r.lineno}),qq(`error:${r.message||"unknown"}`)})}function Dw(){return Ys||(Ys=new Worker(new URL(""+new URL("whisperWorker-Dbia1OpC.js",import.meta.url).href,import.meta.url),{type:"module"}),R4(Ys),mt.info("speech","worker spawned"),Ys)}let Cx=!1;function qq(e){if(!Cp){if(Cx){mt.warn("speech","respawnWorker: already in flight, ignoring",{reason:e});return}if(Cx=!0,j1+=1,P4=!0,mt.warn("speech","respawnWorker: starting",{reason:e,attempt:j1}),kx({reason:e,respawned:!1,finalOnly:!0}),j1>wN){if(Cp=!0,mt.error("speech","respawnWorker: limit exceeded, disabling speech",{limit:wN}),Ys)try{Ys.terminate()}catch{}Ys=null,gl=!1,Ts=!1,kx({reason:"respawn-limit-exceeded",respawned:!1,finalOnly:!0}),Cx=!1;return}if(Ys)try{Ys.terminate()}catch{}Ys=null,gl=!1,Ts=!1;try{Ys=new Worker(new URL(""+new URL("whisperWorker-Dbia1OpC.js",import.meta.url).href,import.meta.url),{type:"module"}),R4(Ys),Ts=!0,Ys.postMessage({type:"load"}),mt.info("speech","respawnWorker: new worker spawned, load posted"),kx({reason:e,respawned:!0,finalOnly:!0})}catch(r){Cp=!0,mt.error("speech","respawnWorker: spawn failed, disabling speech",{error:r instanceof Error?r.message:String(r)}),kx({reason:"spawn-failed",respawned:!1,finalOnly:!0})}finally{Cx=!1}}}function Wq(e,r){if(gl||Ts)return;Ts=!0;const n=Dw();mt.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"&&(gl=!0,Ts=!1,mt.info("speech","preloadModel: ready"),n.removeEventListener("message",i))):s.data.type==="progress"?r==null||r(s.data.pct):s.data.type==="error"&&(Ts=!1,mt.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 Hq(){mt.info("speech","resetModel: clearing load flags"),gl=!1,Ts=!1}function qT(){var e;return typeof Worker<"u"&&!!((e=navigator.mediaDevices)!=null&&e.getUserMedia)&&typeof AudioWorkletNode<"u"}function Vq(e){const r=Dw();return!gl&&!Ts&&(Ts=!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"&&(gl=!0,Ts=!1)};r.addEventListener("message",s),r.postMessage({type:"transcribe",audio:e},[e.buffer])})}function Gq(e){let r=Dw(),n=!1,i=null,s=null,a=null,c=null,l=null;const u=[],f=new Set;let m=null,h=0,y=!1,x=0,k=!1,S=!1,b=0,_=0,w=0,C=-1,E=mN,T=0,$=null,N="",O="",M=!1,U=0;function H(ae,me){const _e=Math.min(ae.length,me.length);let Ne=0;for(;Ne<_e&&ae.charCodeAt(Ne)===me.charCodeAt(Ne);)Ne++;return Ne}function V(ae){const me=H(N,ae);return N=ae,me>O.length&&(O=ae.slice(0,me)),O.length>ae.length&&(O=ae),O}const z=()=>(m||(m=new Float32Array(ip)),m),F=()=>{h=0},Y=ae=>{const me=z(),_e=ae.length;if(_e>=ip){me.set(ae.subarray(_e-ip)),h=ip;return}if(h+_e<=ip){me.set(ae,h),h+=_e;return}const Ne=h+_e-ip;me.copyWithin(0,Ne,h),h-=Ne,me.set(ae,h),h+=_e},te=()=>{$&&(clearTimeout($),$=null)},le=()=>{te(),y=!1,k=!1,S=!1,E=mN,N="",O="",M=!1,U=0,F()},pe=()=>{if(n||!y||S||k||$)return;if(h<Fq){$=setTimeout(()=>{$=null,pe()},E);return}const ae=performance.now()-b;if(ae<E&&b!==0){$=setTimeout(()=>{$=null,pe()},E-ae);return}if(P4||Cp||e.partialsEnabled&&!e.partialsEnabled())return;const me=z(),_e=new Float32Array(h);_e.set(me.subarray(0,h)),_+=1,w=_,k=!0,T=performance.now(),b=T,r.postMessage({type:"transcribe-partial",audio:_e,seq:_},[_e.buffer])},X=ae=>ae.length===0?Promise.resolve():Cp?(mt.warn("speech","transcribeAudio: speech disabled (worker respawn limit hit)"),n||e.onError("Speech recognition disabled — please reload the app."),Promise.resolve()):new Promise(me=>{u.push(me),_+=1;const _e=_;C=_e,r.postMessage({type:"transcribe",audio:ae,seq:_e},[ae.buffer])}),Q=ae=>{const me=X(ae);return f.add(me),me.finally(()=>{f.delete(me)}),me},J=ae=>{var me,_e,Ne,xe,ie;if(ae.data.type==="result"){const ce=ae.data.text,ge=ae.data.seq??0;ge&&ge<C&&mt.warn("speech","result: seq below latestFinalSeq (delivering anyway)",{seq:ge,latestFinalSeq:C}),!n&&ce&&e.onFinal(ce),(me=u.shift())==null||me()}else if(ae.data.type==="partial"){const ce=ae.data.seq??0,ge=ae.data.text??"",Ae=performance.now()-T;k=!1,Ae>=yN?(S=!0,mt.warn("speech","partials.disabled.budget",{elapsedMs:Math.round(Ae),seq:ce})):Ae>=vN&&(E=Math.min(E*2,gN),mt.warn("speech","partials.slowdown",{elapsedMs:Math.round(Ae),newIntervalMs:E,seq:ce})),M||(M=!0,Ae>Uq&&E<500&&(E=500,mt.info("speech","partials.probe.slow_host",{elapsedMs:Math.round(Ae),newIntervalMs:500})));const Te=ce!==w||ce<=C;if(!n&&!Te&&ge){const Me=V(ge);Me&&((_e=e.onPartial)==null||_e.call(e,Me),U===0&&(U=performance.now(),mt.info("speech","partial.first",{msSinceSpeechStart:Math.round(U-x)})))}pe()}else if(ae.data.type==="partial-error"){const ce=performance.now()-T;k=!1,ce>=yN?(S=!0,mt.warn("speech","partials.disabled.budget (after error)",{elapsedMs:Math.round(ce),seq:ae.data.seq})):ce>=vN&&(E=Math.min(E*2,gN),mt.warn("speech","partials.slowdown (after error)",{elapsedMs:Math.round(ce),newIntervalMs:E,seq:ae.data.seq})),mt.warn("speech","partial encode failed",{error:ae.data.error,seq:ae.data.seq}),pe()}else ae.data.type==="error"?(n||e.onError(ae.data.error),(Ne=u.shift())==null||Ne()):ae.data.type==="status"?(n||(xe=e.onModelStatus)==null||xe.call(e,ae.data.status,ae.data.message),ae.data.status==="ready"&&(gl=!0,Ts=!1)):ae.data.type==="progress"&&(n||(ie=e.onProgress)==null||ie.call(e,ae.data.pct))};r.addEventListener("message",J);const ee=ae=>{var me,_e;if(!n){for(mt.warn("speech","createRecognition: worker death event",ae),(me=e.onStatusChange)==null||me.call(e,"restarting");u.length;)(_e=u.shift())==null||_e();if(f.clear(),te(),k=!1,ae.respawned){try{r.removeEventListener("message",J)}catch{}r=Dw(),r.addEventListener("message",J)}}};return _j.add(ee),{start:async()=>{if(!n){if(Cp){e.onError("Speech recognition disabled — please reload the app.");return}!gl&&!Ts&&(Ts=!0,mt.info("speech","createRecognition.start: triggering model load"),r.postMessage({type:"load"})),mt.info("speech","createRecognition.start: initializing VAD",{modelReady:gl,modelLoading:Ts});try{const ae=new URL("vad/",document.baseURI).href,me=e.inputDeviceId||null,_e={channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0};me&&(_e.deviceId={exact:me}),mt.info("speech","getUserMedia",{hasDeviceId:!!me,deviceIdPrefix:me?me.slice(0,8):null});const Ne=await navigator.mediaDevices.getUserMedia({audio:_e});s=Ne,a=new AudioContext;for(const xe of Ne.getAudioTracks())xe.addEventListener("ended",()=>{n||(mt.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(xe){mt.warn("speech","analyser init failed",{error:xe instanceof Error?xe.message:String(xe)}),l=null,c=null}i=await Lq.MicVAD.new({audioContext:a,getStream:async()=>Ne,resumeStream:async()=>Ne,pauseStream:async()=>{},baseAssetPath:ae,onnxWASMBasePath:ae,model:"v5",positiveSpeechThreshold:N4,negativeSpeechThreshold:O4,minSpeechMs:300,redemptionMs:1500,preSpeechPadMs:300,submitUserSpeechOnPause:!0,onFrameProcessed:(xe,ie)=>{var ce;n||((ce=e.onFrame)==null||ce.call(e,xe),y&&(Y(ie),pe()))},onSpeechStart:()=>{var xe;n||(le(),y=!0,x=performance.now(),(xe=e.onSpeechStart)==null||xe.call(e))},onSpeechEnd:xe=>{var ie;n||((ie=e.onStatusChange)==null||ie.call(e,"transcribing"),le(),Q(xe))},onVADMisfire:()=>{var xe,ie;n||((xe=e.onStatusChange)==null||xe.call(e,"idle"),le(),(ie=e.onMisfire)==null||ie.call(e))}}),i.start()}catch(ae){const me=ae instanceof Error?ae.message:"Microphone access denied",_e=ae instanceof Error?ae.stack:"";if(mt.error("speech","createRecognition.start: VAD init failed",{error:me,stack:_e}),c){try{c.disconnect()}catch{}c=null}if(l){try{l.disconnect()}catch{}l=null}if(s){try{s.getTracks().forEach(Ne=>Ne.stop())}catch{}s=null}if(a){try{await a.close()}catch{}a=null}e.onError(me)}}},stop:async()=>{if(i)try{await i.pause()}catch{}for(le();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(ae=>ae.stop())}catch{}s=null}if(a){try{await a.close()}catch{}a=null}},setVadThresholds:(ae,me)=>{if(i)try{i.setOptions({positiveSpeechThreshold:ae,negativeSpeechThreshold:me})}catch(_e){mt.warn("speech","setVadThresholds failed",{error:_e instanceof Error?_e.message:String(_e)})}},getAnalyser:()=>c,destroy:()=>{if(n=!0,le(),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(ae=>ae.stop())}catch{}s=null}_j.delete(ee),r.removeEventListener("message",J)}}}let ny=null;const Sj=new Set,kj=new Set;function Kq(){for(const e of Sj)try{e()}catch{}}function Cj(){for(const e of kj)try{e()}catch{}}function Xq(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 Yq(e){if(!window.speechSynthesis)return;const r=Xq(e);if(!r)return;const n=new SpeechSynthesisUtterance(r);n.rate=1,n.pitch=1,n.onstart=()=>{ny=performance.now(),Kq()},n.onend=()=>{!window.speechSynthesis.speaking&&!window.speechSynthesis.pending&&(ny=null,Cj())},n.onerror=i=>{i.error!=="canceled"&&!window.speechSynthesis.speaking&&!window.speechSynthesis.pending&&(ny=null,Cj())},window.speechSynthesis.speak(n)}function M4(){window.speechSynthesis&&(window.speechSynthesis.cancel(),ny=null,Cj())}function I4(){var e;return((e=window.speechSynthesis)==null?void 0:e.speaking)??!1}function Jq(){return ny}function Zq(e){return Sj.add(e),()=>{Sj.delete(e)}}function Qq(e){return kj.add(e),()=>{kj.delete(e)}}function eW(e){I4()&&(e.setVadThresholds(bN,xN),mt.info("voice","tts.duck.on",{reason:"already-speaking-on-attach"}));const r=Zq(()=>{e.setVadThresholds(bN,xN),mt.info("voice","tts.duck.on")}),n=Qq(()=>{e.setVadThresholds(N4,O4),mt.info("voice","tts.duck.off")});return()=>{r(),n()}}const tW=[{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 rW(e){const r=e.trim();return tW.find(n=>n.match.test(r))??null}const nW=4e4;let Vd=null;function jp(){Vd&&clearTimeout(Vd),Vd=setTimeout(()=>{Vd=null,Mt.getState().stopRecording()},nW)}function jx(){Vd&&(clearTimeout(Vd),Vd=null)}let Su=null,xu=null;const iW=.04,sW=.3;let Lw=0,jj=0;function aW(e){xu!==null&&cancelAnimationFrame(xu);const r=()=>{if(Su===null||Mt.getState().submitCountdownStartAt===null){xu=null;return}const n=performance.now();if(n-jj<200&&Lw>sW){const s=n-e;mt.info("voice","submit.preempted_by_voice",{reason:"vad",prob:Lw.toFixed(2),msIntoCountdown:Math.round(s)}),mu(),jp();return}const i=D4();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>iW){const l=n-e;mt.info("voice","submit.preempted_by_voice",{reason:"rms",rms:c.toFixed(3),msIntoCountdown:Math.round(l)}),mu(),jp();return}}xu=requestAnimationFrame(r)};xu=requestAnimationFrame(r)}function oW(e){Su&&clearTimeout(Su);const r=Mt.getState().submitDelayMs,n=performance.now();Mt.setState({submitCountdownStartAt:n}),Su=setTimeout(()=>{Su=null,Mt.setState({submitCountdownStartAt:null});try{window.api.pty.write({tabId:e,data:"\r"})}catch(i){mt.warn("voice","submit pty.write failed",{error:i instanceof Error?i.message:String(i)})}jp()},r),aW(n)}function mu(){xu!==null&&(cancelAnimationFrame(xu),xu=null),Su&&(clearTimeout(Su),Su=null),Mt.getState().submitCountdownStartAt!==null&&Mt.setState({submitCountdownStartAt:null})}let Ai=null,ls=null;function D4(){var e;return((e=Ai==null?void 0:Ai.getAnalyser)==null?void 0:e.call(Ai))??null}const Ex=1e4;let iy=null;function Tx(){iy&&(clearTimeout(iy),iy=null)}let _w=null,Sw=null;function Ax(){_w=null,Sw&&(Sw(),Sw=null)}const lW=1500,cW=9e4;let $x=0,kw=null,Ej=-1;function Nx(){kw&&(clearTimeout(kw),kw=null,Ej=-1)}const uW=new Set(["you","You","Thank you.","Thanks for watching.","Thanks for watching!","Thank you for watching.","Thank you for watching!",".","Bye.","Bye!"]),Mt=En((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;mt.info("voice","initModel: kicking off preload"),e({modelStatus:"loading",error:null,errorKind:null,loadingProgress:0});const n=++$x,i=()=>{n===$x&&(Nx(),Ej=n,kw=setTimeout(()=>{Ej===n&&r().modelStatus==="loading"&&(mt.warn("voice","mic.gate.timeout: no progress within 90s"),e({modelStatus:"error",error:"Model load timed out",errorKind:"timeout"}))},cW))};i(),Wq((s,a)=>{n===$x&&(s==="ready"?(Nx(),mt.info("voice","modelStatus -> ready"),e({modelStatus:"ready",loadingProgress:100,errorKind:null})):s==="error"?(Nx(),mt.error("voice","modelStatus -> error",{msg:a}),e({modelStatus:"error",error:a,errorKind:"load"})):(i(),e({modelStatus:"loading"})))},s=>{n===$x&&(i(),e({loadingProgress:Math.round(s)}))})},resetAndRetryModel:()=>{mt.info("voice","mic.gate.retry"),Nx(),Hq(),e({modelStatus:"idle",error:null,errorKind:null,loadingProgress:0}),r().initModel()},startRecording:n=>{if(r().isRecording)return;if(Ai){mt.warn("voice","startRecording: prior handle still draining, ignoring");return}if(!qT()){e({error:"Microphone or Web Worker not available",errorKind:"recording"});return}const i=s=>{try{const a=Gq({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=>{Lw=c.isSpeech,jj=performance.now()},onSpeechStart:()=>{if(e({statusPill:"listening",lastPartial:""}),jx(),mu(),I4()){const l=Jq(),u=l!==null?performance.now()-l:null;M4(),e({lastBargeInAt:performance.now()}),mt.info("voice","barge-in",{tabId:n,utteranceOffsetMs:u})}else mt.debug("voice","barge-in.no-op",{tabId:n})},onMisfire:()=>{e({lastPartial:"",statusPill:"idle"}),jp();const c=r().lastBargeInAt;c!==null&&performance.now()-c<600&&mt.warn("voice","barge-in.misfire",{tabId:n,sinceBargeInMs:Math.round(performance.now()-c)})},onFinal:c=>{jp();const l=c.trim();if(!l||uW.has(l)){e({lastTranscript:"",lastPartial:"",statusPill:"idle"});return}const u=rW(l);if(u){mt.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&&oW(n);const f=window;f.__transcripts&&(f.__transcripts.push({tabId:n,text:l}),f.__transcripts.length>500&&f.__transcripts.shift())},onError:c=>{mt.error("voice","recognition error",{err:c}),mu(),e({error:c,errorKind:"recording",isRecording:!1,lastPartial:"",statusPill:"idle"}),ls==null||ls(),ls=null,jx(),Ai==null||Ai.destroy(),Ai=null,rt.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)})});Ai=a,e({isRecording:!0,error:null,lastTranscript:"",lastPartial:"",statusPill:"listening"}),jp(),a.start().then(()=>{Ai===a&&(ls==null||ls(),ls=eW(a))}).catch(c=>{const l=c instanceof Error?c.message:String(c);mt.error("voice","handle.start() failed",{error:l}),rt.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=>{mt.warn("voice","getDevicePref failed; using default device",{error:s instanceof Error?s.message:String(s)}),i(null)})},stopRecording:()=>{const n=Ai;n&&(jx(),mu(),Lw=0,jj=0,ls==null||ls(),ls=null,e({isRecording:!1,lastTranscript:"",lastPartial:"",statusPill:"idle"}),n.stop().finally(()=>{n.destroy(),Ai===n&&(Ai=null),r().hotkeyState==="stopping"&&(Tx(),e({hotkeyState:"idle"}))}))},restartWithDevice:async()=>{if(!r().isRecording)return;const n=Ai;if(!n)return;jx(),ls==null||ls(),ls=null,e({isRecording:!1,lastTranscript:"",lastPartial:""});try{await n.stop()}catch(a){mt.warn("voice","restartWithDevice: drain rejected",{error:a instanceof Error?a.message:String(a)})}n.destroy(),Ai===n&&(Ai=null);const{useSessions:i}=await sb(async()=>{const{useSessions:a}=await Promise.resolve().then(()=>vq);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&&(mt.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"?mt.warn("voice-turn","voice-turn.load_failed"):n==="runtime_error"?mt.warn("voice-turn","voice-turn.runtime_error"):n==="disabled"&&mt.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}=Tj(c);if(n==="down"){if(u==="error"||u==="load-timeout"){c.resetAndRetryModel(),mt.info("voice-hotkey","down.retry",{source:i,reason:u});return}if(!l&&u!=="loading"){mt.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"}),Tx(),iy=setTimeout(()=>{r().hotkeyState==="stopping"&&(mt.warn("voice-hotkey","drain-timeout",{durationMs:Ex}),e({hotkeyState:"aborted"}),setTimeout(()=>{r().hotkeyState==="aborted"&&e({hotkeyState:"idle"})},0))},Ex),c.stopRecording());return}if(u==="loading"){c.hotkeyState!=="armed"&&(e({hotkeyState:"armed"}),mt.info("voice-hotkey","armed",{source:i,modelStatus:c.modelStatus})),Ax(),_w={tabId:a,source:i,mode:s},Sw=Mt.subscribe((f,m)=>{if(_w&&f.modelStatus==="ready"&&m.modelStatus!=="ready"&&f.hotkeyState==="armed"){const h=_w;if(Ax(),!h.tabId){mt.warn("voice-hotkey","armed-promote-no-tab",{source:h.source}),e({hotkeyState:"idle"});return}mt.info("voice-hotkey","armed-promote",h),e({hotkeyState:"recording"}),Mt.getState().startRecording(h.tabId)}});return}if(!a){mt.warn("voice-hotkey","no-active-tab",{source:i});return}mt.info("voice-hotkey","start",{source:i,mode:s,tabId:a}),c.startRecording(a),r().isRecording?e({hotkeyState:"recording"}):(mt.warn("voice-hotkey","start: recording did not engage",{errorKind:r().errorKind}),e({hotkeyState:"idle"}));return}if(!(s!=="hold"||i==="global")){if(c.hotkeyState==="armed"){Ax(),mt.info("voice-hotkey","miss-model-loading-armed-up"),e({hotkeyState:"idle"});return}c.hotkeyState==="recording"&&(e({hotkeyState:"stopping"}),Tx(),iy=setTimeout(()=>{r().hotkeyState==="stopping"&&(mt.warn("voice-hotkey","drain-timeout",{durationMs:Ex}),e({hotkeyState:"aborted"}),setTimeout(()=>{r().hotkeyState==="aborted"&&e({hotkeyState:"idle"})},0))},Ex),c.stopRecording())}},destroyHotkey:()=>{const n=r();if(Ax(),mu(),n.hotkeyState==="recording"){mt.warn("voice-hotkey","destroyed-mid-recording"),e({hotkeyState:"destroyed"});try{n.stopRecording()}catch{}}else(n.hotkeyState==="armed"||n.hotkeyState==="stopping")&&(Tx(),e({hotkeyState:"destroyed"}))}})),dW=e=>({isRecording:e.isRecording,statusPill:e.statusPill,lastPartial:e.lastPartial,lastTranscript:e.lastTranscript,submitCountdownStartAt:e.submitCountdownStartAt}),Tj=e=>qT()?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=Mt,e.__transcripts=[]}function WT(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 fW=5e3,$u=En(()=>({snapshot:null,loaded:!1}));let _N=!1,SN=!1,uv;async function hW(){var e;if(!_N){_N=!0;try{const r=await WT(window.api.schedule.state(),fW,"schedule.state");$u.setState({snapshot:r,loaded:!0}),uv=((e=r.paused)==null?void 0:e.reason)??null}catch(r){if(!SN){SN=!0;const n=r instanceof Error?r.message:String(r);rt.error(`Scheduler state hydrate failed: ${n}`)}uv=null}window.api.schedule.onState(r=>{var i;const n=((i=r.paused)==null?void 0:i.reason)??null;uv!==void 0&&n!==uv&&(n==="auth"?rt.error("Scheduler paused: Claude sign-in expired or invalid. Restart the app or re-run `claude login`, then Resume."):n==="network"&&rt.error("Scheduler paused: billing endpoint unreachable. Will auto-resume in 30 minutes.")),uv=n,$u.setState({snapshot:r,loaded:!0})})}}const pW=6e4,mW=5e3,Ep=En(()=>({data:null,refreshing:!1}));let kN=!1,Cw=null,CN=null,jN=!1;async function HT(){Ep.setState({refreshing:!0});let e=pW;try{const r=await WT(window.api.billing.fetch(),mW,"billing.fetch");Ep.setState({data:r,refreshing:!1}),r.kind==="transient"?e=CN==="transient"?3e4:5e3:r.kind==="auth"&&(e=3e4),CN=r.kind}catch(r){if(Ep.setState({refreshing:!1}),!jN){jN=!0;const n=r instanceof Error?r.message:String(r);rt.warn(`Billing usage fetch failed: ${n}`)}}Cw=setTimeout(HT,e)}function gW(){kN||(kN=!0,HT())}function h_(e){return e?e.kind==="ok"||e.kind==="ok-stale"?e.data:e.kind==="auth"&&e.cached?e.cached:null:null}function Bw(){Cw!==null&&(clearTimeout(Cw),Cw=null),HT()}function dr({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 vW(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 EN=e=>Symbol.iterator in e,TN=e=>"entries"in e,AN=(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},yW=(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 bW(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:EN(e)&&EN(r)?TN(e)&&TN(r)?AN(e,r):yW(e,r):AN({entries:()=>Object.entries(e)},{entries:()=>Object.entries(r)})}function L4(e){const r=He.useRef(void 0);return n=>{const i=e(n);return bW(r.current,i)?r.current:r.current=i}}let $N=0;const xW=1e3;function wW(e){const r=performance.now();r-$N<xW||($N=r,mt.debug("voice","mic.gate.click_rejected",{reason:e}))}function B4(){const e=Mt(f=>f.isRecording),r=Mt(f=>f.error),n=Mt(f=>f.loadingProgress),i=Mt(L4(Tj)),s=()=>{const f=Mt.getState(),{canRecord:m,reason:h}=Tj(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 wW(h);const y=Nt.getState().activeTabId;y&&f.startRecording(y)},a=vW(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 _W(){const e=Mt(n=>n.ttsEnabled),r=Mt(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"})]})}const NN=[{key:"overview",label:"Home",icon:"home",hint:"Today's sessions + the 5-hour window"},{key:"terminal",label:"Terminal",icon:"terminal",hint:"Live Claude Code, in-app"},{key:"browser",label:"Browser",icon:"browser",hint:"Embedded dev browser — capture DOM, record click-sequences"},{key:"projects",label:"File Explorer",icon:"projects",hint:"Browse files + edit, per project"},{key:"subagents",label:"Subagents",icon:"hive",liveKind:"subagents",hint:"Fan out work: Hive · Orchestrate · Race · Boss"},{key:"scheduler",label:"Scheduler",icon:"scheduler",liveKind:"scheduler",hint:"Author PRDs + run them as claude -p jobs"},{key:"history",label:"History",icon:"history",hint:"Every session, ever — resumable"},{key:"usage",label:"Usage",icon:"usage",hint:"Tokens, cost, sessions per day"}],ON=[{key:"skills",label:"Skills",icon:"skills",hint:"Reusable instructions Claude loads"},{key:"plugins",label:"Plugins",icon:"plugins",hint:"Extensions for Claude Code"},{key:"mcp",label:"MCP Servers",icon:"mcp",hint:"External tools and integrations"},{key:"hooks",label:"Hooks",icon:"hooks",hint:"Run scripts on session events"},{key:"keybindings",label:"Keybindings",icon:"keys",hint:"Shortcuts you can override"},{key:"memory",label:"Memory",icon:"memory",hint:"Workspace memory store"},{key:"system-prompt",label:"System Prompt",icon:"system-prompt",hint:"Personality and behavior"},{key:"permissions",label:"Permissions",icon:"permissions",hint:"Allow / deny rules"},{key:"settings",label:"Settings",icon:"settings",hint:"Theme, voice, billing window"},{key:"remote",label:"Remote",icon:"remote",hint:"Web remote control — disabled by default"}],PN=[{key:"voice",label:"Voice",icon:"mic",hint:"Whisper transcription + push-to-talk"},{key:"repoviz",label:"Repo Viz",icon:"repoviz",hint:"Language + directory map"},{key:"search",label:"Search",icon:"global-search",hint:"⌘P file · ⌘⇧F content"}],Aj="sm.almanac.sidebarWidth",z4=180,F4=480,$j=252;function SW(){try{const e=parseInt(localStorage.getItem(Aj)??"",10);if(Number.isFinite(e))return Math.min(F4,Math.max(z4,e))}catch{}return $j}const kW=52,U4="sm.almanac.sidebarCollapsed";function CW(){try{return localStorage.getItem(U4)==="1"}catch{}return!1}const q4="sm.almanac.collapsedGroups";function jW(){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 EW(){const e=xw(a=>a.tabs),r=$u(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 TW({active:e,onNavigate:r,onNewSession:n}){const[i,s]=D.useState(()=>jW()),a=D.useCallback(w=>{s(C=>{const E=new Set(C);E.has(w)?E.delete(w):E.add(w);try{localStorage.setItem(q4,JSON.stringify(Array.from(E)))}catch{}return E})},[]),[c,l]=D.useState(()=>CW()),u=D.useCallback(()=>{l(w=>{const C=!w;try{localStorage.setItem(U4,C?"1":"0")}catch{}return C})},[]),f=Nt(w=>w.tabs),m=Nt(w=>w.activeTabId),h=f.find(w=>w.id===m)??null,y=EW(),[x,k]=D.useState(()=>SW()),S=D.useRef(x);S.current=x;const b=D.useCallback(w=>{w.preventDefault();const C=w.clientX,E=S.current;let T=E;const $=O=>{T=Math.min(F4,Math.max(z4,E+(O.clientX-C))),k(T)},N=()=>{window.removeEventListener("pointermove",$),window.removeEventListener("pointerup",N),document.body.style.cursor="",document.body.style.userSelect="";try{localStorage.setItem(Aj,String(T))}catch{}};window.addEventListener("pointermove",$),window.addEventListener("pointerup",N),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]),_=D.useCallback(()=>{k($j);try{localStorage.setItem(Aj,String($j))}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?kW:x},"data-testid":"tour-leftnav","aria-label":"Primary navigation",children:[o.jsx(AW,{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(E1,{label:"Workspace",collapsed:i.has("Workspace"),count:NN.length,onToggle:()=>a("Workspace")}),(c||!i.has("Workspace"))&&NN.map(w=>o.jsx(RN,{item:w,active:e===w.key,live:w.liveKind?y[w.liveKind]:!1,onClick:()=>r(w.key),rail:c},w.key)),!c&&o.jsx(E1,{label:"Configure",collapsed:i.has("Configure"),count:ON.length,onToggle:()=>a("Configure")}),(c||!i.has("Configure"))&&ON.map(w=>o.jsx(RN,{item:w,active:e===w.key,live:!1,onClick:()=>r(w.key),rail:c},w.key)),!c&&o.jsx(E1,{label:"Tools",collapsed:i.has("Tools"),count:PN.length,onToggle:()=>a("Tools")}),(c||!i.has("Tools"))&&PN.map(w=>o.jsx(OW,{tool:w,active:e===w.key,onClick:()=>r(w.key),rail:c},w.key))]})}),o.jsx(PW,{rail:c}),!c&&o.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar",title:"Drag to resize · double-click to reset",onPointerDown:b,onDoubleClick:_,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 AW({tab:e,onNewSession:r,rail:n,onToggleRail:i}){const s=(e==null?void 0:e.label)??"no session",a=NW((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(dr,{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(dr,{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(dr,{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(dr,{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(B4,{})})]})]})}const Ox=new Map,$W=3e4;function NW(e){const[r,n]=D.useState(()=>{var i;return e?((i=Ox.get(e))==null?void 0:i.value)??null:null});return D.useEffect(()=>{if(!e){n(null);return}let i=!1;return(async()=>{const a=Ox.get(e);if(a&&Date.now()-a.ts<$W){i||n(a.value);return}try{const c=await window.api.app.gitBranch(e);if(i)return;Ox.set(e,{value:c,ts:Date.now()}),n(c)}catch{if(i)return;Ox.set(e,{value:null,ts:Date.now()}),n(null)}})(),()=>{i=!0}},[e]),r}function E1({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 RN({item:e,active:r,live:n,onClick:i,rail:s}){return o.jsxs("button",{onClick:i,title:e.hint,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(dr,{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 OW({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(dr,{name:e.icon,size:15,stroke:1.6})}),!i&&o.jsx("span",{className:"flex-1 truncate",children:e.label})]})}function PW({rail:e}){const r=Mt(l=>l.isRecording),n=Nt(l=>l.tabs),i=Nt(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 g4(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 · ${RW(a)}`:"Claude Code"})]})}function RW(e){var n,i,s,a,c,l;const r=e.toLowerCase();if(r.includes("opus")){const u=(i=(n=e.match(/(\d+[-.]?\d*)/))==null?void 0:n[1])==null?void 0:i.replace("-",".");return u?`Opus ${u}`:"Opus"}if(r.includes("sonnet")){const u=(a=(s=e.match(/(\d+[-.]?\d*)/))==null?void 0:s[1])==null?void 0:a.replace("-",".");return u?`Sonnet ${u}`:"Sonnet"}if(r.includes("haiku")){const u=(l=(c=e.match(/(\d+[-.]?\d*)/))==null?void 0:c[1])==null?void 0:l.replace("-",".");return u?`Haiku ${u}`:"Haiku"}return e}function MW({onNavigate:e}){const r=Nt(E=>E.tabs),n=Nt(E=>E.activeTabId),i=r.find(E=>E.id===n)??null,s=S4(i),a=(s==null?void 0:s.lastEventAt)??0,c=Ep(E=>E.data),l=$u(E=>{var T;return((T=E.snapshot)==null?void 0:T.paused)??null}),[u,f]=D.useState(null),[,m]=D.useState(0);D.useEffect(()=>{const E=setInterval(()=>m(T=>T+1),6e4);return()=>clearInterval(E)},[]),D.useEffect(()=>{let E=!1;if(!(i!=null&&i.cwd)){f(null);return}return window.api.app.gitBranch(i.cwd).then(T=>{E||f(T)}).catch(()=>{E||f(null)}),()=>{E=!0}},[i==null?void 0:i.cwd]);const h=(s==null?void 0:s.todos)??[],[y,x]=D.useState(!1),k=D.useRef(null);D.useEffect(()=>{if(!y)return;const E=T=>{k.current&&!k.current.contains(T.target)&&x(!1)};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[y]),D.useEffect(()=>{h.length===0&&x(!1)},[h.length]);const S=h_(c),b=(S==null?void 0:S.usage.five_hour)??null,_=b?Math.round(b.utilization):null,w=(c==null?void 0:c.kind)==="ok"||(c==null?void 0:c.kind)==="ok-stale",C=a>0?LW(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:w?"Connected to Anthropic":"Disconnected",children:[o.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${w?"bg-sage":"bg-fg-faint"}`}),o.jsx("span",{children:w?"connected":"offline"})]}),o.jsx("button",{onClick:()=>e==null?void 0:e("usage"),className:"hover:text-fg transition-colors",title:"Open Usage",children:_!=null?`${_}% 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:C})]}),h.length>0&&o.jsx(IW,{ref:k,todos:h,open:y,onToggle:()=>x(E=>!E)}),o.jsx("span",{className:"flex-1"}),o.jsxs("span",{className:"text-fg-faint",children:["v","0.35.12"]})]})}const IW=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(DW,{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 DW({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 LW(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 T1={exports:{}},MN;function BW(){return MN||(MN=1,(function(e,r){(function(n,i){e.exports=i()})(globalThis,(()=>(()=>{var n={4567:function(c,l,u){var f=this&&this.__decorate||function(w,C,E,T){var $,N=arguments.length,O=N<3?C:T===null?T=Object.getOwnPropertyDescriptor(C,E):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")O=Reflect.decorate(w,C,E,T);else for(var M=w.length-1;M>=0;M--)($=w[M])&&(O=(N<3?$(O):N>3?$(C,E,O):$(C,E))||O);return N>3&&O&&Object.defineProperty(C,E,O),O},m=this&&this.__param||function(w,C){return function(E,T){C(E,T,w)}};Object.defineProperty(l,"__esModule",{value:!0}),l.AccessibilityManager=void 0;const h=u(9042),y=u(9924),x=u(844),k=u(4725),S=u(2585),b=u(3656);let _=l.AccessibilityManager=class extends x.Disposable{constructor(w,C,E,T){super(),this._terminal=w,this._coreBrowserService=E,this._renderService=T,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let $=0;$<this._terminal.rows;$++)this._rowElements[$]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[$]);if(this._topBoundaryFocusListener=$=>this._handleBoundaryFocus($,0),this._bottomBoundaryFocusListener=$=>this._handleBoundaryFocus($,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new y.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize(($=>this._handleResize($.rows)))),this.register(this._terminal.onRender(($=>this._refreshRows($.start,$.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar(($=>this._handleChar($)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
2896
2896
  `)))),this.register(this._terminal.onA11yTab(($=>this._handleTab($)))),this.register(this._terminal.onKey(($=>this._handleKey($.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this.register((0,b.addDisposableDomListener)(document,"selectionchange",(()=>this._handleSelectionChange()))),this.register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,x.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(w){for(let C=0;C<w;C++)this._handleChar(" ")}_handleChar(w){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==w&&(this._charsToAnnounce+=w):this._charsToAnnounce+=w,w===`
2897
2897
  `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=h.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(w){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(w)||this._charsToConsume.push(w)}_refreshRows(w,C){this._liveRegionDebouncer.refresh(w,C,this._terminal.rows)}_renderRows(w,C){const E=this._terminal.buffer,T=E.lines.length.toString();for(let $=w;$<=C;$++){const N=E.lines.get(E.ydisp+$),O=[],M=(N==null?void 0:N.translateToString(!0,void 0,void 0,O))||"",U=(E.ydisp+$+1).toString(),H=this._rowElements[$];H&&(M.length===0?(H.innerText=" ",this._rowColumns.set(H,[0,1])):(H.textContent=M,this._rowColumns.set(H,O)),H.setAttribute("aria-posinset",U),H.setAttribute("aria-setsize",T))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(w,C){const E=w.target,T=this._rowElements[C===0?1:this._rowElements.length-2];if(E.getAttribute("aria-posinset")===(C===0?"1":`${this._terminal.buffer.lines.length}`)||w.relatedTarget!==T)return;let $,N;if(C===0?($=E,N=this._rowElements.pop(),this._rowContainer.removeChild(N)):($=this._rowElements.shift(),N=E,this._rowContainer.removeChild($)),$.removeEventListener("focus",this._topBoundaryFocusListener),N.removeEventListener("focus",this._bottomBoundaryFocusListener),C===0){const O=this._createAccessibilityTreeNode();this._rowElements.unshift(O),this._rowContainer.insertAdjacentElement("afterbegin",O)}else{const O=this._createAccessibilityTreeNode();this._rowElements.push(O),this._rowContainer.appendChild(O)}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(),w.preventDefault(),w.stopImmediatePropagation()}_handleSelectionChange(){var M;if(this._rowElements.length===0)return;const w=document.getSelection();if(!w)return;if(w.isCollapsed)return void(this._rowContainer.contains(w.anchorNode)&&this._terminal.clearSelection());if(!w.anchorNode||!w.focusNode)return void console.error("anchorNode and/or focusNode are null");let C={node:w.anchorNode,offset:w.anchorOffset},E={node:w.focusNode,offset:w.focusOffset};if((C.node.compareDocumentPosition(E.node)&Node.DOCUMENT_POSITION_PRECEDING||C.node===E.node&&C.offset>E.offset)&&([C,E]=[E,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 T=this._rowElements.slice(-1)[0];if(E.node.compareDocumentPosition(T)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(E={node:T,offset:((M=T.textContent)==null?void 0:M.length)??0}),!this._rowContainer.contains(E.node))return;const $=({node:U,offset:H})=>{const V=U instanceof Text?U.parentNode:U;let z=parseInt(V==null?void 0:V.getAttribute("aria-posinset"),10)-1;if(isNaN(z))return console.warn("row is invalid. Race condition?"),null;const F=this._rowColumns.get(V);if(!F)return console.warn("columns is null. Race condition?"),null;let Y=H<F.length?F[H]:F.slice(-1)[0]+1;return Y>=this._terminal.cols&&(++z,Y=0),{row:z,column:Y}},N=$(C),O=$(E);if(N&&O){if(N.row>O.row||N.row===O.row&&N.column>=O.column)throw new Error("invalid range");this._terminal.select(N.column,N.row,(O.row-N.row)*this._terminal.cols-N.column+O.column)}}_handleResize(w){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>w;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const w=this._coreBrowserService.mainDocument.createElement("div");return w.setAttribute("role","listitem"),w.tabIndex=-1,this._refreshRowDimensions(w),w}_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 w=0;w<this._terminal.rows;w++)this._refreshRowDimensions(this._rowElements[w])}}_refreshRowDimensions(w){w.style.height=`${this._renderService.dimensions.css.cell.height}px`}};l.AccessibilityManager=_=f([m(1,S.IInstantiationService),m(2,k.ICoreBrowserService),m(3,k.IRenderService)],_)},3614:(c,l)=>{function u(y){return y.replace(/\r?\n/g,"\r")}function f(y,x){return x?"\x1B[200~"+y+"\x1B[201~":y}function m(y,x,k,S){y=f(y=u(y),k.decPrivateModes.bracketedPasteMode&&S.rawOptions.ignoreBracketedPasteMode!==!0),k.triggerDataEvent(y,!0),x.value=""}function h(y,x,k){const S=k.getBoundingClientRect(),b=y.clientX-S.left-10,_=y.clientY-S.top-10;x.style.width="20px",x.style.height="20px",x.style.left=`${b}px`,x.style.top=`${_}px`,x.style.zIndex="1000",x.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(y,x){y.clipboardData&&y.clipboardData.setData("text/plain",x.selectionText),y.preventDefault()},l.handlePasteEvent=function(y,x,k,S){y.stopPropagation(),y.clipboardData&&m(y.clipboardData.getData("text/plain"),x,k,S)},l.paste=m,l.moveTextAreaUnderMouseCursor=h,l.rightClickHandler=function(y,x,k,S,b){h(y,x,k),b&&S.rightClickSelect(y),x.value=S.selectionText,x.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,y){this._css.set(m,h,y)}getCss(m,h){return this._css.get(m,h)}setColor(m,h,y){this._color.set(m,h,y)}getColor(m,h){return this._color.get(m,h)}clear(){this._color.clear(),this._css.clear()}}},3656:(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 y=!1;return{dispose:()=>{y||(y=!0,u.removeEventListener(f,m,h))}}}},3551:function(c,l,u){var f=this&&this.__decorate||function(_,w,C,E){var T,$=arguments.length,N=$<3?w:E===null?E=Object.getOwnPropertyDescriptor(w,C):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(_,w,C,E);else for(var O=_.length-1;O>=0;O--)(T=_[O])&&(N=($<3?T(N):$>3?T(w,C,N):T(w,C))||N);return $>3&&N&&Object.defineProperty(w,C,N),N},m=this&&this.__param||function(_,w){return function(C,E){w(C,E,_)}};Object.defineProperty(l,"__esModule",{value:!0}),l.Linkifier=void 0;const h=u(3656),y=u(8460),x=u(844),k=u(2585),S=u(4725);let b=l.Linkifier=class extends x.Disposable{get currentLink(){return this._currentLink}constructor(_,w,C,E,T){super(),this._element=_,this._mouseService=w,this._renderService=C,this._bufferService=E,this._linkProviderService=T,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new y.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new y.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,x.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,x.toDisposable)((()=>{var $;this._lastMouseEvent=void 0,($=this._activeProviderReplies)==null||$.clear()}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0}))),this.register((0,h.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,h.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,h.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,h.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(_){this._lastMouseEvent=_;const w=this._positionFromMouseEvent(_,this._element,this._mouseService);if(!w)return;this._isMouseOut=!1;const C=_.composedPath();for(let E=0;E<C.length;E++){const T=C[E];if(T.classList.contains("xterm"))break;if(T.classList.contains("xterm-hover"))return}this._lastBufferCell&&w.x===this._lastBufferCell.x&&w.y===this._lastBufferCell.y||(this._handleHover(w),this._lastBufferCell=w)}_handleHover(_){if(this._activeLine!==_.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(_,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,_)||(this._clearCurrentLink(),this._askForLink(_,!0))}_askForLink(_,w){var E,T;this._activeProviderReplies&&w||((E=this._activeProviderReplies)==null||E.forEach(($=>{$==null||$.forEach((N=>{N.link.dispose&&N.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=_.y);let C=!1;for(const[$,N]of this._linkProviderService.linkProviders.entries())w?(T=this._activeProviderReplies)!=null&&T.get($)&&(C=this._checkLinkProviderResult($,_,C)):N.provideLinks(_.y,(O=>{var U,H;if(this._isMouseOut)return;const M=O==null?void 0:O.map((V=>({link:V})));(U=this._activeProviderReplies)==null||U.set($,M),C=this._checkLinkProviderResult($,_,C),((H=this._activeProviderReplies)==null?void 0:H.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(_.y,this._activeProviderReplies)}))}_removeIntersectingLinks(_,w){const C=new Set;for(let E=0;E<w.size;E++){const T=w.get(E);if(T)for(let $=0;$<T.length;$++){const N=T[$],O=N.link.range.start.y<_?0:N.link.range.start.x,M=N.link.range.end.y>_?this._bufferService.cols:N.link.range.end.x;for(let U=O;U<=M;U++){if(C.has(U)){T.splice($--,1);break}C.add(U)}}}}_checkLinkProviderResult(_,w,C){var $;if(!this._activeProviderReplies)return C;const E=this._activeProviderReplies.get(_);let T=!1;for(let N=0;N<_;N++)this._activeProviderReplies.has(N)&&!this._activeProviderReplies.get(N)||(T=!0);if(!T&&E){const N=E.find((O=>this._linkAtPosition(O.link,w)));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 O=($=this._activeProviderReplies.get(N))==null?void 0:$.find((M=>this._linkAtPosition(M.link,w)));if(O){C=!0,this._handleNewLink(O);break}}return C}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(_){if(!this._currentLink)return;const w=this._positionFromMouseEvent(_,this._element,this._mouseService);w&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,w)&&this._currentLink.link.activate(_,this._currentLink.link.text)}_clearCurrentLink(_,w){this._currentLink&&this._lastMouseEvent&&(!_||!w||this._currentLink.link.range.start.y>=_&&this._currentLink.link.range.end.y<=w)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,x.disposeArray)(this._linkCacheDisposables))}_handleNewLink(_){if(!this._lastMouseEvent)return;const w=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);w&&this._linkAtPosition(_.link,w)&&(this._currentLink=_,this._currentLink.state={decorations:{underline:_.link.decorations===void 0||_.link.decorations.underline,pointerCursor:_.link.decorations===void 0||_.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,_.link,this._lastMouseEvent),_.link.decorations={},Object.defineProperties(_.link.decorations,{pointerCursor:{get:()=>{var C,E;return(E=(C=this._currentLink)==null?void 0:C.state)==null?void 0:E.decorations.pointerCursor},set:C=>{var E;(E=this._currentLink)!=null&&E.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,E;return(E=(C=this._currentLink)==null?void 0:C.state)==null?void 0:E.decorations.underline},set:C=>{var E,T,$;(E=this._currentLink)!=null&&E.state&&(($=(T=this._currentLink)==null?void 0:T.state)==null?void 0:$.decorations.underline)!==C&&(this._currentLink.state.decorations.underline=C,this._currentLink.state.isHovered&&this._fireUnderlineEvent(_.link,C))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((C=>{if(!this._currentLink)return;const E=C.start===0?0:C.start+1+this._bufferService.buffer.ydisp,T=this._bufferService.buffer.ydisp+1+C.end;if(this._currentLink.link.range.start.y>=E&&this._currentLink.link.range.end.y<=T&&(this._clearCurrentLink(E,T),this._lastMouseEvent)){const $=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);$&&this._askForLink($,!1)}}))))}_linkHover(_,w,C){var E;(E=this._currentLink)!=null&&E.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(w,!0),this._currentLink.state.decorations.pointerCursor&&_.classList.add("xterm-cursor-pointer")),w.hover&&w.hover(C,w.text)}_fireUnderlineEvent(_,w){const C=_.range,E=this._bufferService.buffer.ydisp,T=this._createLinkUnderlineEvent(C.start.x-1,C.start.y-E-1,C.end.x,C.end.y-E-1,void 0);(w?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(T)}_linkLeave(_,w,C){var E;(E=this._currentLink)!=null&&E.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(w,!1),this._currentLink.state.decorations.pointerCursor&&_.classList.remove("xterm-cursor-pointer")),w.leave&&w.leave(C,w.text)}_linkAtPosition(_,w){const C=_.range.start.y*this._bufferService.cols+_.range.start.x,E=_.range.end.y*this._bufferService.cols+_.range.end.x,T=w.y*this._bufferService.cols+w.x;return C<=T&&T<=E}_positionFromMouseEvent(_,w,C){const E=C.getCoords(_,w,this._bufferService.cols,this._bufferService.rows);if(E)return{x:E[0],y:E[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(_,w,C,E,T){return{x1:_,y1:w,x2:C,y2:E,cols:this._bufferService.cols,fg:T}}};l.Linkifier=b=f([m(1,S.IMouseService),m(2,S.IRenderService),m(3,k.IBufferService),m(4,S.ILinkProviderService)],b)},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,b,_,w){var C,E=arguments.length,T=E<3?b:w===null?w=Object.getOwnPropertyDescriptor(b,_):w;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(S,b,_,w);else for(var $=S.length-1;$>=0;$--)(C=S[$])&&(T=(E<3?C(T):E>3?C(b,_,T):C(b,_))||T);return E>3&&T&&Object.defineProperty(b,_,T),T},m=this&&this.__param||function(S,b){return function(_,w){b(_,w,S)}};Object.defineProperty(l,"__esModule",{value:!0}),l.OscLinkProvider=void 0;const h=u(511),y=u(2585);let x=l.OscLinkProvider=class{constructor(S,b,_){this._bufferService=S,this._optionsService=b,this._oscLinkService=_}provideLinks(S,b){var M;const _=this._bufferService.buffer.lines.get(S-1);if(!_)return void b(void 0);const w=[],C=this._optionsService.rawOptions.linkHandler,E=new h.CellData,T=_.getTrimmedLength();let $=-1,N=-1,O=!1;for(let U=0;U<T;U++)if(N!==-1||_.hasContent(U)){if(_.loadCell(U,E),E.hasExtendedAttrs()&&E.extended.urlId){if(N===-1){N=U,$=E.extended.urlId;continue}O=E.extended.urlId!==$}else N!==-1&&(O=!0);if(O||N!==-1&&U===T-1){const H=(M=this._oscLinkService.getLinkData($))==null?void 0:M.uri;if(H){const V={start:{x:N+1,y:S},end:{x:U+(O||U!==T-1?0:1),y:S}};let z=!1;if(!(C!=null&&C.allowNonHttpProtocols))try{const F=new URL(H);["http:","https:"].includes(F.protocol)||(z=!0)}catch{z=!0}z||w.push({text:H,range:V,activate:(F,Y)=>C?C.activate(F,Y,V):k(0,Y),hover:(F,Y)=>{var te;return(te=C==null?void 0:C.hover)==null?void 0:te.call(C,F,Y,V)},leave:(F,Y)=>{var te;return(te=C==null?void 0:C.leave)==null?void 0:te.call(C,F,Y,V)}})}O=!1,E.hasExtendedAttrs()&&E.extended.urlId?(N=U,$=E.extended.urlId):(N=-1,$=-1)}}b(w)}};function k(S,b){if(confirm(`Do you want to navigate to ${b}?
2898
2898
 
@@ -3445,7 +3445,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
3445
3445
  `)),b=T=>{c(T.line),m(null),u(T.error?T.raw:JSON.stringify(T.value,null,2))},_=T=>{let $;try{$=JSON.stringify(JSON.parse(l))}catch(O){m(O.message);return}const N=k();N[T]=$,S(N),c(null)},w=T=>{const $=k();$.splice(T,1),S($),a===T?(c(null),m(null)):a!==null&&a>T&&c(a-1),s(N=>{const O=new Set;for(const M of N)M!==T&&O.add(M>T?M-1:M);return O})},C=()=>{const T=k();let $=T.length;for(;$>0&&T[$-1].trim()==="";)$--;if(T.splice($,0,"{}"),S(T),x){rt.info("Record added at end of file — switch to Edit to see it.");return}c($),u(`{
3446
3446
 
3447
3447
  }`),m(null),s(N=>new Set(N).add($))},E=T=>s($=>{const N=new Set($);return N.has(T)?N.delete(T):N.add(T),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:[y.length.toLocaleString()," record",y.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"}),x&&o.jsxs("span",{className:"text-[10px] text-amber-700",children:["Showing first ",uT.toLocaleString()," — switch to Edit for the full file."]})]}),y.length===0?o.jsx("div",{className:"p-6 text-fg-faint",children:"empty file"}):o.jsx("ul",{className:"divide-y divide-line",children:y.map((T,$)=>{const N=i.has(T.line)||a===T.line;return o.jsxs("li",{className:T.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:()=>E(T.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:T.error?"text-red-400":"text-fg-dim",children:Xfe(T)})]}),o.jsxs("div",{className:"flex shrink-0 gap-2",children:[a!==T.line&&o.jsx("button",{onClick:()=>b(T),className:"text-fg-faint hover:text-fg",children:"Edit"}),o.jsx("button",{onClick:()=>w(T.line),className:"text-fg-faint hover:text-red-400",children:"Delete"})]})]}),N&&a===T.line&&o.jsxs("div",{className:"px-3 pb-2 pl-12",children:[o.jsx("textarea",{value:l,onChange:O=>{u(O.target.value),m(null)},spellCheck:!1,rows:Math.min(20,l.split(`
3448
- `).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:()=>_(T.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!==T.line&&o.jsx("pre",{className:"px-3 pb-2 pl-12 font-mono text-[11px] text-fg-dim whitespace-pre-wrap break-all",children:T.error?T.raw:JSON.stringify(T.value,null,2)})]},T.line)})})]})}function Jfe(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 Zfe({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," · ",Jfe(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 Qfe=D.lazy(()=>sb(()=>import("./TiptapBody-CxSS_K2x.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(e=>({default:e.TiptapBody})));function aw(e){return e.split("/").filter(Boolean).pop()||e}function ow(e){return V4(e)||G4(e)}function dT(){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.closeAll),f=Cn(Me=>Me.loadBuffer),m=Cn(Me=>Me.setBuffer),h=Cn(Me=>Me.markSaved),y=Cn(Me=>Me.setViewMode),x=Yv(),[k,S]=D.useState({}),[b,_]=D.useState({}),[w,C]=D.useState(null),[E,T]=D.useState(null),[$,N]=D.useState(!1),[O,M]=D.useState(!1),[U,H]=D.useState(!0),V=D.useRef(null),z=D.useRef(null),F=D.useRef(void 0),Y=D.useCallback(Me=>{V.current=Me},[]),te=D.useCallback(()=>V.current,[]);D.useEffect(()=>{const Me=r;if(!Me||ow(Me))return;if(Cn.getState().hasBuffer(Me)){S(Ue=>Ue[Me]==="ready"?Ue:{...Ue,[Me]:"ready"});return}let Le=!1;return S(Ue=>({...Ue,[Me]:"loading"})),window.api.files.read(Me).then(Ue=>{Le||(Ue.binary?S(st=>({...st,[Me]:{binary:!0,size:Ue.size??0,mime:Ue.mime??"application/octet-stream",reason:Ue.error??"Binary file"}})):Ue.ok?(f(Me,Ue.text),S(st=>({...st,[Me]:"ready"}))):S(st=>({...st,[Me]:{error:Ue.error??"failed to read"}})))}),()=>{Le=!0}},[r,f]),D.useEffect(()=>{T(null)},[r]);const le=D.useCallback(async(Me,Le=!1)=>{const Ue=Cn.getState().buffers[Me];if(Ue==null)return;Le&&N(!0);const st=await window.api.files.write(Me,Ue);st.ok?(h(Me),_(lt=>({...lt,[Me]:(lt[Me]??0)+1})),Le||rt.info(`Saved ${aw(Me)}`)):rt.error(st.error??`Couldn't save ${aw(Me)}`),Le&&N(!1)},[h]);D.useEffect(()=>{if(!x.autosave)return;const Me=r;if(!(!Me||ow(Me)||!n[Me]))return window.clearTimeout(F.current),F.current=window.setTimeout(()=>{le(Me,!0)},1200),()=>window.clearTimeout(F.current)},[x.autosave,r,n,s,le]),D.useEffect(()=>{const Me=Le=>{if((Le.metaKey||Le.ctrlKey)&&(Le.key==="s"||Le.key==="S")){const Ue=Cn.getState().activeFilePath;Ue&&!ow(Ue)&&(Le.preventDefault(),le(Ue))}else(Le.metaKey||Le.ctrlKey)&&Le.shiftKey&&(Le.key==="f"||Le.key==="F")?(Le.preventDefault(),M(Ue=>!Ue)):Le.key==="Escape"&&O&&M(!1)};return window.addEventListener("keydown",Me),()=>window.removeEventListener("keydown",Me)},[le,O]);const pe=D.useCallback(Me=>{n[Me]?C({kind:"one",path:Me}):c(Me)},[n,c]),X=D.useCallback(Me=>{e.some(Ue=>Ue.path!==Me&&n[Ue.path])?C({kind:"others",path:Me}):l(Me)},[e,n,l]),Q=D.useCallback(()=>{e.some(Le=>n[Le.path])?C({kind:"all",path:""}):u()},[e,n,u]),J=()=>{w&&(w.kind==="one"?c(w.path):w.kind==="others"?l(w.path):u(),C(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 ee=r,ae=ee?aw(ee):"",me=ee?k[ee]:void 0,_e=ee?Y4(ee):!1,Ne=ee?ZW(ee):!1,xe=ee&&_e?i[ee]??QW(ee):"edit",ie=!!ee&&!ow(ee)&&me==="ready",ce=ie,ge=Ne?["edit","wysiwyg","preview","split"]:_e?["edit","preview"]:[],Ae=ee&&o.jsx(Mfe,{path:ee,name:ae,value:s[ee]??"",onChange:Me=>m(ee,Me),onSave:()=>void le(ee),onReady:Y,onCursor:T}),Te=$?"Saving…":ee&&n[ee]?x.autosave?"Editing…":"Unsaved":"All changes saved";return o.jsxs("div",{className:"relative flex flex-col h-full bg-bg",children:[!O&&o.jsx(Nfe,{openFiles:e,activeFilePath:r,dirty:n,onSelectFile:a,onCloseFile:pe,onCloseOthers:X,onCloseAll:Q}),ee&&!O&&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:ae}),o.jsx("span",{className:"ml-3 text-[10px] text-fg-faint truncate",children:ee}),ie&&o.jsxs("span",{className:"ml-3 text-[10px] text-fg-faint shrink-0",children:["· ",Te]}),o.jsx("div",{className:"flex-1"}),Wd(ee)&&(xe==="preview"||xe==="split")&&o.jsx("button",{onClick:()=>H(Me=>!Me),className:`px-2 py-0.5 text-[10px] border border-line rounded mr-1 ${U?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Toggle document outline",children:"Outline"}),ie&&o.jsxs("div",{className:"flex items-center mr-2 rounded border border-line overflow-hidden",children:[o.jsx("button",{onClick:()=>x.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:()=>x.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:x.toggleWordWrap,className:`px-1.5 py-0.5 text-[10px] ${x.wordWrap?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Word wrap",children:"Wrap"}),o.jsx("button",{onClick:x.toggleMinimap,className:`px-1.5 py-0.5 text-[10px] ${x.minimap?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Minimap",children:"Map"}),o.jsx("button",{onClick:()=>x.setTheme(x.theme==="dark"?"paper":"dark"),className:"px-1.5 py-0.5 text-[10px] text-fg-faint hover:text-fg",title:"Toggle editor theme",children:x.theme==="dark"?"Dark":"Paper"}),o.jsx("button",{onClick:x.toggleAutosave,className:`px-1.5 py-0.5 text-[10px] ${x.autosave?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Autosave",children:"Auto"})]}),ge.length>0&&o.jsx("div",{className:"flex items-center mr-2 rounded border border-line overflow-hidden",children:ge.map(Me=>o.jsx("button",{onClick:()=>y(ee,Me),className:`px-2 py-0.5 text-[10px] capitalize transition-colors ${xe===Me?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,children:Me},Me))}),o.jsx("button",{onClick:()=>M(!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:ee}),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:ee}),className:"px-2 py-0.5 text-[10px] text-fg-faint hover:text-fg border border-line rounded",title:"Reveal in OS",children:"Reveal"})]}),O&&o.jsx("button",{onClick:()=>M(!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:ee?V4(ee)?o.jsx(Wfe,{path:ee,name:ae}):G4(ee)?o.jsx(Hfe,{path:ee}):me&&typeof me=="object"&&"binary"in me?o.jsx(Zfe,{path:ee,name:ae,size:me.size,mime:me.mime,reason:me.reason}):me&&typeof me=="object"&&"error"in me?o.jsx("div",{className:"p-6 text-xs text-red-400",children:me.error}):me!=="ready"?o.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"loading…"}):xe==="wysiwyg"&&Wd(ee)?o.jsx(D.Suspense,{fallback:o.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"Loading editor…"}),children:o.jsx(Qfe,{value:s[ee]??"",onChange:Me=>m(ee,Me)},ee)}):xe==="split"&&Wd(ee)?o.jsxs("div",{className:"flex h-full",children:[U&&o.jsx(TL,{text:s[ee]??"",scrollRef:z}),o.jsxs("div",{className:"flex-1 min-w-0 flex flex-col border-r border-line",children:[o.jsx(EL,{getEditor:te}),o.jsx("div",{className:"flex-1 min-h-0",children:Ae})]}),o.jsx("div",{className:"flex-1 min-w-0",children:o.jsx(jL,{ref:z,text:s[ee]??"",flush:!0})})]}):xe==="preview"&&Wd(ee)?o.jsxs("div",{className:"flex h-full",children:[U&&o.jsx(TL,{text:s[ee]??"",scrollRef:z}),o.jsx("div",{className:"flex-1 min-w-0",children:o.jsx(jL,{ref:z,text:s[ee]??""})})]}):xe==="preview"&&H4(ee)?o.jsx(Ufe,{path:ee,dirty:!!n[ee],reloadToken:b[ee]??0}):xe==="preview"&&K4(ee)?o.jsx(Gfe,{path:ee,text:s[ee]??""}):xe==="preview"&&X4(ee)?o.jsx(Yfe,{path:ee,text:s[ee]??""}):Wd(ee)?o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsx(EL,{getEditor:te}),o.jsx("div",{className:"flex-1 min-h-0",children:Ae})]}):Ae:null}),ce&&o.jsx(Ffe,{text:s[ee]??"",cursor:E,language:Sc(ee)||void 0}),w&&o.jsx(ehe,{message:w.kind==="one"?`Discard unsaved changes to ${aw(w.path)}?`:w.kind==="others"?"Discard unsaved changes in the other open files?":"Discard unsaved changes in all open files?",onCancel:()=>C(null),onConfirm:J})]})}function ehe({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 AL={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"},the={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 KC(e){return e>=1e6?(e/1e6).toFixed(1)+"M":e>=1e3?(e/1e3).toFixed(1)+"K":String(e)}function rhe({open:e,onClose:r,variant:n="overlay"}){const i=Nt(T=>T.tabs.find($=>$.id===T.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),y=D.useCallback(async T=>{u(!0),m(null);try{const $=await window.api.repo.analyze(T);$.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}y(s)}},[e,s,y]),D.useEffect(()=>{var $;if(!e)return;const T=N=>{N.key==="Escape"&&(N.stopPropagation(),r())};return window.addEventListener("keydown",T),($=h.current)==null||$.focus(),()=>window.removeEventListener("keydown",T)},[e,r]);const x=D.useCallback(()=>{s&&y(s)},[s,y]),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]),b=D.useMemo(()=>{if(!a)return[];const T=a.topDirectories;if(T.length===0)return[];const $=T.map(O=>Math.sqrt(Math.max(1,O.fileCount))),N=$.reduce((O,M)=>O+M,0)||1;return T.map((O,M)=>({path:O.path,fileCount:O.fileCount,totalLines:O.totalLines,basis:$[M]/N*100}))},[a]);if(!e)return null;const _=T=>{T.target===T.currentTarget&&r()},w=s?s.split("/").filter(Boolean).pop()||s:"no folder",C=n==="page",E=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:_,"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:[w,(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:x,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(XC,{label:"Files",value:KC(a.totalFiles)}),o.jsx(XC,{label:"Lines of code",value:KC(a.totalLines)}),o.jsx(XC,{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(([T,$,N])=>{const O=AL[T]??AL.other,M=the[T]??T,U=$/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:M,children:M}),o.jsx("div",{className:"flex-1 h-4 bg-bg rounded overflow-hidden",children:o.jsx("div",{className:"h-full rounded",style:{width:`${U}%`,backgroundColor:O}})}),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:[KC(N)," L"]})]},T)})})]}),o.jsxs("section",{children:[o.jsx("h3",{className:"text-xs uppercase tracking-wider text-fg-faint mb-2",children:"Top directories"}),b.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:b.map(T=>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(T.basis,6)}%`,flexGrow:T.basis>15?1:0},title:`${T.path} — ${T.fileCount} files, ${T.totalLines.toLocaleString()} lines`,children:[o.jsx("div",{className:"text-[11px] font-mono text-fg truncate",children:T.path}),o.jsxs("div",{className:"text-[10px] text-fg-dim font-mono",children:[T.fileCount," files"]})]},T.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?yf.createPortal(E,document.body):E}function XC({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 kf({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 $L=e=>/[/\\\-_.\s]/.test(e),NL=e=>e>="A"&&e<="Z";function nhe(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},(_,w)=>w)};if(l.startsWith(i))return{match:!0,score:900,matched:Array.from({length:e.length},(_,w)=>w)};let u=0;for(const _ of a.split("/")){if(_===i)return{match:!0,score:800,matched:[]};_.startsWith(i)&&(u=Math.max(u,700))}const f=l.indexOf(i);if(f!==-1)return{match:!0,score:f===0||$L(l[f-1])||NL(c[f])?650:600,matched:Array.from({length:e.length},(w,C)=>f+C)};if(a.includes(i))return{match:!0,score:Math.max(500,u),matched:[]};let m=0,h=0,y=0,x=-1,k=0;const S=[];for(let _=0;_<s.length&&m<i.length;_++)s[_]===i[m]&&(S.push(_),h+=10,x===_-1?(y++,h+=y*8):y=0,(_===0||$L(s[_-1])||NL(r[_]))&&(k++,h+=15,_===0&&(h+=10)),x=_,m++);if(m!==i.length)return{match:!1,score:0,matched:[]};const b=Math.max(0,50-(s.length-i.length));if(h+=b,k>=i.length*.5&&(h+=30),S.length>1){const _=S[S.length-1]-S[0];_>i.length*3&&(h-=Math.min(50,(_-i.length*3)*2))}return{match:!0,score:Math.max(1,h),matched:S}}function YC(e,r){return e.startsWith(r+"/")?e.slice(r.length+1):e===r?"":e}function OL(e){const r=e.lastIndexOf("/");return r<0?"":e.slice(0,r)}const PL="session-manager.quickopen.recent",ihe=8;function she({open:e,onClose:r,variant:n="overlay"}){const i=Nt(M=>M.tabs.find(U=>U.id===M.activeTabId)??null),s=(i==null?void 0:i.cwd)??"",[a,c]=D.useState(""),[l,u]=D.useState([]),[f,m]=D.useState(!1),[h,y]=D.useState(0),[x,k]=D.useState([]),S=D.useRef(null),b=D.useRef(null);D.useEffect(()=>{if(e)try{const M=localStorage.getItem(PL);M&&k(JSON.parse(M))}catch{}},[e]),D.useEffect(()=>{if(!e){c(""),y(0);return}const M=setTimeout(()=>{var U;return(U=S.current)==null?void 0:U.focus()},0);return()=>clearTimeout(M)},[e]),D.useEffect(()=>{if(!e||!s)return;let M=!1;return m(!0),window.api.search.files(s,"",{limit:5e3}).then(U=>{if(!M){if(!U.ok){rt.error(`File search failed: ${U.error??"unknown error"}`),u([]);return}u(U.files)}}).catch(U=>{const H=U instanceof Error?U.message:String(U);mt.error("quick-open","search.files threw",{error:H}),rt.error(`File search failed: ${H}`),u([])}).finally(()=>{M||m(!1)}),()=>{M=!0}},[e,s]);const _=D.useMemo(()=>{if(!a.trim())return[...l].sort((V,z)=>V.name.localeCompare(z.name)).slice(0,100).map(V=>({file:V,score:0,matched:[]}));const M=a.trim(),U=[];for(const H of l){const V=nhe(M,H.name,H.path);V.match&&U.push({file:H,score:V.score,matched:V.matched})}return U.sort((H,V)=>V.score-H.score),U.slice(0,100)},[l,a]),w=D.useMemo(()=>a.trim()?[]:x.map(M=>l.find(U=>U.path===M)||null).filter(M=>M!==null).slice(0,5),[x,l,a]);D.useEffect(()=>{const M=w.length+_.length;h>=M&&y(Math.max(0,M-1))},[w.length,_.length,h]),D.useEffect(()=>{if(!b.current)return;const M=b.current.querySelector(`[data-row="${h}"]`);M&&M.scrollIntoView({block:"nearest"})},[h]);const C=D.useCallback(M=>{try{const z=[M,...x.filter(F=>F!==M)].slice(0,ihe);k(z),localStorage.setItem(PL,JSON.stringify(z))}catch{}const U=i==null?void 0:i.id;if(!U){rt.error("No active tab to receive file path");return}const V=(s?YC(M,s):M)||M;try{window.api.pty.write({tabId:U,data:V})}catch(z){const F=z instanceof Error?z.message:String(z);mt.error("quick-open","pty.write failed",{error:F}),rt.error(`Failed to write to terminal: ${F}`);return}r()},[i==null?void 0:i.id,s,x,r]),E=D.useCallback(M=>{const U=w.length+_.length;if(M.key==="Escape"){M.preventDefault(),r();return}if(M.key==="ArrowDown"){if(M.preventDefault(),U===0)return;y(H=>Math.min(U-1,H+1));return}if(M.key==="ArrowUp"){if(M.preventDefault(),U===0)return;y(H=>Math.max(0,H-1));return}if(M.key==="Enter"){if(M.preventDefault(),h<w.length){const z=w[h];z&&C(z.path);return}const H=h-w.length,V=_[H];V&&C(V.file.path)}},[h,_,w,C,r]);if(!e)return null;const T=(M,U)=>{if(U.length===0)return M;const H=new Set(U);return M.split("").map((V,z)=>o.jsx("span",{className:H.has(z)?"text-accent font-semibold":"",children:V},z))};let $=-1;const N=n==="page",O=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:M=>{M.target===M.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:E,children:[o.jsx("div",{className:"border-b border-line p-2",children:o.jsx("input",{ref:S,type:"text",value:a,onChange:M=>{c(M.target.value),y(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:b,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?w.length===0&&_.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:[w.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"}),w.map(M=>{$++;const U=$,H=U===h;return o.jsxs("button",{"data-row":U,role:"option","aria-selected":H,onClick:()=>C(M.path),onMouseEnter:()=>y(U),className:`w-full text-left px-3 py-1.5 text-sm flex flex-col gap-0.5 ${H?"bg-bg-hi text-fg":"hover:bg-bg-hi/50 text-fg"}`,children:[o.jsx("span",{className:"truncate",children:M.name}),o.jsx("span",{className:"text-xs text-fg-dim truncate",children:YC(OL(M.path),s)})]},`r:${M.path}`)})]}),_.length>0&&o.jsxs("div",{children:[w.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"}),_.map(({file:M,matched:U})=>{$++;const H=$,V=H===h;return o.jsxs("button",{"data-row":H,role:"option","aria-selected":V,onClick:()=>C(M.path),onMouseEnter:()=>y(H),className:`w-full text-left px-3 py-1.5 text-sm flex flex-col gap-0.5 ${V?"bg-bg-hi text-fg":"hover:bg-bg-hi/50 text-fg"}`,children:[o.jsx("span",{className:"truncate",children:T(M.name,U)}),o.jsx("span",{className:"text-xs text-fg-dim truncate",children:YC(OL(M.path),s)})]},M.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:[_.length+w.length," ",_.length+w.length===1?"file":"files"]})]})]})});return!N&&typeof document<"u"&&document.body?yf.createPortal(O,document.body):O}function RL(e,r){return e.startsWith(r+"/")?e.slice(r.length+1):e===r?"":e}function ahe(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 ohe({open:e,onClose:r,variant:n="overlay"}){const i=Nt(z=>z.tabs.find(F=>F.id===z.activeTabId)??null),s=(i==null?void 0:i.cwd)??"",[a,c]=D.useState(""),[l,u]=D.useState(!1),[f,m]=D.useState([]),[h,y]=D.useState(!1),[x,k]=D.useState(null),[S,b]=D.useState(0),[_,w]=D.useState(null),C=D.useRef(null),E=D.useRef(null),T=D.useRef(0);D.useEffect(()=>{if(!e){c(""),m([]),k(null),b(0);return}const z=setTimeout(()=>{var F;return(F=C.current)==null?void 0:F.focus()},0);return()=>clearTimeout(z)},[e]),D.useEffect(()=>{if(!e||!s)return;const z=a.trim();if(!z){m([]),k(null),y(!1);return}const F=++T.current;y(!0);const Y=setTimeout(()=>{window.api.search.text(s,z,{caseSensitive:l,limit:500}).then(te=>{F===T.current&&(te.ok?(m(te.matches),k(null)):(k(te.error??"unknown error"),m([])),w(te.usedRipgrep))}).catch(te=>{if(F!==T.current)return;const le=te instanceof Error?te.message:String(te);mt.error("global-search","search.text threw",{error:le}),k(le),m([])}).finally(()=>{F===T.current&&y(!1)})},250);return()=>clearTimeout(Y)},[e,s,a,l]);const $=D.useMemo(()=>{const z=new Map;for(const Y of f){const te=z.get(Y.path);te?te.push(Y):z.set(Y.path,[Y])}const F=[];for(const[Y,te]of z)F.push({path:Y,matches:te});return F.sort((Y,te)=>te.matches.length-Y.matches.length||Y.path.localeCompare(te.path)),F},[f]),N=D.useMemo(()=>f,[f]);D.useEffect(()=>{S>=N.length&&b(Math.max(0,N.length-1))},[N.length,S]),D.useEffect(()=>{if(!E.current)return;const z=E.current.querySelector(`[data-match="${S}"]`);z&&z.scrollIntoView({block:"nearest"})},[S]);const O=D.useCallback(z=>{const F=i==null?void 0:i.id;if(!F){rt.error("No active tab to receive path");return}const te=`${(s?RL(z.path,s):z.path)||z.path}:${z.line}`;try{window.api.pty.write({tabId:F,data:te})}catch(le){const pe=le instanceof Error?le.message:String(le);mt.error("global-search","pty.write failed",{error:pe}),rt.error(`Failed to write to terminal: ${pe}`);return}r()},[i==null?void 0:i.id,s,r]),M=D.useCallback(z=>{if(z.key==="Escape"){z.preventDefault(),r();return}if(z.key==="ArrowDown"){if(z.preventDefault(),N.length===0)return;b(F=>Math.min(N.length-1,F+1));return}if(z.key==="ArrowUp"){if(z.preventDefault(),N.length===0)return;b(F=>Math.max(0,F-1));return}if(z.key==="Enter"){z.preventDefault();const F=N[S];F&&O(F)}},[N,S,O,r]);if(!e)return null;const U=n==="page";let H=-1;const V=o.jsx("div",{className:U?"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:U?void 0:z=>{z.target===z.currentTarget&&r()},"data-testid":"global-search-backdrop",children:o.jsxs("div",{role:U?void 0:"dialog","aria-modal":U?void 0:"true","aria-label":"Search in project",className:U?"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:M,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:z=>{c(z.target.value),b(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(z=>!z),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:E,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…"}):x?o.jsx("div",{className:"px-4 py-6 text-sm text-red-400",children:x}):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(z=>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:[RL(z.path,s)," ",o.jsxs("span",{className:"text-fg-faint",children:["(",z.matches.length,")"]})]}),z.matches.map(F=>{H++;const Y=H,te=Y===S;return o.jsxs("button",{"data-match":Y,role:"option","aria-selected":te,onClick:()=>O(F),onMouseEnter:()=>b(Y),className:`w-full text-left px-3 py-1 text-xs font-mono flex gap-3 ${te?"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:F.line}),o.jsx("span",{className:"truncate",children:ahe(F.text,a,l)})]},`${F.path}:${F.line}:${F.column}:${Y}`)})]},z.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",_===!1&&" · fs walk (rg missing)"]})]})]})});return!U&&typeof document<"u"&&document.body?yf.createPortal(V,document.body):V}const lhe=[{key:"files",label:"Files"},{key:"content",label:"Content"}];function che({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(kf,{options:lhe,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(she,{open:!0,onClose:r,variant:"page"}):o.jsx(ohe,{open:!0,onClose:r,variant:"page"})})]}):null}class r8 extends D.Component{constructor(){super(...arguments);Yr(this,"state",{error:null});Yr(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 uhe({open:e,onClose:r,title:n,children:i,variant:s="overlay"}){return o.jsxs(bf,{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(r8,{children:i})})]})}function dhe(e){return/^monitor of /i.test(e.trim())}function ML(e){return e.replace(/\s*\([^)]*\)\s*$/,"").replace(/\s*#\d+\s*$/,"").replace(/\s+/g," ").trim().toLowerCase()}function IL(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=ML(r),a=n.filter(c=>c.label&&ML(c.label)===s);return a.length===1?a[0]:null}async function DL(e){var n;return(n=navigator.mediaDevices)!=null&&n.enumerateDevices?(await navigator.mediaDevices.enumerateDevices()).filter(i=>!(i.kind!=="audioinput"||i.label&&dhe(i.label))):[]}const LL=!1;function n8(){const e=Mt(f=>f.isRecording);Mt(f=>f.startRecording),Mt(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 DL(LL);if(f)return;n(h),c(m.selectedLabel);const y=IL(m.selectedDeviceId,m.selectedLabel,h);y?(s(y.deviceId),m.selectedDeviceId&&y.deviceId!==m.selectedDeviceId&&(mt.info("voice","device-picker rebind-by-label",{fromIdPrefix:m.selectedDeviceId.slice(0,8),toIdPrefix:y.deviceId.slice(0,8)}),await window.api.voice.setDevicePref({selectedDeviceId:y.deviceId,selectedLabel:y.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}),mt.warn("voice","device-picker selected-unavailable",{hadId:!!m.selectedDeviceId})),s(null))}catch(m){mt.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 DL(LL);if(n(f),i&&!f.some(m=>m.deviceId===i)){const m=IL(null,a,f);m?(s(m.deviceId),await window.api.voice.setDevicePref({selectedDeviceId:m.deviceId,selectedLabel:m.label||a}).catch(()=>{})):s(null)}}catch(f){mt.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 x;const m=f.target.value,h=m===""?null:m,y=h?((x=r.find(k=>k.deviceId===h))==null?void 0:x.label)??null:null;s(h),c(y);try{await window.api.voice.setDevicePref({selectedDeviceId:h,selectedLabel:y}),mt.info("voice","device-picker selected",{deviceIdPrefix:h?h.slice(0,8):null})}catch(k){mt.warn("voice","setDevicePref failed",{error:k instanceof Error?k.message:String(k)})}if(e)try{await Mt.getState().restartWithDevice()}catch(k){mt.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 fhe(){const e=Mt(x=>x.isRecording),r=Mt(x=>x.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 x=0,k=!1,S=null,b=null;const _=()=>{if(k)return;const C=b??D4();if(!C){x=requestAnimationFrame(_);return}b!==C&&(b=C,S=new Uint8Array(new ArrayBuffer(C.fftSize)));const E=S;C.getByteTimeDomainData(E);let T=0;for(let M=0;M<E.length;M++){const U=E[M]-128;T+=U*U}const $=Math.sqrt(T/E.length)/128,N=$>0?20*Math.log10($):-60,O=Math.max(0,Math.min(1,(N+60)/60));a($),i(O),$>=.95&&(m(!0),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>m(!1),150)),x=requestAnimationFrame(_)};x=requestAnimationFrame(_);const w=setInterval(()=>{k||u(Math.round(c.current*100))},250);return()=>{k=!0,cancelAnimationFrame(x),clearInterval(w),h.current&&(clearTimeout(h.current),h.current=null)}},[e,r]),!e||!r)return null;const y=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 ${y} transition-[width] duration-75 ease-out`,style:{width:`${n*100}%`}})})}function i8(){const e=Mt(f=>f.submitCountdownStartAt),r=Mt(f=>f.submitDelayMs),[n,i]=D.useState(()=>performance.now());if(D.useEffect(()=>{if(e===null)return;let f;const m=()=>{i(performance.now()),f=requestAnimationFrame(m)};return f=requestAnimationFrame(m),()=>cancelAnimationFrame(f)},[e]),e===null)return null;const s=n-e,a=Math.max(0,r-s),c=Math.max(0,Math.min(100,a/r*100)),l=a<500,u=Mt.getState().cancelSubmit;return o.jsx("div",{className:"px-3 pb-1",onClick:u,title:`Submitting in ${(a/1e3).toFixed(1)}s — click to cancel`,children:o.jsx("div",{className:"h-0.5 w-full bg-bg rounded overflow-hidden cursor-pointer",children:o.jsx("div",{className:`h-full transition-colors ${l?"bg-amber-400":"bg-accent"}`,style:{width:`${c}%`}})})})}function hhe({open:e,onClose:r,variant:n="overlay"}){return o.jsx(uhe,{open:e,onClose:r,title:"Voice / Microphone",variant:n,children:o.jsxs("div",{className:"p-4 space-y-4",children:[o.jsx(vhe,{}),o.jsx(i8,{}),o.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[o.jsx(B4,{}),o.jsx(n8,{}),o.jsx(_W,{})]}),o.jsx(phe,{}),o.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[o.jsx("button",{type:"button",onClick:()=>Mt.getState().openWizard(),className:"text-xs text-fg-faint hover:text-fg-dim underline","data-testid":"run-mic-check",children:"Run mic check"}),o.jsx(ghe,{})]}),o.jsx(fhe,{})]})})}function phe(){const e=Mt(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=mhe(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 mhe(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 ghe(){const[e,r]=D.useState(null);if(D.useEffect(()=>{let i=!1;window.api.voice.getHotkeyConfig().then(a=>{i||r(a)}).catch(a=>mt.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){mt.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 vhe(){const e=Mt(a=>a.isRecording),r=Mt(a=>a.lastTranscript),n=Mt(a=>a.error),i=Mt(a=>a.modelStatus),s=Mt(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 JC=null;function yhe(){return JC||(JC=sb(()=>import("./monaco-editor-BW5C4Iv1.js").then(e=>e.b),__vite__mapDeps([1,2]),import.meta.url).then(e=>(rA.config({monaco:e}),e))),JC}function s8({value:e,onChange:r,path:n,readOnly:i}){const s=D.useRef(null),a=c=>{s.current=c};return o.jsx(nA,{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 BL=!1;async function bhe(e){if(BL)return;const r=await yhe(),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}),BL=!0}function o$({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,y=((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:Pi[r].label})]}),y&&o.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:l,onChange:x=>u(x.target.checked),className:"accent-accent"}),"show unset keys"]}),o.jsx("div",{className:"flex-1"}),o.jsx("input",{value:a,onChange:x=>c(x.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(a8,{node:e,path:f,label:s??"(root)",targetScope:r,onOverride:n,filter:a,depth:0,schema:i,showGhosts:l,defaultOpen:!0})})]})}function a8(e){return e.node.kind==="object"?o.jsx(xhe,{...e,node:e.node}):e.node.kind==="array"?o.jsx(whe,{...e,node:e.node}):o.jsx(_he,{...e,node:e.node})}function zL(e,r){return r.trim()?e.toLowerCase().includes(r.toLowerCase()):!0}function cm(e,r,n){return!!(!n.trim()||e.some(i=>zL(i,n))||r!=null&&r.description&&zL(r.description,n))}function xhe({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),y=(l==null?void 0:l.at(r))??null,x=new Set(Object.keys(e.children)),k=u?(y==null?void 0:y.knownChildren)??[]:[],S=Array.from(new Set([...x,...k])).sort(),b=D.useMemo(()=>a.trim()?S.filter(w=>{const C=(l==null?void 0:l.at([...r,w]))??null;return cm([...r,w],C,a)?!0:x.has(w)?o8(e.children[w],[...r,w],a,l):!1}):S,[S.join(","),a,e,r.join("."),l]);if(a.trim()&&b.length===0&&!cm(r,y,a))return null;if(r.length===0)return o.jsx("div",{children:b.map(w=>_(w))});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:[" {",x.size,k.length>x.size?`/${new Set([...x,...k]).size}`:"","}"]}),(y==null?void 0:y.description)&&o.jsxs("span",{className:"text-fg-faint truncate max-w-md",title:y.description,children:["— ",y.description]})]}),m&&b.map(w=>_(w))]});function _(w){if(x.has(w))return o.jsx(a8,{node:e.children[w],path:[...r,w],label:w,targetScope:i,onOverride:s,filter:a,depth:c+1,schema:l,showGhosts:u},w);const C=(l==null?void 0:l.at([...r,w]))??null;return C?o.jsx(She,{path:[...r,w],label:w,info:C,targetScope:i,onSet:s,depth:c+1,filter:a},w):null}}function o8(e,r,n,i){const s=(i==null?void 0:i.at(r))??null;if(cm(r,s,n))return!0;if(e.kind!=="object")return!1;for(const a of Object.keys(e.children))if(o8(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 cm(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:Y0(f.value)}),o.jsx(fT,{scope:f.fromScope})]},m))]}):null}function _he({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(!cm(r,m,a))return null;const h=e.winner!==i,y=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 ${y?"text-fg-faint cursor-pointer":""}`,onClick:()=>y&&f(!u),children:y?u?"▾":"▸":""}),o.jsxs("span",{className:"text-fg",children:[n,":"]}),o.jsx("span",{className:"text-fg-dim truncate max-w-md",children:Y0(e.value)}),o.jsx(fT,{scope:e.winner}),(m==null?void 0:m.deprecated)&&o.jsx(eb,{tone:"warn",children:"deprecated"}),(m==null?void 0:m.default)!==void 0&&khe(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(l8,{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 ${Pi[i].label} draft`:`already winning in ${Pi[i].label}`,children:"override"})]}),u&&e.shadowed.map((x,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:Y0(x.value)}),o.jsx(fT,{scope:x.scope,dim:!0})]},k))]})}function She({path:e,label:r,info:n,targetScope:i,onSet:s,depth:a,filter:c}){if(!cm(e,n,c))return null;const l=n.default!==void 0?n.default:Che(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: ",Y0(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(l8,{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 ${Pi[i].label} draft`,children:"set"})]})}function khe(e,r){return e===r?!0:typeof e!=typeof r?!1:e&&r&&typeof e=="object"?JSON.stringify(e)===JSON.stringify(r):!1}function Che(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 Y0(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 fT({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:Pi[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 l8({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 jhe=[{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"]}],Ehe={mcp:"MCP",url:"URL",urls:"URLs",http:"HTTP",ui:"UI",id:"ID",uuid:"UUID",api:"API",aws:"AWS",otel:"OTel",json:"JSON"};function c8(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=Ehe[i];return a||(s===0?i.charAt(0).toUpperCase()+i.slice(1):i)}).join(" ")}function The(e){const r=new Set,n=[];for(const s of jhe){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 Ahe=["user","project","local","default"],$he={user:"user",project:"project",local:"local",default:"default"};function Nhe({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):[],y=i.rootKeys(),x=new Set([...h,...y]),k=D.useMemo(()=>The(x),[Array.from(x).sort().join(",")]),S=D.useMemo(()=>k.filter(b=>c||!b.advanced).map(b=>({...b,keys:b.keys.filter(_=>{const w=(m==null?void 0:m.children[_])!==void 0;if(!u&&!w)return!1;if(!s.trim())return!0;const C=i.at([_]);return[_,c8(_),(C==null?void 0:C.description)??""].join(" ").toLowerCase().includes(s.toLowerCase())})})).filter(b=>b.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:Pi[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:b=>f(b.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:b=>l(b.target.checked),className:"accent-accent"}),"show advanced"]}),o.jsx("div",{className:"flex-1"}),o.jsx("input",{value:s,onChange:b=>a(b.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(b=>o.jsx(Ohe,{title:b.title,summary:b.summary,advanced:b.advanced,children:b.keys.map(_=>{const w=m==null?void 0:m.children[_],C=i.at([_]);return o.jsx(Phe,{keyName:_,node:w,info:C,targetScope:r,onOverride:(E,T)=>n([_],E,T)},_)})},b.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 Ohe({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 Phe({keyName:e,node:r,info:n,targetScope:i,onOverride:s}){const[a,c]=D.useState(!1),[l,u]=D.useState(!1),f=c8(e),m=r!==void 0,y=(r==null?void 0:r.kind)==="leaf"?r:null,x=(r==null?void 0:r.kind)==="object"||(r==null?void 0:r.kind)==="array",k=n==null?void 0:n.default,S=y&&k!==void 0&&d8(y.value,k),b=Fhe({isSet:m,leafNode:y,defaultVal:k,isDefault:!!S,node:r}),_=Rhe(y,k),w=_.length>=2,C=!!y&&!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(Uhe,{kind:b.kind,label:b.label}),w&&o.jsxs("button",{onClick:E=>{E.stopPropagation(),a||c(!0),u(T=>!T)},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 · ",_.map(E=>$he[E]).join(" · ")]}),C&&y&&o.jsx("button",{onClick:E=>{E.stopPropagation(),s(void 0,y.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 ${Pi[y.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:qhe(n.description)}),a&&l&&y&&o.jsx(Mhe,{leaf:y,defaultVal:k,onReset:E=>s(void 0,E)}),a&&o.jsx(Ihe,{keyName:e,node:r,info:n,targetScope:i,onOverride:E=>s(E)})]}),o.jsx("div",{className:"shrink-0",children:!a&&o.jsx(zhe,{node:r,info:n,onSet:E=>{s(E)},disabled:x&&m})})]})})}function Rhe(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"),Ahe.filter(i=>n.has(i))}function Mhe({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:Pi[s].label}),o.jsx("span",{className:`font-mono truncate ${a!=null&&a.winner?"text-accent":"text-fg-dim"}`,children:c?Mp(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 ${Pi[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?Mp(r):o.jsx("span",{className:"text-fg-faint",children:"—"})}),o.jsx("span",{})]})]})]})}function Ihe({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:Mp(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:Mp(c.value)}),o.jsxs("span",{className:"ml-2 text-fg-faint",children:["from ",Pi[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:[Mp(l.value)," —"," ",o.jsx("span",{className:"no-underline",children:Pi[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(Dhe,{keyName:e,node:r,info:n,onChange:s,targetScope:i})})]})}function Dhe({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=u8(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:["→ ",Pi[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=d8(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:["→ ",Pi[i].label]})]}):c==="integer"||c==="number"?o.jsx(Lhe,{value:typeof a=="number"?a:void 0,integer:c==="integer",onCommit:n,target:Pi[i].label}):c==="string"?o.jsx(Bhe,{value:typeof a=="string"?a:"",onCommit:n,target:Pi[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 Lhe({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 Bhe({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 zhe({node:e,info:r,onSet:n,disabled:i}){const s=(e==null?void 0:e.kind)==="leaf",a=u8(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 Fhe({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 · ${Pi[r.winner].label}`}:r.shadowed.length>0?{kind:"override",label:`overriding ${r.shadowed.length} scope(s)`}:{kind:"set",label:`set in ${Pi[r.winner].label}`}:{kind:"set",label:"configured"}:n!==void 0?{kind:"default",label:`using default: ${Mp(n)}`}:{kind:"unset",label:"not configured"}}function Uhe({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 u8(e){if(e)return Array.isArray(e)?e.find(n=>n!=="null")??e[0]:e}function d8(e,r){return e===r?!0:typeof e!=typeof r?!1:e&&r&&typeof e=="object"?JSON.stringify(e)===JSON.stringify(r):!1}function qhe(e){const r=e.trim().split(`
3448
+ `).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:()=>_(T.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!==T.line&&o.jsx("pre",{className:"px-3 pb-2 pl-12 font-mono text-[11px] text-fg-dim whitespace-pre-wrap break-all",children:T.error?T.raw:JSON.stringify(T.value,null,2)})]},T.line)})})]})}function Jfe(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 Zfe({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," · ",Jfe(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 Qfe=D.lazy(()=>sb(()=>import("./TiptapBody-B_2hT1QJ.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(e=>({default:e.TiptapBody})));function aw(e){return e.split("/").filter(Boolean).pop()||e}function ow(e){return V4(e)||G4(e)}function dT(){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.closeAll),f=Cn(Me=>Me.loadBuffer),m=Cn(Me=>Me.setBuffer),h=Cn(Me=>Me.markSaved),y=Cn(Me=>Me.setViewMode),x=Yv(),[k,S]=D.useState({}),[b,_]=D.useState({}),[w,C]=D.useState(null),[E,T]=D.useState(null),[$,N]=D.useState(!1),[O,M]=D.useState(!1),[U,H]=D.useState(!0),V=D.useRef(null),z=D.useRef(null),F=D.useRef(void 0),Y=D.useCallback(Me=>{V.current=Me},[]),te=D.useCallback(()=>V.current,[]);D.useEffect(()=>{const Me=r;if(!Me||ow(Me))return;if(Cn.getState().hasBuffer(Me)){S(Ue=>Ue[Me]==="ready"?Ue:{...Ue,[Me]:"ready"});return}let Le=!1;return S(Ue=>({...Ue,[Me]:"loading"})),window.api.files.read(Me).then(Ue=>{Le||(Ue.binary?S(st=>({...st,[Me]:{binary:!0,size:Ue.size??0,mime:Ue.mime??"application/octet-stream",reason:Ue.error??"Binary file"}})):Ue.ok?(f(Me,Ue.text),S(st=>({...st,[Me]:"ready"}))):S(st=>({...st,[Me]:{error:Ue.error??"failed to read"}})))}),()=>{Le=!0}},[r,f]),D.useEffect(()=>{T(null)},[r]);const le=D.useCallback(async(Me,Le=!1)=>{const Ue=Cn.getState().buffers[Me];if(Ue==null)return;Le&&N(!0);const st=await window.api.files.write(Me,Ue);st.ok?(h(Me),_(lt=>({...lt,[Me]:(lt[Me]??0)+1})),Le||rt.info(`Saved ${aw(Me)}`)):rt.error(st.error??`Couldn't save ${aw(Me)}`),Le&&N(!1)},[h]);D.useEffect(()=>{if(!x.autosave)return;const Me=r;if(!(!Me||ow(Me)||!n[Me]))return window.clearTimeout(F.current),F.current=window.setTimeout(()=>{le(Me,!0)},1200),()=>window.clearTimeout(F.current)},[x.autosave,r,n,s,le]),D.useEffect(()=>{const Me=Le=>{if((Le.metaKey||Le.ctrlKey)&&(Le.key==="s"||Le.key==="S")){const Ue=Cn.getState().activeFilePath;Ue&&!ow(Ue)&&(Le.preventDefault(),le(Ue))}else(Le.metaKey||Le.ctrlKey)&&Le.shiftKey&&(Le.key==="f"||Le.key==="F")?(Le.preventDefault(),M(Ue=>!Ue)):Le.key==="Escape"&&O&&M(!1)};return window.addEventListener("keydown",Me),()=>window.removeEventListener("keydown",Me)},[le,O]);const pe=D.useCallback(Me=>{n[Me]?C({kind:"one",path:Me}):c(Me)},[n,c]),X=D.useCallback(Me=>{e.some(Ue=>Ue.path!==Me&&n[Ue.path])?C({kind:"others",path:Me}):l(Me)},[e,n,l]),Q=D.useCallback(()=>{e.some(Le=>n[Le.path])?C({kind:"all",path:""}):u()},[e,n,u]),J=()=>{w&&(w.kind==="one"?c(w.path):w.kind==="others"?l(w.path):u(),C(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 ee=r,ae=ee?aw(ee):"",me=ee?k[ee]:void 0,_e=ee?Y4(ee):!1,Ne=ee?ZW(ee):!1,xe=ee&&_e?i[ee]??QW(ee):"edit",ie=!!ee&&!ow(ee)&&me==="ready",ce=ie,ge=Ne?["edit","wysiwyg","preview","split"]:_e?["edit","preview"]:[],Ae=ee&&o.jsx(Mfe,{path:ee,name:ae,value:s[ee]??"",onChange:Me=>m(ee,Me),onSave:()=>void le(ee),onReady:Y,onCursor:T}),Te=$?"Saving…":ee&&n[ee]?x.autosave?"Editing…":"Unsaved":"All changes saved";return o.jsxs("div",{className:"relative flex flex-col h-full bg-bg",children:[!O&&o.jsx(Nfe,{openFiles:e,activeFilePath:r,dirty:n,onSelectFile:a,onCloseFile:pe,onCloseOthers:X,onCloseAll:Q}),ee&&!O&&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:ae}),o.jsx("span",{className:"ml-3 text-[10px] text-fg-faint truncate",children:ee}),ie&&o.jsxs("span",{className:"ml-3 text-[10px] text-fg-faint shrink-0",children:["· ",Te]}),o.jsx("div",{className:"flex-1"}),Wd(ee)&&(xe==="preview"||xe==="split")&&o.jsx("button",{onClick:()=>H(Me=>!Me),className:`px-2 py-0.5 text-[10px] border border-line rounded mr-1 ${U?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Toggle document outline",children:"Outline"}),ie&&o.jsxs("div",{className:"flex items-center mr-2 rounded border border-line overflow-hidden",children:[o.jsx("button",{onClick:()=>x.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:()=>x.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:x.toggleWordWrap,className:`px-1.5 py-0.5 text-[10px] ${x.wordWrap?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Word wrap",children:"Wrap"}),o.jsx("button",{onClick:x.toggleMinimap,className:`px-1.5 py-0.5 text-[10px] ${x.minimap?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Minimap",children:"Map"}),o.jsx("button",{onClick:()=>x.setTheme(x.theme==="dark"?"paper":"dark"),className:"px-1.5 py-0.5 text-[10px] text-fg-faint hover:text-fg",title:"Toggle editor theme",children:x.theme==="dark"?"Dark":"Paper"}),o.jsx("button",{onClick:x.toggleAutosave,className:`px-1.5 py-0.5 text-[10px] ${x.autosave?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Autosave",children:"Auto"})]}),ge.length>0&&o.jsx("div",{className:"flex items-center mr-2 rounded border border-line overflow-hidden",children:ge.map(Me=>o.jsx("button",{onClick:()=>y(ee,Me),className:`px-2 py-0.5 text-[10px] capitalize transition-colors ${xe===Me?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,children:Me},Me))}),o.jsx("button",{onClick:()=>M(!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:ee}),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:ee}),className:"px-2 py-0.5 text-[10px] text-fg-faint hover:text-fg border border-line rounded",title:"Reveal in OS",children:"Reveal"})]}),O&&o.jsx("button",{onClick:()=>M(!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:ee?V4(ee)?o.jsx(Wfe,{path:ee,name:ae}):G4(ee)?o.jsx(Hfe,{path:ee}):me&&typeof me=="object"&&"binary"in me?o.jsx(Zfe,{path:ee,name:ae,size:me.size,mime:me.mime,reason:me.reason}):me&&typeof me=="object"&&"error"in me?o.jsx("div",{className:"p-6 text-xs text-red-400",children:me.error}):me!=="ready"?o.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"loading…"}):xe==="wysiwyg"&&Wd(ee)?o.jsx(D.Suspense,{fallback:o.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"Loading editor…"}),children:o.jsx(Qfe,{value:s[ee]??"",onChange:Me=>m(ee,Me)},ee)}):xe==="split"&&Wd(ee)?o.jsxs("div",{className:"flex h-full",children:[U&&o.jsx(TL,{text:s[ee]??"",scrollRef:z}),o.jsxs("div",{className:"flex-1 min-w-0 flex flex-col border-r border-line",children:[o.jsx(EL,{getEditor:te}),o.jsx("div",{className:"flex-1 min-h-0",children:Ae})]}),o.jsx("div",{className:"flex-1 min-w-0",children:o.jsx(jL,{ref:z,text:s[ee]??"",flush:!0})})]}):xe==="preview"&&Wd(ee)?o.jsxs("div",{className:"flex h-full",children:[U&&o.jsx(TL,{text:s[ee]??"",scrollRef:z}),o.jsx("div",{className:"flex-1 min-w-0",children:o.jsx(jL,{ref:z,text:s[ee]??""})})]}):xe==="preview"&&H4(ee)?o.jsx(Ufe,{path:ee,dirty:!!n[ee],reloadToken:b[ee]??0}):xe==="preview"&&K4(ee)?o.jsx(Gfe,{path:ee,text:s[ee]??""}):xe==="preview"&&X4(ee)?o.jsx(Yfe,{path:ee,text:s[ee]??""}):Wd(ee)?o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsx(EL,{getEditor:te}),o.jsx("div",{className:"flex-1 min-h-0",children:Ae})]}):Ae:null}),ce&&o.jsx(Ffe,{text:s[ee]??"",cursor:E,language:Sc(ee)||void 0}),w&&o.jsx(ehe,{message:w.kind==="one"?`Discard unsaved changes to ${aw(w.path)}?`:w.kind==="others"?"Discard unsaved changes in the other open files?":"Discard unsaved changes in all open files?",onCancel:()=>C(null),onConfirm:J})]})}function ehe({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 AL={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"},the={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 KC(e){return e>=1e6?(e/1e6).toFixed(1)+"M":e>=1e3?(e/1e3).toFixed(1)+"K":String(e)}function rhe({open:e,onClose:r,variant:n="overlay"}){const i=Nt(T=>T.tabs.find($=>$.id===T.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),y=D.useCallback(async T=>{u(!0),m(null);try{const $=await window.api.repo.analyze(T);$.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}y(s)}},[e,s,y]),D.useEffect(()=>{var $;if(!e)return;const T=N=>{N.key==="Escape"&&(N.stopPropagation(),r())};return window.addEventListener("keydown",T),($=h.current)==null||$.focus(),()=>window.removeEventListener("keydown",T)},[e,r]);const x=D.useCallback(()=>{s&&y(s)},[s,y]),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]),b=D.useMemo(()=>{if(!a)return[];const T=a.topDirectories;if(T.length===0)return[];const $=T.map(O=>Math.sqrt(Math.max(1,O.fileCount))),N=$.reduce((O,M)=>O+M,0)||1;return T.map((O,M)=>({path:O.path,fileCount:O.fileCount,totalLines:O.totalLines,basis:$[M]/N*100}))},[a]);if(!e)return null;const _=T=>{T.target===T.currentTarget&&r()},w=s?s.split("/").filter(Boolean).pop()||s:"no folder",C=n==="page",E=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:_,"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:[w,(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:x,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(XC,{label:"Files",value:KC(a.totalFiles)}),o.jsx(XC,{label:"Lines of code",value:KC(a.totalLines)}),o.jsx(XC,{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(([T,$,N])=>{const O=AL[T]??AL.other,M=the[T]??T,U=$/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:M,children:M}),o.jsx("div",{className:"flex-1 h-4 bg-bg rounded overflow-hidden",children:o.jsx("div",{className:"h-full rounded",style:{width:`${U}%`,backgroundColor:O}})}),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:[KC(N)," L"]})]},T)})})]}),o.jsxs("section",{children:[o.jsx("h3",{className:"text-xs uppercase tracking-wider text-fg-faint mb-2",children:"Top directories"}),b.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:b.map(T=>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(T.basis,6)}%`,flexGrow:T.basis>15?1:0},title:`${T.path} — ${T.fileCount} files, ${T.totalLines.toLocaleString()} lines`,children:[o.jsx("div",{className:"text-[11px] font-mono text-fg truncate",children:T.path}),o.jsxs("div",{className:"text-[10px] text-fg-dim font-mono",children:[T.fileCount," files"]})]},T.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?yf.createPortal(E,document.body):E}function XC({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 kf({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 $L=e=>/[/\\\-_.\s]/.test(e),NL=e=>e>="A"&&e<="Z";function nhe(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},(_,w)=>w)};if(l.startsWith(i))return{match:!0,score:900,matched:Array.from({length:e.length},(_,w)=>w)};let u=0;for(const _ of a.split("/")){if(_===i)return{match:!0,score:800,matched:[]};_.startsWith(i)&&(u=Math.max(u,700))}const f=l.indexOf(i);if(f!==-1)return{match:!0,score:f===0||$L(l[f-1])||NL(c[f])?650:600,matched:Array.from({length:e.length},(w,C)=>f+C)};if(a.includes(i))return{match:!0,score:Math.max(500,u),matched:[]};let m=0,h=0,y=0,x=-1,k=0;const S=[];for(let _=0;_<s.length&&m<i.length;_++)s[_]===i[m]&&(S.push(_),h+=10,x===_-1?(y++,h+=y*8):y=0,(_===0||$L(s[_-1])||NL(r[_]))&&(k++,h+=15,_===0&&(h+=10)),x=_,m++);if(m!==i.length)return{match:!1,score:0,matched:[]};const b=Math.max(0,50-(s.length-i.length));if(h+=b,k>=i.length*.5&&(h+=30),S.length>1){const _=S[S.length-1]-S[0];_>i.length*3&&(h-=Math.min(50,(_-i.length*3)*2))}return{match:!0,score:Math.max(1,h),matched:S}}function YC(e,r){return e.startsWith(r+"/")?e.slice(r.length+1):e===r?"":e}function OL(e){const r=e.lastIndexOf("/");return r<0?"":e.slice(0,r)}const PL="session-manager.quickopen.recent",ihe=8;function she({open:e,onClose:r,variant:n="overlay"}){const i=Nt(M=>M.tabs.find(U=>U.id===M.activeTabId)??null),s=(i==null?void 0:i.cwd)??"",[a,c]=D.useState(""),[l,u]=D.useState([]),[f,m]=D.useState(!1),[h,y]=D.useState(0),[x,k]=D.useState([]),S=D.useRef(null),b=D.useRef(null);D.useEffect(()=>{if(e)try{const M=localStorage.getItem(PL);M&&k(JSON.parse(M))}catch{}},[e]),D.useEffect(()=>{if(!e){c(""),y(0);return}const M=setTimeout(()=>{var U;return(U=S.current)==null?void 0:U.focus()},0);return()=>clearTimeout(M)},[e]),D.useEffect(()=>{if(!e||!s)return;let M=!1;return m(!0),window.api.search.files(s,"",{limit:5e3}).then(U=>{if(!M){if(!U.ok){rt.error(`File search failed: ${U.error??"unknown error"}`),u([]);return}u(U.files)}}).catch(U=>{const H=U instanceof Error?U.message:String(U);mt.error("quick-open","search.files threw",{error:H}),rt.error(`File search failed: ${H}`),u([])}).finally(()=>{M||m(!1)}),()=>{M=!0}},[e,s]);const _=D.useMemo(()=>{if(!a.trim())return[...l].sort((V,z)=>V.name.localeCompare(z.name)).slice(0,100).map(V=>({file:V,score:0,matched:[]}));const M=a.trim(),U=[];for(const H of l){const V=nhe(M,H.name,H.path);V.match&&U.push({file:H,score:V.score,matched:V.matched})}return U.sort((H,V)=>V.score-H.score),U.slice(0,100)},[l,a]),w=D.useMemo(()=>a.trim()?[]:x.map(M=>l.find(U=>U.path===M)||null).filter(M=>M!==null).slice(0,5),[x,l,a]);D.useEffect(()=>{const M=w.length+_.length;h>=M&&y(Math.max(0,M-1))},[w.length,_.length,h]),D.useEffect(()=>{if(!b.current)return;const M=b.current.querySelector(`[data-row="${h}"]`);M&&M.scrollIntoView({block:"nearest"})},[h]);const C=D.useCallback(M=>{try{const z=[M,...x.filter(F=>F!==M)].slice(0,ihe);k(z),localStorage.setItem(PL,JSON.stringify(z))}catch{}const U=i==null?void 0:i.id;if(!U){rt.error("No active tab to receive file path");return}const V=(s?YC(M,s):M)||M;try{window.api.pty.write({tabId:U,data:V})}catch(z){const F=z instanceof Error?z.message:String(z);mt.error("quick-open","pty.write failed",{error:F}),rt.error(`Failed to write to terminal: ${F}`);return}r()},[i==null?void 0:i.id,s,x,r]),E=D.useCallback(M=>{const U=w.length+_.length;if(M.key==="Escape"){M.preventDefault(),r();return}if(M.key==="ArrowDown"){if(M.preventDefault(),U===0)return;y(H=>Math.min(U-1,H+1));return}if(M.key==="ArrowUp"){if(M.preventDefault(),U===0)return;y(H=>Math.max(0,H-1));return}if(M.key==="Enter"){if(M.preventDefault(),h<w.length){const z=w[h];z&&C(z.path);return}const H=h-w.length,V=_[H];V&&C(V.file.path)}},[h,_,w,C,r]);if(!e)return null;const T=(M,U)=>{if(U.length===0)return M;const H=new Set(U);return M.split("").map((V,z)=>o.jsx("span",{className:H.has(z)?"text-accent font-semibold":"",children:V},z))};let $=-1;const N=n==="page",O=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:M=>{M.target===M.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:E,children:[o.jsx("div",{className:"border-b border-line p-2",children:o.jsx("input",{ref:S,type:"text",value:a,onChange:M=>{c(M.target.value),y(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:b,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?w.length===0&&_.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:[w.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"}),w.map(M=>{$++;const U=$,H=U===h;return o.jsxs("button",{"data-row":U,role:"option","aria-selected":H,onClick:()=>C(M.path),onMouseEnter:()=>y(U),className:`w-full text-left px-3 py-1.5 text-sm flex flex-col gap-0.5 ${H?"bg-bg-hi text-fg":"hover:bg-bg-hi/50 text-fg"}`,children:[o.jsx("span",{className:"truncate",children:M.name}),o.jsx("span",{className:"text-xs text-fg-dim truncate",children:YC(OL(M.path),s)})]},`r:${M.path}`)})]}),_.length>0&&o.jsxs("div",{children:[w.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"}),_.map(({file:M,matched:U})=>{$++;const H=$,V=H===h;return o.jsxs("button",{"data-row":H,role:"option","aria-selected":V,onClick:()=>C(M.path),onMouseEnter:()=>y(H),className:`w-full text-left px-3 py-1.5 text-sm flex flex-col gap-0.5 ${V?"bg-bg-hi text-fg":"hover:bg-bg-hi/50 text-fg"}`,children:[o.jsx("span",{className:"truncate",children:T(M.name,U)}),o.jsx("span",{className:"text-xs text-fg-dim truncate",children:YC(OL(M.path),s)})]},M.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:[_.length+w.length," ",_.length+w.length===1?"file":"files"]})]})]})});return!N&&typeof document<"u"&&document.body?yf.createPortal(O,document.body):O}function RL(e,r){return e.startsWith(r+"/")?e.slice(r.length+1):e===r?"":e}function ahe(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 ohe({open:e,onClose:r,variant:n="overlay"}){const i=Nt(z=>z.tabs.find(F=>F.id===z.activeTabId)??null),s=(i==null?void 0:i.cwd)??"",[a,c]=D.useState(""),[l,u]=D.useState(!1),[f,m]=D.useState([]),[h,y]=D.useState(!1),[x,k]=D.useState(null),[S,b]=D.useState(0),[_,w]=D.useState(null),C=D.useRef(null),E=D.useRef(null),T=D.useRef(0);D.useEffect(()=>{if(!e){c(""),m([]),k(null),b(0);return}const z=setTimeout(()=>{var F;return(F=C.current)==null?void 0:F.focus()},0);return()=>clearTimeout(z)},[e]),D.useEffect(()=>{if(!e||!s)return;const z=a.trim();if(!z){m([]),k(null),y(!1);return}const F=++T.current;y(!0);const Y=setTimeout(()=>{window.api.search.text(s,z,{caseSensitive:l,limit:500}).then(te=>{F===T.current&&(te.ok?(m(te.matches),k(null)):(k(te.error??"unknown error"),m([])),w(te.usedRipgrep))}).catch(te=>{if(F!==T.current)return;const le=te instanceof Error?te.message:String(te);mt.error("global-search","search.text threw",{error:le}),k(le),m([])}).finally(()=>{F===T.current&&y(!1)})},250);return()=>clearTimeout(Y)},[e,s,a,l]);const $=D.useMemo(()=>{const z=new Map;for(const Y of f){const te=z.get(Y.path);te?te.push(Y):z.set(Y.path,[Y])}const F=[];for(const[Y,te]of z)F.push({path:Y,matches:te});return F.sort((Y,te)=>te.matches.length-Y.matches.length||Y.path.localeCompare(te.path)),F},[f]),N=D.useMemo(()=>f,[f]);D.useEffect(()=>{S>=N.length&&b(Math.max(0,N.length-1))},[N.length,S]),D.useEffect(()=>{if(!E.current)return;const z=E.current.querySelector(`[data-match="${S}"]`);z&&z.scrollIntoView({block:"nearest"})},[S]);const O=D.useCallback(z=>{const F=i==null?void 0:i.id;if(!F){rt.error("No active tab to receive path");return}const te=`${(s?RL(z.path,s):z.path)||z.path}:${z.line}`;try{window.api.pty.write({tabId:F,data:te})}catch(le){const pe=le instanceof Error?le.message:String(le);mt.error("global-search","pty.write failed",{error:pe}),rt.error(`Failed to write to terminal: ${pe}`);return}r()},[i==null?void 0:i.id,s,r]),M=D.useCallback(z=>{if(z.key==="Escape"){z.preventDefault(),r();return}if(z.key==="ArrowDown"){if(z.preventDefault(),N.length===0)return;b(F=>Math.min(N.length-1,F+1));return}if(z.key==="ArrowUp"){if(z.preventDefault(),N.length===0)return;b(F=>Math.max(0,F-1));return}if(z.key==="Enter"){z.preventDefault();const F=N[S];F&&O(F)}},[N,S,O,r]);if(!e)return null;const U=n==="page";let H=-1;const V=o.jsx("div",{className:U?"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:U?void 0:z=>{z.target===z.currentTarget&&r()},"data-testid":"global-search-backdrop",children:o.jsxs("div",{role:U?void 0:"dialog","aria-modal":U?void 0:"true","aria-label":"Search in project",className:U?"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:M,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:z=>{c(z.target.value),b(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(z=>!z),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:E,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…"}):x?o.jsx("div",{className:"px-4 py-6 text-sm text-red-400",children:x}):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(z=>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:[RL(z.path,s)," ",o.jsxs("span",{className:"text-fg-faint",children:["(",z.matches.length,")"]})]}),z.matches.map(F=>{H++;const Y=H,te=Y===S;return o.jsxs("button",{"data-match":Y,role:"option","aria-selected":te,onClick:()=>O(F),onMouseEnter:()=>b(Y),className:`w-full text-left px-3 py-1 text-xs font-mono flex gap-3 ${te?"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:F.line}),o.jsx("span",{className:"truncate",children:ahe(F.text,a,l)})]},`${F.path}:${F.line}:${F.column}:${Y}`)})]},z.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",_===!1&&" · fs walk (rg missing)"]})]})]})});return!U&&typeof document<"u"&&document.body?yf.createPortal(V,document.body):V}const lhe=[{key:"files",label:"Files"},{key:"content",label:"Content"}];function che({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(kf,{options:lhe,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(she,{open:!0,onClose:r,variant:"page"}):o.jsx(ohe,{open:!0,onClose:r,variant:"page"})})]}):null}class r8 extends D.Component{constructor(){super(...arguments);Yr(this,"state",{error:null});Yr(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 uhe({open:e,onClose:r,title:n,children:i,variant:s="overlay"}){return o.jsxs(bf,{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(r8,{children:i})})]})}function dhe(e){return/^monitor of /i.test(e.trim())}function ML(e){return e.replace(/\s*\([^)]*\)\s*$/,"").replace(/\s*#\d+\s*$/,"").replace(/\s+/g," ").trim().toLowerCase()}function IL(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=ML(r),a=n.filter(c=>c.label&&ML(c.label)===s);return a.length===1?a[0]:null}async function DL(e){var n;return(n=navigator.mediaDevices)!=null&&n.enumerateDevices?(await navigator.mediaDevices.enumerateDevices()).filter(i=>!(i.kind!=="audioinput"||i.label&&dhe(i.label))):[]}const LL=!1;function n8(){const e=Mt(f=>f.isRecording);Mt(f=>f.startRecording),Mt(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 DL(LL);if(f)return;n(h),c(m.selectedLabel);const y=IL(m.selectedDeviceId,m.selectedLabel,h);y?(s(y.deviceId),m.selectedDeviceId&&y.deviceId!==m.selectedDeviceId&&(mt.info("voice","device-picker rebind-by-label",{fromIdPrefix:m.selectedDeviceId.slice(0,8),toIdPrefix:y.deviceId.slice(0,8)}),await window.api.voice.setDevicePref({selectedDeviceId:y.deviceId,selectedLabel:y.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}),mt.warn("voice","device-picker selected-unavailable",{hadId:!!m.selectedDeviceId})),s(null))}catch(m){mt.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 DL(LL);if(n(f),i&&!f.some(m=>m.deviceId===i)){const m=IL(null,a,f);m?(s(m.deviceId),await window.api.voice.setDevicePref({selectedDeviceId:m.deviceId,selectedLabel:m.label||a}).catch(()=>{})):s(null)}}catch(f){mt.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 x;const m=f.target.value,h=m===""?null:m,y=h?((x=r.find(k=>k.deviceId===h))==null?void 0:x.label)??null:null;s(h),c(y);try{await window.api.voice.setDevicePref({selectedDeviceId:h,selectedLabel:y}),mt.info("voice","device-picker selected",{deviceIdPrefix:h?h.slice(0,8):null})}catch(k){mt.warn("voice","setDevicePref failed",{error:k instanceof Error?k.message:String(k)})}if(e)try{await Mt.getState().restartWithDevice()}catch(k){mt.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 fhe(){const e=Mt(x=>x.isRecording),r=Mt(x=>x.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 x=0,k=!1,S=null,b=null;const _=()=>{if(k)return;const C=b??D4();if(!C){x=requestAnimationFrame(_);return}b!==C&&(b=C,S=new Uint8Array(new ArrayBuffer(C.fftSize)));const E=S;C.getByteTimeDomainData(E);let T=0;for(let M=0;M<E.length;M++){const U=E[M]-128;T+=U*U}const $=Math.sqrt(T/E.length)/128,N=$>0?20*Math.log10($):-60,O=Math.max(0,Math.min(1,(N+60)/60));a($),i(O),$>=.95&&(m(!0),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>m(!1),150)),x=requestAnimationFrame(_)};x=requestAnimationFrame(_);const w=setInterval(()=>{k||u(Math.round(c.current*100))},250);return()=>{k=!0,cancelAnimationFrame(x),clearInterval(w),h.current&&(clearTimeout(h.current),h.current=null)}},[e,r]),!e||!r)return null;const y=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 ${y} transition-[width] duration-75 ease-out`,style:{width:`${n*100}%`}})})}function i8(){const e=Mt(f=>f.submitCountdownStartAt),r=Mt(f=>f.submitDelayMs),[n,i]=D.useState(()=>performance.now());if(D.useEffect(()=>{if(e===null)return;let f;const m=()=>{i(performance.now()),f=requestAnimationFrame(m)};return f=requestAnimationFrame(m),()=>cancelAnimationFrame(f)},[e]),e===null)return null;const s=n-e,a=Math.max(0,r-s),c=Math.max(0,Math.min(100,a/r*100)),l=a<500,u=Mt.getState().cancelSubmit;return o.jsx("div",{className:"px-3 pb-1",onClick:u,title:`Submitting in ${(a/1e3).toFixed(1)}s — click to cancel`,children:o.jsx("div",{className:"h-0.5 w-full bg-bg rounded overflow-hidden cursor-pointer",children:o.jsx("div",{className:`h-full transition-colors ${l?"bg-amber-400":"bg-accent"}`,style:{width:`${c}%`}})})})}function hhe({open:e,onClose:r,variant:n="overlay"}){return o.jsx(uhe,{open:e,onClose:r,title:"Voice / Microphone",variant:n,children:o.jsxs("div",{className:"p-4 space-y-4",children:[o.jsx(vhe,{}),o.jsx(i8,{}),o.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[o.jsx(B4,{}),o.jsx(n8,{}),o.jsx(_W,{})]}),o.jsx(phe,{}),o.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[o.jsx("button",{type:"button",onClick:()=>Mt.getState().openWizard(),className:"text-xs text-fg-faint hover:text-fg-dim underline","data-testid":"run-mic-check",children:"Run mic check"}),o.jsx(ghe,{})]}),o.jsx(fhe,{})]})})}function phe(){const e=Mt(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=mhe(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 mhe(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 ghe(){const[e,r]=D.useState(null);if(D.useEffect(()=>{let i=!1;window.api.voice.getHotkeyConfig().then(a=>{i||r(a)}).catch(a=>mt.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){mt.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 vhe(){const e=Mt(a=>a.isRecording),r=Mt(a=>a.lastTranscript),n=Mt(a=>a.error),i=Mt(a=>a.modelStatus),s=Mt(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 JC=null;function yhe(){return JC||(JC=sb(()=>import("./monaco-editor-BW5C4Iv1.js").then(e=>e.b),__vite__mapDeps([1,2]),import.meta.url).then(e=>(rA.config({monaco:e}),e))),JC}function s8({value:e,onChange:r,path:n,readOnly:i}){const s=D.useRef(null),a=c=>{s.current=c};return o.jsx(nA,{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 BL=!1;async function bhe(e){if(BL)return;const r=await yhe(),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}),BL=!0}function o$({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,y=((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:Pi[r].label})]}),y&&o.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:l,onChange:x=>u(x.target.checked),className:"accent-accent"}),"show unset keys"]}),o.jsx("div",{className:"flex-1"}),o.jsx("input",{value:a,onChange:x=>c(x.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(a8,{node:e,path:f,label:s??"(root)",targetScope:r,onOverride:n,filter:a,depth:0,schema:i,showGhosts:l,defaultOpen:!0})})]})}function a8(e){return e.node.kind==="object"?o.jsx(xhe,{...e,node:e.node}):e.node.kind==="array"?o.jsx(whe,{...e,node:e.node}):o.jsx(_he,{...e,node:e.node})}function zL(e,r){return r.trim()?e.toLowerCase().includes(r.toLowerCase()):!0}function cm(e,r,n){return!!(!n.trim()||e.some(i=>zL(i,n))||r!=null&&r.description&&zL(r.description,n))}function xhe({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),y=(l==null?void 0:l.at(r))??null,x=new Set(Object.keys(e.children)),k=u?(y==null?void 0:y.knownChildren)??[]:[],S=Array.from(new Set([...x,...k])).sort(),b=D.useMemo(()=>a.trim()?S.filter(w=>{const C=(l==null?void 0:l.at([...r,w]))??null;return cm([...r,w],C,a)?!0:x.has(w)?o8(e.children[w],[...r,w],a,l):!1}):S,[S.join(","),a,e,r.join("."),l]);if(a.trim()&&b.length===0&&!cm(r,y,a))return null;if(r.length===0)return o.jsx("div",{children:b.map(w=>_(w))});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:[" {",x.size,k.length>x.size?`/${new Set([...x,...k]).size}`:"","}"]}),(y==null?void 0:y.description)&&o.jsxs("span",{className:"text-fg-faint truncate max-w-md",title:y.description,children:["— ",y.description]})]}),m&&b.map(w=>_(w))]});function _(w){if(x.has(w))return o.jsx(a8,{node:e.children[w],path:[...r,w],label:w,targetScope:i,onOverride:s,filter:a,depth:c+1,schema:l,showGhosts:u},w);const C=(l==null?void 0:l.at([...r,w]))??null;return C?o.jsx(She,{path:[...r,w],label:w,info:C,targetScope:i,onSet:s,depth:c+1,filter:a},w):null}}function o8(e,r,n,i){const s=(i==null?void 0:i.at(r))??null;if(cm(r,s,n))return!0;if(e.kind!=="object")return!1;for(const a of Object.keys(e.children))if(o8(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 cm(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:Y0(f.value)}),o.jsx(fT,{scope:f.fromScope})]},m))]}):null}function _he({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(!cm(r,m,a))return null;const h=e.winner!==i,y=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 ${y?"text-fg-faint cursor-pointer":""}`,onClick:()=>y&&f(!u),children:y?u?"▾":"▸":""}),o.jsxs("span",{className:"text-fg",children:[n,":"]}),o.jsx("span",{className:"text-fg-dim truncate max-w-md",children:Y0(e.value)}),o.jsx(fT,{scope:e.winner}),(m==null?void 0:m.deprecated)&&o.jsx(eb,{tone:"warn",children:"deprecated"}),(m==null?void 0:m.default)!==void 0&&khe(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(l8,{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 ${Pi[i].label} draft`:`already winning in ${Pi[i].label}`,children:"override"})]}),u&&e.shadowed.map((x,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:Y0(x.value)}),o.jsx(fT,{scope:x.scope,dim:!0})]},k))]})}function She({path:e,label:r,info:n,targetScope:i,onSet:s,depth:a,filter:c}){if(!cm(e,n,c))return null;const l=n.default!==void 0?n.default:Che(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: ",Y0(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(l8,{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 ${Pi[i].label} draft`,children:"set"})]})}function khe(e,r){return e===r?!0:typeof e!=typeof r?!1:e&&r&&typeof e=="object"?JSON.stringify(e)===JSON.stringify(r):!1}function Che(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 Y0(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 fT({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:Pi[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 l8({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 jhe=[{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"]}],Ehe={mcp:"MCP",url:"URL",urls:"URLs",http:"HTTP",ui:"UI",id:"ID",uuid:"UUID",api:"API",aws:"AWS",otel:"OTel",json:"JSON"};function c8(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=Ehe[i];return a||(s===0?i.charAt(0).toUpperCase()+i.slice(1):i)}).join(" ")}function The(e){const r=new Set,n=[];for(const s of jhe){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 Ahe=["user","project","local","default"],$he={user:"user",project:"project",local:"local",default:"default"};function Nhe({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):[],y=i.rootKeys(),x=new Set([...h,...y]),k=D.useMemo(()=>The(x),[Array.from(x).sort().join(",")]),S=D.useMemo(()=>k.filter(b=>c||!b.advanced).map(b=>({...b,keys:b.keys.filter(_=>{const w=(m==null?void 0:m.children[_])!==void 0;if(!u&&!w)return!1;if(!s.trim())return!0;const C=i.at([_]);return[_,c8(_),(C==null?void 0:C.description)??""].join(" ").toLowerCase().includes(s.toLowerCase())})})).filter(b=>b.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:Pi[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:b=>f(b.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:b=>l(b.target.checked),className:"accent-accent"}),"show advanced"]}),o.jsx("div",{className:"flex-1"}),o.jsx("input",{value:s,onChange:b=>a(b.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(b=>o.jsx(Ohe,{title:b.title,summary:b.summary,advanced:b.advanced,children:b.keys.map(_=>{const w=m==null?void 0:m.children[_],C=i.at([_]);return o.jsx(Phe,{keyName:_,node:w,info:C,targetScope:r,onOverride:(E,T)=>n([_],E,T)},_)})},b.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 Ohe({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 Phe({keyName:e,node:r,info:n,targetScope:i,onOverride:s}){const[a,c]=D.useState(!1),[l,u]=D.useState(!1),f=c8(e),m=r!==void 0,y=(r==null?void 0:r.kind)==="leaf"?r:null,x=(r==null?void 0:r.kind)==="object"||(r==null?void 0:r.kind)==="array",k=n==null?void 0:n.default,S=y&&k!==void 0&&d8(y.value,k),b=Fhe({isSet:m,leafNode:y,defaultVal:k,isDefault:!!S,node:r}),_=Rhe(y,k),w=_.length>=2,C=!!y&&!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(Uhe,{kind:b.kind,label:b.label}),w&&o.jsxs("button",{onClick:E=>{E.stopPropagation(),a||c(!0),u(T=>!T)},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 · ",_.map(E=>$he[E]).join(" · ")]}),C&&y&&o.jsx("button",{onClick:E=>{E.stopPropagation(),s(void 0,y.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 ${Pi[y.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:qhe(n.description)}),a&&l&&y&&o.jsx(Mhe,{leaf:y,defaultVal:k,onReset:E=>s(void 0,E)}),a&&o.jsx(Ihe,{keyName:e,node:r,info:n,targetScope:i,onOverride:E=>s(E)})]}),o.jsx("div",{className:"shrink-0",children:!a&&o.jsx(zhe,{node:r,info:n,onSet:E=>{s(E)},disabled:x&&m})})]})})}function Rhe(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"),Ahe.filter(i=>n.has(i))}function Mhe({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:Pi[s].label}),o.jsx("span",{className:`font-mono truncate ${a!=null&&a.winner?"text-accent":"text-fg-dim"}`,children:c?Mp(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 ${Pi[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?Mp(r):o.jsx("span",{className:"text-fg-faint",children:"—"})}),o.jsx("span",{})]})]})]})}function Ihe({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:Mp(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:Mp(c.value)}),o.jsxs("span",{className:"ml-2 text-fg-faint",children:["from ",Pi[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:[Mp(l.value)," —"," ",o.jsx("span",{className:"no-underline",children:Pi[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(Dhe,{keyName:e,node:r,info:n,onChange:s,targetScope:i})})]})}function Dhe({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=u8(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:["→ ",Pi[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=d8(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:["→ ",Pi[i].label]})]}):c==="integer"||c==="number"?o.jsx(Lhe,{value:typeof a=="number"?a:void 0,integer:c==="integer",onCommit:n,target:Pi[i].label}):c==="string"?o.jsx(Bhe,{value:typeof a=="string"?a:"",onCommit:n,target:Pi[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 Lhe({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 Bhe({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 zhe({node:e,info:r,onSet:n,disabled:i}){const s=(e==null?void 0:e.kind)==="leaf",a=u8(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 Fhe({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 · ${Pi[r.winner].label}`}:r.shadowed.length>0?{kind:"override",label:`overriding ${r.shadowed.length} scope(s)`}:{kind:"set",label:`set in ${Pi[r.winner].label}`}:{kind:"set",label:"configured"}:n!==void 0?{kind:"default",label:`using default: ${Mp(n)}`}:{kind:"unset",label:"not configured"}}function Uhe({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 u8(e){if(e)return Array.isArray(e)?e.find(n=>n!=="null")??e[0]:e}function d8(e,r){return e===r?!0:typeof e!=typeof r?!1:e&&r&&typeof e=="object"?JSON.stringify(e)===JSON.stringify(r):!1}function qhe(e){const r=e.trim().split(`
3449
3449
  `)[0],n=r.match(/^([^.!?]+[.!?])/);return n?n[1]:r.length>120?r.slice(0,120)+"…":r}function Mp(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)}const Whe=[];function lw(e){return Array.isArray(e)?"array":e!==null&&typeof e=="object"?"object":"scalar"}function l$(e){const r=e.filter(n=>n.data!==void 0);return r.length===0?{kind:"object",children:{}}:f8(r,[])}function f8(e,r){const n=Whe.includes(r.join(".")),i=e.every(m=>lw(m.data)==="object"),s=e.every(m=>lw(m.data)==="array");if(i){const m=new Set;for(const y of e)for(const x of Object.keys(y.data))m.add(x);const h={};for(const y of m){const x=e.filter(k=>y in k.data).map(k=>({scope:k.scope,data:k.data[y]}));h[y]=f8(x,[...r,y])}return{kind:"object",children:h}}if(s&&!n){const m=[];for(const h of[...e].reverse())for(const y of h.data)m.push({value:y,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=lw(c.data),f=l.some(m=>lw(m.value)!==u);return{kind:"leaf",value:c.data,winner:c.scope,shadowed:l,...f?{typeMismatch:!0}:{}}}function c$(e,r){if(r.length===0)return e;if(e.kind!=="object")return null;const[n,...i]=r,s=e.children[n];return s?c$(s,i):null}function Z_(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]=Z_(a[i],s,n),a}const Hhe=["user","project","local"];function u$(e,r){const n=[];for(const i of Hhe){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 Vhe="http://json-schema.org/draft-07/schema#",Ghe="https://json.schemastore.org/claude-code-settings.json",Khe={permissionRule:{type:"string",description:`Tool permission rule.
3450
3450
  See https://code.claude.com/docs/en/settings#permission-rule-syntax
3451
3451
  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"}}}}},Xhe="Configuration settings for Claude Code. Learn more: https://code.claude.com/docs/en/settings",Yhe=!0,Jhe=!0,Zhe="object",Qhe=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"]}]}}}`),epe="Claude Code Settings",tpe={$schema:Vhe,$id:Ghe,$defs:Khe,description:Xhe,allowTrailingCommas:Yhe,additionalProperties:Jhe,type:Zhe,properties:Qhe,title:epe};function rpe(e){const r=e??{},n={...r.$defs??{},...r.definitions??{}},i=x=>{if(!x)return{};if(!x.$ref)return c(x);const k=/^#\/(\$defs|definitions)\/(.+)$/.exec(x.$ref);if(!k)return c(x);const S=n[k[2]];return S?i({...S,...l(x)}):c(x)},s=new Set(["__proto__","constructor","prototype"]),a=x=>{if(!x)return{};const k={};for(const[S,b]of Object.entries(x))s.has(S)||(k[S]=b);return k},c=x=>{if(!x.allOf||x.allOf.length===0)return x;const k={...x};delete k.allOf;for(const S of x.allOf){const b=i(S);Object.assign(k,{properties:{...a(k.properties),...a(b.properties)},required:npe([...k.required??[],...b.required??[]])}),!k.description&&b.description&&(k.description=b.description),k.default===void 0&&b.default!==void 0&&(k.default=b.default),!k.type&&b.type&&(k.type=b.type)}return k},l=x=>{const{$ref:k,...S}=x;return S},u=(x,k)=>{let S=i(x);for(const b of k){if(!S)return null;if(/^\d+$/.test(b)){const C=Array.isArray(S.items)?S.items[Number(b)]:S.items;S=C?i(C):null;continue}const _=S.properties;if(_&&!s.has(b)&&b in _){S=i(_[b]);continue}const w=S.additionalProperties;if(w&&typeof w=="object"){S=i(w);continue}return null}return S},f=(x,k,S)=>{if(!x)return null;const b={};if(x.description&&(b.description=x.description),x.type&&(b.type=x.type),x.default!==void 0&&(b.default=x.default),x.enum&&(b.enum=x.enum),x.const!==void 0&&(b.const=x.const),x.deprecated&&(b.deprecated=!0),x.examples&&(b.examples=x.examples),x.properties&&(b.knownChildren=Object.keys(x.properties)),S&&(k!=null&&k.includes(S))&&(b.required=!0),x.items&&!Array.isArray(x.items)){const _=i(x.items),w=f(_,void 0,null);w&&(b.itemsInfo=w)}return(x.additionalProperties===!0||typeof x.additionalProperties=="object")&&(b.open=!0),b},m=x=>k=>{if(k.length===0)return f(i(x),void 0,null);const S=u(x,k.slice(0,-1));if(!S)return null;const b=k[k.length-1],_=u(S,[b]);return f(_,S.required,b)},h=x=>{const k=i(x);return Object.keys(k.properties??{})},y=x=>({at:m(x),rootKeys:()=>h(x),rootedAt:k=>{const S=u(x,k);return y(S??{})}});return y(r)}function npe(e){return Array.from(new Set(e))}let ZC=null;function J0(){return ZC||(ZC=rpe(tpe)),ZC}function ipe(){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),[y,x]=D.useState(null);if(D.useEffect(()=>{let w=!1;return Promise.all([window.api.otel.getConfig(),window.api.otel.status(),window.api.otel.configPath()]).then(([C,E,T])=>{w||(r(C),a(C),i(E),l(T))}).catch(C=>{console.warn("[telemetry] load failed:",C==null?void 0:C.message)}),()=>{w=!0}},[]),!s||!e)return o.jsx(Gt,{title:"loading…"});const k=JSON.stringify(s)!==JSON.stringify(e),S=(w,C)=>{h(null),a({...s,[w]:C})},b=async()=>{f(!0),h(null);try{const w=await window.api.otel.setConfig(s);!w.ok&&w.error&&h(w.error),r(w.config),a(w.config),i(w.status),x(Date.now())}catch(w){h(w instanceof Error?w.message:String(w))}finally{f(!1)}},_=()=>{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(Hw,{checked:s.enabled,onChange:w=>S("enabled",w),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:w=>S("endpoint",w.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:w=>S("headers",w.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:w=>S("serviceName",w.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(Hw,{checked:s.includeContent,onChange:w=>S("includeContent",w),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:b,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:_,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&&y&&!k&&o.jsx("span",{className:"text-fg-faint text-xs",children:"saved"})]})]})}function spe(){const{model:e,setModel:r}=mq();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:zT.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 ape(){const e=bn(),r=Nt(O=>O.tabs),n=Nt(O=>O.activeTabId),i=r.find(O=>O.id===n)??null,s=(i==null?void 0:i.cwd)??null,[a,c]=D.useState("user"),[l,u]=D.useState("effective"),f=D.useMemo(()=>{const O={};for(const M of $p.scopes){const U=$p.resolve(M,e??"",s);U&&(O[M]=U)}return O},[e,s]),m=f[a]??null,h=Yt(O=>O.files),y=Yt(O=>O.loadJson),x=Yt(O=>O.setDraft),k=Yt(O=>O.saveJson),S=Yt(O=>O.revert),b=Yt(O=>O.watchFile),_=Yt(O=>O.unwatchFile);D.useEffect(()=>{const O=Object.values(f).filter(Boolean);return O.forEach(M=>{h[M]||y(M),b(M)}),()=>{O.forEach(M=>_(M))}},[JSON.stringify(f)]);const[w,C]=D.useState(null),E=D.useMemo(()=>l$(u$(h,f)),[h,f]),T=(O,M,U)=>{var te;const V=f[U??a];if(!V)return;C(null);const z=((te=h[V])==null?void 0:te.draftRaw)??"";let F={};if(z.trim())try{F=JSON.parse(z)}catch{F={}}const Y=Z_(F,O,M);x(V,JSON.stringify(Y,null,2)+`