openfox 1.6.0 → 1.6.1

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.
@@ -45,7 +45,7 @@ var r1=Object.defineProperty;var i1=(e,r,i)=>r in e?r1(e,r,{enumerable:!0,config
45
45
  `);for(w=d=0;d<ee.length&&!ee[d].includes("DetermineComponentFrameRoot");)d++;for(;w<le.length&&!le[w].includes("DetermineComponentFrameRoot");)w++;if(d===ee.length||w===le.length)for(d=ee.length-1,w=le.length-1;1<=d&&0<=w&&ee[d]!==le[w];)w--;for(;1<=d&&0<=w;d--,w--)if(ee[d]!==le[w]){if(d!==1||w!==1)do if(d--,w--,0>w||ee[d]!==le[w]){var he=`
46
46
  `+ee[d].replace(" at new "," at ");return t.displayName&&he.includes("<anonymous>")&&(he=he.replace("<anonymous>",t.displayName)),he}while(1<=d&&0<=w);break}}}finally{Oe=!1,Error.prepareStackTrace=a}return(a=t?t.displayName||t.name:"")?De(a):""}function ke(t,n){switch(t.tag){case 26:case 27:case 5:return De(t.type);case 16:return De("Lazy");case 13:return t.child!==n&&n!==null?De("Suspense Fallback"):De("Suspense");case 19:return De("SuspenseList");case 0:case 15:return Fe(t.type,!1);case 11:return Fe(t.type.render,!1);case 1:return Fe(t.type,!0);case 31:return De("Activity");default:return""}}function lt(t){try{var n="",a=null;do n+=ke(t,a),a=t,t=t.return;while(t);return n}catch(d){return`
47
47
  Error generating stack: `+d.message+`
48
- `+d.stack}}var ht=Object.prototype.hasOwnProperty,fe=e.unstable_scheduleCallback,Re=e.unstable_cancelCallback,Je=e.unstable_shouldYield,et=e.unstable_requestPaint,Ge=e.unstable_now,ct=e.unstable_getCurrentPriorityLevel,de=e.unstable_ImmediatePriority,be=e.unstable_UserBlockingPriority,re=e.unstable_NormalPriority,Se=e.unstable_LowPriority,Ce=e.unstable_IdlePriority,He=e.log,Ae=e.unstable_setDisableYieldValue,st=null,it=null;function Ct(t){if(typeof He=="function"&&Ae(t),it&&typeof it.setStrictMode=="function")try{it.setStrictMode(st,t)}catch{}}var $e=Math.clz32?Math.clz32:we,Ln=Math.log,pe=Math.LN2;function we(t){return t>>>=0,t===0?32:31-(Ln(t)/pe|0)|0}var ze=256,Ve=262144,tt=4194304;function Be(t){var n=t&42;if(n!==0)return n;switch(t&-t){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:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return t&261888;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function Lt(t,n,a){var d=t.pendingLanes;if(d===0)return 0;var w=0,E=t.suspendedLanes,M=t.pingedLanes;t=t.warmLanes;var G=d&134217727;return G!==0?(d=G&~E,d!==0?w=Be(d):(M&=G,M!==0?w=Be(M):a||(a=G&~t,a!==0&&(w=Be(a))))):(G=d&~E,G!==0?w=Be(G):M!==0?w=Be(M):a||(a=d&~t,a!==0&&(w=Be(a)))),w===0?0:n!==0&&n!==w&&(n&E)===0&&(E=w&-w,a=n&-n,E>=a||E===32&&(a&4194048)!==0)?n:w}function Et(t,n){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&n)===0}function Yt(t,n){switch(t){case 1:case 2:case 4:case 8:case 64:return n+250;case 16:case 32: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 n+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Zl(){var t=tt;return tt<<=1,(tt&62914560)===0&&(tt=4194304),t}function Ls(t){for(var n=[],a=0;31>a;a++)n.push(t);return n}function Rs(t,n){t.pendingLanes|=n,n!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function W0(t,n,a,d,w,E){var M=t.pendingLanes;t.pendingLanes=a,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=a,t.entangledLanes&=a,t.errorRecoveryDisabledLanes&=a,t.shellSuspendCounter=0;var G=t.entanglements,ee=t.expirationTimes,le=t.hiddenUpdates;for(a=M&~a;0<a;){var he=31-$e(a),xe=1<<he;G[he]=0,ee[he]=-1;var ce=le[he];if(ce!==null)for(le[he]=null,he=0;he<ce.length;he++){var ue=ce[he];ue!==null&&(ue.lane&=-536870913)}a&=~xe}d!==0&&Jh(t,d,0),E!==0&&w===0&&t.tag!==0&&(t.suspendedLanes|=E&~(M&~n))}function Jh(t,n,a){t.pendingLanes|=n,t.suspendedLanes&=~n;var d=31-$e(n);t.entangledLanes|=n,t.entanglements[d]=t.entanglements[d]|1073741824|a&261930}function ef(t,n){var a=t.entangledLanes|=n;for(t=t.entanglements;a;){var d=31-$e(a),w=1<<d;w&n|t[d]&n&&(t[d]|=n),a&=~w}}function tf(t,n){var a=n&-n;return a=(a&42)!==0?1:Ql(a),(a&(t.suspendedLanes|n))!==0?0:a}function Ql(t){switch(t){case 2:t=1;break;case 8:t=4;break;case 32:t=16;break;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:t=128;break;case 268435456:t=134217728;break;default:t=0}return t}function Jl(t){return t&=-t,2<t?8<t?(t&134217727)!==0?32:268435456:8:2}function nf(){var t=X.p;return t!==0?t:(t=window.event,t===void 0?32:Ug(t.type))}function rf(t,n){var a=X.p;try{return X.p=t,n()}finally{X.p=a}}var Tr=Math.random().toString(36).slice(2),Kt="__reactFiber$"+Tr,dn="__reactProps$"+Tr,Mi="__reactContainer$"+Tr,ec="__reactEvents$"+Tr,G0="__reactListeners$"+Tr,V0="__reactHandles$"+Tr,sf="__reactResources$"+Tr,Ms="__reactMarker$"+Tr;function tc(t){delete t[Kt],delete t[dn],delete t[ec],delete t[G0],delete t[V0]}function Oi(t){var n=t[Kt];if(n)return n;for(var a=t.parentNode;a;){if(n=a[Mi]||a[Kt]){if(a=n.alternate,n.child!==null||a!==null&&a.child!==null)for(t=Eg(t);t!==null;){if(a=t[Kt])return a;t=Eg(t)}return n}t=a,a=t.parentNode}return null}function Bi(t){if(t=t[Kt]||t[Mi]){var n=t.tag;if(n===5||n===6||n===13||n===31||n===26||n===27||n===3)return t}return null}function Os(t){var n=t.tag;if(n===5||n===26||n===27||n===6)return t.stateNode;throw Error(s(33))}function Ii(t){var n=t[sf];return n||(n=t[sf]={hoistableStyles:new Map,hoistableScripts:new Map}),n}function qt(t){t[Ms]=!0}var af=new Set,of={};function si(t,n){zi(t,n),zi(t+"Capture",n)}function zi(t,n){for(of[t]=n,t=0;t<n.length;t++)af.add(n[t])}var Y0=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),lf={},cf={};function K0(t){return ht.call(cf,t)?!0:ht.call(lf,t)?!1:Y0.test(t)?cf[t]=!0:(lf[t]=!0,!1)}function Ja(t,n,a){if(K0(n))if(a===null)t.removeAttribute(n);else{switch(typeof a){case"undefined":case"function":case"symbol":t.removeAttribute(n);return;case"boolean":var d=n.toLowerCase().slice(0,5);if(d!=="data-"&&d!=="aria-"){t.removeAttribute(n);return}}t.setAttribute(n,""+a)}}function eo(t,n,a){if(a===null)t.removeAttribute(n);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":t.removeAttribute(n);return}t.setAttribute(n,""+a)}}function lr(t,n,a,d){if(d===null)t.removeAttribute(a);else{switch(typeof d){case"undefined":case"function":case"symbol":case"boolean":t.removeAttribute(a);return}t.setAttributeNS(n,a,""+d)}}function Rn(t){switch(typeof t){case"bigint":case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function uf(t){var n=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function X0(t,n,a){var d=Object.getOwnPropertyDescriptor(t.constructor.prototype,n);if(!t.hasOwnProperty(n)&&typeof d<"u"&&typeof d.get=="function"&&typeof d.set=="function"){var w=d.get,E=d.set;return Object.defineProperty(t,n,{configurable:!0,get:function(){return w.call(this)},set:function(M){a=""+M,E.call(this,M)}}),Object.defineProperty(t,n,{enumerable:d.enumerable}),{getValue:function(){return a},setValue:function(M){a=""+M},stopTracking:function(){t._valueTracker=null,delete t[n]}}}}function nc(t){if(!t._valueTracker){var n=uf(t)?"checked":"value";t._valueTracker=X0(t,n,""+t[n])}}function df(t){if(!t)return!1;var n=t._valueTracker;if(!n)return!0;var a=n.getValue(),d="";return t&&(d=uf(t)?t.checked?"true":"false":t.value),t=d,t!==a?(n.setValue(t),!0):!1}function to(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}var Z0=/[\n"\\]/g;function Mn(t){return t.replace(Z0,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function rc(t,n,a,d,w,E,M,G){t.name="",M!=null&&typeof M!="function"&&typeof M!="symbol"&&typeof M!="boolean"?t.type=M:t.removeAttribute("type"),n!=null?M==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+Rn(n)):t.value!==""+Rn(n)&&(t.value=""+Rn(n)):M!=="submit"&&M!=="reset"||t.removeAttribute("value"),n!=null?ic(t,M,Rn(n)):a!=null?ic(t,M,Rn(a)):d!=null&&t.removeAttribute("value"),w==null&&E!=null&&(t.defaultChecked=!!E),w!=null&&(t.checked=w&&typeof w!="function"&&typeof w!="symbol"),G!=null&&typeof G!="function"&&typeof G!="symbol"&&typeof G!="boolean"?t.name=""+Rn(G):t.removeAttribute("name")}function hf(t,n,a,d,w,E,M,G){if(E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"&&(t.type=E),n!=null||a!=null){if(!(E!=="submit"&&E!=="reset"||n!=null)){nc(t);return}a=a!=null?""+Rn(a):"",n=n!=null?""+Rn(n):a,G||n===t.value||(t.value=n),t.defaultValue=n}d=d??w,d=typeof d!="function"&&typeof d!="symbol"&&!!d,t.checked=G?t.checked:!!d,t.defaultChecked=!!d,M!=null&&typeof M!="function"&&typeof M!="symbol"&&typeof M!="boolean"&&(t.name=M),nc(t)}function ic(t,n,a){n==="number"&&to(t.ownerDocument)===t||t.defaultValue===""+a||(t.defaultValue=""+a)}function Hi(t,n,a,d){if(t=t.options,n){n={};for(var w=0;w<a.length;w++)n["$"+a[w]]=!0;for(a=0;a<t.length;a++)w=n.hasOwnProperty("$"+t[a].value),t[a].selected!==w&&(t[a].selected=w),w&&d&&(t[a].defaultSelected=!0)}else{for(a=""+Rn(a),n=null,w=0;w<t.length;w++){if(t[w].value===a){t[w].selected=!0,d&&(t[w].defaultSelected=!0);return}n!==null||t[w].disabled||(n=t[w])}n!==null&&(n.selected=!0)}}function ff(t,n,a){if(n!=null&&(n=""+Rn(n),n!==t.value&&(t.value=n),a==null)){t.defaultValue!==n&&(t.defaultValue=n);return}t.defaultValue=a!=null?""+Rn(a):""}function pf(t,n,a,d){if(n==null){if(d!=null){if(a!=null)throw Error(s(92));if(I(d)){if(1<d.length)throw Error(s(93));d=d[0]}a=d}a==null&&(a=""),n=a}a=Rn(n),t.defaultValue=a,d=t.textContent,d===a&&d!==""&&d!==null&&(t.value=d),nc(t)}function Pi(t,n){if(n){var a=t.firstChild;if(a&&a===t.lastChild&&a.nodeType===3){a.nodeValue=n;return}}t.textContent=n}var Q0=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function mf(t,n,a){var d=n.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?d?t.setProperty(n,""):n==="float"?t.cssFloat="":t[n]="":d?t.setProperty(n,a):typeof a!="number"||a===0||Q0.has(n)?n==="float"?t.cssFloat=a:t[n]=(""+a).trim():t[n]=a+"px"}function gf(t,n,a){if(n!=null&&typeof n!="object")throw Error(s(62));if(t=t.style,a!=null){for(var d in a)!a.hasOwnProperty(d)||n!=null&&n.hasOwnProperty(d)||(d.indexOf("--")===0?t.setProperty(d,""):d==="float"?t.cssFloat="":t[d]="");for(var w in n)d=n[w],n.hasOwnProperty(w)&&a[w]!==d&&mf(t,w,d)}else for(var E in n)n.hasOwnProperty(E)&&mf(t,E,n[E])}function sc(t){if(t.indexOf("-")===-1)return!1;switch(t){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 J0=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),ey=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function no(t){return ey.test(""+t)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":t}function cr(){}var ac=null;function oc(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Fi=null,Ui=null;function xf(t){var n=Bi(t);if(n&&(t=n.stateNode)){var a=t[dn]||null;e:switch(t=n.stateNode,n.type){case"input":if(rc(t,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),n=a.name,a.type==="radio"&&n!=null){for(a=t;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+Mn(""+n)+'"][type="radio"]'),n=0;n<a.length;n++){var d=a[n];if(d!==t&&d.form===t.form){var w=d[dn]||null;if(!w)throw Error(s(90));rc(d,w.value,w.defaultValue,w.defaultValue,w.checked,w.defaultChecked,w.type,w.name)}}for(n=0;n<a.length;n++)d=a[n],d.form===t.form&&df(d)}break e;case"textarea":ff(t,a.value,a.defaultValue);break e;case"select":n=a.value,n!=null&&Hi(t,!!a.multiple,n,!1)}}}var lc=!1;function vf(t,n,a){if(lc)return t(n,a);lc=!0;try{var d=t(n);return d}finally{if(lc=!1,(Fi!==null||Ui!==null)&&(qo(),Fi&&(n=Fi,t=Ui,Ui=Fi=null,xf(n),t)))for(n=0;n<t.length;n++)xf(t[n])}}function Bs(t,n){var a=t.stateNode;if(a===null)return null;var d=a[dn]||null;if(d===null)return null;a=d[n];e:switch(n){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(d=!d.disabled)||(t=t.type,d=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!d;break e;default:t=!1}if(t)return null;if(a&&typeof a!="function")throw Error(s(231,n,typeof a));return a}var ur=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),cc=!1;if(ur)try{var Is={};Object.defineProperty(Is,"passive",{get:function(){cc=!0}}),window.addEventListener("test",Is,Is),window.removeEventListener("test",Is,Is)}catch{cc=!1}var Ar=null,uc=null,ro=null;function bf(){if(ro)return ro;var t,n=uc,a=n.length,d,w="value"in Ar?Ar.value:Ar.textContent,E=w.length;for(t=0;t<a&&n[t]===w[t];t++);var M=a-t;for(d=1;d<=M&&n[a-d]===w[E-d];d++);return ro=w.slice(t,1<d?1-d:void 0)}function io(t){var n=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&n===13&&(t=13)):t=n,t===10&&(t=13),32<=t||t===13?t:0}function so(){return!0}function yf(){return!1}function hn(t){function n(a,d,w,E,M){this._reactName=a,this._targetInst=w,this.type=d,this.nativeEvent=E,this.target=M,this.currentTarget=null;for(var G in t)t.hasOwnProperty(G)&&(a=t[G],this[G]=a?a(E):E[G]);return this.isDefaultPrevented=(E.defaultPrevented!=null?E.defaultPrevented:E.returnValue===!1)?so:yf,this.isPropagationStopped=yf,this}return m(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=so)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=so)},persist:function(){},isPersistent:so}),n}var ai={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ao=hn(ai),zs=m({},ai,{view:0,detail:0}),ty=hn(zs),dc,hc,Hs,oo=m({},zs,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:pc,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==Hs&&(Hs&&t.type==="mousemove"?(dc=t.screenX-Hs.screenX,hc=t.screenY-Hs.screenY):hc=dc=0,Hs=t),dc)},movementY:function(t){return"movementY"in t?t.movementY:hc}}),_f=hn(oo),ny=m({},oo,{dataTransfer:0}),ry=hn(ny),iy=m({},zs,{relatedTarget:0}),fc=hn(iy),sy=m({},ai,{animationName:0,elapsedTime:0,pseudoElement:0}),ay=hn(sy),oy=m({},ai,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),ly=hn(oy),cy=m({},ai,{data:0}),Sf=hn(cy),uy={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},dy={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"},hy={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function fy(t){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(t):(t=hy[t])?!!n[t]:!1}function pc(){return fy}var py=m({},zs,{key:function(t){if(t.key){var n=uy[t.key]||t.key;if(n!=="Unidentified")return n}return t.type==="keypress"?(t=io(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?dy[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:pc,charCode:function(t){return t.type==="keypress"?io(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?io(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),my=hn(py),gy=m({},oo,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),wf=hn(gy),xy=m({},zs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:pc}),vy=hn(xy),by=m({},ai,{propertyName:0,elapsedTime:0,pseudoElement:0}),yy=hn(by),_y=m({},oo,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),Sy=hn(_y),wy=m({},ai,{newState:0,oldState:0}),Cy=hn(wy),ky=[9,13,27,32],mc=ur&&"CompositionEvent"in window,Ps=null;ur&&"documentMode"in document&&(Ps=document.documentMode);var Ey=ur&&"TextEvent"in window&&!Ps,Cf=ur&&(!mc||Ps&&8<Ps&&11>=Ps),kf=" ",Ef=!1;function jf(t,n){switch(t){case"keyup":return ky.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Nf(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var $i=!1;function jy(t,n){switch(t){case"compositionend":return Nf(n);case"keypress":return n.which!==32?null:(Ef=!0,kf);case"textInput":return t=n.data,t===kf&&Ef?null:t;default:return null}}function Ny(t,n){if($i)return t==="compositionend"||!mc&&jf(t,n)?(t=bf(),ro=uc=Ar=null,$i=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1<n.char.length)return n.char;if(n.which)return String.fromCharCode(n.which)}return null;case"compositionend":return Cf&&n.locale!=="ko"?null:n.data;default:return null}}var Ty={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 Tf(t){var n=t&&t.nodeName&&t.nodeName.toLowerCase();return n==="input"?!!Ty[t.type]:n==="textarea"}function Af(t,n,a,d){Fi?Ui?Ui.push(d):Ui=[d]:Fi=d,n=Zo(n,"onChange"),0<n.length&&(a=new ao("onChange","change",null,a,d),t.push({event:a,listeners:n}))}var Fs=null,Us=null;function Ay(t){hg(t,0)}function lo(t){var n=Os(t);if(df(n))return t}function Df(t,n){if(t==="change")return n}var Lf=!1;if(ur){var gc;if(ur){var xc="oninput"in document;if(!xc){var Rf=document.createElement("div");Rf.setAttribute("oninput","return;"),xc=typeof Rf.oninput=="function"}gc=xc}else gc=!1;Lf=gc&&(!document.documentMode||9<document.documentMode)}function Mf(){Fs&&(Fs.detachEvent("onpropertychange",Of),Us=Fs=null)}function Of(t){if(t.propertyName==="value"&&lo(Us)){var n=[];Af(n,Us,t,oc(t)),vf(Ay,n)}}function Dy(t,n,a){t==="focusin"?(Mf(),Fs=n,Us=a,Fs.attachEvent("onpropertychange",Of)):t==="focusout"&&Mf()}function Ly(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return lo(Us)}function Ry(t,n){if(t==="click")return lo(n)}function My(t,n){if(t==="input"||t==="change")return lo(n)}function Oy(t,n){return t===n&&(t!==0||1/t===1/n)||t!==t&&n!==n}var yn=typeof Object.is=="function"?Object.is:Oy;function $s(t,n){if(yn(t,n))return!0;if(typeof t!="object"||t===null||typeof n!="object"||n===null)return!1;var a=Object.keys(t),d=Object.keys(n);if(a.length!==d.length)return!1;for(d=0;d<a.length;d++){var w=a[d];if(!ht.call(n,w)||!yn(t[w],n[w]))return!1}return!0}function Bf(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function If(t,n){var a=Bf(t);t=0;for(var d;a;){if(a.nodeType===3){if(d=t+a.textContent.length,t<=n&&d>=n)return{node:a,offset:n-t};t=d}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Bf(a)}}function zf(t,n){return t&&n?t===n?!0:t&&t.nodeType===3?!1:n&&n.nodeType===3?zf(t,n.parentNode):"contains"in t?t.contains(n):t.compareDocumentPosition?!!(t.compareDocumentPosition(n)&16):!1:!1}function Hf(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var n=to(t.document);n instanceof t.HTMLIFrameElement;){try{var a=typeof n.contentWindow.location.href=="string"}catch{a=!1}if(a)t=n.contentWindow;else break;n=to(t.document)}return n}function vc(t){var n=t&&t.nodeName&&t.nodeName.toLowerCase();return n&&(n==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||n==="textarea"||t.contentEditable==="true")}var By=ur&&"documentMode"in document&&11>=document.documentMode,qi=null,bc=null,qs=null,yc=!1;function Pf(t,n,a){var d=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;yc||qi==null||qi!==to(d)||(d=qi,"selectionStart"in d&&vc(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),qs&&$s(qs,d)||(qs=d,d=Zo(bc,"onSelect"),0<d.length&&(n=new ao("onSelect","select",null,n,a),t.push({event:n,listeners:d}),n.target=qi)))}function oi(t,n){var a={};return a[t.toLowerCase()]=n.toLowerCase(),a["Webkit"+t]="webkit"+n,a["Moz"+t]="moz"+n,a}var Wi={animationend:oi("Animation","AnimationEnd"),animationiteration:oi("Animation","AnimationIteration"),animationstart:oi("Animation","AnimationStart"),transitionrun:oi("Transition","TransitionRun"),transitionstart:oi("Transition","TransitionStart"),transitioncancel:oi("Transition","TransitionCancel"),transitionend:oi("Transition","TransitionEnd")},_c={},Ff={};ur&&(Ff=document.createElement("div").style,"AnimationEvent"in window||(delete Wi.animationend.animation,delete Wi.animationiteration.animation,delete Wi.animationstart.animation),"TransitionEvent"in window||delete Wi.transitionend.transition);function li(t){if(_c[t])return _c[t];if(!Wi[t])return t;var n=Wi[t],a;for(a in n)if(n.hasOwnProperty(a)&&a in Ff)return _c[t]=n[a];return t}var Uf=li("animationend"),$f=li("animationiteration"),qf=li("animationstart"),Iy=li("transitionrun"),zy=li("transitionstart"),Hy=li("transitioncancel"),Wf=li("transitionend"),Gf=new Map,Sc="abort auxClick beforeToggle 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(" ");Sc.push("scrollEnd");function Wn(t,n){Gf.set(t,n),si(n,[t])}var co=typeof reportError=="function"?reportError:function(t){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var n=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof t=="object"&&t!==null&&typeof t.message=="string"?String(t.message):String(t),error:t});if(!window.dispatchEvent(n))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",t);return}console.error(t)},On=[],Gi=0,wc=0;function uo(){for(var t=Gi,n=wc=Gi=0;n<t;){var a=On[n];On[n++]=null;var d=On[n];On[n++]=null;var w=On[n];On[n++]=null;var E=On[n];if(On[n++]=null,d!==null&&w!==null){var M=d.pending;M===null?w.next=w:(w.next=M.next,M.next=w),d.pending=w}E!==0&&Vf(a,w,E)}}function ho(t,n,a,d){On[Gi++]=t,On[Gi++]=n,On[Gi++]=a,On[Gi++]=d,wc|=d,t.lanes|=d,t=t.alternate,t!==null&&(t.lanes|=d)}function Cc(t,n,a,d){return ho(t,n,a,d),fo(t)}function ci(t,n){return ho(t,null,null,n),fo(t)}function Vf(t,n,a){t.lanes|=a;var d=t.alternate;d!==null&&(d.lanes|=a);for(var w=!1,E=t.return;E!==null;)E.childLanes|=a,d=E.alternate,d!==null&&(d.childLanes|=a),E.tag===22&&(t=E.stateNode,t===null||t._visibility&1||(w=!0)),t=E,E=E.return;return t.tag===3?(E=t.stateNode,w&&n!==null&&(w=31-$e(a),t=E.hiddenUpdates,d=t[w],d===null?t[w]=[n]:d.push(n),n.lane=a|536870912),E):null}function fo(t){if(50<ha)throw ha=0,Ru=null,Error(s(185));for(var n=t.return;n!==null;)t=n,n=t.return;return t.tag===3?t.stateNode:null}var Vi={};function Py(t,n,a,d){this.tag=t,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=d,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function _n(t,n,a,d){return new Py(t,n,a,d)}function kc(t){return t=t.prototype,!(!t||!t.isReactComponent)}function dr(t,n){var a=t.alternate;return a===null?(a=_n(t.tag,n,t.key,t.mode),a.elementType=t.elementType,a.type=t.type,a.stateNode=t.stateNode,a.alternate=t,t.alternate=a):(a.pendingProps=n,a.type=t.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=t.flags&65011712,a.childLanes=t.childLanes,a.lanes=t.lanes,a.child=t.child,a.memoizedProps=t.memoizedProps,a.memoizedState=t.memoizedState,a.updateQueue=t.updateQueue,n=t.dependencies,a.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},a.sibling=t.sibling,a.index=t.index,a.ref=t.ref,a.refCleanup=t.refCleanup,a}function Yf(t,n){t.flags&=65011714;var a=t.alternate;return a===null?(t.childLanes=0,t.lanes=n,t.child=null,t.subtreeFlags=0,t.memoizedProps=null,t.memoizedState=null,t.updateQueue=null,t.dependencies=null,t.stateNode=null):(t.childLanes=a.childLanes,t.lanes=a.lanes,t.child=a.child,t.subtreeFlags=0,t.deletions=null,t.memoizedProps=a.memoizedProps,t.memoizedState=a.memoizedState,t.updateQueue=a.updateQueue,t.type=a.type,n=a.dependencies,t.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),t}function po(t,n,a,d,w,E){var M=0;if(d=t,typeof t=="function")kc(t)&&(M=1);else if(typeof t=="string")M=W_(t,a,K.current)?26:t==="html"||t==="head"||t==="body"?27:5;else e:switch(t){case B:return t=_n(31,a,n,w),t.elementType=B,t.lanes=E,t;case C:return ui(a.children,w,E,n);case b:M=8,w|=24;break;case y:return t=_n(12,a,n,w|2),t.elementType=y,t.lanes=E,t;case A:return t=_n(13,a,n,w),t.elementType=A,t.lanes=E,t;case N:return t=_n(19,a,n,w),t.elementType=N,t.lanes=E,t;default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case _:M=10;break e;case v:M=9;break e;case j:M=11;break e;case L:M=14;break e;case T:M=16,d=null;break e}M=29,a=Error(s(130,t===null?"null":typeof t,"")),d=null}return n=_n(M,a,n,w),n.elementType=t,n.type=d,n.lanes=E,n}function ui(t,n,a,d){return t=_n(7,t,d,n),t.lanes=a,t}function Ec(t,n,a){return t=_n(6,t,null,n),t.lanes=a,t}function Kf(t){var n=_n(18,null,null,0);return n.stateNode=t,n}function jc(t,n,a){return n=_n(4,t.children!==null?t.children:[],t.key,n),n.lanes=a,n.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},n}var Xf=new WeakMap;function Bn(t,n){if(typeof t=="object"&&t!==null){var a=Xf.get(t);return a!==void 0?a:(n={value:t,source:n,stack:lt(n)},Xf.set(t,n),n)}return{value:t,source:n,stack:lt(n)}}var Yi=[],Ki=0,mo=null,Ws=0,In=[],zn=0,Dr=null,Zn=1,Qn="";function hr(t,n){Yi[Ki++]=Ws,Yi[Ki++]=mo,mo=t,Ws=n}function Zf(t,n,a){In[zn++]=Zn,In[zn++]=Qn,In[zn++]=Dr,Dr=t;var d=Zn;t=Qn;var w=32-$e(d)-1;d&=~(1<<w),a+=1;var E=32-$e(n)+w;if(30<E){var M=w-w%5;E=(d&(1<<M)-1).toString(32),d>>=M,w-=M,Zn=1<<32-$e(n)+w|a<<w|d,Qn=E+t}else Zn=1<<E|a<<w|d,Qn=t}function Nc(t){t.return!==null&&(hr(t,1),Zf(t,1,0))}function Tc(t){for(;t===mo;)mo=Yi[--Ki],Yi[Ki]=null,Ws=Yi[--Ki],Yi[Ki]=null;for(;t===Dr;)Dr=In[--zn],In[zn]=null,Qn=In[--zn],In[zn]=null,Zn=In[--zn],In[zn]=null}function Qf(t,n){In[zn++]=Zn,In[zn++]=Qn,In[zn++]=Dr,Zn=n.id,Qn=n.overflow,Dr=t}var Xt=null,St=null,nt=!1,Lr=null,Hn=!1,Ac=Error(s(519));function Rr(t){var n=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Gs(Bn(n,t)),Ac}function Jf(t){var n=t.stateNode,a=t.type,d=t.memoizedProps;switch(n[Kt]=t,n[dn]=d,a){case"dialog":Ke("cancel",n),Ke("close",n);break;case"iframe":case"object":case"embed":Ke("load",n);break;case"video":case"audio":for(a=0;a<pa.length;a++)Ke(pa[a],n);break;case"source":Ke("error",n);break;case"img":case"image":case"link":Ke("error",n),Ke("load",n);break;case"details":Ke("toggle",n);break;case"input":Ke("invalid",n),hf(n,d.value,d.defaultValue,d.checked,d.defaultChecked,d.type,d.name,!0);break;case"select":Ke("invalid",n);break;case"textarea":Ke("invalid",n),pf(n,d.value,d.defaultValue,d.children)}a=d.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||n.textContent===""+a||d.suppressHydrationWarning===!0||gg(n.textContent,a)?(d.popover!=null&&(Ke("beforetoggle",n),Ke("toggle",n)),d.onScroll!=null&&Ke("scroll",n),d.onScrollEnd!=null&&Ke("scrollend",n),d.onClick!=null&&(n.onclick=cr),n=!0):n=!1,n||Rr(t,!0)}function ep(t){for(Xt=t.return;Xt;)switch(Xt.tag){case 5:case 31:case 13:Hn=!1;return;case 27:case 3:Hn=!0;return;default:Xt=Xt.return}}function Xi(t){if(t!==Xt)return!1;if(!nt)return ep(t),nt=!0,!1;var n=t.tag,a;if((a=n!==3&&n!==27)&&((a=n===5)&&(a=t.type,a=!(a!=="form"&&a!=="button")||Yu(t.type,t.memoizedProps)),a=!a),a&&St&&Rr(t),ep(t),n===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(s(317));St=kg(t)}else if(n===31){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(s(317));St=kg(t)}else n===27?(n=St,Vr(t.type)?(t=Ju,Ju=null,St=t):St=n):St=Xt?Fn(t.stateNode.nextSibling):null;return!0}function di(){St=Xt=null,nt=!1}function Dc(){var t=Lr;return t!==null&&(gn===null?gn=t:gn.push.apply(gn,t),Lr=null),t}function Gs(t){Lr===null?Lr=[t]:Lr.push(t)}var Lc=O(null),hi=null,fr=null;function Mr(t,n,a){U(Lc,n._currentValue),n._currentValue=a}function pr(t){t._currentValue=Lc.current,W(Lc)}function Rc(t,n,a){for(;t!==null;){var d=t.alternate;if((t.childLanes&n)!==n?(t.childLanes|=n,d!==null&&(d.childLanes|=n)):d!==null&&(d.childLanes&n)!==n&&(d.childLanes|=n),t===a)break;t=t.return}}function Mc(t,n,a,d){var w=t.child;for(w!==null&&(w.return=t);w!==null;){var E=w.dependencies;if(E!==null){var M=w.child;E=E.firstContext;e:for(;E!==null;){var G=E;E=w;for(var ee=0;ee<n.length;ee++)if(G.context===n[ee]){E.lanes|=a,G=E.alternate,G!==null&&(G.lanes|=a),Rc(E.return,a,t),d||(M=null);break e}E=G.next}}else if(w.tag===18){if(M=w.return,M===null)throw Error(s(341));M.lanes|=a,E=M.alternate,E!==null&&(E.lanes|=a),Rc(M,a,t),M=null}else M=w.child;if(M!==null)M.return=w;else for(M=w;M!==null;){if(M===t){M=null;break}if(w=M.sibling,w!==null){w.return=M.return,M=w;break}M=M.return}w=M}}function Zi(t,n,a,d){t=null;for(var w=n,E=!1;w!==null;){if(!E){if((w.flags&524288)!==0)E=!0;else if((w.flags&262144)!==0)break}if(w.tag===10){var M=w.alternate;if(M===null)throw Error(s(387));if(M=M.memoizedProps,M!==null){var G=w.type;yn(w.pendingProps.value,M.value)||(t!==null?t.push(G):t=[G])}}else if(w===Z.current){if(M=w.alternate,M===null)throw Error(s(387));M.memoizedState.memoizedState!==w.memoizedState.memoizedState&&(t!==null?t.push(ba):t=[ba])}w=w.return}t!==null&&Mc(n,t,a,d),n.flags|=262144}function go(t){for(t=t.firstContext;t!==null;){if(!yn(t.context._currentValue,t.memoizedValue))return!0;t=t.next}return!1}function fi(t){hi=t,fr=null,t=t.dependencies,t!==null&&(t.firstContext=null)}function Zt(t){return tp(hi,t)}function xo(t,n){return hi===null&&fi(t),tp(t,n)}function tp(t,n){var a=n._currentValue;if(n={context:n,memoizedValue:a,next:null},fr===null){if(t===null)throw Error(s(308));fr=n,t.dependencies={lanes:0,firstContext:n},t.flags|=524288}else fr=fr.next=n;return a}var Fy=typeof AbortController<"u"?AbortController:function(){var t=[],n=this.signal={aborted:!1,addEventListener:function(a,d){t.push(d)}};this.abort=function(){n.aborted=!0,t.forEach(function(a){return a()})}},Uy=e.unstable_scheduleCallback,$y=e.unstable_NormalPriority,Rt={$$typeof:_,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Oc(){return{controller:new Fy,data:new Map,refCount:0}}function Vs(t){t.refCount--,t.refCount===0&&Uy($y,function(){t.controller.abort()})}var Ys=null,Bc=0,Qi=0,Ji=null;function qy(t,n){if(Ys===null){var a=Ys=[];Bc=0,Qi=Hu(),Ji={status:"pending",value:void 0,then:function(d){a.push(d)}}}return Bc++,n.then(np,np),n}function np(){if(--Bc===0&&Ys!==null){Ji!==null&&(Ji.status="fulfilled");var t=Ys;Ys=null,Qi=0,Ji=null;for(var n=0;n<t.length;n++)(0,t[n])()}}function Wy(t,n){var a=[],d={status:"pending",value:null,reason:null,then:function(w){a.push(w)}};return t.then(function(){d.status="fulfilled",d.value=n;for(var w=0;w<a.length;w++)(0,a[w])(n)},function(w){for(d.status="rejected",d.reason=w,w=0;w<a.length;w++)(0,a[w])(void 0)}),d}var rp=$.S;$.S=function(t,n){Pm=Ge(),typeof n=="object"&&n!==null&&typeof n.then=="function"&&qy(t,n),rp!==null&&rp(t,n)};var pi=O(null);function Ic(){var t=pi.current;return t!==null?t:bt.pooledCache}function vo(t,n){n===null?U(pi,pi.current):U(pi,n.pool)}function ip(){var t=Ic();return t===null?null:{parent:Rt._currentValue,pool:t}}var es=Error(s(460)),zc=Error(s(474)),bo=Error(s(542)),yo={then:function(){}};function sp(t){return t=t.status,t==="fulfilled"||t==="rejected"}function ap(t,n,a){switch(a=t[a],a===void 0?t.push(n):a!==n&&(n.then(cr,cr),n=a),n.status){case"fulfilled":return n.value;case"rejected":throw t=n.reason,lp(t),t;default:if(typeof n.status=="string")n.then(cr,cr);else{if(t=bt,t!==null&&100<t.shellSuspendCounter)throw Error(s(482));t=n,t.status="pending",t.then(function(d){if(n.status==="pending"){var w=n;w.status="fulfilled",w.value=d}},function(d){if(n.status==="pending"){var w=n;w.status="rejected",w.reason=d}})}switch(n.status){case"fulfilled":return n.value;case"rejected":throw t=n.reason,lp(t),t}throw gi=n,es}}function mi(t){try{var n=t._init;return n(t._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(gi=a,es):a}}var gi=null;function op(){if(gi===null)throw Error(s(459));var t=gi;return gi=null,t}function lp(t){if(t===es||t===bo)throw Error(s(483))}var ts=null,Ks=0;function _o(t){var n=Ks;return Ks+=1,ts===null&&(ts=[]),ap(ts,t,n)}function Xs(t,n){n=n.props.ref,t.ref=n!==void 0?n:null}function So(t,n){throw n.$$typeof===x?Error(s(525)):(t=Object.prototype.toString.call(n),Error(s(31,t==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":t)))}function cp(t){function n(ie,ne){if(t){var oe=ie.deletions;oe===null?(ie.deletions=[ne],ie.flags|=16):oe.push(ne)}}function a(ie,ne){if(!t)return null;for(;ne!==null;)n(ie,ne),ne=ne.sibling;return null}function d(ie){for(var ne=new Map;ie!==null;)ie.key!==null?ne.set(ie.key,ie):ne.set(ie.index,ie),ie=ie.sibling;return ne}function w(ie,ne){return ie=dr(ie,ne),ie.index=0,ie.sibling=null,ie}function E(ie,ne,oe){return ie.index=oe,t?(oe=ie.alternate,oe!==null?(oe=oe.index,oe<ne?(ie.flags|=67108866,ne):oe):(ie.flags|=67108866,ne)):(ie.flags|=1048576,ne)}function M(ie){return t&&ie.alternate===null&&(ie.flags|=67108866),ie}function G(ie,ne,oe,me){return ne===null||ne.tag!==6?(ne=Ec(oe,ie.mode,me),ne.return=ie,ne):(ne=w(ne,oe),ne.return=ie,ne)}function ee(ie,ne,oe,me){var Le=oe.type;return Le===C?he(ie,ne,oe.props.children,me,oe.key):ne!==null&&(ne.elementType===Le||typeof Le=="object"&&Le!==null&&Le.$$typeof===T&&mi(Le)===ne.type)?(ne=w(ne,oe.props),Xs(ne,oe),ne.return=ie,ne):(ne=po(oe.type,oe.key,oe.props,null,ie.mode,me),Xs(ne,oe),ne.return=ie,ne)}function le(ie,ne,oe,me){return ne===null||ne.tag!==4||ne.stateNode.containerInfo!==oe.containerInfo||ne.stateNode.implementation!==oe.implementation?(ne=jc(oe,ie.mode,me),ne.return=ie,ne):(ne=w(ne,oe.children||[]),ne.return=ie,ne)}function he(ie,ne,oe,me,Le){return ne===null||ne.tag!==7?(ne=ui(oe,ie.mode,me,Le),ne.return=ie,ne):(ne=w(ne,oe),ne.return=ie,ne)}function xe(ie,ne,oe){if(typeof ne=="string"&&ne!==""||typeof ne=="number"||typeof ne=="bigint")return ne=Ec(""+ne,ie.mode,oe),ne.return=ie,ne;if(typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case S:return oe=po(ne.type,ne.key,ne.props,null,ie.mode,oe),Xs(oe,ne),oe.return=ie,oe;case k:return ne=jc(ne,ie.mode,oe),ne.return=ie,ne;case T:return ne=mi(ne),xe(ie,ne,oe)}if(I(ne)||Y(ne))return ne=ui(ne,ie.mode,oe,null),ne.return=ie,ne;if(typeof ne.then=="function")return xe(ie,_o(ne),oe);if(ne.$$typeof===_)return xe(ie,xo(ie,ne),oe);So(ie,ne)}return null}function ce(ie,ne,oe,me){var Le=ne!==null?ne.key:null;if(typeof oe=="string"&&oe!==""||typeof oe=="number"||typeof oe=="bigint")return Le!==null?null:G(ie,ne,""+oe,me);if(typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case S:return oe.key===Le?ee(ie,ne,oe,me):null;case k:return oe.key===Le?le(ie,ne,oe,me):null;case T:return oe=mi(oe),ce(ie,ne,oe,me)}if(I(oe)||Y(oe))return Le!==null?null:he(ie,ne,oe,me,null);if(typeof oe.then=="function")return ce(ie,ne,_o(oe),me);if(oe.$$typeof===_)return ce(ie,ne,xo(ie,oe),me);So(ie,oe)}return null}function ue(ie,ne,oe,me,Le){if(typeof me=="string"&&me!==""||typeof me=="number"||typeof me=="bigint")return ie=ie.get(oe)||null,G(ne,ie,""+me,Le);if(typeof me=="object"&&me!==null){switch(me.$$typeof){case S:return ie=ie.get(me.key===null?oe:me.key)||null,ee(ne,ie,me,Le);case k:return ie=ie.get(me.key===null?oe:me.key)||null,le(ne,ie,me,Le);case T:return me=mi(me),ue(ie,ne,oe,me,Le)}if(I(me)||Y(me))return ie=ie.get(oe)||null,he(ne,ie,me,Le,null);if(typeof me.then=="function")return ue(ie,ne,oe,_o(me),Le);if(me.$$typeof===_)return ue(ie,ne,oe,xo(ne,me),Le);So(ne,me)}return null}function je(ie,ne,oe,me){for(var Le=null,at=null,Te=ne,qe=ne=0,Qe=null;Te!==null&&qe<oe.length;qe++){Te.index>qe?(Qe=Te,Te=null):Qe=Te.sibling;var ot=ce(ie,Te,oe[qe],me);if(ot===null){Te===null&&(Te=Qe);break}t&&Te&&ot.alternate===null&&n(ie,Te),ne=E(ot,ne,qe),at===null?Le=ot:at.sibling=ot,at=ot,Te=Qe}if(qe===oe.length)return a(ie,Te),nt&&hr(ie,qe),Le;if(Te===null){for(;qe<oe.length;qe++)Te=xe(ie,oe[qe],me),Te!==null&&(ne=E(Te,ne,qe),at===null?Le=Te:at.sibling=Te,at=Te);return nt&&hr(ie,qe),Le}for(Te=d(Te);qe<oe.length;qe++)Qe=ue(Te,ie,qe,oe[qe],me),Qe!==null&&(t&&Qe.alternate!==null&&Te.delete(Qe.key===null?qe:Qe.key),ne=E(Qe,ne,qe),at===null?Le=Qe:at.sibling=Qe,at=Qe);return t&&Te.forEach(function(Qr){return n(ie,Qr)}),nt&&hr(ie,qe),Le}function Ie(ie,ne,oe,me){if(oe==null)throw Error(s(151));for(var Le=null,at=null,Te=ne,qe=ne=0,Qe=null,ot=oe.next();Te!==null&&!ot.done;qe++,ot=oe.next()){Te.index>qe?(Qe=Te,Te=null):Qe=Te.sibling;var Qr=ce(ie,Te,ot.value,me);if(Qr===null){Te===null&&(Te=Qe);break}t&&Te&&Qr.alternate===null&&n(ie,Te),ne=E(Qr,ne,qe),at===null?Le=Qr:at.sibling=Qr,at=Qr,Te=Qe}if(ot.done)return a(ie,Te),nt&&hr(ie,qe),Le;if(Te===null){for(;!ot.done;qe++,ot=oe.next())ot=xe(ie,ot.value,me),ot!==null&&(ne=E(ot,ne,qe),at===null?Le=ot:at.sibling=ot,at=ot);return nt&&hr(ie,qe),Le}for(Te=d(Te);!ot.done;qe++,ot=oe.next())ot=ue(Te,ie,qe,ot.value,me),ot!==null&&(t&&ot.alternate!==null&&Te.delete(ot.key===null?qe:ot.key),ne=E(ot,ne,qe),at===null?Le=ot:at.sibling=ot,at=ot);return t&&Te.forEach(function(n1){return n(ie,n1)}),nt&&hr(ie,qe),Le}function vt(ie,ne,oe,me){if(typeof oe=="object"&&oe!==null&&oe.type===C&&oe.key===null&&(oe=oe.props.children),typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case S:e:{for(var Le=oe.key;ne!==null;){if(ne.key===Le){if(Le=oe.type,Le===C){if(ne.tag===7){a(ie,ne.sibling),me=w(ne,oe.props.children),me.return=ie,ie=me;break e}}else if(ne.elementType===Le||typeof Le=="object"&&Le!==null&&Le.$$typeof===T&&mi(Le)===ne.type){a(ie,ne.sibling),me=w(ne,oe.props),Xs(me,oe),me.return=ie,ie=me;break e}a(ie,ne);break}else n(ie,ne);ne=ne.sibling}oe.type===C?(me=ui(oe.props.children,ie.mode,me,oe.key),me.return=ie,ie=me):(me=po(oe.type,oe.key,oe.props,null,ie.mode,me),Xs(me,oe),me.return=ie,ie=me)}return M(ie);case k:e:{for(Le=oe.key;ne!==null;){if(ne.key===Le)if(ne.tag===4&&ne.stateNode.containerInfo===oe.containerInfo&&ne.stateNode.implementation===oe.implementation){a(ie,ne.sibling),me=w(ne,oe.children||[]),me.return=ie,ie=me;break e}else{a(ie,ne);break}else n(ie,ne);ne=ne.sibling}me=jc(oe,ie.mode,me),me.return=ie,ie=me}return M(ie);case T:return oe=mi(oe),vt(ie,ne,oe,me)}if(I(oe))return je(ie,ne,oe,me);if(Y(oe)){if(Le=Y(oe),typeof Le!="function")throw Error(s(150));return oe=Le.call(oe),Ie(ie,ne,oe,me)}if(typeof oe.then=="function")return vt(ie,ne,_o(oe),me);if(oe.$$typeof===_)return vt(ie,ne,xo(ie,oe),me);So(ie,oe)}return typeof oe=="string"&&oe!==""||typeof oe=="number"||typeof oe=="bigint"?(oe=""+oe,ne!==null&&ne.tag===6?(a(ie,ne.sibling),me=w(ne,oe),me.return=ie,ie=me):(a(ie,ne),me=Ec(oe,ie.mode,me),me.return=ie,ie=me),M(ie)):a(ie,ne)}return function(ie,ne,oe,me){try{Ks=0;var Le=vt(ie,ne,oe,me);return ts=null,Le}catch(Te){if(Te===es||Te===bo)throw Te;var at=_n(29,Te,null,ie.mode);return at.lanes=me,at.return=ie,at}finally{}}}var xi=cp(!0),up=cp(!1),Or=!1;function Hc(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Pc(t,n){t=t.updateQueue,n.updateQueue===t&&(n.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function Br(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function Ir(t,n,a){var d=t.updateQueue;if(d===null)return null;if(d=d.shared,(ut&2)!==0){var w=d.pending;return w===null?n.next=n:(n.next=w.next,w.next=n),d.pending=n,n=fo(t),Vf(t,null,a),n}return ho(t,d,n,a),fo(t)}function Zs(t,n,a){if(n=n.updateQueue,n!==null&&(n=n.shared,(a&4194048)!==0)){var d=n.lanes;d&=t.pendingLanes,a|=d,n.lanes=a,ef(t,a)}}function Fc(t,n){var a=t.updateQueue,d=t.alternate;if(d!==null&&(d=d.updateQueue,a===d)){var w=null,E=null;if(a=a.firstBaseUpdate,a!==null){do{var M={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};E===null?w=E=M:E=E.next=M,a=a.next}while(a!==null);E===null?w=E=n:E=E.next=n}else w=E=n;a={baseState:d.baseState,firstBaseUpdate:w,lastBaseUpdate:E,shared:d.shared,callbacks:d.callbacks},t.updateQueue=a;return}t=a.lastBaseUpdate,t===null?a.firstBaseUpdate=n:t.next=n,a.lastBaseUpdate=n}var Uc=!1;function Qs(){if(Uc){var t=Ji;if(t!==null)throw t}}function Js(t,n,a,d){Uc=!1;var w=t.updateQueue;Or=!1;var E=w.firstBaseUpdate,M=w.lastBaseUpdate,G=w.shared.pending;if(G!==null){w.shared.pending=null;var ee=G,le=ee.next;ee.next=null,M===null?E=le:M.next=le,M=ee;var he=t.alternate;he!==null&&(he=he.updateQueue,G=he.lastBaseUpdate,G!==M&&(G===null?he.firstBaseUpdate=le:G.next=le,he.lastBaseUpdate=ee))}if(E!==null){var xe=w.baseState;M=0,he=le=ee=null,G=E;do{var ce=G.lane&-536870913,ue=ce!==G.lane;if(ue?(Ze&ce)===ce:(d&ce)===ce){ce!==0&&ce===Qi&&(Uc=!0),he!==null&&(he=he.next={lane:0,tag:G.tag,payload:G.payload,callback:null,next:null});e:{var je=t,Ie=G;ce=n;var vt=a;switch(Ie.tag){case 1:if(je=Ie.payload,typeof je=="function"){xe=je.call(vt,xe,ce);break e}xe=je;break e;case 3:je.flags=je.flags&-65537|128;case 0:if(je=Ie.payload,ce=typeof je=="function"?je.call(vt,xe,ce):je,ce==null)break e;xe=m({},xe,ce);break e;case 2:Or=!0}}ce=G.callback,ce!==null&&(t.flags|=64,ue&&(t.flags|=8192),ue=w.callbacks,ue===null?w.callbacks=[ce]:ue.push(ce))}else ue={lane:ce,tag:G.tag,payload:G.payload,callback:G.callback,next:null},he===null?(le=he=ue,ee=xe):he=he.next=ue,M|=ce;if(G=G.next,G===null){if(G=w.shared.pending,G===null)break;ue=G,G=ue.next,ue.next=null,w.lastBaseUpdate=ue,w.shared.pending=null}}while(!0);he===null&&(ee=xe),w.baseState=ee,w.firstBaseUpdate=le,w.lastBaseUpdate=he,E===null&&(w.shared.lanes=0),Ur|=M,t.lanes=M,t.memoizedState=xe}}function dp(t,n){if(typeof t!="function")throw Error(s(191,t));t.call(n)}function hp(t,n){var a=t.callbacks;if(a!==null)for(t.callbacks=null,t=0;t<a.length;t++)dp(a[t],n)}var ns=O(null),wo=O(0);function fp(t,n){t=wr,U(wo,t),U(ns,n),wr=t|n.baseLanes}function $c(){U(wo,wr),U(ns,ns.current)}function qc(){wr=wo.current,W(ns),W(wo)}var Sn=O(null),Pn=null;function zr(t){var n=t.alternate;U(Tt,Tt.current&1),U(Sn,t),Pn===null&&(n===null||ns.current!==null||n.memoizedState!==null)&&(Pn=t)}function Wc(t){U(Tt,Tt.current),U(Sn,t),Pn===null&&(Pn=t)}function pp(t){t.tag===22?(U(Tt,Tt.current),U(Sn,t),Pn===null&&(Pn=t)):Hr()}function Hr(){U(Tt,Tt.current),U(Sn,Sn.current)}function wn(t){W(Sn),Pn===t&&(Pn=null),W(Tt)}var Tt=O(0);function Co(t){for(var n=t;n!==null;){if(n.tag===13){var a=n.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||Zu(a)||Qu(a)))return n}else if(n.tag===19&&(n.memoizedProps.revealOrder==="forwards"||n.memoizedProps.revealOrder==="backwards"||n.memoizedProps.revealOrder==="unstable_legacy-backwards"||n.memoizedProps.revealOrder==="together")){if((n.flags&128)!==0)return n}else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var mr=0,Ue=null,gt=null,Mt=null,ko=!1,rs=!1,vi=!1,Eo=0,ea=0,is=null,Gy=0;function jt(){throw Error(s(321))}function Gc(t,n){if(n===null)return!1;for(var a=0;a<n.length&&a<t.length;a++)if(!yn(t[a],n[a]))return!1;return!0}function Vc(t,n,a,d,w,E){return mr=E,Ue=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,$.H=t===null||t.memoizedState===null?Zp:lu,vi=!1,E=a(d,w),vi=!1,rs&&(E=gp(n,a,d,w)),mp(t),E}function mp(t){$.H=ra;var n=gt!==null&&gt.next!==null;if(mr=0,Mt=gt=Ue=null,ko=!1,ea=0,is=null,n)throw Error(s(300));t===null||Ot||(t=t.dependencies,t!==null&&go(t)&&(Ot=!0))}function gp(t,n,a,d){Ue=t;var w=0;do{if(rs&&(is=null),ea=0,rs=!1,25<=w)throw Error(s(301));if(w+=1,Mt=gt=null,t.updateQueue!=null){var E=t.updateQueue;E.lastEffect=null,E.events=null,E.stores=null,E.memoCache!=null&&(E.memoCache.index=0)}$.H=Qp,E=n(a,d)}while(rs);return E}function Vy(){var t=$.H,n=t.useState()[0];return n=typeof n.then=="function"?ta(n):n,t=t.useState()[0],(gt!==null?gt.memoizedState:null)!==t&&(Ue.flags|=1024),n}function Yc(){var t=Eo!==0;return Eo=0,t}function Kc(t,n,a){n.updateQueue=t.updateQueue,n.flags&=-2053,t.lanes&=~a}function Xc(t){if(ko){for(t=t.memoizedState;t!==null;){var n=t.queue;n!==null&&(n.pending=null),t=t.next}ko=!1}mr=0,Mt=gt=Ue=null,rs=!1,ea=Eo=0,is=null}function on(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Mt===null?Ue.memoizedState=Mt=t:Mt=Mt.next=t,Mt}function At(){if(gt===null){var t=Ue.alternate;t=t!==null?t.memoizedState:null}else t=gt.next;var n=Mt===null?Ue.memoizedState:Mt.next;if(n!==null)Mt=n,gt=t;else{if(t===null)throw Ue.alternate===null?Error(s(467)):Error(s(310));gt=t,t={memoizedState:gt.memoizedState,baseState:gt.baseState,baseQueue:gt.baseQueue,queue:gt.queue,next:null},Mt===null?Ue.memoizedState=Mt=t:Mt=Mt.next=t}return Mt}function jo(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ta(t){var n=ea;return ea+=1,is===null&&(is=[]),t=ap(is,t,n),n=Ue,(Mt===null?n.memoizedState:Mt.next)===null&&(n=n.alternate,$.H=n===null||n.memoizedState===null?Zp:lu),t}function No(t){if(t!==null&&typeof t=="object"){if(typeof t.then=="function")return ta(t);if(t.$$typeof===_)return Zt(t)}throw Error(s(438,String(t)))}function Zc(t){var n=null,a=Ue.updateQueue;if(a!==null&&(n=a.memoCache),n==null){var d=Ue.alternate;d!==null&&(d=d.updateQueue,d!==null&&(d=d.memoCache,d!=null&&(n={data:d.data.map(function(w){return w.slice()}),index:0})))}if(n==null&&(n={data:[],index:0}),a===null&&(a=jo(),Ue.updateQueue=a),a.memoCache=n,a=n.data[n.index],a===void 0)for(a=n.data[n.index]=Array(t),d=0;d<t;d++)a[d]=H;return n.index++,a}function gr(t,n){return typeof n=="function"?n(t):n}function To(t){var n=At();return Qc(n,gt,t)}function Qc(t,n,a){var d=t.queue;if(d===null)throw Error(s(311));d.lastRenderedReducer=a;var w=t.baseQueue,E=d.pending;if(E!==null){if(w!==null){var M=w.next;w.next=E.next,E.next=M}n.baseQueue=w=E,d.pending=null}if(E=t.baseState,w===null)t.memoizedState=E;else{n=w.next;var G=M=null,ee=null,le=n,he=!1;do{var xe=le.lane&-536870913;if(xe!==le.lane?(Ze&xe)===xe:(mr&xe)===xe){var ce=le.revertLane;if(ce===0)ee!==null&&(ee=ee.next={lane:0,revertLane:0,gesture:null,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null}),xe===Qi&&(he=!0);else if((mr&ce)===ce){le=le.next,ce===Qi&&(he=!0);continue}else xe={lane:0,revertLane:le.revertLane,gesture:null,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null},ee===null?(G=ee=xe,M=E):ee=ee.next=xe,Ue.lanes|=ce,Ur|=ce;xe=le.action,vi&&a(E,xe),E=le.hasEagerState?le.eagerState:a(E,xe)}else ce={lane:xe,revertLane:le.revertLane,gesture:le.gesture,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null},ee===null?(G=ee=ce,M=E):ee=ee.next=ce,Ue.lanes|=xe,Ur|=xe;le=le.next}while(le!==null&&le!==n);if(ee===null?M=E:ee.next=G,!yn(E,t.memoizedState)&&(Ot=!0,he&&(a=Ji,a!==null)))throw a;t.memoizedState=E,t.baseState=M,t.baseQueue=ee,d.lastRenderedState=E}return w===null&&(d.lanes=0),[t.memoizedState,d.dispatch]}function Jc(t){var n=At(),a=n.queue;if(a===null)throw Error(s(311));a.lastRenderedReducer=t;var d=a.dispatch,w=a.pending,E=n.memoizedState;if(w!==null){a.pending=null;var M=w=w.next;do E=t(E,M.action),M=M.next;while(M!==w);yn(E,n.memoizedState)||(Ot=!0),n.memoizedState=E,n.baseQueue===null&&(n.baseState=E),a.lastRenderedState=E}return[E,d]}function xp(t,n,a){var d=Ue,w=At(),E=nt;if(E){if(a===void 0)throw Error(s(407));a=a()}else a=n();var M=!yn((gt||w).memoizedState,a);if(M&&(w.memoizedState=a,Ot=!0),w=w.queue,nu(yp.bind(null,d,w,t),[t]),w.getSnapshot!==n||M||Mt!==null&&Mt.memoizedState.tag&1){if(d.flags|=2048,ss(9,{destroy:void 0},bp.bind(null,d,w,a,n),null),bt===null)throw Error(s(349));E||(mr&127)!==0||vp(d,n,a)}return a}function vp(t,n,a){t.flags|=16384,t={getSnapshot:n,value:a},n=Ue.updateQueue,n===null?(n=jo(),Ue.updateQueue=n,n.stores=[t]):(a=n.stores,a===null?n.stores=[t]:a.push(t))}function bp(t,n,a,d){n.value=a,n.getSnapshot=d,_p(n)&&Sp(t)}function yp(t,n,a){return a(function(){_p(n)&&Sp(t)})}function _p(t){var n=t.getSnapshot;t=t.value;try{var a=n();return!yn(t,a)}catch{return!0}}function Sp(t){var n=ci(t,2);n!==null&&xn(n,t,2)}function eu(t){var n=on();if(typeof t=="function"){var a=t;if(t=a(),vi){Ct(!0);try{a()}finally{Ct(!1)}}}return n.memoizedState=n.baseState=t,n.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:gr,lastRenderedState:t},n}function wp(t,n,a,d){return t.baseState=a,Qc(t,gt,typeof d=="function"?d:gr)}function Yy(t,n,a,d,w){if(Lo(t))throw Error(s(485));if(t=n.action,t!==null){var E={payload:w,action:t,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(M){E.listeners.push(M)}};$.T!==null?a(!0):E.isTransition=!1,d(E),a=n.pending,a===null?(E.next=n.pending=E,Cp(n,E)):(E.next=a.next,n.pending=a.next=E)}}function Cp(t,n){var a=n.action,d=n.payload,w=t.state;if(n.isTransition){var E=$.T,M={};$.T=M;try{var G=a(w,d),ee=$.S;ee!==null&&ee(M,G),kp(t,n,G)}catch(le){tu(t,n,le)}finally{E!==null&&M.types!==null&&(E.types=M.types),$.T=E}}else try{E=a(w,d),kp(t,n,E)}catch(le){tu(t,n,le)}}function kp(t,n,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(d){Ep(t,n,d)},function(d){return tu(t,n,d)}):Ep(t,n,a)}function Ep(t,n,a){n.status="fulfilled",n.value=a,jp(n),t.state=a,n=t.pending,n!==null&&(a=n.next,a===n?t.pending=null:(a=a.next,n.next=a,Cp(t,a)))}function tu(t,n,a){var d=t.pending;if(t.pending=null,d!==null){d=d.next;do n.status="rejected",n.reason=a,jp(n),n=n.next;while(n!==d)}t.action=null}function jp(t){t=t.listeners;for(var n=0;n<t.length;n++)(0,t[n])()}function Np(t,n){return n}function Tp(t,n){if(nt){var a=bt.formState;if(a!==null){e:{var d=Ue;if(nt){if(St){t:{for(var w=St,E=Hn;w.nodeType!==8;){if(!E){w=null;break t}if(w=Fn(w.nextSibling),w===null){w=null;break t}}E=w.data,w=E==="F!"||E==="F"?w:null}if(w){St=Fn(w.nextSibling),d=w.data==="F!";break e}}Rr(d)}d=!1}d&&(n=a[0])}}return a=on(),a.memoizedState=a.baseState=n,d={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Np,lastRenderedState:n},a.queue=d,a=Yp.bind(null,Ue,d),d.dispatch=a,d=eu(!1),E=ou.bind(null,Ue,!1,d.queue),d=on(),w={state:n,dispatch:null,action:t,pending:null},d.queue=w,a=Yy.bind(null,Ue,w,E,a),w.dispatch=a,d.memoizedState=t,[n,a,!1]}function Ap(t){var n=At();return Dp(n,gt,t)}function Dp(t,n,a){if(n=Qc(t,n,Np)[0],t=To(gr)[0],typeof n=="object"&&n!==null&&typeof n.then=="function")try{var d=ta(n)}catch(M){throw M===es?bo:M}else d=n;n=At();var w=n.queue,E=w.dispatch;return a!==n.memoizedState&&(Ue.flags|=2048,ss(9,{destroy:void 0},Ky.bind(null,w,a),null)),[d,E,t]}function Ky(t,n){t.action=n}function Lp(t){var n=At(),a=gt;if(a!==null)return Dp(n,a,t);At(),n=n.memoizedState,a=At();var d=a.queue.dispatch;return a.memoizedState=t,[n,d,!1]}function ss(t,n,a,d){return t={tag:t,create:a,deps:d,inst:n,next:null},n=Ue.updateQueue,n===null&&(n=jo(),Ue.updateQueue=n),a=n.lastEffect,a===null?n.lastEffect=t.next=t:(d=a.next,a.next=t,t.next=d,n.lastEffect=t),t}function Rp(){return At().memoizedState}function Ao(t,n,a,d){var w=on();Ue.flags|=t,w.memoizedState=ss(1|n,{destroy:void 0},a,d===void 0?null:d)}function Do(t,n,a,d){var w=At();d=d===void 0?null:d;var E=w.memoizedState.inst;gt!==null&&d!==null&&Gc(d,gt.memoizedState.deps)?w.memoizedState=ss(n,E,a,d):(Ue.flags|=t,w.memoizedState=ss(1|n,E,a,d))}function Mp(t,n){Ao(8390656,8,t,n)}function nu(t,n){Do(2048,8,t,n)}function Xy(t){Ue.flags|=4;var n=Ue.updateQueue;if(n===null)n=jo(),Ue.updateQueue=n,n.events=[t];else{var a=n.events;a===null?n.events=[t]:a.push(t)}}function Op(t){var n=At().memoizedState;return Xy({ref:n,nextImpl:t}),function(){if((ut&2)!==0)throw Error(s(440));return n.impl.apply(void 0,arguments)}}function Bp(t,n){return Do(4,2,t,n)}function Ip(t,n){return Do(4,4,t,n)}function zp(t,n){if(typeof n=="function"){t=t();var a=n(t);return function(){typeof a=="function"?a():n(null)}}if(n!=null)return t=t(),n.current=t,function(){n.current=null}}function Hp(t,n,a){a=a!=null?a.concat([t]):null,Do(4,4,zp.bind(null,n,t),a)}function ru(){}function Pp(t,n){var a=At();n=n===void 0?null:n;var d=a.memoizedState;return n!==null&&Gc(n,d[1])?d[0]:(a.memoizedState=[t,n],t)}function Fp(t,n){var a=At();n=n===void 0?null:n;var d=a.memoizedState;if(n!==null&&Gc(n,d[1]))return d[0];if(d=t(),vi){Ct(!0);try{t()}finally{Ct(!1)}}return a.memoizedState=[d,n],d}function iu(t,n,a){return a===void 0||(mr&1073741824)!==0&&(Ze&261930)===0?t.memoizedState=n:(t.memoizedState=a,t=Um(),Ue.lanes|=t,Ur|=t,a)}function Up(t,n,a,d){return yn(a,n)?a:ns.current!==null?(t=iu(t,a,d),yn(t,n)||(Ot=!0),t):(mr&42)===0||(mr&1073741824)!==0&&(Ze&261930)===0?(Ot=!0,t.memoizedState=a):(t=Um(),Ue.lanes|=t,Ur|=t,n)}function $p(t,n,a,d,w){var E=X.p;X.p=E!==0&&8>E?E:8;var M=$.T,G={};$.T=G,ou(t,!1,n,a);try{var ee=w(),le=$.S;if(le!==null&&le(G,ee),ee!==null&&typeof ee=="object"&&typeof ee.then=="function"){var he=Wy(ee,d);na(t,n,he,En(t))}else na(t,n,d,En(t))}catch(xe){na(t,n,{then:function(){},status:"rejected",reason:xe},En())}finally{X.p=E,M!==null&&G.types!==null&&(M.types=G.types),$.T=M}}function Zy(){}function su(t,n,a,d){if(t.tag!==5)throw Error(s(476));var w=qp(t).queue;$p(t,w,n,J,a===null?Zy:function(){return Wp(t),a(d)})}function qp(t){var n=t.memoizedState;if(n!==null)return n;n={memoizedState:J,baseState:J,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:gr,lastRenderedState:J},next:null};var a={};return n.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:gr,lastRenderedState:a},next:null},t.memoizedState=n,t=t.alternate,t!==null&&(t.memoizedState=n),n}function Wp(t){var n=qp(t);n.next===null&&(n=t.alternate.memoizedState),na(t,n.next.queue,{},En())}function au(){return Zt(ba)}function Gp(){return At().memoizedState}function Vp(){return At().memoizedState}function Qy(t){for(var n=t.return;n!==null;){switch(n.tag){case 24:case 3:var a=En();t=Br(a);var d=Ir(n,t,a);d!==null&&(xn(d,n,a),Zs(d,n,a)),n={cache:Oc()},t.payload=n;return}n=n.return}}function Jy(t,n,a){var d=En();a={lane:d,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Lo(t)?Kp(n,a):(a=Cc(t,n,a,d),a!==null&&(xn(a,t,d),Xp(a,n,d)))}function Yp(t,n,a){var d=En();na(t,n,a,d)}function na(t,n,a,d){var w={lane:d,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Lo(t))Kp(n,w);else{var E=t.alternate;if(t.lanes===0&&(E===null||E.lanes===0)&&(E=n.lastRenderedReducer,E!==null))try{var M=n.lastRenderedState,G=E(M,a);if(w.hasEagerState=!0,w.eagerState=G,yn(G,M))return ho(t,n,w,0),bt===null&&uo(),!1}catch{}finally{}if(a=Cc(t,n,w,d),a!==null)return xn(a,t,d),Xp(a,n,d),!0}return!1}function ou(t,n,a,d){if(d={lane:2,revertLane:Hu(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Lo(t)){if(n)throw Error(s(479))}else n=Cc(t,a,d,2),n!==null&&xn(n,t,2)}function Lo(t){var n=t.alternate;return t===Ue||n!==null&&n===Ue}function Kp(t,n){rs=ko=!0;var a=t.pending;a===null?n.next=n:(n.next=a.next,a.next=n),t.pending=n}function Xp(t,n,a){if((a&4194048)!==0){var d=n.lanes;d&=t.pendingLanes,a|=d,n.lanes=a,ef(t,a)}}var ra={readContext:Zt,use:No,useCallback:jt,useContext:jt,useEffect:jt,useImperativeHandle:jt,useLayoutEffect:jt,useInsertionEffect:jt,useMemo:jt,useReducer:jt,useRef:jt,useState:jt,useDebugValue:jt,useDeferredValue:jt,useTransition:jt,useSyncExternalStore:jt,useId:jt,useHostTransitionStatus:jt,useFormState:jt,useActionState:jt,useOptimistic:jt,useMemoCache:jt,useCacheRefresh:jt};ra.useEffectEvent=jt;var Zp={readContext:Zt,use:No,useCallback:function(t,n){return on().memoizedState=[t,n===void 0?null:n],t},useContext:Zt,useEffect:Mp,useImperativeHandle:function(t,n,a){a=a!=null?a.concat([t]):null,Ao(4194308,4,zp.bind(null,n,t),a)},useLayoutEffect:function(t,n){return Ao(4194308,4,t,n)},useInsertionEffect:function(t,n){Ao(4,2,t,n)},useMemo:function(t,n){var a=on();n=n===void 0?null:n;var d=t();if(vi){Ct(!0);try{t()}finally{Ct(!1)}}return a.memoizedState=[d,n],d},useReducer:function(t,n,a){var d=on();if(a!==void 0){var w=a(n);if(vi){Ct(!0);try{a(n)}finally{Ct(!1)}}}else w=n;return d.memoizedState=d.baseState=w,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:w},d.queue=t,t=t.dispatch=Jy.bind(null,Ue,t),[d.memoizedState,t]},useRef:function(t){var n=on();return t={current:t},n.memoizedState=t},useState:function(t){t=eu(t);var n=t.queue,a=Yp.bind(null,Ue,n);return n.dispatch=a,[t.memoizedState,a]},useDebugValue:ru,useDeferredValue:function(t,n){var a=on();return iu(a,t,n)},useTransition:function(){var t=eu(!1);return t=$p.bind(null,Ue,t.queue,!0,!1),on().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,n,a){var d=Ue,w=on();if(nt){if(a===void 0)throw Error(s(407));a=a()}else{if(a=n(),bt===null)throw Error(s(349));(Ze&127)!==0||vp(d,n,a)}w.memoizedState=a;var E={value:a,getSnapshot:n};return w.queue=E,Mp(yp.bind(null,d,E,t),[t]),d.flags|=2048,ss(9,{destroy:void 0},bp.bind(null,d,E,a,n),null),a},useId:function(){var t=on(),n=bt.identifierPrefix;if(nt){var a=Qn,d=Zn;a=(d&~(1<<32-$e(d)-1)).toString(32)+a,n="_"+n+"R_"+a,a=Eo++,0<a&&(n+="H"+a.toString(32)),n+="_"}else a=Gy++,n="_"+n+"r_"+a.toString(32)+"_";return t.memoizedState=n},useHostTransitionStatus:au,useFormState:Tp,useActionState:Tp,useOptimistic:function(t){var n=on();n.memoizedState=n.baseState=t;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=a,n=ou.bind(null,Ue,!0,a),a.dispatch=n,[t,n]},useMemoCache:Zc,useCacheRefresh:function(){return on().memoizedState=Qy.bind(null,Ue)},useEffectEvent:function(t){var n=on(),a={impl:t};return n.memoizedState=a,function(){if((ut&2)!==0)throw Error(s(440));return a.impl.apply(void 0,arguments)}}},lu={readContext:Zt,use:No,useCallback:Pp,useContext:Zt,useEffect:nu,useImperativeHandle:Hp,useInsertionEffect:Bp,useLayoutEffect:Ip,useMemo:Fp,useReducer:To,useRef:Rp,useState:function(){return To(gr)},useDebugValue:ru,useDeferredValue:function(t,n){var a=At();return Up(a,gt.memoizedState,t,n)},useTransition:function(){var t=To(gr)[0],n=At().memoizedState;return[typeof t=="boolean"?t:ta(t),n]},useSyncExternalStore:xp,useId:Gp,useHostTransitionStatus:au,useFormState:Ap,useActionState:Ap,useOptimistic:function(t,n){var a=At();return wp(a,gt,t,n)},useMemoCache:Zc,useCacheRefresh:Vp};lu.useEffectEvent=Op;var Qp={readContext:Zt,use:No,useCallback:Pp,useContext:Zt,useEffect:nu,useImperativeHandle:Hp,useInsertionEffect:Bp,useLayoutEffect:Ip,useMemo:Fp,useReducer:Jc,useRef:Rp,useState:function(){return Jc(gr)},useDebugValue:ru,useDeferredValue:function(t,n){var a=At();return gt===null?iu(a,t,n):Up(a,gt.memoizedState,t,n)},useTransition:function(){var t=Jc(gr)[0],n=At().memoizedState;return[typeof t=="boolean"?t:ta(t),n]},useSyncExternalStore:xp,useId:Gp,useHostTransitionStatus:au,useFormState:Lp,useActionState:Lp,useOptimistic:function(t,n){var a=At();return gt!==null?wp(a,gt,t,n):(a.baseState=t,[t,a.queue.dispatch])},useMemoCache:Zc,useCacheRefresh:Vp};Qp.useEffectEvent=Op;function cu(t,n,a,d){n=t.memoizedState,a=a(d,n),a=a==null?n:m({},n,a),t.memoizedState=a,t.lanes===0&&(t.updateQueue.baseState=a)}var uu={enqueueSetState:function(t,n,a){t=t._reactInternals;var d=En(),w=Br(d);w.payload=n,a!=null&&(w.callback=a),n=Ir(t,w,d),n!==null&&(xn(n,t,d),Zs(n,t,d))},enqueueReplaceState:function(t,n,a){t=t._reactInternals;var d=En(),w=Br(d);w.tag=1,w.payload=n,a!=null&&(w.callback=a),n=Ir(t,w,d),n!==null&&(xn(n,t,d),Zs(n,t,d))},enqueueForceUpdate:function(t,n){t=t._reactInternals;var a=En(),d=Br(a);d.tag=2,n!=null&&(d.callback=n),n=Ir(t,d,a),n!==null&&(xn(n,t,a),Zs(n,t,a))}};function Jp(t,n,a,d,w,E,M){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(d,E,M):n.prototype&&n.prototype.isPureReactComponent?!$s(a,d)||!$s(w,E):!0}function em(t,n,a,d){t=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(a,d),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(a,d),n.state!==t&&uu.enqueueReplaceState(n,n.state,null)}function bi(t,n){var a=n;if("ref"in n){a={};for(var d in n)d!=="ref"&&(a[d]=n[d])}if(t=t.defaultProps){a===n&&(a=m({},a));for(var w in t)a[w]===void 0&&(a[w]=t[w])}return a}function tm(t){co(t)}function nm(t){console.error(t)}function rm(t){co(t)}function Ro(t,n){try{var a=t.onUncaughtError;a(n.value,{componentStack:n.stack})}catch(d){setTimeout(function(){throw d})}}function im(t,n,a){try{var d=t.onCaughtError;d(a.value,{componentStack:a.stack,errorBoundary:n.tag===1?n.stateNode:null})}catch(w){setTimeout(function(){throw w})}}function du(t,n,a){return a=Br(a),a.tag=3,a.payload={element:null},a.callback=function(){Ro(t,n)},a}function sm(t){return t=Br(t),t.tag=3,t}function am(t,n,a,d){var w=a.type.getDerivedStateFromError;if(typeof w=="function"){var E=d.value;t.payload=function(){return w(E)},t.callback=function(){im(n,a,d)}}var M=a.stateNode;M!==null&&typeof M.componentDidCatch=="function"&&(t.callback=function(){im(n,a,d),typeof w!="function"&&($r===null?$r=new Set([this]):$r.add(this));var G=d.stack;this.componentDidCatch(d.value,{componentStack:G!==null?G:""})})}function e_(t,n,a,d,w){if(a.flags|=32768,d!==null&&typeof d=="object"&&typeof d.then=="function"){if(n=a.alternate,n!==null&&Zi(n,a,w,!0),a=Sn.current,a!==null){switch(a.tag){case 31:case 13:return Pn===null?Wo():a.alternate===null&&Nt===0&&(Nt=3),a.flags&=-257,a.flags|=65536,a.lanes=w,d===yo?a.flags|=16384:(n=a.updateQueue,n===null?a.updateQueue=new Set([d]):n.add(d),Bu(t,d,w)),!1;case 22:return a.flags|=65536,d===yo?a.flags|=16384:(n=a.updateQueue,n===null?(n={transitions:null,markerInstances:null,retryQueue:new Set([d])},a.updateQueue=n):(a=n.retryQueue,a===null?n.retryQueue=new Set([d]):a.add(d)),Bu(t,d,w)),!1}throw Error(s(435,a.tag))}return Bu(t,d,w),Wo(),!1}if(nt)return n=Sn.current,n!==null?((n.flags&65536)===0&&(n.flags|=256),n.flags|=65536,n.lanes=w,d!==Ac&&(t=Error(s(422),{cause:d}),Gs(Bn(t,a)))):(d!==Ac&&(n=Error(s(423),{cause:d}),Gs(Bn(n,a))),t=t.current.alternate,t.flags|=65536,w&=-w,t.lanes|=w,d=Bn(d,a),w=du(t.stateNode,d,w),Fc(t,w),Nt!==4&&(Nt=2)),!1;var E=Error(s(520),{cause:d});if(E=Bn(E,a),da===null?da=[E]:da.push(E),Nt!==4&&(Nt=2),n===null)return!0;d=Bn(d,a),a=n;do{switch(a.tag){case 3:return a.flags|=65536,t=w&-w,a.lanes|=t,t=du(a.stateNode,d,t),Fc(a,t),!1;case 1:if(n=a.type,E=a.stateNode,(a.flags&128)===0&&(typeof n.getDerivedStateFromError=="function"||E!==null&&typeof E.componentDidCatch=="function"&&($r===null||!$r.has(E))))return a.flags|=65536,w&=-w,a.lanes|=w,w=sm(w),am(w,t,a,d),Fc(a,w),!1}a=a.return}while(a!==null);return!1}var hu=Error(s(461)),Ot=!1;function Qt(t,n,a,d){n.child=t===null?up(n,null,a,d):xi(n,t.child,a,d)}function om(t,n,a,d,w){a=a.render;var E=n.ref;if("ref"in d){var M={};for(var G in d)G!=="ref"&&(M[G]=d[G])}else M=d;return fi(n),d=Vc(t,n,a,M,E,w),G=Yc(),t!==null&&!Ot?(Kc(t,n,w),xr(t,n,w)):(nt&&G&&Nc(n),n.flags|=1,Qt(t,n,d,w),n.child)}function lm(t,n,a,d,w){if(t===null){var E=a.type;return typeof E=="function"&&!kc(E)&&E.defaultProps===void 0&&a.compare===null?(n.tag=15,n.type=E,cm(t,n,E,d,w)):(t=po(a.type,null,d,n,n.mode,w),t.ref=n.ref,t.return=n,n.child=t)}if(E=t.child,!yu(t,w)){var M=E.memoizedProps;if(a=a.compare,a=a!==null?a:$s,a(M,d)&&t.ref===n.ref)return xr(t,n,w)}return n.flags|=1,t=dr(E,d),t.ref=n.ref,t.return=n,n.child=t}function cm(t,n,a,d,w){if(t!==null){var E=t.memoizedProps;if($s(E,d)&&t.ref===n.ref)if(Ot=!1,n.pendingProps=d=E,yu(t,w))(t.flags&131072)!==0&&(Ot=!0);else return n.lanes=t.lanes,xr(t,n,w)}return fu(t,n,a,d,w)}function um(t,n,a,d){var w=d.children,E=t!==null?t.memoizedState:null;if(t===null&&n.stateNode===null&&(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),d.mode==="hidden"){if((n.flags&128)!==0){if(E=E!==null?E.baseLanes|a:a,t!==null){for(d=n.child=t.child,w=0;d!==null;)w=w|d.lanes|d.childLanes,d=d.sibling;d=w&~E}else d=0,n.child=null;return dm(t,n,E,a,d)}if((a&536870912)!==0)n.memoizedState={baseLanes:0,cachePool:null},t!==null&&vo(n,E!==null?E.cachePool:null),E!==null?fp(n,E):$c(),pp(n);else return d=n.lanes=536870912,dm(t,n,E!==null?E.baseLanes|a:a,a,d)}else E!==null?(vo(n,E.cachePool),fp(n,E),Hr(),n.memoizedState=null):(t!==null&&vo(n,null),$c(),Hr());return Qt(t,n,w,a),n.child}function ia(t,n){return t!==null&&t.tag===22||n.stateNode!==null||(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),n.sibling}function dm(t,n,a,d,w){var E=Ic();return E=E===null?null:{parent:Rt._currentValue,pool:E},n.memoizedState={baseLanes:a,cachePool:E},t!==null&&vo(n,null),$c(),pp(n),t!==null&&Zi(t,n,d,!0),n.childLanes=w,null}function Mo(t,n){return n=Bo({mode:n.mode,children:n.children},t.mode),n.ref=t.ref,t.child=n,n.return=t,n}function hm(t,n,a){return xi(n,t.child,null,a),t=Mo(n,n.pendingProps),t.flags|=2,wn(n),n.memoizedState=null,t}function t_(t,n,a){var d=n.pendingProps,w=(n.flags&128)!==0;if(n.flags&=-129,t===null){if(nt){if(d.mode==="hidden")return t=Mo(n,d),n.lanes=536870912,ia(null,t);if(Wc(n),(t=St)?(t=Cg(t,Hn),t=t!==null&&t.data==="&"?t:null,t!==null&&(n.memoizedState={dehydrated:t,treeContext:Dr!==null?{id:Zn,overflow:Qn}:null,retryLane:536870912,hydrationErrors:null},a=Kf(t),a.return=n,n.child=a,Xt=n,St=null)):t=null,t===null)throw Rr(n);return n.lanes=536870912,null}return Mo(n,d)}var E=t.memoizedState;if(E!==null){var M=E.dehydrated;if(Wc(n),w)if(n.flags&256)n.flags&=-257,n=hm(t,n,a);else if(n.memoizedState!==null)n.child=t.child,n.flags|=128,n=null;else throw Error(s(558));else if(Ot||Zi(t,n,a,!1),w=(a&t.childLanes)!==0,Ot||w){if(d=bt,d!==null&&(M=tf(d,a),M!==0&&M!==E.retryLane))throw E.retryLane=M,ci(t,M),xn(d,t,M),hu;Wo(),n=hm(t,n,a)}else t=E.treeContext,St=Fn(M.nextSibling),Xt=n,nt=!0,Lr=null,Hn=!1,t!==null&&Qf(n,t),n=Mo(n,d),n.flags|=4096;return n}return t=dr(t.child,{mode:d.mode,children:d.children}),t.ref=n.ref,n.child=t,t.return=n,t}function Oo(t,n){var a=n.ref;if(a===null)t!==null&&t.ref!==null&&(n.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(s(284));(t===null||t.ref!==a)&&(n.flags|=4194816)}}function fu(t,n,a,d,w){return fi(n),a=Vc(t,n,a,d,void 0,w),d=Yc(),t!==null&&!Ot?(Kc(t,n,w),xr(t,n,w)):(nt&&d&&Nc(n),n.flags|=1,Qt(t,n,a,w),n.child)}function fm(t,n,a,d,w,E){return fi(n),n.updateQueue=null,a=gp(n,d,a,w),mp(t),d=Yc(),t!==null&&!Ot?(Kc(t,n,E),xr(t,n,E)):(nt&&d&&Nc(n),n.flags|=1,Qt(t,n,a,E),n.child)}function pm(t,n,a,d,w){if(fi(n),n.stateNode===null){var E=Vi,M=a.contextType;typeof M=="object"&&M!==null&&(E=Zt(M)),E=new a(d,E),n.memoizedState=E.state!==null&&E.state!==void 0?E.state:null,E.updater=uu,n.stateNode=E,E._reactInternals=n,E=n.stateNode,E.props=d,E.state=n.memoizedState,E.refs={},Hc(n),M=a.contextType,E.context=typeof M=="object"&&M!==null?Zt(M):Vi,E.state=n.memoizedState,M=a.getDerivedStateFromProps,typeof M=="function"&&(cu(n,a,M,d),E.state=n.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof E.getSnapshotBeforeUpdate=="function"||typeof E.UNSAFE_componentWillMount!="function"&&typeof E.componentWillMount!="function"||(M=E.state,typeof E.componentWillMount=="function"&&E.componentWillMount(),typeof E.UNSAFE_componentWillMount=="function"&&E.UNSAFE_componentWillMount(),M!==E.state&&uu.enqueueReplaceState(E,E.state,null),Js(n,d,E,w),Qs(),E.state=n.memoizedState),typeof E.componentDidMount=="function"&&(n.flags|=4194308),d=!0}else if(t===null){E=n.stateNode;var G=n.memoizedProps,ee=bi(a,G);E.props=ee;var le=E.context,he=a.contextType;M=Vi,typeof he=="object"&&he!==null&&(M=Zt(he));var xe=a.getDerivedStateFromProps;he=typeof xe=="function"||typeof E.getSnapshotBeforeUpdate=="function",G=n.pendingProps!==G,he||typeof E.UNSAFE_componentWillReceiveProps!="function"&&typeof E.componentWillReceiveProps!="function"||(G||le!==M)&&em(n,E,d,M),Or=!1;var ce=n.memoizedState;E.state=ce,Js(n,d,E,w),Qs(),le=n.memoizedState,G||ce!==le||Or?(typeof xe=="function"&&(cu(n,a,xe,d),le=n.memoizedState),(ee=Or||Jp(n,a,ee,d,ce,le,M))?(he||typeof E.UNSAFE_componentWillMount!="function"&&typeof E.componentWillMount!="function"||(typeof E.componentWillMount=="function"&&E.componentWillMount(),typeof E.UNSAFE_componentWillMount=="function"&&E.UNSAFE_componentWillMount()),typeof E.componentDidMount=="function"&&(n.flags|=4194308)):(typeof E.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=d,n.memoizedState=le),E.props=d,E.state=le,E.context=M,d=ee):(typeof E.componentDidMount=="function"&&(n.flags|=4194308),d=!1)}else{E=n.stateNode,Pc(t,n),M=n.memoizedProps,he=bi(a,M),E.props=he,xe=n.pendingProps,ce=E.context,le=a.contextType,ee=Vi,typeof le=="object"&&le!==null&&(ee=Zt(le)),G=a.getDerivedStateFromProps,(le=typeof G=="function"||typeof E.getSnapshotBeforeUpdate=="function")||typeof E.UNSAFE_componentWillReceiveProps!="function"&&typeof E.componentWillReceiveProps!="function"||(M!==xe||ce!==ee)&&em(n,E,d,ee),Or=!1,ce=n.memoizedState,E.state=ce,Js(n,d,E,w),Qs();var ue=n.memoizedState;M!==xe||ce!==ue||Or||t!==null&&t.dependencies!==null&&go(t.dependencies)?(typeof G=="function"&&(cu(n,a,G,d),ue=n.memoizedState),(he=Or||Jp(n,a,he,d,ce,ue,ee)||t!==null&&t.dependencies!==null&&go(t.dependencies))?(le||typeof E.UNSAFE_componentWillUpdate!="function"&&typeof E.componentWillUpdate!="function"||(typeof E.componentWillUpdate=="function"&&E.componentWillUpdate(d,ue,ee),typeof E.UNSAFE_componentWillUpdate=="function"&&E.UNSAFE_componentWillUpdate(d,ue,ee)),typeof E.componentDidUpdate=="function"&&(n.flags|=4),typeof E.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof E.componentDidUpdate!="function"||M===t.memoizedProps&&ce===t.memoizedState||(n.flags|=4),typeof E.getSnapshotBeforeUpdate!="function"||M===t.memoizedProps&&ce===t.memoizedState||(n.flags|=1024),n.memoizedProps=d,n.memoizedState=ue),E.props=d,E.state=ue,E.context=ee,d=he):(typeof E.componentDidUpdate!="function"||M===t.memoizedProps&&ce===t.memoizedState||(n.flags|=4),typeof E.getSnapshotBeforeUpdate!="function"||M===t.memoizedProps&&ce===t.memoizedState||(n.flags|=1024),d=!1)}return E=d,Oo(t,n),d=(n.flags&128)!==0,E||d?(E=n.stateNode,a=d&&typeof a.getDerivedStateFromError!="function"?null:E.render(),n.flags|=1,t!==null&&d?(n.child=xi(n,t.child,null,w),n.child=xi(n,null,a,w)):Qt(t,n,a,w),n.memoizedState=E.state,t=n.child):t=xr(t,n,w),t}function mm(t,n,a,d){return di(),n.flags|=256,Qt(t,n,a,d),n.child}var pu={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function mu(t){return{baseLanes:t,cachePool:ip()}}function gu(t,n,a){return t=t!==null?t.childLanes&~a:0,n&&(t|=kn),t}function gm(t,n,a){var d=n.pendingProps,w=!1,E=(n.flags&128)!==0,M;if((M=E)||(M=t!==null&&t.memoizedState===null?!1:(Tt.current&2)!==0),M&&(w=!0,n.flags&=-129),M=(n.flags&32)!==0,n.flags&=-33,t===null){if(nt){if(w?zr(n):Hr(),(t=St)?(t=Cg(t,Hn),t=t!==null&&t.data!=="&"?t:null,t!==null&&(n.memoizedState={dehydrated:t,treeContext:Dr!==null?{id:Zn,overflow:Qn}:null,retryLane:536870912,hydrationErrors:null},a=Kf(t),a.return=n,n.child=a,Xt=n,St=null)):t=null,t===null)throw Rr(n);return Qu(t)?n.lanes=32:n.lanes=536870912,null}var G=d.children;return d=d.fallback,w?(Hr(),w=n.mode,G=Bo({mode:"hidden",children:G},w),d=ui(d,w,a,null),G.return=n,d.return=n,G.sibling=d,n.child=G,d=n.child,d.memoizedState=mu(a),d.childLanes=gu(t,M,a),n.memoizedState=pu,ia(null,d)):(zr(n),xu(n,G))}var ee=t.memoizedState;if(ee!==null&&(G=ee.dehydrated,G!==null)){if(E)n.flags&256?(zr(n),n.flags&=-257,n=vu(t,n,a)):n.memoizedState!==null?(Hr(),n.child=t.child,n.flags|=128,n=null):(Hr(),G=d.fallback,w=n.mode,d=Bo({mode:"visible",children:d.children},w),G=ui(G,w,a,null),G.flags|=2,d.return=n,G.return=n,d.sibling=G,n.child=d,xi(n,t.child,null,a),d=n.child,d.memoizedState=mu(a),d.childLanes=gu(t,M,a),n.memoizedState=pu,n=ia(null,d));else if(zr(n),Qu(G)){if(M=G.nextSibling&&G.nextSibling.dataset,M)var le=M.dgst;M=le,d=Error(s(419)),d.stack="",d.digest=M,Gs({value:d,source:null,stack:null}),n=vu(t,n,a)}else if(Ot||Zi(t,n,a,!1),M=(a&t.childLanes)!==0,Ot||M){if(M=bt,M!==null&&(d=tf(M,a),d!==0&&d!==ee.retryLane))throw ee.retryLane=d,ci(t,d),xn(M,t,d),hu;Zu(G)||Wo(),n=vu(t,n,a)}else Zu(G)?(n.flags|=192,n.child=t.child,n=null):(t=ee.treeContext,St=Fn(G.nextSibling),Xt=n,nt=!0,Lr=null,Hn=!1,t!==null&&Qf(n,t),n=xu(n,d.children),n.flags|=4096);return n}return w?(Hr(),G=d.fallback,w=n.mode,ee=t.child,le=ee.sibling,d=dr(ee,{mode:"hidden",children:d.children}),d.subtreeFlags=ee.subtreeFlags&65011712,le!==null?G=dr(le,G):(G=ui(G,w,a,null),G.flags|=2),G.return=n,d.return=n,d.sibling=G,n.child=d,ia(null,d),d=n.child,G=t.child.memoizedState,G===null?G=mu(a):(w=G.cachePool,w!==null?(ee=Rt._currentValue,w=w.parent!==ee?{parent:ee,pool:ee}:w):w=ip(),G={baseLanes:G.baseLanes|a,cachePool:w}),d.memoizedState=G,d.childLanes=gu(t,M,a),n.memoizedState=pu,ia(t.child,d)):(zr(n),a=t.child,t=a.sibling,a=dr(a,{mode:"visible",children:d.children}),a.return=n,a.sibling=null,t!==null&&(M=n.deletions,M===null?(n.deletions=[t],n.flags|=16):M.push(t)),n.child=a,n.memoizedState=null,a)}function xu(t,n){return n=Bo({mode:"visible",children:n},t.mode),n.return=t,t.child=n}function Bo(t,n){return t=_n(22,t,null,n),t.lanes=0,t}function vu(t,n,a){return xi(n,t.child,null,a),t=xu(n,n.pendingProps.children),t.flags|=2,n.memoizedState=null,t}function xm(t,n,a){t.lanes|=n;var d=t.alternate;d!==null&&(d.lanes|=n),Rc(t.return,n,a)}function bu(t,n,a,d,w,E){var M=t.memoizedState;M===null?t.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:d,tail:a,tailMode:w,treeForkCount:E}:(M.isBackwards=n,M.rendering=null,M.renderingStartTime=0,M.last=d,M.tail=a,M.tailMode=w,M.treeForkCount=E)}function vm(t,n,a){var d=n.pendingProps,w=d.revealOrder,E=d.tail;d=d.children;var M=Tt.current,G=(M&2)!==0;if(G?(M=M&1|2,n.flags|=128):M&=1,U(Tt,M),Qt(t,n,d,a),d=nt?Ws:0,!G&&t!==null&&(t.flags&128)!==0)e:for(t=n.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&xm(t,a,n);else if(t.tag===19)xm(t,a,n);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===n)break e;for(;t.sibling===null;){if(t.return===null||t.return===n)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}switch(w){case"forwards":for(a=n.child,w=null;a!==null;)t=a.alternate,t!==null&&Co(t)===null&&(w=a),a=a.sibling;a=w,a===null?(w=n.child,n.child=null):(w=a.sibling,a.sibling=null),bu(n,!1,w,a,E,d);break;case"backwards":case"unstable_legacy-backwards":for(a=null,w=n.child,n.child=null;w!==null;){if(t=w.alternate,t!==null&&Co(t)===null){n.child=w;break}t=w.sibling,w.sibling=a,a=w,w=t}bu(n,!0,a,null,E,d);break;case"together":bu(n,!1,null,null,void 0,d);break;default:n.memoizedState=null}return n.child}function xr(t,n,a){if(t!==null&&(n.dependencies=t.dependencies),Ur|=n.lanes,(a&n.childLanes)===0)if(t!==null){if(Zi(t,n,a,!1),(a&n.childLanes)===0)return null}else return null;if(t!==null&&n.child!==t.child)throw Error(s(153));if(n.child!==null){for(t=n.child,a=dr(t,t.pendingProps),n.child=a,a.return=n;t.sibling!==null;)t=t.sibling,a=a.sibling=dr(t,t.pendingProps),a.return=n;a.sibling=null}return n.child}function yu(t,n){return(t.lanes&n)!==0?!0:(t=t.dependencies,!!(t!==null&&go(t)))}function n_(t,n,a){switch(n.tag){case 3:z(n,n.stateNode.containerInfo),Mr(n,Rt,t.memoizedState.cache),di();break;case 27:case 5:se(n);break;case 4:z(n,n.stateNode.containerInfo);break;case 10:Mr(n,n.type,n.memoizedProps.value);break;case 31:if(n.memoizedState!==null)return n.flags|=128,Wc(n),null;break;case 13:var d=n.memoizedState;if(d!==null)return d.dehydrated!==null?(zr(n),n.flags|=128,null):(a&n.child.childLanes)!==0?gm(t,n,a):(zr(n),t=xr(t,n,a),t!==null?t.sibling:null);zr(n);break;case 19:var w=(t.flags&128)!==0;if(d=(a&n.childLanes)!==0,d||(Zi(t,n,a,!1),d=(a&n.childLanes)!==0),w){if(d)return vm(t,n,a);n.flags|=128}if(w=n.memoizedState,w!==null&&(w.rendering=null,w.tail=null,w.lastEffect=null),U(Tt,Tt.current),d)break;return null;case 22:return n.lanes=0,um(t,n,a,n.pendingProps);case 24:Mr(n,Rt,t.memoizedState.cache)}return xr(t,n,a)}function bm(t,n,a){if(t!==null)if(t.memoizedProps!==n.pendingProps)Ot=!0;else{if(!yu(t,a)&&(n.flags&128)===0)return Ot=!1,n_(t,n,a);Ot=(t.flags&131072)!==0}else Ot=!1,nt&&(n.flags&1048576)!==0&&Zf(n,Ws,n.index);switch(n.lanes=0,n.tag){case 16:e:{var d=n.pendingProps;if(t=mi(n.elementType),n.type=t,typeof t=="function")kc(t)?(d=bi(t,d),n.tag=1,n=pm(null,n,t,d,a)):(n.tag=0,n=fu(null,n,t,d,a));else{if(t!=null){var w=t.$$typeof;if(w===j){n.tag=11,n=om(null,n,t,d,a);break e}else if(w===L){n.tag=14,n=lm(null,n,t,d,a);break e}}throw n=F(t)||t,Error(s(306,n,""))}}return n;case 0:return fu(t,n,n.type,n.pendingProps,a);case 1:return d=n.type,w=bi(d,n.pendingProps),pm(t,n,d,w,a);case 3:e:{if(z(n,n.stateNode.containerInfo),t===null)throw Error(s(387));d=n.pendingProps;var E=n.memoizedState;w=E.element,Pc(t,n),Js(n,d,null,a);var M=n.memoizedState;if(d=M.cache,Mr(n,Rt,d),d!==E.cache&&Mc(n,[Rt],a,!0),Qs(),d=M.element,E.isDehydrated)if(E={element:d,isDehydrated:!1,cache:M.cache},n.updateQueue.baseState=E,n.memoizedState=E,n.flags&256){n=mm(t,n,d,a);break e}else if(d!==w){w=Bn(Error(s(424)),n),Gs(w),n=mm(t,n,d,a);break e}else{switch(t=n.stateNode.containerInfo,t.nodeType){case 9:t=t.body;break;default:t=t.nodeName==="HTML"?t.ownerDocument.body:t}for(St=Fn(t.firstChild),Xt=n,nt=!0,Lr=null,Hn=!0,a=up(n,null,d,a),n.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling}else{if(di(),d===w){n=xr(t,n,a);break e}Qt(t,n,d,a)}n=n.child}return n;case 26:return Oo(t,n),t===null?(a=Ag(n.type,null,n.pendingProps,null))?n.memoizedState=a:nt||(a=n.type,t=n.pendingProps,d=Qo(Q.current).createElement(a),d[Kt]=n,d[dn]=t,Jt(d,a,t),qt(d),n.stateNode=d):n.memoizedState=Ag(n.type,t.memoizedProps,n.pendingProps,t.memoizedState),null;case 27:return se(n),t===null&&nt&&(d=n.stateNode=jg(n.type,n.pendingProps,Q.current),Xt=n,Hn=!0,w=St,Vr(n.type)?(Ju=w,St=Fn(d.firstChild)):St=w),Qt(t,n,n.pendingProps.children,a),Oo(t,n),t===null&&(n.flags|=4194304),n.child;case 5:return t===null&&nt&&((w=d=St)&&(d=L_(d,n.type,n.pendingProps,Hn),d!==null?(n.stateNode=d,Xt=n,St=Fn(d.firstChild),Hn=!1,w=!0):w=!1),w||Rr(n)),se(n),w=n.type,E=n.pendingProps,M=t!==null?t.memoizedProps:null,d=E.children,Yu(w,E)?d=null:M!==null&&Yu(w,M)&&(n.flags|=32),n.memoizedState!==null&&(w=Vc(t,n,Vy,null,null,a),ba._currentValue=w),Oo(t,n),Qt(t,n,d,a),n.child;case 6:return t===null&&nt&&((t=a=St)&&(a=R_(a,n.pendingProps,Hn),a!==null?(n.stateNode=a,Xt=n,St=null,t=!0):t=!1),t||Rr(n)),null;case 13:return gm(t,n,a);case 4:return z(n,n.stateNode.containerInfo),d=n.pendingProps,t===null?n.child=xi(n,null,d,a):Qt(t,n,d,a),n.child;case 11:return om(t,n,n.type,n.pendingProps,a);case 7:return Qt(t,n,n.pendingProps,a),n.child;case 8:return Qt(t,n,n.pendingProps.children,a),n.child;case 12:return Qt(t,n,n.pendingProps.children,a),n.child;case 10:return d=n.pendingProps,Mr(n,n.type,d.value),Qt(t,n,d.children,a),n.child;case 9:return w=n.type._context,d=n.pendingProps.children,fi(n),w=Zt(w),d=d(w),n.flags|=1,Qt(t,n,d,a),n.child;case 14:return lm(t,n,n.type,n.pendingProps,a);case 15:return cm(t,n,n.type,n.pendingProps,a);case 19:return vm(t,n,a);case 31:return t_(t,n,a);case 22:return um(t,n,a,n.pendingProps);case 24:return fi(n),d=Zt(Rt),t===null?(w=Ic(),w===null&&(w=bt,E=Oc(),w.pooledCache=E,E.refCount++,E!==null&&(w.pooledCacheLanes|=a),w=E),n.memoizedState={parent:d,cache:w},Hc(n),Mr(n,Rt,w)):((t.lanes&a)!==0&&(Pc(t,n),Js(n,null,null,a),Qs()),w=t.memoizedState,E=n.memoizedState,w.parent!==d?(w={parent:d,cache:d},n.memoizedState=w,n.lanes===0&&(n.memoizedState=n.updateQueue.baseState=w),Mr(n,Rt,d)):(d=E.cache,Mr(n,Rt,d),d!==w.cache&&Mc(n,[Rt],a,!0))),Qt(t,n,n.pendingProps.children,a),n.child;case 29:throw n.pendingProps}throw Error(s(156,n.tag))}function vr(t){t.flags|=4}function _u(t,n,a,d,w){if((n=(t.mode&32)!==0)&&(n=!1),n){if(t.flags|=16777216,(w&335544128)===w)if(t.stateNode.complete)t.flags|=8192;else if(Gm())t.flags|=8192;else throw gi=yo,zc}else t.flags&=-16777217}function ym(t,n){if(n.type!=="stylesheet"||(n.state.loading&4)!==0)t.flags&=-16777217;else if(t.flags|=16777216,!Og(n))if(Gm())t.flags|=8192;else throw gi=yo,zc}function Io(t,n){n!==null&&(t.flags|=4),t.flags&16384&&(n=t.tag!==22?Zl():536870912,t.lanes|=n,cs|=n)}function sa(t,n){if(!nt)switch(t.tailMode){case"hidden":n=t.tail;for(var a=null;n!==null;)n.alternate!==null&&(a=n),n=n.sibling;a===null?t.tail=null:a.sibling=null;break;case"collapsed":a=t.tail;for(var d=null;a!==null;)a.alternate!==null&&(d=a),a=a.sibling;d===null?n||t.tail===null?t.tail=null:t.tail.sibling=null:d.sibling=null}}function wt(t){var n=t.alternate!==null&&t.alternate.child===t.child,a=0,d=0;if(n)for(var w=t.child;w!==null;)a|=w.lanes|w.childLanes,d|=w.subtreeFlags&65011712,d|=w.flags&65011712,w.return=t,w=w.sibling;else for(w=t.child;w!==null;)a|=w.lanes|w.childLanes,d|=w.subtreeFlags,d|=w.flags,w.return=t,w=w.sibling;return t.subtreeFlags|=d,t.childLanes=a,n}function r_(t,n,a){var d=n.pendingProps;switch(Tc(n),n.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return wt(n),null;case 1:return wt(n),null;case 3:return a=n.stateNode,d=null,t!==null&&(d=t.memoizedState.cache),n.memoizedState.cache!==d&&(n.flags|=2048),pr(Rt),ae(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(t===null||t.child===null)&&(Xi(n)?vr(n):t===null||t.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,Dc())),wt(n),null;case 26:var w=n.type,E=n.memoizedState;return t===null?(vr(n),E!==null?(wt(n),ym(n,E)):(wt(n),_u(n,w,null,d,a))):E?E!==t.memoizedState?(vr(n),wt(n),ym(n,E)):(wt(n),n.flags&=-16777217):(t=t.memoizedProps,t!==d&&vr(n),wt(n),_u(n,w,t,d,a)),null;case 27:if(ge(n),a=Q.current,w=n.type,t!==null&&n.stateNode!=null)t.memoizedProps!==d&&vr(n);else{if(!d){if(n.stateNode===null)throw Error(s(166));return wt(n),null}t=K.current,Xi(n)?Jf(n):(t=jg(w,d,a),n.stateNode=t,vr(n))}return wt(n),null;case 5:if(ge(n),w=n.type,t!==null&&n.stateNode!=null)t.memoizedProps!==d&&vr(n);else{if(!d){if(n.stateNode===null)throw Error(s(166));return wt(n),null}if(E=K.current,Xi(n))Jf(n);else{var M=Qo(Q.current);switch(E){case 1:E=M.createElementNS("http://www.w3.org/2000/svg",w);break;case 2:E=M.createElementNS("http://www.w3.org/1998/Math/MathML",w);break;default:switch(w){case"svg":E=M.createElementNS("http://www.w3.org/2000/svg",w);break;case"math":E=M.createElementNS("http://www.w3.org/1998/Math/MathML",w);break;case"script":E=M.createElement("div"),E.innerHTML="<script><\/script>",E=E.removeChild(E.firstChild);break;case"select":E=typeof d.is=="string"?M.createElement("select",{is:d.is}):M.createElement("select"),d.multiple?E.multiple=!0:d.size&&(E.size=d.size);break;default:E=typeof d.is=="string"?M.createElement(w,{is:d.is}):M.createElement(w)}}E[Kt]=n,E[dn]=d;e:for(M=n.child;M!==null;){if(M.tag===5||M.tag===6)E.appendChild(M.stateNode);else if(M.tag!==4&&M.tag!==27&&M.child!==null){M.child.return=M,M=M.child;continue}if(M===n)break e;for(;M.sibling===null;){if(M.return===null||M.return===n)break e;M=M.return}M.sibling.return=M.return,M=M.sibling}n.stateNode=E;e:switch(Jt(E,w,d),w){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&vr(n)}}return wt(n),_u(n,n.type,t===null?null:t.memoizedProps,n.pendingProps,a),null;case 6:if(t&&n.stateNode!=null)t.memoizedProps!==d&&vr(n);else{if(typeof d!="string"&&n.stateNode===null)throw Error(s(166));if(t=Q.current,Xi(n)){if(t=n.stateNode,a=n.memoizedProps,d=null,w=Xt,w!==null)switch(w.tag){case 27:case 5:d=w.memoizedProps}t[Kt]=n,t=!!(t.nodeValue===a||d!==null&&d.suppressHydrationWarning===!0||gg(t.nodeValue,a)),t||Rr(n,!0)}else t=Qo(t).createTextNode(d),t[Kt]=n,n.stateNode=t}return wt(n),null;case 31:if(a=n.memoizedState,t===null||t.memoizedState!==null){if(d=Xi(n),a!==null){if(t===null){if(!d)throw Error(s(318));if(t=n.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(s(557));t[Kt]=n}else di(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;wt(n),t=!1}else a=Dc(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=a),t=!0;if(!t)return n.flags&256?(wn(n),n):(wn(n),null);if((n.flags&128)!==0)throw Error(s(558))}return wt(n),null;case 13:if(d=n.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(w=Xi(n),d!==null&&d.dehydrated!==null){if(t===null){if(!w)throw Error(s(318));if(w=n.memoizedState,w=w!==null?w.dehydrated:null,!w)throw Error(s(317));w[Kt]=n}else di(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;wt(n),w=!1}else w=Dc(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=w),w=!0;if(!w)return n.flags&256?(wn(n),n):(wn(n),null)}return wn(n),(n.flags&128)!==0?(n.lanes=a,n):(a=d!==null,t=t!==null&&t.memoizedState!==null,a&&(d=n.child,w=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(w=d.alternate.memoizedState.cachePool.pool),E=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(E=d.memoizedState.cachePool.pool),E!==w&&(d.flags|=2048)),a!==t&&a&&(n.child.flags|=8192),Io(n,n.updateQueue),wt(n),null);case 4:return ae(),t===null&&$u(n.stateNode.containerInfo),wt(n),null;case 10:return pr(n.type),wt(n),null;case 19:if(W(Tt),d=n.memoizedState,d===null)return wt(n),null;if(w=(n.flags&128)!==0,E=d.rendering,E===null)if(w)sa(d,!1);else{if(Nt!==0||t!==null&&(t.flags&128)!==0)for(t=n.child;t!==null;){if(E=Co(t),E!==null){for(n.flags|=128,sa(d,!1),t=E.updateQueue,n.updateQueue=t,Io(n,t),n.subtreeFlags=0,t=a,a=n.child;a!==null;)Yf(a,t),a=a.sibling;return U(Tt,Tt.current&1|2),nt&&hr(n,d.treeForkCount),n.child}t=t.sibling}d.tail!==null&&Ge()>Uo&&(n.flags|=128,w=!0,sa(d,!1),n.lanes=4194304)}else{if(!w)if(t=Co(E),t!==null){if(n.flags|=128,w=!0,t=t.updateQueue,n.updateQueue=t,Io(n,t),sa(d,!0),d.tail===null&&d.tailMode==="hidden"&&!E.alternate&&!nt)return wt(n),null}else 2*Ge()-d.renderingStartTime>Uo&&a!==536870912&&(n.flags|=128,w=!0,sa(d,!1),n.lanes=4194304);d.isBackwards?(E.sibling=n.child,n.child=E):(t=d.last,t!==null?t.sibling=E:n.child=E,d.last=E)}return d.tail!==null?(t=d.tail,d.rendering=t,d.tail=t.sibling,d.renderingStartTime=Ge(),t.sibling=null,a=Tt.current,U(Tt,w?a&1|2:a&1),nt&&hr(n,d.treeForkCount),t):(wt(n),null);case 22:case 23:return wn(n),qc(),d=n.memoizedState!==null,t!==null?t.memoizedState!==null!==d&&(n.flags|=8192):d&&(n.flags|=8192),d?(a&536870912)!==0&&(n.flags&128)===0&&(wt(n),n.subtreeFlags&6&&(n.flags|=8192)):wt(n),a=n.updateQueue,a!==null&&Io(n,a.retryQueue),a=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(a=t.memoizedState.cachePool.pool),d=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(d=n.memoizedState.cachePool.pool),d!==a&&(n.flags|=2048),t!==null&&W(pi),null;case 24:return a=null,t!==null&&(a=t.memoizedState.cache),n.memoizedState.cache!==a&&(n.flags|=2048),pr(Rt),wt(n),null;case 25:return null;case 30:return null}throw Error(s(156,n.tag))}function i_(t,n){switch(Tc(n),n.tag){case 1:return t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 3:return pr(Rt),ae(),t=n.flags,(t&65536)!==0&&(t&128)===0?(n.flags=t&-65537|128,n):null;case 26:case 27:case 5:return ge(n),null;case 31:if(n.memoizedState!==null){if(wn(n),n.alternate===null)throw Error(s(340));di()}return t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 13:if(wn(n),t=n.memoizedState,t!==null&&t.dehydrated!==null){if(n.alternate===null)throw Error(s(340));di()}return t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 19:return W(Tt),null;case 4:return ae(),null;case 10:return pr(n.type),null;case 22:case 23:return wn(n),qc(),t!==null&&W(pi),t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 24:return pr(Rt),null;case 25:return null;default:return null}}function _m(t,n){switch(Tc(n),n.tag){case 3:pr(Rt),ae();break;case 26:case 27:case 5:ge(n);break;case 4:ae();break;case 31:n.memoizedState!==null&&wn(n);break;case 13:wn(n);break;case 19:W(Tt);break;case 10:pr(n.type);break;case 22:case 23:wn(n),qc(),t!==null&&W(pi);break;case 24:pr(Rt)}}function aa(t,n){try{var a=n.updateQueue,d=a!==null?a.lastEffect:null;if(d!==null){var w=d.next;a=w;do{if((a.tag&t)===t){d=void 0;var E=a.create,M=a.inst;d=E(),M.destroy=d}a=a.next}while(a!==w)}}catch(G){pt(n,n.return,G)}}function Pr(t,n,a){try{var d=n.updateQueue,w=d!==null?d.lastEffect:null;if(w!==null){var E=w.next;d=E;do{if((d.tag&t)===t){var M=d.inst,G=M.destroy;if(G!==void 0){M.destroy=void 0,w=n;var ee=a,le=G;try{le()}catch(he){pt(w,ee,he)}}}d=d.next}while(d!==E)}}catch(he){pt(n,n.return,he)}}function Sm(t){var n=t.updateQueue;if(n!==null){var a=t.stateNode;try{hp(n,a)}catch(d){pt(t,t.return,d)}}}function wm(t,n,a){a.props=bi(t.type,t.memoizedProps),a.state=t.memoizedState;try{a.componentWillUnmount()}catch(d){pt(t,n,d)}}function oa(t,n){try{var a=t.ref;if(a!==null){switch(t.tag){case 26:case 27:case 5:var d=t.stateNode;break;case 30:d=t.stateNode;break;default:d=t.stateNode}typeof a=="function"?t.refCleanup=a(d):a.current=d}}catch(w){pt(t,n,w)}}function Jn(t,n){var a=t.ref,d=t.refCleanup;if(a!==null)if(typeof d=="function")try{d()}catch(w){pt(t,n,w)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(w){pt(t,n,w)}else a.current=null}function Cm(t){var n=t.type,a=t.memoizedProps,d=t.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":a.autoFocus&&d.focus();break e;case"img":a.src?d.src=a.src:a.srcSet&&(d.srcset=a.srcSet)}}catch(w){pt(t,t.return,w)}}function Su(t,n,a){try{var d=t.stateNode;E_(d,t.type,a,n),d[dn]=n}catch(w){pt(t,t.return,w)}}function km(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&Vr(t.type)||t.tag===4}function wu(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||km(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.tag===27&&Vr(t.type)||t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function Cu(t,n,a){var d=t.tag;if(d===5||d===6)t=t.stateNode,n?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(t,n):(n=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,n.appendChild(t),a=a._reactRootContainer,a!=null||n.onclick!==null||(n.onclick=cr));else if(d!==4&&(d===27&&Vr(t.type)&&(a=t.stateNode,n=null),t=t.child,t!==null))for(Cu(t,n,a),t=t.sibling;t!==null;)Cu(t,n,a),t=t.sibling}function zo(t,n,a){var d=t.tag;if(d===5||d===6)t=t.stateNode,n?a.insertBefore(t,n):a.appendChild(t);else if(d!==4&&(d===27&&Vr(t.type)&&(a=t.stateNode),t=t.child,t!==null))for(zo(t,n,a),t=t.sibling;t!==null;)zo(t,n,a),t=t.sibling}function Em(t){var n=t.stateNode,a=t.memoizedProps;try{for(var d=t.type,w=n.attributes;w.length;)n.removeAttributeNode(w[0]);Jt(n,d,a),n[Kt]=t,n[dn]=a}catch(E){pt(t,t.return,E)}}var br=!1,Bt=!1,ku=!1,jm=typeof WeakSet=="function"?WeakSet:Set,Wt=null;function s_(t,n){if(t=t.containerInfo,Gu=sl,t=Hf(t),vc(t)){if("selectionStart"in t)var a={start:t.selectionStart,end:t.selectionEnd};else e:{a=(a=t.ownerDocument)&&a.defaultView||window;var d=a.getSelection&&a.getSelection();if(d&&d.rangeCount!==0){a=d.anchorNode;var w=d.anchorOffset,E=d.focusNode;d=d.focusOffset;try{a.nodeType,E.nodeType}catch{a=null;break e}var M=0,G=-1,ee=-1,le=0,he=0,xe=t,ce=null;t:for(;;){for(var ue;xe!==a||w!==0&&xe.nodeType!==3||(G=M+w),xe!==E||d!==0&&xe.nodeType!==3||(ee=M+d),xe.nodeType===3&&(M+=xe.nodeValue.length),(ue=xe.firstChild)!==null;)ce=xe,xe=ue;for(;;){if(xe===t)break t;if(ce===a&&++le===w&&(G=M),ce===E&&++he===d&&(ee=M),(ue=xe.nextSibling)!==null)break;xe=ce,ce=xe.parentNode}xe=ue}a=G===-1||ee===-1?null:{start:G,end:ee}}else a=null}a=a||{start:0,end:0}}else a=null;for(Vu={focusedElem:t,selectionRange:a},sl=!1,Wt=n;Wt!==null;)if(n=Wt,t=n.child,(n.subtreeFlags&1028)!==0&&t!==null)t.return=n,Wt=t;else for(;Wt!==null;){switch(n=Wt,E=n.alternate,t=n.flags,n.tag){case 0:if((t&4)!==0&&(t=n.updateQueue,t=t!==null?t.events:null,t!==null))for(a=0;a<t.length;a++)w=t[a],w.ref.impl=w.nextImpl;break;case 11:case 15:break;case 1:if((t&1024)!==0&&E!==null){t=void 0,a=n,w=E.memoizedProps,E=E.memoizedState,d=a.stateNode;try{var je=bi(a.type,w);t=d.getSnapshotBeforeUpdate(je,E),d.__reactInternalSnapshotBeforeUpdate=t}catch(Ie){pt(a,a.return,Ie)}}break;case 3:if((t&1024)!==0){if(t=n.stateNode.containerInfo,a=t.nodeType,a===9)Xu(t);else if(a===1)switch(t.nodeName){case"HEAD":case"HTML":case"BODY":Xu(t);break;default:t.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((t&1024)!==0)throw Error(s(163))}if(t=n.sibling,t!==null){t.return=n.return,Wt=t;break}Wt=n.return}}function Nm(t,n,a){var d=a.flags;switch(a.tag){case 0:case 11:case 15:_r(t,a),d&4&&aa(5,a);break;case 1:if(_r(t,a),d&4)if(t=a.stateNode,n===null)try{t.componentDidMount()}catch(M){pt(a,a.return,M)}else{var w=bi(a.type,n.memoizedProps);n=n.memoizedState;try{t.componentDidUpdate(w,n,t.__reactInternalSnapshotBeforeUpdate)}catch(M){pt(a,a.return,M)}}d&64&&Sm(a),d&512&&oa(a,a.return);break;case 3:if(_r(t,a),d&64&&(t=a.updateQueue,t!==null)){if(n=null,a.child!==null)switch(a.child.tag){case 27:case 5:n=a.child.stateNode;break;case 1:n=a.child.stateNode}try{hp(t,n)}catch(M){pt(a,a.return,M)}}break;case 27:n===null&&d&4&&Em(a);case 26:case 5:_r(t,a),n===null&&d&4&&Cm(a),d&512&&oa(a,a.return);break;case 12:_r(t,a);break;case 31:_r(t,a),d&4&&Dm(t,a);break;case 13:_r(t,a),d&4&&Lm(t,a),d&64&&(t=a.memoizedState,t!==null&&(t=t.dehydrated,t!==null&&(a=p_.bind(null,a),M_(t,a))));break;case 22:if(d=a.memoizedState!==null||br,!d){n=n!==null&&n.memoizedState!==null||Bt,w=br;var E=Bt;br=d,(Bt=n)&&!E?Sr(t,a,(a.subtreeFlags&8772)!==0):_r(t,a),br=w,Bt=E}break;case 30:break;default:_r(t,a)}}function Tm(t){var n=t.alternate;n!==null&&(t.alternate=null,Tm(n)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(n=t.stateNode,n!==null&&tc(n)),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}var kt=null,fn=!1;function yr(t,n,a){for(a=a.child;a!==null;)Am(t,n,a),a=a.sibling}function Am(t,n,a){if(it&&typeof it.onCommitFiberUnmount=="function")try{it.onCommitFiberUnmount(st,a)}catch{}switch(a.tag){case 26:Bt||Jn(a,n),yr(t,n,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:Bt||Jn(a,n);var d=kt,w=fn;Vr(a.type)&&(kt=a.stateNode,fn=!1),yr(t,n,a),ga(a.stateNode),kt=d,fn=w;break;case 5:Bt||Jn(a,n);case 6:if(d=kt,w=fn,kt=null,yr(t,n,a),kt=d,fn=w,kt!==null)if(fn)try{(kt.nodeType===9?kt.body:kt.nodeName==="HTML"?kt.ownerDocument.body:kt).removeChild(a.stateNode)}catch(E){pt(a,n,E)}else try{kt.removeChild(a.stateNode)}catch(E){pt(a,n,E)}break;case 18:kt!==null&&(fn?(t=kt,Sg(t.nodeType===9?t.body:t.nodeName==="HTML"?t.ownerDocument.body:t,a.stateNode),xs(t)):Sg(kt,a.stateNode));break;case 4:d=kt,w=fn,kt=a.stateNode.containerInfo,fn=!0,yr(t,n,a),kt=d,fn=w;break;case 0:case 11:case 14:case 15:Pr(2,a,n),Bt||Pr(4,a,n),yr(t,n,a);break;case 1:Bt||(Jn(a,n),d=a.stateNode,typeof d.componentWillUnmount=="function"&&wm(a,n,d)),yr(t,n,a);break;case 21:yr(t,n,a);break;case 22:Bt=(d=Bt)||a.memoizedState!==null,yr(t,n,a),Bt=d;break;default:yr(t,n,a)}}function Dm(t,n){if(n.memoizedState===null&&(t=n.alternate,t!==null&&(t=t.memoizedState,t!==null))){t=t.dehydrated;try{xs(t)}catch(a){pt(n,n.return,a)}}}function Lm(t,n){if(n.memoizedState===null&&(t=n.alternate,t!==null&&(t=t.memoizedState,t!==null&&(t=t.dehydrated,t!==null))))try{xs(t)}catch(a){pt(n,n.return,a)}}function a_(t){switch(t.tag){case 31:case 13:case 19:var n=t.stateNode;return n===null&&(n=t.stateNode=new jm),n;case 22:return t=t.stateNode,n=t._retryCache,n===null&&(n=t._retryCache=new jm),n;default:throw Error(s(435,t.tag))}}function Ho(t,n){var a=a_(t);n.forEach(function(d){if(!a.has(d)){a.add(d);var w=m_.bind(null,t,d);d.then(w,w)}})}function pn(t,n){var a=n.deletions;if(a!==null)for(var d=0;d<a.length;d++){var w=a[d],E=t,M=n,G=M;e:for(;G!==null;){switch(G.tag){case 27:if(Vr(G.type)){kt=G.stateNode,fn=!1;break e}break;case 5:kt=G.stateNode,fn=!1;break e;case 3:case 4:kt=G.stateNode.containerInfo,fn=!0;break e}G=G.return}if(kt===null)throw Error(s(160));Am(E,M,w),kt=null,fn=!1,E=w.alternate,E!==null&&(E.return=null),w.return=null}if(n.subtreeFlags&13886)for(n=n.child;n!==null;)Rm(n,t),n=n.sibling}var Gn=null;function Rm(t,n){var a=t.alternate,d=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:pn(n,t),mn(t),d&4&&(Pr(3,t,t.return),aa(3,t),Pr(5,t,t.return));break;case 1:pn(n,t),mn(t),d&512&&(Bt||a===null||Jn(a,a.return)),d&64&&br&&(t=t.updateQueue,t!==null&&(d=t.callbacks,d!==null&&(a=t.shared.hiddenCallbacks,t.shared.hiddenCallbacks=a===null?d:a.concat(d))));break;case 26:var w=Gn;if(pn(n,t),mn(t),d&512&&(Bt||a===null||Jn(a,a.return)),d&4){var E=a!==null?a.memoizedState:null;if(d=t.memoizedState,a===null)if(d===null)if(t.stateNode===null){e:{d=t.type,a=t.memoizedProps,w=w.ownerDocument||w;t:switch(d){case"title":E=w.getElementsByTagName("title")[0],(!E||E[Ms]||E[Kt]||E.namespaceURI==="http://www.w3.org/2000/svg"||E.hasAttribute("itemprop"))&&(E=w.createElement(d),w.head.insertBefore(E,w.querySelector("head > title"))),Jt(E,d,a),E[Kt]=t,qt(E),d=E;break e;case"link":var M=Rg("link","href",w).get(d+(a.href||""));if(M){for(var G=0;G<M.length;G++)if(E=M[G],E.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&E.getAttribute("rel")===(a.rel==null?null:a.rel)&&E.getAttribute("title")===(a.title==null?null:a.title)&&E.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){M.splice(G,1);break t}}E=w.createElement(d),Jt(E,d,a),w.head.appendChild(E);break;case"meta":if(M=Rg("meta","content",w).get(d+(a.content||""))){for(G=0;G<M.length;G++)if(E=M[G],E.getAttribute("content")===(a.content==null?null:""+a.content)&&E.getAttribute("name")===(a.name==null?null:a.name)&&E.getAttribute("property")===(a.property==null?null:a.property)&&E.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&E.getAttribute("charset")===(a.charSet==null?null:a.charSet)){M.splice(G,1);break t}}E=w.createElement(d),Jt(E,d,a),w.head.appendChild(E);break;default:throw Error(s(468,d))}E[Kt]=t,qt(E),d=E}t.stateNode=d}else Mg(w,t.type,t.stateNode);else t.stateNode=Lg(w,d,t.memoizedProps);else E!==d?(E===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):E.count--,d===null?Mg(w,t.type,t.stateNode):Lg(w,d,t.memoizedProps)):d===null&&t.stateNode!==null&&Su(t,t.memoizedProps,a.memoizedProps)}break;case 27:pn(n,t),mn(t),d&512&&(Bt||a===null||Jn(a,a.return)),a!==null&&d&4&&Su(t,t.memoizedProps,a.memoizedProps);break;case 5:if(pn(n,t),mn(t),d&512&&(Bt||a===null||Jn(a,a.return)),t.flags&32){w=t.stateNode;try{Pi(w,"")}catch(je){pt(t,t.return,je)}}d&4&&t.stateNode!=null&&(w=t.memoizedProps,Su(t,w,a!==null?a.memoizedProps:w)),d&1024&&(ku=!0);break;case 6:if(pn(n,t),mn(t),d&4){if(t.stateNode===null)throw Error(s(162));d=t.memoizedProps,a=t.stateNode;try{a.nodeValue=d}catch(je){pt(t,t.return,je)}}break;case 3:if(tl=null,w=Gn,Gn=Jo(n.containerInfo),pn(n,t),Gn=w,mn(t),d&4&&a!==null&&a.memoizedState.isDehydrated)try{xs(n.containerInfo)}catch(je){pt(t,t.return,je)}ku&&(ku=!1,Mm(t));break;case 4:d=Gn,Gn=Jo(t.stateNode.containerInfo),pn(n,t),mn(t),Gn=d;break;case 12:pn(n,t),mn(t);break;case 31:pn(n,t),mn(t),d&4&&(d=t.updateQueue,d!==null&&(t.updateQueue=null,Ho(t,d)));break;case 13:pn(n,t),mn(t),t.child.flags&8192&&t.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(Fo=Ge()),d&4&&(d=t.updateQueue,d!==null&&(t.updateQueue=null,Ho(t,d)));break;case 22:w=t.memoizedState!==null;var ee=a!==null&&a.memoizedState!==null,le=br,he=Bt;if(br=le||w,Bt=he||ee,pn(n,t),Bt=he,br=le,mn(t),d&8192)e:for(n=t.stateNode,n._visibility=w?n._visibility&-2:n._visibility|1,w&&(a===null||ee||br||Bt||yi(t)),a=null,n=t;;){if(n.tag===5||n.tag===26){if(a===null){ee=a=n;try{if(E=ee.stateNode,w)M=E.style,typeof M.setProperty=="function"?M.setProperty("display","none","important"):M.display="none";else{G=ee.stateNode;var xe=ee.memoizedProps.style,ce=xe!=null&&xe.hasOwnProperty("display")?xe.display:null;G.style.display=ce==null||typeof ce=="boolean"?"":(""+ce).trim()}}catch(je){pt(ee,ee.return,je)}}}else if(n.tag===6){if(a===null){ee=n;try{ee.stateNode.nodeValue=w?"":ee.memoizedProps}catch(je){pt(ee,ee.return,je)}}}else if(n.tag===18){if(a===null){ee=n;try{var ue=ee.stateNode;w?wg(ue,!0):wg(ee.stateNode,!1)}catch(je){pt(ee,ee.return,je)}}}else if((n.tag!==22&&n.tag!==23||n.memoizedState===null||n===t)&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break e;for(;n.sibling===null;){if(n.return===null||n.return===t)break e;a===n&&(a=null),n=n.return}a===n&&(a=null),n.sibling.return=n.return,n=n.sibling}d&4&&(d=t.updateQueue,d!==null&&(a=d.retryQueue,a!==null&&(d.retryQueue=null,Ho(t,a))));break;case 19:pn(n,t),mn(t),d&4&&(d=t.updateQueue,d!==null&&(t.updateQueue=null,Ho(t,d)));break;case 30:break;case 21:break;default:pn(n,t),mn(t)}}function mn(t){var n=t.flags;if(n&2){try{for(var a,d=t.return;d!==null;){if(km(d)){a=d;break}d=d.return}if(a==null)throw Error(s(160));switch(a.tag){case 27:var w=a.stateNode,E=wu(t);zo(t,E,w);break;case 5:var M=a.stateNode;a.flags&32&&(Pi(M,""),a.flags&=-33);var G=wu(t);zo(t,G,M);break;case 3:case 4:var ee=a.stateNode.containerInfo,le=wu(t);Cu(t,le,ee);break;default:throw Error(s(161))}}catch(he){pt(t,t.return,he)}t.flags&=-3}n&4096&&(t.flags&=-4097)}function Mm(t){if(t.subtreeFlags&1024)for(t=t.child;t!==null;){var n=t;Mm(n),n.tag===5&&n.flags&1024&&n.stateNode.reset(),t=t.sibling}}function _r(t,n){if(n.subtreeFlags&8772)for(n=n.child;n!==null;)Nm(t,n.alternate,n),n=n.sibling}function yi(t){for(t=t.child;t!==null;){var n=t;switch(n.tag){case 0:case 11:case 14:case 15:Pr(4,n,n.return),yi(n);break;case 1:Jn(n,n.return);var a=n.stateNode;typeof a.componentWillUnmount=="function"&&wm(n,n.return,a),yi(n);break;case 27:ga(n.stateNode);case 26:case 5:Jn(n,n.return),yi(n);break;case 22:n.memoizedState===null&&yi(n);break;case 30:yi(n);break;default:yi(n)}t=t.sibling}}function Sr(t,n,a){for(a=a&&(n.subtreeFlags&8772)!==0,n=n.child;n!==null;){var d=n.alternate,w=t,E=n,M=E.flags;switch(E.tag){case 0:case 11:case 15:Sr(w,E,a),aa(4,E);break;case 1:if(Sr(w,E,a),d=E,w=d.stateNode,typeof w.componentDidMount=="function")try{w.componentDidMount()}catch(le){pt(d,d.return,le)}if(d=E,w=d.updateQueue,w!==null){var G=d.stateNode;try{var ee=w.shared.hiddenCallbacks;if(ee!==null)for(w.shared.hiddenCallbacks=null,w=0;w<ee.length;w++)dp(ee[w],G)}catch(le){pt(d,d.return,le)}}a&&M&64&&Sm(E),oa(E,E.return);break;case 27:Em(E);case 26:case 5:Sr(w,E,a),a&&d===null&&M&4&&Cm(E),oa(E,E.return);break;case 12:Sr(w,E,a);break;case 31:Sr(w,E,a),a&&M&4&&Dm(w,E);break;case 13:Sr(w,E,a),a&&M&4&&Lm(w,E);break;case 22:E.memoizedState===null&&Sr(w,E,a),oa(E,E.return);break;case 30:break;default:Sr(w,E,a)}n=n.sibling}}function Eu(t,n){var a=null;t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(a=t.memoizedState.cachePool.pool),t=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(t=n.memoizedState.cachePool.pool),t!==a&&(t!=null&&t.refCount++,a!=null&&Vs(a))}function ju(t,n){t=null,n.alternate!==null&&(t=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==t&&(n.refCount++,t!=null&&Vs(t))}function Vn(t,n,a,d){if(n.subtreeFlags&10256)for(n=n.child;n!==null;)Om(t,n,a,d),n=n.sibling}function Om(t,n,a,d){var w=n.flags;switch(n.tag){case 0:case 11:case 15:Vn(t,n,a,d),w&2048&&aa(9,n);break;case 1:Vn(t,n,a,d);break;case 3:Vn(t,n,a,d),w&2048&&(t=null,n.alternate!==null&&(t=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==t&&(n.refCount++,t!=null&&Vs(t)));break;case 12:if(w&2048){Vn(t,n,a,d),t=n.stateNode;try{var E=n.memoizedProps,M=E.id,G=E.onPostCommit;typeof G=="function"&&G(M,n.alternate===null?"mount":"update",t.passiveEffectDuration,-0)}catch(ee){pt(n,n.return,ee)}}else Vn(t,n,a,d);break;case 31:Vn(t,n,a,d);break;case 13:Vn(t,n,a,d);break;case 23:break;case 22:E=n.stateNode,M=n.alternate,n.memoizedState!==null?E._visibility&2?Vn(t,n,a,d):la(t,n):E._visibility&2?Vn(t,n,a,d):(E._visibility|=2,as(t,n,a,d,(n.subtreeFlags&10256)!==0||!1)),w&2048&&Eu(M,n);break;case 24:Vn(t,n,a,d),w&2048&&ju(n.alternate,n);break;default:Vn(t,n,a,d)}}function as(t,n,a,d,w){for(w=w&&((n.subtreeFlags&10256)!==0||!1),n=n.child;n!==null;){var E=t,M=n,G=a,ee=d,le=M.flags;switch(M.tag){case 0:case 11:case 15:as(E,M,G,ee,w),aa(8,M);break;case 23:break;case 22:var he=M.stateNode;M.memoizedState!==null?he._visibility&2?as(E,M,G,ee,w):la(E,M):(he._visibility|=2,as(E,M,G,ee,w)),w&&le&2048&&Eu(M.alternate,M);break;case 24:as(E,M,G,ee,w),w&&le&2048&&ju(M.alternate,M);break;default:as(E,M,G,ee,w)}n=n.sibling}}function la(t,n){if(n.subtreeFlags&10256)for(n=n.child;n!==null;){var a=t,d=n,w=d.flags;switch(d.tag){case 22:la(a,d),w&2048&&Eu(d.alternate,d);break;case 24:la(a,d),w&2048&&ju(d.alternate,d);break;default:la(a,d)}n=n.sibling}}var ca=8192;function os(t,n,a){if(t.subtreeFlags&ca)for(t=t.child;t!==null;)Bm(t,n,a),t=t.sibling}function Bm(t,n,a){switch(t.tag){case 26:os(t,n,a),t.flags&ca&&t.memoizedState!==null&&G_(a,Gn,t.memoizedState,t.memoizedProps);break;case 5:os(t,n,a);break;case 3:case 4:var d=Gn;Gn=Jo(t.stateNode.containerInfo),os(t,n,a),Gn=d;break;case 22:t.memoizedState===null&&(d=t.alternate,d!==null&&d.memoizedState!==null?(d=ca,ca=16777216,os(t,n,a),ca=d):os(t,n,a));break;default:os(t,n,a)}}function Im(t){var n=t.alternate;if(n!==null&&(t=n.child,t!==null)){n.child=null;do n=t.sibling,t.sibling=null,t=n;while(t!==null)}}function ua(t){var n=t.deletions;if((t.flags&16)!==0){if(n!==null)for(var a=0;a<n.length;a++){var d=n[a];Wt=d,Hm(d,t)}Im(t)}if(t.subtreeFlags&10256)for(t=t.child;t!==null;)zm(t),t=t.sibling}function zm(t){switch(t.tag){case 0:case 11:case 15:ua(t),t.flags&2048&&Pr(9,t,t.return);break;case 3:ua(t);break;case 12:ua(t);break;case 22:var n=t.stateNode;t.memoizedState!==null&&n._visibility&2&&(t.return===null||t.return.tag!==13)?(n._visibility&=-3,Po(t)):ua(t);break;default:ua(t)}}function Po(t){var n=t.deletions;if((t.flags&16)!==0){if(n!==null)for(var a=0;a<n.length;a++){var d=n[a];Wt=d,Hm(d,t)}Im(t)}for(t=t.child;t!==null;){switch(n=t,n.tag){case 0:case 11:case 15:Pr(8,n,n.return),Po(n);break;case 22:a=n.stateNode,a._visibility&2&&(a._visibility&=-3,Po(n));break;default:Po(n)}t=t.sibling}}function Hm(t,n){for(;Wt!==null;){var a=Wt;switch(a.tag){case 0:case 11:case 15:Pr(8,a,n);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var d=a.memoizedState.cachePool.pool;d!=null&&d.refCount++}break;case 24:Vs(a.memoizedState.cache)}if(d=a.child,d!==null)d.return=a,Wt=d;else e:for(a=t;Wt!==null;){d=Wt;var w=d.sibling,E=d.return;if(Tm(d),d===a){Wt=null;break e}if(w!==null){w.return=E,Wt=w;break e}Wt=E}}}var o_={getCacheForType:function(t){var n=Zt(Rt),a=n.data.get(t);return a===void 0&&(a=t(),n.data.set(t,a)),a},cacheSignal:function(){return Zt(Rt).controller.signal}},l_=typeof WeakMap=="function"?WeakMap:Map,ut=0,bt=null,Ye=null,Ze=0,ft=0,Cn=null,Fr=!1,ls=!1,Nu=!1,wr=0,Nt=0,Ur=0,_i=0,Tu=0,kn=0,cs=0,da=null,gn=null,Au=!1,Fo=0,Pm=0,Uo=1/0,$o=null,$r=null,Ft=0,qr=null,us=null,Cr=0,Du=0,Lu=null,Fm=null,ha=0,Ru=null;function En(){return(ut&2)!==0&&Ze!==0?Ze&-Ze:$.T!==null?Hu():nf()}function Um(){if(kn===0)if((Ze&536870912)===0||nt){var t=Ve;Ve<<=1,(Ve&3932160)===0&&(Ve=262144),kn=t}else kn=536870912;return t=Sn.current,t!==null&&(t.flags|=32),kn}function xn(t,n,a){(t===bt&&(ft===2||ft===9)||t.cancelPendingCommit!==null)&&(ds(t,0),Wr(t,Ze,kn,!1)),Rs(t,a),((ut&2)===0||t!==bt)&&(t===bt&&((ut&2)===0&&(_i|=a),Nt===4&&Wr(t,Ze,kn,!1)),er(t))}function $m(t,n,a){if((ut&6)!==0)throw Error(s(327));var d=!a&&(n&127)===0&&(n&t.expiredLanes)===0||Et(t,n),w=d?d_(t,n):Ou(t,n,!0),E=d;do{if(w===0){ls&&!d&&Wr(t,n,0,!1);break}else{if(a=t.current.alternate,E&&!c_(a)){w=Ou(t,n,!1),E=!1;continue}if(w===2){if(E=n,t.errorRecoveryDisabledLanes&E)var M=0;else M=t.pendingLanes&-536870913,M=M!==0?M:M&536870912?536870912:0;if(M!==0){n=M;e:{var G=t;w=da;var ee=G.current.memoizedState.isDehydrated;if(ee&&(ds(G,M).flags|=256),M=Ou(G,M,!1),M!==2){if(Nu&&!ee){G.errorRecoveryDisabledLanes|=E,_i|=E,w=4;break e}E=gn,gn=w,E!==null&&(gn===null?gn=E:gn.push.apply(gn,E))}w=M}if(E=!1,w!==2)continue}}if(w===1){ds(t,0),Wr(t,n,0,!0);break}e:{switch(d=t,E=w,E){case 0:case 1:throw Error(s(345));case 4:if((n&4194048)!==n)break;case 6:Wr(d,n,kn,!Fr);break e;case 2:gn=null;break;case 3:case 5:break;default:throw Error(s(329))}if((n&62914560)===n&&(w=Fo+300-Ge(),10<w)){if(Wr(d,n,kn,!Fr),Lt(d,0,!0)!==0)break e;Cr=n,d.timeoutHandle=yg(qm.bind(null,d,a,gn,$o,Au,n,kn,_i,cs,Fr,E,"Throttled",-0,0),w);break e}qm(d,a,gn,$o,Au,n,kn,_i,cs,Fr,E,null,-0,0)}}break}while(!0);er(t)}function qm(t,n,a,d,w,E,M,G,ee,le,he,xe,ce,ue){if(t.timeoutHandle=-1,xe=n.subtreeFlags,xe&8192||(xe&16785408)===16785408){xe={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:cr},Bm(n,E,xe);var je=(E&62914560)===E?Fo-Ge():(E&4194048)===E?Pm-Ge():0;if(je=V_(xe,je),je!==null){Cr=E,t.cancelPendingCommit=je(Qm.bind(null,t,n,E,a,d,w,M,G,ee,he,xe,null,ce,ue)),Wr(t,E,M,!le);return}}Qm(t,n,E,a,d,w,M,G,ee)}function c_(t){for(var n=t;;){var a=n.tag;if((a===0||a===11||a===15)&&n.flags&16384&&(a=n.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var d=0;d<a.length;d++){var w=a[d],E=w.getSnapshot;w=w.value;try{if(!yn(E(),w))return!1}catch{return!1}}if(a=n.child,n.subtreeFlags&16384&&a!==null)a.return=n,n=a;else{if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return!0;n=n.return}n.sibling.return=n.return,n=n.sibling}}return!0}function Wr(t,n,a,d){n&=~Tu,n&=~_i,t.suspendedLanes|=n,t.pingedLanes&=~n,d&&(t.warmLanes|=n),d=t.expirationTimes;for(var w=n;0<w;){var E=31-$e(w),M=1<<E;d[E]=-1,w&=~M}a!==0&&Jh(t,a,n)}function qo(){return(ut&6)===0?(fa(0),!1):!0}function Mu(){if(Ye!==null){if(ft===0)var t=Ye.return;else t=Ye,fr=hi=null,Xc(t),ts=null,Ks=0,t=Ye;for(;t!==null;)_m(t.alternate,t),t=t.return;Ye=null}}function ds(t,n){var a=t.timeoutHandle;a!==-1&&(t.timeoutHandle=-1,T_(a)),a=t.cancelPendingCommit,a!==null&&(t.cancelPendingCommit=null,a()),Cr=0,Mu(),bt=t,Ye=a=dr(t.current,null),Ze=n,ft=0,Cn=null,Fr=!1,ls=Et(t,n),Nu=!1,cs=kn=Tu=_i=Ur=Nt=0,gn=da=null,Au=!1,(n&8)!==0&&(n|=n&32);var d=t.entangledLanes;if(d!==0)for(t=t.entanglements,d&=n;0<d;){var w=31-$e(d),E=1<<w;n|=t[w],d&=~E}return wr=n,uo(),a}function Wm(t,n){Ue=null,$.H=ra,n===es||n===bo?(n=op(),ft=3):n===zc?(n=op(),ft=4):ft=n===hu?8:n!==null&&typeof n=="object"&&typeof n.then=="function"?6:1,Cn=n,Ye===null&&(Nt=1,Ro(t,Bn(n,t.current)))}function Gm(){var t=Sn.current;return t===null?!0:(Ze&4194048)===Ze?Pn===null:(Ze&62914560)===Ze||(Ze&536870912)!==0?t===Pn:!1}function Vm(){var t=$.H;return $.H=ra,t===null?ra:t}function Ym(){var t=$.A;return $.A=o_,t}function Wo(){Nt=4,Fr||(Ze&4194048)!==Ze&&Sn.current!==null||(ls=!0),(Ur&134217727)===0&&(_i&134217727)===0||bt===null||Wr(bt,Ze,kn,!1)}function Ou(t,n,a){var d=ut;ut|=2;var w=Vm(),E=Ym();(bt!==t||Ze!==n)&&($o=null,ds(t,n)),n=!1;var M=Nt;e:do try{if(ft!==0&&Ye!==null){var G=Ye,ee=Cn;switch(ft){case 8:Mu(),M=6;break e;case 3:case 2:case 9:case 6:Sn.current===null&&(n=!0);var le=ft;if(ft=0,Cn=null,hs(t,G,ee,le),a&&ls){M=0;break e}break;default:le=ft,ft=0,Cn=null,hs(t,G,ee,le)}}u_(),M=Nt;break}catch(he){Wm(t,he)}while(!0);return n&&t.shellSuspendCounter++,fr=hi=null,ut=d,$.H=w,$.A=E,Ye===null&&(bt=null,Ze=0,uo()),M}function u_(){for(;Ye!==null;)Km(Ye)}function d_(t,n){var a=ut;ut|=2;var d=Vm(),w=Ym();bt!==t||Ze!==n?($o=null,Uo=Ge()+500,ds(t,n)):ls=Et(t,n);e:do try{if(ft!==0&&Ye!==null){n=Ye;var E=Cn;t:switch(ft){case 1:ft=0,Cn=null,hs(t,n,E,1);break;case 2:case 9:if(sp(E)){ft=0,Cn=null,Xm(n);break}n=function(){ft!==2&&ft!==9||bt!==t||(ft=7),er(t)},E.then(n,n);break e;case 3:ft=7;break e;case 4:ft=5;break e;case 7:sp(E)?(ft=0,Cn=null,Xm(n)):(ft=0,Cn=null,hs(t,n,E,7));break;case 5:var M=null;switch(Ye.tag){case 26:M=Ye.memoizedState;case 5:case 27:var G=Ye;if(M?Og(M):G.stateNode.complete){ft=0,Cn=null;var ee=G.sibling;if(ee!==null)Ye=ee;else{var le=G.return;le!==null?(Ye=le,Go(le)):Ye=null}break t}}ft=0,Cn=null,hs(t,n,E,5);break;case 6:ft=0,Cn=null,hs(t,n,E,6);break;case 8:Mu(),Nt=6;break e;default:throw Error(s(462))}}h_();break}catch(he){Wm(t,he)}while(!0);return fr=hi=null,$.H=d,$.A=w,ut=a,Ye!==null?0:(bt=null,Ze=0,uo(),Nt)}function h_(){for(;Ye!==null&&!Je();)Km(Ye)}function Km(t){var n=bm(t.alternate,t,wr);t.memoizedProps=t.pendingProps,n===null?Go(t):Ye=n}function Xm(t){var n=t,a=n.alternate;switch(n.tag){case 15:case 0:n=fm(a,n,n.pendingProps,n.type,void 0,Ze);break;case 11:n=fm(a,n,n.pendingProps,n.type.render,n.ref,Ze);break;case 5:Xc(n);default:_m(a,n),n=Ye=Yf(n,wr),n=bm(a,n,wr)}t.memoizedProps=t.pendingProps,n===null?Go(t):Ye=n}function hs(t,n,a,d){fr=hi=null,Xc(n),ts=null,Ks=0;var w=n.return;try{if(e_(t,w,n,a,Ze)){Nt=1,Ro(t,Bn(a,t.current)),Ye=null;return}}catch(E){if(w!==null)throw Ye=w,E;Nt=1,Ro(t,Bn(a,t.current)),Ye=null;return}n.flags&32768?(nt||d===1?t=!0:ls||(Ze&536870912)!==0?t=!1:(Fr=t=!0,(d===2||d===9||d===3||d===6)&&(d=Sn.current,d!==null&&d.tag===13&&(d.flags|=16384))),Zm(n,t)):Go(n)}function Go(t){var n=t;do{if((n.flags&32768)!==0){Zm(n,Fr);return}t=n.return;var a=r_(n.alternate,n,wr);if(a!==null){Ye=a;return}if(n=n.sibling,n!==null){Ye=n;return}Ye=n=t}while(n!==null);Nt===0&&(Nt=5)}function Zm(t,n){do{var a=i_(t.alternate,t);if(a!==null){a.flags&=32767,Ye=a;return}if(a=t.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!n&&(t=t.sibling,t!==null)){Ye=t;return}Ye=t=a}while(t!==null);Nt=6,Ye=null}function Qm(t,n,a,d,w,E,M,G,ee){t.cancelPendingCommit=null;do Vo();while(Ft!==0);if((ut&6)!==0)throw Error(s(327));if(n!==null){if(n===t.current)throw Error(s(177));if(E=n.lanes|n.childLanes,E|=wc,W0(t,a,E,M,G,ee),t===bt&&(Ye=bt=null,Ze=0),us=n,qr=t,Cr=a,Du=E,Lu=w,Fm=d,(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?(t.callbackNode=null,t.callbackPriority=0,g_(re,function(){return rg(),null})):(t.callbackNode=null,t.callbackPriority=0),d=(n.flags&13878)!==0,(n.subtreeFlags&13878)!==0||d){d=$.T,$.T=null,w=X.p,X.p=2,M=ut,ut|=4;try{s_(t,n,a)}finally{ut=M,X.p=w,$.T=d}}Ft=1,Jm(),eg(),tg()}}function Jm(){if(Ft===1){Ft=0;var t=qr,n=us,a=(n.flags&13878)!==0;if((n.subtreeFlags&13878)!==0||a){a=$.T,$.T=null;var d=X.p;X.p=2;var w=ut;ut|=4;try{Rm(n,t);var E=Vu,M=Hf(t.containerInfo),G=E.focusedElem,ee=E.selectionRange;if(M!==G&&G&&G.ownerDocument&&zf(G.ownerDocument.documentElement,G)){if(ee!==null&&vc(G)){var le=ee.start,he=ee.end;if(he===void 0&&(he=le),"selectionStart"in G)G.selectionStart=le,G.selectionEnd=Math.min(he,G.value.length);else{var xe=G.ownerDocument||document,ce=xe&&xe.defaultView||window;if(ce.getSelection){var ue=ce.getSelection(),je=G.textContent.length,Ie=Math.min(ee.start,je),vt=ee.end===void 0?Ie:Math.min(ee.end,je);!ue.extend&&Ie>vt&&(M=vt,vt=Ie,Ie=M);var ie=If(G,Ie),ne=If(G,vt);if(ie&&ne&&(ue.rangeCount!==1||ue.anchorNode!==ie.node||ue.anchorOffset!==ie.offset||ue.focusNode!==ne.node||ue.focusOffset!==ne.offset)){var oe=xe.createRange();oe.setStart(ie.node,ie.offset),ue.removeAllRanges(),Ie>vt?(ue.addRange(oe),ue.extend(ne.node,ne.offset)):(oe.setEnd(ne.node,ne.offset),ue.addRange(oe))}}}}for(xe=[],ue=G;ue=ue.parentNode;)ue.nodeType===1&&xe.push({element:ue,left:ue.scrollLeft,top:ue.scrollTop});for(typeof G.focus=="function"&&G.focus(),G=0;G<xe.length;G++){var me=xe[G];me.element.scrollLeft=me.left,me.element.scrollTop=me.top}}sl=!!Gu,Vu=Gu=null}finally{ut=w,X.p=d,$.T=a}}t.current=n,Ft=2}}function eg(){if(Ft===2){Ft=0;var t=qr,n=us,a=(n.flags&8772)!==0;if((n.subtreeFlags&8772)!==0||a){a=$.T,$.T=null;var d=X.p;X.p=2;var w=ut;ut|=4;try{Nm(t,n.alternate,n)}finally{ut=w,X.p=d,$.T=a}}Ft=3}}function tg(){if(Ft===4||Ft===3){Ft=0,et();var t=qr,n=us,a=Cr,d=Fm;(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?Ft=5:(Ft=0,us=qr=null,ng(t,t.pendingLanes));var w=t.pendingLanes;if(w===0&&($r=null),Jl(a),n=n.stateNode,it&&typeof it.onCommitFiberRoot=="function")try{it.onCommitFiberRoot(st,n,void 0,(n.current.flags&128)===128)}catch{}if(d!==null){n=$.T,w=X.p,X.p=2,$.T=null;try{for(var E=t.onRecoverableError,M=0;M<d.length;M++){var G=d[M];E(G.value,{componentStack:G.stack})}}finally{$.T=n,X.p=w}}(Cr&3)!==0&&Vo(),er(t),w=t.pendingLanes,(a&261930)!==0&&(w&42)!==0?t===Ru?ha++:(ha=0,Ru=t):ha=0,fa(0)}}function ng(t,n){(t.pooledCacheLanes&=n)===0&&(n=t.pooledCache,n!=null&&(t.pooledCache=null,Vs(n)))}function Vo(){return Jm(),eg(),tg(),rg()}function rg(){if(Ft!==5)return!1;var t=qr,n=Du;Du=0;var a=Jl(Cr),d=$.T,w=X.p;try{X.p=32>a?32:a,$.T=null,a=Lu,Lu=null;var E=qr,M=Cr;if(Ft=0,us=qr=null,Cr=0,(ut&6)!==0)throw Error(s(331));var G=ut;if(ut|=4,zm(E.current),Om(E,E.current,M,a),ut=G,fa(0,!1),it&&typeof it.onPostCommitFiberRoot=="function")try{it.onPostCommitFiberRoot(st,E)}catch{}return!0}finally{X.p=w,$.T=d,ng(t,n)}}function ig(t,n,a){n=Bn(a,n),n=du(t.stateNode,n,2),t=Ir(t,n,2),t!==null&&(Rs(t,2),er(t))}function pt(t,n,a){if(t.tag===3)ig(t,t,a);else for(;n!==null;){if(n.tag===3){ig(n,t,a);break}else if(n.tag===1){var d=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&($r===null||!$r.has(d))){t=Bn(a,t),a=sm(2),d=Ir(n,a,2),d!==null&&(am(a,d,n,t),Rs(d,2),er(d));break}}n=n.return}}function Bu(t,n,a){var d=t.pingCache;if(d===null){d=t.pingCache=new l_;var w=new Set;d.set(n,w)}else w=d.get(n),w===void 0&&(w=new Set,d.set(n,w));w.has(a)||(Nu=!0,w.add(a),t=f_.bind(null,t,n,a),n.then(t,t))}function f_(t,n,a){var d=t.pingCache;d!==null&&d.delete(n),t.pingedLanes|=t.suspendedLanes&a,t.warmLanes&=~a,bt===t&&(Ze&a)===a&&(Nt===4||Nt===3&&(Ze&62914560)===Ze&&300>Ge()-Fo?(ut&2)===0&&ds(t,0):Tu|=a,cs===Ze&&(cs=0)),er(t)}function sg(t,n){n===0&&(n=Zl()),t=ci(t,n),t!==null&&(Rs(t,n),er(t))}function p_(t){var n=t.memoizedState,a=0;n!==null&&(a=n.retryLane),sg(t,a)}function m_(t,n){var a=0;switch(t.tag){case 31:case 13:var d=t.stateNode,w=t.memoizedState;w!==null&&(a=w.retryLane);break;case 19:d=t.stateNode;break;case 22:d=t.stateNode._retryCache;break;default:throw Error(s(314))}d!==null&&d.delete(n),sg(t,a)}function g_(t,n){return fe(t,n)}var Yo=null,fs=null,Iu=!1,Ko=!1,zu=!1,Gr=0;function er(t){t!==fs&&t.next===null&&(fs===null?Yo=fs=t:fs=fs.next=t),Ko=!0,Iu||(Iu=!0,v_())}function fa(t,n){if(!zu&&Ko){zu=!0;do for(var a=!1,d=Yo;d!==null;){if(t!==0){var w=d.pendingLanes;if(w===0)var E=0;else{var M=d.suspendedLanes,G=d.pingedLanes;E=(1<<31-$e(42|t)+1)-1,E&=w&~(M&~G),E=E&201326741?E&201326741|1:E?E|2:0}E!==0&&(a=!0,cg(d,E))}else E=Ze,E=Lt(d,d===bt?E:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(E&3)===0||Et(d,E)||(a=!0,cg(d,E));d=d.next}while(a);zu=!1}}function x_(){ag()}function ag(){Ko=Iu=!1;var t=0;Gr!==0&&N_()&&(t=Gr);for(var n=Ge(),a=null,d=Yo;d!==null;){var w=d.next,E=og(d,n);E===0?(d.next=null,a===null?Yo=w:a.next=w,w===null&&(fs=a)):(a=d,(t!==0||(E&3)!==0)&&(Ko=!0)),d=w}Ft!==0&&Ft!==5||fa(t),Gr!==0&&(Gr=0)}function og(t,n){for(var a=t.suspendedLanes,d=t.pingedLanes,w=t.expirationTimes,E=t.pendingLanes&-62914561;0<E;){var M=31-$e(E),G=1<<M,ee=w[M];ee===-1?((G&a)===0||(G&d)!==0)&&(w[M]=Yt(G,n)):ee<=n&&(t.expiredLanes|=G),E&=~G}if(n=bt,a=Ze,a=Lt(t,t===n?a:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),d=t.callbackNode,a===0||t===n&&(ft===2||ft===9)||t.cancelPendingCommit!==null)return d!==null&&d!==null&&Re(d),t.callbackNode=null,t.callbackPriority=0;if((a&3)===0||Et(t,a)){if(n=a&-a,n===t.callbackPriority)return n;switch(d!==null&&Re(d),Jl(a)){case 2:case 8:a=be;break;case 32:a=re;break;case 268435456:a=Ce;break;default:a=re}return d=lg.bind(null,t),a=fe(a,d),t.callbackPriority=n,t.callbackNode=a,n}return d!==null&&d!==null&&Re(d),t.callbackPriority=2,t.callbackNode=null,2}function lg(t,n){if(Ft!==0&&Ft!==5)return t.callbackNode=null,t.callbackPriority=0,null;var a=t.callbackNode;if(Vo()&&t.callbackNode!==a)return null;var d=Ze;return d=Lt(t,t===bt?d:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),d===0?null:($m(t,d,n),og(t,Ge()),t.callbackNode!=null&&t.callbackNode===a?lg.bind(null,t):null)}function cg(t,n){if(Vo())return null;$m(t,n,!0)}function v_(){A_(function(){(ut&6)!==0?fe(de,x_):ag()})}function Hu(){if(Gr===0){var t=Qi;t===0&&(t=ze,ze<<=1,(ze&261888)===0&&(ze=256)),Gr=t}return Gr}function ug(t){return t==null||typeof t=="symbol"||typeof t=="boolean"?null:typeof t=="function"?t:no(""+t)}function dg(t,n){var a=n.ownerDocument.createElement("input");return a.name=n.name,a.value=n.value,t.id&&a.setAttribute("form",t.id),n.parentNode.insertBefore(a,n),t=new FormData(t),a.parentNode.removeChild(a),t}function b_(t,n,a,d,w){if(n==="submit"&&a&&a.stateNode===w){var E=ug((w[dn]||null).action),M=d.submitter;M&&(n=(n=M[dn]||null)?ug(n.formAction):M.getAttribute("formAction"),n!==null&&(E=n,M=null));var G=new ao("action","action",null,d,w);t.push({event:G,listeners:[{instance:null,listener:function(){if(d.defaultPrevented){if(Gr!==0){var ee=M?dg(w,M):new FormData(w);su(a,{pending:!0,data:ee,method:w.method,action:E},null,ee)}}else typeof E=="function"&&(G.preventDefault(),ee=M?dg(w,M):new FormData(w),su(a,{pending:!0,data:ee,method:w.method,action:E},E,ee))},currentTarget:w}]})}}for(var Pu=0;Pu<Sc.length;Pu++){var Fu=Sc[Pu],y_=Fu.toLowerCase(),__=Fu[0].toUpperCase()+Fu.slice(1);Wn(y_,"on"+__)}Wn(Uf,"onAnimationEnd"),Wn($f,"onAnimationIteration"),Wn(qf,"onAnimationStart"),Wn("dblclick","onDoubleClick"),Wn("focusin","onFocus"),Wn("focusout","onBlur"),Wn(Iy,"onTransitionRun"),Wn(zy,"onTransitionStart"),Wn(Hy,"onTransitionCancel"),Wn(Wf,"onTransitionEnd"),zi("onMouseEnter",["mouseout","mouseover"]),zi("onMouseLeave",["mouseout","mouseover"]),zi("onPointerEnter",["pointerout","pointerover"]),zi("onPointerLeave",["pointerout","pointerover"]),si("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),si("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),si("onBeforeInput",["compositionend","keypress","textInput","paste"]),si("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),si("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),si("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var pa="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(" "),S_=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(pa));function hg(t,n){n=(n&4)!==0;for(var a=0;a<t.length;a++){var d=t[a],w=d.event;d=d.listeners;e:{var E=void 0;if(n)for(var M=d.length-1;0<=M;M--){var G=d[M],ee=G.instance,le=G.currentTarget;if(G=G.listener,ee!==E&&w.isPropagationStopped())break e;E=G,w.currentTarget=le;try{E(w)}catch(he){co(he)}w.currentTarget=null,E=ee}else for(M=0;M<d.length;M++){if(G=d[M],ee=G.instance,le=G.currentTarget,G=G.listener,ee!==E&&w.isPropagationStopped())break e;E=G,w.currentTarget=le;try{E(w)}catch(he){co(he)}w.currentTarget=null,E=ee}}}}function Ke(t,n){var a=n[ec];a===void 0&&(a=n[ec]=new Set);var d=t+"__bubble";a.has(d)||(fg(n,t,2,!1),a.add(d))}function Uu(t,n,a){var d=0;n&&(d|=4),fg(a,t,d,n)}var Xo="_reactListening"+Math.random().toString(36).slice(2);function $u(t){if(!t[Xo]){t[Xo]=!0,af.forEach(function(a){a!=="selectionchange"&&(S_.has(a)||Uu(a,!1,t),Uu(a,!0,t))});var n=t.nodeType===9?t:t.ownerDocument;n===null||n[Xo]||(n[Xo]=!0,Uu("selectionchange",!1,n))}}function fg(t,n,a,d){switch(Ug(n)){case 2:var w=X_;break;case 8:w=Z_;break;default:w=id}a=w.bind(null,n,a,t),w=void 0,!cc||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(w=!0),d?w!==void 0?t.addEventListener(n,a,{capture:!0,passive:w}):t.addEventListener(n,a,!0):w!==void 0?t.addEventListener(n,a,{passive:w}):t.addEventListener(n,a,!1)}function qu(t,n,a,d,w){var E=d;if((n&1)===0&&(n&2)===0&&d!==null)e:for(;;){if(d===null)return;var M=d.tag;if(M===3||M===4){var G=d.stateNode.containerInfo;if(G===w)break;if(M===4)for(M=d.return;M!==null;){var ee=M.tag;if((ee===3||ee===4)&&M.stateNode.containerInfo===w)return;M=M.return}for(;G!==null;){if(M=Oi(G),M===null)return;if(ee=M.tag,ee===5||ee===6||ee===26||ee===27){d=E=M;continue e}G=G.parentNode}}d=d.return}vf(function(){var le=E,he=oc(a),xe=[];e:{var ce=Gf.get(t);if(ce!==void 0){var ue=ao,je=t;switch(t){case"keypress":if(io(a)===0)break e;case"keydown":case"keyup":ue=my;break;case"focusin":je="focus",ue=fc;break;case"focusout":je="blur",ue=fc;break;case"beforeblur":case"afterblur":ue=fc;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":ue=_f;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ue=ry;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ue=vy;break;case Uf:case $f:case qf:ue=ay;break;case Wf:ue=yy;break;case"scroll":case"scrollend":ue=ty;break;case"wheel":ue=Sy;break;case"copy":case"cut":case"paste":ue=ly;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ue=wf;break;case"toggle":case"beforetoggle":ue=Cy}var Ie=(n&4)!==0,vt=!Ie&&(t==="scroll"||t==="scrollend"),ie=Ie?ce!==null?ce+"Capture":null:ce;Ie=[];for(var ne=le,oe;ne!==null;){var me=ne;if(oe=me.stateNode,me=me.tag,me!==5&&me!==26&&me!==27||oe===null||ie===null||(me=Bs(ne,ie),me!=null&&Ie.push(ma(ne,me,oe))),vt)break;ne=ne.return}0<Ie.length&&(ce=new ue(ce,je,null,a,he),xe.push({event:ce,listeners:Ie}))}}if((n&7)===0){e:{if(ce=t==="mouseover"||t==="pointerover",ue=t==="mouseout"||t==="pointerout",ce&&a!==ac&&(je=a.relatedTarget||a.fromElement)&&(Oi(je)||je[Mi]))break e;if((ue||ce)&&(ce=he.window===he?he:(ce=he.ownerDocument)?ce.defaultView||ce.parentWindow:window,ue?(je=a.relatedTarget||a.toElement,ue=le,je=je?Oi(je):null,je!==null&&(vt=u(je),Ie=je.tag,je!==vt||Ie!==5&&Ie!==27&&Ie!==6)&&(je=null)):(ue=null,je=le),ue!==je)){if(Ie=_f,me="onMouseLeave",ie="onMouseEnter",ne="mouse",(t==="pointerout"||t==="pointerover")&&(Ie=wf,me="onPointerLeave",ie="onPointerEnter",ne="pointer"),vt=ue==null?ce:Os(ue),oe=je==null?ce:Os(je),ce=new Ie(me,ne+"leave",ue,a,he),ce.target=vt,ce.relatedTarget=oe,me=null,Oi(he)===le&&(Ie=new Ie(ie,ne+"enter",je,a,he),Ie.target=oe,Ie.relatedTarget=vt,me=Ie),vt=me,ue&&je)t:{for(Ie=w_,ie=ue,ne=je,oe=0,me=ie;me;me=Ie(me))oe++;me=0;for(var Le=ne;Le;Le=Ie(Le))me++;for(;0<oe-me;)ie=Ie(ie),oe--;for(;0<me-oe;)ne=Ie(ne),me--;for(;oe--;){if(ie===ne||ne!==null&&ie===ne.alternate){Ie=ie;break t}ie=Ie(ie),ne=Ie(ne)}Ie=null}else Ie=null;ue!==null&&pg(xe,ce,ue,Ie,!1),je!==null&&vt!==null&&pg(xe,vt,je,Ie,!0)}}e:{if(ce=le?Os(le):window,ue=ce.nodeName&&ce.nodeName.toLowerCase(),ue==="select"||ue==="input"&&ce.type==="file")var at=Df;else if(Tf(ce))if(Lf)at=My;else{at=Ly;var Te=Dy}else ue=ce.nodeName,!ue||ue.toLowerCase()!=="input"||ce.type!=="checkbox"&&ce.type!=="radio"?le&&sc(le.elementType)&&(at=Df):at=Ry;if(at&&(at=at(t,le))){Af(xe,at,a,he);break e}Te&&Te(t,ce,le),t==="focusout"&&le&&ce.type==="number"&&le.memoizedProps.value!=null&&ic(ce,"number",ce.value)}switch(Te=le?Os(le):window,t){case"focusin":(Tf(Te)||Te.contentEditable==="true")&&(qi=Te,bc=le,qs=null);break;case"focusout":qs=bc=qi=null;break;case"mousedown":yc=!0;break;case"contextmenu":case"mouseup":case"dragend":yc=!1,Pf(xe,a,he);break;case"selectionchange":if(By)break;case"keydown":case"keyup":Pf(xe,a,he)}var qe;if(mc)e:{switch(t){case"compositionstart":var Qe="onCompositionStart";break e;case"compositionend":Qe="onCompositionEnd";break e;case"compositionupdate":Qe="onCompositionUpdate";break e}Qe=void 0}else $i?jf(t,a)&&(Qe="onCompositionEnd"):t==="keydown"&&a.keyCode===229&&(Qe="onCompositionStart");Qe&&(Cf&&a.locale!=="ko"&&($i||Qe!=="onCompositionStart"?Qe==="onCompositionEnd"&&$i&&(qe=bf()):(Ar=he,uc="value"in Ar?Ar.value:Ar.textContent,$i=!0)),Te=Zo(le,Qe),0<Te.length&&(Qe=new Sf(Qe,t,null,a,he),xe.push({event:Qe,listeners:Te}),qe?Qe.data=qe:(qe=Nf(a),qe!==null&&(Qe.data=qe)))),(qe=Ey?jy(t,a):Ny(t,a))&&(Qe=Zo(le,"onBeforeInput"),0<Qe.length&&(Te=new Sf("onBeforeInput","beforeinput",null,a,he),xe.push({event:Te,listeners:Qe}),Te.data=qe)),b_(xe,t,le,a,he)}hg(xe,n)})}function ma(t,n,a){return{instance:t,listener:n,currentTarget:a}}function Zo(t,n){for(var a=n+"Capture",d=[];t!==null;){var w=t,E=w.stateNode;if(w=w.tag,w!==5&&w!==26&&w!==27||E===null||(w=Bs(t,a),w!=null&&d.unshift(ma(t,w,E)),w=Bs(t,n),w!=null&&d.push(ma(t,w,E))),t.tag===3)return d;t=t.return}return[]}function w_(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5&&t.tag!==27);return t||null}function pg(t,n,a,d,w){for(var E=n._reactName,M=[];a!==null&&a!==d;){var G=a,ee=G.alternate,le=G.stateNode;if(G=G.tag,ee!==null&&ee===d)break;G!==5&&G!==26&&G!==27||le===null||(ee=le,w?(le=Bs(a,E),le!=null&&M.unshift(ma(a,le,ee))):w||(le=Bs(a,E),le!=null&&M.push(ma(a,le,ee)))),a=a.return}M.length!==0&&t.push({event:n,listeners:M})}var C_=/\r\n?/g,k_=/\u0000|\uFFFD/g;function mg(t){return(typeof t=="string"?t:""+t).replace(C_,`
48
+ `+d.stack}}var ht=Object.prototype.hasOwnProperty,fe=e.unstable_scheduleCallback,Re=e.unstable_cancelCallback,Je=e.unstable_shouldYield,et=e.unstable_requestPaint,Ge=e.unstable_now,ct=e.unstable_getCurrentPriorityLevel,de=e.unstable_ImmediatePriority,be=e.unstable_UserBlockingPriority,re=e.unstable_NormalPriority,Se=e.unstable_LowPriority,Ce=e.unstable_IdlePriority,He=e.log,Ae=e.unstable_setDisableYieldValue,st=null,it=null;function Ct(t){if(typeof He=="function"&&Ae(t),it&&typeof it.setStrictMode=="function")try{it.setStrictMode(st,t)}catch{}}var $e=Math.clz32?Math.clz32:we,Ln=Math.log,pe=Math.LN2;function we(t){return t>>>=0,t===0?32:31-(Ln(t)/pe|0)|0}var ze=256,Ve=262144,tt=4194304;function Be(t){var n=t&42;if(n!==0)return n;switch(t&-t){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:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return t&261888;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function Rt(t,n,a){var d=t.pendingLanes;if(d===0)return 0;var w=0,E=t.suspendedLanes,M=t.pingedLanes;t=t.warmLanes;var G=d&134217727;return G!==0?(d=G&~E,d!==0?w=Be(d):(M&=G,M!==0?w=Be(M):a||(a=G&~t,a!==0&&(w=Be(a))))):(G=d&~E,G!==0?w=Be(G):M!==0?w=Be(M):a||(a=d&~t,a!==0&&(w=Be(a)))),w===0?0:n!==0&&n!==w&&(n&E)===0&&(E=w&-w,a=n&-n,E>=a||E===32&&(a&4194048)!==0)?n:w}function Et(t,n){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&n)===0}function Yt(t,n){switch(t){case 1:case 2:case 4:case 8:case 64:return n+250;case 16:case 32: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 n+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Zl(){var t=tt;return tt<<=1,(tt&62914560)===0&&(tt=4194304),t}function Ls(t){for(var n=[],a=0;31>a;a++)n.push(t);return n}function Rs(t,n){t.pendingLanes|=n,n!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function W0(t,n,a,d,w,E){var M=t.pendingLanes;t.pendingLanes=a,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=a,t.entangledLanes&=a,t.errorRecoveryDisabledLanes&=a,t.shellSuspendCounter=0;var G=t.entanglements,ee=t.expirationTimes,le=t.hiddenUpdates;for(a=M&~a;0<a;){var he=31-$e(a),xe=1<<he;G[he]=0,ee[he]=-1;var ce=le[he];if(ce!==null)for(le[he]=null,he=0;he<ce.length;he++){var ue=ce[he];ue!==null&&(ue.lane&=-536870913)}a&=~xe}d!==0&&Jh(t,d,0),E!==0&&w===0&&t.tag!==0&&(t.suspendedLanes|=E&~(M&~n))}function Jh(t,n,a){t.pendingLanes|=n,t.suspendedLanes&=~n;var d=31-$e(n);t.entangledLanes|=n,t.entanglements[d]=t.entanglements[d]|1073741824|a&261930}function ef(t,n){var a=t.entangledLanes|=n;for(t=t.entanglements;a;){var d=31-$e(a),w=1<<d;w&n|t[d]&n&&(t[d]|=n),a&=~w}}function tf(t,n){var a=n&-n;return a=(a&42)!==0?1:Ql(a),(a&(t.suspendedLanes|n))!==0?0:a}function Ql(t){switch(t){case 2:t=1;break;case 8:t=4;break;case 32:t=16;break;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:t=128;break;case 268435456:t=134217728;break;default:t=0}return t}function Jl(t){return t&=-t,2<t?8<t?(t&134217727)!==0?32:268435456:8:2}function nf(){var t=X.p;return t!==0?t:(t=window.event,t===void 0?32:Ug(t.type))}function rf(t,n){var a=X.p;try{return X.p=t,n()}finally{X.p=a}}var Tr=Math.random().toString(36).slice(2),Kt="__reactFiber$"+Tr,dn="__reactProps$"+Tr,Mi="__reactContainer$"+Tr,ec="__reactEvents$"+Tr,G0="__reactListeners$"+Tr,V0="__reactHandles$"+Tr,sf="__reactResources$"+Tr,Ms="__reactMarker$"+Tr;function tc(t){delete t[Kt],delete t[dn],delete t[ec],delete t[G0],delete t[V0]}function Oi(t){var n=t[Kt];if(n)return n;for(var a=t.parentNode;a;){if(n=a[Mi]||a[Kt]){if(a=n.alternate,n.child!==null||a!==null&&a.child!==null)for(t=Eg(t);t!==null;){if(a=t[Kt])return a;t=Eg(t)}return n}t=a,a=t.parentNode}return null}function Bi(t){if(t=t[Kt]||t[Mi]){var n=t.tag;if(n===5||n===6||n===13||n===31||n===26||n===27||n===3)return t}return null}function Os(t){var n=t.tag;if(n===5||n===26||n===27||n===6)return t.stateNode;throw Error(s(33))}function Ii(t){var n=t[sf];return n||(n=t[sf]={hoistableStyles:new Map,hoistableScripts:new Map}),n}function qt(t){t[Ms]=!0}var af=new Set,of={};function si(t,n){zi(t,n),zi(t+"Capture",n)}function zi(t,n){for(of[t]=n,t=0;t<n.length;t++)af.add(n[t])}var Y0=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),lf={},cf={};function K0(t){return ht.call(cf,t)?!0:ht.call(lf,t)?!1:Y0.test(t)?cf[t]=!0:(lf[t]=!0,!1)}function Ja(t,n,a){if(K0(n))if(a===null)t.removeAttribute(n);else{switch(typeof a){case"undefined":case"function":case"symbol":t.removeAttribute(n);return;case"boolean":var d=n.toLowerCase().slice(0,5);if(d!=="data-"&&d!=="aria-"){t.removeAttribute(n);return}}t.setAttribute(n,""+a)}}function eo(t,n,a){if(a===null)t.removeAttribute(n);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":t.removeAttribute(n);return}t.setAttribute(n,""+a)}}function lr(t,n,a,d){if(d===null)t.removeAttribute(a);else{switch(typeof d){case"undefined":case"function":case"symbol":case"boolean":t.removeAttribute(a);return}t.setAttributeNS(n,a,""+d)}}function Rn(t){switch(typeof t){case"bigint":case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function uf(t){var n=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function X0(t,n,a){var d=Object.getOwnPropertyDescriptor(t.constructor.prototype,n);if(!t.hasOwnProperty(n)&&typeof d<"u"&&typeof d.get=="function"&&typeof d.set=="function"){var w=d.get,E=d.set;return Object.defineProperty(t,n,{configurable:!0,get:function(){return w.call(this)},set:function(M){a=""+M,E.call(this,M)}}),Object.defineProperty(t,n,{enumerable:d.enumerable}),{getValue:function(){return a},setValue:function(M){a=""+M},stopTracking:function(){t._valueTracker=null,delete t[n]}}}}function nc(t){if(!t._valueTracker){var n=uf(t)?"checked":"value";t._valueTracker=X0(t,n,""+t[n])}}function df(t){if(!t)return!1;var n=t._valueTracker;if(!n)return!0;var a=n.getValue(),d="";return t&&(d=uf(t)?t.checked?"true":"false":t.value),t=d,t!==a?(n.setValue(t),!0):!1}function to(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}var Z0=/[\n"\\]/g;function Mn(t){return t.replace(Z0,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function rc(t,n,a,d,w,E,M,G){t.name="",M!=null&&typeof M!="function"&&typeof M!="symbol"&&typeof M!="boolean"?t.type=M:t.removeAttribute("type"),n!=null?M==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+Rn(n)):t.value!==""+Rn(n)&&(t.value=""+Rn(n)):M!=="submit"&&M!=="reset"||t.removeAttribute("value"),n!=null?ic(t,M,Rn(n)):a!=null?ic(t,M,Rn(a)):d!=null&&t.removeAttribute("value"),w==null&&E!=null&&(t.defaultChecked=!!E),w!=null&&(t.checked=w&&typeof w!="function"&&typeof w!="symbol"),G!=null&&typeof G!="function"&&typeof G!="symbol"&&typeof G!="boolean"?t.name=""+Rn(G):t.removeAttribute("name")}function hf(t,n,a,d,w,E,M,G){if(E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"&&(t.type=E),n!=null||a!=null){if(!(E!=="submit"&&E!=="reset"||n!=null)){nc(t);return}a=a!=null?""+Rn(a):"",n=n!=null?""+Rn(n):a,G||n===t.value||(t.value=n),t.defaultValue=n}d=d??w,d=typeof d!="function"&&typeof d!="symbol"&&!!d,t.checked=G?t.checked:!!d,t.defaultChecked=!!d,M!=null&&typeof M!="function"&&typeof M!="symbol"&&typeof M!="boolean"&&(t.name=M),nc(t)}function ic(t,n,a){n==="number"&&to(t.ownerDocument)===t||t.defaultValue===""+a||(t.defaultValue=""+a)}function Hi(t,n,a,d){if(t=t.options,n){n={};for(var w=0;w<a.length;w++)n["$"+a[w]]=!0;for(a=0;a<t.length;a++)w=n.hasOwnProperty("$"+t[a].value),t[a].selected!==w&&(t[a].selected=w),w&&d&&(t[a].defaultSelected=!0)}else{for(a=""+Rn(a),n=null,w=0;w<t.length;w++){if(t[w].value===a){t[w].selected=!0,d&&(t[w].defaultSelected=!0);return}n!==null||t[w].disabled||(n=t[w])}n!==null&&(n.selected=!0)}}function ff(t,n,a){if(n!=null&&(n=""+Rn(n),n!==t.value&&(t.value=n),a==null)){t.defaultValue!==n&&(t.defaultValue=n);return}t.defaultValue=a!=null?""+Rn(a):""}function pf(t,n,a,d){if(n==null){if(d!=null){if(a!=null)throw Error(s(92));if(I(d)){if(1<d.length)throw Error(s(93));d=d[0]}a=d}a==null&&(a=""),n=a}a=Rn(n),t.defaultValue=a,d=t.textContent,d===a&&d!==""&&d!==null&&(t.value=d),nc(t)}function Pi(t,n){if(n){var a=t.firstChild;if(a&&a===t.lastChild&&a.nodeType===3){a.nodeValue=n;return}}t.textContent=n}var Q0=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function mf(t,n,a){var d=n.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?d?t.setProperty(n,""):n==="float"?t.cssFloat="":t[n]="":d?t.setProperty(n,a):typeof a!="number"||a===0||Q0.has(n)?n==="float"?t.cssFloat=a:t[n]=(""+a).trim():t[n]=a+"px"}function gf(t,n,a){if(n!=null&&typeof n!="object")throw Error(s(62));if(t=t.style,a!=null){for(var d in a)!a.hasOwnProperty(d)||n!=null&&n.hasOwnProperty(d)||(d.indexOf("--")===0?t.setProperty(d,""):d==="float"?t.cssFloat="":t[d]="");for(var w in n)d=n[w],n.hasOwnProperty(w)&&a[w]!==d&&mf(t,w,d)}else for(var E in n)n.hasOwnProperty(E)&&mf(t,E,n[E])}function sc(t){if(t.indexOf("-")===-1)return!1;switch(t){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 J0=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),ey=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function no(t){return ey.test(""+t)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":t}function cr(){}var ac=null;function oc(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Fi=null,Ui=null;function xf(t){var n=Bi(t);if(n&&(t=n.stateNode)){var a=t[dn]||null;e:switch(t=n.stateNode,n.type){case"input":if(rc(t,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),n=a.name,a.type==="radio"&&n!=null){for(a=t;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+Mn(""+n)+'"][type="radio"]'),n=0;n<a.length;n++){var d=a[n];if(d!==t&&d.form===t.form){var w=d[dn]||null;if(!w)throw Error(s(90));rc(d,w.value,w.defaultValue,w.defaultValue,w.checked,w.defaultChecked,w.type,w.name)}}for(n=0;n<a.length;n++)d=a[n],d.form===t.form&&df(d)}break e;case"textarea":ff(t,a.value,a.defaultValue);break e;case"select":n=a.value,n!=null&&Hi(t,!!a.multiple,n,!1)}}}var lc=!1;function vf(t,n,a){if(lc)return t(n,a);lc=!0;try{var d=t(n);return d}finally{if(lc=!1,(Fi!==null||Ui!==null)&&(qo(),Fi&&(n=Fi,t=Ui,Ui=Fi=null,xf(n),t)))for(n=0;n<t.length;n++)xf(t[n])}}function Bs(t,n){var a=t.stateNode;if(a===null)return null;var d=a[dn]||null;if(d===null)return null;a=d[n];e:switch(n){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(d=!d.disabled)||(t=t.type,d=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!d;break e;default:t=!1}if(t)return null;if(a&&typeof a!="function")throw Error(s(231,n,typeof a));return a}var ur=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),cc=!1;if(ur)try{var Is={};Object.defineProperty(Is,"passive",{get:function(){cc=!0}}),window.addEventListener("test",Is,Is),window.removeEventListener("test",Is,Is)}catch{cc=!1}var Ar=null,uc=null,ro=null;function bf(){if(ro)return ro;var t,n=uc,a=n.length,d,w="value"in Ar?Ar.value:Ar.textContent,E=w.length;for(t=0;t<a&&n[t]===w[t];t++);var M=a-t;for(d=1;d<=M&&n[a-d]===w[E-d];d++);return ro=w.slice(t,1<d?1-d:void 0)}function io(t){var n=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&n===13&&(t=13)):t=n,t===10&&(t=13),32<=t||t===13?t:0}function so(){return!0}function yf(){return!1}function hn(t){function n(a,d,w,E,M){this._reactName=a,this._targetInst=w,this.type=d,this.nativeEvent=E,this.target=M,this.currentTarget=null;for(var G in t)t.hasOwnProperty(G)&&(a=t[G],this[G]=a?a(E):E[G]);return this.isDefaultPrevented=(E.defaultPrevented!=null?E.defaultPrevented:E.returnValue===!1)?so:yf,this.isPropagationStopped=yf,this}return m(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=so)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=so)},persist:function(){},isPersistent:so}),n}var ai={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ao=hn(ai),zs=m({},ai,{view:0,detail:0}),ty=hn(zs),dc,hc,Hs,oo=m({},zs,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:pc,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==Hs&&(Hs&&t.type==="mousemove"?(dc=t.screenX-Hs.screenX,hc=t.screenY-Hs.screenY):hc=dc=0,Hs=t),dc)},movementY:function(t){return"movementY"in t?t.movementY:hc}}),_f=hn(oo),ny=m({},oo,{dataTransfer:0}),ry=hn(ny),iy=m({},zs,{relatedTarget:0}),fc=hn(iy),sy=m({},ai,{animationName:0,elapsedTime:0,pseudoElement:0}),ay=hn(sy),oy=m({},ai,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),ly=hn(oy),cy=m({},ai,{data:0}),Sf=hn(cy),uy={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},dy={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"},hy={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function fy(t){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(t):(t=hy[t])?!!n[t]:!1}function pc(){return fy}var py=m({},zs,{key:function(t){if(t.key){var n=uy[t.key]||t.key;if(n!=="Unidentified")return n}return t.type==="keypress"?(t=io(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?dy[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:pc,charCode:function(t){return t.type==="keypress"?io(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?io(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),my=hn(py),gy=m({},oo,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),wf=hn(gy),xy=m({},zs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:pc}),vy=hn(xy),by=m({},ai,{propertyName:0,elapsedTime:0,pseudoElement:0}),yy=hn(by),_y=m({},oo,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),Sy=hn(_y),wy=m({},ai,{newState:0,oldState:0}),Cy=hn(wy),ky=[9,13,27,32],mc=ur&&"CompositionEvent"in window,Ps=null;ur&&"documentMode"in document&&(Ps=document.documentMode);var Ey=ur&&"TextEvent"in window&&!Ps,Cf=ur&&(!mc||Ps&&8<Ps&&11>=Ps),kf=" ",Ef=!1;function jf(t,n){switch(t){case"keyup":return ky.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Nf(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var $i=!1;function jy(t,n){switch(t){case"compositionend":return Nf(n);case"keypress":return n.which!==32?null:(Ef=!0,kf);case"textInput":return t=n.data,t===kf&&Ef?null:t;default:return null}}function Ny(t,n){if($i)return t==="compositionend"||!mc&&jf(t,n)?(t=bf(),ro=uc=Ar=null,$i=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1<n.char.length)return n.char;if(n.which)return String.fromCharCode(n.which)}return null;case"compositionend":return Cf&&n.locale!=="ko"?null:n.data;default:return null}}var Ty={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 Tf(t){var n=t&&t.nodeName&&t.nodeName.toLowerCase();return n==="input"?!!Ty[t.type]:n==="textarea"}function Af(t,n,a,d){Fi?Ui?Ui.push(d):Ui=[d]:Fi=d,n=Zo(n,"onChange"),0<n.length&&(a=new ao("onChange","change",null,a,d),t.push({event:a,listeners:n}))}var Fs=null,Us=null;function Ay(t){hg(t,0)}function lo(t){var n=Os(t);if(df(n))return t}function Df(t,n){if(t==="change")return n}var Lf=!1;if(ur){var gc;if(ur){var xc="oninput"in document;if(!xc){var Rf=document.createElement("div");Rf.setAttribute("oninput","return;"),xc=typeof Rf.oninput=="function"}gc=xc}else gc=!1;Lf=gc&&(!document.documentMode||9<document.documentMode)}function Mf(){Fs&&(Fs.detachEvent("onpropertychange",Of),Us=Fs=null)}function Of(t){if(t.propertyName==="value"&&lo(Us)){var n=[];Af(n,Us,t,oc(t)),vf(Ay,n)}}function Dy(t,n,a){t==="focusin"?(Mf(),Fs=n,Us=a,Fs.attachEvent("onpropertychange",Of)):t==="focusout"&&Mf()}function Ly(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return lo(Us)}function Ry(t,n){if(t==="click")return lo(n)}function My(t,n){if(t==="input"||t==="change")return lo(n)}function Oy(t,n){return t===n&&(t!==0||1/t===1/n)||t!==t&&n!==n}var yn=typeof Object.is=="function"?Object.is:Oy;function $s(t,n){if(yn(t,n))return!0;if(typeof t!="object"||t===null||typeof n!="object"||n===null)return!1;var a=Object.keys(t),d=Object.keys(n);if(a.length!==d.length)return!1;for(d=0;d<a.length;d++){var w=a[d];if(!ht.call(n,w)||!yn(t[w],n[w]))return!1}return!0}function Bf(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function If(t,n){var a=Bf(t);t=0;for(var d;a;){if(a.nodeType===3){if(d=t+a.textContent.length,t<=n&&d>=n)return{node:a,offset:n-t};t=d}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Bf(a)}}function zf(t,n){return t&&n?t===n?!0:t&&t.nodeType===3?!1:n&&n.nodeType===3?zf(t,n.parentNode):"contains"in t?t.contains(n):t.compareDocumentPosition?!!(t.compareDocumentPosition(n)&16):!1:!1}function Hf(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var n=to(t.document);n instanceof t.HTMLIFrameElement;){try{var a=typeof n.contentWindow.location.href=="string"}catch{a=!1}if(a)t=n.contentWindow;else break;n=to(t.document)}return n}function vc(t){var n=t&&t.nodeName&&t.nodeName.toLowerCase();return n&&(n==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||n==="textarea"||t.contentEditable==="true")}var By=ur&&"documentMode"in document&&11>=document.documentMode,qi=null,bc=null,qs=null,yc=!1;function Pf(t,n,a){var d=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;yc||qi==null||qi!==to(d)||(d=qi,"selectionStart"in d&&vc(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),qs&&$s(qs,d)||(qs=d,d=Zo(bc,"onSelect"),0<d.length&&(n=new ao("onSelect","select",null,n,a),t.push({event:n,listeners:d}),n.target=qi)))}function oi(t,n){var a={};return a[t.toLowerCase()]=n.toLowerCase(),a["Webkit"+t]="webkit"+n,a["Moz"+t]="moz"+n,a}var Wi={animationend:oi("Animation","AnimationEnd"),animationiteration:oi("Animation","AnimationIteration"),animationstart:oi("Animation","AnimationStart"),transitionrun:oi("Transition","TransitionRun"),transitionstart:oi("Transition","TransitionStart"),transitioncancel:oi("Transition","TransitionCancel"),transitionend:oi("Transition","TransitionEnd")},_c={},Ff={};ur&&(Ff=document.createElement("div").style,"AnimationEvent"in window||(delete Wi.animationend.animation,delete Wi.animationiteration.animation,delete Wi.animationstart.animation),"TransitionEvent"in window||delete Wi.transitionend.transition);function li(t){if(_c[t])return _c[t];if(!Wi[t])return t;var n=Wi[t],a;for(a in n)if(n.hasOwnProperty(a)&&a in Ff)return _c[t]=n[a];return t}var Uf=li("animationend"),$f=li("animationiteration"),qf=li("animationstart"),Iy=li("transitionrun"),zy=li("transitionstart"),Hy=li("transitioncancel"),Wf=li("transitionend"),Gf=new Map,Sc="abort auxClick beforeToggle 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(" ");Sc.push("scrollEnd");function Wn(t,n){Gf.set(t,n),si(n,[t])}var co=typeof reportError=="function"?reportError:function(t){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var n=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof t=="object"&&t!==null&&typeof t.message=="string"?String(t.message):String(t),error:t});if(!window.dispatchEvent(n))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",t);return}console.error(t)},On=[],Gi=0,wc=0;function uo(){for(var t=Gi,n=wc=Gi=0;n<t;){var a=On[n];On[n++]=null;var d=On[n];On[n++]=null;var w=On[n];On[n++]=null;var E=On[n];if(On[n++]=null,d!==null&&w!==null){var M=d.pending;M===null?w.next=w:(w.next=M.next,M.next=w),d.pending=w}E!==0&&Vf(a,w,E)}}function ho(t,n,a,d){On[Gi++]=t,On[Gi++]=n,On[Gi++]=a,On[Gi++]=d,wc|=d,t.lanes|=d,t=t.alternate,t!==null&&(t.lanes|=d)}function Cc(t,n,a,d){return ho(t,n,a,d),fo(t)}function ci(t,n){return ho(t,null,null,n),fo(t)}function Vf(t,n,a){t.lanes|=a;var d=t.alternate;d!==null&&(d.lanes|=a);for(var w=!1,E=t.return;E!==null;)E.childLanes|=a,d=E.alternate,d!==null&&(d.childLanes|=a),E.tag===22&&(t=E.stateNode,t===null||t._visibility&1||(w=!0)),t=E,E=E.return;return t.tag===3?(E=t.stateNode,w&&n!==null&&(w=31-$e(a),t=E.hiddenUpdates,d=t[w],d===null?t[w]=[n]:d.push(n),n.lane=a|536870912),E):null}function fo(t){if(50<ha)throw ha=0,Ru=null,Error(s(185));for(var n=t.return;n!==null;)t=n,n=t.return;return t.tag===3?t.stateNode:null}var Vi={};function Py(t,n,a,d){this.tag=t,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=d,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function _n(t,n,a,d){return new Py(t,n,a,d)}function kc(t){return t=t.prototype,!(!t||!t.isReactComponent)}function dr(t,n){var a=t.alternate;return a===null?(a=_n(t.tag,n,t.key,t.mode),a.elementType=t.elementType,a.type=t.type,a.stateNode=t.stateNode,a.alternate=t,t.alternate=a):(a.pendingProps=n,a.type=t.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=t.flags&65011712,a.childLanes=t.childLanes,a.lanes=t.lanes,a.child=t.child,a.memoizedProps=t.memoizedProps,a.memoizedState=t.memoizedState,a.updateQueue=t.updateQueue,n=t.dependencies,a.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},a.sibling=t.sibling,a.index=t.index,a.ref=t.ref,a.refCleanup=t.refCleanup,a}function Yf(t,n){t.flags&=65011714;var a=t.alternate;return a===null?(t.childLanes=0,t.lanes=n,t.child=null,t.subtreeFlags=0,t.memoizedProps=null,t.memoizedState=null,t.updateQueue=null,t.dependencies=null,t.stateNode=null):(t.childLanes=a.childLanes,t.lanes=a.lanes,t.child=a.child,t.subtreeFlags=0,t.deletions=null,t.memoizedProps=a.memoizedProps,t.memoizedState=a.memoizedState,t.updateQueue=a.updateQueue,t.type=a.type,n=a.dependencies,t.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),t}function po(t,n,a,d,w,E){var M=0;if(d=t,typeof t=="function")kc(t)&&(M=1);else if(typeof t=="string")M=W_(t,a,K.current)?26:t==="html"||t==="head"||t==="body"?27:5;else e:switch(t){case B:return t=_n(31,a,n,w),t.elementType=B,t.lanes=E,t;case C:return ui(a.children,w,E,n);case b:M=8,w|=24;break;case y:return t=_n(12,a,n,w|2),t.elementType=y,t.lanes=E,t;case A:return t=_n(13,a,n,w),t.elementType=A,t.lanes=E,t;case N:return t=_n(19,a,n,w),t.elementType=N,t.lanes=E,t;default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case _:M=10;break e;case v:M=9;break e;case j:M=11;break e;case L:M=14;break e;case T:M=16,d=null;break e}M=29,a=Error(s(130,t===null?"null":typeof t,"")),d=null}return n=_n(M,a,n,w),n.elementType=t,n.type=d,n.lanes=E,n}function ui(t,n,a,d){return t=_n(7,t,d,n),t.lanes=a,t}function Ec(t,n,a){return t=_n(6,t,null,n),t.lanes=a,t}function Kf(t){var n=_n(18,null,null,0);return n.stateNode=t,n}function jc(t,n,a){return n=_n(4,t.children!==null?t.children:[],t.key,n),n.lanes=a,n.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},n}var Xf=new WeakMap;function Bn(t,n){if(typeof t=="object"&&t!==null){var a=Xf.get(t);return a!==void 0?a:(n={value:t,source:n,stack:lt(n)},Xf.set(t,n),n)}return{value:t,source:n,stack:lt(n)}}var Yi=[],Ki=0,mo=null,Ws=0,In=[],zn=0,Dr=null,Zn=1,Qn="";function hr(t,n){Yi[Ki++]=Ws,Yi[Ki++]=mo,mo=t,Ws=n}function Zf(t,n,a){In[zn++]=Zn,In[zn++]=Qn,In[zn++]=Dr,Dr=t;var d=Zn;t=Qn;var w=32-$e(d)-1;d&=~(1<<w),a+=1;var E=32-$e(n)+w;if(30<E){var M=w-w%5;E=(d&(1<<M)-1).toString(32),d>>=M,w-=M,Zn=1<<32-$e(n)+w|a<<w|d,Qn=E+t}else Zn=1<<E|a<<w|d,Qn=t}function Nc(t){t.return!==null&&(hr(t,1),Zf(t,1,0))}function Tc(t){for(;t===mo;)mo=Yi[--Ki],Yi[Ki]=null,Ws=Yi[--Ki],Yi[Ki]=null;for(;t===Dr;)Dr=In[--zn],In[zn]=null,Qn=In[--zn],In[zn]=null,Zn=In[--zn],In[zn]=null}function Qf(t,n){In[zn++]=Zn,In[zn++]=Qn,In[zn++]=Dr,Zn=n.id,Qn=n.overflow,Dr=t}var Xt=null,St=null,nt=!1,Lr=null,Hn=!1,Ac=Error(s(519));function Rr(t){var n=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Gs(Bn(n,t)),Ac}function Jf(t){var n=t.stateNode,a=t.type,d=t.memoizedProps;switch(n[Kt]=t,n[dn]=d,a){case"dialog":Ke("cancel",n),Ke("close",n);break;case"iframe":case"object":case"embed":Ke("load",n);break;case"video":case"audio":for(a=0;a<pa.length;a++)Ke(pa[a],n);break;case"source":Ke("error",n);break;case"img":case"image":case"link":Ke("error",n),Ke("load",n);break;case"details":Ke("toggle",n);break;case"input":Ke("invalid",n),hf(n,d.value,d.defaultValue,d.checked,d.defaultChecked,d.type,d.name,!0);break;case"select":Ke("invalid",n);break;case"textarea":Ke("invalid",n),pf(n,d.value,d.defaultValue,d.children)}a=d.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||n.textContent===""+a||d.suppressHydrationWarning===!0||gg(n.textContent,a)?(d.popover!=null&&(Ke("beforetoggle",n),Ke("toggle",n)),d.onScroll!=null&&Ke("scroll",n),d.onScrollEnd!=null&&Ke("scrollend",n),d.onClick!=null&&(n.onclick=cr),n=!0):n=!1,n||Rr(t,!0)}function ep(t){for(Xt=t.return;Xt;)switch(Xt.tag){case 5:case 31:case 13:Hn=!1;return;case 27:case 3:Hn=!0;return;default:Xt=Xt.return}}function Xi(t){if(t!==Xt)return!1;if(!nt)return ep(t),nt=!0,!1;var n=t.tag,a;if((a=n!==3&&n!==27)&&((a=n===5)&&(a=t.type,a=!(a!=="form"&&a!=="button")||Yu(t.type,t.memoizedProps)),a=!a),a&&St&&Rr(t),ep(t),n===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(s(317));St=kg(t)}else if(n===31){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(s(317));St=kg(t)}else n===27?(n=St,Vr(t.type)?(t=Ju,Ju=null,St=t):St=n):St=Xt?Fn(t.stateNode.nextSibling):null;return!0}function di(){St=Xt=null,nt=!1}function Dc(){var t=Lr;return t!==null&&(gn===null?gn=t:gn.push.apply(gn,t),Lr=null),t}function Gs(t){Lr===null?Lr=[t]:Lr.push(t)}var Lc=O(null),hi=null,fr=null;function Mr(t,n,a){U(Lc,n._currentValue),n._currentValue=a}function pr(t){t._currentValue=Lc.current,W(Lc)}function Rc(t,n,a){for(;t!==null;){var d=t.alternate;if((t.childLanes&n)!==n?(t.childLanes|=n,d!==null&&(d.childLanes|=n)):d!==null&&(d.childLanes&n)!==n&&(d.childLanes|=n),t===a)break;t=t.return}}function Mc(t,n,a,d){var w=t.child;for(w!==null&&(w.return=t);w!==null;){var E=w.dependencies;if(E!==null){var M=w.child;E=E.firstContext;e:for(;E!==null;){var G=E;E=w;for(var ee=0;ee<n.length;ee++)if(G.context===n[ee]){E.lanes|=a,G=E.alternate,G!==null&&(G.lanes|=a),Rc(E.return,a,t),d||(M=null);break e}E=G.next}}else if(w.tag===18){if(M=w.return,M===null)throw Error(s(341));M.lanes|=a,E=M.alternate,E!==null&&(E.lanes|=a),Rc(M,a,t),M=null}else M=w.child;if(M!==null)M.return=w;else for(M=w;M!==null;){if(M===t){M=null;break}if(w=M.sibling,w!==null){w.return=M.return,M=w;break}M=M.return}w=M}}function Zi(t,n,a,d){t=null;for(var w=n,E=!1;w!==null;){if(!E){if((w.flags&524288)!==0)E=!0;else if((w.flags&262144)!==0)break}if(w.tag===10){var M=w.alternate;if(M===null)throw Error(s(387));if(M=M.memoizedProps,M!==null){var G=w.type;yn(w.pendingProps.value,M.value)||(t!==null?t.push(G):t=[G])}}else if(w===Z.current){if(M=w.alternate,M===null)throw Error(s(387));M.memoizedState.memoizedState!==w.memoizedState.memoizedState&&(t!==null?t.push(ba):t=[ba])}w=w.return}t!==null&&Mc(n,t,a,d),n.flags|=262144}function go(t){for(t=t.firstContext;t!==null;){if(!yn(t.context._currentValue,t.memoizedValue))return!0;t=t.next}return!1}function fi(t){hi=t,fr=null,t=t.dependencies,t!==null&&(t.firstContext=null)}function Zt(t){return tp(hi,t)}function xo(t,n){return hi===null&&fi(t),tp(t,n)}function tp(t,n){var a=n._currentValue;if(n={context:n,memoizedValue:a,next:null},fr===null){if(t===null)throw Error(s(308));fr=n,t.dependencies={lanes:0,firstContext:n},t.flags|=524288}else fr=fr.next=n;return a}var Fy=typeof AbortController<"u"?AbortController:function(){var t=[],n=this.signal={aborted:!1,addEventListener:function(a,d){t.push(d)}};this.abort=function(){n.aborted=!0,t.forEach(function(a){return a()})}},Uy=e.unstable_scheduleCallback,$y=e.unstable_NormalPriority,Mt={$$typeof:_,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Oc(){return{controller:new Fy,data:new Map,refCount:0}}function Vs(t){t.refCount--,t.refCount===0&&Uy($y,function(){t.controller.abort()})}var Ys=null,Bc=0,Qi=0,Ji=null;function qy(t,n){if(Ys===null){var a=Ys=[];Bc=0,Qi=Hu(),Ji={status:"pending",value:void 0,then:function(d){a.push(d)}}}return Bc++,n.then(np,np),n}function np(){if(--Bc===0&&Ys!==null){Ji!==null&&(Ji.status="fulfilled");var t=Ys;Ys=null,Qi=0,Ji=null;for(var n=0;n<t.length;n++)(0,t[n])()}}function Wy(t,n){var a=[],d={status:"pending",value:null,reason:null,then:function(w){a.push(w)}};return t.then(function(){d.status="fulfilled",d.value=n;for(var w=0;w<a.length;w++)(0,a[w])(n)},function(w){for(d.status="rejected",d.reason=w,w=0;w<a.length;w++)(0,a[w])(void 0)}),d}var rp=$.S;$.S=function(t,n){Pm=Ge(),typeof n=="object"&&n!==null&&typeof n.then=="function"&&qy(t,n),rp!==null&&rp(t,n)};var pi=O(null);function Ic(){var t=pi.current;return t!==null?t:bt.pooledCache}function vo(t,n){n===null?U(pi,pi.current):U(pi,n.pool)}function ip(){var t=Ic();return t===null?null:{parent:Mt._currentValue,pool:t}}var es=Error(s(460)),zc=Error(s(474)),bo=Error(s(542)),yo={then:function(){}};function sp(t){return t=t.status,t==="fulfilled"||t==="rejected"}function ap(t,n,a){switch(a=t[a],a===void 0?t.push(n):a!==n&&(n.then(cr,cr),n=a),n.status){case"fulfilled":return n.value;case"rejected":throw t=n.reason,lp(t),t;default:if(typeof n.status=="string")n.then(cr,cr);else{if(t=bt,t!==null&&100<t.shellSuspendCounter)throw Error(s(482));t=n,t.status="pending",t.then(function(d){if(n.status==="pending"){var w=n;w.status="fulfilled",w.value=d}},function(d){if(n.status==="pending"){var w=n;w.status="rejected",w.reason=d}})}switch(n.status){case"fulfilled":return n.value;case"rejected":throw t=n.reason,lp(t),t}throw gi=n,es}}function mi(t){try{var n=t._init;return n(t._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(gi=a,es):a}}var gi=null;function op(){if(gi===null)throw Error(s(459));var t=gi;return gi=null,t}function lp(t){if(t===es||t===bo)throw Error(s(483))}var ts=null,Ks=0;function _o(t){var n=Ks;return Ks+=1,ts===null&&(ts=[]),ap(ts,t,n)}function Xs(t,n){n=n.props.ref,t.ref=n!==void 0?n:null}function So(t,n){throw n.$$typeof===x?Error(s(525)):(t=Object.prototype.toString.call(n),Error(s(31,t==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":t)))}function cp(t){function n(ie,ne){if(t){var oe=ie.deletions;oe===null?(ie.deletions=[ne],ie.flags|=16):oe.push(ne)}}function a(ie,ne){if(!t)return null;for(;ne!==null;)n(ie,ne),ne=ne.sibling;return null}function d(ie){for(var ne=new Map;ie!==null;)ie.key!==null?ne.set(ie.key,ie):ne.set(ie.index,ie),ie=ie.sibling;return ne}function w(ie,ne){return ie=dr(ie,ne),ie.index=0,ie.sibling=null,ie}function E(ie,ne,oe){return ie.index=oe,t?(oe=ie.alternate,oe!==null?(oe=oe.index,oe<ne?(ie.flags|=67108866,ne):oe):(ie.flags|=67108866,ne)):(ie.flags|=1048576,ne)}function M(ie){return t&&ie.alternate===null&&(ie.flags|=67108866),ie}function G(ie,ne,oe,me){return ne===null||ne.tag!==6?(ne=Ec(oe,ie.mode,me),ne.return=ie,ne):(ne=w(ne,oe),ne.return=ie,ne)}function ee(ie,ne,oe,me){var Le=oe.type;return Le===C?he(ie,ne,oe.props.children,me,oe.key):ne!==null&&(ne.elementType===Le||typeof Le=="object"&&Le!==null&&Le.$$typeof===T&&mi(Le)===ne.type)?(ne=w(ne,oe.props),Xs(ne,oe),ne.return=ie,ne):(ne=po(oe.type,oe.key,oe.props,null,ie.mode,me),Xs(ne,oe),ne.return=ie,ne)}function le(ie,ne,oe,me){return ne===null||ne.tag!==4||ne.stateNode.containerInfo!==oe.containerInfo||ne.stateNode.implementation!==oe.implementation?(ne=jc(oe,ie.mode,me),ne.return=ie,ne):(ne=w(ne,oe.children||[]),ne.return=ie,ne)}function he(ie,ne,oe,me,Le){return ne===null||ne.tag!==7?(ne=ui(oe,ie.mode,me,Le),ne.return=ie,ne):(ne=w(ne,oe),ne.return=ie,ne)}function xe(ie,ne,oe){if(typeof ne=="string"&&ne!==""||typeof ne=="number"||typeof ne=="bigint")return ne=Ec(""+ne,ie.mode,oe),ne.return=ie,ne;if(typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case S:return oe=po(ne.type,ne.key,ne.props,null,ie.mode,oe),Xs(oe,ne),oe.return=ie,oe;case k:return ne=jc(ne,ie.mode,oe),ne.return=ie,ne;case T:return ne=mi(ne),xe(ie,ne,oe)}if(I(ne)||Y(ne))return ne=ui(ne,ie.mode,oe,null),ne.return=ie,ne;if(typeof ne.then=="function")return xe(ie,_o(ne),oe);if(ne.$$typeof===_)return xe(ie,xo(ie,ne),oe);So(ie,ne)}return null}function ce(ie,ne,oe,me){var Le=ne!==null?ne.key:null;if(typeof oe=="string"&&oe!==""||typeof oe=="number"||typeof oe=="bigint")return Le!==null?null:G(ie,ne,""+oe,me);if(typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case S:return oe.key===Le?ee(ie,ne,oe,me):null;case k:return oe.key===Le?le(ie,ne,oe,me):null;case T:return oe=mi(oe),ce(ie,ne,oe,me)}if(I(oe)||Y(oe))return Le!==null?null:he(ie,ne,oe,me,null);if(typeof oe.then=="function")return ce(ie,ne,_o(oe),me);if(oe.$$typeof===_)return ce(ie,ne,xo(ie,oe),me);So(ie,oe)}return null}function ue(ie,ne,oe,me,Le){if(typeof me=="string"&&me!==""||typeof me=="number"||typeof me=="bigint")return ie=ie.get(oe)||null,G(ne,ie,""+me,Le);if(typeof me=="object"&&me!==null){switch(me.$$typeof){case S:return ie=ie.get(me.key===null?oe:me.key)||null,ee(ne,ie,me,Le);case k:return ie=ie.get(me.key===null?oe:me.key)||null,le(ne,ie,me,Le);case T:return me=mi(me),ue(ie,ne,oe,me,Le)}if(I(me)||Y(me))return ie=ie.get(oe)||null,he(ne,ie,me,Le,null);if(typeof me.then=="function")return ue(ie,ne,oe,_o(me),Le);if(me.$$typeof===_)return ue(ie,ne,oe,xo(ne,me),Le);So(ne,me)}return null}function je(ie,ne,oe,me){for(var Le=null,at=null,Te=ne,qe=ne=0,Qe=null;Te!==null&&qe<oe.length;qe++){Te.index>qe?(Qe=Te,Te=null):Qe=Te.sibling;var ot=ce(ie,Te,oe[qe],me);if(ot===null){Te===null&&(Te=Qe);break}t&&Te&&ot.alternate===null&&n(ie,Te),ne=E(ot,ne,qe),at===null?Le=ot:at.sibling=ot,at=ot,Te=Qe}if(qe===oe.length)return a(ie,Te),nt&&hr(ie,qe),Le;if(Te===null){for(;qe<oe.length;qe++)Te=xe(ie,oe[qe],me),Te!==null&&(ne=E(Te,ne,qe),at===null?Le=Te:at.sibling=Te,at=Te);return nt&&hr(ie,qe),Le}for(Te=d(Te);qe<oe.length;qe++)Qe=ue(Te,ie,qe,oe[qe],me),Qe!==null&&(t&&Qe.alternate!==null&&Te.delete(Qe.key===null?qe:Qe.key),ne=E(Qe,ne,qe),at===null?Le=Qe:at.sibling=Qe,at=Qe);return t&&Te.forEach(function(Qr){return n(ie,Qr)}),nt&&hr(ie,qe),Le}function Ie(ie,ne,oe,me){if(oe==null)throw Error(s(151));for(var Le=null,at=null,Te=ne,qe=ne=0,Qe=null,ot=oe.next();Te!==null&&!ot.done;qe++,ot=oe.next()){Te.index>qe?(Qe=Te,Te=null):Qe=Te.sibling;var Qr=ce(ie,Te,ot.value,me);if(Qr===null){Te===null&&(Te=Qe);break}t&&Te&&Qr.alternate===null&&n(ie,Te),ne=E(Qr,ne,qe),at===null?Le=Qr:at.sibling=Qr,at=Qr,Te=Qe}if(ot.done)return a(ie,Te),nt&&hr(ie,qe),Le;if(Te===null){for(;!ot.done;qe++,ot=oe.next())ot=xe(ie,ot.value,me),ot!==null&&(ne=E(ot,ne,qe),at===null?Le=ot:at.sibling=ot,at=ot);return nt&&hr(ie,qe),Le}for(Te=d(Te);!ot.done;qe++,ot=oe.next())ot=ue(Te,ie,qe,ot.value,me),ot!==null&&(t&&ot.alternate!==null&&Te.delete(ot.key===null?qe:ot.key),ne=E(ot,ne,qe),at===null?Le=ot:at.sibling=ot,at=ot);return t&&Te.forEach(function(n1){return n(ie,n1)}),nt&&hr(ie,qe),Le}function vt(ie,ne,oe,me){if(typeof oe=="object"&&oe!==null&&oe.type===C&&oe.key===null&&(oe=oe.props.children),typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case S:e:{for(var Le=oe.key;ne!==null;){if(ne.key===Le){if(Le=oe.type,Le===C){if(ne.tag===7){a(ie,ne.sibling),me=w(ne,oe.props.children),me.return=ie,ie=me;break e}}else if(ne.elementType===Le||typeof Le=="object"&&Le!==null&&Le.$$typeof===T&&mi(Le)===ne.type){a(ie,ne.sibling),me=w(ne,oe.props),Xs(me,oe),me.return=ie,ie=me;break e}a(ie,ne);break}else n(ie,ne);ne=ne.sibling}oe.type===C?(me=ui(oe.props.children,ie.mode,me,oe.key),me.return=ie,ie=me):(me=po(oe.type,oe.key,oe.props,null,ie.mode,me),Xs(me,oe),me.return=ie,ie=me)}return M(ie);case k:e:{for(Le=oe.key;ne!==null;){if(ne.key===Le)if(ne.tag===4&&ne.stateNode.containerInfo===oe.containerInfo&&ne.stateNode.implementation===oe.implementation){a(ie,ne.sibling),me=w(ne,oe.children||[]),me.return=ie,ie=me;break e}else{a(ie,ne);break}else n(ie,ne);ne=ne.sibling}me=jc(oe,ie.mode,me),me.return=ie,ie=me}return M(ie);case T:return oe=mi(oe),vt(ie,ne,oe,me)}if(I(oe))return je(ie,ne,oe,me);if(Y(oe)){if(Le=Y(oe),typeof Le!="function")throw Error(s(150));return oe=Le.call(oe),Ie(ie,ne,oe,me)}if(typeof oe.then=="function")return vt(ie,ne,_o(oe),me);if(oe.$$typeof===_)return vt(ie,ne,xo(ie,oe),me);So(ie,oe)}return typeof oe=="string"&&oe!==""||typeof oe=="number"||typeof oe=="bigint"?(oe=""+oe,ne!==null&&ne.tag===6?(a(ie,ne.sibling),me=w(ne,oe),me.return=ie,ie=me):(a(ie,ne),me=Ec(oe,ie.mode,me),me.return=ie,ie=me),M(ie)):a(ie,ne)}return function(ie,ne,oe,me){try{Ks=0;var Le=vt(ie,ne,oe,me);return ts=null,Le}catch(Te){if(Te===es||Te===bo)throw Te;var at=_n(29,Te,null,ie.mode);return at.lanes=me,at.return=ie,at}finally{}}}var xi=cp(!0),up=cp(!1),Or=!1;function Hc(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Pc(t,n){t=t.updateQueue,n.updateQueue===t&&(n.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function Br(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function Ir(t,n,a){var d=t.updateQueue;if(d===null)return null;if(d=d.shared,(ut&2)!==0){var w=d.pending;return w===null?n.next=n:(n.next=w.next,w.next=n),d.pending=n,n=fo(t),Vf(t,null,a),n}return ho(t,d,n,a),fo(t)}function Zs(t,n,a){if(n=n.updateQueue,n!==null&&(n=n.shared,(a&4194048)!==0)){var d=n.lanes;d&=t.pendingLanes,a|=d,n.lanes=a,ef(t,a)}}function Fc(t,n){var a=t.updateQueue,d=t.alternate;if(d!==null&&(d=d.updateQueue,a===d)){var w=null,E=null;if(a=a.firstBaseUpdate,a!==null){do{var M={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};E===null?w=E=M:E=E.next=M,a=a.next}while(a!==null);E===null?w=E=n:E=E.next=n}else w=E=n;a={baseState:d.baseState,firstBaseUpdate:w,lastBaseUpdate:E,shared:d.shared,callbacks:d.callbacks},t.updateQueue=a;return}t=a.lastBaseUpdate,t===null?a.firstBaseUpdate=n:t.next=n,a.lastBaseUpdate=n}var Uc=!1;function Qs(){if(Uc){var t=Ji;if(t!==null)throw t}}function Js(t,n,a,d){Uc=!1;var w=t.updateQueue;Or=!1;var E=w.firstBaseUpdate,M=w.lastBaseUpdate,G=w.shared.pending;if(G!==null){w.shared.pending=null;var ee=G,le=ee.next;ee.next=null,M===null?E=le:M.next=le,M=ee;var he=t.alternate;he!==null&&(he=he.updateQueue,G=he.lastBaseUpdate,G!==M&&(G===null?he.firstBaseUpdate=le:G.next=le,he.lastBaseUpdate=ee))}if(E!==null){var xe=w.baseState;M=0,he=le=ee=null,G=E;do{var ce=G.lane&-536870913,ue=ce!==G.lane;if(ue?(Ze&ce)===ce:(d&ce)===ce){ce!==0&&ce===Qi&&(Uc=!0),he!==null&&(he=he.next={lane:0,tag:G.tag,payload:G.payload,callback:null,next:null});e:{var je=t,Ie=G;ce=n;var vt=a;switch(Ie.tag){case 1:if(je=Ie.payload,typeof je=="function"){xe=je.call(vt,xe,ce);break e}xe=je;break e;case 3:je.flags=je.flags&-65537|128;case 0:if(je=Ie.payload,ce=typeof je=="function"?je.call(vt,xe,ce):je,ce==null)break e;xe=m({},xe,ce);break e;case 2:Or=!0}}ce=G.callback,ce!==null&&(t.flags|=64,ue&&(t.flags|=8192),ue=w.callbacks,ue===null?w.callbacks=[ce]:ue.push(ce))}else ue={lane:ce,tag:G.tag,payload:G.payload,callback:G.callback,next:null},he===null?(le=he=ue,ee=xe):he=he.next=ue,M|=ce;if(G=G.next,G===null){if(G=w.shared.pending,G===null)break;ue=G,G=ue.next,ue.next=null,w.lastBaseUpdate=ue,w.shared.pending=null}}while(!0);he===null&&(ee=xe),w.baseState=ee,w.firstBaseUpdate=le,w.lastBaseUpdate=he,E===null&&(w.shared.lanes=0),Ur|=M,t.lanes=M,t.memoizedState=xe}}function dp(t,n){if(typeof t!="function")throw Error(s(191,t));t.call(n)}function hp(t,n){var a=t.callbacks;if(a!==null)for(t.callbacks=null,t=0;t<a.length;t++)dp(a[t],n)}var ns=O(null),wo=O(0);function fp(t,n){t=wr,U(wo,t),U(ns,n),wr=t|n.baseLanes}function $c(){U(wo,wr),U(ns,ns.current)}function qc(){wr=wo.current,W(ns),W(wo)}var Sn=O(null),Pn=null;function zr(t){var n=t.alternate;U(Tt,Tt.current&1),U(Sn,t),Pn===null&&(n===null||ns.current!==null||n.memoizedState!==null)&&(Pn=t)}function Wc(t){U(Tt,Tt.current),U(Sn,t),Pn===null&&(Pn=t)}function pp(t){t.tag===22?(U(Tt,Tt.current),U(Sn,t),Pn===null&&(Pn=t)):Hr()}function Hr(){U(Tt,Tt.current),U(Sn,Sn.current)}function wn(t){W(Sn),Pn===t&&(Pn=null),W(Tt)}var Tt=O(0);function Co(t){for(var n=t;n!==null;){if(n.tag===13){var a=n.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||Zu(a)||Qu(a)))return n}else if(n.tag===19&&(n.memoizedProps.revealOrder==="forwards"||n.memoizedProps.revealOrder==="backwards"||n.memoizedProps.revealOrder==="unstable_legacy-backwards"||n.memoizedProps.revealOrder==="together")){if((n.flags&128)!==0)return n}else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var mr=0,Ue=null,gt=null,Ot=null,ko=!1,rs=!1,vi=!1,Eo=0,ea=0,is=null,Gy=0;function jt(){throw Error(s(321))}function Gc(t,n){if(n===null)return!1;for(var a=0;a<n.length&&a<t.length;a++)if(!yn(t[a],n[a]))return!1;return!0}function Vc(t,n,a,d,w,E){return mr=E,Ue=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,$.H=t===null||t.memoizedState===null?Zp:lu,vi=!1,E=a(d,w),vi=!1,rs&&(E=gp(n,a,d,w)),mp(t),E}function mp(t){$.H=ra;var n=gt!==null&&gt.next!==null;if(mr=0,Ot=gt=Ue=null,ko=!1,ea=0,is=null,n)throw Error(s(300));t===null||Bt||(t=t.dependencies,t!==null&&go(t)&&(Bt=!0))}function gp(t,n,a,d){Ue=t;var w=0;do{if(rs&&(is=null),ea=0,rs=!1,25<=w)throw Error(s(301));if(w+=1,Ot=gt=null,t.updateQueue!=null){var E=t.updateQueue;E.lastEffect=null,E.events=null,E.stores=null,E.memoCache!=null&&(E.memoCache.index=0)}$.H=Qp,E=n(a,d)}while(rs);return E}function Vy(){var t=$.H,n=t.useState()[0];return n=typeof n.then=="function"?ta(n):n,t=t.useState()[0],(gt!==null?gt.memoizedState:null)!==t&&(Ue.flags|=1024),n}function Yc(){var t=Eo!==0;return Eo=0,t}function Kc(t,n,a){n.updateQueue=t.updateQueue,n.flags&=-2053,t.lanes&=~a}function Xc(t){if(ko){for(t=t.memoizedState;t!==null;){var n=t.queue;n!==null&&(n.pending=null),t=t.next}ko=!1}mr=0,Ot=gt=Ue=null,rs=!1,ea=Eo=0,is=null}function on(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ot===null?Ue.memoizedState=Ot=t:Ot=Ot.next=t,Ot}function At(){if(gt===null){var t=Ue.alternate;t=t!==null?t.memoizedState:null}else t=gt.next;var n=Ot===null?Ue.memoizedState:Ot.next;if(n!==null)Ot=n,gt=t;else{if(t===null)throw Ue.alternate===null?Error(s(467)):Error(s(310));gt=t,t={memoizedState:gt.memoizedState,baseState:gt.baseState,baseQueue:gt.baseQueue,queue:gt.queue,next:null},Ot===null?Ue.memoizedState=Ot=t:Ot=Ot.next=t}return Ot}function jo(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ta(t){var n=ea;return ea+=1,is===null&&(is=[]),t=ap(is,t,n),n=Ue,(Ot===null?n.memoizedState:Ot.next)===null&&(n=n.alternate,$.H=n===null||n.memoizedState===null?Zp:lu),t}function No(t){if(t!==null&&typeof t=="object"){if(typeof t.then=="function")return ta(t);if(t.$$typeof===_)return Zt(t)}throw Error(s(438,String(t)))}function Zc(t){var n=null,a=Ue.updateQueue;if(a!==null&&(n=a.memoCache),n==null){var d=Ue.alternate;d!==null&&(d=d.updateQueue,d!==null&&(d=d.memoCache,d!=null&&(n={data:d.data.map(function(w){return w.slice()}),index:0})))}if(n==null&&(n={data:[],index:0}),a===null&&(a=jo(),Ue.updateQueue=a),a.memoCache=n,a=n.data[n.index],a===void 0)for(a=n.data[n.index]=Array(t),d=0;d<t;d++)a[d]=H;return n.index++,a}function gr(t,n){return typeof n=="function"?n(t):n}function To(t){var n=At();return Qc(n,gt,t)}function Qc(t,n,a){var d=t.queue;if(d===null)throw Error(s(311));d.lastRenderedReducer=a;var w=t.baseQueue,E=d.pending;if(E!==null){if(w!==null){var M=w.next;w.next=E.next,E.next=M}n.baseQueue=w=E,d.pending=null}if(E=t.baseState,w===null)t.memoizedState=E;else{n=w.next;var G=M=null,ee=null,le=n,he=!1;do{var xe=le.lane&-536870913;if(xe!==le.lane?(Ze&xe)===xe:(mr&xe)===xe){var ce=le.revertLane;if(ce===0)ee!==null&&(ee=ee.next={lane:0,revertLane:0,gesture:null,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null}),xe===Qi&&(he=!0);else if((mr&ce)===ce){le=le.next,ce===Qi&&(he=!0);continue}else xe={lane:0,revertLane:le.revertLane,gesture:null,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null},ee===null?(G=ee=xe,M=E):ee=ee.next=xe,Ue.lanes|=ce,Ur|=ce;xe=le.action,vi&&a(E,xe),E=le.hasEagerState?le.eagerState:a(E,xe)}else ce={lane:xe,revertLane:le.revertLane,gesture:le.gesture,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null},ee===null?(G=ee=ce,M=E):ee=ee.next=ce,Ue.lanes|=xe,Ur|=xe;le=le.next}while(le!==null&&le!==n);if(ee===null?M=E:ee.next=G,!yn(E,t.memoizedState)&&(Bt=!0,he&&(a=Ji,a!==null)))throw a;t.memoizedState=E,t.baseState=M,t.baseQueue=ee,d.lastRenderedState=E}return w===null&&(d.lanes=0),[t.memoizedState,d.dispatch]}function Jc(t){var n=At(),a=n.queue;if(a===null)throw Error(s(311));a.lastRenderedReducer=t;var d=a.dispatch,w=a.pending,E=n.memoizedState;if(w!==null){a.pending=null;var M=w=w.next;do E=t(E,M.action),M=M.next;while(M!==w);yn(E,n.memoizedState)||(Bt=!0),n.memoizedState=E,n.baseQueue===null&&(n.baseState=E),a.lastRenderedState=E}return[E,d]}function xp(t,n,a){var d=Ue,w=At(),E=nt;if(E){if(a===void 0)throw Error(s(407));a=a()}else a=n();var M=!yn((gt||w).memoizedState,a);if(M&&(w.memoizedState=a,Bt=!0),w=w.queue,nu(yp.bind(null,d,w,t),[t]),w.getSnapshot!==n||M||Ot!==null&&Ot.memoizedState.tag&1){if(d.flags|=2048,ss(9,{destroy:void 0},bp.bind(null,d,w,a,n),null),bt===null)throw Error(s(349));E||(mr&127)!==0||vp(d,n,a)}return a}function vp(t,n,a){t.flags|=16384,t={getSnapshot:n,value:a},n=Ue.updateQueue,n===null?(n=jo(),Ue.updateQueue=n,n.stores=[t]):(a=n.stores,a===null?n.stores=[t]:a.push(t))}function bp(t,n,a,d){n.value=a,n.getSnapshot=d,_p(n)&&Sp(t)}function yp(t,n,a){return a(function(){_p(n)&&Sp(t)})}function _p(t){var n=t.getSnapshot;t=t.value;try{var a=n();return!yn(t,a)}catch{return!0}}function Sp(t){var n=ci(t,2);n!==null&&xn(n,t,2)}function eu(t){var n=on();if(typeof t=="function"){var a=t;if(t=a(),vi){Ct(!0);try{a()}finally{Ct(!1)}}}return n.memoizedState=n.baseState=t,n.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:gr,lastRenderedState:t},n}function wp(t,n,a,d){return t.baseState=a,Qc(t,gt,typeof d=="function"?d:gr)}function Yy(t,n,a,d,w){if(Lo(t))throw Error(s(485));if(t=n.action,t!==null){var E={payload:w,action:t,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(M){E.listeners.push(M)}};$.T!==null?a(!0):E.isTransition=!1,d(E),a=n.pending,a===null?(E.next=n.pending=E,Cp(n,E)):(E.next=a.next,n.pending=a.next=E)}}function Cp(t,n){var a=n.action,d=n.payload,w=t.state;if(n.isTransition){var E=$.T,M={};$.T=M;try{var G=a(w,d),ee=$.S;ee!==null&&ee(M,G),kp(t,n,G)}catch(le){tu(t,n,le)}finally{E!==null&&M.types!==null&&(E.types=M.types),$.T=E}}else try{E=a(w,d),kp(t,n,E)}catch(le){tu(t,n,le)}}function kp(t,n,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(d){Ep(t,n,d)},function(d){return tu(t,n,d)}):Ep(t,n,a)}function Ep(t,n,a){n.status="fulfilled",n.value=a,jp(n),t.state=a,n=t.pending,n!==null&&(a=n.next,a===n?t.pending=null:(a=a.next,n.next=a,Cp(t,a)))}function tu(t,n,a){var d=t.pending;if(t.pending=null,d!==null){d=d.next;do n.status="rejected",n.reason=a,jp(n),n=n.next;while(n!==d)}t.action=null}function jp(t){t=t.listeners;for(var n=0;n<t.length;n++)(0,t[n])()}function Np(t,n){return n}function Tp(t,n){if(nt){var a=bt.formState;if(a!==null){e:{var d=Ue;if(nt){if(St){t:{for(var w=St,E=Hn;w.nodeType!==8;){if(!E){w=null;break t}if(w=Fn(w.nextSibling),w===null){w=null;break t}}E=w.data,w=E==="F!"||E==="F"?w:null}if(w){St=Fn(w.nextSibling),d=w.data==="F!";break e}}Rr(d)}d=!1}d&&(n=a[0])}}return a=on(),a.memoizedState=a.baseState=n,d={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Np,lastRenderedState:n},a.queue=d,a=Yp.bind(null,Ue,d),d.dispatch=a,d=eu(!1),E=ou.bind(null,Ue,!1,d.queue),d=on(),w={state:n,dispatch:null,action:t,pending:null},d.queue=w,a=Yy.bind(null,Ue,w,E,a),w.dispatch=a,d.memoizedState=t,[n,a,!1]}function Ap(t){var n=At();return Dp(n,gt,t)}function Dp(t,n,a){if(n=Qc(t,n,Np)[0],t=To(gr)[0],typeof n=="object"&&n!==null&&typeof n.then=="function")try{var d=ta(n)}catch(M){throw M===es?bo:M}else d=n;n=At();var w=n.queue,E=w.dispatch;return a!==n.memoizedState&&(Ue.flags|=2048,ss(9,{destroy:void 0},Ky.bind(null,w,a),null)),[d,E,t]}function Ky(t,n){t.action=n}function Lp(t){var n=At(),a=gt;if(a!==null)return Dp(n,a,t);At(),n=n.memoizedState,a=At();var d=a.queue.dispatch;return a.memoizedState=t,[n,d,!1]}function ss(t,n,a,d){return t={tag:t,create:a,deps:d,inst:n,next:null},n=Ue.updateQueue,n===null&&(n=jo(),Ue.updateQueue=n),a=n.lastEffect,a===null?n.lastEffect=t.next=t:(d=a.next,a.next=t,t.next=d,n.lastEffect=t),t}function Rp(){return At().memoizedState}function Ao(t,n,a,d){var w=on();Ue.flags|=t,w.memoizedState=ss(1|n,{destroy:void 0},a,d===void 0?null:d)}function Do(t,n,a,d){var w=At();d=d===void 0?null:d;var E=w.memoizedState.inst;gt!==null&&d!==null&&Gc(d,gt.memoizedState.deps)?w.memoizedState=ss(n,E,a,d):(Ue.flags|=t,w.memoizedState=ss(1|n,E,a,d))}function Mp(t,n){Ao(8390656,8,t,n)}function nu(t,n){Do(2048,8,t,n)}function Xy(t){Ue.flags|=4;var n=Ue.updateQueue;if(n===null)n=jo(),Ue.updateQueue=n,n.events=[t];else{var a=n.events;a===null?n.events=[t]:a.push(t)}}function Op(t){var n=At().memoizedState;return Xy({ref:n,nextImpl:t}),function(){if((ut&2)!==0)throw Error(s(440));return n.impl.apply(void 0,arguments)}}function Bp(t,n){return Do(4,2,t,n)}function Ip(t,n){return Do(4,4,t,n)}function zp(t,n){if(typeof n=="function"){t=t();var a=n(t);return function(){typeof a=="function"?a():n(null)}}if(n!=null)return t=t(),n.current=t,function(){n.current=null}}function Hp(t,n,a){a=a!=null?a.concat([t]):null,Do(4,4,zp.bind(null,n,t),a)}function ru(){}function Pp(t,n){var a=At();n=n===void 0?null:n;var d=a.memoizedState;return n!==null&&Gc(n,d[1])?d[0]:(a.memoizedState=[t,n],t)}function Fp(t,n){var a=At();n=n===void 0?null:n;var d=a.memoizedState;if(n!==null&&Gc(n,d[1]))return d[0];if(d=t(),vi){Ct(!0);try{t()}finally{Ct(!1)}}return a.memoizedState=[d,n],d}function iu(t,n,a){return a===void 0||(mr&1073741824)!==0&&(Ze&261930)===0?t.memoizedState=n:(t.memoizedState=a,t=Um(),Ue.lanes|=t,Ur|=t,a)}function Up(t,n,a,d){return yn(a,n)?a:ns.current!==null?(t=iu(t,a,d),yn(t,n)||(Bt=!0),t):(mr&42)===0||(mr&1073741824)!==0&&(Ze&261930)===0?(Bt=!0,t.memoizedState=a):(t=Um(),Ue.lanes|=t,Ur|=t,n)}function $p(t,n,a,d,w){var E=X.p;X.p=E!==0&&8>E?E:8;var M=$.T,G={};$.T=G,ou(t,!1,n,a);try{var ee=w(),le=$.S;if(le!==null&&le(G,ee),ee!==null&&typeof ee=="object"&&typeof ee.then=="function"){var he=Wy(ee,d);na(t,n,he,En(t))}else na(t,n,d,En(t))}catch(xe){na(t,n,{then:function(){},status:"rejected",reason:xe},En())}finally{X.p=E,M!==null&&G.types!==null&&(M.types=G.types),$.T=M}}function Zy(){}function su(t,n,a,d){if(t.tag!==5)throw Error(s(476));var w=qp(t).queue;$p(t,w,n,J,a===null?Zy:function(){return Wp(t),a(d)})}function qp(t){var n=t.memoizedState;if(n!==null)return n;n={memoizedState:J,baseState:J,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:gr,lastRenderedState:J},next:null};var a={};return n.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:gr,lastRenderedState:a},next:null},t.memoizedState=n,t=t.alternate,t!==null&&(t.memoizedState=n),n}function Wp(t){var n=qp(t);n.next===null&&(n=t.alternate.memoizedState),na(t,n.next.queue,{},En())}function au(){return Zt(ba)}function Gp(){return At().memoizedState}function Vp(){return At().memoizedState}function Qy(t){for(var n=t.return;n!==null;){switch(n.tag){case 24:case 3:var a=En();t=Br(a);var d=Ir(n,t,a);d!==null&&(xn(d,n,a),Zs(d,n,a)),n={cache:Oc()},t.payload=n;return}n=n.return}}function Jy(t,n,a){var d=En();a={lane:d,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Lo(t)?Kp(n,a):(a=Cc(t,n,a,d),a!==null&&(xn(a,t,d),Xp(a,n,d)))}function Yp(t,n,a){var d=En();na(t,n,a,d)}function na(t,n,a,d){var w={lane:d,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Lo(t))Kp(n,w);else{var E=t.alternate;if(t.lanes===0&&(E===null||E.lanes===0)&&(E=n.lastRenderedReducer,E!==null))try{var M=n.lastRenderedState,G=E(M,a);if(w.hasEagerState=!0,w.eagerState=G,yn(G,M))return ho(t,n,w,0),bt===null&&uo(),!1}catch{}finally{}if(a=Cc(t,n,w,d),a!==null)return xn(a,t,d),Xp(a,n,d),!0}return!1}function ou(t,n,a,d){if(d={lane:2,revertLane:Hu(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Lo(t)){if(n)throw Error(s(479))}else n=Cc(t,a,d,2),n!==null&&xn(n,t,2)}function Lo(t){var n=t.alternate;return t===Ue||n!==null&&n===Ue}function Kp(t,n){rs=ko=!0;var a=t.pending;a===null?n.next=n:(n.next=a.next,a.next=n),t.pending=n}function Xp(t,n,a){if((a&4194048)!==0){var d=n.lanes;d&=t.pendingLanes,a|=d,n.lanes=a,ef(t,a)}}var ra={readContext:Zt,use:No,useCallback:jt,useContext:jt,useEffect:jt,useImperativeHandle:jt,useLayoutEffect:jt,useInsertionEffect:jt,useMemo:jt,useReducer:jt,useRef:jt,useState:jt,useDebugValue:jt,useDeferredValue:jt,useTransition:jt,useSyncExternalStore:jt,useId:jt,useHostTransitionStatus:jt,useFormState:jt,useActionState:jt,useOptimistic:jt,useMemoCache:jt,useCacheRefresh:jt};ra.useEffectEvent=jt;var Zp={readContext:Zt,use:No,useCallback:function(t,n){return on().memoizedState=[t,n===void 0?null:n],t},useContext:Zt,useEffect:Mp,useImperativeHandle:function(t,n,a){a=a!=null?a.concat([t]):null,Ao(4194308,4,zp.bind(null,n,t),a)},useLayoutEffect:function(t,n){return Ao(4194308,4,t,n)},useInsertionEffect:function(t,n){Ao(4,2,t,n)},useMemo:function(t,n){var a=on();n=n===void 0?null:n;var d=t();if(vi){Ct(!0);try{t()}finally{Ct(!1)}}return a.memoizedState=[d,n],d},useReducer:function(t,n,a){var d=on();if(a!==void 0){var w=a(n);if(vi){Ct(!0);try{a(n)}finally{Ct(!1)}}}else w=n;return d.memoizedState=d.baseState=w,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:w},d.queue=t,t=t.dispatch=Jy.bind(null,Ue,t),[d.memoizedState,t]},useRef:function(t){var n=on();return t={current:t},n.memoizedState=t},useState:function(t){t=eu(t);var n=t.queue,a=Yp.bind(null,Ue,n);return n.dispatch=a,[t.memoizedState,a]},useDebugValue:ru,useDeferredValue:function(t,n){var a=on();return iu(a,t,n)},useTransition:function(){var t=eu(!1);return t=$p.bind(null,Ue,t.queue,!0,!1),on().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,n,a){var d=Ue,w=on();if(nt){if(a===void 0)throw Error(s(407));a=a()}else{if(a=n(),bt===null)throw Error(s(349));(Ze&127)!==0||vp(d,n,a)}w.memoizedState=a;var E={value:a,getSnapshot:n};return w.queue=E,Mp(yp.bind(null,d,E,t),[t]),d.flags|=2048,ss(9,{destroy:void 0},bp.bind(null,d,E,a,n),null),a},useId:function(){var t=on(),n=bt.identifierPrefix;if(nt){var a=Qn,d=Zn;a=(d&~(1<<32-$e(d)-1)).toString(32)+a,n="_"+n+"R_"+a,a=Eo++,0<a&&(n+="H"+a.toString(32)),n+="_"}else a=Gy++,n="_"+n+"r_"+a.toString(32)+"_";return t.memoizedState=n},useHostTransitionStatus:au,useFormState:Tp,useActionState:Tp,useOptimistic:function(t){var n=on();n.memoizedState=n.baseState=t;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=a,n=ou.bind(null,Ue,!0,a),a.dispatch=n,[t,n]},useMemoCache:Zc,useCacheRefresh:function(){return on().memoizedState=Qy.bind(null,Ue)},useEffectEvent:function(t){var n=on(),a={impl:t};return n.memoizedState=a,function(){if((ut&2)!==0)throw Error(s(440));return a.impl.apply(void 0,arguments)}}},lu={readContext:Zt,use:No,useCallback:Pp,useContext:Zt,useEffect:nu,useImperativeHandle:Hp,useInsertionEffect:Bp,useLayoutEffect:Ip,useMemo:Fp,useReducer:To,useRef:Rp,useState:function(){return To(gr)},useDebugValue:ru,useDeferredValue:function(t,n){var a=At();return Up(a,gt.memoizedState,t,n)},useTransition:function(){var t=To(gr)[0],n=At().memoizedState;return[typeof t=="boolean"?t:ta(t),n]},useSyncExternalStore:xp,useId:Gp,useHostTransitionStatus:au,useFormState:Ap,useActionState:Ap,useOptimistic:function(t,n){var a=At();return wp(a,gt,t,n)},useMemoCache:Zc,useCacheRefresh:Vp};lu.useEffectEvent=Op;var Qp={readContext:Zt,use:No,useCallback:Pp,useContext:Zt,useEffect:nu,useImperativeHandle:Hp,useInsertionEffect:Bp,useLayoutEffect:Ip,useMemo:Fp,useReducer:Jc,useRef:Rp,useState:function(){return Jc(gr)},useDebugValue:ru,useDeferredValue:function(t,n){var a=At();return gt===null?iu(a,t,n):Up(a,gt.memoizedState,t,n)},useTransition:function(){var t=Jc(gr)[0],n=At().memoizedState;return[typeof t=="boolean"?t:ta(t),n]},useSyncExternalStore:xp,useId:Gp,useHostTransitionStatus:au,useFormState:Lp,useActionState:Lp,useOptimistic:function(t,n){var a=At();return gt!==null?wp(a,gt,t,n):(a.baseState=t,[t,a.queue.dispatch])},useMemoCache:Zc,useCacheRefresh:Vp};Qp.useEffectEvent=Op;function cu(t,n,a,d){n=t.memoizedState,a=a(d,n),a=a==null?n:m({},n,a),t.memoizedState=a,t.lanes===0&&(t.updateQueue.baseState=a)}var uu={enqueueSetState:function(t,n,a){t=t._reactInternals;var d=En(),w=Br(d);w.payload=n,a!=null&&(w.callback=a),n=Ir(t,w,d),n!==null&&(xn(n,t,d),Zs(n,t,d))},enqueueReplaceState:function(t,n,a){t=t._reactInternals;var d=En(),w=Br(d);w.tag=1,w.payload=n,a!=null&&(w.callback=a),n=Ir(t,w,d),n!==null&&(xn(n,t,d),Zs(n,t,d))},enqueueForceUpdate:function(t,n){t=t._reactInternals;var a=En(),d=Br(a);d.tag=2,n!=null&&(d.callback=n),n=Ir(t,d,a),n!==null&&(xn(n,t,a),Zs(n,t,a))}};function Jp(t,n,a,d,w,E,M){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(d,E,M):n.prototype&&n.prototype.isPureReactComponent?!$s(a,d)||!$s(w,E):!0}function em(t,n,a,d){t=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(a,d),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(a,d),n.state!==t&&uu.enqueueReplaceState(n,n.state,null)}function bi(t,n){var a=n;if("ref"in n){a={};for(var d in n)d!=="ref"&&(a[d]=n[d])}if(t=t.defaultProps){a===n&&(a=m({},a));for(var w in t)a[w]===void 0&&(a[w]=t[w])}return a}function tm(t){co(t)}function nm(t){console.error(t)}function rm(t){co(t)}function Ro(t,n){try{var a=t.onUncaughtError;a(n.value,{componentStack:n.stack})}catch(d){setTimeout(function(){throw d})}}function im(t,n,a){try{var d=t.onCaughtError;d(a.value,{componentStack:a.stack,errorBoundary:n.tag===1?n.stateNode:null})}catch(w){setTimeout(function(){throw w})}}function du(t,n,a){return a=Br(a),a.tag=3,a.payload={element:null},a.callback=function(){Ro(t,n)},a}function sm(t){return t=Br(t),t.tag=3,t}function am(t,n,a,d){var w=a.type.getDerivedStateFromError;if(typeof w=="function"){var E=d.value;t.payload=function(){return w(E)},t.callback=function(){im(n,a,d)}}var M=a.stateNode;M!==null&&typeof M.componentDidCatch=="function"&&(t.callback=function(){im(n,a,d),typeof w!="function"&&($r===null?$r=new Set([this]):$r.add(this));var G=d.stack;this.componentDidCatch(d.value,{componentStack:G!==null?G:""})})}function e_(t,n,a,d,w){if(a.flags|=32768,d!==null&&typeof d=="object"&&typeof d.then=="function"){if(n=a.alternate,n!==null&&Zi(n,a,w,!0),a=Sn.current,a!==null){switch(a.tag){case 31:case 13:return Pn===null?Wo():a.alternate===null&&Nt===0&&(Nt=3),a.flags&=-257,a.flags|=65536,a.lanes=w,d===yo?a.flags|=16384:(n=a.updateQueue,n===null?a.updateQueue=new Set([d]):n.add(d),Bu(t,d,w)),!1;case 22:return a.flags|=65536,d===yo?a.flags|=16384:(n=a.updateQueue,n===null?(n={transitions:null,markerInstances:null,retryQueue:new Set([d])},a.updateQueue=n):(a=n.retryQueue,a===null?n.retryQueue=new Set([d]):a.add(d)),Bu(t,d,w)),!1}throw Error(s(435,a.tag))}return Bu(t,d,w),Wo(),!1}if(nt)return n=Sn.current,n!==null?((n.flags&65536)===0&&(n.flags|=256),n.flags|=65536,n.lanes=w,d!==Ac&&(t=Error(s(422),{cause:d}),Gs(Bn(t,a)))):(d!==Ac&&(n=Error(s(423),{cause:d}),Gs(Bn(n,a))),t=t.current.alternate,t.flags|=65536,w&=-w,t.lanes|=w,d=Bn(d,a),w=du(t.stateNode,d,w),Fc(t,w),Nt!==4&&(Nt=2)),!1;var E=Error(s(520),{cause:d});if(E=Bn(E,a),da===null?da=[E]:da.push(E),Nt!==4&&(Nt=2),n===null)return!0;d=Bn(d,a),a=n;do{switch(a.tag){case 3:return a.flags|=65536,t=w&-w,a.lanes|=t,t=du(a.stateNode,d,t),Fc(a,t),!1;case 1:if(n=a.type,E=a.stateNode,(a.flags&128)===0&&(typeof n.getDerivedStateFromError=="function"||E!==null&&typeof E.componentDidCatch=="function"&&($r===null||!$r.has(E))))return a.flags|=65536,w&=-w,a.lanes|=w,w=sm(w),am(w,t,a,d),Fc(a,w),!1}a=a.return}while(a!==null);return!1}var hu=Error(s(461)),Bt=!1;function Qt(t,n,a,d){n.child=t===null?up(n,null,a,d):xi(n,t.child,a,d)}function om(t,n,a,d,w){a=a.render;var E=n.ref;if("ref"in d){var M={};for(var G in d)G!=="ref"&&(M[G]=d[G])}else M=d;return fi(n),d=Vc(t,n,a,M,E,w),G=Yc(),t!==null&&!Bt?(Kc(t,n,w),xr(t,n,w)):(nt&&G&&Nc(n),n.flags|=1,Qt(t,n,d,w),n.child)}function lm(t,n,a,d,w){if(t===null){var E=a.type;return typeof E=="function"&&!kc(E)&&E.defaultProps===void 0&&a.compare===null?(n.tag=15,n.type=E,cm(t,n,E,d,w)):(t=po(a.type,null,d,n,n.mode,w),t.ref=n.ref,t.return=n,n.child=t)}if(E=t.child,!yu(t,w)){var M=E.memoizedProps;if(a=a.compare,a=a!==null?a:$s,a(M,d)&&t.ref===n.ref)return xr(t,n,w)}return n.flags|=1,t=dr(E,d),t.ref=n.ref,t.return=n,n.child=t}function cm(t,n,a,d,w){if(t!==null){var E=t.memoizedProps;if($s(E,d)&&t.ref===n.ref)if(Bt=!1,n.pendingProps=d=E,yu(t,w))(t.flags&131072)!==0&&(Bt=!0);else return n.lanes=t.lanes,xr(t,n,w)}return fu(t,n,a,d,w)}function um(t,n,a,d){var w=d.children,E=t!==null?t.memoizedState:null;if(t===null&&n.stateNode===null&&(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),d.mode==="hidden"){if((n.flags&128)!==0){if(E=E!==null?E.baseLanes|a:a,t!==null){for(d=n.child=t.child,w=0;d!==null;)w=w|d.lanes|d.childLanes,d=d.sibling;d=w&~E}else d=0,n.child=null;return dm(t,n,E,a,d)}if((a&536870912)!==0)n.memoizedState={baseLanes:0,cachePool:null},t!==null&&vo(n,E!==null?E.cachePool:null),E!==null?fp(n,E):$c(),pp(n);else return d=n.lanes=536870912,dm(t,n,E!==null?E.baseLanes|a:a,a,d)}else E!==null?(vo(n,E.cachePool),fp(n,E),Hr(),n.memoizedState=null):(t!==null&&vo(n,null),$c(),Hr());return Qt(t,n,w,a),n.child}function ia(t,n){return t!==null&&t.tag===22||n.stateNode!==null||(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),n.sibling}function dm(t,n,a,d,w){var E=Ic();return E=E===null?null:{parent:Mt._currentValue,pool:E},n.memoizedState={baseLanes:a,cachePool:E},t!==null&&vo(n,null),$c(),pp(n),t!==null&&Zi(t,n,d,!0),n.childLanes=w,null}function Mo(t,n){return n=Bo({mode:n.mode,children:n.children},t.mode),n.ref=t.ref,t.child=n,n.return=t,n}function hm(t,n,a){return xi(n,t.child,null,a),t=Mo(n,n.pendingProps),t.flags|=2,wn(n),n.memoizedState=null,t}function t_(t,n,a){var d=n.pendingProps,w=(n.flags&128)!==0;if(n.flags&=-129,t===null){if(nt){if(d.mode==="hidden")return t=Mo(n,d),n.lanes=536870912,ia(null,t);if(Wc(n),(t=St)?(t=Cg(t,Hn),t=t!==null&&t.data==="&"?t:null,t!==null&&(n.memoizedState={dehydrated:t,treeContext:Dr!==null?{id:Zn,overflow:Qn}:null,retryLane:536870912,hydrationErrors:null},a=Kf(t),a.return=n,n.child=a,Xt=n,St=null)):t=null,t===null)throw Rr(n);return n.lanes=536870912,null}return Mo(n,d)}var E=t.memoizedState;if(E!==null){var M=E.dehydrated;if(Wc(n),w)if(n.flags&256)n.flags&=-257,n=hm(t,n,a);else if(n.memoizedState!==null)n.child=t.child,n.flags|=128,n=null;else throw Error(s(558));else if(Bt||Zi(t,n,a,!1),w=(a&t.childLanes)!==0,Bt||w){if(d=bt,d!==null&&(M=tf(d,a),M!==0&&M!==E.retryLane))throw E.retryLane=M,ci(t,M),xn(d,t,M),hu;Wo(),n=hm(t,n,a)}else t=E.treeContext,St=Fn(M.nextSibling),Xt=n,nt=!0,Lr=null,Hn=!1,t!==null&&Qf(n,t),n=Mo(n,d),n.flags|=4096;return n}return t=dr(t.child,{mode:d.mode,children:d.children}),t.ref=n.ref,n.child=t,t.return=n,t}function Oo(t,n){var a=n.ref;if(a===null)t!==null&&t.ref!==null&&(n.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(s(284));(t===null||t.ref!==a)&&(n.flags|=4194816)}}function fu(t,n,a,d,w){return fi(n),a=Vc(t,n,a,d,void 0,w),d=Yc(),t!==null&&!Bt?(Kc(t,n,w),xr(t,n,w)):(nt&&d&&Nc(n),n.flags|=1,Qt(t,n,a,w),n.child)}function fm(t,n,a,d,w,E){return fi(n),n.updateQueue=null,a=gp(n,d,a,w),mp(t),d=Yc(),t!==null&&!Bt?(Kc(t,n,E),xr(t,n,E)):(nt&&d&&Nc(n),n.flags|=1,Qt(t,n,a,E),n.child)}function pm(t,n,a,d,w){if(fi(n),n.stateNode===null){var E=Vi,M=a.contextType;typeof M=="object"&&M!==null&&(E=Zt(M)),E=new a(d,E),n.memoizedState=E.state!==null&&E.state!==void 0?E.state:null,E.updater=uu,n.stateNode=E,E._reactInternals=n,E=n.stateNode,E.props=d,E.state=n.memoizedState,E.refs={},Hc(n),M=a.contextType,E.context=typeof M=="object"&&M!==null?Zt(M):Vi,E.state=n.memoizedState,M=a.getDerivedStateFromProps,typeof M=="function"&&(cu(n,a,M,d),E.state=n.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof E.getSnapshotBeforeUpdate=="function"||typeof E.UNSAFE_componentWillMount!="function"&&typeof E.componentWillMount!="function"||(M=E.state,typeof E.componentWillMount=="function"&&E.componentWillMount(),typeof E.UNSAFE_componentWillMount=="function"&&E.UNSAFE_componentWillMount(),M!==E.state&&uu.enqueueReplaceState(E,E.state,null),Js(n,d,E,w),Qs(),E.state=n.memoizedState),typeof E.componentDidMount=="function"&&(n.flags|=4194308),d=!0}else if(t===null){E=n.stateNode;var G=n.memoizedProps,ee=bi(a,G);E.props=ee;var le=E.context,he=a.contextType;M=Vi,typeof he=="object"&&he!==null&&(M=Zt(he));var xe=a.getDerivedStateFromProps;he=typeof xe=="function"||typeof E.getSnapshotBeforeUpdate=="function",G=n.pendingProps!==G,he||typeof E.UNSAFE_componentWillReceiveProps!="function"&&typeof E.componentWillReceiveProps!="function"||(G||le!==M)&&em(n,E,d,M),Or=!1;var ce=n.memoizedState;E.state=ce,Js(n,d,E,w),Qs(),le=n.memoizedState,G||ce!==le||Or?(typeof xe=="function"&&(cu(n,a,xe,d),le=n.memoizedState),(ee=Or||Jp(n,a,ee,d,ce,le,M))?(he||typeof E.UNSAFE_componentWillMount!="function"&&typeof E.componentWillMount!="function"||(typeof E.componentWillMount=="function"&&E.componentWillMount(),typeof E.UNSAFE_componentWillMount=="function"&&E.UNSAFE_componentWillMount()),typeof E.componentDidMount=="function"&&(n.flags|=4194308)):(typeof E.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=d,n.memoizedState=le),E.props=d,E.state=le,E.context=M,d=ee):(typeof E.componentDidMount=="function"&&(n.flags|=4194308),d=!1)}else{E=n.stateNode,Pc(t,n),M=n.memoizedProps,he=bi(a,M),E.props=he,xe=n.pendingProps,ce=E.context,le=a.contextType,ee=Vi,typeof le=="object"&&le!==null&&(ee=Zt(le)),G=a.getDerivedStateFromProps,(le=typeof G=="function"||typeof E.getSnapshotBeforeUpdate=="function")||typeof E.UNSAFE_componentWillReceiveProps!="function"&&typeof E.componentWillReceiveProps!="function"||(M!==xe||ce!==ee)&&em(n,E,d,ee),Or=!1,ce=n.memoizedState,E.state=ce,Js(n,d,E,w),Qs();var ue=n.memoizedState;M!==xe||ce!==ue||Or||t!==null&&t.dependencies!==null&&go(t.dependencies)?(typeof G=="function"&&(cu(n,a,G,d),ue=n.memoizedState),(he=Or||Jp(n,a,he,d,ce,ue,ee)||t!==null&&t.dependencies!==null&&go(t.dependencies))?(le||typeof E.UNSAFE_componentWillUpdate!="function"&&typeof E.componentWillUpdate!="function"||(typeof E.componentWillUpdate=="function"&&E.componentWillUpdate(d,ue,ee),typeof E.UNSAFE_componentWillUpdate=="function"&&E.UNSAFE_componentWillUpdate(d,ue,ee)),typeof E.componentDidUpdate=="function"&&(n.flags|=4),typeof E.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof E.componentDidUpdate!="function"||M===t.memoizedProps&&ce===t.memoizedState||(n.flags|=4),typeof E.getSnapshotBeforeUpdate!="function"||M===t.memoizedProps&&ce===t.memoizedState||(n.flags|=1024),n.memoizedProps=d,n.memoizedState=ue),E.props=d,E.state=ue,E.context=ee,d=he):(typeof E.componentDidUpdate!="function"||M===t.memoizedProps&&ce===t.memoizedState||(n.flags|=4),typeof E.getSnapshotBeforeUpdate!="function"||M===t.memoizedProps&&ce===t.memoizedState||(n.flags|=1024),d=!1)}return E=d,Oo(t,n),d=(n.flags&128)!==0,E||d?(E=n.stateNode,a=d&&typeof a.getDerivedStateFromError!="function"?null:E.render(),n.flags|=1,t!==null&&d?(n.child=xi(n,t.child,null,w),n.child=xi(n,null,a,w)):Qt(t,n,a,w),n.memoizedState=E.state,t=n.child):t=xr(t,n,w),t}function mm(t,n,a,d){return di(),n.flags|=256,Qt(t,n,a,d),n.child}var pu={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function mu(t){return{baseLanes:t,cachePool:ip()}}function gu(t,n,a){return t=t!==null?t.childLanes&~a:0,n&&(t|=kn),t}function gm(t,n,a){var d=n.pendingProps,w=!1,E=(n.flags&128)!==0,M;if((M=E)||(M=t!==null&&t.memoizedState===null?!1:(Tt.current&2)!==0),M&&(w=!0,n.flags&=-129),M=(n.flags&32)!==0,n.flags&=-33,t===null){if(nt){if(w?zr(n):Hr(),(t=St)?(t=Cg(t,Hn),t=t!==null&&t.data!=="&"?t:null,t!==null&&(n.memoizedState={dehydrated:t,treeContext:Dr!==null?{id:Zn,overflow:Qn}:null,retryLane:536870912,hydrationErrors:null},a=Kf(t),a.return=n,n.child=a,Xt=n,St=null)):t=null,t===null)throw Rr(n);return Qu(t)?n.lanes=32:n.lanes=536870912,null}var G=d.children;return d=d.fallback,w?(Hr(),w=n.mode,G=Bo({mode:"hidden",children:G},w),d=ui(d,w,a,null),G.return=n,d.return=n,G.sibling=d,n.child=G,d=n.child,d.memoizedState=mu(a),d.childLanes=gu(t,M,a),n.memoizedState=pu,ia(null,d)):(zr(n),xu(n,G))}var ee=t.memoizedState;if(ee!==null&&(G=ee.dehydrated,G!==null)){if(E)n.flags&256?(zr(n),n.flags&=-257,n=vu(t,n,a)):n.memoizedState!==null?(Hr(),n.child=t.child,n.flags|=128,n=null):(Hr(),G=d.fallback,w=n.mode,d=Bo({mode:"visible",children:d.children},w),G=ui(G,w,a,null),G.flags|=2,d.return=n,G.return=n,d.sibling=G,n.child=d,xi(n,t.child,null,a),d=n.child,d.memoizedState=mu(a),d.childLanes=gu(t,M,a),n.memoizedState=pu,n=ia(null,d));else if(zr(n),Qu(G)){if(M=G.nextSibling&&G.nextSibling.dataset,M)var le=M.dgst;M=le,d=Error(s(419)),d.stack="",d.digest=M,Gs({value:d,source:null,stack:null}),n=vu(t,n,a)}else if(Bt||Zi(t,n,a,!1),M=(a&t.childLanes)!==0,Bt||M){if(M=bt,M!==null&&(d=tf(M,a),d!==0&&d!==ee.retryLane))throw ee.retryLane=d,ci(t,d),xn(M,t,d),hu;Zu(G)||Wo(),n=vu(t,n,a)}else Zu(G)?(n.flags|=192,n.child=t.child,n=null):(t=ee.treeContext,St=Fn(G.nextSibling),Xt=n,nt=!0,Lr=null,Hn=!1,t!==null&&Qf(n,t),n=xu(n,d.children),n.flags|=4096);return n}return w?(Hr(),G=d.fallback,w=n.mode,ee=t.child,le=ee.sibling,d=dr(ee,{mode:"hidden",children:d.children}),d.subtreeFlags=ee.subtreeFlags&65011712,le!==null?G=dr(le,G):(G=ui(G,w,a,null),G.flags|=2),G.return=n,d.return=n,d.sibling=G,n.child=d,ia(null,d),d=n.child,G=t.child.memoizedState,G===null?G=mu(a):(w=G.cachePool,w!==null?(ee=Mt._currentValue,w=w.parent!==ee?{parent:ee,pool:ee}:w):w=ip(),G={baseLanes:G.baseLanes|a,cachePool:w}),d.memoizedState=G,d.childLanes=gu(t,M,a),n.memoizedState=pu,ia(t.child,d)):(zr(n),a=t.child,t=a.sibling,a=dr(a,{mode:"visible",children:d.children}),a.return=n,a.sibling=null,t!==null&&(M=n.deletions,M===null?(n.deletions=[t],n.flags|=16):M.push(t)),n.child=a,n.memoizedState=null,a)}function xu(t,n){return n=Bo({mode:"visible",children:n},t.mode),n.return=t,t.child=n}function Bo(t,n){return t=_n(22,t,null,n),t.lanes=0,t}function vu(t,n,a){return xi(n,t.child,null,a),t=xu(n,n.pendingProps.children),t.flags|=2,n.memoizedState=null,t}function xm(t,n,a){t.lanes|=n;var d=t.alternate;d!==null&&(d.lanes|=n),Rc(t.return,n,a)}function bu(t,n,a,d,w,E){var M=t.memoizedState;M===null?t.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:d,tail:a,tailMode:w,treeForkCount:E}:(M.isBackwards=n,M.rendering=null,M.renderingStartTime=0,M.last=d,M.tail=a,M.tailMode=w,M.treeForkCount=E)}function vm(t,n,a){var d=n.pendingProps,w=d.revealOrder,E=d.tail;d=d.children;var M=Tt.current,G=(M&2)!==0;if(G?(M=M&1|2,n.flags|=128):M&=1,U(Tt,M),Qt(t,n,d,a),d=nt?Ws:0,!G&&t!==null&&(t.flags&128)!==0)e:for(t=n.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&xm(t,a,n);else if(t.tag===19)xm(t,a,n);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===n)break e;for(;t.sibling===null;){if(t.return===null||t.return===n)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}switch(w){case"forwards":for(a=n.child,w=null;a!==null;)t=a.alternate,t!==null&&Co(t)===null&&(w=a),a=a.sibling;a=w,a===null?(w=n.child,n.child=null):(w=a.sibling,a.sibling=null),bu(n,!1,w,a,E,d);break;case"backwards":case"unstable_legacy-backwards":for(a=null,w=n.child,n.child=null;w!==null;){if(t=w.alternate,t!==null&&Co(t)===null){n.child=w;break}t=w.sibling,w.sibling=a,a=w,w=t}bu(n,!0,a,null,E,d);break;case"together":bu(n,!1,null,null,void 0,d);break;default:n.memoizedState=null}return n.child}function xr(t,n,a){if(t!==null&&(n.dependencies=t.dependencies),Ur|=n.lanes,(a&n.childLanes)===0)if(t!==null){if(Zi(t,n,a,!1),(a&n.childLanes)===0)return null}else return null;if(t!==null&&n.child!==t.child)throw Error(s(153));if(n.child!==null){for(t=n.child,a=dr(t,t.pendingProps),n.child=a,a.return=n;t.sibling!==null;)t=t.sibling,a=a.sibling=dr(t,t.pendingProps),a.return=n;a.sibling=null}return n.child}function yu(t,n){return(t.lanes&n)!==0?!0:(t=t.dependencies,!!(t!==null&&go(t)))}function n_(t,n,a){switch(n.tag){case 3:z(n,n.stateNode.containerInfo),Mr(n,Mt,t.memoizedState.cache),di();break;case 27:case 5:se(n);break;case 4:z(n,n.stateNode.containerInfo);break;case 10:Mr(n,n.type,n.memoizedProps.value);break;case 31:if(n.memoizedState!==null)return n.flags|=128,Wc(n),null;break;case 13:var d=n.memoizedState;if(d!==null)return d.dehydrated!==null?(zr(n),n.flags|=128,null):(a&n.child.childLanes)!==0?gm(t,n,a):(zr(n),t=xr(t,n,a),t!==null?t.sibling:null);zr(n);break;case 19:var w=(t.flags&128)!==0;if(d=(a&n.childLanes)!==0,d||(Zi(t,n,a,!1),d=(a&n.childLanes)!==0),w){if(d)return vm(t,n,a);n.flags|=128}if(w=n.memoizedState,w!==null&&(w.rendering=null,w.tail=null,w.lastEffect=null),U(Tt,Tt.current),d)break;return null;case 22:return n.lanes=0,um(t,n,a,n.pendingProps);case 24:Mr(n,Mt,t.memoizedState.cache)}return xr(t,n,a)}function bm(t,n,a){if(t!==null)if(t.memoizedProps!==n.pendingProps)Bt=!0;else{if(!yu(t,a)&&(n.flags&128)===0)return Bt=!1,n_(t,n,a);Bt=(t.flags&131072)!==0}else Bt=!1,nt&&(n.flags&1048576)!==0&&Zf(n,Ws,n.index);switch(n.lanes=0,n.tag){case 16:e:{var d=n.pendingProps;if(t=mi(n.elementType),n.type=t,typeof t=="function")kc(t)?(d=bi(t,d),n.tag=1,n=pm(null,n,t,d,a)):(n.tag=0,n=fu(null,n,t,d,a));else{if(t!=null){var w=t.$$typeof;if(w===j){n.tag=11,n=om(null,n,t,d,a);break e}else if(w===L){n.tag=14,n=lm(null,n,t,d,a);break e}}throw n=F(t)||t,Error(s(306,n,""))}}return n;case 0:return fu(t,n,n.type,n.pendingProps,a);case 1:return d=n.type,w=bi(d,n.pendingProps),pm(t,n,d,w,a);case 3:e:{if(z(n,n.stateNode.containerInfo),t===null)throw Error(s(387));d=n.pendingProps;var E=n.memoizedState;w=E.element,Pc(t,n),Js(n,d,null,a);var M=n.memoizedState;if(d=M.cache,Mr(n,Mt,d),d!==E.cache&&Mc(n,[Mt],a,!0),Qs(),d=M.element,E.isDehydrated)if(E={element:d,isDehydrated:!1,cache:M.cache},n.updateQueue.baseState=E,n.memoizedState=E,n.flags&256){n=mm(t,n,d,a);break e}else if(d!==w){w=Bn(Error(s(424)),n),Gs(w),n=mm(t,n,d,a);break e}else{switch(t=n.stateNode.containerInfo,t.nodeType){case 9:t=t.body;break;default:t=t.nodeName==="HTML"?t.ownerDocument.body:t}for(St=Fn(t.firstChild),Xt=n,nt=!0,Lr=null,Hn=!0,a=up(n,null,d,a),n.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling}else{if(di(),d===w){n=xr(t,n,a);break e}Qt(t,n,d,a)}n=n.child}return n;case 26:return Oo(t,n),t===null?(a=Ag(n.type,null,n.pendingProps,null))?n.memoizedState=a:nt||(a=n.type,t=n.pendingProps,d=Qo(Q.current).createElement(a),d[Kt]=n,d[dn]=t,Jt(d,a,t),qt(d),n.stateNode=d):n.memoizedState=Ag(n.type,t.memoizedProps,n.pendingProps,t.memoizedState),null;case 27:return se(n),t===null&&nt&&(d=n.stateNode=jg(n.type,n.pendingProps,Q.current),Xt=n,Hn=!0,w=St,Vr(n.type)?(Ju=w,St=Fn(d.firstChild)):St=w),Qt(t,n,n.pendingProps.children,a),Oo(t,n),t===null&&(n.flags|=4194304),n.child;case 5:return t===null&&nt&&((w=d=St)&&(d=L_(d,n.type,n.pendingProps,Hn),d!==null?(n.stateNode=d,Xt=n,St=Fn(d.firstChild),Hn=!1,w=!0):w=!1),w||Rr(n)),se(n),w=n.type,E=n.pendingProps,M=t!==null?t.memoizedProps:null,d=E.children,Yu(w,E)?d=null:M!==null&&Yu(w,M)&&(n.flags|=32),n.memoizedState!==null&&(w=Vc(t,n,Vy,null,null,a),ba._currentValue=w),Oo(t,n),Qt(t,n,d,a),n.child;case 6:return t===null&&nt&&((t=a=St)&&(a=R_(a,n.pendingProps,Hn),a!==null?(n.stateNode=a,Xt=n,St=null,t=!0):t=!1),t||Rr(n)),null;case 13:return gm(t,n,a);case 4:return z(n,n.stateNode.containerInfo),d=n.pendingProps,t===null?n.child=xi(n,null,d,a):Qt(t,n,d,a),n.child;case 11:return om(t,n,n.type,n.pendingProps,a);case 7:return Qt(t,n,n.pendingProps,a),n.child;case 8:return Qt(t,n,n.pendingProps.children,a),n.child;case 12:return Qt(t,n,n.pendingProps.children,a),n.child;case 10:return d=n.pendingProps,Mr(n,n.type,d.value),Qt(t,n,d.children,a),n.child;case 9:return w=n.type._context,d=n.pendingProps.children,fi(n),w=Zt(w),d=d(w),n.flags|=1,Qt(t,n,d,a),n.child;case 14:return lm(t,n,n.type,n.pendingProps,a);case 15:return cm(t,n,n.type,n.pendingProps,a);case 19:return vm(t,n,a);case 31:return t_(t,n,a);case 22:return um(t,n,a,n.pendingProps);case 24:return fi(n),d=Zt(Mt),t===null?(w=Ic(),w===null&&(w=bt,E=Oc(),w.pooledCache=E,E.refCount++,E!==null&&(w.pooledCacheLanes|=a),w=E),n.memoizedState={parent:d,cache:w},Hc(n),Mr(n,Mt,w)):((t.lanes&a)!==0&&(Pc(t,n),Js(n,null,null,a),Qs()),w=t.memoizedState,E=n.memoizedState,w.parent!==d?(w={parent:d,cache:d},n.memoizedState=w,n.lanes===0&&(n.memoizedState=n.updateQueue.baseState=w),Mr(n,Mt,d)):(d=E.cache,Mr(n,Mt,d),d!==w.cache&&Mc(n,[Mt],a,!0))),Qt(t,n,n.pendingProps.children,a),n.child;case 29:throw n.pendingProps}throw Error(s(156,n.tag))}function vr(t){t.flags|=4}function _u(t,n,a,d,w){if((n=(t.mode&32)!==0)&&(n=!1),n){if(t.flags|=16777216,(w&335544128)===w)if(t.stateNode.complete)t.flags|=8192;else if(Gm())t.flags|=8192;else throw gi=yo,zc}else t.flags&=-16777217}function ym(t,n){if(n.type!=="stylesheet"||(n.state.loading&4)!==0)t.flags&=-16777217;else if(t.flags|=16777216,!Og(n))if(Gm())t.flags|=8192;else throw gi=yo,zc}function Io(t,n){n!==null&&(t.flags|=4),t.flags&16384&&(n=t.tag!==22?Zl():536870912,t.lanes|=n,cs|=n)}function sa(t,n){if(!nt)switch(t.tailMode){case"hidden":n=t.tail;for(var a=null;n!==null;)n.alternate!==null&&(a=n),n=n.sibling;a===null?t.tail=null:a.sibling=null;break;case"collapsed":a=t.tail;for(var d=null;a!==null;)a.alternate!==null&&(d=a),a=a.sibling;d===null?n||t.tail===null?t.tail=null:t.tail.sibling=null:d.sibling=null}}function wt(t){var n=t.alternate!==null&&t.alternate.child===t.child,a=0,d=0;if(n)for(var w=t.child;w!==null;)a|=w.lanes|w.childLanes,d|=w.subtreeFlags&65011712,d|=w.flags&65011712,w.return=t,w=w.sibling;else for(w=t.child;w!==null;)a|=w.lanes|w.childLanes,d|=w.subtreeFlags,d|=w.flags,w.return=t,w=w.sibling;return t.subtreeFlags|=d,t.childLanes=a,n}function r_(t,n,a){var d=n.pendingProps;switch(Tc(n),n.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return wt(n),null;case 1:return wt(n),null;case 3:return a=n.stateNode,d=null,t!==null&&(d=t.memoizedState.cache),n.memoizedState.cache!==d&&(n.flags|=2048),pr(Mt),ae(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(t===null||t.child===null)&&(Xi(n)?vr(n):t===null||t.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,Dc())),wt(n),null;case 26:var w=n.type,E=n.memoizedState;return t===null?(vr(n),E!==null?(wt(n),ym(n,E)):(wt(n),_u(n,w,null,d,a))):E?E!==t.memoizedState?(vr(n),wt(n),ym(n,E)):(wt(n),n.flags&=-16777217):(t=t.memoizedProps,t!==d&&vr(n),wt(n),_u(n,w,t,d,a)),null;case 27:if(ge(n),a=Q.current,w=n.type,t!==null&&n.stateNode!=null)t.memoizedProps!==d&&vr(n);else{if(!d){if(n.stateNode===null)throw Error(s(166));return wt(n),null}t=K.current,Xi(n)?Jf(n):(t=jg(w,d,a),n.stateNode=t,vr(n))}return wt(n),null;case 5:if(ge(n),w=n.type,t!==null&&n.stateNode!=null)t.memoizedProps!==d&&vr(n);else{if(!d){if(n.stateNode===null)throw Error(s(166));return wt(n),null}if(E=K.current,Xi(n))Jf(n);else{var M=Qo(Q.current);switch(E){case 1:E=M.createElementNS("http://www.w3.org/2000/svg",w);break;case 2:E=M.createElementNS("http://www.w3.org/1998/Math/MathML",w);break;default:switch(w){case"svg":E=M.createElementNS("http://www.w3.org/2000/svg",w);break;case"math":E=M.createElementNS("http://www.w3.org/1998/Math/MathML",w);break;case"script":E=M.createElement("div"),E.innerHTML="<script><\/script>",E=E.removeChild(E.firstChild);break;case"select":E=typeof d.is=="string"?M.createElement("select",{is:d.is}):M.createElement("select"),d.multiple?E.multiple=!0:d.size&&(E.size=d.size);break;default:E=typeof d.is=="string"?M.createElement(w,{is:d.is}):M.createElement(w)}}E[Kt]=n,E[dn]=d;e:for(M=n.child;M!==null;){if(M.tag===5||M.tag===6)E.appendChild(M.stateNode);else if(M.tag!==4&&M.tag!==27&&M.child!==null){M.child.return=M,M=M.child;continue}if(M===n)break e;for(;M.sibling===null;){if(M.return===null||M.return===n)break e;M=M.return}M.sibling.return=M.return,M=M.sibling}n.stateNode=E;e:switch(Jt(E,w,d),w){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&vr(n)}}return wt(n),_u(n,n.type,t===null?null:t.memoizedProps,n.pendingProps,a),null;case 6:if(t&&n.stateNode!=null)t.memoizedProps!==d&&vr(n);else{if(typeof d!="string"&&n.stateNode===null)throw Error(s(166));if(t=Q.current,Xi(n)){if(t=n.stateNode,a=n.memoizedProps,d=null,w=Xt,w!==null)switch(w.tag){case 27:case 5:d=w.memoizedProps}t[Kt]=n,t=!!(t.nodeValue===a||d!==null&&d.suppressHydrationWarning===!0||gg(t.nodeValue,a)),t||Rr(n,!0)}else t=Qo(t).createTextNode(d),t[Kt]=n,n.stateNode=t}return wt(n),null;case 31:if(a=n.memoizedState,t===null||t.memoizedState!==null){if(d=Xi(n),a!==null){if(t===null){if(!d)throw Error(s(318));if(t=n.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(s(557));t[Kt]=n}else di(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;wt(n),t=!1}else a=Dc(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=a),t=!0;if(!t)return n.flags&256?(wn(n),n):(wn(n),null);if((n.flags&128)!==0)throw Error(s(558))}return wt(n),null;case 13:if(d=n.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(w=Xi(n),d!==null&&d.dehydrated!==null){if(t===null){if(!w)throw Error(s(318));if(w=n.memoizedState,w=w!==null?w.dehydrated:null,!w)throw Error(s(317));w[Kt]=n}else di(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;wt(n),w=!1}else w=Dc(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=w),w=!0;if(!w)return n.flags&256?(wn(n),n):(wn(n),null)}return wn(n),(n.flags&128)!==0?(n.lanes=a,n):(a=d!==null,t=t!==null&&t.memoizedState!==null,a&&(d=n.child,w=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(w=d.alternate.memoizedState.cachePool.pool),E=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(E=d.memoizedState.cachePool.pool),E!==w&&(d.flags|=2048)),a!==t&&a&&(n.child.flags|=8192),Io(n,n.updateQueue),wt(n),null);case 4:return ae(),t===null&&$u(n.stateNode.containerInfo),wt(n),null;case 10:return pr(n.type),wt(n),null;case 19:if(W(Tt),d=n.memoizedState,d===null)return wt(n),null;if(w=(n.flags&128)!==0,E=d.rendering,E===null)if(w)sa(d,!1);else{if(Nt!==0||t!==null&&(t.flags&128)!==0)for(t=n.child;t!==null;){if(E=Co(t),E!==null){for(n.flags|=128,sa(d,!1),t=E.updateQueue,n.updateQueue=t,Io(n,t),n.subtreeFlags=0,t=a,a=n.child;a!==null;)Yf(a,t),a=a.sibling;return U(Tt,Tt.current&1|2),nt&&hr(n,d.treeForkCount),n.child}t=t.sibling}d.tail!==null&&Ge()>Uo&&(n.flags|=128,w=!0,sa(d,!1),n.lanes=4194304)}else{if(!w)if(t=Co(E),t!==null){if(n.flags|=128,w=!0,t=t.updateQueue,n.updateQueue=t,Io(n,t),sa(d,!0),d.tail===null&&d.tailMode==="hidden"&&!E.alternate&&!nt)return wt(n),null}else 2*Ge()-d.renderingStartTime>Uo&&a!==536870912&&(n.flags|=128,w=!0,sa(d,!1),n.lanes=4194304);d.isBackwards?(E.sibling=n.child,n.child=E):(t=d.last,t!==null?t.sibling=E:n.child=E,d.last=E)}return d.tail!==null?(t=d.tail,d.rendering=t,d.tail=t.sibling,d.renderingStartTime=Ge(),t.sibling=null,a=Tt.current,U(Tt,w?a&1|2:a&1),nt&&hr(n,d.treeForkCount),t):(wt(n),null);case 22:case 23:return wn(n),qc(),d=n.memoizedState!==null,t!==null?t.memoizedState!==null!==d&&(n.flags|=8192):d&&(n.flags|=8192),d?(a&536870912)!==0&&(n.flags&128)===0&&(wt(n),n.subtreeFlags&6&&(n.flags|=8192)):wt(n),a=n.updateQueue,a!==null&&Io(n,a.retryQueue),a=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(a=t.memoizedState.cachePool.pool),d=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(d=n.memoizedState.cachePool.pool),d!==a&&(n.flags|=2048),t!==null&&W(pi),null;case 24:return a=null,t!==null&&(a=t.memoizedState.cache),n.memoizedState.cache!==a&&(n.flags|=2048),pr(Mt),wt(n),null;case 25:return null;case 30:return null}throw Error(s(156,n.tag))}function i_(t,n){switch(Tc(n),n.tag){case 1:return t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 3:return pr(Mt),ae(),t=n.flags,(t&65536)!==0&&(t&128)===0?(n.flags=t&-65537|128,n):null;case 26:case 27:case 5:return ge(n),null;case 31:if(n.memoizedState!==null){if(wn(n),n.alternate===null)throw Error(s(340));di()}return t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 13:if(wn(n),t=n.memoizedState,t!==null&&t.dehydrated!==null){if(n.alternate===null)throw Error(s(340));di()}return t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 19:return W(Tt),null;case 4:return ae(),null;case 10:return pr(n.type),null;case 22:case 23:return wn(n),qc(),t!==null&&W(pi),t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 24:return pr(Mt),null;case 25:return null;default:return null}}function _m(t,n){switch(Tc(n),n.tag){case 3:pr(Mt),ae();break;case 26:case 27:case 5:ge(n);break;case 4:ae();break;case 31:n.memoizedState!==null&&wn(n);break;case 13:wn(n);break;case 19:W(Tt);break;case 10:pr(n.type);break;case 22:case 23:wn(n),qc(),t!==null&&W(pi);break;case 24:pr(Mt)}}function aa(t,n){try{var a=n.updateQueue,d=a!==null?a.lastEffect:null;if(d!==null){var w=d.next;a=w;do{if((a.tag&t)===t){d=void 0;var E=a.create,M=a.inst;d=E(),M.destroy=d}a=a.next}while(a!==w)}}catch(G){pt(n,n.return,G)}}function Pr(t,n,a){try{var d=n.updateQueue,w=d!==null?d.lastEffect:null;if(w!==null){var E=w.next;d=E;do{if((d.tag&t)===t){var M=d.inst,G=M.destroy;if(G!==void 0){M.destroy=void 0,w=n;var ee=a,le=G;try{le()}catch(he){pt(w,ee,he)}}}d=d.next}while(d!==E)}}catch(he){pt(n,n.return,he)}}function Sm(t){var n=t.updateQueue;if(n!==null){var a=t.stateNode;try{hp(n,a)}catch(d){pt(t,t.return,d)}}}function wm(t,n,a){a.props=bi(t.type,t.memoizedProps),a.state=t.memoizedState;try{a.componentWillUnmount()}catch(d){pt(t,n,d)}}function oa(t,n){try{var a=t.ref;if(a!==null){switch(t.tag){case 26:case 27:case 5:var d=t.stateNode;break;case 30:d=t.stateNode;break;default:d=t.stateNode}typeof a=="function"?t.refCleanup=a(d):a.current=d}}catch(w){pt(t,n,w)}}function Jn(t,n){var a=t.ref,d=t.refCleanup;if(a!==null)if(typeof d=="function")try{d()}catch(w){pt(t,n,w)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(w){pt(t,n,w)}else a.current=null}function Cm(t){var n=t.type,a=t.memoizedProps,d=t.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":a.autoFocus&&d.focus();break e;case"img":a.src?d.src=a.src:a.srcSet&&(d.srcset=a.srcSet)}}catch(w){pt(t,t.return,w)}}function Su(t,n,a){try{var d=t.stateNode;E_(d,t.type,a,n),d[dn]=n}catch(w){pt(t,t.return,w)}}function km(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&Vr(t.type)||t.tag===4}function wu(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||km(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.tag===27&&Vr(t.type)||t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function Cu(t,n,a){var d=t.tag;if(d===5||d===6)t=t.stateNode,n?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(t,n):(n=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,n.appendChild(t),a=a._reactRootContainer,a!=null||n.onclick!==null||(n.onclick=cr));else if(d!==4&&(d===27&&Vr(t.type)&&(a=t.stateNode,n=null),t=t.child,t!==null))for(Cu(t,n,a),t=t.sibling;t!==null;)Cu(t,n,a),t=t.sibling}function zo(t,n,a){var d=t.tag;if(d===5||d===6)t=t.stateNode,n?a.insertBefore(t,n):a.appendChild(t);else if(d!==4&&(d===27&&Vr(t.type)&&(a=t.stateNode),t=t.child,t!==null))for(zo(t,n,a),t=t.sibling;t!==null;)zo(t,n,a),t=t.sibling}function Em(t){var n=t.stateNode,a=t.memoizedProps;try{for(var d=t.type,w=n.attributes;w.length;)n.removeAttributeNode(w[0]);Jt(n,d,a),n[Kt]=t,n[dn]=a}catch(E){pt(t,t.return,E)}}var br=!1,It=!1,ku=!1,jm=typeof WeakSet=="function"?WeakSet:Set,Wt=null;function s_(t,n){if(t=t.containerInfo,Gu=sl,t=Hf(t),vc(t)){if("selectionStart"in t)var a={start:t.selectionStart,end:t.selectionEnd};else e:{a=(a=t.ownerDocument)&&a.defaultView||window;var d=a.getSelection&&a.getSelection();if(d&&d.rangeCount!==0){a=d.anchorNode;var w=d.anchorOffset,E=d.focusNode;d=d.focusOffset;try{a.nodeType,E.nodeType}catch{a=null;break e}var M=0,G=-1,ee=-1,le=0,he=0,xe=t,ce=null;t:for(;;){for(var ue;xe!==a||w!==0&&xe.nodeType!==3||(G=M+w),xe!==E||d!==0&&xe.nodeType!==3||(ee=M+d),xe.nodeType===3&&(M+=xe.nodeValue.length),(ue=xe.firstChild)!==null;)ce=xe,xe=ue;for(;;){if(xe===t)break t;if(ce===a&&++le===w&&(G=M),ce===E&&++he===d&&(ee=M),(ue=xe.nextSibling)!==null)break;xe=ce,ce=xe.parentNode}xe=ue}a=G===-1||ee===-1?null:{start:G,end:ee}}else a=null}a=a||{start:0,end:0}}else a=null;for(Vu={focusedElem:t,selectionRange:a},sl=!1,Wt=n;Wt!==null;)if(n=Wt,t=n.child,(n.subtreeFlags&1028)!==0&&t!==null)t.return=n,Wt=t;else for(;Wt!==null;){switch(n=Wt,E=n.alternate,t=n.flags,n.tag){case 0:if((t&4)!==0&&(t=n.updateQueue,t=t!==null?t.events:null,t!==null))for(a=0;a<t.length;a++)w=t[a],w.ref.impl=w.nextImpl;break;case 11:case 15:break;case 1:if((t&1024)!==0&&E!==null){t=void 0,a=n,w=E.memoizedProps,E=E.memoizedState,d=a.stateNode;try{var je=bi(a.type,w);t=d.getSnapshotBeforeUpdate(je,E),d.__reactInternalSnapshotBeforeUpdate=t}catch(Ie){pt(a,a.return,Ie)}}break;case 3:if((t&1024)!==0){if(t=n.stateNode.containerInfo,a=t.nodeType,a===9)Xu(t);else if(a===1)switch(t.nodeName){case"HEAD":case"HTML":case"BODY":Xu(t);break;default:t.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((t&1024)!==0)throw Error(s(163))}if(t=n.sibling,t!==null){t.return=n.return,Wt=t;break}Wt=n.return}}function Nm(t,n,a){var d=a.flags;switch(a.tag){case 0:case 11:case 15:_r(t,a),d&4&&aa(5,a);break;case 1:if(_r(t,a),d&4)if(t=a.stateNode,n===null)try{t.componentDidMount()}catch(M){pt(a,a.return,M)}else{var w=bi(a.type,n.memoizedProps);n=n.memoizedState;try{t.componentDidUpdate(w,n,t.__reactInternalSnapshotBeforeUpdate)}catch(M){pt(a,a.return,M)}}d&64&&Sm(a),d&512&&oa(a,a.return);break;case 3:if(_r(t,a),d&64&&(t=a.updateQueue,t!==null)){if(n=null,a.child!==null)switch(a.child.tag){case 27:case 5:n=a.child.stateNode;break;case 1:n=a.child.stateNode}try{hp(t,n)}catch(M){pt(a,a.return,M)}}break;case 27:n===null&&d&4&&Em(a);case 26:case 5:_r(t,a),n===null&&d&4&&Cm(a),d&512&&oa(a,a.return);break;case 12:_r(t,a);break;case 31:_r(t,a),d&4&&Dm(t,a);break;case 13:_r(t,a),d&4&&Lm(t,a),d&64&&(t=a.memoizedState,t!==null&&(t=t.dehydrated,t!==null&&(a=p_.bind(null,a),M_(t,a))));break;case 22:if(d=a.memoizedState!==null||br,!d){n=n!==null&&n.memoizedState!==null||It,w=br;var E=It;br=d,(It=n)&&!E?Sr(t,a,(a.subtreeFlags&8772)!==0):_r(t,a),br=w,It=E}break;case 30:break;default:_r(t,a)}}function Tm(t){var n=t.alternate;n!==null&&(t.alternate=null,Tm(n)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(n=t.stateNode,n!==null&&tc(n)),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}var kt=null,fn=!1;function yr(t,n,a){for(a=a.child;a!==null;)Am(t,n,a),a=a.sibling}function Am(t,n,a){if(it&&typeof it.onCommitFiberUnmount=="function")try{it.onCommitFiberUnmount(st,a)}catch{}switch(a.tag){case 26:It||Jn(a,n),yr(t,n,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:It||Jn(a,n);var d=kt,w=fn;Vr(a.type)&&(kt=a.stateNode,fn=!1),yr(t,n,a),ga(a.stateNode),kt=d,fn=w;break;case 5:It||Jn(a,n);case 6:if(d=kt,w=fn,kt=null,yr(t,n,a),kt=d,fn=w,kt!==null)if(fn)try{(kt.nodeType===9?kt.body:kt.nodeName==="HTML"?kt.ownerDocument.body:kt).removeChild(a.stateNode)}catch(E){pt(a,n,E)}else try{kt.removeChild(a.stateNode)}catch(E){pt(a,n,E)}break;case 18:kt!==null&&(fn?(t=kt,Sg(t.nodeType===9?t.body:t.nodeName==="HTML"?t.ownerDocument.body:t,a.stateNode),xs(t)):Sg(kt,a.stateNode));break;case 4:d=kt,w=fn,kt=a.stateNode.containerInfo,fn=!0,yr(t,n,a),kt=d,fn=w;break;case 0:case 11:case 14:case 15:Pr(2,a,n),It||Pr(4,a,n),yr(t,n,a);break;case 1:It||(Jn(a,n),d=a.stateNode,typeof d.componentWillUnmount=="function"&&wm(a,n,d)),yr(t,n,a);break;case 21:yr(t,n,a);break;case 22:It=(d=It)||a.memoizedState!==null,yr(t,n,a),It=d;break;default:yr(t,n,a)}}function Dm(t,n){if(n.memoizedState===null&&(t=n.alternate,t!==null&&(t=t.memoizedState,t!==null))){t=t.dehydrated;try{xs(t)}catch(a){pt(n,n.return,a)}}}function Lm(t,n){if(n.memoizedState===null&&(t=n.alternate,t!==null&&(t=t.memoizedState,t!==null&&(t=t.dehydrated,t!==null))))try{xs(t)}catch(a){pt(n,n.return,a)}}function a_(t){switch(t.tag){case 31:case 13:case 19:var n=t.stateNode;return n===null&&(n=t.stateNode=new jm),n;case 22:return t=t.stateNode,n=t._retryCache,n===null&&(n=t._retryCache=new jm),n;default:throw Error(s(435,t.tag))}}function Ho(t,n){var a=a_(t);n.forEach(function(d){if(!a.has(d)){a.add(d);var w=m_.bind(null,t,d);d.then(w,w)}})}function pn(t,n){var a=n.deletions;if(a!==null)for(var d=0;d<a.length;d++){var w=a[d],E=t,M=n,G=M;e:for(;G!==null;){switch(G.tag){case 27:if(Vr(G.type)){kt=G.stateNode,fn=!1;break e}break;case 5:kt=G.stateNode,fn=!1;break e;case 3:case 4:kt=G.stateNode.containerInfo,fn=!0;break e}G=G.return}if(kt===null)throw Error(s(160));Am(E,M,w),kt=null,fn=!1,E=w.alternate,E!==null&&(E.return=null),w.return=null}if(n.subtreeFlags&13886)for(n=n.child;n!==null;)Rm(n,t),n=n.sibling}var Gn=null;function Rm(t,n){var a=t.alternate,d=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:pn(n,t),mn(t),d&4&&(Pr(3,t,t.return),aa(3,t),Pr(5,t,t.return));break;case 1:pn(n,t),mn(t),d&512&&(It||a===null||Jn(a,a.return)),d&64&&br&&(t=t.updateQueue,t!==null&&(d=t.callbacks,d!==null&&(a=t.shared.hiddenCallbacks,t.shared.hiddenCallbacks=a===null?d:a.concat(d))));break;case 26:var w=Gn;if(pn(n,t),mn(t),d&512&&(It||a===null||Jn(a,a.return)),d&4){var E=a!==null?a.memoizedState:null;if(d=t.memoizedState,a===null)if(d===null)if(t.stateNode===null){e:{d=t.type,a=t.memoizedProps,w=w.ownerDocument||w;t:switch(d){case"title":E=w.getElementsByTagName("title")[0],(!E||E[Ms]||E[Kt]||E.namespaceURI==="http://www.w3.org/2000/svg"||E.hasAttribute("itemprop"))&&(E=w.createElement(d),w.head.insertBefore(E,w.querySelector("head > title"))),Jt(E,d,a),E[Kt]=t,qt(E),d=E;break e;case"link":var M=Rg("link","href",w).get(d+(a.href||""));if(M){for(var G=0;G<M.length;G++)if(E=M[G],E.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&E.getAttribute("rel")===(a.rel==null?null:a.rel)&&E.getAttribute("title")===(a.title==null?null:a.title)&&E.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){M.splice(G,1);break t}}E=w.createElement(d),Jt(E,d,a),w.head.appendChild(E);break;case"meta":if(M=Rg("meta","content",w).get(d+(a.content||""))){for(G=0;G<M.length;G++)if(E=M[G],E.getAttribute("content")===(a.content==null?null:""+a.content)&&E.getAttribute("name")===(a.name==null?null:a.name)&&E.getAttribute("property")===(a.property==null?null:a.property)&&E.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&E.getAttribute("charset")===(a.charSet==null?null:a.charSet)){M.splice(G,1);break t}}E=w.createElement(d),Jt(E,d,a),w.head.appendChild(E);break;default:throw Error(s(468,d))}E[Kt]=t,qt(E),d=E}t.stateNode=d}else Mg(w,t.type,t.stateNode);else t.stateNode=Lg(w,d,t.memoizedProps);else E!==d?(E===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):E.count--,d===null?Mg(w,t.type,t.stateNode):Lg(w,d,t.memoizedProps)):d===null&&t.stateNode!==null&&Su(t,t.memoizedProps,a.memoizedProps)}break;case 27:pn(n,t),mn(t),d&512&&(It||a===null||Jn(a,a.return)),a!==null&&d&4&&Su(t,t.memoizedProps,a.memoizedProps);break;case 5:if(pn(n,t),mn(t),d&512&&(It||a===null||Jn(a,a.return)),t.flags&32){w=t.stateNode;try{Pi(w,"")}catch(je){pt(t,t.return,je)}}d&4&&t.stateNode!=null&&(w=t.memoizedProps,Su(t,w,a!==null?a.memoizedProps:w)),d&1024&&(ku=!0);break;case 6:if(pn(n,t),mn(t),d&4){if(t.stateNode===null)throw Error(s(162));d=t.memoizedProps,a=t.stateNode;try{a.nodeValue=d}catch(je){pt(t,t.return,je)}}break;case 3:if(tl=null,w=Gn,Gn=Jo(n.containerInfo),pn(n,t),Gn=w,mn(t),d&4&&a!==null&&a.memoizedState.isDehydrated)try{xs(n.containerInfo)}catch(je){pt(t,t.return,je)}ku&&(ku=!1,Mm(t));break;case 4:d=Gn,Gn=Jo(t.stateNode.containerInfo),pn(n,t),mn(t),Gn=d;break;case 12:pn(n,t),mn(t);break;case 31:pn(n,t),mn(t),d&4&&(d=t.updateQueue,d!==null&&(t.updateQueue=null,Ho(t,d)));break;case 13:pn(n,t),mn(t),t.child.flags&8192&&t.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(Fo=Ge()),d&4&&(d=t.updateQueue,d!==null&&(t.updateQueue=null,Ho(t,d)));break;case 22:w=t.memoizedState!==null;var ee=a!==null&&a.memoizedState!==null,le=br,he=It;if(br=le||w,It=he||ee,pn(n,t),It=he,br=le,mn(t),d&8192)e:for(n=t.stateNode,n._visibility=w?n._visibility&-2:n._visibility|1,w&&(a===null||ee||br||It||yi(t)),a=null,n=t;;){if(n.tag===5||n.tag===26){if(a===null){ee=a=n;try{if(E=ee.stateNode,w)M=E.style,typeof M.setProperty=="function"?M.setProperty("display","none","important"):M.display="none";else{G=ee.stateNode;var xe=ee.memoizedProps.style,ce=xe!=null&&xe.hasOwnProperty("display")?xe.display:null;G.style.display=ce==null||typeof ce=="boolean"?"":(""+ce).trim()}}catch(je){pt(ee,ee.return,je)}}}else if(n.tag===6){if(a===null){ee=n;try{ee.stateNode.nodeValue=w?"":ee.memoizedProps}catch(je){pt(ee,ee.return,je)}}}else if(n.tag===18){if(a===null){ee=n;try{var ue=ee.stateNode;w?wg(ue,!0):wg(ee.stateNode,!1)}catch(je){pt(ee,ee.return,je)}}}else if((n.tag!==22&&n.tag!==23||n.memoizedState===null||n===t)&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break e;for(;n.sibling===null;){if(n.return===null||n.return===t)break e;a===n&&(a=null),n=n.return}a===n&&(a=null),n.sibling.return=n.return,n=n.sibling}d&4&&(d=t.updateQueue,d!==null&&(a=d.retryQueue,a!==null&&(d.retryQueue=null,Ho(t,a))));break;case 19:pn(n,t),mn(t),d&4&&(d=t.updateQueue,d!==null&&(t.updateQueue=null,Ho(t,d)));break;case 30:break;case 21:break;default:pn(n,t),mn(t)}}function mn(t){var n=t.flags;if(n&2){try{for(var a,d=t.return;d!==null;){if(km(d)){a=d;break}d=d.return}if(a==null)throw Error(s(160));switch(a.tag){case 27:var w=a.stateNode,E=wu(t);zo(t,E,w);break;case 5:var M=a.stateNode;a.flags&32&&(Pi(M,""),a.flags&=-33);var G=wu(t);zo(t,G,M);break;case 3:case 4:var ee=a.stateNode.containerInfo,le=wu(t);Cu(t,le,ee);break;default:throw Error(s(161))}}catch(he){pt(t,t.return,he)}t.flags&=-3}n&4096&&(t.flags&=-4097)}function Mm(t){if(t.subtreeFlags&1024)for(t=t.child;t!==null;){var n=t;Mm(n),n.tag===5&&n.flags&1024&&n.stateNode.reset(),t=t.sibling}}function _r(t,n){if(n.subtreeFlags&8772)for(n=n.child;n!==null;)Nm(t,n.alternate,n),n=n.sibling}function yi(t){for(t=t.child;t!==null;){var n=t;switch(n.tag){case 0:case 11:case 14:case 15:Pr(4,n,n.return),yi(n);break;case 1:Jn(n,n.return);var a=n.stateNode;typeof a.componentWillUnmount=="function"&&wm(n,n.return,a),yi(n);break;case 27:ga(n.stateNode);case 26:case 5:Jn(n,n.return),yi(n);break;case 22:n.memoizedState===null&&yi(n);break;case 30:yi(n);break;default:yi(n)}t=t.sibling}}function Sr(t,n,a){for(a=a&&(n.subtreeFlags&8772)!==0,n=n.child;n!==null;){var d=n.alternate,w=t,E=n,M=E.flags;switch(E.tag){case 0:case 11:case 15:Sr(w,E,a),aa(4,E);break;case 1:if(Sr(w,E,a),d=E,w=d.stateNode,typeof w.componentDidMount=="function")try{w.componentDidMount()}catch(le){pt(d,d.return,le)}if(d=E,w=d.updateQueue,w!==null){var G=d.stateNode;try{var ee=w.shared.hiddenCallbacks;if(ee!==null)for(w.shared.hiddenCallbacks=null,w=0;w<ee.length;w++)dp(ee[w],G)}catch(le){pt(d,d.return,le)}}a&&M&64&&Sm(E),oa(E,E.return);break;case 27:Em(E);case 26:case 5:Sr(w,E,a),a&&d===null&&M&4&&Cm(E),oa(E,E.return);break;case 12:Sr(w,E,a);break;case 31:Sr(w,E,a),a&&M&4&&Dm(w,E);break;case 13:Sr(w,E,a),a&&M&4&&Lm(w,E);break;case 22:E.memoizedState===null&&Sr(w,E,a),oa(E,E.return);break;case 30:break;default:Sr(w,E,a)}n=n.sibling}}function Eu(t,n){var a=null;t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(a=t.memoizedState.cachePool.pool),t=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(t=n.memoizedState.cachePool.pool),t!==a&&(t!=null&&t.refCount++,a!=null&&Vs(a))}function ju(t,n){t=null,n.alternate!==null&&(t=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==t&&(n.refCount++,t!=null&&Vs(t))}function Vn(t,n,a,d){if(n.subtreeFlags&10256)for(n=n.child;n!==null;)Om(t,n,a,d),n=n.sibling}function Om(t,n,a,d){var w=n.flags;switch(n.tag){case 0:case 11:case 15:Vn(t,n,a,d),w&2048&&aa(9,n);break;case 1:Vn(t,n,a,d);break;case 3:Vn(t,n,a,d),w&2048&&(t=null,n.alternate!==null&&(t=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==t&&(n.refCount++,t!=null&&Vs(t)));break;case 12:if(w&2048){Vn(t,n,a,d),t=n.stateNode;try{var E=n.memoizedProps,M=E.id,G=E.onPostCommit;typeof G=="function"&&G(M,n.alternate===null?"mount":"update",t.passiveEffectDuration,-0)}catch(ee){pt(n,n.return,ee)}}else Vn(t,n,a,d);break;case 31:Vn(t,n,a,d);break;case 13:Vn(t,n,a,d);break;case 23:break;case 22:E=n.stateNode,M=n.alternate,n.memoizedState!==null?E._visibility&2?Vn(t,n,a,d):la(t,n):E._visibility&2?Vn(t,n,a,d):(E._visibility|=2,as(t,n,a,d,(n.subtreeFlags&10256)!==0||!1)),w&2048&&Eu(M,n);break;case 24:Vn(t,n,a,d),w&2048&&ju(n.alternate,n);break;default:Vn(t,n,a,d)}}function as(t,n,a,d,w){for(w=w&&((n.subtreeFlags&10256)!==0||!1),n=n.child;n!==null;){var E=t,M=n,G=a,ee=d,le=M.flags;switch(M.tag){case 0:case 11:case 15:as(E,M,G,ee,w),aa(8,M);break;case 23:break;case 22:var he=M.stateNode;M.memoizedState!==null?he._visibility&2?as(E,M,G,ee,w):la(E,M):(he._visibility|=2,as(E,M,G,ee,w)),w&&le&2048&&Eu(M.alternate,M);break;case 24:as(E,M,G,ee,w),w&&le&2048&&ju(M.alternate,M);break;default:as(E,M,G,ee,w)}n=n.sibling}}function la(t,n){if(n.subtreeFlags&10256)for(n=n.child;n!==null;){var a=t,d=n,w=d.flags;switch(d.tag){case 22:la(a,d),w&2048&&Eu(d.alternate,d);break;case 24:la(a,d),w&2048&&ju(d.alternate,d);break;default:la(a,d)}n=n.sibling}}var ca=8192;function os(t,n,a){if(t.subtreeFlags&ca)for(t=t.child;t!==null;)Bm(t,n,a),t=t.sibling}function Bm(t,n,a){switch(t.tag){case 26:os(t,n,a),t.flags&ca&&t.memoizedState!==null&&G_(a,Gn,t.memoizedState,t.memoizedProps);break;case 5:os(t,n,a);break;case 3:case 4:var d=Gn;Gn=Jo(t.stateNode.containerInfo),os(t,n,a),Gn=d;break;case 22:t.memoizedState===null&&(d=t.alternate,d!==null&&d.memoizedState!==null?(d=ca,ca=16777216,os(t,n,a),ca=d):os(t,n,a));break;default:os(t,n,a)}}function Im(t){var n=t.alternate;if(n!==null&&(t=n.child,t!==null)){n.child=null;do n=t.sibling,t.sibling=null,t=n;while(t!==null)}}function ua(t){var n=t.deletions;if((t.flags&16)!==0){if(n!==null)for(var a=0;a<n.length;a++){var d=n[a];Wt=d,Hm(d,t)}Im(t)}if(t.subtreeFlags&10256)for(t=t.child;t!==null;)zm(t),t=t.sibling}function zm(t){switch(t.tag){case 0:case 11:case 15:ua(t),t.flags&2048&&Pr(9,t,t.return);break;case 3:ua(t);break;case 12:ua(t);break;case 22:var n=t.stateNode;t.memoizedState!==null&&n._visibility&2&&(t.return===null||t.return.tag!==13)?(n._visibility&=-3,Po(t)):ua(t);break;default:ua(t)}}function Po(t){var n=t.deletions;if((t.flags&16)!==0){if(n!==null)for(var a=0;a<n.length;a++){var d=n[a];Wt=d,Hm(d,t)}Im(t)}for(t=t.child;t!==null;){switch(n=t,n.tag){case 0:case 11:case 15:Pr(8,n,n.return),Po(n);break;case 22:a=n.stateNode,a._visibility&2&&(a._visibility&=-3,Po(n));break;default:Po(n)}t=t.sibling}}function Hm(t,n){for(;Wt!==null;){var a=Wt;switch(a.tag){case 0:case 11:case 15:Pr(8,a,n);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var d=a.memoizedState.cachePool.pool;d!=null&&d.refCount++}break;case 24:Vs(a.memoizedState.cache)}if(d=a.child,d!==null)d.return=a,Wt=d;else e:for(a=t;Wt!==null;){d=Wt;var w=d.sibling,E=d.return;if(Tm(d),d===a){Wt=null;break e}if(w!==null){w.return=E,Wt=w;break e}Wt=E}}}var o_={getCacheForType:function(t){var n=Zt(Mt),a=n.data.get(t);return a===void 0&&(a=t(),n.data.set(t,a)),a},cacheSignal:function(){return Zt(Mt).controller.signal}},l_=typeof WeakMap=="function"?WeakMap:Map,ut=0,bt=null,Ye=null,Ze=0,ft=0,Cn=null,Fr=!1,ls=!1,Nu=!1,wr=0,Nt=0,Ur=0,_i=0,Tu=0,kn=0,cs=0,da=null,gn=null,Au=!1,Fo=0,Pm=0,Uo=1/0,$o=null,$r=null,Ft=0,qr=null,us=null,Cr=0,Du=0,Lu=null,Fm=null,ha=0,Ru=null;function En(){return(ut&2)!==0&&Ze!==0?Ze&-Ze:$.T!==null?Hu():nf()}function Um(){if(kn===0)if((Ze&536870912)===0||nt){var t=Ve;Ve<<=1,(Ve&3932160)===0&&(Ve=262144),kn=t}else kn=536870912;return t=Sn.current,t!==null&&(t.flags|=32),kn}function xn(t,n,a){(t===bt&&(ft===2||ft===9)||t.cancelPendingCommit!==null)&&(ds(t,0),Wr(t,Ze,kn,!1)),Rs(t,a),((ut&2)===0||t!==bt)&&(t===bt&&((ut&2)===0&&(_i|=a),Nt===4&&Wr(t,Ze,kn,!1)),er(t))}function $m(t,n,a){if((ut&6)!==0)throw Error(s(327));var d=!a&&(n&127)===0&&(n&t.expiredLanes)===0||Et(t,n),w=d?d_(t,n):Ou(t,n,!0),E=d;do{if(w===0){ls&&!d&&Wr(t,n,0,!1);break}else{if(a=t.current.alternate,E&&!c_(a)){w=Ou(t,n,!1),E=!1;continue}if(w===2){if(E=n,t.errorRecoveryDisabledLanes&E)var M=0;else M=t.pendingLanes&-536870913,M=M!==0?M:M&536870912?536870912:0;if(M!==0){n=M;e:{var G=t;w=da;var ee=G.current.memoizedState.isDehydrated;if(ee&&(ds(G,M).flags|=256),M=Ou(G,M,!1),M!==2){if(Nu&&!ee){G.errorRecoveryDisabledLanes|=E,_i|=E,w=4;break e}E=gn,gn=w,E!==null&&(gn===null?gn=E:gn.push.apply(gn,E))}w=M}if(E=!1,w!==2)continue}}if(w===1){ds(t,0),Wr(t,n,0,!0);break}e:{switch(d=t,E=w,E){case 0:case 1:throw Error(s(345));case 4:if((n&4194048)!==n)break;case 6:Wr(d,n,kn,!Fr);break e;case 2:gn=null;break;case 3:case 5:break;default:throw Error(s(329))}if((n&62914560)===n&&(w=Fo+300-Ge(),10<w)){if(Wr(d,n,kn,!Fr),Rt(d,0,!0)!==0)break e;Cr=n,d.timeoutHandle=yg(qm.bind(null,d,a,gn,$o,Au,n,kn,_i,cs,Fr,E,"Throttled",-0,0),w);break e}qm(d,a,gn,$o,Au,n,kn,_i,cs,Fr,E,null,-0,0)}}break}while(!0);er(t)}function qm(t,n,a,d,w,E,M,G,ee,le,he,xe,ce,ue){if(t.timeoutHandle=-1,xe=n.subtreeFlags,xe&8192||(xe&16785408)===16785408){xe={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:cr},Bm(n,E,xe);var je=(E&62914560)===E?Fo-Ge():(E&4194048)===E?Pm-Ge():0;if(je=V_(xe,je),je!==null){Cr=E,t.cancelPendingCommit=je(Qm.bind(null,t,n,E,a,d,w,M,G,ee,he,xe,null,ce,ue)),Wr(t,E,M,!le);return}}Qm(t,n,E,a,d,w,M,G,ee)}function c_(t){for(var n=t;;){var a=n.tag;if((a===0||a===11||a===15)&&n.flags&16384&&(a=n.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var d=0;d<a.length;d++){var w=a[d],E=w.getSnapshot;w=w.value;try{if(!yn(E(),w))return!1}catch{return!1}}if(a=n.child,n.subtreeFlags&16384&&a!==null)a.return=n,n=a;else{if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return!0;n=n.return}n.sibling.return=n.return,n=n.sibling}}return!0}function Wr(t,n,a,d){n&=~Tu,n&=~_i,t.suspendedLanes|=n,t.pingedLanes&=~n,d&&(t.warmLanes|=n),d=t.expirationTimes;for(var w=n;0<w;){var E=31-$e(w),M=1<<E;d[E]=-1,w&=~M}a!==0&&Jh(t,a,n)}function qo(){return(ut&6)===0?(fa(0),!1):!0}function Mu(){if(Ye!==null){if(ft===0)var t=Ye.return;else t=Ye,fr=hi=null,Xc(t),ts=null,Ks=0,t=Ye;for(;t!==null;)_m(t.alternate,t),t=t.return;Ye=null}}function ds(t,n){var a=t.timeoutHandle;a!==-1&&(t.timeoutHandle=-1,T_(a)),a=t.cancelPendingCommit,a!==null&&(t.cancelPendingCommit=null,a()),Cr=0,Mu(),bt=t,Ye=a=dr(t.current,null),Ze=n,ft=0,Cn=null,Fr=!1,ls=Et(t,n),Nu=!1,cs=kn=Tu=_i=Ur=Nt=0,gn=da=null,Au=!1,(n&8)!==0&&(n|=n&32);var d=t.entangledLanes;if(d!==0)for(t=t.entanglements,d&=n;0<d;){var w=31-$e(d),E=1<<w;n|=t[w],d&=~E}return wr=n,uo(),a}function Wm(t,n){Ue=null,$.H=ra,n===es||n===bo?(n=op(),ft=3):n===zc?(n=op(),ft=4):ft=n===hu?8:n!==null&&typeof n=="object"&&typeof n.then=="function"?6:1,Cn=n,Ye===null&&(Nt=1,Ro(t,Bn(n,t.current)))}function Gm(){var t=Sn.current;return t===null?!0:(Ze&4194048)===Ze?Pn===null:(Ze&62914560)===Ze||(Ze&536870912)!==0?t===Pn:!1}function Vm(){var t=$.H;return $.H=ra,t===null?ra:t}function Ym(){var t=$.A;return $.A=o_,t}function Wo(){Nt=4,Fr||(Ze&4194048)!==Ze&&Sn.current!==null||(ls=!0),(Ur&134217727)===0&&(_i&134217727)===0||bt===null||Wr(bt,Ze,kn,!1)}function Ou(t,n,a){var d=ut;ut|=2;var w=Vm(),E=Ym();(bt!==t||Ze!==n)&&($o=null,ds(t,n)),n=!1;var M=Nt;e:do try{if(ft!==0&&Ye!==null){var G=Ye,ee=Cn;switch(ft){case 8:Mu(),M=6;break e;case 3:case 2:case 9:case 6:Sn.current===null&&(n=!0);var le=ft;if(ft=0,Cn=null,hs(t,G,ee,le),a&&ls){M=0;break e}break;default:le=ft,ft=0,Cn=null,hs(t,G,ee,le)}}u_(),M=Nt;break}catch(he){Wm(t,he)}while(!0);return n&&t.shellSuspendCounter++,fr=hi=null,ut=d,$.H=w,$.A=E,Ye===null&&(bt=null,Ze=0,uo()),M}function u_(){for(;Ye!==null;)Km(Ye)}function d_(t,n){var a=ut;ut|=2;var d=Vm(),w=Ym();bt!==t||Ze!==n?($o=null,Uo=Ge()+500,ds(t,n)):ls=Et(t,n);e:do try{if(ft!==0&&Ye!==null){n=Ye;var E=Cn;t:switch(ft){case 1:ft=0,Cn=null,hs(t,n,E,1);break;case 2:case 9:if(sp(E)){ft=0,Cn=null,Xm(n);break}n=function(){ft!==2&&ft!==9||bt!==t||(ft=7),er(t)},E.then(n,n);break e;case 3:ft=7;break e;case 4:ft=5;break e;case 7:sp(E)?(ft=0,Cn=null,Xm(n)):(ft=0,Cn=null,hs(t,n,E,7));break;case 5:var M=null;switch(Ye.tag){case 26:M=Ye.memoizedState;case 5:case 27:var G=Ye;if(M?Og(M):G.stateNode.complete){ft=0,Cn=null;var ee=G.sibling;if(ee!==null)Ye=ee;else{var le=G.return;le!==null?(Ye=le,Go(le)):Ye=null}break t}}ft=0,Cn=null,hs(t,n,E,5);break;case 6:ft=0,Cn=null,hs(t,n,E,6);break;case 8:Mu(),Nt=6;break e;default:throw Error(s(462))}}h_();break}catch(he){Wm(t,he)}while(!0);return fr=hi=null,$.H=d,$.A=w,ut=a,Ye!==null?0:(bt=null,Ze=0,uo(),Nt)}function h_(){for(;Ye!==null&&!Je();)Km(Ye)}function Km(t){var n=bm(t.alternate,t,wr);t.memoizedProps=t.pendingProps,n===null?Go(t):Ye=n}function Xm(t){var n=t,a=n.alternate;switch(n.tag){case 15:case 0:n=fm(a,n,n.pendingProps,n.type,void 0,Ze);break;case 11:n=fm(a,n,n.pendingProps,n.type.render,n.ref,Ze);break;case 5:Xc(n);default:_m(a,n),n=Ye=Yf(n,wr),n=bm(a,n,wr)}t.memoizedProps=t.pendingProps,n===null?Go(t):Ye=n}function hs(t,n,a,d){fr=hi=null,Xc(n),ts=null,Ks=0;var w=n.return;try{if(e_(t,w,n,a,Ze)){Nt=1,Ro(t,Bn(a,t.current)),Ye=null;return}}catch(E){if(w!==null)throw Ye=w,E;Nt=1,Ro(t,Bn(a,t.current)),Ye=null;return}n.flags&32768?(nt||d===1?t=!0:ls||(Ze&536870912)!==0?t=!1:(Fr=t=!0,(d===2||d===9||d===3||d===6)&&(d=Sn.current,d!==null&&d.tag===13&&(d.flags|=16384))),Zm(n,t)):Go(n)}function Go(t){var n=t;do{if((n.flags&32768)!==0){Zm(n,Fr);return}t=n.return;var a=r_(n.alternate,n,wr);if(a!==null){Ye=a;return}if(n=n.sibling,n!==null){Ye=n;return}Ye=n=t}while(n!==null);Nt===0&&(Nt=5)}function Zm(t,n){do{var a=i_(t.alternate,t);if(a!==null){a.flags&=32767,Ye=a;return}if(a=t.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!n&&(t=t.sibling,t!==null)){Ye=t;return}Ye=t=a}while(t!==null);Nt=6,Ye=null}function Qm(t,n,a,d,w,E,M,G,ee){t.cancelPendingCommit=null;do Vo();while(Ft!==0);if((ut&6)!==0)throw Error(s(327));if(n!==null){if(n===t.current)throw Error(s(177));if(E=n.lanes|n.childLanes,E|=wc,W0(t,a,E,M,G,ee),t===bt&&(Ye=bt=null,Ze=0),us=n,qr=t,Cr=a,Du=E,Lu=w,Fm=d,(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?(t.callbackNode=null,t.callbackPriority=0,g_(re,function(){return rg(),null})):(t.callbackNode=null,t.callbackPriority=0),d=(n.flags&13878)!==0,(n.subtreeFlags&13878)!==0||d){d=$.T,$.T=null,w=X.p,X.p=2,M=ut,ut|=4;try{s_(t,n,a)}finally{ut=M,X.p=w,$.T=d}}Ft=1,Jm(),eg(),tg()}}function Jm(){if(Ft===1){Ft=0;var t=qr,n=us,a=(n.flags&13878)!==0;if((n.subtreeFlags&13878)!==0||a){a=$.T,$.T=null;var d=X.p;X.p=2;var w=ut;ut|=4;try{Rm(n,t);var E=Vu,M=Hf(t.containerInfo),G=E.focusedElem,ee=E.selectionRange;if(M!==G&&G&&G.ownerDocument&&zf(G.ownerDocument.documentElement,G)){if(ee!==null&&vc(G)){var le=ee.start,he=ee.end;if(he===void 0&&(he=le),"selectionStart"in G)G.selectionStart=le,G.selectionEnd=Math.min(he,G.value.length);else{var xe=G.ownerDocument||document,ce=xe&&xe.defaultView||window;if(ce.getSelection){var ue=ce.getSelection(),je=G.textContent.length,Ie=Math.min(ee.start,je),vt=ee.end===void 0?Ie:Math.min(ee.end,je);!ue.extend&&Ie>vt&&(M=vt,vt=Ie,Ie=M);var ie=If(G,Ie),ne=If(G,vt);if(ie&&ne&&(ue.rangeCount!==1||ue.anchorNode!==ie.node||ue.anchorOffset!==ie.offset||ue.focusNode!==ne.node||ue.focusOffset!==ne.offset)){var oe=xe.createRange();oe.setStart(ie.node,ie.offset),ue.removeAllRanges(),Ie>vt?(ue.addRange(oe),ue.extend(ne.node,ne.offset)):(oe.setEnd(ne.node,ne.offset),ue.addRange(oe))}}}}for(xe=[],ue=G;ue=ue.parentNode;)ue.nodeType===1&&xe.push({element:ue,left:ue.scrollLeft,top:ue.scrollTop});for(typeof G.focus=="function"&&G.focus(),G=0;G<xe.length;G++){var me=xe[G];me.element.scrollLeft=me.left,me.element.scrollTop=me.top}}sl=!!Gu,Vu=Gu=null}finally{ut=w,X.p=d,$.T=a}}t.current=n,Ft=2}}function eg(){if(Ft===2){Ft=0;var t=qr,n=us,a=(n.flags&8772)!==0;if((n.subtreeFlags&8772)!==0||a){a=$.T,$.T=null;var d=X.p;X.p=2;var w=ut;ut|=4;try{Nm(t,n.alternate,n)}finally{ut=w,X.p=d,$.T=a}}Ft=3}}function tg(){if(Ft===4||Ft===3){Ft=0,et();var t=qr,n=us,a=Cr,d=Fm;(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?Ft=5:(Ft=0,us=qr=null,ng(t,t.pendingLanes));var w=t.pendingLanes;if(w===0&&($r=null),Jl(a),n=n.stateNode,it&&typeof it.onCommitFiberRoot=="function")try{it.onCommitFiberRoot(st,n,void 0,(n.current.flags&128)===128)}catch{}if(d!==null){n=$.T,w=X.p,X.p=2,$.T=null;try{for(var E=t.onRecoverableError,M=0;M<d.length;M++){var G=d[M];E(G.value,{componentStack:G.stack})}}finally{$.T=n,X.p=w}}(Cr&3)!==0&&Vo(),er(t),w=t.pendingLanes,(a&261930)!==0&&(w&42)!==0?t===Ru?ha++:(ha=0,Ru=t):ha=0,fa(0)}}function ng(t,n){(t.pooledCacheLanes&=n)===0&&(n=t.pooledCache,n!=null&&(t.pooledCache=null,Vs(n)))}function Vo(){return Jm(),eg(),tg(),rg()}function rg(){if(Ft!==5)return!1;var t=qr,n=Du;Du=0;var a=Jl(Cr),d=$.T,w=X.p;try{X.p=32>a?32:a,$.T=null,a=Lu,Lu=null;var E=qr,M=Cr;if(Ft=0,us=qr=null,Cr=0,(ut&6)!==0)throw Error(s(331));var G=ut;if(ut|=4,zm(E.current),Om(E,E.current,M,a),ut=G,fa(0,!1),it&&typeof it.onPostCommitFiberRoot=="function")try{it.onPostCommitFiberRoot(st,E)}catch{}return!0}finally{X.p=w,$.T=d,ng(t,n)}}function ig(t,n,a){n=Bn(a,n),n=du(t.stateNode,n,2),t=Ir(t,n,2),t!==null&&(Rs(t,2),er(t))}function pt(t,n,a){if(t.tag===3)ig(t,t,a);else for(;n!==null;){if(n.tag===3){ig(n,t,a);break}else if(n.tag===1){var d=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&($r===null||!$r.has(d))){t=Bn(a,t),a=sm(2),d=Ir(n,a,2),d!==null&&(am(a,d,n,t),Rs(d,2),er(d));break}}n=n.return}}function Bu(t,n,a){var d=t.pingCache;if(d===null){d=t.pingCache=new l_;var w=new Set;d.set(n,w)}else w=d.get(n),w===void 0&&(w=new Set,d.set(n,w));w.has(a)||(Nu=!0,w.add(a),t=f_.bind(null,t,n,a),n.then(t,t))}function f_(t,n,a){var d=t.pingCache;d!==null&&d.delete(n),t.pingedLanes|=t.suspendedLanes&a,t.warmLanes&=~a,bt===t&&(Ze&a)===a&&(Nt===4||Nt===3&&(Ze&62914560)===Ze&&300>Ge()-Fo?(ut&2)===0&&ds(t,0):Tu|=a,cs===Ze&&(cs=0)),er(t)}function sg(t,n){n===0&&(n=Zl()),t=ci(t,n),t!==null&&(Rs(t,n),er(t))}function p_(t){var n=t.memoizedState,a=0;n!==null&&(a=n.retryLane),sg(t,a)}function m_(t,n){var a=0;switch(t.tag){case 31:case 13:var d=t.stateNode,w=t.memoizedState;w!==null&&(a=w.retryLane);break;case 19:d=t.stateNode;break;case 22:d=t.stateNode._retryCache;break;default:throw Error(s(314))}d!==null&&d.delete(n),sg(t,a)}function g_(t,n){return fe(t,n)}var Yo=null,fs=null,Iu=!1,Ko=!1,zu=!1,Gr=0;function er(t){t!==fs&&t.next===null&&(fs===null?Yo=fs=t:fs=fs.next=t),Ko=!0,Iu||(Iu=!0,v_())}function fa(t,n){if(!zu&&Ko){zu=!0;do for(var a=!1,d=Yo;d!==null;){if(t!==0){var w=d.pendingLanes;if(w===0)var E=0;else{var M=d.suspendedLanes,G=d.pingedLanes;E=(1<<31-$e(42|t)+1)-1,E&=w&~(M&~G),E=E&201326741?E&201326741|1:E?E|2:0}E!==0&&(a=!0,cg(d,E))}else E=Ze,E=Rt(d,d===bt?E:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(E&3)===0||Et(d,E)||(a=!0,cg(d,E));d=d.next}while(a);zu=!1}}function x_(){ag()}function ag(){Ko=Iu=!1;var t=0;Gr!==0&&N_()&&(t=Gr);for(var n=Ge(),a=null,d=Yo;d!==null;){var w=d.next,E=og(d,n);E===0?(d.next=null,a===null?Yo=w:a.next=w,w===null&&(fs=a)):(a=d,(t!==0||(E&3)!==0)&&(Ko=!0)),d=w}Ft!==0&&Ft!==5||fa(t),Gr!==0&&(Gr=0)}function og(t,n){for(var a=t.suspendedLanes,d=t.pingedLanes,w=t.expirationTimes,E=t.pendingLanes&-62914561;0<E;){var M=31-$e(E),G=1<<M,ee=w[M];ee===-1?((G&a)===0||(G&d)!==0)&&(w[M]=Yt(G,n)):ee<=n&&(t.expiredLanes|=G),E&=~G}if(n=bt,a=Ze,a=Rt(t,t===n?a:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),d=t.callbackNode,a===0||t===n&&(ft===2||ft===9)||t.cancelPendingCommit!==null)return d!==null&&d!==null&&Re(d),t.callbackNode=null,t.callbackPriority=0;if((a&3)===0||Et(t,a)){if(n=a&-a,n===t.callbackPriority)return n;switch(d!==null&&Re(d),Jl(a)){case 2:case 8:a=be;break;case 32:a=re;break;case 268435456:a=Ce;break;default:a=re}return d=lg.bind(null,t),a=fe(a,d),t.callbackPriority=n,t.callbackNode=a,n}return d!==null&&d!==null&&Re(d),t.callbackPriority=2,t.callbackNode=null,2}function lg(t,n){if(Ft!==0&&Ft!==5)return t.callbackNode=null,t.callbackPriority=0,null;var a=t.callbackNode;if(Vo()&&t.callbackNode!==a)return null;var d=Ze;return d=Rt(t,t===bt?d:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),d===0?null:($m(t,d,n),og(t,Ge()),t.callbackNode!=null&&t.callbackNode===a?lg.bind(null,t):null)}function cg(t,n){if(Vo())return null;$m(t,n,!0)}function v_(){A_(function(){(ut&6)!==0?fe(de,x_):ag()})}function Hu(){if(Gr===0){var t=Qi;t===0&&(t=ze,ze<<=1,(ze&261888)===0&&(ze=256)),Gr=t}return Gr}function ug(t){return t==null||typeof t=="symbol"||typeof t=="boolean"?null:typeof t=="function"?t:no(""+t)}function dg(t,n){var a=n.ownerDocument.createElement("input");return a.name=n.name,a.value=n.value,t.id&&a.setAttribute("form",t.id),n.parentNode.insertBefore(a,n),t=new FormData(t),a.parentNode.removeChild(a),t}function b_(t,n,a,d,w){if(n==="submit"&&a&&a.stateNode===w){var E=ug((w[dn]||null).action),M=d.submitter;M&&(n=(n=M[dn]||null)?ug(n.formAction):M.getAttribute("formAction"),n!==null&&(E=n,M=null));var G=new ao("action","action",null,d,w);t.push({event:G,listeners:[{instance:null,listener:function(){if(d.defaultPrevented){if(Gr!==0){var ee=M?dg(w,M):new FormData(w);su(a,{pending:!0,data:ee,method:w.method,action:E},null,ee)}}else typeof E=="function"&&(G.preventDefault(),ee=M?dg(w,M):new FormData(w),su(a,{pending:!0,data:ee,method:w.method,action:E},E,ee))},currentTarget:w}]})}}for(var Pu=0;Pu<Sc.length;Pu++){var Fu=Sc[Pu],y_=Fu.toLowerCase(),__=Fu[0].toUpperCase()+Fu.slice(1);Wn(y_,"on"+__)}Wn(Uf,"onAnimationEnd"),Wn($f,"onAnimationIteration"),Wn(qf,"onAnimationStart"),Wn("dblclick","onDoubleClick"),Wn("focusin","onFocus"),Wn("focusout","onBlur"),Wn(Iy,"onTransitionRun"),Wn(zy,"onTransitionStart"),Wn(Hy,"onTransitionCancel"),Wn(Wf,"onTransitionEnd"),zi("onMouseEnter",["mouseout","mouseover"]),zi("onMouseLeave",["mouseout","mouseover"]),zi("onPointerEnter",["pointerout","pointerover"]),zi("onPointerLeave",["pointerout","pointerover"]),si("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),si("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),si("onBeforeInput",["compositionend","keypress","textInput","paste"]),si("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),si("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),si("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var pa="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(" "),S_=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(pa));function hg(t,n){n=(n&4)!==0;for(var a=0;a<t.length;a++){var d=t[a],w=d.event;d=d.listeners;e:{var E=void 0;if(n)for(var M=d.length-1;0<=M;M--){var G=d[M],ee=G.instance,le=G.currentTarget;if(G=G.listener,ee!==E&&w.isPropagationStopped())break e;E=G,w.currentTarget=le;try{E(w)}catch(he){co(he)}w.currentTarget=null,E=ee}else for(M=0;M<d.length;M++){if(G=d[M],ee=G.instance,le=G.currentTarget,G=G.listener,ee!==E&&w.isPropagationStopped())break e;E=G,w.currentTarget=le;try{E(w)}catch(he){co(he)}w.currentTarget=null,E=ee}}}}function Ke(t,n){var a=n[ec];a===void 0&&(a=n[ec]=new Set);var d=t+"__bubble";a.has(d)||(fg(n,t,2,!1),a.add(d))}function Uu(t,n,a){var d=0;n&&(d|=4),fg(a,t,d,n)}var Xo="_reactListening"+Math.random().toString(36).slice(2);function $u(t){if(!t[Xo]){t[Xo]=!0,af.forEach(function(a){a!=="selectionchange"&&(S_.has(a)||Uu(a,!1,t),Uu(a,!0,t))});var n=t.nodeType===9?t:t.ownerDocument;n===null||n[Xo]||(n[Xo]=!0,Uu("selectionchange",!1,n))}}function fg(t,n,a,d){switch(Ug(n)){case 2:var w=X_;break;case 8:w=Z_;break;default:w=id}a=w.bind(null,n,a,t),w=void 0,!cc||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(w=!0),d?w!==void 0?t.addEventListener(n,a,{capture:!0,passive:w}):t.addEventListener(n,a,!0):w!==void 0?t.addEventListener(n,a,{passive:w}):t.addEventListener(n,a,!1)}function qu(t,n,a,d,w){var E=d;if((n&1)===0&&(n&2)===0&&d!==null)e:for(;;){if(d===null)return;var M=d.tag;if(M===3||M===4){var G=d.stateNode.containerInfo;if(G===w)break;if(M===4)for(M=d.return;M!==null;){var ee=M.tag;if((ee===3||ee===4)&&M.stateNode.containerInfo===w)return;M=M.return}for(;G!==null;){if(M=Oi(G),M===null)return;if(ee=M.tag,ee===5||ee===6||ee===26||ee===27){d=E=M;continue e}G=G.parentNode}}d=d.return}vf(function(){var le=E,he=oc(a),xe=[];e:{var ce=Gf.get(t);if(ce!==void 0){var ue=ao,je=t;switch(t){case"keypress":if(io(a)===0)break e;case"keydown":case"keyup":ue=my;break;case"focusin":je="focus",ue=fc;break;case"focusout":je="blur",ue=fc;break;case"beforeblur":case"afterblur":ue=fc;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":ue=_f;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ue=ry;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ue=vy;break;case Uf:case $f:case qf:ue=ay;break;case Wf:ue=yy;break;case"scroll":case"scrollend":ue=ty;break;case"wheel":ue=Sy;break;case"copy":case"cut":case"paste":ue=ly;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ue=wf;break;case"toggle":case"beforetoggle":ue=Cy}var Ie=(n&4)!==0,vt=!Ie&&(t==="scroll"||t==="scrollend"),ie=Ie?ce!==null?ce+"Capture":null:ce;Ie=[];for(var ne=le,oe;ne!==null;){var me=ne;if(oe=me.stateNode,me=me.tag,me!==5&&me!==26&&me!==27||oe===null||ie===null||(me=Bs(ne,ie),me!=null&&Ie.push(ma(ne,me,oe))),vt)break;ne=ne.return}0<Ie.length&&(ce=new ue(ce,je,null,a,he),xe.push({event:ce,listeners:Ie}))}}if((n&7)===0){e:{if(ce=t==="mouseover"||t==="pointerover",ue=t==="mouseout"||t==="pointerout",ce&&a!==ac&&(je=a.relatedTarget||a.fromElement)&&(Oi(je)||je[Mi]))break e;if((ue||ce)&&(ce=he.window===he?he:(ce=he.ownerDocument)?ce.defaultView||ce.parentWindow:window,ue?(je=a.relatedTarget||a.toElement,ue=le,je=je?Oi(je):null,je!==null&&(vt=u(je),Ie=je.tag,je!==vt||Ie!==5&&Ie!==27&&Ie!==6)&&(je=null)):(ue=null,je=le),ue!==je)){if(Ie=_f,me="onMouseLeave",ie="onMouseEnter",ne="mouse",(t==="pointerout"||t==="pointerover")&&(Ie=wf,me="onPointerLeave",ie="onPointerEnter",ne="pointer"),vt=ue==null?ce:Os(ue),oe=je==null?ce:Os(je),ce=new Ie(me,ne+"leave",ue,a,he),ce.target=vt,ce.relatedTarget=oe,me=null,Oi(he)===le&&(Ie=new Ie(ie,ne+"enter",je,a,he),Ie.target=oe,Ie.relatedTarget=vt,me=Ie),vt=me,ue&&je)t:{for(Ie=w_,ie=ue,ne=je,oe=0,me=ie;me;me=Ie(me))oe++;me=0;for(var Le=ne;Le;Le=Ie(Le))me++;for(;0<oe-me;)ie=Ie(ie),oe--;for(;0<me-oe;)ne=Ie(ne),me--;for(;oe--;){if(ie===ne||ne!==null&&ie===ne.alternate){Ie=ie;break t}ie=Ie(ie),ne=Ie(ne)}Ie=null}else Ie=null;ue!==null&&pg(xe,ce,ue,Ie,!1),je!==null&&vt!==null&&pg(xe,vt,je,Ie,!0)}}e:{if(ce=le?Os(le):window,ue=ce.nodeName&&ce.nodeName.toLowerCase(),ue==="select"||ue==="input"&&ce.type==="file")var at=Df;else if(Tf(ce))if(Lf)at=My;else{at=Ly;var Te=Dy}else ue=ce.nodeName,!ue||ue.toLowerCase()!=="input"||ce.type!=="checkbox"&&ce.type!=="radio"?le&&sc(le.elementType)&&(at=Df):at=Ry;if(at&&(at=at(t,le))){Af(xe,at,a,he);break e}Te&&Te(t,ce,le),t==="focusout"&&le&&ce.type==="number"&&le.memoizedProps.value!=null&&ic(ce,"number",ce.value)}switch(Te=le?Os(le):window,t){case"focusin":(Tf(Te)||Te.contentEditable==="true")&&(qi=Te,bc=le,qs=null);break;case"focusout":qs=bc=qi=null;break;case"mousedown":yc=!0;break;case"contextmenu":case"mouseup":case"dragend":yc=!1,Pf(xe,a,he);break;case"selectionchange":if(By)break;case"keydown":case"keyup":Pf(xe,a,he)}var qe;if(mc)e:{switch(t){case"compositionstart":var Qe="onCompositionStart";break e;case"compositionend":Qe="onCompositionEnd";break e;case"compositionupdate":Qe="onCompositionUpdate";break e}Qe=void 0}else $i?jf(t,a)&&(Qe="onCompositionEnd"):t==="keydown"&&a.keyCode===229&&(Qe="onCompositionStart");Qe&&(Cf&&a.locale!=="ko"&&($i||Qe!=="onCompositionStart"?Qe==="onCompositionEnd"&&$i&&(qe=bf()):(Ar=he,uc="value"in Ar?Ar.value:Ar.textContent,$i=!0)),Te=Zo(le,Qe),0<Te.length&&(Qe=new Sf(Qe,t,null,a,he),xe.push({event:Qe,listeners:Te}),qe?Qe.data=qe:(qe=Nf(a),qe!==null&&(Qe.data=qe)))),(qe=Ey?jy(t,a):Ny(t,a))&&(Qe=Zo(le,"onBeforeInput"),0<Qe.length&&(Te=new Sf("onBeforeInput","beforeinput",null,a,he),xe.push({event:Te,listeners:Qe}),Te.data=qe)),b_(xe,t,le,a,he)}hg(xe,n)})}function ma(t,n,a){return{instance:t,listener:n,currentTarget:a}}function Zo(t,n){for(var a=n+"Capture",d=[];t!==null;){var w=t,E=w.stateNode;if(w=w.tag,w!==5&&w!==26&&w!==27||E===null||(w=Bs(t,a),w!=null&&d.unshift(ma(t,w,E)),w=Bs(t,n),w!=null&&d.push(ma(t,w,E))),t.tag===3)return d;t=t.return}return[]}function w_(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5&&t.tag!==27);return t||null}function pg(t,n,a,d,w){for(var E=n._reactName,M=[];a!==null&&a!==d;){var G=a,ee=G.alternate,le=G.stateNode;if(G=G.tag,ee!==null&&ee===d)break;G!==5&&G!==26&&G!==27||le===null||(ee=le,w?(le=Bs(a,E),le!=null&&M.unshift(ma(a,le,ee))):w||(le=Bs(a,E),le!=null&&M.push(ma(a,le,ee)))),a=a.return}M.length!==0&&t.push({event:n,listeners:M})}var C_=/\r\n?/g,k_=/\u0000|\uFFFD/g;function mg(t){return(typeof t=="string"?t:""+t).replace(C_,`
49
49
  `).replace(k_,"")}function gg(t,n){return n=mg(n),mg(t)===n}function xt(t,n,a,d,w,E){switch(a){case"children":typeof d=="string"?n==="body"||n==="textarea"&&d===""||Pi(t,d):(typeof d=="number"||typeof d=="bigint")&&n!=="body"&&Pi(t,""+d);break;case"className":eo(t,"class",d);break;case"tabIndex":eo(t,"tabindex",d);break;case"dir":case"role":case"viewBox":case"width":case"height":eo(t,a,d);break;case"style":gf(t,d,E);break;case"data":if(n!=="object"){eo(t,"data",d);break}case"src":case"href":if(d===""&&(n!=="a"||a!=="href")){t.removeAttribute(a);break}if(d==null||typeof d=="function"||typeof d=="symbol"||typeof d=="boolean"){t.removeAttribute(a);break}d=no(""+d),t.setAttribute(a,d);break;case"action":case"formAction":if(typeof d=="function"){t.setAttribute(a,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof E=="function"&&(a==="formAction"?(n!=="input"&&xt(t,n,"name",w.name,w,null),xt(t,n,"formEncType",w.formEncType,w,null),xt(t,n,"formMethod",w.formMethod,w,null),xt(t,n,"formTarget",w.formTarget,w,null)):(xt(t,n,"encType",w.encType,w,null),xt(t,n,"method",w.method,w,null),xt(t,n,"target",w.target,w,null)));if(d==null||typeof d=="symbol"||typeof d=="boolean"){t.removeAttribute(a);break}d=no(""+d),t.setAttribute(a,d);break;case"onClick":d!=null&&(t.onclick=cr);break;case"onScroll":d!=null&&Ke("scroll",t);break;case"onScrollEnd":d!=null&&Ke("scrollend",t);break;case"dangerouslySetInnerHTML":if(d!=null){if(typeof d!="object"||!("__html"in d))throw Error(s(61));if(a=d.__html,a!=null){if(w.children!=null)throw Error(s(60));t.innerHTML=a}}break;case"multiple":t.multiple=d&&typeof d!="function"&&typeof d!="symbol";break;case"muted":t.muted=d&&typeof d!="function"&&typeof d!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(d==null||typeof d=="function"||typeof d=="boolean"||typeof d=="symbol"){t.removeAttribute("xlink:href");break}a=no(""+d),t.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":d!=null&&typeof d!="function"&&typeof d!="symbol"?t.setAttribute(a,""+d):t.removeAttribute(a);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":d&&typeof d!="function"&&typeof d!="symbol"?t.setAttribute(a,""):t.removeAttribute(a);break;case"capture":case"download":d===!0?t.setAttribute(a,""):d!==!1&&d!=null&&typeof d!="function"&&typeof d!="symbol"?t.setAttribute(a,d):t.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":d!=null&&typeof d!="function"&&typeof d!="symbol"&&!isNaN(d)&&1<=d?t.setAttribute(a,d):t.removeAttribute(a);break;case"rowSpan":case"start":d==null||typeof d=="function"||typeof d=="symbol"||isNaN(d)?t.removeAttribute(a):t.setAttribute(a,d);break;case"popover":Ke("beforetoggle",t),Ke("toggle",t),Ja(t,"popover",d);break;case"xlinkActuate":lr(t,"http://www.w3.org/1999/xlink","xlink:actuate",d);break;case"xlinkArcrole":lr(t,"http://www.w3.org/1999/xlink","xlink:arcrole",d);break;case"xlinkRole":lr(t,"http://www.w3.org/1999/xlink","xlink:role",d);break;case"xlinkShow":lr(t,"http://www.w3.org/1999/xlink","xlink:show",d);break;case"xlinkTitle":lr(t,"http://www.w3.org/1999/xlink","xlink:title",d);break;case"xlinkType":lr(t,"http://www.w3.org/1999/xlink","xlink:type",d);break;case"xmlBase":lr(t,"http://www.w3.org/XML/1998/namespace","xml:base",d);break;case"xmlLang":lr(t,"http://www.w3.org/XML/1998/namespace","xml:lang",d);break;case"xmlSpace":lr(t,"http://www.w3.org/XML/1998/namespace","xml:space",d);break;case"is":Ja(t,"is",d);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=J0.get(a)||a,Ja(t,a,d))}}function Wu(t,n,a,d,w,E){switch(a){case"style":gf(t,d,E);break;case"dangerouslySetInnerHTML":if(d!=null){if(typeof d!="object"||!("__html"in d))throw Error(s(61));if(a=d.__html,a!=null){if(w.children!=null)throw Error(s(60));t.innerHTML=a}}break;case"children":typeof d=="string"?Pi(t,d):(typeof d=="number"||typeof d=="bigint")&&Pi(t,""+d);break;case"onScroll":d!=null&&Ke("scroll",t);break;case"onScrollEnd":d!=null&&Ke("scrollend",t);break;case"onClick":d!=null&&(t.onclick=cr);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!of.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(w=a.endsWith("Capture"),n=a.slice(2,w?a.length-7:void 0),E=t[dn]||null,E=E!=null?E[a]:null,typeof E=="function"&&t.removeEventListener(n,E,w),typeof d=="function")){typeof E!="function"&&E!==null&&(a in t?t[a]=null:t.hasAttribute(a)&&t.removeAttribute(a)),t.addEventListener(n,d,w);break e}a in t?t[a]=d:d===!0?t.setAttribute(a,""):Ja(t,a,d)}}}function Jt(t,n,a){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Ke("error",t),Ke("load",t);var d=!1,w=!1,E;for(E in a)if(a.hasOwnProperty(E)){var M=a[E];if(M!=null)switch(E){case"src":d=!0;break;case"srcSet":w=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,n));default:xt(t,n,E,M,a,null)}}w&&xt(t,n,"srcSet",a.srcSet,a,null),d&&xt(t,n,"src",a.src,a,null);return;case"input":Ke("invalid",t);var G=E=M=w=null,ee=null,le=null;for(d in a)if(a.hasOwnProperty(d)){var he=a[d];if(he!=null)switch(d){case"name":w=he;break;case"type":M=he;break;case"checked":ee=he;break;case"defaultChecked":le=he;break;case"value":E=he;break;case"defaultValue":G=he;break;case"children":case"dangerouslySetInnerHTML":if(he!=null)throw Error(s(137,n));break;default:xt(t,n,d,he,a,null)}}hf(t,E,G,ee,le,M,w,!1);return;case"select":Ke("invalid",t),d=M=E=null;for(w in a)if(a.hasOwnProperty(w)&&(G=a[w],G!=null))switch(w){case"value":E=G;break;case"defaultValue":M=G;break;case"multiple":d=G;default:xt(t,n,w,G,a,null)}n=E,a=M,t.multiple=!!d,n!=null?Hi(t,!!d,n,!1):a!=null&&Hi(t,!!d,a,!0);return;case"textarea":Ke("invalid",t),E=w=d=null;for(M in a)if(a.hasOwnProperty(M)&&(G=a[M],G!=null))switch(M){case"value":d=G;break;case"defaultValue":w=G;break;case"children":E=G;break;case"dangerouslySetInnerHTML":if(G!=null)throw Error(s(91));break;default:xt(t,n,M,G,a,null)}pf(t,d,w,E);return;case"option":for(ee in a)if(a.hasOwnProperty(ee)&&(d=a[ee],d!=null))switch(ee){case"selected":t.selected=d&&typeof d!="function"&&typeof d!="symbol";break;default:xt(t,n,ee,d,a,null)}return;case"dialog":Ke("beforetoggle",t),Ke("toggle",t),Ke("cancel",t),Ke("close",t);break;case"iframe":case"object":Ke("load",t);break;case"video":case"audio":for(d=0;d<pa.length;d++)Ke(pa[d],t);break;case"image":Ke("error",t),Ke("load",t);break;case"details":Ke("toggle",t);break;case"embed":case"source":case"link":Ke("error",t),Ke("load",t);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(le in a)if(a.hasOwnProperty(le)&&(d=a[le],d!=null))switch(le){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,n));default:xt(t,n,le,d,a,null)}return;default:if(sc(n)){for(he in a)a.hasOwnProperty(he)&&(d=a[he],d!==void 0&&Wu(t,n,he,d,a,void 0));return}}for(G in a)a.hasOwnProperty(G)&&(d=a[G],d!=null&&xt(t,n,G,d,a,null))}function E_(t,n,a,d){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var w=null,E=null,M=null,G=null,ee=null,le=null,he=null;for(ue in a){var xe=a[ue];if(a.hasOwnProperty(ue)&&xe!=null)switch(ue){case"checked":break;case"value":break;case"defaultValue":ee=xe;default:d.hasOwnProperty(ue)||xt(t,n,ue,null,d,xe)}}for(var ce in d){var ue=d[ce];if(xe=a[ce],d.hasOwnProperty(ce)&&(ue!=null||xe!=null))switch(ce){case"type":E=ue;break;case"name":w=ue;break;case"checked":le=ue;break;case"defaultChecked":he=ue;break;case"value":M=ue;break;case"defaultValue":G=ue;break;case"children":case"dangerouslySetInnerHTML":if(ue!=null)throw Error(s(137,n));break;default:ue!==xe&&xt(t,n,ce,ue,d,xe)}}rc(t,M,G,ee,le,he,E,w);return;case"select":ue=M=G=ce=null;for(E in a)if(ee=a[E],a.hasOwnProperty(E)&&ee!=null)switch(E){case"value":break;case"multiple":ue=ee;default:d.hasOwnProperty(E)||xt(t,n,E,null,d,ee)}for(w in d)if(E=d[w],ee=a[w],d.hasOwnProperty(w)&&(E!=null||ee!=null))switch(w){case"value":ce=E;break;case"defaultValue":G=E;break;case"multiple":M=E;default:E!==ee&&xt(t,n,w,E,d,ee)}n=G,a=M,d=ue,ce!=null?Hi(t,!!a,ce,!1):!!d!=!!a&&(n!=null?Hi(t,!!a,n,!0):Hi(t,!!a,a?[]:"",!1));return;case"textarea":ue=ce=null;for(G in a)if(w=a[G],a.hasOwnProperty(G)&&w!=null&&!d.hasOwnProperty(G))switch(G){case"value":break;case"children":break;default:xt(t,n,G,null,d,w)}for(M in d)if(w=d[M],E=a[M],d.hasOwnProperty(M)&&(w!=null||E!=null))switch(M){case"value":ce=w;break;case"defaultValue":ue=w;break;case"children":break;case"dangerouslySetInnerHTML":if(w!=null)throw Error(s(91));break;default:w!==E&&xt(t,n,M,w,d,E)}ff(t,ce,ue);return;case"option":for(var je in a)if(ce=a[je],a.hasOwnProperty(je)&&ce!=null&&!d.hasOwnProperty(je))switch(je){case"selected":t.selected=!1;break;default:xt(t,n,je,null,d,ce)}for(ee in d)if(ce=d[ee],ue=a[ee],d.hasOwnProperty(ee)&&ce!==ue&&(ce!=null||ue!=null))switch(ee){case"selected":t.selected=ce&&typeof ce!="function"&&typeof ce!="symbol";break;default:xt(t,n,ee,ce,d,ue)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Ie in a)ce=a[Ie],a.hasOwnProperty(Ie)&&ce!=null&&!d.hasOwnProperty(Ie)&&xt(t,n,Ie,null,d,ce);for(le in d)if(ce=d[le],ue=a[le],d.hasOwnProperty(le)&&ce!==ue&&(ce!=null||ue!=null))switch(le){case"children":case"dangerouslySetInnerHTML":if(ce!=null)throw Error(s(137,n));break;default:xt(t,n,le,ce,d,ue)}return;default:if(sc(n)){for(var vt in a)ce=a[vt],a.hasOwnProperty(vt)&&ce!==void 0&&!d.hasOwnProperty(vt)&&Wu(t,n,vt,void 0,d,ce);for(he in d)ce=d[he],ue=a[he],!d.hasOwnProperty(he)||ce===ue||ce===void 0&&ue===void 0||Wu(t,n,he,ce,d,ue);return}}for(var ie in a)ce=a[ie],a.hasOwnProperty(ie)&&ce!=null&&!d.hasOwnProperty(ie)&&xt(t,n,ie,null,d,ce);for(xe in d)ce=d[xe],ue=a[xe],!d.hasOwnProperty(xe)||ce===ue||ce==null&&ue==null||xt(t,n,xe,ce,d,ue)}function xg(t){switch(t){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function j_(){if(typeof performance.getEntriesByType=="function"){for(var t=0,n=0,a=performance.getEntriesByType("resource"),d=0;d<a.length;d++){var w=a[d],E=w.transferSize,M=w.initiatorType,G=w.duration;if(E&&G&&xg(M)){for(M=0,G=w.responseEnd,d+=1;d<a.length;d++){var ee=a[d],le=ee.startTime;if(le>G)break;var he=ee.transferSize,xe=ee.initiatorType;he&&xg(xe)&&(ee=ee.responseEnd,M+=he*(ee<G?1:(G-le)/(ee-le)))}if(--d,n+=8*(E+M)/(w.duration/1e3),t++,10<t)break}}if(0<t)return n/t/1e6}return navigator.connection&&(t=navigator.connection.downlink,typeof t=="number")?t:5}var Gu=null,Vu=null;function Qo(t){return t.nodeType===9?t:t.ownerDocument}function vg(t){switch(t){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function bg(t,n){if(t===0)switch(n){case"svg":return 1;case"math":return 2;default:return 0}return t===1&&n==="foreignObject"?0:t}function Yu(t,n){return t==="textarea"||t==="noscript"||typeof n.children=="string"||typeof n.children=="number"||typeof n.children=="bigint"||typeof n.dangerouslySetInnerHTML=="object"&&n.dangerouslySetInnerHTML!==null&&n.dangerouslySetInnerHTML.__html!=null}var Ku=null;function N_(){var t=window.event;return t&&t.type==="popstate"?t===Ku?!1:(Ku=t,!0):(Ku=null,!1)}var yg=typeof setTimeout=="function"?setTimeout:void 0,T_=typeof clearTimeout=="function"?clearTimeout:void 0,_g=typeof Promise=="function"?Promise:void 0,A_=typeof queueMicrotask=="function"?queueMicrotask:typeof _g<"u"?function(t){return _g.resolve(null).then(t).catch(D_)}:yg;function D_(t){setTimeout(function(){throw t})}function Vr(t){return t==="head"}function Sg(t,n){var a=n,d=0;do{var w=a.nextSibling;if(t.removeChild(a),w&&w.nodeType===8)if(a=w.data,a==="/$"||a==="/&"){if(d===0){t.removeChild(w),xs(n);return}d--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")d++;else if(a==="html")ga(t.ownerDocument.documentElement);else if(a==="head"){a=t.ownerDocument.head,ga(a);for(var E=a.firstChild;E;){var M=E.nextSibling,G=E.nodeName;E[Ms]||G==="SCRIPT"||G==="STYLE"||G==="LINK"&&E.rel.toLowerCase()==="stylesheet"||a.removeChild(E),E=M}}else a==="body"&&ga(t.ownerDocument.body);a=w}while(a);xs(n)}function wg(t,n){var a=t;t=0;do{var d=a.nextSibling;if(a.nodeType===1?n?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(n?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),d&&d.nodeType===8)if(a=d.data,a==="/$"){if(t===0)break;t--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||t++;a=d}while(a)}function Xu(t){var n=t.firstChild;for(n&&n.nodeType===10&&(n=n.nextSibling);n;){var a=n;switch(n=n.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":Xu(a),tc(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}t.removeChild(a)}}function L_(t,n,a,d){for(;t.nodeType===1;){var w=a;if(t.nodeName.toLowerCase()!==n.toLowerCase()){if(!d&&(t.nodeName!=="INPUT"||t.type!=="hidden"))break}else if(d){if(!t[Ms])switch(n){case"meta":if(!t.hasAttribute("itemprop"))break;return t;case"link":if(E=t.getAttribute("rel"),E==="stylesheet"&&t.hasAttribute("data-precedence"))break;if(E!==w.rel||t.getAttribute("href")!==(w.href==null||w.href===""?null:w.href)||t.getAttribute("crossorigin")!==(w.crossOrigin==null?null:w.crossOrigin)||t.getAttribute("title")!==(w.title==null?null:w.title))break;return t;case"style":if(t.hasAttribute("data-precedence"))break;return t;case"script":if(E=t.getAttribute("src"),(E!==(w.src==null?null:w.src)||t.getAttribute("type")!==(w.type==null?null:w.type)||t.getAttribute("crossorigin")!==(w.crossOrigin==null?null:w.crossOrigin))&&E&&t.hasAttribute("async")&&!t.hasAttribute("itemprop"))break;return t;default:return t}}else if(n==="input"&&t.type==="hidden"){var E=w.name==null?null:""+w.name;if(w.type==="hidden"&&t.getAttribute("name")===E)return t}else return t;if(t=Fn(t.nextSibling),t===null)break}return null}function R_(t,n,a){if(n==="")return null;for(;t.nodeType!==3;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!a||(t=Fn(t.nextSibling),t===null))return null;return t}function Cg(t,n){for(;t.nodeType!==8;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!n||(t=Fn(t.nextSibling),t===null))return null;return t}function Zu(t){return t.data==="$?"||t.data==="$~"}function Qu(t){return t.data==="$!"||t.data==="$?"&&t.ownerDocument.readyState!=="loading"}function M_(t,n){var a=t.ownerDocument;if(t.data==="$~")t._reactRetry=n;else if(t.data!=="$?"||a.readyState!=="loading")n();else{var d=function(){n(),a.removeEventListener("DOMContentLoaded",d)};a.addEventListener("DOMContentLoaded",d),t._reactRetry=d}}function Fn(t){for(;t!=null;t=t.nextSibling){var n=t.nodeType;if(n===1||n===3)break;if(n===8){if(n=t.data,n==="$"||n==="$!"||n==="$?"||n==="$~"||n==="&"||n==="F!"||n==="F")break;if(n==="/$"||n==="/&")return null}}return t}var Ju=null;function kg(t){t=t.nextSibling;for(var n=0;t;){if(t.nodeType===8){var a=t.data;if(a==="/$"||a==="/&"){if(n===0)return Fn(t.nextSibling);n--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||n++}t=t.nextSibling}return null}function Eg(t){t=t.previousSibling;for(var n=0;t;){if(t.nodeType===8){var a=t.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(n===0)return t;n--}else a!=="/$"&&a!=="/&"||n++}t=t.previousSibling}return null}function jg(t,n,a){switch(n=Qo(a),t){case"html":if(t=n.documentElement,!t)throw Error(s(452));return t;case"head":if(t=n.head,!t)throw Error(s(453));return t;case"body":if(t=n.body,!t)throw Error(s(454));return t;default:throw Error(s(451))}}function ga(t){for(var n=t.attributes;n.length;)t.removeAttributeNode(n[0]);tc(t)}var Un=new Map,Ng=new Set;function Jo(t){return typeof t.getRootNode=="function"?t.getRootNode():t.nodeType===9?t:t.ownerDocument}var kr=X.d;X.d={f:O_,r:B_,D:I_,C:z_,L:H_,m:P_,X:U_,S:F_,M:$_};function O_(){var t=kr.f(),n=qo();return t||n}function B_(t){var n=Bi(t);n!==null&&n.tag===5&&n.type==="form"?Wp(n):kr.r(t)}var ps=typeof document>"u"?null:document;function Tg(t,n,a){var d=ps;if(d&&typeof n=="string"&&n){var w=Mn(n);w='link[rel="'+t+'"][href="'+w+'"]',typeof a=="string"&&(w+='[crossorigin="'+a+'"]'),Ng.has(w)||(Ng.add(w),t={rel:t,crossOrigin:a,href:n},d.querySelector(w)===null&&(n=d.createElement("link"),Jt(n,"link",t),qt(n),d.head.appendChild(n)))}}function I_(t){kr.D(t),Tg("dns-prefetch",t,null)}function z_(t,n){kr.C(t,n),Tg("preconnect",t,n)}function H_(t,n,a){kr.L(t,n,a);var d=ps;if(d&&t&&n){var w='link[rel="preload"][as="'+Mn(n)+'"]';n==="image"&&a&&a.imageSrcSet?(w+='[imagesrcset="'+Mn(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(w+='[imagesizes="'+Mn(a.imageSizes)+'"]')):w+='[href="'+Mn(t)+'"]';var E=w;switch(n){case"style":E=ms(t);break;case"script":E=gs(t)}Un.has(E)||(t=m({rel:"preload",href:n==="image"&&a&&a.imageSrcSet?void 0:t,as:n},a),Un.set(E,t),d.querySelector(w)!==null||n==="style"&&d.querySelector(xa(E))||n==="script"&&d.querySelector(va(E))||(n=d.createElement("link"),Jt(n,"link",t),qt(n),d.head.appendChild(n)))}}function P_(t,n){kr.m(t,n);var a=ps;if(a&&t){var d=n&&typeof n.as=="string"?n.as:"script",w='link[rel="modulepreload"][as="'+Mn(d)+'"][href="'+Mn(t)+'"]',E=w;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":E=gs(t)}if(!Un.has(E)&&(t=m({rel:"modulepreload",href:t},n),Un.set(E,t),a.querySelector(w)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(va(E)))return}d=a.createElement("link"),Jt(d,"link",t),qt(d),a.head.appendChild(d)}}}function F_(t,n,a){kr.S(t,n,a);var d=ps;if(d&&t){var w=Ii(d).hoistableStyles,E=ms(t);n=n||"default";var M=w.get(E);if(!M){var G={loading:0,preload:null};if(M=d.querySelector(xa(E)))G.loading=5;else{t=m({rel:"stylesheet",href:t,"data-precedence":n},a),(a=Un.get(E))&&ed(t,a);var ee=M=d.createElement("link");qt(ee),Jt(ee,"link",t),ee._p=new Promise(function(le,he){ee.onload=le,ee.onerror=he}),ee.addEventListener("load",function(){G.loading|=1}),ee.addEventListener("error",function(){G.loading|=2}),G.loading|=4,el(M,n,d)}M={type:"stylesheet",instance:M,count:1,state:G},w.set(E,M)}}}function U_(t,n){kr.X(t,n);var a=ps;if(a&&t){var d=Ii(a).hoistableScripts,w=gs(t),E=d.get(w);E||(E=a.querySelector(va(w)),E||(t=m({src:t,async:!0},n),(n=Un.get(w))&&td(t,n),E=a.createElement("script"),qt(E),Jt(E,"link",t),a.head.appendChild(E)),E={type:"script",instance:E,count:1,state:null},d.set(w,E))}}function $_(t,n){kr.M(t,n);var a=ps;if(a&&t){var d=Ii(a).hoistableScripts,w=gs(t),E=d.get(w);E||(E=a.querySelector(va(w)),E||(t=m({src:t,async:!0,type:"module"},n),(n=Un.get(w))&&td(t,n),E=a.createElement("script"),qt(E),Jt(E,"link",t),a.head.appendChild(E)),E={type:"script",instance:E,count:1,state:null},d.set(w,E))}}function Ag(t,n,a,d){var w=(w=Q.current)?Jo(w):null;if(!w)throw Error(s(446));switch(t){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(n=ms(a.href),a=Ii(w).hoistableStyles,d=a.get(n),d||(d={type:"style",instance:null,count:0,state:null},a.set(n,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){t=ms(a.href);var E=Ii(w).hoistableStyles,M=E.get(t);if(M||(w=w.ownerDocument||w,M={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},E.set(t,M),(E=w.querySelector(xa(t)))&&!E._p&&(M.instance=E,M.state.loading=5),Un.has(t)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},Un.set(t,a),E||q_(w,t,a,M.state))),n&&d===null)throw Error(s(528,""));return M}if(n&&d!==null)throw Error(s(529,""));return null;case"script":return n=a.async,a=a.src,typeof a=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=gs(a),a=Ii(w).hoistableScripts,d=a.get(n),d||(d={type:"script",instance:null,count:0,state:null},a.set(n,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,t))}}function ms(t){return'href="'+Mn(t)+'"'}function xa(t){return'link[rel="stylesheet"]['+t+"]"}function Dg(t){return m({},t,{"data-precedence":t.precedence,precedence:null})}function q_(t,n,a,d){t.querySelector('link[rel="preload"][as="style"]['+n+"]")?d.loading=1:(n=t.createElement("link"),d.preload=n,n.addEventListener("load",function(){return d.loading|=1}),n.addEventListener("error",function(){return d.loading|=2}),Jt(n,"link",a),qt(n),t.head.appendChild(n))}function gs(t){return'[src="'+Mn(t)+'"]'}function va(t){return"script[async]"+t}function Lg(t,n,a){if(n.count++,n.instance===null)switch(n.type){case"style":var d=t.querySelector('style[data-href~="'+Mn(a.href)+'"]');if(d)return n.instance=d,qt(d),d;var w=m({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return d=(t.ownerDocument||t).createElement("style"),qt(d),Jt(d,"style",w),el(d,a.precedence,t),n.instance=d;case"stylesheet":w=ms(a.href);var E=t.querySelector(xa(w));if(E)return n.state.loading|=4,n.instance=E,qt(E),E;d=Dg(a),(w=Un.get(w))&&ed(d,w),E=(t.ownerDocument||t).createElement("link"),qt(E);var M=E;return M._p=new Promise(function(G,ee){M.onload=G,M.onerror=ee}),Jt(E,"link",d),n.state.loading|=4,el(E,a.precedence,t),n.instance=E;case"script":return E=gs(a.src),(w=t.querySelector(va(E)))?(n.instance=w,qt(w),w):(d=a,(w=Un.get(E))&&(d=m({},a),td(d,w)),t=t.ownerDocument||t,w=t.createElement("script"),qt(w),Jt(w,"link",d),t.head.appendChild(w),n.instance=w);case"void":return null;default:throw Error(s(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(d=n.instance,n.state.loading|=4,el(d,a.precedence,t));return n.instance}function el(t,n,a){for(var d=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),w=d.length?d[d.length-1]:null,E=w,M=0;M<d.length;M++){var G=d[M];if(G.dataset.precedence===n)E=G;else if(E!==w)break}E?E.parentNode.insertBefore(t,E.nextSibling):(n=a.nodeType===9?a.head:a,n.insertBefore(t,n.firstChild))}function ed(t,n){t.crossOrigin==null&&(t.crossOrigin=n.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=n.referrerPolicy),t.title==null&&(t.title=n.title)}function td(t,n){t.crossOrigin==null&&(t.crossOrigin=n.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=n.referrerPolicy),t.integrity==null&&(t.integrity=n.integrity)}var tl=null;function Rg(t,n,a){if(tl===null){var d=new Map,w=tl=new Map;w.set(a,d)}else w=tl,d=w.get(a),d||(d=new Map,w.set(a,d));if(d.has(t))return d;for(d.set(t,null),a=a.getElementsByTagName(t),w=0;w<a.length;w++){var E=a[w];if(!(E[Ms]||E[Kt]||t==="link"&&E.getAttribute("rel")==="stylesheet")&&E.namespaceURI!=="http://www.w3.org/2000/svg"){var M=E.getAttribute(n)||"";M=t+M;var G=d.get(M);G?G.push(E):d.set(M,[E])}}return d}function Mg(t,n,a){t=t.ownerDocument||t,t.head.insertBefore(a,n==="title"?t.querySelector("head > title"):null)}function W_(t,n,a){if(a===1||n.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof n.precedence!="string"||typeof n.href!="string"||n.href==="")break;return!0;case"link":if(typeof n.rel!="string"||typeof n.href!="string"||n.href===""||n.onLoad||n.onError)break;switch(n.rel){case"stylesheet":return t=n.disabled,typeof n.precedence=="string"&&t==null;default:return!0}case"script":if(n.async&&typeof n.async!="function"&&typeof n.async!="symbol"&&!n.onLoad&&!n.onError&&n.src&&typeof n.src=="string")return!0}return!1}function Og(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function G_(t,n,a,d){if(a.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var w=ms(d.href),E=n.querySelector(xa(w));if(E){n=E._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(t.count++,t=nl.bind(t),n.then(t,t)),a.state.loading|=4,a.instance=E,qt(E);return}E=n.ownerDocument||n,d=Dg(d),(w=Un.get(w))&&ed(d,w),E=E.createElement("link"),qt(E);var M=E;M._p=new Promise(function(G,ee){M.onload=G,M.onerror=ee}),Jt(E,"link",d),a.instance=E}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(a,n),(n=a.state.preload)&&(a.state.loading&3)===0&&(t.count++,a=nl.bind(t),n.addEventListener("load",a),n.addEventListener("error",a))}}var nd=0;function V_(t,n){return t.stylesheets&&t.count===0&&il(t,t.stylesheets),0<t.count||0<t.imgCount?function(a){var d=setTimeout(function(){if(t.stylesheets&&il(t,t.stylesheets),t.unsuspend){var E=t.unsuspend;t.unsuspend=null,E()}},6e4+n);0<t.imgBytes&&nd===0&&(nd=62500*j_());var w=setTimeout(function(){if(t.waitingForImages=!1,t.count===0&&(t.stylesheets&&il(t,t.stylesheets),t.unsuspend)){var E=t.unsuspend;t.unsuspend=null,E()}},(t.imgBytes>nd?50:800)+n);return t.unsuspend=a,function(){t.unsuspend=null,clearTimeout(d),clearTimeout(w)}}:null}function nl(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)il(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var rl=null;function il(t,n){t.stylesheets=null,t.unsuspend!==null&&(t.count++,rl=new Map,n.forEach(Y_,t),rl=null,nl.call(t))}function Y_(t,n){if(!(n.state.loading&4)){var a=rl.get(t);if(a)var d=a.get(null);else{a=new Map,rl.set(t,a);for(var w=t.querySelectorAll("link[data-precedence],style[data-precedence]"),E=0;E<w.length;E++){var M=w[E];(M.nodeName==="LINK"||M.getAttribute("media")!=="not all")&&(a.set(M.dataset.precedence,M),d=M)}d&&a.set(null,d)}w=n.instance,M=w.getAttribute("data-precedence"),E=a.get(M)||d,E===d&&a.set(null,w),a.set(M,w),this.count++,d=nl.bind(this),w.addEventListener("load",d),w.addEventListener("error",d),E?E.parentNode.insertBefore(w,E.nextSibling):(t=t.nodeType===9?t.head:t,t.insertBefore(w,t.firstChild)),n.state.loading|=4}}var ba={$$typeof:_,Provider:null,Consumer:null,_currentValue:J,_currentValue2:J,_threadCount:0};function K_(t,n,a,d,w,E,M,G,ee){this.tag=1,this.containerInfo=t,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Ls(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ls(0),this.hiddenUpdates=Ls(null),this.identifierPrefix=d,this.onUncaughtError=w,this.onCaughtError=E,this.onRecoverableError=M,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=ee,this.incompleteTransitions=new Map}function Bg(t,n,a,d,w,E,M,G,ee,le,he,xe){return t=new K_(t,n,a,M,ee,le,he,xe,G),n=1,E===!0&&(n|=24),E=_n(3,null,null,n),t.current=E,E.stateNode=t,n=Oc(),n.refCount++,t.pooledCache=n,n.refCount++,E.memoizedState={element:d,isDehydrated:a,cache:n},Hc(E),t}function Ig(t){return t?(t=Vi,t):Vi}function zg(t,n,a,d,w,E){w=Ig(w),d.context===null?d.context=w:d.pendingContext=w,d=Br(n),d.payload={element:a},E=E===void 0?null:E,E!==null&&(d.callback=E),a=Ir(t,d,n),a!==null&&(xn(a,t,n),Zs(a,t,n))}function Hg(t,n){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var a=t.retryLane;t.retryLane=a!==0&&a<n?a:n}}function rd(t,n){Hg(t,n),(t=t.alternate)&&Hg(t,n)}function Pg(t){if(t.tag===13||t.tag===31){var n=ci(t,67108864);n!==null&&xn(n,t,67108864),rd(t,67108864)}}function Fg(t){if(t.tag===13||t.tag===31){var n=En();n=Ql(n);var a=ci(t,n);a!==null&&xn(a,t,n),rd(t,n)}}var sl=!0;function X_(t,n,a,d){var w=$.T;$.T=null;var E=X.p;try{X.p=2,id(t,n,a,d)}finally{X.p=E,$.T=w}}function Z_(t,n,a,d){var w=$.T;$.T=null;var E=X.p;try{X.p=8,id(t,n,a,d)}finally{X.p=E,$.T=w}}function id(t,n,a,d){if(sl){var w=sd(d);if(w===null)qu(t,n,d,al,a),$g(t,d);else if(J_(w,t,n,a,d))d.stopPropagation();else if($g(t,d),n&4&&-1<Q_.indexOf(t)){for(;w!==null;){var E=Bi(w);if(E!==null)switch(E.tag){case 3:if(E=E.stateNode,E.current.memoizedState.isDehydrated){var M=Be(E.pendingLanes);if(M!==0){var G=E;for(G.pendingLanes|=2,G.entangledLanes|=2;M;){var ee=1<<31-$e(M);G.entanglements[1]|=ee,M&=~ee}er(E),(ut&6)===0&&(Uo=Ge()+500,fa(0))}}break;case 31:case 13:G=ci(E,2),G!==null&&xn(G,E,2),qo(),rd(E,2)}if(E=sd(d),E===null&&qu(t,n,d,al,a),E===w)break;w=E}w!==null&&d.stopPropagation()}else qu(t,n,d,null,a)}}function sd(t){return t=oc(t),ad(t)}var al=null;function ad(t){if(al=null,t=Oi(t),t!==null){var n=u(t);if(n===null)t=null;else{var a=n.tag;if(a===13){if(t=p(n),t!==null)return t;t=null}else if(a===31){if(t=l(n),t!==null)return t;t=null}else if(a===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;t=null}else n!==t&&(t=null)}}return al=t,null}function Ug(t){switch(t){case"beforetoggle":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"toggle":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 2;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"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(ct()){case de:return 2;case be:return 8;case re:case Se:return 32;case Ce:return 268435456;default:return 32}default:return 32}}var od=!1,Yr=null,Kr=null,Xr=null,ya=new Map,_a=new Map,Zr=[],Q_="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".split(" ");function $g(t,n){switch(t){case"focusin":case"focusout":Yr=null;break;case"dragenter":case"dragleave":Kr=null;break;case"mouseover":case"mouseout":Xr=null;break;case"pointerover":case"pointerout":ya.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":_a.delete(n.pointerId)}}function Sa(t,n,a,d,w,E){return t===null||t.nativeEvent!==E?(t={blockedOn:n,domEventName:a,eventSystemFlags:d,nativeEvent:E,targetContainers:[w]},n!==null&&(n=Bi(n),n!==null&&Pg(n)),t):(t.eventSystemFlags|=d,n=t.targetContainers,w!==null&&n.indexOf(w)===-1&&n.push(w),t)}function J_(t,n,a,d,w){switch(n){case"focusin":return Yr=Sa(Yr,t,n,a,d,w),!0;case"dragenter":return Kr=Sa(Kr,t,n,a,d,w),!0;case"mouseover":return Xr=Sa(Xr,t,n,a,d,w),!0;case"pointerover":var E=w.pointerId;return ya.set(E,Sa(ya.get(E)||null,t,n,a,d,w)),!0;case"gotpointercapture":return E=w.pointerId,_a.set(E,Sa(_a.get(E)||null,t,n,a,d,w)),!0}return!1}function qg(t){var n=Oi(t.target);if(n!==null){var a=u(n);if(a!==null){if(n=a.tag,n===13){if(n=p(a),n!==null){t.blockedOn=n,rf(t.priority,function(){Fg(a)});return}}else if(n===31){if(n=l(a),n!==null){t.blockedOn=n,rf(t.priority,function(){Fg(a)});return}}else if(n===3&&a.stateNode.current.memoizedState.isDehydrated){t.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}t.blockedOn=null}function ol(t){if(t.blockedOn!==null)return!1;for(var n=t.targetContainers;0<n.length;){var a=sd(t.nativeEvent);if(a===null){a=t.nativeEvent;var d=new a.constructor(a.type,a);ac=d,a.target.dispatchEvent(d),ac=null}else return n=Bi(a),n!==null&&Pg(n),t.blockedOn=a,!1;n.shift()}return!0}function Wg(t,n,a){ol(t)&&a.delete(n)}function e1(){od=!1,Yr!==null&&ol(Yr)&&(Yr=null),Kr!==null&&ol(Kr)&&(Kr=null),Xr!==null&&ol(Xr)&&(Xr=null),ya.forEach(Wg),_a.forEach(Wg)}function ll(t,n){t.blockedOn===n&&(t.blockedOn=null,od||(od=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,e1)))}var cl=null;function Gg(t){cl!==t&&(cl=t,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){cl===t&&(cl=null);for(var n=0;n<t.length;n+=3){var a=t[n],d=t[n+1],w=t[n+2];if(typeof d!="function"){if(ad(d||a)===null)continue;break}var E=Bi(a);E!==null&&(t.splice(n,3),n-=3,su(E,{pending:!0,data:w,method:a.method,action:d},d,w))}}))}function xs(t){function n(ee){return ll(ee,t)}Yr!==null&&ll(Yr,t),Kr!==null&&ll(Kr,t),Xr!==null&&ll(Xr,t),ya.forEach(n),_a.forEach(n);for(var a=0;a<Zr.length;a++){var d=Zr[a];d.blockedOn===t&&(d.blockedOn=null)}for(;0<Zr.length&&(a=Zr[0],a.blockedOn===null);)qg(a),a.blockedOn===null&&Zr.shift();if(a=(t.ownerDocument||t).$$reactFormReplay,a!=null)for(d=0;d<a.length;d+=3){var w=a[d],E=a[d+1],M=w[dn]||null;if(typeof E=="function")M||Gg(a);else if(M){var G=null;if(E&&E.hasAttribute("formAction")){if(w=E,M=E[dn]||null)G=M.formAction;else if(ad(w)!==null)continue}else G=M.action;typeof G=="function"?a[d+1]=G:(a.splice(d,3),d-=3),Gg(a)}}}function Vg(){function t(E){E.canIntercept&&E.info==="react-transition"&&E.intercept({handler:function(){return new Promise(function(M){return w=M})},focusReset:"manual",scroll:"manual"})}function n(){w!==null&&(w(),w=null),d||setTimeout(a,20)}function a(){if(!d&&!navigation.transition){var E=navigation.currentEntry;E&&E.url!=null&&navigation.navigate(E.url,{state:E.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var d=!1,w=null;return navigation.addEventListener("navigate",t),navigation.addEventListener("navigatesuccess",n),navigation.addEventListener("navigateerror",n),setTimeout(a,100),function(){d=!0,navigation.removeEventListener("navigate",t),navigation.removeEventListener("navigatesuccess",n),navigation.removeEventListener("navigateerror",n),w!==null&&(w(),w=null)}}}function ld(t){this._internalRoot=t}ul.prototype.render=ld.prototype.render=function(t){var n=this._internalRoot;if(n===null)throw Error(s(409));var a=n.current,d=En();zg(a,d,t,n,null,null)},ul.prototype.unmount=ld.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var n=t.containerInfo;zg(t.current,2,null,t,null,null),qo(),n[Mi]=null}};function ul(t){this._internalRoot=t}ul.prototype.unstable_scheduleHydration=function(t){if(t){var n=nf();t={blockedOn:null,target:t,priority:n};for(var a=0;a<Zr.length&&n!==0&&n<Zr[a].priority;a++);Zr.splice(a,0,t),a===0&&qg(t)}};var Yg=r.version;if(Yg!=="19.2.4")throw Error(s(527,Yg,"19.2.4"));X.findDOMNode=function(t){var n=t._reactInternals;if(n===void 0)throw typeof t.render=="function"?Error(s(188)):(t=Object.keys(t).join(","),Error(s(268,t)));return t=f(n),t=t!==null?g(t):null,t=t===null?null:t.stateNode,t};var t1={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:$,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var dl=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!dl.isDisabled&&dl.supportsFiber)try{st=dl.inject(t1),it=dl}catch{}}return Ca.createRoot=function(t,n){if(!c(t))throw Error(s(299));var a=!1,d="",w=tm,E=nm,M=rm;return n!=null&&(n.unstable_strictMode===!0&&(a=!0),n.identifierPrefix!==void 0&&(d=n.identifierPrefix),n.onUncaughtError!==void 0&&(w=n.onUncaughtError),n.onCaughtError!==void 0&&(E=n.onCaughtError),n.onRecoverableError!==void 0&&(M=n.onRecoverableError)),n=Bg(t,1,!1,null,null,a,d,null,w,E,M,Vg),t[Mi]=n.current,$u(t),new ld(n)},Ca.hydrateRoot=function(t,n,a){if(!c(t))throw Error(s(299));var d=!1,w="",E=tm,M=nm,G=rm,ee=null;return a!=null&&(a.unstable_strictMode===!0&&(d=!0),a.identifierPrefix!==void 0&&(w=a.identifierPrefix),a.onUncaughtError!==void 0&&(E=a.onUncaughtError),a.onCaughtError!==void 0&&(M=a.onCaughtError),a.onRecoverableError!==void 0&&(G=a.onRecoverableError),a.formState!==void 0&&(ee=a.formState)),n=Bg(t,1,!0,n,a??null,d,w,ee,E,M,G,Vg),n.context=Ig(null),a=n.current,d=En(),d=Ql(d),w=Br(d),w.callback=null,Ir(a,w,d),a=d,n.current.lanes=a,Rs(n,a),er(n),t[Mi]=n.current,$u(t),new ul(n)},Ca.version="19.2.4",Ca}var ix;function p1(){if(ix)return dd.exports;ix=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(),dd.exports=f1(),dd.exports}var m1=p1();const g1=Ol(m1);function x1(e,r){if(e instanceof RegExp)return{keys:!1,pattern:e};var i,s,c,u,p=[],l="",h=e.split("/");for(h[0]||h.shift();c=h.shift();)i=c[0],i==="*"?(p.push(i),l+=c[1]==="?"?"(?:/(.*))?":"/(.*)"):i===":"?(s=c.indexOf("?",1),u=c.indexOf(".",1),p.push(c.substring(1,~s?s:~u?u:c.length)),l+=~s&&!~u?"(?:/([^/]+?))?":"/([^/]+?)",~u&&(l+=(~s?"?":"")+"\\"+c.substring(u))):l+="/"+c;return{keys:p,pattern:new RegExp("^"+l+(r?"(?=$|/)":"/?$"),"i")}}var md={exports:{}},gd={};/**
50
50
  * @license React
51
51
  * use-sync-external-store-shim.production.js
@@ -54,7 +54,7 @@ Error generating stack: `+d.message+`
54
54
  *
55
55
  * This source code is licensed under the MIT license found in the
56
56
  * LICENSE file in the root directory of this source tree.
57
- */var sx;function v1(){if(sx)return gd;sx=1;var e=Bl();function r(m,x){return m===x&&(m!==0||1/m===1/x)||m!==m&&x!==x}var i=typeof Object.is=="function"?Object.is:r,s=e.useState,c=e.useEffect,u=e.useLayoutEffect,p=e.useDebugValue;function l(m,x){var S=x(),k=s({inst:{value:S,getSnapshot:x}}),C=k[0].inst,b=k[1];return u(function(){C.value=S,C.getSnapshot=x,h(C)&&b({inst:C})},[m,S,x]),c(function(){return h(C)&&b({inst:C}),m(function(){h(C)&&b({inst:C})})},[m]),p(S),S}function h(m){var x=m.getSnapshot;m=m.value;try{var S=x();return!i(m,S)}catch{return!0}}function f(m,x){return x()}var g=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:l;return gd.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:g,gd}var ax;function b1(){return ax||(ax=1,md.exports=v1()),md.exports}var y1=b1();const _1=c1.useInsertionEffect,S1=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",w1=S1?P.useLayoutEffect:P.useEffect,C1=_1||w1,Xv=e=>{const r=P.useRef([e,(...i)=>r[0](...i)]).current;return C1(()=>{r[0]=e}),r[1]},k1="popstate",ch="pushState",uh="replaceState",E1="hashchange",ox=[k1,ch,uh,E1],j1=e=>{for(const r of ox)addEventListener(r,e);return()=>{for(const r of ox)removeEventListener(r,e)}},Zv=(e,r)=>y1.useSyncExternalStore(j1,e,r),lx=()=>location.search,N1=({ssrSearch:e}={})=>Zv(lx,e!=null?()=>e:lx),cx=()=>location.pathname,T1=({ssrPath:e}={})=>Zv(cx,e!=null?()=>e:cx),A1=(e,{replace:r=!1,state:i=null}={})=>history[r?uh:ch](i,"",e),D1=(e={})=>[T1(e),A1],ux=Symbol.for("wouter_v3");if(typeof history<"u"&&typeof window[ux]>"u"){for(const e of[ch,uh]){const r=history[e];history[e]=function(){const i=r.apply(this,arguments),s=new Event(e);return s.arguments=arguments,dispatchEvent(s),i}}Object.defineProperty(window,ux,{value:!0})}const L1=(e,r)=>r.toLowerCase().indexOf(e.toLowerCase())?"~"+r:r.slice(e.length)||"/",Qv=(e="")=>e==="/"?"":e,R1=(e,r)=>e[0]==="~"?e.slice(1):Qv(r)+e,M1=(e="",r)=>L1(dx(Qv(e)),dx(r)),dx=e=>{try{return decodeURI(e)}catch{return e}},Jv={hook:D1,searchHook:N1,parser:x1,base:"",ssrPath:void 0,ssrSearch:void 0,ssrContext:void 0,hrefs:e=>e,aroundNav:(e,r,i)=>e(r,i)},eb=P.createContext(Jv),Ts=()=>P.useContext(eb),tb={},nb=P.createContext(tb),O1=()=>P.useContext(nb),Il=e=>{const[r,i]=e.hook(e);return[M1(e.base,r),Xv((s,c)=>e.aroundNav(i,R1(s,e.base),c))]},ar=()=>Il(Ts()),dh=(e,r,i,s)=>{const{pattern:c,keys:u}=r instanceof RegExp?{keys:!1,pattern:r}:e(r||"*",s),p=c.exec(i)||[],[l,...h]=p;return l!==void 0?[!0,(()=>{const f=u!==!1?Object.fromEntries(u.map((m,x)=>[m,h[x]])):p.groups;let g={...h};return f&&Object.assign(g,f),g})(),...s?[l]:[]]:[!1,null]},hh=e=>dh(Ts().parser,e,ar()[0]),B1=({children:e,...r})=>{var g,m,x;const i=Ts(),s=r.hook?Jv:i;let c=s;const[u,p=r.ssrSearch??""]=((g=r.ssrPath)==null?void 0:g.split("?"))??[];u&&(r.ssrSearch=p,r.ssrPath=u),r.hrefs=r.hrefs??((m=r.hook)==null?void 0:m.hrefs),r.searchHook=r.searchHook??((x=r.hook)==null?void 0:x.searchHook);let l=P.useRef({}),h=l.current,f=h;for(let S in s){const k=S==="base"?s[S]+(r[S]??""):r[S]??s[S];h===f&&k!==f[S]&&(l.current=f={...f}),f[S]=k,(k!==s[S]||k!==c[S])&&(c=f)}return P.createElement(eb.Provider,{value:c,children:e})},hx=({children:e,component:r},i)=>r?P.createElement(r,{params:i}):typeof e=="function"?e(i):e,I1=e=>{let r=P.useRef(tb);const i=r.current;return r.current=Object.keys(e).length!==Object.keys(i).length||Object.entries(e).some(([s,c])=>c!==i[s])?e:i},ka=({path:e,nest:r,match:i,...s})=>{const c=Ts(),[u]=Il(c),[p,l,h]=i??dh(c.parser,e,u,r),f=I1({...O1(),...l});if(!p)return null;const g=h?P.createElement(B1,{base:h},hx(s,f)):hx(s,f);return P.createElement(nb.Provider,{value:f,children:g})},An=P.forwardRef((e,r)=>{const i=Ts(),[s,c]=Il(i),{to:u="",href:p=u,onClick:l,asChild:h,children:f,className:g,replace:m,state:x,transition:S,...k}=e,C=Xv(y=>{y.ctrlKey||y.metaKey||y.altKey||y.shiftKey||y.button!==0||(l==null||l(y),y.defaultPrevented||(y.preventDefault(),c(p,e)))}),b=i.hrefs(p[0]==="~"?p.slice(1):i.base+p,i);return h&&P.isValidElement(f)?P.cloneElement(f,{onClick:C,href:b}):P.createElement("a",{...k,onClick:C,href:b,className:g!=null&&g.call?g(s===p):g,children:f,ref:r})}),rb=e=>Array.isArray(e)?e.flatMap(r=>rb(r&&r.type===P.Fragment?r.props.children:r)):[e],z1=({children:e,location:r})=>{const i=Ts(),[s]=Il(i);for(const c of rb(e)){let u=0;if(P.isValidElement(c)&&(u=dh(i.parser,c.props.path,r||s,c.props.nest))[0])return P.cloneElement(c,{match:u})}return null},fx=e=>{let r;const i=new Set,s=(f,g)=>{const m=typeof f=="function"?f(r):f;if(!Object.is(m,r)){const x=r;r=g??(typeof m!="object"||m===null)?m:Object.assign({},r,m),i.forEach(S=>S(r,x))}},c=()=>r,l={setState:s,getState:c,getInitialState:()=>h,subscribe:f=>(i.add(f),()=>i.delete(f))},h=r=e(s,c,l);return l},H1=(e=>e?fx(e):fx),P1=e=>e;function F1(e,r=P1){const i=ln.useSyncExternalStore(e.subscribe,ln.useCallback(()=>r(e.getState()),[e,r]),ln.useCallback(()=>r(e.getInitialState()),[e,r]));return ln.useDebugValue(i),i}const px=e=>{const r=H1(e),i=s=>F1(r,s);return Object.assign(i,r),i},qn=(e=>e?px(e):px);async function ye(e,r={}){const i=localStorage.getItem("openfox_token"),s={...r.headers instanceof Headers?Object.fromEntries(r.headers.entries()):r.headers,...i?{"x-session-token":i}:{}};return fetch(e,{...r,headers:s})}function U1(e){return typeof e=="object"&&e!==null&&"type"in e&&"payload"in e}function Sl(){if(typeof crypto<"u"&&crypto.randomUUID)try{return crypto.randomUUID()}catch{}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const r=Math.random()*16|0;return(e==="x"?r:r&3|8).toString(16)})}class $1{constructor(r){tr(this,"ws",null);tr(this,"handlers",new Set);tr(this,"statusHandler",null);tr(this,"baseUrl");tr(this,"isReconnecting",!1);tr(this,"connectingPromise",null);tr(this,"lastCloseCode",0);tr(this,"reconnectAttempts",0);tr(this,"manualReconnectScheduled",!1);this.baseUrl=r}getUrl(){const r=localStorage.getItem("openfox_token");if(r){const i=this.baseUrl.includes("?")?"&":"?";return`${this.baseUrl}${i}token=${encodeURIComponent(r)}`}return this.baseUrl}setToken(r){localStorage.setItem("openfox_token",r)}clearToken(){localStorage.removeItem("openfox_token")}hasToken(){return!!localStorage.getItem("openfox_token")}getLastCloseCode(){return this.lastCloseCode}onStatusChange(r){this.statusHandler=r}connect(){var r,i;return((r=this.ws)==null?void 0:r.readyState)===WebSocket.OPEN?Promise.resolve():(this.lastCloseCode=0,this.isReconnecting=!1,this.connectingPromise&&((i=this.ws)==null?void 0:i.readyState)===WebSocket.CONNECTING?this.connectingPromise:(this.connectingPromise=new Promise((s,c)=>{try{const u=this.getUrl();this.ws=new WebSocket(u);const p=setTimeout(()=>{var l;((l=this.ws)==null?void 0:l.readyState)===WebSocket.CONNECTING&&(this.ws.close(),c(new Error("Connection timeout")))},5e3);this.ws.onopen=()=>{var l;clearTimeout(p),this.isReconnecting=!1,this.connectingPromise=null,(l=this.statusHandler)==null||l.call(this,"connected"),s()},this.ws.onclose=l=>{var h,f,g;clearTimeout(p),this.lastCloseCode=l.code,((h=this.ws)==null?void 0:h.readyState)===WebSocket.CONNECTING?(this.connectingPromise=null,(f=this.statusHandler)==null||f.call(this,"disconnected"),c(new Error(`Connection closed: ${l.code}`))):(this.connectingPromise=null,(g=this.statusHandler)==null||g.call(this,"disconnected"),this.attemptReconnect())},this.ws.onerror=l=>{clearTimeout(p),console.error("WebSocket error:",l),this.connectingPromise=null,c(l)},this.ws.onmessage=l=>{try{const h=JSON.parse(l.data);U1(h)&&this.handlers.forEach(f=>f(h))}catch(h){console.error("Failed to parse WebSocket message:",h)}}}catch(u){this.connectingPromise=null,c(u)}}),this.connectingPromise))}attemptReconnect(){var c;if(([1e3,1005,1006,4e3].includes(this.lastCloseCode)||this.lastCloseCode===0)&&this.hasToken()){console.log("[WS] Auth failure or initial failure with token - not auto-reconnecting, awaiting user action");return}if(this.isReconnecting||this.manualReconnectScheduled)return;this.isReconnecting=!0,(c=this.statusHandler)==null||c.call(this,"reconnecting");const s=Math.min(1e3*Math.pow(2,this.reconnectAttempts||0),3e4);this.reconnectAttempts=(this.reconnectAttempts||0)+1,setTimeout(()=>{this.isReconnecting=!1,this.manualReconnectScheduled=!1,this.connect().catch(()=>{})},s)}reconnect(){this.manualReconnectScheduled=!0,this.isReconnecting=!1,this.lastCloseCode=0,this.connectingPromise=null,this.connect().catch(()=>{})}disconnect(){this.isReconnecting=!1,this.reconnectAttempts=0,this.ws&&(this.ws.close(),this.ws=null)}resetReconnectAttempts(){this.reconnectAttempts=0}send(r,i){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket not connected");const s=Sl(),c={id:s,type:r,payload:i};return this.ws.send(JSON.stringify(c)),s}subscribe(r){return this.handlers.add(r),()=>this.handlers.delete(r)}get isConnected(){var r;return((r=this.ws)==null?void 0:r.readyState)===WebSocket.OPEN}}const q1=`ws://${window.location.hostname}:${window.location.port||"10469"}/ws`,zt=new $1(q1);let hl=[],xd=null,wl=null;function W1(){xd===null&&(xd=requestAnimationFrame(()=>{xd=null,wl==null||wl()}))}const rr=qn()((e,r)=>(wl=()=>{if(hl.length===0)return;const i=hl;hl=[],e(s=>({logs:[...s.logs,...i]}))},{workdir:null,status:null,logs:[],config:null,loading:!1,setWorkdir:i=>{r().workdir!==i&&(e({workdir:i,status:null,logs:[],config:null,loading:!0}),i&&(r().fetchStatus(),r().fetchConfig()))},fetchStatus:async()=>{const i=r().workdir;if(i)try{const c=await(await ye(`/api/dev-server?workdir=${encodeURIComponent(i)}`)).json();e({status:c,loading:!1})}catch{e({loading:!1})}},fetchConfig:async()=>{const i=r().workdir;if(i)try{const c=await(await ye(`/api/dev-server/config?workdir=${encodeURIComponent(i)}`)).json();e({config:c.config??null})}catch{}},fetchLogs:async()=>{const i=r().workdir;if(i)try{const u=(await(await ye(`/api/dev-server/logs?workdir=${encodeURIComponent(i)}`)).json()).logs.map(p=>({stream:p.stream,content:p.content}));e({logs:u})}catch{}},start:async()=>{const i=r().workdir;if(i)try{const c=await(await ye(`/api/dev-server/start?workdir=${encodeURIComponent(i)}`,{method:"POST"})).json();e({status:c,logs:[]})}catch{}},stop:async()=>{const i=r().workdir;if(i)try{const c=await(await ye(`/api/dev-server/stop?workdir=${encodeURIComponent(i)}`,{method:"POST"})).json();e({status:c})}catch{}},restart:async()=>{const i=r().workdir;if(i)try{const c=await(await ye(`/api/dev-server/restart?workdir=${encodeURIComponent(i)}`,{method:"POST"})).json();e({status:c,logs:[]})}catch{}},saveConfig:async i=>{const s=r().workdir;if(s)try{const u=await(await ye(`/api/dev-server/config?workdir=${encodeURIComponent(s)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})).json();e({config:u.config??i}),r().fetchStatus()}catch{}},handleMessage:i=>{const s=r().workdir;if(s)switch(i.type){case"devServer.output":{const c=i.payload;if(c.workdir!==s)return;hl.push({stream:c.stream,content:c.content}),W1();break}case"devServer.state":{const c=i.payload;if(c.workdir!==s)return;e(u=>({status:u.status?{...u.status,state:c.state,errorMessage:c.errorMessage}:u.status}));break}}}})),G1=3e4;function V1(e){switch(e){case"vllm":return"vLLM";case"sglang":return"SGLang";case"ollama":return"Ollama";case"llamacpp":return"llama.cpp";case"openai":return"OpenAI";case"anthropic":return"Anthropic";case"opencode-go":return"OpenCode Go";case"auto":return"Auto";case"unknown":return""}}const Pt=qn((e,r)=>({model:null,maxContext:2e5,llmUrl:null,llmStatus:"unknown",backend:"unknown",providers:[],activeProviderId:null,defaultModelSelection:null,loading:!1,activating:!1,error:null,autoRefreshInterval:null,fetchConfig:async()=>{e({loading:!0,error:null});try{const i=await ye("/api/config");if(!i.ok)throw new Error("Failed to fetch config");const s=await i.json();e({model:s.model,maxContext:s.maxContext,llmUrl:s.llmUrl,llmStatus:s.llmStatus,backend:s.backend,providers:s.providers??[],activeProviderId:s.activeProviderId??null,defaultModelSelection:s.defaultModelSelection??null,loading:!1})}catch(i){e({error:i instanceof Error?i.message:"Unknown error",loading:!1})}},refreshModel:async()=>{try{const i=await ye("/api/model/refresh",{method:"POST"});if(!i.ok)throw new Error("Failed to refresh model");const s=await i.json(),u=Ee.getState().currentSession;if(u!=null&&u.providerId&&u.providerModel){e({llmStatus:s.llmStatus,backend:s.backend});return}e({model:s.model,llmStatus:s.llmStatus,backend:s.backend})}catch(i){console.error("Failed to refresh model:",i)}},activateProvider:async i=>{const{activeProviderId:s,providers:c}=r();if(i===s)return!0;e({activating:!0,error:null});try{const u=await ye(`/api/providers/${i}/activate`,{method:"POST"});if(!u.ok){const l=await u.json();throw new Error(l.error??"Failed to activate provider")}const p=await u.json();return e({activeProviderId:p.activeProviderId,model:p.model,backend:p.backend,providers:c.map(l=>({...l,isActive:l.id===p.activeProviderId})),activating:!1}),!0}catch(u){return e({error:u instanceof Error?u.message:"Failed to switch provider",activating:!1}),!1}},syncFromSession:(i,s)=>{const{providers:c}=r();e({activeProviderId:i,model:s,defaultModelSelection:`${i}/${s}`,providers:c.map(u=>({...u,isActive:u.id===i}))})},updateModelContext:async(i,s,c)=>{e({activating:!0,error:null});try{const u=await ye(`/api/providers/${i}/models/${encodeURIComponent(s)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({contextWindow:c})});if(!u.ok){const h=await u.json();throw new Error(h.error??"Failed to update model context")}const p=await u.json(),{providers:l}=r();return e({providers:l.map(h=>h.id===i?{...h,models:h.models.map(f=>f.id===s?{...f,contextWindow:c,source:"user"}:f)}:h),activating:!1}),p.contextState&&Ee.getState().updateContextState(p.contextState),!0}catch(u){return e({error:u instanceof Error?u.message:"Failed to update model context",activating:!1}),!1}},refreshProviderModels:async i=>{e({activating:!0,error:null});try{const s=await ye(`/api/providers/${i}/refresh`,{method:"POST"});if(!s.ok){const p=await s.json();throw new Error(p.error??"Failed to refresh models")}const c=await s.json(),{providers:u}=r();return e({providers:u.map(p=>p.id===i?{...p,models:c.models}:p),activating:!1}),!0}catch(s){return e({error:s instanceof Error?s.message:"Failed to refresh models",activating:!1}),!1}},startAutoRefresh:()=>{const{autoRefreshInterval:i,refreshModel:s}=r();if(i)return;const c=setInterval(()=>{s()},G1);e({autoRefreshInterval:c})},stopAutoRefresh:()=>{const{autoRefreshInterval:i}=r();i&&(clearInterval(i),e({autoRefreshInterval:null}))},getActiveProvider:()=>{const{providers:i,activeProviderId:s}=r();return i.find(c=>c.id===s)},getModelContext:i=>{const{providers:s,activeProviderId:c}=r(),u=s.find(l=>l.id===c);if(!u)return 2e5;const p=u.models.find(l=>l.id===i);return(p==null?void 0:p.contextWindow)??2e5}})),Ut=qn((e,r)=>({projects:[],currentProject:null,loading:!1,listProjects:async()=>{e({loading:!0});try{const s=await(await ye("/api/projects")).json();e({projects:s.projects??[],loading:!1})}catch{e({loading:!1})}},createProject:async(i,s)=>{try{const c=await ye("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:i,workdir:s})});if(!c.ok)return null;const u=await c.json();return await r().listProjects(),u.project}catch{return null}},loadProject:async i=>{try{const s=await ye(`/api/projects/${i}`);if(!s.ok)return null;const c=await s.json();return e({currentProject:c.project}),r().projects.length===0&&await r().listProjects(),c.project}catch{return null}},updateProject:async(i,s)=>{var c;try{const u=await ye(`/api/projects/${i}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!u.ok)return null;const p=await u.json();return((c=r().currentProject)==null?void 0:c.id)===i&&e({currentProject:p.project}),await r().listProjects(),p.project}catch{return null}},deleteProject:async i=>{var s;try{return(await ye(`/api/projects/${i}`,{method:"DELETE"})).ok?(await r().listProjects(),((s=r().currentProject)==null?void 0:s.id)===i&&e({currentProject:null}),!0):!1}catch{return!1}},clearProject:()=>{e({currentProject:null})}}));let fl=[],vd=null,Cl=null;function Y1(){vd===null&&(vd=requestAnimationFrame(()=>{vd=null,Cl==null||Cl()}))}const Oa=qn()((e,r)=>(Cl=()=>{if(fl.length===0)return;const i=fl;fl=[],e(s=>{const c={...s.logs};for(const u of i){const p=c[u.processId]??[];c[u.processId]=[...p,{offset:p.length,content:u.content,timestamp:Date.now(),stream:u.stream}]}return{logs:c}})},{processes:[],logs:{},loading:!1,setProcesses:i=>e({processes:i}),addProcess:i=>e(s=>({processes:[...s.processes,i]})),updateProcess:(i,s)=>e(c=>({processes:c.processes.map(u=>u.id===i?{...u,...s}:u)})),removeProcess:i=>e(s=>({processes:s.processes.filter(c=>c.id!==i),logs:Object.fromEntries(Object.entries(s.logs).filter(([c])=>c!==i))})),stopProcess:async(i,s)=>{try{(await ye(`/api/sessions/${s}/background-process/${i}/stop`,{method:"POST"})).ok&&r().removeProcess(i)}catch{}},appendLog:(i,s,c)=>{fl.push({processId:i,stream:s,content:c}),Y1()},setLogs:(i,s)=>e(c=>({logs:{...c.logs,[i]:s}})),clearLogs:i=>e(s=>({logs:{...s.logs,[i]:[]}})),handleMessage:(i,s)=>{switch(i){case"backgroundProcess.started":{const{processId:c,name:u,pid:p,status:l}=s;e(h=>({processes:[...h.processes,{id:c,sessionId:"",name:u,command:"",cwd:"",pid:p,status:l,exitCode:null,createdAt:Date.now(),startedAt:Date.now(),endedAt:null}]}));break}case"backgroundProcess.output":{const c=s.processId,u=s.stream,p=s.content;r().appendLog(c,u,p);break}case"backgroundProcess.exited":{const c=s.processId,u=s.exitCode;e(p=>({processes:p.processes.map(l=>l.id===c?{...l,status:"exited",exitCode:u}:l)}));break}case"backgroundProcess.removed":{const c=s.processId;r().removeProcess(c);break}}}})),ei={GLOBAL_INSTRUCTIONS:"global_instructions",NOTIFICATION_SETTINGS:"notification_settings"},ti=qn(e=>({settings:{},loading:{},getSetting:async r=>{e(i=>({loading:{...i.loading,[r]:!0}}));try{const s=await(await ye(`/api/settings/${r}`)).json();return e(c=>({settings:{...c.settings,[r]:s.value??""},loading:{...c.loading,[r]:!1}})),s.value}catch{return e(i=>({loading:{...i.loading,[r]:!1}})),null}},setSetting:async(r,i)=>{e(s=>({loading:{...s.loading,[r]:!0}}));try{const c=await(await ye(`/api/settings/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:i})})).json();e(u=>({settings:{...u.settings,[r]:c.value??""},loading:{...u.loading,[r]:!1}}))}catch{e(s=>({loading:{...s.loading,[r]:!1}}))}}})),mx=[{key:"complete",label:"Task Complete",description:"When an agent finishes its work"},{key:"waiting_for_user",label:"Waiting for Input",description:"When the agent needs your input"},{key:"phase_done",label:"Phase Done",description:"When a build phase completes successfully"},{key:"phase_blocked",label:"Phase Blocked",description:"When a build phase is blocked and needs intervention"},{key:"new_message",label:"New Message",description:"When a new assistant message starts arriving"}],K1=[{key:"planner",label:"Planner"},{key:"build",label:"Builder"},{key:"sub-agent",label:"Sub-agent"}],X1=[{url:"/sounds/notification.mp3",label:"Notification"},{url:"/sounds/waiting-for-user.mp3",label:"Waiting for User"},{url:"/sounds/achievement.mp3",label:"Achievement"},{url:"/sounds/intervention.mp3",label:"Intervention"},{url:"/sounds/typing.mp3",label:"Typing"}],fh={complete:"/sounds/notification.mp3",waiting_for_user:"/sounds/waiting-for-user.mp3",phase_done:"/sounds/achievement.mp3",phase_blocked:"/sounds/intervention.mp3",new_message:"/sounds/typing.mp3"},ir={soundEnabled:!0,browserNotification:!1,customSoundUrl:null},Wd={soundEnabled:!0,browserNotificationEnabled:!1,events:{complete:{...ir},waiting_for_user:{...ir},phase_done:{...ir},phase_blocked:{...ir},new_message:{...ir}},agentOverrides:{}};function ib(e,r,i){var u;const s=e.events[r];if(!i)return s;const c=(u=e.agentOverrides[i])==null?void 0:u[r];return c?{soundEnabled:c.soundEnabled??s.soundEnabled,browserNotification:c.browserNotification??s.browserNotification,customSoundUrl:c.customSoundUrl!==void 0?c.customSoundUrl:s.customSoundUrl}:s}const Ei=qn((e,r)=>({settings:Wd,loaded:!1,load:()=>{ti.getState().getSetting(ei.NOTIFICATION_SETTINGS);const s=ti.subscribe(u=>{const p=u.settings[ei.NOTIFICATION_SETTINGS];if(p!==void 0)try{const l=JSON.parse(p);e({settings:gx(l),loaded:!0})}catch{e({loaded:!0})}}),c=ti.getState().settings[ei.NOTIFICATION_SETTINGS];if(c)try{const u=JSON.parse(c);e({settings:gx(u),loaded:!0})}catch{e({loaded:!0})}return s},update:i=>{e({settings:i}),bd(i)},updateEvent:(i,s)=>{const c=r().settings,u={...c,events:{...c.events,[i]:{...c.events[i],...s}}};e({settings:u}),bd(u)},updateAgentOverride:(i,s,c)=>{var h;const u=r().settings,p={...u.agentOverrides};if(c===null){if(p[i]){const f={...p[i]};delete f[s],Object.keys(f).length===0?delete p[i]:p[i]=f}}else p[i]={...p[i],[s]:{...((h=p[i])==null?void 0:h[s])??{},...c}};const l={...u,agentOverrides:p};e({settings:l}),bd(l)}}));function bd(e){ti.getState().setSetting(ei.NOTIFICATION_SETTINGS,JSON.stringify(e))}function gx(e){var r,i,s,c,u;return{soundEnabled:e.soundEnabled??Wd.soundEnabled,browserNotificationEnabled:e.browserNotificationEnabled??Wd.browserNotificationEnabled,events:{complete:{...ir,...(r=e.events)==null?void 0:r.complete},waiting_for_user:{...ir,...(i=e.events)==null?void 0:i.waiting_for_user},phase_done:{...ir,...(s=e.events)==null?void 0:s.phase_done},phase_blocked:{...ir,...(c=e.events)==null?void 0:c.phase_blocked},new_message:{...ir,...(u=e.events)==null?void 0:u.new_message}},agentOverrides:e.agentOverrides??{}}}const xx=new Map;function Z1(e){let r=xx.get(e);return r||(r=new Audio(e),r.volume=.5,xx.set(e,r)),r}let sb=typeof Notification<"u"?Notification.permission:"denied";function Q1(){return typeof Notification>"u"?Promise.resolve("denied"):Notification.requestPermission().then(e=>(sb=e,e))}const J1={complete:"Task Complete",waiting_for_user:"Waiting for Input",phase_done:"Phase Complete",phase_blocked:"Phase Blocked",new_message:"New Message"},eS={complete:"The agent has finished its work.",waiting_for_user:"The agent needs your input to continue.",phase_done:"The build phase completed successfully.",phase_blocked:"The build phase is blocked and needs intervention.",new_message:"A new assistant message is arriving."};function tS(e){typeof Notification>"u"||sb==="granted"&&(document.hasFocus()||new Notification(J1[e],{body:eS[e],icon:"/fox.svg",tag:`openfox-${e}`}))}function Va(e,r){const{settings:i}=Ei.getState(),s=ib(i,e,r);if(i.soundEnabled&&s.soundEnabled){const c=s.customSoundUrl??fh[e],u=Z1(c);u.currentTime=0,u.play().catch(()=>{})}i.browserNotificationEnabled&&s.browserNotification&&tS(e)}const nS=e=>Va("complete",e),rS=e=>Va("phase_done",e),iS=e=>Va("phase_blocked",e),vx=e=>Va("waiting_for_user",e),bx=e=>Va("new_message",e);let pl=!1;const Ea=new Set,It={messageId:null,deltaContent:"",thinkingContent:"",toolOutput:[]};let Es=null,nn=null;function yd(){Es===null&&(Es=requestAnimationFrame(()=>{Es=null,nn==null||nn()}))}function Si(){Es!==null&&(cancelAnimationFrame(Es),Es=null)}function Dt(e,r){return r!==null&&e.sessionId===r}function sS(e,r,i){return e.id!==void 0||Dt(e,r)||i===!0&&e.sessionId!==void 0}function aS(e,r){return e.includes(r)?e:[...e,r]}function ja(e,r){return e.filter(i=>i!==r)}function oS(e,r){const i=e.find(c=>c.id===r.id),s=i?{...i,projectId:r.projectId,workdir:r.workdir,mode:r.mode,phase:r.phase,isRunning:r.isRunning,messageCount:r.messages.length,criteriaCount:r.criteria.length,criteriaCompleted:r.criteria.filter(c=>c.status.type==="passed").length}:{id:r.id,projectId:r.projectId,workdir:r.workdir,mode:r.mode,phase:r.phase,isRunning:r.isRunning,createdAt:"",updatedAt:"",criteriaCount:r.criteria.length,criteriaCompleted:r.criteria.filter(c=>c.status.type==="passed").length,messageCount:r.messages.length};return i?e.map(c=>c.id===r.id?s:c):[s,...e]}function lS(e,r,i){return e.map(s=>{const c=(i==null?void 0:i.id)===s.id?i:null,u=r.find(p=>p.id===s.id);return{...s,title:s.title??(u==null?void 0:u.title),mode:(c==null?void 0:c.mode)??(u==null?void 0:u.mode)??s.mode,phase:(c==null?void 0:c.phase)??(u==null?void 0:u.phase)??s.phase,isRunning:(c==null?void 0:c.isRunning)??(u==null?void 0:u.isRunning)??s.isRunning,messageCount:s.messageCount,recentUserPrompts:s.recentUserPrompts}})}const yx=new Map;function Cs(e,r){var u;const i=r===((u=e.currentSession)==null?void 0:u.id)?e.currentSession:null,s=e.sessions.find(p=>p.id===r),c=(i==null?void 0:i.mode)??(s==null?void 0:s.mode);return c==="planner"?"planner":c==="builder"?"build":"planner"}function cS(e,r){if(e.type==="chat.done"){const i=e.payload,s=Cs(r,e.sessionId);i.reason==="complete"&&nS(s),i.reason==="waiting_for_user"&&vx(s);return}if(e.type==="chat.path_confirmation"){const i=Cs(r,e.sessionId);vx(i);return}if(e.type==="task.completed"){const i=Cs(r,e.sessionId);rS(i);return}if(e.type==="phase.changed"&&e.sessionId){const i=e.payload,s=yx.get(e.sessionId)??null;if(yx.set(e.sessionId,i.phase),s===i.phase)return;const c=Cs(r,e.sessionId);i.phase==="blocked"&&iS(c)}}const Ee=qn((e,r)=>(nn=()=>{const i=It;if(!i.messageId)return;const s=i.deltaContent.length>0,c=i.thinkingContent.length>0,u=i.toolOutput.length>0;if(!s&&!c&&!u)return;const p=i.deltaContent,l=i.thinkingContent,h=i.toolOutput;i.deltaContent="",i.thinkingContent="",i.toolOutput=[],e(f=>{var m;const g=f.streamingMessage;if(g&&g.id===i.messageId){let x={...g};if(s&&(x.content=x.content+p),c&&(x.thinkingContent=(x.thinkingContent??"")+l),u){const S=new Set;x.toolCalls=(m=x.toolCalls)==null?void 0:m.map(C=>{const b=h.filter(y=>y.callId===C.id);return b.length===0?C:(S.add(C.id),{...C,streamingOutput:[...C.streamingOutput??[],...b.map(y=>({stream:y.stream,content:y.content}))]})});const k=h.filter(C=>!S.has(C.callId));k.length>0&&It.toolOutput.push(...k)}return{streamingMessage:x}}if(u){const x=new Set,S=f.messages.map(C=>{var y;if(C.id!==i.messageId)return C;const b=(y=C.toolCalls)==null?void 0:y.map(v=>{const _=h.filter(j=>j.callId===v.id);return _.length===0?v:(x.add(v.id),{...v,streamingOutput:[...v.streamingOutput??[],..._.map(j=>({stream:j.stream,content:j.content}))]})});return{...C,toolCalls:b}}),k=h.filter(C=>!x.has(C.callId));return k.length>0&&It.toolOutput.push(...k),{messages:S}}return f})},{connectionStatus:"disconnected",showPasswordModal:!1,passwordModalRetry:!1,sessions:[],currentSession:null,unreadSessionIds:[],messages:[],streamingMessageId:null,streamingMessage:null,currentTodos:[],contextState:null,pendingPathConfirmation:null,pendingQuestion:null,visionFallbackByMessage:{},queuedMessages:[],abortInProgress:!1,error:null,sessionsHasMore:!0,sessionsPaginationLoading:!1,pendingSessionCreate:!1,connect:async()=>{const i=r().connectionStatus;if(i==="connected"||i==="reconnecting")return;e({connectionStatus:"reconnecting"});let s=!1;try{s=(await(await ye("/api/auth")).json()).requiresAuth}catch{}if(s&&!zt.hasToken()){e({showPasswordModal:!0,passwordModalRetry:!1,connectionStatus:"reconnecting"});return}zt.onStatusChange(c=>{e({connectionStatus:c}),c==="connected"&&r().listSessions(void 0)});try{if(await zt.connect(),!pl){pl=!0;const c=r().handleServerMessage;zt.subscribe(c)}}catch(c){console.error("Failed to connect:",c);const u=zt.getLastCloseCode();if(!zt.hasToken()&&(u===1006||u===4e3)){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}e({connectionStatus:"disconnected"})}},reconnect:()=>{zt.disconnect(),pl=!1,e({connectionStatus:"reconnecting"}),r().connect()},disconnect:()=>{zt.disconnect(),pl=!1,e({connectionStatus:"disconnected",showPasswordModal:!1})},submitPassword:async i=>{try{const s=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:i})});if(!s.ok){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}const{token:c}=await s.json();zt.setToken(c),e({showPasswordModal:!1,connectionStatus:"disconnected"});const{listProjects:u}=Ut.getState(),{fetchConfig:p}=Pt.getState();u(),p(),r().connect()}catch{e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"})}},cancelPassword:()=>{zt.clearToken(),e({showPasswordModal:!1,connectionStatus:"disconnected"})},createSession:async(i,s)=>{try{e({pendingSessionCreate:!0});const c=await ye("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:i,title:s})});if(!c.ok)return e({pendingSessionCreate:!1}),null;const u=await c.json();return zt.send("session.load",{sessionId:u.session.id}),u.session}catch{return e({pendingSessionCreate:!1}),null}},loadSession:async i=>{try{const s=r().currentSession;!s||s.id!==i?(Si(),e({currentSession:null,unreadSessionIds:ja(r().unreadSessionIds,i),messages:[],streamingMessageId:null,streamingMessage:null,currentTodos:[],contextState:null,pendingPathConfirmation:null,queuedMessages:[],abortInProgress:!1,error:null})):e({unreadSessionIds:ja(r().unreadSessionIds,i)});const c=await ye(`/api/sessions/${i}`);if(!c.ok)return;const u=await c.json();e({currentSession:u.session,messages:u.messages??[],contextState:u.contextState,queuedMessages:u.queueState??[]}),zt.send("session.load",{sessionId:i});try{const p=await ye(`/api/sessions/${i}/background-processes`);if(p.ok){const l=await p.json();Oa.getState().setProcesses(l.processes??[])}}catch{}}catch{}},listSessions:async(i,s=20)=>{try{const c=new URLSearchParams;c.set("limit",String(s)),i&&c.set("projectId",i);const p=await(await ye(`/api/sessions?${c.toString()}`)).json();e({sessions:p.sessions??[],sessionsHasMore:i?p.hasMore??!1:!0})}catch{}},loadMoreSessions:async i=>{const s=r();if(!(s.sessionsPaginationLoading||!s.sessionsHasMore)){e({sessionsPaginationLoading:!0});try{const c=new URLSearchParams;c.set("limit","20"),c.set("offset",String(s.sessions.length)),c.set("projectId",i);const p=await(await ye(`/api/sessions?${c.toString()}`)).json();e(l=>({sessions:[...l.sessions,...p.sessions??[]],sessionsHasMore:p.hasMore??!1,sessionsPaginationLoading:!1}))}catch{e({sessionsPaginationLoading:!1})}}},deleteSession:async i=>{var s;try{return(await ye(`/api/sessions/${i}`,{method:"DELETE"})).ok?(await r().listSessions(),((s=r().currentSession)==null?void 0:s.id)===i&&r().clearSession(),!0):!1}catch{return!1}},deleteAllSessions:async i=>{try{return(await ye(`/api/projects/${i}/sessions`,{method:"DELETE"})).ok?(await r().listSessions(),!0):!1}catch{return!1}},clearSession:()=>{Si(),e(i=>({currentSession:null,messages:[],streamingMessageId:null,streamingMessage:null,currentTodos:[],contextState:null,unreadSessionIds:i.currentSession?ja(i.unreadSessionIds,i.currentSession.id):i.unreadSessionIds}))},sendMessage:async(i,s,c)=>{var p;const u=(p=r().currentSession)==null?void 0:p.id;if(u){e({streamingMessageId:null});try{const h=await(await ye(`/api/sessions/${u}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:i,attachments:s,messageKind:c==null?void 0:c.messageKind})})).json();h.queueState&&e({queuedMessages:h.queueState})}catch(l){console.error("Error sending message:",l)}}},stopGeneration:async()=>{var s;const i=(s=r().currentSession)==null?void 0:s.id;if(i&&!r().abortInProgress){Si(),nn==null||nn(),e({abortInProgress:!0});try{await ye(`/api/sessions/${i}/stop`,{method:"POST"})}catch(c){console.error("Error stopping generation:",c)}}},continueGeneration:async()=>{var s;const i=(s=r().currentSession)==null?void 0:s.id;if(i){e({streamingMessageId:null});try{await ye(`/api/sessions/${i}/continue`,{method:"POST"})}catch(c){console.error("Error continuing generation:",c)}}},launchRunner:(i,s,c)=>{e({streamingMessageId:null});const u={};i!=null&&i.trim()&&(u.content=i),s&&s.length>0&&(u.attachments=s),c&&(u.workflowId=c),zt.send("runner.launch",u)},switchMode:async i=>{var c;const s=(c=r().currentSession)==null?void 0:c.id;if(s)try{const u=await ye(`/api/sessions/${s}/mode`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:i})});if(!u.ok){console.error("Failed to switch mode:",await u.json());return}const p=await u.json();p.session&&e({currentSession:p.session})}catch(u){console.error("Error switching mode:",u)}},switchDangerLevel:async i=>{var c;const s=(c=r().currentSession)==null?void 0:c.id;if(s)try{const u=await ye(`/api/sessions/${s}/danger-level`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({dangerLevel:i})});if(!u.ok){console.error("Failed to switch danger level:",await u.json());return}const p=await u.json();p.session&&e({currentSession:p.session})}catch(u){console.error("Error switching danger level:",u)}},acceptAndBuild:(i,s,c)=>{e({streamingMessageId:null});const u={};i&&(u.workflowId=i),s!=null&&s.trim()&&(u.content=s),c&&c.length>0&&(u.attachments=c),zt.send("mode.accept",u)},editCriteria:async i=>{var c;const s=(c=r().currentSession)==null?void 0:c.id;if(s)try{const u=await ye(`/api/sessions/${s}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:i})});u.ok||console.error("Failed to update criteria:",await u.json())}catch(u){console.error("Error updating criteria:",u)}},compactContext:()=>{zt.send("context.compact",{})},setSessionProvider:async(i,s)=>{var c;try{const u=(c=r().currentSession)==null?void 0:c.id;if(!u)return null;const p=await ye(`/api/sessions/${u}/provider`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:i,...s?{model:s}:{}})});if(!p.ok)return null;const l=await p.json();return e({currentSession:l.session,messages:l.messages??[],contextState:l.contextState}),l.session}catch{return null}},updateContextState:i=>{e({contextState:i})},confirmPath:async(i,s,c=!1)=>{var p;const u=(p=r().currentSession)==null?void 0:p.id;if(u)try{await ye(`/api/sessions/${u}/confirm-path`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:i,approved:s,alwaysAllow:c})})}catch(l){console.error("Error confirming path:",l)}},answerQuestion:async(i,s)=>{var u;const c=(u=r().currentSession)==null?void 0:u.id;if(c){try{await ye(`/api/sessions/${c}/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:i,answer:s})})}catch(p){console.error("Error answering question:",p)}e({pendingQuestion:null})}},queueAsap:async(i,s,c)=>{var p;const u=(p=r().currentSession)==null?void 0:p.id;if(u)try{const h=await(await ye(`/api/sessions/${u}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:i,attachments:s,messageKind:c})})).json();h.queueState&&e({queuedMessages:h.queueState})}catch(l){console.error("Error queueing ASAP message:",l)}},queueCompletion:async(i,s,c)=>{var p;const u=(p=r().currentSession)==null?void 0:p.id;if(u)try{const h=await(await ye(`/api/sessions/${u}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:i,attachments:s,messageKind:c})})).json();h.queueState&&e({queuedMessages:h.queueState})}catch(l){console.error("Error queueing completion message:",l)}},cancelQueued:async i=>{var c;const s=(c=r().currentSession)==null?void 0:c.id;if(s)try{const p=await(await ye(`/api/sessions/${s}/queue/${i}`,{method:"DELETE"})).json();p.queueState&&e({queuedMessages:p.queueState})}catch(u){console.error("Error canceling queued message:",u)}},clearError:()=>{e({error:null})},resetPendingSessionCreate:()=>{e({pendingSessionCreate:!1})},handleServerMessage:i=>{var p,l,h,f,g,m,x,S,k,C,b,y,v,_,j,A,N,L,T,B,H,q,Y,V;const s=r();cS(i,s);const c=((p=s.currentSession)==null?void 0:p.id)??null,u=()=>{const F=i.sessionId;!F||F===c||e(I=>({unreadSessionIds:aS(I.unreadSessionIds,F)}))};switch(i.type){case"session.state":{const F=i.payload;if(!sS(i,c,s.pendingSessionCreate))break;Si();const I=F.messages.find(D=>D.isStreaming)??null,$=r().pendingSessionCreate===!0,X=F.pendingConfirmations??[],R=s.pendingPathConfirmation??(X.length>0?X[0]??null:null);if(e({currentSession:F.session,sessions:oS(r().sessions,F.session),unreadSessionIds:ja(r().unreadSessionIds,F.session.id),messages:F.messages,streamingMessageId:(I==null?void 0:I.id)??null,streamingMessage:I,currentTodos:[],pendingPathConfirmation:R,error:null,...$?{pendingSessionCreate:F.session.id}:{}}),F.session.providerId&&F.session.providerModel){const D=Pt.getState();D.providers.find(W=>W.id===F.session.providerId)&&D.syncFromSession(F.session.providerId,F.session.providerModel)}break}case"session.list":{const F=i.payload;e(I=>({sessions:lS(F.sessions,I.sessions,I.currentSession)}));break}case"session.deleted":{const F=i.payload;e(I=>({unreadSessionIds:ja(I.unreadSessionIds,F.sessionId)})),r().listSessions();break}case"session.deletedAll":{r().listSessions();break}case"session.running":{const F=i.payload,I=i.sessionId,$=(l=r().currentSession)==null?void 0:l.id,X=I&&I!==$;e(J=>({sessions:J.sessions.map(R=>R.id===I?{...R,isRunning:F.isRunning}:R)})),X||e(J=>({currentSession:J.currentSession?{...J.currentSession,isRunning:F.isRunning}:null,...F.isRunning?{}:{abortInProgress:!1,queuedMessages:[]}}));break}case"chat.message":{if(!Dt(i,((h=r().currentSession)==null?void 0:h.id)??null)){u();break}const F=i.payload;e(I=>I.messages.some($=>$.id===F.message.id)?I:{messages:[...I.messages,F.message],streamingMessageId:F.message.isStreaming?F.message.id:I.streamingMessageId,streamingMessage:F.message.isStreaming?F.message:I.streamingMessage});break}case"chat.message_updated":{if(!Dt(i,((f=r().currentSession)==null?void 0:f.id)??null)){u();break}const F=i.payload,I=F.updates.isStreaming===!1&&r().streamingMessageId===F.messageId;I&&(Si(),nn==null||nn()),e($=>{const X=$.streamingMessage,J=I;if(X&&X.id===F.messageId){const R={...X,...F.updates};return{messages:$.messages.map(D=>D.id===F.messageId?R:D),streamingMessageId:J?null:$.streamingMessageId,streamingMessage:J?null:{...X,...F.updates}}}return{messages:$.messages.map(R=>R.id===F.messageId?{...R,...F.updates}:R),streamingMessageId:J?null:$.streamingMessageId}});break}case"chat.delta":{if(!Dt(i,((g=r().currentSession)==null?void 0:g.id)??null)){u();break}const F=i.payload;if(!Ea.has(F.messageId)){Ea.add(F.messageId);const I=Cs(r(),i.sessionId);bx(I)}It.messageId=F.messageId,It.deltaContent+=F.content,yd();break}case"chat.thinking":{if(!Dt(i,((m=r().currentSession)==null?void 0:m.id)??null)){u();break}const F=i.payload;if(!Ea.has(F.messageId)){Ea.add(F.messageId);const I=Cs(r(),i.sessionId);bx(I)}It.messageId=F.messageId,It.thinkingContent+=F.content,yd();break}case"chat.tool_preparing":{if(!Dt(i,((x=r().currentSession)==null?void 0:x.id)??null)){u();break}const F=i.payload;e(I=>{const $=I.streamingMessage;return $&&$.id===F.messageId?{streamingMessage:{...$,preparingToolCalls:[...$.preparingToolCalls??[],{index:F.index,name:F.name}]}}:{messages:I.messages.map(X=>X.id===F.messageId?{...X,preparingToolCalls:[...X.preparingToolCalls??[],{index:F.index,name:F.name}]}:X)}});break}case"chat.tool_call":{if(!Dt(i,((S=r().currentSession)==null?void 0:S.id)??null)){u();break}const F=i.payload,I=$=>{var R;const X=(R=$.preparingToolCalls)==null?void 0:R.filter((D,O)=>{var W;return D.name===F.tool?(W=$.preparingToolCalls)==null?void 0:W.slice(0,O).some(K=>K.name===F.tool):!0}),J=It.toolOutput.filter(D=>D.callId===F.callId);return J.length>0&&(It.toolOutput=It.toolOutput.filter(D=>D.callId!==F.callId)),{...$,toolCalls:[...$.toolCalls??[],{id:F.callId,name:F.tool,arguments:F.args,startedAt:Date.now(),...J.length>0?{streamingOutput:J.map(D=>({stream:D.stream,content:D.content}))}:{}}],...X&&X.length>0?{preparingToolCalls:X}:{preparingToolCalls:void 0}}};e($=>{const X=$.streamingMessage;return X&&X.id===F.messageId?{streamingMessage:I(X)}:{messages:$.messages.map(J=>J.id===F.messageId?I(J):J)}});break}case"chat.tool_output":{if(!Dt(i,((k=r().currentSession)==null?void 0:k.id)??null)){u();break}const F=i.payload;It.messageId=F.messageId,It.toolOutput.push({messageId:F.messageId,callId:F.callId,stream:F.stream,content:F.output}),yd();break}case"chat.tool_result":{if(!Dt(i,((C=r().currentSession)==null?void 0:C.id)??null)){u();break}const F=i.payload,I=$=>{var J;const X=(J=$.toolCalls)==null?void 0:J.map(R=>R.id===F.callId?{...R,result:F.result}:R);return{...$,toolCalls:X}};e($=>{const X=$.streamingMessage;return X&&X.id===F.messageId?{streamingMessage:I(X)}:{messages:$.messages.map(J=>J.id===F.messageId?I(J):J)}});break}case"chat.vision_fallback":{if(!Dt(i,((b=r().currentSession)==null?void 0:b.id)??null)){u();break}const F=i.payload;e(I=>{const $=`${F.messageId}-${F.attachmentId}`,X={...I.visionFallbackByMessage};return X[$]={type:F.type,attachmentId:F.attachmentId,filename:F.filename,description:F.description},{visionFallbackByMessage:X}});break}case"chat.todo":{if(!Dt(i,((y=r().currentSession)==null?void 0:y.id)??null)){u();break}const F=i.payload;e({currentTodos:F.todos});break}case"chat.summary":{if(!Dt(i,((v=r().currentSession)==null?void 0:v.id)??null)){u();break}const F=i.payload;e(I=>({currentSession:I.currentSession?{...I.currentSession,summary:F.summary}:null}));break}case"chat.progress":{if(!Dt(i,((_=r().currentSession)==null?void 0:_.id)??null)){u();break}const F=i.payload;console.log("Progress:",F.message,F.phase);break}case"chat.format_retry":{if(!Dt(i,((j=r().currentSession)==null?void 0:j.id)??null)){u();break}const F=i.payload;console.log("Format retry:",F.attempt,"/",F.maxAttempts);break}case"chat.done":{if(!Dt(i,((A=r().currentSession)==null?void 0:A.id)??null)){u();break}Si(),nn==null||nn();const F=i.payload,I=F.stats;It.messageId=null,It.deltaContent="",It.thinkingContent="",It.toolOutput=[],Ea.delete(F.messageId),e($=>{const X=$.streamingMessage,J=X&&X.id===F.messageId?{...X,isStreaming:!1,stats:I??X.stats}:null;return{messages:$.messages.map(R=>R.id===F.messageId?J??{...R,isStreaming:!1,stats:I??R.stats}:R),streamingMessageId:null,streamingMessage:null,visionFallbackByMessage:{}}});break}case"chat.error":{if(!Dt(i,((N=r().currentSession)==null?void 0:N.id)??null)){u();break}Si(),nn==null||nn();const F=i.payload;console.error("Chat error:",F.error,"recoverable:",F.recoverable),F.recoverable||(It.messageId=null,It.deltaContent="",It.thinkingContent="",It.toolOutput=[]),e(I=>({error:{code:"CHAT_ERROR",message:F.error},streamingMessageId:F.recoverable?I.streamingMessageId:null,...F.recoverable?{}:{messages:I.streamingMessage?I.messages.map($=>$.id===I.streamingMessage.id?I.streamingMessage:$):I.messages,streamingMessage:null}}));break}case"chat.path_confirmation":{if(!Dt(i,((L=r().currentSession)==null?void 0:L.id)??null)){u();break}const F=i.payload;e({pendingPathConfirmation:{callId:F.callId,tool:F.tool,paths:F.paths,workdir:F.workdir,reason:F.reason}});break}case"chat.ask_user":{if(!Dt(i,((T=r().currentSession)==null?void 0:T.id)??null)){u();return}const F=i.payload;e({pendingQuestion:{callId:F.callId,question:F.question}});break}case"mode.changed":{if(!Dt(i,((B=r().currentSession)==null?void 0:B.id)??null)){u();break}const F=i.payload;e(I=>({currentSession:I.currentSession?{...I.currentSession,mode:F.mode}:null}));break}case"phase.changed":{const F=i.payload,I=i.sessionId,$=(H=r().currentSession)==null?void 0:H.id,X=I&&I!==$;e(J=>({sessions:J.sessions.map(R=>R.id===I?{...R,phase:F.phase}:R)})),X||e(J=>({currentSession:J.currentSession?{...J.currentSession,phase:F.phase}:null}));break}case"criteria.updated":{if(!Dt(i,((q=r().currentSession)==null?void 0:q.id)??null)){u();break}const F=i.payload;e(I=>({currentSession:I.currentSession?{...I.currentSession,criteria:F.criteria}:null}));break}case"context.state":{if(!Dt(i,((Y=r().currentSession)==null?void 0:Y.id)??null)){u();break}const F=i.payload;console.log("[session.handleServerMessage.context.state] Received context state:",F.context),e({contextState:F.context});break}case"session.name_generated":{const F=i.payload,I=i.sessionId,$=(V=r().currentSession)==null?void 0:V.id;e(X=>{const J=X.sessions.map(D=>D.id===I?{...D,title:F.name,updatedAt:new Date().toISOString()}:D),R=$===I?X.currentSession?{...X.currentSession,title:F.name,updatedAt:new Date().toISOString()}:null:X.currentSession;return{sessions:J,currentSession:R}});break}case"queue.state":{const F=i.payload;e({queuedMessages:F.messages});break}case"devServer.output":case"devServer.state":{rr.getState().handleMessage(i);break}case"backgroundProcess.started":case"backgroundProcess.output":case"backgroundProcess.exited":case"backgroundProcess.removed":{Oa.getState().handleMessage(i.type,i.payload);break}case"error":{const F=i.payload;console.error("Server error:",F),e({error:{code:F.code,message:F.message},streamingMessageId:null});break}}}}));function ab(){return Ee(e=>{var r;return((r=e.currentSession)==null?void 0:r.isRunning)??!1})}function uS(){return Ee(e=>e.queuedMessages)}function dS(){return Ee(e=>e.abortInProgress)}function hS(){const e=Ee(s=>s.connect),r=Ee(s=>s.connectionStatus),i=Ei(s=>s.load);return P.useEffect(()=>{e()},[e]),P.useEffect(()=>{r==="connected"&&i()},[r,i]),{connectionStatus:r}}function Gd(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const r=Math.random()*16|0;return(e==="x"?r:r&3|8).toString(16)})}function _x(e,r){const i=zt.ws;!i||i.readyState!==WebSocket.OPEN||i.send(JSON.stringify({id:Gd(),type:e,payload:r}))}const sr=qn((e,r)=>({isOpen:!1,sessions:[],workdir:null,setOpen:i=>e({isOpen:i}),toggleOpen:()=>e(i=>({isOpen:!i.isOpen})),setWorkdir:i=>e({workdir:i}),fetchSessions:async()=>{try{const i=await ye("/api/terminals");if(i.ok){const s=await i.json();e({sessions:s});const c=zt.ws;if(c&&c.readyState===WebSocket.OPEN)for(const u of s)c.send(JSON.stringify({id:Gd(),type:"terminal.subscribe",payload:{sessionId:u.id}}))}}catch(i){console.error("Failed to fetch terminals:",i)}},createSession:async i=>{try{const s=await ye("/api/terminals",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:i??r().workdir??void 0})});if(s.ok){const c=await s.json();e(p=>({sessions:[...p.sessions,c]}));const u=zt.ws;u&&u.readyState===WebSocket.OPEN&&u.send(JSON.stringify({id:Gd(),type:"terminal.subscribe",payload:{sessionId:c.id}}))}}catch(s){console.error("Failed to create terminal:",s)}},writeSession:(i,s)=>{_x("terminal.write",{sessionId:i,data:s})},resizeSession:(i,s,c)=>{_x("terminal.resize",{sessionId:i,cols:s,rows:c})},killSession:async i=>{try{(await ye(`/api/terminals/${i}`,{method:"DELETE"})).ok&&e(c=>({sessions:c.sessions.filter(u=>u.id!==i)}))}catch(s){console.error("Failed to kill terminal:",s)}},handleMessage:i=>{switch(i.type){case"terminal.exit":{const{sessionId:s}=i.payload||{};s&&e(c=>{const u=c.sessions.filter(p=>p.id!==s);return u.length===0&&c.isOpen?{sessions:[],isOpen:!1}:{sessions:u}});break}}}}));zt.subscribe(e=>{var r;(r=e.type)!=null&&r.startsWith("terminal.")&&sr.getState().handleMessage(e)});var ph=Kv();function un({isOpen:e,onClose:r,title:i,children:s,size:c="md"}){const u=P.useRef(null),p=P.useRef(null),l=P.useCallback(f=>{f.key==="Escape"&&r()},[r]);if(P.useEffect(()=>{var f,g;return e?(p.current=document.activeElement,(f=u.current)==null||f.focus(),document.body.style.overflow="hidden"):((g=p.current)==null||g.focus(),document.body.style.overflow=""),()=>{document.body.style.overflow=""}},[e]),P.useEffect(()=>{if(e)return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[e,l]),!e)return null;const h={sm:"max-w-sm md:max-w-sm",md:"max-w-[90vw] md:max-w-md",lg:"max-w-[90vw] md:max-w-2xl h-[80vh]",xl:"max-w-[90vw] md:max-w-4xl h-[80vh]",full:"max-w-[95vw] h-[90vh]"};return ph.createPortal(o.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[o.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:r}),o.jsxs("div",{ref:u,tabIndex:-1,className:`relative w-full ${h[c]} bg-bg-secondary border border-border rounded shadow-xl flex flex-col max-h-[90vh]`,children:[o.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[o.jsx("h2",{className:"text-lg font-semibold text-text-primary truncate",children:i}),o.jsx("button",{onClick:r,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors flex-shrink-0",children:o.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),o.jsx("div",{className:"p-4 overflow-y-auto flex-1 min-h-0",children:s})]})]}),document.body)}const dt=P.forwardRef(({variant:e="secondary",size:r="md",className:i="",children:s,...c},u)=>{const p="rounded font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed",l={primary:"bg-accent-primary/25 text-white hover:bg-accent-primary/40",secondary:"bg-bg-tertiary text-text-primary hover:bg-border",danger:"bg-accent-error text-white hover:bg-accent-error/80"},h={sm:"px-1.5 py-1 text-xs",md:"px-3 py-1.5 text-sm",lg:"px-4 py-2 text-base"};return o.jsx("button",{ref:u,className:`${p} ${l[e]} ${h[r]} ${i}`,...c,children:s})});dt.displayName="Button";function fS(e){const r=new Audio(e);r.volume=.5,r.play().catch(()=>{})}function ob({value:e,defaultUrl:r,disabled:i,onChange:s}){const c=e??r;return o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("select",{value:c,disabled:i,onChange:u=>{const p=u.target.value;s(p===r?null:p)},className:"px-2 py-1 text-xs bg-bg-tertiary border border-border rounded focus:outline-none focus:ring-1 focus:ring-accent-primary disabled:opacity-40",children:X1.map(({url:u,label:p})=>o.jsxs("option",{value:u,children:[p,u===r?" (default)":""]},u))}),o.jsx("button",{onClick:()=>fS(c),disabled:i,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary disabled:opacity-40 disabled:cursor-not-allowed transition-colors",title:"Preview sound",children:o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.536 8.464a5 5 0 010 7.072M17.95 6.05a8 8 0 010 11.9M6.5 8.8h-2a1 1 0 00-1 1v4.4a1 1 0 001 1h2l4.5 3.5V5.3L6.5 8.8z"})})})]})}function pS(){const e=Ei(h=>h.settings),r=Ei(h=>h.update),i=Ei(h=>h.updateEvent),s=Ei(h=>h.updateAgentOverride),c=Ei(h=>h.load),[u,p]=P.useState(null);P.useEffect(()=>{c()},[c]);const l=async()=>{await Q1()==="granted"&&r({...e,browserNotificationEnabled:!0})};return o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"space-y-3",children:[o.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Master Controls"}),o.jsx(Sx,{label:"Sound notifications",description:"Play sounds when events occur",checked:e.soundEnabled,onChange:h=>r({...e,soundEnabled:h})}),o.jsx(Sx,{label:"Browser notifications",description:"Show desktop notifications when the window is not focused",checked:e.browserNotificationEnabled,onChange:h=>{h&&typeof Notification<"u"&&Notification.permission!=="granted"?l():r({...e,browserNotificationEnabled:h})}}),typeof Notification<"u"&&Notification.permission==="denied"&&e.browserNotificationEnabled&&o.jsx("p",{className:"text-xs text-accent-error ml-6",children:"Browser notifications are blocked. Please enable them in your browser settings."})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Event Configuration"}),mx.map(({key:h,label:f,description:g})=>o.jsx(mS,{event:h,label:f,description:g,config:e.events[h],onUpdate:m=>i(h,m),soundMasterEnabled:e.soundEnabled,browserMasterEnabled:e.browserNotificationEnabled},h))]}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Per-Agent Overrides"}),o.jsx("p",{className:"text-xs text-text-muted",children:"Override notification settings for specific agent types. Unconfigured events use the global defaults above."}),K1.map(({key:h,label:f})=>o.jsxs("div",{className:"border border-border rounded",children:[o.jsxs("button",{className:"w-full flex items-center justify-between px-3 py-2 text-sm text-text-secondary hover:bg-bg-tertiary transition-colors rounded",onClick:()=>p(u===h?null:h),children:[o.jsx("span",{className:"font-medium",children:f}),o.jsx("svg",{className:`w-4 h-4 transition-transform ${u===h?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),u===h&&o.jsx("div",{className:"px-3 pb-3 space-y-3 border-t border-border pt-2",children:mx.map(({key:g,label:m})=>{var b;const x=(b=e.agentOverrides[h])==null?void 0:b[g],S=x!==void 0,k=ib(e,g,h),C=fh[g];return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[o.jsx("input",{type:"checkbox",checked:S,onChange:y=>{y.target.checked?s(h,g,{soundEnabled:k.soundEnabled,browserNotification:k.browserNotification}):s(h,g,null)},className:"rounded border-border"}),o.jsx("span",{className:`flex-1 ${S?"text-text-primary":"text-text-muted"}`,children:m}),S&&o.jsxs(o.Fragment,{children:[o.jsxs("label",{className:"flex items-center gap-1 text-text-secondary",children:[o.jsx("input",{type:"checkbox",checked:k.soundEnabled,onChange:y=>s(h,g,{soundEnabled:y.target.checked}),className:"rounded border-border"}),"Sound"]}),o.jsxs("label",{className:"flex items-center gap-1 text-text-secondary",children:[o.jsx("input",{type:"checkbox",checked:k.browserNotification,onChange:y=>s(h,g,{browserNotification:y.target.checked}),className:"rounded border-border"}),"Browser"]})]})]}),S&&k.soundEnabled&&o.jsx("div",{className:"ml-6",children:o.jsx(ob,{value:(x==null?void 0:x.customSoundUrl)??null,defaultUrl:C,onChange:y=>s(h,g,{customSoundUrl:y})})})]},g)})})]},h))]})]})}function Sx({label:e,description:r,checked:i,onChange:s}){return o.jsxs("label",{className:"flex items-start gap-3 cursor-pointer group",children:[o.jsx("div",{className:"pt-0.5",children:o.jsx("div",{className:`relative w-9 h-5 rounded-full transition-colors ${i?"bg-accent-primary":"bg-bg-tertiary border border-border"}`,onClick:c=>{c.preventDefault(),s(!i)},children:o.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform ${i?"translate-x-4":"translate-x-0.5"}`})})}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm text-text-primary group-hover:text-accent-primary transition-colors",children:e}),o.jsx("div",{className:"text-xs text-text-muted",children:r})]})]})}function mS({event:e,label:r,description:i,config:s,onUpdate:c,soundMasterEnabled:u,browserMasterEnabled:p}){return o.jsxs("div",{className:"border border-border rounded px-3 py-2 space-y-2",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-sm text-text-primary",children:r}),o.jsx("div",{className:"text-xs text-text-muted",children:i})]}),o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[o.jsx("input",{type:"checkbox",checked:s.soundEnabled,onChange:l=>c({soundEnabled:l.target.checked}),disabled:!u,className:"rounded border-border"}),"Sound ",!u&&o.jsx("span",{className:"text-text-muted",children:"(master off)"})]}),o.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[o.jsx("input",{type:"checkbox",checked:s.browserNotification,onChange:l=>c({browserNotification:l.target.checked}),disabled:!p,className:"rounded border-border"}),"Browser notification ",!p&&o.jsx("span",{className:"text-text-muted",children:"(master off)"})]})]}),s.soundEnabled&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-xs text-text-muted",children:"Sound:"}),o.jsx(ob,{value:s.customSoundUrl,defaultUrl:fh[e],disabled:!u,onChange:l=>c({customSoundUrl:l})})]})]})}const lb=P.forwardRef(({icon:e,iconSize:r="w-3.5 h-3.5",className:i="",...s},c)=>o.jsx("button",{ref:c,type:"button",className:`p-1 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors ${i}`,...s,children:o.jsx("svg",{className:r,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:e})})}));lb.displayName="IconButton";const gS="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z",ri=P.forwardRef((e,r)=>o.jsx(lb,{ref:r,icon:gS,title:"Edit",...e}));ri.displayName="EditButton";const Yn=qn((e,r)=>({skills:[],defaultIds:[],modifiedIds:[],loading:!1,fetchDefaultIds:async()=>{try{const s=await(await ye("/api/skills/default-ids")).json();e({defaultIds:s.ids??[]})}catch{}},fetchSkills:async()=>{e({loading:!0});try{const s=await(await ye("/api/skills")).json();e({skills:s.skills??[],defaultIds:s.defaultIds??r().defaultIds,modifiedIds:s.modifiedIds??[],loading:!1})}catch{e({loading:!1})}},toggleSkill:async i=>{try{const c=await(await ye(`/api/skills/${i}/toggle`,{method:"POST"})).json();e({skills:r().skills.map(u=>u.id===i?{...u,enabled:c.enabled}:u)})}catch{}},fetchSkill:async i=>{try{const s=await ye(`/api/skills/${i}`);return s.ok?await s.json():null}catch{return null}},createSkill:async i=>{try{const s=await ye("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});return s.ok?(await r().fetchSkills(),{success:!0}):{success:!1,error:(await s.json()).error}}catch{return{success:!1,error:"Network error"}}},updateSkill:async(i,s)=>{try{const c=await ye(`/api/skills/${i}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});return c.ok?(await r().fetchSkills(),{success:!0}):{success:!1,error:(await c.json()).error}}catch{return{success:!1,error:"Network error"}}},deleteSkill:async i=>{try{return(await ye(`/api/skills/${i}`,{method:"DELETE"})).ok?(e({skills:r().skills.filter(c=>c.id!==i)}),!0):!1}catch{return!1}},restoreDefault:async i=>{try{return(await ye(`/api/skills/${i}/restore-default`,{method:"POST"})).ok?(await r().fetchSkills(),!0):!1}catch{return!1}},restoreAllDefaults:async()=>{try{return(await ye("/api/skills/restore-all-defaults",{method:"POST"})).ok?(await r().fetchSkills(),!0):!1}catch{return!1}}}));function xS(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function vS({isOpen:e}){const r=Yn(Q=>Q.skills),i=Yn(Q=>Q.modifiedIds),s=Yn(Q=>Q.loading),c=Yn(Q=>Q.fetchSkills),u=Yn(Q=>Q.toggleSkill),p=Yn(Q=>Q.fetchSkill),l=Yn(Q=>Q.createSkill),h=Yn(Q=>Q.updateSkill),f=Yn(Q=>Q.deleteSkill),g=Yn(Q=>Q.restoreDefault),m=Yn(Q=>Q.restoreAllDefaults),[x,S]=P.useState("list"),[k,C]=P.useState(null),[b,y]=P.useState(null),[v,_]=P.useState(""),[j,A]=P.useState(""),[N,L]=P.useState(""),[T,B]=P.useState("1.0.0"),[H,q]=P.useState(""),[Y,V]=P.useState(""),[F,I]=P.useState(!1),[$,X]=P.useState(null),[J,R]=P.useState(!1);P.useEffect(()=>{e&&(c(),S("list"),C(null),y(null),X(null),R(!1))},[e,c]);const D=()=>{C(null),_(""),A(""),L(""),B("1.0.0"),q(""),V(""),S("edit")},O=async Q=>{const Z=await p(Q);Z&&(C(Q),_(Z.metadata.name),A(Z.metadata.id),L(Z.metadata.description),B(Z.metadata.version),q(Z.prompt),V(""),S("edit"))},W=async Q=>{await f(Q),y(null)},U=async()=>{const Q=k??j;if(!Q||!v||!H){V("Name and prompt are required.");return}I(!0),V("");const Z={metadata:{id:Q,name:v,description:N,version:T||"1.0.0"},prompt:H},z=k?await h(k,Z):await l(Z);if(I(!1),!z.success){V(z.error??"Failed to save skill.");return}S("list")},K=()=>{S("list")},te=Q=>{_(Q),k||A(xS(Q))};return x==="edit"?o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[o.jsx("button",{onClick:K,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Back to list",children:o.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),o.jsx("span",{className:"text-sm font-medium text-text-primary",children:k?"Edit Skill":"New Skill"})]}),Y&&o.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded",children:Y}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Name"}),o.jsx("input",{value:v,onChange:Q=>te(Q.target.value),placeholder:"My Skill",className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary"})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["ID ",k&&o.jsx("span",{className:"text-text-muted",children:"(read-only)"})]}),o.jsx("input",{value:j,onChange:Q=>!k&&A(Q.target.value),readOnly:!!k,placeholder:"my-skill",className:`w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary ${k?"opacity-60":""}`})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Description"}),o.jsx("input",{value:N,onChange:Q=>L(Q.target.value),placeholder:"Short description of what this skill provides",className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Version"}),o.jsx("input",{value:T,onChange:Q=>B(Q.target.value),placeholder:"1.0.0",className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary"})]})]})]}),o.jsxs("div",{className:"flex-1 min-h-[150px] mt-3 overflow-hidden",children:[o.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Prompt"}),o.jsx("textarea",{value:H,onChange:Q=>q(Q.target.value),placeholder:"Instructions the agent receives when this skill is loaded...",className:"w-full h-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-accent-primary"})]}),o.jsxs("div",{className:"flex justify-end gap-2 pt-2 mt-5 border-t border-border flex-shrink-0",children:[o.jsx(dt,{variant:"secondary",onClick:K,children:"Cancel"}),o.jsx(dt,{variant:"primary",onClick:U,disabled:F||!v||!H,children:F?"Saving...":"Save"})]})]}):o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsx("p",{className:"text-text-secondary text-sm",children:"Skills provide domain-specific knowledge that agents can load on demand."}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:[i.length>0&&(J?o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:async()=>{await m(),R(!1)},className:"px-1.5 py-0.5 rounded bg-amber-500/20 text-amber-400 text-xs hover:bg-amber-500/30 transition-colors",children:"Confirm"}),o.jsx("button",{onClick:()=>R(!1),className:"px-1.5 py-0.5 rounded text-text-muted text-xs hover:bg-bg-primary transition-colors",children:"Cancel"})]}):o.jsx("button",{onClick:()=>R(!0),className:"px-2 py-1 rounded text-xs text-text-muted hover:text-amber-400 hover:bg-amber-500/10 transition-colors",title:"Restore all skills to defaults",children:"Restore Defaults"})),o.jsx(dt,{variant:"primary",size:"sm",onClick:D,children:"+ New"})]})]}),s&&r.length===0?o.jsx("div",{className:"text-text-muted text-sm",children:"Loading skills..."}):r.length===0?o.jsx("div",{className:"text-text-muted text-sm",children:"No skills installed."}):o.jsx("div",{className:"space-y-2",children:r.map(Q=>o.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[o.jsxs("div",{className:"min-w-0 flex-1 mr-3",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-text-primary text-sm font-medium",children:Q.name}),o.jsxs("span",{className:"text-text-muted text-xs",children:["v",Q.version]}),i.includes(Q.id)&&o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-amber-500/15 text-amber-400",children:"modified"})]}),o.jsx("p",{className:"text-text-secondary text-xs mt-0.5 truncate",children:Q.description})]}),o.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[i.includes(Q.id)&&($===Q.id?o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:async()=>{await g(Q.id),X(null)},className:"px-1.5 py-0.5 rounded bg-amber-500/20 text-amber-400 text-xs hover:bg-amber-500/30 transition-colors",children:"Restore"}),o.jsx("button",{onClick:()=>X(null),className:"px-1.5 py-0.5 rounded text-text-muted text-xs hover:bg-bg-primary transition-colors",children:"Cancel"})]}):o.jsx("button",{onClick:()=>X(Q.id),className:"p-1.5 rounded hover:bg-bg-primary text-text-muted hover:text-amber-400 transition-colors",title:"Restore default",children:o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})),o.jsx(ri,{onClick:()=>O(Q.id)}),b===Q.id?o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:()=>W(Q.id),className:"px-1.5 py-0.5 rounded bg-accent-error/20 text-accent-error text-xs hover:bg-accent-error/30 transition-colors",children:"Delete"}),o.jsx("button",{onClick:()=>y(null),className:"px-1.5 py-0.5 rounded text-text-muted text-xs hover:bg-bg-primary transition-colors",children:"Cancel"})]}):o.jsx("button",{onClick:()=>y(Q.id),className:"p-1.5 rounded hover:bg-bg-primary text-text-muted hover:text-accent-error transition-colors",title:"Delete skill",children:o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})}),o.jsx("button",{onClick:()=>u(Q.id),className:`relative w-9 h-5 rounded-full transition-colors flex-shrink-0 ml-1 ${Q.enabled?"bg-accent-primary":"bg-bg-primary"}`,title:Q.enabled?"Disable skill":"Enable skill",children:o.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white transition-transform ${Q.enabled?"translate-x-4":"translate-x-0"}`})})]})]},Q.id))})]})}function bS({isOpen:e,onClose:r}){const[i,s]=P.useState("instructions");return o.jsx(un,{isOpen:e,onClose:r,title:"Settings",size:"lg",children:o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex border-b border-border mb-4 -mt-1",children:[o.jsx(ml,{label:"Instructions",active:i==="instructions",onClick:()=>s("instructions")}),o.jsx(ml,{label:"Skills",active:i==="skills",onClick:()=>s("skills")}),o.jsx(ml,{label:"Notifications",active:i==="notifications",onClick:()=>s("notifications")}),o.jsx(ml,{label:"Advanced",active:i==="advanced",onClick:()=>s("advanced")})]}),i==="instructions"&&o.jsx(_S,{isOpen:e}),i==="skills"&&o.jsx(vS,{isOpen:e}),i==="notifications"&&o.jsx(pS,{}),i==="advanced"&&o.jsx(yS,{onClose:r})]})})}function yS({onClose:e}){const[,r]=ar();function i(){e(),r("/onboarding")}return o.jsx("div",{className:"space-y-6",children:o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium text-text-primary mb-1",children:"Onboarding"}),o.jsx("p",{className:"text-sm text-text-muted mb-4",children:"Reset your OpenFox setup and go through the initial configuration again."}),o.jsx(dt,{variant:"secondary",onClick:i,children:"Launch Onboarding"})]})})}function ml({label:e,active:r,onClick:i}){return o.jsx("button",{onClick:i,className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${r?"border-accent-primary text-accent-primary":"border-transparent text-text-muted hover:text-text-secondary hover:border-border"}`,children:e})}function _S({isOpen:e}){const r=ti(b=>b.settings),i=ti(b=>b.loading),s=ti(b=>b.getSetting),c=ti(b=>b.setSetting),u=r[ei.GLOBAL_INSTRUCTIONS]??"",p=i[ei.GLOBAL_INSTRUCTIONS]??!1,[l,h]=P.useState(u),[f,g]=P.useState(!1),[m,x]=P.useState(!1);P.useEffect(()=>{e&&s(ei.GLOBAL_INSTRUCTIONS)},[e,s]),P.useEffect(()=>{h(u),g(!1)},[u]);const S=async()=>{x(!0),c(ei.GLOBAL_INSTRUCTIONS,l),x(!1),g(!1)},k=()=>{h(u),g(!1)},C=p||m;return o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-text-primary mb-2",children:"Global Instructions"}),o.jsx("p",{className:"text-sm text-text-muted mb-2",children:"These instructions are injected into every prompt, regardless of project."}),o.jsx("textarea",{value:l,onChange:b=>{h(b.target.value),g(!0)},placeholder:"Enter global instructions that apply to all projects...",className:"w-full h-64 px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:C})]}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(dt,{variant:"secondary",onClick:k,disabled:!f,children:"Discard"}),o.jsx(dt,{variant:"primary",onClick:S,disabled:!f||C,children:m?"Saving...":"Save"})]})]})}var _d={exports:{}},wx;function SS(){return wx||(wx=1,(function(e,r){(function(i,s){e.exports=s()})(globalThis,(()=>(()=>{var i={4567:function(p,l,h){var f=this&&this.__decorate||function(v,_,j,A){var N,L=arguments.length,T=L<3?_:A===null?A=Object.getOwnPropertyDescriptor(_,j):A;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(v,_,j,A);else for(var B=v.length-1;B>=0;B--)(N=v[B])&&(T=(L<3?N(T):L>3?N(_,j,T):N(_,j))||T);return L>3&&T&&Object.defineProperty(_,j,T),T},g=this&&this.__param||function(v,_){return function(j,A){_(j,A,v)}};Object.defineProperty(l,"__esModule",{value:!0}),l.AccessibilityManager=void 0;const m=h(9042),x=h(9924),S=h(844),k=h(4725),C=h(2585),b=h(3656);let y=l.AccessibilityManager=class extends S.Disposable{constructor(v,_,j,A){super(),this._terminal=v,this._coreBrowserService=j,this._renderService=A,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 N=0;N<this._terminal.rows;N++)this._rowElements[N]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[N]);if(this._topBoundaryFocusListener=N=>this._handleBoundaryFocus(N,0),this._bottomBoundaryFocusListener=N=>this._handleBoundaryFocus(N,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 x.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((N=>this._handleResize(N.rows)))),this.register(this._terminal.onRender((N=>this._refreshRows(N.start,N.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((N=>this._handleChar(N)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
57
+ */var sx;function v1(){if(sx)return gd;sx=1;var e=Bl();function r(m,x){return m===x&&(m!==0||1/m===1/x)||m!==m&&x!==x}var i=typeof Object.is=="function"?Object.is:r,s=e.useState,c=e.useEffect,u=e.useLayoutEffect,p=e.useDebugValue;function l(m,x){var S=x(),k=s({inst:{value:S,getSnapshot:x}}),C=k[0].inst,b=k[1];return u(function(){C.value=S,C.getSnapshot=x,h(C)&&b({inst:C})},[m,S,x]),c(function(){return h(C)&&b({inst:C}),m(function(){h(C)&&b({inst:C})})},[m]),p(S),S}function h(m){var x=m.getSnapshot;m=m.value;try{var S=x();return!i(m,S)}catch{return!0}}function f(m,x){return x()}var g=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:l;return gd.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:g,gd}var ax;function b1(){return ax||(ax=1,md.exports=v1()),md.exports}var y1=b1();const _1=c1.useInsertionEffect,S1=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",w1=S1?P.useLayoutEffect:P.useEffect,C1=_1||w1,Xv=e=>{const r=P.useRef([e,(...i)=>r[0](...i)]).current;return C1(()=>{r[0]=e}),r[1]},k1="popstate",ch="pushState",uh="replaceState",E1="hashchange",ox=[k1,ch,uh,E1],j1=e=>{for(const r of ox)addEventListener(r,e);return()=>{for(const r of ox)removeEventListener(r,e)}},Zv=(e,r)=>y1.useSyncExternalStore(j1,e,r),lx=()=>location.search,N1=({ssrSearch:e}={})=>Zv(lx,e!=null?()=>e:lx),cx=()=>location.pathname,T1=({ssrPath:e}={})=>Zv(cx,e!=null?()=>e:cx),A1=(e,{replace:r=!1,state:i=null}={})=>history[r?uh:ch](i,"",e),D1=(e={})=>[T1(e),A1],ux=Symbol.for("wouter_v3");if(typeof history<"u"&&typeof window[ux]>"u"){for(const e of[ch,uh]){const r=history[e];history[e]=function(){const i=r.apply(this,arguments),s=new Event(e);return s.arguments=arguments,dispatchEvent(s),i}}Object.defineProperty(window,ux,{value:!0})}const L1=(e,r)=>r.toLowerCase().indexOf(e.toLowerCase())?"~"+r:r.slice(e.length)||"/",Qv=(e="")=>e==="/"?"":e,R1=(e,r)=>e[0]==="~"?e.slice(1):Qv(r)+e,M1=(e="",r)=>L1(dx(Qv(e)),dx(r)),dx=e=>{try{return decodeURI(e)}catch{return e}},Jv={hook:D1,searchHook:N1,parser:x1,base:"",ssrPath:void 0,ssrSearch:void 0,ssrContext:void 0,hrefs:e=>e,aroundNav:(e,r,i)=>e(r,i)},eb=P.createContext(Jv),Ts=()=>P.useContext(eb),tb={},nb=P.createContext(tb),O1=()=>P.useContext(nb),Il=e=>{const[r,i]=e.hook(e);return[M1(e.base,r),Xv((s,c)=>e.aroundNav(i,R1(s,e.base),c))]},ar=()=>Il(Ts()),dh=(e,r,i,s)=>{const{pattern:c,keys:u}=r instanceof RegExp?{keys:!1,pattern:r}:e(r||"*",s),p=c.exec(i)||[],[l,...h]=p;return l!==void 0?[!0,(()=>{const f=u!==!1?Object.fromEntries(u.map((m,x)=>[m,h[x]])):p.groups;let g={...h};return f&&Object.assign(g,f),g})(),...s?[l]:[]]:[!1,null]},hh=e=>dh(Ts().parser,e,ar()[0]),B1=({children:e,...r})=>{var g,m,x;const i=Ts(),s=r.hook?Jv:i;let c=s;const[u,p=r.ssrSearch??""]=((g=r.ssrPath)==null?void 0:g.split("?"))??[];u&&(r.ssrSearch=p,r.ssrPath=u),r.hrefs=r.hrefs??((m=r.hook)==null?void 0:m.hrefs),r.searchHook=r.searchHook??((x=r.hook)==null?void 0:x.searchHook);let l=P.useRef({}),h=l.current,f=h;for(let S in s){const k=S==="base"?s[S]+(r[S]??""):r[S]??s[S];h===f&&k!==f[S]&&(l.current=f={...f}),f[S]=k,(k!==s[S]||k!==c[S])&&(c=f)}return P.createElement(eb.Provider,{value:c,children:e})},hx=({children:e,component:r},i)=>r?P.createElement(r,{params:i}):typeof e=="function"?e(i):e,I1=e=>{let r=P.useRef(tb);const i=r.current;return r.current=Object.keys(e).length!==Object.keys(i).length||Object.entries(e).some(([s,c])=>c!==i[s])?e:i},ka=({path:e,nest:r,match:i,...s})=>{const c=Ts(),[u]=Il(c),[p,l,h]=i??dh(c.parser,e,u,r),f=I1({...O1(),...l});if(!p)return null;const g=h?P.createElement(B1,{base:h},hx(s,f)):hx(s,f);return P.createElement(nb.Provider,{value:f,children:g})},An=P.forwardRef((e,r)=>{const i=Ts(),[s,c]=Il(i),{to:u="",href:p=u,onClick:l,asChild:h,children:f,className:g,replace:m,state:x,transition:S,...k}=e,C=Xv(y=>{y.ctrlKey||y.metaKey||y.altKey||y.shiftKey||y.button!==0||(l==null||l(y),y.defaultPrevented||(y.preventDefault(),c(p,e)))}),b=i.hrefs(p[0]==="~"?p.slice(1):i.base+p,i);return h&&P.isValidElement(f)?P.cloneElement(f,{onClick:C,href:b}):P.createElement("a",{...k,onClick:C,href:b,className:g!=null&&g.call?g(s===p):g,children:f,ref:r})}),rb=e=>Array.isArray(e)?e.flatMap(r=>rb(r&&r.type===P.Fragment?r.props.children:r)):[e],z1=({children:e,location:r})=>{const i=Ts(),[s]=Il(i);for(const c of rb(e)){let u=0;if(P.isValidElement(c)&&(u=dh(i.parser,c.props.path,r||s,c.props.nest))[0])return P.cloneElement(c,{match:u})}return null},fx=e=>{let r;const i=new Set,s=(f,g)=>{const m=typeof f=="function"?f(r):f;if(!Object.is(m,r)){const x=r;r=g??(typeof m!="object"||m===null)?m:Object.assign({},r,m),i.forEach(S=>S(r,x))}},c=()=>r,l={setState:s,getState:c,getInitialState:()=>h,subscribe:f=>(i.add(f),()=>i.delete(f))},h=r=e(s,c,l);return l},H1=(e=>e?fx(e):fx),P1=e=>e;function F1(e,r=P1){const i=ln.useSyncExternalStore(e.subscribe,ln.useCallback(()=>r(e.getState()),[e,r]),ln.useCallback(()=>r(e.getInitialState()),[e,r]));return ln.useDebugValue(i),i}const px=e=>{const r=H1(e),i=s=>F1(r,s);return Object.assign(i,r),i},qn=(e=>e?px(e):px);async function ye(e,r={}){const i=localStorage.getItem("openfox_token"),s={...r.headers instanceof Headers?Object.fromEntries(r.headers.entries()):r.headers,...i?{"x-session-token":i}:{}};return fetch(e,{...r,headers:s})}function U1(e){return typeof e=="object"&&e!==null&&"type"in e&&"payload"in e}function Sl(){if(typeof crypto<"u"&&crypto.randomUUID)try{return crypto.randomUUID()}catch{}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const r=Math.random()*16|0;return(e==="x"?r:r&3|8).toString(16)})}class $1{constructor(r){tr(this,"ws",null);tr(this,"handlers",new Set);tr(this,"statusHandler",null);tr(this,"baseUrl");tr(this,"isReconnecting",!1);tr(this,"connectingPromise",null);tr(this,"lastCloseCode",0);tr(this,"reconnectAttempts",0);tr(this,"manualReconnectScheduled",!1);this.baseUrl=r}getUrl(){const r=localStorage.getItem("openfox_token");if(r){const i=this.baseUrl.includes("?")?"&":"?";return`${this.baseUrl}${i}token=${encodeURIComponent(r)}`}return this.baseUrl}setToken(r){localStorage.setItem("openfox_token",r)}clearToken(){localStorage.removeItem("openfox_token")}hasToken(){return!!localStorage.getItem("openfox_token")}getLastCloseCode(){return this.lastCloseCode}onStatusChange(r){this.statusHandler=r}connect(){var r,i;return((r=this.ws)==null?void 0:r.readyState)===WebSocket.OPEN?Promise.resolve():(this.lastCloseCode=0,this.isReconnecting=!1,this.connectingPromise&&((i=this.ws)==null?void 0:i.readyState)===WebSocket.CONNECTING?this.connectingPromise:(this.connectingPromise=new Promise((s,c)=>{try{const u=this.getUrl();this.ws=new WebSocket(u);const p=setTimeout(()=>{var l;((l=this.ws)==null?void 0:l.readyState)===WebSocket.CONNECTING&&(this.ws.close(),c(new Error("Connection timeout")))},5e3);this.ws.onopen=()=>{var l;clearTimeout(p),this.isReconnecting=!1,this.connectingPromise=null,(l=this.statusHandler)==null||l.call(this,"connected"),s()},this.ws.onclose=l=>{var h,f,g;clearTimeout(p),this.lastCloseCode=l.code,((h=this.ws)==null?void 0:h.readyState)===WebSocket.CONNECTING?(this.connectingPromise=null,(f=this.statusHandler)==null||f.call(this,"disconnected"),c(new Error(`Connection closed: ${l.code}`))):(this.connectingPromise=null,(g=this.statusHandler)==null||g.call(this,"disconnected"),this.attemptReconnect())},this.ws.onerror=l=>{clearTimeout(p),console.error("WebSocket error:",l),this.connectingPromise=null,c(l)},this.ws.onmessage=l=>{try{const h=JSON.parse(l.data);U1(h)&&this.handlers.forEach(f=>f(h))}catch(h){console.error("Failed to parse WebSocket message:",h)}}}catch(u){this.connectingPromise=null,c(u)}}),this.connectingPromise))}attemptReconnect(){var c;if(([1e3,1005,1006,4e3].includes(this.lastCloseCode)||this.lastCloseCode===0)&&this.hasToken()){console.log("[WS] Auth failure or initial failure with token - not auto-reconnecting, awaiting user action");return}if(this.isReconnecting||this.manualReconnectScheduled)return;this.isReconnecting=!0,(c=this.statusHandler)==null||c.call(this,"reconnecting");const s=Math.min(1e3*Math.pow(2,this.reconnectAttempts||0),3e4);this.reconnectAttempts=(this.reconnectAttempts||0)+1,setTimeout(()=>{this.isReconnecting=!1,this.manualReconnectScheduled=!1,this.connect().catch(()=>{})},s)}reconnect(){this.manualReconnectScheduled=!0,this.isReconnecting=!1,this.lastCloseCode=0,this.connectingPromise=null,this.connect().catch(()=>{})}disconnect(){this.isReconnecting=!1,this.reconnectAttempts=0,this.ws&&(this.ws.close(),this.ws=null)}resetReconnectAttempts(){this.reconnectAttempts=0}send(r,i){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket not connected");const s=Sl(),c={id:s,type:r,payload:i};return this.ws.send(JSON.stringify(c)),s}subscribe(r){return this.handlers.add(r),()=>this.handlers.delete(r)}get isConnected(){var r;return((r=this.ws)==null?void 0:r.readyState)===WebSocket.OPEN}}const q1=`ws://${window.location.hostname}:${window.location.port||"10469"}/ws`,Ht=new $1(q1);let hl=[],xd=null,wl=null;function W1(){xd===null&&(xd=requestAnimationFrame(()=>{xd=null,wl==null||wl()}))}const rr=qn()((e,r)=>(wl=()=>{if(hl.length===0)return;const i=hl;hl=[],e(s=>({logs:[...s.logs,...i]}))},{workdir:null,status:null,logs:[],config:null,loading:!1,setWorkdir:i=>{r().workdir!==i&&(e({workdir:i,status:null,logs:[],config:null,loading:!0}),i&&(r().fetchStatus(),r().fetchConfig()))},fetchStatus:async()=>{const i=r().workdir;if(i)try{const c=await(await ye(`/api/dev-server?workdir=${encodeURIComponent(i)}`)).json();e({status:c,loading:!1})}catch{e({loading:!1})}},fetchConfig:async()=>{const i=r().workdir;if(i)try{const c=await(await ye(`/api/dev-server/config?workdir=${encodeURIComponent(i)}`)).json();e({config:c.config??null})}catch{}},fetchLogs:async()=>{const i=r().workdir;if(i)try{const u=(await(await ye(`/api/dev-server/logs?workdir=${encodeURIComponent(i)}`)).json()).logs.map(p=>({stream:p.stream,content:p.content}));e({logs:u})}catch{}},start:async()=>{const i=r().workdir;if(i)try{const c=await(await ye(`/api/dev-server/start?workdir=${encodeURIComponent(i)}`,{method:"POST"})).json();e({status:c,logs:[]})}catch{}},stop:async()=>{const i=r().workdir;if(i)try{const c=await(await ye(`/api/dev-server/stop?workdir=${encodeURIComponent(i)}`,{method:"POST"})).json();e({status:c})}catch{}},restart:async()=>{const i=r().workdir;if(i)try{const c=await(await ye(`/api/dev-server/restart?workdir=${encodeURIComponent(i)}`,{method:"POST"})).json();e({status:c,logs:[]})}catch{}},saveConfig:async i=>{const s=r().workdir;if(s)try{const u=await(await ye(`/api/dev-server/config?workdir=${encodeURIComponent(s)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})).json();e({config:u.config??i}),r().fetchStatus()}catch{}},handleMessage:i=>{const s=r().workdir;if(s)switch(i.type){case"devServer.output":{const c=i.payload;if(c.workdir!==s)return;hl.push({stream:c.stream,content:c.content}),W1();break}case"devServer.state":{const c=i.payload;if(c.workdir!==s)return;e(u=>({status:u.status?{...u.status,state:c.state,errorMessage:c.errorMessage}:u.status}));break}}}})),G1=3e4;function V1(e){switch(e){case"vllm":return"vLLM";case"sglang":return"SGLang";case"ollama":return"Ollama";case"llamacpp":return"llama.cpp";case"openai":return"OpenAI";case"anthropic":return"Anthropic";case"opencode-go":return"OpenCode Go";case"auto":return"Auto";case"unknown":return""}}const Lt=qn((e,r)=>({version:null,model:null,maxContext:2e5,llmUrl:null,llmStatus:"unknown",backend:"unknown",providers:[],activeProviderId:null,defaultModelSelection:null,loading:!1,activating:!1,error:null,autoRefreshInterval:null,fetchConfig:async()=>{e({loading:!0,error:null});try{const i=await ye("/api/config");if(!i.ok)throw new Error("Failed to fetch config");const s=await i.json();e({version:s.version,model:s.model,maxContext:s.maxContext,llmUrl:s.llmUrl,llmStatus:s.llmStatus,backend:s.backend,providers:s.providers??[],activeProviderId:s.activeProviderId??null,defaultModelSelection:s.defaultModelSelection??null,loading:!1})}catch(i){e({error:i instanceof Error?i.message:"Unknown error",loading:!1})}},refreshModel:async()=>{try{const i=await ye("/api/model/refresh",{method:"POST"});if(!i.ok)throw new Error("Failed to refresh model");const s=await i.json(),u=Ee.getState().currentSession;if(u!=null&&u.providerId&&u.providerModel){e({llmStatus:s.llmStatus,backend:s.backend});return}e({model:s.model,llmStatus:s.llmStatus,backend:s.backend})}catch(i){console.error("Failed to refresh model:",i)}},activateProvider:async i=>{const{activeProviderId:s,providers:c}=r();if(i===s)return!0;e({activating:!0,error:null});try{const u=await ye(`/api/providers/${i}/activate`,{method:"POST"});if(!u.ok){const l=await u.json();throw new Error(l.error??"Failed to activate provider")}const p=await u.json();return e({activeProviderId:p.activeProviderId,model:p.model,backend:p.backend,providers:c.map(l=>({...l,isActive:l.id===p.activeProviderId})),activating:!1}),!0}catch(u){return e({error:u instanceof Error?u.message:"Failed to switch provider",activating:!1}),!1}},syncFromSession:(i,s)=>{const{providers:c}=r();e({activeProviderId:i,model:s,defaultModelSelection:`${i}/${s}`,providers:c.map(u=>({...u,isActive:u.id===i}))})},updateModelContext:async(i,s,c)=>{e({activating:!0,error:null});try{const u=await ye(`/api/providers/${i}/models/${encodeURIComponent(s)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({contextWindow:c})});if(!u.ok){const h=await u.json();throw new Error(h.error??"Failed to update model context")}const p=await u.json(),{providers:l}=r();return e({providers:l.map(h=>h.id===i?{...h,models:h.models.map(f=>f.id===s?{...f,contextWindow:c,source:"user"}:f)}:h),activating:!1}),p.contextState&&Ee.getState().updateContextState(p.contextState),!0}catch(u){return e({error:u instanceof Error?u.message:"Failed to update model context",activating:!1}),!1}},refreshProviderModels:async i=>{e({activating:!0,error:null});try{const s=await ye(`/api/providers/${i}/refresh`,{method:"POST"});if(!s.ok){const p=await s.json();throw new Error(p.error??"Failed to refresh models")}const c=await s.json(),{providers:u}=r();return e({providers:u.map(p=>p.id===i?{...p,models:c.models}:p),activating:!1}),!0}catch(s){return e({error:s instanceof Error?s.message:"Failed to refresh models",activating:!1}),!1}},startAutoRefresh:()=>{const{autoRefreshInterval:i,refreshModel:s}=r();if(i)return;const c=setInterval(()=>{s()},G1);e({autoRefreshInterval:c})},stopAutoRefresh:()=>{const{autoRefreshInterval:i}=r();i&&(clearInterval(i),e({autoRefreshInterval:null}))},getActiveProvider:()=>{const{providers:i,activeProviderId:s}=r();return i.find(c=>c.id===s)},getModelContext:i=>{const{providers:s,activeProviderId:c}=r(),u=s.find(l=>l.id===c);if(!u)return 2e5;const p=u.models.find(l=>l.id===i);return(p==null?void 0:p.contextWindow)??2e5}})),Ut=qn((e,r)=>({projects:[],currentProject:null,loading:!1,listProjects:async()=>{e({loading:!0});try{const s=await(await ye("/api/projects")).json();e({projects:s.projects??[],loading:!1})}catch{e({loading:!1})}},createProject:async(i,s)=>{try{const c=await ye("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:i,workdir:s})});if(!c.ok)return null;const u=await c.json();return await r().listProjects(),u.project}catch{return null}},loadProject:async i=>{try{const s=await ye(`/api/projects/${i}`);if(!s.ok)return null;const c=await s.json();return e({currentProject:c.project}),r().projects.length===0&&await r().listProjects(),c.project}catch{return null}},updateProject:async(i,s)=>{var c;try{const u=await ye(`/api/projects/${i}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!u.ok)return null;const p=await u.json();return((c=r().currentProject)==null?void 0:c.id)===i&&e({currentProject:p.project}),await r().listProjects(),p.project}catch{return null}},deleteProject:async i=>{var s;try{return(await ye(`/api/projects/${i}`,{method:"DELETE"})).ok?(await r().listProjects(),((s=r().currentProject)==null?void 0:s.id)===i&&e({currentProject:null}),!0):!1}catch{return!1}},clearProject:()=>{e({currentProject:null})}}));let fl=[],vd=null,Cl=null;function Y1(){vd===null&&(vd=requestAnimationFrame(()=>{vd=null,Cl==null||Cl()}))}const Oa=qn()((e,r)=>(Cl=()=>{if(fl.length===0)return;const i=fl;fl=[],e(s=>{const c={...s.logs};for(const u of i){const p=c[u.processId]??[];c[u.processId]=[...p,{offset:p.length,content:u.content,timestamp:Date.now(),stream:u.stream}]}return{logs:c}})},{processes:[],logs:{},loading:!1,setProcesses:i=>e({processes:i}),addProcess:i=>e(s=>({processes:[...s.processes,i]})),updateProcess:(i,s)=>e(c=>({processes:c.processes.map(u=>u.id===i?{...u,...s}:u)})),removeProcess:i=>e(s=>({processes:s.processes.filter(c=>c.id!==i),logs:Object.fromEntries(Object.entries(s.logs).filter(([c])=>c!==i))})),stopProcess:async(i,s)=>{try{(await ye(`/api/sessions/${s}/background-process/${i}/stop`,{method:"POST"})).ok&&r().removeProcess(i)}catch{}},appendLog:(i,s,c)=>{fl.push({processId:i,stream:s,content:c}),Y1()},setLogs:(i,s)=>e(c=>({logs:{...c.logs,[i]:s}})),clearLogs:i=>e(s=>({logs:{...s.logs,[i]:[]}})),handleMessage:(i,s)=>{switch(i){case"backgroundProcess.started":{const{processId:c,name:u,pid:p,status:l}=s;e(h=>({processes:[...h.processes,{id:c,sessionId:"",name:u,command:"",cwd:"",pid:p,status:l,exitCode:null,createdAt:Date.now(),startedAt:Date.now(),endedAt:null}]}));break}case"backgroundProcess.output":{const c=s.processId,u=s.stream,p=s.content;r().appendLog(c,u,p);break}case"backgroundProcess.exited":{const c=s.processId,u=s.exitCode;e(p=>({processes:p.processes.map(l=>l.id===c?{...l,status:"exited",exitCode:u}:l)}));break}case"backgroundProcess.removed":{const c=s.processId;r().removeProcess(c);break}}}})),ei={GLOBAL_INSTRUCTIONS:"global_instructions",NOTIFICATION_SETTINGS:"notification_settings"},ti=qn(e=>({settings:{},loading:{},getSetting:async r=>{e(i=>({loading:{...i.loading,[r]:!0}}));try{const s=await(await ye(`/api/settings/${r}`)).json();return e(c=>({settings:{...c.settings,[r]:s.value??""},loading:{...c.loading,[r]:!1}})),s.value}catch{return e(i=>({loading:{...i.loading,[r]:!1}})),null}},setSetting:async(r,i)=>{e(s=>({loading:{...s.loading,[r]:!0}}));try{const c=await(await ye(`/api/settings/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:i})})).json();e(u=>({settings:{...u.settings,[r]:c.value??""},loading:{...u.loading,[r]:!1}}))}catch{e(s=>({loading:{...s.loading,[r]:!1}}))}}})),mx=[{key:"complete",label:"Task Complete",description:"When an agent finishes its work"},{key:"waiting_for_user",label:"Waiting for Input",description:"When the agent needs your input"},{key:"phase_done",label:"Phase Done",description:"When a build phase completes successfully"},{key:"phase_blocked",label:"Phase Blocked",description:"When a build phase is blocked and needs intervention"},{key:"new_message",label:"New Message",description:"When a new assistant message starts arriving"}],K1=[{key:"planner",label:"Planner"},{key:"build",label:"Builder"},{key:"sub-agent",label:"Sub-agent"}],X1=[{url:"/sounds/notification.mp3",label:"Notification"},{url:"/sounds/waiting-for-user.mp3",label:"Waiting for User"},{url:"/sounds/achievement.mp3",label:"Achievement"},{url:"/sounds/intervention.mp3",label:"Intervention"},{url:"/sounds/typing.mp3",label:"Typing"}],fh={complete:"/sounds/notification.mp3",waiting_for_user:"/sounds/waiting-for-user.mp3",phase_done:"/sounds/achievement.mp3",phase_blocked:"/sounds/intervention.mp3",new_message:"/sounds/typing.mp3"},ir={soundEnabled:!0,browserNotification:!1,customSoundUrl:null},Wd={soundEnabled:!0,browserNotificationEnabled:!1,events:{complete:{...ir},waiting_for_user:{...ir},phase_done:{...ir},phase_blocked:{...ir},new_message:{...ir}},agentOverrides:{}};function ib(e,r,i){var u;const s=e.events[r];if(!i)return s;const c=(u=e.agentOverrides[i])==null?void 0:u[r];return c?{soundEnabled:c.soundEnabled??s.soundEnabled,browserNotification:c.browserNotification??s.browserNotification,customSoundUrl:c.customSoundUrl!==void 0?c.customSoundUrl:s.customSoundUrl}:s}const Ei=qn((e,r)=>({settings:Wd,loaded:!1,load:()=>{ti.getState().getSetting(ei.NOTIFICATION_SETTINGS);const s=ti.subscribe(u=>{const p=u.settings[ei.NOTIFICATION_SETTINGS];if(p!==void 0)try{const l=JSON.parse(p);e({settings:gx(l),loaded:!0})}catch{e({loaded:!0})}}),c=ti.getState().settings[ei.NOTIFICATION_SETTINGS];if(c)try{const u=JSON.parse(c);e({settings:gx(u),loaded:!0})}catch{e({loaded:!0})}return s},update:i=>{e({settings:i}),bd(i)},updateEvent:(i,s)=>{const c=r().settings,u={...c,events:{...c.events,[i]:{...c.events[i],...s}}};e({settings:u}),bd(u)},updateAgentOverride:(i,s,c)=>{var h;const u=r().settings,p={...u.agentOverrides};if(c===null){if(p[i]){const f={...p[i]};delete f[s],Object.keys(f).length===0?delete p[i]:p[i]=f}}else p[i]={...p[i],[s]:{...((h=p[i])==null?void 0:h[s])??{},...c}};const l={...u,agentOverrides:p};e({settings:l}),bd(l)}}));function bd(e){ti.getState().setSetting(ei.NOTIFICATION_SETTINGS,JSON.stringify(e))}function gx(e){var r,i,s,c,u;return{soundEnabled:e.soundEnabled??Wd.soundEnabled,browserNotificationEnabled:e.browserNotificationEnabled??Wd.browserNotificationEnabled,events:{complete:{...ir,...(r=e.events)==null?void 0:r.complete},waiting_for_user:{...ir,...(i=e.events)==null?void 0:i.waiting_for_user},phase_done:{...ir,...(s=e.events)==null?void 0:s.phase_done},phase_blocked:{...ir,...(c=e.events)==null?void 0:c.phase_blocked},new_message:{...ir,...(u=e.events)==null?void 0:u.new_message}},agentOverrides:e.agentOverrides??{}}}const xx=new Map;function Z1(e){let r=xx.get(e);return r||(r=new Audio(e),r.volume=.5,xx.set(e,r)),r}let sb=typeof Notification<"u"?Notification.permission:"denied";function Q1(){return typeof Notification>"u"?Promise.resolve("denied"):Notification.requestPermission().then(e=>(sb=e,e))}const J1={complete:"Task Complete",waiting_for_user:"Waiting for Input",phase_done:"Phase Complete",phase_blocked:"Phase Blocked",new_message:"New Message"},eS={complete:"The agent has finished its work.",waiting_for_user:"The agent needs your input to continue.",phase_done:"The build phase completed successfully.",phase_blocked:"The build phase is blocked and needs intervention.",new_message:"A new assistant message is arriving."};function tS(e){typeof Notification>"u"||sb==="granted"&&(document.hasFocus()||new Notification(J1[e],{body:eS[e],icon:"/fox.svg",tag:`openfox-${e}`}))}function Va(e,r){const{settings:i}=Ei.getState(),s=ib(i,e,r);if(i.soundEnabled&&s.soundEnabled){const c=s.customSoundUrl??fh[e],u=Z1(c);u.currentTime=0,u.play().catch(()=>{})}i.browserNotificationEnabled&&s.browserNotification&&tS(e)}const nS=e=>Va("complete",e),rS=e=>Va("phase_done",e),iS=e=>Va("phase_blocked",e),vx=e=>Va("waiting_for_user",e),bx=e=>Va("new_message",e);let pl=!1;const Ea=new Set,zt={messageId:null,deltaContent:"",thinkingContent:"",toolOutput:[]};let Es=null,nn=null;function yd(){Es===null&&(Es=requestAnimationFrame(()=>{Es=null,nn==null||nn()}))}function Si(){Es!==null&&(cancelAnimationFrame(Es),Es=null)}function Dt(e,r){return r!==null&&e.sessionId===r}function sS(e,r,i){return e.id!==void 0||Dt(e,r)||i===!0&&e.sessionId!==void 0}function aS(e,r){return e.includes(r)?e:[...e,r]}function ja(e,r){return e.filter(i=>i!==r)}function oS(e,r){const i=e.find(c=>c.id===r.id),s=i?{...i,projectId:r.projectId,workdir:r.workdir,mode:r.mode,phase:r.phase,isRunning:r.isRunning,messageCount:r.messages.length,criteriaCount:r.criteria.length,criteriaCompleted:r.criteria.filter(c=>c.status.type==="passed").length}:{id:r.id,projectId:r.projectId,workdir:r.workdir,mode:r.mode,phase:r.phase,isRunning:r.isRunning,createdAt:"",updatedAt:"",criteriaCount:r.criteria.length,criteriaCompleted:r.criteria.filter(c=>c.status.type==="passed").length,messageCount:r.messages.length};return i?e.map(c=>c.id===r.id?s:c):[s,...e]}function lS(e,r,i){return e.map(s=>{const c=(i==null?void 0:i.id)===s.id?i:null,u=r.find(p=>p.id===s.id);return{...s,title:s.title??(u==null?void 0:u.title),mode:(c==null?void 0:c.mode)??(u==null?void 0:u.mode)??s.mode,phase:(c==null?void 0:c.phase)??(u==null?void 0:u.phase)??s.phase,isRunning:(c==null?void 0:c.isRunning)??(u==null?void 0:u.isRunning)??s.isRunning,messageCount:s.messageCount,recentUserPrompts:s.recentUserPrompts}})}const yx=new Map;function Cs(e,r){var u;const i=r===((u=e.currentSession)==null?void 0:u.id)?e.currentSession:null,s=e.sessions.find(p=>p.id===r),c=(i==null?void 0:i.mode)??(s==null?void 0:s.mode);return c==="planner"?"planner":c==="builder"?"build":"planner"}function cS(e,r){if(e.type==="chat.done"){const i=e.payload,s=Cs(r,e.sessionId);i.reason==="complete"&&nS(s),i.reason==="waiting_for_user"&&vx(s);return}if(e.type==="chat.path_confirmation"){const i=Cs(r,e.sessionId);vx(i);return}if(e.type==="task.completed"){const i=Cs(r,e.sessionId);rS(i);return}if(e.type==="phase.changed"&&e.sessionId){const i=e.payload,s=yx.get(e.sessionId)??null;if(yx.set(e.sessionId,i.phase),s===i.phase)return;const c=Cs(r,e.sessionId);i.phase==="blocked"&&iS(c)}}const Ee=qn((e,r)=>(nn=()=>{const i=zt;if(!i.messageId)return;const s=i.deltaContent.length>0,c=i.thinkingContent.length>0,u=i.toolOutput.length>0;if(!s&&!c&&!u)return;const p=i.deltaContent,l=i.thinkingContent,h=i.toolOutput;i.deltaContent="",i.thinkingContent="",i.toolOutput=[],e(f=>{var m;const g=f.streamingMessage;if(g&&g.id===i.messageId){let x={...g};if(s&&(x.content=x.content+p),c&&(x.thinkingContent=(x.thinkingContent??"")+l),u){const S=new Set;x.toolCalls=(m=x.toolCalls)==null?void 0:m.map(C=>{const b=h.filter(y=>y.callId===C.id);return b.length===0?C:(S.add(C.id),{...C,streamingOutput:[...C.streamingOutput??[],...b.map(y=>({stream:y.stream,content:y.content}))]})});const k=h.filter(C=>!S.has(C.callId));k.length>0&&zt.toolOutput.push(...k)}return{streamingMessage:x}}if(u){const x=new Set,S=f.messages.map(C=>{var y;if(C.id!==i.messageId)return C;const b=(y=C.toolCalls)==null?void 0:y.map(v=>{const _=h.filter(j=>j.callId===v.id);return _.length===0?v:(x.add(v.id),{...v,streamingOutput:[...v.streamingOutput??[],..._.map(j=>({stream:j.stream,content:j.content}))]})});return{...C,toolCalls:b}}),k=h.filter(C=>!x.has(C.callId));return k.length>0&&zt.toolOutput.push(...k),{messages:S}}return f})},{connectionStatus:"disconnected",showPasswordModal:!1,passwordModalRetry:!1,sessions:[],currentSession:null,unreadSessionIds:[],messages:[],streamingMessageId:null,streamingMessage:null,currentTodos:[],contextState:null,pendingPathConfirmation:null,pendingQuestion:null,visionFallbackByMessage:{},queuedMessages:[],abortInProgress:!1,error:null,sessionsHasMore:!0,sessionsPaginationLoading:!1,pendingSessionCreate:!1,connect:async()=>{const i=r().connectionStatus;if(i==="connected"||i==="reconnecting")return;e({connectionStatus:"reconnecting"});let s=!1;try{s=(await(await ye("/api/auth")).json()).requiresAuth}catch{}if(s&&!Ht.hasToken()){e({showPasswordModal:!0,passwordModalRetry:!1,connectionStatus:"reconnecting"});return}Ht.onStatusChange(c=>{e({connectionStatus:c}),c==="connected"&&r().listSessions(void 0)});try{if(await Ht.connect(),!pl){pl=!0;const c=r().handleServerMessage;Ht.subscribe(c)}}catch(c){console.error("Failed to connect:",c);const u=Ht.getLastCloseCode();if(!Ht.hasToken()&&(u===1006||u===4e3)){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}e({connectionStatus:"disconnected"})}},reconnect:()=>{Ht.disconnect(),pl=!1,e({connectionStatus:"reconnecting"}),r().connect()},disconnect:()=>{Ht.disconnect(),pl=!1,e({connectionStatus:"disconnected",showPasswordModal:!1})},submitPassword:async i=>{try{const s=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:i})});if(!s.ok){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}const{token:c}=await s.json();Ht.setToken(c),e({showPasswordModal:!1,connectionStatus:"disconnected"});const{listProjects:u}=Ut.getState(),{fetchConfig:p}=Lt.getState();u(),p(),r().connect()}catch{e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"})}},cancelPassword:()=>{Ht.clearToken(),e({showPasswordModal:!1,connectionStatus:"disconnected"})},createSession:async(i,s)=>{try{e({pendingSessionCreate:!0});const c=await ye("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:i,title:s})});if(!c.ok)return e({pendingSessionCreate:!1}),null;const u=await c.json();return Ht.send("session.load",{sessionId:u.session.id}),u.session}catch{return e({pendingSessionCreate:!1}),null}},loadSession:async i=>{try{const s=r().currentSession;!s||s.id!==i?(Si(),e({currentSession:null,unreadSessionIds:ja(r().unreadSessionIds,i),messages:[],streamingMessageId:null,streamingMessage:null,currentTodos:[],contextState:null,pendingPathConfirmation:null,queuedMessages:[],abortInProgress:!1,error:null})):e({unreadSessionIds:ja(r().unreadSessionIds,i)});const c=await ye(`/api/sessions/${i}`);if(!c.ok)return;const u=await c.json();e({currentSession:u.session,messages:u.messages??[],contextState:u.contextState,queuedMessages:u.queueState??[]}),Ht.send("session.load",{sessionId:i});try{const p=await ye(`/api/sessions/${i}/background-processes`);if(p.ok){const l=await p.json();Oa.getState().setProcesses(l.processes??[])}}catch{}}catch{}},listSessions:async(i,s=20)=>{try{const c=new URLSearchParams;c.set("limit",String(s)),i&&c.set("projectId",i);const p=await(await ye(`/api/sessions?${c.toString()}`)).json();e({sessions:p.sessions??[],sessionsHasMore:i?p.hasMore??!1:!0})}catch{}},loadMoreSessions:async i=>{const s=r();if(!(s.sessionsPaginationLoading||!s.sessionsHasMore)){e({sessionsPaginationLoading:!0});try{const c=new URLSearchParams;c.set("limit","20"),c.set("offset",String(s.sessions.length)),c.set("projectId",i);const p=await(await ye(`/api/sessions?${c.toString()}`)).json();e(l=>({sessions:[...l.sessions,...p.sessions??[]],sessionsHasMore:p.hasMore??!1,sessionsPaginationLoading:!1}))}catch{e({sessionsPaginationLoading:!1})}}},deleteSession:async i=>{var s;try{return(await ye(`/api/sessions/${i}`,{method:"DELETE"})).ok?(await r().listSessions(),((s=r().currentSession)==null?void 0:s.id)===i&&r().clearSession(),!0):!1}catch{return!1}},deleteAllSessions:async i=>{try{return(await ye(`/api/projects/${i}/sessions`,{method:"DELETE"})).ok?(await r().listSessions(),!0):!1}catch{return!1}},clearSession:()=>{Si(),e(i=>({currentSession:null,messages:[],streamingMessageId:null,streamingMessage:null,currentTodos:[],contextState:null,unreadSessionIds:i.currentSession?ja(i.unreadSessionIds,i.currentSession.id):i.unreadSessionIds}))},sendMessage:async(i,s,c)=>{var p;const u=(p=r().currentSession)==null?void 0:p.id;if(u){e({streamingMessageId:null});try{const h=await(await ye(`/api/sessions/${u}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:i,attachments:s,messageKind:c==null?void 0:c.messageKind})})).json();h.queueState&&e({queuedMessages:h.queueState})}catch(l){console.error("Error sending message:",l)}}},stopGeneration:async()=>{var s;const i=(s=r().currentSession)==null?void 0:s.id;if(i&&!r().abortInProgress){Si(),nn==null||nn(),e({abortInProgress:!0});try{await ye(`/api/sessions/${i}/stop`,{method:"POST"})}catch(c){console.error("Error stopping generation:",c)}}},continueGeneration:async()=>{var s;const i=(s=r().currentSession)==null?void 0:s.id;if(i){e({streamingMessageId:null});try{await ye(`/api/sessions/${i}/continue`,{method:"POST"})}catch(c){console.error("Error continuing generation:",c)}}},launchRunner:(i,s,c)=>{e({streamingMessageId:null});const u={};i!=null&&i.trim()&&(u.content=i),s&&s.length>0&&(u.attachments=s),c&&(u.workflowId=c),Ht.send("runner.launch",u)},switchMode:async i=>{var c;const s=(c=r().currentSession)==null?void 0:c.id;if(s)try{const u=await ye(`/api/sessions/${s}/mode`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:i})});if(!u.ok){console.error("Failed to switch mode:",await u.json());return}const p=await u.json();p.session&&e({currentSession:p.session})}catch(u){console.error("Error switching mode:",u)}},switchDangerLevel:async i=>{var c;const s=(c=r().currentSession)==null?void 0:c.id;if(s)try{const u=await ye(`/api/sessions/${s}/danger-level`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({dangerLevel:i})});if(!u.ok){console.error("Failed to switch danger level:",await u.json());return}const p=await u.json();p.session&&e({currentSession:p.session})}catch(u){console.error("Error switching danger level:",u)}},acceptAndBuild:(i,s,c)=>{e({streamingMessageId:null});const u={};i&&(u.workflowId=i),s!=null&&s.trim()&&(u.content=s),c&&c.length>0&&(u.attachments=c),Ht.send("mode.accept",u)},editCriteria:async i=>{var c;const s=(c=r().currentSession)==null?void 0:c.id;if(s)try{const u=await ye(`/api/sessions/${s}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:i})});u.ok||console.error("Failed to update criteria:",await u.json())}catch(u){console.error("Error updating criteria:",u)}},compactContext:()=>{Ht.send("context.compact",{})},setSessionProvider:async(i,s)=>{var c;try{const u=(c=r().currentSession)==null?void 0:c.id;if(!u)return null;const p=await ye(`/api/sessions/${u}/provider`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:i,...s?{model:s}:{}})});if(!p.ok)return null;const l=await p.json();return e({currentSession:l.session,messages:l.messages??[],contextState:l.contextState}),l.session}catch{return null}},updateContextState:i=>{e({contextState:i})},confirmPath:async(i,s,c=!1)=>{var p;const u=(p=r().currentSession)==null?void 0:p.id;if(u)try{await ye(`/api/sessions/${u}/confirm-path`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:i,approved:s,alwaysAllow:c})})}catch(l){console.error("Error confirming path:",l)}},answerQuestion:async(i,s)=>{var u;const c=(u=r().currentSession)==null?void 0:u.id;if(c){try{await ye(`/api/sessions/${c}/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:i,answer:s})})}catch(p){console.error("Error answering question:",p)}e({pendingQuestion:null})}},queueAsap:async(i,s,c)=>{var p;const u=(p=r().currentSession)==null?void 0:p.id;if(u)try{const h=await(await ye(`/api/sessions/${u}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:i,attachments:s,messageKind:c})})).json();h.queueState&&e({queuedMessages:h.queueState})}catch(l){console.error("Error queueing ASAP message:",l)}},queueCompletion:async(i,s,c)=>{var p;const u=(p=r().currentSession)==null?void 0:p.id;if(u)try{const h=await(await ye(`/api/sessions/${u}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:i,attachments:s,messageKind:c})})).json();h.queueState&&e({queuedMessages:h.queueState})}catch(l){console.error("Error queueing completion message:",l)}},cancelQueued:async i=>{var c;const s=(c=r().currentSession)==null?void 0:c.id;if(s)try{const p=await(await ye(`/api/sessions/${s}/queue/${i}`,{method:"DELETE"})).json();p.queueState&&e({queuedMessages:p.queueState})}catch(u){console.error("Error canceling queued message:",u)}},clearError:()=>{e({error:null})},resetPendingSessionCreate:()=>{e({pendingSessionCreate:!1})},handleServerMessage:i=>{var p,l,h,f,g,m,x,S,k,C,b,y,v,_,j,A,N,L,T,B,H,q,Y,V;const s=r();cS(i,s);const c=((p=s.currentSession)==null?void 0:p.id)??null,u=()=>{const F=i.sessionId;!F||F===c||e(I=>({unreadSessionIds:aS(I.unreadSessionIds,F)}))};switch(i.type){case"session.state":{const F=i.payload;if(!sS(i,c,s.pendingSessionCreate))break;Si();const I=F.messages.find(D=>D.isStreaming)??null,$=r().pendingSessionCreate===!0,X=F.pendingConfirmations??[],R=s.pendingPathConfirmation??(X.length>0?X[0]??null:null);if(e({currentSession:F.session,sessions:oS(r().sessions,F.session),unreadSessionIds:ja(r().unreadSessionIds,F.session.id),messages:F.messages,streamingMessageId:(I==null?void 0:I.id)??null,streamingMessage:I,currentTodos:[],pendingPathConfirmation:R,error:null,...$?{pendingSessionCreate:F.session.id}:{}}),F.session.providerId&&F.session.providerModel){const D=Lt.getState();D.providers.find(W=>W.id===F.session.providerId)&&D.syncFromSession(F.session.providerId,F.session.providerModel)}break}case"session.list":{const F=i.payload;e(I=>({sessions:lS(F.sessions,I.sessions,I.currentSession)}));break}case"session.deleted":{const F=i.payload;e(I=>({unreadSessionIds:ja(I.unreadSessionIds,F.sessionId)})),r().listSessions();break}case"session.deletedAll":{r().listSessions();break}case"session.running":{const F=i.payload,I=i.sessionId,$=(l=r().currentSession)==null?void 0:l.id,X=I&&I!==$;e(J=>({sessions:J.sessions.map(R=>R.id===I?{...R,isRunning:F.isRunning}:R)})),X||e(J=>({currentSession:J.currentSession?{...J.currentSession,isRunning:F.isRunning}:null,...F.isRunning?{}:{abortInProgress:!1,queuedMessages:[]}}));break}case"chat.message":{if(!Dt(i,((h=r().currentSession)==null?void 0:h.id)??null)){u();break}const F=i.payload;e(I=>I.messages.some($=>$.id===F.message.id)?I:{messages:[...I.messages,F.message],streamingMessageId:F.message.isStreaming?F.message.id:I.streamingMessageId,streamingMessage:F.message.isStreaming?F.message:I.streamingMessage});break}case"chat.message_updated":{if(!Dt(i,((f=r().currentSession)==null?void 0:f.id)??null)){u();break}const F=i.payload,I=F.updates.isStreaming===!1&&r().streamingMessageId===F.messageId;I&&(Si(),nn==null||nn()),e($=>{const X=$.streamingMessage,J=I;if(X&&X.id===F.messageId){const R={...X,...F.updates};return{messages:$.messages.map(D=>D.id===F.messageId?R:D),streamingMessageId:J?null:$.streamingMessageId,streamingMessage:J?null:{...X,...F.updates}}}return{messages:$.messages.map(R=>R.id===F.messageId?{...R,...F.updates}:R),streamingMessageId:J?null:$.streamingMessageId}});break}case"chat.delta":{if(!Dt(i,((g=r().currentSession)==null?void 0:g.id)??null)){u();break}const F=i.payload;if(!Ea.has(F.messageId)){Ea.add(F.messageId);const I=Cs(r(),i.sessionId);bx(I)}zt.messageId=F.messageId,zt.deltaContent+=F.content,yd();break}case"chat.thinking":{if(!Dt(i,((m=r().currentSession)==null?void 0:m.id)??null)){u();break}const F=i.payload;if(!Ea.has(F.messageId)){Ea.add(F.messageId);const I=Cs(r(),i.sessionId);bx(I)}zt.messageId=F.messageId,zt.thinkingContent+=F.content,yd();break}case"chat.tool_preparing":{if(!Dt(i,((x=r().currentSession)==null?void 0:x.id)??null)){u();break}const F=i.payload;e(I=>{const $=I.streamingMessage;return $&&$.id===F.messageId?{streamingMessage:{...$,preparingToolCalls:[...$.preparingToolCalls??[],{index:F.index,name:F.name}]}}:{messages:I.messages.map(X=>X.id===F.messageId?{...X,preparingToolCalls:[...X.preparingToolCalls??[],{index:F.index,name:F.name}]}:X)}});break}case"chat.tool_call":{if(!Dt(i,((S=r().currentSession)==null?void 0:S.id)??null)){u();break}const F=i.payload,I=$=>{var R;const X=(R=$.preparingToolCalls)==null?void 0:R.filter((D,O)=>{var W;return D.name===F.tool?(W=$.preparingToolCalls)==null?void 0:W.slice(0,O).some(K=>K.name===F.tool):!0}),J=zt.toolOutput.filter(D=>D.callId===F.callId);return J.length>0&&(zt.toolOutput=zt.toolOutput.filter(D=>D.callId!==F.callId)),{...$,toolCalls:[...$.toolCalls??[],{id:F.callId,name:F.tool,arguments:F.args,startedAt:Date.now(),...J.length>0?{streamingOutput:J.map(D=>({stream:D.stream,content:D.content}))}:{}}],...X&&X.length>0?{preparingToolCalls:X}:{preparingToolCalls:void 0}}};e($=>{const X=$.streamingMessage;return X&&X.id===F.messageId?{streamingMessage:I(X)}:{messages:$.messages.map(J=>J.id===F.messageId?I(J):J)}});break}case"chat.tool_output":{if(!Dt(i,((k=r().currentSession)==null?void 0:k.id)??null)){u();break}const F=i.payload;zt.messageId=F.messageId,zt.toolOutput.push({messageId:F.messageId,callId:F.callId,stream:F.stream,content:F.output}),yd();break}case"chat.tool_result":{if(!Dt(i,((C=r().currentSession)==null?void 0:C.id)??null)){u();break}const F=i.payload,I=$=>{var J;const X=(J=$.toolCalls)==null?void 0:J.map(R=>R.id===F.callId?{...R,result:F.result}:R);return{...$,toolCalls:X}};e($=>{const X=$.streamingMessage;return X&&X.id===F.messageId?{streamingMessage:I(X)}:{messages:$.messages.map(J=>J.id===F.messageId?I(J):J)}});break}case"chat.vision_fallback":{if(!Dt(i,((b=r().currentSession)==null?void 0:b.id)??null)){u();break}const F=i.payload;e(I=>{const $=`${F.messageId}-${F.attachmentId}`,X={...I.visionFallbackByMessage};return X[$]={type:F.type,attachmentId:F.attachmentId,filename:F.filename,description:F.description},{visionFallbackByMessage:X}});break}case"chat.todo":{if(!Dt(i,((y=r().currentSession)==null?void 0:y.id)??null)){u();break}const F=i.payload;e({currentTodos:F.todos});break}case"chat.summary":{if(!Dt(i,((v=r().currentSession)==null?void 0:v.id)??null)){u();break}const F=i.payload;e(I=>({currentSession:I.currentSession?{...I.currentSession,summary:F.summary}:null}));break}case"chat.progress":{if(!Dt(i,((_=r().currentSession)==null?void 0:_.id)??null)){u();break}const F=i.payload;console.log("Progress:",F.message,F.phase);break}case"chat.format_retry":{if(!Dt(i,((j=r().currentSession)==null?void 0:j.id)??null)){u();break}const F=i.payload;console.log("Format retry:",F.attempt,"/",F.maxAttempts);break}case"chat.done":{if(!Dt(i,((A=r().currentSession)==null?void 0:A.id)??null)){u();break}Si(),nn==null||nn();const F=i.payload,I=F.stats;zt.messageId=null,zt.deltaContent="",zt.thinkingContent="",zt.toolOutput=[],Ea.delete(F.messageId),e($=>{const X=$.streamingMessage,J=X&&X.id===F.messageId?{...X,isStreaming:!1,stats:I??X.stats}:null;return{messages:$.messages.map(R=>R.id===F.messageId?J??{...R,isStreaming:!1,stats:I??R.stats}:R),streamingMessageId:null,streamingMessage:null,visionFallbackByMessage:{}}});break}case"chat.error":{if(!Dt(i,((N=r().currentSession)==null?void 0:N.id)??null)){u();break}Si(),nn==null||nn();const F=i.payload;console.error("Chat error:",F.error,"recoverable:",F.recoverable),F.recoverable||(zt.messageId=null,zt.deltaContent="",zt.thinkingContent="",zt.toolOutput=[]),e(I=>({error:{code:"CHAT_ERROR",message:F.error},streamingMessageId:F.recoverable?I.streamingMessageId:null,...F.recoverable?{}:{messages:I.streamingMessage?I.messages.map($=>$.id===I.streamingMessage.id?I.streamingMessage:$):I.messages,streamingMessage:null}}));break}case"chat.path_confirmation":{if(!Dt(i,((L=r().currentSession)==null?void 0:L.id)??null)){u();break}const F=i.payload;e({pendingPathConfirmation:{callId:F.callId,tool:F.tool,paths:F.paths,workdir:F.workdir,reason:F.reason}});break}case"chat.ask_user":{if(!Dt(i,((T=r().currentSession)==null?void 0:T.id)??null)){u();return}const F=i.payload;e({pendingQuestion:{callId:F.callId,question:F.question}});break}case"mode.changed":{if(!Dt(i,((B=r().currentSession)==null?void 0:B.id)??null)){u();break}const F=i.payload;e(I=>({currentSession:I.currentSession?{...I.currentSession,mode:F.mode}:null}));break}case"phase.changed":{const F=i.payload,I=i.sessionId,$=(H=r().currentSession)==null?void 0:H.id,X=I&&I!==$;e(J=>({sessions:J.sessions.map(R=>R.id===I?{...R,phase:F.phase}:R)})),X||e(J=>({currentSession:J.currentSession?{...J.currentSession,phase:F.phase}:null}));break}case"criteria.updated":{if(!Dt(i,((q=r().currentSession)==null?void 0:q.id)??null)){u();break}const F=i.payload;e(I=>({currentSession:I.currentSession?{...I.currentSession,criteria:F.criteria}:null}));break}case"context.state":{if(!Dt(i,((Y=r().currentSession)==null?void 0:Y.id)??null)){u();break}const F=i.payload;console.log("[session.handleServerMessage.context.state] Received context state:",F.context),e({contextState:F.context});break}case"session.name_generated":{const F=i.payload,I=i.sessionId,$=(V=r().currentSession)==null?void 0:V.id;e(X=>{const J=X.sessions.map(D=>D.id===I?{...D,title:F.name,updatedAt:new Date().toISOString()}:D),R=$===I?X.currentSession?{...X.currentSession,title:F.name,updatedAt:new Date().toISOString()}:null:X.currentSession;return{sessions:J,currentSession:R}});break}case"queue.state":{const F=i.payload;e({queuedMessages:F.messages});break}case"devServer.output":case"devServer.state":{rr.getState().handleMessage(i);break}case"backgroundProcess.started":case"backgroundProcess.output":case"backgroundProcess.exited":case"backgroundProcess.removed":{Oa.getState().handleMessage(i.type,i.payload);break}case"error":{const F=i.payload;console.error("Server error:",F),e({error:{code:F.code,message:F.message},streamingMessageId:null});break}}}}));function ab(){return Ee(e=>{var r;return((r=e.currentSession)==null?void 0:r.isRunning)??!1})}function uS(){return Ee(e=>e.queuedMessages)}function dS(){return Ee(e=>e.abortInProgress)}function hS(){const e=Ee(s=>s.connect),r=Ee(s=>s.connectionStatus),i=Ei(s=>s.load);return P.useEffect(()=>{e()},[e]),P.useEffect(()=>{r==="connected"&&i()},[r,i]),{connectionStatus:r}}function Gd(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const r=Math.random()*16|0;return(e==="x"?r:r&3|8).toString(16)})}function _x(e,r){const i=Ht.ws;!i||i.readyState!==WebSocket.OPEN||i.send(JSON.stringify({id:Gd(),type:e,payload:r}))}const sr=qn((e,r)=>({isOpen:!1,sessions:[],workdir:null,setOpen:i=>e({isOpen:i}),toggleOpen:()=>e(i=>({isOpen:!i.isOpen})),setWorkdir:i=>e({workdir:i}),fetchSessions:async()=>{try{const i=await ye("/api/terminals");if(i.ok){const s=await i.json();e({sessions:s});const c=Ht.ws;if(c&&c.readyState===WebSocket.OPEN)for(const u of s)c.send(JSON.stringify({id:Gd(),type:"terminal.subscribe",payload:{sessionId:u.id}}))}}catch(i){console.error("Failed to fetch terminals:",i)}},createSession:async i=>{try{const s=await ye("/api/terminals",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:i??r().workdir??void 0})});if(s.ok){const c=await s.json();e(p=>({sessions:[...p.sessions,c]}));const u=Ht.ws;u&&u.readyState===WebSocket.OPEN&&u.send(JSON.stringify({id:Gd(),type:"terminal.subscribe",payload:{sessionId:c.id}}))}}catch(s){console.error("Failed to create terminal:",s)}},writeSession:(i,s)=>{_x("terminal.write",{sessionId:i,data:s})},resizeSession:(i,s,c)=>{_x("terminal.resize",{sessionId:i,cols:s,rows:c})},killSession:async i=>{try{(await ye(`/api/terminals/${i}`,{method:"DELETE"})).ok&&e(c=>({sessions:c.sessions.filter(u=>u.id!==i)}))}catch(s){console.error("Failed to kill terminal:",s)}},handleMessage:i=>{switch(i.type){case"terminal.exit":{const{sessionId:s}=i.payload||{};s&&e(c=>{const u=c.sessions.filter(p=>p.id!==s);return u.length===0&&c.isOpen?{sessions:[],isOpen:!1}:{sessions:u}});break}}}}));Ht.subscribe(e=>{var r;(r=e.type)!=null&&r.startsWith("terminal.")&&sr.getState().handleMessage(e)});var ph=Kv();function un({isOpen:e,onClose:r,title:i,children:s,size:c="md"}){const u=P.useRef(null),p=P.useRef(null),l=P.useCallback(f=>{f.key==="Escape"&&r()},[r]);if(P.useEffect(()=>{var f,g;return e?(p.current=document.activeElement,(f=u.current)==null||f.focus(),document.body.style.overflow="hidden"):((g=p.current)==null||g.focus(),document.body.style.overflow=""),()=>{document.body.style.overflow=""}},[e]),P.useEffect(()=>{if(e)return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[e,l]),!e)return null;const h={sm:"max-w-sm md:max-w-sm",md:"max-w-[90vw] md:max-w-md",lg:"max-w-[90vw] md:max-w-2xl h-[80vh]",xl:"max-w-[90vw] md:max-w-4xl h-[80vh]",full:"max-w-[95vw] h-[90vh]"};return ph.createPortal(o.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[o.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:r}),o.jsxs("div",{ref:u,tabIndex:-1,className:`relative w-full ${h[c]} bg-bg-secondary border border-border rounded shadow-xl flex flex-col max-h-[90vh]`,children:[o.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[o.jsx("h2",{className:"text-lg font-semibold text-text-primary truncate",children:i}),o.jsx("button",{onClick:r,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors flex-shrink-0",children:o.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),o.jsx("div",{className:"p-4 overflow-y-auto flex-1 min-h-0",children:s})]})]}),document.body)}const dt=P.forwardRef(({variant:e="secondary",size:r="md",className:i="",children:s,...c},u)=>{const p="rounded font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed",l={primary:"bg-accent-primary/25 text-white hover:bg-accent-primary/40",secondary:"bg-bg-tertiary text-text-primary hover:bg-border",danger:"bg-accent-error text-white hover:bg-accent-error/80"},h={sm:"px-1.5 py-1 text-xs",md:"px-3 py-1.5 text-sm",lg:"px-4 py-2 text-base"};return o.jsx("button",{ref:u,className:`${p} ${l[e]} ${h[r]} ${i}`,...c,children:s})});dt.displayName="Button";function fS(e){const r=new Audio(e);r.volume=.5,r.play().catch(()=>{})}function ob({value:e,defaultUrl:r,disabled:i,onChange:s}){const c=e??r;return o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("select",{value:c,disabled:i,onChange:u=>{const p=u.target.value;s(p===r?null:p)},className:"px-2 py-1 text-xs bg-bg-tertiary border border-border rounded focus:outline-none focus:ring-1 focus:ring-accent-primary disabled:opacity-40",children:X1.map(({url:u,label:p})=>o.jsxs("option",{value:u,children:[p,u===r?" (default)":""]},u))}),o.jsx("button",{onClick:()=>fS(c),disabled:i,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary disabled:opacity-40 disabled:cursor-not-allowed transition-colors",title:"Preview sound",children:o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.536 8.464a5 5 0 010 7.072M17.95 6.05a8 8 0 010 11.9M6.5 8.8h-2a1 1 0 00-1 1v4.4a1 1 0 001 1h2l4.5 3.5V5.3L6.5 8.8z"})})})]})}function pS(){const e=Ei(h=>h.settings),r=Ei(h=>h.update),i=Ei(h=>h.updateEvent),s=Ei(h=>h.updateAgentOverride),c=Ei(h=>h.load),[u,p]=P.useState(null);P.useEffect(()=>{c()},[c]);const l=async()=>{await Q1()==="granted"&&r({...e,browserNotificationEnabled:!0})};return o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"space-y-3",children:[o.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Master Controls"}),o.jsx(Sx,{label:"Sound notifications",description:"Play sounds when events occur",checked:e.soundEnabled,onChange:h=>r({...e,soundEnabled:h})}),o.jsx(Sx,{label:"Browser notifications",description:"Show desktop notifications when the window is not focused",checked:e.browserNotificationEnabled,onChange:h=>{h&&typeof Notification<"u"&&Notification.permission!=="granted"?l():r({...e,browserNotificationEnabled:h})}}),typeof Notification<"u"&&Notification.permission==="denied"&&e.browserNotificationEnabled&&o.jsx("p",{className:"text-xs text-accent-error ml-6",children:"Browser notifications are blocked. Please enable them in your browser settings."})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Event Configuration"}),mx.map(({key:h,label:f,description:g})=>o.jsx(mS,{event:h,label:f,description:g,config:e.events[h],onUpdate:m=>i(h,m),soundMasterEnabled:e.soundEnabled,browserMasterEnabled:e.browserNotificationEnabled},h))]}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Per-Agent Overrides"}),o.jsx("p",{className:"text-xs text-text-muted",children:"Override notification settings for specific agent types. Unconfigured events use the global defaults above."}),K1.map(({key:h,label:f})=>o.jsxs("div",{className:"border border-border rounded",children:[o.jsxs("button",{className:"w-full flex items-center justify-between px-3 py-2 text-sm text-text-secondary hover:bg-bg-tertiary transition-colors rounded",onClick:()=>p(u===h?null:h),children:[o.jsx("span",{className:"font-medium",children:f}),o.jsx("svg",{className:`w-4 h-4 transition-transform ${u===h?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),u===h&&o.jsx("div",{className:"px-3 pb-3 space-y-3 border-t border-border pt-2",children:mx.map(({key:g,label:m})=>{var b;const x=(b=e.agentOverrides[h])==null?void 0:b[g],S=x!==void 0,k=ib(e,g,h),C=fh[g];return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[o.jsx("input",{type:"checkbox",checked:S,onChange:y=>{y.target.checked?s(h,g,{soundEnabled:k.soundEnabled,browserNotification:k.browserNotification}):s(h,g,null)},className:"rounded border-border"}),o.jsx("span",{className:`flex-1 ${S?"text-text-primary":"text-text-muted"}`,children:m}),S&&o.jsxs(o.Fragment,{children:[o.jsxs("label",{className:"flex items-center gap-1 text-text-secondary",children:[o.jsx("input",{type:"checkbox",checked:k.soundEnabled,onChange:y=>s(h,g,{soundEnabled:y.target.checked}),className:"rounded border-border"}),"Sound"]}),o.jsxs("label",{className:"flex items-center gap-1 text-text-secondary",children:[o.jsx("input",{type:"checkbox",checked:k.browserNotification,onChange:y=>s(h,g,{browserNotification:y.target.checked}),className:"rounded border-border"}),"Browser"]})]})]}),S&&k.soundEnabled&&o.jsx("div",{className:"ml-6",children:o.jsx(ob,{value:(x==null?void 0:x.customSoundUrl)??null,defaultUrl:C,onChange:y=>s(h,g,{customSoundUrl:y})})})]},g)})})]},h))]})]})}function Sx({label:e,description:r,checked:i,onChange:s}){return o.jsxs("label",{className:"flex items-start gap-3 cursor-pointer group",children:[o.jsx("div",{className:"pt-0.5",children:o.jsx("div",{className:`relative w-9 h-5 rounded-full transition-colors ${i?"bg-accent-primary":"bg-bg-tertiary border border-border"}`,onClick:c=>{c.preventDefault(),s(!i)},children:o.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform ${i?"translate-x-4":"translate-x-0.5"}`})})}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm text-text-primary group-hover:text-accent-primary transition-colors",children:e}),o.jsx("div",{className:"text-xs text-text-muted",children:r})]})]})}function mS({event:e,label:r,description:i,config:s,onUpdate:c,soundMasterEnabled:u,browserMasterEnabled:p}){return o.jsxs("div",{className:"border border-border rounded px-3 py-2 space-y-2",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-sm text-text-primary",children:r}),o.jsx("div",{className:"text-xs text-text-muted",children:i})]}),o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[o.jsx("input",{type:"checkbox",checked:s.soundEnabled,onChange:l=>c({soundEnabled:l.target.checked}),disabled:!u,className:"rounded border-border"}),"Sound ",!u&&o.jsx("span",{className:"text-text-muted",children:"(master off)"})]}),o.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[o.jsx("input",{type:"checkbox",checked:s.browserNotification,onChange:l=>c({browserNotification:l.target.checked}),disabled:!p,className:"rounded border-border"}),"Browser notification ",!p&&o.jsx("span",{className:"text-text-muted",children:"(master off)"})]})]}),s.soundEnabled&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-xs text-text-muted",children:"Sound:"}),o.jsx(ob,{value:s.customSoundUrl,defaultUrl:fh[e],disabled:!u,onChange:l=>c({customSoundUrl:l})})]})]})}const lb=P.forwardRef(({icon:e,iconSize:r="w-3.5 h-3.5",className:i="",...s},c)=>o.jsx("button",{ref:c,type:"button",className:`p-1 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors ${i}`,...s,children:o.jsx("svg",{className:r,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:e})})}));lb.displayName="IconButton";const gS="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z",ri=P.forwardRef((e,r)=>o.jsx(lb,{ref:r,icon:gS,title:"Edit",...e}));ri.displayName="EditButton";const Yn=qn((e,r)=>({skills:[],defaultIds:[],modifiedIds:[],loading:!1,fetchDefaultIds:async()=>{try{const s=await(await ye("/api/skills/default-ids")).json();e({defaultIds:s.ids??[]})}catch{}},fetchSkills:async()=>{e({loading:!0});try{const s=await(await ye("/api/skills")).json();e({skills:s.skills??[],defaultIds:s.defaultIds??r().defaultIds,modifiedIds:s.modifiedIds??[],loading:!1})}catch{e({loading:!1})}},toggleSkill:async i=>{try{const c=await(await ye(`/api/skills/${i}/toggle`,{method:"POST"})).json();e({skills:r().skills.map(u=>u.id===i?{...u,enabled:c.enabled}:u)})}catch{}},fetchSkill:async i=>{try{const s=await ye(`/api/skills/${i}`);return s.ok?await s.json():null}catch{return null}},createSkill:async i=>{try{const s=await ye("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});return s.ok?(await r().fetchSkills(),{success:!0}):{success:!1,error:(await s.json()).error}}catch{return{success:!1,error:"Network error"}}},updateSkill:async(i,s)=>{try{const c=await ye(`/api/skills/${i}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});return c.ok?(await r().fetchSkills(),{success:!0}):{success:!1,error:(await c.json()).error}}catch{return{success:!1,error:"Network error"}}},deleteSkill:async i=>{try{return(await ye(`/api/skills/${i}`,{method:"DELETE"})).ok?(e({skills:r().skills.filter(c=>c.id!==i)}),!0):!1}catch{return!1}},restoreDefault:async i=>{try{return(await ye(`/api/skills/${i}/restore-default`,{method:"POST"})).ok?(await r().fetchSkills(),!0):!1}catch{return!1}},restoreAllDefaults:async()=>{try{return(await ye("/api/skills/restore-all-defaults",{method:"POST"})).ok?(await r().fetchSkills(),!0):!1}catch{return!1}}}));function xS(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function vS({isOpen:e}){const r=Yn(Q=>Q.skills),i=Yn(Q=>Q.modifiedIds),s=Yn(Q=>Q.loading),c=Yn(Q=>Q.fetchSkills),u=Yn(Q=>Q.toggleSkill),p=Yn(Q=>Q.fetchSkill),l=Yn(Q=>Q.createSkill),h=Yn(Q=>Q.updateSkill),f=Yn(Q=>Q.deleteSkill),g=Yn(Q=>Q.restoreDefault),m=Yn(Q=>Q.restoreAllDefaults),[x,S]=P.useState("list"),[k,C]=P.useState(null),[b,y]=P.useState(null),[v,_]=P.useState(""),[j,A]=P.useState(""),[N,L]=P.useState(""),[T,B]=P.useState("1.0.0"),[H,q]=P.useState(""),[Y,V]=P.useState(""),[F,I]=P.useState(!1),[$,X]=P.useState(null),[J,R]=P.useState(!1);P.useEffect(()=>{e&&(c(),S("list"),C(null),y(null),X(null),R(!1))},[e,c]);const D=()=>{C(null),_(""),A(""),L(""),B("1.0.0"),q(""),V(""),S("edit")},O=async Q=>{const Z=await p(Q);Z&&(C(Q),_(Z.metadata.name),A(Z.metadata.id),L(Z.metadata.description),B(Z.metadata.version),q(Z.prompt),V(""),S("edit"))},W=async Q=>{await f(Q),y(null)},U=async()=>{const Q=k??j;if(!Q||!v||!H){V("Name and prompt are required.");return}I(!0),V("");const Z={metadata:{id:Q,name:v,description:N,version:T||"1.0.0"},prompt:H},z=k?await h(k,Z):await l(Z);if(I(!1),!z.success){V(z.error??"Failed to save skill.");return}S("list")},K=()=>{S("list")},te=Q=>{_(Q),k||A(xS(Q))};return x==="edit"?o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[o.jsx("button",{onClick:K,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Back to list",children:o.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),o.jsx("span",{className:"text-sm font-medium text-text-primary",children:k?"Edit Skill":"New Skill"})]}),Y&&o.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded",children:Y}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Name"}),o.jsx("input",{value:v,onChange:Q=>te(Q.target.value),placeholder:"My Skill",className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary"})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["ID ",k&&o.jsx("span",{className:"text-text-muted",children:"(read-only)"})]}),o.jsx("input",{value:j,onChange:Q=>!k&&A(Q.target.value),readOnly:!!k,placeholder:"my-skill",className:`w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary ${k?"opacity-60":""}`})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Description"}),o.jsx("input",{value:N,onChange:Q=>L(Q.target.value),placeholder:"Short description of what this skill provides",className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Version"}),o.jsx("input",{value:T,onChange:Q=>B(Q.target.value),placeholder:"1.0.0",className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary"})]})]})]}),o.jsxs("div",{className:"flex-1 min-h-[150px] mt-3 overflow-hidden",children:[o.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Prompt"}),o.jsx("textarea",{value:H,onChange:Q=>q(Q.target.value),placeholder:"Instructions the agent receives when this skill is loaded...",className:"w-full h-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-accent-primary"})]}),o.jsxs("div",{className:"flex justify-end gap-2 pt-2 mt-5 border-t border-border flex-shrink-0",children:[o.jsx(dt,{variant:"secondary",onClick:K,children:"Cancel"}),o.jsx(dt,{variant:"primary",onClick:U,disabled:F||!v||!H,children:F?"Saving...":"Save"})]})]}):o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsx("p",{className:"text-text-secondary text-sm",children:"Skills provide domain-specific knowledge that agents can load on demand."}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:[i.length>0&&(J?o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:async()=>{await m(),R(!1)},className:"px-1.5 py-0.5 rounded bg-amber-500/20 text-amber-400 text-xs hover:bg-amber-500/30 transition-colors",children:"Confirm"}),o.jsx("button",{onClick:()=>R(!1),className:"px-1.5 py-0.5 rounded text-text-muted text-xs hover:bg-bg-primary transition-colors",children:"Cancel"})]}):o.jsx("button",{onClick:()=>R(!0),className:"px-2 py-1 rounded text-xs text-text-muted hover:text-amber-400 hover:bg-amber-500/10 transition-colors",title:"Restore all skills to defaults",children:"Restore Defaults"})),o.jsx(dt,{variant:"primary",size:"sm",onClick:D,children:"+ New"})]})]}),s&&r.length===0?o.jsx("div",{className:"text-text-muted text-sm",children:"Loading skills..."}):r.length===0?o.jsx("div",{className:"text-text-muted text-sm",children:"No skills installed."}):o.jsx("div",{className:"space-y-2",children:r.map(Q=>o.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[o.jsxs("div",{className:"min-w-0 flex-1 mr-3",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-text-primary text-sm font-medium",children:Q.name}),o.jsxs("span",{className:"text-text-muted text-xs",children:["v",Q.version]}),i.includes(Q.id)&&o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-amber-500/15 text-amber-400",children:"modified"})]}),o.jsx("p",{className:"text-text-secondary text-xs mt-0.5 truncate",children:Q.description})]}),o.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[i.includes(Q.id)&&($===Q.id?o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:async()=>{await g(Q.id),X(null)},className:"px-1.5 py-0.5 rounded bg-amber-500/20 text-amber-400 text-xs hover:bg-amber-500/30 transition-colors",children:"Restore"}),o.jsx("button",{onClick:()=>X(null),className:"px-1.5 py-0.5 rounded text-text-muted text-xs hover:bg-bg-primary transition-colors",children:"Cancel"})]}):o.jsx("button",{onClick:()=>X(Q.id),className:"p-1.5 rounded hover:bg-bg-primary text-text-muted hover:text-amber-400 transition-colors",title:"Restore default",children:o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})),o.jsx(ri,{onClick:()=>O(Q.id)}),b===Q.id?o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:()=>W(Q.id),className:"px-1.5 py-0.5 rounded bg-accent-error/20 text-accent-error text-xs hover:bg-accent-error/30 transition-colors",children:"Delete"}),o.jsx("button",{onClick:()=>y(null),className:"px-1.5 py-0.5 rounded text-text-muted text-xs hover:bg-bg-primary transition-colors",children:"Cancel"})]}):o.jsx("button",{onClick:()=>y(Q.id),className:"p-1.5 rounded hover:bg-bg-primary text-text-muted hover:text-accent-error transition-colors",title:"Delete skill",children:o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})}),o.jsx("button",{onClick:()=>u(Q.id),className:`relative w-9 h-5 rounded-full transition-colors flex-shrink-0 ml-1 ${Q.enabled?"bg-accent-primary":"bg-bg-primary"}`,title:Q.enabled?"Disable skill":"Enable skill",children:o.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white transition-transform ${Q.enabled?"translate-x-4":"translate-x-0"}`})})]})]},Q.id))})]})}function bS({isOpen:e,onClose:r}){const[i,s]=P.useState("instructions");return o.jsx(un,{isOpen:e,onClose:r,title:"Settings",size:"lg",children:o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex border-b border-border mb-4 -mt-1",children:[o.jsx(ml,{label:"Instructions",active:i==="instructions",onClick:()=>s("instructions")}),o.jsx(ml,{label:"Skills",active:i==="skills",onClick:()=>s("skills")}),o.jsx(ml,{label:"Notifications",active:i==="notifications",onClick:()=>s("notifications")}),o.jsx(ml,{label:"Advanced",active:i==="advanced",onClick:()=>s("advanced")})]}),i==="instructions"&&o.jsx(_S,{isOpen:e}),i==="skills"&&o.jsx(vS,{isOpen:e}),i==="notifications"&&o.jsx(pS,{}),i==="advanced"&&o.jsx(yS,{onClose:r})]})})}function yS({onClose:e}){const[,r]=ar();function i(){e(),r("/onboarding")}return o.jsx("div",{className:"space-y-6",children:o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium text-text-primary mb-1",children:"Onboarding"}),o.jsx("p",{className:"text-sm text-text-muted mb-4",children:"Reset your OpenFox setup and go through the initial configuration again."}),o.jsx(dt,{variant:"secondary",onClick:i,children:"Launch Onboarding"})]})})}function ml({label:e,active:r,onClick:i}){return o.jsx("button",{onClick:i,className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${r?"border-accent-primary text-accent-primary":"border-transparent text-text-muted hover:text-text-secondary hover:border-border"}`,children:e})}function _S({isOpen:e}){const r=ti(b=>b.settings),i=ti(b=>b.loading),s=ti(b=>b.getSetting),c=ti(b=>b.setSetting),u=r[ei.GLOBAL_INSTRUCTIONS]??"",p=i[ei.GLOBAL_INSTRUCTIONS]??!1,[l,h]=P.useState(u),[f,g]=P.useState(!1),[m,x]=P.useState(!1);P.useEffect(()=>{e&&s(ei.GLOBAL_INSTRUCTIONS)},[e,s]),P.useEffect(()=>{h(u),g(!1)},[u]);const S=async()=>{x(!0),c(ei.GLOBAL_INSTRUCTIONS,l),x(!1),g(!1)},k=()=>{h(u),g(!1)},C=p||m;return o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-text-primary mb-2",children:"Global Instructions"}),o.jsx("p",{className:"text-sm text-text-muted mb-2",children:"These instructions are injected into every prompt, regardless of project."}),o.jsx("textarea",{value:l,onChange:b=>{h(b.target.value),g(!0)},placeholder:"Enter global instructions that apply to all projects...",className:"w-full h-64 px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:C})]}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(dt,{variant:"secondary",onClick:k,disabled:!f,children:"Discard"}),o.jsx(dt,{variant:"primary",onClick:S,disabled:!f||C,children:m?"Saving...":"Save"})]})]})}var _d={exports:{}},wx;function SS(){return wx||(wx=1,(function(e,r){(function(i,s){e.exports=s()})(globalThis,(()=>(()=>{var i={4567:function(p,l,h){var f=this&&this.__decorate||function(v,_,j,A){var N,L=arguments.length,T=L<3?_:A===null?A=Object.getOwnPropertyDescriptor(_,j):A;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(v,_,j,A);else for(var B=v.length-1;B>=0;B--)(N=v[B])&&(T=(L<3?N(T):L>3?N(_,j,T):N(_,j))||T);return L>3&&T&&Object.defineProperty(_,j,T),T},g=this&&this.__param||function(v,_){return function(j,A){_(j,A,v)}};Object.defineProperty(l,"__esModule",{value:!0}),l.AccessibilityManager=void 0;const m=h(9042),x=h(9924),S=h(844),k=h(4725),C=h(2585),b=h(3656);let y=l.AccessibilityManager=class extends S.Disposable{constructor(v,_,j,A){super(),this._terminal=v,this._coreBrowserService=j,this._renderService=A,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 N=0;N<this._terminal.rows;N++)this._rowElements[N]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[N]);if(this._topBoundaryFocusListener=N=>this._handleBoundaryFocus(N,0),this._bottomBoundaryFocusListener=N=>this._handleBoundaryFocus(N,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 x.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((N=>this._handleResize(N.rows)))),this.register(this._terminal.onRender((N=>this._refreshRows(N.start,N.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((N=>this._handleChar(N)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
58
58
  `)))),this.register(this._terminal.onA11yTab((N=>this._handleTab(N)))),this.register(this._terminal.onKey((N=>this._handleKey(N.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,S.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(v){for(let _=0;_<v;_++)this._handleChar(" ")}_handleChar(v){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==v&&(this._charsToAnnounce+=v):this._charsToAnnounce+=v,v===`
59
59
  `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=m.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(v){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(v)||this._charsToConsume.push(v)}_refreshRows(v,_){this._liveRegionDebouncer.refresh(v,_,this._terminal.rows)}_renderRows(v,_){const j=this._terminal.buffer,A=j.lines.length.toString();for(let N=v;N<=_;N++){const L=j.lines.get(j.ydisp+N),T=[],B=(L==null?void 0:L.translateToString(!0,void 0,void 0,T))||"",H=(j.ydisp+N+1).toString(),q=this._rowElements[N];q&&(B.length===0?(q.innerText=" ",this._rowColumns.set(q,[0,1])):(q.textContent=B,this._rowColumns.set(q,T)),q.setAttribute("aria-posinset",H),q.setAttribute("aria-setsize",A))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(v,_){const j=v.target,A=this._rowElements[_===0?1:this._rowElements.length-2];if(j.getAttribute("aria-posinset")===(_===0?"1":`${this._terminal.buffer.lines.length}`)||v.relatedTarget!==A)return;let N,L;if(_===0?(N=j,L=this._rowElements.pop(),this._rowContainer.removeChild(L)):(N=this._rowElements.shift(),L=j,this._rowContainer.removeChild(N)),N.removeEventListener("focus",this._topBoundaryFocusListener),L.removeEventListener("focus",this._bottomBoundaryFocusListener),_===0){const T=this._createAccessibilityTreeNode();this._rowElements.unshift(T),this._rowContainer.insertAdjacentElement("afterbegin",T)}else{const T=this._createAccessibilityTreeNode();this._rowElements.push(T),this._rowContainer.appendChild(T)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(_===0?-1:1),this._rowElements[_===0?1:this._rowElements.length-2].focus(),v.preventDefault(),v.stopImmediatePropagation()}_handleSelectionChange(){var B;if(this._rowElements.length===0)return;const v=document.getSelection();if(!v)return;if(v.isCollapsed)return void(this._rowContainer.contains(v.anchorNode)&&this._terminal.clearSelection());if(!v.anchorNode||!v.focusNode)return void console.error("anchorNode and/or focusNode are null");let _={node:v.anchorNode,offset:v.anchorOffset},j={node:v.focusNode,offset:v.focusOffset};if((_.node.compareDocumentPosition(j.node)&Node.DOCUMENT_POSITION_PRECEDING||_.node===j.node&&_.offset>j.offset)&&([_,j]=[j,_]),_.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(_={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(_.node))return;const A=this._rowElements.slice(-1)[0];if(j.node.compareDocumentPosition(A)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(j={node:A,offset:((B=A.textContent)==null?void 0:B.length)??0}),!this._rowContainer.contains(j.node))return;const N=({node:H,offset:q})=>{const Y=H instanceof Text?H.parentNode:H;let V=parseInt(Y==null?void 0:Y.getAttribute("aria-posinset"),10)-1;if(isNaN(V))return console.warn("row is invalid. Race condition?"),null;const F=this._rowColumns.get(Y);if(!F)return console.warn("columns is null. Race condition?"),null;let I=q<F.length?F[q]:F.slice(-1)[0]+1;return I>=this._terminal.cols&&(++V,I=0),{row:V,column:I}},L=N(_),T=N(j);if(L&&T){if(L.row>T.row||L.row===T.row&&L.column>=T.column)throw new Error("invalid range");this._terminal.select(L.column,L.row,(T.row-L.row)*this._terminal.cols-L.column+T.column)}}_handleResize(v){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let _=this._rowContainer.children.length;_<this._terminal.rows;_++)this._rowElements[_]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[_]);for(;this._rowElements.length>v;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const v=this._coreBrowserService.mainDocument.createElement("div");return v.setAttribute("role","listitem"),v.tabIndex=-1,this._refreshRowDimensions(v),v}_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 v=0;v<this._terminal.rows;v++)this._refreshRowDimensions(this._rowElements[v])}}_refreshRowDimensions(v){v.style.height=`${this._renderService.dimensions.css.cell.height}px`}};l.AccessibilityManager=y=f([g(1,C.IInstantiationService),g(2,k.ICoreBrowserService),g(3,k.IRenderService)],y)},3614:(p,l)=>{function h(x){return x.replace(/\r?\n/g,"\r")}function f(x,S){return S?"\x1B[200~"+x+"\x1B[201~":x}function g(x,S,k,C){x=f(x=h(x),k.decPrivateModes.bracketedPasteMode&&C.rawOptions.ignoreBracketedPasteMode!==!0),k.triggerDataEvent(x,!0),S.value=""}function m(x,S,k){const C=k.getBoundingClientRect(),b=x.clientX-C.left-10,y=x.clientY-C.top-10;S.style.width="20px",S.style.height="20px",S.style.left=`${b}px`,S.style.top=`${y}px`,S.style.zIndex="1000",S.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=h,l.bracketTextForPaste=f,l.copyHandler=function(x,S){x.clipboardData&&x.clipboardData.setData("text/plain",S.selectionText),x.preventDefault()},l.handlePasteEvent=function(x,S,k,C){x.stopPropagation(),x.clipboardData&&g(x.clipboardData.getData("text/plain"),S,k,C)},l.paste=g,l.moveTextAreaUnderMouseCursor=m,l.rightClickHandler=function(x,S,k,C,b){m(x,S,k),b&&C.rightClickSelect(x),S.value=C.selectionText,S.select()}},7239:(p,l,h)=>{Object.defineProperty(l,"__esModule",{value:!0}),l.ColorContrastCache=void 0;const f=h(1505);l.ColorContrastCache=class{constructor(){this._color=new f.TwoKeyMap,this._css=new f.TwoKeyMap}setCss(g,m,x){this._css.set(g,m,x)}getCss(g,m){return this._css.get(g,m)}setColor(g,m,x){this._color.set(g,m,x)}getColor(g,m){return this._color.get(g,m)}clear(){this._color.clear(),this._css.clear()}}},3656:(p,l)=>{Object.defineProperty(l,"__esModule",{value:!0}),l.addDisposableDomListener=void 0,l.addDisposableDomListener=function(h,f,g,m){h.addEventListener(f,g,m);let x=!1;return{dispose:()=>{x||(x=!0,h.removeEventListener(f,g,m))}}}},3551:function(p,l,h){var f=this&&this.__decorate||function(y,v,_,j){var A,N=arguments.length,L=N<3?v:j===null?j=Object.getOwnPropertyDescriptor(v,_):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(y,v,_,j);else for(var T=y.length-1;T>=0;T--)(A=y[T])&&(L=(N<3?A(L):N>3?A(v,_,L):A(v,_))||L);return N>3&&L&&Object.defineProperty(v,_,L),L},g=this&&this.__param||function(y,v){return function(_,j){v(_,j,y)}};Object.defineProperty(l,"__esModule",{value:!0}),l.Linkifier=void 0;const m=h(3656),x=h(8460),S=h(844),k=h(2585),C=h(4725);let b=l.Linkifier=class extends S.Disposable{get currentLink(){return this._currentLink}constructor(y,v,_,j,A){super(),this._element=y,this._mouseService=v,this._renderService=_,this._bufferService=j,this._linkProviderService=A,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new x.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new x.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,S.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,S.toDisposable)((()=>{var N;this._lastMouseEvent=void 0,(N=this._activeProviderReplies)==null||N.clear()}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0}))),this.register((0,m.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,m.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,m.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,m.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(y){this._lastMouseEvent=y;const v=this._positionFromMouseEvent(y,this._element,this._mouseService);if(!v)return;this._isMouseOut=!1;const _=y.composedPath();for(let j=0;j<_.length;j++){const A=_[j];if(A.classList.contains("xterm"))break;if(A.classList.contains("xterm-hover"))return}this._lastBufferCell&&v.x===this._lastBufferCell.x&&v.y===this._lastBufferCell.y||(this._handleHover(v),this._lastBufferCell=v)}_handleHover(y){if(this._activeLine!==y.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(y,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,y)||(this._clearCurrentLink(),this._askForLink(y,!0))}_askForLink(y,v){var j,A;this._activeProviderReplies&&v||((j=this._activeProviderReplies)==null||j.forEach((N=>{N==null||N.forEach((L=>{L.link.dispose&&L.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=y.y);let _=!1;for(const[N,L]of this._linkProviderService.linkProviders.entries())v?(A=this._activeProviderReplies)!=null&&A.get(N)&&(_=this._checkLinkProviderResult(N,y,_)):L.provideLinks(y.y,(T=>{var H,q;if(this._isMouseOut)return;const B=T==null?void 0:T.map((Y=>({link:Y})));(H=this._activeProviderReplies)==null||H.set(N,B),_=this._checkLinkProviderResult(N,y,_),((q=this._activeProviderReplies)==null?void 0:q.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(y.y,this._activeProviderReplies)}))}_removeIntersectingLinks(y,v){const _=new Set;for(let j=0;j<v.size;j++){const A=v.get(j);if(A)for(let N=0;N<A.length;N++){const L=A[N],T=L.link.range.start.y<y?0:L.link.range.start.x,B=L.link.range.end.y>y?this._bufferService.cols:L.link.range.end.x;for(let H=T;H<=B;H++){if(_.has(H)){A.splice(N--,1);break}_.add(H)}}}}_checkLinkProviderResult(y,v,_){var N;if(!this._activeProviderReplies)return _;const j=this._activeProviderReplies.get(y);let A=!1;for(let L=0;L<y;L++)this._activeProviderReplies.has(L)&&!this._activeProviderReplies.get(L)||(A=!0);if(!A&&j){const L=j.find((T=>this._linkAtPosition(T.link,v)));L&&(_=!0,this._handleNewLink(L))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!_)for(let L=0;L<this._activeProviderReplies.size;L++){const T=(N=this._activeProviderReplies.get(L))==null?void 0:N.find((B=>this._linkAtPosition(B.link,v)));if(T){_=!0,this._handleNewLink(T);break}}return _}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(y){if(!this._currentLink)return;const v=this._positionFromMouseEvent(y,this._element,this._mouseService);v&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,v)&&this._currentLink.link.activate(y,this._currentLink.link.text)}_clearCurrentLink(y,v){this._currentLink&&this._lastMouseEvent&&(!y||!v||this._currentLink.link.range.start.y>=y&&this._currentLink.link.range.end.y<=v)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,S.disposeArray)(this._linkCacheDisposables))}_handleNewLink(y){if(!this._lastMouseEvent)return;const v=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);v&&this._linkAtPosition(y.link,v)&&(this._currentLink=y,this._currentLink.state={decorations:{underline:y.link.decorations===void 0||y.link.decorations.underline,pointerCursor:y.link.decorations===void 0||y.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,y.link,this._lastMouseEvent),y.link.decorations={},Object.defineProperties(y.link.decorations,{pointerCursor:{get:()=>{var _,j;return(j=(_=this._currentLink)==null?void 0:_.state)==null?void 0:j.decorations.pointerCursor},set:_=>{var j;(j=this._currentLink)!=null&&j.state&&this._currentLink.state.decorations.pointerCursor!==_&&(this._currentLink.state.decorations.pointerCursor=_,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",_))}},underline:{get:()=>{var _,j;return(j=(_=this._currentLink)==null?void 0:_.state)==null?void 0:j.decorations.underline},set:_=>{var j,A,N;(j=this._currentLink)!=null&&j.state&&((N=(A=this._currentLink)==null?void 0:A.state)==null?void 0:N.decorations.underline)!==_&&(this._currentLink.state.decorations.underline=_,this._currentLink.state.isHovered&&this._fireUnderlineEvent(y.link,_))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((_=>{if(!this._currentLink)return;const j=_.start===0?0:_.start+1+this._bufferService.buffer.ydisp,A=this._bufferService.buffer.ydisp+1+_.end;if(this._currentLink.link.range.start.y>=j&&this._currentLink.link.range.end.y<=A&&(this._clearCurrentLink(j,A),this._lastMouseEvent)){const N=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);N&&this._askForLink(N,!1)}}))))}_linkHover(y,v,_){var j;(j=this._currentLink)!=null&&j.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(v,!0),this._currentLink.state.decorations.pointerCursor&&y.classList.add("xterm-cursor-pointer")),v.hover&&v.hover(_,v.text)}_fireUnderlineEvent(y,v){const _=y.range,j=this._bufferService.buffer.ydisp,A=this._createLinkUnderlineEvent(_.start.x-1,_.start.y-j-1,_.end.x,_.end.y-j-1,void 0);(v?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(A)}_linkLeave(y,v,_){var j;(j=this._currentLink)!=null&&j.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(v,!1),this._currentLink.state.decorations.pointerCursor&&y.classList.remove("xterm-cursor-pointer")),v.leave&&v.leave(_,v.text)}_linkAtPosition(y,v){const _=y.range.start.y*this._bufferService.cols+y.range.start.x,j=y.range.end.y*this._bufferService.cols+y.range.end.x,A=v.y*this._bufferService.cols+v.x;return _<=A&&A<=j}_positionFromMouseEvent(y,v,_){const j=_.getCoords(y,v,this._bufferService.cols,this._bufferService.rows);if(j)return{x:j[0],y:j[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(y,v,_,j,A){return{x1:y,y1:v,x2:_,y2:j,cols:this._bufferService.cols,fg:A}}};l.Linkifier=b=f([g(1,C.IMouseService),g(2,C.IRenderService),g(3,k.IBufferService),g(4,C.ILinkProviderService)],b)},9042:(p,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(p,l,h){var f=this&&this.__decorate||function(C,b,y,v){var _,j=arguments.length,A=j<3?b:v===null?v=Object.getOwnPropertyDescriptor(b,y):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(C,b,y,v);else for(var N=C.length-1;N>=0;N--)(_=C[N])&&(A=(j<3?_(A):j>3?_(b,y,A):_(b,y))||A);return j>3&&A&&Object.defineProperty(b,y,A),A},g=this&&this.__param||function(C,b){return function(y,v){b(y,v,C)}};Object.defineProperty(l,"__esModule",{value:!0}),l.OscLinkProvider=void 0;const m=h(511),x=h(2585);let S=l.OscLinkProvider=class{constructor(C,b,y){this._bufferService=C,this._optionsService=b,this._oscLinkService=y}provideLinks(C,b){var B;const y=this._bufferService.buffer.lines.get(C-1);if(!y)return void b(void 0);const v=[],_=this._optionsService.rawOptions.linkHandler,j=new m.CellData,A=y.getTrimmedLength();let N=-1,L=-1,T=!1;for(let H=0;H<A;H++)if(L!==-1||y.hasContent(H)){if(y.loadCell(H,j),j.hasExtendedAttrs()&&j.extended.urlId){if(L===-1){L=H,N=j.extended.urlId;continue}T=j.extended.urlId!==N}else L!==-1&&(T=!0);if(T||L!==-1&&H===A-1){const q=(B=this._oscLinkService.getLinkData(N))==null?void 0:B.uri;if(q){const Y={start:{x:L+1,y:C},end:{x:H+(T||H!==A-1?0:1),y:C}};let V=!1;if(!(_!=null&&_.allowNonHttpProtocols))try{const F=new URL(q);["http:","https:"].includes(F.protocol)||(V=!0)}catch{V=!0}V||v.push({text:q,range:Y,activate:(F,I)=>_?_.activate(F,I,Y):k(0,I),hover:(F,I)=>{var $;return($=_==null?void 0:_.hover)==null?void 0:$.call(_,F,I,Y)},leave:(F,I)=>{var $;return($=_==null?void 0:_.leave)==null?void 0:$.call(_,F,I,Y)}})}T=!1,j.hasExtendedAttrs()&&j.extended.urlId?(L=H,N=j.extended.urlId):(L=-1,N=-1)}}b(v)}};function k(C,b){if(confirm(`Do you want to navigate to ${b}?
60
60
 
@@ -73,7 +73,7 @@ WARNING: This link could potentially be dangerous`)){const y=window.open();if(y)
73
73
  * Fabrice Bellard's javascript vt100 for jslinux:
74
74
  * http://bellard.org/jslinux/
75
75
  * Copyright (c) 2011 Fabrice Bellard
76
- */var CS=2,kS=1,ES=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let r=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(r._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var m;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let r=this._terminal.options.scrollback===0?0:((m=this._terminal.options.overviewRuler)==null?void 0:m.width)||14,i=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(i.getPropertyValue("height")),c=Math.max(0,parseInt(i.getPropertyValue("width"))),u=window.getComputedStyle(this._terminal.element),p={top:parseInt(u.getPropertyValue("padding-top")),bottom:parseInt(u.getPropertyValue("padding-bottom")),right:parseInt(u.getPropertyValue("padding-right")),left:parseInt(u.getPropertyValue("padding-left"))},l=p.top+p.bottom,h=p.right+p.left,f=s-l,g=c-h-r;return{cols:Math.max(CS,Math.floor(g/e.css.cell.width)),rows:Math.max(kS,Math.floor(f/e.css.cell.height))}}};function jS({sessionId:e,onClose:r,onEscape:i,autoFocus:s}){const c=P.useRef(null),u=P.useRef(e),p=P.useRef(null),l=P.useRef(null),h=sr(g=>g.writeSession),f=sr(g=>g.resizeSession);return P.useEffect(()=>{u.current=e},[e]),P.useEffect(()=>{if(!i)return;const g=m=>{(m.key==="²"||m.key==="`")&&(m.preventDefault(),m.stopPropagation(),i())};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[i]),P.useEffect(()=>{if(!c.current)return;const g=new wS.Terminal({fontFamily:'"JetBrains Mono", monospace',fontSize:13,theme:{background:"#1a1a1a",foreground:"#e0e0e0",cursor:"#ffffff",cursorAccent:"#1a1a1a"},cursorBlink:!0,cursorStyle:"bar",convertEol:!0}),m=new ES;g.loadAddon(m),p.current={term:g,fitAddon:m},c.current.addEventListener("keydown",C=>{(C.key==="²"||C.key==="`")&&i&&(C.preventDefault(),C.stopPropagation(),i())}),g.open(c.current);const x=c.current.querySelector(".xterm");x&&(x.style.padding="8px"),m.fit(),s&&setTimeout(()=>{g.focus()},150);const S=new ResizeObserver(()=>{l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{requestAnimationFrame(()=>{var b;m.fit&&m.fit();const C=(b=p.current)==null?void 0:b.term;C&&C.cols>0&&C.rows>0&&f(u.current,C.cols,C.rows)})},100)});S.observe(c.current),g.onData(C=>{if((C==="\x1B"||C==="²"||C==="`")&&i){i();return}h(u.current,C)}),g.onKey(C=>{(C.key==="\x1B"||C.key==="²"||C.key==="`")&&i&&(C.domEvent.stopPropagation(),i())});const k=zt.subscribe(C=>{var b,y;if(C.type==="terminal.output"&&((b=C.payload)==null?void 0:b.sessionId)===u.current){const v=(y=C.payload)==null?void 0:y.data;v&&g.write(v)}});return()=>{k(),S.disconnect(),l.current&&clearTimeout(l.current),g.dispose(),p.current=null}},[e,h,f]),o.jsxs("div",{className:"flex flex-col h-full bg-[#1a1a1a]",children:[o.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-2 py-1 bg-[#252525] border-b border-[#333]",children:[o.jsx("div",{}),o.jsx("button",{onClick:r,className:"p-1 rounded hover:bg-[#333] text-[#888] hover:text-[#ccc] transition-colors",title:"Close terminal",children:o.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("path",{d:"M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.55.5 0 0 1 0-.708z"})})})]}),o.jsx("div",{ref:c,className:"flex-1 relative overflow-hidden",tabIndex:0,onKeyDown:g=>{(g.key==="²"||g.key==="`")&&i&&(g.preventDefault(),g.stopPropagation(),i())}})]})}function NS(e){return e===1?"grid-cols-1":e===2?"grid-cols-1 lg:grid-cols-2":"grid-cols-1 lg:grid-cols-2 xl:grid-cols-3"}function TS({isOpen:e,onClose:r,onFocusChat:i}){const s=sr(C=>C.createSession),c=sr(C=>C.killSession),u=sr(C=>C.sessions),p=sr(C=>C.setWorkdir),l=sr(C=>C.fetchSessions),h=Ut(C=>C.currentProject),[f,g]=P.useState(!0),m=P.useRef(null),x=P.useRef(!1),S=P.useRef(!1),k=P.useCallback(()=>{r(),i()},[r,i]);return P.useEffect(()=>{h!=null&&h.workdir&&p(h.workdir)},[h==null?void 0:h.workdir,p]),P.useEffect(()=>{e&&(g(!0),l().finally(()=>g(!1)))},[e,l]),P.useEffect(()=>{e&&u.length===0&&!f&&!S.current&&(S.current=!0,s())},[e,u.length,f,s]),P.useEffect(()=>{e?(x.current=!0,setTimeout(()=>{var C;(C=m.current)==null||C.focus(),setTimeout(()=>{x.current=!1},200)},100)):S.current=!1},[e]),P.useEffect(()=>{if(!e)return;const C=b=>{x.current||(b.key==="Escape"||b.key==="²"||b.key==="`")&&(b.preventDefault(),r(),i())};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[e,r,i]),e?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"fixed inset-x-0 top-[50vh] bottom-0 z-[100] bg-black/40",style:{pointerEvents:"auto"},onClick:k}),o.jsxs("div",{ref:m,tabIndex:-1,className:"fixed inset-x-0 top-0 z-[100] h-[50vh] bg-bg-primary border-b border-border flex flex-col animate-slide-down outline-none",onClick:C=>C.stopPropagation(),onKeyDown:C=>{(C.key==="Escape"||C.key==="²"||C.key==="`")&&(C.preventDefault(),k())},children:[o.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border",children:[o.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Terminal"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{onClick:()=>s(),className:"p-2 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"New terminal",children:o.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z",clipRule:"evenodd"})})}),o.jsx("button",{onClick:()=>{r(),i()},className:"p-2 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Close (Esc)",children:o.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]})]}),o.jsx("div",{className:"flex-1 min-h-0 p-2 overflow-auto",children:f?o.jsx("div",{className:"flex items-center justify-center h-full text-text-muted",children:"Loading..."}):u.length===0?o.jsx("div",{className:"flex items-center justify-center h-full text-text-muted",children:o.jsxs("div",{className:"text-center",children:[o.jsx("p",{className:"mb-4",children:"No terminal sessions"}),o.jsx("button",{onClick:()=>s(),className:"px-4 py-2 bg-accent-primary/25 text-white rounded hover:bg-accent-primary/40 transition-colors",children:"Create Terminal"})]})}):o.jsx("div",{className:`grid ${NS(u.length)} gap-2 h-full auto-rows-fr`,children:u.map(C=>o.jsx(jS,{sessionId:C.id,onClose:()=>c(C.id),onEscape:k,autoFocus:u.length===1},C.id))})})]})]}):null}function Ya({items:e,trigger:r,minWidth:i="120px"}){const[s,c]=P.useState(!1),[u,p]=P.useState(null),l=P.useRef(null),h=P.useRef(null);P.useEffect(()=>{function x(S){h.current&&!h.current.contains(S.target)&&c(!1)}return s&&document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}},[s]);const f=P.useCallback(()=>{if(!l.current)return;const x=l.current.getBoundingClientRect(),S=200,C=window.innerHeight-x.bottom<S;p({top:C?x.top-S-4:x.bottom+4,left:x.left,alignToTop:C})},[]),g=x=>{x.stopPropagation(),s||f(),c(!s)},m=u&&o.jsx("div",{ref:h,"data-testid":"session-dropdown-menu",className:`fixed bg-bg-secondary border border-border rounded shadow-lg z-50 ${u.alignToTop?"mb-1":"mt-1"}`,style:{top:u.top,left:u.left,minWidth:i},children:e.map((x,S)=>{const k=o.jsxs(o.Fragment,{children:[x.icon&&o.jsx("span",{className:"w-4 h-4 flex-shrink-0",children:x.icon}),x.label]});return x.href?o.jsx("a",{href:x.href,onClick:C=>{var b;(b=x.onClick)==null||b.call(x,C),c(!1)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bg-tertiary transition-colors flex items-center gap-2 ${x.danger?"text-accent-error hover:bg-accent-error/10":"text-text-primary"} ${S!==e.length-1?"border-b border-border":""}`,children:k},S):o.jsx("button",{onClick:C=>{var b;(b=x.onClick)==null||b.call(x,C),x.closeOnClick!==!1&&c(!1)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bg-tertiary transition-colors flex items-center gap-2 ${x.danger?"text-accent-error hover:bg-accent-error/10":"text-text-primary"} ${S!==e.length-1?"border-b border-border":""}`,children:k},S)})});return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"relative",children:o.jsx("div",{ref:l,onClick:g,children:r})}),s&&ph.createPortal(m,document.body)]})}function ub(e){const r=new Date(e),s=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][r.getDay()],c=r.getFullYear(),u=String(r.getMonth()+1).padStart(2,"0"),p=String(r.getDate()).padStart(2,"0");return`${s} ${c}/${u}/${p}`}function mh(e){const r=new Date(e),i=String(r.getHours()).padStart(2,"0"),s=String(r.getMinutes()).padStart(2,"0");return`${i}:${s}`}function AS(e){const r=new Date(e),i=new Date,s=new Date(i.getFullYear(),i.getMonth(),i.getDate()),c=new Date(r.getFullYear(),r.getMonth(),r.getDate()),u=Math.floor((s.getTime()-c.getTime())/(1e3*60*60*24)),p=mh(e);if(u===0)return`today ${p}`;if(u===1)return`yesterday ${p}`;if(u<7)return`${u} days ago ${p}`;{const l=r.getFullYear(),h=String(r.getMonth()+1).padStart(2,"0"),f=String(r.getDate()).padStart(2,"0");return`${l}/${h}/${f} ${p}`}}function DS(e){const r=new Date(e),i=r.getFullYear(),s=String(r.getMonth()+1).padStart(2,"0"),c=String(r.getDate()).padStart(2,"0");return`${i}-${s}-${c}`}function db(e){const r=new Map;for(const c of e){const u=DS(c.updatedAt);r.has(u)||r.set(u,[]),r.get(u).push(c)}for(const[c,u]of r)u.sort((p,l)=>{const h=new Date(p.updatedAt).getTime();return new Date(l.updatedAt).getTime()-h});const i=Array.from(r.keys()).sort((c,u)=>u.localeCompare(c)),s=new Map;for(const c of i)s.set(c,r.get(c));return s}function LS({projects:e,currentProject:r}){const i=Ut(u=>u.loadProject),c=[...e].sort((u,p)=>u.name.localeCompare(p.name)).map(u=>({label:u.name,icon:u.id===r.id?o.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):void 0,href:`/p/${u.id}`,onClick:()=>{i(u.id)}}));return o.jsx(Ya,{items:c,trigger:o.jsxs("button",{className:"text-text-secondary hover:text-text-primary hover:underline text-sm truncate flex items-center gap-1",title:r.name,children:[r.name,o.jsx("svg",{className:"w-3 h-3 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),minWidth:"250px"})}function RS({currentProject:e,sessions:r,currentSession:i,projectIdFromUrl:s}){const[c,u]=P.useState(!1),p=P.useRef(null);if(P.useEffect(()=>{function f(g){p.current&&!p.current.contains(g.target)&&u(!1)}if(c)return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[c]),!(e!=null&&e.id)||e.id!==s)return null;const l=r.filter(f=>f.projectId===e.id).sort((f,g)=>new Date(g.updatedAt).getTime()-new Date(f.updatedAt).getTime()).slice(0,5),h=[];h.push({label:o.jsxs(An,{href:`/p/${e.id}/new`,className:"flex items-center gap-2",children:[o.jsx("svg",{className:"w-3 h-3 text-accent-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),o.jsx("span",{className:"text-sm",children:"New Session"})]}),onClick:()=>{}});for(const f of l)h.push({label:o.jsx(An,{href:`/p/${e.id}/s/${f.id}`,className:"flex items-center gap-2 truncate text-sm",children:o.jsx("span",{children:f.title??f.id.slice(0,8)})}),icon:f.id===(i==null?void 0:i.id)?o.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):void 0,onClick:()=>{}});return h.push({label:o.jsxs(An,{href:"/",className:"flex items-center gap-2 text-text-muted hover:text-text-primary",children:[o.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})}),o.jsx("span",{className:"text-sm",children:"Projects"})]}),onClick:()=>{}}),o.jsxs("div",{className:"relative",ref:p,children:[o.jsxs("button",{type:"button",onClick:()=>u(!c),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors",children:[o.jsx("span",{className:"text-sm text-text-secondary font-medium",children:e==null?void 0:e.name}),o.jsx("svg",{className:"w-3 h-3 text-text-muted flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),c&&h.length>0&&o.jsx("div",{className:"absolute top-full left-0 mt-1 w-56 bg-bg-secondary border border-border rounded-lg shadow-lg overflow-hidden z-50",children:h.map((f,g)=>{if(f.label&&typeof f.label=="object"&&f.label.type===An){const m=f.label,x=m.props.href||"";return o.jsxs(An,{href:x,className:"flex items-center gap-2 px-3 py-2 text-sm border-b border-border hover:bg-bg-tertiary transition-colors",children:[f.icon,m.props.children]},g)}return f.href?o.jsxs("a",{href:f.href,className:"flex items-center gap-2 px-3 py-2 text-sm border-b border-border hover:bg-bg-tertiary transition-colors",children:[f.icon,f.label]},g):o.jsxs("button",{type:"button",onClick:()=>{var m;(m=f.onClick)==null||m.call(f),u(!1)},className:"flex items-center gap-2 px-3 py-2 text-sm w-full text-left border-b border-border hover:bg-bg-tertiary transition-colors",children:[f.icon,f.label]},g)})})]})}function MS({sessions:e,currentProject:r,currentSession:i}){var h;const s=Ee(f=>f.loadSession),c=e.filter(f=>f.projectId===r.id).slice(0,15),u=db(c),p=[];p.push({label:o.jsxs(An,{href:`/p/${r.id}/new`,className:"flex items-center gap-2 px-3 py-2 min-w-[160px]","data-testid":"session-dropdown-new-session",children:[o.jsx("svg",{className:"w-4 h-4 text-accent-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),o.jsx("span",{className:"text-sm",children:"New session"})]}),onClick:()=>{}});for(const[f,g]of u){const m=g[0];if(m){p.push({label:o.jsx("div",{className:"px-3 py-2 text-text-muted text-xs font-medium cursor-default",children:ub(m.updatedAt)}),onClick:()=>{}});for(const x of g)p.push({label:o.jsxs("div",{className:"min-w-[160px]",children:[o.jsx("div",{className:"truncate text-sm",children:x.title??x.id.slice(0,8)}),o.jsx("div",{className:"text-text-muted text-xs",children:mh(x.updatedAt)})]}),icon:x.id===(i==null?void 0:i.id)?o.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):void 0,href:`/p/${r.id}/s/${x.id}`,onClick:()=>{s(x.id)}})}}const l=i?((h=i.metadata)==null?void 0:h.title)??i.id.slice(0,8):"No session selected";return o.jsx(Ya,{items:p,trigger:o.jsxs("button",{className:"text-text-secondary hover:text-text-primary hover:underline text-sm truncate flex items-center gap-1",title:l,"data-testid":"header-session-dropdown",children:[l,o.jsx("svg",{className:"w-3 h-3 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),minWidth:"280px"})}function OS({onMenuClick:e,onCriteriaToggle:r}){const[i,s]=P.useState(!1),[c]=ar(),u=c.startsWith("/p/"),p=/^\/p\/[^/]+\/s\/[^/]+$/.test(c),l=Ee(b=>b.currentSession),h=Ee(b=>b.sessions),f=Ut(b=>b.currentProject),g=Ut(b=>b.projects),m=Pt(b=>b.startAutoRefresh),x=Pt(b=>b.stopAutoRefresh),S=sr(b=>b.setOpen),k=sr(b=>b.isOpen),C=P.useCallback(()=>{const b=document.querySelector('textarea[placeholder*="What would you like to build"], textarea[placeholder*="Send a message"]');b&&b.focus()},[]);return P.useEffect(()=>{const b=y=>{(y.key==="²"||y.key==="`")&&(y.preventDefault(),k||S(!0))};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[k,S]),P.useEffect(()=>(m(),()=>x()),[m,x]),o.jsxs("header",{className:"h-8 bg-bg-secondary border-b border-border flex items-center justify-between px-2",children:[o.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e&&u&&o.jsx("button",{onClick:e,className:"flex-shrink-0 p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Toggle session list",children:o.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),o.jsx(An,{href:"/",className:"text-accent-primary font-semibold text-base hover:underline flex-shrink-0 hidden md:inline",children:"OpenFox"}),f&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"hidden md:inline text-text-muted flex-shrink-0",children:"/"}),o.jsx("span",{className:"hidden md:inline",children:o.jsx(LS,{projects:g,currentProject:f})}),o.jsx("span",{className:"md:hidden",children:o.jsx(RS,{currentProject:f,sessions:h,currentSession:l,projectIdFromUrl:u&&c.split("/")[2]||null},f==null?void 0:f.id)}),o.jsx("span",{className:"hidden md:inline text-text-muted flex-shrink-0",children:"/"}),o.jsx("span",{className:"hidden md:inline",children:o.jsx(MS,{sessions:h,currentProject:f,currentSession:l})})]})]}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[u&&o.jsx("button",{onClick:()=>S(!k),className:`p-2.5 rounded hover:bg-bg-tertiary transition-colors ${k?"text-accent-primary":"text-text-muted hover:text-text-primary"}`,title:"Toggle terminal (²)",children:o.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M2 5a2 2 0 012-2h12a2 2 0 012 2v10a2 2 0 01-2 2H4a2 2 0 01-2-2V5zm3 1h10v1H5V6zm10 7H5v1h10v-1zm-10 2H5v1h10v-1z",clipRule:"evenodd"})})}),o.jsx("button",{onClick:()=>s(!0),className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Settings",children:o.jsxs("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}),o.jsx("button",{onClick:()=>{localStorage.removeItem("openfox_token"),window.location.reload()},className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Logout",children:o.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"})})}),r&&p&&o.jsx("button",{onClick:r,className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Toggle summary sidebar",children:o.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})]}),o.jsx(bS,{isOpen:i,onClose:()=>s(!1)}),o.jsx(TS,{isOpen:k,onClose:()=>S(!1),onFocusChat:C})]})}function BS({isOpen:e,onClose:r,title:i,label:s,description:c,placeholder:u,value:p,isLoading:l=!1,onSave:h}){const[f,g]=P.useState(p),[m,x]=P.useState(!1),[S,k]=P.useState(!1);P.useEffect(()=>{g(p),x(!1)},[p]);const C=_=>{g(_.target.value),x(!0)},b=async()=>{k(!0),await h(f),k(!1),x(!1),r()},y=()=>{g(p),x(!1),r()},v=l||S;return o.jsx(un,{isOpen:e,onClose:y,title:i,size:"lg",children:o.jsxs("div",{className:"flex flex-col h-full -mt-1",children:[o.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:s}),o.jsx("p",{className:"text-sm text-text-muted mb-3 flex-shrink-0",children:c}),o.jsx("div",{className:"flex-1 min-h-[150px]",children:o.jsx("textarea",{value:f,onChange:C,placeholder:u,className:"w-full h-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:v})}),o.jsxs("div",{className:"flex justify-end gap-2 pt-2 mt-3 border-t border-border flex-shrink-0",children:[o.jsx(dt,{variant:"secondary",onClick:y,children:"Cancel"}),o.jsx(dt,{variant:"primary",onClick:b,disabled:!m||v,children:S?"Saving...":"Save"})]})]})})}function IS({isOpen:e,onClose:r,project:i}){const s=Ut(u=>u.updateProject),c=async u=>{s(i.id,{customInstructions:u||null}),await new Promise(p=>setTimeout(p,100))};return o.jsx(BS,{isOpen:e,onClose:r,title:`${i.name} Settings`,label:"Project Instructions",description:"These instructions are injected into prompts when working in this project. They are applied after global instructions but before AGENTS.md files.",placeholder:"Enter project-specific instructions...",value:i.customInstructions??"",onSave:c})}function hb({projectId:e,isOpen:r=!0,onClose:i}){const[,s]=ar(),[c,u]=P.useState(!1),p=Ee(j=>j.sessions),l=Ee(j=>j.currentSession),h=Ee(j=>j.unreadSessionIds),f=Ee(j=>j.deleteSession),g=Ee(j=>j.deleteAllSessions),m=Ee(j=>j.loadMoreSessions),x=Ee(j=>j.sessionsHasMore),S=Ee(j=>j.sessionsPaginationLoading),k=Ut(j=>j.currentProject),C=P.useRef(null),b=P.useCallback(()=>{x&&!S&&k&&m(k.id)},[x,S,k,m]);P.useEffect(()=>{if(!C.current||!x)return;const j=new IntersectionObserver(A=>{const N=A[0];N&&N.isIntersecting&&b()},{threshold:.1});return j.observe(C.current),()=>j.disconnect()},[x,b]);const y=p.filter(j=>j.projectId===(k==null?void 0:k.id)),v=(j,A)=>{A==null||A.stopPropagation(),confirm("Delete this session?")&&(f(j),(l==null?void 0:l.id)===j&&s(`/p/${e}`))},_=()=>{confirm("Delete all sessions in this project? This cannot be undone.")&&(g(e),s(`/p/${e}`))};return o.jsxs(o.Fragment,{children:[r&&i&&o.jsx("div",{className:"md:hidden fixed inset-0 bg-black/50 z-40",onClick:i}),o.jsxs("aside",{className:`
76
+ */var CS=2,kS=1,ES=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let r=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(r._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var m;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let r=this._terminal.options.scrollback===0?0:((m=this._terminal.options.overviewRuler)==null?void 0:m.width)||14,i=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(i.getPropertyValue("height")),c=Math.max(0,parseInt(i.getPropertyValue("width"))),u=window.getComputedStyle(this._terminal.element),p={top:parseInt(u.getPropertyValue("padding-top")),bottom:parseInt(u.getPropertyValue("padding-bottom")),right:parseInt(u.getPropertyValue("padding-right")),left:parseInt(u.getPropertyValue("padding-left"))},l=p.top+p.bottom,h=p.right+p.left,f=s-l,g=c-h-r;return{cols:Math.max(CS,Math.floor(g/e.css.cell.width)),rows:Math.max(kS,Math.floor(f/e.css.cell.height))}}};function jS({sessionId:e,onClose:r,onEscape:i,autoFocus:s}){const c=P.useRef(null),u=P.useRef(e),p=P.useRef(null),l=P.useRef(null),h=sr(g=>g.writeSession),f=sr(g=>g.resizeSession);return P.useEffect(()=>{u.current=e},[e]),P.useEffect(()=>{if(!i)return;const g=m=>{(m.key==="²"||m.key==="`")&&(m.preventDefault(),m.stopPropagation(),i())};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[i]),P.useEffect(()=>{if(!c.current)return;const g=new wS.Terminal({fontFamily:'"JetBrains Mono", monospace',fontSize:13,theme:{background:"#1a1a1a",foreground:"#e0e0e0",cursor:"#ffffff",cursorAccent:"#1a1a1a"},cursorBlink:!0,cursorStyle:"bar",convertEol:!0}),m=new ES;g.loadAddon(m),p.current={term:g,fitAddon:m},c.current.addEventListener("keydown",C=>{(C.key==="²"||C.key==="`")&&i&&(C.preventDefault(),C.stopPropagation(),i())}),g.open(c.current);const x=c.current.querySelector(".xterm");x&&(x.style.padding="8px"),m.fit(),s&&setTimeout(()=>{g.focus()},150);const S=new ResizeObserver(()=>{l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{requestAnimationFrame(()=>{var b;m.fit&&m.fit();const C=(b=p.current)==null?void 0:b.term;C&&C.cols>0&&C.rows>0&&f(u.current,C.cols,C.rows)})},100)});S.observe(c.current),g.onData(C=>{if((C==="\x1B"||C==="²"||C==="`")&&i){i();return}h(u.current,C)}),g.onKey(C=>{(C.key==="\x1B"||C.key==="²"||C.key==="`")&&i&&(C.domEvent.stopPropagation(),i())});const k=Ht.subscribe(C=>{var b,y;if(C.type==="terminal.output"&&((b=C.payload)==null?void 0:b.sessionId)===u.current){const v=(y=C.payload)==null?void 0:y.data;v&&g.write(v)}});return()=>{k(),S.disconnect(),l.current&&clearTimeout(l.current),g.dispose(),p.current=null}},[e,h,f]),o.jsxs("div",{className:"flex flex-col h-full bg-[#1a1a1a]",children:[o.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-2 py-1 bg-[#252525] border-b border-[#333]",children:[o.jsx("div",{}),o.jsx("button",{onClick:r,className:"p-1 rounded hover:bg-[#333] text-[#888] hover:text-[#ccc] transition-colors",title:"Close terminal",children:o.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("path",{d:"M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.55.5 0 0 1 0-.708z"})})})]}),o.jsx("div",{ref:c,className:"flex-1 relative overflow-hidden",tabIndex:0,onKeyDown:g=>{(g.key==="²"||g.key==="`")&&i&&(g.preventDefault(),g.stopPropagation(),i())}})]})}function NS(e){return e===1?"grid-cols-1":e===2?"grid-cols-1 lg:grid-cols-2":"grid-cols-1 lg:grid-cols-2 xl:grid-cols-3"}function TS({isOpen:e,onClose:r,onFocusChat:i}){const s=sr(C=>C.createSession),c=sr(C=>C.killSession),u=sr(C=>C.sessions),p=sr(C=>C.setWorkdir),l=sr(C=>C.fetchSessions),h=Ut(C=>C.currentProject),[f,g]=P.useState(!0),m=P.useRef(null),x=P.useRef(!1),S=P.useRef(!1),k=P.useCallback(()=>{r(),i()},[r,i]);return P.useEffect(()=>{h!=null&&h.workdir&&p(h.workdir)},[h==null?void 0:h.workdir,p]),P.useEffect(()=>{e&&(g(!0),l().finally(()=>g(!1)))},[e,l]),P.useEffect(()=>{e&&u.length===0&&!f&&!S.current&&(S.current=!0,s())},[e,u.length,f,s]),P.useEffect(()=>{e?(x.current=!0,setTimeout(()=>{var C;(C=m.current)==null||C.focus(),setTimeout(()=>{x.current=!1},200)},100)):S.current=!1},[e]),P.useEffect(()=>{if(!e)return;const C=b=>{x.current||(b.key==="Escape"||b.key==="²"||b.key==="`")&&(b.preventDefault(),r(),i())};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[e,r,i]),e?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"fixed inset-x-0 top-[50vh] bottom-0 z-[100] bg-black/40",style:{pointerEvents:"auto"},onClick:k}),o.jsxs("div",{ref:m,tabIndex:-1,className:"fixed inset-x-0 top-0 z-[100] h-[50vh] bg-bg-primary border-b border-border flex flex-col animate-slide-down outline-none",onClick:C=>C.stopPropagation(),onKeyDown:C=>{(C.key==="Escape"||C.key==="²"||C.key==="`")&&(C.preventDefault(),k())},children:[o.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border",children:[o.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Terminal"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{onClick:()=>s(),className:"p-2 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"New terminal",children:o.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z",clipRule:"evenodd"})})}),o.jsx("button",{onClick:()=>{r(),i()},className:"p-2 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Close (Esc)",children:o.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]})]}),o.jsx("div",{className:"flex-1 min-h-0 p-2 overflow-auto",children:f?o.jsx("div",{className:"flex items-center justify-center h-full text-text-muted",children:"Loading..."}):u.length===0?o.jsx("div",{className:"flex items-center justify-center h-full text-text-muted",children:o.jsxs("div",{className:"text-center",children:[o.jsx("p",{className:"mb-4",children:"No terminal sessions"}),o.jsx("button",{onClick:()=>s(),className:"px-4 py-2 bg-accent-primary/25 text-white rounded hover:bg-accent-primary/40 transition-colors",children:"Create Terminal"})]})}):o.jsx("div",{className:`grid ${NS(u.length)} gap-2 h-full auto-rows-fr`,children:u.map(C=>o.jsx(jS,{sessionId:C.id,onClose:()=>c(C.id),onEscape:k,autoFocus:u.length===1},C.id))})})]})]}):null}function Ya({items:e,trigger:r,minWidth:i="120px"}){const[s,c]=P.useState(!1),[u,p]=P.useState(null),l=P.useRef(null),h=P.useRef(null);P.useEffect(()=>{function x(S){h.current&&!h.current.contains(S.target)&&c(!1)}return s&&document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}},[s]);const f=P.useCallback(()=>{if(!l.current)return;const x=l.current.getBoundingClientRect(),S=200,C=window.innerHeight-x.bottom<S;p({top:C?x.top-S-4:x.bottom+4,left:x.left,alignToTop:C})},[]),g=x=>{x.stopPropagation(),s||f(),c(!s)},m=u&&o.jsx("div",{ref:h,"data-testid":"session-dropdown-menu",className:`fixed bg-bg-secondary border border-border rounded shadow-lg z-50 ${u.alignToTop?"mb-1":"mt-1"}`,style:{top:u.top,left:u.left,minWidth:i},children:e.map((x,S)=>{const k=o.jsxs(o.Fragment,{children:[x.icon&&o.jsx("span",{className:"w-4 h-4 flex-shrink-0",children:x.icon}),x.label]});return x.href?o.jsx("a",{href:x.href,onClick:C=>{var b;(b=x.onClick)==null||b.call(x,C),c(!1)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bg-tertiary transition-colors flex items-center gap-2 ${x.danger?"text-accent-error hover:bg-accent-error/10":"text-text-primary"} ${S!==e.length-1?"border-b border-border":""}`,children:k},S):o.jsx("button",{onClick:C=>{var b;(b=x.onClick)==null||b.call(x,C),x.closeOnClick!==!1&&c(!1)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bg-tertiary transition-colors flex items-center gap-2 ${x.danger?"text-accent-error hover:bg-accent-error/10":"text-text-primary"} ${S!==e.length-1?"border-b border-border":""}`,children:k},S)})});return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"relative",children:o.jsx("div",{ref:l,onClick:g,children:r})}),s&&ph.createPortal(m,document.body)]})}function ub(e){const r=new Date(e),s=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][r.getDay()],c=r.getFullYear(),u=String(r.getMonth()+1).padStart(2,"0"),p=String(r.getDate()).padStart(2,"0");return`${s} ${c}/${u}/${p}`}function mh(e){const r=new Date(e),i=String(r.getHours()).padStart(2,"0"),s=String(r.getMinutes()).padStart(2,"0");return`${i}:${s}`}function AS(e){const r=new Date(e),i=new Date,s=new Date(i.getFullYear(),i.getMonth(),i.getDate()),c=new Date(r.getFullYear(),r.getMonth(),r.getDate()),u=Math.floor((s.getTime()-c.getTime())/(1e3*60*60*24)),p=mh(e);if(u===0)return`today ${p}`;if(u===1)return`yesterday ${p}`;if(u<7)return`${u} days ago ${p}`;{const l=r.getFullYear(),h=String(r.getMonth()+1).padStart(2,"0"),f=String(r.getDate()).padStart(2,"0");return`${l}/${h}/${f} ${p}`}}function DS(e){const r=new Date(e),i=r.getFullYear(),s=String(r.getMonth()+1).padStart(2,"0"),c=String(r.getDate()).padStart(2,"0");return`${i}-${s}-${c}`}function db(e){const r=new Map;for(const c of e){const u=DS(c.updatedAt);r.has(u)||r.set(u,[]),r.get(u).push(c)}for(const[c,u]of r)u.sort((p,l)=>{const h=new Date(p.updatedAt).getTime();return new Date(l.updatedAt).getTime()-h});const i=Array.from(r.keys()).sort((c,u)=>u.localeCompare(c)),s=new Map;for(const c of i)s.set(c,r.get(c));return s}function LS({projects:e,currentProject:r}){const i=Ut(u=>u.loadProject),c=[...e].sort((u,p)=>u.name.localeCompare(p.name)).map(u=>({label:u.name,icon:u.id===r.id?o.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):void 0,href:`/p/${u.id}`,onClick:()=>{i(u.id)}}));return o.jsx(Ya,{items:c,trigger:o.jsxs("button",{className:"text-text-secondary hover:text-text-primary hover:underline text-sm truncate flex items-center gap-1",title:r.name,children:[r.name,o.jsx("svg",{className:"w-3 h-3 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),minWidth:"250px"})}function RS({currentProject:e,sessions:r,currentSession:i,projectIdFromUrl:s}){const[c,u]=P.useState(!1),p=P.useRef(null);if(P.useEffect(()=>{function f(g){p.current&&!p.current.contains(g.target)&&u(!1)}if(c)return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[c]),!(e!=null&&e.id)||e.id!==s)return null;const l=r.filter(f=>f.projectId===e.id).sort((f,g)=>new Date(g.updatedAt).getTime()-new Date(f.updatedAt).getTime()).slice(0,5),h=[];h.push({label:o.jsxs(An,{href:`/p/${e.id}/new`,className:"flex items-center gap-2",children:[o.jsx("svg",{className:"w-3 h-3 text-accent-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),o.jsx("span",{className:"text-sm",children:"New Session"})]}),onClick:()=>{}});for(const f of l)h.push({label:o.jsx(An,{href:`/p/${e.id}/s/${f.id}`,className:"flex items-center gap-2 truncate text-sm",children:o.jsx("span",{children:f.title??f.id.slice(0,8)})}),icon:f.id===(i==null?void 0:i.id)?o.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):void 0,onClick:()=>{}});return h.push({label:o.jsxs(An,{href:"/",className:"flex items-center gap-2 text-text-muted hover:text-text-primary",children:[o.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})}),o.jsx("span",{className:"text-sm",children:"Projects"})]}),onClick:()=>{}}),o.jsxs("div",{className:"relative",ref:p,children:[o.jsxs("button",{type:"button",onClick:()=>u(!c),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors",children:[o.jsx("span",{className:"text-sm text-text-secondary font-medium",children:e==null?void 0:e.name}),o.jsx("svg",{className:"w-3 h-3 text-text-muted flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),c&&h.length>0&&o.jsx("div",{className:"absolute top-full left-0 mt-1 w-56 bg-bg-secondary border border-border rounded-lg shadow-lg overflow-hidden z-50",children:h.map((f,g)=>{if(f.label&&typeof f.label=="object"&&f.label.type===An){const m=f.label,x=m.props.href||"";return o.jsxs(An,{href:x,className:"flex items-center gap-2 px-3 py-2 text-sm border-b border-border hover:bg-bg-tertiary transition-colors",children:[f.icon,m.props.children]},g)}return f.href?o.jsxs("a",{href:f.href,className:"flex items-center gap-2 px-3 py-2 text-sm border-b border-border hover:bg-bg-tertiary transition-colors",children:[f.icon,f.label]},g):o.jsxs("button",{type:"button",onClick:()=>{var m;(m=f.onClick)==null||m.call(f),u(!1)},className:"flex items-center gap-2 px-3 py-2 text-sm w-full text-left border-b border-border hover:bg-bg-tertiary transition-colors",children:[f.icon,f.label]},g)})})]})}function MS({sessions:e,currentProject:r,currentSession:i}){var h;const s=Ee(f=>f.loadSession),c=e.filter(f=>f.projectId===r.id).slice(0,15),u=db(c),p=[];p.push({label:o.jsxs(An,{href:`/p/${r.id}/new`,className:"flex items-center gap-2 px-3 py-2 min-w-[160px]","data-testid":"session-dropdown-new-session",children:[o.jsx("svg",{className:"w-4 h-4 text-accent-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),o.jsx("span",{className:"text-sm",children:"New session"})]}),onClick:()=>{}});for(const[f,g]of u){const m=g[0];if(m){p.push({label:o.jsx("div",{className:"px-3 py-2 text-text-muted text-xs font-medium cursor-default",children:ub(m.updatedAt)}),onClick:()=>{}});for(const x of g)p.push({label:o.jsxs("div",{className:"min-w-[160px]",children:[o.jsx("div",{className:"truncate text-sm",children:x.title??x.id.slice(0,8)}),o.jsx("div",{className:"text-text-muted text-xs",children:mh(x.updatedAt)})]}),icon:x.id===(i==null?void 0:i.id)?o.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):void 0,href:`/p/${r.id}/s/${x.id}`,onClick:()=>{s(x.id)}})}}const l=i?((h=i.metadata)==null?void 0:h.title)??i.id.slice(0,8):"No session selected";return o.jsx(Ya,{items:p,trigger:o.jsxs("button",{className:"text-text-secondary hover:text-text-primary hover:underline text-sm truncate flex items-center gap-1",title:l,"data-testid":"header-session-dropdown",children:[l,o.jsx("svg",{className:"w-3 h-3 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),minWidth:"280px"})}function OS({onMenuClick:e,onCriteriaToggle:r}){const[i,s]=P.useState(!1),[c]=ar(),u=c.startsWith("/p/"),p=/^\/p\/[^/]+\/s\/[^/]+$/.test(c),l=Ee(b=>b.currentSession),h=Ee(b=>b.sessions),f=Ut(b=>b.currentProject),g=Ut(b=>b.projects),m=Lt(b=>b.startAutoRefresh),x=Lt(b=>b.stopAutoRefresh),S=sr(b=>b.setOpen),k=sr(b=>b.isOpen),C=P.useCallback(()=>{const b=document.querySelector('textarea[placeholder*="What would you like to build"], textarea[placeholder*="Send a message"]');b&&b.focus()},[]);return P.useEffect(()=>{const b=y=>{(y.key==="²"||y.key==="`")&&(y.preventDefault(),k||S(!0))};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[k,S]),P.useEffect(()=>(m(),()=>x()),[m,x]),o.jsxs("header",{className:"h-8 bg-bg-secondary border-b border-border flex items-center justify-between px-2",children:[o.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e&&u&&o.jsx("button",{onClick:e,className:"flex-shrink-0 p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Toggle session list",children:o.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),o.jsx(An,{href:"/",className:"text-accent-primary font-semibold text-base hover:underline flex-shrink-0 hidden md:inline",children:"OpenFox"}),f&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"hidden md:inline text-text-muted flex-shrink-0",children:"/"}),o.jsx("span",{className:"hidden md:inline",children:o.jsx(LS,{projects:g,currentProject:f})}),o.jsx("span",{className:"md:hidden",children:o.jsx(RS,{currentProject:f,sessions:h,currentSession:l,projectIdFromUrl:u&&c.split("/")[2]||null},f==null?void 0:f.id)}),o.jsx("span",{className:"hidden md:inline text-text-muted flex-shrink-0",children:"/"}),o.jsx("span",{className:"hidden md:inline",children:o.jsx(MS,{sessions:h,currentProject:f,currentSession:l})})]})]}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[u&&o.jsx("button",{onClick:()=>S(!k),className:`p-2.5 rounded hover:bg-bg-tertiary transition-colors ${k?"text-accent-primary":"text-text-muted hover:text-text-primary"}`,title:"Toggle terminal (²)",children:o.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M2 5a2 2 0 012-2h12a2 2 0 012 2v10a2 2 0 01-2 2H4a2 2 0 01-2-2V5zm3 1h10v1H5V6zm10 7H5v1h10v-1zm-10 2H5v1h10v-1z",clipRule:"evenodd"})})}),o.jsx("button",{onClick:()=>s(!0),className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Settings",children:o.jsxs("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}),o.jsx("button",{onClick:()=>{localStorage.removeItem("openfox_token"),window.location.reload()},className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Logout",children:o.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"})})}),r&&p&&o.jsx("button",{onClick:r,className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Toggle summary sidebar",children:o.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})]}),o.jsx(bS,{isOpen:i,onClose:()=>s(!1)}),o.jsx(TS,{isOpen:k,onClose:()=>S(!1),onFocusChat:C})]})}function BS({isOpen:e,onClose:r,title:i,label:s,description:c,placeholder:u,value:p,isLoading:l=!1,onSave:h}){const[f,g]=P.useState(p),[m,x]=P.useState(!1),[S,k]=P.useState(!1);P.useEffect(()=>{g(p),x(!1)},[p]);const C=_=>{g(_.target.value),x(!0)},b=async()=>{k(!0),await h(f),k(!1),x(!1),r()},y=()=>{g(p),x(!1),r()},v=l||S;return o.jsx(un,{isOpen:e,onClose:y,title:i,size:"lg",children:o.jsxs("div",{className:"flex flex-col h-full -mt-1",children:[o.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:s}),o.jsx("p",{className:"text-sm text-text-muted mb-3 flex-shrink-0",children:c}),o.jsx("div",{className:"flex-1 min-h-[150px]",children:o.jsx("textarea",{value:f,onChange:C,placeholder:u,className:"w-full h-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:v})}),o.jsxs("div",{className:"flex justify-end gap-2 pt-2 mt-3 border-t border-border flex-shrink-0",children:[o.jsx(dt,{variant:"secondary",onClick:y,children:"Cancel"}),o.jsx(dt,{variant:"primary",onClick:b,disabled:!m||v,children:S?"Saving...":"Save"})]})]})})}function IS({isOpen:e,onClose:r,project:i}){const s=Ut(u=>u.updateProject),c=async u=>{s(i.id,{customInstructions:u||null}),await new Promise(p=>setTimeout(p,100))};return o.jsx(BS,{isOpen:e,onClose:r,title:`${i.name} Settings`,label:"Project Instructions",description:"These instructions are injected into prompts when working in this project. They are applied after global instructions but before AGENTS.md files.",placeholder:"Enter project-specific instructions...",value:i.customInstructions??"",onSave:c})}function hb({projectId:e,isOpen:r=!0,onClose:i}){const[,s]=ar(),[c,u]=P.useState(!1),p=Ee(j=>j.sessions),l=Ee(j=>j.currentSession),h=Ee(j=>j.unreadSessionIds),f=Ee(j=>j.deleteSession),g=Ee(j=>j.deleteAllSessions),m=Ee(j=>j.loadMoreSessions),x=Ee(j=>j.sessionsHasMore),S=Ee(j=>j.sessionsPaginationLoading),k=Ut(j=>j.currentProject),C=P.useRef(null),b=P.useCallback(()=>{x&&!S&&k&&m(k.id)},[x,S,k,m]);P.useEffect(()=>{if(!C.current||!x)return;const j=new IntersectionObserver(A=>{const N=A[0];N&&N.isIntersecting&&b()},{threshold:.1});return j.observe(C.current),()=>j.disconnect()},[x,b]);const y=p.filter(j=>j.projectId===(k==null?void 0:k.id)),v=(j,A)=>{A==null||A.stopPropagation(),confirm("Delete this session?")&&(f(j),(l==null?void 0:l.id)===j&&s(`/p/${e}`))},_=()=>{confirm("Delete all sessions in this project? This cannot be undone.")&&(g(e),s(`/p/${e}`))};return o.jsxs(o.Fragment,{children:[r&&i&&o.jsx("div",{className:"md:hidden fixed inset-0 bg-black/50 z-40",onClick:i}),o.jsxs("aside",{className:`
77
77
  ${r?"md:w-[300px] md:shrink-0":"md:w-0 md:shrink-0 md:overflow-hidden"}
78
78
  md:relative md:h-auto md:translate-x-0
79
79
 
@@ -81,13 +81,13 @@ WARNING: This link could potentially be dangerous`)){const y=window.open();if(y)
81
81
  w-[300px] bg-bg-secondary border-r border-border flex flex-col
82
82
  transition-all duration-300 ease-in-out
83
83
  ${r?"translate-x-0":"-translate-x-full"}
84
- `,children:[o.jsxs("div",{className:"p-4 border-b border-border flex gap-2",children:[o.jsx(An,{href:`/p/${e}/new`,className:"flex-1 block text-center rounded font-medium transition-colors bg-accent-primary/25 text-white hover:bg-accent-primary/40 px-3 py-1.5 text-sm","data-testid":"sidebar-new-session-button",children:"+ New Session"}),o.jsx(Ya,{items:[{label:"Edit project settings",onClick:()=>u(!0)},{label:"Delete all sessions",onClick:_,danger:!0}],trigger:o.jsx("button",{className:"flex-shrink-0 p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Options",children:o.jsxs("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 24 24",children:[o.jsx("circle",{cx:"12",cy:"5",r:"2"}),o.jsx("circle",{cx:"12",cy:"12",r:"2"}),o.jsx("circle",{cx:"12",cy:"19",r:"2"})]})})}),i&&o.jsx("button",{onClick:i,className:"md:hidden flex-shrink-0 p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Close sidebar",children:o.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),k&&o.jsx(IS,{isOpen:c,onClose:()=>u(!1),project:k}),o.jsx("div",{className:"flex-1 overflow-y-auto",children:y.length===0?o.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:"No sessions"}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"divide-y divide-border",children:zS(y,l,h,v,e)}),S&&o.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:"Loading more..."}),o.jsx("div",{ref:C,className:"h-px"})]})})]})]})}function zS(e,r,i,s,c){const u=db(e);return Array.from(u).map(([p,l])=>{const h=l[0];return h?o.jsxs("div",{children:[o.jsx("div",{className:"px-4 py-2 bg-bg-tertiary/30 text-text-muted text-xs font-medium",children:ub(h.updatedAt)}),l.map(f=>{const g=(r==null?void 0:r.id)===f.id,m=i.includes(f.id),x=f.isRunning;return o.jsx("div",{className:`w-full px-4 py-3 text-left hover:bg-bg-tertiary/50 transition-colors group ${g?"bg-bg-tertiary":""}`,children:o.jsxs(An,{href:`/p/${c}/s/${f.id}`,className:`block ${g?"text-accent-primary":"text-text-primary"} hover:text-accent-primary`,children:[o.jsxs("div",{className:"flex justify-between items-center mb-1",children:[o.jsx("span",{className:`font-medium truncate text-sm ${g?"text-accent-primary":"text-text-primary"}`,children:f.title??f.id.slice(0,6)}),o.jsx(Ya,{items:[{label:"Delete session",onClick:S=>s(f.id,S),danger:!0}],trigger:o.jsx("button",{onClick:S=>S.preventDefault(),className:"p-1.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-all",title:"Options",children:o.jsxs("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 24 24",children:[o.jsx("circle",{cx:"12",cy:"5",r:"2"}),o.jsx("circle",{cx:"12",cy:"12",r:"2"}),o.jsx("circle",{cx:"12",cy:"19",r:"2"})]})})})]}),o.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[x?o.jsxs("svg",{"aria-label":"Session running",className:"w-3 h-3 text-blue-400 animate-spin flex-shrink-0",viewBox:"0 0 24 24",fill:"none",children:[o.jsx("title",{children:"Running"}),o.jsx("circle",{className:"opacity-30",cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"3"}),o.jsx("path",{d:"M21 12a9 9 0 00-9-9",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]}):m&&!g?o.jsx("span",{"aria-label":"Unread activity",title:"Unread activity",className:"w-2 h-2 rounded-full bg-amber-400 flex-shrink-0"}):null,o.jsx("span",{className:"text-text-muted text-xs flex-shrink-0",children:mh(f.updatedAt)}),o.jsxs("span",{className:"text-text-muted text-xs flex-shrink-0",children:[f.messageCount," messages"]})]})]})},f.id)})]},p):null})}const Cx=["⠋","⠙","⠹","⠸","⠼","⠴"];function HS(){var l;const e=Ut(h=>h.currentProject),r=Ee(h=>h.currentSession),i=ab(),s=!1,c=P.useRef(0),u=P.useRef(null);P.useEffect(()=>(i?(u.current=window.setInterval(()=>{c.current=(c.current+1)%Cx.length,p()},150),p()):(u.current&&(clearInterval(u.current),u.current=null),p()),()=>{u.current&&(clearInterval(u.current),u.current=null)}),[i,e,r,s]);const p=()=>{var m;const f=(m=r==null?void 0:r.metadata)==null?void 0:m.title,g=i?`${Cx[c.current]} `:"";e&&f?document.title=`${g}${e.name} - ${f} | OpenFox`:e?document.title=`${g}${e.name} | OpenFox`:document.title=`${g}OpenFox`};return typeof window<"u"&&((l=r==null?void 0:r.metadata)!=null&&l.title)&&window.document.documentElement.setAttribute("data-session-title",r.metadata.title),null}const zl=P.forwardRef(({className:e="",...r},i)=>o.jsx("input",{ref:i,className:`bg-bg-tertiary border border-border rounded px-3 py-2 text-text-primary placeholder-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary ${e}`,...r}));zl.displayName="Input";function PS({isOpen:e,onClose:r,projectName:i,onConfirm:s}){const c=()=>{s(),r()};return o.jsx(un,{isOpen:e,onClose:r,title:"Delete Project",size:"sm",children:o.jsxs("div",{className:"space-y-4",children:[o.jsxs("p",{className:"text-text-secondary",children:["This will permanently delete the project ",o.jsx("span",{className:"font-semibold text-text-primary",children:i})," and all its sessions from OpenFox. The project files on disk will remain untouched."]}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(dt,{variant:"secondary",onClick:r,children:"Cancel"}),o.jsx(dt,{variant:"danger",onClick:c,children:"Delete"})]})]})})}function FS(e){return!e||e.trim()===""?{valid:!1,error:"Project name cannot be empty"}:/^[a-zA-Z0-9._-]+$/.test(e)?{valid:!0}:{valid:!1,error:"Project name can only contain letters, numbers, hyphens, underscores, and dots"}}function US({isOpen:e,onClose:r}){const[,i]=ar(),[s,c]=P.useState(""),[u,p]=P.useState(null),[l,h]=P.useState(!1),[f,g]=P.useState(""),m=P.useRef(null);P.useEffect(()=>{e&&(ye("/api/config").then(C=>C.json()).then(C=>{C.workdir&&g(C.workdir)}),c(""),p(null),h(!1),setTimeout(()=>{var C;(C=m.current)==null||C.focus()},100))},[e]);const x=P.useCallback(async C=>{C.preventDefault();const b=FS(s);if(!b.valid){p(b.error);return}h(!0),p(null);const y=`${f}/${s}`;try{const v=await ye("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s,workdir:y})});if(!v.ok){const A=await v.json().catch(()=>({}));throw new Error(A.error||"Failed to create project")}const j=(await v.json()).project;r(),i(`/p/${j.id}`)}catch(v){p(v instanceof Error?v.message:"Failed to create project"),h(!1)}},[s,i,r,f]),S=P.useCallback(()=>{c(""),p(null),r()},[r]),k=s?`${f}/${s}`:"";return o.jsx(un,{isOpen:e,onClose:S,title:"Create New Project",size:"sm",children:o.jsxs("form",{onSubmit:x,className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{htmlFor:"project-name",className:"block text-sm font-medium text-text-secondary mb-2",children:"Project Name"}),o.jsx(zl,{ref:m,id:"project-name",value:s,onChange:C=>{c(C.target.value),p(null)},placeholder:"my-project",disabled:l,className:"w-full"}),s&&o.jsxs("div",{className:"mt-2 text-xs text-text-muted",children:["Full path: ",o.jsx("span",{className:"font-mono",children:k})]}),u&&o.jsx("div",{className:"mt-3 p-3 bg-accent-error/10 border border-accent-error/30 rounded text-sm text-accent-error",children:u})]}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(dt,{type:"button",variant:"secondary",onClick:S,disabled:l,children:"Cancel"}),o.jsx(dt,{type:"submit",variant:"primary",disabled:l||!s.trim(),className:"min-w-[100px]",children:l?o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsxs("svg",{className:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24",children:[o.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),o.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Creating..."]}):"Create"})]})]})})}const $S={sm:"w-4 h-4",md:"w-8 h-8",lg:"w-12 h-12"};function Hl({size:e="md",className:r=""}){return o.jsx("div",{className:`animate-spin border-2 border-accent-primary border-t-transparent rounded-full ${$S[e]} ${r}`})}function qS({text:e,...r}){return o.jsxs("div",{className:"text-center",children:[o.jsx(Hl,{...r,className:"mx-auto mb-4"}),e&&o.jsx("div",{className:"text-text-secondary",children:e})]})}function fb({onSelect:e,onClose:r,initialPath:i}){const[s,c]=P.useState(null),[u,p]=P.useState(!0),l=P.useCallback(async k=>{p(!0);try{const C=k?`/api/directories?path=${encodeURIComponent(k)}`:"/api/directories",y=await(await ye(C)).json();c(y)}catch(C){console.error("Failed to load directories:",C)}finally{p(!1)}},[]);P.useEffect(()=>{l(i)},[i,l]);const h=k=>{l(k)},f=k=>{e(k)},m=((s==null?void 0:s.current)??"").split("/").filter(Boolean),S=m.map((k,C)=>({name:k,path:"/"+m.slice(0,C+1).join("/")}));return o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50",onClick:r,children:o.jsxs("div",{className:"bg-bg-secondary border border-border rounded-lg w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:k=>k.stopPropagation(),children:[o.jsxs("div",{className:"p-4 border-b border-border flex items-center justify-between",children:[o.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:"Select Folder"}),o.jsx("button",{onClick:r,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary",children:o.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),s&&o.jsx("div",{className:"px-3 py-2 bg-bg-tertiary/30 border-b border-border",children:o.jsxs("div",{className:"flex items-center text-xs overflow-x-auto",children:[S.map((k,C)=>o.jsxs("span",{className:"flex items-center shrink-0",children:[o.jsx("span",{className:"text-text-muted",children:"/"}),o.jsx("button",{onClick:()=>h(k.path),className:`px-1 ${C===S.length-1?"text-accent-primary font-medium":"text-text-secondary hover:text-accent-primary"}`,children:k.name})]},k.path)),S.length===0&&o.jsx("button",{onClick:()=>h("/"),className:"text-text-muted hover:text-accent-primary",children:"/"})]})}),o.jsx("div",{className:"flex-1 overflow-y-auto",children:u?o.jsx("div",{className:"p-8 text-center",children:o.jsx(Hl,{size:"sm"})}):o.jsxs("div",{className:"divide-y divide-border",children:[(s==null?void 0:s.parent)&&o.jsxs("button",{onClick:()=>h(s.parent),className:"w-full p-3 flex items-center gap-3 hover:bg-bg-tertiary/50 text-text-muted",children:[o.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),o.jsx("span",{children:".."})]}),s==null?void 0:s.directories.map(k=>o.jsxs("div",{className:"group flex items-center gap-2 hover:bg-bg-tertiary/50",children:[o.jsxs("button",{onClick:()=>h(k.path),className:"flex-1 p-3 flex items-center gap-3 text-left",children:[o.jsx("svg",{className:"w-5 h-5 text-accent-primary",fill:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{d:"M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"})}),o.jsx("span",{children:k.name})]}),o.jsx("button",{onClick:()=>f(k.path),className:"px-3 py-1 text-xs bg-accent-primary/10 text-accent-primary rounded opacity-0 group-hover:opacity-100 transition-opacity mr-3",children:"Select"})]},k.path)),(s==null?void 0:s.directories.length)===0&&o.jsx("div",{className:"p-8 text-center text-text-muted text-sm",children:"No subdirectories"})]})}),o.jsxs("div",{className:"p-4 border-t border-border space-y-2",children:[(s==null?void 0:s.current)&&o.jsx("button",{onClick:()=>f(s.current),className:"w-full px-4 py-2 bg-accent-primary text-white rounded-lg font-medium hover:bg-accent-primary/90 transition-colors",children:"Select this folder"}),o.jsx("button",{onClick:r,className:"w-full text-center text-text-muted hover:text-text-secondary text-sm",children:"Cancel"})]})]})})}function WS({isOpen:e,onClose:r}){const[,i]=ar(),[s,c]=P.useState(!1),[u,p]=P.useState(""),[l,h]=P.useState(null),[f,g]=P.useState(!1),[m,x]=P.useState(null),S=Ut(R=>R.projects),k=Ut(R=>R.createProject),C=Ut(R=>R.listProjects),b=Ut(R=>R.deleteProject),[y,v]=P.useState(null),[_,j]=P.useState(-1),[A,N]=P.useState(null),[L,T]=P.useState(!1),B=P.useRef([]);P.useEffect(()=>{ye("/api/config").then(R=>R.json()).then(R=>{R.workdir&&x(R.workdir)})},[]);const H=P.useCallback(async R=>{g(!0);try{const D=R?`/api/directories?path=${encodeURIComponent(R)}`:m?`/api/directories?path=${encodeURIComponent(m)}`:"/api/directories",W=await(await ye(D)).json();h(W)}catch(D){console.error("Failed to load directories:",D)}finally{g(!1)}},[m]);P.useEffect(()=>{e&&m&&(H(m),C())},[e,m,H,C]);const q=(l==null?void 0:l.directories.filter(R=>u===""||R.name.toLowerCase().includes(u.toLowerCase())))??[],Y=[...l!=null&&l.parent&&!u?[{type:"parent",path:l.parent,name:".."}]:[],...q.map(R=>({type:"directory",path:R.path,name:R.name}))],V=R=>{i(`/p/${R}`),r()},F=(R,D)=>{D.stopPropagation(),N(R)},I=()=>{A&&(b(A.id),N(null))},$=R=>{const D=R.split("/").filter(Boolean).pop()??"";k(D,R),C(),v(R)};P.useEffect(()=>{if(y){const R=S.find(D=>D.workdir===y);R&&(i(`/p/${R.id}`),r(),v(null))}},[S,y,i,r]),P.useEffect(()=>{j(Y.length>0?0:-1)},[u,Y.length]);const X=R=>{p(""),H(R)},J=P.useCallback(R=>{if(!e)return;if(R.key==="Escape"){r();return}if(!["ArrowDown","ArrowUp","Enter"].includes(R.key))return;const D=document.activeElement;if(!(!D||D.tagName!=="INPUT")){if(R.preventDefault(),R.key==="ArrowDown")j(O=>{const W=O+1;return W>=Y.length?0:W});else if(R.key==="ArrowUp")j(O=>{const W=O-1;return W<0?Y.length-1:W});else if(R.key==="Enter"&&_>=0&&_<Y.length){const O=Y[_];(O==null?void 0:O.type)==="parent"?X(O.path):O&&$(O.path)}}},[e,Y.length,_,X,$,r]);return P.useEffect(()=>{if(e)return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)},[e,J]),P.useEffect(()=>{_>=0&&B.current[_]&&B.current[_].scrollIntoView({behavior:"smooth",block:"nearest"})},[_]),e?o.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50",children:[o.jsxs("div",{className:"bg-bg-secondary border border-border rounded-lg w-full max-w-[90vw] md:max-w-4xl max-h-[90vh] flex flex-col",children:[o.jsxs("div",{className:"p-4 border-b border-border flex items-center justify-between",children:[o.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:"Open Project"}),o.jsx("button",{onClick:r,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",children:o.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),o.jsxs("div",{className:"flex-1 flex overflow-hidden min-h-[400px]",children:[o.jsxs("div",{className:"w-1/2 border-r border-border flex flex-col",children:[o.jsx("div",{className:"p-3 border-b border-border bg-bg-tertiary/30",children:o.jsx("h3",{className:"font-medium text-sm text-text-secondary",children:"Recent Projects"})}),o.jsx("div",{className:"flex-1 overflow-y-auto",children:S.length===0?o.jsx("div",{className:"p-4 text-center text-text-muted text-sm",children:"No recent projects"}):o.jsx("div",{className:"divide-y divide-border",children:S.map(R=>o.jsxs("div",{className:"group flex items-center gap-3 p-3 hover:bg-bg-tertiary/50 transition-colors",children:[o.jsxs("button",{onClick:()=>V(R.id),className:"flex-1 flex items-center gap-3 text-left",children:[o.jsx("svg",{className:"w-5 h-5 text-accent-primary",fill:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{d:"M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"font-medium truncate",children:R.name}),o.jsx("div",{className:"text-xs text-text-muted truncate",children:R.workdir})]})]}),o.jsx("button",{onClick:D=>F(R,D),className:"opacity-0 group-hover:opacity-100 text-accent-error/70 hover:text-accent-error p-1 transition-opacity",title:"Delete project",children:o.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]},R.id))})})]}),o.jsxs("div",{className:"w-1/2 flex flex-col",children:[o.jsxs("div",{className:"p-3 border-b border-border bg-bg-tertiary/30 flex items-center justify-between",children:[o.jsx("h3",{className:"font-medium text-sm text-text-secondary",children:"Browse Projects"}),o.jsx("button",{onClick:()=>T(!0),className:"text-xs text-accent-primary hover:underline",children:"Open in dialog"})]}),o.jsx("div",{className:"p-3 border-b border-border",children:o.jsx(zl,{value:u,onChange:R=>p(R.target.value),placeholder:"Filter directories...",className:"w-full"})}),o.jsx("div",{className:"flex-1 overflow-y-auto",children:f?o.jsx("div",{className:"p-8 text-center text-text-muted",children:o.jsx("div",{className:"animate-spin w-5 h-5 border-2 border-accent-primary border-t-transparent rounded-full mx-auto"})}):Y.length===0?o.jsx("div",{className:"p-8 text-center text-text-muted text-sm",children:u?"No matching directories":"No subdirectories"}):o.jsx("div",{className:"divide-y divide-border",children:Y.map((R,D)=>o.jsxs("button",{ref:O=>{B.current[D]=O},onClick:()=>R.type==="parent"?X(R.path):$(R.path),className:`w-full p-3 flex items-center gap-3 text-left transition-colors ${D===_?"bg-accent-primary/20 text-accent-primary":"hover:bg-bg-tertiary/50"}`,children:[o.jsx("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{d:"M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"})}),o.jsx("span",{className:"flex-1",children:R.name})]},R.path))})})]})]}),o.jsxs("div",{className:"p-4 border-t border-border flex justify-between gap-2",children:[o.jsx(dt,{variant:"secondary",onClick:()=>c(!0),children:"Create Project"}),o.jsx(dt,{variant:"secondary",onClick:r,children:"Cancel"})]})]}),s&&o.jsx(US,{isOpen:s,onClose:()=>c(!1)}),A&&o.jsx(PS,{isOpen:!0,onClose:()=>N(null),projectName:A.name,onConfirm:I}),L&&o.jsx(fb,{initialPath:m??void 0,onSelect:R=>{$(R),T(!1)},onClose:()=>T(!1)})]}):null}function GS(){const[e,r]=P.useState(!1),i=Ee(g=>g.sessions),s=Ut(g=>g.projects),c=Ut(g=>g.listProjects),u=Ee(g=>g.listSessions),p=Ee(g=>g.connectionStatus);P.useEffect(()=>{p==="connected"&&(c(),u())},[p,c,u]);const l=[...s].sort((g,m)=>{const x=i.filter(b=>b.workdir.startsWith(g.workdir)),S=i.filter(b=>b.workdir.startsWith(m.workdir)),k=x.length>0?new Date(x.reduce((b,y)=>new Date(y.updatedAt)>new Date(b.updatedAt)?y:b).updatedAt).getTime():new Date(g.updatedAt).getTime();return(S.length>0?new Date(S.reduce((b,y)=>new Date(y.updatedAt)>new Date(b.updatedAt)?y:b).updatedAt).getTime():new Date(m.updatedAt).getTime())-k}),h=g=>{const m=s.find(x=>x.id===g);return m?i.filter(x=>x.workdir.startsWith(m.workdir)).sort((x,S)=>new Date(S.updatedAt).getTime()-new Date(x.updatedAt).getTime()).slice(0,5):[]},f=()=>{r(!0)};return o.jsxs("div",{className:"flex-1 flex flex-col overflow-y-auto",children:[o.jsxs("div",{className:"max-w-5xl mx-auto w-full p-4 md:p-8",children:[o.jsxs("div",{className:"mb-6 md:mb-8 flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-3xl font-bold text-accent-primary",children:"OpenFox"}),o.jsx("p",{className:"text-text-secondary",children:"Local LLM-powered coding assistant with contract-driven execution"})]}),o.jsx(dt,{variant:"primary",onClick:f,children:"Open Project"})]}),l.map(g=>{const m=h(g.id);return o.jsx("div",{className:"mb-6 md:mb-8",children:o.jsxs("div",{className:"bg-bg-secondary border border-border rounded-lg overflow-hidden",children:[o.jsxs("div",{className:"p-3 md:p-4 border-b border-border flex items-center justify-between gap-2",children:[o.jsxs(An,{href:`/p/${g.id}`,className:"flex items-center gap-2 cursor-pointer hover:opacity-80 transition-opacity flex-1",children:[o.jsx("svg",{className:"w-5 h-5 text-accent-primary flex-shrink-0",fill:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{d:"M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"})}),o.jsx("span",{className:"text-text-primary font-semibold",children:g.name})]}),o.jsx(An,{href:`/p/${g.id}/new`,className:"rounded font-medium transition-colors bg-accent-primary/25 text-white hover:bg-accent-primary/40 px-1.5 py-1 text-xs",children:"+ New Session"})]}),o.jsx("div",{className:"divide-y divide-border",children:m.length>0?m.map(x=>{const S=s.find(C=>x.workdir.startsWith(C.workdir)),k=S?`/p/${S.id}/s/${x.id}`:"#";return o.jsx(An,{href:k,className:"block p-3 md:p-4 hover:bg-bg-tertiary/50 cursor-pointer transition-colors",children:o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:o.jsx("div",{className:"flex-1 min-w-0",children:o.jsx("div",{className:"text-sm text-text-muted truncate",children:x.title??x.id.slice(0,8)})})}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[o.jsx("span",{className:"text-text-muted text-xs",children:AS(x.updatedAt)}),o.jsxs("span",{className:"text-text-muted text-xs",children:[x.messageCount," msgs"]})]})]})},x.id)}):o.jsx("div",{className:"p-3 md:p-4 text-text-muted text-sm",children:"No sessions yet"})})]})},g.id)}),l.length===0&&o.jsx("div",{className:"text-center py-12 text-text-muted",children:"No projects yet. Open a project to get started."})]}),e&&o.jsx(WS,{isOpen:e,onClose:()=>r(!1)})]})}function VS(){const[,e]=hh("/p/:projectId/new"),[,r]=ar(),i=e==null?void 0:e.projectId,s=Ee(c=>c.createSession);return P.useEffect(()=>{i&&(async()=>{const u=await s(i);r(u?`/p/${i}/s/${u.id}`:`/p/${i}`)})()},[i,s,r]),o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Hl,{})})}function YS(){const e=Ut(r=>r.currentProject);return o.jsx("div",{className:"h-full flex flex-col items-center justify-center p-8 text-center",children:o.jsxs("div",{className:"max-w-md",children:[o.jsx("h2",{className:"text-xl font-semibold text-text-primary mb-2",children:(e==null?void 0:e.name)??"Project"}),o.jsx("p",{className:"text-text-secondary mb-6",children:"No session selected"}),o.jsxs("div",{className:"flex flex-col gap-3",children:[e&&o.jsx(An,{href:`/p/${e.id}/new`,className:"block w-full rounded font-medium transition-colors bg-accent-primary/25 text-white hover:bg-accent-primary/40 px-3 py-2 text-center",children:"Create New Session"}),o.jsx("p",{className:"text-sm text-text-muted",children:"Or select an existing session from the sidebar"})]})]})})}const Na=e=>Math.round(e*10)/10;function Vd(e){return{providerId:e.providerId,providerName:e.providerName,backend:e.backend,model:e.model}}function KS(e){return`${e.providerId}::${e.model}`}function XS(e){return`${e.providerName} > ${e.model}`}function kx(e){let r=0,i=0,s=0,c=0,u=0,p=0;const l=[],h=[];let f=0;for(const[x,S]of e.entries()){const k=S.stats,C=Vd(k);r+=k.totalTime,i+=k.toolTime,s+=k.prefillTokens,c+=k.generationTokens;const b=k.prefillSpeed>0?k.prefillTokens/k.prefillSpeed:0,y=k.generationSpeed>0?k.generationTokens/k.generationSpeed:0;u+=b,p+=y,l.push({messageId:S.id,timestamp:S.timestamp,...C,mode:k.mode,responseIndex:x+1,prefillTokens:k.prefillTokens,generationTokens:k.generationTokens,prefillSpeed:k.prefillSpeed,generationSpeed:k.generationSpeed,totalTime:k.totalTime,aiTime:k.totalTime-k.toolTime,toolTime:k.toolTime});const v=k.llmCalls??[];for(const _ of v)f+=1,h.push({messageId:S.id,timestamp:_.timestamp??S.timestamp,providerId:_.providerId,providerName:_.providerName,backend:_.backend,model:_.model,mode:k.mode,responseIndex:x+1,sessionCallIndex:f,callIndex:_.callIndex,promptTokens:_.promptTokens,completionTokens:_.completionTokens,ttft:_.ttft,completionTime:_.completionTime,prefillSpeed:_.prefillSpeed,generationSpeed:_.generationSpeed,totalTime:_.totalTime})}const g=u>0?Na(s/u):0,m=p>0?Na(c/p):0;return{totalTime:Na(r),aiTime:Na(r-i),toolTime:Na(i),prefillTokens:s,generationTokens:c,avgPrefillSpeed:g,avgGenerationSpeed:m,responseCount:e.length,llmCallCount:h.length,dataPoints:l,callDataPoints:h}}function ZS(e){const r=e.filter(c=>c.stats!==void 0&&c.stats!==null).sort((c,u)=>new Date(c.timestamp).getTime()-new Date(u.timestamp).getTime());if(r.length===0)return null;const i=new Map;for(const c of r){const u=KS(Vd(c.stats)),p=i.get(u)??[];i.set(u,[...p,c])}const s=Array.from(i.entries()).map(([c,u])=>{const p=Vd(u[0].stats),l=kx(u);return{...p,key:c,label:XS(p),...l}});return{...kx(r),modelGroups:s}}function QS(e){return P.useMemo(()=>ZS(e),[e])}function JS(e){const[r,i]=P.useState(null),[s,c]=P.useState(!0),[u,p]=P.useState(null),l=e||"";return P.useEffect(()=>{if(!l){c(!1);return}let h=!0,f=null;const g=async()=>{try{const x=await(await ye(`/api/branch?workdir=${encodeURIComponent(l)}`)).json();h&&(i(x.branch),p(x.error||null),c(!1))}catch(m){h&&(p(m instanceof Error?m.message:"Failed to fetch branch"),c(!1))}};return g(),f=setInterval(g,3e3),()=>{h=!1,f&&clearInterval(f)}},[l]),{branch:r,loading:s,error:u}}function Ex(e){return e.toLocaleString("en-US").replace(/,/g," ")}function jx(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function ew(e){if(e<60)return`${e.toFixed(1)}s`;const r=Math.floor(e/60),i=Math.round(e%60);return`${r}m${i}s`}const tw="modulepreload",nw=function(e){return"/"+e},Nx={},rw=function(r,i,s){let c=Promise.resolve();if(i&&i.length>0){let p=function(f){return Promise.all(f.map(g=>Promise.resolve(g).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),h=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));c=p(i.map(f=>{if(f=nw(f),f in Nx)return;Nx[f]=!0;const g=f.endsWith(".css"),m=g?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${m}`))return;const x=document.createElement("link");if(x.rel=g?"stylesheet":tw,g||(x.as="script"),x.crossOrigin="",x.href=f,h&&x.setAttribute("nonce",h),document.head.appendChild(x),g)return new Promise((S,k)=>{x.addEventListener("load",S),x.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${f}`)))})}))}function u(p){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=p,window.dispatchEvent(l),!l.defaultPrevented)throw p}return c.then(p=>{for(const l of p||[])l.status==="rejected"&&u(l.reason);return r().catch(u)})},Tx=["▁","▂","▃","▄","▅","▆","▇","█"];function iw(e,r,i){if(i===r)return 4;const s=(e-r)/(i-r);return Math.min(7,Math.max(0,Math.round(s*7)))}function sw(e,r){if(e===r){const c=Math.max(Math.abs(e)*.05,1);return{minY:e-c,maxY:r+c}}const i=r-e,s=Math.max(i*.1,.1);return{minY:e-s,maxY:r+s}}function aw(e,r){if(e.length===0||r<=0)return{blocks:"",minX:0,maxX:0,minY:0,maxY:0};const i=[...e].sort((m,x)=>m.x-x.x),s=i[0].x,c=i[i.length-1].x,u=Math.min(...i.map(m=>m.y)),p=Math.max(...i.map(m=>m.y)),{minY:l,maxY:h}=sw(u,p),f=Array.from({length:r},()=>" "),g=new Map;for(const m of i){const x=c===s?0:Math.round((m.x-s)/(c-s)*(r-1)),S=g.get(x)??[];g.set(x,[...S,m.y])}for(const[m,x]of g){const S=Math.max(...x);f[m]=Tx[iw(S,l,h)]??Tx[0]}return{blocks:f.join(""),minX:s,maxX:c,minY:l,maxY:h}}function Ax(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function Dx({data:e,width:r=60,height:i=78,label:s,xLabel:c,yLabel:u,showAxes:p=!0,formatY:l=Ax,formatX:h=Ax}){const f=P.useMemo(()=>{const g=aw(e,r),m=Math.max(r*6,240),x=10,S=8,C=[...e].sort((_,j)=>_.x-j.x).map(_=>{const j=g.maxX===g.minX?m/2:x+(_.x-g.minX)/(g.maxX-g.minX)*(m-x*2),A=g.maxY===g.minY?i/2:S+(g.maxY-_.y)/(g.maxY-g.minY)*(i-S*2);return{..._,cx:j,cy:A,leftPercent:j/m*100,topPercent:A/i*100}}),b=C.map((_,j)=>`${j===0?"M":"L"} ${_.cx.toFixed(1)} ${_.cy.toFixed(1)}`).join(" "),v=[g.maxY,(g.maxY+g.minY)/2,g.minY].map(_=>({value:_,y:g.maxY===g.minY?i/2:S+(g.maxY-_)/(g.maxY-g.minY)*(i-S*2)}));return{...g,chartWidth:m,points:C,path:b,gridLines:v}},[e,i,r]);return e.length===0?o.jsxs("div",{className:"font-mono text-text-muted text-xs",children:[s&&o.jsx("div",{className:"mb-1",children:s}),o.jsx("div",{children:"No data"})]}):o.jsxs("div",{className:"font-mono text-xs",children:[s&&o.jsx("div",{className:"text-text-secondary mb-2",children:s}),o.jsxs("div",{className:"flex gap-3",children:[p&&o.jsx("div",{className:"w-12 h-[78px] flex flex-col justify-between text-right text-text-muted",children:f.gridLines.map(g=>o.jsx("span",{children:l(g.value)},`${g.value}-${g.y}`))}),o.jsx("div",{className:"flex-1 min-w-0",children:o.jsxs("div",{className:"relative h-[78px]",children:[o.jsxs("svg",{viewBox:`0 0 ${f.chartWidth} ${i}`,className:"w-full h-[78px] overflow-visible",preserveAspectRatio:"none","aria-hidden":"true",children:[f.gridLines.map(g=>o.jsx("line",{x1:"0",x2:f.chartWidth,y1:g.y,y2:g.y,stroke:"currentColor",strokeDasharray:"3 4",className:"text-border/60"},`grid-${g.y}`)),f.points.map(g=>o.jsx("line",{x1:g.cx,x2:g.cx,y1:i-4,y2:g.cy,stroke:"currentColor",className:"text-border/40"},`guide-${g.cx}-${g.cy}`)),f.points.length>1&&o.jsx("path",{d:f.path,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-accent-primary/45"})]}),f.points.map(g=>o.jsx("div",{className:"absolute -translate-x-1/2 -translate-y-1/2",style:{left:`${g.leftPercent}%`,top:`${g.topPercent}%`},title:`${h(g.x)} -> ${l(g.y)}`,children:o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-accent-primary/20 flex items-center justify-center",children:o.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-accent-primary"})})},`point-${g.x}-${g.y}`))]})})]}),p&&o.jsxs("div",{className:"flex items-start gap-3 text-text-muted mt-1",children:[o.jsx("span",{className:"w-12"}),o.jsxs("span",{className:"flex-1 flex justify-between",children:[o.jsx("span",{children:h(f.minX)}),o.jsx("span",{children:c}),o.jsx("span",{children:h(f.maxX)})]})]}),u&&p&&o.jsx("div",{className:"text-text-muted mt-1 text-center",children:u})]})}function ow({data:e,prefillLabel:r="Prefill Speed (tok/s) by Response",generationLabel:i="Generation Speed (tok/s) by Response",xLabel:s="response",width:c=60}){const u=e.map(l=>({x:l.x,y:l.ppSpeed})),p=e.map(l=>({x:l.x,y:l.tgSpeed}));return o.jsxs("div",{className:"space-y-5",children:[o.jsx(Dx,{data:u,width:c,label:r,xLabel:s}),o.jsx(Dx,{data:p,width:c,label:i,xLabel:s})]})}function lw(e){const r=new Map;for(const i of e.callDataPoints){const s=r.get(i.messageId)??[];r.set(i.messageId,[...s,i])}return e.dataPoints.map(i=>{const s=[...r.get(i.messageId)??[]].sort((c,u)=>c.callIndex-u.callIndex);return{...i,callCount:s.length,calls:s,isExpandable:s.length>1}})}function cw(e){return{mode:"responses",xLabel:"response",prefillLabel:"Prefill Speed (tok/s) by Response",generationLabel:"Generation Speed (tok/s) by Response",points:e.dataPoints.map(r=>({x:r.responseIndex,ppSpeed:r.prefillSpeed,tgSpeed:r.generationSpeed}))}}function uw(e){return{mode:"calls",xLabel:"context",prefillLabel:"Prefill Speed (tok/s) vs Context",generationLabel:"Generation Speed (tok/s) vs Context",points:e.callDataPoints.map(r=>({x:r.promptTokens,ppSpeed:r.prefillSpeed,tgSpeed:r.generationSpeed}))}}function dw(e){return e.callDataPoints.length>0?uw(e):cw(e)}function Sd(e){if(e<60)return`${e.toFixed(1)}s`;const r=Math.floor(e/60),i=e%60;return`${r}m ${i.toFixed(0)}s`}function ji(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toString()}function Ma(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function hw(e){if(e.length===0)return"0 ctx";const r=Math.min(...e),i=Math.max(...e);return r===i?`${ji(r)} ctx`:`${ji(r)}-${ji(i)} ctx`}function Tl(e){return`${Ma(e)} t/s`}function pb(e){try{return new Date(e).toLocaleTimeString("en-US",{hour12:!1})}catch{return e}}function fw(e){return{exportedAt:new Date().toISOString(),providerId:e.providerId,providerName:e.providerName,backend:e.backend,model:e.model,label:e.label,summary:{totalTime:e.totalTime,aiTime:e.aiTime,toolTime:e.toolTime,prefillTokens:e.prefillTokens,generationTokens:e.generationTokens,avgPrefillSpeed:e.avgPrefillSpeed,avgGenerationSpeed:e.avgGenerationSpeed,responseCount:e.responseCount,llmCallCount:e.llmCallCount},responses:e.dataPoints.map(r=>({responseIndex:r.responseIndex,timestamp:r.timestamp,mode:r.mode,prefillTokens:r.prefillTokens,generationTokens:r.generationTokens,prefillSpeed:r.prefillSpeed,generationSpeed:r.generationSpeed,totalTime:r.totalTime,aiTime:r.aiTime,toolTime:r.toolTime})),llmCalls:e.callDataPoints.map(r=>({sessionCallIndex:r.sessionCallIndex,responseIndex:r.responseIndex,callIndex:r.callIndex,timestamp:r.timestamp,mode:r.mode,promptTokens:r.promptTokens,completionTokens:r.completionTokens,ttft:r.ttft,completionTime:r.completionTime,prefillSpeed:r.prefillSpeed,generationSpeed:r.generationSpeed,totalTime:r.totalTime}))}}function pw({isOpen:e,onClose:r,stats:i}){const s=P.useRef(null),[c,u]=P.useState({}),[p,l]=P.useState(()=>{var k;return((k=i.modelGroups[0])==null?void 0:k.key)??""});P.useEffect(()=>{var k;i.modelGroups.some(C=>C.key===p)||l(((k=i.modelGroups[0])==null?void 0:k.key)??"")},[p,i.modelGroups]);const h=P.useMemo(()=>i.modelGroups.find(k=>k.key===p)??i.modelGroups[0],[p,i.modelGroups]),f=P.useMemo(()=>h?lw(h):[],[h]),g=P.useMemo(()=>h?dw(h):{mode:"responses",xLabel:"response",prefillLabel:"",generationLabel:"",points:[]},[h]),m=P.useCallback(k=>{u(C=>({...C,[k]:!C[k]}))},[]),x=P.useCallback(()=>{if(!h)return;const k=fw(h);navigator.clipboard.writeText(JSON.stringify(k,null,2)).catch(C=>console.error("Failed to copy:",C))},[h]),S=P.useCallback(async()=>{if(s.current)try{const k=(await rw(async()=>{const{default:y}=await import("./html2canvas.esm-QH1iLAAe.js");return{default:y}},[])).default,C=await k(s.current,{backgroundColor:"#1a1a1a",scale:2}),b=document.createElement("a");b.download=`openfox-stats-${new Date().toISOString().slice(0,10)}.png`,b.href=C.toDataURL("image/png"),b.click()}catch(k){console.error("Failed to export PNG:",k),x()}},[x]);return o.jsx(un,{isOpen:e,onClose:r,title:"Session Stats",size:"lg",children:o.jsxs("div",{ref:s,className:"space-y-6",children:[o.jsx("section",{children:o.jsx("div",{className:"flex flex-wrap gap-2",children:i.modelGroups.map(k=>o.jsx("button",{onClick:()=>l(k.key),className:`px-3 py-1.5 rounded border text-xs transition-colors ${k.key===(h==null?void 0:h.key)?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border text-text-muted hover:text-text-primary hover:bg-bg-tertiary/40"}`,title:k.label,children:k.label},k.key))})}),h&&o.jsxs("section",{children:[o.jsx("h3",{className:"text-sm font-semibold text-text-secondary mb-3 uppercase tracking-wide",children:"Summary"}),o.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[o.jsx(Er,{label:"AI Time",value:Sd(h.aiTime)}),o.jsx(Er,{label:"Total Time",value:Sd(h.totalTime)}),o.jsx(Er,{label:"Tool Time",value:Sd(h.toolTime)}),o.jsx(Er,{label:"Responses",value:h.responseCount.toString()}),o.jsx(Er,{label:"LLM Calls",value:h.llmCallCount.toString()})]}),o.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mt-3",children:[o.jsx(Er,{label:"Prefill Tokens",value:ji(h.prefillTokens),subValue:`@ ${Ma(h.avgPrefillSpeed)} tok/s`}),o.jsx(Er,{label:"Gen Tokens",value:ji(h.generationTokens),subValue:`@ ${Ma(h.avgGenerationSpeed)} tok/s`}),o.jsx(Er,{label:"Avg PP Speed",value:`${Ma(h.avgPrefillSpeed)}`,subValue:"tok/s"}),o.jsx(Er,{label:"Avg TG Speed",value:`${Ma(h.avgGenerationSpeed)}`,subValue:"tok/s"})]})]}),h&&g.points.length>1&&o.jsxs("section",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-3",children:[o.jsx("h3",{className:"text-sm font-semibold text-text-secondary uppercase tracking-wide",children:"Performance Progression"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{onClick:x,className:"px-2 py-1 text-xs text-text-muted hover:text-text-primary hover:bg-bg-tertiary rounded transition-colors",children:"Copy JSON"}),o.jsx("button",{onClick:S,className:"px-2 py-1 text-xs text-text-muted hover:text-text-primary hover:bg-bg-tertiary rounded transition-colors",children:"Save PNG"})]})]}),o.jsx("div",{className:"bg-bg-tertiary/50 rounded p-4",children:o.jsx(ow,{data:g.points,width:50,prefillLabel:g.prefillLabel,generationLabel:g.generationLabel,xLabel:g.xLabel})})]}),h&&o.jsxs("section",{children:[o.jsxs("h3",{className:"text-sm font-semibold text-text-secondary mb-3 uppercase tracking-wide",children:["Response Log (",h.responseCount," responses)"]}),o.jsx("div",{className:"overflow-y-auto bg-bg-tertiary/30 rounded",children:o.jsxs("table",{className:"w-full table-fixed border-separate border-spacing-0 text-xs",children:[o.jsxs("colgroup",{children:[o.jsx("col",{className:"w-[7%]"}),o.jsx("col",{className:"w-[14%]"}),o.jsx("col",{className:"w-[10%]"}),o.jsx("col",{className:"w-[14%]"}),o.jsx("col",{className:"w-[14%]"}),o.jsx("col",{className:"w-[14%]"}),o.jsx("col",{className:"w-[11%]"}),o.jsx("col",{className:"w-[2%]"})]}),o.jsx("thead",{children:o.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-text-muted/80",children:[o.jsx("th",{className:"px-3 py-2 text-center font-medium",children:"#"}),o.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"At"}),o.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Time"}),o.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Context"}),o.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"PP t/s"}),o.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"TG t/s"}),o.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Calls"}),o.jsx("th",{className:"px-2 py-2"})]})}),o.jsx("tbody",{children:f.map((k,C)=>o.jsxs(P.Fragment,{children:[o.jsx(mw,{row:k,index:C,isExpanded:c[k.messageId]??!1,onToggle:k.isExpandable?()=>m(k.messageId):void 0}),(c[k.messageId]??!1)&&k.calls.map((b,y)=>o.jsx(gw,{dataPoint:b,index:y},`${b.messageId}-${b.callIndex}`))]},k.messageId))})]})})]})]})})}function Er({label:e,value:r,subValue:i}){return o.jsxs("div",{className:"bg-bg-tertiary/50 rounded p-3",children:[o.jsx("div",{className:"text-text-muted text-xs mb-1",children:e}),o.jsx("div",{className:"text-text-primary text-lg font-semibold",children:r}),i&&o.jsx("div",{className:"text-text-muted text-xs",children:i})]})}function mw({row:e,index:r,isExpanded:i,onToggle:s}){const c=e.calls.length>0?hw(e.calls.map(u=>u.promptTokens)):`${ji(e.prefillTokens)} ctx`;return o.jsxs("tr",{onClick:s,className:`${r%2===0?"bg-bg-tertiary/20":""} ${s?"cursor-pointer hover:bg-bg-tertiary/35 transition-colors":""}`,children:[o.jsx("td",{className:"px-3 py-2 text-center text-text-muted align-middle",children:e.responseIndex}),o.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:pb(e.timestamp)}),o.jsxs("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:[e.totalTime.toFixed(1),"s"]}),o.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:c.replace(/ ctx$/,"")}),o.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Tl(e.prefillSpeed)}),o.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Tl(e.generationSpeed)}),o.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:e.callCount}),o.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:e.isExpandable?i?"v":">":""})]})}function gw({dataPoint:e,index:r}){return o.jsxs("tr",{className:`${r%2===0?"bg-bg-tertiary/10":"bg-bg-tertiary/5"}`,children:[o.jsxs("td",{className:"px-3 py-2 pl-6 text-center text-text-muted align-middle border-l border-border/60",children:["c",e.callIndex]}),o.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:pb(e.timestamp)}),o.jsxs("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:[e.totalTime.toFixed(1),"s"]}),o.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:ji(e.promptTokens)}),o.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Tl(e.prefillSpeed)}),o.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Tl(e.generationSpeed)}),o.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:e.callIndex}),o.jsx("td",{className:"px-2 py-2"})]})}const xw={pending:{icon:"○",color:"text-text-muted",label:"Pending"},in_progress:{icon:"●",color:"text-accent-warning",label:"In Progress",animate:!0},completed:{icon:"◉",color:"text-purple-400",label:"Completed"},passed:{icon:"✓",color:"text-accent-success",label:"Passed"},failed:{icon:"✗",color:"text-accent-error",label:"Failed"}},vw=P.memo(function({criteria:r}){if(r.length===0)return o.jsx("div",{className:"text-text-muted text-sm text-center py-2",children:"No criteria yet"});const i={pending:0,in_progress:0,completed:0,passed:0,failed:0};for(const c of r){const u=c.status.type;u in i&&i[u]++}const s=Object.keys(i).filter(c=>i[c]>0);return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[o.jsx("span",{className:"font-semibold text-text-primary",children:"Total:"}),o.jsx("span",{className:"text-text-secondary",children:r.length})]}),o.jsx("div",{className:"space-y-1",children:s.map(c=>{const u=xw[c];return o.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[o.jsx("span",{className:`${u.color} ${u.animate?"animate-pulse":""} text-sm leading-tight`,children:u.icon}),o.jsxs("span",{className:"text-text-muted",children:[u.label,":"]}),o.jsx("span",{className:"text-text-primary font-medium",children:i[c]})]},c)})})]})});function bw({isOpen:e,onClose:r}){const i=rr(S=>S.config),s=rr(S=>S.saveConfig),[c,u]=P.useState(""),[p,l]=P.useState(""),[h,f]=P.useState(!1),[g,m]=P.useState(!1);P.useEffect(()=>{e&&(u((i==null?void 0:i.command)??""),l((i==null?void 0:i.url)??""),f((i==null?void 0:i.hotReload)??!1))},[e,i]);const x=async()=>{!c.trim()||!p.trim()||(m(!0),await s({command:c.trim(),url:p.trim(),hotReload:h}),m(!1),r())};return o.jsx(un,{isOpen:e,onClose:r,title:"Dev Server Config",size:"sm",children:o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Command"}),o.jsx("input",{className:"input w-full",type:"text",value:c,onChange:S=>u(S.target.value),placeholder:"npm run dev"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Dev URL"}),o.jsx("input",{className:"input w-full",type:"text",value:p,onChange:S=>l(S.target.value),placeholder:"http://localhost:3000"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"checkbox",id:"hotReload",checked:h,onChange:S=>f(S.target.checked),className:"rounded border-border bg-bg-tertiary"}),o.jsx("label",{htmlFor:"hotReload",className:"text-xs text-text-secondary",children:"Hot Reload"})]}),o.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[o.jsx("button",{className:"btn btn-secondary",onClick:r,children:"Cancel"}),o.jsx("button",{className:"btn btn-primary",onClick:x,disabled:g||!c.trim()||!p.trim(),children:g?"Saving...":"Save"})]})]})})}const Lx={30:"text-black",31:"text-red-400",32:"text-accent-success",33:"text-accent-warning",34:"text-blue-400",35:"text-purple-400",36:"text-cyan-400",37:"text-gray-300",90:"text-gray-500",91:"text-red-500",92:"text-green-500",93:"text-yellow-400",94:"text-blue-500",95:"text-pink-400",96:"text-cyan-500",97:"text-white"},yw={40:"bg-black",41:"bg-red-900",42:"bg-green-900",43:"bg-yellow-900",44:"bg-blue-900",45:"bg-purple-900",46:"bg-cyan-900",47:"bg-gray-700"},Rx={1:"font-bold",2:"opacity-75",4:"underline",7:"bg-bg-secondary"},_w="text-text-primary";function Sw(e){const r=[],i=/\x1b\[([0-9;]+)m/g;let s=0,c="text-text-primary",u;try{for(;(u=i.exec(e))!==null;){if(u.index>s){const f=e.slice(s,u.index);f&&r.push({text:f,className:c})}const p=u[1];if(!p)continue;const l=p.split(";").map(Number);if(l.length===0||l[0]===0){c="text-text-primary";continue}const h=[];for(const f of l)if(f>=30&&f<=37){const g=Lx[f];g&&h.push(g)}else if(f>=40&&f<=47){const g=yw[f];g&&h.push(g)}else if(f>=90&&f<=97){const g=Lx[f];g&&h.push(g)}else if(f in Rx){const g=Rx[f];g&&h.push(g)}else f===39?h.push(_w):f===49&&(c=c.split(" ").filter(g=>!g.startsWith("bg-")).join(" "));h.length>0&&(c=h.join(" ")),s=i.lastIndex}if(s<e.length){const p=e.slice(s);p&&r.push({text:p,className:c})}return r}catch(p){return console.warn("ANSI parsing failed, stripping codes:",p),[{text:ww(e),className:"text-text-primary"}]}}function ww(e){return e.replace(/\x1b\[([0-9;]+)m/g,"")}function Pa(e){var i,s;const r=Sw(e);return r.length===1&&((i=r[0])==null?void 0:i.className)==="text-text-primary"?(s=r[0])==null?void 0:s.text:r.map((c,u)=>ln.createElement("span",{key:u,className:c.className},c.text))}const Cw=P.memo(function({logs:r,onClose:i}){const s=P.useRef(null);return P.useEffect(()=>{const c=u=>{u.key==="Escape"&&i()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[i]),P.useEffect(()=>{s.current&&(s.current.scrollTop=s.current.scrollHeight)},[r]),o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:i,children:o.jsxs("div",{className:"relative w-[90vw] h-[90vh] bg-bg-primary rounded-lg border border-border flex flex-col",onClick:c=>c.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between p-3 border-b border-border",children:[o.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Dev Server Logs"}),o.jsx("button",{onClick:i,className:"p-1.5 rounded hover:bg-bg-tertiary transition-colors text-text-muted",children:o.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]}),o.jsx("pre",{ref:s,className:"flex-1 overflow-auto p-4 text-sm font-mono text-text-primary",children:r.length===0?o.jsx("span",{className:"text-text-muted",children:"No output yet"}):r.map((c,u)=>o.jsx("span",{className:c.stream==="stderr"?"text-accent-warning":"",children:Pa(c.content)},u))})]})})}),kw=P.memo(function({workdir:r}){const i=rr(_=>_.setWorkdir),s=rr(_=>_.status),c=rr(_=>_.config),u=rr(_=>_.logs),p=rr(_=>_.start),l=rr(_=>_.stop),h=rr(_=>_.fetchLogs),[f,g]=P.useState(!1),[m,x]=P.useState(!1),S=P.useRef(null),k=(s==null?void 0:s.state)??"off",C=c!==null,b=k==="running"||k==="warning";P.useEffect(()=>{i(r??null)},[r,i]),P.useEffect(()=>{b&&h()},[b,h]),P.useEffect(()=>{S.current&&b&&(S.current.scrollTop=S.current.scrollHeight)},[u,b]);const y=()=>{b?l():p()},v=o.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("path",{d:"M8 0a8.2 8.2 0 0 1 .701.031C9.444.095 9.99.645 10.16 1.29l.288 1.107c.018.066.079.158.212.224.231.114.454.243.668.386.123.082.233.09.299.071l1.1-.303c.652-.18 1.37.008 1.755.653a8.043 8.043 0 0 1 .683 1.18c.227.568.096 1.26-.378 1.726l-.812.804a.312.312 0 0 0-.081.283c.024.166.04.335.04.507s-.016.341-.04.507a.312.312 0 0 0 .08.283l.813.804c.474.466.605 1.158.378 1.726a8.07 8.07 0 0 1-.683 1.18c-.385.645-1.103.833-1.755.653l-1.1-.303c-.066-.019-.176-.011-.299.071a5.1 5.1 0 0 1-.668.386c-.133.066-.194.158-.211.224l-.29 1.107c-.168.645-.714 1.196-1.458 1.26a8.094 8.094 0 0 1-1.402 0c-.744-.064-1.29-.615-1.458-1.26l-.29-1.107a.426.426 0 0 0-.211-.224 5.11 5.11 0 0 1-.668-.386c-.123-.082-.233-.09-.299-.071l-1.1.303c-.652.18-1.37-.008-1.755-.653a8.044 8.044 0 0 1-.683-1.18c-.227-.568-.096-1.26.378-1.726l.812-.804a.312.312 0 0 0 .081-.283A5.18 5.18 0 0 1 2.3 8c0-.172.016-.341.04-.507a.312.312 0 0 0-.08-.283l-.813-.804C.973 5.94.842 5.248 1.069 4.68c.181-.452.395-.882.683-1.18.385-.645 1.103-.833 1.755-.653l1.1.303c.066.019.176.011.299-.071.214-.143.437-.272.668-.386a.426.426 0 0 0 .211-.224l.29-1.107C6.009.645 6.556.095 7.299.03 7.53.01 7.764 0 8 0Zm0 5.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5Z"})});return o.jsxs("div",{className:"mt-2 pt-3 border-t border-border space-y-3",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:`inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 ${k==="running"?"bg-accent-success":k==="warning"?"bg-accent-warning":k==="error"?"bg-accent-error":"bg-text-muted"}`}),o.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Dev Server"})]}),o.jsx("button",{onClick:()=>g(!0),className:"p-1.5 rounded hover:bg-bg-tertiary transition-colors text-text-muted",title:"Configure dev server",children:v})]}),C?o.jsxs(o.Fragment,{children:[k==="running"||k==="warning"?o.jsxs("div",{className:"flex gap-2",children:[o.jsxs("button",{onClick:y,className:"flex-1 flex items-center justify-center gap-1.5 rounded font-medium text-sm px-3 py-1.5 bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:[o.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"})}),"Stop"]}),(s==null?void 0:s.url)&&o.jsxs("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",className:"flex-1 flex items-center justify-center gap-1.5 rounded font-medium text-sm px-3 py-1.5 bg-accent-primary/25 text-white hover:bg-accent-primary/40 transition-colors",title:s.url,children:[o.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M6.5 3.5H3a1 1 0 0 0-1 1V13a1 1 0 0 0 1 1h8.5a1 1 0 0 0 1-1V9.5"}),o.jsx("path",{d:"M9.5 2h4.5v4.5"}),o.jsx("path",{d:"M14 2L7.5 8.5"})]}),"Open"]})]}):o.jsx("button",{onClick:y,className:"w-full rounded font-medium text-sm px-3 py-1.5 bg-accent-primary/25 text-white hover:bg-accent-primary/40 transition-colors",children:"Start"}),b&&o.jsxs("div",{className:"relative",children:[o.jsx("pre",{ref:S,className:"text-sm bg-bg-primary p-2 rounded overflow-auto max-h-[200px] border border-border",children:u.length===0?o.jsx("span",{className:"text-text-muted",children:"No output yet"}):u.map((_,j)=>o.jsx("span",{className:_.stream==="stderr"?"text-accent-warning":"",children:Pa(_.content)},j))}),o.jsx("button",{onClick:()=>x(!0),className:"absolute bottom-2 right-2 p-1 rounded bg-bg-tertiary/80 hover:bg-bg-tertiary text-text-muted transition-colors",title:"Expand logs",children:o.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M3 4a1 1 0 011-1h4a1 1 0 010 2H5v3a1 1 0 01-2 0V4zm12-1a1 1 0 00-1 1v3a1 1 0 102 0V5h3a1 1 0 100-2h-4zm-9 12a1 1 0 011 1v3h3a1 1 0 110 2H4a1 1 0 01-1-1v-4a1 1 0 011-1zm12 0a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 110-2h3v-3a1 1 0 011-1z",clipRule:"evenodd"})})})]})]}):o.jsx("button",{onClick:()=>g(!0),className:"w-full rounded font-medium text-sm px-3 py-1.5 bg-bg-tertiary text-text-muted hover:bg-border transition-colors",children:"Configure"}),o.jsx(bw,{isOpen:f,onClose:()=>g(!1)}),m&&o.jsx(Cw,{logs:u,onClose:()=>x(!1)})]})}),Ew=P.memo(function({isOpen:r,onClose:i,processName:s,logs:c}){const u=P.useRef(null);return P.useEffect(()=>{const p=l=>{l.key==="Escape"&&i()};if(r)return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[r,i]),P.useEffect(()=>{u.current&&r&&(u.current.scrollTop=u.current.scrollHeight)},[c,r]),r?o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:i,children:o.jsxs("div",{className:"relative w-[90vw] h-[90vh] bg-bg-primary rounded-lg border border-border flex flex-col",onClick:p=>p.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between p-3 border-b border-border",children:[o.jsx("h3",{className:"text-sm font-semibold text-text-primary truncate",children:s}),o.jsx("button",{onClick:i,className:"p-1.5 rounded hover:bg-bg-tertiary transition-colors text-text-muted",children:o.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]}),o.jsx("pre",{ref:u,className:"flex-1 overflow-auto p-4 text-sm font-mono text-text-primary whitespace-pre-wrap",children:c.length===0?o.jsx("span",{className:"text-text-muted",children:"No output yet"}):c.map((p,l)=>o.jsx("span",{className:p.stream==="stderr"?"text-accent-warning":"",children:Pa(p.content)},l))})]})}):null}),jw=P.memo(function({sessionId:r}){var S;const i=Oa(k=>k.processes),s=Oa(k=>k.stopProcess),[c,u]=P.useState(null),[p,l]=P.useState([]),h=i.filter(k=>k.status!=="exited"),f=h.filter(k=>k.status==="running").length;if(i.length===0)return null;const g=k=>{switch(k){case"running":return"bg-accent-success";case"starting":return"bg-accent-warning";case"stopping":return"bg-accent-warning";case"exited":return"bg-text-muted";default:return"bg-text-muted"}},m=k=>{const C=Oa.getState().logs[k]??[];l(C.map(b=>({content:b.content,stream:b.stream}))),u(k)},x=k=>{r&&s(k,r)};return o.jsxs("div",{className:"mt-2 pt-3 border-t border-border space-y-3",children:[o.jsx("div",{className:"flex items-center justify-between",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 bg-accent-primary"}),o.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Background"}),o.jsxs("span",{className:"text-xs text-text-muted",children:["(",f," running)"]})]})}),o.jsx("div",{className:"space-y-2",children:h.map(k=>o.jsx("div",{className:"border border-border rounded p-2",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[o.jsx("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${g(k.status)}`}),o.jsx("span",{className:"text-sm text-text-primary truncate",title:k.name,children:k.name}),o.jsxs("span",{className:"text-xs text-text-muted",children:["[",k.status,"]"]})]}),o.jsxs("div",{className:"flex gap-1 ml-2",children:[o.jsx("button",{onClick:()=>m(k.id),className:"px-2 py-1 text-xs rounded bg-bg-tertiary hover:bg-border text-text-secondary transition-colors",title:"View logs",children:"Logs"}),o.jsx("button",{onClick:()=>x(k.id),className:"px-2 py-1 text-xs rounded bg-bg-tertiary hover:bg-accent-error/20 text-text-secondary hover:text-accent-error transition-colors",title:"Stop process",children:"Stop"})]})]})},k.id))}),c&&o.jsx(Ew,{isOpen:!!c,onClose:()=>{u(null),l([])},processName:((S=h.find(k=>k.id===c))==null?void 0:S.name)??"",logs:p})]})});function Mx({summary:e,messages:r,workdir:i}){const[s,c]=P.useState(!1),u=QS(r),{branch:p}=JS(i),l=Ee(h=>h.currentSession);return o.jsxs("div",{className:"flex flex-col h-full",children:[u&&o.jsxs("div",{className:"mb-4",children:[o.jsx("button",{onClick:()=>c(!0),className:"w-full flex items-center justify-center px-3 py-2 rounded bg-bg-tertiary hover:bg-bg-secondary transition-colors",title:"View detailed response and call-level stats",children:o.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[o.jsx("span",{className:"text-text-secondary",children:ew(u.aiTime)}),o.jsx("span",{className:"w-px h-3 bg-border"}),o.jsx("span",{className:"text-text-secondary",children:jx(u.avgPrefillSpeed)}),o.jsx("span",{children:"pp"}),o.jsx("span",{className:"w-px h-3 bg-border"}),o.jsx("span",{className:"text-text-secondary",children:jx(u.avgGenerationSpeed)}),o.jsx("span",{children:"tg"})]})}),o.jsx(pw,{isOpen:s,onClose:()=>c(!1),stats:u})]}),o.jsxs("div",{className:"flex flex-col flex-1 overflow-y-auto",children:[o.jsx("div",{className:"flex items-center justify-between mb-2",children:o.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Summary"})}),e?o.jsx("p",{className:"text-sm text-text-primary leading-relaxed",children:e}):o.jsx("div",{className:"text-text-muted text-sm text-center py-2",children:"No summary yet"}),o.jsxs("div",{className:"mt-4",children:[o.jsx("h3",{className:"text-sm font-semibold text-text-primary mb-2",children:"Progress"}),o.jsx(vw,{criteria:(l==null?void 0:l.criteria)??[]})]})]}),p&&o.jsxs("div",{className:"mt-4 flex items-center gap-2 text-sm",children:[o.jsx("svg",{className:"w-4 h-4 flex-shrink-0 text-text-muted",viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("path",{d:"M9.5 3.25a2.25 2.25 0 1 1 3 2.122V6A2.5 2.5 0 0 1 10 8.5H6a1 1 0 0 0-1 1v1.128a2.251 2.251 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.5 0v1.836A2.493 2.493 0 0 1 6 7h4a1 1 0 0 0 1-1v-.628A2.25 2.25 0 0 1 9.5 3.25Zm-6 0a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Zm8.25-.75a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM4.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z"})}),o.jsx("span",{className:"truncate text-text-secondary",title:p,children:p})]}),o.jsx(kw,{workdir:i}),o.jsx(jw,{sessionId:l==null?void 0:l.id})]})}function Nw({children:e,criteriaSidebarOpen:r=!0,onCriteriaSidebarToggle:i,messages:s}){const c=Ee(u=>u.currentSession);return o.jsxs("div",{className:"relative h-full overflow-hidden",children:[r&&o.jsx("div",{className:"fixed md:hidden inset-0 bg-black/50 z-40",onClick:i}),o.jsxs("div",{className:"flex h-full",children:[o.jsx("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden",children:e}),r?o.jsx("aside",{className:"hidden md:block w-[320px] shrink-0 border-l border-border p-4 overflow-y-auto bg-bg-secondary",children:o.jsx(Mx,{summary:(c==null?void 0:c.summary)??null,messages:s,workdir:c==null?void 0:c.workdir})}):o.jsx("aside",{className:"hidden md:block w-0 shrink-0 overflow-hidden border-l-0"}),o.jsx("aside",{className:`
84
+ `,children:[o.jsxs("div",{className:"p-4 border-b border-border flex gap-2",children:[o.jsx(An,{href:`/p/${e}/new`,className:"flex-1 block text-center rounded font-medium transition-colors bg-accent-primary/25 text-white hover:bg-accent-primary/40 px-3 py-1.5 text-sm","data-testid":"sidebar-new-session-button",children:"+ New Session"}),o.jsx(Ya,{items:[{label:"Edit project settings",onClick:()=>u(!0)},{label:"Delete all sessions",onClick:_,danger:!0}],trigger:o.jsx("button",{className:"flex-shrink-0 p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Options",children:o.jsxs("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 24 24",children:[o.jsx("circle",{cx:"12",cy:"5",r:"2"}),o.jsx("circle",{cx:"12",cy:"12",r:"2"}),o.jsx("circle",{cx:"12",cy:"19",r:"2"})]})})}),i&&o.jsx("button",{onClick:i,className:"md:hidden flex-shrink-0 p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Close sidebar",children:o.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),k&&o.jsx(IS,{isOpen:c,onClose:()=>u(!1),project:k}),o.jsx("div",{className:"flex-1 overflow-y-auto",children:y.length===0?o.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:"No sessions"}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"divide-y divide-border",children:zS(y,l,h,v,e)}),S&&o.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:"Loading more..."}),o.jsx("div",{ref:C,className:"h-px"})]})})]})]})}function zS(e,r,i,s,c){const u=db(e);return Array.from(u).map(([p,l])=>{const h=l[0];return h?o.jsxs("div",{children:[o.jsx("div",{className:"px-4 py-2 bg-bg-tertiary/30 text-text-muted text-xs font-medium",children:ub(h.updatedAt)}),l.map(f=>{const g=(r==null?void 0:r.id)===f.id,m=i.includes(f.id),x=f.isRunning;return o.jsx("div",{className:`w-full px-4 py-3 text-left hover:bg-bg-tertiary/50 transition-colors group ${g?"bg-bg-tertiary":""}`,children:o.jsxs(An,{href:`/p/${c}/s/${f.id}`,className:`block ${g?"text-accent-primary":"text-text-primary"} hover:text-accent-primary`,children:[o.jsxs("div",{className:"flex justify-between items-center mb-1",children:[o.jsx("span",{className:`font-medium truncate text-sm ${g?"text-accent-primary":"text-text-primary"}`,children:f.title??f.id.slice(0,6)}),o.jsx(Ya,{items:[{label:"Delete session",onClick:S=>s(f.id,S),danger:!0}],trigger:o.jsx("button",{onClick:S=>S.preventDefault(),className:"p-1.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-all",title:"Options",children:o.jsxs("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 24 24",children:[o.jsx("circle",{cx:"12",cy:"5",r:"2"}),o.jsx("circle",{cx:"12",cy:"12",r:"2"}),o.jsx("circle",{cx:"12",cy:"19",r:"2"})]})})})]}),o.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[x?o.jsxs("svg",{"aria-label":"Session running",className:"w-3 h-3 text-blue-400 animate-spin flex-shrink-0",viewBox:"0 0 24 24",fill:"none",children:[o.jsx("title",{children:"Running"}),o.jsx("circle",{className:"opacity-30",cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"3"}),o.jsx("path",{d:"M21 12a9 9 0 00-9-9",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]}):m&&!g?o.jsx("span",{"aria-label":"Unread activity",title:"Unread activity",className:"w-2 h-2 rounded-full bg-amber-400 flex-shrink-0"}):null,o.jsx("span",{className:"text-text-muted text-xs flex-shrink-0",children:mh(f.updatedAt)}),o.jsxs("span",{className:"text-text-muted text-xs flex-shrink-0",children:[f.messageCount," messages"]})]})]})},f.id)})]},p):null})}const Cx=["⠋","⠙","⠹","⠸","⠼","⠴"];function HS(){var l;const e=Ut(h=>h.currentProject),r=Ee(h=>h.currentSession),i=ab(),s=!1,c=P.useRef(0),u=P.useRef(null);P.useEffect(()=>(i?(u.current=window.setInterval(()=>{c.current=(c.current+1)%Cx.length,p()},150),p()):(u.current&&(clearInterval(u.current),u.current=null),p()),()=>{u.current&&(clearInterval(u.current),u.current=null)}),[i,e,r,s]);const p=()=>{var m;const f=(m=r==null?void 0:r.metadata)==null?void 0:m.title,g=i?`${Cx[c.current]} `:"";e&&f?document.title=`${g}${e.name} - ${f} | OpenFox`:e?document.title=`${g}${e.name} | OpenFox`:document.title=`${g}OpenFox`};return typeof window<"u"&&((l=r==null?void 0:r.metadata)!=null&&l.title)&&window.document.documentElement.setAttribute("data-session-title",r.metadata.title),null}const zl=P.forwardRef(({className:e="",...r},i)=>o.jsx("input",{ref:i,className:`bg-bg-tertiary border border-border rounded px-3 py-2 text-text-primary placeholder-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary ${e}`,...r}));zl.displayName="Input";function PS({isOpen:e,onClose:r,projectName:i,onConfirm:s}){const c=()=>{s(),r()};return o.jsx(un,{isOpen:e,onClose:r,title:"Delete Project",size:"sm",children:o.jsxs("div",{className:"space-y-4",children:[o.jsxs("p",{className:"text-text-secondary",children:["This will permanently delete the project ",o.jsx("span",{className:"font-semibold text-text-primary",children:i})," and all its sessions from OpenFox. The project files on disk will remain untouched."]}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(dt,{variant:"secondary",onClick:r,children:"Cancel"}),o.jsx(dt,{variant:"danger",onClick:c,children:"Delete"})]})]})})}function FS(e){return!e||e.trim()===""?{valid:!1,error:"Project name cannot be empty"}:/^[a-zA-Z0-9._-]+$/.test(e)?{valid:!0}:{valid:!1,error:"Project name can only contain letters, numbers, hyphens, underscores, and dots"}}function US({isOpen:e,onClose:r}){const[,i]=ar(),[s,c]=P.useState(""),[u,p]=P.useState(null),[l,h]=P.useState(!1),[f,g]=P.useState(""),m=P.useRef(null);P.useEffect(()=>{e&&(ye("/api/config").then(C=>C.json()).then(C=>{C.workdir&&g(C.workdir)}),c(""),p(null),h(!1),setTimeout(()=>{var C;(C=m.current)==null||C.focus()},100))},[e]);const x=P.useCallback(async C=>{C.preventDefault();const b=FS(s);if(!b.valid){p(b.error);return}h(!0),p(null);const y=`${f}/${s}`;try{const v=await ye("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s,workdir:y})});if(!v.ok){const A=await v.json().catch(()=>({}));throw new Error(A.error||"Failed to create project")}const j=(await v.json()).project;r(),i(`/p/${j.id}`)}catch(v){p(v instanceof Error?v.message:"Failed to create project"),h(!1)}},[s,i,r,f]),S=P.useCallback(()=>{c(""),p(null),r()},[r]),k=s?`${f}/${s}`:"";return o.jsx(un,{isOpen:e,onClose:S,title:"Create New Project",size:"sm",children:o.jsxs("form",{onSubmit:x,className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{htmlFor:"project-name",className:"block text-sm font-medium text-text-secondary mb-2",children:"Project Name"}),o.jsx(zl,{ref:m,id:"project-name",value:s,onChange:C=>{c(C.target.value),p(null)},placeholder:"my-project",disabled:l,className:"w-full"}),s&&o.jsxs("div",{className:"mt-2 text-xs text-text-muted",children:["Full path: ",o.jsx("span",{className:"font-mono",children:k})]}),u&&o.jsx("div",{className:"mt-3 p-3 bg-accent-error/10 border border-accent-error/30 rounded text-sm text-accent-error",children:u})]}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(dt,{type:"button",variant:"secondary",onClick:S,disabled:l,children:"Cancel"}),o.jsx(dt,{type:"submit",variant:"primary",disabled:l||!s.trim(),className:"min-w-[100px]",children:l?o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsxs("svg",{className:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24",children:[o.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),o.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Creating..."]}):"Create"})]})]})})}const $S={sm:"w-4 h-4",md:"w-8 h-8",lg:"w-12 h-12"};function Hl({size:e="md",className:r=""}){return o.jsx("div",{className:`animate-spin border-2 border-accent-primary border-t-transparent rounded-full ${$S[e]} ${r}`})}function qS({text:e,...r}){return o.jsxs("div",{className:"text-center",children:[o.jsx(Hl,{...r,className:"mx-auto mb-4"}),e&&o.jsx("div",{className:"text-text-secondary",children:e})]})}function fb({onSelect:e,onClose:r,initialPath:i}){const[s,c]=P.useState(null),[u,p]=P.useState(!0),l=P.useCallback(async k=>{p(!0);try{const C=k?`/api/directories?path=${encodeURIComponent(k)}`:"/api/directories",y=await(await ye(C)).json();c(y)}catch(C){console.error("Failed to load directories:",C)}finally{p(!1)}},[]);P.useEffect(()=>{l(i)},[i,l]);const h=k=>{l(k)},f=k=>{e(k)},m=((s==null?void 0:s.current)??"").split("/").filter(Boolean),S=m.map((k,C)=>({name:k,path:"/"+m.slice(0,C+1).join("/")}));return o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50",onClick:r,children:o.jsxs("div",{className:"bg-bg-secondary border border-border rounded-lg w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:k=>k.stopPropagation(),children:[o.jsxs("div",{className:"p-4 border-b border-border flex items-center justify-between",children:[o.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:"Select Folder"}),o.jsx("button",{onClick:r,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary",children:o.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),s&&o.jsx("div",{className:"px-3 py-2 bg-bg-tertiary/30 border-b border-border",children:o.jsxs("div",{className:"flex items-center text-xs overflow-x-auto",children:[S.map((k,C)=>o.jsxs("span",{className:"flex items-center shrink-0",children:[o.jsx("span",{className:"text-text-muted",children:"/"}),o.jsx("button",{onClick:()=>h(k.path),className:`px-1 ${C===S.length-1?"text-accent-primary font-medium":"text-text-secondary hover:text-accent-primary"}`,children:k.name})]},k.path)),S.length===0&&o.jsx("button",{onClick:()=>h("/"),className:"text-text-muted hover:text-accent-primary",children:"/"})]})}),o.jsx("div",{className:"flex-1 overflow-y-auto",children:u?o.jsx("div",{className:"p-8 text-center",children:o.jsx(Hl,{size:"sm"})}):o.jsxs("div",{className:"divide-y divide-border",children:[(s==null?void 0:s.parent)&&o.jsxs("button",{onClick:()=>h(s.parent),className:"w-full p-3 flex items-center gap-3 hover:bg-bg-tertiary/50 text-text-muted",children:[o.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),o.jsx("span",{children:".."})]}),s==null?void 0:s.directories.map(k=>o.jsxs("div",{className:"group flex items-center gap-2 hover:bg-bg-tertiary/50",children:[o.jsxs("button",{onClick:()=>h(k.path),className:"flex-1 p-3 flex items-center gap-3 text-left",children:[o.jsx("svg",{className:"w-5 h-5 text-accent-primary",fill:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{d:"M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"})}),o.jsx("span",{children:k.name})]}),o.jsx("button",{onClick:()=>f(k.path),className:"px-3 py-1 text-xs bg-accent-primary/10 text-accent-primary rounded opacity-0 group-hover:opacity-100 transition-opacity mr-3",children:"Select"})]},k.path)),(s==null?void 0:s.directories.length)===0&&o.jsx("div",{className:"p-8 text-center text-text-muted text-sm",children:"No subdirectories"})]})}),o.jsxs("div",{className:"p-4 border-t border-border space-y-2",children:[(s==null?void 0:s.current)&&o.jsx("button",{onClick:()=>f(s.current),className:"w-full px-4 py-2 bg-accent-primary text-white rounded-lg font-medium hover:bg-accent-primary/90 transition-colors",children:"Select this folder"}),o.jsx("button",{onClick:r,className:"w-full text-center text-text-muted hover:text-text-secondary text-sm",children:"Cancel"})]})]})})}function WS({isOpen:e,onClose:r}){const[,i]=ar(),[s,c]=P.useState(!1),[u,p]=P.useState(""),[l,h]=P.useState(null),[f,g]=P.useState(!1),[m,x]=P.useState(null),S=Ut(R=>R.projects),k=Ut(R=>R.createProject),C=Ut(R=>R.listProjects),b=Ut(R=>R.deleteProject),[y,v]=P.useState(null),[_,j]=P.useState(-1),[A,N]=P.useState(null),[L,T]=P.useState(!1),B=P.useRef([]);P.useEffect(()=>{ye("/api/config").then(R=>R.json()).then(R=>{R.workdir&&x(R.workdir)})},[]);const H=P.useCallback(async R=>{g(!0);try{const D=R?`/api/directories?path=${encodeURIComponent(R)}`:m?`/api/directories?path=${encodeURIComponent(m)}`:"/api/directories",W=await(await ye(D)).json();h(W)}catch(D){console.error("Failed to load directories:",D)}finally{g(!1)}},[m]);P.useEffect(()=>{e&&m&&(H(m),C())},[e,m,H,C]);const q=(l==null?void 0:l.directories.filter(R=>u===""||R.name.toLowerCase().includes(u.toLowerCase())))??[],Y=[...l!=null&&l.parent&&!u?[{type:"parent",path:l.parent,name:".."}]:[],...q.map(R=>({type:"directory",path:R.path,name:R.name}))],V=R=>{i(`/p/${R}`),r()},F=(R,D)=>{D.stopPropagation(),N(R)},I=()=>{A&&(b(A.id),N(null))},$=R=>{const D=R.split("/").filter(Boolean).pop()??"";k(D,R),C(),v(R)};P.useEffect(()=>{if(y){const R=S.find(D=>D.workdir===y);R&&(i(`/p/${R.id}`),r(),v(null))}},[S,y,i,r]),P.useEffect(()=>{j(Y.length>0?0:-1)},[u,Y.length]);const X=R=>{p(""),H(R)},J=P.useCallback(R=>{if(!e)return;if(R.key==="Escape"){r();return}if(!["ArrowDown","ArrowUp","Enter"].includes(R.key))return;const D=document.activeElement;if(!(!D||D.tagName!=="INPUT")){if(R.preventDefault(),R.key==="ArrowDown")j(O=>{const W=O+1;return W>=Y.length?0:W});else if(R.key==="ArrowUp")j(O=>{const W=O-1;return W<0?Y.length-1:W});else if(R.key==="Enter"&&_>=0&&_<Y.length){const O=Y[_];(O==null?void 0:O.type)==="parent"?X(O.path):O&&$(O.path)}}},[e,Y.length,_,X,$,r]);return P.useEffect(()=>{if(e)return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)},[e,J]),P.useEffect(()=>{_>=0&&B.current[_]&&B.current[_].scrollIntoView({behavior:"smooth",block:"nearest"})},[_]),e?o.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50",children:[o.jsxs("div",{className:"bg-bg-secondary border border-border rounded-lg w-full max-w-[90vw] md:max-w-4xl max-h-[90vh] flex flex-col",children:[o.jsxs("div",{className:"p-4 border-b border-border flex items-center justify-between",children:[o.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:"Open Project"}),o.jsx("button",{onClick:r,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",children:o.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),o.jsxs("div",{className:"flex-1 flex overflow-hidden min-h-[400px]",children:[o.jsxs("div",{className:"w-1/2 border-r border-border flex flex-col",children:[o.jsx("div",{className:"p-3 border-b border-border bg-bg-tertiary/30",children:o.jsx("h3",{className:"font-medium text-sm text-text-secondary",children:"Recent Projects"})}),o.jsx("div",{className:"flex-1 overflow-y-auto",children:S.length===0?o.jsx("div",{className:"p-4 text-center text-text-muted text-sm",children:"No recent projects"}):o.jsx("div",{className:"divide-y divide-border",children:S.map(R=>o.jsxs("div",{className:"group flex items-center gap-3 p-3 hover:bg-bg-tertiary/50 transition-colors",children:[o.jsxs("button",{onClick:()=>V(R.id),className:"flex-1 flex items-center gap-3 text-left",children:[o.jsx("svg",{className:"w-5 h-5 text-accent-primary",fill:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{d:"M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"font-medium truncate",children:R.name}),o.jsx("div",{className:"text-xs text-text-muted truncate",children:R.workdir})]})]}),o.jsx("button",{onClick:D=>F(R,D),className:"opacity-0 group-hover:opacity-100 text-accent-error/70 hover:text-accent-error p-1 transition-opacity",title:"Delete project",children:o.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]},R.id))})})]}),o.jsxs("div",{className:"w-1/2 flex flex-col",children:[o.jsxs("div",{className:"p-3 border-b border-border bg-bg-tertiary/30 flex items-center justify-between",children:[o.jsx("h3",{className:"font-medium text-sm text-text-secondary",children:"Browse Projects"}),o.jsx("button",{onClick:()=>T(!0),className:"text-xs text-accent-primary hover:underline",children:"Open in dialog"})]}),o.jsx("div",{className:"p-3 border-b border-border",children:o.jsx(zl,{value:u,onChange:R=>p(R.target.value),placeholder:"Filter directories...",className:"w-full"})}),o.jsx("div",{className:"flex-1 overflow-y-auto",children:f?o.jsx("div",{className:"p-8 text-center text-text-muted",children:o.jsx("div",{className:"animate-spin w-5 h-5 border-2 border-accent-primary border-t-transparent rounded-full mx-auto"})}):Y.length===0?o.jsx("div",{className:"p-8 text-center text-text-muted text-sm",children:u?"No matching directories":"No subdirectories"}):o.jsx("div",{className:"divide-y divide-border",children:Y.map((R,D)=>o.jsxs("button",{ref:O=>{B.current[D]=O},onClick:()=>R.type==="parent"?X(R.path):$(R.path),className:`w-full p-3 flex items-center gap-3 text-left transition-colors ${D===_?"bg-accent-primary/20 text-accent-primary":"hover:bg-bg-tertiary/50"}`,children:[o.jsx("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{d:"M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"})}),o.jsx("span",{className:"flex-1",children:R.name})]},R.path))})})]})]}),o.jsxs("div",{className:"p-4 border-t border-border flex justify-between gap-2",children:[o.jsx(dt,{variant:"secondary",onClick:()=>c(!0),children:"Create Project"}),o.jsx(dt,{variant:"secondary",onClick:r,children:"Cancel"})]})]}),s&&o.jsx(US,{isOpen:s,onClose:()=>c(!1)}),A&&o.jsx(PS,{isOpen:!0,onClose:()=>N(null),projectName:A.name,onConfirm:I}),L&&o.jsx(fb,{initialPath:m??void 0,onSelect:R=>{$(R),T(!1)},onClose:()=>T(!1)})]}):null}function GS(){const[e,r]=P.useState(!1),i=Ee(g=>g.sessions),s=Ut(g=>g.projects),c=Ut(g=>g.listProjects),u=Ee(g=>g.listSessions),p=Ee(g=>g.connectionStatus);P.useEffect(()=>{p==="connected"&&(c(),u())},[p,c,u]);const l=[...s].sort((g,m)=>{const x=i.filter(b=>b.workdir.startsWith(g.workdir)),S=i.filter(b=>b.workdir.startsWith(m.workdir)),k=x.length>0?new Date(x.reduce((b,y)=>new Date(y.updatedAt)>new Date(b.updatedAt)?y:b).updatedAt).getTime():new Date(g.updatedAt).getTime();return(S.length>0?new Date(S.reduce((b,y)=>new Date(y.updatedAt)>new Date(b.updatedAt)?y:b).updatedAt).getTime():new Date(m.updatedAt).getTime())-k}),h=g=>{const m=s.find(x=>x.id===g);return m?i.filter(x=>x.workdir.startsWith(m.workdir)).sort((x,S)=>new Date(S.updatedAt).getTime()-new Date(x.updatedAt).getTime()).slice(0,5):[]},f=()=>{r(!0)};return o.jsxs("div",{className:"flex-1 flex flex-col overflow-y-auto",children:[o.jsxs("div",{className:"max-w-5xl mx-auto w-full p-4 md:p-8",children:[o.jsxs("div",{className:"mb-6 md:mb-8 flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-3xl font-bold text-accent-primary",children:"OpenFox"}),o.jsx("p",{className:"text-text-secondary",children:"Local LLM-powered coding assistant with contract-driven execution"})]}),o.jsx(dt,{variant:"primary",onClick:f,children:"Open Project"})]}),l.map(g=>{const m=h(g.id);return o.jsx("div",{className:"mb-6 md:mb-8",children:o.jsxs("div",{className:"bg-bg-secondary border border-border rounded-lg overflow-hidden",children:[o.jsxs("div",{className:"p-3 md:p-4 border-b border-border flex items-center justify-between gap-2",children:[o.jsxs(An,{href:`/p/${g.id}`,className:"flex items-center gap-2 cursor-pointer hover:opacity-80 transition-opacity flex-1",children:[o.jsx("svg",{className:"w-5 h-5 text-accent-primary flex-shrink-0",fill:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{d:"M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"})}),o.jsx("span",{className:"text-text-primary font-semibold",children:g.name})]}),o.jsx(An,{href:`/p/${g.id}/new`,className:"rounded font-medium transition-colors bg-accent-primary/25 text-white hover:bg-accent-primary/40 px-1.5 py-1 text-xs",children:"+ New Session"})]}),o.jsx("div",{className:"divide-y divide-border",children:m.length>0?m.map(x=>{const S=s.find(C=>x.workdir.startsWith(C.workdir)),k=S?`/p/${S.id}/s/${x.id}`:"#";return o.jsx(An,{href:k,className:"block p-3 md:p-4 hover:bg-bg-tertiary/50 cursor-pointer transition-colors",children:o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:o.jsx("div",{className:"flex-1 min-w-0",children:o.jsx("div",{className:"text-sm text-text-muted truncate",children:x.title??x.id.slice(0,8)})})}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[o.jsx("span",{className:"text-text-muted text-xs",children:AS(x.updatedAt)}),o.jsxs("span",{className:"text-text-muted text-xs",children:[x.messageCount," msgs"]})]})]})},x.id)}):o.jsx("div",{className:"p-3 md:p-4 text-text-muted text-sm",children:"No sessions yet"})})]})},g.id)}),l.length===0&&o.jsx("div",{className:"text-center py-12 text-text-muted",children:"No projects yet. Open a project to get started."})]}),e&&o.jsx(WS,{isOpen:e,onClose:()=>r(!1)})]})}function VS(){const[,e]=hh("/p/:projectId/new"),[,r]=ar(),i=e==null?void 0:e.projectId,s=Ee(c=>c.createSession);return P.useEffect(()=>{i&&(async()=>{const u=await s(i);r(u?`/p/${i}/s/${u.id}`:`/p/${i}`)})()},[i,s,r]),o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Hl,{})})}function YS(){const e=Ut(r=>r.currentProject);return o.jsx("div",{className:"h-full flex flex-col items-center justify-center p-8 text-center",children:o.jsxs("div",{className:"max-w-md",children:[o.jsx("h2",{className:"text-xl font-semibold text-text-primary mb-2",children:(e==null?void 0:e.name)??"Project"}),o.jsx("p",{className:"text-text-secondary mb-6",children:"No session selected"}),o.jsxs("div",{className:"flex flex-col gap-3",children:[e&&o.jsx(An,{href:`/p/${e.id}/new`,className:"block w-full rounded font-medium transition-colors bg-accent-primary/25 text-white hover:bg-accent-primary/40 px-3 py-2 text-center",children:"Create New Session"}),o.jsx("p",{className:"text-sm text-text-muted",children:"Or select an existing session from the sidebar"})]})]})})}const Na=e=>Math.round(e*10)/10;function Vd(e){return{providerId:e.providerId,providerName:e.providerName,backend:e.backend,model:e.model}}function KS(e){return`${e.providerId}::${e.model}`}function XS(e){return`${e.providerName} > ${e.model}`}function kx(e){let r=0,i=0,s=0,c=0,u=0,p=0;const l=[],h=[];let f=0;for(const[x,S]of e.entries()){const k=S.stats,C=Vd(k);r+=k.totalTime,i+=k.toolTime,s+=k.prefillTokens,c+=k.generationTokens;const b=k.prefillSpeed>0?k.prefillTokens/k.prefillSpeed:0,y=k.generationSpeed>0?k.generationTokens/k.generationSpeed:0;u+=b,p+=y,l.push({messageId:S.id,timestamp:S.timestamp,...C,mode:k.mode,responseIndex:x+1,prefillTokens:k.prefillTokens,generationTokens:k.generationTokens,prefillSpeed:k.prefillSpeed,generationSpeed:k.generationSpeed,totalTime:k.totalTime,aiTime:k.totalTime-k.toolTime,toolTime:k.toolTime});const v=k.llmCalls??[];for(const _ of v)f+=1,h.push({messageId:S.id,timestamp:_.timestamp??S.timestamp,providerId:_.providerId,providerName:_.providerName,backend:_.backend,model:_.model,mode:k.mode,responseIndex:x+1,sessionCallIndex:f,callIndex:_.callIndex,promptTokens:_.promptTokens,completionTokens:_.completionTokens,ttft:_.ttft,completionTime:_.completionTime,prefillSpeed:_.prefillSpeed,generationSpeed:_.generationSpeed,totalTime:_.totalTime})}const g=u>0?Na(s/u):0,m=p>0?Na(c/p):0;return{totalTime:Na(r),aiTime:Na(r-i),toolTime:Na(i),prefillTokens:s,generationTokens:c,avgPrefillSpeed:g,avgGenerationSpeed:m,responseCount:e.length,llmCallCount:h.length,dataPoints:l,callDataPoints:h}}function ZS(e){const r=e.filter(c=>c.stats!==void 0&&c.stats!==null).sort((c,u)=>new Date(c.timestamp).getTime()-new Date(u.timestamp).getTime());if(r.length===0)return null;const i=new Map;for(const c of r){const u=KS(Vd(c.stats)),p=i.get(u)??[];i.set(u,[...p,c])}const s=Array.from(i.entries()).map(([c,u])=>{const p=Vd(u[0].stats),l=kx(u);return{...p,key:c,label:XS(p),...l}});return{...kx(r),modelGroups:s}}function QS(e){return P.useMemo(()=>ZS(e),[e])}function JS(e){const[r,i]=P.useState(null),[s,c]=P.useState(!0),[u,p]=P.useState(null),l=e||"";return P.useEffect(()=>{if(!l){c(!1);return}let h=!0,f=null;const g=async()=>{try{const x=await(await ye(`/api/branch?workdir=${encodeURIComponent(l)}`)).json();h&&(i(x.branch),p(x.error||null),c(!1))}catch(m){h&&(p(m instanceof Error?m.message:"Failed to fetch branch"),c(!1))}};return g(),f=setInterval(g,3e3),()=>{h=!1,f&&clearInterval(f)}},[l]),{branch:r,loading:s,error:u}}function Ex(e){return e.toLocaleString("en-US").replace(/,/g," ")}function jx(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function ew(e){if(e<60)return`${e.toFixed(1)}s`;const r=Math.floor(e/60),i=Math.round(e%60);return`${r}m${i}s`}const tw="modulepreload",nw=function(e){return"/"+e},Nx={},rw=function(r,i,s){let c=Promise.resolve();if(i&&i.length>0){let p=function(f){return Promise.all(f.map(g=>Promise.resolve(g).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),h=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));c=p(i.map(f=>{if(f=nw(f),f in Nx)return;Nx[f]=!0;const g=f.endsWith(".css"),m=g?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${m}`))return;const x=document.createElement("link");if(x.rel=g?"stylesheet":tw,g||(x.as="script"),x.crossOrigin="",x.href=f,h&&x.setAttribute("nonce",h),document.head.appendChild(x),g)return new Promise((S,k)=>{x.addEventListener("load",S),x.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${f}`)))})}))}function u(p){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=p,window.dispatchEvent(l),!l.defaultPrevented)throw p}return c.then(p=>{for(const l of p||[])l.status==="rejected"&&u(l.reason);return r().catch(u)})},Tx=["▁","▂","▃","▄","▅","▆","▇","█"];function iw(e,r,i){if(i===r)return 4;const s=(e-r)/(i-r);return Math.min(7,Math.max(0,Math.round(s*7)))}function sw(e,r){if(e===r){const c=Math.max(Math.abs(e)*.05,1);return{minY:e-c,maxY:r+c}}const i=r-e,s=Math.max(i*.1,.1);return{minY:e-s,maxY:r+s}}function aw(e,r){if(e.length===0||r<=0)return{blocks:"",minX:0,maxX:0,minY:0,maxY:0};const i=[...e].sort((m,x)=>m.x-x.x),s=i[0].x,c=i[i.length-1].x,u=Math.min(...i.map(m=>m.y)),p=Math.max(...i.map(m=>m.y)),{minY:l,maxY:h}=sw(u,p),f=Array.from({length:r},()=>" "),g=new Map;for(const m of i){const x=c===s?0:Math.round((m.x-s)/(c-s)*(r-1)),S=g.get(x)??[];g.set(x,[...S,m.y])}for(const[m,x]of g){const S=Math.max(...x);f[m]=Tx[iw(S,l,h)]??Tx[0]}return{blocks:f.join(""),minX:s,maxX:c,minY:l,maxY:h}}function Ax(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function Dx({data:e,width:r=60,height:i=78,label:s,xLabel:c,yLabel:u,showAxes:p=!0,formatY:l=Ax,formatX:h=Ax}){const f=P.useMemo(()=>{const g=aw(e,r),m=Math.max(r*6,240),x=10,S=8,C=[...e].sort((_,j)=>_.x-j.x).map(_=>{const j=g.maxX===g.minX?m/2:x+(_.x-g.minX)/(g.maxX-g.minX)*(m-x*2),A=g.maxY===g.minY?i/2:S+(g.maxY-_.y)/(g.maxY-g.minY)*(i-S*2);return{..._,cx:j,cy:A,leftPercent:j/m*100,topPercent:A/i*100}}),b=C.map((_,j)=>`${j===0?"M":"L"} ${_.cx.toFixed(1)} ${_.cy.toFixed(1)}`).join(" "),v=[g.maxY,(g.maxY+g.minY)/2,g.minY].map(_=>({value:_,y:g.maxY===g.minY?i/2:S+(g.maxY-_)/(g.maxY-g.minY)*(i-S*2)}));return{...g,chartWidth:m,points:C,path:b,gridLines:v}},[e,i,r]);return e.length===0?o.jsxs("div",{className:"font-mono text-text-muted text-xs",children:[s&&o.jsx("div",{className:"mb-1",children:s}),o.jsx("div",{children:"No data"})]}):o.jsxs("div",{className:"font-mono text-xs",children:[s&&o.jsx("div",{className:"text-text-secondary mb-2",children:s}),o.jsxs("div",{className:"flex gap-3",children:[p&&o.jsx("div",{className:"w-12 h-[78px] flex flex-col justify-between text-right text-text-muted",children:f.gridLines.map(g=>o.jsx("span",{children:l(g.value)},`${g.value}-${g.y}`))}),o.jsx("div",{className:"flex-1 min-w-0",children:o.jsxs("div",{className:"relative h-[78px]",children:[o.jsxs("svg",{viewBox:`0 0 ${f.chartWidth} ${i}`,className:"w-full h-[78px] overflow-visible",preserveAspectRatio:"none","aria-hidden":"true",children:[f.gridLines.map(g=>o.jsx("line",{x1:"0",x2:f.chartWidth,y1:g.y,y2:g.y,stroke:"currentColor",strokeDasharray:"3 4",className:"text-border/60"},`grid-${g.y}`)),f.points.map(g=>o.jsx("line",{x1:g.cx,x2:g.cx,y1:i-4,y2:g.cy,stroke:"currentColor",className:"text-border/40"},`guide-${g.cx}-${g.cy}`)),f.points.length>1&&o.jsx("path",{d:f.path,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-accent-primary/45"})]}),f.points.map(g=>o.jsx("div",{className:"absolute -translate-x-1/2 -translate-y-1/2",style:{left:`${g.leftPercent}%`,top:`${g.topPercent}%`},title:`${h(g.x)} -> ${l(g.y)}`,children:o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-accent-primary/20 flex items-center justify-center",children:o.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-accent-primary"})})},`point-${g.x}-${g.y}`))]})})]}),p&&o.jsxs("div",{className:"flex items-start gap-3 text-text-muted mt-1",children:[o.jsx("span",{className:"w-12"}),o.jsxs("span",{className:"flex-1 flex justify-between",children:[o.jsx("span",{children:h(f.minX)}),o.jsx("span",{children:c}),o.jsx("span",{children:h(f.maxX)})]})]}),u&&p&&o.jsx("div",{className:"text-text-muted mt-1 text-center",children:u})]})}function ow({data:e,prefillLabel:r="Prefill Speed (tok/s) by Response",generationLabel:i="Generation Speed (tok/s) by Response",xLabel:s="response",width:c=60}){const u=e.map(l=>({x:l.x,y:l.ppSpeed})),p=e.map(l=>({x:l.x,y:l.tgSpeed}));return o.jsxs("div",{className:"space-y-5",children:[o.jsx(Dx,{data:u,width:c,label:r,xLabel:s}),o.jsx(Dx,{data:p,width:c,label:i,xLabel:s})]})}function lw(e){const r=new Map;for(const i of e.callDataPoints){const s=r.get(i.messageId)??[];r.set(i.messageId,[...s,i])}return e.dataPoints.map(i=>{const s=[...r.get(i.messageId)??[]].sort((c,u)=>c.callIndex-u.callIndex);return{...i,callCount:s.length,calls:s,isExpandable:s.length>1}})}function cw(e){return{mode:"responses",xLabel:"response",prefillLabel:"Prefill Speed (tok/s) by Response",generationLabel:"Generation Speed (tok/s) by Response",points:e.dataPoints.map(r=>({x:r.responseIndex,ppSpeed:r.prefillSpeed,tgSpeed:r.generationSpeed}))}}function uw(e){return{mode:"calls",xLabel:"context",prefillLabel:"Prefill Speed (tok/s) vs Context",generationLabel:"Generation Speed (tok/s) vs Context",points:e.callDataPoints.map(r=>({x:r.promptTokens,ppSpeed:r.prefillSpeed,tgSpeed:r.generationSpeed}))}}function dw(e){return e.callDataPoints.length>0?uw(e):cw(e)}function Sd(e){if(e<60)return`${e.toFixed(1)}s`;const r=Math.floor(e/60),i=e%60;return`${r}m ${i.toFixed(0)}s`}function ji(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toString()}function Ma(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function hw(e){if(e.length===0)return"0 ctx";const r=Math.min(...e),i=Math.max(...e);return r===i?`${ji(r)} ctx`:`${ji(r)}-${ji(i)} ctx`}function Tl(e){return`${Ma(e)} t/s`}function pb(e){try{return new Date(e).toLocaleTimeString("en-US",{hour12:!1})}catch{return e}}function fw(e){return{exportedAt:new Date().toISOString(),providerId:e.providerId,providerName:e.providerName,backend:e.backend,model:e.model,label:e.label,summary:{totalTime:e.totalTime,aiTime:e.aiTime,toolTime:e.toolTime,prefillTokens:e.prefillTokens,generationTokens:e.generationTokens,avgPrefillSpeed:e.avgPrefillSpeed,avgGenerationSpeed:e.avgGenerationSpeed,responseCount:e.responseCount,llmCallCount:e.llmCallCount},responses:e.dataPoints.map(r=>({responseIndex:r.responseIndex,timestamp:r.timestamp,mode:r.mode,prefillTokens:r.prefillTokens,generationTokens:r.generationTokens,prefillSpeed:r.prefillSpeed,generationSpeed:r.generationSpeed,totalTime:r.totalTime,aiTime:r.aiTime,toolTime:r.toolTime})),llmCalls:e.callDataPoints.map(r=>({sessionCallIndex:r.sessionCallIndex,responseIndex:r.responseIndex,callIndex:r.callIndex,timestamp:r.timestamp,mode:r.mode,promptTokens:r.promptTokens,completionTokens:r.completionTokens,ttft:r.ttft,completionTime:r.completionTime,prefillSpeed:r.prefillSpeed,generationSpeed:r.generationSpeed,totalTime:r.totalTime}))}}function pw({isOpen:e,onClose:r,stats:i}){const s=P.useRef(null),[c,u]=P.useState({}),[p,l]=P.useState(()=>{var k;return((k=i.modelGroups[0])==null?void 0:k.key)??""});P.useEffect(()=>{var k;i.modelGroups.some(C=>C.key===p)||l(((k=i.modelGroups[0])==null?void 0:k.key)??"")},[p,i.modelGroups]);const h=P.useMemo(()=>i.modelGroups.find(k=>k.key===p)??i.modelGroups[0],[p,i.modelGroups]),f=P.useMemo(()=>h?lw(h):[],[h]),g=P.useMemo(()=>h?dw(h):{mode:"responses",xLabel:"response",prefillLabel:"",generationLabel:"",points:[]},[h]),m=P.useCallback(k=>{u(C=>({...C,[k]:!C[k]}))},[]),x=P.useCallback(()=>{if(!h)return;const k=fw(h);navigator.clipboard.writeText(JSON.stringify(k,null,2)).catch(C=>console.error("Failed to copy:",C))},[h]),S=P.useCallback(async()=>{if(s.current)try{const k=(await rw(async()=>{const{default:y}=await import("./html2canvas.esm-QH1iLAAe.js");return{default:y}},[])).default,C=await k(s.current,{backgroundColor:"#1a1a1a",scale:2}),b=document.createElement("a");b.download=`openfox-stats-${new Date().toISOString().slice(0,10)}.png`,b.href=C.toDataURL("image/png"),b.click()}catch(k){console.error("Failed to export PNG:",k),x()}},[x]);return o.jsx(un,{isOpen:e,onClose:r,title:"Session Stats",size:"lg",children:o.jsxs("div",{ref:s,className:"space-y-6",children:[o.jsx("section",{children:o.jsx("div",{className:"flex flex-wrap gap-2",children:i.modelGroups.map(k=>o.jsx("button",{onClick:()=>l(k.key),className:`px-3 py-1.5 rounded border text-xs transition-colors ${k.key===(h==null?void 0:h.key)?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border text-text-muted hover:text-text-primary hover:bg-bg-tertiary/40"}`,title:k.label,children:k.label},k.key))})}),h&&o.jsxs("section",{children:[o.jsx("h3",{className:"text-sm font-semibold text-text-secondary mb-3 uppercase tracking-wide",children:"Summary"}),o.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[o.jsx(Er,{label:"AI Time",value:Sd(h.aiTime)}),o.jsx(Er,{label:"Total Time",value:Sd(h.totalTime)}),o.jsx(Er,{label:"Tool Time",value:Sd(h.toolTime)}),o.jsx(Er,{label:"Responses",value:h.responseCount.toString()}),o.jsx(Er,{label:"LLM Calls",value:h.llmCallCount.toString()})]}),o.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mt-3",children:[o.jsx(Er,{label:"Prefill Tokens",value:ji(h.prefillTokens),subValue:`@ ${Ma(h.avgPrefillSpeed)} tok/s`}),o.jsx(Er,{label:"Gen Tokens",value:ji(h.generationTokens),subValue:`@ ${Ma(h.avgGenerationSpeed)} tok/s`}),o.jsx(Er,{label:"Avg PP Speed",value:`${Ma(h.avgPrefillSpeed)}`,subValue:"tok/s"}),o.jsx(Er,{label:"Avg TG Speed",value:`${Ma(h.avgGenerationSpeed)}`,subValue:"tok/s"})]})]}),h&&g.points.length>1&&o.jsxs("section",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-3",children:[o.jsx("h3",{className:"text-sm font-semibold text-text-secondary uppercase tracking-wide",children:"Performance Progression"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{onClick:x,className:"px-2 py-1 text-xs text-text-muted hover:text-text-primary hover:bg-bg-tertiary rounded transition-colors",children:"Copy JSON"}),o.jsx("button",{onClick:S,className:"px-2 py-1 text-xs text-text-muted hover:text-text-primary hover:bg-bg-tertiary rounded transition-colors",children:"Save PNG"})]})]}),o.jsx("div",{className:"bg-bg-tertiary/50 rounded p-4",children:o.jsx(ow,{data:g.points,width:50,prefillLabel:g.prefillLabel,generationLabel:g.generationLabel,xLabel:g.xLabel})})]}),h&&o.jsxs("section",{children:[o.jsxs("h3",{className:"text-sm font-semibold text-text-secondary mb-3 uppercase tracking-wide",children:["Response Log (",h.responseCount," responses)"]}),o.jsx("div",{className:"overflow-y-auto bg-bg-tertiary/30 rounded",children:o.jsxs("table",{className:"w-full table-fixed border-separate border-spacing-0 text-xs",children:[o.jsxs("colgroup",{children:[o.jsx("col",{className:"w-[7%]"}),o.jsx("col",{className:"w-[14%]"}),o.jsx("col",{className:"w-[10%]"}),o.jsx("col",{className:"w-[14%]"}),o.jsx("col",{className:"w-[14%]"}),o.jsx("col",{className:"w-[14%]"}),o.jsx("col",{className:"w-[11%]"}),o.jsx("col",{className:"w-[2%]"})]}),o.jsx("thead",{children:o.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-text-muted/80",children:[o.jsx("th",{className:"px-3 py-2 text-center font-medium",children:"#"}),o.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"At"}),o.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Time"}),o.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Context"}),o.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"PP t/s"}),o.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"TG t/s"}),o.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Calls"}),o.jsx("th",{className:"px-2 py-2"})]})}),o.jsx("tbody",{children:f.map((k,C)=>o.jsxs(P.Fragment,{children:[o.jsx(mw,{row:k,index:C,isExpanded:c[k.messageId]??!1,onToggle:k.isExpandable?()=>m(k.messageId):void 0}),(c[k.messageId]??!1)&&k.calls.map((b,y)=>o.jsx(gw,{dataPoint:b,index:y},`${b.messageId}-${b.callIndex}`))]},k.messageId))})]})})]})]})})}function Er({label:e,value:r,subValue:i}){return o.jsxs("div",{className:"bg-bg-tertiary/50 rounded p-3",children:[o.jsx("div",{className:"text-text-muted text-xs mb-1",children:e}),o.jsx("div",{className:"text-text-primary text-lg font-semibold",children:r}),i&&o.jsx("div",{className:"text-text-muted text-xs",children:i})]})}function mw({row:e,index:r,isExpanded:i,onToggle:s}){const c=e.calls.length>0?hw(e.calls.map(u=>u.promptTokens)):`${ji(e.prefillTokens)} ctx`;return o.jsxs("tr",{onClick:s,className:`${r%2===0?"bg-bg-tertiary/20":""} ${s?"cursor-pointer hover:bg-bg-tertiary/35 transition-colors":""}`,children:[o.jsx("td",{className:"px-3 py-2 text-center text-text-muted align-middle",children:e.responseIndex}),o.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:pb(e.timestamp)}),o.jsxs("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:[e.totalTime.toFixed(1),"s"]}),o.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:c.replace(/ ctx$/,"")}),o.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Tl(e.prefillSpeed)}),o.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Tl(e.generationSpeed)}),o.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:e.callCount}),o.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:e.isExpandable?i?"v":">":""})]})}function gw({dataPoint:e,index:r}){return o.jsxs("tr",{className:`${r%2===0?"bg-bg-tertiary/10":"bg-bg-tertiary/5"}`,children:[o.jsxs("td",{className:"px-3 py-2 pl-6 text-center text-text-muted align-middle border-l border-border/60",children:["c",e.callIndex]}),o.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:pb(e.timestamp)}),o.jsxs("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:[e.totalTime.toFixed(1),"s"]}),o.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:ji(e.promptTokens)}),o.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Tl(e.prefillSpeed)}),o.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Tl(e.generationSpeed)}),o.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:e.callIndex}),o.jsx("td",{className:"px-2 py-2"})]})}const xw={pending:{icon:"○",color:"text-text-muted",label:"Pending"},in_progress:{icon:"●",color:"text-accent-warning",label:"In Progress",animate:!0},completed:{icon:"◉",color:"text-purple-400",label:"Completed"},passed:{icon:"✓",color:"text-accent-success",label:"Passed"},failed:{icon:"✗",color:"text-accent-error",label:"Failed"}},vw=P.memo(function({criteria:r}){if(r.length===0)return o.jsx("div",{className:"text-text-muted text-sm text-center py-2",children:"No criteria yet"});const i={pending:0,in_progress:0,completed:0,passed:0,failed:0};for(const c of r){const u=c.status.type;u in i&&i[u]++}const s=Object.keys(i).filter(c=>i[c]>0);return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[o.jsx("span",{className:"font-semibold text-text-primary",children:"Total:"}),o.jsx("span",{className:"text-text-secondary",children:r.length})]}),o.jsx("div",{className:"space-y-1",children:s.map(c=>{const u=xw[c];return o.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[o.jsx("span",{className:`${u.color} ${u.animate?"animate-pulse":""} text-sm leading-tight`,children:u.icon}),o.jsxs("span",{className:"text-text-muted",children:[u.label,":"]}),o.jsx("span",{className:"text-text-primary font-medium",children:i[c]})]},c)})})]})});function bw({isOpen:e,onClose:r}){const i=rr(S=>S.config),s=rr(S=>S.saveConfig),[c,u]=P.useState(""),[p,l]=P.useState(""),[h,f]=P.useState(!1),[g,m]=P.useState(!1);P.useEffect(()=>{e&&(u((i==null?void 0:i.command)??""),l((i==null?void 0:i.url)??""),f((i==null?void 0:i.hotReload)??!1))},[e,i]);const x=async()=>{!c.trim()||!p.trim()||(m(!0),await s({command:c.trim(),url:p.trim(),hotReload:h}),m(!1),r())};return o.jsx(un,{isOpen:e,onClose:r,title:"Dev Server Config",size:"sm",children:o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Command"}),o.jsx("input",{className:"input w-full",type:"text",value:c,onChange:S=>u(S.target.value),placeholder:"npm run dev"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Dev URL"}),o.jsx("input",{className:"input w-full",type:"text",value:p,onChange:S=>l(S.target.value),placeholder:"http://localhost:3000"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"checkbox",id:"hotReload",checked:h,onChange:S=>f(S.target.checked),className:"rounded border-border bg-bg-tertiary"}),o.jsx("label",{htmlFor:"hotReload",className:"text-xs text-text-secondary",children:"Hot Reload"})]}),o.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[o.jsx("button",{className:"btn btn-secondary",onClick:r,children:"Cancel"}),o.jsx("button",{className:"btn btn-primary",onClick:x,disabled:g||!c.trim()||!p.trim(),children:g?"Saving...":"Save"})]})]})})}const Lx={30:"text-black",31:"text-red-400",32:"text-accent-success",33:"text-accent-warning",34:"text-blue-400",35:"text-purple-400",36:"text-cyan-400",37:"text-gray-300",90:"text-gray-500",91:"text-red-500",92:"text-green-500",93:"text-yellow-400",94:"text-blue-500",95:"text-pink-400",96:"text-cyan-500",97:"text-white"},yw={40:"bg-black",41:"bg-red-900",42:"bg-green-900",43:"bg-yellow-900",44:"bg-blue-900",45:"bg-purple-900",46:"bg-cyan-900",47:"bg-gray-700"},Rx={1:"font-bold",2:"opacity-75",4:"underline",7:"bg-bg-secondary"},_w="text-text-primary";function Sw(e){const r=[],i=/\x1b\[([0-9;]+)m/g;let s=0,c="text-text-primary",u;try{for(;(u=i.exec(e))!==null;){if(u.index>s){const f=e.slice(s,u.index);f&&r.push({text:f,className:c})}const p=u[1];if(!p)continue;const l=p.split(";").map(Number);if(l.length===0||l[0]===0){c="text-text-primary";continue}const h=[];for(const f of l)if(f>=30&&f<=37){const g=Lx[f];g&&h.push(g)}else if(f>=40&&f<=47){const g=yw[f];g&&h.push(g)}else if(f>=90&&f<=97){const g=Lx[f];g&&h.push(g)}else if(f in Rx){const g=Rx[f];g&&h.push(g)}else f===39?h.push(_w):f===49&&(c=c.split(" ").filter(g=>!g.startsWith("bg-")).join(" "));h.length>0&&(c=h.join(" ")),s=i.lastIndex}if(s<e.length){const p=e.slice(s);p&&r.push({text:p,className:c})}return r}catch(p){return console.warn("ANSI parsing failed, stripping codes:",p),[{text:ww(e),className:"text-text-primary"}]}}function ww(e){return e.replace(/\x1b\[([0-9;]+)m/g,"")}function Pa(e){var i,s;const r=Sw(e);return r.length===1&&((i=r[0])==null?void 0:i.className)==="text-text-primary"?(s=r[0])==null?void 0:s.text:r.map((c,u)=>ln.createElement("span",{key:u,className:c.className},c.text))}const Cw=P.memo(function({logs:r,onClose:i}){const s=P.useRef(null);return P.useEffect(()=>{const c=u=>{u.key==="Escape"&&i()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[i]),P.useEffect(()=>{s.current&&(s.current.scrollTop=s.current.scrollHeight)},[r]),o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:i,children:o.jsxs("div",{className:"relative w-[90vw] h-[90vh] bg-bg-primary rounded-lg border border-border flex flex-col",onClick:c=>c.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between p-3 border-b border-border",children:[o.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Dev Server Logs"}),o.jsx("button",{onClick:i,className:"p-1.5 rounded hover:bg-bg-tertiary transition-colors text-text-muted",children:o.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]}),o.jsx("pre",{ref:s,className:"flex-1 overflow-auto p-4 text-sm font-mono text-text-primary",children:r.length===0?o.jsx("span",{className:"text-text-muted",children:"No output yet"}):r.map((c,u)=>o.jsx("span",{className:c.stream==="stderr"?"text-accent-warning":"",children:Pa(c.content)},u))})]})})}),kw=P.memo(function({workdir:r}){const i=rr(_=>_.setWorkdir),s=rr(_=>_.status),c=rr(_=>_.config),u=rr(_=>_.logs),p=rr(_=>_.start),l=rr(_=>_.stop),h=rr(_=>_.fetchLogs),[f,g]=P.useState(!1),[m,x]=P.useState(!1),S=P.useRef(null),k=(s==null?void 0:s.state)??"off",C=c!==null,b=k==="running"||k==="warning";P.useEffect(()=>{i(r??null)},[r,i]),P.useEffect(()=>{b&&h()},[b,h]),P.useEffect(()=>{S.current&&b&&(S.current.scrollTop=S.current.scrollHeight)},[u,b]);const y=()=>{b?l():p()},v=o.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("path",{d:"M8 0a8.2 8.2 0 0 1 .701.031C9.444.095 9.99.645 10.16 1.29l.288 1.107c.018.066.079.158.212.224.231.114.454.243.668.386.123.082.233.09.299.071l1.1-.303c.652-.18 1.37.008 1.755.653a8.043 8.043 0 0 1 .683 1.18c.227.568.096 1.26-.378 1.726l-.812.804a.312.312 0 0 0-.081.283c.024.166.04.335.04.507s-.016.341-.04.507a.312.312 0 0 0 .08.283l.813.804c.474.466.605 1.158.378 1.726a8.07 8.07 0 0 1-.683 1.18c-.385.645-1.103.833-1.755.653l-1.1-.303c-.066-.019-.176-.011-.299.071a5.1 5.1 0 0 1-.668.386c-.133.066-.194.158-.211.224l-.29 1.107c-.168.645-.714 1.196-1.458 1.26a8.094 8.094 0 0 1-1.402 0c-.744-.064-1.29-.615-1.458-1.26l-.29-1.107a.426.426 0 0 0-.211-.224 5.11 5.11 0 0 1-.668-.386c-.123-.082-.233-.09-.299-.071l-1.1.303c-.652.18-1.37-.008-1.755-.653a8.044 8.044 0 0 1-.683-1.18c-.227-.568-.096-1.26.378-1.726l.812-.804a.312.312 0 0 0 .081-.283A5.18 5.18 0 0 1 2.3 8c0-.172.016-.341.04-.507a.312.312 0 0 0-.08-.283l-.813-.804C.973 5.94.842 5.248 1.069 4.68c.181-.452.395-.882.683-1.18.385-.645 1.103-.833 1.755-.653l1.1.303c.066.019.176.011.299-.071.214-.143.437-.272.668-.386a.426.426 0 0 0 .211-.224l.29-1.107C6.009.645 6.556.095 7.299.03 7.53.01 7.764 0 8 0Zm0 5.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5Z"})});return o.jsxs("div",{className:"mt-2 pt-3 border-t border-border space-y-3",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:`inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 ${k==="running"?"bg-accent-success":k==="warning"?"bg-accent-warning":k==="error"?"bg-accent-error":"bg-text-muted"}`}),o.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Dev Server"})]}),o.jsx("button",{onClick:()=>g(!0),className:"p-1.5 rounded hover:bg-bg-tertiary transition-colors text-text-muted",title:"Configure dev server",children:v})]}),C?o.jsxs(o.Fragment,{children:[k==="running"||k==="warning"?o.jsxs("div",{className:"flex gap-2",children:[o.jsxs("button",{onClick:y,className:"flex-1 flex items-center justify-center gap-1.5 rounded font-medium text-sm px-3 py-1.5 bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:[o.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"})}),"Stop"]}),(s==null?void 0:s.url)&&o.jsxs("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",className:"flex-1 flex items-center justify-center gap-1.5 rounded font-medium text-sm px-3 py-1.5 bg-accent-primary/25 text-white hover:bg-accent-primary/40 transition-colors",title:s.url,children:[o.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M6.5 3.5H3a1 1 0 0 0-1 1V13a1 1 0 0 0 1 1h8.5a1 1 0 0 0 1-1V9.5"}),o.jsx("path",{d:"M9.5 2h4.5v4.5"}),o.jsx("path",{d:"M14 2L7.5 8.5"})]}),"Open"]})]}):o.jsx("button",{onClick:y,className:"w-full rounded font-medium text-sm px-3 py-1.5 bg-accent-primary/25 text-white hover:bg-accent-primary/40 transition-colors",children:"Start"}),b&&o.jsxs("div",{className:"relative",children:[o.jsx("pre",{ref:S,className:"text-sm bg-bg-primary p-2 rounded overflow-auto max-h-[200px] border border-border",children:u.length===0?o.jsx("span",{className:"text-text-muted",children:"No output yet"}):u.map((_,j)=>o.jsx("span",{className:_.stream==="stderr"?"text-accent-warning":"",children:Pa(_.content)},j))}),o.jsx("button",{onClick:()=>x(!0),className:"absolute bottom-2 right-2 p-1 rounded bg-bg-tertiary/80 hover:bg-bg-tertiary text-text-muted transition-colors",title:"Expand logs",children:o.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M3 4a1 1 0 011-1h4a1 1 0 010 2H5v3a1 1 0 01-2 0V4zm12-1a1 1 0 00-1 1v3a1 1 0 102 0V5h3a1 1 0 100-2h-4zm-9 12a1 1 0 011 1v3h3a1 1 0 110 2H4a1 1 0 01-1-1v-4a1 1 0 011-1zm12 0a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 110-2h3v-3a1 1 0 011-1z",clipRule:"evenodd"})})})]})]}):o.jsx("button",{onClick:()=>g(!0),className:"w-full rounded font-medium text-sm px-3 py-1.5 bg-bg-tertiary text-text-muted hover:bg-border transition-colors",children:"Configure"}),o.jsx(bw,{isOpen:f,onClose:()=>g(!1)}),m&&o.jsx(Cw,{logs:u,onClose:()=>x(!1)})]})}),Ew=P.memo(function({isOpen:r,onClose:i,processName:s,logs:c}){const u=P.useRef(null);return P.useEffect(()=>{const p=l=>{l.key==="Escape"&&i()};if(r)return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[r,i]),P.useEffect(()=>{u.current&&r&&(u.current.scrollTop=u.current.scrollHeight)},[c,r]),r?o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:i,children:o.jsxs("div",{className:"relative w-[90vw] h-[90vh] bg-bg-primary rounded-lg border border-border flex flex-col",onClick:p=>p.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between p-3 border-b border-border",children:[o.jsx("h3",{className:"text-sm font-semibold text-text-primary truncate",children:s}),o.jsx("button",{onClick:i,className:"p-1.5 rounded hover:bg-bg-tertiary transition-colors text-text-muted",children:o.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]}),o.jsx("pre",{ref:u,className:"flex-1 overflow-auto p-4 text-sm font-mono text-text-primary whitespace-pre-wrap",children:c.length===0?o.jsx("span",{className:"text-text-muted",children:"No output yet"}):c.map((p,l)=>o.jsx("span",{className:p.stream==="stderr"?"text-accent-warning":"",children:Pa(p.content)},l))})]})}):null}),jw=P.memo(function({sessionId:r}){var S;const i=Oa(k=>k.processes),s=Oa(k=>k.stopProcess),[c,u]=P.useState(null),[p,l]=P.useState([]),h=i.filter(k=>k.status!=="exited"),f=h.filter(k=>k.status==="running").length;if(i.length===0)return null;const g=k=>{switch(k){case"running":return"bg-accent-success";case"starting":return"bg-accent-warning";case"stopping":return"bg-accent-warning";case"exited":return"bg-text-muted";default:return"bg-text-muted"}},m=k=>{const C=Oa.getState().logs[k]??[];l(C.map(b=>({content:b.content,stream:b.stream}))),u(k)},x=k=>{r&&s(k,r)};return o.jsxs("div",{className:"mt-2 pt-3 border-t border-border space-y-3",children:[o.jsx("div",{className:"flex items-center justify-between",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 bg-accent-primary"}),o.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Background"}),o.jsxs("span",{className:"text-xs text-text-muted",children:["(",f," running)"]})]})}),o.jsx("div",{className:"space-y-2",children:h.map(k=>o.jsx("div",{className:"border border-border rounded p-2",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[o.jsx("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${g(k.status)}`}),o.jsx("span",{className:"text-sm text-text-primary truncate",title:k.name,children:k.name}),o.jsxs("span",{className:"text-xs text-text-muted",children:["[",k.status,"]"]})]}),o.jsxs("div",{className:"flex gap-1 ml-2",children:[o.jsx("button",{onClick:()=>m(k.id),className:"px-2 py-1 text-xs rounded bg-bg-tertiary hover:bg-border text-text-secondary transition-colors",title:"View logs",children:"Logs"}),o.jsx("button",{onClick:()=>x(k.id),className:"px-2 py-1 text-xs rounded bg-bg-tertiary hover:bg-accent-error/20 text-text-secondary hover:text-accent-error transition-colors",title:"Stop process",children:"Stop"})]})]})},k.id))}),c&&o.jsx(Ew,{isOpen:!!c,onClose:()=>{u(null),l([])},processName:((S=h.find(k=>k.id===c))==null?void 0:S.name)??"",logs:p})]})});function Mx({summary:e,messages:r,workdir:i}){const[s,c]=P.useState(!1),u=QS(r),{branch:p}=JS(i),l=Lt(f=>f.version),h=Ee(f=>f.currentSession);return o.jsxs("div",{className:"flex flex-col h-full",children:[u&&o.jsxs("div",{className:"mb-4",children:[o.jsx("button",{onClick:()=>c(!0),className:"w-full flex items-center justify-center px-3 py-2 rounded bg-bg-tertiary hover:bg-bg-secondary transition-colors",title:"View detailed response and call-level stats",children:o.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[o.jsx("span",{className:"text-text-secondary",children:ew(u.aiTime)}),o.jsx("span",{className:"w-px h-3 bg-border"}),o.jsx("span",{className:"text-text-secondary",children:jx(u.avgPrefillSpeed)}),o.jsx("span",{children:"pp"}),o.jsx("span",{className:"w-px h-3 bg-border"}),o.jsx("span",{className:"text-text-secondary",children:jx(u.avgGenerationSpeed)}),o.jsx("span",{children:"tg"})]})}),o.jsx(pw,{isOpen:s,onClose:()=>c(!1),stats:u})]}),o.jsxs("div",{className:"flex flex-col flex-1 overflow-y-auto",children:[o.jsx("div",{className:"flex items-center justify-between mb-2",children:o.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Summary"})}),e?o.jsx("p",{className:"text-sm text-text-primary leading-relaxed",children:e}):o.jsx("div",{className:"text-text-muted text-sm text-center py-2",children:"No summary yet"}),o.jsxs("div",{className:"mt-4",children:[o.jsx("h3",{className:"text-sm font-semibold text-text-primary mb-2",children:"Progress"}),o.jsx(vw,{criteria:(h==null?void 0:h.criteria)??[]})]})]}),p&&o.jsxs("div",{className:"mt-4 flex items-center gap-2 text-sm",children:[o.jsx("svg",{className:"w-4 h-4 flex-shrink-0 text-text-muted",viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("path",{d:"M9.5 3.25a2.25 2.25 0 1 1 3 2.122V6A2.5 2.5 0 0 1 10 8.5H6a1 1 0 0 0-1 1v1.128a2.251 2.251 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.5 0v1.836A2.493 2.493 0 0 1 6 7h4a1 1 0 0 0 1-1v-.628A2.25 2.25 0 0 1 9.5 3.25Zm-6 0a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Zm8.25-.75a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM4.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z"})}),o.jsx("span",{className:"truncate text-text-secondary",title:p,children:p})]}),o.jsx(kw,{workdir:i}),o.jsx(jw,{sessionId:h==null?void 0:h.id}),l&&o.jsxs("div",{className:"mt-4 pt-4 border-t border-border text-center text-xs text-text-muted",children:[o.jsx("a",{href:"https://github.com/co-l/openfox",target:"_blank",rel:"noopener noreferrer",className:"hover:text-accent-primary transition-colors",children:"OpenFox"})," - ",o.jsxs("span",{children:["v",l]})]})]})}function Nw({children:e,criteriaSidebarOpen:r=!0,onCriteriaSidebarToggle:i,messages:s}){const c=Ee(u=>u.currentSession);return o.jsxs("div",{className:"relative h-full overflow-hidden",children:[r&&o.jsx("div",{className:"fixed md:hidden inset-0 bg-black/50 z-40",onClick:i}),o.jsxs("div",{className:"flex h-full",children:[o.jsx("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden",children:e}),r?o.jsx("aside",{className:"hidden md:block w-[320px] shrink-0 border-l border-border p-4 overflow-y-auto bg-bg-secondary",children:o.jsx(Mx,{summary:(c==null?void 0:c.summary)??null,messages:s,workdir:c==null?void 0:c.workdir})}):o.jsx("aside",{className:"hidden md:block w-0 shrink-0 overflow-hidden border-l-0"}),o.jsx("aside",{className:`
85
85
  md:hidden
86
86
  p-4 overflow-y-auto bg-bg-secondary
87
87
  transition-all duration-300 ease-in-out
88
88
  fixed right-0 top-[32px] h-[calc(100vh-32px)] z-50
89
89
  ${r?"w-[320px] translate-x-0 border-l border-border":"w-[320px] translate-x-full"}
90
- `,children:o.jsx(Mx,{summary:(c==null?void 0:c.summary)??null,messages:s,workdir:c==null?void 0:c.workdir})})]})]})}function Tw(e,r){return r||e>85?"bg-accent-error":e>60?"bg-accent-warning":"bg-accent-success"}function Ox(e,r){return r||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function Aw(){const e=Ee(f=>f.contextState),r=Ee(f=>f.currentSession),i=Ee(f=>f.compactContext);if(!e||!r)return null;const{currentTokens:s,maxTokens:c,compactionCount:u,dangerZone:p}=e,l=Math.round(s/c*100),h=r.isRunning;return o.jsx("div",{className:"flex-shrink-0 px-4 py-1.5 border-b border-border bg-bg-secondary/50",children:o.jsx("div",{className:"flex items-center justify-between gap-4",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[o.jsx("span",{className:"text-text-muted",children:"Context:"}),o.jsxs("span",{className:Ox(l,p),children:[Ex(s)," / ",Ex(c)]}),o.jsxs("span",{className:Ox(l,p),children:["(",l,"%)"]})]}),o.jsx("div",{className:"h-1.5 bg-bg-tertiary rounded-full overflow-hidden w-20",children:o.jsx("div",{className:`h-full transition-all duration-300 ${Tw(l,p)}`,style:{width:`${Math.min(l,100)}%`}})}),p&&o.jsx("span",{className:"text-[10px] text-accent-error font-medium animate-pulse",children:"Low!"}),u>0&&o.jsxs("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1 py-0.5 rounded",children:[u,"x"]}),o.jsx(dt,{variant:"secondary",size:"md",onClick:i,disabled:h,title:h?"Cannot compact while running":"Compact context",className:p?"border-accent-error text-accent-error hover:bg-accent-error/10":"",children:"Compact"})]})})})}function Bx(e){const r=[],i=String(e||"");let s=i.indexOf(","),c=0,u=!1;for(;!u;){s===-1&&(s=i.length,u=!0);const p=i.slice(c,s).trim();(p||!u)&&r.push(p),c=s+1,s=i.indexOf(",",c)}return r}function Dw(e,r){const i={};return(e[e.length-1]===""?[...e,""]:e).join((i.padRight?" ":"")+","+(i.padLeft===!1?"":" ")).trim()}const Lw=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Rw=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Mw={};function Ix(e,r){return(Mw.jsx?Rw:Lw).test(e)}const Ow=/[ \t\n\f\r]/g;function Bw(e){return typeof e=="object"?e.type==="text"?zx(e.value):!1:zx(e)}function zx(e){return e.replace(Ow,"")===""}class Ka{constructor(r,i,s){this.normal=i,this.property=r,s&&(this.space=s)}}Ka.prototype.normal={};Ka.prototype.property={};Ka.prototype.space=void 0;function mb(e,r){const i={},s={};for(const c of e)Object.assign(i,c.property),Object.assign(s,c.normal);return new Ka(i,s,r)}function Fa(e){return e.toLowerCase()}class bn{constructor(r,i){this.attribute=i,this.property=r}}bn.prototype.attribute="";bn.prototype.booleanish=!1;bn.prototype.boolean=!1;bn.prototype.commaOrSpaceSeparated=!1;bn.prototype.commaSeparated=!1;bn.prototype.defined=!1;bn.prototype.mustUseProperty=!1;bn.prototype.number=!1;bn.prototype.overloadedBoolean=!1;bn.prototype.property="";bn.prototype.spaceSeparated=!1;bn.prototype.space=void 0;let Iw=0;const We=Ai(),Ht=Ai(),Yd=Ai(),_e=Ai(),_t=Ai(),js=Ai(),Nn=Ai();function Ai(){return 2**++Iw}const Kd=Object.freeze(Object.defineProperty({__proto__:null,boolean:We,booleanish:Ht,commaOrSpaceSeparated:Nn,commaSeparated:js,number:_e,overloadedBoolean:Yd,spaceSeparated:_t},Symbol.toStringTag,{value:"Module"})),wd=Object.keys(Kd);class gh extends bn{constructor(r,i,s,c){let u=-1;if(super(r,i),Hx(this,"space",c),typeof s=="number")for(;++u<wd.length;){const p=wd[u];Hx(this,wd[u],(s&Kd[p])===Kd[p])}}}gh.prototype.defined=!0;function Hx(e,r,i){i&&(e[r]=i)}function As(e){const r={},i={};for(const[s,c]of Object.entries(e.properties)){const u=new gh(s,e.transform(e.attributes||{},s),c,e.space);e.mustUseProperty&&e.mustUseProperty.includes(s)&&(u.mustUseProperty=!0),r[s]=u,i[Fa(s)]=s,i[Fa(u.attribute)]=s}return new Ka(r,i,e.space)}const gb=As({properties:{ariaActiveDescendant:null,ariaAtomic:Ht,ariaAutoComplete:null,ariaBusy:Ht,ariaChecked:Ht,ariaColCount:_e,ariaColIndex:_e,ariaColSpan:_e,ariaControls:_t,ariaCurrent:null,ariaDescribedBy:_t,ariaDetails:null,ariaDisabled:Ht,ariaDropEffect:_t,ariaErrorMessage:null,ariaExpanded:Ht,ariaFlowTo:_t,ariaGrabbed:Ht,ariaHasPopup:null,ariaHidden:Ht,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:_t,ariaLevel:_e,ariaLive:null,ariaModal:Ht,ariaMultiLine:Ht,ariaMultiSelectable:Ht,ariaOrientation:null,ariaOwns:_t,ariaPlaceholder:null,ariaPosInSet:_e,ariaPressed:Ht,ariaReadOnly:Ht,ariaRelevant:null,ariaRequired:Ht,ariaRoleDescription:_t,ariaRowCount:_e,ariaRowIndex:_e,ariaRowSpan:_e,ariaSelected:Ht,ariaSetSize:_e,ariaSort:null,ariaValueMax:_e,ariaValueMin:_e,ariaValueNow:_e,ariaValueText:null,role:null},transform(e,r){return r==="role"?r:"aria-"+r.slice(4).toLowerCase()}});function xb(e,r){return r in e?e[r]:r}function vb(e,r){return xb(e,r.toLowerCase())}const zw=As({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:js,acceptCharset:_t,accessKey:_t,action:null,allow:null,allowFullScreen:We,allowPaymentRequest:We,allowUserMedia:We,alt:null,as:null,async:We,autoCapitalize:null,autoComplete:_t,autoFocus:We,autoPlay:We,blocking:_t,capture:null,charSet:null,checked:We,cite:null,className:_t,cols:_e,colSpan:null,content:null,contentEditable:Ht,controls:We,controlsList:_t,coords:_e|js,crossOrigin:null,data:null,dateTime:null,decoding:null,default:We,defer:We,dir:null,dirName:null,disabled:We,download:Yd,draggable:Ht,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:We,formTarget:null,headers:_t,height:_e,hidden:Yd,high:_e,href:null,hrefLang:null,htmlFor:_t,httpEquiv:_t,id:null,imageSizes:null,imageSrcSet:null,inert:We,inputMode:null,integrity:null,is:null,isMap:We,itemId:null,itemProp:_t,itemRef:_t,itemScope:We,itemType:_t,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:We,low:_e,manifest:null,max:null,maxLength:_e,media:null,method:null,min:null,minLength:_e,multiple:We,muted:We,name:null,nonce:null,noModule:We,noValidate:We,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:We,optimum:_e,pattern:null,ping:_t,placeholder:null,playsInline:We,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:We,referrerPolicy:null,rel:_t,required:We,reversed:We,rows:_e,rowSpan:_e,sandbox:_t,scope:null,scoped:We,seamless:We,selected:We,shadowRootClonable:We,shadowRootDelegatesFocus:We,shadowRootMode:null,shape:null,size:_e,sizes:null,slot:null,span:_e,spellCheck:Ht,src:null,srcDoc:null,srcLang:null,srcSet:null,start:_e,step:null,style:null,tabIndex:_e,target:null,title:null,translate:null,type:null,typeMustMatch:We,useMap:null,value:Ht,width:_e,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:_t,axis:null,background:null,bgColor:null,border:_e,borderColor:null,bottomMargin:_e,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:We,declare:We,event:null,face:null,frame:null,frameBorder:null,hSpace:_e,leftMargin:_e,link:null,longDesc:null,lowSrc:null,marginHeight:_e,marginWidth:_e,noResize:We,noHref:We,noShade:We,noWrap:We,object:null,profile:null,prompt:null,rev:null,rightMargin:_e,rules:null,scheme:null,scrolling:Ht,standby:null,summary:null,text:null,topMargin:_e,valueType:null,version:null,vAlign:null,vLink:null,vSpace:_e,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:We,disableRemotePlayback:We,prefix:null,property:null,results:_e,security:null,unselectable:null},space:"html",transform:vb}),Hw=As({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Nn,accentHeight:_e,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:_e,amplitude:_e,arabicForm:null,ascent:_e,attributeName:null,attributeType:null,azimuth:_e,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:_e,by:null,calcMode:null,capHeight:_e,className:_t,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:_e,diffuseConstant:_e,direction:null,display:null,dur:null,divisor:_e,dominantBaseline:null,download:We,dx:null,dy:null,edgeMode:null,editable:null,elevation:_e,enableBackground:null,end:null,event:null,exponent:_e,externalResourcesRequired:null,fill:null,fillOpacity:_e,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:js,g2:js,glyphName:js,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:_e,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:_e,horizOriginX:_e,horizOriginY:_e,id:null,ideographic:_e,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:_e,k:_e,k1:_e,k2:_e,k3:_e,k4:_e,kernelMatrix:Nn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:_e,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:_e,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:_e,overlineThickness:_e,paintOrder:null,panose1:null,path:null,pathLength:_e,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:_t,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:_e,pointsAtY:_e,pointsAtZ:_e,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Nn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Nn,rev:Nn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Nn,requiredFeatures:Nn,requiredFonts:Nn,requiredFormats:Nn,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:_e,specularExponent:_e,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:_e,strikethroughThickness:_e,string:null,stroke:null,strokeDashArray:Nn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:_e,strokeOpacity:_e,strokeWidth:null,style:null,surfaceScale:_e,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Nn,tabIndex:_e,tableValues:null,target:null,targetX:_e,targetY:_e,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Nn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:_e,underlineThickness:_e,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:_e,values:null,vAlphabetic:_e,vMathematical:_e,vectorEffect:null,vHanging:_e,vIdeographic:_e,version:null,vertAdvY:_e,vertOriginX:_e,vertOriginY:_e,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:_e,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:xb}),bb=As({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,r){return"xlink:"+r.slice(5).toLowerCase()}}),yb=As({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:vb}),_b=As({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,r){return"xml:"+r.slice(3).toLowerCase()}}),Pw={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Fw=/[A-Z]/g,Px=/-[a-z]/g,Uw=/^data[-\w.:]+$/i;function Sb(e,r){const i=Fa(r);let s=r,c=bn;if(i in e.normal)return e.property[e.normal[i]];if(i.length>4&&i.slice(0,4)==="data"&&Uw.test(r)){if(r.charAt(4)==="-"){const u=r.slice(5).replace(Px,qw);s="data"+u.charAt(0).toUpperCase()+u.slice(1)}else{const u=r.slice(4);if(!Px.test(u)){let p=u.replace(Fw,$w);p.charAt(0)!=="-"&&(p="-"+p),r="data"+p}}c=gh}return new c(s,r)}function $w(e){return"-"+e.toLowerCase()}function qw(e){return e.charAt(1).toUpperCase()}const wb=mb([gb,zw,bb,yb,_b],"html"),Pl=mb([gb,Hw,bb,yb,_b],"svg");function Fx(e){const r=String(e||"").trim();return r?r.split(/[ \t\n\r\f]+/g):[]}function Ww(e){return e.join(" ").trim()}var vs={},Cd,Ux;function Gw(){if(Ux)return Cd;Ux=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,s=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,c=/^:\s*/,u=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,p=/^[;\s]*/,l=/^\s+|\s+$/g,h=`
90
+ `,children:o.jsx(Mx,{summary:(c==null?void 0:c.summary)??null,messages:s,workdir:c==null?void 0:c.workdir})})]})]})}function Tw(e,r){return r||e>85?"bg-accent-error":e>60?"bg-accent-warning":"bg-accent-success"}function Ox(e,r){return r||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function Aw(){const e=Ee(f=>f.contextState),r=Ee(f=>f.currentSession),i=Ee(f=>f.compactContext);if(!e||!r)return null;const{currentTokens:s,maxTokens:c,compactionCount:u,dangerZone:p}=e,l=Math.round(s/c*100),h=r.isRunning;return o.jsx("div",{className:"flex-shrink-0 px-4 py-1.5 border-b border-border bg-bg-secondary/50",children:o.jsx("div",{className:"flex items-center justify-between gap-4",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[o.jsx("span",{className:"text-text-muted",children:"Context:"}),o.jsxs("span",{className:Ox(l,p),children:[Ex(s)," / ",Ex(c)]}),o.jsxs("span",{className:Ox(l,p),children:["(",l,"%)"]})]}),o.jsx("div",{className:"h-1.5 bg-bg-tertiary rounded-full overflow-hidden w-20",children:o.jsx("div",{className:`h-full transition-all duration-300 ${Tw(l,p)}`,style:{width:`${Math.min(l,100)}%`}})}),p&&o.jsx("span",{className:"text-[10px] text-accent-error font-medium animate-pulse",children:"Low!"}),u>0&&o.jsxs("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1 py-0.5 rounded",children:[u,"x"]}),o.jsx(dt,{variant:"secondary",size:"md",onClick:i,disabled:h,title:h?"Cannot compact while running":"Compact context",className:p?"border-accent-error text-accent-error hover:bg-accent-error/10":"",children:"Compact"})]})})})}function Bx(e){const r=[],i=String(e||"");let s=i.indexOf(","),c=0,u=!1;for(;!u;){s===-1&&(s=i.length,u=!0);const p=i.slice(c,s).trim();(p||!u)&&r.push(p),c=s+1,s=i.indexOf(",",c)}return r}function Dw(e,r){const i={};return(e[e.length-1]===""?[...e,""]:e).join((i.padRight?" ":"")+","+(i.padLeft===!1?"":" ")).trim()}const Lw=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Rw=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Mw={};function Ix(e,r){return(Mw.jsx?Rw:Lw).test(e)}const Ow=/[ \t\n\f\r]/g;function Bw(e){return typeof e=="object"?e.type==="text"?zx(e.value):!1:zx(e)}function zx(e){return e.replace(Ow,"")===""}class Ka{constructor(r,i,s){this.normal=i,this.property=r,s&&(this.space=s)}}Ka.prototype.normal={};Ka.prototype.property={};Ka.prototype.space=void 0;function mb(e,r){const i={},s={};for(const c of e)Object.assign(i,c.property),Object.assign(s,c.normal);return new Ka(i,s,r)}function Fa(e){return e.toLowerCase()}class bn{constructor(r,i){this.attribute=i,this.property=r}}bn.prototype.attribute="";bn.prototype.booleanish=!1;bn.prototype.boolean=!1;bn.prototype.commaOrSpaceSeparated=!1;bn.prototype.commaSeparated=!1;bn.prototype.defined=!1;bn.prototype.mustUseProperty=!1;bn.prototype.number=!1;bn.prototype.overloadedBoolean=!1;bn.prototype.property="";bn.prototype.spaceSeparated=!1;bn.prototype.space=void 0;let Iw=0;const We=Ai(),Pt=Ai(),Yd=Ai(),_e=Ai(),_t=Ai(),js=Ai(),Nn=Ai();function Ai(){return 2**++Iw}const Kd=Object.freeze(Object.defineProperty({__proto__:null,boolean:We,booleanish:Pt,commaOrSpaceSeparated:Nn,commaSeparated:js,number:_e,overloadedBoolean:Yd,spaceSeparated:_t},Symbol.toStringTag,{value:"Module"})),wd=Object.keys(Kd);class gh extends bn{constructor(r,i,s,c){let u=-1;if(super(r,i),Hx(this,"space",c),typeof s=="number")for(;++u<wd.length;){const p=wd[u];Hx(this,wd[u],(s&Kd[p])===Kd[p])}}}gh.prototype.defined=!0;function Hx(e,r,i){i&&(e[r]=i)}function As(e){const r={},i={};for(const[s,c]of Object.entries(e.properties)){const u=new gh(s,e.transform(e.attributes||{},s),c,e.space);e.mustUseProperty&&e.mustUseProperty.includes(s)&&(u.mustUseProperty=!0),r[s]=u,i[Fa(s)]=s,i[Fa(u.attribute)]=s}return new Ka(r,i,e.space)}const gb=As({properties:{ariaActiveDescendant:null,ariaAtomic:Pt,ariaAutoComplete:null,ariaBusy:Pt,ariaChecked:Pt,ariaColCount:_e,ariaColIndex:_e,ariaColSpan:_e,ariaControls:_t,ariaCurrent:null,ariaDescribedBy:_t,ariaDetails:null,ariaDisabled:Pt,ariaDropEffect:_t,ariaErrorMessage:null,ariaExpanded:Pt,ariaFlowTo:_t,ariaGrabbed:Pt,ariaHasPopup:null,ariaHidden:Pt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:_t,ariaLevel:_e,ariaLive:null,ariaModal:Pt,ariaMultiLine:Pt,ariaMultiSelectable:Pt,ariaOrientation:null,ariaOwns:_t,ariaPlaceholder:null,ariaPosInSet:_e,ariaPressed:Pt,ariaReadOnly:Pt,ariaRelevant:null,ariaRequired:Pt,ariaRoleDescription:_t,ariaRowCount:_e,ariaRowIndex:_e,ariaRowSpan:_e,ariaSelected:Pt,ariaSetSize:_e,ariaSort:null,ariaValueMax:_e,ariaValueMin:_e,ariaValueNow:_e,ariaValueText:null,role:null},transform(e,r){return r==="role"?r:"aria-"+r.slice(4).toLowerCase()}});function xb(e,r){return r in e?e[r]:r}function vb(e,r){return xb(e,r.toLowerCase())}const zw=As({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:js,acceptCharset:_t,accessKey:_t,action:null,allow:null,allowFullScreen:We,allowPaymentRequest:We,allowUserMedia:We,alt:null,as:null,async:We,autoCapitalize:null,autoComplete:_t,autoFocus:We,autoPlay:We,blocking:_t,capture:null,charSet:null,checked:We,cite:null,className:_t,cols:_e,colSpan:null,content:null,contentEditable:Pt,controls:We,controlsList:_t,coords:_e|js,crossOrigin:null,data:null,dateTime:null,decoding:null,default:We,defer:We,dir:null,dirName:null,disabled:We,download:Yd,draggable:Pt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:We,formTarget:null,headers:_t,height:_e,hidden:Yd,high:_e,href:null,hrefLang:null,htmlFor:_t,httpEquiv:_t,id:null,imageSizes:null,imageSrcSet:null,inert:We,inputMode:null,integrity:null,is:null,isMap:We,itemId:null,itemProp:_t,itemRef:_t,itemScope:We,itemType:_t,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:We,low:_e,manifest:null,max:null,maxLength:_e,media:null,method:null,min:null,minLength:_e,multiple:We,muted:We,name:null,nonce:null,noModule:We,noValidate:We,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:We,optimum:_e,pattern:null,ping:_t,placeholder:null,playsInline:We,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:We,referrerPolicy:null,rel:_t,required:We,reversed:We,rows:_e,rowSpan:_e,sandbox:_t,scope:null,scoped:We,seamless:We,selected:We,shadowRootClonable:We,shadowRootDelegatesFocus:We,shadowRootMode:null,shape:null,size:_e,sizes:null,slot:null,span:_e,spellCheck:Pt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:_e,step:null,style:null,tabIndex:_e,target:null,title:null,translate:null,type:null,typeMustMatch:We,useMap:null,value:Pt,width:_e,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:_t,axis:null,background:null,bgColor:null,border:_e,borderColor:null,bottomMargin:_e,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:We,declare:We,event:null,face:null,frame:null,frameBorder:null,hSpace:_e,leftMargin:_e,link:null,longDesc:null,lowSrc:null,marginHeight:_e,marginWidth:_e,noResize:We,noHref:We,noShade:We,noWrap:We,object:null,profile:null,prompt:null,rev:null,rightMargin:_e,rules:null,scheme:null,scrolling:Pt,standby:null,summary:null,text:null,topMargin:_e,valueType:null,version:null,vAlign:null,vLink:null,vSpace:_e,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:We,disableRemotePlayback:We,prefix:null,property:null,results:_e,security:null,unselectable:null},space:"html",transform:vb}),Hw=As({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Nn,accentHeight:_e,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:_e,amplitude:_e,arabicForm:null,ascent:_e,attributeName:null,attributeType:null,azimuth:_e,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:_e,by:null,calcMode:null,capHeight:_e,className:_t,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:_e,diffuseConstant:_e,direction:null,display:null,dur:null,divisor:_e,dominantBaseline:null,download:We,dx:null,dy:null,edgeMode:null,editable:null,elevation:_e,enableBackground:null,end:null,event:null,exponent:_e,externalResourcesRequired:null,fill:null,fillOpacity:_e,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:js,g2:js,glyphName:js,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:_e,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:_e,horizOriginX:_e,horizOriginY:_e,id:null,ideographic:_e,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:_e,k:_e,k1:_e,k2:_e,k3:_e,k4:_e,kernelMatrix:Nn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:_e,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:_e,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:_e,overlineThickness:_e,paintOrder:null,panose1:null,path:null,pathLength:_e,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:_t,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:_e,pointsAtY:_e,pointsAtZ:_e,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Nn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Nn,rev:Nn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Nn,requiredFeatures:Nn,requiredFonts:Nn,requiredFormats:Nn,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:_e,specularExponent:_e,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:_e,strikethroughThickness:_e,string:null,stroke:null,strokeDashArray:Nn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:_e,strokeOpacity:_e,strokeWidth:null,style:null,surfaceScale:_e,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Nn,tabIndex:_e,tableValues:null,target:null,targetX:_e,targetY:_e,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Nn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:_e,underlineThickness:_e,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:_e,values:null,vAlphabetic:_e,vMathematical:_e,vectorEffect:null,vHanging:_e,vIdeographic:_e,version:null,vertAdvY:_e,vertOriginX:_e,vertOriginY:_e,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:_e,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:xb}),bb=As({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,r){return"xlink:"+r.slice(5).toLowerCase()}}),yb=As({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:vb}),_b=As({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,r){return"xml:"+r.slice(3).toLowerCase()}}),Pw={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Fw=/[A-Z]/g,Px=/-[a-z]/g,Uw=/^data[-\w.:]+$/i;function Sb(e,r){const i=Fa(r);let s=r,c=bn;if(i in e.normal)return e.property[e.normal[i]];if(i.length>4&&i.slice(0,4)==="data"&&Uw.test(r)){if(r.charAt(4)==="-"){const u=r.slice(5).replace(Px,qw);s="data"+u.charAt(0).toUpperCase()+u.slice(1)}else{const u=r.slice(4);if(!Px.test(u)){let p=u.replace(Fw,$w);p.charAt(0)!=="-"&&(p="-"+p),r="data"+p}}c=gh}return new c(s,r)}function $w(e){return"-"+e.toLowerCase()}function qw(e){return e.charAt(1).toUpperCase()}const wb=mb([gb,zw,bb,yb,_b],"html"),Pl=mb([gb,Hw,bb,yb,_b],"svg");function Fx(e){const r=String(e||"").trim();return r?r.split(/[ \t\n\r\f]+/g):[]}function Ww(e){return e.join(" ").trim()}var vs={},Cd,Ux;function Gw(){if(Ux)return Cd;Ux=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,s=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,c=/^:\s*/,u=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,p=/^[;\s]*/,l=/^\s+|\s+$/g,h=`
91
91
  `,f="/",g="*",m="",x="comment",S="declaration";function k(b,y){if(typeof b!="string")throw new TypeError("First argument must be a string");if(!b)return[];y=y||{};var v=1,_=1;function j(F){var I=F.match(r);I&&(v+=I.length);var $=F.lastIndexOf(h);_=~$?F.length-$:_+F.length}function A(){var F={line:v,column:_};return function(I){return I.position=new N(F),B(),I}}function N(F){this.start=F,this.end={line:v,column:_},this.source=y.source}N.prototype.content=b;function L(F){var I=new Error(y.source+":"+v+":"+_+": "+F);if(I.reason=F,I.filename=y.source,I.line=v,I.column=_,I.source=b,!y.silent)throw I}function T(F){var I=F.exec(b);if(I){var $=I[0];return j($),b=b.slice($.length),I}}function B(){T(i)}function H(F){var I;for(F=F||[];I=q();)I!==!1&&F.push(I);return F}function q(){var F=A();if(!(f!=b.charAt(0)||g!=b.charAt(1))){for(var I=2;m!=b.charAt(I)&&(g!=b.charAt(I)||f!=b.charAt(I+1));)++I;if(I+=2,m===b.charAt(I-1))return L("End of comment missing");var $=b.slice(2,I-2);return _+=2,j($),b=b.slice(I),_+=2,F({type:x,comment:$})}}function Y(){var F=A(),I=T(s);if(I){if(q(),!T(c))return L("property missing ':'");var $=T(u),X=F({type:S,property:C(I[0].replace(e,m)),value:$?C($[0].replace(e,m)):m});return T(p),X}}function V(){var F=[];H(F);for(var I;I=Y();)I!==!1&&(F.push(I),H(F));return F}return B(),V()}function C(b){return b?b.replace(l,m):m}return Cd=k,Cd}var $x;function Vw(){if($x)return vs;$x=1;var e=vs&&vs.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(vs,"__esModule",{value:!0}),vs.default=i;const r=e(Gw());function i(s,c){let u=null;if(!s||typeof s!="string")return u;const p=(0,r.default)(s),l=typeof c=="function";return p.forEach(h=>{if(h.type!=="declaration")return;const{property:f,value:g}=h;l?c(f,g,h):g&&(u=u||{},u[f]=g)}),u}return vs}var Ta={},qx;function Yw(){if(qx)return Ta;qx=1,Object.defineProperty(Ta,"__esModule",{value:!0}),Ta.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,r=/-([a-z])/g,i=/^[^-]+$/,s=/^-(webkit|moz|ms|o|khtml)-/,c=/^-(ms)-/,u=function(f){return!f||i.test(f)||e.test(f)},p=function(f,g){return g.toUpperCase()},l=function(f,g){return"".concat(g,"-")},h=function(f,g){return g===void 0&&(g={}),u(f)?f:(f=f.toLowerCase(),g.reactCompat?f=f.replace(c,l):f=f.replace(s,l),f.replace(r,p))};return Ta.camelCase=h,Ta}var Aa,Wx;function Kw(){if(Wx)return Aa;Wx=1;var e=Aa&&Aa.__importDefault||function(c){return c&&c.__esModule?c:{default:c}},r=e(Vw()),i=Yw();function s(c,u){var p={};return!c||typeof c!="string"||(0,r.default)(c,function(l,h){l&&h&&(p[(0,i.camelCase)(l,u)]=h)}),p}return s.default=s,Aa=s,Aa}var Xw=Kw();const Zw=Ol(Xw),Cb=kb("end"),xh=kb("start");function kb(e){return r;function r(i){const s=i&&i.position&&i.position[e]||{};if(typeof s.line=="number"&&s.line>0&&typeof s.column=="number"&&s.column>0)return{line:s.line,column:s.column,offset:typeof s.offset=="number"&&s.offset>-1?s.offset:void 0}}}function Qw(e){const r=xh(e),i=Cb(e);if(r&&i)return{start:r,end:i}}function Ba(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Gx(e.position):"start"in e||"end"in e?Gx(e):"line"in e||"column"in e?Xd(e):""}function Xd(e){return Vx(e&&e.line)+":"+Vx(e&&e.column)}function Gx(e){return Xd(e&&e.start)+"-"+Xd(e&&e.end)}function Vx(e){return e&&typeof e=="number"?e:1}class an extends Error{constructor(r,i,s){super(),typeof i=="string"&&(s=i,i=void 0);let c="",u={},p=!1;if(i&&("line"in i&&"column"in i?u={place:i}:"start"in i&&"end"in i?u={place:i}:"type"in i?u={ancestors:[i],place:i.position}:u={...i}),typeof r=="string"?c=r:!u.cause&&r&&(p=!0,c=r.message,u.cause=r),!u.ruleId&&!u.source&&typeof s=="string"){const h=s.indexOf(":");h===-1?u.ruleId=s:(u.source=s.slice(0,h),u.ruleId=s.slice(h+1))}if(!u.place&&u.ancestors&&u.ancestors){const h=u.ancestors[u.ancestors.length-1];h&&(u.place=h.position)}const l=u.place&&"start"in u.place?u.place.start:u.place;this.ancestors=u.ancestors||void 0,this.cause=u.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=c,this.line=l?l.line:void 0,this.name=Ba(u.place)||"1:1",this.place=u.place||void 0,this.reason=this.message,this.ruleId=u.ruleId||void 0,this.source=u.source||void 0,this.stack=p&&u.cause&&typeof u.cause.stack=="string"?u.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}an.prototype.file="";an.prototype.name="";an.prototype.reason="";an.prototype.message="";an.prototype.stack="";an.prototype.column=void 0;an.prototype.line=void 0;an.prototype.ancestors=void 0;an.prototype.cause=void 0;an.prototype.fatal=void 0;an.prototype.place=void 0;an.prototype.ruleId=void 0;an.prototype.source=void 0;const vh={}.hasOwnProperty,Jw=new Map,e2=/[A-Z]/g,t2=new Set(["table","tbody","thead","tfoot","tr"]),n2=new Set(["td","th"]),Eb="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function r2(e,r){if(!r||r.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const i=r.filePath||void 0;let s;if(r.development){if(typeof r.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");s=d2(i,r.jsxDEV)}else{if(typeof r.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof r.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");s=u2(i,r.jsx,r.jsxs)}const c={Fragment:r.Fragment,ancestors:[],components:r.components||{},create:s,elementAttributeNameCase:r.elementAttributeNameCase||"react",evaluater:r.createEvaluater?r.createEvaluater():void 0,filePath:i,ignoreInvalidStyle:r.ignoreInvalidStyle||!1,passKeys:r.passKeys!==!1,passNode:r.passNode||!1,schema:r.space==="svg"?Pl:wb,stylePropertyNameCase:r.stylePropertyNameCase||"dom",tableCellAlignToStyle:r.tableCellAlignToStyle!==!1},u=jb(c,e,void 0);return u&&typeof u!="string"?u:c.create(e,c.Fragment,{children:u||void 0},void 0)}function jb(e,r,i){if(r.type==="element")return i2(e,r,i);if(r.type==="mdxFlowExpression"||r.type==="mdxTextExpression")return s2(e,r);if(r.type==="mdxJsxFlowElement"||r.type==="mdxJsxTextElement")return o2(e,r,i);if(r.type==="mdxjsEsm")return a2(e,r);if(r.type==="root")return l2(e,r,i);if(r.type==="text")return c2(e,r)}function i2(e,r,i){const s=e.schema;let c=s;r.tagName.toLowerCase()==="svg"&&s.space==="html"&&(c=Pl,e.schema=c),e.ancestors.push(r);const u=Tb(e,r.tagName,!1),p=h2(e,r);let l=yh(e,r);return t2.has(r.tagName)&&(l=l.filter(function(h){return typeof h=="string"?!Bw(h):!0})),Nb(e,p,u,r),bh(p,l),e.ancestors.pop(),e.schema=s,e.create(r,u,p,i)}function s2(e,r){if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];return s.type,e.evaluater.evaluateExpression(s.expression)}Ua(e,r.position)}function a2(e,r){if(r.data&&r.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(r.data.estree);Ua(e,r.position)}function o2(e,r,i){const s=e.schema;let c=s;r.name==="svg"&&s.space==="html"&&(c=Pl,e.schema=c),e.ancestors.push(r);const u=r.name===null?e.Fragment:Tb(e,r.name,!0),p=f2(e,r),l=yh(e,r);return Nb(e,p,u,r),bh(p,l),e.ancestors.pop(),e.schema=s,e.create(r,u,p,i)}function l2(e,r,i){const s={};return bh(s,yh(e,r)),e.create(r,e.Fragment,s,i)}function c2(e,r){return r.value}function Nb(e,r,i,s){typeof i!="string"&&i!==e.Fragment&&e.passNode&&(r.node=s)}function bh(e,r){if(r.length>0){const i=r.length>1?r:r[0];i&&(e.children=i)}}function u2(e,r,i){return s;function s(c,u,p,l){const f=Array.isArray(p.children)?i:r;return l?f(u,p,l):f(u,p)}}function d2(e,r){return i;function i(s,c,u,p){const l=Array.isArray(u.children),h=xh(s);return r(c,u,p,l,{columnNumber:h?h.column-1:void 0,fileName:e,lineNumber:h?h.line:void 0},void 0)}}function h2(e,r){const i={};let s,c;for(c in r.properties)if(c!=="children"&&vh.call(r.properties,c)){const u=p2(e,c,r.properties[c]);if(u){const[p,l]=u;e.tableCellAlignToStyle&&p==="align"&&typeof l=="string"&&n2.has(r.tagName)?s=l:i[p]=l}}if(s){const u=i.style||(i.style={});u[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=s}return i}function f2(e,r){const i={};for(const s of r.attributes)if(s.type==="mdxJsxExpressionAttribute")if(s.data&&s.data.estree&&e.evaluater){const u=s.data.estree.body[0];u.type;const p=u.expression;p.type;const l=p.properties[0];l.type,Object.assign(i,e.evaluater.evaluateExpression(l.argument))}else Ua(e,r.position);else{const c=s.name;let u;if(s.value&&typeof s.value=="object")if(s.value.data&&s.value.data.estree&&e.evaluater){const l=s.value.data.estree.body[0];l.type,u=e.evaluater.evaluateExpression(l.expression)}else Ua(e,r.position);else u=s.value===null?!0:s.value;i[c]=u}return i}function yh(e,r){const i=[];let s=-1;const c=e.passKeys?new Map:Jw;for(;++s<r.children.length;){const u=r.children[s];let p;if(e.passKeys){const h=u.type==="element"?u.tagName:u.type==="mdxJsxFlowElement"||u.type==="mdxJsxTextElement"?u.name:void 0;if(h){const f=c.get(h)||0;p=h+"-"+f,c.set(h,f+1)}}const l=jb(e,u,p);l!==void 0&&i.push(l)}return i}function p2(e,r,i){const s=Sb(e.schema,r);if(!(i==null||typeof i=="number"&&Number.isNaN(i))){if(Array.isArray(i)&&(i=s.commaSeparated?Dw(i):Ww(i)),s.property==="style"){let c=typeof i=="object"?i:m2(e,String(i));return e.stylePropertyNameCase==="css"&&(c=g2(c)),["style",c]}return[e.elementAttributeNameCase==="react"&&s.space?Pw[s.property]||s.property:s.attribute,i]}}function m2(e,r){try{return Zw(r,{reactCompat:!0})}catch(i){if(e.ignoreInvalidStyle)return{};const s=i,c=new an("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:s,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw c.file=e.filePath||void 0,c.url=Eb+"#cannot-parse-style-attribute",c}}function Tb(e,r,i){let s;if(!i)s={type:"Literal",value:r};else if(r.includes(".")){const c=r.split(".");let u=-1,p;for(;++u<c.length;){const l=Ix(c[u])?{type:"Identifier",name:c[u]}:{type:"Literal",value:c[u]};p=p?{type:"MemberExpression",object:p,property:l,computed:!!(u&&l.type==="Literal"),optional:!1}:l}s=p}else s=Ix(r)&&!/^[a-z]/.test(r)?{type:"Identifier",name:r}:{type:"Literal",value:r};if(s.type==="Literal"){const c=s.value;return vh.call(e.components,c)?e.components[c]:c}if(e.evaluater)return e.evaluater.evaluateExpression(s);Ua(e)}function Ua(e,r){const i=new an("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:r,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=Eb+"#cannot-handle-mdx-estrees-without-createevaluater",i}function g2(e){const r={};let i;for(i in e)vh.call(e,i)&&(r[x2(i)]=e[i]);return r}function x2(e){let r=e.replace(e2,v2);return r.slice(0,3)==="ms-"&&(r="-"+r),r}function v2(e){return"-"+e.toLowerCase()}const kd={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},b2={};function _h(e,r){const i=b2,s=typeof i.includeImageAlt=="boolean"?i.includeImageAlt:!0,c=typeof i.includeHtml=="boolean"?i.includeHtml:!0;return Ab(e,s,c)}function Ab(e,r,i){if(y2(e)){if("value"in e)return e.type==="html"&&!i?"":e.value;if(r&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Yx(e.children,r,i)}return Array.isArray(e)?Yx(e,r,i):""}function Yx(e,r,i){const s=[];let c=-1;for(;++c<e.length;)s[c]=Ab(e[c],r,i);return s.join("")}function y2(e){return!!(e&&typeof e=="object")}const Kx=document.createElement("i");function $a(e){const r="&"+e+";";Kx.innerHTML=r;const i=Kx.textContent;return i.charCodeAt(i.length-1)===59&&e!=="semi"||i===r?!1:i}function Dn(e,r,i,s){const c=e.length;let u=0,p;if(r<0?r=-r>c?0:c+r:r=r>c?c:r,i=i>0?i:0,s.length<1e4)p=Array.from(s),p.unshift(r,i),e.splice(...p);else for(i&&e.splice(r,i);u<s.length;)p=s.slice(u,u+1e4),p.unshift(r,0),e.splice(...p),u+=1e4,r+=1e4}function $n(e,r){return e.length>0?(Dn(e,e.length,0,r),e):r}const Xx={}.hasOwnProperty;function Db(e){const r={};let i=-1;for(;++i<e.length;)_2(r,e[i]);return r}function _2(e,r){let i;for(i in r){const c=(Xx.call(e,i)?e[i]:void 0)||(e[i]={}),u=r[i];let p;if(u)for(p in u){Xx.call(c,p)||(c[p]=[]);const l=u[p];S2(c[p],Array.isArray(l)?l:l?[l]:[])}}}function S2(e,r){let i=-1;const s=[];for(;++i<r.length;)(r[i].add==="after"?e:s).push(r[i]);Dn(e,0,0,s)}function Lb(e,r){const i=Number.parseInt(e,r);return i<9||i===11||i>13&&i<32||i>126&&i<160||i>55295&&i<57344||i>64975&&i<65008||(i&65535)===65535||(i&65535)===65534||i>1114111?"�":String.fromCodePoint(i)}function Xn(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const cn=ii(/[A-Za-z]/),sn=ii(/[\dA-Za-z]/),w2=ii(/[#-'*+\--9=?A-Z^-~]/);function Al(e){return e!==null&&(e<32||e===127)}const Zd=ii(/\d/),C2=ii(/[\dA-Fa-f]/),k2=ii(/[!-/:-@[-`{-~]/);function Me(e){return e!==null&&e<-2}function yt(e){return e!==null&&(e<0||e===32)}function Xe(e){return e===-2||e===-1||e===32}const Fl=ii(new RegExp("\\p{P}|\\p{S}","u")),Ti=ii(/\s/);function ii(e){return r;function r(i){return i!==null&&i>-1&&e.test(String.fromCharCode(i))}}function Ds(e){const r=[];let i=-1,s=0,c=0;for(;++i<e.length;){const u=e.charCodeAt(i);let p="";if(u===37&&sn(e.charCodeAt(i+1))&&sn(e.charCodeAt(i+2)))c=2;else if(u<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(u))||(p=String.fromCharCode(u));else if(u>55295&&u<57344){const l=e.charCodeAt(i+1);u<56320&&l>56319&&l<57344?(p=String.fromCharCode(u,l),c=1):p="�"}else p=String.fromCharCode(u);p&&(r.push(e.slice(s,i),encodeURIComponent(p)),s=i+c+1,p=""),c&&(i+=c,c=0)}return r.join("")+e.slice(s)}function rt(e,r,i,s){const c=s?s-1:Number.POSITIVE_INFINITY;let u=0;return p;function p(h){return Xe(h)?(e.enter(i),l(h)):r(h)}function l(h){return Xe(h)&&u++<c?(e.consume(h),l):(e.exit(i),r(h))}}const E2={tokenize:j2};function j2(e){const r=e.attempt(this.parser.constructs.contentInitial,s,c);let i;return r;function s(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),rt(e,r,"linePrefix")}function c(l){return e.enter("paragraph"),u(l)}function u(l){const h=e.enter("chunkText",{contentType:"text",previous:i});return i&&(i.next=h),i=h,p(l)}function p(l){if(l===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(l);return}return Me(l)?(e.consume(l),e.exit("chunkText"),u):(e.consume(l),p)}}const N2={tokenize:T2},Zx={tokenize:A2};function T2(e){const r=this,i=[];let s=0,c,u,p;return l;function l(_){if(s<i.length){const j=i[s];return r.containerState=j[1],e.attempt(j[0].continuation,h,f)(_)}return f(_)}function h(_){if(s++,r.containerState._closeFlow){r.containerState._closeFlow=void 0,c&&v();const j=r.events.length;let A=j,N;for(;A--;)if(r.events[A][0]==="exit"&&r.events[A][1].type==="chunkFlow"){N=r.events[A][1].end;break}y(s);let L=j;for(;L<r.events.length;)r.events[L][1].end={...N},L++;return Dn(r.events,A+1,0,r.events.slice(j)),r.events.length=L,f(_)}return l(_)}function f(_){if(s===i.length){if(!c)return x(_);if(c.currentConstruct&&c.currentConstruct.concrete)return k(_);r.interrupt=!!(c.currentConstruct&&!c._gfmTableDynamicInterruptHack)}return r.containerState={},e.check(Zx,g,m)(_)}function g(_){return c&&v(),y(s),x(_)}function m(_){return r.parser.lazy[r.now().line]=s!==i.length,p=r.now().offset,k(_)}function x(_){return r.containerState={},e.attempt(Zx,S,k)(_)}function S(_){return s++,i.push([r.currentConstruct,r.containerState]),x(_)}function k(_){if(_===null){c&&v(),y(0),e.consume(_);return}return c=c||r.parser.flow(r.now()),e.enter("chunkFlow",{_tokenizer:c,contentType:"flow",previous:u}),C(_)}function C(_){if(_===null){b(e.exit("chunkFlow"),!0),y(0),e.consume(_);return}return Me(_)?(e.consume(_),b(e.exit("chunkFlow")),s=0,r.interrupt=void 0,l):(e.consume(_),C)}function b(_,j){const A=r.sliceStream(_);if(j&&A.push(null),_.previous=u,u&&(u.next=_),u=_,c.defineSkip(_.start),c.write(A),r.parser.lazy[_.start.line]){let N=c.events.length;for(;N--;)if(c.events[N][1].start.offset<p&&(!c.events[N][1].end||c.events[N][1].end.offset>p))return;const L=r.events.length;let T=L,B,H;for(;T--;)if(r.events[T][0]==="exit"&&r.events[T][1].type==="chunkFlow"){if(B){H=r.events[T][1].end;break}B=!0}for(y(s),N=L;N<r.events.length;)r.events[N][1].end={...H},N++;Dn(r.events,T+1,0,r.events.slice(L)),r.events.length=N}}function y(_){let j=i.length;for(;j-- >_;){const A=i[j];r.containerState=A[1],A[0].exit.call(r,e)}i.length=_}function v(){c.write([null]),u=void 0,c=void 0,r.containerState._closeFlow=void 0}}function A2(e,r,i){return rt(e,e.attempt(this.parser.constructs.document,r,i),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ns(e){if(e===null||yt(e)||Ti(e))return 1;if(Fl(e))return 2}function Ul(e,r,i){const s=[];let c=-1;for(;++c<e.length;){const u=e[c].resolveAll;u&&!s.includes(u)&&(r=u(r,i),s.push(u))}return r}const Qd={name:"attention",resolveAll:D2,tokenize:L2};function D2(e,r){let i=-1,s,c,u,p,l,h,f,g;for(;++i<e.length;)if(e[i][0]==="enter"&&e[i][1].type==="attentionSequence"&&e[i][1]._close){for(s=i;s--;)if(e[s][0]==="exit"&&e[s][1].type==="attentionSequence"&&e[s][1]._open&&r.sliceSerialize(e[s][1]).charCodeAt(0)===r.sliceSerialize(e[i][1]).charCodeAt(0)){if((e[s][1]._close||e[i][1]._open)&&(e[i][1].end.offset-e[i][1].start.offset)%3&&!((e[s][1].end.offset-e[s][1].start.offset+e[i][1].end.offset-e[i][1].start.offset)%3))continue;h=e[s][1].end.offset-e[s][1].start.offset>1&&e[i][1].end.offset-e[i][1].start.offset>1?2:1;const m={...e[s][1].end},x={...e[i][1].start};Qx(m,-h),Qx(x,h),p={type:h>1?"strongSequence":"emphasisSequence",start:m,end:{...e[s][1].end}},l={type:h>1?"strongSequence":"emphasisSequence",start:{...e[i][1].start},end:x},u={type:h>1?"strongText":"emphasisText",start:{...e[s][1].end},end:{...e[i][1].start}},c={type:h>1?"strong":"emphasis",start:{...p.start},end:{...l.end}},e[s][1].end={...p.start},e[i][1].start={...l.end},f=[],e[s][1].end.offset-e[s][1].start.offset&&(f=$n(f,[["enter",e[s][1],r],["exit",e[s][1],r]])),f=$n(f,[["enter",c,r],["enter",p,r],["exit",p,r],["enter",u,r]]),f=$n(f,Ul(r.parser.constructs.insideSpan.null,e.slice(s+1,i),r)),f=$n(f,[["exit",u,r],["enter",l,r],["exit",l,r],["exit",c,r]]),e[i][1].end.offset-e[i][1].start.offset?(g=2,f=$n(f,[["enter",e[i][1],r],["exit",e[i][1],r]])):g=0,Dn(e,s-1,i-s+3,f),i=s+f.length-g-2;break}}for(i=-1;++i<e.length;)e[i][1].type==="attentionSequence"&&(e[i][1].type="data");return e}function L2(e,r){const i=this.parser.constructs.attentionMarkers.null,s=this.previous,c=Ns(s);let u;return p;function p(h){return u=h,e.enter("attentionSequence"),l(h)}function l(h){if(h===u)return e.consume(h),l;const f=e.exit("attentionSequence"),g=Ns(h),m=!g||g===2&&c||i.includes(h),x=!c||c===2&&g||i.includes(s);return f._open=!!(u===42?m:m&&(c||!x)),f._close=!!(u===42?x:x&&(g||!m)),r(h)}}function Qx(e,r){e.column+=r,e.offset+=r,e._bufferIndex+=r}const R2={name:"autolink",tokenize:M2};function M2(e,r,i){let s=0;return c;function c(S){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(S),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),u}function u(S){return cn(S)?(e.consume(S),p):S===64?i(S):f(S)}function p(S){return S===43||S===45||S===46||sn(S)?(s=1,l(S)):f(S)}function l(S){return S===58?(e.consume(S),s=0,h):(S===43||S===45||S===46||sn(S))&&s++<32?(e.consume(S),l):(s=0,f(S))}function h(S){return S===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(S),e.exit("autolinkMarker"),e.exit("autolink"),r):S===null||S===32||S===60||Al(S)?i(S):(e.consume(S),h)}function f(S){return S===64?(e.consume(S),g):w2(S)?(e.consume(S),f):i(S)}function g(S){return sn(S)?m(S):i(S)}function m(S){return S===46?(e.consume(S),s=0,g):S===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(S),e.exit("autolinkMarker"),e.exit("autolink"),r):x(S)}function x(S){if((S===45||sn(S))&&s++<63){const k=S===45?x:m;return e.consume(S),k}return i(S)}}const Xa={partial:!0,tokenize:O2};function O2(e,r,i){return s;function s(u){return Xe(u)?rt(e,c,"linePrefix")(u):c(u)}function c(u){return u===null||Me(u)?r(u):i(u)}}const Rb={continuation:{tokenize:I2},exit:z2,name:"blockQuote",tokenize:B2};function B2(e,r,i){const s=this;return c;function c(p){if(p===62){const l=s.containerState;return l.open||(e.enter("blockQuote",{_container:!0}),l.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(p),e.exit("blockQuoteMarker"),u}return i(p)}function u(p){return Xe(p)?(e.enter("blockQuotePrefixWhitespace"),e.consume(p),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),r):(e.exit("blockQuotePrefix"),r(p))}}function I2(e,r,i){const s=this;return c;function c(p){return Xe(p)?rt(e,u,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(p):u(p)}function u(p){return e.attempt(Rb,r,i)(p)}}function z2(e){e.exit("blockQuote")}const Mb={name:"characterEscape",tokenize:H2};function H2(e,r,i){return s;function s(u){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(u),e.exit("escapeMarker"),c}function c(u){return k2(u)?(e.enter("characterEscapeValue"),e.consume(u),e.exit("characterEscapeValue"),e.exit("characterEscape"),r):i(u)}}const Ob={name:"characterReference",tokenize:P2};function P2(e,r,i){const s=this;let c=0,u,p;return l;function l(m){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(m),e.exit("characterReferenceMarker"),h}function h(m){return m===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(m),e.exit("characterReferenceMarkerNumeric"),f):(e.enter("characterReferenceValue"),u=31,p=sn,g(m))}function f(m){return m===88||m===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(m),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),u=6,p=C2,g):(e.enter("characterReferenceValue"),u=7,p=Zd,g(m))}function g(m){if(m===59&&c){const x=e.exit("characterReferenceValue");return p===sn&&!$a(s.sliceSerialize(x))?i(m):(e.enter("characterReferenceMarker"),e.consume(m),e.exit("characterReferenceMarker"),e.exit("characterReference"),r)}return p(m)&&c++<u?(e.consume(m),g):i(m)}}const Jx={partial:!0,tokenize:U2},ev={concrete:!0,name:"codeFenced",tokenize:F2};function F2(e,r,i){const s=this,c={partial:!0,tokenize:A};let u=0,p=0,l;return h;function h(N){return f(N)}function f(N){const L=s.events[s.events.length-1];return u=L&&L[1].type==="linePrefix"?L[2].sliceSerialize(L[1],!0).length:0,l=N,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),g(N)}function g(N){return N===l?(p++,e.consume(N),g):p<3?i(N):(e.exit("codeFencedFenceSequence"),Xe(N)?rt(e,m,"whitespace")(N):m(N))}function m(N){return N===null||Me(N)?(e.exit("codeFencedFence"),s.interrupt?r(N):e.check(Jx,C,j)(N)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),x(N))}function x(N){return N===null||Me(N)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),m(N)):Xe(N)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),rt(e,S,"whitespace")(N)):N===96&&N===l?i(N):(e.consume(N),x)}function S(N){return N===null||Me(N)?m(N):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),k(N))}function k(N){return N===null||Me(N)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),m(N)):N===96&&N===l?i(N):(e.consume(N),k)}function C(N){return e.attempt(c,j,b)(N)}function b(N){return e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),y}function y(N){return u>0&&Xe(N)?rt(e,v,"linePrefix",u+1)(N):v(N)}function v(N){return N===null||Me(N)?e.check(Jx,C,j)(N):(e.enter("codeFlowValue"),_(N))}function _(N){return N===null||Me(N)?(e.exit("codeFlowValue"),v(N)):(e.consume(N),_)}function j(N){return e.exit("codeFenced"),r(N)}function A(N,L,T){let B=0;return H;function H(I){return N.enter("lineEnding"),N.consume(I),N.exit("lineEnding"),q}function q(I){return N.enter("codeFencedFence"),Xe(I)?rt(N,Y,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(I):Y(I)}function Y(I){return I===l?(N.enter("codeFencedFenceSequence"),V(I)):T(I)}function V(I){return I===l?(B++,N.consume(I),V):B>=p?(N.exit("codeFencedFenceSequence"),Xe(I)?rt(N,F,"whitespace")(I):F(I)):T(I)}function F(I){return I===null||Me(I)?(N.exit("codeFencedFence"),L(I)):T(I)}}}function U2(e,r,i){const s=this;return c;function c(p){return p===null?i(p):(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),u)}function u(p){return s.parser.lazy[s.now().line]?i(p):r(p)}}const Ed={name:"codeIndented",tokenize:q2},$2={partial:!0,tokenize:W2};function q2(e,r,i){const s=this;return c;function c(f){return e.enter("codeIndented"),rt(e,u,"linePrefix",5)(f)}function u(f){const g=s.events[s.events.length-1];return g&&g[1].type==="linePrefix"&&g[2].sliceSerialize(g[1],!0).length>=4?p(f):i(f)}function p(f){return f===null?h(f):Me(f)?e.attempt($2,p,h)(f):(e.enter("codeFlowValue"),l(f))}function l(f){return f===null||Me(f)?(e.exit("codeFlowValue"),p(f)):(e.consume(f),l)}function h(f){return e.exit("codeIndented"),r(f)}}function W2(e,r,i){const s=this;return c;function c(p){return s.parser.lazy[s.now().line]?i(p):Me(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),c):rt(e,u,"linePrefix",5)(p)}function u(p){const l=s.events[s.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?r(p):Me(p)?c(p):i(p)}}const G2={name:"codeText",previous:Y2,resolve:V2,tokenize:K2};function V2(e){let r=e.length-4,i=3,s,c;if((e[i][1].type==="lineEnding"||e[i][1].type==="space")&&(e[r][1].type==="lineEnding"||e[r][1].type==="space")){for(s=i;++s<r;)if(e[s][1].type==="codeTextData"){e[i][1].type="codeTextPadding",e[r][1].type="codeTextPadding",i+=2,r-=2;break}}for(s=i-1,r++;++s<=r;)c===void 0?s!==r&&e[s][1].type!=="lineEnding"&&(c=s):(s===r||e[s][1].type==="lineEnding")&&(e[c][1].type="codeTextData",s!==c+2&&(e[c][1].end=e[s-1][1].end,e.splice(c+2,s-c-2),r-=s-c-2,s=c+2),c=void 0);return e}function Y2(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function K2(e,r,i){let s=0,c,u;return p;function p(m){return e.enter("codeText"),e.enter("codeTextSequence"),l(m)}function l(m){return m===96?(e.consume(m),s++,l):(e.exit("codeTextSequence"),h(m))}function h(m){return m===null?i(m):m===32?(e.enter("space"),e.consume(m),e.exit("space"),h):m===96?(u=e.enter("codeTextSequence"),c=0,g(m)):Me(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),h):(e.enter("codeTextData"),f(m))}function f(m){return m===null||m===32||m===96||Me(m)?(e.exit("codeTextData"),h(m)):(e.consume(m),f)}function g(m){return m===96?(e.consume(m),c++,g):c===s?(e.exit("codeTextSequence"),e.exit("codeText"),r(m)):(u.type="codeTextData",f(m))}}class X2{constructor(r){this.left=r?[...r]:[],this.right=[]}get(r){if(r<0||r>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+r+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return r<this.left.length?this.left[r]:this.right[this.right.length-r+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(r,i){const s=i??Number.POSITIVE_INFINITY;return s<this.left.length?this.left.slice(r,s):r>this.left.length?this.right.slice(this.right.length-s+this.left.length,this.right.length-r+this.left.length).reverse():this.left.slice(r).concat(this.right.slice(this.right.length-s+this.left.length).reverse())}splice(r,i,s){const c=i||0;this.setCursor(Math.trunc(r));const u=this.right.splice(this.right.length-c,Number.POSITIVE_INFINITY);return s&&Da(this.left,s),u.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(r){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(r)}pushMany(r){this.setCursor(Number.POSITIVE_INFINITY),Da(this.left,r)}unshift(r){this.setCursor(0),this.right.push(r)}unshiftMany(r){this.setCursor(0),Da(this.right,r.reverse())}setCursor(r){if(!(r===this.left.length||r>this.left.length&&this.right.length===0||r<0&&this.left.length===0))if(r<this.left.length){const i=this.left.splice(r,Number.POSITIVE_INFINITY);Da(this.right,i.reverse())}else{const i=this.right.splice(this.left.length+this.right.length-r,Number.POSITIVE_INFINITY);Da(this.left,i.reverse())}}}function Da(e,r){let i=0;if(r.length<1e4)e.push(...r);else for(;i<r.length;)e.push(...r.slice(i,i+1e4)),i+=1e4}function Bb(e){const r={};let i=-1,s,c,u,p,l,h,f;const g=new X2(e);for(;++i<g.length;){for(;i in r;)i=r[i];if(s=g.get(i),i&&s[1].type==="chunkFlow"&&g.get(i-1)[1].type==="listItemPrefix"&&(h=s[1]._tokenizer.events,u=0,u<h.length&&h[u][1].type==="lineEndingBlank"&&(u+=2),u<h.length&&h[u][1].type==="content"))for(;++u<h.length&&h[u][1].type!=="content";)h[u][1].type==="chunkText"&&(h[u][1]._isInFirstContentOfListItem=!0,u++);if(s[0]==="enter")s[1].contentType&&(Object.assign(r,Z2(g,i)),i=r[i],f=!0);else if(s[1]._container){for(u=i,c=void 0;u--;)if(p=g.get(u),p[1].type==="lineEnding"||p[1].type==="lineEndingBlank")p[0]==="enter"&&(c&&(g.get(c)[1].type="lineEndingBlank"),p[1].type="lineEnding",c=u);else if(!(p[1].type==="linePrefix"||p[1].type==="listItemIndent"))break;c&&(s[1].end={...g.get(c)[1].start},l=g.slice(c,i),l.unshift(s),g.splice(c,i-c+1,l))}}return Dn(e,0,Number.POSITIVE_INFINITY,g.slice(0)),!f}function Z2(e,r){const i=e.get(r)[1],s=e.get(r)[2];let c=r-1;const u=[];let p=i._tokenizer;p||(p=s.parser[i.contentType](i.start),i._contentTypeTextTrailing&&(p._contentTypeTextTrailing=!0));const l=p.events,h=[],f={};let g,m,x=-1,S=i,k=0,C=0;const b=[C];for(;S;){for(;e.get(++c)[1]!==S;);u.push(c),S._tokenizer||(g=s.sliceStream(S),S.next||g.push(null),m&&p.defineSkip(S.start),S._isInFirstContentOfListItem&&(p._gfmTasklistFirstContentOfListItem=!0),p.write(g),S._isInFirstContentOfListItem&&(p._gfmTasklistFirstContentOfListItem=void 0)),m=S,S=S.next}for(S=i;++x<l.length;)l[x][0]==="exit"&&l[x-1][0]==="enter"&&l[x][1].type===l[x-1][1].type&&l[x][1].start.line!==l[x][1].end.line&&(C=x+1,b.push(C),S._tokenizer=void 0,S.previous=void 0,S=S.next);for(p.events=[],S?(S._tokenizer=void 0,S.previous=void 0):b.pop(),x=b.length;x--;){const y=l.slice(b[x],b[x+1]),v=u.pop();h.push([v,v+y.length-1]),e.splice(v,2,y)}for(h.reverse(),x=-1;++x<h.length;)f[k+h[x][0]]=k+h[x][1],k+=h[x][1]-h[x][0]-1;return f}const Q2={resolve:eC,tokenize:tC},J2={partial:!0,tokenize:nC};function eC(e){return Bb(e),e}function tC(e,r){let i;return s;function s(l){return e.enter("content"),i=e.enter("chunkContent",{contentType:"content"}),c(l)}function c(l){return l===null?u(l):Me(l)?e.check(J2,p,u)(l):(e.consume(l),c)}function u(l){return e.exit("chunkContent"),e.exit("content"),r(l)}function p(l){return e.consume(l),e.exit("chunkContent"),i.next=e.enter("chunkContent",{contentType:"content",previous:i}),i=i.next,c}}function nC(e,r,i){const s=this;return c;function c(p){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),rt(e,u,"linePrefix")}function u(p){if(p===null||Me(p))return i(p);const l=s.events[s.events.length-1];return!s.parser.constructs.disable.null.includes("codeIndented")&&l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?r(p):e.interrupt(s.parser.constructs.flow,i,r)(p)}}function Ib(e,r,i,s,c,u,p,l,h){const f=h||Number.POSITIVE_INFINITY;let g=0;return m;function m(y){return y===60?(e.enter(s),e.enter(c),e.enter(u),e.consume(y),e.exit(u),x):y===null||y===32||y===41||Al(y)?i(y):(e.enter(s),e.enter(p),e.enter(l),e.enter("chunkString",{contentType:"string"}),C(y))}function x(y){return y===62?(e.enter(u),e.consume(y),e.exit(u),e.exit(c),e.exit(s),r):(e.enter(l),e.enter("chunkString",{contentType:"string"}),S(y))}function S(y){return y===62?(e.exit("chunkString"),e.exit(l),x(y)):y===null||y===60||Me(y)?i(y):(e.consume(y),y===92?k:S)}function k(y){return y===60||y===62||y===92?(e.consume(y),S):S(y)}function C(y){return!g&&(y===null||y===41||yt(y))?(e.exit("chunkString"),e.exit(l),e.exit(p),e.exit(s),r(y)):g<f&&y===40?(e.consume(y),g++,C):y===41?(e.consume(y),g--,C):y===null||y===32||y===40||Al(y)?i(y):(e.consume(y),y===92?b:C)}function b(y){return y===40||y===41||y===92?(e.consume(y),C):C(y)}}function zb(e,r,i,s,c,u){const p=this;let l=0,h;return f;function f(S){return e.enter(s),e.enter(c),e.consume(S),e.exit(c),e.enter(u),g}function g(S){return l>999||S===null||S===91||S===93&&!h||S===94&&!l&&"_hiddenFootnoteSupport"in p.parser.constructs?i(S):S===93?(e.exit(u),e.enter(c),e.consume(S),e.exit(c),e.exit(s),r):Me(S)?(e.enter("lineEnding"),e.consume(S),e.exit("lineEnding"),g):(e.enter("chunkString",{contentType:"string"}),m(S))}function m(S){return S===null||S===91||S===93||Me(S)||l++>999?(e.exit("chunkString"),g(S)):(e.consume(S),h||(h=!Xe(S)),S===92?x:m)}function x(S){return S===91||S===92||S===93?(e.consume(S),l++,m):m(S)}}function Hb(e,r,i,s,c,u){let p;return l;function l(x){return x===34||x===39||x===40?(e.enter(s),e.enter(c),e.consume(x),e.exit(c),p=x===40?41:x,h):i(x)}function h(x){return x===p?(e.enter(c),e.consume(x),e.exit(c),e.exit(s),r):(e.enter(u),f(x))}function f(x){return x===p?(e.exit(u),h(p)):x===null?i(x):Me(x)?(e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),rt(e,f,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),g(x))}function g(x){return x===p||x===null||Me(x)?(e.exit("chunkString"),f(x)):(e.consume(x),x===92?m:g)}function m(x){return x===p||x===92?(e.consume(x),g):g(x)}}function Ia(e,r){let i;return s;function s(c){return Me(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),i=!0,s):Xe(c)?rt(e,s,i?"linePrefix":"lineSuffix")(c):r(c)}}const rC={name:"definition",tokenize:sC},iC={partial:!0,tokenize:aC};function sC(e,r,i){const s=this;let c;return u;function u(S){return e.enter("definition"),p(S)}function p(S){return zb.call(s,e,l,i,"definitionLabel","definitionLabelMarker","definitionLabelString")(S)}function l(S){return c=Xn(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)),S===58?(e.enter("definitionMarker"),e.consume(S),e.exit("definitionMarker"),h):i(S)}function h(S){return yt(S)?Ia(e,f)(S):f(S)}function f(S){return Ib(e,g,i,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(S)}function g(S){return e.attempt(iC,m,m)(S)}function m(S){return Xe(S)?rt(e,x,"whitespace")(S):x(S)}function x(S){return S===null||Me(S)?(e.exit("definition"),s.parser.defined.push(c),r(S)):i(S)}}function aC(e,r,i){return s;function s(l){return yt(l)?Ia(e,c)(l):i(l)}function c(l){return Hb(e,u,i,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function u(l){return Xe(l)?rt(e,p,"whitespace")(l):p(l)}function p(l){return l===null||Me(l)?r(l):i(l)}}const oC={name:"hardBreakEscape",tokenize:lC};function lC(e,r,i){return s;function s(u){return e.enter("hardBreakEscape"),e.consume(u),c}function c(u){return Me(u)?(e.exit("hardBreakEscape"),r(u)):i(u)}}const cC={name:"headingAtx",resolve:uC,tokenize:dC};function uC(e,r){let i=e.length-2,s=3,c,u;return e[s][1].type==="whitespace"&&(s+=2),i-2>s&&e[i][1].type==="whitespace"&&(i-=2),e[i][1].type==="atxHeadingSequence"&&(s===i-1||i-4>s&&e[i-2][1].type==="whitespace")&&(i-=s+1===i?2:4),i>s&&(c={type:"atxHeadingText",start:e[s][1].start,end:e[i][1].end},u={type:"chunkText",start:e[s][1].start,end:e[i][1].end,contentType:"text"},Dn(e,s,i-s+1,[["enter",c,r],["enter",u,r],["exit",u,r],["exit",c,r]])),e}function dC(e,r,i){let s=0;return c;function c(g){return e.enter("atxHeading"),u(g)}function u(g){return e.enter("atxHeadingSequence"),p(g)}function p(g){return g===35&&s++<6?(e.consume(g),p):g===null||yt(g)?(e.exit("atxHeadingSequence"),l(g)):i(g)}function l(g){return g===35?(e.enter("atxHeadingSequence"),h(g)):g===null||Me(g)?(e.exit("atxHeading"),r(g)):Xe(g)?rt(e,l,"whitespace")(g):(e.enter("atxHeadingText"),f(g))}function h(g){return g===35?(e.consume(g),h):(e.exit("atxHeadingSequence"),l(g))}function f(g){return g===null||g===35||yt(g)?(e.exit("atxHeadingText"),l(g)):(e.consume(g),f)}}const hC=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],tv=["pre","script","style","textarea"],fC={concrete:!0,name:"htmlFlow",resolveTo:gC,tokenize:xC},pC={partial:!0,tokenize:bC},mC={partial:!0,tokenize:vC};function gC(e){let r=e.length;for(;r--&&!(e[r][0]==="enter"&&e[r][1].type==="htmlFlow"););return r>1&&e[r-2][1].type==="linePrefix"&&(e[r][1].start=e[r-2][1].start,e[r+1][1].start=e[r-2][1].start,e.splice(r-2,2)),e}function xC(e,r,i){const s=this;let c,u,p,l,h;return f;function f(U){return g(U)}function g(U){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(U),m}function m(U){return U===33?(e.consume(U),x):U===47?(e.consume(U),u=!0,C):U===63?(e.consume(U),c=3,s.interrupt?r:D):cn(U)?(e.consume(U),p=String.fromCharCode(U),b):i(U)}function x(U){return U===45?(e.consume(U),c=2,S):U===91?(e.consume(U),c=5,l=0,k):cn(U)?(e.consume(U),c=4,s.interrupt?r:D):i(U)}function S(U){return U===45?(e.consume(U),s.interrupt?r:D):i(U)}function k(U){const K="CDATA[";return U===K.charCodeAt(l++)?(e.consume(U),l===K.length?s.interrupt?r:Y:k):i(U)}function C(U){return cn(U)?(e.consume(U),p=String.fromCharCode(U),b):i(U)}function b(U){if(U===null||U===47||U===62||yt(U)){const K=U===47,te=p.toLowerCase();return!K&&!u&&tv.includes(te)?(c=1,s.interrupt?r(U):Y(U)):hC.includes(p.toLowerCase())?(c=6,K?(e.consume(U),y):s.interrupt?r(U):Y(U)):(c=7,s.interrupt&&!s.parser.lazy[s.now().line]?i(U):u?v(U):_(U))}return U===45||sn(U)?(e.consume(U),p+=String.fromCharCode(U),b):i(U)}function y(U){return U===62?(e.consume(U),s.interrupt?r:Y):i(U)}function v(U){return Xe(U)?(e.consume(U),v):H(U)}function _(U){return U===47?(e.consume(U),H):U===58||U===95||cn(U)?(e.consume(U),j):Xe(U)?(e.consume(U),_):H(U)}function j(U){return U===45||U===46||U===58||U===95||sn(U)?(e.consume(U),j):A(U)}function A(U){return U===61?(e.consume(U),N):Xe(U)?(e.consume(U),A):_(U)}function N(U){return U===null||U===60||U===61||U===62||U===96?i(U):U===34||U===39?(e.consume(U),h=U,L):Xe(U)?(e.consume(U),N):T(U)}function L(U){return U===h?(e.consume(U),h=null,B):U===null||Me(U)?i(U):(e.consume(U),L)}function T(U){return U===null||U===34||U===39||U===47||U===60||U===61||U===62||U===96||yt(U)?A(U):(e.consume(U),T)}function B(U){return U===47||U===62||Xe(U)?_(U):i(U)}function H(U){return U===62?(e.consume(U),q):i(U)}function q(U){return U===null||Me(U)?Y(U):Xe(U)?(e.consume(U),q):i(U)}function Y(U){return U===45&&c===2?(e.consume(U),$):U===60&&c===1?(e.consume(U),X):U===62&&c===4?(e.consume(U),O):U===63&&c===3?(e.consume(U),D):U===93&&c===5?(e.consume(U),R):Me(U)&&(c===6||c===7)?(e.exit("htmlFlowData"),e.check(pC,W,V)(U)):U===null||Me(U)?(e.exit("htmlFlowData"),V(U)):(e.consume(U),Y)}function V(U){return e.check(mC,F,W)(U)}function F(U){return e.enter("lineEnding"),e.consume(U),e.exit("lineEnding"),I}function I(U){return U===null||Me(U)?V(U):(e.enter("htmlFlowData"),Y(U))}function $(U){return U===45?(e.consume(U),D):Y(U)}function X(U){return U===47?(e.consume(U),p="",J):Y(U)}function J(U){if(U===62){const K=p.toLowerCase();return tv.includes(K)?(e.consume(U),O):Y(U)}return cn(U)&&p.length<8?(e.consume(U),p+=String.fromCharCode(U),J):Y(U)}function R(U){return U===93?(e.consume(U),D):Y(U)}function D(U){return U===62?(e.consume(U),O):U===45&&c===2?(e.consume(U),D):Y(U)}function O(U){return U===null||Me(U)?(e.exit("htmlFlowData"),W(U)):(e.consume(U),O)}function W(U){return e.exit("htmlFlow"),r(U)}}function vC(e,r,i){const s=this;return c;function c(p){return Me(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),u):i(p)}function u(p){return s.parser.lazy[s.now().line]?i(p):r(p)}}function bC(e,r,i){return s;function s(c){return e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),e.attempt(Xa,r,i)}}const yC={name:"htmlText",tokenize:_C};function _C(e,r,i){const s=this;let c,u,p;return l;function l(D){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(D),h}function h(D){return D===33?(e.consume(D),f):D===47?(e.consume(D),A):D===63?(e.consume(D),_):cn(D)?(e.consume(D),T):i(D)}function f(D){return D===45?(e.consume(D),g):D===91?(e.consume(D),u=0,k):cn(D)?(e.consume(D),v):i(D)}function g(D){return D===45?(e.consume(D),S):i(D)}function m(D){return D===null?i(D):D===45?(e.consume(D),x):Me(D)?(p=m,X(D)):(e.consume(D),m)}function x(D){return D===45?(e.consume(D),S):m(D)}function S(D){return D===62?$(D):D===45?x(D):m(D)}function k(D){const O="CDATA[";return D===O.charCodeAt(u++)?(e.consume(D),u===O.length?C:k):i(D)}function C(D){return D===null?i(D):D===93?(e.consume(D),b):Me(D)?(p=C,X(D)):(e.consume(D),C)}function b(D){return D===93?(e.consume(D),y):C(D)}function y(D){return D===62?$(D):D===93?(e.consume(D),y):C(D)}function v(D){return D===null||D===62?$(D):Me(D)?(p=v,X(D)):(e.consume(D),v)}function _(D){return D===null?i(D):D===63?(e.consume(D),j):Me(D)?(p=_,X(D)):(e.consume(D),_)}function j(D){return D===62?$(D):_(D)}function A(D){return cn(D)?(e.consume(D),N):i(D)}function N(D){return D===45||sn(D)?(e.consume(D),N):L(D)}function L(D){return Me(D)?(p=L,X(D)):Xe(D)?(e.consume(D),L):$(D)}function T(D){return D===45||sn(D)?(e.consume(D),T):D===47||D===62||yt(D)?B(D):i(D)}function B(D){return D===47?(e.consume(D),$):D===58||D===95||cn(D)?(e.consume(D),H):Me(D)?(p=B,X(D)):Xe(D)?(e.consume(D),B):$(D)}function H(D){return D===45||D===46||D===58||D===95||sn(D)?(e.consume(D),H):q(D)}function q(D){return D===61?(e.consume(D),Y):Me(D)?(p=q,X(D)):Xe(D)?(e.consume(D),q):B(D)}function Y(D){return D===null||D===60||D===61||D===62||D===96?i(D):D===34||D===39?(e.consume(D),c=D,V):Me(D)?(p=Y,X(D)):Xe(D)?(e.consume(D),Y):(e.consume(D),F)}function V(D){return D===c?(e.consume(D),c=void 0,I):D===null?i(D):Me(D)?(p=V,X(D)):(e.consume(D),V)}function F(D){return D===null||D===34||D===39||D===60||D===61||D===96?i(D):D===47||D===62||yt(D)?B(D):(e.consume(D),F)}function I(D){return D===47||D===62||yt(D)?B(D):i(D)}function $(D){return D===62?(e.consume(D),e.exit("htmlTextData"),e.exit("htmlText"),r):i(D)}function X(D){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(D),e.exit("lineEnding"),J}function J(D){return Xe(D)?rt(e,R,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):R(D)}function R(D){return e.enter("htmlTextData"),p(D)}}const Sh={name:"labelEnd",resolveAll:kC,resolveTo:EC,tokenize:jC},SC={tokenize:NC},wC={tokenize:TC},CC={tokenize:AC};function kC(e){let r=-1;const i=[];for(;++r<e.length;){const s=e[r][1];if(i.push(e[r]),s.type==="labelImage"||s.type==="labelLink"||s.type==="labelEnd"){const c=s.type==="labelImage"?4:2;s.type="data",r+=c}}return e.length!==i.length&&Dn(e,0,e.length,i),e}function EC(e,r){let i=e.length,s=0,c,u,p,l;for(;i--;)if(c=e[i][1],u){if(c.type==="link"||c.type==="labelLink"&&c._inactive)break;e[i][0]==="enter"&&c.type==="labelLink"&&(c._inactive=!0)}else if(p){if(e[i][0]==="enter"&&(c.type==="labelImage"||c.type==="labelLink")&&!c._balanced&&(u=i,c.type!=="labelLink")){s=2;break}}else c.type==="labelEnd"&&(p=i);const h={type:e[u][1].type==="labelLink"?"link":"image",start:{...e[u][1].start},end:{...e[e.length-1][1].end}},f={type:"label",start:{...e[u][1].start},end:{...e[p][1].end}},g={type:"labelText",start:{...e[u+s+2][1].end},end:{...e[p-2][1].start}};return l=[["enter",h,r],["enter",f,r]],l=$n(l,e.slice(u+1,u+s+3)),l=$n(l,[["enter",g,r]]),l=$n(l,Ul(r.parser.constructs.insideSpan.null,e.slice(u+s+4,p-3),r)),l=$n(l,[["exit",g,r],e[p-2],e[p-1],["exit",f,r]]),l=$n(l,e.slice(p+1)),l=$n(l,[["exit",h,r]]),Dn(e,u,e.length,l),e}function jC(e,r,i){const s=this;let c=s.events.length,u,p;for(;c--;)if((s.events[c][1].type==="labelImage"||s.events[c][1].type==="labelLink")&&!s.events[c][1]._balanced){u=s.events[c][1];break}return l;function l(x){return u?u._inactive?m(x):(p=s.parser.defined.includes(Xn(s.sliceSerialize({start:u.end,end:s.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(x),e.exit("labelMarker"),e.exit("labelEnd"),h):i(x)}function h(x){return x===40?e.attempt(SC,g,p?g:m)(x):x===91?e.attempt(wC,g,p?f:m)(x):p?g(x):m(x)}function f(x){return e.attempt(CC,g,m)(x)}function g(x){return r(x)}function m(x){return u._balanced=!0,i(x)}}function NC(e,r,i){return s;function s(m){return e.enter("resource"),e.enter("resourceMarker"),e.consume(m),e.exit("resourceMarker"),c}function c(m){return yt(m)?Ia(e,u)(m):u(m)}function u(m){return m===41?g(m):Ib(e,p,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(m)}function p(m){return yt(m)?Ia(e,h)(m):g(m)}function l(m){return i(m)}function h(m){return m===34||m===39||m===40?Hb(e,f,i,"resourceTitle","resourceTitleMarker","resourceTitleString")(m):g(m)}function f(m){return yt(m)?Ia(e,g)(m):g(m)}function g(m){return m===41?(e.enter("resourceMarker"),e.consume(m),e.exit("resourceMarker"),e.exit("resource"),r):i(m)}}function TC(e,r,i){const s=this;return c;function c(l){return zb.call(s,e,u,p,"reference","referenceMarker","referenceString")(l)}function u(l){return s.parser.defined.includes(Xn(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)))?r(l):i(l)}function p(l){return i(l)}}function AC(e,r,i){return s;function s(u){return e.enter("reference"),e.enter("referenceMarker"),e.consume(u),e.exit("referenceMarker"),c}function c(u){return u===93?(e.enter("referenceMarker"),e.consume(u),e.exit("referenceMarker"),e.exit("reference"),r):i(u)}}const DC={name:"labelStartImage",resolveAll:Sh.resolveAll,tokenize:LC};function LC(e,r,i){const s=this;return c;function c(l){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(l),e.exit("labelImageMarker"),u}function u(l){return l===91?(e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelImage"),p):i(l)}function p(l){return l===94&&"_hiddenFootnoteSupport"in s.parser.constructs?i(l):r(l)}}const RC={name:"labelStartLink",resolveAll:Sh.resolveAll,tokenize:MC};function MC(e,r,i){const s=this;return c;function c(p){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelLink"),u}function u(p){return p===94&&"_hiddenFootnoteSupport"in s.parser.constructs?i(p):r(p)}}const jd={name:"lineEnding",tokenize:OC};function OC(e,r){return i;function i(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),rt(e,r,"linePrefix")}}const kl={name:"thematicBreak",tokenize:BC};function BC(e,r,i){let s=0,c;return u;function u(f){return e.enter("thematicBreak"),p(f)}function p(f){return c=f,l(f)}function l(f){return f===c?(e.enter("thematicBreakSequence"),h(f)):s>=3&&(f===null||Me(f))?(e.exit("thematicBreak"),r(f)):i(f)}function h(f){return f===c?(e.consume(f),s++,h):(e.exit("thematicBreakSequence"),Xe(f)?rt(e,l,"whitespace")(f):l(f))}}const vn={continuation:{tokenize:PC},exit:UC,name:"list",tokenize:HC},IC={partial:!0,tokenize:$C},zC={partial:!0,tokenize:FC};function HC(e,r,i){const s=this,c=s.events[s.events.length-1];let u=c&&c[1].type==="linePrefix"?c[2].sliceSerialize(c[1],!0).length:0,p=0;return l;function l(S){const k=s.containerState.type||(S===42||S===43||S===45?"listUnordered":"listOrdered");if(k==="listUnordered"?!s.containerState.marker||S===s.containerState.marker:Zd(S)){if(s.containerState.type||(s.containerState.type=k,e.enter(k,{_container:!0})),k==="listUnordered")return e.enter("listItemPrefix"),S===42||S===45?e.check(kl,i,f)(S):f(S);if(!s.interrupt||S===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),h(S)}return i(S)}function h(S){return Zd(S)&&++p<10?(e.consume(S),h):(!s.interrupt||p<2)&&(s.containerState.marker?S===s.containerState.marker:S===41||S===46)?(e.exit("listItemValue"),f(S)):i(S)}function f(S){return e.enter("listItemMarker"),e.consume(S),e.exit("listItemMarker"),s.containerState.marker=s.containerState.marker||S,e.check(Xa,s.interrupt?i:g,e.attempt(IC,x,m))}function g(S){return s.containerState.initialBlankLine=!0,u++,x(S)}function m(S){return Xe(S)?(e.enter("listItemPrefixWhitespace"),e.consume(S),e.exit("listItemPrefixWhitespace"),x):i(S)}function x(S){return s.containerState.size=u+s.sliceSerialize(e.exit("listItemPrefix"),!0).length,r(S)}}function PC(e,r,i){const s=this;return s.containerState._closeFlow=void 0,e.check(Xa,c,u);function c(l){return s.containerState.furtherBlankLines=s.containerState.furtherBlankLines||s.containerState.initialBlankLine,rt(e,r,"listItemIndent",s.containerState.size+1)(l)}function u(l){return s.containerState.furtherBlankLines||!Xe(l)?(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,p(l)):(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,e.attempt(zC,r,p)(l))}function p(l){return s.containerState._closeFlow=!0,s.interrupt=void 0,rt(e,e.attempt(vn,r,i),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function FC(e,r,i){const s=this;return rt(e,c,"listItemIndent",s.containerState.size+1);function c(u){const p=s.events[s.events.length-1];return p&&p[1].type==="listItemIndent"&&p[2].sliceSerialize(p[1],!0).length===s.containerState.size?r(u):i(u)}}function UC(e){e.exit(this.containerState.type)}function $C(e,r,i){const s=this;return rt(e,c,"listItemPrefixWhitespace",s.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function c(u){const p=s.events[s.events.length-1];return!Xe(u)&&p&&p[1].type==="listItemPrefixWhitespace"?r(u):i(u)}}const nv={name:"setextUnderline",resolveTo:qC,tokenize:WC};function qC(e,r){let i=e.length,s,c,u;for(;i--;)if(e[i][0]==="enter"){if(e[i][1].type==="content"){s=i;break}e[i][1].type==="paragraph"&&(c=i)}else e[i][1].type==="content"&&e.splice(i,1),!u&&e[i][1].type==="definition"&&(u=i);const p={type:"setextHeading",start:{...e[s][1].start},end:{...e[e.length-1][1].end}};return e[c][1].type="setextHeadingText",u?(e.splice(c,0,["enter",p,r]),e.splice(u+1,0,["exit",e[s][1],r]),e[s][1].end={...e[u][1].end}):e[s][1]=p,e.push(["exit",p,r]),e}function WC(e,r,i){const s=this;let c;return u;function u(f){let g=s.events.length,m;for(;g--;)if(s.events[g][1].type!=="lineEnding"&&s.events[g][1].type!=="linePrefix"&&s.events[g][1].type!=="content"){m=s.events[g][1].type==="paragraph";break}return!s.parser.lazy[s.now().line]&&(s.interrupt||m)?(e.enter("setextHeadingLine"),c=f,p(f)):i(f)}function p(f){return e.enter("setextHeadingLineSequence"),l(f)}function l(f){return f===c?(e.consume(f),l):(e.exit("setextHeadingLineSequence"),Xe(f)?rt(e,h,"lineSuffix")(f):h(f))}function h(f){return f===null||Me(f)?(e.exit("setextHeadingLine"),r(f)):i(f)}}const GC={tokenize:VC};function VC(e){const r=this,i=e.attempt(Xa,s,e.attempt(this.parser.constructs.flowInitial,c,rt(e,e.attempt(this.parser.constructs.flow,c,e.attempt(Q2,c)),"linePrefix")));return i;function s(u){if(u===null){e.consume(u);return}return e.enter("lineEndingBlank"),e.consume(u),e.exit("lineEndingBlank"),r.currentConstruct=void 0,i}function c(u){if(u===null){e.consume(u);return}return e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),r.currentConstruct=void 0,i}}const YC={resolveAll:Fb()},KC=Pb("string"),XC=Pb("text");function Pb(e){return{resolveAll:Fb(e==="text"?ZC:void 0),tokenize:r};function r(i){const s=this,c=this.parser.constructs[e],u=i.attempt(c,p,l);return p;function p(g){return f(g)?u(g):l(g)}function l(g){if(g===null){i.consume(g);return}return i.enter("data"),i.consume(g),h}function h(g){return f(g)?(i.exit("data"),u(g)):(i.consume(g),h)}function f(g){if(g===null)return!0;const m=c[g];let x=-1;if(m)for(;++x<m.length;){const S=m[x];if(!S.previous||S.previous.call(s,s.previous))return!0}return!1}}}function Fb(e){return r;function r(i,s){let c=-1,u;for(;++c<=i.length;)u===void 0?i[c]&&i[c][1].type==="data"&&(u=c,c++):(!i[c]||i[c][1].type!=="data")&&(c!==u+2&&(i[u][1].end=i[c-1][1].end,i.splice(u+2,c-u-2),c=u+2),u=void 0);return e?e(i,s):i}}function ZC(e,r){let i=0;for(;++i<=e.length;)if((i===e.length||e[i][1].type==="lineEnding")&&e[i-1][1].type==="data"){const s=e[i-1][1],c=r.sliceStream(s);let u=c.length,p=-1,l=0,h;for(;u--;){const f=c[u];if(typeof f=="string"){for(p=f.length;f.charCodeAt(p-1)===32;)l++,p--;if(p)break;p=-1}else if(f===-2)h=!0,l++;else if(f!==-1){u++;break}}if(r._contentTypeTextTrailing&&i===e.length&&(l=0),l){const f={type:i===e.length||h||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:u?p:s.start._bufferIndex+p,_index:s.start._index+u,line:s.end.line,column:s.end.column-l,offset:s.end.offset-l},end:{...s.end}};s.end={...f.start},s.start.offset===s.end.offset?Object.assign(s,f):(e.splice(i,0,["enter",f,r],["exit",f,r]),i+=2)}i++}return e}const QC={42:vn,43:vn,45:vn,48:vn,49:vn,50:vn,51:vn,52:vn,53:vn,54:vn,55:vn,56:vn,57:vn,62:Rb},JC={91:rC},ek={[-2]:Ed,[-1]:Ed,32:Ed},tk={35:cC,42:kl,45:[nv,kl],60:fC,61:nv,95:kl,96:ev,126:ev},nk={38:Ob,92:Mb},rk={[-5]:jd,[-4]:jd,[-3]:jd,33:DC,38:Ob,42:Qd,60:[R2,yC],91:RC,92:[oC,Mb],93:Sh,95:Qd,96:G2},ik={null:[Qd,YC]},sk={null:[42,95]},ak={null:[]},ok=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:sk,contentInitial:JC,disable:ak,document:QC,flow:tk,flowInitial:ek,insideSpan:ik,string:nk,text:rk},Symbol.toStringTag,{value:"Module"}));function lk(e,r,i){let s={_bufferIndex:-1,_index:0,line:i&&i.line||1,column:i&&i.column||1,offset:i&&i.offset||0};const c={},u=[];let p=[],l=[];const h={attempt:L(A),check:L(N),consume:v,enter:_,exit:j,interrupt:L(N,{interrupt:!0})},f={code:null,containerState:{},defineSkip:C,events:[],now:k,parser:e,previous:null,sliceSerialize:x,sliceStream:S,write:m};let g=r.tokenize.call(f,h);return r.resolveAll&&u.push(r),f;function m(q){return p=$n(p,q),b(),p[p.length-1]!==null?[]:(T(r,0),f.events=Ul(u,f.events,f),f.events)}function x(q,Y){return uk(S(q),Y)}function S(q){return ck(p,q)}function k(){const{_bufferIndex:q,_index:Y,line:V,column:F,offset:I}=s;return{_bufferIndex:q,_index:Y,line:V,column:F,offset:I}}function C(q){c[q.line]=q.column,H()}function b(){let q;for(;s._index<p.length;){const Y=p[s._index];if(typeof Y=="string")for(q=s._index,s._bufferIndex<0&&(s._bufferIndex=0);s._index===q&&s._bufferIndex<Y.length;)y(Y.charCodeAt(s._bufferIndex));else y(Y)}}function y(q){g=g(q)}function v(q){Me(q)?(s.line++,s.column=1,s.offset+=q===-3?2:1,H()):q!==-1&&(s.column++,s.offset++),s._bufferIndex<0?s._index++:(s._bufferIndex++,s._bufferIndex===p[s._index].length&&(s._bufferIndex=-1,s._index++)),f.previous=q}function _(q,Y){const V=Y||{};return V.type=q,V.start=k(),f.events.push(["enter",V,f]),l.push(V),V}function j(q){const Y=l.pop();return Y.end=k(),f.events.push(["exit",Y,f]),Y}function A(q,Y){T(q,Y.from)}function N(q,Y){Y.restore()}function L(q,Y){return V;function V(F,I,$){let X,J,R,D;return Array.isArray(F)?W(F):"tokenize"in F?W([F]):O(F);function O(Q){return Z;function Z(z){const ae=z!==null&&Q[z],se=z!==null&&Q.null,ge=[...Array.isArray(ae)?ae:ae?[ae]:[],...Array.isArray(se)?se:se?[se]:[]];return W(ge)(z)}}function W(Q){return X=Q,J=0,Q.length===0?$:U(Q[J])}function U(Q){return Z;function Z(z){return D=B(),R=Q,Q.partial||(f.currentConstruct=Q),Q.name&&f.parser.constructs.disable.null.includes(Q.name)?te():Q.tokenize.call(Y?Object.assign(Object.create(f),Y):f,h,K,te)(z)}}function K(Q){return q(R,D),I}function te(Q){return D.restore(),++J<X.length?U(X[J]):$}}}function T(q,Y){q.resolveAll&&!u.includes(q)&&u.push(q),q.resolve&&Dn(f.events,Y,f.events.length-Y,q.resolve(f.events.slice(Y),f)),q.resolveTo&&(f.events=q.resolveTo(f.events,f))}function B(){const q=k(),Y=f.previous,V=f.currentConstruct,F=f.events.length,I=Array.from(l);return{from:F,restore:$};function $(){s=q,f.previous=Y,f.currentConstruct=V,f.events.length=F,l=I,H()}}function H(){s.line in c&&s.column<2&&(s.column=c[s.line],s.offset+=c[s.line]-1)}}function ck(e,r){const i=r.start._index,s=r.start._bufferIndex,c=r.end._index,u=r.end._bufferIndex;let p;if(i===c)p=[e[i].slice(s,u)];else{if(p=e.slice(i,c),s>-1){const l=p[0];typeof l=="string"?p[0]=l.slice(s):p.shift()}u>0&&p.push(e[c].slice(0,u))}return p}function uk(e,r){let i=-1;const s=[];let c;for(;++i<e.length;){const u=e[i];let p;if(typeof u=="string")p=u;else switch(u){case-5:{p="\r";break}case-4:{p=`
92
92
  `;break}case-3:{p=`\r
93
93
  `;break}case-2:{p=r?" ":" ";break}case-1:{if(!r&&c)continue;p=" ";break}default:p=String.fromCharCode(u)}c=u===-2,s.push(p)}return s.join("")}function dk(e){const s={constructs:Db([ok,...(e||{}).extensions||[]]),content:c(E2),defined:[],document:c(N2),flow:c(GC),lazy:{},string:c(KC),text:c(XC)};return s;function c(u){return p;function p(l){return lk(s,u,l)}}}function hk(e){for(;!Bb(e););return e}const rv=/[\0\t\n\r]/g;function fk(){let e=1,r="",i=!0,s;return c;function c(u,p,l){const h=[];let f,g,m,x,S;for(u=r+(typeof u=="string"?u.toString():new TextDecoder(p||void 0).decode(u)),m=0,r="",i&&(u.charCodeAt(0)===65279&&m++,i=void 0);m<u.length;){if(rv.lastIndex=m,f=rv.exec(u),x=f&&f.index!==void 0?f.index:u.length,S=u.charCodeAt(x),!f){r=u.slice(m);break}if(S===10&&m===x&&s)h.push(-3),s=void 0;else switch(s&&(h.push(-5),s=void 0),m<x&&(h.push(u.slice(m,x)),e+=x-m),S){case 0:{h.push(65533),e++;break}case 9:{for(g=Math.ceil(e/4)*4,h.push(-2);e++<g;)h.push(-1);break}case 10:{h.push(-4),e=1;break}default:s=!0,e=1}m=x+1}return l&&(s&&h.push(-5),r&&h.push(r),h.push(null)),h}}const pk=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function mk(e){return e.replace(pk,gk)}function gk(e,r,i){if(r)return r;if(i.charCodeAt(0)===35){const c=i.charCodeAt(1),u=c===120||c===88;return Lb(i.slice(u?2:1),u?16:10)}return $a(i)||e}const Ub={}.hasOwnProperty;function xk(e,r,i){return r&&typeof r=="object"&&(i=r,r=void 0),vk(i)(hk(dk(i).document().write(fk()(e,r,!0))))}function vk(e){const r={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:u(ht),autolinkProtocol:B,autolinkEmail:B,atxHeading:u(Oe),blockQuote:u(se),characterEscape:B,characterReference:B,codeFenced:u(ge),codeFencedFenceInfo:p,codeFencedFenceMeta:p,codeIndented:u(ge,p),codeText:u(ve,p),codeTextData:B,data:B,codeFlowValue:B,definition:u(Ne),definitionDestinationString:p,definitionLabelString:p,definitionTitleString:p,emphasis:u(De),hardBreakEscape:u(Fe),hardBreakTrailing:u(Fe),htmlFlow:u(ke,p),htmlFlowData:B,htmlText:u(ke,p),htmlTextData:B,image:u(lt),label:p,link:u(ht),listItem:u(Re),listItemValue:x,listOrdered:u(fe,m),listUnordered:u(fe),paragraph:u(Je),reference:U,referenceString:p,resourceDestinationString:p,resourceTitleString:p,setextHeading:u(Oe),strong:u(et),thematicBreak:u(ct)},exit:{atxHeading:h(),atxHeadingSequence:A,autolink:h(),autolinkEmail:ae,autolinkProtocol:z,blockQuote:h(),characterEscapeValue:H,characterReferenceMarkerHexadecimal:te,characterReferenceMarkerNumeric:te,characterReferenceValue:Q,characterReference:Z,codeFenced:h(b),codeFencedFence:C,codeFencedFenceInfo:S,codeFencedFenceMeta:k,codeFlowValue:H,codeIndented:h(y),codeText:h(I),codeTextData:H,data:H,definition:h(),definitionDestinationString:j,definitionLabelString:v,definitionTitleString:_,emphasis:h(),hardBreakEscape:h(Y),hardBreakTrailing:h(Y),htmlFlow:h(V),htmlFlowData:H,htmlText:h(F),htmlTextData:H,image:h(X),label:R,labelText:J,lineEnding:q,link:h($),listItem:h(),listOrdered:h(),listUnordered:h(),paragraph:h(),referenceString:K,resourceDestinationString:D,resourceTitleString:O,resource:W,setextHeading:h(T),setextHeadingLineSequence:L,setextHeadingText:N,strong:h(),thematicBreak:h()}};$b(r,(e||{}).mdastExtensions||[]);const i={};return s;function s(de){let be={type:"root",children:[]};const re={stack:[be],tokenStack:[],config:r,enter:l,exit:f,buffer:p,resume:g,data:i},Se=[];let Ce=-1;for(;++Ce<de.length;)if(de[Ce][1].type==="listOrdered"||de[Ce][1].type==="listUnordered")if(de[Ce][0]==="enter")Se.push(Ce);else{const He=Se.pop();Ce=c(de,He,Ce)}for(Ce=-1;++Ce<de.length;){const He=r[de[Ce][0]];Ub.call(He,de[Ce][1].type)&&He[de[Ce][1].type].call(Object.assign({sliceSerialize:de[Ce][2].sliceSerialize},re),de[Ce][1])}if(re.tokenStack.length>0){const He=re.tokenStack[re.tokenStack.length-1];(He[1]||iv).call(re,void 0,He[0])}for(be.position={start:Jr(de.length>0?de[0][1].start:{line:1,column:1,offset:0}),end:Jr(de.length>0?de[de.length-2][1].end:{line:1,column:1,offset:0})},Ce=-1;++Ce<r.transforms.length;)be=r.transforms[Ce](be)||be;return be}function c(de,be,re){let Se=be-1,Ce=-1,He=!1,Ae,st,it,Ct;for(;++Se<=re;){const $e=de[Se];switch($e[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{$e[0]==="enter"?Ce++:Ce--,Ct=void 0;break}case"lineEndingBlank":{$e[0]==="enter"&&(Ae&&!Ct&&!Ce&&!it&&(it=Se),Ct=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Ct=void 0}if(!Ce&&$e[0]==="enter"&&$e[1].type==="listItemPrefix"||Ce===-1&&$e[0]==="exit"&&($e[1].type==="listUnordered"||$e[1].type==="listOrdered")){if(Ae){let Ln=Se;for(st=void 0;Ln--;){const pe=de[Ln];if(pe[1].type==="lineEnding"||pe[1].type==="lineEndingBlank"){if(pe[0]==="exit")continue;st&&(de[st][1].type="lineEndingBlank",He=!0),pe[1].type="lineEnding",st=Ln}else if(!(pe[1].type==="linePrefix"||pe[1].type==="blockQuotePrefix"||pe[1].type==="blockQuotePrefixWhitespace"||pe[1].type==="blockQuoteMarker"||pe[1].type==="listItemIndent"))break}it&&(!st||it<st)&&(Ae._spread=!0),Ae.end=Object.assign({},st?de[st][1].start:$e[1].end),de.splice(st||Se,0,["exit",Ae,$e[2]]),Se++,re++}if($e[1].type==="listItemPrefix"){const Ln={type:"listItem",_spread:!1,start:Object.assign({},$e[1].start),end:void 0};Ae=Ln,de.splice(Se,0,["enter",Ln,$e[2]]),Se++,re++,it=void 0,Ct=!0}}}return de[be][1]._spread=He,re}function u(de,be){return re;function re(Se){l.call(this,de(Se),Se),be&&be.call(this,Se)}}function p(){this.stack.push({type:"fragment",children:[]})}function l(de,be,re){this.stack[this.stack.length-1].children.push(de),this.stack.push(de),this.tokenStack.push([be,re||void 0]),de.position={start:Jr(be.start),end:void 0}}function h(de){return be;function be(re){de&&de.call(this,re),f.call(this,re)}}function f(de,be){const re=this.stack.pop(),Se=this.tokenStack.pop();if(Se)Se[0].type!==de.type&&(be?be.call(this,de,Se[0]):(Se[1]||iv).call(this,de,Se[0]));else throw new Error("Cannot close `"+de.type+"` ("+Ba({start:de.start,end:de.end})+"): it’s not open");re.position.end=Jr(de.end)}function g(){return _h(this.stack.pop())}function m(){this.data.expectingFirstListItemValue=!0}function x(de){if(this.data.expectingFirstListItemValue){const be=this.stack[this.stack.length-2];be.start=Number.parseInt(this.sliceSerialize(de),10),this.data.expectingFirstListItemValue=void 0}}function S(){const de=this.resume(),be=this.stack[this.stack.length-1];be.lang=de}function k(){const de=this.resume(),be=this.stack[this.stack.length-1];be.meta=de}function C(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function b(){const de=this.resume(),be=this.stack[this.stack.length-1];be.value=de.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const de=this.resume(),be=this.stack[this.stack.length-1];be.value=de.replace(/(\r?\n|\r)$/g,"")}function v(de){const be=this.resume(),re=this.stack[this.stack.length-1];re.label=be,re.identifier=Xn(this.sliceSerialize(de)).toLowerCase()}function _(){const de=this.resume(),be=this.stack[this.stack.length-1];be.title=de}function j(){const de=this.resume(),be=this.stack[this.stack.length-1];be.url=de}function A(de){const be=this.stack[this.stack.length-1];if(!be.depth){const re=this.sliceSerialize(de).length;be.depth=re}}function N(){this.data.setextHeadingSlurpLineEnding=!0}function L(de){const be=this.stack[this.stack.length-1];be.depth=this.sliceSerialize(de).codePointAt(0)===61?1:2}function T(){this.data.setextHeadingSlurpLineEnding=void 0}function B(de){const re=this.stack[this.stack.length-1].children;let Se=re[re.length-1];(!Se||Se.type!=="text")&&(Se=Ge(),Se.position={start:Jr(de.start),end:void 0},re.push(Se)),this.stack.push(Se)}function H(de){const be=this.stack.pop();be.value+=this.sliceSerialize(de),be.position.end=Jr(de.end)}function q(de){const be=this.stack[this.stack.length-1];if(this.data.atHardBreak){const re=be.children[be.children.length-1];re.position.end=Jr(de.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&r.canContainEols.includes(be.type)&&(B.call(this,de),H.call(this,de))}function Y(){this.data.atHardBreak=!0}function V(){const de=this.resume(),be=this.stack[this.stack.length-1];be.value=de}function F(){const de=this.resume(),be=this.stack[this.stack.length-1];be.value=de}function I(){const de=this.resume(),be=this.stack[this.stack.length-1];be.value=de}function $(){const de=this.stack[this.stack.length-1];if(this.data.inReference){const be=this.data.referenceType||"shortcut";de.type+="Reference",de.referenceType=be,delete de.url,delete de.title}else delete de.identifier,delete de.label;this.data.referenceType=void 0}function X(){const de=this.stack[this.stack.length-1];if(this.data.inReference){const be=this.data.referenceType||"shortcut";de.type+="Reference",de.referenceType=be,delete de.url,delete de.title}else delete de.identifier,delete de.label;this.data.referenceType=void 0}function J(de){const be=this.sliceSerialize(de),re=this.stack[this.stack.length-2];re.label=mk(be),re.identifier=Xn(be).toLowerCase()}function R(){const de=this.stack[this.stack.length-1],be=this.resume(),re=this.stack[this.stack.length-1];if(this.data.inReference=!0,re.type==="link"){const Se=de.children;re.children=Se}else re.alt=be}function D(){const de=this.resume(),be=this.stack[this.stack.length-1];be.url=de}function O(){const de=this.resume(),be=this.stack[this.stack.length-1];be.title=de}function W(){this.data.inReference=void 0}function U(){this.data.referenceType="collapsed"}function K(de){const be=this.resume(),re=this.stack[this.stack.length-1];re.label=be,re.identifier=Xn(this.sliceSerialize(de)).toLowerCase(),this.data.referenceType="full"}function te(de){this.data.characterReferenceType=de.type}function Q(de){const be=this.sliceSerialize(de),re=this.data.characterReferenceType;let Se;re?(Se=Lb(be,re==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Se=$a(be);const Ce=this.stack[this.stack.length-1];Ce.value+=Se}function Z(de){const be=this.stack.pop();be.position.end=Jr(de.end)}function z(de){H.call(this,de);const be=this.stack[this.stack.length-1];be.url=this.sliceSerialize(de)}function ae(de){H.call(this,de);const be=this.stack[this.stack.length-1];be.url="mailto:"+this.sliceSerialize(de)}function se(){return{type:"blockquote",children:[]}}function ge(){return{type:"code",lang:null,meta:null,value:""}}function ve(){return{type:"inlineCode",value:""}}function Ne(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function De(){return{type:"emphasis",children:[]}}function Oe(){return{type:"heading",depth:0,children:[]}}function Fe(){return{type:"break"}}function ke(){return{type:"html",value:""}}function lt(){return{type:"image",title:null,url:"",alt:null}}function ht(){return{type:"link",title:null,url:"",children:[]}}function fe(de){return{type:"list",ordered:de.type==="listOrdered",start:null,spread:de._spread,children:[]}}function Re(de){return{type:"listItem",spread:de._spread,checked:null,children:[]}}function Je(){return{type:"paragraph",children:[]}}function et(){return{type:"strong",children:[]}}function Ge(){return{type:"text",value:""}}function ct(){return{type:"thematicBreak"}}}function Jr(e){return{line:e.line,column:e.column,offset:e.offset}}function $b(e,r){let i=-1;for(;++i<r.length;){const s=r[i];Array.isArray(s)?$b(e,s):bk(e,s)}}function bk(e,r){let i;for(i in r)if(Ub.call(r,i))switch(i){case"canContainEols":{const s=r[i];s&&e[i].push(...s);break}case"transforms":{const s=r[i];s&&e[i].push(...s);break}case"enter":case"exit":{const s=r[i];s&&Object.assign(e[i],s);break}}}function iv(e,r){throw e?new Error("Cannot close `"+e.type+"` ("+Ba({start:e.start,end:e.end})+"): a different token (`"+r.type+"`, "+Ba({start:r.start,end:r.end})+") is open"):new Error("Cannot close document, a token (`"+r.type+"`, "+Ba({start:r.start,end:r.end})+") is still open")}function yk(e){const r=this;r.parser=i;function i(s){return xk(s,{...r.data("settings"),...e,extensions:r.data("micromarkExtensions")||[],mdastExtensions:r.data("fromMarkdownExtensions")||[]})}}function _k(e,r){const i={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(r),!0)};return e.patch(r,i),e.applyData(r,i)}function Sk(e,r){const i={type:"element",tagName:"br",properties:{},children:[]};return e.patch(r,i),[e.applyData(r,i),{type:"text",value:`
@@ -145,6 +145,6 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
145
145
  `,children:i?"Reconnecting...":"Reconnect"})]})}function W3(){const e=dS(),r=e?"bg-amber-400":"bg-accent-primary";return o.jsxs("div",{className:"flex items-center gap-3 text-xs text-text-muted py-2",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsxs("span",{className:"flex gap-0.5",children:[o.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${r}`,style:{animationDelay:"0ms"}}),o.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${r}`,style:{animationDelay:"150ms"}}),o.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${r}`,style:{animationDelay:"300ms"}})]}),o.jsx("span",{className:"text-text-secondary",children:e?"Running... (abort in progress)":"Running"})]}),!e&&o.jsx("span",{className:"text-text-muted",children:"esc to interrupt"})]})}function G3({attachment:e,onRemove:r}){const i=s=>s<1024?`${s} B`:s<1048576?`${(s/1024).toFixed(1)} KB`:`${(s/1048576).toFixed(1)} MB`;return o.jsxs("div",{className:"relative inline-flex flex-col items-center p-2 bg-bg-tertiary rounded-lg border border-border",children:[o.jsx("button",{onClick:()=>r(e.id),className:"absolute -top-2 -right-2 w-5 h-5 bg-accent-error text-white rounded-full flex items-center justify-center hover:bg-accent-error/80 transition-colors","aria-label":`Remove ${e.filename}`,children:o.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),o.jsx("img",{src:e.data,alt:e.filename,className:"w-16 h-16 object-cover rounded-md bg-bg-secondary"}),o.jsx("div",{className:"mt-1 text-xs text-text-muted text-center max-w-16 truncate",title:e.filename,children:e.filename}),o.jsx("div",{className:"text-[10px] text-text-muted",children:i(e.size)})]})}function V3({history:e,selectedIndex:r,onSelect:i,onEscape:s,onNavigate:c}){const u=P.useRef(null),p=P.useRef(null);P.useEffect(()=>{p.current&&u.current&&p.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[r]);const l=f=>{switch(f.key){case"Enter":f.preventDefault(),e[r]&&i(e[r].content);break;case"Escape":f.preventDefault(),s();break;case"ArrowUp":f.preventDefault(),c("up");break;case"ArrowDown":f.preventDefault(),c("down");break}},h=f=>{i(f)};return o.jsx("div",{ref:u,role:"list",className:"mb-2 p-2 bg-bg-secondary border border-border rounded-lg overflow-y-auto max-h-64",onKeyDown:l,children:e.map((f,g)=>o.jsxs("div",{ref:g===r?p:null,role:"listitem",onClick:()=>h(f.content),className:`
146
146
  p-2 rounded cursor-pointer transition-colors
147
147
  ${g===r?"bg-accent-primary/20 border border-accent-primary":"hover:bg-bg-tertiary"}
148
- `,children:[o.jsxs("div",{className:"text-xs text-text-muted font-mono",children:[f.formattedTimestamp,f.sessionName&&o.jsxs(o.Fragment,{children:[" | ",o.jsx("span",{className:"text-accent-primary font-medium",children:f.sessionName})]})]}),o.jsx("div",{className:"text-sm text-text-primary mt-1",children:f.trimmedContent})]},f.id))})}const Y3={maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576};async function Fd(e,r={}){const i={...Y3,...r};if(!e.type.startsWith("image/"))throw new Error("File is not an image");if(!["image/png","image/jpeg","image/gif"].includes(e.type))throw new Error(`Unsupported image format: ${e.type}. Only PNG, JPG, and GIF are supported.`);if(e.size<=i.maxSizeBytes){const c=await e.arrayBuffer(),u=t4(c),p=`data:${e.type};base64,${u}`,l=await z0(p);return{dataUrl:p,mimeType:e.type,size:e.size,width:l.width,height:l.height}}return await K3(e,i)}async function K3(e,r){const i=await Z3(e),s=await z0(i),{width:c,height:u}=X3(s.width,s.height,r.maxWidth,r.maxHeight),p=Q3();p.width=c,p.height=u;const l=p.getContext("2d");if(!l)throw new Error("Failed to get canvas context");l.imageSmoothingEnabled=!0,l.imageSmoothingQuality="high",l.drawImage(s,0,0,c,u);let h=r.quality,f;do{if(f=p.toDataURL(e.type.startsWith("image/gif")?"image/png":e.type,h),Uv(f)<=r.maxSizeBytes||h<=.3)break;h-=.1}while(!0);const g=Uv(f);return{dataUrl:f,mimeType:e.type.startsWith("image/gif")?"image/png":e.type,size:g,width:c,height:u}}function X3(e,r,i,s){const c=e/r;return e>r&&e>i?{width:i,height:Math.round(i/c)}:r>e&&r>s?{width:Math.round(s*c),height:s}:{width:e,height:r}}function Z3(e){return new Promise((r,i)=>{const s=e4(),c=new s;c.onload=()=>r(c.result),c.onerror=()=>i(new Error("Failed to read file")),c.readAsDataURL(e)})}function z0(e){return new Promise((r,i)=>{const s=J3(),c=new s;c.onload=()=>r(c),c.onerror=()=>i(new Error("Failed to load image")),c.src=e})}function Q3(){var r;const e=Xh();if(!((r=e.document)!=null&&r.createElement))throw new Error("Image compression requires browser canvas APIs");return e.document.createElement("canvas")}function J3(){const e=Xh();if(!e.Image)throw new Error("Image compression requires browser image APIs");return e.Image}function e4(){const e=Xh();if(!e.FileReader)throw new Error("Image compression requires browser file APIs");return e.FileReader}function Xh(){return globalThis}function t4(e){const r=new Uint8Array(e);let i="";for(let s=0;s<r.byteLength;s++){const c=r[s];c!==void 0&&(i+=String.fromCharCode(c))}return btoa(i)}function Uv(e){const i=e.split(",")[1];return i?Math.round(i.length*3/4):0}function Ud(e){return["image/png","image/jpeg","image/gif"].includes(e.type)}function $d(e,r=50*1024*1024){return e.size>r?{valid:!1,error:`Image file is too large (${$v(e.size)}). Maximum size is ${$v(r)}.`}:{valid:!0}}function $v(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function n4(e){const r={};let i=null;for(const s of e){if(s.role==="user"&&!s.isSystemGenerated){i=s.id;continue}s.role==="assistant"&&s.promptContext&&i&&r[i]===void 0&&(r[i]=s.promptContext)}return r}function r4({isOpen:e,onClose:r,providerId:i,model:s}){const[c,u]=P.useState(s.contextWindow),[p,l]=P.useState(!1),h=Pt(m=>m.updateModelContext);if(P.useEffect(()=>{u(s.contextWindow)},[s]),!e)return null;const f=async()=>{c<1024||c>1e7||(l(!0),await h(i,s.id,c),l(!1),r())},g=()=>{u(s.contextWindow),r()};return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:o.jsxs("div",{className:"bg-bg-secondary rounded-lg shadow-xl max-w-md w-full mx-4 border border-border",children:[o.jsx("div",{className:"px-6 py-4 border-b border-border",children:o.jsx("h3",{className:"text-lg font-medium text-text-primary",children:"Model Properties"})}),o.jsxs("div",{className:"px-6 py-4 space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-text-secondary mb-1",children:"Model Name"}),o.jsx("p",{className:"text-text-primary bg-bg-tertiary px-3 py-2 rounded",children:s.id})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-text-secondary mb-1",children:"Context Window"}),o.jsx("input",{type:"number",min:1024,max:1e7,value:c,onChange:m=>u(parseInt(m.target.value)||0),className:"w-full bg-bg-tertiary border border-border rounded px-3 py-2 text-text-primary focus:outline-none focus:border-accent-primary"}),o.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Range: 1,024 - 10,000,000 tokens"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-text-secondary mb-1",children:"Source"}),o.jsxs("p",{className:"text-text-primary bg-bg-tertiary px-3 py-2 rounded",children:[s.source==="backend"&&"Auto-detected from backend",s.source==="user"&&"Manually set",s.source==="default"&&"Default value"]})]})]}),o.jsxs("div",{className:"px-6 py-4 border-t border-border flex justify-end gap-3",children:[o.jsx("button",{type:"button",onClick:g,disabled:p,className:"px-4 py-2 text-text-secondary hover:text-text-primary transition-colors disabled:opacity-50",children:"Cancel"}),o.jsx("button",{type:"button",onClick:f,disabled:p||c<1024||c>1e7,className:"px-4 py-2 bg-accent-primary text-white rounded hover:opacity-90 transition-opacity disabled:opacity-50 disabled:cursor-not-allowed",children:p?"Saving...":"Save"})]})]})})}function i4(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:`${e}`}function s4(){var F;const[,e]=ar(),r=Ee(I=>I.currentSession),i=Ee(I=>I.setSessionProvider),[s,c]=P.useState(!1),[u,p]=P.useState([]),[l,h]=P.useState(null),f=P.useRef(null),[g,m]=P.useState(null),x=P.useRef(new Set),S=Pt(I=>I.providers),k=Pt(I=>I.activeProviderId),C=Pt(I=>I.model);Pt(I=>I.backend);const b=Pt(I=>I.llmStatus),y=Pt(I=>I.activating),v=Pt(I=>I.activateProvider),_=Pt(I=>I.refreshModel),j=Pt(I=>I.refreshProviderModels);P.useEffect(()=>{function I($){f.current&&!f.current.contains($.target)&&(c(!1),p([]),x.current=new Set)}return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[]),P.useEffect(()=>{if(s){const I=S.map($=>$.id);p(I),I.forEach($=>{x.current.has($)||(x.current.add($),L($))})}},[s,S]),S.find(I=>I.id===k);const A=b==="disconnected",N=C?((F=C.split("/").pop())==null?void 0:F.replace(/-/g," "))??C:"detecting...",L=async I=>{h(I);try{await j(I)}catch{}finally{h(null)}},T=async I=>{if(I.id===k){u.includes(I.id)?p(u.filter($=>$!==I.id)):(p([...u,I.id]),L(I.id));return}r?(i(I.id,void 0),Pt.getState().syncFromSession(I.id,""),c(!1),p([])):await v(I.id)&&(c(!1),p([]))},B=I=>{u.includes(I.id)?p(u.filter($=>$!==I.id)):(p([...u,I.id]),L(I.id))},H=async(I,$)=>{I.stopPropagation(),x.current.delete($),await j($),await L($)},q=(I,$)=>{m({providerId:I,model:$})},Y=()=>{m(null)},V=async(I,$)=>{if(console.log("[ProviderSelector.handleModelClick] providerId:",I,"model:",$),r){console.log("[ProviderSelector.handleModelClick] Calling setSessionProvider"),i(I,$),Pt.getState().syncFromSession(I,$),p([]),c(!1);return}h("activating");try{(await ye(`/api/providers/${I}/activate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:$})})).ok&&(await Pt.getState().fetchConfig(),p([]),c(!1))}catch{}finally{h(null)}};return S.length===0?o.jsxs("button",{type:"button",onClick:()=>_(),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:A?"LLM server is offline. Click to retry.":C??"Click to refresh model",children:[A?o.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"LLM offline"}):o.jsx("span",{className:"text-sm text-accent-primary",children:N}),o.jsx("span",{className:"text-text-muted opacity-0 group-hover:opacity-100 transition-opacity",children:"↻"})]}):o.jsxs("div",{className:"relative",ref:f,children:[o.jsxs("button",{type:"button",onClick:()=>c(!s),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:"Click to switch provider or model",children:[A?o.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"offline"}):o.jsx("span",{className:"text-sm text-accent-primary",children:N}),o.jsx("svg",{className:`w-3 h-3 text-text-muted transition-transform ${s?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),s&&o.jsxs("div",{className:"absolute bottom-full right-0 mb-1 w-72 bg-bg-secondary border border-border rounded-lg shadow-lg z-50 overflow-hidden",children:[o.jsx("div",{className:"py-1",children:S.map(I=>{var $;return o.jsxs("div",{children:[o.jsxs("div",{className:`px-3 py-2 flex items-center justify-between ${I.id===k?"bg-bg-tertiary":"hover:bg-bg-tertiary"} ${y?"opacity-50 cursor-wait":"cursor-pointer"}`,children:[o.jsxs("div",{onClick:()=>!y&&T(I),className:"flex flex-col min-w-0 flex-1 cursor-pointer",children:[o.jsx("span",{className:`text-sm font-medium truncate ${I.id===k?"text-accent-primary":"text-text-primary"}`,children:I.name}),o.jsx("span",{className:"text-xs text-text-muted truncate",children:I.backend!=="auto"&&V1(I.backend)})]}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[I.id===k?o.jsx("span",{className:"text-accent-success",title:"Active",children:o.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:o.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})}):o.jsx("span",{className:"w-4"}),o.jsx("button",{type:"button",onClick:X=>{X.stopPropagation(),H(X,I.id)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Refresh models",children:o.jsx("svg",{className:`w-4 h-4 ${l===I.id?"animate-spin":""} ${I.id===k?"text-accent-primary":"text-text-muted"}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),o.jsx("button",{type:"button",onClick:X=>{X.stopPropagation(),B(I)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Show models",children:o.jsx("svg",{className:`w-4 h-4 transition-transform ${u.includes(I.id)?"rotate-180":""} ${I.id===k?"text-accent-primary":"text-text-muted"}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]})]}),u.includes(I.id)&&o.jsx("div",{className:"bg-bg-primary border-t border-border",children:l===I.id?o.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"Loading models..."}):($=I.models)!=null&&$.length?I.models.map(X=>{var J;return o.jsxs("button",{type:"button",onClick:()=>V(I.id,X.id),disabled:l==="activating",className:`w-full px-4 py-1.5 text-left hover:bg-bg-tertiary transition-colors text-sm flex items-center justify-between group ${l==="activating"?"opacity-50 cursor-wait":""} ${C===X.id?"text-accent-primary":"text-text-secondary"}`,children:[o.jsx("span",{className:"truncate flex-1",children:((J=X.id.split("/").pop())==null?void 0:J.replace(/-/g," "))??X.id}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[o.jsx("span",{className:"text-xs text-text-muted",children:i4(X.contextWindow)}),o.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),q(I.id,X)},className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-bg-tertiary rounded transition-opacity",title:"Edit model context",children:o.jsx("svg",{className:"w-3 h-3 text-text-muted",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})})]}),C===X.id&&o.jsx("span",{className:"text-accent-success flex-shrink-0 ml-1",children:o.jsx("svg",{className:"w-3.5 h-3.5",fill:"currentColor",viewBox:"0 0 20 20",children:o.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})})]},X.id)}):o.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"No models available"})})]},I.id)})}),o.jsx("div",{className:"border-t border-border px-3 py-2",children:o.jsx("button",{onClick:()=>e("/onboarding"),className:"text-xs text-accent-primary hover:underline",children:"Manage providers"})})]}),g&&o.jsx(r4,{isOpen:!0,onClose:Y,providerId:g.providerId,model:g.model})]})}const Tn=qn((e,r)=>({commands:[],defaultIds:[],modifiedIds:[],loading:!1,fetchDefaultIds:async()=>{try{const s=await(await ye("/api/commands/default-ids")).json();e({defaultIds:s.ids??[]})}catch{}},fetchCommands:async()=>{e({loading:!0});try{const s=await(await ye("/api/commands")).json();e({commands:s.commands??[],defaultIds:s.defaultIds??r().defaultIds,modifiedIds:s.modifiedIds??[],loading:!1})}catch{e({loading:!1})}},fetchCommand:async i=>{try{const s=await ye(`/api/commands/${i}`);return s.ok?await s.json():null}catch{return null}},createCommand:async i=>{try{const s=await ye("/api/commands",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});return s.ok?(await r().fetchCommands(),{success:!0}):{success:!1,error:(await s.json()).error}}catch{return{success:!1,error:"Network error"}}},updateCommand:async(i,s)=>{try{const c=await ye(`/api/commands/${i}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});return c.ok?(await r().fetchCommands(),{success:!0}):{success:!1,error:(await c.json()).error}}catch{return{success:!1,error:"Network error"}}},deleteCommand:async i=>{try{return(await ye(`/api/commands/${i}`,{method:"DELETE"})).ok?(e({commands:r().commands.filter(c=>c.id!==i)}),!0):!1}catch{return!1}},restoreDefault:async i=>{try{return(await ye(`/api/commands/${i}/restore-default`,{method:"POST"})).ok?(await r().fetchCommands(),!0):!1}catch{return!1}},restoreAllDefaults:async()=>{try{return(await ye("/api/commands/restore-all-defaults",{method:"POST"})).ok?(await r().fetchCommands(),!0):!1}catch{return!1}}}));function a4(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function H0({isOpen:e,onClose:r,initialEditId:i}){const s=Tn(z=>z.commands),c=Tn(z=>z.modifiedIds),u=Tn(z=>z.loading),p=Tn(z=>z.fetchCommands),l=Tn(z=>z.fetchCommand),h=Tn(z=>z.createCommand),f=Tn(z=>z.updateCommand),g=Tn(z=>z.deleteCommand),m=Tn(z=>z.restoreDefault),x=Tn(z=>z.restoreAllDefaults),[S,k]=P.useState("list"),[C,b]=P.useState(null),[y,v]=P.useState(null),_=rn(z=>z.agents),j=rn(z=>z.fetchAgents),A=_.filter(z=>!z.subagent),[N,L]=P.useState(""),[T,B]=P.useState(""),[H,q]=P.useState(""),[Y,V]=P.useState(""),[F,I]=P.useState(""),[$,X]=P.useState(!1),[J,R]=P.useState(null),[D,O]=P.useState(!1);P.useEffect(()=>{e&&(p(),j(),v(null),R(null),O(!1),i?(k("edit"),b(i),I(""),l(i).then(z=>{z&&(L(z.metadata.name),B(z.metadata.id),q(z.prompt),V(z.metadata.agentMode??""))})):(k("list"),b(null)))},[e,p,j,l,i]);const W=()=>{b(null),L(""),B(""),q(""),V(""),I(""),k("edit")},U=async z=>{const ae=await l(z);ae&&(b(z),L(ae.metadata.name),B(ae.metadata.id),q(ae.prompt),V(ae.metadata.agentMode??""),I(""),k("edit"))},K=async z=>{await g(z),v(null)},te=async()=>{const z=C??T;if(!z||!N||!H){I("Name and message are required.");return}X(!0),I("");const ae={metadata:{id:z,name:N,...Y?{agentMode:Y}:{}},prompt:H},se=C?await f(C,ae):await h(ae);if(X(!1),!se.success){I(se.error??"Failed to save command.");return}i?r():k("list")},Q=()=>{i?r():k("list")},Z=z=>{L(z),C||B(a4(z))};return S==="edit"?o.jsx(un,{isOpen:e,onClose:Q,title:C?"Edit Command":"New Command",size:"xl",children:o.jsxs("div",{className:"space-y-3",children:[F&&o.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded",children:F}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Name"}),o.jsx("input",{value:N,onChange:z=>Z(z.target.value),placeholder:"My Command",className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary"})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["ID ",C&&o.jsx("span",{className:"text-text-muted",children:"(read-only)"})]}),o.jsx("input",{value:T,onChange:z=>!C&&B(z.target.value),readOnly:!!C,placeholder:"my-command",className:`w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary ${C?"opacity-60":""}`})]})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["Agent Mode ",o.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),o.jsxs("select",{value:Y,onChange:z=>V(z.target.value),className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",children:[o.jsx("option",{value:"",children:"None (keep current mode)"}),A.map(z=>o.jsx("option",{value:z.id,children:z.name},z.id))]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Message"}),o.jsx("textarea",{value:H,onChange:z=>q(z.target.value),placeholder:"The message that will be sent when this command is triggered...",className:"w-full h-64 px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-accent-primary"})]}),o.jsxs("div",{className:"flex justify-end gap-2 pt-2 border-t border-border",children:[o.jsx(dt,{variant:"secondary",onClick:Q,children:"Cancel"}),o.jsx(dt,{variant:"primary",onClick:te,disabled:$||!N||!H,children:$?"Saving...":"Save"})]})]})}):o.jsxs(un,{isOpen:e,onClose:r,title:"Commands",size:"lg",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsx("p",{className:"text-text-secondary text-sm",children:"Commands are pre-defined messages you can send with a single click."}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:[c.length>0&&(D?o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:async()=>{await x(),O(!1)},className:"px-1.5 py-0.5 rounded bg-amber-500/20 text-amber-400 text-xs hover:bg-amber-500/30 transition-colors",children:"Confirm"}),o.jsx("button",{onClick:()=>O(!1),className:"px-1.5 py-0.5 rounded text-text-muted text-xs hover:bg-bg-primary transition-colors",children:"Cancel"})]}):o.jsx("button",{onClick:()=>O(!0),className:"px-2 py-1 rounded text-xs text-text-muted hover:text-amber-400 hover:bg-amber-500/10 transition-colors",title:"Restore all commands to defaults",children:"Restore Defaults"})),o.jsx(dt,{variant:"primary",size:"sm",onClick:W,children:"+ New"})]})]}),u&&s.length===0?o.jsx("div",{className:"text-text-muted text-sm",children:"Loading commands..."}):s.length===0?o.jsx("div",{className:"text-text-muted text-sm",children:"No commands created yet."}):o.jsx("div",{className:"space-y-2",children:s.map(z=>o.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[o.jsx("div",{className:"min-w-0 flex-1 mr-3",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-text-primary text-sm font-medium",children:z.name}),c.includes(z.id)&&o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-amber-500/15 text-amber-400",children:"modified"})]})}),o.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[c.includes(z.id)&&(J===z.id?o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:async()=>{await m(z.id),R(null)},className:"px-1.5 py-0.5 rounded bg-amber-500/20 text-amber-400 text-xs hover:bg-amber-500/30 transition-colors",children:"Restore"}),o.jsx("button",{onClick:()=>R(null),className:"px-1.5 py-0.5 rounded text-text-muted text-xs hover:bg-bg-primary transition-colors",children:"Cancel"})]}):o.jsx("button",{onClick:()=>R(z.id),className:"p-1.5 rounded hover:bg-bg-primary text-text-muted hover:text-amber-400 transition-colors",title:"Restore default",children:o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})),o.jsx(ri,{onClick:()=>U(z.id)}),y===z.id?o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:()=>K(z.id),className:"px-1.5 py-0.5 rounded bg-accent-error/20 text-accent-error text-xs hover:bg-accent-error/30 transition-colors",children:"Delete"}),o.jsx("button",{onClick:()=>v(null),className:"px-1.5 py-0.5 rounded text-text-muted text-xs hover:bg-bg-primary transition-colors",children:"Cancel"})]}):o.jsx("button",{onClick:()=>v(z.id),className:"p-1.5 rounded hover:bg-bg-primary text-text-muted hover:text-accent-error transition-colors",title:"Delete command",children:o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})]},z.id))})]})}function o4({onSendCommand:e,onOpenManager:r,textareaContent:i,attachments:s}){const[c,u]=P.useState(!1),[p,l]=P.useState(""),[h,f]=P.useState(0),[g,m]=P.useState(null),x=P.useRef(null),S=P.useRef(null),k=Tn(j=>j.commands),C=Tn(j=>j.fetchCommands);P.useEffect(()=>{c&&(C(),l(""),f(0),requestAnimationFrame(()=>{var j;return(j=S.current)==null?void 0:j.focus()}))},[c,C]),P.useEffect(()=>{if(!c)return;const j=A=>{x.current&&!x.current.contains(A.target)&&u(!1)};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[c]);const b=k.filter(j=>{if(!p)return!0;const A=p.toLowerCase();return j.name.toLowerCase().includes(A)}),y=j=>{switch(j.key){case"ArrowDown":j.preventDefault(),f(A=>Math.min(A+1,b.length-1));break;case"ArrowUp":j.preventDefault(),f(A=>Math.max(A-1,0));break;case"Enter":j.preventDefault(),b[h]&&v(b[h].id);break;case"Escape":j.preventDefault(),u(!1);break}},v=async j=>{const A=await Tn.getState().fetchCommand(j);A&&e(A.prompt,A.metadata.agentMode,i,s),u(!1)},_=()=>{u(!1),r()};return o.jsxs("div",{ref:x,className:"relative",children:[o.jsxs("button",{type:"button",onClick:()=>u(j=>!j),className:"flex items-center gap-1 text-sm text-text-muted hover:text-text-primary transition-colors",children:["Commands",o.jsx("svg",{className:`w-3 h-3 transition-transform ${c?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),c&&o.jsxs("div",{className:"absolute bottom-full right-0 mb-1 w-72 bg-bg-secondary border border-border rounded-lg shadow-xl z-50",onKeyDown:y,children:[o.jsx("div",{className:"p-2 border-b border-border",children:o.jsx("input",{ref:S,value:p,onChange:j=>{l(j.target.value),f(0)},placeholder:"Search commands...",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary"})}),o.jsx("div",{className:"overflow-y-auto max-h-64 p-1",children:b.length===0?o.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:k.length===0?"No commands yet":"No matches"}):b.map((j,A)=>o.jsxs("div",{className:`flex items-center gap-1 px-3 py-2 rounded transition-colors group ${A===h?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[o.jsx("button",{type:"button",onClick:()=>v(j.id),className:"flex-1 text-left",children:o.jsx("div",{className:"text-sm text-text-primary font-medium",children:j.name})}),o.jsx(ri,{className:"opacity-0 group-hover:opacity-100",onClick:N=>{N.stopPropagation(),u(!1),m(j.id)}})]},j.id))}),o.jsx("div",{className:"border-t border-border p-1",children:o.jsx("button",{type:"button",onClick:_,className:"w-full text-left px-3 py-1.5 rounded text-sm text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors",children:"Manage Commands..."})})]}),o.jsx(H0,{isOpen:!!g,onClose:()=>m(null),initialEditId:g})]})}function l4(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function c4(e){let r=1;for(;e.some(i=>i.id===`s${r}`);)r++;return`s${r}`}const u4=[{value:"agent",label:"Agent"},{value:"sub_agent",label:"Sub-Agent"},{value:"shell",label:"Shell"}],P0={all_criteria_passed:"All passed",all_criteria_completed_or_passed:"All completed",any_criteria_blocked:"Blocked",has_pending_criteria:"Pending/Failed",step_result:"Result",always:"Always"},F0=[{value:"all_criteria_passed",label:"All criteria passed"},{value:"all_criteria_completed_or_passed",label:"All criteria completed or passed"},{value:"any_criteria_blocked",label:"Any criteria blocked (retry limit)"},{value:"has_pending_criteria",label:"Has pending or failed criteria"},{value:"step_result",label:"Step result is..."},{value:"always",label:"Always (fallback)"}],Ci=150,jr=54,_s=80,jn=30,Ss=70,qv=100,ki=50,_l=50,Wv=4;function Zh(e,r){if(e.type==="agent"){const i=r.find(s=>s.id===e.toolMode);return{name:(i==null?void 0:i.name)??(e.toolMode||"Agent"),color:(i==null?void 0:i.color)||"#3b82f6"}}if(e.type==="sub_agent"){const i=r.find(s=>s.id===e.subAgentType);return{name:(i==null?void 0:i.name)??(e.subAgentType||"Sub-Agent"),color:(i==null?void 0:i.color)||"#a855f7"}}return{name:"Shell",color:"#22c55e"}}function d4(e,r,i,s){const c=_l+ki+Ci+qv+Ci+ki+_l,u=c/2,p=_l+ki+Ci/2,l=_l+ki+Ci+qv+Ci/2,h=[],f=[],g=new Map,m=e.filter(F=>F.type==="agent"||F.type==="shell"),x=e.filter(F=>F.type==="sub_agent"),S=x.length>0,k=S?p:u,C=m.length>0?l:u,b=ki+jn/2;if(h.push({id:"$start",type:"terminal",label:"Start",cx:k,cy:b,w:_s,h:jn}),g.set("$start",{cx:k,cy:b,w:_s,h:jn}),e.length===0){const F=b+jn/2+Ss*2+jn/2;return h.push({id:"$done",type:"terminal",label:"Done",cx:k,cy:F,w:_s,h:jn}),g.set("$done",{cx:k,cy:F,w:_s,h:jn}),{nodes:h,edges:f,width:c,height:F+jn/2+ki,posMap:g}}const y=b+jn/2+Ss,v=(F,I)=>{F.forEach(($,X)=>{const J=y+X*(jr+Ss)+jr/2,{name:R,color:D}=Zh($,s);h.push({id:$.id,type:"step",label:R,color:D,cx:I,cy:J,w:Ci,h:jr}),g.set($.id,{cx:I,cy:J,w:Ci,h:jr})})};v(m,k),v(x,C);const _=m.length>0?y+(m.length-1)*(jr+Ss)+jr/2:b,j=S?y+(x.length-1)*(jr+Ss)+jr/2:b,A=Math.max(_,j)+jr/2+Ss+jn/2;h.push({id:"$done",type:"terminal",label:"Done",cx:k,cy:A,w:_s,h:jn}),g.set("$done",{cx:k,cy:A,w:_s,h:jn});const N=[];r&&g.has(r)&&N.push({from:"$start",to:r,label:i,edgeKey:"start",direction:"down",backEdgeIndex:0});let L=0;for(const F of e)F.transitions.forEach((I,$)=>{if(!I.goto||!g.has(I.goto))return;const X=g.get(F.id),J=g.get(I.goto),R=I.when.type==="step_result"?`${I.when.result}`:P0[I.when.type]??I.when.type,D=F.id===I.goto;let O;D?O="back":J.cy>X.cy+1?O="down":J.cy<X.cy-1?O="back":O="same",N.push({from:F.id,to:I.goto,label:R,edgeKey:`${F.id}:${$}`,direction:O,backEdgeIndex:O==="back"?L++:0})});const T=new Map,B=new Map,H=new Map,q=new Map;for(const F of N)F.direction==="down"&&(T.set(F.from,(T.get(F.from)??0)+1),B.set(F.to,(B.get(F.to)??0)+1));const Y=new Map,V=new Map;for(const F of N){if(F.direction!=="same")continue;const I=[F.from,F.to].sort().join("|");Y.set(I,(Y.get(I)??0)+1)}for(const F of N){if(F.direction==="back"||F.direction==="same"){let O=0;if(F.direction==="same"){const W=[F.from,F.to].sort().join("|");O=V.get(W)??0,V.set(W,O+1)}f.push({...F,fromPort:0,toPort:0,sameEdgeIndex:O});continue}const I=T.get(F.from)??1,$=B.get(F.to)??1,X=H.get(F.from)??0,J=q.get(F.to)??0;H.set(F.from,X+1),q.set(F.to,J+1);const R=I===1?0:-.6+1.2*X/(I-1),D=$===1?0:-.6+1.2*J/($-1);f.push({...F,fromPort:R,toPort:D,sameEdgeIndex:0})}return{nodes:h,edges:f,width:c,height:A+jn/2+ki,posMap:g}}function h4({steps:e,entryStep:r,selectedNodeId:i,selectedEdgeKey:s,startConditionLabel:c,agentTypes:u,onSelectNode:p,onSelectEdge:l,onRemoveStep:h,onCreateTransition:f,onReconnectTo:g,onReconnectFrom:m,onDeleteTransition:x}){const S=P.useRef(null),k=P.useRef(!1),[C,b]=P.useState(null),[y,v]=P.useState(null),[_,j]=P.useState(null),{nodes:A,edges:N,width:L,height:T,posMap:B}=P.useMemo(()=>d4(e,r,c,u),[e,r,c,u]),H=P.useCallback(K=>{var ae;const te=S.current;if(!te)return{x:0,y:0};const Q=te.createSVGPoint();Q.x=K.clientX,Q.y=K.clientY;const Z=(ae=te.getScreenCTM())==null?void 0:ae.inverse();if(!Z)return{x:0,y:0};const z=Q.matrixTransform(Z);return{x:z.x,y:z.y}},[]),q=P.useCallback(K=>!K||!y||K==="$start"?!1:y.type==="reconnect-from"?K!=="$done":!0,[y]),Y=P.useCallback((K,te)=>{K.stopPropagation(),K.preventDefault();const Q=H(K);v({type:"new",fromNodeId:te,mouseX:Q.x,mouseY:Q.y})},[H]),V=P.useCallback((K,te)=>{K.stopPropagation(),K.preventDefault();const Q=H(K);v({type:"reconnect-to",fromNodeId:te.from,edgeKey:te.edgeKey,mouseX:Q.x,mouseY:Q.y})},[H]),F=P.useCallback((K,te)=>{K.stopPropagation(),K.preventDefault();const Q=H(K);v({type:"reconnect-from",fromNodeId:te.from,fixedTargetId:te.to,edgeKey:te.edgeKey,mouseX:Q.x,mouseY:Q.y})},[H]),I=P.useCallback(K=>{if(!y)return;const te=H(K);v(Q=>Q?{...Q,mouseX:te.x,mouseY:te.y}:null)},[y,H]),$=P.useCallback(()=>{y&&(k.current=!0,_&&q(_)&&(y.type==="new"?f(y.fromNodeId,_):y.type==="reconnect-to"?g(y.edgeKey,_):y.type==="reconnect-from"&&m(y.edgeKey,_)),v(null),j(null))},[y,_,q,f,g,m]),X=P.useCallback(()=>{if(k.current){k.current=!1;return}p(null),l(null)},[p,l]);P.useEffect(()=>{const K=te=>{te.target instanceof HTMLInputElement||te.target instanceof HTMLTextAreaElement||te.target instanceof HTMLSelectElement||(te.key==="Delete"||te.key==="Backspace")&&s&&s!=="start"&&(te.preventDefault(),x(s),l(null))};return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},[s,x,l]);const J=K=>{const te=B.get(K.from),Q=B.get(K.to);if(!te||!Q)return null;let Z,z,ae,se="middle",ge,ve;if(K.direction==="down"){const Ne=te.cx+K.fromPort*(te.w/2-10),De=te.cy+te.h/2,Oe=Q.cx+K.toPort*(Q.w/2-10),Fe=Q.cy-Q.h/2,ke=Fe-De,lt=Oe-Ne;Z=`M ${Ne} ${De} C ${Ne} ${De+ke*.4}, ${Oe-lt*.2} ${Fe-ke*.1}, ${Oe} ${Fe}`,z=Ne+(Oe-Ne)*.5,ae=De+ke*.6,ge={x:Ne,y:De},ve={x:Oe,y:Fe}}else if(K.direction==="back"){const Ne=K.from===K.to,De=te.cx>=L/2,Oe=K.backEdgeIndex*16,Fe=De?L-20-Oe:20+Oe;if(Ne){const ke=te.cx>=L/2,lt=30+K.backEdgeIndex*14,ht=te.cy-te.h/2,fe=ke?te.cx+te.w/2:te.cx-te.w/2,Re=ke?fe+lt:fe-lt,Je=te.cx+(ke?te.w/4:-te.w/4),et=ht-20-K.backEdgeIndex*10;Z=`M ${fe} ${te.cy} C ${Re} ${te.cy}, ${Re} ${et}, ${Je} ${ht}`,z=Re+10,ae=et+4,se="middle",ge={x:fe,y:te.cy},ve={x:Je,y:ht}}else{const ke=De?te.cx+te.w/2:te.cx-te.w/2,lt=Q.cx+(De?Q.w/4:-Q.w/4),ht=Math.min(te.cy,Q.cy)-Q.h/2-18-K.backEdgeIndex*14;Z=`M ${ke} ${te.cy} L ${Fe} ${te.cy} L ${Fe} ${ht} L ${lt} ${ht} L ${lt} ${Q.cy-Q.h/2}`,z=Fe,ae=(te.cy+ht)/2,se=De?"start":"end",ge={x:ke,y:te.cy},ve={x:lt,y:Q.cy-Q.h/2}}}else{const Ne=Q.cx>te.cx,De=K.sameEdgeIndex===0?-12:12,Oe=Ne?te.cx+te.w/2:te.cx-te.w/2,Fe=Ne?Q.cx-Q.w/2:Q.cx+Q.w/2,ke=te.cy+De,lt=Q.cy+De,ht=(Oe+Fe)/2;Z=`M ${Oe} ${ke} C ${ht} ${ke}, ${ht} ${lt}, ${Fe} ${lt}`,z=ht,ae=(ke+lt)/2-6,ge={x:Oe,y:ke},ve={x:Fe,y:lt}}return{path:Z,labelX:z,labelY:ae,labelAnchor:se,fromPt:ge,toPt:ve}},R=(K,te)=>{const Q=J(K);if(!Q)return null;const{path:Z,labelX:z,labelY:ae,labelAnchor:se}=Q,ge=s===K.edgeKey,ve=K.label&&!(K.from==="$start"&&K.label==="Always");return o.jsxs("g",{children:[o.jsx("path",{d:Z,fill:"none",stroke:"transparent",strokeWidth:14,className:"cursor-pointer",onClick:Ne=>{Ne.stopPropagation(),l(ge?null:K.edgeKey)}}),o.jsx("path",{d:Z,fill:"none",stroke:ge?"#58a6ff":"#484f58",strokeWidth:ge?2.2:1.2,markerEnd:ge?"url(#arrow-selected)":"url(#arrow)",pointerEvents:"none"}),ve&&o.jsx("text",{x:z+(se==="start"?5:se==="end"?-5:0),y:ae+3,textAnchor:se,className:"text-[8px]",fill:ge?"#79c0ff":"#8b949e",style:{paintOrder:"stroke",stroke:"#0d1117",strokeWidth:3,strokeLinejoin:"round"},pointerEvents:"none",children:K.label})]},te)},D=()=>{if(!s||y)return null;const K=N.find(ae=>ae.edgeKey===s);if(!K)return null;const te=J(K);if(!te)return null;const{fromPt:Q,toPt:Z}=te,z=6;return o.jsxs(o.Fragment,{children:[K.edgeKey!=="start"&&o.jsx("circle",{cx:Q.x,cy:Q.y,r:z,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:ae=>F(ae,K)}),o.jsx("circle",{cx:Z.x,cy:Z.y,r:z,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:ae=>V(ae,K)})]})},O=()=>{if(!y)return null;let K,te,Q,Z;if(y.type==="reconnect-from"){const se=B.get(y.fixedTargetId);if(!se)return null;K=y.mouseX,te=y.mouseY,Q=se.cx,Z=se.cy-se.h/2}else{const se=B.get(y.fromNodeId);if(!se)return null;K=se.cx,te=se.cy+se.h/2,Q=y.mouseX,Z=y.mouseY}const z=Z-te,ae=Math.abs(z)>10?`M ${K} ${te} C ${K} ${te+z*.4}, ${Q} ${Z-z*.4}, ${Q} ${Z}`:`M ${K} ${te} L ${Q} ${Z}`;return o.jsx("path",{d:ae,fill:"none",stroke:"#58a6ff",strokeWidth:2,strokeDasharray:"6 3",strokeOpacity:.7,pointerEvents:"none"})},W=K=>{const te=K.cy+K.h/2,Q=(y==null?void 0:y.fromNodeId)===K.id;return o.jsx("circle",{cx:K.cx,cy:te,r:Wv,fill:Q?"#58a6ff":"#1c2128",stroke:Q?"#58a6ff":"#484f58",strokeWidth:1.5,strokeOpacity:Q?1:.5,className:"cursor-crosshair",onMouseDown:Z=>Y(Z,K.id)})},U=K=>{const te=K.cy-K.h/2,Q=y&&_===K.id&&q(K.id);return o.jsx("circle",{cx:K.cx,cy:te,r:Wv,fill:Q?"#3fb950":"#1c2128",stroke:Q?"#3fb950":"#484f58",strokeWidth:1.5,strokeOpacity:Q?1:.5})};return o.jsxs("svg",{ref:S,viewBox:`0 0 ${L} ${T}`,className:"block w-full",preserveAspectRatio:"xMidYMin meet",onMouseMove:I,onMouseUp:$,onClick:X,children:[o.jsxs("defs",{children:[o.jsx("marker",{id:"arrow",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"7",markerHeight:"5",orient:"auto",children:o.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#484f58"})}),o.jsx("marker",{id:"arrow-selected",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"7",markerHeight:"5",orient:"auto",children:o.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#58a6ff"})})]}),N.map((K,te)=>R(K,te)),A.map(K=>{const te=i===K.id,Q=K.cx-K.w/2,Z=K.cy-K.h/2,z=C===K.id,ae=y&&_===K.id&&q(K.id);if(K.type==="terminal"){const ge=K.id==="$start",ve=ge?"#58a6ff":"#3fb950",Ne=ge,De=!ge;return o.jsxs("g",{onClick:Oe=>{Oe.stopPropagation(),ge&&l("start")},className:ge?"cursor-pointer":void 0,children:[ae&&o.jsx("rect",{x:Q-3,y:Z-3,width:K.w+6,height:K.h+6,rx:K.h/2+3,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),ge&&s==="start"&&o.jsx("rect",{x:Q-3,y:Z-3,width:K.w+6,height:K.h+6,rx:K.h/2+3,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),o.jsx("rect",{x:Q,y:Z,width:K.w,height:K.h,rx:K.h/2,fill:ve,fillOpacity:.08,stroke:ve,strokeOpacity:.4,strokeWidth:1.5}),o.jsx("text",{x:K.cx,y:K.cy+4,textAnchor:"middle",fill:ve,className:"text-[10px] font-medium",pointerEvents:"none",children:K.label}),Ne&&W(K),De&&U(K)]},K.id)}const se=K.color??"#6b7280";return o.jsxs("g",{onClick:ge=>{ge.stopPropagation(),p(te?null:K.id)},onMouseEnter:()=>b(K.id),onMouseLeave:()=>b(null),className:"cursor-pointer",children:[ae&&o.jsx("rect",{x:Q-3,y:Z-3,width:K.w+6,height:K.h+6,rx:12,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),te&&o.jsx("rect",{x:Q-3,y:Z-3,width:K.w+6,height:K.h+6,rx:12,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),o.jsx("rect",{x:Q,y:Z,width:K.w,height:K.h,rx:10,fill:se,fillOpacity:.08,stroke:se,strokeOpacity:.6,strokeWidth:te?2:1.5}),o.jsx("text",{x:K.cx,y:K.cy+4,textAnchor:"middle",fill:"#c9d1d9",className:"text-[11px] font-medium",pointerEvents:"none",children:K.label}),W(K),U(K),z&&!y&&o.jsxs("g",{onClick:ge=>{ge.stopPropagation(),h(K.id)},className:"cursor-pointer",children:[o.jsx("circle",{cx:Q+K.w-2,cy:Z+2,r:8,fill:"#0d1117",fillOpacity:.9,stroke:"#f85149",strokeOpacity:.5,strokeWidth:1}),o.jsx("line",{x1:Q+K.w-5,y1:Z-1,x2:Q+K.w+1,y2:Z+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"}),o.jsx("line",{x1:Q+K.w+1,y1:Z-1,x2:Q+K.w-5,y2:Z+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"})]})]},K.id)}),y&&A.map(K=>q(K.id)?o.jsx("rect",{x:K.cx-K.w/2-8,y:K.cy-K.h/2-8,width:K.w+16,height:K.h+16,fill:"transparent",rx:12,onMouseEnter:()=>j(K.id),onMouseLeave:()=>j(null),onMouseUp:te=>{te.stopPropagation(),$()}},`drop-${K.id}`):null),O(),D()]})}const Kn="w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",Ni="w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",en="block text-[11px] text-text-secondary mb-0.5";function f4({fromLabel:e,toLabel:r,condition:i,fromStep:s,agentTypes:c,onUpdateCondition:u,onDelete:p}){const l=s&&(s.type==="sub_agent"||s.type==="agent")?c.find(f=>f.id===(s.type==="sub_agent"?s.subAgentType:s.toolMode)):void 0,h=(l==null?void 0:l.results)&&l.results.length>0;return o.jsxs("div",{className:"space-y-3 text-sm",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-blue-500/15 text-blue-300",children:"Transition"}),o.jsx("button",{onClick:p,className:"p-1 rounded text-text-muted hover:text-accent-error text-xs",children:"Delete"})]}),o.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[o.jsx("span",{className:"font-medium text-text-primary",children:e}),o.jsx("svg",{className:"w-3.5 h-3.5 shrink-0 text-text-muted",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14 5l7 7m0 0l-7 7m7-7H3"})}),o.jsx("span",{className:"font-medium text-text-primary",children:r})]}),o.jsxs("div",{children:[o.jsx("label",{className:en,children:"Condition"}),o.jsx("select",{value:i.type,onChange:f=>{u(f.target.value==="step_result"?{type:"step_result",result:"success"}:{type:f.target.value})},className:Ni,children:F0.map(f=>o.jsx("option",{value:f.value,children:f.label},f.value))})]}),i.type==="step_result"&&o.jsxs("div",{children:[o.jsx("label",{className:en,children:"Result"}),h?o.jsx("select",{value:i.result??l.results[0],onChange:f=>{u({type:"step_result",result:f.target.value})},className:Ni,children:l.results.map(f=>o.jsx("option",{value:f,children:f},f))}):o.jsx("input",{type:"text",value:i.result??"success",onChange:f=>u({type:"step_result",result:f.target.value}),placeholder:"e.g. success, passed, failed",className:Kn})]}),o.jsx("p",{className:"text-text-muted text-[10px]",children:"Drag handles to reconnect. Press Delete to remove."})]})}function qd({variables:e,onInsert:r}){return e.length===0?null:o.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:e.map(i=>o.jsx("button",{type:"button",onClick:()=>r(i.name),title:i.description,className:"px-1.5 py-0.5 rounded text-[10px] font-mono bg-bg-primary border border-border text-text-secondary hover:text-accent-primary hover:border-accent-primary/40 transition-colors",children:`{{${i.name}}}`},i.name))})}function p4({step:e,isEntry:r,agentTypes:i,transitionCount:s,templateVariables:c,onUpdate:u,onRemove:p,onSetEntry:l}){const{color:h,name:f}=Zh(e,i);return o.jsxs("div",{className:"space-y-3 text-sm",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold",style:{backgroundColor:h+"20",color:h},children:f}),r&&o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-accent-primary/15 text-accent-primary",children:"Entry"})]}),o.jsxs("div",{className:"flex items-center gap-1",children:[!r&&o.jsx("button",{onClick:l,className:"p-1 rounded text-text-muted hover:text-accent-primary text-xs",children:"Set entry"}),o.jsx("button",{onClick:p,className:"p-1 rounded text-text-muted hover:text-accent-error text-xs",children:"Delete"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:en,children:"Type"}),o.jsx("select",{value:e.type,onChange:g=>{const m=g.target.value,x=m==="sub_agent"?"verification":"build";if(m==="agent"){const S=i.find(k=>!k.subagent);u({...e,type:m,phase:x,toolMode:(S==null?void 0:S.id)??"builder",name:(S==null?void 0:S.name)??"Agent"})}else if(m==="sub_agent"){const S=i.find(k=>k.subagent);u({...e,type:m,phase:x,subAgentType:(S==null?void 0:S.id)??"",name:(S==null?void 0:S.name)??"Sub-Agent"})}else u({...e,type:m,phase:x,name:"Shell"})},className:Ni,children:u4.map(g=>o.jsx("option",{value:g.value,children:g.label},g.value))})]}),e.type==="agent"&&o.jsxs("div",{children:[o.jsx("label",{className:en,children:"Agent Type"}),o.jsx("select",{value:e.toolMode??"builder",onChange:g=>{const m=i.find(x=>x.id===g.target.value);u({...e,toolMode:g.target.value,name:(m==null?void 0:m.name)??g.target.value})},className:Ni,children:i.filter(g=>!g.subagent).map(g=>o.jsx("option",{value:g.id,children:g.name},g.id))})]}),e.type==="sub_agent"&&o.jsxs("div",{children:[o.jsx("label",{className:en,children:"Sub-Agent Type"}),o.jsxs("select",{value:e.subAgentType??"",onChange:g=>{const m=i.find(x=>x.id===g.target.value);u({...e,subAgentType:g.target.value,name:(m==null?void 0:m.name)??g.target.value})},className:Ni,children:[o.jsx("option",{value:"",children:"— select —"}),i.filter(g=>g.subagent).map(g=>o.jsx("option",{value:g.id,children:g.name},g.id))]})]}),(e.type==="agent"||e.type==="sub_agent")&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("label",{className:en,children:"Prompt"}),o.jsx("textarea",{value:e.prompt??"",onChange:g=>u({...e,prompt:g.target.value||void 0}),rows:6,className:`${Kn} resize-y text-xs`,placeholder:"Injected on first entry..."}),o.jsx(qd,{variables:c,onInsert:g=>u({...e,prompt:(e.prompt??"")+`{{${g}}}`})})]}),o.jsxs("div",{children:[o.jsx("label",{className:en,children:"Nudge Prompt"}),o.jsx("textarea",{value:e.nudgePrompt??"",onChange:g=>u({...e,nudgePrompt:g.target.value||void 0}),rows:6,className:`${Kn} resize-y text-xs`,placeholder:"Injected on re-entry..."}),o.jsx(qd,{variables:c,onInsert:g=>u({...e,nudgePrompt:(e.nudgePrompt??"")+`{{${g}}}`})})]})]}),e.type==="shell"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("label",{className:en,children:"Command"}),o.jsx("textarea",{value:e.command??"",onChange:g=>u({...e,command:g.target.value}),rows:3,className:`${Kn} font-mono text-xs resize-y`,placeholder:"cd {{workdir}} && npm run lint"}),o.jsx(qd,{variables:c,onInsert:g=>u({...e,command:(e.command??"")+`{{${g}}}`})})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{children:[o.jsx("label",{className:en,children:"Timeout (ms)"}),o.jsx("input",{type:"number",value:e.timeout??6e4,onChange:g=>u({...e,timeout:Number(g.target.value)}),className:`${Kn} font-mono text-xs`})]}),o.jsxs("div",{children:[o.jsx("label",{className:en,children:"Success Codes"}),o.jsx("input",{value:(e.successExitCodes??[0]).join(", "),onChange:g=>u({...e,successExitCodes:g.target.value.split(",").map(m=>Number(m.trim())).filter(m=>!isNaN(m))}),className:`${Kn} font-mono text-xs`})]})]})]}),o.jsx("div",{className:"pt-1 border-t border-border/50",children:o.jsxs("p",{className:"text-text-muted text-[10px]",children:[s," outgoing transition",s!==1?"s":""," — drag from the bottom port to connect."]})})]})}const Gv=[];function U0({isOpen:e,onClose:r,initialEditId:i}){const s=Vt(pe=>pe.workflows),c=Vt(pe=>pe.modifiedIds),u=Vt(pe=>pe.loading),p=Vt(pe=>pe.templateVariables),l=Vt(pe=>pe.fetchWorkflows),h=Vt(pe=>pe.fetchWorkflow),f=Vt(pe=>pe.fetchTemplateVariables),g=Vt(pe=>pe.createWorkflow),m=Vt(pe=>pe.updateWorkflow),x=Vt(pe=>pe.deleteWorkflow),S=Vt(pe=>pe.restoreDefault),k=Vt(pe=>pe.restoreAllDefaults),[C,b]=P.useState("list"),[y,v]=P.useState(null),[_,j]=P.useState(null),[A,N]=P.useState(null),[L,T]=P.useState(null),[B,H]=P.useState(""),[q,Y]=P.useState(""),[V,F]=P.useState(""),[I,$]=P.useState("1.0.0"),[X,J]=P.useState("#3b82f6"),[R,D]=P.useState(""),[O,W]=P.useState(50),[U,K]=P.useState(Gv),[te,Q]=P.useState({type:"always"}),[Z,z]=P.useState(""),[ae,se]=P.useState(!1),[ge,ve]=P.useState([]),[Ne,De]=P.useState(null),[Oe,Fe]=P.useState(!1);P.useEffect(()=>{e&&(l(),f(),ye("/api/agents").then(pe=>pe.json()).then(pe=>ve(pe.agents??[])).catch(()=>{}),j(null),De(null),Fe(!1),N(null),T(null),i?(b("edit"),v(i),z(""),h(i).then(pe=>{pe&&(H(pe.metadata.name),Y(pe.metadata.id),F(pe.metadata.description),$(pe.metadata.version),J(pe.metadata.color??"#3b82f6"),D(pe.entryStep),W(pe.settings.maxIterations),K(pe.steps),Q(pe.startCondition??{type:"always"}))})):(b("list"),v(null)))},[e,l,h,f,i]);const ke=()=>{v(null),H(""),Y(""),F(""),$("1.0.0"),J("#3b82f6"),D(""),W(50),K(structuredClone(Gv)),Q({type:"always"}),z(""),N(null),T(null),b("edit")},lt=async pe=>{const we=await h(pe);we&&(v(pe),H(we.metadata.name),Y(we.metadata.id),F(we.metadata.description),$(we.metadata.version),J(we.metadata.color??"#3b82f6"),D(we.entryStep),W(we.settings.maxIterations),K(we.steps),Q(we.startCondition??{type:"always"}),z(""),N(null),T(null),b("edit"))},ht=async()=>{var tt;const pe=y??q;if(!pe||!B)return z("Name is required."),!1;if(U.length===0)return z("Add at least one step."),!1;let we=R;if(!we||!U.some(Be=>Be.id===we)){if(we=((tt=U.find(Be=>Be.id))==null?void 0:tt.id)??"",!we)return z("All steps need an ID."),!1;D(we)}se(!0),z("");const ze={metadata:{id:pe,name:B,description:V,version:I||"1.0.0",color:X},entryStep:we,settings:{maxIterations:O},steps:U,startCondition:te},Ve=y?await m(y,ze):await g(ze);return se(!1),Ve.success?(y||v(pe),!0):(z(Ve.error??"Failed to save."),!1)},fe=async()=>{await ht()},Re=async()=>{await ht()&&(i?r():b("list"))},Je=()=>{i?r():b("list")},et=pe=>{H(pe),y||Y(l4(pe))},Ge=P.useCallback(pe=>{N(pe),T(null)},[]),ct=P.useCallback(pe=>{T(pe),N(null)},[]),de=A!==null?Number(A):-1,be=de>=0?U[de]??null:null,re=P.useCallback(pe=>{K(we=>we.map((ze,Ve)=>Ve===de?pe:ze))},[de]),Se=te.type==="step_result"?`${te.result}`:P0[te.type]??te.type,Ce=()=>{const pe=U.length,we=c4(U),ze=ge.find(Ve=>!Ve.subagent);K([...U,{id:we,name:(ze==null?void 0:ze.name)??"Agent",type:"agent",phase:"build",toolMode:(ze==null?void 0:ze.id)??"builder",transitions:[]}]),R||D(we),Ge(String(pe))},He=P.useCallback((pe,we)=>{pe==="$start"?(D(we),ct("start")):K(ze=>{const Ve=ze.find(Be=>Be.id===pe),tt=Ve?Ve.transitions.length:0;return ct(`${pe}:${tt}`),ze.map(Be=>Be.id===pe?{...Be,transitions:[...Be.transitions,{when:{type:"always"},goto:we}]}:Be)})},[ct]),Ae=P.useCallback((pe,we)=>{if(pe==="start")D(we);else{const ze=pe.lastIndexOf(":"),Ve=pe.slice(0,ze),tt=parseInt(pe.slice(ze+1));K(Be=>Be.map(Lt=>Lt.id===Ve?{...Lt,transitions:Lt.transitions.map((Et,Yt)=>Yt===tt?{...Et,goto:we}:Et)}:Lt))}},[]),st=P.useCallback((pe,we)=>{const ze=pe.lastIndexOf(":"),Ve=pe.slice(0,ze),tt=parseInt(pe.slice(ze+1));K(Be=>{const Lt=Be.find(Yt=>Yt.id===Ve);if(!Lt)return Be;const Et=Lt.transitions[tt];return Et?Be.map(Yt=>Yt.id===Ve?{...Yt,transitions:Yt.transitions.filter((Zl,Ls)=>Ls!==tt)}:Yt.id===we?{...Yt,transitions:[...Yt.transitions,Et]}:Yt):Be}),T(null)},[]),it=P.useCallback(pe=>{if(pe==="start")D("");else{const we=pe.lastIndexOf(":"),ze=pe.slice(0,we),Ve=parseInt(pe.slice(we+1));K(tt=>tt.map(Be=>Be.id===ze?{...Be,transitions:Be.transitions.filter((Lt,Et)=>Et!==Ve)}:Be))}T(null)},[]),Ct=P.useCallback((pe,we)=>{if(pe==="start")Q(we);else{const ze=pe.lastIndexOf(":"),Ve=pe.slice(0,ze),tt=parseInt(pe.slice(ze+1));K(Be=>Be.map(Lt=>Lt.id===Ve?{...Lt,transitions:Lt.transitions.map((Et,Yt)=>Yt===tt?{...Et,when:we}:Et)}:Lt))}},[]),$e=pe=>Zh(pe,ge).name,Ln=()=>{if(!L)return null;if(L==="start"){const Et=U.find(Yt=>Yt.id===R);return{type:"start",fromLabel:"Start",toLabel:Et?$e(Et):"(none)",condition:te}}const pe=L.lastIndexOf(":"),we=L.slice(0,pe),ze=parseInt(L.slice(pe+1)),Ve=U.find(Et=>Et.id===we);if(!Ve)return null;const tt=Ve.transitions[ze];if(!tt)return null;const Be=U.find(Et=>Et.id===tt.goto),Lt=tt.goto==="$done"?"Done":Be?$e(Be):tt.goto;return{type:"step",fromLabel:$e(Ve),toLabel:Lt,condition:tt.when}};if(C==="edit"){const pe=Ln();return o.jsxs(un,{isOpen:e,onClose:Je,title:y?"Edit Workflow":"New Workflow",size:"full",children:[Z&&o.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded mb-3",children:Z}),o.jsxs("div",{className:"flex items-end gap-3 mb-3 pb-3 border-b border-border flex-wrap",children:[o.jsxs("div",{className:"min-w-[140px]",children:[o.jsx("label",{className:en,children:"Name"}),o.jsx("input",{value:B,onChange:we=>et(we.target.value),placeholder:"Workflow name",className:Kn})]}),o.jsxs("div",{className:"min-w-[100px]",children:[o.jsx("label",{className:en,children:"ID"}),o.jsx("input",{value:q,onChange:we=>!y&&Y(we.target.value),readOnly:!!y,className:`${Kn} font-mono ${y?"opacity-50":""}`})]}),o.jsxs("div",{className:"flex-1 min-w-[140px]",children:[o.jsx("label",{className:en,children:"Description"}),o.jsx("input",{value:V,onChange:we=>F(we.target.value),placeholder:"What does this workflow do?",className:Kn})]}),o.jsxs("div",{className:"w-20",children:[o.jsx("label",{className:en,children:"Max Iter."}),o.jsx("input",{type:"number",value:O,onChange:we=>W(Number(we.target.value)),className:`${Kn} font-mono`})]}),o.jsxs("div",{children:[o.jsx("label",{className:en,children:"Color"}),o.jsx("input",{type:"color",value:X,onChange:we=>J(we.target.value),className:"w-8 h-8 rounded border border-border cursor-pointer bg-transparent"})]})]}),o.jsxs("div",{className:"flex gap-3",style:{height:"calc(90vh - 220px)",minHeight:300},children:[o.jsxs("div",{className:"flex-1 min-w-0 bg-bg-primary/50 border border-border rounded-lg flex flex-col overflow-hidden",children:[o.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/50 shrink-0",children:[o.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider font-medium",children:"Flow"}),o.jsx("button",{onClick:Ce,className:"text-[11px] text-accent-primary hover:text-accent-primary/80",children:"+ Add Step"})]}),o.jsxs("div",{className:"flex-1 min-h-0 p-2 overflow-auto",children:[o.jsx(h4,{steps:U,entryStep:R,selectedNodeId:(be==null?void 0:be.id)??null,selectedEdgeKey:L,startConditionLabel:Se,agentTypes:ge,onSelectNode:we=>{if(we===null){Ge(null);return}const ze=U.findIndex(Ve=>Ve.id===we);Ge(ze>=0?String(ze):null)},onSelectEdge:ct,onRemoveStep:we=>{var Ve;const ze=U.findIndex(tt=>tt.id===we);if(K(tt=>tt.filter(Be=>Be.id!==we)),de===ze&&Ge(null),R===we){const tt=U.filter(Be=>Be.id!==we);D(((Ve=tt[0])==null?void 0:Ve.id)??"")}},onCreateTransition:He,onReconnectTo:Ae,onReconnectFrom:st,onDeleteTransition:it}),U.length===0&&o.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-text-muted",children:[o.jsx("p",{className:"text-xs mb-2",children:"No steps yet"}),o.jsx("button",{onClick:Ce,className:"px-3 py-1.5 rounded bg-accent-primary/10 text-accent-primary text-xs hover:bg-accent-primary/20",children:"+ Add your first step"})]})]})]}),o.jsxs("div",{className:"w-[300px] shrink-0 border border-border rounded-lg bg-bg-secondary flex flex-col overflow-hidden",children:[o.jsx("div",{className:"px-3 py-1.5 border-b border-border shrink-0",children:o.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider font-medium",children:"Properties"})}),o.jsx("div",{className:"p-3 overflow-y-auto flex-1 min-h-0",children:pe?pe.type==="start"?o.jsxs("div",{className:"space-y-3 text-sm",children:[o.jsx("div",{className:"flex items-center gap-2",children:o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-blue-500/20 text-blue-300",children:"Start"})}),R&&o.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[o.jsx("span",{className:"text-text-primary font-medium",children:"Start"}),o.jsx("svg",{className:"w-3.5 h-3.5 shrink-0 text-text-muted",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14 5l7 7m0 0l-7 7m7-7H3"})}),o.jsx("span",{className:"text-text-primary font-medium",children:pe.toLabel})]}),o.jsxs("div",{children:[o.jsx("label",{className:en,children:"Activation Condition"}),o.jsx("select",{value:te.type,onChange:we=>Q(we.target.value==="step_result"?{type:"step_result",result:"success"}:{type:we.target.value}),className:Ni,children:F0.map(we=>o.jsx("option",{value:we.value,children:we.label},we.value))})]}),te.type==="step_result"&&o.jsxs("div",{children:[o.jsx("label",{className:en,children:"Result"}),R&&(()=>{const we=U.find(Be=>Be.id===R),ze=we&&(we.type==="sub_agent"||we.type==="agent")?ge.find(Be=>Be.id===(we.type==="sub_agent"?we.subAgentType:we.toolMode)):void 0,Ve=(ze==null?void 0:ze.results)&&ze.results.length>0,tt=(ze==null?void 0:ze.results)??[];return Ve?o.jsx("select",{value:te.result??tt[0],onChange:Be=>Q({type:"step_result",result:Be.target.value}),className:Ni,children:tt.map(Be=>o.jsx("option",{value:Be,children:Be},Be))}):o.jsx("input",{type:"text",value:te.result??"success",onChange:Be=>Q({type:"step_result",result:Be.target.value}),placeholder:"e.g. success, passed, failed",className:Kn})})()]}),o.jsx("p",{className:"text-text-muted text-[10px]",children:"Workflow only proceeds when this condition is met. Drag the target handle to change entry step."})]}):o.jsx(f4,{fromLabel:pe.fromLabel,toLabel:pe.toLabel,condition:pe.condition,fromStep:pe.type==="step"?U.find(we=>we.id===pe.fromLabel):void 0,agentTypes:ge,onUpdateCondition:we=>Ct(L,we),onDelete:()=>it(L)}):be?o.jsx(p4,{step:be,isEntry:be.id===R,agentTypes:ge,transitionCount:be.transitions.length,templateVariables:p,onUpdate:re,onRemove:()=>{var we;if(be&&(K(U.filter((ze,Ve)=>Ve!==de)),Ge(null),R===be.id)){const ze=U.filter((Ve,tt)=>tt!==de);D(((we=ze[0])==null?void 0:we.id)??"")}},onSetEntry:()=>D(be.id)}):o.jsxs("p",{className:"text-text-muted text-xs text-center py-8",children:["Click a node or edge to edit.",o.jsx("br",{}),"Drag from a port to connect."]})})]})]}),o.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border",children:[o.jsx(dt,{variant:"secondary",onClick:Je,children:"Cancel"}),o.jsx(dt,{variant:"secondary",onClick:fe,disabled:ae||!B,children:ae?"Saving...":"Save"}),o.jsx(dt,{variant:"primary",onClick:Re,disabled:ae||!B,children:"Save & Close"})]})]})}return o.jsxs(un,{isOpen:e,onClose:r,title:"Workflows",size:"lg",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsx("p",{className:"text-text-secondary text-sm",children:"Workflows define the orchestrator's step sequence when running tasks."}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:[c.length>0&&(Oe?o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:async()=>{await k(),Fe(!1)},className:"px-1.5 py-0.5 rounded bg-amber-500/20 text-amber-400 text-xs hover:bg-amber-500/30 transition-colors",children:"Confirm"}),o.jsx("button",{onClick:()=>Fe(!1),className:"px-1.5 py-0.5 rounded text-text-muted text-xs hover:bg-bg-primary transition-colors",children:"Cancel"})]}):o.jsx("button",{onClick:()=>Fe(!0),className:"px-2 py-1 rounded text-xs text-text-muted hover:text-amber-400 hover:bg-amber-500/10 transition-colors",title:"Restore all workflows to defaults",children:"Restore Defaults"})),o.jsx(dt,{variant:"primary",size:"sm",onClick:ke,children:"+ New"})]})]}),u&&s.length===0?o.jsx("div",{className:"text-text-muted text-sm",children:"Loading workflows..."}):s.length===0?o.jsx("div",{className:"text-text-muted text-sm",children:"No workflows installed."}):o.jsx("div",{className:"space-y-2",children:s.map(pe=>o.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[o.jsxs("div",{className:"min-w-0 flex-1 mr-3",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-text-primary text-sm font-medium",children:pe.name}),o.jsxs("span",{className:"text-text-muted text-xs",children:["v",pe.version]}),c.includes(pe.id)&&o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-amber-500/15 text-amber-400",children:"modified"})]}),o.jsx("p",{className:"text-text-secondary text-xs mt-0.5 truncate",children:pe.description})]}),o.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[c.includes(pe.id)&&(Ne===pe.id?o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:async()=>{await S(pe.id),De(null)},className:"px-1.5 py-0.5 rounded bg-amber-500/20 text-amber-400 text-xs hover:bg-amber-500/30 transition-colors",children:"Restore"}),o.jsx("button",{onClick:()=>De(null),className:"px-1.5 py-0.5 rounded text-text-muted text-xs hover:bg-bg-primary transition-colors",children:"Cancel"})]}):o.jsx("button",{onClick:()=>De(pe.id),className:"p-1.5 rounded hover:bg-bg-primary text-text-muted hover:text-amber-400 transition-colors",title:"Restore default",children:o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})),o.jsx(ri,{onClick:()=>lt(pe.id)}),pe.id!=="default"&&(_===pe.id?o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:()=>{x(pe.id),j(null)},className:"px-1.5 py-0.5 rounded bg-accent-error/20 text-accent-error text-xs",children:"Delete"}),o.jsx("button",{onClick:()=>j(null),className:"px-1.5 py-0.5 rounded text-text-muted text-xs",children:"Cancel"})]}):o.jsx("button",{onClick:()=>j(pe.id),className:"p-1.5 rounded hover:bg-bg-primary text-text-muted hover:text-accent-error transition-colors",children:o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})}))]})]},pe.id))})]})}function m4(e,r){const i=e.startCondition;if(!i||i.type==="always")return!0;switch(i.type){case"has_pending_criteria":return r.some(s=>s.status.type!=="passed");case"all_criteria_passed":return r.length===0||r.every(s=>s.status.type==="passed");case"all_criteria_completed_or_passed":return r.every(s=>s.status.type==="completed"||s.status.type==="passed");case"any_criteria_blocked":return r.some(s=>s.status.type==="failed"&&s.attempts.filter(c=>c.status==="failed").length>=4);case"step_result":return null;default:return null}}function g4({onSelectWorkflow:e,onOpenManager:r,criteria:i}){const[s,c]=P.useState(!1),[u,p]=P.useState(""),[l,h]=P.useState(0),[f,g]=P.useState(null),m=P.useRef(null),x=P.useRef(null),S=Vt(_=>_.workflows),k=Vt(_=>_.fetchWorkflows);P.useEffect(()=>{s&&(k(),p(""),h(0),requestAnimationFrame(()=>{var _;return(_=x.current)==null?void 0:_.focus()}))},[s,k]),P.useEffect(()=>{if(!s)return;const _=j=>{m.current&&!m.current.contains(j.target)&&c(!1)};return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[s]);const C=S.filter(_=>{if(!u)return!0;const j=u.toLowerCase();return _.name.toLowerCase().includes(j)}),b=_=>{switch(_.key){case"ArrowDown":_.preventDefault(),h(j=>Math.min(j+1,C.length-1));break;case"ArrowUp":_.preventDefault(),h(j=>Math.max(j-1,0));break;case"Enter":_.preventDefault(),C[l]&&y(C[l].id);break;case"Escape":_.preventDefault(),c(!1);break}},y=_=>{e(_),c(!1)},v=()=>{c(!1),r()};return o.jsxs("div",{ref:m,className:"relative",children:[o.jsxs("button",{type:"button",onClick:()=>c(_=>!_),className:"flex items-center gap-1 text-sm text-text-muted hover:text-text-primary transition-colors",children:["Workflows",o.jsx("svg",{className:`w-3 h-3 transition-transform ${s?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),s&&o.jsxs("div",{className:"absolute bottom-full right-0 mb-1 w-72 bg-bg-secondary border border-border rounded-lg shadow-xl z-50",onKeyDown:b,children:[o.jsx("div",{className:"p-2 border-b border-border",children:o.jsx("input",{ref:x,value:u,onChange:_=>{p(_.target.value),h(0)},placeholder:"Search workflows...",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary"})}),o.jsx("div",{className:"overflow-y-auto max-h-64 p-1",children:C.length===0?o.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:S.length===0?"No workflows yet":"No matches"}):C.map((_,j)=>{const A=m4(_,i),N=_.color??"#3b82f6";return o.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 rounded transition-colors group ${j===l?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[o.jsxs("button",{type:"button",onClick:()=>y(_.id),className:"flex-1 text-left flex items-center gap-2",children:[o.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:N}}),o.jsx("span",{className:"text-sm text-text-primary font-medium flex-1",children:_.name}),A!==null&&o.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:A?"#22c55e":"#6b7280"},title:A?"Entry condition met":"Entry condition not met"})]}),o.jsx(ri,{className:"opacity-0 group-hover:opacity-100",onClick:L=>{L.stopPropagation(),c(!1),g(_.id)}})]},_.id)})}),o.jsx("div",{className:"border-t border-border p-1",children:o.jsx("button",{type:"button",onClick:v,className:"w-full text-left px-3 py-1.5 rounded text-sm text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors",children:"Manage Workflows..."})})]}),o.jsx(U0,{isOpen:!!f,onClose:()=>g(null),initialEditId:f})]})}function x4(e){return e==="criterion"}function v4(e){var r,i;return e.role!=="assistant"||e.subAgentId||(r=e.content)!=null&&r.trim()||(i=e.thinkingContent)!=null&&i.trim()||!e.toolCalls||e.toolCalls.length===0?!1:e.toolCalls.every(s=>x4(s.name))}function b4(e,r=[]){const i=[];let s=null,c=[],u,p=1;const l=new Map,h=new Map,f=[];for(const S of r)S.type==="message"?l.set(S.message.id,S):S.type==="subagent"?h.set(S.subAgentId,S):S.type==="criteria-batch"&&f.push(S);let g=0;const m=()=>{if(c.length>0){const S=f[g];S&&S.type==="criteria-batch"&&S.toolCalls.length===c.length&&S.toolCalls.every((C,b)=>{var y;return C.id===((y=c[b])==null?void 0:y.id)})?i.push(S):i.push({type:"criteria-batch",toolCalls:[...c]}),g++,c=[]}},x=()=>{if(!s)return;const S=s,k=h.get(S.subAgentId);k&&k.type==="subagent"&&k.messages.length===S.messages.length&&k.messages.every((b,y)=>b===S.messages[y])?i.push(k):i.push({type:"subagent",subAgentId:S.subAgentId,subAgentType:S.subAgentType,messages:S.messages}),s=null};for(const S of e)if(S.role!=="tool"){if(S.contextWindowId&&u&&S.contextWindowId!==u&&(m(),x(),p++,i.push({type:"context-divider",windowSequence:p})),u=S.contextWindowId,v4(S)){x();for(const k of S.toolCalls)c.push(k);continue}if(m(),S.subAgentId&&S.subAgentType)s&&s.subAgentId===S.subAgentId?s.messages.push(S):(x(),s={subAgentId:S.subAgentId,subAgentType:S.subAgentType,messages:[S]});else{x();const k=l.get(S.id);k&&k.type==="message"&&k.message===S?i.push(k):i.push({type:"message",message:S})}}return m(),x(),i}function y4(e){const r=new Date(e),i=r.getFullYear(),s=String(r.getMonth()+1).padStart(2,"0"),c=String(r.getDate()).padStart(2,"0"),u=String(r.getHours()).padStart(2,"0"),p=String(r.getMinutes()).padStart(2,"0");return`${i}/${s}/${c} ${u}:${p}`}function _4(e,r){return e.length<=r?e:e.substring(0,r)+"..."}const S4=10,w4=150;function C4(e,r,i){const s=[],c=e.filter(l=>l.role==="user"&&!l.isSystemGenerated&&l.messageKind!=="auto-prompt");for(const l of c)s.push({id:l.id,content:l.content,timestamp:l.timestamp,sessionId:i,sessionName:"This session"});for(const l of r)if(!(i&&l.id===i)&&l.recentUserPrompts)for(const h of l.recentUserPrompts)s.push({id:h.id,content:h.content,timestamp:h.timestamp,sessionId:l.id,sessionName:l.title||l.id});s.sort((l,h)=>new Date(h.timestamp).getTime()-new Date(l.timestamp).getTime());const u=s.slice(0,S4);u.reverse();const p=[];for(const l of u)p.push({id:l.id,content:l.content,timestamp:l.timestamp,formattedTimestamp:y4(l.timestamp),trimmedContent:_4(l.content,w4),sessionId:l.sessionId||void 0,sessionName:l.sessionName});return p}function k4(e,r=[],i=null){const[s,c]=P.useState(0),[u,p]=P.useState(!1),l=P.useMemo(()=>C4(e,r,i),[e,r,i]),h=P.useCallback(()=>{l.length>0&&(c(l.length-1),p(!0))},[l.length]),f=P.useCallback(()=>{p(!1),c(0)},[]),g=P.useCallback(()=>{c(S=>l.length===0?S:S===0?l.length-1:S-1)},[l.length]),m=P.useCallback(()=>{c(S=>l.length===0?S:S===l.length-1?0:S+1)},[l.length]),x=P.useCallback(()=>{if(l.length===0||!u)return null;const S=l[s];return(S==null?void 0:S.content)??null},[l,s,u]);return{history:l,selectedIndex:s,showHistory:u,openHistory:h,closeHistory:f,navigateUp:g,navigateDown:m,selectCurrent:x}}const E4=(e,r)=>{let i,s=!1,c=!1,u=!1,p=!1;const l=()=>{p=!0;const f=e.current;f&&(f.scrollTop=f.scrollHeight),setTimeout(()=>{p=!1},100)},h=()=>{i=requestAnimationFrame(l),setTimeout(()=>{i=requestAnimationFrame(l)},250),setTimeout(()=>{i=requestAnimationFrame(l)},500),setTimeout(()=>{i=requestAnimationFrame(l)},1e3)};return P.useEffect(()=>{const f=e.current;if(!f)return;const g=new MutationObserver(()=>{if(s||c){cancelAnimationFrame(i);return}i=requestAnimationFrame(l)});h(),g.observe(f,{childList:!0,subtree:!0,characterData:!0});const m=setInterval(()=>{if(s||c){cancelAnimationFrame(i);return}l()},1e3),x=C=>{if(u||p)return;f.scrollHeight-f.scrollTop-f.offsetHeight>50?(cancelAnimationFrame(i),s=!0,console.log("Scroll detected!",C)):s=!1},S=()=>c=!0,k=()=>c=!1;return f.addEventListener("wheel",x,{passive:!0}),f.addEventListener("touchstart",S,{passive:!0}),f.addEventListener("touchend",k,{passive:!0}),()=>{f.removeEventListener("wheel",x),f.removeEventListener("touchstart",S),f.removeEventListener("touchend",k),g.disconnect(),clearInterval(m)}},[r==null?void 0:r.id]),{force_scroll_to_bottom:()=>{s=!1,c=!1,u=!0,l(),setTimeout(()=>l(),250),setTimeout(()=>l(),500),setTimeout(()=>l(),750),setTimeout(()=>l(),1e3),setTimeout(()=>{u=!1},1250)}}};function j4({criteriaSidebarOpen:e,onCriteriaSidebarToggle:r}={}){const i=e??!0,[s,c]=P.useState(""),[u,p]=P.useState([]),[l,h]=P.useState(!1),[f,g]=P.useState(null),[m,x]=P.useState(!1),[S,k]=P.useState(!1),C=P.useRef(null),b=P.useRef(null),y=P.useRef(null),v=Ee(re=>re.currentSession),_=Ee(re=>re.messages),j=Ee(re=>re.streamingMessage),A=Ee(re=>re.sessions),N=Ee(re=>re.error),L=Ee(re=>re.pendingQuestion),T=ab(),B=Ee(re=>re.sendMessage),H=Ee(re=>re.clearError),q=Ee(re=>re.acceptAndBuild),Y=Ee(re=>re.stopGeneration),V=Ee(re=>re.launchRunner),F=Ee(re=>re.cancelQueued),I=uS(),$=Vt(re=>re.workflows),X=Vt(re=>re.fetchWorkflows);P.useEffect(()=>{X()},[X]);const{history:J,selectedIndex:R,showHistory:D,openHistory:O,closeHistory:W,navigateUp:U,navigateDown:K,selectCurrent:te}=k4(_,A,v==null?void 0:v.id),Q=P.useMemo(()=>j?_.map(re=>re.id===j.id?j:re):_,[_,j]),Z=P.useRef([]),z=P.useMemo(()=>{const re=b4(Q,Z.current);return Z.current=re,re},[Q]),ae=P.useMemo(()=>n4(_),[_]),{force_scroll_to_bottom:se}=E4(C,v),ge=P.useCallback(()=>{const re=b.current;if(!re)return;re.style.height="auto";const Se=Math.min(200,re.scrollHeight);re.style.height=`${Se}px`},[]);P.useEffect(()=>{if(!(v!=null&&v.id))return;const re=`openfox:draft:${v.id}`,Se=localStorage.getItem(re);Se!==null&&c(Se)},[v==null?void 0:v.id]),P.useEffect(()=>{var re;(re=b.current)==null||re.focus(),ge()},[v==null?void 0:v.id,ge]),P.useEffect(()=>{if(!(v!=null&&v.id))return;const re=`openfox:draft:${v.id}`,Se=setTimeout(()=>{s?localStorage.setItem(re,s):localStorage.removeItem(re)},500);return()=>clearTimeout(Se)},[v==null?void 0:v.id,s]),P.useEffect(()=>{ge()},[s,ge]),P.useEffect(()=>{const re=Se=>{Se.key==="Escape"&&T&&Y()};return window.addEventListener("keydown",re),()=>window.removeEventListener("keydown",re)},[T,Y]),P.useEffect(()=>{const re=b.current;if(!re)return;const Se=Ce=>{var Ae;if(document.activeElement!==re)return;const He=(Ae=Ce.clipboardData)==null?void 0:Ae.items;if(He){for(const st of Array.from(He))if(st.type.startsWith("image/")){Ce.preventDefault();const it=st.getAsFile();if(!it)continue;(async()=>{try{if(!Ud(it)){g("Only PNG, JPG, and GIF images are supported.");return}const Ct=$d(it,50*1024*1024);if(!Ct.valid){g(Ct.error??"Image file is too large");return}const $e=await Fd(it,{maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576}),Ln={id:Sl(),filename:"pasted-image",mimeType:$e.mimeType,size:$e.size,data:$e.dataUrl};p(pe=>[...pe,Ln])}catch(Ct){const $e=Ct instanceof Error?Ct.message??"Failed to process image":"Failed to process image";g($e)}})()}}};return re.addEventListener("paste",Se),()=>re.removeEventListener("paste",Se)},[]);const ve=()=>{c(""),p([]),v!=null&&v.id&&localStorage.removeItem(`openfox:draft:${v.id}`)},Ne=async re=>{re.preventDefault(),!(!s.trim()&&u.length===0)&&(se(),B(s,u.length>0?u:void 0),ve())},De=re=>{if(D)switch(re.key){case"Enter":re.preventDefault();const Se=te();Se&&(c(Se),W());return;case"Escape":re.preventDefault(),W(),T&&Y();return;case"ArrowUp":re.preventDefault(),U();return;case"ArrowDown":re.preventDefault(),K();return}if(re.key==="ArrowUp"&&s.trim()===""&&!D){re.preventDefault(),O();return}re.key==="Enter"&&!re.shiftKey&&(re.preventDefault(),Ne(re))},Oe=P.useCallback(async re=>{const Se=re.target.files;if(!(!Se||Se.length===0)){g(null);for(const Ce of Array.from(Se))try{if(!Ud(Ce)){g(`Unsupported file type: ${Ce.type}. Only PNG, JPG, and GIF are supported.`);continue}const He=$d(Ce,50*1024*1024);if(!He.valid){g(He.error??"Image file is too large");continue}const Ae=await Fd(Ce,{maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576}),st={id:Sl(),filename:Ce.name,mimeType:Ae.mimeType,size:Ae.size,data:Ae.dataUrl};p(it=>[...it,st])}catch(He){const Ae=He instanceof Error?He.message??"Failed to process image":"Failed to process image";g(Ae)}y.current&&(y.current.value="")}},[]),Fe=P.useCallback(re=>{re.preventDefault(),re.stopPropagation(),h(!0)},[]),ke=P.useCallback(re=>{re.preventDefault(),re.stopPropagation(),h(!1)},[]),lt=P.useCallback(async re=>{re.preventDefault(),re.stopPropagation(),h(!1),g(null);const Se=re.dataTransfer.files;if(!(!Se||Se.length===0))for(const Ce of Array.from(Se))try{if(!Ud(Ce)){g(`Unsupported file type: ${Ce.type}. Only PNG, JPG, and GIF are supported.`);continue}const He=$d(Ce,50*1024*1024);if(!He.valid){g(He.error??"Image file is too large");continue}const Ae=await Fd(Ce,{maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576}),st={id:Sl(),filename:Ce.name,mimeType:Ae.mimeType,size:Ae.size,data:Ae.dataUrl};p(it=>[...it,st])}catch(He){const Ae=He instanceof Error?He.message??"Failed to process image":"Failed to process image";g(Ae)}},[]),ht=P.useCallback(re=>{p(Se=>Se.filter(Ce=>Ce.id!==re))},[]),fe=P.useCallback(()=>{var re;(re=y.current)==null||re.click()},[]),Re=(v==null?void 0:v.mode)==="planner",Je=(v==null?void 0:v.mode)==="builder",et=((v==null?void 0:v.criteria.length)??0)>0,Ge=(v==null?void 0:v.phase)==="done",ct=z.some(re=>re.type==="message"&&re.message.role==="assistant"),de=Re&&et&&!T&&ct&&!Ge,be=re=>{const Se=s.trim()?s:void 0,Ce=u.length>0?u:void 0;Re?q(re,Se,Ce):Je&&V(Se,Ce,re),ve()};return o.jsxs(Nw,{criteriaSidebarOpen:i,onCriteriaSidebarToggle:r,messages:Q,children:[L&&o.jsx($3,{question:L}),o.jsx(Aw,{}),o.jsx(q3,{}),o.jsxs("div",{ref:C,"data-testid":"chat-scroll-container",className:"flex-1 min-w-0 overflow-y-auto",children:[o.jsx("div",{className:"pt-4",children:z.map((re,Se)=>{if(re.type==="context-divider")return o.jsxs("div",{className:"flex items-center gap-2 feed-item px-2 md:px-4",children:[o.jsx("div",{className:"flex-1 border-t border-border"}),o.jsx("span",{className:"text-[10px] text-text-muted font-medium px-2",children:"Earlier context summarized"}),o.jsx("div",{className:"flex-1 border-t border-border"})]},Se);if(re.type==="subagent"){const He=re.messages.some(Ae=>Ae.isStreaming);return o.jsx("div",{className:"px-2 md:px-4",children:o.jsx(z3,{messages:re.messages,subAgentType:re.subAgentType,isStreaming:He})},Se)}if(re.type==="criteria-batch")return o.jsx("div",{className:"feed-item px-2 md:px-4",children:o.jsx(B0,{toolCalls:re.toolCalls,criteria:v==null?void 0:v.criteria})},Se);const Ce=re.message;return Ce.role==="assistant"?o.jsx("div",{className:"px-2 md:px-4",children:o.jsx(Kh,{message:Ce,showStats:!0})},Se):o.jsx("div",{className:"px-2 md:px-4",children:o.jsx(I0,{message:Ce,isLastAssistantMessage:!1,promptContext:Ce.role==="user"?ae[Ce.id]:void 0})},Se)})}),o.jsxs("div",{className:"px-2 md:px-4 pb-4",children:[N&&o.jsx("div",{className:"feed-item bg-red-500/10 border border-red-500/50 rounded p-2",children:o.jsxs("div",{className:"flex items-start justify-between gap-2",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-red-400 text-sm font-medium",children:N.code}),o.jsx("div",{className:"text-red-300 text-xs mt-0.5",children:N.message})]}),o.jsx("button",{onClick:H,className:"text-red-400 hover:text-red-300 p-0.5","aria-label":"Dismiss error",children:o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),de&&o.jsx("div",{className:"flex justify-center gap-2 feed-item flex-wrap",children:$.map(re=>{const Se=re.color??"#3b82f6",Ce=parseInt(Se.slice(1,3),16),He=parseInt(Se.slice(3,5),16),Ae=parseInt(Se.slice(5,7),16),st=`rgba(${Ce},${He},${Ae},0.12)`,it=`rgba(${Ce},${He},${Ae},0.22)`,Ct=`rgba(${Ce},${He},${Ae},0.25)`;return o.jsxs("button",{onClick:()=>q(re.id),className:"px-4 py-1.5 rounded text-sm font-medium transition-colors",style:{backgroundColor:st,color:Se,border:`1px solid ${Ct}`},onMouseEnter:$e=>{$e.currentTarget.style.backgroundColor=it},onMouseLeave:$e=>{$e.currentTarget.style.backgroundColor=st},children:["▶ ",re.name]},re.id)})}),T&&o.jsx(W3,{})]})]}),o.jsxs("form",{onSubmit:Ne,className:"p-2 md:p-4 border-t border-border bg-gradient-to-t from-bg-secondary/50 to-transparent",children:[o.jsx("input",{ref:y,type:"file",accept:".png,.jpg,.jpeg,.gif",onChange:Oe,className:"hidden",multiple:!0}),f&&o.jsx("div",{className:"mb-2 p-2 bg-red-500/10 border border-red-500/50 rounded text-red-300 text-sm",children:f}),u.length>0&&o.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:u.map(re=>o.jsx(G3,{attachment:re,onRemove:ht},re.id))}),D&&o.jsx(V3,{history:J,selectedIndex:R,onSelect:re=>{c(re),W()},onEscape:W,onNavigate:re=>{re==="up"?U():K()}}),I.length>0&&o.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:I.map(re=>o.jsxs("div",{className:`inline-flex items-center gap-1.5 px-2 py-1 rounded text-xs ${re.mode==="asap"?"bg-amber-500/15 text-amber-300 border border-amber-500/30":"bg-blue-500/15 text-blue-300 border border-blue-500/30"}`,children:[o.jsxs("span",{className:"font-medium",children:[re.mode==="asap"?"ASAP":"Queue",":"]}),o.jsx("span",{className:"truncate max-w-[200px]",children:re.content}),o.jsx("button",{type:"button",onClick:()=>F(re.queueId),className:"hover:text-white transition-colors",children:o.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]},re.queueId))}),o.jsxs("div",{className:`flex items-end gap-3 p-3 rounded border transition-colors ${l?"border-accent-primary/50 bg-accent-primary/10":"border-border bg-bg-tertiary/50"}`,onDragOver:Fe,onDragLeave:ke,onDrop:lt,children:[o.jsx("button",{type:"button",onClick:fe,className:"p-3 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Attach image file",children:o.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13"})})}),o.jsx("textarea",{ref:b,value:s,onChange:re=>{c(re.target.value),D&&W()},onKeyDown:De,placeholder:Re?"What would you like to build?":"Send a message...",className:"flex-1 bg-transparent text-sm placeholder:text-text-muted resize-none overflow-y-auto focus:outline-none",style:{minHeight:"24px",maxHeight:"200px"}}),o.jsxs("div",{className:"flex flex-col items-end gap-1",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(o4,{onSendCommand:(re,Se,Ce,He)=>{var st;Se&&(v==null?void 0:v.mode)!==Se&&Ee.getState().switchMode(Se);const Ae=Ce&&Ce.trim()?`${Ce.trim()}
148
+ `,children:[o.jsxs("div",{className:"text-xs text-text-muted font-mono",children:[f.formattedTimestamp,f.sessionName&&o.jsxs(o.Fragment,{children:[" | ",o.jsx("span",{className:"text-accent-primary font-medium",children:f.sessionName})]})]}),o.jsx("div",{className:"text-sm text-text-primary mt-1",children:f.trimmedContent})]},f.id))})}const Y3={maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576};async function Fd(e,r={}){const i={...Y3,...r};if(!e.type.startsWith("image/"))throw new Error("File is not an image");if(!["image/png","image/jpeg","image/gif"].includes(e.type))throw new Error(`Unsupported image format: ${e.type}. Only PNG, JPG, and GIF are supported.`);if(e.size<=i.maxSizeBytes){const c=await e.arrayBuffer(),u=t4(c),p=`data:${e.type};base64,${u}`,l=await z0(p);return{dataUrl:p,mimeType:e.type,size:e.size,width:l.width,height:l.height}}return await K3(e,i)}async function K3(e,r){const i=await Z3(e),s=await z0(i),{width:c,height:u}=X3(s.width,s.height,r.maxWidth,r.maxHeight),p=Q3();p.width=c,p.height=u;const l=p.getContext("2d");if(!l)throw new Error("Failed to get canvas context");l.imageSmoothingEnabled=!0,l.imageSmoothingQuality="high",l.drawImage(s,0,0,c,u);let h=r.quality,f;do{if(f=p.toDataURL(e.type.startsWith("image/gif")?"image/png":e.type,h),Uv(f)<=r.maxSizeBytes||h<=.3)break;h-=.1}while(!0);const g=Uv(f);return{dataUrl:f,mimeType:e.type.startsWith("image/gif")?"image/png":e.type,size:g,width:c,height:u}}function X3(e,r,i,s){const c=e/r;return e>r&&e>i?{width:i,height:Math.round(i/c)}:r>e&&r>s?{width:Math.round(s*c),height:s}:{width:e,height:r}}function Z3(e){return new Promise((r,i)=>{const s=e4(),c=new s;c.onload=()=>r(c.result),c.onerror=()=>i(new Error("Failed to read file")),c.readAsDataURL(e)})}function z0(e){return new Promise((r,i)=>{const s=J3(),c=new s;c.onload=()=>r(c),c.onerror=()=>i(new Error("Failed to load image")),c.src=e})}function Q3(){var r;const e=Xh();if(!((r=e.document)!=null&&r.createElement))throw new Error("Image compression requires browser canvas APIs");return e.document.createElement("canvas")}function J3(){const e=Xh();if(!e.Image)throw new Error("Image compression requires browser image APIs");return e.Image}function e4(){const e=Xh();if(!e.FileReader)throw new Error("Image compression requires browser file APIs");return e.FileReader}function Xh(){return globalThis}function t4(e){const r=new Uint8Array(e);let i="";for(let s=0;s<r.byteLength;s++){const c=r[s];c!==void 0&&(i+=String.fromCharCode(c))}return btoa(i)}function Uv(e){const i=e.split(",")[1];return i?Math.round(i.length*3/4):0}function Ud(e){return["image/png","image/jpeg","image/gif"].includes(e.type)}function $d(e,r=50*1024*1024){return e.size>r?{valid:!1,error:`Image file is too large (${$v(e.size)}). Maximum size is ${$v(r)}.`}:{valid:!0}}function $v(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function n4(e){const r={};let i=null;for(const s of e){if(s.role==="user"&&!s.isSystemGenerated){i=s.id;continue}s.role==="assistant"&&s.promptContext&&i&&r[i]===void 0&&(r[i]=s.promptContext)}return r}function r4({isOpen:e,onClose:r,providerId:i,model:s}){const[c,u]=P.useState(s.contextWindow),[p,l]=P.useState(!1),h=Lt(m=>m.updateModelContext);if(P.useEffect(()=>{u(s.contextWindow)},[s]),!e)return null;const f=async()=>{c<1024||c>1e7||(l(!0),await h(i,s.id,c),l(!1),r())},g=()=>{u(s.contextWindow),r()};return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:o.jsxs("div",{className:"bg-bg-secondary rounded-lg shadow-xl max-w-md w-full mx-4 border border-border",children:[o.jsx("div",{className:"px-6 py-4 border-b border-border",children:o.jsx("h3",{className:"text-lg font-medium text-text-primary",children:"Model Properties"})}),o.jsxs("div",{className:"px-6 py-4 space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-text-secondary mb-1",children:"Model Name"}),o.jsx("p",{className:"text-text-primary bg-bg-tertiary px-3 py-2 rounded",children:s.id})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-text-secondary mb-1",children:"Context Window"}),o.jsx("input",{type:"number",min:1024,max:1e7,value:c,onChange:m=>u(parseInt(m.target.value)||0),className:"w-full bg-bg-tertiary border border-border rounded px-3 py-2 text-text-primary focus:outline-none focus:border-accent-primary"}),o.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Range: 1,024 - 10,000,000 tokens"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-text-secondary mb-1",children:"Source"}),o.jsxs("p",{className:"text-text-primary bg-bg-tertiary px-3 py-2 rounded",children:[s.source==="backend"&&"Auto-detected from backend",s.source==="user"&&"Manually set",s.source==="default"&&"Default value"]})]})]}),o.jsxs("div",{className:"px-6 py-4 border-t border-border flex justify-end gap-3",children:[o.jsx("button",{type:"button",onClick:g,disabled:p,className:"px-4 py-2 text-text-secondary hover:text-text-primary transition-colors disabled:opacity-50",children:"Cancel"}),o.jsx("button",{type:"button",onClick:f,disabled:p||c<1024||c>1e7,className:"px-4 py-2 bg-accent-primary text-white rounded hover:opacity-90 transition-opacity disabled:opacity-50 disabled:cursor-not-allowed",children:p?"Saving...":"Save"})]})]})})}function i4(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:`${e}`}function s4(){var F;const[,e]=ar(),r=Ee(I=>I.currentSession),i=Ee(I=>I.setSessionProvider),[s,c]=P.useState(!1),[u,p]=P.useState([]),[l,h]=P.useState(null),f=P.useRef(null),[g,m]=P.useState(null),x=P.useRef(new Set),S=Lt(I=>I.providers),k=Lt(I=>I.activeProviderId),C=Lt(I=>I.model);Lt(I=>I.backend);const b=Lt(I=>I.llmStatus),y=Lt(I=>I.activating),v=Lt(I=>I.activateProvider),_=Lt(I=>I.refreshModel),j=Lt(I=>I.refreshProviderModels);P.useEffect(()=>{function I($){f.current&&!f.current.contains($.target)&&(c(!1),p([]),x.current=new Set)}return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[]),P.useEffect(()=>{if(s){const I=S.map($=>$.id);p(I),I.forEach($=>{x.current.has($)||(x.current.add($),L($))})}},[s,S]),S.find(I=>I.id===k);const A=b==="disconnected",N=C?((F=C.split("/").pop())==null?void 0:F.replace(/-/g," "))??C:"detecting...",L=async I=>{h(I);try{await j(I)}catch{}finally{h(null)}},T=async I=>{if(I.id===k){u.includes(I.id)?p(u.filter($=>$!==I.id)):(p([...u,I.id]),L(I.id));return}r?(i(I.id,void 0),Lt.getState().syncFromSession(I.id,""),c(!1),p([])):await v(I.id)&&(c(!1),p([]))},B=I=>{u.includes(I.id)?p(u.filter($=>$!==I.id)):(p([...u,I.id]),L(I.id))},H=async(I,$)=>{I.stopPropagation(),x.current.delete($),await j($),await L($)},q=(I,$)=>{m({providerId:I,model:$})},Y=()=>{m(null)},V=async(I,$)=>{if(console.log("[ProviderSelector.handleModelClick] providerId:",I,"model:",$),r){console.log("[ProviderSelector.handleModelClick] Calling setSessionProvider"),i(I,$),Lt.getState().syncFromSession(I,$),p([]),c(!1);return}h("activating");try{(await ye(`/api/providers/${I}/activate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:$})})).ok&&(await Lt.getState().fetchConfig(),p([]),c(!1))}catch{}finally{h(null)}};return S.length===0?o.jsxs("button",{type:"button",onClick:()=>_(),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:A?"LLM server is offline. Click to retry.":C??"Click to refresh model",children:[A?o.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"LLM offline"}):o.jsx("span",{className:"text-sm text-accent-primary",children:N}),o.jsx("span",{className:"text-text-muted opacity-0 group-hover:opacity-100 transition-opacity",children:"↻"})]}):o.jsxs("div",{className:"relative",ref:f,children:[o.jsxs("button",{type:"button",onClick:()=>c(!s),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:"Click to switch provider or model",children:[A?o.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"offline"}):o.jsx("span",{className:"text-sm text-accent-primary",children:N}),o.jsx("svg",{className:`w-3 h-3 text-text-muted transition-transform ${s?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),s&&o.jsxs("div",{className:"absolute bottom-full right-0 mb-1 w-72 bg-bg-secondary border border-border rounded-lg shadow-lg z-50 overflow-hidden",children:[o.jsx("div",{className:"py-1",children:S.map(I=>{var $;return o.jsxs("div",{children:[o.jsxs("div",{className:`px-3 py-2 flex items-center justify-between ${I.id===k?"bg-bg-tertiary":"hover:bg-bg-tertiary"} ${y?"opacity-50 cursor-wait":"cursor-pointer"}`,children:[o.jsxs("div",{onClick:()=>!y&&T(I),className:"flex flex-col min-w-0 flex-1 cursor-pointer",children:[o.jsx("span",{className:`text-sm font-medium truncate ${I.id===k?"text-accent-primary":"text-text-primary"}`,children:I.name}),o.jsx("span",{className:"text-xs text-text-muted truncate",children:I.backend!=="auto"&&V1(I.backend)})]}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[I.id===k?o.jsx("span",{className:"text-accent-success",title:"Active",children:o.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:o.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})}):o.jsx("span",{className:"w-4"}),o.jsx("button",{type:"button",onClick:X=>{X.stopPropagation(),H(X,I.id)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Refresh models",children:o.jsx("svg",{className:`w-4 h-4 ${l===I.id?"animate-spin":""} ${I.id===k?"text-accent-primary":"text-text-muted"}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),o.jsx("button",{type:"button",onClick:X=>{X.stopPropagation(),B(I)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Show models",children:o.jsx("svg",{className:`w-4 h-4 transition-transform ${u.includes(I.id)?"rotate-180":""} ${I.id===k?"text-accent-primary":"text-text-muted"}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]})]}),u.includes(I.id)&&o.jsx("div",{className:"bg-bg-primary border-t border-border",children:l===I.id?o.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"Loading models..."}):($=I.models)!=null&&$.length?I.models.map(X=>{var J;return o.jsxs("button",{type:"button",onClick:()=>V(I.id,X.id),disabled:l==="activating",className:`w-full px-4 py-1.5 text-left hover:bg-bg-tertiary transition-colors text-sm flex items-center justify-between group ${l==="activating"?"opacity-50 cursor-wait":""} ${C===X.id?"text-accent-primary":"text-text-secondary"}`,children:[o.jsx("span",{className:"truncate flex-1",children:((J=X.id.split("/").pop())==null?void 0:J.replace(/-/g," "))??X.id}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[o.jsx("span",{className:"text-xs text-text-muted",children:i4(X.contextWindow)}),o.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),q(I.id,X)},className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-bg-tertiary rounded transition-opacity",title:"Edit model context",children:o.jsx("svg",{className:"w-3 h-3 text-text-muted",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})})]}),C===X.id&&o.jsx("span",{className:"text-accent-success flex-shrink-0 ml-1",children:o.jsx("svg",{className:"w-3.5 h-3.5",fill:"currentColor",viewBox:"0 0 20 20",children:o.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})})]},X.id)}):o.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"No models available"})})]},I.id)})}),o.jsx("div",{className:"border-t border-border px-3 py-2",children:o.jsx("button",{onClick:()=>e("/onboarding"),className:"text-xs text-accent-primary hover:underline",children:"Manage providers"})})]}),g&&o.jsx(r4,{isOpen:!0,onClose:Y,providerId:g.providerId,model:g.model})]})}const Tn=qn((e,r)=>({commands:[],defaultIds:[],modifiedIds:[],loading:!1,fetchDefaultIds:async()=>{try{const s=await(await ye("/api/commands/default-ids")).json();e({defaultIds:s.ids??[]})}catch{}},fetchCommands:async()=>{e({loading:!0});try{const s=await(await ye("/api/commands")).json();e({commands:s.commands??[],defaultIds:s.defaultIds??r().defaultIds,modifiedIds:s.modifiedIds??[],loading:!1})}catch{e({loading:!1})}},fetchCommand:async i=>{try{const s=await ye(`/api/commands/${i}`);return s.ok?await s.json():null}catch{return null}},createCommand:async i=>{try{const s=await ye("/api/commands",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});return s.ok?(await r().fetchCommands(),{success:!0}):{success:!1,error:(await s.json()).error}}catch{return{success:!1,error:"Network error"}}},updateCommand:async(i,s)=>{try{const c=await ye(`/api/commands/${i}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});return c.ok?(await r().fetchCommands(),{success:!0}):{success:!1,error:(await c.json()).error}}catch{return{success:!1,error:"Network error"}}},deleteCommand:async i=>{try{return(await ye(`/api/commands/${i}`,{method:"DELETE"})).ok?(e({commands:r().commands.filter(c=>c.id!==i)}),!0):!1}catch{return!1}},restoreDefault:async i=>{try{return(await ye(`/api/commands/${i}/restore-default`,{method:"POST"})).ok?(await r().fetchCommands(),!0):!1}catch{return!1}},restoreAllDefaults:async()=>{try{return(await ye("/api/commands/restore-all-defaults",{method:"POST"})).ok?(await r().fetchCommands(),!0):!1}catch{return!1}}}));function a4(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function H0({isOpen:e,onClose:r,initialEditId:i}){const s=Tn(z=>z.commands),c=Tn(z=>z.modifiedIds),u=Tn(z=>z.loading),p=Tn(z=>z.fetchCommands),l=Tn(z=>z.fetchCommand),h=Tn(z=>z.createCommand),f=Tn(z=>z.updateCommand),g=Tn(z=>z.deleteCommand),m=Tn(z=>z.restoreDefault),x=Tn(z=>z.restoreAllDefaults),[S,k]=P.useState("list"),[C,b]=P.useState(null),[y,v]=P.useState(null),_=rn(z=>z.agents),j=rn(z=>z.fetchAgents),A=_.filter(z=>!z.subagent),[N,L]=P.useState(""),[T,B]=P.useState(""),[H,q]=P.useState(""),[Y,V]=P.useState(""),[F,I]=P.useState(""),[$,X]=P.useState(!1),[J,R]=P.useState(null),[D,O]=P.useState(!1);P.useEffect(()=>{e&&(p(),j(),v(null),R(null),O(!1),i?(k("edit"),b(i),I(""),l(i).then(z=>{z&&(L(z.metadata.name),B(z.metadata.id),q(z.prompt),V(z.metadata.agentMode??""))})):(k("list"),b(null)))},[e,p,j,l,i]);const W=()=>{b(null),L(""),B(""),q(""),V(""),I(""),k("edit")},U=async z=>{const ae=await l(z);ae&&(b(z),L(ae.metadata.name),B(ae.metadata.id),q(ae.prompt),V(ae.metadata.agentMode??""),I(""),k("edit"))},K=async z=>{await g(z),v(null)},te=async()=>{const z=C??T;if(!z||!N||!H){I("Name and message are required.");return}X(!0),I("");const ae={metadata:{id:z,name:N,...Y?{agentMode:Y}:{}},prompt:H},se=C?await f(C,ae):await h(ae);if(X(!1),!se.success){I(se.error??"Failed to save command.");return}i?r():k("list")},Q=()=>{i?r():k("list")},Z=z=>{L(z),C||B(a4(z))};return S==="edit"?o.jsx(un,{isOpen:e,onClose:Q,title:C?"Edit Command":"New Command",size:"xl",children:o.jsxs("div",{className:"space-y-3",children:[F&&o.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded",children:F}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Name"}),o.jsx("input",{value:N,onChange:z=>Z(z.target.value),placeholder:"My Command",className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary"})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["ID ",C&&o.jsx("span",{className:"text-text-muted",children:"(read-only)"})]}),o.jsx("input",{value:T,onChange:z=>!C&&B(z.target.value),readOnly:!!C,placeholder:"my-command",className:`w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary ${C?"opacity-60":""}`})]})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["Agent Mode ",o.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),o.jsxs("select",{value:Y,onChange:z=>V(z.target.value),className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",children:[o.jsx("option",{value:"",children:"None (keep current mode)"}),A.map(z=>o.jsx("option",{value:z.id,children:z.name},z.id))]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Message"}),o.jsx("textarea",{value:H,onChange:z=>q(z.target.value),placeholder:"The message that will be sent when this command is triggered...",className:"w-full h-64 px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-accent-primary"})]}),o.jsxs("div",{className:"flex justify-end gap-2 pt-2 border-t border-border",children:[o.jsx(dt,{variant:"secondary",onClick:Q,children:"Cancel"}),o.jsx(dt,{variant:"primary",onClick:te,disabled:$||!N||!H,children:$?"Saving...":"Save"})]})]})}):o.jsxs(un,{isOpen:e,onClose:r,title:"Commands",size:"lg",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsx("p",{className:"text-text-secondary text-sm",children:"Commands are pre-defined messages you can send with a single click."}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:[c.length>0&&(D?o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:async()=>{await x(),O(!1)},className:"px-1.5 py-0.5 rounded bg-amber-500/20 text-amber-400 text-xs hover:bg-amber-500/30 transition-colors",children:"Confirm"}),o.jsx("button",{onClick:()=>O(!1),className:"px-1.5 py-0.5 rounded text-text-muted text-xs hover:bg-bg-primary transition-colors",children:"Cancel"})]}):o.jsx("button",{onClick:()=>O(!0),className:"px-2 py-1 rounded text-xs text-text-muted hover:text-amber-400 hover:bg-amber-500/10 transition-colors",title:"Restore all commands to defaults",children:"Restore Defaults"})),o.jsx(dt,{variant:"primary",size:"sm",onClick:W,children:"+ New"})]})]}),u&&s.length===0?o.jsx("div",{className:"text-text-muted text-sm",children:"Loading commands..."}):s.length===0?o.jsx("div",{className:"text-text-muted text-sm",children:"No commands created yet."}):o.jsx("div",{className:"space-y-2",children:s.map(z=>o.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[o.jsx("div",{className:"min-w-0 flex-1 mr-3",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-text-primary text-sm font-medium",children:z.name}),c.includes(z.id)&&o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-amber-500/15 text-amber-400",children:"modified"})]})}),o.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[c.includes(z.id)&&(J===z.id?o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:async()=>{await m(z.id),R(null)},className:"px-1.5 py-0.5 rounded bg-amber-500/20 text-amber-400 text-xs hover:bg-amber-500/30 transition-colors",children:"Restore"}),o.jsx("button",{onClick:()=>R(null),className:"px-1.5 py-0.5 rounded text-text-muted text-xs hover:bg-bg-primary transition-colors",children:"Cancel"})]}):o.jsx("button",{onClick:()=>R(z.id),className:"p-1.5 rounded hover:bg-bg-primary text-text-muted hover:text-amber-400 transition-colors",title:"Restore default",children:o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})),o.jsx(ri,{onClick:()=>U(z.id)}),y===z.id?o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:()=>K(z.id),className:"px-1.5 py-0.5 rounded bg-accent-error/20 text-accent-error text-xs hover:bg-accent-error/30 transition-colors",children:"Delete"}),o.jsx("button",{onClick:()=>v(null),className:"px-1.5 py-0.5 rounded text-text-muted text-xs hover:bg-bg-primary transition-colors",children:"Cancel"})]}):o.jsx("button",{onClick:()=>v(z.id),className:"p-1.5 rounded hover:bg-bg-primary text-text-muted hover:text-accent-error transition-colors",title:"Delete command",children:o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})]},z.id))})]})}function o4({onSendCommand:e,onOpenManager:r,textareaContent:i,attachments:s}){const[c,u]=P.useState(!1),[p,l]=P.useState(""),[h,f]=P.useState(0),[g,m]=P.useState(null),x=P.useRef(null),S=P.useRef(null),k=Tn(j=>j.commands),C=Tn(j=>j.fetchCommands);P.useEffect(()=>{c&&(C(),l(""),f(0),requestAnimationFrame(()=>{var j;return(j=S.current)==null?void 0:j.focus()}))},[c,C]),P.useEffect(()=>{if(!c)return;const j=A=>{x.current&&!x.current.contains(A.target)&&u(!1)};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[c]);const b=k.filter(j=>{if(!p)return!0;const A=p.toLowerCase();return j.name.toLowerCase().includes(A)}),y=j=>{switch(j.key){case"ArrowDown":j.preventDefault(),f(A=>Math.min(A+1,b.length-1));break;case"ArrowUp":j.preventDefault(),f(A=>Math.max(A-1,0));break;case"Enter":j.preventDefault(),b[h]&&v(b[h].id);break;case"Escape":j.preventDefault(),u(!1);break}},v=async j=>{const A=await Tn.getState().fetchCommand(j);A&&e(A.prompt,A.metadata.agentMode,i,s),u(!1)},_=()=>{u(!1),r()};return o.jsxs("div",{ref:x,className:"relative",children:[o.jsxs("button",{type:"button",onClick:()=>u(j=>!j),className:"flex items-center gap-1 text-sm text-text-muted hover:text-text-primary transition-colors",children:["Commands",o.jsx("svg",{className:`w-3 h-3 transition-transform ${c?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),c&&o.jsxs("div",{className:"absolute bottom-full right-0 mb-1 w-72 bg-bg-secondary border border-border rounded-lg shadow-xl z-50",onKeyDown:y,children:[o.jsx("div",{className:"p-2 border-b border-border",children:o.jsx("input",{ref:S,value:p,onChange:j=>{l(j.target.value),f(0)},placeholder:"Search commands...",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary"})}),o.jsx("div",{className:"overflow-y-auto max-h-64 p-1",children:b.length===0?o.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:k.length===0?"No commands yet":"No matches"}):b.map((j,A)=>o.jsxs("div",{className:`flex items-center gap-1 px-3 py-2 rounded transition-colors group ${A===h?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[o.jsx("button",{type:"button",onClick:()=>v(j.id),className:"flex-1 text-left",children:o.jsx("div",{className:"text-sm text-text-primary font-medium",children:j.name})}),o.jsx(ri,{className:"opacity-0 group-hover:opacity-100",onClick:N=>{N.stopPropagation(),u(!1),m(j.id)}})]},j.id))}),o.jsx("div",{className:"border-t border-border p-1",children:o.jsx("button",{type:"button",onClick:_,className:"w-full text-left px-3 py-1.5 rounded text-sm text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors",children:"Manage Commands..."})})]}),o.jsx(H0,{isOpen:!!g,onClose:()=>m(null),initialEditId:g})]})}function l4(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function c4(e){let r=1;for(;e.some(i=>i.id===`s${r}`);)r++;return`s${r}`}const u4=[{value:"agent",label:"Agent"},{value:"sub_agent",label:"Sub-Agent"},{value:"shell",label:"Shell"}],P0={all_criteria_passed:"All passed",all_criteria_completed_or_passed:"All completed",any_criteria_blocked:"Blocked",has_pending_criteria:"Pending/Failed",step_result:"Result",always:"Always"},F0=[{value:"all_criteria_passed",label:"All criteria passed"},{value:"all_criteria_completed_or_passed",label:"All criteria completed or passed"},{value:"any_criteria_blocked",label:"Any criteria blocked (retry limit)"},{value:"has_pending_criteria",label:"Has pending or failed criteria"},{value:"step_result",label:"Step result is..."},{value:"always",label:"Always (fallback)"}],Ci=150,jr=54,_s=80,jn=30,Ss=70,qv=100,ki=50,_l=50,Wv=4;function Zh(e,r){if(e.type==="agent"){const i=r.find(s=>s.id===e.toolMode);return{name:(i==null?void 0:i.name)??(e.toolMode||"Agent"),color:(i==null?void 0:i.color)||"#3b82f6"}}if(e.type==="sub_agent"){const i=r.find(s=>s.id===e.subAgentType);return{name:(i==null?void 0:i.name)??(e.subAgentType||"Sub-Agent"),color:(i==null?void 0:i.color)||"#a855f7"}}return{name:"Shell",color:"#22c55e"}}function d4(e,r,i,s){const c=_l+ki+Ci+qv+Ci+ki+_l,u=c/2,p=_l+ki+Ci/2,l=_l+ki+Ci+qv+Ci/2,h=[],f=[],g=new Map,m=e.filter(F=>F.type==="agent"||F.type==="shell"),x=e.filter(F=>F.type==="sub_agent"),S=x.length>0,k=S?p:u,C=m.length>0?l:u,b=ki+jn/2;if(h.push({id:"$start",type:"terminal",label:"Start",cx:k,cy:b,w:_s,h:jn}),g.set("$start",{cx:k,cy:b,w:_s,h:jn}),e.length===0){const F=b+jn/2+Ss*2+jn/2;return h.push({id:"$done",type:"terminal",label:"Done",cx:k,cy:F,w:_s,h:jn}),g.set("$done",{cx:k,cy:F,w:_s,h:jn}),{nodes:h,edges:f,width:c,height:F+jn/2+ki,posMap:g}}const y=b+jn/2+Ss,v=(F,I)=>{F.forEach(($,X)=>{const J=y+X*(jr+Ss)+jr/2,{name:R,color:D}=Zh($,s);h.push({id:$.id,type:"step",label:R,color:D,cx:I,cy:J,w:Ci,h:jr}),g.set($.id,{cx:I,cy:J,w:Ci,h:jr})})};v(m,k),v(x,C);const _=m.length>0?y+(m.length-1)*(jr+Ss)+jr/2:b,j=S?y+(x.length-1)*(jr+Ss)+jr/2:b,A=Math.max(_,j)+jr/2+Ss+jn/2;h.push({id:"$done",type:"terminal",label:"Done",cx:k,cy:A,w:_s,h:jn}),g.set("$done",{cx:k,cy:A,w:_s,h:jn});const N=[];r&&g.has(r)&&N.push({from:"$start",to:r,label:i,edgeKey:"start",direction:"down",backEdgeIndex:0});let L=0;for(const F of e)F.transitions.forEach((I,$)=>{if(!I.goto||!g.has(I.goto))return;const X=g.get(F.id),J=g.get(I.goto),R=I.when.type==="step_result"?`${I.when.result}`:P0[I.when.type]??I.when.type,D=F.id===I.goto;let O;D?O="back":J.cy>X.cy+1?O="down":J.cy<X.cy-1?O="back":O="same",N.push({from:F.id,to:I.goto,label:R,edgeKey:`${F.id}:${$}`,direction:O,backEdgeIndex:O==="back"?L++:0})});const T=new Map,B=new Map,H=new Map,q=new Map;for(const F of N)F.direction==="down"&&(T.set(F.from,(T.get(F.from)??0)+1),B.set(F.to,(B.get(F.to)??0)+1));const Y=new Map,V=new Map;for(const F of N){if(F.direction!=="same")continue;const I=[F.from,F.to].sort().join("|");Y.set(I,(Y.get(I)??0)+1)}for(const F of N){if(F.direction==="back"||F.direction==="same"){let O=0;if(F.direction==="same"){const W=[F.from,F.to].sort().join("|");O=V.get(W)??0,V.set(W,O+1)}f.push({...F,fromPort:0,toPort:0,sameEdgeIndex:O});continue}const I=T.get(F.from)??1,$=B.get(F.to)??1,X=H.get(F.from)??0,J=q.get(F.to)??0;H.set(F.from,X+1),q.set(F.to,J+1);const R=I===1?0:-.6+1.2*X/(I-1),D=$===1?0:-.6+1.2*J/($-1);f.push({...F,fromPort:R,toPort:D,sameEdgeIndex:0})}return{nodes:h,edges:f,width:c,height:A+jn/2+ki,posMap:g}}function h4({steps:e,entryStep:r,selectedNodeId:i,selectedEdgeKey:s,startConditionLabel:c,agentTypes:u,onSelectNode:p,onSelectEdge:l,onRemoveStep:h,onCreateTransition:f,onReconnectTo:g,onReconnectFrom:m,onDeleteTransition:x}){const S=P.useRef(null),k=P.useRef(!1),[C,b]=P.useState(null),[y,v]=P.useState(null),[_,j]=P.useState(null),{nodes:A,edges:N,width:L,height:T,posMap:B}=P.useMemo(()=>d4(e,r,c,u),[e,r,c,u]),H=P.useCallback(K=>{var ae;const te=S.current;if(!te)return{x:0,y:0};const Q=te.createSVGPoint();Q.x=K.clientX,Q.y=K.clientY;const Z=(ae=te.getScreenCTM())==null?void 0:ae.inverse();if(!Z)return{x:0,y:0};const z=Q.matrixTransform(Z);return{x:z.x,y:z.y}},[]),q=P.useCallback(K=>!K||!y||K==="$start"?!1:y.type==="reconnect-from"?K!=="$done":!0,[y]),Y=P.useCallback((K,te)=>{K.stopPropagation(),K.preventDefault();const Q=H(K);v({type:"new",fromNodeId:te,mouseX:Q.x,mouseY:Q.y})},[H]),V=P.useCallback((K,te)=>{K.stopPropagation(),K.preventDefault();const Q=H(K);v({type:"reconnect-to",fromNodeId:te.from,edgeKey:te.edgeKey,mouseX:Q.x,mouseY:Q.y})},[H]),F=P.useCallback((K,te)=>{K.stopPropagation(),K.preventDefault();const Q=H(K);v({type:"reconnect-from",fromNodeId:te.from,fixedTargetId:te.to,edgeKey:te.edgeKey,mouseX:Q.x,mouseY:Q.y})},[H]),I=P.useCallback(K=>{if(!y)return;const te=H(K);v(Q=>Q?{...Q,mouseX:te.x,mouseY:te.y}:null)},[y,H]),$=P.useCallback(()=>{y&&(k.current=!0,_&&q(_)&&(y.type==="new"?f(y.fromNodeId,_):y.type==="reconnect-to"?g(y.edgeKey,_):y.type==="reconnect-from"&&m(y.edgeKey,_)),v(null),j(null))},[y,_,q,f,g,m]),X=P.useCallback(()=>{if(k.current){k.current=!1;return}p(null),l(null)},[p,l]);P.useEffect(()=>{const K=te=>{te.target instanceof HTMLInputElement||te.target instanceof HTMLTextAreaElement||te.target instanceof HTMLSelectElement||(te.key==="Delete"||te.key==="Backspace")&&s&&s!=="start"&&(te.preventDefault(),x(s),l(null))};return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},[s,x,l]);const J=K=>{const te=B.get(K.from),Q=B.get(K.to);if(!te||!Q)return null;let Z,z,ae,se="middle",ge,ve;if(K.direction==="down"){const Ne=te.cx+K.fromPort*(te.w/2-10),De=te.cy+te.h/2,Oe=Q.cx+K.toPort*(Q.w/2-10),Fe=Q.cy-Q.h/2,ke=Fe-De,lt=Oe-Ne;Z=`M ${Ne} ${De} C ${Ne} ${De+ke*.4}, ${Oe-lt*.2} ${Fe-ke*.1}, ${Oe} ${Fe}`,z=Ne+(Oe-Ne)*.5,ae=De+ke*.6,ge={x:Ne,y:De},ve={x:Oe,y:Fe}}else if(K.direction==="back"){const Ne=K.from===K.to,De=te.cx>=L/2,Oe=K.backEdgeIndex*16,Fe=De?L-20-Oe:20+Oe;if(Ne){const ke=te.cx>=L/2,lt=30+K.backEdgeIndex*14,ht=te.cy-te.h/2,fe=ke?te.cx+te.w/2:te.cx-te.w/2,Re=ke?fe+lt:fe-lt,Je=te.cx+(ke?te.w/4:-te.w/4),et=ht-20-K.backEdgeIndex*10;Z=`M ${fe} ${te.cy} C ${Re} ${te.cy}, ${Re} ${et}, ${Je} ${ht}`,z=Re+10,ae=et+4,se="middle",ge={x:fe,y:te.cy},ve={x:Je,y:ht}}else{const ke=De?te.cx+te.w/2:te.cx-te.w/2,lt=Q.cx+(De?Q.w/4:-Q.w/4),ht=Math.min(te.cy,Q.cy)-Q.h/2-18-K.backEdgeIndex*14;Z=`M ${ke} ${te.cy} L ${Fe} ${te.cy} L ${Fe} ${ht} L ${lt} ${ht} L ${lt} ${Q.cy-Q.h/2}`,z=Fe,ae=(te.cy+ht)/2,se=De?"start":"end",ge={x:ke,y:te.cy},ve={x:lt,y:Q.cy-Q.h/2}}}else{const Ne=Q.cx>te.cx,De=K.sameEdgeIndex===0?-12:12,Oe=Ne?te.cx+te.w/2:te.cx-te.w/2,Fe=Ne?Q.cx-Q.w/2:Q.cx+Q.w/2,ke=te.cy+De,lt=Q.cy+De,ht=(Oe+Fe)/2;Z=`M ${Oe} ${ke} C ${ht} ${ke}, ${ht} ${lt}, ${Fe} ${lt}`,z=ht,ae=(ke+lt)/2-6,ge={x:Oe,y:ke},ve={x:Fe,y:lt}}return{path:Z,labelX:z,labelY:ae,labelAnchor:se,fromPt:ge,toPt:ve}},R=(K,te)=>{const Q=J(K);if(!Q)return null;const{path:Z,labelX:z,labelY:ae,labelAnchor:se}=Q,ge=s===K.edgeKey,ve=K.label&&!(K.from==="$start"&&K.label==="Always");return o.jsxs("g",{children:[o.jsx("path",{d:Z,fill:"none",stroke:"transparent",strokeWidth:14,className:"cursor-pointer",onClick:Ne=>{Ne.stopPropagation(),l(ge?null:K.edgeKey)}}),o.jsx("path",{d:Z,fill:"none",stroke:ge?"#58a6ff":"#484f58",strokeWidth:ge?2.2:1.2,markerEnd:ge?"url(#arrow-selected)":"url(#arrow)",pointerEvents:"none"}),ve&&o.jsx("text",{x:z+(se==="start"?5:se==="end"?-5:0),y:ae+3,textAnchor:se,className:"text-[8px]",fill:ge?"#79c0ff":"#8b949e",style:{paintOrder:"stroke",stroke:"#0d1117",strokeWidth:3,strokeLinejoin:"round"},pointerEvents:"none",children:K.label})]},te)},D=()=>{if(!s||y)return null;const K=N.find(ae=>ae.edgeKey===s);if(!K)return null;const te=J(K);if(!te)return null;const{fromPt:Q,toPt:Z}=te,z=6;return o.jsxs(o.Fragment,{children:[K.edgeKey!=="start"&&o.jsx("circle",{cx:Q.x,cy:Q.y,r:z,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:ae=>F(ae,K)}),o.jsx("circle",{cx:Z.x,cy:Z.y,r:z,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:ae=>V(ae,K)})]})},O=()=>{if(!y)return null;let K,te,Q,Z;if(y.type==="reconnect-from"){const se=B.get(y.fixedTargetId);if(!se)return null;K=y.mouseX,te=y.mouseY,Q=se.cx,Z=se.cy-se.h/2}else{const se=B.get(y.fromNodeId);if(!se)return null;K=se.cx,te=se.cy+se.h/2,Q=y.mouseX,Z=y.mouseY}const z=Z-te,ae=Math.abs(z)>10?`M ${K} ${te} C ${K} ${te+z*.4}, ${Q} ${Z-z*.4}, ${Q} ${Z}`:`M ${K} ${te} L ${Q} ${Z}`;return o.jsx("path",{d:ae,fill:"none",stroke:"#58a6ff",strokeWidth:2,strokeDasharray:"6 3",strokeOpacity:.7,pointerEvents:"none"})},W=K=>{const te=K.cy+K.h/2,Q=(y==null?void 0:y.fromNodeId)===K.id;return o.jsx("circle",{cx:K.cx,cy:te,r:Wv,fill:Q?"#58a6ff":"#1c2128",stroke:Q?"#58a6ff":"#484f58",strokeWidth:1.5,strokeOpacity:Q?1:.5,className:"cursor-crosshair",onMouseDown:Z=>Y(Z,K.id)})},U=K=>{const te=K.cy-K.h/2,Q=y&&_===K.id&&q(K.id);return o.jsx("circle",{cx:K.cx,cy:te,r:Wv,fill:Q?"#3fb950":"#1c2128",stroke:Q?"#3fb950":"#484f58",strokeWidth:1.5,strokeOpacity:Q?1:.5})};return o.jsxs("svg",{ref:S,viewBox:`0 0 ${L} ${T}`,className:"block w-full",preserveAspectRatio:"xMidYMin meet",onMouseMove:I,onMouseUp:$,onClick:X,children:[o.jsxs("defs",{children:[o.jsx("marker",{id:"arrow",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"7",markerHeight:"5",orient:"auto",children:o.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#484f58"})}),o.jsx("marker",{id:"arrow-selected",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"7",markerHeight:"5",orient:"auto",children:o.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#58a6ff"})})]}),N.map((K,te)=>R(K,te)),A.map(K=>{const te=i===K.id,Q=K.cx-K.w/2,Z=K.cy-K.h/2,z=C===K.id,ae=y&&_===K.id&&q(K.id);if(K.type==="terminal"){const ge=K.id==="$start",ve=ge?"#58a6ff":"#3fb950",Ne=ge,De=!ge;return o.jsxs("g",{onClick:Oe=>{Oe.stopPropagation(),ge&&l("start")},className:ge?"cursor-pointer":void 0,children:[ae&&o.jsx("rect",{x:Q-3,y:Z-3,width:K.w+6,height:K.h+6,rx:K.h/2+3,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),ge&&s==="start"&&o.jsx("rect",{x:Q-3,y:Z-3,width:K.w+6,height:K.h+6,rx:K.h/2+3,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),o.jsx("rect",{x:Q,y:Z,width:K.w,height:K.h,rx:K.h/2,fill:ve,fillOpacity:.08,stroke:ve,strokeOpacity:.4,strokeWidth:1.5}),o.jsx("text",{x:K.cx,y:K.cy+4,textAnchor:"middle",fill:ve,className:"text-[10px] font-medium",pointerEvents:"none",children:K.label}),Ne&&W(K),De&&U(K)]},K.id)}const se=K.color??"#6b7280";return o.jsxs("g",{onClick:ge=>{ge.stopPropagation(),p(te?null:K.id)},onMouseEnter:()=>b(K.id),onMouseLeave:()=>b(null),className:"cursor-pointer",children:[ae&&o.jsx("rect",{x:Q-3,y:Z-3,width:K.w+6,height:K.h+6,rx:12,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),te&&o.jsx("rect",{x:Q-3,y:Z-3,width:K.w+6,height:K.h+6,rx:12,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),o.jsx("rect",{x:Q,y:Z,width:K.w,height:K.h,rx:10,fill:se,fillOpacity:.08,stroke:se,strokeOpacity:.6,strokeWidth:te?2:1.5}),o.jsx("text",{x:K.cx,y:K.cy+4,textAnchor:"middle",fill:"#c9d1d9",className:"text-[11px] font-medium",pointerEvents:"none",children:K.label}),W(K),U(K),z&&!y&&o.jsxs("g",{onClick:ge=>{ge.stopPropagation(),h(K.id)},className:"cursor-pointer",children:[o.jsx("circle",{cx:Q+K.w-2,cy:Z+2,r:8,fill:"#0d1117",fillOpacity:.9,stroke:"#f85149",strokeOpacity:.5,strokeWidth:1}),o.jsx("line",{x1:Q+K.w-5,y1:Z-1,x2:Q+K.w+1,y2:Z+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"}),o.jsx("line",{x1:Q+K.w+1,y1:Z-1,x2:Q+K.w-5,y2:Z+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"})]})]},K.id)}),y&&A.map(K=>q(K.id)?o.jsx("rect",{x:K.cx-K.w/2-8,y:K.cy-K.h/2-8,width:K.w+16,height:K.h+16,fill:"transparent",rx:12,onMouseEnter:()=>j(K.id),onMouseLeave:()=>j(null),onMouseUp:te=>{te.stopPropagation(),$()}},`drop-${K.id}`):null),O(),D()]})}const Kn="w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",Ni="w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",en="block text-[11px] text-text-secondary mb-0.5";function f4({fromLabel:e,toLabel:r,condition:i,fromStep:s,agentTypes:c,onUpdateCondition:u,onDelete:p}){const l=s&&(s.type==="sub_agent"||s.type==="agent")?c.find(f=>f.id===(s.type==="sub_agent"?s.subAgentType:s.toolMode)):void 0,h=(l==null?void 0:l.results)&&l.results.length>0;return o.jsxs("div",{className:"space-y-3 text-sm",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-blue-500/15 text-blue-300",children:"Transition"}),o.jsx("button",{onClick:p,className:"p-1 rounded text-text-muted hover:text-accent-error text-xs",children:"Delete"})]}),o.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[o.jsx("span",{className:"font-medium text-text-primary",children:e}),o.jsx("svg",{className:"w-3.5 h-3.5 shrink-0 text-text-muted",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14 5l7 7m0 0l-7 7m7-7H3"})}),o.jsx("span",{className:"font-medium text-text-primary",children:r})]}),o.jsxs("div",{children:[o.jsx("label",{className:en,children:"Condition"}),o.jsx("select",{value:i.type,onChange:f=>{u(f.target.value==="step_result"?{type:"step_result",result:"success"}:{type:f.target.value})},className:Ni,children:F0.map(f=>o.jsx("option",{value:f.value,children:f.label},f.value))})]}),i.type==="step_result"&&o.jsxs("div",{children:[o.jsx("label",{className:en,children:"Result"}),h?o.jsx("select",{value:i.result??l.results[0],onChange:f=>{u({type:"step_result",result:f.target.value})},className:Ni,children:l.results.map(f=>o.jsx("option",{value:f,children:f},f))}):o.jsx("input",{type:"text",value:i.result??"success",onChange:f=>u({type:"step_result",result:f.target.value}),placeholder:"e.g. success, passed, failed",className:Kn})]}),o.jsx("p",{className:"text-text-muted text-[10px]",children:"Drag handles to reconnect. Press Delete to remove."})]})}function qd({variables:e,onInsert:r}){return e.length===0?null:o.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:e.map(i=>o.jsx("button",{type:"button",onClick:()=>r(i.name),title:i.description,className:"px-1.5 py-0.5 rounded text-[10px] font-mono bg-bg-primary border border-border text-text-secondary hover:text-accent-primary hover:border-accent-primary/40 transition-colors",children:`{{${i.name}}}`},i.name))})}function p4({step:e,isEntry:r,agentTypes:i,transitionCount:s,templateVariables:c,onUpdate:u,onRemove:p,onSetEntry:l}){const{color:h,name:f}=Zh(e,i);return o.jsxs("div",{className:"space-y-3 text-sm",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold",style:{backgroundColor:h+"20",color:h},children:f}),r&&o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-accent-primary/15 text-accent-primary",children:"Entry"})]}),o.jsxs("div",{className:"flex items-center gap-1",children:[!r&&o.jsx("button",{onClick:l,className:"p-1 rounded text-text-muted hover:text-accent-primary text-xs",children:"Set entry"}),o.jsx("button",{onClick:p,className:"p-1 rounded text-text-muted hover:text-accent-error text-xs",children:"Delete"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:en,children:"Type"}),o.jsx("select",{value:e.type,onChange:g=>{const m=g.target.value,x=m==="sub_agent"?"verification":"build";if(m==="agent"){const S=i.find(k=>!k.subagent);u({...e,type:m,phase:x,toolMode:(S==null?void 0:S.id)??"builder",name:(S==null?void 0:S.name)??"Agent"})}else if(m==="sub_agent"){const S=i.find(k=>k.subagent);u({...e,type:m,phase:x,subAgentType:(S==null?void 0:S.id)??"",name:(S==null?void 0:S.name)??"Sub-Agent"})}else u({...e,type:m,phase:x,name:"Shell"})},className:Ni,children:u4.map(g=>o.jsx("option",{value:g.value,children:g.label},g.value))})]}),e.type==="agent"&&o.jsxs("div",{children:[o.jsx("label",{className:en,children:"Agent Type"}),o.jsx("select",{value:e.toolMode??"builder",onChange:g=>{const m=i.find(x=>x.id===g.target.value);u({...e,toolMode:g.target.value,name:(m==null?void 0:m.name)??g.target.value})},className:Ni,children:i.filter(g=>!g.subagent).map(g=>o.jsx("option",{value:g.id,children:g.name},g.id))})]}),e.type==="sub_agent"&&o.jsxs("div",{children:[o.jsx("label",{className:en,children:"Sub-Agent Type"}),o.jsxs("select",{value:e.subAgentType??"",onChange:g=>{const m=i.find(x=>x.id===g.target.value);u({...e,subAgentType:g.target.value,name:(m==null?void 0:m.name)??g.target.value})},className:Ni,children:[o.jsx("option",{value:"",children:"— select —"}),i.filter(g=>g.subagent).map(g=>o.jsx("option",{value:g.id,children:g.name},g.id))]})]}),(e.type==="agent"||e.type==="sub_agent")&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("label",{className:en,children:"Prompt"}),o.jsx("textarea",{value:e.prompt??"",onChange:g=>u({...e,prompt:g.target.value||void 0}),rows:6,className:`${Kn} resize-y text-xs`,placeholder:"Injected on first entry..."}),o.jsx(qd,{variables:c,onInsert:g=>u({...e,prompt:(e.prompt??"")+`{{${g}}}`})})]}),o.jsxs("div",{children:[o.jsx("label",{className:en,children:"Nudge Prompt"}),o.jsx("textarea",{value:e.nudgePrompt??"",onChange:g=>u({...e,nudgePrompt:g.target.value||void 0}),rows:6,className:`${Kn} resize-y text-xs`,placeholder:"Injected on re-entry..."}),o.jsx(qd,{variables:c,onInsert:g=>u({...e,nudgePrompt:(e.nudgePrompt??"")+`{{${g}}}`})})]})]}),e.type==="shell"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("label",{className:en,children:"Command"}),o.jsx("textarea",{value:e.command??"",onChange:g=>u({...e,command:g.target.value}),rows:3,className:`${Kn} font-mono text-xs resize-y`,placeholder:"cd {{workdir}} && npm run lint"}),o.jsx(qd,{variables:c,onInsert:g=>u({...e,command:(e.command??"")+`{{${g}}}`})})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{children:[o.jsx("label",{className:en,children:"Timeout (ms)"}),o.jsx("input",{type:"number",value:e.timeout??6e4,onChange:g=>u({...e,timeout:Number(g.target.value)}),className:`${Kn} font-mono text-xs`})]}),o.jsxs("div",{children:[o.jsx("label",{className:en,children:"Success Codes"}),o.jsx("input",{value:(e.successExitCodes??[0]).join(", "),onChange:g=>u({...e,successExitCodes:g.target.value.split(",").map(m=>Number(m.trim())).filter(m=>!isNaN(m))}),className:`${Kn} font-mono text-xs`})]})]})]}),o.jsx("div",{className:"pt-1 border-t border-border/50",children:o.jsxs("p",{className:"text-text-muted text-[10px]",children:[s," outgoing transition",s!==1?"s":""," — drag from the bottom port to connect."]})})]})}const Gv=[];function U0({isOpen:e,onClose:r,initialEditId:i}){const s=Vt(pe=>pe.workflows),c=Vt(pe=>pe.modifiedIds),u=Vt(pe=>pe.loading),p=Vt(pe=>pe.templateVariables),l=Vt(pe=>pe.fetchWorkflows),h=Vt(pe=>pe.fetchWorkflow),f=Vt(pe=>pe.fetchTemplateVariables),g=Vt(pe=>pe.createWorkflow),m=Vt(pe=>pe.updateWorkflow),x=Vt(pe=>pe.deleteWorkflow),S=Vt(pe=>pe.restoreDefault),k=Vt(pe=>pe.restoreAllDefaults),[C,b]=P.useState("list"),[y,v]=P.useState(null),[_,j]=P.useState(null),[A,N]=P.useState(null),[L,T]=P.useState(null),[B,H]=P.useState(""),[q,Y]=P.useState(""),[V,F]=P.useState(""),[I,$]=P.useState("1.0.0"),[X,J]=P.useState("#3b82f6"),[R,D]=P.useState(""),[O,W]=P.useState(50),[U,K]=P.useState(Gv),[te,Q]=P.useState({type:"always"}),[Z,z]=P.useState(""),[ae,se]=P.useState(!1),[ge,ve]=P.useState([]),[Ne,De]=P.useState(null),[Oe,Fe]=P.useState(!1);P.useEffect(()=>{e&&(l(),f(),ye("/api/agents").then(pe=>pe.json()).then(pe=>ve(pe.agents??[])).catch(()=>{}),j(null),De(null),Fe(!1),N(null),T(null),i?(b("edit"),v(i),z(""),h(i).then(pe=>{pe&&(H(pe.metadata.name),Y(pe.metadata.id),F(pe.metadata.description),$(pe.metadata.version),J(pe.metadata.color??"#3b82f6"),D(pe.entryStep),W(pe.settings.maxIterations),K(pe.steps),Q(pe.startCondition??{type:"always"}))})):(b("list"),v(null)))},[e,l,h,f,i]);const ke=()=>{v(null),H(""),Y(""),F(""),$("1.0.0"),J("#3b82f6"),D(""),W(50),K(structuredClone(Gv)),Q({type:"always"}),z(""),N(null),T(null),b("edit")},lt=async pe=>{const we=await h(pe);we&&(v(pe),H(we.metadata.name),Y(we.metadata.id),F(we.metadata.description),$(we.metadata.version),J(we.metadata.color??"#3b82f6"),D(we.entryStep),W(we.settings.maxIterations),K(we.steps),Q(we.startCondition??{type:"always"}),z(""),N(null),T(null),b("edit"))},ht=async()=>{var tt;const pe=y??q;if(!pe||!B)return z("Name is required."),!1;if(U.length===0)return z("Add at least one step."),!1;let we=R;if(!we||!U.some(Be=>Be.id===we)){if(we=((tt=U.find(Be=>Be.id))==null?void 0:tt.id)??"",!we)return z("All steps need an ID."),!1;D(we)}se(!0),z("");const ze={metadata:{id:pe,name:B,description:V,version:I||"1.0.0",color:X},entryStep:we,settings:{maxIterations:O},steps:U,startCondition:te},Ve=y?await m(y,ze):await g(ze);return se(!1),Ve.success?(y||v(pe),!0):(z(Ve.error??"Failed to save."),!1)},fe=async()=>{await ht()},Re=async()=>{await ht()&&(i?r():b("list"))},Je=()=>{i?r():b("list")},et=pe=>{H(pe),y||Y(l4(pe))},Ge=P.useCallback(pe=>{N(pe),T(null)},[]),ct=P.useCallback(pe=>{T(pe),N(null)},[]),de=A!==null?Number(A):-1,be=de>=0?U[de]??null:null,re=P.useCallback(pe=>{K(we=>we.map((ze,Ve)=>Ve===de?pe:ze))},[de]),Se=te.type==="step_result"?`${te.result}`:P0[te.type]??te.type,Ce=()=>{const pe=U.length,we=c4(U),ze=ge.find(Ve=>!Ve.subagent);K([...U,{id:we,name:(ze==null?void 0:ze.name)??"Agent",type:"agent",phase:"build",toolMode:(ze==null?void 0:ze.id)??"builder",transitions:[]}]),R||D(we),Ge(String(pe))},He=P.useCallback((pe,we)=>{pe==="$start"?(D(we),ct("start")):K(ze=>{const Ve=ze.find(Be=>Be.id===pe),tt=Ve?Ve.transitions.length:0;return ct(`${pe}:${tt}`),ze.map(Be=>Be.id===pe?{...Be,transitions:[...Be.transitions,{when:{type:"always"},goto:we}]}:Be)})},[ct]),Ae=P.useCallback((pe,we)=>{if(pe==="start")D(we);else{const ze=pe.lastIndexOf(":"),Ve=pe.slice(0,ze),tt=parseInt(pe.slice(ze+1));K(Be=>Be.map(Rt=>Rt.id===Ve?{...Rt,transitions:Rt.transitions.map((Et,Yt)=>Yt===tt?{...Et,goto:we}:Et)}:Rt))}},[]),st=P.useCallback((pe,we)=>{const ze=pe.lastIndexOf(":"),Ve=pe.slice(0,ze),tt=parseInt(pe.slice(ze+1));K(Be=>{const Rt=Be.find(Yt=>Yt.id===Ve);if(!Rt)return Be;const Et=Rt.transitions[tt];return Et?Be.map(Yt=>Yt.id===Ve?{...Yt,transitions:Yt.transitions.filter((Zl,Ls)=>Ls!==tt)}:Yt.id===we?{...Yt,transitions:[...Yt.transitions,Et]}:Yt):Be}),T(null)},[]),it=P.useCallback(pe=>{if(pe==="start")D("");else{const we=pe.lastIndexOf(":"),ze=pe.slice(0,we),Ve=parseInt(pe.slice(we+1));K(tt=>tt.map(Be=>Be.id===ze?{...Be,transitions:Be.transitions.filter((Rt,Et)=>Et!==Ve)}:Be))}T(null)},[]),Ct=P.useCallback((pe,we)=>{if(pe==="start")Q(we);else{const ze=pe.lastIndexOf(":"),Ve=pe.slice(0,ze),tt=parseInt(pe.slice(ze+1));K(Be=>Be.map(Rt=>Rt.id===Ve?{...Rt,transitions:Rt.transitions.map((Et,Yt)=>Yt===tt?{...Et,when:we}:Et)}:Rt))}},[]),$e=pe=>Zh(pe,ge).name,Ln=()=>{if(!L)return null;if(L==="start"){const Et=U.find(Yt=>Yt.id===R);return{type:"start",fromLabel:"Start",toLabel:Et?$e(Et):"(none)",condition:te}}const pe=L.lastIndexOf(":"),we=L.slice(0,pe),ze=parseInt(L.slice(pe+1)),Ve=U.find(Et=>Et.id===we);if(!Ve)return null;const tt=Ve.transitions[ze];if(!tt)return null;const Be=U.find(Et=>Et.id===tt.goto),Rt=tt.goto==="$done"?"Done":Be?$e(Be):tt.goto;return{type:"step",fromLabel:$e(Ve),toLabel:Rt,condition:tt.when}};if(C==="edit"){const pe=Ln();return o.jsxs(un,{isOpen:e,onClose:Je,title:y?"Edit Workflow":"New Workflow",size:"full",children:[Z&&o.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded mb-3",children:Z}),o.jsxs("div",{className:"flex items-end gap-3 mb-3 pb-3 border-b border-border flex-wrap",children:[o.jsxs("div",{className:"min-w-[140px]",children:[o.jsx("label",{className:en,children:"Name"}),o.jsx("input",{value:B,onChange:we=>et(we.target.value),placeholder:"Workflow name",className:Kn})]}),o.jsxs("div",{className:"min-w-[100px]",children:[o.jsx("label",{className:en,children:"ID"}),o.jsx("input",{value:q,onChange:we=>!y&&Y(we.target.value),readOnly:!!y,className:`${Kn} font-mono ${y?"opacity-50":""}`})]}),o.jsxs("div",{className:"flex-1 min-w-[140px]",children:[o.jsx("label",{className:en,children:"Description"}),o.jsx("input",{value:V,onChange:we=>F(we.target.value),placeholder:"What does this workflow do?",className:Kn})]}),o.jsxs("div",{className:"w-20",children:[o.jsx("label",{className:en,children:"Max Iter."}),o.jsx("input",{type:"number",value:O,onChange:we=>W(Number(we.target.value)),className:`${Kn} font-mono`})]}),o.jsxs("div",{children:[o.jsx("label",{className:en,children:"Color"}),o.jsx("input",{type:"color",value:X,onChange:we=>J(we.target.value),className:"w-8 h-8 rounded border border-border cursor-pointer bg-transparent"})]})]}),o.jsxs("div",{className:"flex gap-3",style:{height:"calc(90vh - 220px)",minHeight:300},children:[o.jsxs("div",{className:"flex-1 min-w-0 bg-bg-primary/50 border border-border rounded-lg flex flex-col overflow-hidden",children:[o.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/50 shrink-0",children:[o.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider font-medium",children:"Flow"}),o.jsx("button",{onClick:Ce,className:"text-[11px] text-accent-primary hover:text-accent-primary/80",children:"+ Add Step"})]}),o.jsxs("div",{className:"flex-1 min-h-0 p-2 overflow-auto",children:[o.jsx(h4,{steps:U,entryStep:R,selectedNodeId:(be==null?void 0:be.id)??null,selectedEdgeKey:L,startConditionLabel:Se,agentTypes:ge,onSelectNode:we=>{if(we===null){Ge(null);return}const ze=U.findIndex(Ve=>Ve.id===we);Ge(ze>=0?String(ze):null)},onSelectEdge:ct,onRemoveStep:we=>{var Ve;const ze=U.findIndex(tt=>tt.id===we);if(K(tt=>tt.filter(Be=>Be.id!==we)),de===ze&&Ge(null),R===we){const tt=U.filter(Be=>Be.id!==we);D(((Ve=tt[0])==null?void 0:Ve.id)??"")}},onCreateTransition:He,onReconnectTo:Ae,onReconnectFrom:st,onDeleteTransition:it}),U.length===0&&o.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-text-muted",children:[o.jsx("p",{className:"text-xs mb-2",children:"No steps yet"}),o.jsx("button",{onClick:Ce,className:"px-3 py-1.5 rounded bg-accent-primary/10 text-accent-primary text-xs hover:bg-accent-primary/20",children:"+ Add your first step"})]})]})]}),o.jsxs("div",{className:"w-[300px] shrink-0 border border-border rounded-lg bg-bg-secondary flex flex-col overflow-hidden",children:[o.jsx("div",{className:"px-3 py-1.5 border-b border-border shrink-0",children:o.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider font-medium",children:"Properties"})}),o.jsx("div",{className:"p-3 overflow-y-auto flex-1 min-h-0",children:pe?pe.type==="start"?o.jsxs("div",{className:"space-y-3 text-sm",children:[o.jsx("div",{className:"flex items-center gap-2",children:o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-blue-500/20 text-blue-300",children:"Start"})}),R&&o.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[o.jsx("span",{className:"text-text-primary font-medium",children:"Start"}),o.jsx("svg",{className:"w-3.5 h-3.5 shrink-0 text-text-muted",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14 5l7 7m0 0l-7 7m7-7H3"})}),o.jsx("span",{className:"text-text-primary font-medium",children:pe.toLabel})]}),o.jsxs("div",{children:[o.jsx("label",{className:en,children:"Activation Condition"}),o.jsx("select",{value:te.type,onChange:we=>Q(we.target.value==="step_result"?{type:"step_result",result:"success"}:{type:we.target.value}),className:Ni,children:F0.map(we=>o.jsx("option",{value:we.value,children:we.label},we.value))})]}),te.type==="step_result"&&o.jsxs("div",{children:[o.jsx("label",{className:en,children:"Result"}),R&&(()=>{const we=U.find(Be=>Be.id===R),ze=we&&(we.type==="sub_agent"||we.type==="agent")?ge.find(Be=>Be.id===(we.type==="sub_agent"?we.subAgentType:we.toolMode)):void 0,Ve=(ze==null?void 0:ze.results)&&ze.results.length>0,tt=(ze==null?void 0:ze.results)??[];return Ve?o.jsx("select",{value:te.result??tt[0],onChange:Be=>Q({type:"step_result",result:Be.target.value}),className:Ni,children:tt.map(Be=>o.jsx("option",{value:Be,children:Be},Be))}):o.jsx("input",{type:"text",value:te.result??"success",onChange:Be=>Q({type:"step_result",result:Be.target.value}),placeholder:"e.g. success, passed, failed",className:Kn})})()]}),o.jsx("p",{className:"text-text-muted text-[10px]",children:"Workflow only proceeds when this condition is met. Drag the target handle to change entry step."})]}):o.jsx(f4,{fromLabel:pe.fromLabel,toLabel:pe.toLabel,condition:pe.condition,fromStep:pe.type==="step"?U.find(we=>we.id===pe.fromLabel):void 0,agentTypes:ge,onUpdateCondition:we=>Ct(L,we),onDelete:()=>it(L)}):be?o.jsx(p4,{step:be,isEntry:be.id===R,agentTypes:ge,transitionCount:be.transitions.length,templateVariables:p,onUpdate:re,onRemove:()=>{var we;if(be&&(K(U.filter((ze,Ve)=>Ve!==de)),Ge(null),R===be.id)){const ze=U.filter((Ve,tt)=>tt!==de);D(((we=ze[0])==null?void 0:we.id)??"")}},onSetEntry:()=>D(be.id)}):o.jsxs("p",{className:"text-text-muted text-xs text-center py-8",children:["Click a node or edge to edit.",o.jsx("br",{}),"Drag from a port to connect."]})})]})]}),o.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border",children:[o.jsx(dt,{variant:"secondary",onClick:Je,children:"Cancel"}),o.jsx(dt,{variant:"secondary",onClick:fe,disabled:ae||!B,children:ae?"Saving...":"Save"}),o.jsx(dt,{variant:"primary",onClick:Re,disabled:ae||!B,children:"Save & Close"})]})]})}return o.jsxs(un,{isOpen:e,onClose:r,title:"Workflows",size:"lg",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsx("p",{className:"text-text-secondary text-sm",children:"Workflows define the orchestrator's step sequence when running tasks."}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:[c.length>0&&(Oe?o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:async()=>{await k(),Fe(!1)},className:"px-1.5 py-0.5 rounded bg-amber-500/20 text-amber-400 text-xs hover:bg-amber-500/30 transition-colors",children:"Confirm"}),o.jsx("button",{onClick:()=>Fe(!1),className:"px-1.5 py-0.5 rounded text-text-muted text-xs hover:bg-bg-primary transition-colors",children:"Cancel"})]}):o.jsx("button",{onClick:()=>Fe(!0),className:"px-2 py-1 rounded text-xs text-text-muted hover:text-amber-400 hover:bg-amber-500/10 transition-colors",title:"Restore all workflows to defaults",children:"Restore Defaults"})),o.jsx(dt,{variant:"primary",size:"sm",onClick:ke,children:"+ New"})]})]}),u&&s.length===0?o.jsx("div",{className:"text-text-muted text-sm",children:"Loading workflows..."}):s.length===0?o.jsx("div",{className:"text-text-muted text-sm",children:"No workflows installed."}):o.jsx("div",{className:"space-y-2",children:s.map(pe=>o.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[o.jsxs("div",{className:"min-w-0 flex-1 mr-3",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-text-primary text-sm font-medium",children:pe.name}),o.jsxs("span",{className:"text-text-muted text-xs",children:["v",pe.version]}),c.includes(pe.id)&&o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-amber-500/15 text-amber-400",children:"modified"})]}),o.jsx("p",{className:"text-text-secondary text-xs mt-0.5 truncate",children:pe.description})]}),o.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[c.includes(pe.id)&&(Ne===pe.id?o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:async()=>{await S(pe.id),De(null)},className:"px-1.5 py-0.5 rounded bg-amber-500/20 text-amber-400 text-xs hover:bg-amber-500/30 transition-colors",children:"Restore"}),o.jsx("button",{onClick:()=>De(null),className:"px-1.5 py-0.5 rounded text-text-muted text-xs hover:bg-bg-primary transition-colors",children:"Cancel"})]}):o.jsx("button",{onClick:()=>De(pe.id),className:"p-1.5 rounded hover:bg-bg-primary text-text-muted hover:text-amber-400 transition-colors",title:"Restore default",children:o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})),o.jsx(ri,{onClick:()=>lt(pe.id)}),pe.id!=="default"&&(_===pe.id?o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:()=>{x(pe.id),j(null)},className:"px-1.5 py-0.5 rounded bg-accent-error/20 text-accent-error text-xs",children:"Delete"}),o.jsx("button",{onClick:()=>j(null),className:"px-1.5 py-0.5 rounded text-text-muted text-xs",children:"Cancel"})]}):o.jsx("button",{onClick:()=>j(pe.id),className:"p-1.5 rounded hover:bg-bg-primary text-text-muted hover:text-accent-error transition-colors",children:o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})}))]})]},pe.id))})]})}function m4(e,r){const i=e.startCondition;if(!i||i.type==="always")return!0;switch(i.type){case"has_pending_criteria":return r.some(s=>s.status.type!=="passed");case"all_criteria_passed":return r.length===0||r.every(s=>s.status.type==="passed");case"all_criteria_completed_or_passed":return r.every(s=>s.status.type==="completed"||s.status.type==="passed");case"any_criteria_blocked":return r.some(s=>s.status.type==="failed"&&s.attempts.filter(c=>c.status==="failed").length>=4);case"step_result":return null;default:return null}}function g4({onSelectWorkflow:e,onOpenManager:r,criteria:i}){const[s,c]=P.useState(!1),[u,p]=P.useState(""),[l,h]=P.useState(0),[f,g]=P.useState(null),m=P.useRef(null),x=P.useRef(null),S=Vt(_=>_.workflows),k=Vt(_=>_.fetchWorkflows);P.useEffect(()=>{s&&(k(),p(""),h(0),requestAnimationFrame(()=>{var _;return(_=x.current)==null?void 0:_.focus()}))},[s,k]),P.useEffect(()=>{if(!s)return;const _=j=>{m.current&&!m.current.contains(j.target)&&c(!1)};return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[s]);const C=S.filter(_=>{if(!u)return!0;const j=u.toLowerCase();return _.name.toLowerCase().includes(j)}),b=_=>{switch(_.key){case"ArrowDown":_.preventDefault(),h(j=>Math.min(j+1,C.length-1));break;case"ArrowUp":_.preventDefault(),h(j=>Math.max(j-1,0));break;case"Enter":_.preventDefault(),C[l]&&y(C[l].id);break;case"Escape":_.preventDefault(),c(!1);break}},y=_=>{e(_),c(!1)},v=()=>{c(!1),r()};return o.jsxs("div",{ref:m,className:"relative",children:[o.jsxs("button",{type:"button",onClick:()=>c(_=>!_),className:"flex items-center gap-1 text-sm text-text-muted hover:text-text-primary transition-colors",children:["Workflows",o.jsx("svg",{className:`w-3 h-3 transition-transform ${s?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),s&&o.jsxs("div",{className:"absolute bottom-full right-0 mb-1 w-72 bg-bg-secondary border border-border rounded-lg shadow-xl z-50",onKeyDown:b,children:[o.jsx("div",{className:"p-2 border-b border-border",children:o.jsx("input",{ref:x,value:u,onChange:_=>{p(_.target.value),h(0)},placeholder:"Search workflows...",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary"})}),o.jsx("div",{className:"overflow-y-auto max-h-64 p-1",children:C.length===0?o.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:S.length===0?"No workflows yet":"No matches"}):C.map((_,j)=>{const A=m4(_,i),N=_.color??"#3b82f6";return o.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 rounded transition-colors group ${j===l?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[o.jsxs("button",{type:"button",onClick:()=>y(_.id),className:"flex-1 text-left flex items-center gap-2",children:[o.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:N}}),o.jsx("span",{className:"text-sm text-text-primary font-medium flex-1",children:_.name}),A!==null&&o.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:A?"#22c55e":"#6b7280"},title:A?"Entry condition met":"Entry condition not met"})]}),o.jsx(ri,{className:"opacity-0 group-hover:opacity-100",onClick:L=>{L.stopPropagation(),c(!1),g(_.id)}})]},_.id)})}),o.jsx("div",{className:"border-t border-border p-1",children:o.jsx("button",{type:"button",onClick:v,className:"w-full text-left px-3 py-1.5 rounded text-sm text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors",children:"Manage Workflows..."})})]}),o.jsx(U0,{isOpen:!!f,onClose:()=>g(null),initialEditId:f})]})}function x4(e){return e==="criterion"}function v4(e){var r,i;return e.role!=="assistant"||e.subAgentId||(r=e.content)!=null&&r.trim()||(i=e.thinkingContent)!=null&&i.trim()||!e.toolCalls||e.toolCalls.length===0?!1:e.toolCalls.every(s=>x4(s.name))}function b4(e,r=[]){const i=[];let s=null,c=[],u,p=1;const l=new Map,h=new Map,f=[];for(const S of r)S.type==="message"?l.set(S.message.id,S):S.type==="subagent"?h.set(S.subAgentId,S):S.type==="criteria-batch"&&f.push(S);let g=0;const m=()=>{if(c.length>0){const S=f[g];S&&S.type==="criteria-batch"&&S.toolCalls.length===c.length&&S.toolCalls.every((C,b)=>{var y;return C.id===((y=c[b])==null?void 0:y.id)})?i.push(S):i.push({type:"criteria-batch",toolCalls:[...c]}),g++,c=[]}},x=()=>{if(!s)return;const S=s,k=h.get(S.subAgentId);k&&k.type==="subagent"&&k.messages.length===S.messages.length&&k.messages.every((b,y)=>b===S.messages[y])?i.push(k):i.push({type:"subagent",subAgentId:S.subAgentId,subAgentType:S.subAgentType,messages:S.messages}),s=null};for(const S of e)if(S.role!=="tool"){if(S.contextWindowId&&u&&S.contextWindowId!==u&&(m(),x(),p++,i.push({type:"context-divider",windowSequence:p})),u=S.contextWindowId,v4(S)){x();for(const k of S.toolCalls)c.push(k);continue}if(m(),S.subAgentId&&S.subAgentType)s&&s.subAgentId===S.subAgentId?s.messages.push(S):(x(),s={subAgentId:S.subAgentId,subAgentType:S.subAgentType,messages:[S]});else{x();const k=l.get(S.id);k&&k.type==="message"&&k.message===S?i.push(k):i.push({type:"message",message:S})}}return m(),x(),i}function y4(e){const r=new Date(e),i=r.getFullYear(),s=String(r.getMonth()+1).padStart(2,"0"),c=String(r.getDate()).padStart(2,"0"),u=String(r.getHours()).padStart(2,"0"),p=String(r.getMinutes()).padStart(2,"0");return`${i}/${s}/${c} ${u}:${p}`}function _4(e,r){return e.length<=r?e:e.substring(0,r)+"..."}const S4=10,w4=150;function C4(e,r,i){const s=[],c=e.filter(l=>l.role==="user"&&!l.isSystemGenerated&&l.messageKind!=="auto-prompt");for(const l of c)s.push({id:l.id,content:l.content,timestamp:l.timestamp,sessionId:i,sessionName:"This session"});for(const l of r)if(!(i&&l.id===i)&&l.recentUserPrompts)for(const h of l.recentUserPrompts)s.push({id:h.id,content:h.content,timestamp:h.timestamp,sessionId:l.id,sessionName:l.title||l.id});s.sort((l,h)=>new Date(h.timestamp).getTime()-new Date(l.timestamp).getTime());const u=s.slice(0,S4);u.reverse();const p=[];for(const l of u)p.push({id:l.id,content:l.content,timestamp:l.timestamp,formattedTimestamp:y4(l.timestamp),trimmedContent:_4(l.content,w4),sessionId:l.sessionId||void 0,sessionName:l.sessionName});return p}function k4(e,r=[],i=null){const[s,c]=P.useState(0),[u,p]=P.useState(!1),l=P.useMemo(()=>C4(e,r,i),[e,r,i]),h=P.useCallback(()=>{l.length>0&&(c(l.length-1),p(!0))},[l.length]),f=P.useCallback(()=>{p(!1),c(0)},[]),g=P.useCallback(()=>{c(S=>l.length===0?S:S===0?l.length-1:S-1)},[l.length]),m=P.useCallback(()=>{c(S=>l.length===0?S:S===l.length-1?0:S+1)},[l.length]),x=P.useCallback(()=>{if(l.length===0||!u)return null;const S=l[s];return(S==null?void 0:S.content)??null},[l,s,u]);return{history:l,selectedIndex:s,showHistory:u,openHistory:h,closeHistory:f,navigateUp:g,navigateDown:m,selectCurrent:x}}const E4=(e,r)=>{let i,s=!1,c=!1,u=!1,p=!1;const l=()=>{p=!0;const f=e.current;f&&(f.scrollTop=f.scrollHeight),setTimeout(()=>{p=!1},100)},h=()=>{i=requestAnimationFrame(l),setTimeout(()=>{i=requestAnimationFrame(l)},250),setTimeout(()=>{i=requestAnimationFrame(l)},500),setTimeout(()=>{i=requestAnimationFrame(l)},1e3)};return P.useEffect(()=>{const f=e.current;if(!f)return;const g=new MutationObserver(()=>{if(s||c){cancelAnimationFrame(i);return}i=requestAnimationFrame(l)});h(),g.observe(f,{childList:!0,subtree:!0,characterData:!0});const m=setInterval(()=>{if(s||c){cancelAnimationFrame(i);return}l()},1e3),x=C=>{if(u||p)return;f.scrollHeight-f.scrollTop-f.offsetHeight>50?(cancelAnimationFrame(i),s=!0,console.log("Scroll detected!",C)):s=!1},S=()=>c=!0,k=()=>c=!1;return f.addEventListener("wheel",x,{passive:!0}),f.addEventListener("touchstart",S,{passive:!0}),f.addEventListener("touchend",k,{passive:!0}),()=>{f.removeEventListener("wheel",x),f.removeEventListener("touchstart",S),f.removeEventListener("touchend",k),g.disconnect(),clearInterval(m)}},[r==null?void 0:r.id]),{force_scroll_to_bottom:()=>{s=!1,c=!1,u=!0,l(),setTimeout(()=>l(),250),setTimeout(()=>l(),500),setTimeout(()=>l(),750),setTimeout(()=>l(),1e3),setTimeout(()=>{u=!1},1250)}}};function j4({criteriaSidebarOpen:e,onCriteriaSidebarToggle:r}={}){const i=e??!0,[s,c]=P.useState(""),[u,p]=P.useState([]),[l,h]=P.useState(!1),[f,g]=P.useState(null),[m,x]=P.useState(!1),[S,k]=P.useState(!1),C=P.useRef(null),b=P.useRef(null),y=P.useRef(null),v=Ee(re=>re.currentSession),_=Ee(re=>re.messages),j=Ee(re=>re.streamingMessage),A=Ee(re=>re.sessions),N=Ee(re=>re.error),L=Ee(re=>re.pendingQuestion),T=ab(),B=Ee(re=>re.sendMessage),H=Ee(re=>re.clearError),q=Ee(re=>re.acceptAndBuild),Y=Ee(re=>re.stopGeneration),V=Ee(re=>re.launchRunner),F=Ee(re=>re.cancelQueued),I=uS(),$=Vt(re=>re.workflows),X=Vt(re=>re.fetchWorkflows);P.useEffect(()=>{X()},[X]);const{history:J,selectedIndex:R,showHistory:D,openHistory:O,closeHistory:W,navigateUp:U,navigateDown:K,selectCurrent:te}=k4(_,A,v==null?void 0:v.id),Q=P.useMemo(()=>j?_.map(re=>re.id===j.id?j:re):_,[_,j]),Z=P.useRef([]),z=P.useMemo(()=>{const re=b4(Q,Z.current);return Z.current=re,re},[Q]),ae=P.useMemo(()=>n4(_),[_]),{force_scroll_to_bottom:se}=E4(C,v),ge=P.useCallback(()=>{const re=b.current;if(!re)return;re.style.height="auto";const Se=Math.min(200,re.scrollHeight);re.style.height=`${Se}px`},[]);P.useEffect(()=>{if(!(v!=null&&v.id))return;const re=`openfox:draft:${v.id}`,Se=localStorage.getItem(re);Se!==null&&c(Se)},[v==null?void 0:v.id]),P.useEffect(()=>{var re;(re=b.current)==null||re.focus(),ge()},[v==null?void 0:v.id,ge]),P.useEffect(()=>{if(!(v!=null&&v.id))return;const re=`openfox:draft:${v.id}`,Se=setTimeout(()=>{s?localStorage.setItem(re,s):localStorage.removeItem(re)},500);return()=>clearTimeout(Se)},[v==null?void 0:v.id,s]),P.useEffect(()=>{ge()},[s,ge]),P.useEffect(()=>{const re=Se=>{Se.key==="Escape"&&T&&Y()};return window.addEventListener("keydown",re),()=>window.removeEventListener("keydown",re)},[T,Y]),P.useEffect(()=>{const re=b.current;if(!re)return;const Se=Ce=>{var Ae;if(document.activeElement!==re)return;const He=(Ae=Ce.clipboardData)==null?void 0:Ae.items;if(He){for(const st of Array.from(He))if(st.type.startsWith("image/")){Ce.preventDefault();const it=st.getAsFile();if(!it)continue;(async()=>{try{if(!Ud(it)){g("Only PNG, JPG, and GIF images are supported.");return}const Ct=$d(it,50*1024*1024);if(!Ct.valid){g(Ct.error??"Image file is too large");return}const $e=await Fd(it,{maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576}),Ln={id:Sl(),filename:"pasted-image",mimeType:$e.mimeType,size:$e.size,data:$e.dataUrl};p(pe=>[...pe,Ln])}catch(Ct){const $e=Ct instanceof Error?Ct.message??"Failed to process image":"Failed to process image";g($e)}})()}}};return re.addEventListener("paste",Se),()=>re.removeEventListener("paste",Se)},[]);const ve=()=>{c(""),p([]),v!=null&&v.id&&localStorage.removeItem(`openfox:draft:${v.id}`)},Ne=async re=>{re.preventDefault(),!(!s.trim()&&u.length===0)&&(se(),B(s,u.length>0?u:void 0),ve())},De=re=>{if(D)switch(re.key){case"Enter":re.preventDefault();const Se=te();Se&&(c(Se),W());return;case"Escape":re.preventDefault(),W(),T&&Y();return;case"ArrowUp":re.preventDefault(),U();return;case"ArrowDown":re.preventDefault(),K();return}if(re.key==="ArrowUp"&&s.trim()===""&&!D){re.preventDefault(),O();return}re.key==="Enter"&&!re.shiftKey&&(re.preventDefault(),Ne(re))},Oe=P.useCallback(async re=>{const Se=re.target.files;if(!(!Se||Se.length===0)){g(null);for(const Ce of Array.from(Se))try{if(!Ud(Ce)){g(`Unsupported file type: ${Ce.type}. Only PNG, JPG, and GIF are supported.`);continue}const He=$d(Ce,50*1024*1024);if(!He.valid){g(He.error??"Image file is too large");continue}const Ae=await Fd(Ce,{maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576}),st={id:Sl(),filename:Ce.name,mimeType:Ae.mimeType,size:Ae.size,data:Ae.dataUrl};p(it=>[...it,st])}catch(He){const Ae=He instanceof Error?He.message??"Failed to process image":"Failed to process image";g(Ae)}y.current&&(y.current.value="")}},[]),Fe=P.useCallback(re=>{re.preventDefault(),re.stopPropagation(),h(!0)},[]),ke=P.useCallback(re=>{re.preventDefault(),re.stopPropagation(),h(!1)},[]),lt=P.useCallback(async re=>{re.preventDefault(),re.stopPropagation(),h(!1),g(null);const Se=re.dataTransfer.files;if(!(!Se||Se.length===0))for(const Ce of Array.from(Se))try{if(!Ud(Ce)){g(`Unsupported file type: ${Ce.type}. Only PNG, JPG, and GIF are supported.`);continue}const He=$d(Ce,50*1024*1024);if(!He.valid){g(He.error??"Image file is too large");continue}const Ae=await Fd(Ce,{maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576}),st={id:Sl(),filename:Ce.name,mimeType:Ae.mimeType,size:Ae.size,data:Ae.dataUrl};p(it=>[...it,st])}catch(He){const Ae=He instanceof Error?He.message??"Failed to process image":"Failed to process image";g(Ae)}},[]),ht=P.useCallback(re=>{p(Se=>Se.filter(Ce=>Ce.id!==re))},[]),fe=P.useCallback(()=>{var re;(re=y.current)==null||re.click()},[]),Re=(v==null?void 0:v.mode)==="planner",Je=(v==null?void 0:v.mode)==="builder",et=((v==null?void 0:v.criteria.length)??0)>0,Ge=(v==null?void 0:v.phase)==="done",ct=z.some(re=>re.type==="message"&&re.message.role==="assistant"),de=Re&&et&&!T&&ct&&!Ge,be=re=>{const Se=s.trim()?s:void 0,Ce=u.length>0?u:void 0;Re?q(re,Se,Ce):Je&&V(Se,Ce,re),ve()};return o.jsxs(Nw,{criteriaSidebarOpen:i,onCriteriaSidebarToggle:r,messages:Q,children:[L&&o.jsx($3,{question:L}),o.jsx(Aw,{}),o.jsx(q3,{}),o.jsxs("div",{ref:C,"data-testid":"chat-scroll-container",className:"flex-1 min-w-0 overflow-y-auto",children:[o.jsx("div",{className:"pt-4",children:z.map((re,Se)=>{if(re.type==="context-divider")return o.jsxs("div",{className:"flex items-center gap-2 feed-item px-2 md:px-4",children:[o.jsx("div",{className:"flex-1 border-t border-border"}),o.jsx("span",{className:"text-[10px] text-text-muted font-medium px-2",children:"Earlier context summarized"}),o.jsx("div",{className:"flex-1 border-t border-border"})]},Se);if(re.type==="subagent"){const He=re.messages.some(Ae=>Ae.isStreaming);return o.jsx("div",{className:"px-2 md:px-4",children:o.jsx(z3,{messages:re.messages,subAgentType:re.subAgentType,isStreaming:He})},Se)}if(re.type==="criteria-batch")return o.jsx("div",{className:"feed-item px-2 md:px-4",children:o.jsx(B0,{toolCalls:re.toolCalls,criteria:v==null?void 0:v.criteria})},Se);const Ce=re.message;return Ce.role==="assistant"?o.jsx("div",{className:"px-2 md:px-4",children:o.jsx(Kh,{message:Ce,showStats:!0})},Se):o.jsx("div",{className:"px-2 md:px-4",children:o.jsx(I0,{message:Ce,isLastAssistantMessage:!1,promptContext:Ce.role==="user"?ae[Ce.id]:void 0})},Se)})}),o.jsxs("div",{className:"px-2 md:px-4 pb-4",children:[N&&o.jsx("div",{className:"feed-item bg-red-500/10 border border-red-500/50 rounded p-2",children:o.jsxs("div",{className:"flex items-start justify-between gap-2",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-red-400 text-sm font-medium",children:N.code}),o.jsx("div",{className:"text-red-300 text-xs mt-0.5",children:N.message})]}),o.jsx("button",{onClick:H,className:"text-red-400 hover:text-red-300 p-0.5","aria-label":"Dismiss error",children:o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),de&&o.jsx("div",{className:"flex justify-center gap-2 feed-item flex-wrap",children:$.map(re=>{const Se=re.color??"#3b82f6",Ce=parseInt(Se.slice(1,3),16),He=parseInt(Se.slice(3,5),16),Ae=parseInt(Se.slice(5,7),16),st=`rgba(${Ce},${He},${Ae},0.12)`,it=`rgba(${Ce},${He},${Ae},0.22)`,Ct=`rgba(${Ce},${He},${Ae},0.25)`;return o.jsxs("button",{onClick:()=>q(re.id),className:"px-4 py-1.5 rounded text-sm font-medium transition-colors",style:{backgroundColor:st,color:Se,border:`1px solid ${Ct}`},onMouseEnter:$e=>{$e.currentTarget.style.backgroundColor=it},onMouseLeave:$e=>{$e.currentTarget.style.backgroundColor=st},children:["▶ ",re.name]},re.id)})}),T&&o.jsx(W3,{})]})]}),o.jsxs("form",{onSubmit:Ne,className:"p-2 md:p-4 border-t border-border bg-gradient-to-t from-bg-secondary/50 to-transparent",children:[o.jsx("input",{ref:y,type:"file",accept:".png,.jpg,.jpeg,.gif",onChange:Oe,className:"hidden",multiple:!0}),f&&o.jsx("div",{className:"mb-2 p-2 bg-red-500/10 border border-red-500/50 rounded text-red-300 text-sm",children:f}),u.length>0&&o.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:u.map(re=>o.jsx(G3,{attachment:re,onRemove:ht},re.id))}),D&&o.jsx(V3,{history:J,selectedIndex:R,onSelect:re=>{c(re),W()},onEscape:W,onNavigate:re=>{re==="up"?U():K()}}),I.length>0&&o.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:I.map(re=>o.jsxs("div",{className:`inline-flex items-center gap-1.5 px-2 py-1 rounded text-xs ${re.mode==="asap"?"bg-amber-500/15 text-amber-300 border border-amber-500/30":"bg-blue-500/15 text-blue-300 border border-blue-500/30"}`,children:[o.jsxs("span",{className:"font-medium",children:[re.mode==="asap"?"ASAP":"Queue",":"]}),o.jsx("span",{className:"truncate max-w-[200px]",children:re.content}),o.jsx("button",{type:"button",onClick:()=>F(re.queueId),className:"hover:text-white transition-colors",children:o.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]},re.queueId))}),o.jsxs("div",{className:`flex items-end gap-3 p-3 rounded border transition-colors ${l?"border-accent-primary/50 bg-accent-primary/10":"border-border bg-bg-tertiary/50"}`,onDragOver:Fe,onDragLeave:ke,onDrop:lt,children:[o.jsx("button",{type:"button",onClick:fe,className:"p-3 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Attach image file",children:o.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13"})})}),o.jsx("textarea",{ref:b,value:s,onChange:re=>{c(re.target.value),D&&W()},onKeyDown:De,placeholder:Re?"What would you like to build?":"Send a message...",className:"flex-1 bg-transparent text-sm placeholder:text-text-muted resize-none overflow-y-auto focus:outline-none",style:{minHeight:"24px",maxHeight:"200px"}}),o.jsxs("div",{className:"flex flex-col items-end gap-1",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(o4,{onSendCommand:(re,Se,Ce,He)=>{var st;Se&&(v==null?void 0:v.mode)!==Se&&Ee.getState().switchMode(Se);const Ae=Ce&&Ce.trim()?`${Ce.trim()}
149
149
 
150
- ${re}`:re;(st=C.current)==null||st.scrollTo({top:C.current.scrollHeight,behavior:"smooth"}),B(Ae,He!=null&&He.length?He:void 0,{messageKind:"command",isSystemGenerated:!0}),ve()},onOpenManager:()=>x(!0),textareaContent:s,attachments:u.length>0?u:void 0}),o.jsx(g4,{onSelectWorkflow:be,onOpenManager:()=>k(!0),criteria:(v==null?void 0:v.criteria)??[]})]}),o.jsx("div",{className:"flex items-center gap-2",children:o.jsx("button",{type:"button",onClick:()=>{var re;!s.trim()&&u.length===0||((re=C.current)==null||re.scrollTo({top:C.current.scrollHeight,behavior:"smooth"}),B(s,u),ve())},disabled:!s.trim()&&u.length===0,className:"px-4 py-1.5 rounded bg-accent-primary/20 text-sm text-accent-primary font-medium hover:bg-accent-primary/30 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:"Send"})})]})]}),o.jsxs("div",{className:"mt-3 flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(F3,{}),o.jsx(U3,{})]}),o.jsx(s4,{})]})]}),o.jsx(H0,{isOpen:m,onClose:()=>x(!1)}),o.jsx(U0,{isOpen:S,onClose:()=>k(!1)})]})}P.memo(function({item:r}){const[i,s]=P.useState(!1);return r.type==="start"?o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-amber-500/10 border border-amber-500/30 rounded text-amber-300 text-sm",children:[o.jsx("span",{className:"animate-pulse",children:"●"}),o.jsx("span",{children:"Delegating image to fallback vision model..."}),r.filename&&o.jsxs("span",{className:"text-amber-400/70",children:["(",r.filename,")"]})]}):o.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 bg-accent-success/10 border border-accent-success/30 rounded",children:[o.jsx("span",{className:"text-accent-success",children:"✓"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx("span",{className:"text-accent-success text-sm",children:"Image description done"}),o.jsx("button",{type:"button",onClick:()=>s(!i),className:"text-xs text-accent-primary hover:text-accent-primary/80 transition-colors",children:i?"Hide":"Show"})]}),i&&r.description&&o.jsx("div",{className:"mt-2 text-xs prose prose-invert prose-sm max-w-none",children:o.jsx(Ri,{content:r.description})})]})]})});function Vv({isOpen:e,isRetry:r,onSubmit:i,onCancel:s}){const[c,u]=P.useState(""),p=P.useRef(null);P.useEffect(()=>{e&&(u(""),setTimeout(()=>{var h;return(h=p.current)==null?void 0:h.focus()},100))},[e]);const l=h=>{h.preventDefault(),c.trim()&&i(c)};return o.jsx(un,{isOpen:e,onClose:s,title:r?"Invalid Password":"Password Required",size:"sm",children:o.jsxs("form",{onSubmit:l,className:"space-y-4",children:[o.jsx("p",{className:"text-text-secondary text-sm",children:r?"The password you entered was incorrect. Please try again.":"This server requires a password to connect."}),o.jsx(zl,{ref:p,type:"password",value:c,onChange:h=>u(h.target.value),placeholder:"Enter password",autoFocus:!0}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(dt,{type:"button",variant:"secondary",onClick:s,children:"Cancel"}),o.jsx(dt,{type:"submit",disabled:!c.trim(),children:r?"Try Again":"Connect"})]})]})})}const N4=[8e3,11434,8080],T4=[{name:"OpenCode Go",url:"https://opencode.ai/zen/go/v1",backend:"opencode-go"}];function Yv(e){switch(e){case"vllm":return"vLLM";case"sglang":return"SGLang";case"ollama":return"Ollama";case"llamacpp":return"llama.cpp";case"openai":return"OpenAI";case"anthropic":return"Anthropic";case"opencode-go":return"OpenCode Go";case"auto":return"Auto";case"unknown":return"Unknown";default:return e}}function $0({size:e="md"}){const r=e==="sm"?"w-4 h-4":"w-6 h-6";return o.jsxs("svg",{className:`animate-spin ${r} text-text-muted`,fill:"none",viewBox:"0 0 24 24",children:[o.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),o.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})}function A4(){return o.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}function D4(){return o.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})}function L4({currentStep:e,totalSteps:r,labels:i,onStepClick:s}){return o.jsx("div",{className:"flex justify-center py-6",children:o.jsx("div",{className:"flex items-center",children:Array.from({length:r},(c,u)=>{const p=u+1,l=p<e,h=p===e;return o.jsxs("div",{className:"flex items-center",children:[o.jsx("button",{onClick:()=>s==null?void 0:s(p),className:`size-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors shrink-0 ${l?"bg-accent-primary text-white hover:opacity-80":h?"bg-accent-primary text-white":"bg-bg-tertiary text-text-muted"}`,children:l?"✓":p}),o.jsx("button",{onClick:()=>s==null?void 0:s(p),className:`ml-2 mr-4 text-sm whitespace-nowrap hidden sm:block ${h?"text-text-primary font-medium":"text-text-muted hover:text-text-secondary"}`,children:i[u]}),u<r-1&&o.jsx("div",{className:`w-12 sm:w-20 h-0.5 mr-4 ${l?"bg-accent-primary":"bg-border"}`})]},u)})})})}function R4({onNext:e}){const[r,i]=P.useState([]),[s,c]=P.useState([]),[u,p]=P.useState(!1),[l,h]=P.useState(""),[f,g]=P.useState(""),[m,x]=P.useState(""),[S,k]=P.useState("auto"),[C,b]=P.useState(!1),[y,v]=P.useState(null),[_,j]=P.useState(null),[A,N]=P.useState(null),[L,T]=P.useState("");P.useEffect(()=>{B()},[]);async function B(){try{const I=await ye("/api/providers");if(I.ok){const X=(await I.json()).providers.map(J=>({id:J.id,name:J.name,url:J.url,backend:J.backend,model:null,apiKey:J.apiKey}));i(X),c(X)}}catch{}}async function H(I){b(!0),v(null);const $=S!=="auto";try{const J=await(await ye("/api/providers/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:I,skipBackendDetection:$})})).json();J.success?($||k(J.backend??"auto"),v({success:!0,model:J.model??void 0})):v({success:!1,error:J.error??"Connection failed"})}catch(X){v({success:!1,error:X instanceof Error?X.message:"Connection failed"})}b(!1)}function q(){if(!f)return;const I=l||`Provider ${s.length+1}`,$={id:`temp-${Date.now()}`,name:I,url:f,backend:y!=null&&y.success?S:"auto",model:y!=null&&y.success?y.model??null:null,apiKey:m||void 0};c([...s,$]),h(""),g(""),x(""),v(null)}function Y(I){j(I),r.some(X=>X.id===I)?ye(`/api/providers/${I}`,{method:"DELETE"}).then(()=>{c(s.filter(X=>X.id!==I)),i(r.filter(X=>X.id!==I)),j(null)}).catch(()=>{j(null)}):(c(s.filter(X=>X.id!==I)),j(null))}async function V(){for(const $ of s)($.id.startsWith("temp-")||!r.some(X=>X.id===$.id))&&((await ye("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:$.name,url:$.url,backend:$.backend,model:$.model,apiKey:$.apiKey})})).ok||console.error("Failed to add provider",$));const I=s.filter($=>!$.id.startsWith("temp-"));e({providers:I})}const F=s.length>0;return o.jsxs("div",{className:"max-w-xl mx-auto",children:[o.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"LLM Providers"}),o.jsx("p",{className:"text-text-secondary mb-8",children:"Manage your LLM server connections"}),o.jsxs("div",{className:"space-y-4",children:[s.length>0?o.jsx("div",{className:"space-y-2",children:s.map(I=>o.jsxs("div",{className:"flex items-center justify-between bg-bg-secondary rounded-lg p-4 border border-border",children:[o.jsxs("div",{className:"flex-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"px-2 py-0.5 bg-accent-primary/25 text-accent-primary rounded text-xs font-medium",children:Yv(I.backend)}),A===I.id?o.jsx("input",{type:"text",value:L,onChange:$=>T($.target.value),onKeyDown:$=>{$.key==="Enter"&&(c(s.map(X=>X.id===I.id?{...X,name:L}:X)),N(null)),$.key==="Escape"&&N(null)},onBlur:()=>{c(s.map($=>$.id===I.id?{...$,name:L}:$)),N(null)},className:"px-2 py-0.5 bg-bg-primary border border-accent-primary rounded text-text-primary text-sm focus:outline-none",autoFocus:!0}):o.jsx("span",{className:"text-text-primary font-medium cursor-pointer hover:text-accent-primary",onClick:()=>{N(I.id),T(I.name)},title:"Click to edit",children:I.name})]}),o.jsx("p",{className:"text-text-muted text-sm mt-1",children:I.url}),I.model&&o.jsxs("p",{className:"text-text-secondary text-xs mt-0.5",children:["Model: ",I.model]})]}),o.jsx("button",{onClick:()=>Y(I.id),disabled:_===I.id,className:"p-2 text-text-muted hover:text-red-500 transition-colors disabled:opacity-50",title:"Remove provider",children:o.jsx(D4,{})})]},I.id))}):o.jsx("div",{className:"bg-bg-secondary rounded-lg p-8 text-center border border-border",children:o.jsx("p",{className:"text-text-muted",children:"No providers configured yet"})}),u?o.jsxs("form",{onSubmit:I=>{I.preventDefault(),f&&q()},className:"space-y-4 p-4 bg-bg-tertiary rounded-lg",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-text-secondary mb-2",children:"Service Presets"}),o.jsx("div",{className:"grid grid-cols-2 gap-2",children:T4.map(I=>o.jsx("button",{type:"button",onClick:()=>{h(I.name),g(I.url),k(I.backend),v(null)},className:`p-2 rounded border text-center text-sm transition-colors ${f===I.url?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:I.name},I.name))})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-text-secondary mb-2",children:"Local Presets"}),o.jsx("div",{className:"grid grid-cols-3 gap-2",children:N4.map(I=>o.jsxs("button",{type:"button",onClick:()=>{h(""),g(`http://localhost:${I}`),k("auto"),v(null)},className:`p-2 rounded border text-center text-sm transition-colors ${f===`http://localhost:${I}`?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:["localhost:",I]},I))})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Or enter address manually"}),o.jsx("input",{type:"text",name:"url",value:f,onChange:I=>{g(I.target.value),v(null)},onKeyDown:I=>{I.key==="Enter"&&(I.preventDefault(),H(f))},placeholder:"http://localhost:8000",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Provider name (optional)"}),o.jsx("input",{type:"text",name:"name",value:l,onChange:I=>h(I.target.value),onKeyDown:I=>{I.key==="Enter"&&(I.preventDefault(),q())},placeholder:"My LLM Server",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"API key (optional)"}),o.jsx("input",{type:"password",name:"apiKey",value:m,onChange:I=>x(I.target.value),placeholder:"sk-...",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),y&&o.jsx("div",{className:`p-3 rounded-lg ${y.success?"bg-accent-primary/10":"bg-red-500/10"}`,children:y.success?o.jsxs("p",{className:"text-accent-primary font-medium",children:["✓ Connected to ",Yv(S),y.model&&` (${y.model})`]}):o.jsx("p",{className:"text-red-500",children:y.error})}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("button",{type:"button",onClick:()=>H(f),disabled:!f||C,className:"flex-1 px-4 py-2 bg-bg-secondary border border-border rounded-lg hover:border-text-muted disabled:opacity-50",children:C?o.jsx($0,{size:"sm"}):"Test Connection"}),o.jsx("button",{type:"submit",disabled:!f,className:"flex-1 px-4 py-2 bg-accent-primary text-white rounded-lg hover:bg-accent-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors font-medium",children:y!=null&&y.success?"Add Provider ✓":"Add Provider"})]}),o.jsx("button",{type:"button",onClick:()=>{p(!1),h(""),g(""),v(null)},className:"w-full text-center text-text-muted hover:text-text-secondary text-sm",children:"Cancel"})]}):o.jsxs("button",{onClick:()=>p(!0),className:"w-full flex items-center justify-center gap-2 px-4 py-3 bg-bg-secondary border border-dashed border-border rounded-lg text-text-secondary hover:text-text-primary hover:border-text-muted transition-colors",children:[o.jsx(A4,{}),"Add Provider"]}),o.jsx("button",{onClick:V,disabled:!F,className:"w-full mt-6 px-6 py-3 bg-accent-primary text-white rounded-lg font-medium hover:bg-accent-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Continue"})]})]})}function M4({onNext:e}){const[r,i]=P.useState(""),[s,c]=P.useState(!1);return P.useEffect(()=>{ye("/api/config").then(u=>u.json()).then(u=>{u.workdir?i(u.workdir):fetch("/api/directories?path="+encodeURIComponent("/home")).then(p=>p.json()).then(p=>{p.current&&i(p.current)}).catch(()=>{})}).catch(()=>{fetch("/api/directories?path="+encodeURIComponent("/home")).then(u=>u.json()).then(u=>{u.current&&i(u.current)}).catch(()=>{})})},[]),o.jsxs("div",{className:"max-w-xl mx-auto",children:[o.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"Your Projects Folder"}),o.jsx("p",{className:"text-text-secondary mb-8",children:"Where should OpenFox create project folders?"}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Workspace directory"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("input",{type:"text",value:r,onChange:u=>i(u.target.value),placeholder:"/home/user/projects",className:"flex-1 px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"}),o.jsx("button",{onClick:()=>c(!0),className:"px-4 py-2 bg-bg-secondary border border-border rounded-lg hover:border-text-muted",children:"Browse"})]})]}),s&&o.jsx(fb,{initialPath:r||void 0,onSelect:u=>{i(u),c(!1)},onClose:()=>c(!1)}),o.jsx("button",{onClick:()=>e({workdir:r}),disabled:!r,className:"w-full mt-6 px-6 py-3 bg-accent-primary text-white rounded-lg font-medium hover:bg-accent-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Continue"})]})]})}function O4({onNext:e}){const[r,i]=P.useState(!1),[s,c]=P.useState("http://localhost:11434"),[u,p]=P.useState("qwen3-vl:2b"),{copied:l,copy:h}=L0();P.useEffect(()=>{ye("/api/config").then(g=>g.json()).then(g=>{g.visionFallback&&(i(g.visionFallback.enabled),c(g.visionFallback.url),p(g.visionFallback.model))}).catch(()=>{})},[]);function f(g){if(g){e({});return}e({visionFallback:{enabled:r,url:s,model:u,timeout:120}})}return o.jsxs("div",{className:"max-w-xl mx-auto",children:[o.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"Vision (Optional)"}),o.jsx("p",{className:"text-text-secondary mb-8",children:"Configure a vision model for non-vision models"}),o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"bg-bg-secondary rounded-lg p-4 border border-border",children:[o.jsx("p",{className:"text-text-secondary text-sm mb-2",children:"To enable vision support, you need an Ollama server with a vision model:"}),o.jsx("a",{href:"https://ollama.com/download",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline text-sm",children:"Download Ollama"}),o.jsxs("div",{className:"mt-3 p-2 bg-bg-primary rounded border border-border flex items-center justify-between gap-2",children:[o.jsx("code",{className:"text-text-secondary text-xs",children:"ollama pull qwen3-vl:2b"}),o.jsx("button",{onClick:()=>h("ollama pull qwen3-vl:2b"),className:"text-text-muted hover:text-text-primary transition-colors",title:"Copy",children:l?o.jsx("svg",{className:"w-4 h-4 text-accent-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):o.jsxs("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[o.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",strokeWidth:"2"}),o.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1",strokeWidth:"2"})]})})]})]}),o.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:r,onChange:g=>i(g.target.checked),className:"w-5 h-5 rounded border-border bg-bg-secondary text-accent-primary focus:ring-accent-primary"}),o.jsx("span",{className:"text-text-primary",children:"Enable vision fallback for non-vision models"})]}),r&&o.jsxs("div",{className:"space-y-4 pl-8",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision server URL"}),o.jsx("input",{type:"text",value:s,onChange:g=>c(g.target.value),placeholder:"http://localhost:11434",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision model name"}),o.jsx("input",{type:"text",value:u,onChange:g=>p(g.target.value),placeholder:"qwen3-vl:2b",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]})]}),o.jsxs("div",{className:"flex items-center justify-between pt-4",children:[o.jsx("button",{onClick:()=>f(!0),className:"text-text-muted hover:text-text-secondary text-sm underline",children:"Skip for now"}),o.jsx("button",{onClick:()=>f(!1),className:"px-6 py-3 bg-accent-primary text-white rounded-lg font-medium hover:bg-accent-primary/90 transition-colors",children:"Finish Setup"})]})]})]})}function B4({onClick:e}){return o.jsx("button",{onClick:e,className:"absolute top-4 right-4 p-2 text-text-muted hover:text-text-primary transition-colors",title:"Close",children:o.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})}function I4({onComplete:e}){const[r,i]=P.useState(1),[s,c]=P.useState(!1),[u,p]=P.useState({});async function l(m){p(x=>({...x,providers:m.providers})),i(2)}async function h(m){p(x=>({...x,...m})),i(3)}async function f(m){c(!0);try{if(!(await ye("/api/init/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:u.workdir,visionFallback:m.visionFallback})})).ok)throw new Error("Failed to save config");e()}catch(x){console.error("Failed to save onboarding data:",x),c(!1)}}const g=m=>{i(m)};return o.jsxs("div",{className:"w-full max-w-xl mx-auto px-6 py-16 relative",children:[o.jsx(B4,{onClick:e}),o.jsx(L4,{currentStep:r,totalSteps:3,labels:["LLM Server","Projects Folder","Vision"],onStepClick:g}),o.jsx("div",{className:"max-w-xl mx-auto",children:s?o.jsxs("div",{className:"text-center",children:[o.jsx($0,{size:"md"}),o.jsx("p",{className:"mt-4 text-text-secondary",children:"Saving your settings..."})]}):o.jsxs(o.Fragment,{children:[r===1&&o.jsx(R4,{onNext:l}),r===2&&o.jsx(M4,{onNext:h}),r===3&&o.jsx(O4,{onNext:f})]})})]})}function Qh(){return typeof window>"u"?!1:localStorage.getItem("openfox_token")!==null}function q0(){return o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Hl,{})})}function z4({sidebarOpen:e,onSidebarToggle:r}){const[,i]=hh("/p/:projectId"),s=i==null?void 0:i.projectId,c=Ee(m=>m.connectionStatus),u=Ee(m=>m.listSessions),p=Ee(m=>m.clearSession),l=Ut(m=>m.currentProject),h=Ut(m=>m.loadProject),f=Qh(),g=c==="connected"||f;return P.useEffect(()=>{g&&s&&((l==null?void 0:l.id)!==s&&h(s),u(s),p())},[g,s,l==null?void 0:l.id,h,u,p]),!l||l.id!==s?o.jsx(q0,{}):o.jsxs(o.Fragment,{children:[o.jsx(hb,{projectId:s,isOpen:e,onClose:r}),o.jsx("div",{className:"flex-1 min-w-0 bg-bg-primary",children:o.jsx(YS,{})})]})}function H4({sidebarOpen:e,onSidebarToggle:r,rightSidebarOpen:i,onRightSidebarToggle:s}){const[,c]=hh("/p/:projectId/s/:sessionId"),u=c==null?void 0:c.projectId,p=c==null?void 0:c.sessionId,[,l]=ar(),h=Ee(_=>_.connectionStatus),f=Ee(_=>_.currentSession),g=Ee(_=>_.loadSession),m=Ee(_=>_.listSessions),x=Ee(_=>_.pendingSessionCreate),S=Ee(_=>_.error),k=Ee(_=>_.clearError),C=Ut(_=>_.currentProject),b=Ut(_=>_.loadProject),y=Qh(),v=h==="connected"||y;return P.useEffect(()=>{v&&u&&(C==null?void 0:C.id)!==u&&b(u)},[v,u,C==null?void 0:C.id,b]),P.useEffect(()=>{v&&p&&(f==null?void 0:f.id)!==p&&!x&&g(p),v&&u&&m(u)},[v,p,f==null?void 0:f.id,g,m,x,u]),P.useEffect(()=>{(S==null?void 0:S.code)==="NOT_FOUND"&&u&&(k(),l(`/p/${u}`))},[S,u,k,l]),!C||C.id!==u?o.jsx(q0,{}):o.jsxs(o.Fragment,{children:[o.jsx(hb,{projectId:u,isOpen:e,onClose:r}),o.jsx("div",{className:"flex-1 min-w-0 bg-bg-primary",children:o.jsx(j4,{criteriaSidebarOpen:i,onCriteriaSidebarToggle:s})})]})}function P4(){const e=Pt(i=>i.fetchConfig);function r(){e(),window.history.back()}return o.jsx("div",{className:"flex-1 overflow-y-auto",children:o.jsx(I4,{onComplete:r})})}function F4(){const{connectionStatus:e}=hS(),r=Pt(q=>q.fetchConfig),i=Pt(q=>q.providers),[,s]=ar(),c=Qh(),[u,p]=P.useState(!1);P.useEffect(()=>{(e==="connected"||c)&&r().then(()=>{p(!0)})},[e,c,r]),P.useEffect(()=>{u&&i.length===0&&s("/onboarding")},[u,i.length]);const l=()=>{const q=localStorage.getItem("openfox:leftSidebar");return q!==null?q==="true":!1},h=()=>{const q=localStorage.getItem("openfox:rightSidebar");return q!==null?q==="true":!0},[f,g]=P.useState(l),[m,x]=P.useState(h),[S,k]=P.useState(!1),[C,b]=P.useState(!1),[y,v]=P.useState(!1);P.useEffect(()=>{const q=()=>{v(window.innerWidth<768)};return q(),window.addEventListener("resize",q),()=>window.removeEventListener("resize",q)},[]);const _=y?S:f,j=y?C:m,A=()=>{y?k(!S):g(!f)},N=()=>{y?b(!C):x(!m)};P.useEffect(()=>{y||localStorage.setItem("openfox:leftSidebar",String(f))},[f,y]),P.useEffect(()=>{y||localStorage.setItem("openfox:rightSidebar",String(m))},[m,y]),P.useEffect(()=>{(e==="connected"||c)&&r()},[e,r,c]);const L=Ee(q=>q.showPasswordModal),T=Ee(q=>q.passwordModalRetry),B=Ee(q=>q.submitPassword),H=Ee(q=>q.cancelPassword);return e!=="connected"&&!L&&!c?o.jsxs(o.Fragment,{children:[o.jsx(Vv,{isOpen:!0,isRetry:T,onSubmit:B,onCancel:H}),o.jsx("div",{className:"h-screen flex items-center justify-center",children:o.jsx(qS,{text:"Connecting to server..."})})]}):o.jsxs(o.Fragment,{children:[o.jsx(Vv,{isOpen:L,isRetry:T,onSubmit:B,onCancel:H}),o.jsxs("div",{className:"h-screen flex flex-col",children:[o.jsx(HS,{}),o.jsx(OS,{onMenuClick:A,onCriteriaToggle:N}),o.jsx("div",{className:"flex-1 flex overflow-hidden",children:o.jsxs(z1,{children:[o.jsx(ka,{path:"/onboarding",children:o.jsx(P4,{})}),o.jsx(ka,{path:"/p/:projectId/s/:sessionId",children:o.jsx(H4,{sidebarOpen:_,onSidebarToggle:A,rightSidebarOpen:j,onRightSidebarToggle:N})}),o.jsx(ka,{path:"/p/:projectId/new",children:o.jsx(VS,{})}),o.jsx(ka,{path:"/p/:projectId",children:o.jsx(z4,{sidebarOpen:_,onSidebarToggle:A})}),o.jsx(ka,{path:"/",children:o.jsx(GS,{})})]})})]})]})}g1.createRoot(document.getElementById("root")).render(o.jsx(ln.StrictMode,{children:o.jsx(F4,{})}));
150
+ ${re}`:re;(st=C.current)==null||st.scrollTo({top:C.current.scrollHeight,behavior:"smooth"}),B(Ae,He!=null&&He.length?He:void 0,{messageKind:"command",isSystemGenerated:!0}),ve()},onOpenManager:()=>x(!0),textareaContent:s,attachments:u.length>0?u:void 0}),o.jsx(g4,{onSelectWorkflow:be,onOpenManager:()=>k(!0),criteria:(v==null?void 0:v.criteria)??[]})]}),o.jsx("div",{className:"flex items-center gap-2",children:o.jsx("button",{type:"button",onClick:()=>{var re;!s.trim()&&u.length===0||((re=C.current)==null||re.scrollTo({top:C.current.scrollHeight,behavior:"smooth"}),B(s,u),ve())},disabled:!s.trim()&&u.length===0,className:"px-4 py-1.5 rounded bg-accent-primary/20 text-sm text-accent-primary font-medium hover:bg-accent-primary/30 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:"Send"})})]})]}),o.jsxs("div",{className:"mt-3 flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(F3,{}),o.jsx(U3,{})]}),o.jsx(s4,{})]})]}),o.jsx(H0,{isOpen:m,onClose:()=>x(!1)}),o.jsx(U0,{isOpen:S,onClose:()=>k(!1)})]})}P.memo(function({item:r}){const[i,s]=P.useState(!1);return r.type==="start"?o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-amber-500/10 border border-amber-500/30 rounded text-amber-300 text-sm",children:[o.jsx("span",{className:"animate-pulse",children:"●"}),o.jsx("span",{children:"Delegating image to fallback vision model..."}),r.filename&&o.jsxs("span",{className:"text-amber-400/70",children:["(",r.filename,")"]})]}):o.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 bg-accent-success/10 border border-accent-success/30 rounded",children:[o.jsx("span",{className:"text-accent-success",children:"✓"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx("span",{className:"text-accent-success text-sm",children:"Image description done"}),o.jsx("button",{type:"button",onClick:()=>s(!i),className:"text-xs text-accent-primary hover:text-accent-primary/80 transition-colors",children:i?"Hide":"Show"})]}),i&&r.description&&o.jsx("div",{className:"mt-2 text-xs prose prose-invert prose-sm max-w-none",children:o.jsx(Ri,{content:r.description})})]})]})});function Vv({isOpen:e,isRetry:r,onSubmit:i,onCancel:s}){const[c,u]=P.useState(""),p=P.useRef(null);P.useEffect(()=>{e&&(u(""),setTimeout(()=>{var h;return(h=p.current)==null?void 0:h.focus()},100))},[e]);const l=h=>{h.preventDefault(),c.trim()&&i(c)};return o.jsx(un,{isOpen:e,onClose:s,title:r?"Invalid Password":"Password Required",size:"sm",children:o.jsxs("form",{onSubmit:l,className:"space-y-4",children:[o.jsx("p",{className:"text-text-secondary text-sm",children:r?"The password you entered was incorrect. Please try again.":"This server requires a password to connect."}),o.jsx(zl,{ref:p,type:"password",value:c,onChange:h=>u(h.target.value),placeholder:"Enter password",autoFocus:!0}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(dt,{type:"button",variant:"secondary",onClick:s,children:"Cancel"}),o.jsx(dt,{type:"submit",disabled:!c.trim(),children:r?"Try Again":"Connect"})]})]})})}const N4=[8e3,11434,8080],T4=[{name:"OpenCode Go",url:"https://opencode.ai/zen/go/v1",backend:"opencode-go"}];function Yv(e){switch(e){case"vllm":return"vLLM";case"sglang":return"SGLang";case"ollama":return"Ollama";case"llamacpp":return"llama.cpp";case"openai":return"OpenAI";case"anthropic":return"Anthropic";case"opencode-go":return"OpenCode Go";case"auto":return"Auto";case"unknown":return"Unknown";default:return e}}function $0({size:e="md"}){const r=e==="sm"?"w-4 h-4":"w-6 h-6";return o.jsxs("svg",{className:`animate-spin ${r} text-text-muted`,fill:"none",viewBox:"0 0 24 24",children:[o.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),o.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})}function A4(){return o.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}function D4(){return o.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})}function L4({currentStep:e,totalSteps:r,labels:i,onStepClick:s}){return o.jsx("div",{className:"flex justify-center py-6",children:o.jsx("div",{className:"flex items-center",children:Array.from({length:r},(c,u)=>{const p=u+1,l=p<e,h=p===e;return o.jsxs("div",{className:"flex items-center",children:[o.jsx("button",{onClick:()=>s==null?void 0:s(p),className:`size-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors shrink-0 ${l?"bg-accent-primary text-white hover:opacity-80":h?"bg-accent-primary text-white":"bg-bg-tertiary text-text-muted"}`,children:l?"✓":p}),o.jsx("button",{onClick:()=>s==null?void 0:s(p),className:`ml-2 mr-4 text-sm whitespace-nowrap hidden sm:block ${h?"text-text-primary font-medium":"text-text-muted hover:text-text-secondary"}`,children:i[u]}),u<r-1&&o.jsx("div",{className:`w-12 sm:w-20 h-0.5 mr-4 ${l?"bg-accent-primary":"bg-border"}`})]},u)})})})}function R4({onNext:e}){const[r,i]=P.useState([]),[s,c]=P.useState([]),[u,p]=P.useState(!1),[l,h]=P.useState(""),[f,g]=P.useState(""),[m,x]=P.useState(""),[S,k]=P.useState("auto"),[C,b]=P.useState(!1),[y,v]=P.useState(null),[_,j]=P.useState(null),[A,N]=P.useState(null),[L,T]=P.useState("");P.useEffect(()=>{B()},[]);async function B(){try{const I=await ye("/api/providers");if(I.ok){const X=(await I.json()).providers.map(J=>({id:J.id,name:J.name,url:J.url,backend:J.backend,model:null,apiKey:J.apiKey}));i(X),c(X)}}catch{}}async function H(I){b(!0),v(null);const $=S!=="auto";try{const J=await(await ye("/api/providers/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:I,skipBackendDetection:$})})).json();J.success?($||k(J.backend??"auto"),v({success:!0,model:J.model??void 0})):v({success:!1,error:J.error??"Connection failed"})}catch(X){v({success:!1,error:X instanceof Error?X.message:"Connection failed"})}b(!1)}function q(){if(!f)return;const I=l||`Provider ${s.length+1}`,$={id:`temp-${Date.now()}`,name:I,url:f,backend:y!=null&&y.success?S:"auto",model:y!=null&&y.success?y.model??null:null,apiKey:m||void 0};c([...s,$]),h(""),g(""),x(""),v(null)}function Y(I){j(I),r.some(X=>X.id===I)?ye(`/api/providers/${I}`,{method:"DELETE"}).then(()=>{c(s.filter(X=>X.id!==I)),i(r.filter(X=>X.id!==I)),j(null)}).catch(()=>{j(null)}):(c(s.filter(X=>X.id!==I)),j(null))}async function V(){for(const $ of s)($.id.startsWith("temp-")||!r.some(X=>X.id===$.id))&&((await ye("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:$.name,url:$.url,backend:$.backend,model:$.model,apiKey:$.apiKey})})).ok||console.error("Failed to add provider",$));const I=s.filter($=>!$.id.startsWith("temp-"));e({providers:I})}const F=s.length>0;return o.jsxs("div",{className:"max-w-xl mx-auto",children:[o.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"LLM Providers"}),o.jsx("p",{className:"text-text-secondary mb-8",children:"Manage your LLM server connections"}),o.jsxs("div",{className:"space-y-4",children:[s.length>0?o.jsx("div",{className:"space-y-2",children:s.map(I=>o.jsxs("div",{className:"flex items-center justify-between bg-bg-secondary rounded-lg p-4 border border-border",children:[o.jsxs("div",{className:"flex-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"px-2 py-0.5 bg-accent-primary/25 text-accent-primary rounded text-xs font-medium",children:Yv(I.backend)}),A===I.id?o.jsx("input",{type:"text",value:L,onChange:$=>T($.target.value),onKeyDown:$=>{$.key==="Enter"&&(c(s.map(X=>X.id===I.id?{...X,name:L}:X)),N(null)),$.key==="Escape"&&N(null)},onBlur:()=>{c(s.map($=>$.id===I.id?{...$,name:L}:$)),N(null)},className:"px-2 py-0.5 bg-bg-primary border border-accent-primary rounded text-text-primary text-sm focus:outline-none",autoFocus:!0}):o.jsx("span",{className:"text-text-primary font-medium cursor-pointer hover:text-accent-primary",onClick:()=>{N(I.id),T(I.name)},title:"Click to edit",children:I.name})]}),o.jsx("p",{className:"text-text-muted text-sm mt-1",children:I.url}),I.model&&o.jsxs("p",{className:"text-text-secondary text-xs mt-0.5",children:["Model: ",I.model]})]}),o.jsx("button",{onClick:()=>Y(I.id),disabled:_===I.id,className:"p-2 text-text-muted hover:text-red-500 transition-colors disabled:opacity-50",title:"Remove provider",children:o.jsx(D4,{})})]},I.id))}):o.jsx("div",{className:"bg-bg-secondary rounded-lg p-8 text-center border border-border",children:o.jsx("p",{className:"text-text-muted",children:"No providers configured yet"})}),u?o.jsxs("form",{onSubmit:I=>{I.preventDefault(),f&&q()},className:"space-y-4 p-4 bg-bg-tertiary rounded-lg",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-text-secondary mb-2",children:"Service Presets"}),o.jsx("div",{className:"grid grid-cols-2 gap-2",children:T4.map(I=>o.jsx("button",{type:"button",onClick:()=>{h(I.name),g(I.url),k(I.backend),v(null)},className:`p-2 rounded border text-center text-sm transition-colors ${f===I.url?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:I.name},I.name))})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-text-secondary mb-2",children:"Local Presets"}),o.jsx("div",{className:"grid grid-cols-3 gap-2",children:N4.map(I=>o.jsxs("button",{type:"button",onClick:()=>{h(""),g(`http://localhost:${I}`),k("auto"),v(null)},className:`p-2 rounded border text-center text-sm transition-colors ${f===`http://localhost:${I}`?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:["localhost:",I]},I))})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Or enter address manually"}),o.jsx("input",{type:"text",name:"url",value:f,onChange:I=>{g(I.target.value),v(null)},onKeyDown:I=>{I.key==="Enter"&&(I.preventDefault(),H(f))},placeholder:"http://localhost:8000",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Provider name (optional)"}),o.jsx("input",{type:"text",name:"name",value:l,onChange:I=>h(I.target.value),onKeyDown:I=>{I.key==="Enter"&&(I.preventDefault(),q())},placeholder:"My LLM Server",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"API key (optional)"}),o.jsx("input",{type:"password",name:"apiKey",value:m,onChange:I=>x(I.target.value),placeholder:"sk-...",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),y&&o.jsx("div",{className:`p-3 rounded-lg ${y.success?"bg-accent-primary/10":"bg-red-500/10"}`,children:y.success?o.jsxs("p",{className:"text-accent-primary font-medium",children:["✓ Connected to ",Yv(S),y.model&&` (${y.model})`]}):o.jsx("p",{className:"text-red-500",children:y.error})}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("button",{type:"button",onClick:()=>H(f),disabled:!f||C,className:"flex-1 px-4 py-2 bg-bg-secondary border border-border rounded-lg hover:border-text-muted disabled:opacity-50",children:C?o.jsx($0,{size:"sm"}):"Test Connection"}),o.jsx("button",{type:"submit",disabled:!f,className:"flex-1 px-4 py-2 bg-accent-primary text-white rounded-lg hover:bg-accent-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors font-medium",children:y!=null&&y.success?"Add Provider ✓":"Add Provider"})]}),o.jsx("button",{type:"button",onClick:()=>{p(!1),h(""),g(""),v(null)},className:"w-full text-center text-text-muted hover:text-text-secondary text-sm",children:"Cancel"})]}):o.jsxs("button",{onClick:()=>p(!0),className:"w-full flex items-center justify-center gap-2 px-4 py-3 bg-bg-secondary border border-dashed border-border rounded-lg text-text-secondary hover:text-text-primary hover:border-text-muted transition-colors",children:[o.jsx(A4,{}),"Add Provider"]}),o.jsx("button",{onClick:V,disabled:!F,className:"w-full mt-6 px-6 py-3 bg-accent-primary text-white rounded-lg font-medium hover:bg-accent-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Continue"})]})]})}function M4({onNext:e}){const[r,i]=P.useState(""),[s,c]=P.useState(!1);return P.useEffect(()=>{ye("/api/config").then(u=>u.json()).then(u=>{u.workdir?i(u.workdir):fetch("/api/directories?path="+encodeURIComponent("/home")).then(p=>p.json()).then(p=>{p.current&&i(p.current)}).catch(()=>{})}).catch(()=>{fetch("/api/directories?path="+encodeURIComponent("/home")).then(u=>u.json()).then(u=>{u.current&&i(u.current)}).catch(()=>{})})},[]),o.jsxs("div",{className:"max-w-xl mx-auto",children:[o.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"Your Projects Folder"}),o.jsx("p",{className:"text-text-secondary mb-8",children:"Where should OpenFox create project folders?"}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Workspace directory"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("input",{type:"text",value:r,onChange:u=>i(u.target.value),placeholder:"/home/user/projects",className:"flex-1 px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"}),o.jsx("button",{onClick:()=>c(!0),className:"px-4 py-2 bg-bg-secondary border border-border rounded-lg hover:border-text-muted",children:"Browse"})]})]}),s&&o.jsx(fb,{initialPath:r||void 0,onSelect:u=>{i(u),c(!1)},onClose:()=>c(!1)}),o.jsx("button",{onClick:()=>e({workdir:r}),disabled:!r,className:"w-full mt-6 px-6 py-3 bg-accent-primary text-white rounded-lg font-medium hover:bg-accent-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Continue"})]})]})}function O4({onNext:e}){const[r,i]=P.useState(!1),[s,c]=P.useState("http://localhost:11434"),[u,p]=P.useState("qwen3-vl:2b"),{copied:l,copy:h}=L0();P.useEffect(()=>{ye("/api/config").then(g=>g.json()).then(g=>{g.visionFallback&&(i(g.visionFallback.enabled),c(g.visionFallback.url),p(g.visionFallback.model))}).catch(()=>{})},[]);function f(g){if(g){e({});return}e({visionFallback:{enabled:r,url:s,model:u,timeout:120}})}return o.jsxs("div",{className:"max-w-xl mx-auto",children:[o.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"Vision (Optional)"}),o.jsx("p",{className:"text-text-secondary mb-8",children:"Configure a vision model for non-vision models"}),o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"bg-bg-secondary rounded-lg p-4 border border-border",children:[o.jsx("p",{className:"text-text-secondary text-sm mb-2",children:"To enable vision support, you need an Ollama server with a vision model:"}),o.jsx("a",{href:"https://ollama.com/download",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline text-sm",children:"Download Ollama"}),o.jsxs("div",{className:"mt-3 p-2 bg-bg-primary rounded border border-border flex items-center justify-between gap-2",children:[o.jsx("code",{className:"text-text-secondary text-xs",children:"ollama pull qwen3-vl:2b"}),o.jsx("button",{onClick:()=>h("ollama pull qwen3-vl:2b"),className:"text-text-muted hover:text-text-primary transition-colors",title:"Copy",children:l?o.jsx("svg",{className:"w-4 h-4 text-accent-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):o.jsxs("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[o.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",strokeWidth:"2"}),o.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1",strokeWidth:"2"})]})})]})]}),o.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:r,onChange:g=>i(g.target.checked),className:"w-5 h-5 rounded border-border bg-bg-secondary text-accent-primary focus:ring-accent-primary"}),o.jsx("span",{className:"text-text-primary",children:"Enable vision fallback for non-vision models"})]}),r&&o.jsxs("div",{className:"space-y-4 pl-8",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision server URL"}),o.jsx("input",{type:"text",value:s,onChange:g=>c(g.target.value),placeholder:"http://localhost:11434",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision model name"}),o.jsx("input",{type:"text",value:u,onChange:g=>p(g.target.value),placeholder:"qwen3-vl:2b",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]})]}),o.jsxs("div",{className:"flex items-center justify-between pt-4",children:[o.jsx("button",{onClick:()=>f(!0),className:"text-text-muted hover:text-text-secondary text-sm underline",children:"Skip for now"}),o.jsx("button",{onClick:()=>f(!1),className:"px-6 py-3 bg-accent-primary text-white rounded-lg font-medium hover:bg-accent-primary/90 transition-colors",children:"Finish Setup"})]})]})]})}function B4({onClick:e}){return o.jsx("button",{onClick:e,className:"absolute top-4 right-4 p-2 text-text-muted hover:text-text-primary transition-colors",title:"Close",children:o.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})}function I4({onComplete:e}){const[r,i]=P.useState(1),[s,c]=P.useState(!1),[u,p]=P.useState({});async function l(m){p(x=>({...x,providers:m.providers})),i(2)}async function h(m){p(x=>({...x,...m})),i(3)}async function f(m){c(!0);try{if(!(await ye("/api/init/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:u.workdir,visionFallback:m.visionFallback})})).ok)throw new Error("Failed to save config");e()}catch(x){console.error("Failed to save onboarding data:",x),c(!1)}}const g=m=>{i(m)};return o.jsxs("div",{className:"w-full max-w-xl mx-auto px-6 py-16 relative",children:[o.jsx(B4,{onClick:e}),o.jsx(L4,{currentStep:r,totalSteps:3,labels:["LLM Server","Projects Folder","Vision"],onStepClick:g}),o.jsx("div",{className:"max-w-xl mx-auto",children:s?o.jsxs("div",{className:"text-center",children:[o.jsx($0,{size:"md"}),o.jsx("p",{className:"mt-4 text-text-secondary",children:"Saving your settings..."})]}):o.jsxs(o.Fragment,{children:[r===1&&o.jsx(R4,{onNext:l}),r===2&&o.jsx(M4,{onNext:h}),r===3&&o.jsx(O4,{onNext:f})]})})]})}function Qh(){return typeof window>"u"?!1:localStorage.getItem("openfox_token")!==null}function q0(){return o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Hl,{})})}function z4({sidebarOpen:e,onSidebarToggle:r}){const[,i]=hh("/p/:projectId"),s=i==null?void 0:i.projectId,c=Ee(m=>m.connectionStatus),u=Ee(m=>m.listSessions),p=Ee(m=>m.clearSession),l=Ut(m=>m.currentProject),h=Ut(m=>m.loadProject),f=Qh(),g=c==="connected"||f;return P.useEffect(()=>{g&&s&&((l==null?void 0:l.id)!==s&&h(s),u(s),p())},[g,s,l==null?void 0:l.id,h,u,p]),!l||l.id!==s?o.jsx(q0,{}):o.jsxs(o.Fragment,{children:[o.jsx(hb,{projectId:s,isOpen:e,onClose:r}),o.jsx("div",{className:"flex-1 min-w-0 bg-bg-primary",children:o.jsx(YS,{})})]})}function H4({sidebarOpen:e,onSidebarToggle:r,rightSidebarOpen:i,onRightSidebarToggle:s}){const[,c]=hh("/p/:projectId/s/:sessionId"),u=c==null?void 0:c.projectId,p=c==null?void 0:c.sessionId,[,l]=ar(),h=Ee(_=>_.connectionStatus),f=Ee(_=>_.currentSession),g=Ee(_=>_.loadSession),m=Ee(_=>_.listSessions),x=Ee(_=>_.pendingSessionCreate),S=Ee(_=>_.error),k=Ee(_=>_.clearError),C=Ut(_=>_.currentProject),b=Ut(_=>_.loadProject),y=Qh(),v=h==="connected"||y;return P.useEffect(()=>{v&&u&&(C==null?void 0:C.id)!==u&&b(u)},[v,u,C==null?void 0:C.id,b]),P.useEffect(()=>{v&&p&&(f==null?void 0:f.id)!==p&&!x&&g(p),v&&u&&m(u)},[v,p,f==null?void 0:f.id,g,m,x,u]),P.useEffect(()=>{(S==null?void 0:S.code)==="NOT_FOUND"&&u&&(k(),l(`/p/${u}`))},[S,u,k,l]),!C||C.id!==u?o.jsx(q0,{}):o.jsxs(o.Fragment,{children:[o.jsx(hb,{projectId:u,isOpen:e,onClose:r}),o.jsx("div",{className:"flex-1 min-w-0 bg-bg-primary",children:o.jsx(j4,{criteriaSidebarOpen:i,onCriteriaSidebarToggle:s})})]})}function P4(){const e=Lt(i=>i.fetchConfig);function r(){e(),window.history.back()}return o.jsx("div",{className:"flex-1 overflow-y-auto",children:o.jsx(I4,{onComplete:r})})}function F4(){const{connectionStatus:e}=hS(),r=Lt(q=>q.fetchConfig),i=Lt(q=>q.providers),[,s]=ar(),c=Qh(),[u,p]=P.useState(!1);P.useEffect(()=>{(e==="connected"||c)&&r().then(()=>{p(!0)})},[e,c,r]),P.useEffect(()=>{u&&i.length===0&&s("/onboarding")},[u,i.length]);const l=()=>{const q=localStorage.getItem("openfox:leftSidebar");return q!==null?q==="true":!1},h=()=>{const q=localStorage.getItem("openfox:rightSidebar");return q!==null?q==="true":!0},[f,g]=P.useState(l),[m,x]=P.useState(h),[S,k]=P.useState(!1),[C,b]=P.useState(!1),[y,v]=P.useState(!1);P.useEffect(()=>{const q=()=>{v(window.innerWidth<768)};return q(),window.addEventListener("resize",q),()=>window.removeEventListener("resize",q)},[]);const _=y?S:f,j=y?C:m,A=()=>{y?k(!S):g(!f)},N=()=>{y?b(!C):x(!m)};P.useEffect(()=>{y||localStorage.setItem("openfox:leftSidebar",String(f))},[f,y]),P.useEffect(()=>{y||localStorage.setItem("openfox:rightSidebar",String(m))},[m,y]),P.useEffect(()=>{(e==="connected"||c)&&r()},[e,r,c]);const L=Ee(q=>q.showPasswordModal),T=Ee(q=>q.passwordModalRetry),B=Ee(q=>q.submitPassword),H=Ee(q=>q.cancelPassword);return e!=="connected"&&!L&&!c?o.jsxs(o.Fragment,{children:[o.jsx(Vv,{isOpen:!0,isRetry:T,onSubmit:B,onCancel:H}),o.jsx("div",{className:"h-screen flex items-center justify-center",children:o.jsx(qS,{text:"Connecting to server..."})})]}):o.jsxs(o.Fragment,{children:[o.jsx(Vv,{isOpen:L,isRetry:T,onSubmit:B,onCancel:H}),o.jsxs("div",{className:"h-screen flex flex-col",children:[o.jsx(HS,{}),o.jsx(OS,{onMenuClick:A,onCriteriaToggle:N}),o.jsx("div",{className:"flex-1 flex overflow-hidden",children:o.jsxs(z1,{children:[o.jsx(ka,{path:"/onboarding",children:o.jsx(P4,{})}),o.jsx(ka,{path:"/p/:projectId/s/:sessionId",children:o.jsx(H4,{sidebarOpen:_,onSidebarToggle:A,rightSidebarOpen:j,onRightSidebarToggle:N})}),o.jsx(ka,{path:"/p/:projectId/new",children:o.jsx(VS,{})}),o.jsx(ka,{path:"/p/:projectId",children:o.jsx(z4,{sidebarOpen:_,onSidebarToggle:A})}),o.jsx(ka,{path:"/",children:o.jsx(GS,{})})]})})]})]})}g1.createRoot(document.getElementById("root")).render(o.jsx(ln.StrictMode,{children:o.jsx(F4,{})}));