@nice-code/commander 0.102.0 → 0.103.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,10 +14,10 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
14
14
  `+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{Se=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?xe(n):``}function we(e,t){switch(e.tag){case 26:case 27:case 5:return xe(e.type);case 16:return xe(`Lazy`);case 13:return e.child!==t&&t!==null?xe(`Suspense Fallback`):xe(`Suspense`);case 19:return xe(`SuspenseList`);case 0:case 15:return Ce(e.type,!1);case 11:return Ce(e.type.render,!1);case 1:return Ce(e.type,!0);case 31:return xe(`Activity`);default:return``}}function Te(e){try{var t=``,n=null;do t+=we(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
15
15
  Error generating stack: `+e.message+`
16
16
  `+e.stack}}var Ee=Object.prototype.hasOwnProperty,De=t.unstable_scheduleCallback,Oe=t.unstable_cancelCallback,ke=t.unstable_shouldYield,Ae=t.unstable_requestPaint,je=t.unstable_now,Me=t.unstable_getCurrentPriorityLevel,Ne=t.unstable_ImmediatePriority,Pe=t.unstable_UserBlockingPriority,Fe=t.unstable_NormalPriority,Ie=t.unstable_LowPriority,Le=t.unstable_IdlePriority,Re=t.log,ze=t.unstable_setDisableYieldValue,Be=null,j=null;function Ve(e){if(typeof Re==`function`&&ze(e),j&&typeof j.setStrictMode==`function`)try{j.setStrictMode(Be,e)}catch{}}var He=Math.clz32?Math.clz32:Ge,Ue=Math.log,We=Math.LN2;function Ge(e){return e>>>=0,e===0?32:31-(Ue(e)/We|0)|0}var Ke=256,qe=262144,Je=4194304;function Ye(e){var t=e&42;if(t!==0)return t;switch(e&-e){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 e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Xe(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=Ye(n))):i=Ye(o):i=Ye(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Ye(n))):i=Ye(o)):i=Ye(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function Qe(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function M(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+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 t+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 $e(){var e=Je;return Je<<=1,!(Je&62914560)&&(Je=4194304),e}function et(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function tt(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function nt(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-He(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&rt(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function rt(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-He(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function it(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-He(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function at(e,t){var n=t&-t;return n=n&42?1:ot(n),(n&(e.suspendedLanes|t))===0?n:0}function ot(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=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:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function st(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function ct(){var e=O.p;return e===0?(e=window.event,e===void 0?32:gp(e.type)):e}function lt(e,t){var n=O.p;try{return O.p=e,t()}finally{O.p=n}}var ut=Math.random().toString(36).slice(2),dt=`__reactFiber$`+ut,ft=`__reactProps$`+ut,pt=`__reactContainer$`+ut,mt=`__reactEvents$`+ut,ht=`__reactListeners$`+ut,gt=`__reactHandles$`+ut,_t=`__reactResources$`+ut,vt=`__reactMarker$`+ut;function yt(e){delete e[dt],delete e[ft],delete e[mt],delete e[ht],delete e[gt]}function bt(e){var t=e[dt];if(t)return t;for(var n=e.parentNode;n;){if(t=n[pt]||n[dt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=pf(e);e!==null;){if(n=e[dt])return n;e=pf(e)}return t}e=n,n=e.parentNode}return null}function xt(e){if(e=e[dt]||e[pt]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function St(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function Ct(e){var t=e[_t];return t||=e[_t]={hoistableStyles:new Map,hoistableScripts:new Map},t}function wt(e){e[vt]=!0}var Tt=new Set,Et={};function Dt(e,t){Ot(e,t),Ot(e+`Capture`,t)}function Ot(e,t){for(Et[e]=t,e=0;e<t.length;e++)Tt.add(t[e])}var kt=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]*$`),At={},jt={};function Mt(e){return Ee.call(jt,e)?!0:Ee.call(At,e)?!1:kt.test(e)?jt[e]=!0:(At[e]=!0,!1)}function Nt(e,t,n){if(Mt(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,``+n)}}function Pt(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,``+n)}}function Ft(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,``+r)}}function It(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function Lt(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function Rt(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function zt(e){if(!e._valueTracker){var t=Lt(e)?`checked`:`value`;e._valueTracker=Rt(e,t,``+e[t])}}function Bt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=Lt(e)?e.checked?`true`:`false`:e.value),e=r,e===n?!1:(t.setValue(e),!0)}function Vt(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}var Ht=/[\n"\\]/g;function Ut(e){return e.replace(Ht,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function Wt(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+It(t)):e.value!==``+It(t)&&(e.value=``+It(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):Kt(e,o,It(n)):Kt(e,o,It(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+It(s):e.removeAttribute(`name`)}function Gt(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){zt(e);return}n=n==null?``:``+It(n),t=t==null?n:``+It(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),zt(e)}function Kt(e,t,n){t===`number`&&Vt(e.ownerDocument)===e||e.defaultValue===``+n||(e.defaultValue=``+n)}function qt(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+It(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function Jt(e,t,n){if(t!=null&&(t=``+It(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+It(n)}function Yt(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(oe(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=It(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),zt(e)}function Xt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Qt=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 $t(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||Qt.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function en(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(i(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&$t(e,a,r)}else for(var o in t)t.hasOwnProperty(o)&&$t(e,o,t[o])}function tn(e){if(e.indexOf(`-`)===-1)return!1;switch(e){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 nn=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`]]),rn=/^[\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 an(e){return rn.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function on(){}var sn=null;function cn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ln=null,un=null;function dn(e){var t=xt(e);if(t&&(e=t.stateNode)){var n=e[ft]||null;a:switch(e=t.stateNode,t.type){case`input`:if(Wt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+Ut(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[ft]||null;if(!a)throw Error(i(90));Wt(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&Bt(r)}break a;case`textarea`:Jt(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&qt(e,!!n.multiple,t,!1)}}}var N=!1;function fn(e,t,n){if(N)return e(t,n);N=!0;try{return e(t)}finally{if(N=!1,(ln!==null||un!==null)&&(bu(),ln&&(t=ln,e=un,un=ln=null,dn(t),e)))for(t=0;t<e.length;t++)dn(e[t])}}function pn(e,t){var n=e.stateNode;if(n===null)return null;var r=n[ft]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=!(e===`button`||e===`input`||e===`select`||e===`textarea`)),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(i(231,t,typeof n));return n}var mn=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),hn=!1;if(mn)try{var gn={};Object.defineProperty(gn,"passive",{get:function(){hn=!0}}),window.addEventListener(`test`,gn,gn),window.removeEventListener(`test`,gn,gn)}catch{hn=!1}var _n=null,vn=null,yn=null;function bn(){if(yn)return yn;var e,t=vn,n=t.length,r,i=`value`in _n?_n.value:_n.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return yn=i.slice(e,1<r?1-r:void 0)}function xn(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Sn(){return!0}function Cn(){return!1}function wn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?Sn:Cn,this.isPropagationStopped=Cn,this}return p(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=Sn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=Sn)},persist:function(){},isPersistent:Sn}),t}var Tn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},En=wn(Tn),Dn=p({},Tn,{view:0,detail:0}),On=wn(Dn),kn,An,jn,Mn=p({},Dn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Un,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==jn&&(jn&&e.type===`mousemove`?(kn=e.screenX-jn.screenX,An=e.screenY-jn.screenY):An=kn=0,jn=e),kn)},movementY:function(e){return`movementY`in e?e.movementY:An}}),Nn=wn(Mn),Pn=wn(p({},Mn,{dataTransfer:0})),Fn=wn(p({},Dn,{relatedTarget:0})),In=wn(p({},Tn,{animationName:0,elapsedTime:0,pseudoElement:0})),Ln=wn(p({},Tn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),Rn=wn(p({},Tn,{data:0})),zn={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},Bn={8:`Backspace`,9:`Tab`,12:`Clear`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,224:`Meta`},Vn={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function Hn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Vn[e])?!!t[e]:!1}function Un(){return Hn}var Wn=wn(p({},Dn,{key:function(e){if(e.key){var t=zn[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=xn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?Bn[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Un,charCode:function(e){return e.type===`keypress`?xn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?xn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),Gn=wn(p({},Mn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Kn=wn(p({},Dn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Un})),qn=wn(p({},Tn,{propertyName:0,elapsedTime:0,pseudoElement:0})),Jn=wn(p({},Mn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),Yn=wn(p({},Tn,{newState:0,oldState:0})),Xn=[9,13,27,32],Zn=mn&&`CompositionEvent`in window,Qn=null;mn&&`documentMode`in document&&(Qn=document.documentMode);var $n=mn&&`TextEvent`in window&&!Qn,er=mn&&(!Zn||Qn&&8<Qn&&11>=Qn),tr=` `,nr=!1;function rr(e,t){switch(e){case`keyup`:return Xn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function ir(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var ar=!1;function or(e,t){switch(e){case`compositionend`:return ir(t);case`keypress`:return t.which===32?(nr=!0,tr):null;case`textInput`:return e=t.data,e===tr&&nr?null:e;default:return null}}function sr(e,t){if(ar)return e===`compositionend`||!Zn&&rr(e,t)?(e=bn(),yn=vn=_n=null,ar=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return er&&t.locale!==`ko`?null:t.data;default:return null}}var cr={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 lr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!cr[e.type]:t===`textarea`}function ur(e,t,n,r){ln?un?un.push(r):un=[r]:ln=r,t=Dd(t,`onChange`),0<t.length&&(n=new En(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var dr=null,fr=null;function pr(e){bd(e,0)}function mr(e){if(Bt(St(e)))return e}function hr(e,t){if(e===`change`)return t}var gr=!1;if(mn){var _r;if(mn){var vr=`oninput`in document;if(!vr){var yr=document.createElement(`div`);yr.setAttribute(`oninput`,`return;`),vr=typeof yr.oninput==`function`}_r=vr}else _r=!1;gr=_r&&(!document.documentMode||9<document.documentMode)}function br(){dr&&(dr.detachEvent(`onpropertychange`,xr),fr=dr=null)}function xr(e){if(e.propertyName===`value`&&mr(fr)){var t=[];ur(t,fr,e,cn(e)),fn(pr,t)}}function Sr(e,t,n){e===`focusin`?(br(),dr=t,fr=n,dr.attachEvent(`onpropertychange`,xr)):e===`focusout`&&br()}function Cr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return mr(fr)}function wr(e,t){if(e===`click`)return mr(t)}function Tr(e,t){if(e===`input`||e===`change`)return mr(t)}function Er(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var Dr=typeof Object.is==`function`?Object.is:Er;function Or(e,t){if(Dr(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!Ee.call(t,i)||!Dr(e[i],t[i]))return!1}return!0}function kr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Ar(e,t){var n=kr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=kr(n)}}function jr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?jr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Mr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Vt(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Vt(e.document)}return t}function Nr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var Pr=mn&&`documentMode`in document&&11>=document.documentMode,Fr=null,Ir=null,Lr=null,Rr=!1;function zr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Rr||Fr==null||Fr!==Vt(r)||(r=Fr,`selectionStart`in r&&Nr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Lr&&Or(Lr,r)||(Lr=r,r=Dd(Ir,`onSelect`),0<r.length&&(t=new En(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Fr)))}function Br(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var Vr={animationend:Br(`Animation`,`AnimationEnd`),animationiteration:Br(`Animation`,`AnimationIteration`),animationstart:Br(`Animation`,`AnimationStart`),transitionrun:Br(`Transition`,`TransitionRun`),transitionstart:Br(`Transition`,`TransitionStart`),transitioncancel:Br(`Transition`,`TransitionCancel`),transitionend:Br(`Transition`,`TransitionEnd`)},Hr={},Ur={};mn&&(Ur=document.createElement(`div`).style,`AnimationEvent`in window||(delete Vr.animationend.animation,delete Vr.animationiteration.animation,delete Vr.animationstart.animation),`TransitionEvent`in window||delete Vr.transitionend.transition);function Wr(e){if(Hr[e])return Hr[e];if(!Vr[e])return e;var t=Vr[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Ur)return Hr[e]=t[n];return e}var Gr=Wr(`animationend`),Kr=Wr(`animationiteration`),qr=Wr(`animationstart`),Jr=Wr(`transitionrun`),Yr=Wr(`transitionstart`),Xr=Wr(`transitioncancel`),Zr=Wr(`transitionend`),Qr=new Map,$r=`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(` `);$r.push(`scrollEnd`);function ei(e,t){Qr.set(e,t),Dt(t,[e])}var ti=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},ni=[],ri=0,ii=0;function ai(){for(var e=ri,t=ii=ri=0;t<e;){var n=ni[t];ni[t++]=null;var r=ni[t];ni[t++]=null;var i=ni[t];ni[t++]=null;var a=ni[t];if(ni[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&li(n,i,a)}}function oi(e,t,n,r){ni[ri++]=e,ni[ri++]=t,ni[ri++]=n,ni[ri++]=r,ii|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function si(e,t,n,r){return oi(e,t,n,r),ui(e)}function ci(e,t){return oi(e,null,null,t),ui(e)}function li(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-He(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function ui(e){if(50<du)throw du=0,fu=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var di={};function fi(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function pi(e,t,n,r){return new fi(e,t,n,r)}function mi(e){return e=e.prototype,!(!e||!e.isReactComponent)}function hi(e,t){var n=e.alternate;return n===null?(n=pi(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function gi(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function _i(e,t,n,r,a,o){var s=0;if(r=e,typeof e==`function`)mi(e)&&(s=1);else if(typeof e==`string`)s=Gf(e,n,de.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(e){case te:return e=pi(31,n,t,a),e.elementType=te,e.lanes=o,e;case _:return vi(n.children,a,o,t);case v:s=8,a|=24;break;case y:return e=pi(12,n,t,a|2),e.elementType=y,e.lanes=o,e;case S:return e=pi(13,n,t,a),e.elementType=S,e.lanes=o,e;case C:return e=pi(19,n,t,a),e.elementType=C,e.lanes=o,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case x:s=10;break a;case b:s=9;break a;case ee:s=11;break a;case w:s=14;break a;case T:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=pi(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function vi(e,t,n,r){return e=pi(7,e,r,t),e.lanes=n,e}function yi(e,t,n){return e=pi(6,e,null,t),e.lanes=n,e}function bi(e){var t=pi(18,null,null,0);return t.stateNode=e,t}function xi(e,t,n){return t=pi(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Si=new WeakMap;function Ci(e,t){if(typeof e==`object`&&e){var n=Si.get(e);return n===void 0?(t={value:e,source:t,stack:Te(t)},Si.set(e,t),t):n}return{value:e,source:t,stack:Te(t)}}var wi=[],Ti=0,Ei=null,Di=0,Oi=[],ki=0,Ai=null,ji=1,Mi=``;function Ni(e,t){wi[Ti++]=Di,wi[Ti++]=Ei,Ei=e,Di=t}function Pi(e,t,n){Oi[ki++]=ji,Oi[ki++]=Mi,Oi[ki++]=Ai,Ai=e;var r=ji;e=Mi;var i=32-He(r)-1;r&=~(1<<i),n+=1;var a=32-He(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,ji=1<<32-He(t)+i|n<<i|r,Mi=a+e}else ji=1<<a|n<<i|r,Mi=e}function Fi(e){e.return!==null&&(Ni(e,1),Pi(e,1,0))}function Ii(e){for(;e===Ei;)Ei=wi[--Ti],wi[Ti]=null,Di=wi[--Ti],wi[Ti]=null;for(;e===Ai;)Ai=Oi[--ki],Oi[ki]=null,Mi=Oi[--ki],Oi[ki]=null,ji=Oi[--ki],Oi[ki]=null}function Li(e,t){Oi[ki++]=ji,Oi[ki++]=Mi,Oi[ki++]=Ai,ji=t.id,Mi=t.overflow,Ai=e}var Ri=null,zi=null,P=!1,Bi=null,Vi=!1,Hi=Error(i(519));function Ui(e){throw Yi(Ci(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),Hi}function Wi(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[dt]=e,t[ft]=r,n){case`dialog`:Z(`cancel`,t),Z(`close`,t);break;case`iframe`:case`object`:case`embed`:Z(`load`,t);break;case`video`:case`audio`:for(n=0;n<vd.length;n++)Z(vd[n],t);break;case`source`:Z(`error`,t);break;case`img`:case`image`:case`link`:Z(`error`,t),Z(`load`,t);break;case`details`:Z(`toggle`,t);break;case`input`:Z(`invalid`,t),Gt(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:Z(`invalid`,t);break;case`textarea`:Z(`invalid`,t),Yt(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||Nd(t.textContent,n)?(r.popover!=null&&(Z(`beforetoggle`,t),Z(`toggle`,t)),r.onScroll!=null&&Z(`scroll`,t),r.onScrollEnd!=null&&Z(`scrollend`,t),r.onClick!=null&&(t.onclick=on),t=!0):t=!1,t||Ui(e,!0)}function Gi(e){for(Ri=e.return;Ri;)switch(Ri.tag){case 5:case 31:case 13:Vi=!1;return;case 27:case 3:Vi=!0;return;default:Ri=Ri.return}}function Ki(e){if(e!==Ri)return!1;if(!P)return Gi(e),P=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!==`form`&&n!==`button`)||Gd(e.type,e.memoizedProps)),n=!n),n&&zi&&Ui(e),Gi(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));zi=ff(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));zi=ff(e)}else t===27?(t=zi,$d(e.type)?(e=df,df=null,zi=e):zi=t):zi=Ri?uf(e.stateNode.nextSibling):null;return!0}function qi(){zi=Ri=null,P=!1}function Ji(){var e=Bi;return e!==null&&(Zl===null?Zl=e:Zl.push.apply(Zl,e),Bi=null),e}function Yi(e){Bi===null?Bi=[e]:Bi.push(e)}var Xi=le(null),Zi=null,Qi=null;function $i(e,t,n){A(Xi,t._currentValue),t._currentValue=n}function ea(e){e._currentValue=Xi.current,ue(Xi)}function ta(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function na(e,t,n,r){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),ta(o.return,n,e),r||(s=null);break a}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(i(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),ta(s,n,e),s=null}else s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function ra(e,t,n,r){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(i(387));if(s=s.memoizedProps,s!==null){var c=a.type;Dr(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===me.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[ep]:e.push(ep))}a=a.return}e!==null&&na(t,e,n,r),t.flags|=262144}function ia(e){for(e=e.firstContext;e!==null;){if(!Dr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function aa(e){Zi=e,Qi=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function oa(e){return ca(Zi,e)}function sa(e,t){return Zi===null&&aa(e),ca(e,t)}function ca(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},Qi===null){if(e===null)throw Error(i(308));Qi=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Qi=Qi.next=t;return n}var la=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},ua=t.unstable_scheduleCallback,da=t.unstable_NormalPriority,F={$$typeof:x,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function fa(){return{controller:new la,data:new Map,refCount:0}}function pa(e){e.refCount--,e.refCount===0&&ua(da,function(){e.controller.abort()})}var ma=null,ha=0,ga=0,_a=null;function va(e,t){if(ma===null){var n=ma=[];ha=0,ga=fd(),_a={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return ha++,t.then(ya,ya),t}function ya(){if(--ha===0&&ma!==null){_a!==null&&(_a.status=`fulfilled`);var e=ma;ma=null,ga=0,_a=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function ba(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var xa=D.S;D.S=function(e,t){eu=je(),typeof t==`object`&&t&&typeof t.then==`function`&&va(e,t),xa!==null&&xa(e,t)};var Sa=le(null);function Ca(){var e=Sa.current;return e===null?Ll.pooledCache:e}function wa(e,t){t===null?A(Sa,Sa.current):A(Sa,t.pool)}function Ta(){var e=Ca();return e===null?null:{parent:F._currentValue,pool:e}}var Ea=Error(i(460)),Da=Error(i(474)),Oa=Error(i(542)),ka={then:function(){}};function Aa(e){return e=e.status,e===`fulfilled`||e===`rejected`}function ja(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(on,on),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Fa(e),e;default:if(typeof t.status==`string`)t.then(on,on);else{if(e=Ll,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Fa(e),e}throw Na=t,Ea}}function Ma(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(Na=e,Ea):e}}var Na=null;function Pa(){if(Na===null)throw Error(i(459));var e=Na;return Na=null,e}function Fa(e){if(e===Ea||e===Oa)throw Error(i(483))}var Ia=null,La=0;function Ra(e){var t=La;return La+=1,Ia===null&&(Ia=[]),ja(Ia,e,t)}function za(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function Ba(e,t){throw t.$$typeof===m?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function Va(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function a(e,t){return e=hi(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=67108866,n):(r=r.index,r<n?(t.flags|=67108866,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=67108866),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=yi(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===_?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===T&&Ma(i)===t.type)?(t=a(t,n.props),za(t,n),t.return=e,t):(t=_i(n.type,n.key,n.props,null,e.mode,r),za(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=xi(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=vi(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=yi(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case h:return n=_i(t.type,t.key,t.props,null,e.mode,n),za(n,t),n.return=e,n;case g:return t=xi(t,e.mode,n),t.return=e,t;case T:return t=Ma(t),f(e,t,n)}if(oe(t)||E(t))return t=vi(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,Ra(t),n);if(t.$$typeof===x)return f(e,sa(e,t),n);Ba(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case h:return n.key===i?l(e,t,n,r):null;case g:return n.key===i?u(e,t,n,r):null;case T:return n=Ma(n),p(e,t,n,r)}if(oe(n)||E(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,Ra(n),r);if(n.$$typeof===x)return p(e,t,sa(e,n),r);Ba(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case h:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case g:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case T:return r=Ma(r),m(e,t,n,r,i)}if(oe(r)||E(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,Ra(r),i);if(r.$$typeof===x)return m(e,t,n,sa(t,r),i);Ba(t,r)}return null}function v(i,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),P&&Ni(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return P&&Ni(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&g.alternate!==null&&d.delete(g.key===null?h:g.key),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),P&&Ni(i,h),l}function y(a,s,c,l){if(c==null)throw Error(i(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),P&&Ni(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return P&&Ni(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),P&&Ni(a,g),u}function b(e,r,o,c){if(typeof o==`object`&&o&&o.type===_&&o.key===null&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case h:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===_){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===T&&Ma(l)===r.type){n(e,r.sibling),c=a(r,o.props),za(c,o),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}o.type===_?(c=vi(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=_i(o.type,o.key,o.props,null,e.mode,c),za(c,o),c.return=e,e=c)}return s(e);case g:a:{for(l=o.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}else{n(e,r);break}else t(e,r);r=r.sibling}c=xi(o,e.mode,c),c.return=e,e=c}return s(e);case T:return o=Ma(o),b(e,r,o,c)}if(oe(o))return v(e,r,o,c);if(E(o)){if(l=E(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),y(e,r,o,c)}if(typeof o.then==`function`)return b(e,r,Ra(o),c);if(o.$$typeof===x)return b(e,r,sa(e,o),c);Ba(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=yi(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{La=0;var i=b(e,t,n,r);return Ia=null,i}catch(t){if(t===Ea||t===Oa)throw t;var a=pi(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Ha=Va(!0),Ua=Va(!1),Wa=!1;function Ga(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ka(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function qa(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Ja(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,J&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=ui(e),li(e,null,n),t}return oi(e,r,t,n),ui(e)}function Ya(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,it(e,n)}}function Xa(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Za=!1;function Qa(){if(Za){var e=_a;if(e!==null)throw e}}function $a(e,t,n,r){Za=!1;var i=e.updateQueue;Wa=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,m=f!==s.lane;if(m?(X&f)===f:(r&f)===f){f!==0&&f===ga&&(Za=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var h=e,g=s;f=t;var _=n;switch(g.tag){case 1:if(h=g.payload,typeof h==`function`){d=h.call(_,d,f);break a}d=h;break a;case 3:h.flags=h.flags&-65537|128;case 0:if(h=g.payload,f=typeof h==`function`?h.call(_,d,f):h,f==null)break a;d=p({},d,f);break a;case 2:Wa=!0}}f=s.callback,f!==null&&(e.flags|=64,m&&(e.flags|=8192),m=i.callbacks,m===null?i.callbacks=[f]:m.push(f))}else m={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=m,c=d):u=u.next=m,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;m=s,s=m.next,m.next=null,i.lastBaseUpdate=m,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),Gl|=o,e.lanes=o,e.memoizedState=d}}function eo(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function to(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)eo(n[e],t)}var no=le(null),ro=le(0);function io(e,t){e=Ul,A(ro,e),A(no,t),Ul=e|t.baseLanes}function ao(){A(ro,Ul),A(no,no.current)}function oo(){Ul=ro.current,ue(no),ue(ro)}var so=le(null),co=null;function lo(e){var t=e.alternate;A(ho,ho.current&1),A(so,e),co===null&&(t===null||no.current!==null||t.memoizedState!==null)&&(co=e)}function uo(e){A(ho,ho.current),A(so,e),co===null&&(co=e)}function fo(e){e.tag===22?(A(ho,ho.current),A(so,e),co===null&&(co=e)):po(e)}function po(){A(ho,ho.current),A(so,so.current)}function mo(e){ue(so),co===e&&(co=null),ue(ho)}var ho=le(0);function go(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||sf(n)||cf(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder===`forwards`||t.memoizedProps.revealOrder===`backwards`||t.memoizedProps.revealOrder===`unstable_legacy-backwards`||t.memoizedProps.revealOrder===`together`)){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var _o=0,I=null,vo=null,yo=null,bo=!1,xo=!1,So=!1,Co=0,L=0,wo=null,R=0;function To(){throw Error(i(321))}function Eo(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Dr(e[n],t[n]))return!1;return!0}function Do(e,t,n,r,i,a){return _o=a,I=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,D.H=e===null||e.memoizedState===null?Rs:zs,So=!1,a=n(r,i),So=!1,xo&&(a=B(t,n,r,i)),z(e),a}function z(e){D.H=Ls;var t=vo!==null&&vo.next!==null;if(_o=0,yo=vo=I=null,bo=!1,L=0,wo=null,t)throw Error(i(300));e===null||nc||(e=e.dependencies,e!==null&&ia(e)&&(nc=!0))}function B(e,t,n,r){I=e;var a=0;do{if(xo&&(wo=null),L=0,xo=!1,25<=a)throw Error(i(301));if(a+=1,yo=vo=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}D.H=Bs,o=t(n,r)}while(xo);return o}function Oo(){var e=D.H,t=e.useState()[0];return t=typeof t.then==`function`?No(t):t,e=e.useState()[0],(vo===null?null:vo.memoizedState)!==e&&(I.flags|=1024),t}function ko(){var e=Co!==0;return Co=0,e}function Ao(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function jo(e){if(bo){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}bo=!1}_o=0,yo=vo=I=null,xo=!1,L=Co=0,wo=null}function Mo(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return yo===null?I.memoizedState=yo=e:yo=yo.next=e,yo}function V(){if(vo===null){var e=I.alternate;e=e===null?null:e.memoizedState}else e=vo.next;var t=yo===null?I.memoizedState:yo.next;if(t!==null)yo=t,vo=e;else{if(e===null)throw I.alternate===null?Error(i(467)):Error(i(310));vo=e,e={memoizedState:vo.memoizedState,baseState:vo.baseState,baseQueue:vo.baseQueue,queue:vo.queue,next:null},yo===null?I.memoizedState=yo=e:yo=yo.next=e}return yo}function H(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function No(e){var t=L;return L+=1,wo===null&&(wo=[]),e=ja(wo,e,t),t=I,(yo===null?t.memoizedState:yo.next)===null&&(t=t.alternate,D.H=t===null||t.memoizedState===null?Rs:zs),e}function Po(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return No(e);if(e.$$typeof===x)return oa(e)}throw Error(i(438,String(e)))}function Fo(e){var t=null,n=I.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=I.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=H(),I.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=ne;return t.index++,n}function Io(e,t){return typeof t==`function`?t(e):t}function Lo(e){return Ro(V(),vo,e)}function Ro(e,t,n){var r=e.queue;if(r===null)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,o=r.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,r.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(_o&f)===f:(X&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===ga&&(d=!0);else if((_o&p)===p){u=u.next,p===ga&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,I.lanes|=p,Gl|=p;f=u.action,So&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,I.lanes|=f,Gl|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!Dr(o,e.memoizedState)&&(nc=!0,d&&(n=_a,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return a===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function zo(e){var t=V(),n=t.queue;if(n===null)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);Dr(o,t.memoizedState)||(nc=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function Bo(e,t,n){var r=I,a=V(),o=P;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!Dr((vo||a).memoizedState,n);if(s&&(a.memoizedState=n,nc=!0),a=a.queue,ds(Uo.bind(null,r,a,e),[e]),a.getSnapshot!==t||s||yo!==null&&yo.memoizedState.tag&1){if(r.flags|=2048,os(9,{destroy:void 0},Ho.bind(null,r,a,n,t),null),Ll===null)throw Error(i(349));o||_o&127||Vo(r,t,n)}return n}function Vo(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=I.updateQueue,t===null?(t=H(),I.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Ho(e,t,n,r){t.value=n,t.getSnapshot=r,Wo(t)&&Go(e)}function Uo(e,t,n){return n(function(){Wo(t)&&Go(e)})}function Wo(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Dr(e,n)}catch{return!0}}function Go(e){var t=ci(e,2);t!==null&&hu(t,e,2)}function Ko(e){var t=Mo();if(typeof e==`function`){var n=e;if(e=n(),So){Ve(!0);try{n()}finally{Ve(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Io,lastRenderedState:e},t}function qo(e,t,n,r){return e.baseState=n,Ro(e,vo,typeof r==`function`?r:Io)}function Jo(e,t,n,r,a){if(Ps(e))throw Error(i(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};D.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,Yo(t,o)):(o.next=n.next,t.pending=n.next=o)}}function Yo(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=D.T,o={};D.T=o;try{var s=n(i,r),c=D.S;c!==null&&c(o,s),Xo(e,t,s)}catch(n){Qo(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),D.T=a}}else try{a=n(i,r),Xo(e,t,a)}catch(n){Qo(e,t,n)}}function Xo(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){Zo(e,t,n)},function(n){return Qo(e,t,n)}):Zo(e,t,n)}function Zo(e,t,n){t.status=`fulfilled`,t.value=n,$o(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Yo(e,n)))}function Qo(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,$o(t),t=t.next;while(t!==r)}e.action=null}function $o(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function es(e,t){return t}function ts(e,t){if(P){var n=Ll.formState;if(n!==null){a:{var r=I;if(P){if(zi){b:{for(var i=zi,a=Vi;i.nodeType!==8;){if(!a){i=null;break b}if(i=uf(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){zi=uf(i.nextSibling),r=i.data===`F!`;break a}}Ui(r)}r=!1}r&&(t=n[0])}}return n=Mo(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:es,lastRenderedState:t},n.queue=r,n=js.bind(null,I,r),r.dispatch=n,r=Ko(!1),a=Ns.bind(null,I,!1,r.queue),r=Mo(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=Jo.bind(null,I,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function ns(e){return rs(V(),vo,e)}function rs(e,t,n){if(t=Ro(e,t,es)[0],e=Lo(Io)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=No(t)}catch(e){throw e===Ea?Oa:e}else r=t;t=V();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(I.flags|=2048,os(9,{destroy:void 0},is.bind(null,i,n),null)),[r,a,e]}function is(e,t){e.action=t}function as(e){var t=V(),n=vo;if(n!==null)return rs(t,n,e);V(),t=t.memoizedState,n=V();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function os(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=I.updateQueue,t===null&&(t=H(),I.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function ss(){return V().memoizedState}function cs(e,t,n,r){var i=Mo();I.flags|=e,i.memoizedState=os(1|t,{destroy:void 0},n,r===void 0?null:r)}function ls(e,t,n,r){var i=V();r=r===void 0?null:r;var a=i.memoizedState.inst;vo!==null&&r!==null&&Eo(r,vo.memoizedState.deps)?i.memoizedState=os(t,a,n,r):(I.flags|=e,i.memoizedState=os(1|t,a,n,r))}function us(e,t){cs(8390656,8,e,t)}function ds(e,t){ls(2048,8,e,t)}function fs(e){I.flags|=4;var t=I.updateQueue;if(t===null)t=H(),I.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function ps(e){var t=V().memoizedState;return fs({ref:t,nextImpl:e}),function(){if(J&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function ms(e,t){return ls(4,2,e,t)}function hs(e,t){return ls(4,4,e,t)}function gs(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function _s(e,t,n){n=n==null?null:n.concat([e]),ls(4,4,gs.bind(null,t,e),n)}function vs(){}function ys(e,t){var n=V();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&Eo(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function bs(e,t){var n=V();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&Eo(t,r[1]))return r[0];if(r=e(),So){Ve(!0);try{e()}finally{Ve(!1)}}return n.memoizedState=[r,t],r}function xs(e,t,n){return n===void 0||_o&1073741824&&!(X&261930)?e.memoizedState=t:(e.memoizedState=n,e=mu(),I.lanes|=e,Gl|=e,n)}function Ss(e,t,n,r){return Dr(n,t)?n:no.current===null?!(_o&42)||_o&1073741824&&!(X&261930)?(nc=!0,e.memoizedState=n):(e=mu(),I.lanes|=e,Gl|=e,t):(e=xs(e,n,r),Dr(e,t)||(nc=!0),e)}function Cs(e,t,n,r,i){var a=O.p;O.p=a!==0&&8>a?a:8;var o=D.T,s={};D.T=s,Ns(e,!1,t,n);try{var c=i(),l=D.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Ms(e,t,ba(c,r),pu(e)):Ms(e,t,r,pu(e))}catch(n){Ms(e,t,{then:function(){},status:`rejected`,reason:n},pu())}finally{O.p=a,o!==null&&s.types!==null&&(o.types=s.types),D.T=o}}function ws(){}function Ts(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=U(e).queue;Cs(e,a,t,se,n===null?ws:function(){return Es(e),n(r)})}function U(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:se,baseState:se,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Io,lastRenderedState:se},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Io,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Es(e){var t=U(e);t.next===null&&(t=e.alternate.memoizedState),Ms(e,t.next.queue,{},pu())}function Ds(){return oa(ep)}function W(){return V().memoizedState}function Os(){return V().memoizedState}function ks(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=pu();e=qa(n);var r=Ja(t,e,n);r!==null&&(hu(r,t,n),Ya(r,t,n)),t={cache:fa()},e.payload=t;return}t=t.return}}function As(e,t,n){var r=pu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Ps(e)?Fs(t,n):(n=si(e,t,n,r),n!==null&&(hu(n,e,r),Is(n,t,r)))}function js(e,t,n){Ms(e,t,n,pu())}function Ms(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ps(e))Fs(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Dr(s,o))return oi(e,t,i,0),Ll===null&&ai(),!1}catch{}if(n=si(e,t,i,r),n!==null)return hu(n,e,r),Is(n,t,r),!0}return!1}function Ns(e,t,n,r){if(r={lane:2,revertLane:fd(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Ps(e)){if(t)throw Error(i(479))}else t=si(e,n,r,2),t!==null&&hu(t,e,2)}function Ps(e){var t=e.alternate;return e===I||t!==null&&t===I}function Fs(e,t){xo=bo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Is(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,it(e,n)}}var Ls={readContext:oa,use:Po,useCallback:To,useContext:To,useEffect:To,useImperativeHandle:To,useLayoutEffect:To,useInsertionEffect:To,useMemo:To,useReducer:To,useRef:To,useState:To,useDebugValue:To,useDeferredValue:To,useTransition:To,useSyncExternalStore:To,useId:To,useHostTransitionStatus:To,useFormState:To,useActionState:To,useOptimistic:To,useMemoCache:To,useCacheRefresh:To};Ls.useEffectEvent=To;var Rs={readContext:oa,use:Po,useCallback:function(e,t){return Mo().memoizedState=[e,t===void 0?null:t],e},useContext:oa,useEffect:us,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),cs(4194308,4,gs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return cs(4194308,4,e,t)},useInsertionEffect:function(e,t){cs(4,2,e,t)},useMemo:function(e,t){var n=Mo();t=t===void 0?null:t;var r=e();if(So){Ve(!0);try{e()}finally{Ve(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=Mo();if(n!==void 0){var i=n(t);if(So){Ve(!0);try{n(t)}finally{Ve(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=As.bind(null,I,e),[r.memoizedState,e]},useRef:function(e){var t=Mo();return e={current:e},t.memoizedState=e},useState:function(e){e=Ko(e);var t=e.queue,n=js.bind(null,I,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:vs,useDeferredValue:function(e,t){return xs(Mo(),e,t)},useTransition:function(){var e=Ko(!1);return e=Cs.bind(null,I,e.queue,!0,!1),Mo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=I,a=Mo();if(P){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Ll===null)throw Error(i(349));X&127||Vo(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,us(Uo.bind(null,r,o,e),[e]),r.flags|=2048,os(9,{destroy:void 0},Ho.bind(null,r,o,n,t),null),n},useId:function(){var e=Mo(),t=Ll.identifierPrefix;if(P){var n=Mi,r=ji;n=(r&~(1<<32-He(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=Co++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=R++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:Ds,useFormState:ts,useActionState:ts,useOptimistic:function(e){var t=Mo();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Ns.bind(null,I,!0,n),n.dispatch=t,[e,t]},useMemoCache:Fo,useCacheRefresh:function(){return Mo().memoizedState=ks.bind(null,I)},useEffectEvent:function(e){var t=Mo(),n={impl:e};return t.memoizedState=n,function(){if(J&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},zs={readContext:oa,use:Po,useCallback:ys,useContext:oa,useEffect:ds,useImperativeHandle:_s,useInsertionEffect:ms,useLayoutEffect:hs,useMemo:bs,useReducer:Lo,useRef:ss,useState:function(){return Lo(Io)},useDebugValue:vs,useDeferredValue:function(e,t){return Ss(V(),vo.memoizedState,e,t)},useTransition:function(){var e=Lo(Io)[0],t=V().memoizedState;return[typeof e==`boolean`?e:No(e),t]},useSyncExternalStore:Bo,useId:W,useHostTransitionStatus:Ds,useFormState:ns,useActionState:ns,useOptimistic:function(e,t){return qo(V(),vo,e,t)},useMemoCache:Fo,useCacheRefresh:Os};zs.useEffectEvent=ps;var Bs={readContext:oa,use:Po,useCallback:ys,useContext:oa,useEffect:ds,useImperativeHandle:_s,useInsertionEffect:ms,useLayoutEffect:hs,useMemo:bs,useReducer:zo,useRef:ss,useState:function(){return zo(Io)},useDebugValue:vs,useDeferredValue:function(e,t){var n=V();return vo===null?xs(n,e,t):Ss(n,vo.memoizedState,e,t)},useTransition:function(){var e=zo(Io)[0],t=V().memoizedState;return[typeof e==`boolean`?e:No(e),t]},useSyncExternalStore:Bo,useId:W,useHostTransitionStatus:Ds,useFormState:as,useActionState:as,useOptimistic:function(e,t){var n=V();return vo===null?(n.baseState=e,[e,n.queue.dispatch]):qo(n,vo,e,t)},useMemoCache:Fo,useCacheRefresh:Os};Bs.useEffectEvent=ps;function Vs(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:p({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Hs={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=pu(),i=qa(r);i.payload=t,n!=null&&(i.callback=n),t=Ja(e,i,r),t!==null&&(hu(t,e,r),Ya(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=pu(),i=qa(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Ja(e,i,r),t!==null&&(hu(t,e,r),Ya(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=pu(),r=qa(n);r.tag=2,t!=null&&(r.callback=t),t=Ja(e,r,n),t!==null&&(hu(t,e,n),Ya(t,e,n))}};function Us(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!Or(n,r)||!Or(i,a):!0}function Ws(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Hs.enqueueReplaceState(t,t.state,null)}function Gs(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=p({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function Ks(e){ti(e)}function qs(e){console.error(e)}function Js(e){ti(e)}function Ys(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Xs(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Zs(e,t,n){return n=qa(n),n.tag=3,n.payload={element:null},n.callback=function(){Ys(e,t)},n}function Qs(e){return e=qa(e),e.tag=3,e}function $s(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){Xs(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Xs(t,n,r),typeof i!=`function`&&(ru===null?ru=new Set([this]):ru.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function ec(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&ra(t,n,a,!0),n=so.current,n!==null){switch(n.tag){case 31:case 13:return co===null?Du():n.alternate===null&&Wl===0&&(Wl=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===ka?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),Ku(e,r,a)),!1;case 22:return n.flags|=65536,r===ka?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),Ku(e,r,a)),!1}throw Error(i(435,n.tag))}return Ku(e,r,a),Du(),!1}if(P)return t=so.current,t===null?(r!==Hi&&(t=Error(i(423),{cause:r}),Yi(Ci(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=Ci(r,n),a=Zs(e.stateNode,r,a),Xa(e,a),Wl!==4&&(Wl=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==Hi&&(e=Error(i(422),{cause:r}),Yi(Ci(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=Ci(o,n),Xl===null?Xl=[o]:Xl.push(o),Wl!==4&&(Wl=2),t===null)return!0;r=Ci(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=Zs(n.stateNode,r,e),Xa(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(ru===null||!ru.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=Qs(a),$s(a,e,n,r),Xa(n,a),!1}n=n.return}while(n!==null);return!1}var tc=Error(i(461)),nc=!1;function rc(e,t,n,r){t.child=e===null?Ua(t,null,n,r):Ha(t,e.child,n,r)}function ic(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return aa(t),r=Do(e,t,n,o,a,i),s=ko(),e!==null&&!nc?(Ao(e,t,i),Oc(e,t,i)):(P&&s&&Fi(t),t.flags|=1,rc(e,t,r,i),t.child)}function ac(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!mi(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,oc(e,t,a,r,i)):(e=_i(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!kc(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?Or:n,n(o,r)&&e.ref===t.ref)return Oc(e,t,i)}return t.flags|=1,e=hi(a,r),e.ref=t.ref,e.return=t,t.child=e}function oc(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Or(a,r)&&e.ref===t.ref)if(nc=!1,t.pendingProps=r=a,kc(e,i))e.flags&131072&&(nc=!0);else return t.lanes=e.lanes,Oc(e,t,i)}return mc(e,t,n,r,i)}function sc(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return lc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&wa(t,a===null?null:a.cachePool),a===null?ao():io(t,a),fo(t);else return r=t.lanes=536870912,lc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&wa(t,null),ao(),po(t)):(wa(t,a.cachePool),io(t,a),po(t),t.memoizedState=null);return rc(e,t,i,n),t.child}function cc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function lc(e,t,n,r,i){var a=Ca();return a=a===null?null:{parent:F._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&wa(t,null),ao(),fo(t),e!==null&&ra(e,t,r,!0),t.childLanes=i,null}function uc(e,t){return t=Cc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function dc(e,t,n){return Ha(t,e.child,null,n),e=uc(t,t.pendingProps),e.flags|=2,mo(t),t.memoizedState=null,e}function fc(e,t,n){var r=t.pendingProps,a=(t.flags&128)!=0;if(t.flags&=-129,e===null){if(P){if(r.mode===`hidden`)return e=uc(t,r),t.lanes=536870912,cc(null,e);if(uo(t),(e=zi)?(e=of(e,Vi),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Ai===null?null:{id:ji,overflow:Mi},retryLane:536870912,hydrationErrors:null},n=bi(e),n.return=t,t.child=n,Ri=t,zi=null)):e=null,e===null)throw Ui(t);return t.lanes=536870912,null}return uc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(uo(t),a)if(t.flags&256)t.flags&=-257,t=dc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558));else if(nc||ra(e,t,n,!1),a=(n&e.childLanes)!==0,nc||a){if(r=Ll,r!==null&&(s=at(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,ci(e,s),hu(r,e,s),tc;Du(),t=dc(e,t,n)}else e=o.treeContext,zi=uf(s.nextSibling),Ri=t,P=!0,Bi=null,Vi=!1,e!==null&&Li(t,e),t=uc(t,r),t.flags|=4096;return t}return e=hi(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function pc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(i(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function mc(e,t,n,r,i){return aa(t),n=Do(e,t,n,r,void 0,i),r=ko(),e!==null&&!nc?(Ao(e,t,i),Oc(e,t,i)):(P&&r&&Fi(t),t.flags|=1,rc(e,t,n,i),t.child)}function hc(e,t,n,r,i,a){return aa(t),t.updateQueue=null,n=B(t,r,n,i),z(e),r=ko(),e!==null&&!nc?(Ao(e,t,a),Oc(e,t,a)):(P&&r&&Fi(t),t.flags|=1,rc(e,t,n,a),t.child)}function gc(e,t,n,r,i){if(aa(t),t.stateNode===null){var a=di,o=n.contextType;typeof o==`object`&&o&&(a=oa(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Hs,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},Ga(t),o=n.contextType,a.context=typeof o==`object`&&o?oa(o):di,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Vs(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&Hs.enqueueReplaceState(a,a.state,null),$a(t,r,a,i),Qa(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=Gs(n,s);a.props=c;var l=a.context,u=n.contextType;o=di,typeof u==`object`&&u&&(o=oa(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&Ws(t,a,r,o),Wa=!1;var f=t.memoizedState;a.state=f,$a(t,r,a,i),Qa(),l=t.memoizedState,s||f!==l||Wa?(typeof d==`function`&&(Vs(t,n,d,r),l=t.memoizedState),(c=Wa||Us(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,Ka(e,t),o=t.memoizedProps,u=Gs(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=di,typeof l==`object`&&l&&(c=oa(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&Ws(t,a,r,c),Wa=!1,f=t.memoizedState,a.state=f,$a(t,r,a,i),Qa();var p=t.memoizedState;o!==d||f!==p||Wa||e!==null&&e.dependencies!==null&&ia(e.dependencies)?(typeof s==`function`&&(Vs(t,n,s,r),p=t.memoizedState),(u=Wa||Us(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&ia(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,pc(e,t),r=(t.flags&128)!=0,a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=Ha(t,e.child,null,i),t.child=Ha(t,null,n,i)):rc(e,t,n,i),t.memoizedState=a.state,e=t.child):e=Oc(e,t,i),e}function _c(e,t,n,r){return qi(),t.flags|=256,rc(e,t,n,r),t.child}var vc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function yc(e){return{baseLanes:e,cachePool:Ta()}}function bc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=Jl),e}function xc(e,t,n){var r=t.pendingProps,a=!1,o=(t.flags&128)!=0,s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:(ho.current&2)!=0),s&&(a=!0,t.flags&=-129),s=(t.flags&32)!=0,t.flags&=-33,e===null){if(P){if(a?lo(t):po(t),(e=zi)?(e=of(e,Vi),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Ai===null?null:{id:ji,overflow:Mi},retryLane:536870912,hydrationErrors:null},n=bi(e),n.return=t,t.child=n,Ri=t,zi=null)):e=null,e===null)throw Ui(t);return cf(e)?t.lanes=32:t.lanes=536870912,null}var c=r.children;return r=r.fallback,a?(po(t),a=t.mode,c=Cc({mode:`hidden`,children:c},a),r=vi(r,a,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,r=t.child,r.memoizedState=yc(n),r.childLanes=bc(e,s,n),t.memoizedState=vc,cc(null,r)):(lo(t),Sc(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(o)t.flags&256?(lo(t),t.flags&=-257,t=wc(e,t,n)):t.memoizedState===null?(po(t),c=r.fallback,a=t.mode,r=Cc({mode:`visible`,children:r.children},a),c=vi(c,a,n,null),c.flags|=2,r.return=t,c.return=t,r.sibling=c,t.child=r,Ha(t,e.child,null,n),r=t.child,r.memoizedState=yc(n),r.childLanes=bc(e,s,n),t.memoizedState=vc,t=cc(null,r)):(po(t),t.child=e.child,t.flags|=128,t=null);else if(lo(t),cf(c)){if(s=c.nextSibling&&c.nextSibling.dataset,s)var u=s.dgst;s=u,r=Error(i(419)),r.stack=``,r.digest=s,Yi({value:r,source:null,stack:null}),t=wc(e,t,n)}else if(nc||ra(e,t,n,!1),s=(n&e.childLanes)!==0,nc||s){if(s=Ll,s!==null&&(r=at(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,ci(e,r),hu(s,e,r),tc;sf(c)||Du(),t=wc(e,t,n)}else sf(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,zi=uf(c.nextSibling),Ri=t,P=!0,Bi=null,Vi=!1,e!==null&&Li(t,e),t=Sc(t,r.children),t.flags|=4096);return t}return a?(po(t),c=r.fallback,a=t.mode,l=e.child,u=l.sibling,r=hi(l,{mode:`hidden`,children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u===null?(c=vi(c,a,n,null),c.flags|=2):c=hi(u,c),c.return=t,r.return=t,r.sibling=c,t.child=r,cc(null,r),r=t.child,c=e.child.memoizedState,c===null?c=yc(n):(a=c.cachePool,a===null?a=Ta():(l=F._currentValue,a=a.parent===l?a:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:a}),r.memoizedState=c,r.childLanes=bc(e,s,n),t.memoizedState=vc,cc(e.child,r)):(lo(t),n=e.child,e=n.sibling,n=hi(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function Sc(e,t){return t=Cc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function Cc(e,t){return e=pi(22,e,null,t),e.lanes=0,e}function wc(e,t,n){return Ha(t,e.child,null,n),e=Sc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Tc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),ta(e.return,t,n)}function Ec(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function Dc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=ho.current,s=(o&2)!=0;if(s?(o=o&1|2,t.flags|=128):o&=1,A(ho,o),rc(e,t,r,n),r=P?Di:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Tc(e,n,t);else if(e.tag===19)Tc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&go(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),Ec(t,!1,i,n,a,r);break;case`backwards`:case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&go(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}Ec(t,!0,n,null,a,r);break;case`together`:Ec(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function Oc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Gl|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(ra(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,n=hi(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=hi(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function kc(e,t){return(e.lanes&t)===0?(e=e.dependencies,!!(e!==null&&ia(e))):!0}function Ac(e,t,n){switch(t.tag){case 3:he(t,t.stateNode.containerInfo),$i(t,F,e.memoizedState.cache),qi();break;case 27:case 5:_e(t);break;case 4:he(t,t.stateNode.containerInfo);break;case 10:$i(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,uo(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(lo(t),e=Oc(e,t,n),e===null?null:e.sibling):xc(e,t,n):(lo(t),t.flags|=128,null);lo(t);break;case 19:var i=(e.flags&128)!=0;if(r=(n&t.childLanes)!==0,r||=(ra(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return Dc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),A(ho,ho.current),r)break;return null;case 22:return t.lanes=0,sc(e,t,n,t.pendingProps);case 24:$i(t,F,e.memoizedState.cache)}return Oc(e,t,n)}function jc(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)nc=!0;else{if(!kc(e,n)&&!(t.flags&128))return nc=!1,Ac(e,t,n);nc=!!(e.flags&131072)}else nc=!1,P&&t.flags&1048576&&Pi(t,Di,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=Ma(t.elementType),t.type=e,typeof e==`function`)mi(e)?(r=Gs(e,r),t.tag=1,t=gc(null,t,e,r,n)):(t.tag=0,t=mc(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===ee){t.tag=11,t=ic(null,t,e,r,n);break a}else if(a===w){t.tag=14,t=ac(null,t,e,r,n);break a}}throw t=ae(e)||e,Error(i(306,t,``))}}return t;case 0:return mc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=Gs(r,t.pendingProps),gc(e,t,r,a,n);case 3:a:{if(he(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,Ka(e,t),$a(t,r,null,n);var s=t.memoizedState;if(r=s.cache,$i(t,F,r),r!==o.cache&&na(t,[F],n,!0),Qa(),r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=_c(e,t,r,n);break a}else if(r!==a){a=Ci(Error(i(424)),t),Yi(a),t=_c(e,t,r,n);break a}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(zi=uf(e.firstChild),Ri=t,P=!0,Bi=null,Vi=!0,n=Ua(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(qi(),r===a){t=Oc(e,t,n);break a}rc(e,t,r,n)}t=t.child}return t;case 26:return pc(e,t),e===null?(n=jf(t.type,null,t.pendingProps,null))?t.memoizedState=n:P||(n=t.type,e=t.pendingProps,r=Hd(pe.current).createElement(n),r[dt]=t,r[ft]=e,Id(r,n,e),wt(r),t.stateNode=r):t.memoizedState=jf(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return _e(t),e===null&&P&&(r=t.stateNode=mf(t.type,t.pendingProps,pe.current),Ri=t,Vi=!0,a=zi,$d(t.type)?(df=a,zi=uf(r.firstChild)):zi=a),rc(e,t,t.pendingProps.children,n),pc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&P&&((a=r=zi)&&(r=rf(r,t.type,t.pendingProps,Vi),r===null?a=!1:(t.stateNode=r,Ri=t,zi=uf(r.firstChild),Vi=!1,a=!0)),a||Ui(t)),_e(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,Gd(a,o)?r=null:s!==null&&Gd(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=Do(e,t,Oo,null,null,n),ep._currentValue=a),pc(e,t),rc(e,t,r,n),t.child;case 6:return e===null&&P&&((e=n=zi)&&(n=af(n,t.pendingProps,Vi),n===null?e=!1:(t.stateNode=n,Ri=t,zi=null,e=!0)),e||Ui(t)),null;case 13:return xc(e,t,n);case 4:return he(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Ha(t,null,r,n):rc(e,t,r,n),t.child;case 11:return ic(e,t,t.type,t.pendingProps,n);case 7:return rc(e,t,t.pendingProps,n),t.child;case 8:return rc(e,t,t.pendingProps.children,n),t.child;case 12:return rc(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,$i(t,t.type,r.value),rc(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,aa(t),a=oa(a),r=r(a),t.flags|=1,rc(e,t,r,n),t.child;case 14:return ac(e,t,t.type,t.pendingProps,n);case 15:return oc(e,t,t.type,t.pendingProps,n);case 19:return Dc(e,t,n);case 31:return fc(e,t,n);case 22:return sc(e,t,n,t.pendingProps);case 24:return aa(t),r=oa(F),e===null?(a=Ca(),a===null&&(a=Ll,o=fa(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},Ga(t),$i(t,F,a)):((e.lanes&n)!==0&&(Ka(e,t),$a(t,null,null,n),Qa()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,$i(t,F,r),r!==a.cache&&na(t,[F],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),$i(t,F,r))),rc(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function Mc(e){e.flags|=4}function Nc(e,t,n,r,i){if((t=(e.mode&32)!=0)&&(t=!1),t){if(e.flags|=16777216,(i&335544128)===i)if(e.stateNode.complete)e.flags|=8192;else if(wu())e.flags|=8192;else throw Na=ka,Da}else e.flags&=-16777217}function Pc(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!Kf(t))if(wu())e.flags|=8192;else throw Na=ka,Da}function Fc(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:$e(),e.lanes|=t,Yl|=t)}function Ic(e,t){if(!P)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Lc(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Rc(e,t,n){var r=t.pendingProps;switch(Ii(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Lc(t),null;case 1:return Lc(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),ea(F),ge(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(Ki(t)?Mc(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Ji())),Lc(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(Mc(t),o===null?(Lc(t),Nc(t,a,null,r,n)):(Lc(t),Pc(t,o))):o?o===e.memoizedState?(Lc(t),t.flags&=-16777217):(Mc(t),Lc(t),Pc(t,o)):(e=e.memoizedProps,e!==r&&Mc(t),Lc(t),Nc(t,a,e,r,n)),null;case 27:if(ve(t),n=pe.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Mc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Lc(t),null}e=de.current,Ki(t)?Wi(t,e):(e=mf(a,r,n),t.stateNode=e,Mc(t))}return Lc(t),null;case 5:if(ve(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Mc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Lc(t),null}if(o=de.current,Ki(t))Wi(t,o);else{var s=Hd(pe.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;default:switch(a){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[dt]=t,o[ft]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(Id(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&Mc(t)}}return Lc(t),Nc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Mc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=pe.current,Ki(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=Ri,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[dt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||Nd(e.nodeValue,n)),e||Ui(t,!0)}else e=Hd(e).createTextNode(r),e[dt]=t,t.stateNode=e}return Lc(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Ki(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[dt]=t}else qi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Lc(t),e=!1}else n=Ji(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(mo(t),t):(mo(t),null);if(t.flags&128)throw Error(i(558))}return Lc(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=Ki(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[dt]=t}else qi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Lc(t),a=!1}else a=Ji(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(mo(t),t):(mo(t),null)}return mo(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Fc(t,t.updateQueue),Lc(t),null);case 4:return ge(),e===null&&Cd(t.stateNode.containerInfo),Lc(t),null;case 10:return ea(t.type),Lc(t),null;case 19:if(ue(ho),r=t.memoizedState,r===null)return Lc(t),null;if(a=(t.flags&128)!=0,o=r.rendering,o===null)if(a)Ic(r,!1);else{if(Wl!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=go(e),o!==null){for(t.flags|=128,Ic(r,!1),e=o.updateQueue,t.updateQueue=e,Fc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)gi(n,e),n=n.sibling;return A(ho,ho.current&1|2),P&&Ni(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&je()>tu&&(t.flags|=128,a=!0,Ic(r,!1),t.lanes=4194304)}else{if(!a)if(e=go(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Fc(t,e),Ic(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!P)return Lc(t),null}else 2*je()-r.renderingStartTime>tu&&n!==536870912&&(t.flags|=128,a=!0,Ic(r,!1),t.lanes=4194304);r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}return r.tail===null?(Lc(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=je(),e.sibling=null,n=ho.current,A(ho,a?n&1|2:n&1),P&&Ni(t,r.treeForkCount),e);case 22:case 23:return mo(t),oo(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Lc(t),t.subtreeFlags&6&&(t.flags|=8192)):Lc(t),n=t.updateQueue,n!==null&&Fc(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&ue(Sa),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),ea(F),Lc(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function zc(e,t){switch(Ii(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ea(F),ge(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ve(t),null;case 31:if(t.memoizedState!==null){if(mo(t),t.alternate===null)throw Error(i(340));qi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(mo(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));qi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ue(ho),null;case 4:return ge(),null;case 10:return ea(t.type),null;case 22:case 23:return mo(t),oo(),e!==null&&ue(Sa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return ea(F),null;case 25:return null;default:return null}}function Bc(e,t){switch(Ii(t),t.tag){case 3:ea(F),ge();break;case 26:case 27:case 5:ve(t);break;case 4:ge();break;case 31:t.memoizedState!==null&&mo(t);break;case 13:mo(t);break;case 19:ue(ho);break;case 10:ea(t.type);break;case 22:case 23:mo(t),oo(),e!==null&&ue(Sa);break;case 24:ea(F)}}function Vc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Gu(t,t.return,e)}}function Hc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Gu(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Gu(t,t.return,e)}}function Uc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{to(t,n)}catch(t){Gu(e,e.return,t)}}}function Wc(e,t,n){n.props=Gs(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Gu(e,t,n)}}function Gc(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Gu(e,t,n)}}function Kc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){Gu(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Gu(e,t,n)}else n.current=null}function qc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Gu(e,e.return,t)}}function Jc(e,t,n){try{var r=e.stateNode;Ld(r,e.type,n,t),r[ft]=t}catch(t){Gu(e,e.return,t)}}function Yc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&$d(e.type)||e.tag===4}function Xc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Yc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&$d(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Zc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=on));else if(r!==4&&(r===27&&$d(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Zc(e,t,n),e=e.sibling;e!==null;)Zc(e,t,n),e=e.sibling}function Qc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&$d(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Qc(e,t,n),e=e.sibling;e!==null;)Qc(e,t,n),e=e.sibling}function $c(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Id(t,r,n),t[dt]=e,t[ft]=n}catch(t){Gu(e,e.return,t)}}var el=!1,tl=!1,nl=!1,rl=typeof WeakSet==`function`?WeakSet:Set,il=null;function al(e,t){if(e=e.containerInfo,Bd=lp,e=Mr(e),Nr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(Vd={focusedElem:e,selectionRange:n},lp=!1,il=t;il!==null;)if(t=il,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,il=e;else for(;il!==null;){switch(t=il,o=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n<e.length;n++)a=e[n],a.ref.impl=a.nextImpl;break;case 11:case 15:break;case 1:if(e&1024&&o!==null){e=void 0,n=t,a=o.memoizedProps,o=o.memoizedState,r=n.stateNode;try{var h=Gs(n.type,a);e=r.getSnapshotBeforeUpdate(h,o),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){Gu(n,n.return,e)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)nf(e);else if(n===1)switch(e.nodeName){case`HEAD`:case`HTML`:case`BODY`:nf(e);break;default:e.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(e&1024)throw Error(i(163))}if(e=t.sibling,e!==null){e.return=t.return,il=e;break}il=t.return}}function ol(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:bl(e,n),r&4&&Vc(5,n);break;case 1:if(bl(e,n),r&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){Gu(n,n.return,e)}else{var i=Gs(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Gu(n,n.return,e)}}r&64&&Uc(n),r&512&&Gc(n,n.return);break;case 3:if(bl(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{to(e,t)}catch(e){Gu(n,n.return,e)}}break;case 27:t===null&&r&4&&$c(n);case 26:case 5:bl(e,n),t===null&&r&4&&qc(n),r&512&&Gc(n,n.return);break;case 12:bl(e,n);break;case 31:bl(e,n),r&4&&fl(e,n);break;case 13:bl(e,n),r&4&&pl(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=Yu.bind(null,n),lf(e,n))));break;case 22:if(r=n.memoizedState!==null||el,!r){t=t!==null&&t.memoizedState!==null||tl,i=el;var a=tl;el=r,(tl=t)&&!a?K(e,n,(n.subtreeFlags&8772)!=0):bl(e,n),el=i,tl=a}break;case 30:break;default:bl(e,n)}}function sl(e){var t=e.alternate;t!==null&&(e.alternate=null,sl(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&yt(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var cl=null,ll=!1;function ul(e,t,n){for(n=n.child;n!==null;)dl(e,t,n),n=n.sibling}function dl(e,t,n){if(j&&typeof j.onCommitFiberUnmount==`function`)try{j.onCommitFiberUnmount(Be,n)}catch{}switch(n.tag){case 26:tl||Kc(n,t),ul(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:tl||Kc(n,t);var r=cl,i=ll;$d(n.type)&&(cl=n.stateNode,ll=!1),ul(e,t,n),hf(n.stateNode),cl=r,ll=i;break;case 5:tl||Kc(n,t);case 6:if(r=cl,i=ll,cl=null,ul(e,t,n),cl=r,ll=i,cl!==null)if(ll)try{(cl.nodeType===9?cl.body:cl.nodeName===`HTML`?cl.ownerDocument.body:cl).removeChild(n.stateNode)}catch(e){Gu(n,t,e)}else try{cl.removeChild(n.stateNode)}catch(e){Gu(n,t,e)}break;case 18:cl!==null&&(ll?(e=cl,ef(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Fp(e)):ef(cl,n.stateNode));break;case 4:r=cl,i=ll,cl=n.stateNode.containerInfo,ll=!0,ul(e,t,n),cl=r,ll=i;break;case 0:case 11:case 14:case 15:Hc(2,n,t),tl||Hc(4,n,t),ul(e,t,n);break;case 1:tl||(Kc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Wc(n,t,r)),ul(e,t,n);break;case 21:ul(e,t,n);break;case 22:tl=(r=tl)||n.memoizedState!==null,ul(e,t,n),tl=r;break;default:ul(e,t,n)}}function fl(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Fp(e)}catch(e){Gu(t,t.return,e)}}}function pl(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Fp(e)}catch(e){Gu(t,t.return,e)}}function ml(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new rl),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new rl),t;default:throw Error(i(435,e.tag))}}function G(e,t){var n=ml(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=Xu.bind(null,e,t);t.then(r,r)}})}function hl(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var a=n[r],o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 27:if($d(c.type)){cl=c.stateNode,ll=!1;break a}break;case 5:cl=c.stateNode,ll=!1;break a;case 3:case 4:cl=c.stateNode.containerInfo,ll=!0;break a}c=c.return}if(cl===null)throw Error(i(160));dl(o,s,a),cl=null,ll=!1,o=a.alternate,o!==null&&(o.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)_l(t,e),t=t.sibling}var gl=null;function _l(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:hl(t,e),vl(e),r&4&&(Hc(3,e,e.return),Vc(3,e),Hc(5,e,e.return));break;case 1:hl(t,e),vl(e),r&512&&(tl||n===null||Kc(n,n.return)),r&64&&el&&(e=e.updateQueue,e!==null&&(r=e.callbacks,r!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?r:n.concat(r))));break;case 26:var a=gl;if(hl(t,e),vl(e),r&512&&(tl||n===null||Kc(n,n.return)),r&4){var o=n===null?null:n.memoizedState;if(r=e.memoizedState,n===null)if(r===null)if(e.stateNode===null){a:{r=e.type,n=e.memoizedProps,a=a.ownerDocument||a;b:switch(r){case`title`:o=a.getElementsByTagName(`title`)[0],(!o||o[vt]||o[dt]||o.namespaceURI===`http://www.w3.org/2000/svg`||o.hasAttribute(`itemprop`))&&(o=a.createElement(r),a.head.insertBefore(o,a.querySelector(`head > title`))),Id(o,r,n),o[dt]=e,wt(o),r=o;break a;case`link`:var s=Uf(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&o.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&o.getAttribute(`title`)===(n.title==null?null:n.title)&&o.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(c,1);break b}}o=a.createElement(r),Id(o,r,n),a.head.appendChild(o);break;case`meta`:if(s=Uf(`meta`,`content`,a).get(r+(n.content||``))){for(c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`content`)===(n.content==null?null:``+n.content)&&o.getAttribute(`name`)===(n.name==null?null:n.name)&&o.getAttribute(`property`)===(n.property==null?null:n.property)&&o.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&o.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){s.splice(c,1);break b}}o=a.createElement(r),Id(o,r,n),a.head.appendChild(o);break;default:throw Error(i(468,r))}o[dt]=e,wt(o),r=o}e.stateNode=r}else Wf(a,e.type,e.stateNode);else e.stateNode=Rf(a,r,e.memoizedProps);else o===r?r===null&&e.stateNode!==null&&Jc(e,e.memoizedProps,n.memoizedProps):(o===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):o.count--,r===null?Wf(a,e.type,e.stateNode):Rf(a,r,e.memoizedProps))}break;case 27:hl(t,e),vl(e),r&512&&(tl||n===null||Kc(n,n.return)),n!==null&&r&4&&Jc(e,e.memoizedProps,n.memoizedProps);break;case 5:if(hl(t,e),vl(e),r&512&&(tl||n===null||Kc(n,n.return)),e.flags&32){a=e.stateNode;try{Xt(a,``)}catch(t){Gu(e,e.return,t)}}r&4&&e.stateNode!=null&&(a=e.memoizedProps,Jc(e,a,n===null?a:n.memoizedProps)),r&1024&&(nl=!0);break;case 6:if(hl(t,e),vl(e),r&4){if(e.stateNode===null)throw Error(i(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){Gu(e,e.return,t)}}break;case 3:if(Hf=null,a=gl,gl=vf(t.containerInfo),hl(t,e),gl=a,vl(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Fp(t.containerInfo)}catch(t){Gu(e,e.return,t)}nl&&(nl=!1,yl(e));break;case 4:r=gl,gl=vf(e.stateNode.containerInfo),hl(t,e),vl(e),gl=r;break;case 12:hl(t,e),vl(e);break;case 31:hl(t,e),vl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,G(e,r)));break;case 13:hl(t,e),vl(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&($l=je()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,G(e,r)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=el,d=tl;if(el=u||a,tl=d||l,hl(t,e),tl=d,el=u,vl(e),r&8192)a:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||el||tl||xl(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(o=l.stateNode,a)s=o.style,typeof s.setProperty==`function`?s.setProperty(`display`,`none`,`important`):s.display=`none`;else{c=l.stateNode;var f=l.memoizedProps.style,p=f!=null&&f.hasOwnProperty(`display`)?f.display:null;c.style.display=p==null||typeof p==`boolean`?``:(``+p).trim()}}catch(e){Gu(l,l.return,e)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=a?``:l.memoizedProps}catch(e){Gu(l,l.return,e)}}}else if(t.tag===18){if(n===null){l=t;try{var m=l.stateNode;a?tf(m,!0):tf(l.stateNode,!1)}catch(e){Gu(l,l.return,e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break a;for(;t.sibling===null;){if(t.return===null||t.return===e)break a;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=e.updateQueue,r!==null&&(n=r.retryQueue,n!==null&&(r.retryQueue=null,G(e,n))));break;case 19:hl(t,e),vl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,G(e,r)));break;case 30:break;case 21:break;default:hl(t,e),vl(e)}}function vl(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Yc(r)){n=r;break}r=r.return}if(n==null)throw Error(i(160));switch(n.tag){case 27:var a=n.stateNode;Qc(e,Xc(e),a);break;case 5:var o=n.stateNode;n.flags&32&&(Xt(o,``),n.flags&=-33),Qc(e,Xc(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;Zc(e,Xc(e),s);break;default:throw Error(i(161))}}catch(t){Gu(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function yl(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;yl(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function bl(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)ol(e,t.alternate,t),t=t.sibling}function xl(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Hc(4,t,t.return),xl(t);break;case 1:Kc(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&Wc(t,t.return,n),xl(t);break;case 27:hf(t.stateNode);case 26:case 5:Kc(t,t.return),xl(t);break;case 22:t.memoizedState===null&&xl(t);break;case 30:xl(t);break;default:xl(t)}e=e.sibling}}function K(e,t,n){for(n&&=(t.subtreeFlags&8772)!=0,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags;switch(a.tag){case 0:case 11:case 15:K(i,a,n),Vc(4,a);break;case 1:if(K(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){Gu(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var s=r.stateNode;try{var c=i.shared.hiddenCallbacks;if(c!==null)for(i.shared.hiddenCallbacks=null,i=0;i<c.length;i++)eo(c[i],s)}catch(e){Gu(r,r.return,e)}}n&&o&64&&Uc(a),Gc(a,a.return);break;case 27:$c(a);case 26:case 5:K(i,a,n),n&&r===null&&o&4&&qc(a),Gc(a,a.return);break;case 12:K(i,a,n);break;case 31:K(i,a,n),n&&o&4&&fl(i,a);break;case 13:K(i,a,n),n&&o&4&&pl(i,a);break;case 22:a.memoizedState===null&&K(i,a,n),Gc(a,a.return);break;case 30:break;default:K(i,a,n)}t=t.sibling}}function q(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&pa(n))}function Sl(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&pa(e))}function Cl(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)wl(e,t,n,r),t=t.sibling}function wl(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:Cl(e,t,n,r),i&2048&&Vc(9,t);break;case 1:Cl(e,t,n,r);break;case 3:Cl(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&pa(e)));break;case 12:if(i&2048){Cl(e,t,n,r),e=t.stateNode;try{var a=t.memoizedProps,o=a.id,s=a.onPostCommit;typeof s==`function`&&s(o,t.alternate===null?`mount`:`update`,e.passiveEffectDuration,-0)}catch(e){Gu(t,t.return,e)}}else Cl(e,t,n,r);break;case 31:Cl(e,t,n,r);break;case 13:Cl(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?Cl(e,t,n,r):(a._visibility|=2,Tl(e,t,n,r,(t.subtreeFlags&10256)!=0||!1)):a._visibility&2?Cl(e,t,n,r):El(e,t),i&2048&&q(o,t);break;case 24:Cl(e,t,n,r),i&2048&&Sl(t.alternate,t);break;default:Cl(e,t,n,r)}}function Tl(e,t,n,r,i){for(i&&=(t.subtreeFlags&10256)!=0||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:Tl(a,o,s,c,i),Vc(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,Tl(a,o,s,c,i)):u._visibility&2?Tl(a,o,s,c,i):El(a,o),i&&l&2048&&q(o.alternate,o);break;case 24:Tl(a,o,s,c,i),i&&l&2048&&Sl(o.alternate,o);break;default:Tl(a,o,s,c,i)}t=t.sibling}}function El(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:El(n,r),i&2048&&q(r.alternate,r);break;case 24:El(n,r),i&2048&&Sl(r.alternate,r);break;default:El(n,r)}t=t.sibling}}var Dl=8192;function Ol(e,t,n){if(e.subtreeFlags&Dl)for(e=e.child;e!==null;)kl(e,t,n),e=e.sibling}function kl(e,t,n){switch(e.tag){case 26:Ol(e,t,n),e.flags&Dl&&e.memoizedState!==null&&qf(n,gl,e.memoizedState,e.memoizedProps);break;case 5:Ol(e,t,n);break;case 3:case 4:var r=gl;gl=vf(e.stateNode.containerInfo),Ol(e,t,n),gl=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Dl,Dl=16777216,Ol(e,t,n),Dl=r):Ol(e,t,n));break;default:Ol(e,t,n)}}function Al(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function jl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];il=r,Pl(r,e)}Al(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Ml(e),e=e.sibling}function Ml(e){switch(e.tag){case 0:case 11:case 15:jl(e),e.flags&2048&&Hc(9,e,e.return);break;case 3:jl(e);break;case 12:jl(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Nl(e)):jl(e);break;default:jl(e)}}function Nl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];il=r,Pl(r,e)}Al(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Hc(8,t,t.return),Nl(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Nl(t));break;default:Nl(t)}e=e.sibling}}function Pl(e,t){for(;il!==null;){var n=il;switch(n.tag){case 0:case 11:case 15:Hc(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:pa(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,il=r;else a:for(n=e;il!==null;){r=il;var i=r.sibling,a=r.return;if(sl(r),r===n){il=null;break a}if(i!==null){i.return=a,il=i;break a}il=a}}}var Fl={getCacheForType:function(e){var t=oa(F),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return oa(F).controller.signal}},Il=typeof WeakMap==`function`?WeakMap:Map,J=0,Ll=null,Y=null,X=0,Rl=0,zl=null,Bl=!1,Vl=!1,Hl=!1,Ul=0,Wl=0,Gl=0,Kl=0,ql=0,Jl=0,Yl=0,Xl=null,Zl=null,Ql=!1,$l=0,eu=0,tu=1/0,nu=null,ru=null,iu=0,au=null,ou=null,su=0,cu=0,lu=null,uu=null,du=0,fu=null;function pu(){return J&2&&X!==0?X&-X:D.T===null?ct():fd()}function mu(){if(Jl===0)if(!(X&536870912)||P){var e=qe;qe<<=1,!(qe&3932160)&&(qe=262144),Jl=e}else Jl=536870912;return e=so.current,e!==null&&(e.flags|=32),Jl}function hu(e,t,n){(e===Ll&&(Rl===2||Rl===9)||e.cancelPendingCommit!==null)&&(Su(e,0),yu(e,X,Jl,!1)),tt(e,n),(!(J&2)||e!==Ll)&&(e===Ll&&(!(J&2)&&(Kl|=n),Wl===4&&yu(e,X,Jl,!1)),id(e))}function gu(e,t,n){if(J&6)throw Error(i(327));var r=!n&&(t&127)==0&&(t&e.expiredLanes)===0||Qe(e,t),a=r?Au(e,t):Ou(e,t,!0),o=r;do{if(a===0){Vl&&!r&&yu(e,t,0,!1);break}else{if(n=e.current.alternate,o&&!vu(n)){a=Ou(e,t,!1),o=!1;continue}if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=Xl;var l=c.current.memoizedState.isDehydrated;if(l&&(Su(c,s).flags|=256),s=Ou(c,s,!1),s!==2){if(Hl&&!l){c.errorRecoveryDisabledLanes|=o,Kl|=o,a=4;break a}o=Zl,Zl=a,o!==null&&(Zl===null?Zl=o:Zl.push.apply(Zl,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){Su(e,0),yu(e,t,0,!0);break}a:{switch(r=e,o=a,o){case 0:case 1:throw Error(i(345));case 4:if((t&4194048)!==t)break;case 6:yu(r,t,Jl,!Bl);break a;case 2:Zl=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=$l+300-je(),10<a)){if(yu(r,t,Jl,!Bl),Xe(r,0,!0)!==0)break a;su=t,r.timeoutHandle=Jd(_u.bind(null,r,n,Zl,nu,Ql,t,Jl,Kl,Yl,Bl,o,`Throttled`,-0,0),a);break a}_u(r,n,Zl,nu,Ql,t,Jl,Kl,Yl,Bl,o,null,-0,0)}}break}while(1);id(e)}function _u(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)==16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:on},kl(t,a,d);var m=(a&62914560)===a?$l-je():(a&4194048)===a?eu-je():0;if(m=Yf(d,m),m!==null){su=a,e.cancelPendingCommit=m(Lu.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),yu(e,a,o,!l);return}}Lu(e,t,a,n,r,i,o,s,c)}function vu(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!Dr(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function yu(e,t,n,r){t&=~ql,t&=~Kl,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-He(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&rt(e,n,t)}function bu(){return J&6?!0:(ad(0,!1),!1)}function xu(){if(Y!==null){if(Rl===0)var e=Y.return;else e=Y,Qi=Zi=null,jo(e),Ia=null,La=0,e=Y;for(;e!==null;)Bc(e.alternate,e),e=e.return;Y=null}}function Su(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,Yd(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),su=0,xu(),Ll=e,Y=n=hi(e.current,null),X=t,Rl=0,zl=null,Bl=!1,Vl=Qe(e,t),Hl=!1,Yl=Jl=ql=Kl=Gl=Wl=0,Zl=Xl=null,Ql=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-He(r),a=1<<i;t|=e[i],r&=~a}return Ul=t,ai(),n}function Cu(e,t){I=null,D.H=Ls,t===Ea||t===Oa?(t=Pa(),Rl=3):t===Da?(t=Pa(),Rl=4):Rl=t===tc?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,zl=t,Y===null&&(Wl=1,Ys(e,Ci(t,e.current)))}function wu(){var e=so.current;return e===null?!0:(X&4194048)===X?co===null:(X&62914560)===X||X&536870912?e===co:!1}function Tu(){var e=D.H;return D.H=Ls,e===null?Ls:e}function Eu(){var e=D.A;return D.A=Fl,e}function Du(){Wl=4,Bl||(X&4194048)!==X&&so.current!==null||(Vl=!0),!(Gl&134217727)&&!(Kl&134217727)||Ll===null||yu(Ll,X,Jl,!1)}function Ou(e,t,n){var r=J;J|=2;var i=Tu(),a=Eu();(Ll!==e||X!==t)&&(nu=null,Su(e,t)),t=!1;var o=Wl;a:do try{if(Rl!==0&&Y!==null){var s=Y,c=zl;switch(Rl){case 8:xu(),o=6;break a;case 3:case 2:case 9:case 6:so.current===null&&(t=!0);var l=Rl;if(Rl=0,zl=null,Pu(e,s,c,l),n&&Vl){o=0;break a}break;default:l=Rl,Rl=0,zl=null,Pu(e,s,c,l)}}ku(),o=Wl;break}catch(t){Cu(e,t)}while(1);return t&&e.shellSuspendCounter++,Qi=Zi=null,J=r,D.H=i,D.A=a,Y===null&&(Ll=null,X=0,ai()),o}function ku(){for(;Y!==null;)Mu(Y)}function Au(e,t){var n=J;J|=2;var r=Tu(),a=Eu();Ll!==e||X!==t?(nu=null,tu=je()+500,Su(e,t)):Vl=Qe(e,t);a:do try{if(Rl!==0&&Y!==null){t=Y;var o=zl;b:switch(Rl){case 1:Rl=0,zl=null,Pu(e,t,o,1);break;case 2:case 9:if(Aa(o)){Rl=0,zl=null,Nu(t);break}t=function(){Rl!==2&&Rl!==9||Ll!==e||(Rl=7),id(e)},o.then(t,t);break a;case 3:Rl=7;break a;case 4:Rl=5;break a;case 7:Aa(o)?(Rl=0,zl=null,Nu(t)):(Rl=0,zl=null,Pu(e,t,o,7));break;case 5:var s=null;switch(Y.tag){case 26:s=Y.memoizedState;case 5:case 27:var c=Y;if(s?Kf(s):c.stateNode.complete){Rl=0,zl=null;var l=c.sibling;if(l!==null)Y=l;else{var u=c.return;u===null?Y=null:(Y=u,Fu(u))}break b}}Rl=0,zl=null,Pu(e,t,o,5);break;case 6:Rl=0,zl=null,Pu(e,t,o,6);break;case 8:xu(),Wl=6;break a;default:throw Error(i(462))}}ju();break}catch(t){Cu(e,t)}while(1);return Qi=Zi=null,D.H=r,D.A=a,J=n,Y===null?(Ll=null,X=0,ai(),Wl):0}function ju(){for(;Y!==null&&!ke();)Mu(Y)}function Mu(e){var t=jc(e.alternate,e,Ul);e.memoizedProps=e.pendingProps,t===null?Fu(e):Y=t}function Nu(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=hc(n,t,t.pendingProps,t.type,void 0,X);break;case 11:t=hc(n,t,t.pendingProps,t.type.render,t.ref,X);break;case 5:jo(t);default:Bc(n,t),t=Y=gi(t,Ul),t=jc(n,t,Ul)}e.memoizedProps=e.pendingProps,t===null?Fu(e):Y=t}function Pu(e,t,n,r){Qi=Zi=null,jo(t),Ia=null,La=0;var i=t.return;try{if(ec(e,i,t,n,X)){Wl=1,Ys(e,Ci(n,e.current)),Y=null;return}}catch(t){if(i!==null)throw Y=i,t;Wl=1,Ys(e,Ci(n,e.current)),Y=null;return}t.flags&32768?(P||r===1?e=!0:Vl||X&536870912?e=!1:(Bl=e=!0,(r===2||r===9||r===3||r===6)&&(r=so.current,r!==null&&r.tag===13&&(r.flags|=16384))),Iu(t,e)):Fu(t)}function Fu(e){var t=e;do{if(t.flags&32768){Iu(t,Bl);return}e=t.return;var n=Rc(t.alternate,t,Ul);if(n!==null){Y=n;return}if(t=t.sibling,t!==null){Y=t;return}Y=t=e}while(t!==null);Wl===0&&(Wl=5)}function Iu(e,t){do{var n=zc(e.alternate,e);if(n!==null){n.flags&=32767,Y=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Y=e;return}Y=e=n}while(e!==null);Wl=6,Y=null}function Lu(e,t,n,r,a,o,s,c,l){e.cancelPendingCommit=null;do Hu();while(iu!==0);if(J&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));if(o=t.lanes|t.childLanes,o|=ii,nt(e,n,o,s,c,l),e===Ll&&(Y=Ll=null,X=0),ou=t,au=e,su=n,cu=o,lu=a,uu=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,Zu(Fe,function(){return Uu(),null})):(e.callbackNode=null,e.callbackPriority=0),r=(t.flags&13878)!=0,t.subtreeFlags&13878||r){r=D.T,D.T=null,a=O.p,O.p=2,s=J,J|=4;try{al(e,t,n)}finally{J=s,O.p=a,D.T=r}}iu=1,Ru(),zu(),Bu()}}function Ru(){if(iu===1){iu=0;var e=au,t=ou,n=(t.flags&13878)!=0;if(t.subtreeFlags&13878||n){n=D.T,D.T=null;var r=O.p;O.p=2;var i=J;J|=4;try{_l(t,e);var a=Vd,o=Mr(e.containerInfo),s=a.focusedElem,c=a.selectionRange;if(o!==s&&s&&s.ownerDocument&&jr(s.ownerDocument.documentElement,s)){if(c!==null&&Nr(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=Ar(s,h),v=Ar(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}lp=!!Bd,Vd=Bd=null}finally{J=i,O.p=r,D.T=n}}e.current=t,iu=2}}function zu(){if(iu===2){iu=0;var e=au,t=ou,n=(t.flags&8772)!=0;if(t.subtreeFlags&8772||n){n=D.T,D.T=null;var r=O.p;O.p=2;var i=J;J|=4;try{ol(e,t.alternate,t)}finally{J=i,O.p=r,D.T=n}}iu=3}}function Bu(){if(iu===4||iu===3){iu=0,Ae();var e=au,t=ou,n=su,r=uu;t.subtreeFlags&10256||t.flags&10256?iu=5:(iu=0,ou=au=null,Vu(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(ru=null),st(n),t=t.stateNode,j&&typeof j.onCommitFiberRoot==`function`)try{j.onCommitFiberRoot(Be,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=D.T,i=O.p,O.p=2,D.T=null;try{for(var a=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];a(s.value,{componentStack:s.stack})}}finally{D.T=t,O.p=i}}su&3&&Hu(),id(e),i=e.pendingLanes,n&261930&&i&42?e===fu?du++:(du=0,fu=e):du=0,ad(0,!1)}}function Vu(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,pa(t)))}function Hu(){return Ru(),zu(),Bu(),Uu()}function Uu(){if(iu!==5)return!1;var e=au,t=cu;cu=0;var n=st(su),r=D.T,a=O.p;try{O.p=32>n?32:n,D.T=null,n=lu,lu=null;var o=au,s=su;if(iu=0,ou=au=null,su=0,J&6)throw Error(i(331));var c=J;if(J|=4,Ml(o.current),wl(o,o.current,s,n),J=c,ad(0,!1),j&&typeof j.onPostCommitFiberRoot==`function`)try{j.onPostCommitFiberRoot(Be,o)}catch{}return!0}finally{O.p=a,D.T=r,Vu(e,t)}}function Wu(e,t,n){t=Ci(n,t),t=Zs(e.stateNode,t,2),e=Ja(e,t,2),e!==null&&(tt(e,2),id(e))}function Gu(e,t,n){if(e.tag===3)Wu(e,e,n);else for(;t!==null;){if(t.tag===3){Wu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(ru===null||!ru.has(r))){e=Ci(n,e),n=Qs(2),r=Ja(t,n,2),r!==null&&($s(n,r,t,e),tt(r,2),id(r));break}}t=t.return}}function Ku(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Il;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Hl=!0,i.add(n),e=qu.bind(null,e,t,n),t.then(e,e))}function qu(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Ll===e&&(X&n)===n&&(Wl===4||Wl===3&&(X&62914560)===X&&300>je()-$l?!(J&2)&&Su(e,0):ql|=n,Yl===X&&(Yl=0)),id(e)}function Ju(e,t){t===0&&(t=$e()),e=ci(e,t),e!==null&&(tt(e,t),id(e))}function Yu(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Ju(e,n)}function Xu(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),Ju(e,n)}function Zu(e,t){return De(e,t)}var Qu=null,$u=null,ed=!1,td=!1,nd=!1,rd=0;function id(e){e!==$u&&e.next===null&&($u===null?Qu=$u=e:$u=$u.next=e),td=!0,ed||(ed=!0,dd())}function ad(e,t){if(!nd&&td){nd=!0;do for(var n=!1,r=Qu;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-He(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,ud(r,a))}else a=X,a=Xe(r,r===Ll?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||Qe(r,a)||(n=!0,ud(r,a));r=r.next}while(n);nd=!1}}function od(){sd()}function sd(){td=ed=!1;var e=0;rd!==0&&qd()&&(e=rd);for(var t=je(),n=null,r=Qu;r!==null;){var i=r.next,a=cd(r,t);a===0?(r.next=null,n===null?Qu=i:n.next=i,i===null&&($u=n)):(n=r,(e!==0||a&3)&&(td=!0)),r=i}iu!==0&&iu!==5||ad(e,!1),rd!==0&&(rd=0)}function cd(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-He(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=M(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Ll,n=X,n=Xe(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Rl===2||Rl===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&Oe(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||Qe(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&Oe(r),st(n)){case 2:case 8:n=Pe;break;case 32:n=Fe;break;case 268435456:n=Le;break;default:n=Fe}return r=ld.bind(null,e),n=De(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&Oe(r),e.callbackPriority=2,e.callbackNode=null,2}function ld(e,t){if(iu!==0&&iu!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(Hu()&&e.callbackNode!==n)return null;var r=X;return r=Xe(e,e===Ll?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(gu(e,r,t),cd(e,je()),e.callbackNode!=null&&e.callbackNode===n?ld.bind(null,e):null)}function ud(e,t){if(Hu())return null;gu(e,t,!0)}function dd(){Zd(function(){J&6?De(Ne,od):sd()})}function fd(){if(rd===0){var e=ga;e===0&&(e=Ke,Ke<<=1,!(Ke&261888)&&(Ke=256)),rd=e}return rd}function pd(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:an(``+e)}function md(e,t){var n=t.ownerDocument.createElement(`input`);return n.name=t.name,n.value=t.value,e.id&&n.setAttribute(`form`,e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function hd(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=pd((i[ft]||null).action),o=r.submitter;o&&(t=(t=o[ft]||null)?pd(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new En(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(rd!==0){var e=o?md(i,o):new FormData(i);Ts(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=o?md(i,o):new FormData(i),Ts(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var gd=0;gd<$r.length;gd++){var _d=$r[gd];ei(_d.toLowerCase(),`on`+(_d[0].toUpperCase()+_d.slice(1)))}ei(Gr,`onAnimationEnd`),ei(Kr,`onAnimationIteration`),ei(qr,`onAnimationStart`),ei(`dblclick`,`onDoubleClick`),ei(`focusin`,`onFocus`),ei(`focusout`,`onBlur`),ei(Jr,`onTransitionRun`),ei(Yr,`onTransitionStart`),ei(Xr,`onTransitionCancel`),ei(Zr,`onTransitionEnd`),Ot(`onMouseEnter`,[`mouseout`,`mouseover`]),Ot(`onMouseLeave`,[`mouseout`,`mouseover`]),Ot(`onPointerEnter`,[`pointerout`,`pointerover`]),Ot(`onPointerLeave`,[`pointerout`,`pointerover`]),Dt(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),Dt(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),Dt(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),Dt(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),Dt(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),Dt(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var vd=`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(` `),yd=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(vd));function bd(e,t){t=(t&4)!=0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){ti(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){ti(e)}i.currentTarget=null,a=c}}}}function Z(e,t){var n=t[mt];n===void 0&&(n=t[mt]=new Set);var r=e+`__bubble`;n.has(r)||(wd(t,e,2,!1),n.add(r))}function xd(e,t,n){var r=0;t&&(r|=4),wd(n,e,r,t)}var Sd=`_reactListening`+Math.random().toString(36).slice(2);function Cd(e){if(!e[Sd]){e[Sd]=!0,Tt.forEach(function(t){t!==`selectionchange`&&(yd.has(t)||xd(t,!1,e),xd(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Sd]||(t[Sd]=!0,xd(`selectionchange`,!1,t))}}function wd(e,t,n,r){switch(gp(t)){case 2:var i=up;break;case 8:i=dp;break;default:i=fp}n=i.bind(null,t,n,e),i=void 0,!hn||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function Td(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var c=r.stateNode.containerInfo;if(c===i)break;if(s===4)for(s=r.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===i)return;s=s.return}for(;c!==null;){if(s=bt(c),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){r=a=s;continue a}c=c.parentNode}}r=r.return}fn(function(){var r=a,i=cn(n),s=[];a:{var c=Qr.get(e);if(c!==void 0){var l=En,u=e;switch(e){case`keypress`:if(xn(n)===0)break a;case`keydown`:case`keyup`:l=Wn;break;case`focusin`:u=`focus`,l=Fn;break;case`focusout`:u=`blur`,l=Fn;break;case`beforeblur`:case`afterblur`:l=Fn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=Nn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=Pn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=Kn;break;case Gr:case Kr:case qr:l=In;break;case Zr:l=qn;break;case`scroll`:case`scrollend`:l=On;break;case`wheel`:l=Jn;break;case`copy`:case`cut`:case`paste`:l=Ln;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=Gn;break;case`toggle`:case`beforetoggle`:l=Yn}var d=(t&4)!=0,f=!d&&(e===`scroll`||e===`scrollend`),p=d?c===null?null:c+`Capture`:c;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=pn(m,p),g!=null&&d.push(Ed(m,g,h))),f)break;m=m.return}0<d.length&&(c=new l(c,u,null,n,i),s.push({event:c,listeners:d}))}}if(!(t&7)){a:{if(c=e===`mouseover`||e===`pointerover`,l=e===`mouseout`||e===`pointerout`,c&&n!==sn&&(u=n.relatedTarget||n.fromElement)&&(bt(u)||u[pt]))break a;if((l||c)&&(c=i.window===i?i:(c=i.ownerDocument)?c.defaultView||c.parentWindow:window,l?(u=n.relatedTarget||n.toElement,l=r,u=u?bt(u):null,u!==null&&(f=o(u),d=u.tag,u!==f||d!==5&&d!==27&&d!==6)&&(u=null)):(l=null,u=r),l!==u)){if(d=Nn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=Gn,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=l==null?c:St(l),h=u==null?c:St(u),c=new d(g,m+`leave`,l,n,i),c.target=f,c.relatedTarget=h,g=null,bt(i)===r&&(d=new d(p,m+`enter`,u,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,l&&u)b:{for(d=Od,p=l,m=u,h=0,g=p;g;g=d(g))h++;g=0;for(var _=m;_;_=d(_))g++;for(;0<h-g;)p=d(p),h--;for(;0<g-h;)m=d(m),g--;for(;h--;){if(p===m||m!==null&&p===m.alternate){d=p;break b}p=d(p),m=d(m)}d=null}else d=null;l!==null&&kd(s,c,l,d,!1),u!==null&&f!==null&&kd(s,f,u,d,!0)}}a:{if(c=r?St(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var v=hr;else if(lr(c))if(gr)v=Tr;else{v=Cr;var y=Sr}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&tn(r.elementType)&&(v=hr):v=wr;if(v&&=v(e,r)){ur(s,v,n,i);break a}y&&y(e,c,r),e===`focusout`&&r&&c.type===`number`&&r.memoizedProps.value!=null&&Kt(c,`number`,c.value)}switch(y=r?St(r):window,e){case`focusin`:(lr(y)||y.contentEditable===`true`)&&(Fr=y,Ir=r,Lr=null);break;case`focusout`:Lr=Ir=Fr=null;break;case`mousedown`:Rr=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:Rr=!1,zr(s,n,i);break;case`selectionchange`:if(Pr)break;case`keydown`:case`keyup`:zr(s,n,i)}var b;if(Zn)b:{switch(e){case`compositionstart`:var x=`onCompositionStart`;break b;case`compositionend`:x=`onCompositionEnd`;break b;case`compositionupdate`:x=`onCompositionUpdate`;break b}x=void 0}else ar?rr(e,n)&&(x=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(x=`onCompositionStart`);x&&(er&&n.locale!==`ko`&&(ar||x!==`onCompositionStart`?x===`onCompositionEnd`&&ar&&(b=bn()):(_n=i,vn=`value`in _n?_n.value:_n.textContent,ar=!0)),y=Dd(r,x),0<y.length&&(x=new Rn(x,e,null,n,i),s.push({event:x,listeners:y}),b?x.data=b:(b=ir(n),b!==null&&(x.data=b)))),(b=$n?or(e,n):sr(e,n))&&(x=Dd(r,`onBeforeInput`),0<x.length&&(y=new Rn(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:y,listeners:x}),y.data=b)),hd(s,e,r,n,i)}bd(s,t)})}function Ed(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Dd(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=pn(e,n),i!=null&&r.unshift(Ed(e,i,a)),i=pn(e,t),i!=null&&r.push(Ed(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Od(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function kd(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=pn(n,a),l!=null&&o.unshift(Ed(n,l,c))):i||(l=pn(n,a),l!=null&&o.push(Ed(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Ad=/\r\n?/g,jd=/\u0000|\uFFFD/g;function Md(e){return(typeof e==`string`?e:``+e).replace(Ad,`
17
- `).replace(jd,``)}function Nd(e,t){return t=Md(t),Md(e)===t}function Pd(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||Xt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&Xt(e,``+r);break;case`className`:Pt(e,`class`,r);break;case`tabIndex`:Pt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Pt(e,n,r);break;case`style`:en(e,r,o);break;case`data`:if(t!==`object`){Pt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=an(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`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 o==`function`&&(n===`formAction`?(t!==`input`&&Pd(e,t,`name`,a.name,a,null),Pd(e,t,`formEncType`,a.formEncType,a,null),Pd(e,t,`formMethod`,a.formMethod,a,null),Pd(e,t,`formTarget`,a.formTarget,a,null)):(Pd(e,t,`encType`,a.encType,a,null),Pd(e,t,`method`,a.method,a,null),Pd(e,t,`target`,a.target,a,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=an(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=on);break;case`onScroll`:r!=null&&Z(`scroll`,e);break;case`onScrollEnd`:r!=null&&Z(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=an(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);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`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:Z(`beforetoggle`,e),Z(`toggle`,e),Nt(e,`popover`,r);break;case`xlinkActuate`:Ft(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Ft(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Ft(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Ft(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Ft(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Ft(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Ft(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Ft(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Ft(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Nt(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=nn.get(n)||n,Nt(e,n,r))}}function Fd(e,t,n,r,a,o){switch(n){case`style`:en(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?Xt(e,r):(typeof r==`number`||typeof r==`bigint`)&&Xt(e,``+r);break;case`onScroll`:r!=null&&Z(`scroll`,e);break;case`onScrollEnd`:r!=null&&Z(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=on);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!Et.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),t=n.slice(2,a?n.length-7:void 0),o=e[ft]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,a),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):Nt(e,n,r)}}}function Id(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:Z(`error`,e),Z(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Pd(e,t,o,s,n,null)}}a&&Pd(e,t,`srcSet`,n.srcSet,n,null),r&&Pd(e,t,`src`,n.src,n,null);return;case`input`:Z(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:Pd(e,t,r,d,n,null)}}Gt(e,o,c,l,u,s,a,!1);return;case`select`:for(a in Z(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:Pd(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&qt(e,!!r,n,!0):qt(e,!!r,t,!1);return;case`textarea`:for(s in Z(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:Pd(e,t,s,c,n,null)}Yt(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:Pd(e,t,l,r,n,null)}return;case`dialog`:Z(`beforetoggle`,e),Z(`toggle`,e),Z(`cancel`,e),Z(`close`,e);break;case`iframe`:case`object`:Z(`load`,e);break;case`video`:case`audio`:for(r=0;r<vd.length;r++)Z(vd[r],e);break;case`image`:Z(`error`,e),Z(`load`,e);break;case`details`:Z(`toggle`,e);break;case`embed`:case`source`:case`link`:Z(`error`,e),Z(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Pd(e,t,u,r,n,null)}return;default:if(tn(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Fd(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Pd(e,t,c,r,n,null))}function Ld(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||Pd(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:a=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&Pd(e,t,p,m,r,f)}}Wt(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||Pd(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&Pd(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?qt(e,!!n,n?[]:``,!1):qt(e,!!n,t,!0)):qt(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:Pd(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:p=a;break;case`defaultValue`:m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&Pd(e,t,s,a,r,o)}Jt(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:Pd(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:Pd(e,t,l,p,r,m)}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 g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&Pd(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:Pd(e,t,u,p,r,m)}return;default:if(tn(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Fd(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Fd(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Pd(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||Pd(e,t,f,p,r,m)}function Rd(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function zd(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&Rd(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&Rd(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var Bd=null,Vd=null;function Hd(e){return e.nodeType===9?e:e.ownerDocument}function Ud(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Wd(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function Gd(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Kd=null;function qd(){var e=window.event;return e&&e.type===`popstate`?e===Kd?!1:(Kd=e,!0):(Kd=null,!1)}var Jd=typeof setTimeout==`function`?setTimeout:void 0,Yd=typeof clearTimeout==`function`?clearTimeout:void 0,Xd=typeof Promise==`function`?Promise:void 0,Zd=typeof queueMicrotask==`function`?queueMicrotask:Xd===void 0?Jd:function(e){return Xd.resolve(null).then(e).catch(Qd)};function Qd(e){setTimeout(function(){throw e})}function $d(e){return e===`head`}function ef(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Fp(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)hf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,hf(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[vt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&hf(e.ownerDocument.body);n=i}while(n);Fp(t)}function tf(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8)if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++;n=r}while(n)}function nf(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:nf(n),yt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function rf(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r)if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e;else if(!e[vt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=uf(e.nextSibling),e===null)break}return null}function af(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=uf(e.nextSibling),e===null))return null;return e}function of(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=uf(e.nextSibling),e===null))return null;return e}function sf(e){return e.data===`$?`||e.data===`$~`}function cf(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function lf(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function uf(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var df=null;function ff(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return uf(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function pf(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function mf(e,t,n){switch(t=Hd(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function hf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);yt(e)}var gf=new Map,_f=new Set;function vf(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var yf=O.d;O.d={f:bf,r:xf,D:wf,C:Tf,L:Ef,m:Df,X:kf,S:Of,M:Af};function bf(){var e=yf.f(),t=bu();return e||t}function xf(e){var t=xt(e);t!==null&&t.tag===5&&t.type===`form`?Es(t):yf.r(e)}var Sf=typeof document>`u`?null:document;function Cf(e,t,n){var r=Sf;if(r&&typeof t==`string`&&t){var i=Ut(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),_f.has(i)||(_f.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Id(t,`link`,e),wt(t),r.head.appendChild(t)))}}function wf(e){yf.D(e),Cf(`dns-prefetch`,e,null)}function Tf(e,t){yf.C(e,t),Cf(`preconnect`,e,t)}function Ef(e,t,n){yf.L(e,t,n);var r=Sf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Ut(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Ut(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Ut(n.imageSizes)+`"]`)):i+=`[href="`+Ut(e)+`"]`;var a=i;switch(t){case`style`:a=Mf(e);break;case`script`:a=If(e)}gf.has(a)||(e=p({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),gf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Nf(a))||t===`script`&&r.querySelector(Lf(a))||(t=r.createElement(`link`),Id(t,`link`,e),wt(t),r.head.appendChild(t)))}}function Df(e,t){yf.m(e,t);var n=Sf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Ut(r)+`"][href="`+Ut(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=If(e)}if(!gf.has(a)&&(e=p({rel:`modulepreload`,href:e},t),gf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Lf(a)))return}r=n.createElement(`link`),Id(r,`link`,e),wt(r),n.head.appendChild(r)}}}function Of(e,t,n){yf.S(e,t,n);var r=Sf;if(r&&e){var i=Ct(r).hoistableStyles,a=Mf(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Nf(a)))s.loading=5;else{e=p({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=gf.get(a))&&Bf(e,n);var c=o=r.createElement(`link`);wt(c),Id(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,zf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function kf(e,t){yf.X(e,t);var n=Sf;if(n&&e){var r=Ct(n).hoistableScripts,i=If(e),a=r.get(i);a||(a=n.querySelector(Lf(i)),a||(e=p({src:e,async:!0},t),(t=gf.get(i))&&Vf(e,t),a=n.createElement(`script`),wt(a),Id(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Af(e,t){yf.M(e,t);var n=Sf;if(n&&e){var r=Ct(n).hoistableScripts,i=If(e),a=r.get(i);a||(a=n.querySelector(Lf(i)),a||(e=p({src:e,async:!0,type:`module`},t),(t=gf.get(i))&&Vf(e,t),a=n.createElement(`script`),wt(a),Id(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function jf(e,t,n,r){var a=(a=pe.current)?vf(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Mf(n.href),n=Ct(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Mf(n.href);var o=Ct(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Nf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),gf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},gf.set(e,n),o||Ff(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=If(n),n=Ct(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Mf(e){return`href="`+Ut(e)+`"`}function Nf(e){return`link[rel="stylesheet"][`+e+`]`}function Pf(e){return p({},e,{"data-precedence":e.precedence,precedence:null})}function Ff(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Id(t,`link`,n),wt(t),e.head.appendChild(t))}function If(e){return`[src="`+Ut(e)+`"]`}function Lf(e){return`script[async]`+e}function Rf(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Ut(n.href)+`"]`);if(r)return t.instance=r,wt(r),r;var a=p({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),wt(r),Id(r,`style`,a),zf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Mf(n.href);var o=e.querySelector(Nf(a));if(o)return t.state.loading|=4,t.instance=o,wt(o),o;r=Pf(n),(a=gf.get(a))&&Bf(r,a),o=(e.ownerDocument||e).createElement(`link`),wt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Id(o,`link`,r),t.state.loading|=4,zf(o,n.precedence,e),t.instance=o;case`script`:return o=If(n.src),(a=e.querySelector(Lf(o)))?(t.instance=a,wt(a),a):(r=n,(a=gf.get(o))&&(r=p({},n),Vf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),wt(a),Id(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,zf(r,n.precedence,e));return t.instance}function zf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Bf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Vf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Hf=null;function Uf(e,t,n){if(Hf===null){var r=new Map,i=Hf=new Map;i.set(n,r)}else i=Hf,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[vt]||a[dt]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Wf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Gf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Kf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function qf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Mf(r.href),a=t.querySelector(Nf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Xf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,wt(a);return}a=t.ownerDocument||t,r=Pf(r),(i=gf.get(i))&&Bf(r,i),a=a.createElement(`link`),wt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Id(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Xf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Jf=0;function Yf(e,t){return e.stylesheets&&e.count===0&&Qf(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&Qf(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&Jf===0&&(Jf=62500*zd());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Qf(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>Jf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Xf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Qf(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Zf=null;function Qf(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Zf=new Map,t.forEach($f,e),Zf=null,Xf.call(e))}function $f(e,t){if(!(t.state.loading&4)){var n=Zf.get(e);if(n)var r=n.get(null);else{n=new Map,Zf.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=Xf.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var ep={$$typeof:x,Provider:null,Consumer:null,_currentValue:se,_currentValue2:se,_threadCount:0};function tp(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,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=et(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=et(0),this.hiddenUpdates=et(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function np(e,t,n,r,i,a,o,s,c,l,u,d){return e=new tp(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=pi(3,null,null,t),e.current=a,a.stateNode=e,t=fa(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},Ga(a),e}function rp(e){return e?(e=di,e):di}function ip(e,t,n,r,i,a){i=rp(i),r.context===null?r.context=i:r.pendingContext=i,r=qa(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=Ja(e,r,t),n!==null&&(hu(n,e,t),Ya(n,e,t))}function ap(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function op(e,t){ap(e,t),(e=e.alternate)&&ap(e,t)}function sp(e){if(e.tag===13||e.tag===31){var t=ci(e,67108864);t!==null&&hu(t,e,67108864),op(e,67108864)}}function cp(e){if(e.tag===13||e.tag===31){var t=pu();t=ot(t);var n=ci(e,t);n!==null&&hu(n,e,t),op(e,t)}}var lp=!0;function up(e,t,n,r){var i=D.T;D.T=null;var a=O.p;try{O.p=2,fp(e,t,n,r)}finally{O.p=a,D.T=i}}function dp(e,t,n,r){var i=D.T;D.T=null;var a=O.p;try{O.p=8,fp(e,t,n,r)}finally{O.p=a,D.T=i}}function fp(e,t,n,r){if(lp){var i=pp(r);if(i===null)Td(e,t,r,mp,n),Tp(e,r);else if(Dp(i,e,t,n,r))r.stopPropagation();else if(Tp(e,r),t&4&&-1<wp.indexOf(e)){for(;i!==null;){var a=xt(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Ye(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-He(o);s.entanglements[1]|=c,o&=~c}id(a),!(J&6)&&(tu=je()+500,ad(0,!1))}}break;case 31:case 13:s=ci(a,2),s!==null&&hu(s,a,2),bu(),op(a,2)}if(a=pp(r),a===null&&Td(e,t,r,mp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Td(e,t,r,null,n)}}function pp(e){return e=cn(e),hp(e)}var mp=null;function hp(e){if(mp=null,e=bt(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return mp=e,null}function gp(e){switch(e){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(Me()){case Ne:return 2;case Pe:return 8;case Fe:case Ie:return 32;case Le:return 268435456;default:return 32}default:return 32}}var _p=!1,vp=null,yp=null,bp=null,xp=new Map,Sp=new Map,Cp=[],wp=`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 Tp(e,t){switch(e){case`focusin`:case`focusout`:vp=null;break;case`dragenter`:case`dragleave`:yp=null;break;case`mouseover`:case`mouseout`:bp=null;break;case`pointerover`:case`pointerout`:xp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:Sp.delete(t.pointerId)}}function Ep(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=xt(t),t!==null&&sp(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Dp(e,t,n,r,i){switch(t){case`focusin`:return vp=Ep(vp,e,t,n,r,i),!0;case`dragenter`:return yp=Ep(yp,e,t,n,r,i),!0;case`mouseover`:return bp=Ep(bp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return xp.set(a,Ep(xp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,Sp.set(a,Ep(Sp.get(a)||null,e,t,n,r,i)),!0}return!1}function Op(e){var t=bt(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,lt(e.priority,function(){cp(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,lt(e.priority,function(){cp(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function kp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=pp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);sn=r,n.target.dispatchEvent(r),sn=null}else return t=xt(n),t!==null&&sp(t),e.blockedOn=n,!1;t.shift()}return!0}function Ap(e,t,n){kp(e)&&n.delete(t)}function jp(){_p=!1,vp!==null&&kp(vp)&&(vp=null),yp!==null&&kp(yp)&&(yp=null),bp!==null&&kp(bp)&&(bp=null),xp.forEach(Ap),Sp.forEach(Ap)}function Mp(e,n){e.blockedOn===n&&(e.blockedOn=null,_p||(_p=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,jp)))}var Np=null;function Pp(e){Np!==e&&(Np=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Np===e&&(Np=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(hp(r||n)===null)continue;break}var a=xt(n);a!==null&&(e.splice(t,3),t-=3,Ts(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Fp(e){function t(t){return Mp(t,e)}vp!==null&&Mp(vp,e),yp!==null&&Mp(yp,e),bp!==null&&Mp(bp,e),xp.forEach(t),Sp.forEach(t);for(var n=0;n<Cp.length;n++){var r=Cp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Cp.length&&(n=Cp[0],n.blockedOn===null);)Op(n),n.blockedOn===null&&Cp.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[ft]||null;if(typeof a==`function`)o||Pp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[ft]||null)s=o.formAction;else if(hp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Pp(n)}}}function Ip(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!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 r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Lp(e){this._internalRoot=e}Rp.prototype.render=Lp.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;ip(n,pu(),e,t,null,null)},Rp.prototype.unmount=Lp.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;ip(e.current,2,null,e,null,null),bu(),t[pt]=null}};function Rp(e){this._internalRoot=e}Rp.prototype.unstable_scheduleHydration=function(e){if(e){var t=ct();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Cp.length&&t!==0&&t<Cp[n].priority;n++);Cp.splice(n,0,e),n===0&&Op(e)}};var zp=n.version;if(zp!==`19.2.7`)throw Error(i(527,zp,`19.2.7`));O.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=d(t),e=e===null?null:f(e),e=e===null?null:e.stateNode,e};var Bp={bundleType:0,version:`19.2.7`,rendererPackageName:`react-dom`,currentDispatcherRef:D,reconcilerVersion:`19.2.7`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Vp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Vp.isDisabled&&Vp.supportsFiber)try{Be=Vp.inject(Bp),j=Vp}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=Ks,s=qs,c=Js;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=np(e,1,!1,null,null,n,r,null,o,s,c,Ip),e[pt]=t.current,Cd(e),new Lp(t)}})),$t=o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Qt()}))();function en(e){let t=e.indexOf(`=`);return t>0?[e.slice(0,t),e.slice(t+1)]:null}function tn(e,t){return t.filter(t=>{let n=en(t);return n!=null&&e[n[0]]?.includes(n[1])===!0})}function nn(e,t,n){let r=new Map;for(let i of e){let e=tn(i.tags,t);if(e.length===0||n===`all`&&e.length<t.length)continue;let a=e.join(`,`),o=r.get(a)??{signature:e,members:[]};o.members.push(i),r.set(a,o)}let i=e=>e.signature.map(e=>t.indexOf(e));return[...r.values()].sort((e,t)=>{if(e.signature.length!==t.signature.length)return t.signature.length-e.signature.length;let[n,r]=[i(e),i(t)];for(let e=0;e<n.length;e+=1)if(n[e]!==r[e])return(n[e]??0)-(r[e]??0);return 0})}function rn(e,t){return e.length===t.length&&e.every(e=>t.includes(e))}function an(e,t){let n=nn(t.filter(e=>!e.optIn),[...e.terms].sort(),e.mode),r=e.bucket;return(r==null?n:n.filter(e=>rn(e.signature,r))).flatMap(e=>e.members)}function on(e){if(!Array.isArray(e)||e.length===0||e.length>16)return null;let t=[];for(let n of e){if(typeof n!=`string`||n.length>512||en(n)==null)return null;t.includes(n)||t.push(n)}return t.sort()}function sn(e){if(typeof e!=`object`||!e||Array.isArray(e))return`expected an object`;let t={...e},n=t.mode;if(n!==`all`&&n!==`any`)return`mode: expected "all" | "any"`;let r=on(t.terms);if(r==null)return`terms: expected 1–16 tag=value strings`;if(t.bucket==null)return{mode:n,terms:r};let i=on(t.bucket);return i==null||!i.every(e=>r.includes(e))?`bucket: expected a subset of terms`:{mode:n,terms:r,bucket:i}}function cn(e,t){let n=new Map(e.map((e,t)=>[e.id,t])),r=new Map,i=new Map;for(let e of t)r.set(e,0),i.set(e,[]);for(let n of t){let a=e.find(e=>e.id===n);for(let e of a?.dependsOn??[])t.has(e)&&(r.set(n,(r.get(n)??0)+1),i.get(e)?.push(n))}let a=[...t].filter(e=>r.get(e)===0);a.sort((e,t)=>(n.get(e)??0)-(n.get(t)??0));let o=[];for(let e=0;e<a.length;e+=1){let t=a[e];o.push(t);for(let o of i.get(t)??[]){let t=(r.get(o)??0)-1;if(r.set(o,t),t===0){let t=e+1;for(;t<a.length&&(n.get(a[t])??0)<(n.get(o)??0);)t+=1;a.splice(t,0,o)}}}return o.length===t.size?o:[...o,...[...t].filter(e=>!o.includes(e))]}function ln(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Set,i=[...t];for(;i.length>0;){let e=i.pop();if(!r.has(e)){r.add(e);for(let t of n.get(e)?.dependsOn??[])i.push(t)}}return r}function un(e,t,n){let r=ln(e,t),i=[];for(let a=!0;a;){a=!1;let o=ln(e,e.filter(e=>!r.has(e.id)&&n(e.id)).map(e=>e.id));for(let e of[...r])t.includes(e)||!o.has(e)||(r.delete(e),n(e)&&i.push(e),a=!0)}return{stop:cn(e,r),kept:i}}function dn(e,t){return`color-mix(in srgb, ${e} ${t}%, transparent)`}var N={void:j(`surfaceVoid`),surface:j(`surfaceBase`),surfaceSelected:j(`surfaceSelected`),surfaceHeader:j(`surfaceDetailHeader`),surfaceSection:j(`surfaceSection`),border:j(`borderPanel`),borderStrong:j(`borderDivider`),textEmphasis:j(`textEmphasis`),text:j(`textSecondary`),textMeta:j(`semanticMetadata`),textMuted:j(`textMuted`),error:j(`semanticError`),success:j(`semanticSuccess`),system:j(`semanticSystem`),warning:j(`semanticWarning`)};function fn(e){let t=0;for(let n=0;n<e.length;n+=1)t=t*31+e.charCodeAt(n)|0;let n=Ue();return n[Math.abs(t)%n.length]??N.system}var pn=e=>`color-mix(in srgb, ${e} 72%, white)`,mn=Ue(),hn=[j(`surfaceVoid`),j(`semanticError`),j(`semanticSuccess`),j(`semanticWarning`),j(`semanticSystem`),mn[0]??j(`semanticSystem`),mn[2]??j(`semanticSystem`),j(`textSecondary`)],gn=[...hn,...hn.map(pn)];function _n(e){switch(e){case`ready`:case`succeeded`:case`running`:return`ready`;case`starting`:case`stopping`:return`active`;case`unready`:case`backoff`:case`blocked`:return`warn`;case`failed`:case`crashed`:return`bad`;default:return`idle`}}var vn={ready:N.success,active:N.system,warn:N.warning,bad:N.error,idle:N.textMuted};function yn(e){if(e.state===`blocked`)return{indicator:`warning`,label:`blocked`,tone:`warn`};if(bn(e.state))return e.state===`unready`||e.state===`backoff`?{indicator:`warning`,label:e.state,tone:`warn`}:e.state===`starting`||e.state===`stopping`?{indicator:`transition`,label:e.state,tone:`active`}:{indicator:`running`,label:e.state,tone:`ready`};let t=e.kind===`task`?e.lastTask?.outcome:void 0;return t===`failed`||e.state===`failed`||e.state===`crashed`?{indicator:`failure`,label:e.lastTask?.timedOut?`timed out`:e.state===`crashed`?`crashed`:`failed`,tone:`bad`}:t===`succeeded`||e.state===`succeeded`?{indicator:`success`,label:`succeeded`,tone:`ready`}:{indicator:`idle`,label:e.state,tone:`idle`}}function bn(e){return e===`starting`||e===`running`||e===`ready`||e===`unready`||e===`backoff`||e===`stopping`}var xn=15e3;function Sn(e,t){let n=[];e.removed&&n.push(`removed from config`),e.stale&&n.push(`config changed`),e.envDrift&&n.push(`env changed — restart to apply`),e.blockedBy!=null&&n.push(`blocked: ${e.blockedBy}`),e.unreadyReason!=null&&n.push(`unready: ${e.unreadyReason}`),bn(e.state)&&e.sawOutputAt==null&&e.startedAt!=null&&t-e.startedAt>xn&&n.push(`no output since start`),!bn(e.state)&&e.lastTask?.outcome===`failed`&&e.lastTask.reason!=null&&n.push(`last run failed: ${e.lastTask.reason}`);for(let t of e.degradedBy)n.push(`degraded by ${t}`);return e.restarts>=3&&n.push(`${e.restarts} restarts`),e.capability?.degraded===!0&&n.push(`tree ownership degraded (${e.capability.treeMechanism})`),n}function Cn(e,t=Date.now()){return Object.entries(e.processes).map(([e,n])=>({id:e,node:n,tone:yn(n).tone,chips:Sn(n,t),stickyOverrides:n.detail.envVars.filter(e=>e.source===`override`).map(e=>e.name)})).sort((e,t)=>e.id<t.id?-1:+(e.id>t.id))}function wn(e,t){let n=new Map(e.map(e=>[e.id,e]));return t.flatMap(e=>n.get(e)??[])}function Tn(e){return wn(e,cn(e.map(e=>({id:e.id,dependsOn:e.node.detail.dependsOn})).sort((e,t)=>e.id<t.id?-1:1),new Set(e.map(e=>e.id))))}function En(e){let t=new Map;for(let n of e)for(let[e,r]of Object.entries(n.node.tags)){let n=t.get(e)??new Set;for(let e of r)n.add(e);t.set(e,n)}return[...t.entries()].map(([e,t])=>({key:e,values:[...t].sort()})).sort((e,t)=>e.key<t.key?-1:+(e.key>t.key))}function Dn(e){return[...e].sort()}function On(e,t,n,r){let i=e.map(e=>({row:e,tags:e.node.tags})),a=e=>{let t=Tn(e.members.map(e=>e.row));return{signature:e.signature,members:t.filter(e=>!e.node.optIn),optIn:t.filter(e=>e.node.optIn)}};if(t.length>0)return nn(i,Dn(t),n).map(a);if(r==null)return e.length===0?[]:[a({signature:[],members:i})];let o=nn(i,(En(e).find(e=>e.key===r)?.values??[]).map(e=>`${r}=${e}`),`any`).flatMap(e=>e.signature.map(t=>({signature:[t],members:e.members}))),s=new Map;for(let e of o){let t=e.signature[0]??``,n=s.get(t);s.set(t,{signature:e.signature,members:[...n?.members??[],...e.members]})}let c=i.filter(e=>e.tags[r]==null);return[...[...s.values()].sort((e,t)=>(e.signature[0]??``)<(t.signature[0]??``)?-1:1),...c.length>0?[{signature:[],members:c}]:[]].map(a)}function kn(e,t,n){let r=new Map,i=e.map(e=>({tags:e.node.tags}));for(let{key:a,values:o}of En(e))for(let e of o){let o=`${a}=${e}`,s=nn(i,t.includes(o)?t:[...t,o],n).reduce((e,t)=>e+(n===`all`||t.signature.includes(o)?t.members.length:0),0);r.set(o,s)}return r}function An(e,t,n,r){let i=r.trim().toLowerCase(),a=e.filter(e=>i===``||e.id.toLowerCase().includes(i));if(t.length===0)return a;let o=new Set(nn(a.map(e=>({id:e.id,tags:e.node.tags})),t,n).flatMap(e=>e.members.map(e=>e.id)));return a.filter(e=>o.has(e.id))}function jn(e,t){let n=Object.entries(t).map(([e,t])=>({id:e,dependsOn:t.detail.dependsOn})),r=e=>{let n=t[e];return n!=null&&bn(n.state)};return{starts:e.filter(e=>!r(e)),alreadyRunning:e.filter(r),dependencies:[...ln(n,e)].filter(t=>!e.includes(t)).sort()}}function Mn(e,t){let n=Object.entries(t).map(([e,t])=>({id:e,dependsOn:t.detail.dependsOn})),r=e=>bn(t[e]?.state??``),{stop:i,kept:a}=un(n,e,r);return{stops:i.filter(r),kept:a}}function Nn(e,t){let n=Object.entries(t).map(([e,t])=>({id:e,dependsOn:t.detail.dependsOn}));return n.filter(({id:n})=>!e.includes(n)&&bn(t[n]?.state??``)).filter(({id:t})=>e.some(e=>ln(n,[t]).has(e))).map(({id:e})=>e)}function Pn(e){let t=new Map;for(let n of Object.values(e))if(n.endedAt==null)for(let e of Object.keys(n.members))t.set(e,n.suite??`tag group`);return t}function Fn(e,t){return Tn(an(e,t.map(e=>({row:e,tags:e.node.tags,optIn:e.node.optIn}))).map(e=>e.row))}function In(e){return e.name==null?(e.bucket??e.terms).map(e=>e.slice(e.indexOf(`=`)+1)).join(` · `):e.name}function Ln(e,t){return e.detail.endpoints.map(e=>{let n=e.host===`127.0.0.1`||e.host===`localhost`,r=e.url!=null&&t;return{name:e.name,label:`${e.protocol}:${e.port}`,...r?{href:e.url}:{},remote:!t&&n}})}function Rn(e){return e===`127.0.0.1`||e===`localhost`||e===`[::1]`}function zn(e,t){let n=e.map(e=>t[e]?yn(t[e]).label:`not-started`);return n.length===0?`stopped`:e.some(e=>t[e]&&yn(t[e]).indicator===`failure`)?`failed`:n.filter(e=>_n(e)!==`idle`).length===0?`stopped`:n.some(e=>e===`starting`)?`starting`:n.filter(e=>e===`ready`||e===`succeeded`).length===n.length?`ready`:`partial`}function Bn(e,t){if(e.length===0)return null;let n=e.map(e=>t[e]);return n.every(e=>e!=null&&e.kind===`task`)?e.map((e,t)=>{let r=n[t],i=yn(r);return i.indicator===`success`?{id:e,verdict:`pass`}:i.indicator===`failure`?{id:e,verdict:`fail`}:r.state===`blocked`?{id:e,verdict:`blocked`}:bn(r.state)?{id:e,verdict:`running`}:r.state===`stopped`?{id:e,verdict:`stopped`}:{id:e,verdict:`pending`}}):null}function Vn({rows:e}){let t={running:0,success:0,failure:0,warning:0,transition:0,idle:0};for(let n of e)t[yn(n.node).indicator]+=1;let n=e.filter(e=>e.stickyOverrides.length>0).length;return(0,M.jsxs)(`section`,{className:`nc-overview nc-chrome`,"aria-label":`visible process overview`,children:[(0,M.jsxs)(`div`,{className:`nc-overview-heading`,children:[(0,M.jsx)(`span`,{className:`nc-section-title`,children:`process overview`}),(0,M.jsxs)(`span`,{children:[e.length,` visible`]})]}),(0,M.jsxs)(`div`,{className:`nc-overview-counts`,children:[(0,M.jsxs)(`span`,{children:[(0,M.jsx)(`strong`,{children:t.running}),` running`]}),(0,M.jsxs)(`span`,{children:[(0,M.jsx)(`strong`,{children:t.success}),` passed`]}),(0,M.jsxs)(`span`,{"data-attention":t.failure>0,children:[(0,M.jsx)(`strong`,{children:t.failure}),` failed`]}),(0,M.jsxs)(`span`,{children:[(0,M.jsx)(`strong`,{children:t.idle}),` idle`]})]}),n>0&&(0,M.jsxs)(`p`,{className:`nc-overview-attention`,"data-sticky-count":n,children:[n,` carrying sticky env — applies to every start until cleared`]}),(t.warning>0||t.transition>0)&&(0,M.jsxs)(`p`,{className:`nc-overview-attention`,children:[t.transition,` starting / stopping · `,t.warning,` need attention`]}),(0,M.jsxs)(`details`,{className:`nc-state-legend`,children:[(0,M.jsx)(`summary`,{children:`status guide`}),(0,M.jsx)(`p`,{children:`● Pulsing green: running or ready. ✓ Green ring: completed successfully. × Red ring: failed, crashed or timed out.`}),(0,M.jsx)(`p`,{children:`! Amber: unready, retrying or blocked. Blue ring: starting or stopping. Muted ring: not started or deliberately stopped.`})]})]})}function Hn(e,t){let n=e.toLowerCase(),r=t.trim().toLowerCase();if(r===``)return 0;let i=n.indexOf(r);if(i>=0)return i;let a=100,o=0;for(let e of r){let t=n.indexOf(e,o);if(t<0)return null;a+=t-o,o=t+1}return a}function Un(e,t,n=12){return e.flatMap((e,n)=>{let r=Hn(e.label,t);return r==null?[]:[{entry:e,score:r,index:n}]}).sort((e,t)=>e.score-t.score||e.index-t.index).slice(0,n).map(e=>e.entry)}function Wn({open:e,onClose:t,entries:n}){let[r,i]=(0,d.useState)(``),[a,o]=(0,d.useState)(0),s=(0,d.useRef)(null),c=(0,d.useMemo)(()=>Un(n,r),[n,r]);(0,d.useEffect)(()=>{if(!e)return;i(``),o(0);let t=requestAnimationFrame(()=>s.current?.focus());return()=>cancelAnimationFrame(t)},[e]);let l=e=>{e!=null&&(t(),e.run())};return(0,M.jsxs)(gt,{open:e,onClose:t,title:`go to…`,description:`Processes, tags, suites and pins — Enter picks, arrows move.`,children:[(0,M.jsx)(`input`,{ref:s,value:r,"aria-label":`command palette`,placeholder:`type a process, tag, suite or pin…`,onChange:e=>{i(e.target.value),o(0)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;o(e=>(e+t+c.length)%Math.max(1,c.length))}else e.key===`Enter`&&(e.preventDefault(),l(c[a]))},className:`nc-palette-input`}),(0,M.jsxs)(`div`,{role:`listbox`,"aria-label":`matches`,className:`nc-palette-list`,children:[c.map((e,t)=>(0,M.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===a,"data-active":t===a,onMouseEnter:()=>o(t),onClick:()=>l(e),children:[(0,M.jsx)(`span`,{style:{color:N.textEmphasis},children:e.label}),(0,M.jsx)(`span`,{style:{color:N.textMuted,fontSize:11},children:e.hint})]},`${e.hint}:${e.label}`)),c.length===0&&(0,M.jsx)(`div`,{style:{color:N.textMuted,fontSize:12,padding:6},children:`nothing matches`})]})]})}function Gn(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e;return typeof t.text==`string`&&typeof t.seq==`number`}function Kn(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e;return typeof t.g==`number`&&typeof t.s==`number`&&typeof t.id==`string`&&Gn(t.line)}function qn(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!=`object`||!t||Array.isArray(t))return null;let n=t;if(n.k===`merged-gap`){let e=n.dropped;return typeof e==`number`?{k:`merged-gap`,dropped:e}:null}if(n.k===`merged`){let e=n.entries;return!Array.isArray(e)||!e.every(Kn)?null:n.reset===!0?{k:`merged`,reset:!0,entries:e}:{k:`merged`,entries:e}}if(n.k===`search-result`){let e=n.entries;return typeof n.id!=`string`||!Array.isArray(e)||!e.every(Kn)||typeof n.complete!=`boolean`||typeof n.scanned!=`number`?null:{k:`search-result`,id:n.id,entries:e,complete:n.complete,scanned:n.scanned}}let r=n.proc;if(typeof r!=`string`)return null;if(n.k===`gap`){let e=n.dropped;return typeof e==`number`?{k:`gap`,proc:r,dropped:e}:null}if(n.k===`batch`){let e=n.lines;return!Array.isArray(e)||!e.every(Gn)?null:n.reset===!0?{k:`batch`,proc:r,reset:!0,lines:e}:{k:`batch`,proc:r,lines:e}}return null}var Jn=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)|\x1b[[(][0-9;?]*[A-Za-z]/g,Yn=/^\x1b\[([0-9;]*)m$/,Xn=gn.slice(0,8),Zn=gn.slice(8);function Qn(e){let t={};return e.color!=null&&(t.color=e.color),e.background!=null&&(t.backgroundColor=e.background),e.bold===!0&&(t.fontWeight=`600`),e.dim===!0&&(t.opacity=`0.65`),e.italic===!0&&(t.fontStyle=`italic`),e.underline===!0&&(t.textDecoration=`underline`),t}function $n(e,t){let n={...e},r=t===``?[`0`]:t.split(`;`);for(let e=0;e<r.length;e+=1){let t=Number(r[e]);if(Number.isFinite(t)){if(t===0)for(let e of Object.keys(n))delete n[e];else if(t===1)n.bold=!0;else if(t===2)n.dim=!0;else if(t===3)n.italic=!0;else if(t===4)n.underline=!0;else if(t===22)n.bold=!1,n.dim=!1;else if(t===23)n.italic=!1;else if(t===24)n.underline=!1;else if(t>=30&&t<=37)n.color=Xn[t-30];else if(t===39)delete n.color;else if(t>=40&&t<=47)n.background=Xn[t-40];else if(t===49)delete n.background;else if(t>=90&&t<=97)n.color=Zn[t-90];else if(t>=100&&t<=107)n.background=Zn[t-100];else if((t===38||t===48)&&r[e+1]===`5`){let i=er(Number(r[e+2]));i!=null&&(t===38?n.color=i:n.background=i),e+=2}else if((t===38||t===48)&&r[e+1]===`2`){let[i,a,o]=[Number(r[e+2]),Number(r[e+3]),Number(r[e+4])];if([i,a,o].every(e=>Number.isFinite(e)&&e>=0&&e<=255)){let e=`rgb(${i},${a},${o})`;t===38?n.color=e:n.background=e}e+=4}}}return n}function er(e){if(!Number.isFinite(e)||e<0||e>255)return null;if(e<8)return Xn[e]??null;if(e<16)return Zn[e-8]??null;if(e<232){let t=e=>e===0?0:55+e*40,n=e-16;return`rgb(${t(Math.floor(n/36))},${t(Math.floor(n/6)%6)},${t(n%6)})`}let t=8+(e-232)*10;return`rgb(${t},${t},${t})`}function tr(e){let t=[],n={},r=0;for(Jn.lastIndex=0;;){let i=Jn.exec(e);if(i==null)break;i.index>r&&t.push({text:e.slice(r,i.index),style:Qn(n)});let a=Yn.exec(i[0]);a!=null&&(n=$n(n,a[1]??``)),r=i.index+i[0].length}return r<e.length&&t.push({text:e.slice(r),style:Qn(n)}),t.length>0?t:[{text:``,style:{}}]}var nr=/\bhttps?:\/\/[^\s"'<>]+/g,rr=/[.,;:!?]+$/;function ir(e,t){let n=[],r=0;for(let i of e.matchAll(nr)){let a=ar(i[0]);if(a===``)continue;let o=i.index;!t.allowLoopback&&sr(a)||(o>r&&n.push({kind:`text`,text:e.slice(r,o)}),n.push({kind:`link`,text:a,href:a}),r=o+a.length)}return n.length===0?[{kind:`text`,text:e}]:(r<e.length&&n.push({kind:`text`,text:e.slice(r)}),n)}function ar(e){let t=e.replace(rr,``);for(;;){let e=t.at(-1)??``,n=e===`)`?`(`:e===`]`?`[`:null;if(n==null||t.split(n).length>=t.split(e).length)return t;t=t.slice(0,-1)}}function or(e,t){let n=e.map(e=>e.text).join(``),r=[],i=0;for(let t of e)r.push(i),i+=t.text.length;let a=[],o=0;for(let i of ir(n,t)){let t=o,n=o+i.text.length;o=n;let s=0;for(;s<e.length&&r[s]+e[s].text.length<=t;)s+=1;let c=[];for(;s<e.length&&r[s]<n;){let a=r[s]+e[s].text.length,o=i.text.slice(Math.max(t,r[s])-t,Math.min(n,a)-t);o.length>0&&c.push({text:o,style:e[s].style}),s+=1}if(i.kind===`link`)a.push({kind:`link`,href:i.href,pieces:c});else for(let e of c)a.push({kind:`text`,text:e.text,style:e.style})}return a}function sr(e){try{let t=new URL(e).hostname;return t===`localhost`||t===`127.0.0.1`||t===`0.0.0.0`||t===`[::1]`}catch{return!1}}var cr=5e3;function lr(e,t,n,r){if(e.kind===`proc`){if(r.k===`gap`&&r.proc===e.id)return{rows:hr(t,[gr(t.length,r.dropped)]),cursor:n};if(r.k!==`batch`||r.proc!==e.id)return null;let i=r.lines.map(e=>({key:`${e.seq}-${e.stream}`,text:e.text,gap:!1,ts:e.ts})),a=r.lines[r.lines.length-1]?.seq,o=r.reset===!0?a:Math.max(n.seq??0,a??0)||void 0;return{rows:r.reset===!0?i.slice(-5e3):hr(t,i),cursor:o==null?{}:{seq:o}}}if(r.k===`merged-gap`)return{rows:hr(t,[gr(t.length,r.dropped)]),cursor:n};if(r.k!==`merged`)return null;let i=r.entries.map(dr),a=r.entries[r.entries.length-1]?.s,o=r.reset===!0?a:Math.max(n.s??0,a??0)||void 0;return{rows:r.reset===!0?i.slice(-5e3):hr(t,i),cursor:o==null?{}:{s:o}}}function ur(e){return e.kind===`proc`?`proc:${e.id}`:`merged:${e.procs?.join(`,`)??`*`}`}function dr(e){return{key:`${e.g}-${e.s}`,prefix:e.id,text:e.line.text,gap:!1,ts:e.line.ts}}function fr(e,t){return e.kind===`proc`?JSON.stringify({k:`sub`,proc:e.id,fromSeq:t.seq}):JSON.stringify({k:`sub-merged`,...e.procs==null?{}:{procs:e.procs},fromS:t.s})}function pr(e){return JSON.stringify(e.kind===`proc`?{k:`unsub`,proc:e.id}:{k:`unsub-merged`})}function mr(e,t){return e.kind===`proc`?t.k===`batch`&&t.proc===e.id&&t.reset===!0:t.k===`merged`&&t.reset===!0}function hr(e,t){let n=[...e,...t];return n.length>5e3?n.slice(n.length-cr):n}function gr(e,t){return{key:`gap-${e}`,text:`… ${t} lines dropped …`,gap:!0}}function _r(e,t,n){let r=new Set;if(e.kind===`proc`){if(n.keepProcs.has(e.id))for(let e of t.filter(e=>!e.gap).slice(-12))r.add(e.key)}else{let e=new Map;for(let n of t){if(n.gap||n.prefix==null)continue;let t=e.get(n.prefix)??[];t.push(n),e.set(n.prefix,t)}for(let[t,i]of e)if(n.keepProcs.has(t))for(let e of i.slice(-12))r.add(e.key)}let i=t.filter(e=>r.has(e.key)),a=t.length-i.length,o=new Date(n.now),s=String(o.getHours()).padStart(2,`0`),c=String(o.getMinutes()).padStart(2,`0`),l=i.length===0?``:e.kind===`proc`?` · kept the last ${i.length} line${i.length===1?``:`s`}`:` · kept ${i.length} lines from ${new Set(i.map(e=>e.prefix)).size} running processes`;return{rows:[...i,{key:`cleared-${n.now}`,text:`— cleared ${s}:${c}${l} · nothing was deleted; search covers the full history —`,gap:!0}],kept:i.length,dropped:a}}function vr(e){if(typeof e!=`object`||!e)return`expected an object`;let t={...e};return!Array.isArray(t.ids)||!t.ids.every(e=>typeof e==`string`&&e.length>0)?`expected ids`:t.token!=null&&(typeof t.token!=`string`||!t.token)?`expected token`:t.force!=null&&typeof t.force!=`boolean`?`expected force boolean`:t.force&&!t.token?`force requires a listener token`:{ids:t.ids,...typeof t.token==`string`?{token:t.token}:{},...typeof t.force==`boolean`?{force:t.force}:{}}}function yr(e){if(typeof e!=`object`||!e)return`expected an object`;let t={...e};if(!Array.isArray(t.warnings)||!t.warnings.every(e=>typeof e==`string`)||!Array.isArray(t.listeners))return`expected listeners and warnings`;let n=[];for(let e of t.listeners){if(typeof e!=`object`||!e)return`invalid listener`;let t={...e};if(![t.id,t.endpoint,t.host,t.command].every(e=>typeof e==`string`)||!Number.isInteger(t.pid)||Number(t.pid)<1||!Number.isInteger(t.port)||Number(t.port)<1||Number(t.port)>65535||!(t.ppid===null||Number.isInteger(t.ppid)&&Number(t.ppid)>=0)||!(t.cwd===null||typeof t.cwd==`string`)||![t.startStamp,t.token,t.refusal].every(e=>e===null||typeof e==`string`))return`invalid listener`;n.push(e)}return{listeners:n,warnings:t.warnings}}var br=function(e){return e.duplex=`duplex`,e.exchange=`exchange`,e}({}),xr=function(e){return e.uninitialized=`uninitialized`,e.unsupported=`unsupported`,e.initializing=`initializing`,e.ready=`ready`,e.failed=`failed`,e}({}),Sr=ue.createChildDomain({domain:`err_nice_wire_connect`,schema:{connect_exhausted:k({message:({peerId:e,attempted:t})=>`connect() to peer [${e}] exhausted its transport chain (tried: ${t.join(`, `)||`none configured`}).`}),connect_closed:k({message:({peerId:e})=>`connect() to peer [${e}] on a closed WireClient — closed is terminal; create a new client.`}),dial_failed:k({message:({peerId:e,carrierLabel:t,reason:n,endpoint:r})=>`Dialing peer [${e}] over "${t}"${r==null?``:` against ${r}`} failed: ${n}`}),dial_unavailable:k({message:({carrierLabel:e})=>`Dial over "${e}" unavailable — createRequest returned null (no valid endpoint right now). A keep-alive redial parks on this until the next explicit connect()/dispatch.`}),conflicting_connect_options:k({message:({detail:e})=>`Conflicting connection options: ${e}`}),endpoint_answered_non_protocol:k({message:({stage:e,expected:t,url:n,httpStatus:r,contentType:i,receivedKind:a,bodyPreview:o})=>{let s=r==null?a==null?`a response it could not decode`:`a "${a}" frame`:`an HTTP ${r}${i==null?``:` ${i}`} response`;return`[${e}] expected ${t??`a nice-wire frame`} but received ${s} — the endpoint answered but is not speaking the nice-wire protocol (wrong URL, an intercepting proxy/WAF, or a different server)${n==null?``:`. Dialed: ${n}`}${o==null?``:`. Body: ${JSON.stringify(o)}`}.`}}),endpoint_unreachable:k({message:({url:e,carrierLabel:t,reason:n})=>`Could not reach ${e??(t==null?`the endpoint`:`the "${t}" endpoint`)}: ${n} — nothing answered there (wrong host/port, the server is not running, or a firewall/offline network).`}),handshake_rejected:k({message:({stage:e,reason:t})=>`[${e}] rejected by peer: ${t}`}),protocol_version_mismatch:k({message:({reason:e,observedProtocolVersion:t,localSupportedProtocolVersions:n,remoteSupportedProtocolVersions:r})=>`Handshake protocol version mismatch: ${e}. Local support: [${n.join(`, `)}]${r==null?``:`; remote support: [${r.join(`, `)}]`}${t==null?``:`; observed version: ${t}`}. Carrier fallback and automatic redial are parked until an explicit retry.`}),peer_identity_mismatch:k({message:({expected:e,actual:t,endpoint:n})=>`Secure peer identity mismatch: expected envId=${JSON.stringify(e.envId)}${e.perId==null?``:`, perId=${JSON.stringify(e.perId)}`}; received envId=${JSON.stringify(t.envId)}${t.perId==null?``:`, perId=${JSON.stringify(t.perId)}`}. ${n==null?``:`Dialed ${n}. `}Carrier fallback and automatic redial are parked until an explicit retry.`}),protocol_unsupported:k({message:({protocolId:e})=>`Protocol "${e}" cannot speak on this connection — the peer did not advertise "proto:${e}" (or it is not registered here).`}),protocol_on_exchange_only:k({message:({protocolId:e})=>`Protocol "${e}" needs a duplex transport — this connection is exchange-only (request/reply), which carries only the lane.`}),protocol_security_blocked:k({message:({protocolId:e,securityLevel:t})=>`Protocol "${e}" frame blocked: connection is at security level "${t}" and the protocol did not opt into allowPlain.`}),binding_version_mismatch:k({message:({found:e,expected:t})=>`Persisted connection binding has schema version ${JSON.stringify(e)} (this build reads v${t}) — the binding is invalidated; the connection must re-handshake.`}),identity_pin_mismatch:k({message:({reason:e})=>`Handshake rejected by peer: ${e}. The peer has a different verify key pinned for this client identity (TOFU) — permanent until the client connects under a new persistent id or the peer's pin is removed; auto-redial parks on this.`})}});function Cr(e,t){if(typeof t==`string`||t instanceof ArrayBuffer){e.send(t);return}e.send(new Uint8Array(t))}function wr(e){try{let t=new URL(e);return`${t.host}${t.pathname}`}catch{return e}}function Tr(e){let t=!1,n=e.readyState===WebSocket.OPEN,r,i,a=[],o=e=>{r==null?a.push(e):r(e)};return e.addEventListener(`open`,()=>{n=!0}),e.addEventListener(`message`,async e=>{let t=await kr(e.data);t!==void 0&&o(t)}),e.addEventListener(`close`,e=>{n&&!t&&console.warn(`WebSocket closed:`,e),i?.()}),e.addEventListener(`error`,()=>{n&&console.warn(`WebSocket error: ${Or(e)}`),i?.()}),{ready:new Promise((t,n)=>{if(e.readyState===WebSocket.OPEN){t();return}e.addEventListener(`open`,()=>t(),{once:!0}),e.addEventListener(`error`,()=>n(Er(e)),{once:!0}),e.addEventListener(`close`,t=>n(Dr(e,`WebSocket closed before open (code=${t.code})`)),{once:!0})}),isOpen:()=>e.readyState===WebSocket.OPEN,send:t=>Cr(e,t),attach:e=>{r=e.onMessage,i=e.onClose;for(let t of a)e.onMessage(t);a.length=0},close:()=>{t=!0;try{e.close()}catch{}},get label(){return e.url!=null&&e.url!==``?e.url:void 0}}}function Er(e){return Dr(e,`WebSocket dial failed`)}function Dr(e,t){return Sr.fromId(`endpoint_unreachable`,{url:e.url!=null&&e.url!==``?e.url:void 0,carrierLabel:`ws`,reason:t})}function Or(e){return e.url!=null&&e.url!==``?e.url:`(no url)`}async function kr(e){if(typeof e==`string`||e instanceof ArrayBuffer||e instanceof Uint8Array)return e;if(typeof Blob<`u`&&e instanceof Blob)return await e.arrayBuffer()}function Ar(e,t={}){let n=t=>{let n=typeof e==`string`?e:e(t);return n==null?null:typeof n==`string`?{url:n}:n},r=t.createWebSocket??(e=>new WebSocket(e));return{secure:t.secure,carrierLabel:`ws`,open:e=>{let t=n(e);if(t==null)throw Sr.fromId(`dial_unavailable`,{carrierLabel:`ws`});let i=r(t.url);return i.binaryType=`arraybuffer`,Tr(i)},getCacheKey:t.getCacheKey??(e=>[n(e)?.url??`ws:(unavailable)`]),getRouteInfo:t.getRouteInfo??(e=>{let t=n(e)?.url;return t==null?{carrierLabel:`ws`,summary:`ws (unavailable)`}:{carrierLabel:`ws`,url:t,summary:`ws ${wr(t)}`}})}}var jr=200;function Mr(e){return Array.from(e,e=>{let t=e.codePointAt(0);return t<=31||t>=127&&t<=159?` `:e}).join(``)}function Nr(e){if(typeof e!=`string`)return;let t=Mr(e).replace(/\s+/g,` `).trim();if(t.length!==0)return t.length>jr?`${t.slice(0,jr)}…`:t}function Pr(e){if(e!=null)try{let t=new URL(e);return t.username=``,t.password=``,t.search=``,t.hash=``,t.toString()}catch{return e.split(/[?#]/,1)[0]}}function Fr(e){return Sr.isExact(e)?e.hasId(`endpoint_answered_non_protocol`)?`endpoint_answered_non_protocol`:e.hasId(`endpoint_unreachable`)?`endpoint_unreachable`:e.hasId(`protocol_version_mismatch`)?`protocol_version_mismatch`:e.hasId(`peer_identity_mismatch`)?`peer_identity_mismatch`:e.hasId(`identity_pin_mismatch`)||e.hasId(`handshake_rejected`)?`handshake_rejected`:`unknown`:`unknown`}function Ir(e){if(Sr.isExact(e)){if(e.hasId(`endpoint_answered_non_protocol`))return e.getContext(`endpoint_answered_non_protocol`).url;if(e.hasId(`endpoint_unreachable`))return e.getContext(`endpoint_unreachable`).url;if(e.hasId(`peer_identity_mismatch`))return e.getContext(`peer_identity_mismatch`).endpoint}}var Lr=class{_cache;_errors;_transports=[];constructor(e,t){this._cache=e,this._errors=t}addTransport(e){this._transports.push(e)}getPreferredTransport(){return this._transports[0]}async getReadyTransport(e){let t=[],n=[];for(let r of this._transports){if(!r.isAvailable(e)){n.push(r);continue}let i=r.getCacheKey(e);if(i!=null){let e=this._cache.get(i);if(e!=null){if(e instanceof Promise){t.push({transport:r,promise:e});continue}t.push({transport:r,promise:Promise.resolve({...e,transport:r})});break}}let a=r.getTransport(e);if(a.status===xr.ready){let e=a.readyData;if(i!=null){let t={methods:e,transport:r};this._cache.set(i,t),e.addOnDisconnectListener?.(()=>{this._cache.get(i)===t&&this._cache.delete(i)})}t.push({transport:r,promise:Promise.resolve({methods:e,transport:r})});break}if(a.status===xr.unsupported){n.push(r);continue}if(a.status===xr.initializing){let e=a.initializationPromise.then(t=>{if(t.status===xr.failed)throw t.error;if(t.status===xr.unsupported)throw this._errors.unsupported([r.type]);let n=t.readyData,a={methods:n,transport:r};return i!=null&&(this._cache.get(i)===e?(this._cache.set(i,a),n.addOnDisconnectListener?.(()=>{this._cache.get(i)===a&&this._cache.delete(i)})):n.disconnect?.()),a}).catch(t=>{throw i!=null&&this._cache.get(i)===e&&this._cache.delete(i),t});i!=null&&this._cache.set(i,e),t.push({transport:r,promise:e})}}if(t.length===0)throw n.length>0?this._errors.unsupported(n.map(e=>e.type)):this._errors.notFound(e);let r,i;for(let n of t)try{return await n.promise}catch(t){if(Sr.isExact(t)&&t.hasId(`peer_identity_mismatch`)){let r=t.getContext(`peer_identity_mismatch`),i=Pr(n.transport.getRouteInfo(e)?.url);throw i!=null&&r.endpoint==null?Sr.fromId(`peer_identity_mismatch`,{...r,endpoint:i}).withOriginError(t):t}if(Sr.isExact(t)&&t.hasId(`protocol_version_mismatch`))throw t;r=t,i=n.transport}throw Sr.isExact(r)&&(r.hasId(`dial_unavailable`)||r.hasId(`identity_pin_mismatch`)||r.hasId(`protocol_version_mismatch`)||r.hasId(`peer_identity_mismatch`))?r:this._errors.initializationFailed(e,{cause:Rr(r),endpoint:Ir(r)??i?.getRouteInfo(e)?.url,kind:Fr(r),origin:r})}};function Rr(e){if(e!=null)return e instanceof Error?e.message:typeof e==`string`?e:String(e)}var zr=e=>e!=null&&e.length>0,Br=async({privateKey:e,publicKey:t})=>new Uint8Array(await crypto.subtle.deriveBits({name:`X25519`,public:t},e,256)),Vr=`METEOR_BRIDGE_DEFAULT_INFO_STRING`,Hr=async({externalX25519PublicKey:e,internalX25519PrivateKey:t,infoString:n,saltString:r})=>{let i=await Br({privateKey:t,publicKey:e}),a=await crypto.subtle.importKey(`raw`,new Uint8Array(i),`HKDF`,!1,[`deriveKey`]),o=zr(r)?new TextEncoder().encode(r):new Uint8Array,s=new TextEncoder().encode(zr(n)?n:Vr);return await crypto.subtle.deriveKey({name:`HKDF`,hash:`SHA-256`,salt:o,info:s},a,{name:`AES-GCM`,length:256},!1,[`encrypt`,`decrypt`])},Ur=async({aesGcmKey:e,dataToDecrypt:t})=>{let n=await crypto.subtle.decrypt({name:`AES-GCM`,iv:new Uint8Array(t.nonce)},e,new Uint8Array(t.ciphertext));return new Uint8Array(n)};function Wr(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}function Gr(e){if(!Wr(e))throw TypeError(`Uint8Array expected`)}function Kr(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(e=>typeof e==`string`):t.every(e=>Number.isSafeInteger(e)):!1}function qr(e){if(typeof e!=`function`)throw TypeError(`function expected`);return!0}function Jr(e,t){if(typeof t!=`string`)throw TypeError(`${e}: string expected`);return!0}function Yr(e){if(typeof e!=`number`)throw TypeError(`number expected, got ${typeof e}`);if(!Number.isSafeInteger(e))throw RangeError(`invalid integer: ${e}`)}function Xr(e){if(!Array.isArray(e))throw TypeError(`array expected`)}function Zr(e,t){if(!Kr(!0,t))throw TypeError(`${e}: array of strings expected`)}function Qr(e,t){if(!Kr(!1,t))throw TypeError(`${e}: array of numbers expected`)}function $r(...e){let t=e=>e,n=(e,t)=>n=>e(t(n));return{encode:e.map(e=>e.encode).reduceRight(n,t),decode:e.map(e=>e.decode).reduce(n,t)}}function ei(e){let t=typeof e==`string`?e.split(``):e,n=t.length;Zr(`alphabet`,t);let r=new Map(t.map((e,t)=>[e,t]));return{encode:r=>(Xr(r),r.map(r=>{if(!Number.isSafeInteger(r)||r<0||r>=n)throw Error(`alphabet.encode: digit index outside alphabet "${r}". Allowed: ${e}`);return t[r]})),decode:t=>(Xr(t),t.map(t=>{Jr(`alphabet.decode`,t);let n=r.get(t);if(n===void 0)throw Error(`Unknown letter: "${t}". Allowed: ${e}`);return n}))}}function ti(e=``){return Jr(`join`,e),{encode:t=>(Zr(`join.decode`,t),t.join(e)),decode:t=>(Jr(`join.decode`,t),t.split(e))}}function ni(e,t=`=`){return Yr(e),Jr(`padding`,t),{encode(n){for(Zr(`padding.encode`,n);n.length*e%8;)n.push(t);return n},decode(n){Zr(`padding.decode`,n);let r=n.length;if(r*e%8)throw Error(`padding: invalid, string should have whole number of bytes`);for(;r>0&&n[r-1]===t;r--)if((r-1)*e%8==0)throw Error(`padding: invalid, string has too much padding`);return n.slice(0,r)}}}function ri(e){return qr(e),{encode:e=>e,decode:t=>e(t)}}var ii=(e,t)=>t===0?e:ii(t,e%t),ai=(e,t)=>e+(t-ii(e,t)),oi=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function si(e,t,n,r){if(Xr(e),t<=0||t>32)throw RangeError(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw RangeError(`convertRadix2: wrong to=${n}`);if(ai(t,n)>32)throw Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${ai(t,n)}`);let i=0,a=0,o=oi[t],s=oi[n]-1,c=[];for(let r of e){if(Yr(r),r>=o)throw Error(`convertRadix2: invalid data word=${r} from=${t}`);if(i=i<<t|r,a+t>32)throw Error(`convertRadix2: carry overflow pos=${a} from=${t}`);for(a+=t;a>=n;a-=n)c.push((i>>a-n&s)>>>0);let e=oi[a];if(e===void 0)throw Error(`invalid carry`);i&=e-1}if(i=i<<n-a&s,!r&&a>=t)throw Error(`Excess padding`);if(!r&&i>0)throw Error(`Non-zero padding: ${i}`);return r&&a>0&&c.push(i>>>0),c}function ci(e,t=!1){if(Yr(e),e<=0||e>32)throw RangeError(`radix2: bits should be in (0..32]`);if(ai(8,e)>32||ai(e,8)>32)throw RangeError(`radix2: carry overflow`);return{encode:n=>{if(!Wr(n))throw TypeError(`radix2.encode input should be Uint8Array`);return si(Array.from(n),8,e,!t)},decode:n=>(Qr(`radix2.decode`,n),Uint8Array.from(si(n,e,8,t)))}}function li(e){return qr(e),function(...t){try{return e.apply(null,t)}catch{}}}$r(ci(4),ei(`0123456789ABCDEF`),ti(``)),$r(ci(5),ei(`ABCDEFGHIJKLMNOPQRSTUVWXYZ234567`),ni(5),ti(``)),$r(ci(5),ei(`ABCDEFGHIJKLMNOPQRSTUVWXYZ234567`),ti(``)),$r(ci(5),ei(`0123456789ABCDEFGHIJKLMNOPQRSTUV`),ni(5),ti(``)),$r(ci(5),ei(`0123456789ABCDEFGHIJKLMNOPQRSTUV`),ti(``)),$r(ci(5),ei(`0123456789ABCDEFGHJKMNPQRSTVWXYZ`),ti(``),ri(e=>e.toUpperCase().replace(/O/g,`0`).replace(/[IL]/g,`1`)));var ui=typeof Uint8Array.from([]).toBase64==`function`&&typeof Uint8Array.fromBase64==`function`,di=/[\t\n\f\r ]/,fi=(e,t)=>{Jr(`base64`,e);let n=t?`base64url`:`base64`;if(e.length>0&&di.test(e))throw Error(`invalid base64`);return Uint8Array.fromBase64(e,{alphabet:n,lastChunkHandling:`strict`})},pi=Object.freeze(ui?{encode(e){return Gr(e),e.toBase64()},decode(e){return fi(e,!1)}}:$r(ci(6),ei(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`),ni(6),ti(``)));$r(ci(6),ei(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`),ti(``)),ui||$r(ci(6),ei(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`),ni(6),ti(``)),$r(ci(6),ei(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`),ti(``));var mi=$r(ei(`qpzry9x8gf2tvdw0s3jn54khce6mua7l`),ti(``)),hi=[996825010,642813549,513874426,1027748829,705979059];function gi(e){let t=e>>25,n=(e&33554431)<<5;for(let e=0;e<hi.length;e++)(t>>e&1)==1&&(n^=hi[e]);return n}function _i(e,t,n=1){let r=e.length,i=1;for(let t=0;t<r;t++){let n=e.charCodeAt(t);if(n<33||n>126)throw Error(`Invalid prefix (${e})`);i=gi(i)^n>>5}i=gi(i);for(let t=0;t<r;t++)i=gi(i)^e.charCodeAt(t)&31;for(let e of t)i=gi(i)^e;for(let e=0;e<6;e++)i=gi(i);return i^=n,mi.encode(si([i%oi[30]],30,5,!1))}function vi(e){let t=e===`bech32`?1:734539939,n=ci(5),r=n.decode,i=n.encode,a=li(r);function o(e,n,r=90){Jr(`bech32.encode prefix`,e),Wr(n)&&(n=Array.from(n)),Qr(`bech32.encode`,n);let i=e.length;if(i===0)throw TypeError(`Invalid prefix length ${i}`);let a=i+7+n.length;if(r!==!1&&a>r)throw TypeError(`Length ${a} exceeds limit ${r}`);let o=e.toLowerCase(),s=_i(o,n,t);return`${o}1${mi.encode(n)}${s}`}function s(e,n=90){Jr(`bech32.decode input`,e);let r=e.length;if(r<8||n!==!1&&r>n)throw TypeError(`invalid string length: ${r} (${e}). Expected (8..${n})`);let i=e.toLowerCase();if(e!==i&&e!==e.toUpperCase())throw Error(`String must be lowercase or uppercase`);let a=i.lastIndexOf(`1`);if(a===0||a===-1)throw Error(`Letter "1" must be present between prefix and data only`);let o=i.slice(0,a),s=i.slice(a+1);if(s.length<6)throw Error(`Data must be at least 6 characters long`);let c=mi.decode(s).slice(0,-6),l=_i(o,c,t);if(!s.endsWith(l))throw Error(`Invalid checksum in ${e}: expected "${l}"`);return{prefix:o,words:c}}let c=li(s);function l(e){let{prefix:t,words:n}=s(e,!1);return{prefix:t,words:n,bytes:r(n)}}function u(e,t){return o(e,i(t))}return{encode:o,decode:s,encodeFromBytes:u,decodeToBytes:l,decodeUnsafe:c,fromWords:r,fromWordsUnsafe:a,toWords:i}}vi(`bech32`),vi(`bech32m`),typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`||$r(ci(4),ei(`0123456789abcdef`),ti(``),ri(e=>{if(typeof e!=`string`||e.length%2!=0)throw TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()}));var yi=async({aesGcmKey:e,dataToDecrypt:t})=>{let n=await crypto.subtle.decrypt({name:`AES-GCM`,iv:new Uint8Array(pi.decode(t.nonce))},e,new Uint8Array(pi.decode(t.ciphertext)));return new TextDecoder().decode(n)},bi=async({aesGcmKey:e,dataToEncrypt:t})=>{let n=crypto.getRandomValues(new Uint8Array(12)),r=await crypto.subtle.encrypt({name:`AES-GCM`,iv:n},e,new Uint8Array(t));return{nonce:n,ciphertext:new Uint8Array(r)}},xi=async({aesGcmKey:e,dataToEncrypt:t})=>{let n=crypto.getRandomValues(new Uint8Array(12)),r=await crypto.subtle.encrypt({name:`AES-GCM`,iv:n},e,new TextEncoder().encode(t));return{nonce:pi.encode(n),ciphertext:pi.encode(new Uint8Array(r))}};function Si(e){return Ci(e,`$`,new Set)}function Ci(e,t,n){if(e===null)return`null`;switch(typeof e){case`string`:return JSON.stringify(e);case`boolean`:return e?`true`:`false`;case`number`:if(!Number.isFinite(e))throw Error(`stringifyCanonicalJson: non-finite number at ${t}`);return JSON.stringify(e);case`undefined`:case`bigint`:case`function`:case`symbol`:throw Error(`stringifyCanonicalJson: unsupported ${typeof e} at ${t}`);default:break}let r=e;if(n.has(r))throw Error(`stringifyCanonicalJson: circular reference at ${t}`);n.add(r);try{if(Array.isArray(r)){let e=`[`;for(let i=0;i<r.length;i++)i>0&&(e+=`,`),e+=i in r?Ci(r[i],`${t}[${i}]`,n):`null`;return`${e}]`}let e=r,i=Object.keys(e).sort(),a=[];for(let r of i){let i=e[r];i!==void 0&&a.push(`${JSON.stringify(r)}:${Ci(i,`${t}.${r}`,n)}`)}return`{${a.join(`,`)}}`}finally{n.delete(r)}}function wi(e){if(typeof e.domainTag!=`string`||e.domainTag.length===0)throw Error(`buildCanonicalChallenge: domainTag must be a non-empty string`);if(typeof e.version!=`number`||!Number.isSafeInteger(e.version)||e.version<1)throw Error(`buildCanonicalChallenge: version must be a positive safe integer`);if(!Ti(e.fields))throw Error(`buildCanonicalChallenge: fields must be a plain object`);for(let[t,n]of Object.entries(e.fields))Ei(n,`fields.${t}`);return Si({domainTag:e.domainTag,version:e.version,fields:e.fields})}function Ti(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Ei(e,t){if(e===void 0)throw Error(`buildCanonicalChallenge: undefined entry at ${t}`);if(!(e===null||typeof e==`string`||typeof e==`boolean`)){if(typeof e==`number`){if(!Number.isFinite(e))throw Error(`buildCanonicalChallenge: non-finite number at ${t}`);return}if(Array.isArray(e)){for(let n=0;n<e.length;n++){if(!(n in e))throw Error(`buildCanonicalChallenge: sparse array hole at ${t}[${n}]`);Ei(e[n],`${t}[${n}]`)}return}if(Ti(e)){for(let[n,r]of Object.entries(e)){if(r===void 0)throw Error(`buildCanonicalChallenge: undefined entry at ${t}.${n}`);Ei(r,`${t}.${n}`)}return}throw Error(`buildCanonicalChallenge: unsupported value at ${t} — strict JSON values only (null, boolean, finite number, string, dense array, plain object)`)}}function Di(e){return pi.encode(e)}function Oi(e){return pi.decode(e)}var ki=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function Ai(e,t){return e>>>t|e<<32-t}function ji(e){let t=typeof e==`string`?new TextEncoder().encode(e):e,n=t.length*8,r=(t.length+8>>6)+1<<6,i=new Uint8Array(r);i.set(t),i[t.length]=128;let a=new DataView(i.buffer);a.setUint32(r-8,Math.floor(n/4294967296),!1),a.setUint32(r-4,n>>>0,!1);let o=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),s=new Uint32Array(64);for(let e=0;e<r;e+=64){for(let t=0;t<16;t++)s[t]=a.getUint32(e+t*4,!1);for(let e=16;e<64;e++){let t=Ai(s[e-15],7)^Ai(s[e-15],18)^s[e-15]>>>3,n=Ai(s[e-2],17)^Ai(s[e-2],19)^s[e-2]>>>10;s[e]=s[e-16]+t+s[e-7]+n>>>0}let t=o[0],n=o[1],r=o[2],i=o[3],c=o[4],l=o[5],u=o[6],d=o[7];for(let e=0;e<64;e++){let a=Ai(c,6)^Ai(c,11)^Ai(c,25),o=c&l^~c&u,f=d+a+o+ki[e]+s[e]>>>0,p=(Ai(t,2)^Ai(t,13)^Ai(t,22))+(t&n^t&r^n&r)>>>0;d=u,u=l,l=c,c=i+f>>>0,i=r,r=n,n=t,t=f+p>>>0}o[0]=o[0]+t>>>0,o[1]=o[1]+n>>>0,o[2]=o[2]+r>>>0,o[3]=o[3]+i>>>0,o[4]=o[4]+c>>>0,o[5]=o[5]+l>>>0,o[6]=o[6]+u>>>0,o[7]=o[7]+d>>>0}let c=new Uint8Array(32),l=new DataView(c.buffer);for(let e=0;e<8;e++)l.setUint32(e*4,o[e],!1);return c}function Mi(e){let t=ji(e),n=``;for(let e of t)n+=e.toString(16).padStart(2,`0`);return n}var Ni=async(e,t)=>{let n=new TextEncoder().encode(e),r=await crypto.subtle.sign({name:`ED25519`},t,n);return new Uint8Array(r)},Pi=async(e,t,n=`::`)=>await Ni(e.join(n),t),Fi=({infoString:e,verifyPublicKeys:t})=>{let n=[...t].sort();return[...e==null?[]:[e],...n].join(`::`)},Ii=class extends Error{key;issues;constructor(e,t){let n=t.map((e,t)=>{let n=e.path?.map(e=>String(typeof e==`object`?e.key:e)).join(`.`);return` (issue ${t+1})${n?` [${n}]`:``}: ${e.message}`}).join(`
17
+ `).replace(jd,``)}function Nd(e,t){return t=Md(t),Md(e)===t}function Pd(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||Xt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&Xt(e,``+r);break;case`className`:Pt(e,`class`,r);break;case`tabIndex`:Pt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Pt(e,n,r);break;case`style`:en(e,r,o);break;case`data`:if(t!==`object`){Pt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=an(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`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 o==`function`&&(n===`formAction`?(t!==`input`&&Pd(e,t,`name`,a.name,a,null),Pd(e,t,`formEncType`,a.formEncType,a,null),Pd(e,t,`formMethod`,a.formMethod,a,null),Pd(e,t,`formTarget`,a.formTarget,a,null)):(Pd(e,t,`encType`,a.encType,a,null),Pd(e,t,`method`,a.method,a,null),Pd(e,t,`target`,a.target,a,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=an(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=on);break;case`onScroll`:r!=null&&Z(`scroll`,e);break;case`onScrollEnd`:r!=null&&Z(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=an(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);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`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:Z(`beforetoggle`,e),Z(`toggle`,e),Nt(e,`popover`,r);break;case`xlinkActuate`:Ft(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Ft(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Ft(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Ft(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Ft(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Ft(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Ft(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Ft(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Ft(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Nt(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=nn.get(n)||n,Nt(e,n,r))}}function Fd(e,t,n,r,a,o){switch(n){case`style`:en(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?Xt(e,r):(typeof r==`number`||typeof r==`bigint`)&&Xt(e,``+r);break;case`onScroll`:r!=null&&Z(`scroll`,e);break;case`onScrollEnd`:r!=null&&Z(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=on);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!Et.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),t=n.slice(2,a?n.length-7:void 0),o=e[ft]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,a),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):Nt(e,n,r)}}}function Id(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:Z(`error`,e),Z(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Pd(e,t,o,s,n,null)}}a&&Pd(e,t,`srcSet`,n.srcSet,n,null),r&&Pd(e,t,`src`,n.src,n,null);return;case`input`:Z(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:Pd(e,t,r,d,n,null)}}Gt(e,o,c,l,u,s,a,!1);return;case`select`:for(a in Z(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:Pd(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&qt(e,!!r,n,!0):qt(e,!!r,t,!1);return;case`textarea`:for(s in Z(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:Pd(e,t,s,c,n,null)}Yt(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:Pd(e,t,l,r,n,null)}return;case`dialog`:Z(`beforetoggle`,e),Z(`toggle`,e),Z(`cancel`,e),Z(`close`,e);break;case`iframe`:case`object`:Z(`load`,e);break;case`video`:case`audio`:for(r=0;r<vd.length;r++)Z(vd[r],e);break;case`image`:Z(`error`,e),Z(`load`,e);break;case`details`:Z(`toggle`,e);break;case`embed`:case`source`:case`link`:Z(`error`,e),Z(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Pd(e,t,u,r,n,null)}return;default:if(tn(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Fd(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Pd(e,t,c,r,n,null))}function Ld(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||Pd(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:a=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&Pd(e,t,p,m,r,f)}}Wt(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||Pd(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&Pd(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?qt(e,!!n,n?[]:``,!1):qt(e,!!n,t,!0)):qt(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:Pd(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:p=a;break;case`defaultValue`:m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&Pd(e,t,s,a,r,o)}Jt(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:Pd(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:Pd(e,t,l,p,r,m)}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 g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&Pd(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:Pd(e,t,u,p,r,m)}return;default:if(tn(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Fd(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Fd(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Pd(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||Pd(e,t,f,p,r,m)}function Rd(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function zd(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&Rd(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&Rd(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var Bd=null,Vd=null;function Hd(e){return e.nodeType===9?e:e.ownerDocument}function Ud(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Wd(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function Gd(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Kd=null;function qd(){var e=window.event;return e&&e.type===`popstate`?e===Kd?!1:(Kd=e,!0):(Kd=null,!1)}var Jd=typeof setTimeout==`function`?setTimeout:void 0,Yd=typeof clearTimeout==`function`?clearTimeout:void 0,Xd=typeof Promise==`function`?Promise:void 0,Zd=typeof queueMicrotask==`function`?queueMicrotask:Xd===void 0?Jd:function(e){return Xd.resolve(null).then(e).catch(Qd)};function Qd(e){setTimeout(function(){throw e})}function $d(e){return e===`head`}function ef(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Fp(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)hf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,hf(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[vt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&hf(e.ownerDocument.body);n=i}while(n);Fp(t)}function tf(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8)if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++;n=r}while(n)}function nf(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:nf(n),yt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function rf(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r)if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e;else if(!e[vt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=uf(e.nextSibling),e===null)break}return null}function af(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=uf(e.nextSibling),e===null))return null;return e}function of(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=uf(e.nextSibling),e===null))return null;return e}function sf(e){return e.data===`$?`||e.data===`$~`}function cf(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function lf(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function uf(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var df=null;function ff(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return uf(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function pf(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function mf(e,t,n){switch(t=Hd(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function hf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);yt(e)}var gf=new Map,_f=new Set;function vf(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var yf=O.d;O.d={f:bf,r:xf,D:wf,C:Tf,L:Ef,m:Df,X:kf,S:Of,M:Af};function bf(){var e=yf.f(),t=bu();return e||t}function xf(e){var t=xt(e);t!==null&&t.tag===5&&t.type===`form`?Es(t):yf.r(e)}var Sf=typeof document>`u`?null:document;function Cf(e,t,n){var r=Sf;if(r&&typeof t==`string`&&t){var i=Ut(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),_f.has(i)||(_f.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Id(t,`link`,e),wt(t),r.head.appendChild(t)))}}function wf(e){yf.D(e),Cf(`dns-prefetch`,e,null)}function Tf(e,t){yf.C(e,t),Cf(`preconnect`,e,t)}function Ef(e,t,n){yf.L(e,t,n);var r=Sf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Ut(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Ut(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Ut(n.imageSizes)+`"]`)):i+=`[href="`+Ut(e)+`"]`;var a=i;switch(t){case`style`:a=Mf(e);break;case`script`:a=If(e)}gf.has(a)||(e=p({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),gf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Nf(a))||t===`script`&&r.querySelector(Lf(a))||(t=r.createElement(`link`),Id(t,`link`,e),wt(t),r.head.appendChild(t)))}}function Df(e,t){yf.m(e,t);var n=Sf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Ut(r)+`"][href="`+Ut(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=If(e)}if(!gf.has(a)&&(e=p({rel:`modulepreload`,href:e},t),gf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Lf(a)))return}r=n.createElement(`link`),Id(r,`link`,e),wt(r),n.head.appendChild(r)}}}function Of(e,t,n){yf.S(e,t,n);var r=Sf;if(r&&e){var i=Ct(r).hoistableStyles,a=Mf(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Nf(a)))s.loading=5;else{e=p({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=gf.get(a))&&Bf(e,n);var c=o=r.createElement(`link`);wt(c),Id(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,zf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function kf(e,t){yf.X(e,t);var n=Sf;if(n&&e){var r=Ct(n).hoistableScripts,i=If(e),a=r.get(i);a||(a=n.querySelector(Lf(i)),a||(e=p({src:e,async:!0},t),(t=gf.get(i))&&Vf(e,t),a=n.createElement(`script`),wt(a),Id(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Af(e,t){yf.M(e,t);var n=Sf;if(n&&e){var r=Ct(n).hoistableScripts,i=If(e),a=r.get(i);a||(a=n.querySelector(Lf(i)),a||(e=p({src:e,async:!0,type:`module`},t),(t=gf.get(i))&&Vf(e,t),a=n.createElement(`script`),wt(a),Id(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function jf(e,t,n,r){var a=(a=pe.current)?vf(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Mf(n.href),n=Ct(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Mf(n.href);var o=Ct(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Nf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),gf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},gf.set(e,n),o||Ff(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=If(n),n=Ct(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Mf(e){return`href="`+Ut(e)+`"`}function Nf(e){return`link[rel="stylesheet"][`+e+`]`}function Pf(e){return p({},e,{"data-precedence":e.precedence,precedence:null})}function Ff(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Id(t,`link`,n),wt(t),e.head.appendChild(t))}function If(e){return`[src="`+Ut(e)+`"]`}function Lf(e){return`script[async]`+e}function Rf(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Ut(n.href)+`"]`);if(r)return t.instance=r,wt(r),r;var a=p({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),wt(r),Id(r,`style`,a),zf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Mf(n.href);var o=e.querySelector(Nf(a));if(o)return t.state.loading|=4,t.instance=o,wt(o),o;r=Pf(n),(a=gf.get(a))&&Bf(r,a),o=(e.ownerDocument||e).createElement(`link`),wt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Id(o,`link`,r),t.state.loading|=4,zf(o,n.precedence,e),t.instance=o;case`script`:return o=If(n.src),(a=e.querySelector(Lf(o)))?(t.instance=a,wt(a),a):(r=n,(a=gf.get(o))&&(r=p({},n),Vf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),wt(a),Id(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,zf(r,n.precedence,e));return t.instance}function zf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Bf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Vf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Hf=null;function Uf(e,t,n){if(Hf===null){var r=new Map,i=Hf=new Map;i.set(n,r)}else i=Hf,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[vt]||a[dt]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Wf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Gf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Kf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function qf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Mf(r.href),a=t.querySelector(Nf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Xf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,wt(a);return}a=t.ownerDocument||t,r=Pf(r),(i=gf.get(i))&&Bf(r,i),a=a.createElement(`link`),wt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Id(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Xf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Jf=0;function Yf(e,t){return e.stylesheets&&e.count===0&&Qf(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&Qf(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&Jf===0&&(Jf=62500*zd());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Qf(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>Jf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Xf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Qf(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Zf=null;function Qf(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Zf=new Map,t.forEach($f,e),Zf=null,Xf.call(e))}function $f(e,t){if(!(t.state.loading&4)){var n=Zf.get(e);if(n)var r=n.get(null);else{n=new Map,Zf.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=Xf.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var ep={$$typeof:x,Provider:null,Consumer:null,_currentValue:se,_currentValue2:se,_threadCount:0};function tp(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,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=et(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=et(0),this.hiddenUpdates=et(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function np(e,t,n,r,i,a,o,s,c,l,u,d){return e=new tp(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=pi(3,null,null,t),e.current=a,a.stateNode=e,t=fa(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},Ga(a),e}function rp(e){return e?(e=di,e):di}function ip(e,t,n,r,i,a){i=rp(i),r.context===null?r.context=i:r.pendingContext=i,r=qa(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=Ja(e,r,t),n!==null&&(hu(n,e,t),Ya(n,e,t))}function ap(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function op(e,t){ap(e,t),(e=e.alternate)&&ap(e,t)}function sp(e){if(e.tag===13||e.tag===31){var t=ci(e,67108864);t!==null&&hu(t,e,67108864),op(e,67108864)}}function cp(e){if(e.tag===13||e.tag===31){var t=pu();t=ot(t);var n=ci(e,t);n!==null&&hu(n,e,t),op(e,t)}}var lp=!0;function up(e,t,n,r){var i=D.T;D.T=null;var a=O.p;try{O.p=2,fp(e,t,n,r)}finally{O.p=a,D.T=i}}function dp(e,t,n,r){var i=D.T;D.T=null;var a=O.p;try{O.p=8,fp(e,t,n,r)}finally{O.p=a,D.T=i}}function fp(e,t,n,r){if(lp){var i=pp(r);if(i===null)Td(e,t,r,mp,n),Tp(e,r);else if(Dp(i,e,t,n,r))r.stopPropagation();else if(Tp(e,r),t&4&&-1<wp.indexOf(e)){for(;i!==null;){var a=xt(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Ye(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-He(o);s.entanglements[1]|=c,o&=~c}id(a),!(J&6)&&(tu=je()+500,ad(0,!1))}}break;case 31:case 13:s=ci(a,2),s!==null&&hu(s,a,2),bu(),op(a,2)}if(a=pp(r),a===null&&Td(e,t,r,mp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Td(e,t,r,null,n)}}function pp(e){return e=cn(e),hp(e)}var mp=null;function hp(e){if(mp=null,e=bt(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return mp=e,null}function gp(e){switch(e){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(Me()){case Ne:return 2;case Pe:return 8;case Fe:case Ie:return 32;case Le:return 268435456;default:return 32}default:return 32}}var _p=!1,vp=null,yp=null,bp=null,xp=new Map,Sp=new Map,Cp=[],wp=`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 Tp(e,t){switch(e){case`focusin`:case`focusout`:vp=null;break;case`dragenter`:case`dragleave`:yp=null;break;case`mouseover`:case`mouseout`:bp=null;break;case`pointerover`:case`pointerout`:xp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:Sp.delete(t.pointerId)}}function Ep(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=xt(t),t!==null&&sp(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Dp(e,t,n,r,i){switch(t){case`focusin`:return vp=Ep(vp,e,t,n,r,i),!0;case`dragenter`:return yp=Ep(yp,e,t,n,r,i),!0;case`mouseover`:return bp=Ep(bp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return xp.set(a,Ep(xp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,Sp.set(a,Ep(Sp.get(a)||null,e,t,n,r,i)),!0}return!1}function Op(e){var t=bt(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,lt(e.priority,function(){cp(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,lt(e.priority,function(){cp(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function kp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=pp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);sn=r,n.target.dispatchEvent(r),sn=null}else return t=xt(n),t!==null&&sp(t),e.blockedOn=n,!1;t.shift()}return!0}function Ap(e,t,n){kp(e)&&n.delete(t)}function jp(){_p=!1,vp!==null&&kp(vp)&&(vp=null),yp!==null&&kp(yp)&&(yp=null),bp!==null&&kp(bp)&&(bp=null),xp.forEach(Ap),Sp.forEach(Ap)}function Mp(e,n){e.blockedOn===n&&(e.blockedOn=null,_p||(_p=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,jp)))}var Np=null;function Pp(e){Np!==e&&(Np=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Np===e&&(Np=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(hp(r||n)===null)continue;break}var a=xt(n);a!==null&&(e.splice(t,3),t-=3,Ts(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Fp(e){function t(t){return Mp(t,e)}vp!==null&&Mp(vp,e),yp!==null&&Mp(yp,e),bp!==null&&Mp(bp,e),xp.forEach(t),Sp.forEach(t);for(var n=0;n<Cp.length;n++){var r=Cp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Cp.length&&(n=Cp[0],n.blockedOn===null);)Op(n),n.blockedOn===null&&Cp.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[ft]||null;if(typeof a==`function`)o||Pp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[ft]||null)s=o.formAction;else if(hp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Pp(n)}}}function Ip(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!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 r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Lp(e){this._internalRoot=e}Rp.prototype.render=Lp.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;ip(n,pu(),e,t,null,null)},Rp.prototype.unmount=Lp.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;ip(e.current,2,null,e,null,null),bu(),t[pt]=null}};function Rp(e){this._internalRoot=e}Rp.prototype.unstable_scheduleHydration=function(e){if(e){var t=ct();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Cp.length&&t!==0&&t<Cp[n].priority;n++);Cp.splice(n,0,e),n===0&&Op(e)}};var zp=n.version;if(zp!==`19.2.7`)throw Error(i(527,zp,`19.2.7`));O.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=d(t),e=e===null?null:f(e),e=e===null?null:e.stateNode,e};var Bp={bundleType:0,version:`19.2.7`,rendererPackageName:`react-dom`,currentDispatcherRef:D,reconcilerVersion:`19.2.7`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Vp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Vp.isDisabled&&Vp.supportsFiber)try{Be=Vp.inject(Bp),j=Vp}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=Ks,s=qs,c=Js;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=np(e,1,!1,null,null,n,r,null,o,s,c,Ip),e[pt]=t.current,Cd(e),new Lp(t)}})),$t=o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Qt()}))();function en(e){let t=e.indexOf(`=`);return t>0?[e.slice(0,t),e.slice(t+1)]:null}function tn(e,t){return t.filter(t=>{let n=en(t);return n!=null&&e[n[0]]?.includes(n[1])===!0})}function nn(e,t,n){let r=new Map;for(let i of e){let e=tn(i.tags,t);if(e.length===0||n===`all`&&e.length<t.length)continue;let a=e.join(`,`),o=r.get(a)??{signature:e,members:[]};o.members.push(i),r.set(a,o)}let i=e=>e.signature.map(e=>t.indexOf(e));return[...r.values()].sort((e,t)=>{if(e.signature.length!==t.signature.length)return t.signature.length-e.signature.length;let[n,r]=[i(e),i(t)];for(let e=0;e<n.length;e+=1)if(n[e]!==r[e])return(n[e]??0)-(r[e]??0);return 0})}function rn(e,t){return e.length===t.length&&e.every(e=>t.includes(e))}function an(e,t){let n=nn(t.filter(e=>!e.optIn),[...e.terms].sort(),e.mode),r=e.bucket;return(r==null?n:n.filter(e=>rn(e.signature,r))).flatMap(e=>e.members)}function on(e){if(!Array.isArray(e)||e.length===0||e.length>16)return null;let t=[];for(let n of e){if(typeof n!=`string`||n.length>512||en(n)==null)return null;t.includes(n)||t.push(n)}return t.sort()}function sn(e){if(typeof e!=`object`||!e||Array.isArray(e))return`expected an object`;let t={...e},n=t.mode;if(n!==`all`&&n!==`any`)return`mode: expected "all" | "any"`;let r=on(t.terms);if(r==null)return`terms: expected 1–16 tag=value strings`;if(t.bucket==null)return{mode:n,terms:r};let i=on(t.bucket);return i==null||!i.every(e=>r.includes(e))?`bucket: expected a subset of terms`:{mode:n,terms:r,bucket:i}}function cn(e,t){let n=new Map(e.map((e,t)=>[e.id,t])),r=new Map,i=new Map;for(let e of t)r.set(e,0),i.set(e,[]);for(let n of t){let a=e.find(e=>e.id===n);for(let e of a?.dependsOn??[])t.has(e)&&(r.set(n,(r.get(n)??0)+1),i.get(e)?.push(n))}let a=[...t].filter(e=>r.get(e)===0);a.sort((e,t)=>(n.get(e)??0)-(n.get(t)??0));let o=[];for(let e=0;e<a.length;e+=1){let t=a[e];o.push(t);for(let o of i.get(t)??[]){let t=(r.get(o)??0)-1;if(r.set(o,t),t===0){let t=e+1;for(;t<a.length&&(n.get(a[t])??0)<(n.get(o)??0);)t+=1;a.splice(t,0,o)}}}return o.length===t.size?o:[...o,...[...t].filter(e=>!o.includes(e))]}function ln(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Set,i=[...t];for(;i.length>0;){let e=i.pop();if(!r.has(e)){r.add(e);for(let t of n.get(e)?.dependsOn??[])i.push(t)}}return r}function un(e,t,n){let r=ln(e,t),i=[];for(let a=!0;a;){a=!1;let o=ln(e,e.filter(e=>!r.has(e.id)&&n(e.id)).map(e=>e.id));for(let e of[...r])t.includes(e)||!o.has(e)||(r.delete(e),n(e)&&i.push(e),a=!0)}return{stop:cn(e,r),kept:i}}function dn(e,t){return`color-mix(in srgb, ${e} ${t}%, transparent)`}var N={void:j(`surfaceVoid`),surface:j(`surfaceBase`),surfaceSelected:j(`surfaceSelected`),surfaceHeader:j(`surfaceDetailHeader`),surfaceSection:j(`surfaceSection`),border:j(`borderPanel`),borderStrong:j(`borderDivider`),textEmphasis:j(`textEmphasis`),text:j(`textSecondary`),textMeta:j(`semanticMetadata`),textMuted:j(`textMuted`),error:j(`semanticError`),success:j(`semanticSuccess`),system:j(`semanticSystem`),warning:j(`semanticWarning`)};function fn(e){let t=0;for(let n=0;n<e.length;n+=1)t=t*31+e.charCodeAt(n)|0;let n=Ue();return n[Math.abs(t)%n.length]??N.system}var pn=e=>`color-mix(in srgb, ${e} 72%, white)`,mn=Ue(),hn=[j(`surfaceVoid`),j(`semanticError`),j(`semanticSuccess`),j(`semanticWarning`),j(`semanticSystem`),mn[0]??j(`semanticSystem`),mn[2]??j(`semanticSystem`),j(`textSecondary`)],gn=[...hn,...hn.map(pn)];function _n(e){switch(e){case`ready`:case`succeeded`:case`running`:return`ready`;case`starting`:case`stopping`:return`active`;case`unready`:case`backoff`:case`blocked`:return`warn`;case`failed`:case`crashed`:return`bad`;default:return`idle`}}var vn={ready:N.success,active:N.system,warn:N.warning,bad:N.error,idle:N.textMuted};function yn(e){if(e.state===`blocked`)return{indicator:`warning`,label:`blocked`,tone:`warn`};if(bn(e.state))return e.state===`unready`||e.state===`backoff`?{indicator:`warning`,label:e.state,tone:`warn`}:e.state===`starting`||e.state===`stopping`?{indicator:`transition`,label:e.state,tone:`active`}:{indicator:`running`,label:e.state,tone:`ready`};let t=e.kind===`task`?e.lastTask?.outcome:void 0;return t===`failed`||e.state===`failed`||e.state===`crashed`?{indicator:`failure`,label:e.lastTask?.timedOut?`timed out`:e.state===`crashed`?`crashed`:`failed`,tone:`bad`}:t===`succeeded`||e.state===`succeeded`?{indicator:`success`,label:`succeeded`,tone:`ready`}:{indicator:`idle`,label:e.state,tone:`idle`}}function bn(e){return e===`starting`||e===`running`||e===`ready`||e===`unready`||e===`backoff`||e===`stopping`}var xn=15e3;function Sn(e,t){let n=[];e.removed&&n.push(`removed from config`),e.stale&&n.push(`config changed`),e.envDrift&&n.push(`env changed — restart to apply`),e.blockedBy!=null&&n.push(`blocked: ${e.blockedBy}`),e.startError!=null&&n.push(`start failed: ${e.startError}`),e.unreadyReason!=null&&n.push(`unready: ${e.unreadyReason}`),bn(e.state)&&e.sawOutputAt==null&&e.startedAt!=null&&t-e.startedAt>xn&&n.push(`no output since start`),!bn(e.state)&&e.lastTask?.outcome===`failed`&&e.lastTask.reason!=null&&n.push(`last run failed: ${e.lastTask.reason}`);for(let t of e.degradedBy)n.push(`degraded by ${t}`);return e.restarts>=3&&n.push(`${e.restarts} restarts`),e.capability?.degraded===!0&&n.push(`tree ownership degraded (${e.capability.treeMechanism})`),n}function Cn(e,t=Date.now()){return Object.entries(e.processes).map(([e,n])=>({id:e,node:n,tone:yn(n).tone,chips:Sn(n,t),stickyOverrides:n.detail.envVars.filter(e=>e.source===`override`).map(e=>e.name)})).sort((e,t)=>e.id<t.id?-1:+(e.id>t.id))}function wn(e,t){let n=new Map(e.map(e=>[e.id,e]));return t.flatMap(e=>n.get(e)??[])}function Tn(e){return wn(e,cn(e.map(e=>({id:e.id,dependsOn:e.node.detail.dependsOn})).sort((e,t)=>e.id<t.id?-1:1),new Set(e.map(e=>e.id))))}function En(e){let t=new Map;for(let n of e)for(let[e,r]of Object.entries(n.node.tags)){let n=t.get(e)??new Set;for(let e of r)n.add(e);t.set(e,n)}return[...t.entries()].map(([e,t])=>({key:e,values:[...t].sort()})).sort((e,t)=>e.key<t.key?-1:+(e.key>t.key))}function Dn(e){return[...e].sort()}function On(e,t,n,r){let i=e.map(e=>({row:e,tags:e.node.tags})),a=e=>{let t=Tn(e.members.map(e=>e.row));return{signature:e.signature,members:t.filter(e=>!e.node.optIn),optIn:t.filter(e=>e.node.optIn)}};if(t.length>0)return nn(i,Dn(t),n).map(a);if(r==null)return e.length===0?[]:[a({signature:[],members:i})];let o=nn(i,(En(e).find(e=>e.key===r)?.values??[]).map(e=>`${r}=${e}`),`any`).flatMap(e=>e.signature.map(t=>({signature:[t],members:e.members}))),s=new Map;for(let e of o){let t=e.signature[0]??``,n=s.get(t);s.set(t,{signature:e.signature,members:[...n?.members??[],...e.members]})}let c=i.filter(e=>e.tags[r]==null);return[...[...s.values()].sort((e,t)=>(e.signature[0]??``)<(t.signature[0]??``)?-1:1),...c.length>0?[{signature:[],members:c}]:[]].map(a)}function kn(e,t,n){let r=new Map,i=e.map(e=>({tags:e.node.tags}));for(let{key:a,values:o}of En(e))for(let e of o){let o=`${a}=${e}`,s=nn(i,t.includes(o)?t:[...t,o],n).reduce((e,t)=>e+(n===`all`||t.signature.includes(o)?t.members.length:0),0);r.set(o,s)}return r}function An(e,t,n,r){let i=r.trim().toLowerCase(),a=e.filter(e=>i===``||e.id.toLowerCase().includes(i));if(t.length===0)return a;let o=new Set(nn(a.map(e=>({id:e.id,tags:e.node.tags})),t,n).flatMap(e=>e.members.map(e=>e.id)));return a.filter(e=>o.has(e.id))}function jn(e,t){let n=Object.entries(t).map(([e,t])=>({id:e,dependsOn:t.detail.dependsOn})),r=e=>{let n=t[e];return n!=null&&bn(n.state)};return{starts:e.filter(e=>!r(e)),alreadyRunning:e.filter(r),dependencies:[...ln(n,e)].filter(t=>!e.includes(t)).sort()}}function Mn(e,t){let n=Object.entries(t).map(([e,t])=>({id:e,dependsOn:t.detail.dependsOn})),r=e=>bn(t[e]?.state??``),{stop:i,kept:a}=un(n,e,r);return{stops:i.filter(r),kept:a}}function Nn(e,t){let n=Object.entries(t).map(([e,t])=>({id:e,dependsOn:t.detail.dependsOn}));return n.filter(({id:n})=>!e.includes(n)&&bn(t[n]?.state??``)).filter(({id:t})=>e.some(e=>ln(n,[t]).has(e))).map(({id:e})=>e)}function Pn(e){let t=new Map;for(let n of Object.values(e))if(n.endedAt==null)for(let e of Object.keys(n.members))t.set(e,n.suite??`tag group`);return t}function Fn(e,t){return Tn(an(e,t.map(e=>({row:e,tags:e.node.tags,optIn:e.node.optIn}))).map(e=>e.row))}function In(e){return e.name==null?(e.bucket??e.terms).map(e=>e.slice(e.indexOf(`=`)+1)).join(` · `):e.name}function Ln(e,t){return e.detail.endpoints.map(e=>{let n=e.host===`127.0.0.1`||e.host===`localhost`,r=e.url!=null&&t;return{name:e.name,label:`${e.protocol}:${e.port}`,...r?{href:e.url}:{},remote:!t&&n}})}function Rn(e){return e===`127.0.0.1`||e===`localhost`||e===`[::1]`}function zn(e,t){let n=e.map(e=>t[e]?yn(t[e]).label:`not-started`);return n.length===0?`stopped`:e.some(e=>t[e]&&yn(t[e]).indicator===`failure`)?`failed`:n.filter(e=>_n(e)!==`idle`).length===0?`stopped`:n.some(e=>e===`starting`)?`starting`:n.filter(e=>e===`ready`||e===`succeeded`).length===n.length?`ready`:`partial`}function Bn(e,t){if(e.length===0)return null;let n=e.map(e=>t[e]);return n.every(e=>e!=null&&e.kind===`task`)?e.map((e,t)=>{let r=n[t],i=yn(r);return i.indicator===`success`?{id:e,verdict:`pass`}:i.indicator===`failure`?{id:e,verdict:`fail`}:r.state===`blocked`?{id:e,verdict:`blocked`}:bn(r.state)?{id:e,verdict:`running`}:r.state===`stopped`?{id:e,verdict:`stopped`}:{id:e,verdict:`pending`}}):null}function Vn({rows:e}){let t={running:0,success:0,failure:0,warning:0,transition:0,idle:0};for(let n of e)t[yn(n.node).indicator]+=1;let n=e.filter(e=>e.stickyOverrides.length>0).length;return(0,M.jsxs)(`section`,{className:`nc-overview nc-chrome`,"aria-label":`visible process overview`,children:[(0,M.jsxs)(`div`,{className:`nc-overview-heading`,children:[(0,M.jsx)(`span`,{className:`nc-section-title`,children:`process overview`}),(0,M.jsxs)(`span`,{children:[e.length,` visible`]})]}),(0,M.jsxs)(`div`,{className:`nc-overview-counts`,children:[(0,M.jsxs)(`span`,{children:[(0,M.jsx)(`strong`,{children:t.running}),` running`]}),(0,M.jsxs)(`span`,{children:[(0,M.jsx)(`strong`,{children:t.success}),` passed`]}),(0,M.jsxs)(`span`,{"data-attention":t.failure>0,children:[(0,M.jsx)(`strong`,{children:t.failure}),` failed`]}),(0,M.jsxs)(`span`,{children:[(0,M.jsx)(`strong`,{children:t.idle}),` idle`]})]}),n>0&&(0,M.jsxs)(`p`,{className:`nc-overview-attention`,"data-sticky-count":n,children:[n,` carrying sticky env — applies to every start until cleared`]}),(t.warning>0||t.transition>0)&&(0,M.jsxs)(`p`,{className:`nc-overview-attention`,children:[t.transition,` starting / stopping · `,t.warning,` need attention`]}),(0,M.jsxs)(`details`,{className:`nc-state-legend`,children:[(0,M.jsx)(`summary`,{children:`status guide`}),(0,M.jsx)(`p`,{children:`● Pulsing green: running or ready. ✓ Green ring: completed successfully. × Red ring: failed, crashed or timed out.`}),(0,M.jsx)(`p`,{children:`! Amber: unready, retrying or blocked. Blue ring: starting or stopping. Muted ring: not started or deliberately stopped.`})]})]})}function Hn(e,t){let n=e.toLowerCase(),r=t.trim().toLowerCase();if(r===``)return 0;let i=n.indexOf(r);if(i>=0)return i;let a=100,o=0;for(let e of r){let t=n.indexOf(e,o);if(t<0)return null;a+=t-o,o=t+1}return a}function Un(e,t,n=12){return e.flatMap((e,n)=>{let r=Hn(e.label,t);return r==null?[]:[{entry:e,score:r,index:n}]}).sort((e,t)=>e.score-t.score||e.index-t.index).slice(0,n).map(e=>e.entry)}function Wn({open:e,onClose:t,entries:n}){let[r,i]=(0,d.useState)(``),[a,o]=(0,d.useState)(0),s=(0,d.useRef)(null),c=(0,d.useMemo)(()=>Un(n,r),[n,r]);(0,d.useEffect)(()=>{if(!e)return;i(``),o(0);let t=requestAnimationFrame(()=>s.current?.focus());return()=>cancelAnimationFrame(t)},[e]);let l=e=>{e!=null&&(t(),e.run())};return(0,M.jsxs)(gt,{open:e,onClose:t,title:`go to…`,description:`Processes, tags, suites and pins — Enter picks, arrows move.`,children:[(0,M.jsx)(`input`,{ref:s,value:r,"aria-label":`command palette`,placeholder:`type a process, tag, suite or pin…`,onChange:e=>{i(e.target.value),o(0)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;o(e=>(e+t+c.length)%Math.max(1,c.length))}else e.key===`Enter`&&(e.preventDefault(),l(c[a]))},className:`nc-palette-input`}),(0,M.jsxs)(`div`,{role:`listbox`,"aria-label":`matches`,className:`nc-palette-list`,children:[c.map((e,t)=>(0,M.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===a,"data-active":t===a,onMouseEnter:()=>o(t),onClick:()=>l(e),children:[(0,M.jsx)(`span`,{style:{color:N.textEmphasis},children:e.label}),(0,M.jsx)(`span`,{style:{color:N.textMuted,fontSize:11},children:e.hint})]},`${e.hint}:${e.label}`)),c.length===0&&(0,M.jsx)(`div`,{style:{color:N.textMuted,fontSize:12,padding:6},children:`nothing matches`})]})]})}function Gn(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e;return typeof t.text==`string`&&typeof t.seq==`number`}function Kn(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e;return typeof t.g==`number`&&typeof t.s==`number`&&typeof t.id==`string`&&Gn(t.line)}function qn(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!=`object`||!t||Array.isArray(t))return null;let n=t;if(n.k===`merged-gap`){let e=n.dropped;return typeof e==`number`?{k:`merged-gap`,dropped:e}:null}if(n.k===`merged`){let e=n.entries;return!Array.isArray(e)||!e.every(Kn)?null:n.reset===!0?{k:`merged`,reset:!0,entries:e}:{k:`merged`,entries:e}}if(n.k===`search-result`){let e=n.entries;return typeof n.id!=`string`||!Array.isArray(e)||!e.every(Kn)||typeof n.complete!=`boolean`||typeof n.scanned!=`number`?null:{k:`search-result`,id:n.id,entries:e,complete:n.complete,scanned:n.scanned}}let r=n.proc;if(typeof r!=`string`)return null;if(n.k===`gap`){let e=n.dropped;return typeof e==`number`?{k:`gap`,proc:r,dropped:e}:null}if(n.k===`batch`){let e=n.lines;return!Array.isArray(e)||!e.every(Gn)?null:n.reset===!0?{k:`batch`,proc:r,reset:!0,lines:e}:{k:`batch`,proc:r,lines:e}}return null}var Jn=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)|\x1b[[(][0-9;?]*[A-Za-z]/g,Yn=/^\x1b\[([0-9;]*)m$/,Xn=gn.slice(0,8),Zn=gn.slice(8);function Qn(e){let t={};return e.color!=null&&(t.color=e.color),e.background!=null&&(t.backgroundColor=e.background),e.bold===!0&&(t.fontWeight=`600`),e.dim===!0&&(t.opacity=`0.65`),e.italic===!0&&(t.fontStyle=`italic`),e.underline===!0&&(t.textDecoration=`underline`),t}function $n(e,t){let n={...e},r=t===``?[`0`]:t.split(`;`);for(let e=0;e<r.length;e+=1){let t=Number(r[e]);if(Number.isFinite(t)){if(t===0)for(let e of Object.keys(n))delete n[e];else if(t===1)n.bold=!0;else if(t===2)n.dim=!0;else if(t===3)n.italic=!0;else if(t===4)n.underline=!0;else if(t===22)n.bold=!1,n.dim=!1;else if(t===23)n.italic=!1;else if(t===24)n.underline=!1;else if(t>=30&&t<=37)n.color=Xn[t-30];else if(t===39)delete n.color;else if(t>=40&&t<=47)n.background=Xn[t-40];else if(t===49)delete n.background;else if(t>=90&&t<=97)n.color=Zn[t-90];else if(t>=100&&t<=107)n.background=Zn[t-100];else if((t===38||t===48)&&r[e+1]===`5`){let i=er(Number(r[e+2]));i!=null&&(t===38?n.color=i:n.background=i),e+=2}else if((t===38||t===48)&&r[e+1]===`2`){let[i,a,o]=[Number(r[e+2]),Number(r[e+3]),Number(r[e+4])];if([i,a,o].every(e=>Number.isFinite(e)&&e>=0&&e<=255)){let e=`rgb(${i},${a},${o})`;t===38?n.color=e:n.background=e}e+=4}}}return n}function er(e){if(!Number.isFinite(e)||e<0||e>255)return null;if(e<8)return Xn[e]??null;if(e<16)return Zn[e-8]??null;if(e<232){let t=e=>e===0?0:55+e*40,n=e-16;return`rgb(${t(Math.floor(n/36))},${t(Math.floor(n/6)%6)},${t(n%6)})`}let t=8+(e-232)*10;return`rgb(${t},${t},${t})`}function tr(e){let t=[],n={},r=0;for(Jn.lastIndex=0;;){let i=Jn.exec(e);if(i==null)break;i.index>r&&t.push({text:e.slice(r,i.index),style:Qn(n)});let a=Yn.exec(i[0]);a!=null&&(n=$n(n,a[1]??``)),r=i.index+i[0].length}return r<e.length&&t.push({text:e.slice(r),style:Qn(n)}),t.length>0?t:[{text:``,style:{}}]}var nr=/\bhttps?:\/\/[^\s"'<>]+/g,rr=/[.,;:!?]+$/;function ir(e,t){let n=[],r=0;for(let i of e.matchAll(nr)){let a=ar(i[0]);if(a===``)continue;let o=i.index;!t.allowLoopback&&sr(a)||(o>r&&n.push({kind:`text`,text:e.slice(r,o)}),n.push({kind:`link`,text:a,href:a}),r=o+a.length)}return n.length===0?[{kind:`text`,text:e}]:(r<e.length&&n.push({kind:`text`,text:e.slice(r)}),n)}function ar(e){let t=e.replace(rr,``);for(;;){let e=t.at(-1)??``,n=e===`)`?`(`:e===`]`?`[`:null;if(n==null||t.split(n).length>=t.split(e).length)return t;t=t.slice(0,-1)}}function or(e,t){let n=e.map(e=>e.text).join(``),r=[],i=0;for(let t of e)r.push(i),i+=t.text.length;let a=[],o=0;for(let i of ir(n,t)){let t=o,n=o+i.text.length;o=n;let s=0;for(;s<e.length&&r[s]+e[s].text.length<=t;)s+=1;let c=[];for(;s<e.length&&r[s]<n;){let a=r[s]+e[s].text.length,o=i.text.slice(Math.max(t,r[s])-t,Math.min(n,a)-t);o.length>0&&c.push({text:o,style:e[s].style}),s+=1}if(i.kind===`link`)a.push({kind:`link`,href:i.href,pieces:c});else for(let e of c)a.push({kind:`text`,text:e.text,style:e.style})}return a}function sr(e){try{let t=new URL(e).hostname;return t===`localhost`||t===`127.0.0.1`||t===`0.0.0.0`||t===`[::1]`}catch{return!1}}var cr=5e3;function lr(e,t,n,r){if(e.kind===`proc`){if(r.k===`gap`&&r.proc===e.id)return{rows:hr(t,[gr(t.length,r.dropped)]),cursor:n};if(r.k!==`batch`||r.proc!==e.id)return null;let i=r.lines.map(e=>({key:`${e.seq}-${e.stream}`,text:e.text,gap:!1,ts:e.ts})),a=r.lines[r.lines.length-1]?.seq,o=r.reset===!0?a:Math.max(n.seq??0,a??0)||void 0;return{rows:r.reset===!0?i.slice(-5e3):hr(t,i),cursor:o==null?{}:{seq:o}}}if(r.k===`merged-gap`)return{rows:hr(t,[gr(t.length,r.dropped)]),cursor:n};if(r.k!==`merged`)return null;let i=r.entries.map(dr),a=r.entries[r.entries.length-1]?.s,o=r.reset===!0?a:Math.max(n.s??0,a??0)||void 0;return{rows:r.reset===!0?i.slice(-5e3):hr(t,i),cursor:o==null?{}:{s:o}}}function ur(e){return e.kind===`proc`?`proc:${e.id}`:`merged:${e.procs?.join(`,`)??`*`}`}function dr(e){return{key:`${e.g}-${e.s}`,prefix:e.id,text:e.line.text,gap:!1,ts:e.line.ts}}function fr(e,t){return e.kind===`proc`?JSON.stringify({k:`sub`,proc:e.id,fromSeq:t.seq}):JSON.stringify({k:`sub-merged`,...e.procs==null?{}:{procs:e.procs},fromS:t.s})}function pr(e){return JSON.stringify(e.kind===`proc`?{k:`unsub`,proc:e.id}:{k:`unsub-merged`})}function mr(e,t){return e.kind===`proc`?t.k===`batch`&&t.proc===e.id&&t.reset===!0:t.k===`merged`&&t.reset===!0}function hr(e,t){let n=[...e,...t];return n.length>5e3?n.slice(n.length-cr):n}function gr(e,t){return{key:`gap-${e}`,text:`… ${t} lines dropped …`,gap:!0}}function _r(e,t,n){let r=new Set;if(e.kind===`proc`){if(n.keepProcs.has(e.id))for(let e of t.filter(e=>!e.gap).slice(-12))r.add(e.key)}else{let e=new Map;for(let n of t){if(n.gap||n.prefix==null)continue;let t=e.get(n.prefix)??[];t.push(n),e.set(n.prefix,t)}for(let[t,i]of e)if(n.keepProcs.has(t))for(let e of i.slice(-12))r.add(e.key)}let i=t.filter(e=>r.has(e.key)),a=t.length-i.length,o=new Date(n.now),s=String(o.getHours()).padStart(2,`0`),c=String(o.getMinutes()).padStart(2,`0`),l=i.length===0?``:e.kind===`proc`?` · kept the last ${i.length} line${i.length===1?``:`s`}`:` · kept ${i.length} lines from ${new Set(i.map(e=>e.prefix)).size} running processes`;return{rows:[...i,{key:`cleared-${n.now}`,text:`— cleared ${s}:${c}${l} · nothing was deleted; search covers the full history —`,gap:!0}],kept:i.length,dropped:a}}function vr(e){if(typeof e!=`object`||!e)return`expected an object`;let t={...e};return!Array.isArray(t.ids)||!t.ids.every(e=>typeof e==`string`&&e.length>0)?`expected ids`:t.token!=null&&(typeof t.token!=`string`||!t.token)?`expected token`:t.force!=null&&typeof t.force!=`boolean`?`expected force boolean`:t.force&&!t.token?`force requires a listener token`:{ids:t.ids,...typeof t.token==`string`?{token:t.token}:{},...typeof t.force==`boolean`?{force:t.force}:{}}}function yr(e){if(typeof e!=`object`||!e)return`expected an object`;let t={...e};if(!Array.isArray(t.warnings)||!t.warnings.every(e=>typeof e==`string`)||!Array.isArray(t.listeners))return`expected listeners and warnings`;let n=[];for(let e of t.listeners){if(typeof e!=`object`||!e)return`invalid listener`;let t={...e};if(![t.id,t.endpoint,t.host,t.command].every(e=>typeof e==`string`)||!Number.isInteger(t.pid)||Number(t.pid)<1||!Number.isInteger(t.port)||Number(t.port)<1||Number(t.port)>65535||!(t.ppid===null||Number.isInteger(t.ppid)&&Number(t.ppid)>=0)||!(t.cwd===null||typeof t.cwd==`string`)||typeof t.stray!=`boolean`||!(t.strayRoot===null||Number.isInteger(t.strayRoot)&&Number(t.strayRoot)>=1)||![t.startStamp,t.token,t.refusal].every(e=>e===null||typeof e==`string`))return`invalid listener`;n.push(e)}return{listeners:n,warnings:t.warnings}}var br=function(e){return e.duplex=`duplex`,e.exchange=`exchange`,e}({}),xr=function(e){return e.uninitialized=`uninitialized`,e.unsupported=`unsupported`,e.initializing=`initializing`,e.ready=`ready`,e.failed=`failed`,e}({}),Sr=ue.createChildDomain({domain:`err_nice_wire_connect`,schema:{connect_exhausted:k({message:({peerId:e,attempted:t})=>`connect() to peer [${e}] exhausted its transport chain (tried: ${t.join(`, `)||`none configured`}).`}),connect_closed:k({message:({peerId:e})=>`connect() to peer [${e}] on a closed WireClient — closed is terminal; create a new client.`}),dial_failed:k({message:({peerId:e,carrierLabel:t,reason:n,endpoint:r})=>`Dialing peer [${e}] over "${t}"${r==null?``:` against ${r}`} failed: ${n}`}),dial_unavailable:k({message:({carrierLabel:e})=>`Dial over "${e}" unavailable — createRequest returned null (no valid endpoint right now). A keep-alive redial parks on this until the next explicit connect()/dispatch.`}),conflicting_connect_options:k({message:({detail:e})=>`Conflicting connection options: ${e}`}),endpoint_answered_non_protocol:k({message:({stage:e,expected:t,url:n,httpStatus:r,contentType:i,receivedKind:a,bodyPreview:o})=>{let s=r==null?a==null?`a response it could not decode`:`a "${a}" frame`:`an HTTP ${r}${i==null?``:` ${i}`} response`;return`[${e}] expected ${t??`a nice-wire frame`} but received ${s} — the endpoint answered but is not speaking the nice-wire protocol (wrong URL, an intercepting proxy/WAF, or a different server)${n==null?``:`. Dialed: ${n}`}${o==null?``:`. Body: ${JSON.stringify(o)}`}.`}}),endpoint_unreachable:k({message:({url:e,carrierLabel:t,reason:n})=>`Could not reach ${e??(t==null?`the endpoint`:`the "${t}" endpoint`)}: ${n} — nothing answered there (wrong host/port, the server is not running, or a firewall/offline network).`}),handshake_rejected:k({message:({stage:e,reason:t})=>`[${e}] rejected by peer: ${t}`}),protocol_version_mismatch:k({message:({reason:e,observedProtocolVersion:t,localSupportedProtocolVersions:n,remoteSupportedProtocolVersions:r})=>`Handshake protocol version mismatch: ${e}. Local support: [${n.join(`, `)}]${r==null?``:`; remote support: [${r.join(`, `)}]`}${t==null?``:`; observed version: ${t}`}. Carrier fallback and automatic redial are parked until an explicit retry.`}),peer_identity_mismatch:k({message:({expected:e,actual:t,endpoint:n})=>`Secure peer identity mismatch: expected envId=${JSON.stringify(e.envId)}${e.perId==null?``:`, perId=${JSON.stringify(e.perId)}`}; received envId=${JSON.stringify(t.envId)}${t.perId==null?``:`, perId=${JSON.stringify(t.perId)}`}. ${n==null?``:`Dialed ${n}. `}Carrier fallback and automatic redial are parked until an explicit retry.`}),protocol_unsupported:k({message:({protocolId:e})=>`Protocol "${e}" cannot speak on this connection — the peer did not advertise "proto:${e}" (or it is not registered here).`}),protocol_on_exchange_only:k({message:({protocolId:e})=>`Protocol "${e}" needs a duplex transport — this connection is exchange-only (request/reply), which carries only the lane.`}),protocol_security_blocked:k({message:({protocolId:e,securityLevel:t})=>`Protocol "${e}" frame blocked: connection is at security level "${t}" and the protocol did not opt into allowPlain.`}),binding_version_mismatch:k({message:({found:e,expected:t})=>`Persisted connection binding has schema version ${JSON.stringify(e)} (this build reads v${t}) — the binding is invalidated; the connection must re-handshake.`}),identity_pin_mismatch:k({message:({reason:e})=>`Handshake rejected by peer: ${e}. The peer has a different verify key pinned for this client identity (TOFU) — permanent until the client connects under a new persistent id or the peer's pin is removed; auto-redial parks on this.`})}});function Cr(e,t){if(typeof t==`string`||t instanceof ArrayBuffer){e.send(t);return}e.send(new Uint8Array(t))}function wr(e){try{let t=new URL(e);return`${t.host}${t.pathname}`}catch{return e}}function Tr(e){let t=!1,n=e.readyState===WebSocket.OPEN,r,i,a=[],o=e=>{r==null?a.push(e):r(e)};return e.addEventListener(`open`,()=>{n=!0}),e.addEventListener(`message`,async e=>{let t=await kr(e.data);t!==void 0&&o(t)}),e.addEventListener(`close`,e=>{n&&!t&&console.warn(`WebSocket closed:`,e),i?.()}),e.addEventListener(`error`,()=>{n&&console.warn(`WebSocket error: ${Or(e)}`),i?.()}),{ready:new Promise((t,n)=>{if(e.readyState===WebSocket.OPEN){t();return}e.addEventListener(`open`,()=>t(),{once:!0}),e.addEventListener(`error`,()=>n(Er(e)),{once:!0}),e.addEventListener(`close`,t=>n(Dr(e,`WebSocket closed before open (code=${t.code})`)),{once:!0})}),isOpen:()=>e.readyState===WebSocket.OPEN,send:t=>Cr(e,t),attach:e=>{r=e.onMessage,i=e.onClose;for(let t of a)e.onMessage(t);a.length=0},close:()=>{t=!0;try{e.close()}catch{}},get label(){return e.url!=null&&e.url!==``?e.url:void 0}}}function Er(e){return Dr(e,`WebSocket dial failed`)}function Dr(e,t){return Sr.fromId(`endpoint_unreachable`,{url:e.url!=null&&e.url!==``?e.url:void 0,carrierLabel:`ws`,reason:t})}function Or(e){return e.url!=null&&e.url!==``?e.url:`(no url)`}async function kr(e){if(typeof e==`string`||e instanceof ArrayBuffer||e instanceof Uint8Array)return e;if(typeof Blob<`u`&&e instanceof Blob)return await e.arrayBuffer()}function Ar(e,t={}){let n=t=>{let n=typeof e==`string`?e:e(t);return n==null?null:typeof n==`string`?{url:n}:n},r=t.createWebSocket??(e=>new WebSocket(e));return{secure:t.secure,carrierLabel:`ws`,open:e=>{let t=n(e);if(t==null)throw Sr.fromId(`dial_unavailable`,{carrierLabel:`ws`});let i=r(t.url);return i.binaryType=`arraybuffer`,Tr(i)},getCacheKey:t.getCacheKey??(e=>[n(e)?.url??`ws:(unavailable)`]),getRouteInfo:t.getRouteInfo??(e=>{let t=n(e)?.url;return t==null?{carrierLabel:`ws`,summary:`ws (unavailable)`}:{carrierLabel:`ws`,url:t,summary:`ws ${wr(t)}`}})}}var jr=200;function Mr(e){return Array.from(e,e=>{let t=e.codePointAt(0);return t<=31||t>=127&&t<=159?` `:e}).join(``)}function Nr(e){if(typeof e!=`string`)return;let t=Mr(e).replace(/\s+/g,` `).trim();if(t.length!==0)return t.length>jr?`${t.slice(0,jr)}…`:t}function Pr(e){if(e!=null)try{let t=new URL(e);return t.username=``,t.password=``,t.search=``,t.hash=``,t.toString()}catch{return e.split(/[?#]/,1)[0]}}function Fr(e){return Sr.isExact(e)?e.hasId(`endpoint_answered_non_protocol`)?`endpoint_answered_non_protocol`:e.hasId(`endpoint_unreachable`)?`endpoint_unreachable`:e.hasId(`protocol_version_mismatch`)?`protocol_version_mismatch`:e.hasId(`peer_identity_mismatch`)?`peer_identity_mismatch`:e.hasId(`identity_pin_mismatch`)||e.hasId(`handshake_rejected`)?`handshake_rejected`:`unknown`:`unknown`}function Ir(e){if(Sr.isExact(e)){if(e.hasId(`endpoint_answered_non_protocol`))return e.getContext(`endpoint_answered_non_protocol`).url;if(e.hasId(`endpoint_unreachable`))return e.getContext(`endpoint_unreachable`).url;if(e.hasId(`peer_identity_mismatch`))return e.getContext(`peer_identity_mismatch`).endpoint}}var Lr=class{_cache;_errors;_transports=[];constructor(e,t){this._cache=e,this._errors=t}addTransport(e){this._transports.push(e)}getPreferredTransport(){return this._transports[0]}async getReadyTransport(e){let t=[],n=[];for(let r of this._transports){if(!r.isAvailable(e)){n.push(r);continue}let i=r.getCacheKey(e);if(i!=null){let e=this._cache.get(i);if(e!=null){if(e instanceof Promise){t.push({transport:r,promise:e});continue}t.push({transport:r,promise:Promise.resolve({...e,transport:r})});break}}let a=r.getTransport(e);if(a.status===xr.ready){let e=a.readyData;if(i!=null){let t={methods:e,transport:r};this._cache.set(i,t),e.addOnDisconnectListener?.(()=>{this._cache.get(i)===t&&this._cache.delete(i)})}t.push({transport:r,promise:Promise.resolve({methods:e,transport:r})});break}if(a.status===xr.unsupported){n.push(r);continue}if(a.status===xr.initializing){let e=a.initializationPromise.then(t=>{if(t.status===xr.failed)throw t.error;if(t.status===xr.unsupported)throw this._errors.unsupported([r.type]);let n=t.readyData,a={methods:n,transport:r};return i!=null&&(this._cache.get(i)===e?(this._cache.set(i,a),n.addOnDisconnectListener?.(()=>{this._cache.get(i)===a&&this._cache.delete(i)})):n.disconnect?.()),a}).catch(t=>{throw i!=null&&this._cache.get(i)===e&&this._cache.delete(i),t});i!=null&&this._cache.set(i,e),t.push({transport:r,promise:e})}}if(t.length===0)throw n.length>0?this._errors.unsupported(n.map(e=>e.type)):this._errors.notFound(e);let r,i;for(let n of t)try{return await n.promise}catch(t){if(Sr.isExact(t)&&t.hasId(`peer_identity_mismatch`)){let r=t.getContext(`peer_identity_mismatch`),i=Pr(n.transport.getRouteInfo(e)?.url);throw i!=null&&r.endpoint==null?Sr.fromId(`peer_identity_mismatch`,{...r,endpoint:i}).withOriginError(t):t}if(Sr.isExact(t)&&t.hasId(`protocol_version_mismatch`))throw t;r=t,i=n.transport}throw Sr.isExact(r)&&(r.hasId(`dial_unavailable`)||r.hasId(`identity_pin_mismatch`)||r.hasId(`protocol_version_mismatch`)||r.hasId(`peer_identity_mismatch`))?r:this._errors.initializationFailed(e,{cause:Rr(r),endpoint:Ir(r)??i?.getRouteInfo(e)?.url,kind:Fr(r),origin:r})}};function Rr(e){if(e!=null)return e instanceof Error?e.message:typeof e==`string`?e:String(e)}var zr=e=>e!=null&&e.length>0,Br=async({privateKey:e,publicKey:t})=>new Uint8Array(await crypto.subtle.deriveBits({name:`X25519`,public:t},e,256)),Vr=`METEOR_BRIDGE_DEFAULT_INFO_STRING`,Hr=async({externalX25519PublicKey:e,internalX25519PrivateKey:t,infoString:n,saltString:r})=>{let i=await Br({privateKey:t,publicKey:e}),a=await crypto.subtle.importKey(`raw`,new Uint8Array(i),`HKDF`,!1,[`deriveKey`]),o=zr(r)?new TextEncoder().encode(r):new Uint8Array,s=new TextEncoder().encode(zr(n)?n:Vr);return await crypto.subtle.deriveKey({name:`HKDF`,hash:`SHA-256`,salt:o,info:s},a,{name:`AES-GCM`,length:256},!1,[`encrypt`,`decrypt`])},Ur=async({aesGcmKey:e,dataToDecrypt:t})=>{let n=await crypto.subtle.decrypt({name:`AES-GCM`,iv:new Uint8Array(t.nonce)},e,new Uint8Array(t.ciphertext));return new Uint8Array(n)};function Wr(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}function Gr(e){if(!Wr(e))throw TypeError(`Uint8Array expected`)}function Kr(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(e=>typeof e==`string`):t.every(e=>Number.isSafeInteger(e)):!1}function qr(e){if(typeof e!=`function`)throw TypeError(`function expected`);return!0}function Jr(e,t){if(typeof t!=`string`)throw TypeError(`${e}: string expected`);return!0}function Yr(e){if(typeof e!=`number`)throw TypeError(`number expected, got ${typeof e}`);if(!Number.isSafeInteger(e))throw RangeError(`invalid integer: ${e}`)}function Xr(e){if(!Array.isArray(e))throw TypeError(`array expected`)}function Zr(e,t){if(!Kr(!0,t))throw TypeError(`${e}: array of strings expected`)}function Qr(e,t){if(!Kr(!1,t))throw TypeError(`${e}: array of numbers expected`)}function $r(...e){let t=e=>e,n=(e,t)=>n=>e(t(n));return{encode:e.map(e=>e.encode).reduceRight(n,t),decode:e.map(e=>e.decode).reduce(n,t)}}function ei(e){let t=typeof e==`string`?e.split(``):e,n=t.length;Zr(`alphabet`,t);let r=new Map(t.map((e,t)=>[e,t]));return{encode:r=>(Xr(r),r.map(r=>{if(!Number.isSafeInteger(r)||r<0||r>=n)throw Error(`alphabet.encode: digit index outside alphabet "${r}". Allowed: ${e}`);return t[r]})),decode:t=>(Xr(t),t.map(t=>{Jr(`alphabet.decode`,t);let n=r.get(t);if(n===void 0)throw Error(`Unknown letter: "${t}". Allowed: ${e}`);return n}))}}function ti(e=``){return Jr(`join`,e),{encode:t=>(Zr(`join.decode`,t),t.join(e)),decode:t=>(Jr(`join.decode`,t),t.split(e))}}function ni(e,t=`=`){return Yr(e),Jr(`padding`,t),{encode(n){for(Zr(`padding.encode`,n);n.length*e%8;)n.push(t);return n},decode(n){Zr(`padding.decode`,n);let r=n.length;if(r*e%8)throw Error(`padding: invalid, string should have whole number of bytes`);for(;r>0&&n[r-1]===t;r--)if((r-1)*e%8==0)throw Error(`padding: invalid, string has too much padding`);return n.slice(0,r)}}}function ri(e){return qr(e),{encode:e=>e,decode:t=>e(t)}}var ii=(e,t)=>t===0?e:ii(t,e%t),ai=(e,t)=>e+(t-ii(e,t)),oi=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function si(e,t,n,r){if(Xr(e),t<=0||t>32)throw RangeError(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw RangeError(`convertRadix2: wrong to=${n}`);if(ai(t,n)>32)throw Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${ai(t,n)}`);let i=0,a=0,o=oi[t],s=oi[n]-1,c=[];for(let r of e){if(Yr(r),r>=o)throw Error(`convertRadix2: invalid data word=${r} from=${t}`);if(i=i<<t|r,a+t>32)throw Error(`convertRadix2: carry overflow pos=${a} from=${t}`);for(a+=t;a>=n;a-=n)c.push((i>>a-n&s)>>>0);let e=oi[a];if(e===void 0)throw Error(`invalid carry`);i&=e-1}if(i=i<<n-a&s,!r&&a>=t)throw Error(`Excess padding`);if(!r&&i>0)throw Error(`Non-zero padding: ${i}`);return r&&a>0&&c.push(i>>>0),c}function ci(e,t=!1){if(Yr(e),e<=0||e>32)throw RangeError(`radix2: bits should be in (0..32]`);if(ai(8,e)>32||ai(e,8)>32)throw RangeError(`radix2: carry overflow`);return{encode:n=>{if(!Wr(n))throw TypeError(`radix2.encode input should be Uint8Array`);return si(Array.from(n),8,e,!t)},decode:n=>(Qr(`radix2.decode`,n),Uint8Array.from(si(n,e,8,t)))}}function li(e){return qr(e),function(...t){try{return e.apply(null,t)}catch{}}}$r(ci(4),ei(`0123456789ABCDEF`),ti(``)),$r(ci(5),ei(`ABCDEFGHIJKLMNOPQRSTUVWXYZ234567`),ni(5),ti(``)),$r(ci(5),ei(`ABCDEFGHIJKLMNOPQRSTUVWXYZ234567`),ti(``)),$r(ci(5),ei(`0123456789ABCDEFGHIJKLMNOPQRSTUV`),ni(5),ti(``)),$r(ci(5),ei(`0123456789ABCDEFGHIJKLMNOPQRSTUV`),ti(``)),$r(ci(5),ei(`0123456789ABCDEFGHJKMNPQRSTVWXYZ`),ti(``),ri(e=>e.toUpperCase().replace(/O/g,`0`).replace(/[IL]/g,`1`)));var ui=typeof Uint8Array.from([]).toBase64==`function`&&typeof Uint8Array.fromBase64==`function`,di=/[\t\n\f\r ]/,fi=(e,t)=>{Jr(`base64`,e);let n=t?`base64url`:`base64`;if(e.length>0&&di.test(e))throw Error(`invalid base64`);return Uint8Array.fromBase64(e,{alphabet:n,lastChunkHandling:`strict`})},pi=Object.freeze(ui?{encode(e){return Gr(e),e.toBase64()},decode(e){return fi(e,!1)}}:$r(ci(6),ei(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`),ni(6),ti(``)));$r(ci(6),ei(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`),ti(``)),ui||$r(ci(6),ei(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`),ni(6),ti(``)),$r(ci(6),ei(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`),ti(``));var mi=$r(ei(`qpzry9x8gf2tvdw0s3jn54khce6mua7l`),ti(``)),hi=[996825010,642813549,513874426,1027748829,705979059];function gi(e){let t=e>>25,n=(e&33554431)<<5;for(let e=0;e<hi.length;e++)(t>>e&1)==1&&(n^=hi[e]);return n}function _i(e,t,n=1){let r=e.length,i=1;for(let t=0;t<r;t++){let n=e.charCodeAt(t);if(n<33||n>126)throw Error(`Invalid prefix (${e})`);i=gi(i)^n>>5}i=gi(i);for(let t=0;t<r;t++)i=gi(i)^e.charCodeAt(t)&31;for(let e of t)i=gi(i)^e;for(let e=0;e<6;e++)i=gi(i);return i^=n,mi.encode(si([i%oi[30]],30,5,!1))}function vi(e){let t=e===`bech32`?1:734539939,n=ci(5),r=n.decode,i=n.encode,a=li(r);function o(e,n,r=90){Jr(`bech32.encode prefix`,e),Wr(n)&&(n=Array.from(n)),Qr(`bech32.encode`,n);let i=e.length;if(i===0)throw TypeError(`Invalid prefix length ${i}`);let a=i+7+n.length;if(r!==!1&&a>r)throw TypeError(`Length ${a} exceeds limit ${r}`);let o=e.toLowerCase(),s=_i(o,n,t);return`${o}1${mi.encode(n)}${s}`}function s(e,n=90){Jr(`bech32.decode input`,e);let r=e.length;if(r<8||n!==!1&&r>n)throw TypeError(`invalid string length: ${r} (${e}). Expected (8..${n})`);let i=e.toLowerCase();if(e!==i&&e!==e.toUpperCase())throw Error(`String must be lowercase or uppercase`);let a=i.lastIndexOf(`1`);if(a===0||a===-1)throw Error(`Letter "1" must be present between prefix and data only`);let o=i.slice(0,a),s=i.slice(a+1);if(s.length<6)throw Error(`Data must be at least 6 characters long`);let c=mi.decode(s).slice(0,-6),l=_i(o,c,t);if(!s.endsWith(l))throw Error(`Invalid checksum in ${e}: expected "${l}"`);return{prefix:o,words:c}}let c=li(s);function l(e){let{prefix:t,words:n}=s(e,!1);return{prefix:t,words:n,bytes:r(n)}}function u(e,t){return o(e,i(t))}return{encode:o,decode:s,encodeFromBytes:u,decodeToBytes:l,decodeUnsafe:c,fromWords:r,fromWordsUnsafe:a,toWords:i}}vi(`bech32`),vi(`bech32m`),typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`||$r(ci(4),ei(`0123456789abcdef`),ti(``),ri(e=>{if(typeof e!=`string`||e.length%2!=0)throw TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()}));var yi=async({aesGcmKey:e,dataToDecrypt:t})=>{let n=await crypto.subtle.decrypt({name:`AES-GCM`,iv:new Uint8Array(pi.decode(t.nonce))},e,new Uint8Array(pi.decode(t.ciphertext)));return new TextDecoder().decode(n)},bi=async({aesGcmKey:e,dataToEncrypt:t})=>{let n=crypto.getRandomValues(new Uint8Array(12)),r=await crypto.subtle.encrypt({name:`AES-GCM`,iv:n},e,new Uint8Array(t));return{nonce:n,ciphertext:new Uint8Array(r)}},xi=async({aesGcmKey:e,dataToEncrypt:t})=>{let n=crypto.getRandomValues(new Uint8Array(12)),r=await crypto.subtle.encrypt({name:`AES-GCM`,iv:n},e,new TextEncoder().encode(t));return{nonce:pi.encode(n),ciphertext:pi.encode(new Uint8Array(r))}};function Si(e){return Ci(e,`$`,new Set)}function Ci(e,t,n){if(e===null)return`null`;switch(typeof e){case`string`:return JSON.stringify(e);case`boolean`:return e?`true`:`false`;case`number`:if(!Number.isFinite(e))throw Error(`stringifyCanonicalJson: non-finite number at ${t}`);return JSON.stringify(e);case`undefined`:case`bigint`:case`function`:case`symbol`:throw Error(`stringifyCanonicalJson: unsupported ${typeof e} at ${t}`);default:break}let r=e;if(n.has(r))throw Error(`stringifyCanonicalJson: circular reference at ${t}`);n.add(r);try{if(Array.isArray(r)){let e=`[`;for(let i=0;i<r.length;i++)i>0&&(e+=`,`),e+=i in r?Ci(r[i],`${t}[${i}]`,n):`null`;return`${e}]`}let e=r,i=Object.keys(e).sort(),a=[];for(let r of i){let i=e[r];i!==void 0&&a.push(`${JSON.stringify(r)}:${Ci(i,`${t}.${r}`,n)}`)}return`{${a.join(`,`)}}`}finally{n.delete(r)}}function wi(e){if(typeof e.domainTag!=`string`||e.domainTag.length===0)throw Error(`buildCanonicalChallenge: domainTag must be a non-empty string`);if(typeof e.version!=`number`||!Number.isSafeInteger(e.version)||e.version<1)throw Error(`buildCanonicalChallenge: version must be a positive safe integer`);if(!Ti(e.fields))throw Error(`buildCanonicalChallenge: fields must be a plain object`);for(let[t,n]of Object.entries(e.fields))Ei(n,`fields.${t}`);return Si({domainTag:e.domainTag,version:e.version,fields:e.fields})}function Ti(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Ei(e,t){if(e===void 0)throw Error(`buildCanonicalChallenge: undefined entry at ${t}`);if(!(e===null||typeof e==`string`||typeof e==`boolean`)){if(typeof e==`number`){if(!Number.isFinite(e))throw Error(`buildCanonicalChallenge: non-finite number at ${t}`);return}if(Array.isArray(e)){for(let n=0;n<e.length;n++){if(!(n in e))throw Error(`buildCanonicalChallenge: sparse array hole at ${t}[${n}]`);Ei(e[n],`${t}[${n}]`)}return}if(Ti(e)){for(let[n,r]of Object.entries(e)){if(r===void 0)throw Error(`buildCanonicalChallenge: undefined entry at ${t}.${n}`);Ei(r,`${t}.${n}`)}return}throw Error(`buildCanonicalChallenge: unsupported value at ${t} — strict JSON values only (null, boolean, finite number, string, dense array, plain object)`)}}function Di(e){return pi.encode(e)}function Oi(e){return pi.decode(e)}var ki=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function Ai(e,t){return e>>>t|e<<32-t}function ji(e){let t=typeof e==`string`?new TextEncoder().encode(e):e,n=t.length*8,r=(t.length+8>>6)+1<<6,i=new Uint8Array(r);i.set(t),i[t.length]=128;let a=new DataView(i.buffer);a.setUint32(r-8,Math.floor(n/4294967296),!1),a.setUint32(r-4,n>>>0,!1);let o=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),s=new Uint32Array(64);for(let e=0;e<r;e+=64){for(let t=0;t<16;t++)s[t]=a.getUint32(e+t*4,!1);for(let e=16;e<64;e++){let t=Ai(s[e-15],7)^Ai(s[e-15],18)^s[e-15]>>>3,n=Ai(s[e-2],17)^Ai(s[e-2],19)^s[e-2]>>>10;s[e]=s[e-16]+t+s[e-7]+n>>>0}let t=o[0],n=o[1],r=o[2],i=o[3],c=o[4],l=o[5],u=o[6],d=o[7];for(let e=0;e<64;e++){let a=Ai(c,6)^Ai(c,11)^Ai(c,25),o=c&l^~c&u,f=d+a+o+ki[e]+s[e]>>>0,p=(Ai(t,2)^Ai(t,13)^Ai(t,22))+(t&n^t&r^n&r)>>>0;d=u,u=l,l=c,c=i+f>>>0,i=r,r=n,n=t,t=f+p>>>0}o[0]=o[0]+t>>>0,o[1]=o[1]+n>>>0,o[2]=o[2]+r>>>0,o[3]=o[3]+i>>>0,o[4]=o[4]+c>>>0,o[5]=o[5]+l>>>0,o[6]=o[6]+u>>>0,o[7]=o[7]+d>>>0}let c=new Uint8Array(32),l=new DataView(c.buffer);for(let e=0;e<8;e++)l.setUint32(e*4,o[e],!1);return c}function Mi(e){let t=ji(e),n=``;for(let e of t)n+=e.toString(16).padStart(2,`0`);return n}var Ni=async(e,t)=>{let n=new TextEncoder().encode(e),r=await crypto.subtle.sign({name:`ED25519`},t,n);return new Uint8Array(r)},Pi=async(e,t,n=`::`)=>await Ni(e.join(n),t),Fi=({infoString:e,verifyPublicKeys:t})=>{let n=[...t].sort();return[...e==null?[]:[e],...n].join(`::`)},Ii=class extends Error{key;issues;constructor(e,t){let n=t.map((e,t)=>{let n=e.path?.map(e=>String(typeof e==`object`?e.key:e)).join(`.`);return` (issue ${t+1})${n?` [${n}]`:``}: ${e.message}`}).join(`
18
18
  `);super(`Typed storage validation failed for key "${e}":\n${n}`),this.name=`StorageValidationError`,this.key=e,this.issues=t}};function Li({storageAdapter:e,schemas:t,onInvalid:n}){let r=(e,r)=>{let i=t?.[e];if(i==null)return r;let a=i[`~standard`].validate(r),o;if(a instanceof Promise)o=[{message:`async schema validation is not supported for typed storage`}];else if(a.issues!=null)o=a.issues;else return a.value;let s=new Ii(e,o);throw n?.(s),s},i=e=>t?.[e]!=null;return{getJson:async t=>{let n=await e.getJson(t);return n===void 0||!i(t)?n:r(t,n)},getJsonOrDef:async(t,n)=>{let a=await e.getJson(t)??n;return i(t)?r(t,a):a},setJson:async(t,n)=>e.setJson(t,i(t)?r(t,n):n),removeItem:async t=>{await e.removeItem(t)},updateJson:async(t,n)=>{if(!i(t)){await e.updateJson(t,n);return}await e.updateJson(t,e=>r(t,n(e===void 0?void 0:r(t,e))))},updateJsonWithDef:async(t,n,a)=>{if(!i(t)){await e.updateJsonOrDef(t,n,a);return}await e.updateJsonOrDef(t,n,e=>r(t,a(r(t,e))))},clearAll:async()=>{await e.clearAll()}}}var Ri=async()=>await crypto.subtle.generateKey({name:`Ed25519`},!0,[`sign`,`verify`]),zi=({transformJsonForFormats:e=[],transformJson:t=!1}={})=>n=>{let[r,i,a]=n.split(`::`),o=a;if(t||e.includes(i))try{o=JSON.parse(a)}catch(e){let t=Error(`Failed to parse type and format data string. Given input: "${n}", expected JSON parsable "data" value in the format "${r}::${i}::data" ${e instanceof Error?e.message:String(e)}`);throw t.cause=e,t}return{formattedString:n,type:r,format:i,data:o}},P,Bi={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function Vi(e){return!e&&!P?Bi:{lang:e?.lang??P?.lang,message:e?.message,abortEarly:e?.abortEarly??P?.abortEarly,abortPipeEarly:e?.abortPipeEarly??P?.abortPipeEarly}}var Hi;function Ui(e){return Hi?.get(e)}var Wi;function Gi(e){return Wi?.get(e)}var Ki;function qi(e,t){return Ki?.get(e)?.get(t)}function Ji(e){let t=typeof e;return t===`string`?`"${e}"`:t===`number`||t===`bigint`||t===`boolean`?`${e}`:t===`object`||t===`function`?(e&&Object.getPrototypeOf(e)?.constructor?.name)??`null`:t}function Yi(e,t,n,r,i){let a=i&&`input`in i?i.input:n.value,o=i?.expected??e.expects??null,s=i?.received??Ji(a),c={kind:e.kind,type:e.type,input:a,expected:o,received:s,message:`Invalid ${t}: ${o?`Expected ${o} but r`:`R`}eceived ${s}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},l=e.kind===`schema`,u=i?.message??e.message??qi(e.reference,c.lang)??(l?Gi(c.lang):null)??r.message??Ui(c.lang);u!==void 0&&(c.message=typeof u==`function`?u(c):u),l&&(n.typed=!1),n.issues?n.issues.push(c):n.issues=[c]}var Xi=new WeakMap;function Zi(e){let t=Xi.get(e);return t||(t={version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},Vi())}},Xi.set(e,t)),t}function Qi(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??`never`}var $i=/^(?:[\da-z+/]{4})*(?:[\da-z+/]{2}==|[\da-z+/]{3}=)?$/iu;function ea(e){return{kind:`validation`,type:`base64`,reference:ea,async:!1,expects:null,requirement:$i,message:e,"~run"(e,t){return e.typed&&!this.requirement.test(e.value)&&Yi(this,`Base64`,e,t),e}}}var ta={abortEarly:!0};function na(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function ra(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function ia(e,t){return{kind:`schema`,type:`array`,reference:ia,expects:`Array`,async:!1,item:e,message:t,get"~standard"(){return Zi(this)},"~run"(e,t){let n=e.value;if(Array.isArray(n)){e.typed=!0,e.value=[];for(let r=0;r<n.length;r++){let i=n[r],a=this.item[`~run`]({value:i},t);if(a.issues){let o={type:`array`,origin:`value`,input:n,key:r,value:i};for(let t of a.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),e.value.push(a.value)}}else Yi(this,`type`,e,t);return e}}}function aa(e){return{kind:`schema`,type:`boolean`,reference:aa,expects:`boolean`,async:!1,message:e,get"~standard"(){return Zi(this)},"~run"(e,t){return typeof e.value==`boolean`?e.typed=!0:Yi(this,`type`,e,t),e}}}function oa(e,t){return{kind:`schema`,type:`custom`,reference:oa,expects:`unknown`,async:!1,check:e,message:t,get"~standard"(){return Zi(this)},"~run"(e,t){return this.check(e.value)?e.typed=!0:Yi(this,`type`,e,t),e}}}function sa(e,t){if(typeof e==typeof t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{value:e};if(e&&t&&e.constructor===Object&&t.constructor===Object){let n={...e};for(let r in t)if(Object.prototype.hasOwnProperty.call(e,r)){let i=sa(e[r],t[r]);if(i.issue)return i;n[r]=i.value}else n[r]=t[r];return{value:n}}if(Array.isArray(e)&&Array.isArray(t)&&e.length===t.length){let n=[...e];for(let r=0;r<e.length;r++){let i=sa(e[r],t[r]);if(i.issue)return i;n[r]=i.value}return{value:n}}}return{issue:!0}}function ca(e,t){return{kind:`schema`,type:`intersect`,reference:ca,expects:Qi(e.map(e=>e.expects),`&`),async:!1,options:e,message:t,get"~standard"(){return Zi(this)},"~run"(e,t){if(this.options.length){let n=e.value,r;e.typed=!0;for(let i of this.options){let a=i[`~run`]({value:n},t);if(a.issues){if(e.issues)for(let t of a.issues)e.issues.push(t);else e.issues=a.issues;if(t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),e.typed&&(r?r.push(a.value):r=[a.value])}if(e.typed){e.value=r[0];for(let n=1;n<r.length;n++){let i=sa(e.value,r[n]);if(i.issue){Yi(this,`type`,e,t,{received:`unknown`});break}e.value=i.value}}}else Yi(this,`type`,e,t);return e}}}function la(e,t){return{kind:`schema`,type:`literal`,reference:la,expects:Ji(e),async:!1,literal:e,message:t,get"~standard"(){return Zi(this)},"~run"(e,t){return e.value===this.literal?e.typed=!0:Yi(this,`type`,e,t),e}}}function ua(e){return{kind:`schema`,type:`number`,reference:ua,expects:`number`,async:!1,message:e,get"~standard"(){return Zi(this)},"~run"(e,t){return typeof e.value==`number`&&!isNaN(e.value)?e.typed=!0:Yi(this,`type`,e,t),e}}}function da(e,t){return{kind:`schema`,type:`object`,reference:da,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return Zi(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let r in this.entries){let i=this.entries[r];if(r in n||(i.type===`exact_optional`||i.type===`optional`||i.type===`nullish`)&&i.default!==void 0){let a=r in n?n[r]:ra(i),o=i[`~run`]({value:a},t);if(o.issues){let i={type:`object`,origin:`value`,input:n,key:r,value:a};for(let t of o.issues)t.path?t.path.unshift(i):t.path=[i],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[r]=o.value}else if(i.fallback!==void 0)e.value[r]=na(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(Yi(this,`key`,e,t,{input:void 0,expected:`"${r}"`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]}),t.abortEarly))break}}else Yi(this,`type`,e,t);return e}}}function F(e,t){return{kind:`schema`,type:`optional`,reference:F,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return Zi(this)},"~run"(e,t){return e.value===void 0&&(this.default!==void 0&&(e.value=ra(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function fa(e,t){return{kind:`schema`,type:`picklist`,reference:fa,expects:Qi(e.map(Ji),`|`),async:!1,options:e,message:t,get"~standard"(){return Zi(this)},"~run"(e,t){return this.options.includes(e.value)?e.typed=!0:Yi(this,`type`,e,t),e}}}function pa(e){return{kind:`schema`,type:`string`,reference:pa,expects:`string`,async:!1,message:e,get"~standard"(){return Zi(this)},"~run"(e,t){return typeof e.value==`string`?e.typed=!0:Yi(this,`type`,e,t),e}}}function ma(e,t,n){return{kind:`schema`,type:`variant`,reference:ma,expects:`Object`,async:!1,key:e,options:t,message:n,get"~standard"(){return Zi(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){let r,i=0,a=this.key,o=[],s=(e,c)=>{for(let l of e.options){if(l.type===`variant`)s(l,new Set(c).add(l.key));else{let e=!0,s=0;for(let t of c){let r=l.entries[t];if(t in n?r[`~run`]({typed:!1,value:n[t]},ta).issues:r.type!==`exact_optional`&&r.type!==`optional`&&r.type!==`nullish`){e=!1,a!==t&&(i<s||i===s&&t in n&&!(a in n))&&(i=s,a=t,o=[]),a===t&&o.push(l.entries[t].expects);break}s++}if(e){let e=l[`~run`]({value:n},t);(!r||!r.typed&&e.typed)&&(r=e)}}if(r&&!r.issues)break}};if(s(this,new Set([this.key])),r)return r;Yi(this,`type`,e,t,{input:n[a],expected:Qi(o,`|`),path:[{type:`object`,origin:`value`,input:n,key:a,value:n[a]}]})}else Yi(this,`type`,e,t);return e}}}function ha(...e){return{...e[0],pipe:e,get"~standard"(){return Zi(this)},"~run"(t,n){for(let r of e)if(r.kind!==`metadata`){if(t.issues&&(r.kind===`schema`||r.kind===`transformation`)){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=r[`~run`](t,n))}return t}}}function ga(e,t,n){let r=e[`~run`]({value:t},Vi(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}var _a=({type:e,format:t,typeKind:n,formatKind:r})=>{let i=n??`data_type`,a=r??`data_format`;return ha(oa(n=>{if(typeof n!=`string`)return!1;let[r,i,a]=n.split(`::`);return r===e&&i===t&&typeof a==`string`},`Invalid format, expected '<${i}>::<${a}>::<value>' where "${i}" is "${e}", "${a}" is "${t}", and "value" is a string in the specified format`))},va=function(e){return e.ed25519=`ed25519`,e.x25519=`x25519`,e}({}),ya=function(e){return e.raw_base64=`raw_base64`,e.jwk=`jwk`,e}({});_a({format:`raw_base64`,type:`ed25519`,typeKind:`algo`}),_a({format:`jwk`,type:`ed25519`,typeKind:`algo`,transformJson:!0}),_a({format:`raw_base64`,type:`x25519`,typeKind:`algo`}),_a({format:`jwk`,type:`x25519`,typeKind:`algo`,transformJson:!0}),zi(),zi({transformJson:!0});var ba=zi({transformJsonForFormats:[ya.jwk]}),xa=e=>ba(e);zi(),zi({transformJson:!0});var Sa=zi({transformJsonForFormats:[ya.jwk]}),Ca=e=>Sa(e),wa=async(e,t,n)=>{let r=Uint8Array.from(pi.decode(e));return await crypto.subtle.importKey(`raw`,r,{name:`Ed25519`},n,t)},Ta=async(e,t,n=!0)=>await crypto.subtle.importKey(`jwk`,e,{name:`Ed25519`},n,t),Ea=async(e,t,n=!0)=>e.format===ya.jwk?await Ta(e.data,t,n):await wa(e.data,t,n),Da=async(e,t,n=!0)=>await Ea(xa(e),t,n),Oa=(e,t)=>({extractable:n=>t(n,e,!0),nonExtractable:n=>t(n,e,!1)}),ka={private:{fromFormattedString:Oa([`sign`],Da),fromSerializedObject:Oa([`sign`],Ea),fromJwk:Oa([`sign`],Ta)},public:{fromBase64:Oa([`verify`],wa),fromFormattedString:Oa([`verify`],Da),fromSerializedObject:Oa([`verify`],Ea),fromJwk:Oa([`verify`],Ta)}},Aa=async e=>{let t=await crypto.subtle.exportKey(`jwk`,e),n=`${va.ed25519}::${ya.jwk}::${JSON.stringify(t)}`;return{transformed:{formattedString:n,type:va.ed25519,data:t,format:ya.jwk},prefixed:n}},ja=async e=>{let t=await crypto.subtle.exportKey(`raw`,e),n=pi.encode(new Uint8Array(t)),r=`${va.ed25519}::${ya.raw_base64}::${n}`;return{transformed:{formattedString:r,type:va.ed25519,data:n,format:ya.raw_base64},prefixed:r}},Ma=async({challenge:e,signatureBase64:t,publicKey:n})=>{let r=Uint8Array.from(pi.decode(t)),i=new TextEncoder().encode(e);return await crypto.subtle.verify({name:`ED25519`},n,r,i)},Na=async()=>await crypto.subtle.generateKey({name:`X25519`},!0,[`deriveKey`,`deriveBits`]),Pa=async(e,t,n)=>{let r=Uint8Array.from(pi.decode(e));return await crypto.subtle.importKey(`raw`,r,{name:`X25519`},n,t)},Fa=async(e,t,n=!0)=>await crypto.subtle.importKey(`jwk`,e,{name:`X25519`},n,t),Ia=async(e,t,n=!0)=>e.format===ya.jwk?await Fa(e.data,t,n):await Pa(e.data,t,n),La=async(e,t,n=!0)=>await Ia(Ca(e),t,n),Ra=(e,t)=>({extractable:n=>t(n,e,!0),nonExtractable:n=>t(n,e,!1)}),za={private:{fromFormattedString:Ra([`deriveKey`,`deriveBits`],La),fromSerializedObject:Ra([`deriveKey`,`deriveBits`],Ia),fromJwk:Ra([`deriveKey`,`deriveBits`],Fa)},public:{fromBase64:Ra([],Pa),fromFormattedString:Ra([],La),fromSerializedObject:Ra([],Ia),fromJwk:Ra([],Fa)}},Ba=async e=>{let t=await crypto.subtle.exportKey(`jwk`,e),n=`${va.x25519}::${ya.jwk}::${JSON.stringify(t)}`;return{transformed:{formattedString:n,type:va.x25519,data:t,format:ya.jwk},prefixed:n}},Va=async e=>{let t=await crypto.subtle.exportKey(`raw`,e),n=pi.encode(new Uint8Array(t)),r=`${va.x25519}::${ya.raw_base64}::${n}`;return{transformed:{formattedString:r,type:va.x25519,data:n,format:ya.raw_base64},prefixed:r}},Ha=class extends Error{constructor(e=`ClientCryptoKeyLink: identity not provisioned (identityMode 'required'). Call provisionIdentity() once, out-of-band, before serving.`){super(e),this.name=`IdentityNotProvisionedError`}},Ua=class{localExchangeKeyPair;localVerifyKeyPair;linkedClientKeys=new Map;storage;identityMode;initialized=!1;initializePromise;localExchangeKeyPairPromise;localVerifyKeyPairPromise;constructor({storageAdapter:e,identityMode:t}={}){e!=null&&(this.storage=Li({storageAdapter:e})),this.identityMode=t??`lazy`}async initialize(){if(!this.initialized){this.initializePromise??=this.runInitialize();try{await this.initializePromise}finally{this.initializePromise=void 0}}}async runInitialize(){await this.loadStoredLocalKeys(),await this.loadLinkedClients(),this.initialized=!0}async provisionIdentity(){await this.initialize(),await this.mintLocalExchangeKeyPair(),await this.mintLocalVerifyKeyPair()}async loadStoredLocalKeys(){let e=await this.storage?.getJson(`localExchangeKeyPair`);if(e!=null){let t=await za.private.fromFormattedString.extractable(e.privateKey),n=await za.public.fromFormattedString.extractable(e.publicKey);this.localExchangeKeyPair={privateKey:t,publicKey:n}}let t=await this.storage?.getJson(`localVerifyKeyPair`);if(t!=null){let e=await ka.private.fromFormattedString.extractable(t.privateKey),n=await ka.public.fromFormattedString.extractable(t.publicKey);this.localVerifyKeyPair={privateKey:e,publicKey:n}}}async ensureLocalExchangeKeyPair(){if(this.localExchangeKeyPair!=null)return this.localExchangeKeyPair;if(this.identityMode===`required`)throw new Ha;return this.mintLocalExchangeKeyPair()}async mintLocalExchangeKeyPair(){if(this.localExchangeKeyPair!=null)return this.localExchangeKeyPair;this.localExchangeKeyPairPromise??=(async()=>{let e=await Na();return this.localExchangeKeyPair=e,this.storage!=null&&await this.storage.setJson(`localExchangeKeyPair`,await this.serializeExchangeKeyPair(e)),e})();try{return await this.localExchangeKeyPairPromise}finally{this.localExchangeKeyPairPromise=void 0}}async ensureLocalVerifyKeyPair(){if(this.localVerifyKeyPair!=null)return this.localVerifyKeyPair;if(this.identityMode===`required`)throw new Ha;return this.mintLocalVerifyKeyPair()}async mintLocalVerifyKeyPair(){if(this.localVerifyKeyPair!=null)return this.localVerifyKeyPair;this.localVerifyKeyPairPromise??=(async()=>{let e=await Ri();return this.localVerifyKeyPair=e,this.storage!=null&&await this.storage.setJson(`localVerifyKeyPair`,await this.serializeVerifyKeyPair(e)),e})();try{return await this.localVerifyKeyPairPromise}finally{this.localVerifyKeyPairPromise=void 0}}async loadLinkedClients(){let e=await this.storage?.getJson(`linkedClientPublicKeys`);if(e!=null)for(let[t,n]of Object.entries(e))await this.linkClient({linkedClientId:t,verifyPublicKey:n.verifyPublicKey,exchangePublicKey:n.exchangePublicKey,saltString:n.saltString,infoString:n.infoString,bindVerifyKeysIntoDerivation:n.bindVerifyKeysIntoDerivation})}async serializeExchangeKeyPair(e){return{publicKey:(await Va(e.publicKey)).prefixed,privateKey:(await Ba(e.privateKey)).prefixed}}async serializeVerifyKeyPair(e){return{publicKey:(await ja(e.publicKey)).prefixed,privateKey:(await Aa(e.privateKey)).prefixed}}async getLocalPublicKeys(){return{verifyPublicKey:await this.getLocalVerifyPublicKey(),exchangePublicKey:await this.getLocalExchangePublicKey()}}async getLocalExchangePublicKey(){return(await Va((await this.ensureLocalExchangeKeyPair()).publicKey)).prefixed}async getLocalVerifyPublicKey(){return(await ja((await this.ensureLocalVerifyKeyPair()).publicKey)).prefixed}async linkClient({linkedClientId:e,verifyPublicKey:t,exchangePublicKey:n,saltString:r,infoString:i,bindVerifyKeysIntoDerivation:a}){let o=this.linkedClientKeys.get(e),s=o?.verify;t!=null&&(s={publicKey:await ka.public.fromFormattedString.extractable(t),publicKeySerialized:t});let c=t!=null&&t!==o?.verify?.publicKeySerialized,l=o?.exchange;if(n!=null||r!==void 0||i!==void 0||a!==void 0){let t=n??o?.exchange?.publicKeySerialized;if(t==null)throw Error(`ClientCryptoKeyLink: Cannot set salt/info for ${e} without an exchange public key`);let s=r===void 0?o?.exchange?.saltString:r,u=i===void 0?o?.exchange?.infoString:i,d=a===void 0?o?.exchange?.bindVerifyKeysIntoDerivation:a,f;f=n==null?o.exchange.publicKey:await za.public.fromFormattedString.extractable(n);let p=t===o?.exchange?.publicKeySerialized&&s===o?.exchange?.saltString&&u===o?.exchange?.infoString&&d===o?.exchange?.bindVerifyKeysIntoDerivation&&!(d===!0&&c);l={publicKey:f,publicKeySerialized:t,saltString:s,infoString:u,bindVerifyKeysIntoDerivation:d,sharedEncryptKey:p?o?.exchange?.sharedEncryptKey:void 0}}else l?.bindVerifyKeysIntoDerivation===!0&&c&&l.sharedEncryptKey!=null&&(l={...l,sharedEncryptKey:void 0});this.linkedClientKeys.set(e,{verify:s,exchange:l})}async linkClientAndStore(e){if(await this.linkClient(e),this.storage==null)return;let{linkedClientId:t,verifyPublicKey:n,exchangePublicKey:r,saltString:i,infoString:a,bindVerifyKeysIntoDerivation:o}=e;await this.storage.updateJsonWithDef(`linkedClientPublicKeys`,{},e=>({...e,[t]:{...e[t],...n==null?{}:{verifyPublicKey:n},...r==null?{}:{exchangePublicKey:r},...i===void 0?{}:{saltString:i},...a===void 0?{}:{infoString:a},...o===void 0?{}:{bindVerifyKeysIntoDerivation:o}}}))}hasLinkedClient(e){return this.linkedClientKeys.has(e)}getLinkedClientPublicKeys(e){let t=this.linkedClientKeys.get(e);if(t!=null)return{verifyPublicKey:t.verify?.publicKeySerialized,exchangePublicKey:t.exchange?.publicKeySerialized}}async unlinkClient(e){this.linkedClientKeys.delete(e),this.storage!=null&&await this.storage.updateJson(`linkedClientPublicKeys`,t=>{if(t==null)return{};let{[e]:n,...r}=t;return r})}async unlinkAllClients(){this.linkedClientKeys.clear(),this.storage!=null&&await this.storage.setJson(`linkedClientPublicKeys`,{})}async reset(){this.linkedClientKeys.clear(),this.localExchangeKeyPair=void 0,this.localVerifyKeyPair=void 0,this.initialized=!1,this.storage!=null&&(await this.storage.removeItem(`linkedClientPublicKeys`),await this.storage.removeItem(`localExchangeKeyPair`),await this.storage.removeItem(`localVerifyKeyPair`))}getLinkedClient(e){let t=this.linkedClientKeys.get(e);if(t==null)throw Error(`ClientCryptoKeyLink: No linked client for ${e}`);return t}async getAesGcmKeyForLinkedClient(e){let t=this.getLinkedClient(e);if(t.exchange?.sharedEncryptKey!=null)return t.exchange.sharedEncryptKey;if(t.exchange?.publicKey==null)throw Error(`ClientCryptoKeyLink: No public exchange key set for ${e}`);let n=await this.ensureLocalExchangeKeyPair(),r=t.exchange.infoString;if(t.exchange.bindVerifyKeysIntoDerivation===!0){let n=t.verify?.publicKeySerialized;if(n==null)throw Error(`ClientCryptoKeyLink: Link for ${e} binds verify keys into the derivation, but no verify public key is set`);r=Fi({infoString:t.exchange.infoString,verifyPublicKeys:[await this.getLocalVerifyPublicKey(),n]})}let i=await Hr({internalX25519PrivateKey:n.privateKey,externalX25519PublicKey:t.exchange.publicKey,saltString:t.exchange.saltString,infoString:r});return this.linkedClientKeys.set(e,{...t,exchange:{...t.exchange,sharedEncryptKey:i}}),i}async deriveSharedAesGcmKey({exchangePublicKey:e,saltString:t,infoString:n,bindVerifyKeysIntoDerivation:r,verifyPublicKey:i}){let a=await this.ensureLocalExchangeKeyPair(),o=await za.public.fromFormattedString.extractable(e),s=n;if(r===!0){if(i==null)throw Error(`ClientCryptoKeyLink.deriveSharedAesGcmKey: a verify public key is required when binding verify keys into the derivation`);s=Fi({infoString:n,verifyPublicKeys:[await this.getLocalVerifyPublicKey(),i]})}return await Hr({internalX25519PrivateKey:a.privateKey,externalX25519PublicKey:o,saltString:t,infoString:s})}async deriveLocalSealKey(e){let t=await this.ensureLocalExchangeKeyPair();return await Hr({internalX25519PrivateKey:t.privateKey,externalX25519PublicKey:t.publicKey,infoString:`exchange-ticket-seal/${e?.version??`v1`}`})}async encryptDataForLinkedClient({dataToEncrypt:e,linkedClientId:t}){return await xi({dataToEncrypt:e,aesGcmKey:await this.getAesGcmKeyForLinkedClient(t)})}async decryptDataFromLinkedClient({dataToDecrypt:e,linkedClientId:t}){return await yi({dataToDecrypt:e,aesGcmKey:await this.getAesGcmKeyForLinkedClient(t)})}async encryptBytesForLinkedClient({dataToEncrypt:e,linkedClientId:t}){return await bi({dataToEncrypt:e,aesGcmKey:await this.getAesGcmKeyForLinkedClient(t)})}async decryptBytesFromLinkedClient({dataToDecrypt:e,linkedClientId:t}){return await Ur({dataToDecrypt:e,aesGcmKey:await this.getAesGcmKeyForLinkedClient(t)})}async signAndEncryptDataForLinkedClient({dataToEncrypt:e,linkedClientId:t}){let{signatureBase64:n}=await this.signChallenge([e]);return{encryptedData:await this.encryptDataForLinkedClient({dataToEncrypt:e,linkedClientId:t}),signatureBase64:n}}async decryptAndVerifyDataFromLinkedClient({dataToDecrypt:e,linkedClientId:t,signatureBase64:n}){let r=await this.decryptDataFromLinkedClient({dataToDecrypt:e,linkedClientId:t});return{data:r,isValid:await this.verifyChallengeFromLinkedClient({linkedClientId:t,challenge:r,signatureBase64:n})}}async signChallenge(e){if(e.length===0)throw Error(`Challenge must contain at least one string`);let t=await this.ensureLocalVerifyKeyPair(),n=e.length>1?await Pi(e,t.privateKey):await Ni(e[0],t.privateKey);return{signatureBase64:pi.encode(n)}}async signChallengeCanonical(e){return this.signChallenge([wi(e)])}async verifyChallengeCanonicalFromLinkedClient({linkedClientId:e,challenge:t,signatureBase64:n}){return this.verifyChallengeFromLinkedClient({linkedClientId:e,challenge:wi(t),signatureBase64:n})}async verifyChallengeFromLinkedClient({linkedClientId:e,challenge:t,signatureBase64:n}){let r=this.getLinkedClient(e);if(r.verify?.publicKey==null)throw Error(`ClientCryptoKeyLink: No verify public key set for ${e}`);return await Ma({challenge:t,signatureBase64:n,publicKey:r.verify.publicKey})}},Wa=function(e){return e.string=`string`,e.json=`json`,e}({}),Ga=class e{implementation;keyPrefix;durable;trackKeysForClearing;adapterStorage;indexMutationChain=Promise.resolve();constructor({methods:t,keyPrefix:n,trackKeysForClearing:r}){this.implementation=t,this.durable=t.durable,this.keyPrefix=n??``;let i=r??!0;this.trackKeysForClearing=i,this.adapterStorage=i?Li({storageAdapter:new e({methods:t,keyPrefix:n,trackKeysForClearing:!1})}):void 0}getPrefixedKey(e){return`${this.keyPrefix}${e}`}withIndexLock(e){let t=this.indexMutationChain.then(e,e);return this.indexMutationChain=t.then(()=>void 0,()=>void 0),t}withKeyPrefix(t){return new e({methods:this.implementation,keyPrefix:`${this.keyPrefix}${t}`,trackKeysForClearing:this.trackKeysForClearing})}async trackUsedKey(e){let t=this.adapterStorage;t&&await this.withIndexLock(()=>t.updateJsonWithDef(`__usedKeys__`,[],t=>t.includes(e)?t:[...t,e]))}async untrackUsedKey(e){let t=this.adapterStorage;t&&await this.withIndexLock(()=>t.updateJsonWithDef(`__usedKeys__`,[],t=>t.filter(t=>t!==e)))}async clearAll(){let e=this.adapterStorage;e&&await this.withIndexLock(async()=>{let t=await e.getJsonOrDef(`__usedKeys__`,[])??[];await Promise.all(t.map(e=>this.implementation.removeItem(this.getPrefixedKey(e)))),await e.removeItem(`__usedKeys__`)})}async removeItem(e){await this.implementation.removeItem(this.getPrefixedKey(e)),await this.untrackUsedKey(e)}async setJson(e,t){let n=this.getPrefixedKey(e);this.implementation.type===Wa.string?await this.implementation.setItem(n,JSON.stringify(t)):await this.implementation.setItem(n,t),await this.trackUsedKey(e)}async getJson(e){let t=this.getPrefixedKey(e);if(this.implementation.type===Wa.string){let e=await this.implementation.getItem(t);return e==null||e===`undefined`||e===`null`?void 0:JSON.parse(e)}else{let e=await this.implementation.getItem(t);return e==null||e===`undefined`||e===`null`?void 0:e}}async getJsonOrDef(e,t){if(this.implementation.type===Wa.string){let n=await this.implementation.getItem(this.getPrefixedKey(e));return n==null||n===`undefined`||n===`null`?t:JSON.parse(n)}let n=await this.implementation.getItem(this.getPrefixedKey(e));return n==null||n===`undefined`||n===`null`?t:n}async updateJson(e,t){let n=t(await this.getJson(e));return await this.setJson(e,n),n}async updateJsonOrDef(e,t,n){let r=n(await this.getJsonOrDef(e,t));return await this.setJson(e,r),r}createJsonGetterSetter(e){return{get:()=>this.getJson(e),set:t=>this.setJson(e,t)}}};function Ka(e=new Map){return{type:Wa.json,durable:!1,getItem:async t=>e.get(t),setItem:async(t,n)=>{e.set(t,n)},removeItem:async t=>{e.delete(t)}}}function qa(e){typeof e!=`number`&&e.unref?.()}var Ja=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`,Ya=(e=21)=>{let t=``,n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=Ja[n[e]&63];return t},Xa=[1],Za=`_unset_`;function Qa(e){return[`envId[${e.envId}]perId[${e.perId??`_`}]:insId[${e.insId??`_`}]`,`envId[${e.envId}]perId[${e.perId??`_`}]:insId[_]`,`envId[${e.envId}]perId[_]:insId[_]`]}var $a=class e{envId;perId;insId;get persistentId(){return this.perId}get instanceId(){return this.insId}static get unknown(){return new e({envId:Za})}static env(t){return new e({envId:t})}withPersistentId(e){return this.specify({perId:e})}withConnectionId(e){if(e.length===0||/[[\]:~]/.test(e))throw Error(`RuntimeCoordinate.withConnectionId: "${e}" is not a usable connection id — it must be non-empty and free of \`[\`, \`]\`, \`:\` and \`~\` (the coordinate's own string-form separators).`);return this.specify({insId:`${this.insId??`_`}~${e}`})}constructor({envId:e,perId:t,insId:n}){this.envId=e,this.perId=t,this.insId=n}specify(t){return new e({envId:this.envId,perId:this.perId,insId:this.insId,...t})}specifyIfUnset(t){return new e({envId:this.envId,perId:this.perId??t.perId,insId:this.insId??t.insId})}toJsonObject(){return{envId:this.envId,perId:this.perId,insId:this.insId}}isExactlySame(e){return this.envId===e.envId&&this.perId===e.perId&&this.insId===e.insId}isSameFor(e){return{id:this.envId===e.envId,perId:this.envId===e.envId&&this.perId===e.perId,insId:this.envId===e.envId&&this.perId===e.perId&&this.insId===e.insId}}similarityLevel(e){let t=this.isSameFor(e);return t.insId?3:t.perId?2:+!!t.id}get stringId(){return`envId[${this.envId}]perId[${this.perId??`_`}]:insId[${this.insId??`_`}]`}toStringIds(){return Qa(this)}},eo=`nice-ws-hs/1`,to=`reliable`,no=`reliable-streamkey`,ro=function(e){return e.none=`none`,e.authenticated=`authenticated`,e.encrypted=`encrypted`,e}({}),io=function(e){return e.hello=`hello`,e.welcome=`welcome`,e.prove=`prove`,e.accept=`accept`,e.reject=`reject`,e}({}),ao=oa(e=>typeof e==`string`&&e.startsWith(`ed25519::raw_base64::`)),oo=oa(e=>typeof e==`string`&&e.startsWith(`x25519::raw_base64::`)),so=da({envId:pa(),perId:F(pa()),insId:F(pa())}),co=fa([`none`,`authenticated`,`encrypted`]),lo=ma(`t`,[da({t:la(`hello`),protocol:pa(),securityLevel:co,dictionaryVersion:pa(),client:so,clientNonce:pa(),verifyPublicKey:ao,exchangePublicKey:F(oo),channels:F(ia(pa())),caps:F(ia(pa()))}),da({t:la(`welcome`),securityLevel:co,dictionaryVersion:pa(),server:so,serverNonce:pa(),verifyPublicKey:ao,exchangePublicKey:F(oo),caps:F(ia(pa()))}),da({t:la(`prove`),signatureBase64:pa()}),da({t:la(`accept`),signatureBase64:F(pa())}),da({t:la(`reject`),reason:pa(),id:F(pa()),observedProtocolVersion:F(ua()),supportedProtocolVersions:F(ia(ua()))})]);function uo(e){return JSON.stringify(e)}function fo(e){let t;try{t=JSON.parse(e)}catch{return}let n=ga(lo,t);return n.success?n.output:void 0}function po(e){return`runtime::${new $a(e).stringId}`}function mo(e){return new $a(e).stringId}function ho(e,t){return`${e}::${t}`}function go(e){return`${eo}::${e}`}function _o(e){return JSON.stringify([eo,e.securityLevel,e.dictionaryVersion,e.clientCoordId,e.serverCoordId,e.clientNonce,e.serverNonce,e.clientVerifyKey,e.serverVerifyKey,e.clientExchangeKey??`_`,e.serverExchangeKey??`_`])}function I(e){let{link:t,localCoordinate:n,dictionaryVersion:r,securityLevel:i,channelTags:a}=e,o=i===`encrypted`,s=Ya(),c;return{async createHello(){return{t:`hello`,protocol:eo,securityLevel:i,dictionaryVersion:r,client:n,clientNonce:s,verifyPublicKey:await t.getLocalVerifyPublicKey(),exchangePublicKey:o?await t.getLocalExchangePublicKey():void 0,channels:a==null?void 0:[...a],caps:[to,no,...e.extraCaps??[]]}},async onWelcome(a){if(a.dictionaryVersion!==r)throw Error(`[ws-handshake] server dictionary version mismatch`);if(a.securityLevel!==i)throw Error(`[ws-handshake] server security level mismatch`);if(o&&a.exchangePublicKey==null)throw Error(`[ws-handshake] server did not provide an exchange key for encryption`);let l=e.expectedPeer;if(l!=null&&(a.server.envId!==l.envId||l.perId!=null&&a.server.perId!==l.perId))throw Sr.fromId(`peer_identity_mismatch`,{expected:{envId:l.envId,perId:l.perId},actual:{envId:a.server.envId,perId:a.server.perId}});let u=po(a.server);await t.linkClient({linkedClientId:u,verifyPublicKey:a.verifyPublicKey,...o?{exchangePublicKey:a.exchangePublicKey,saltString:ho(s,a.serverNonce),infoString:go(r),bindVerifyKeysIntoDerivation:!0}:{}});let d=o&&a.exchangePublicKey!=null?{verifyPublicKey:a.verifyPublicKey,exchangePublicKey:a.exchangePublicKey,saltString:ho(s,a.serverNonce),infoString:go(r),bindVerifyKeysIntoDerivation:!0}:void 0,f=_o({securityLevel:i,dictionaryVersion:r,clientCoordId:mo(n),serverCoordId:mo(a.server),clientNonce:s,serverNonce:a.serverNonce,clientVerifyKey:await t.getLocalVerifyPublicKey(),serverVerifyKey:a.verifyPublicKey,clientExchangeKey:o?await t.getLocalExchangePublicKey():void 0,serverExchangeKey:a.exchangePublicKey});return c={linkedServerId:u,server:a.server,challenge:f,encryptionKeyMaterial:d,remoteCaps:a.caps},{t:`prove`,signatureBase64:(await t.signChallenge([f])).signatureBase64}},async onAccept(e){if(c==null)throw Error(`[ws-handshake] accept before welcome`);if(e.signatureBase64!=null&&!await t.verifyChallengeFromLinkedClient({linkedClientId:c.linkedServerId,challenge:c.challenge,signatureBase64:e.signatureBase64}))throw Error(`[ws-handshake] server signature invalid`);return{linkedClientId:c.linkedServerId,remote:c.server,securityLevel:i,encryptionKeyMaterial:c.encryptionKeyMaterial,remoteCaps:c.remoteCaps}}}}var vo={[ro.none]:0,[ro.authenticated]:1,[ro.encrypted]:2};function yo(e,t){return vo[e]>=vo[t]}var bo=e=>Sr.isExact(e)&&e.hasId(`dial_unavailable`),xo=e=>bo(e)||Sr.isExact(e)&&(e.hasId(`identity_pin_mismatch`)||e.hasId(`protocol_version_mismatch`)||e.hasId(`peer_identity_mismatch`)),So=class{mux;peer;localCoordinate;securityLevel;canPush;_cache=new Map;_manager;_buildConnectInput;_defaultLocalCoordinate;_linkEventListeners=new Set;_downSince;_currentLinkMethods;_tornDown=!1;_reconnectOption;_reconnectHooked=new WeakSet;_redialTimer;_redialAttempts=0;_suppressRedial=!1;_debugResumeTimer;_disposed=!1;debug={dropLink:async e=>{if(this._disposed)return;let t=e?.suppressRedialMs??0;if(this._cancelDebugResume(),this._currentLinkMethods!=null&&this._downSince==null&&(this._downSince=Date.now(),this._emitLinkEvent({type:`link_down`})),t>0){this._suppressRedial=!0,this._cancelRedial();let e=setTimeout(()=>{this._debugResumeTimer=void 0,!this._disposed&&(this._suppressRedial=!1,this._scheduleRedial())},t);qa(e),this._debugResumeTimer=e}this.clearCache()}};constructor(e){if(this.mux=e.mux,this.peer=e.peer,this.localCoordinate=e.localCoordinate,this.securityLevel=e.securityLevel??ro.none,this.canPush=e.canPush,e.reconnect!=null&&e.keepLinkAlive!=null)throw Sr.fromId(`conflicting_connect_options`,{detail:"WireClient: pass only `reconnect`; `keepLinkAlive` is deprecated"});this._reconnectOption=e.reconnect??e.keepLinkAlive,this._buildConnectInput=e.buildConnectInput,this._defaultLocalCoordinate=e.defaultLocalCoordinate,this._manager=e.createManager(this._cache)}addTransport(e){this._manager.addTransport(e)}getPreferredTransport(){return this._manager.getPreferredTransport()}async getReadyTransport(e){let t=await this._manager.getReadyTransport(e);return this._onLinkEstablished(t.methods),t}get wireMux(){return this.mux}get peerClient(){return this.peer}get requestReconnect(){return()=>void this.reconnectLink()}get _shouldReconnect(){return this._disposed||!this.canPush?!1:this._reconnectOption==null?(this.mux?.localCaps().length??0)>0:this._reconnectOption}_onLinkEstablished(e){let t=e!==this._currentLinkMethods;if(this._currentLinkMethods=e,this._suppressRedial=!1,this._tornDown=!1,this._redialAttempts=0,this._cancelRedial(),this._cancelDebugResume(),this._hookKeepAlive(e),t){let e=this._downSince==null?void 0:Date.now()-this._downSince;this._downSince=void 0,this._emitLinkEvent({type:`link_up`,downForMs:e})}}_hookKeepAlive(e){e.addOnDisconnectListener==null||this._reconnectHooked.has(e)||(this._reconnectHooked.add(e),e.addOnDisconnectListener(()=>{e===this._currentLinkMethods&&(this._tornDown||(this._downSince??(this._downSince=Date.now(),this._emitLinkEvent({type:`link_down`})),this._shouldReconnect&&!this._suppressRedial&&this._scheduleRedial()))}))}_scheduleRedial(){if(!this._shouldReconnect||this._suppressRedial||this._redialTimer!=null)return;let e=Math.min(1e3*2**this._redialAttempts,3e4),t=e/2+e/2*Math.random();this._redialAttempts+=1,this._emitLinkEvent({type:`redial_scheduled`,attempt:this._redialAttempts,delayMs:Math.round(t)});let n=setTimeout(()=>{this._redialTimer=void 0,this.connect().catch(()=>{})},t);qa(n),this._redialTimer=n}_cancelRedial(){this._redialTimer!=null&&(clearTimeout(this._redialTimer),this._redialTimer=void 0)}_cancelDebugResume(){this._debugResumeTimer!=null&&(clearTimeout(this._debugResumeTimer),this._debugResumeTimer=void 0)}async connect(e){let t=e?.localCoordinate??this.localCoordinate??this._defaultLocalCoordinate?.();if(t==null)throw Sr.fromId(`connect_exhausted`,{peerId:this.peer.stringId,attempted:[]});try{await this.getReadyTransport(this._buildConnectInput({localClient:t,externalClient:this.peer}))}catch(e){throw xo(e)||this._scheduleRedial(),e}}async reconnectLink(){this._cancelRedial(),this._suppressRedial=!0,this.clearCache();try{await this.connect()}catch(e){this._suppressRedial=!1,xo(e)||this._scheduleRedial()}}releaseLink(){this.clearTransportCache()}clearTransportCache(){this._suppressRedial=!0,this._tornDown=!0,this._cancelRedial(),this._cancelDebugResume(),this.clearCache()}dispose(){this._disposed=!0,this._tornDown=!0,this._cancelRedial(),this._cancelDebugResume(),this.clearCache()}clearCache(){for(let e of this._cache.values())e instanceof Promise?e.then(e=>e.methods.disconnect?.()).catch(()=>{}):e.methods.disconnect?.();this._cache.clear()}addLinkEventListener(e){return this._linkEventListeners.add(e),()=>{this._linkEventListeners.delete(e)}}_emitLinkEvent(e){for(let t of this._linkEventListeners)try{t(e)}catch(e){console.error(`[link] onLinkEvent listener threw`,e)}}},Co;try{Co=new TextDecoder}catch{}var L,wo,R=0,To=[],Eo=To,Do=0,z={},B,Oo,ko=0,Ao=0,jo,Mo,V=[],H,No={useRecords:!1,mapsAsObjects:!0},Po=class{},Fo=new Po;Fo.name=`MessagePack 0xC1`;var Io=!1,Lo=2,Ro=class e{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.sequential&&e.trusted!==!1&&(e.trusted=!0,!e.structures&&e.useRecords!=0&&(e.structures=[],e.maxSharedStructures||=0)),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0),e.int64AsNumber&&(e.int64AsType=`number`)),Object.assign(this,e)}unpack(t,n){if(L)return ps(()=>(ms(),this?this.unpack(t,n):e.prototype.unpack.call(No,t,n)));!t.buffer&&t.constructor===ArrayBuffer&&(t=typeof Buffer<`u`?Buffer.from(t):new Uint8Array(t)),typeof n==`object`?(wo=n.end||t.length,R=n.start||0):(R=0,wo=n>-1?n:t.length),Do=0,Ao=0,Oo=null,Eo=To,jo=null,L=t;try{H=t.dataView||=new DataView(t.buffer,t.byteOffset,t.byteLength)}catch(e){throw L=null,t instanceof Uint8Array?e:Error(`Source must be a Uint8Array or Buffer but was a `+(t&&typeof t==`object`?t.constructor.name:typeof t))}if(this instanceof e){if(z=this,this.structures)return B=this.structures,zo(n);(!B||B.length>0)&&(B=[])}else z=No,(!B||B.length>0)&&(B=[]);return zo(n)}unpackMultiple(e,t){let n,r=0;try{Io=!0;let i=e.length,a=this?this.unpack(e,i):gs.unpack(e,i);if(t){if(t(a,r,R)===!1)return;for(;R<i;)if(r=R,t(zo(),r,R)===!1)return}else{for(n=[a];R<i;)r=R,n.push(zo());return n}}catch(e){throw e.lastPosition=r,e.values=n,e}finally{Io=!1,ms()}}_mergeStructures(e,t){this._onLoadedStructures&&(e=this._onLoadedStructures(e)),e||=[],Object.isFrozen(e)&&(e=e.map(e=>e.slice(0)));for(let t=0,n=e.length;t<n;t++){let n=e[t];n&&(n.isShared=!0,t>=32&&(n.highByte=t-32>>5))}e.sharedLength=e.length;for(let n in t||[])if(n>=0){let r=e[n],i=t[n];i&&(r&&((e.restoreStructures||=[])[n]=r),e[n]=i)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function zo(e){try{if(!z.trusted&&!Io){let e=B.sharedLength||0;e<B.length&&(B.length=e)}let t;if(z._readStruct&&L[R]<64&&L[R]>=32?(t=z._readStruct(L,R,wo),L=null,!(e&&e.lazy)&&t&&(t=t.toJSON()),R=wo):t=Vo(),jo&&=(R=jo.postBundlePosition,null),Io&&(B.restoreStructures=null),R==wo)B&&B.restoreStructures&&Bo(),B=null,L=null,Mo&&=null;else if(R>wo)throw Error(`Unexpected end of MessagePack data`);else if(!Io){let e;try{e=JSON.stringify(t,(e,t)=>typeof t==`bigint`?`${t}n`:t).slice(0,100)}catch(t){e=`(JSON view not available `+t+`)`}throw Error(`Data read, but end of buffer not reached `+e)}return t}catch(e){throw B&&B.restoreStructures&&Bo(),ms(),(e instanceof RangeError||e.message.startsWith(`Unexpected end of buffer`)||R>wo)&&(e.incomplete=!0),e}}function Bo(){for(let e in B.restoreStructures)B[e]=B.restoreStructures[e];B.restoreStructures=null}function Vo(){let e=L[R++];if(e<160)if(e<128){if(e<64)return e;{let t=B[e&63]||z.getStructures&&Go()[e&63];return t?(t.read||=Uo(t,e&63),t.read()):e}}else if(e<144)if(e-=128,z.mapsAsObjects){let t={};for(let n=0;n<e;n++){let e=os();e===`__proto__`&&(e=`__proto_`),t[e]=Vo()}return t}else{let t=new Map;for(let n=0;n<e;n++)t.set(Vo(),Vo());return t}else{e-=144;let t=Array(e);for(let n=0;n<e;n++)t[n]=Vo();return z.freezeData?Object.freeze(t):t}else if(e<192){let t=e-160;if(Ao>=R)return Oo.slice(R-ko,(R+=t)-ko);if(Ao==0&&wo<140){let e=t<16?ts(t):es(t);if(e!=null)return e}return Ko(t)}else{let t;switch(e){case 192:return null;case 193:return jo?(t=Vo(),t>0?jo[1].slice(jo.position1,jo.position1+=t):jo[0].slice(jo.position0,jo.position0-=t)):Fo;case 194:return!1;case 195:return!0;case 196:if(t=L[R++],t===void 0)throw Error(`Unexpected end of buffer`);return rs(t);case 197:return t=H.getUint16(R),R+=2,rs(t);case 198:return t=H.getUint32(R),R+=4,rs(t);case 199:return is(L[R++]);case 200:return t=H.getUint16(R),R+=2,is(t);case 201:return t=H.getUint32(R),R+=4,is(t);case 202:if(t=H.getFloat32(R),z.useFloat32>2){let e=hs[(L[R]&127)<<1|L[R+1]>>7];return R+=4,(e*t+(t>0?.5:-.5)>>0)/e}return R+=4,t;case 203:return t=H.getFloat64(R),R+=8,t;case 204:return L[R++];case 205:return t=H.getUint16(R),R+=2,t;case 206:return t=H.getUint32(R),R+=4,t;case 207:return z.int64AsType===`number`?(t=H.getUint32(R)*4294967296,t+=H.getUint32(R+4)):z.int64AsType===`string`?t=H.getBigUint64(R).toString():z.int64AsType===`auto`?(t=H.getBigUint64(R),t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=H.getBigUint64(R),R+=8,t;case 208:return H.getInt8(R++);case 209:return t=H.getInt16(R),R+=2,t;case 210:return t=H.getInt32(R),R+=4,t;case 211:return z.int64AsType===`number`?(t=H.getInt32(R)*4294967296,t+=H.getUint32(R+4)):z.int64AsType===`string`?t=H.getBigInt64(R).toString():z.int64AsType===`auto`?(t=H.getBigInt64(R),t>=BigInt(-2)<<BigInt(52)&&t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=H.getBigInt64(R),R+=8,t;case 212:if(t=L[R++],t==114)return cs(L[R++]&63);{let e=V[t];if(e)return e.read?(R++,e.read(Vo())):e.noBuffer?(R++,e()):e(L.subarray(R,++R));throw Error(`Unknown extension `+t)}case 213:return t=L[R],t==114?(R++,cs(L[R++]&63,L[R++])):is(2);case 214:return is(4);case 215:return is(8);case 216:return is(16);case 217:return t=L[R++],Ao>=R?Oo.slice(R-ko,(R+=t)-ko):qo(t);case 218:return t=H.getUint16(R),R+=2,Ao>=R?Oo.slice(R-ko,(R+=t)-ko):Jo(t);case 219:return t=H.getUint32(R),R+=4,Ao>=R?Oo.slice(R-ko,(R+=t)-ko):Yo(t);case 220:return t=H.getUint16(R),R+=2,Zo(t);case 221:return t=H.getUint32(R),R+=4,Zo(t);case 222:return t=H.getUint16(R),R+=2,Qo(t);case 223:return t=H.getUint32(R),R+=4,Qo(t);default:if(e>=224)return e-256;if(e===void 0){let e=Error(`Unexpected end of MessagePack data`);throw e.incomplete=!0,e}throw Error(`Unknown MessagePack token `+e)}}}var Ho=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Uo(e,t){function n(){if(n.count++>Lo){let r;try{r=e.read=Function(`r`,`return function(){return `+(z.freezeData?`Object.freeze`:``)+`({`+e.map(e=>e===`__proto__`?`__proto_:r()`:Ho.test(e)?e+`:r()`:`[`+JSON.stringify(e)+`]:r()`).join(`,`)+`})}`)(Vo)}catch{return Lo=1/0,n()}return e.read0=r,e.highByte===0&&(e.read=Wo(t,e.read)),r()}let r={};for(let t=0,n=e.length;t<n;t++){let n=e[t];n===`__proto__`&&(n=`__proto_`),r[n]=Vo()}return z.freezeData?Object.freeze(r):r}return n.count=0,e.read0=n,e.highByte===0?Wo(t,n):n}var Wo=(e,t)=>function(){let n=L[R++];if(n===0)return t();let r=e<32?-(e+(n<<5)):e+(n<<5),i=B[r]||Go()[r];if(!i)throw Error(`Record id is not defined for `+r);return i.read||=Uo(i,e),i.read()};function Go(){let e=ps(()=>(L=null,z.getStructures()));return B=z._mergeStructures(e,B)}var Ko=Xo,qo=Xo,Jo=Xo,Yo=Xo;function Xo(e){let t;if(e<16&&(t=ts(e)))return t;if(e>64&&Co)return Co.decode(L.subarray(R,R+=e));let n=R+e,r=[];for(t=``;R<n;){let e=L[R++];if(!(e&128))r.push(e);else if((e&224)==192){let t=L[R++]&63,n=(e&31)<<6|t;n<128?r.push(65533):r.push(n)}else if((e&240)==224){let t=L[R++]&63,n=L[R++]&63,i=(e&31)<<12|t<<6|n;i<2048||i>=55296&&i<=57343?r.push(65533):r.push(i)}else if((e&248)==240){let t=L[R++]&63,n=L[R++]&63,i=L[R++]&63,a=(e&7)<<18|t<<12|n<<6|i;a<65536||a>1114111?r.push(65533):a>65535?(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023,r.push(a)):r.push(a)}else r.push(65533);r.length>=4096&&(t+=$o.apply(String,r),r.length=0)}return r.length>0&&(t+=$o.apply(String,r)),t}function Zo(e){let t=Array(e);for(let n=0;n<e;n++)t[n]=Vo();return z.freezeData?Object.freeze(t):t}function Qo(e){if(z.mapsAsObjects){let t={};for(let n=0;n<e;n++){let e=os();e===`__proto__`&&(e=`__proto_`),t[e]=Vo()}return t}else{let t=new Map;for(let n=0;n<e;n++)t.set(Vo(),Vo());return t}}var $o=String.fromCharCode;function es(e){let t=R,n=Array(e);for(let r=0;r<e;r++){let e=L[R++];if((e&128)>0){R=t;return}n[r]=e}return $o.apply(String,n)}function ts(e){if(e<4)if(e<2){if(e===0)return``;{let e=L[R++];if((e&128)>1){--R;return}return $o(e)}}else{let t=L[R++],n=L[R++];if((t&128)>0||(n&128)>0){R-=2;return}if(e<3)return $o(t,n);let r=L[R++];if((r&128)>0){R-=3;return}return $o(t,n,r)}else{let t=L[R++],n=L[R++],r=L[R++],i=L[R++];if((t&128)>0||(n&128)>0||(r&128)>0||(i&128)>0){R-=4;return}if(e<6){if(e===4)return $o(t,n,r,i);{let e=L[R++];if((e&128)>0){R-=5;return}return $o(t,n,r,i,e)}}else if(e<8){let a=L[R++],o=L[R++];if((a&128)>0||(o&128)>0){R-=6;return}if(e<7)return $o(t,n,r,i,a,o);let s=L[R++];if((s&128)>0){R-=7;return}return $o(t,n,r,i,a,o,s)}else{let a=L[R++],o=L[R++],s=L[R++],c=L[R++];if((a&128)>0||(o&128)>0||(s&128)>0||(c&128)>0){R-=8;return}if(e<10){if(e===8)return $o(t,n,r,i,a,o,s,c);{let e=L[R++];if((e&128)>0){R-=9;return}return $o(t,n,r,i,a,o,s,c,e)}}else if(e<12){let l=L[R++],u=L[R++];if((l&128)>0||(u&128)>0){R-=10;return}if(e<11)return $o(t,n,r,i,a,o,s,c,l,u);let d=L[R++];if((d&128)>0){R-=11;return}return $o(t,n,r,i,a,o,s,c,l,u,d)}else{let l=L[R++],u=L[R++],d=L[R++],f=L[R++];if((l&128)>0||(u&128)>0||(d&128)>0||(f&128)>0){R-=12;return}if(e<14){if(e===12)return $o(t,n,r,i,a,o,s,c,l,u,d,f);{let e=L[R++];if((e&128)>0){R-=13;return}return $o(t,n,r,i,a,o,s,c,l,u,d,f,e)}}else{let p=L[R++],m=L[R++];if((p&128)>0||(m&128)>0){R-=14;return}if(e<15)return $o(t,n,r,i,a,o,s,c,l,u,d,f,p,m);let h=L[R++];if((h&128)>0){R-=15;return}return $o(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)}}}}}function ns(){let e=L[R++],t;if(e<192)t=e-160;else switch(e){case 217:t=L[R++];break;case 218:t=H.getUint16(R),R+=2;break;case 219:t=H.getUint32(R),R+=4;break;default:throw Error(`Expected string`)}return Xo(t)}function rs(e){return z.copyBuffers?Uint8Array.prototype.slice.call(L,R,R+=e):L.subarray(R,R+=e)}function is(e){let t=L[R++];if(V[t]){let n;return V[t](L.subarray(R,n=R+=e),e=>{R=e;try{return Vo()}finally{R=n}})}else throw Error(`Unknown extension type `+t)}var as=Array(4096);function os(){let e=L[R++];if(e>=160&&e<192){if(e-=160,Ao>=R)return Oo.slice(R-ko,(R+=e)-ko);if(!(Ao==0&&wo<180))return Ko(e)}else return R--,ss(Vo());let t=(e<<5^(e>1?H.getUint16(R):e>0?L[R]:0))&4095,n=as[t],r=R,i=R+e-3,a,o=0;if(n&&n.bytes==e){for(;r<i;){if(a=H.getUint32(r),a!=n[o++]){r=1879048192;break}r+=4}for(i+=3;r<i;)if(a=L[r++],a!=n[o++]){r=1879048192;break}if(r===i)return R=r,n.string;i-=3,r=R}for(n=[],as[t]=n,n.bytes=e;r<i;)a=H.getUint32(r),n.push(a),r+=4;for(i+=3;r<i;)a=L[r++],n.push(a);let s=e<16?ts(e):es(e);return s==null?n.string=Ko(e):n.string=s}function ss(e){if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return e.toString();if(e==null)return e+``;if(z.allowArraysInMapKeys&&Array.isArray(e)&&e.flat().every(e=>[`string`,`number`,`boolean`,`bigint`].includes(typeof e)))return e.flat().toString();throw Error(`Invalid property type for record: ${typeof e}`)}var cs=(e,t)=>{let n=Vo().map(ss),r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,n.highByte=t);let i=B[e];return i&&(i.isShared||Io)&&((B.restoreStructures||=[])[e]=i),B[e]=n,n.read=Uo(n,r),(n.read0||n.read)()};V[0]=()=>{},V[0].noBuffer=!0,V[66]=e=>{let t=e.byteLength%8||8,n=BigInt(e[0]&128?e[0]-256:e[0]);for(let r=1;r<t;r++)n<<=BigInt(8),n+=BigInt(e[r]);if(e.byteLength!==t){let r=new DataView(e.buffer,e.byteOffset,e.byteLength),i=(e,t)=>{let n=t-e;if(n<=40){let n=r.getBigUint64(e);for(let i=e+8;i<t;i+=8)n<<=BigInt(64),n|=r.getBigUint64(i);return n}let a=e+(n>>4<<3),o=i(e,a),s=i(a,t);return o<<BigInt((t-a)*8)|s};n=n<<BigInt((r.byteLength-t)*8)|i(t,r.byteLength)}return n};var ls={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError==`function`?AggregateError:null};V[101]=()=>{let e=Vo();if(!ls[e[0]]){let t=Error(e[1],{cause:e[2]});return t.name=e[0],t}return ls[e[0]](e[1],{cause:e[2]})},V[105]=e=>{if(z.structuredClone===!1)throw Error(`Structured clone extension is disabled`);let t=H.getUint32(R-4);Mo||=new Map;let n=L[R],r;r=n>=144&&n<160||n==220||n==221?[]:n>=128&&n<144||n==222||n==223?new Map:(n>=199&&n<=201||n>=212&&n<=216)&&L[R+1]===115?new Set:{};let i={target:r};Mo.set(t,i);let a=Vo();if(i.used)Object.assign(r,a);else return i.target=a;if(r instanceof Map)for(let[e,t]of a.entries())r.set(e,t);if(r instanceof Set)for(let e of Array.from(a))r.add(e);return r},V[112]=e=>{if(z.structuredClone===!1)throw Error(`Structured clone extension is disabled`);let t=H.getUint32(R-4),n=Mo.get(t);return n.used=!0,n.target},V[115]=()=>new Set(Vo());var us=[`Int8`,`Uint8`,`Uint8Clamped`,`Int16`,`Uint16`,`Int32`,`Uint32`,`Float32`,`Float64`,`BigInt64`,`BigUint64`].map(e=>e+`Array`),ds=typeof globalThis==`object`?globalThis:window;V[116]=e=>{let t=e[0],n=Uint8Array.prototype.slice.call(e,1).buffer,r=us[t];if(!r){if(t===16)return n;if(t===17)return new DataView(n);throw Error(`Could not find typed array for code `+t)}return new ds[r](n)},V[120]=()=>{let e=Vo();return new RegExp(e[0],e[1])};var fs=[];V[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],n=R;return R+=t-e.length,jo=fs,jo=[ns(),ns()],jo.position0=0,jo.position1=0,jo.postBundlePosition=R,R=n,Vo()},V[255]=e=>e.length==4?new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3):new Date(`invalid`);function ps(e){z&&z._onSaveState&&z._onSaveState();let t=wo,n=R,r=Do,i=ko,a=Ao,o=Oo,s=Eo,c=Mo,l=jo,u=new Uint8Array(L.slice(0,wo)),d=B,f=B.slice(0,B.length),p=z,m=Io,h=e();return wo=t,R=n,Do=r,ko=i,Ao=a,Oo=o,Eo=s,Mo=c,jo=l,L=u,Io=m,B=d,B.splice(0,B.length,...f),z=p,H=new DataView(L.buffer,L.byteOffset,L.byteLength),h}function ms(){L=null,Mo=null,B=null}var hs=Array(147);for(let e=0;e<256;e++)hs[e]=+(`1e`+Math.floor(45.15-e*.30103));var gs=new Ro({useRecords:!1}),_s=gs.unpack;gs.unpackMultiple,gs.unpack;var vs={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4};new Uint8Array(new Float32Array(1).buffer,0,4),Ro.SUPPORTS_STRUCT_HOOKS=!0;var ys;try{ys=new TextEncoder}catch{}var bs,xs,Ss=typeof Buffer<`u`,Cs=Ss?function(e){return Buffer.allocUnsafeSlow(e)}:Uint8Array,ws=Ss?Buffer:Uint8Array,Ts=Ss?4294967296:2144337920,U,Es,Ds,W=0,Os,ks=null,As=21760,js=/[\u0080-\uFFFF]/,Ms=Symbol(`record-id`),Ns=class extends Ro{constructor(e){super(e),this.offset=0;let t,n,r,i,a=ws.prototype.utf8Write?function(e,t){return U.utf8Write(e,t,U.byteLength-t)}:ys&&ys.encodeInto?function(e,t){return ys.encodeInto(e,U.subarray(t)).written}:!1,o=this;e||={};let s=e&&e.sequential,c=e.structures||e.saveStructures,l=e.maxSharedStructures;if(l??=c?32:0,l>8160)throw Error(`Maximum maxSharedStructure is 8160`);e.structuredClone&&e.moreTypes==null&&(this.moreTypes=!0);let u=e.maxOwnStructures;u??=c?32:64,!this.structures&&e.useRecords!=0&&(this.structures=[]);let d=l>32||u+l>64,f=l+64,p=l+u+64;if(p>8256)throw Error(`Maximum maxSharedStructure + maxOwnStructure is 8192`);let m=[],h=0,g=0;this.pack=this.encode=function(e,a){if(U||(U=new Cs(8192),Ds=U.dataView||=new DataView(U.buffer,0,8192),W=0),Os=U.length-10,Os-W<2048?(U=new Cs(U.length),Ds=U.dataView||=new DataView(U.buffer,0,U.length),Os=U.length-10,W=0):W=W+7&2147483640,t=W,a&2048&&(W+=a&255),i=o.structuredClone?new Map:null,o.bundleStrings&&typeof e!=`string`?(ks=[],ks.size=1/0):ks=null,r=o.structures,r){r.uninitialized&&(r=o._mergeStructures(o.getStructures()));let e=r.sharedLength||0;if(e>l)throw Error(`Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to `+r.sharedLength);if(!r.transitions){r.transitions=Object.create(null);for(let t=0;t<e;t++){let e=r[t];if(!e)continue;let n,i=r.transitions;for(let t=0,r=e.length;t<r;t++){let r=e[t];n=i[r],n||=i[r]=Object.create(null),i=n}i[Ms]=t+64}this.lastNamedStructuresLength=e}s||(r.nextId=e+64)}n&&=!1;let c;try{o._writeStruct&&e&&typeof e==`object`?e.constructor===Object?C(e):e.constructor!==Map&&!Array.isArray(e)&&!xs.some(t=>e instanceof t)?C(e.toJSON?e.toJSON():e):y(e):y(e);let n=ks;if(ks&&Rs(t,y,0),i&&i.idsToInsert){let e=i.idsToInsert.sort((e,t)=>e.offset>t.offset?1:-1),r=e.length,a=-1;for(;n&&r>0;){let i=e[--r].offset+t;i<n.stringsPosition+t&&a===-1&&(a=0),i>n.position+t?a>=0&&(a+=6):(a>=0&&(Ds.setUint32(n.position+t,Ds.getUint32(n.position+t)+a),a=-1),n=n.previous,r++)}a>=0&&n&&Ds.setUint32(n.position+t,Ds.getUint32(n.position+t)+a),W+=e.length*6,W>Os&&w(W),o.offset=W;let s=Ls(U.subarray(t,W),e);return i=null,s}return o.offset=W,a&512?(U.start=t,U.end=W,U):U.subarray(t,W)}catch(e){throw c=e,e}finally{if(r&&(_(),n&&o.saveStructures)){let n=r.sharedLength||0,i=U.subarray(t,W),s=(o._prepareStructures||zs)(r,o);if(!c)return o.saveStructures(s,s.isCompatible)===!1?(r.uninitialized=!0,o.pack(e,a)):(o.lastNamedStructuresLength=n,U.length>1073741824&&(U=null),i)}U.length>1073741824&&(U=null),a&1024&&(W=t)}};let _=()=>{g<10&&g++;let e=r.sharedLength||0;if(r.length>e&&!s&&(r.length=e),h>1e4)r.transitions=null,g=0,h=0,m.length>0&&(m=[]);else if(m.length>0&&!s){for(let e=0,t=m.length;e<t;e++)m[e][Ms]=0;m=[]}},v=e=>{var t=e.length;t<16?U[W++]=144|t:t<65536?(U[W++]=220,U[W++]=t>>8,U[W++]=t&255):(U[W++]=221,Ds.setUint32(W,t),W+=4);for(let n=0;n<t;n++)y(e[n])},y=e=>{W>Os&&(U=w(W));var n=typeof e,r;if(n===`string`){let n=e.length;if(ks&&n>=4&&n<4096){if((ks.size+=n)>As){let e,n=(ks[0]?ks[0].length*3+ks[1].length:0)+10;W+n>Os&&(U=w(W+n));let r;ks.position?(r=ks,U[W]=200,W+=3,U[W++]=98,e=W-t,W+=4,Rs(t,y,0),Ds.setUint16(e+t-3,W-t-e)):(U[W++]=214,U[W++]=98,e=W-t,W+=4),ks=[``,``],ks.previous=r,ks.size=0,ks.position=e}let r=js.test(e);ks[+!r]+=e,U[W++]=193,y(r?-n:n);return}let i;i=n<32?1:n<256?2:n<65536?3:5;let o=n*3;if(W+o>Os&&(U=w(W+o)),n<64||!a){let t,a,o,s=W+i;for(t=0;t<n;t++)a=e.charCodeAt(t),a<128?U[s++]=a:a<2048?(U[s++]=a>>6|192,U[s++]=a&63|128):(a&64512)==55296&&((o=e.charCodeAt(t+1))&64512)==56320?(a=65536+((a&1023)<<10)+(o&1023),t++,U[s++]=a>>18|240,U[s++]=a>>12&63|128,U[s++]=a>>6&63|128,U[s++]=a&63|128):(U[s++]=a>>12|224,U[s++]=a>>6&63|128,U[s++]=a&63|128);r=s-W-i}else r=a(e,W+i);r<32?U[W++]=160|r:r<256?(i<2&&U.copyWithin(W+2,W+1,W+1+r),U[W++]=217,U[W++]=r):r<65536?(i<3&&U.copyWithin(W+3,W+2,W+2+r),U[W++]=218,U[W++]=r>>8,U[W++]=r&255):(i<5&&U.copyWithin(W+5,W+3,W+3+r),U[W++]=219,Ds.setUint32(W,r),W+=4),W+=r}else if(n===`number`)if(e>>>0===e)e<32||e<128&&this.useRecords===!1||e<64&&!this._writeStruct?U[W++]=e:e<256?(U[W++]=204,U[W++]=e):e<65536?(U[W++]=205,U[W++]=e>>8,U[W++]=e&255):(U[W++]=206,Ds.setUint32(W,e),W+=4);else if(e>>0===e)e>=-32?U[W++]=256+e:e>=-128?(U[W++]=208,U[W++]=e+256):e>=-32768?(U[W++]=209,Ds.setInt16(W,e),W+=2):(U[W++]=210,Ds.setInt32(W,e),W+=4);else{let t;if((t=this.useFloat32)>0&&e<4294967296&&e>=-2147483648){U[W++]=202,Ds.setFloat32(W,e);let n;if(t<4||(n=e*hs[(U[W]&127)<<1|U[W+1]>>7])>>0===n){W+=4;return}else W--}U[W++]=203,Ds.setFloat64(W,e),W+=8}else if(n===`object`||n===`function`)if(!e)U[W++]=192;else{if(i){let n=i.get(e);if(n){n.id||=(i.idsToInsert||=[]).push(n),U[W++]=214,U[W++]=112,Ds.setUint32(W,n.id),W+=4;return}else i.set(e,{offset:W-t})}let a=e.constructor;if(a===Object)S(e);else if(a===Array)v(e);else if(a===Map)if(this.mapAsEmptyObject)U[W++]=128;else{r=e.size,r<16?U[W++]=128|r:r<65536?(U[W++]=222,U[W++]=r>>8,U[W++]=r&255):(U[W++]=223,Ds.setUint32(W,r),W+=4);for(let[t,n]of e)y(t),y(n)}else{for(let t=0,n=bs.length;t<n;t++){let n=xs[t];if(e instanceof n){let n=bs[t];if(n.write){n.type&&(U[W++]=212,U[W++]=n.type,U[W++]=0);let t=n.write.call(this,e);t===e?Array.isArray(e)?v(e):S(e):y(t);return}let r=U,i=Ds,a=W;U=null;let o;try{o=n.pack.call(this,e,e=>(U=r,r=null,W+=e,W>Os&&w(W),{target:U,targetView:Ds,position:W-e}),y)}finally{r&&(U=r,Ds=i,W=a,Os=U.length-10)}o&&(o.length+W>Os&&w(o.length+W),W=Is(o,U,W,n.type));return}}if(Array.isArray(e))v(e);else{if(e.toJSON){let t=e.toJSON();if(t!==e)return y(t)}if(n===`function`)return y(this.writeFunction&&this.writeFunction(e));S(e)}}}else if(n===`boolean`)U[W++]=e?195:194;else if(n===`bigint`){if(e<0x8000000000000000&&e>=-0x8000000000000000)U[W++]=211,Ds.setBigInt64(W,e);else if(e<0x10000000000000000&&e>0)U[W++]=207,Ds.setBigUint64(W,e);else if(this.largeBigIntToFloat)U[W++]=203,Ds.setFloat64(W,Number(e));else if(this.largeBigIntToString)return y(e.toString());else if(this.useBigIntExtension||this.moreTypes){let t=BigInt(e<0?-1:0),n;if(e>>BigInt(65536)===t){let r=BigInt(0x10000000000000000)-BigInt(1),i=[];for(;i.push(e&r),e>>BigInt(63)!==t;)e>>=BigInt(64);n=new Uint8Array(new BigUint64Array(i).buffer),n.reverse()}else{let t=e<0,r=(t?~e:e).toString(16);if(r.length%2?r=`0`+r:parseInt(r.charAt(0),16)>=8&&(r=`00`+r),Ss)n=Buffer.from(r,`hex`);else{n=new Uint8Array(r.length/2);for(let e=0;e<n.length;e++)n[e]=parseInt(r.slice(e*2,e*2+2),16)}if(t)for(let e=0;e<n.length;e++)n[e]=~n[e]}n.length+W>Os&&w(n.length+W),W=Is(n,U,W,66);return}else throw RangeError(e+` was too large to fit in MessagePack 64-bit integer format, use useBigIntExtension, or set largeBigIntToFloat to convert to float-64, or set largeBigIntToString to convert to string`);W+=8}else if(n===`undefined`)this.encodeUndefinedAsNil?U[W++]=192:(U[W++]=212,U[W++]=0,U[W++]=0);else throw Error(`Unknown type: `+n)},b=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?e=>{let t;if(this.skipValues){t=[];for(let n in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(n))&&!this.skipValues.includes(e[n])&&t.push(n)}else t=Object.keys(e);let n=t.length;n<16?U[W++]=128|n:n<65536?(U[W++]=222,U[W++]=n>>8,U[W++]=n&255):(U[W++]=223,Ds.setUint32(W,n),W+=4);let r;if(this.coercibleKeyAsNumber)for(let i=0;i<n;i++){r=t[i];let n=Number(r);y(isNaN(n)?r:n),y(e[r])}else for(let i=0;i<n;i++)y(r=t[i]),y(e[r])}:e=>{U[W++]=222;let n=W-t;W+=2;let r=0;for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(y(t),y(e[t]),r++);if(r>65535)throw Error(`Object is too large to serialize with fast 16-bit map size, use the "variableMapSize" option to serialize this object`);U[n+++t]=r>>8,U[n+t]=r&255},x=this.useRecords===!1?b:e.progressiveRecords&&!d?e=>{let n,i=r.transitions||=Object.create(null),a=W++-t,o;for(let s in e)if(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(s)){if(n=i[s],n)i=n;else{let c=Object.keys(e),l=i;i=r.transitions;let u=0;for(let e=0,t=c.length;e<t;e++){let t=c[e];n=i[t],n||(n=i[t]=Object.create(null),u++),i=n}a+t+1==W?(W--,T(i,c,u)):te(i,c,a,u),o=!0,i=l[s]}y(e[s])}if(!o){let n=i[Ms];n?U[a+t]=n:te(i,Object.keys(e),a,0)}}:e=>{let t,n=r.transitions||=Object.create(null),i=0;for(let r in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(r))&&(t=n[r],t||(t=n[r]=Object.create(null),i++),n=t);let a=n[Ms];a?a>=96&&d?(U[W++]=((a-=96)&31)+96,U[W++]=a>>5):U[W++]=a:T(n,n.__keys__||Object.keys(e),i);for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&y(e[t])},ee=typeof this.useRecords==`function`&&this.useRecords,S=ee?e=>{ee(e)?x(e):b(e)}:x,C=e=>{let i=o._writeStruct(e,U,t,W,r,w,(e,t,r)=>{if(r)return n=!0;W=t;let i=U;return y(e),_(),i===U?W:{position:W,targetView:Ds,target:U}});if(i===0)return S(e);W=i},w=e=>{let n;if(e>16777216){if(e-t>Ts)throw Error(`Packed buffer would be larger than maximum buffer size`);n=Math.min(Ts,Math.round(Math.max((e-t)*(e>67108864?1.25:2),4194304)/4096)*4096)}else n=(Math.max(e-t<<2,U.length-1)>>12)+1<<12;let r=new Cs(n);return Ds=r.dataView||=new DataView(r.buffer,0,n),e=Math.min(e,U.length),U.copy?U.copy(r,0,t,e):r.set(U.slice(t,e)),W-=t,t=0,Os=r.length-10,U=r},T=(e,t,i)=>{let a=r.nextId;a||=64,a<f&&this.shouldShareStructure&&!this.shouldShareStructure(t)?(a=r.nextOwnId,a<p||(a=f),r.nextOwnId=a+1):(a>=p&&(a=f),r.nextId=a+1);let o=t.highByte=a>=96&&d?a-96>>5:-1;e[Ms]=a,e.__keys__=t,r[a-64]=t,a<f?(t.isShared=!0,r.sharedLength=a-63,n=!0,o>=0?(U[W++]=(a&31)+96,U[W++]=o):U[W++]=a):(o>=0?(U[W++]=213,U[W++]=114,U[W++]=(a&31)+96,U[W++]=o):(U[W++]=212,U[W++]=114,U[W++]=a),i&&(h+=g*i),m.length>=u&&(m.shift()[Ms]=0),m.push(e),y(t))},te=(e,n,r,i)=>{let a=U,o=W,s=Os,c=t;U=Es,W=0,t=0,U||(Es=U=new Cs(8192)),Os=U.length-10,T(e,n,i),Es=U;let l=W;if(U=a,W=o,Os=s,t=c,l>1){let e=W+l-1;e>Os&&w(e);let n=r+t;U.copyWithin(n+l,n+1,W),U.set(Es.slice(0,l),n),W=e}else U[r+t]=Es[0]}}useBuffer(e){U=e,U.dataView||=new DataView(U.buffer,U.byteOffset,U.byteLength),Ds=U.dataView,W=0}set position(e){W=e}get position(){return W}clearSharedData(){this.structures&&=[],this.typedStructs&&=[]}};xs=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,DataView,Po],bs=[{pack(e,t,n){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:e,targetView:n,position:i}=t(6);e[i++]=214,e[i++]=255,n.setUint32(i,r)}else if(r>0&&r<4294967296){let{target:n,targetView:i,position:a}=t(10);n[a++]=215,n[a++]=255,i.setUint32(a,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),i.setUint32(a+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),n(this.onInvalidDate());let{target:e,targetView:r,position:i}=t(3);e[i++]=212,e[i++]=255,e[i++]=255}else{let{target:n,targetView:i,position:a}=t(15);n[a++]=199,n[a++]=12,n[a++]=255,i.setUint32(a,e.getMilliseconds()*1e6),i.setBigInt64(a+4,BigInt(Math.floor(r)))}}},{pack(e,t,n){if(this.setAsEmptyObject)return t(0),n({});let r=Array.from(e),{target:i,position:a}=t(this.moreTypes?3:0);this.moreTypes&&(i[a++]=212,i[a++]=115,i[a++]=0),n(r)}},{pack(e,t,n){let{target:r,position:i}=t(this.moreTypes?3:0);this.moreTypes&&(r[i++]=212,r[i++]=101,r[i++]=0),n([e.name,e.message,e.cause])}},{pack(e,t,n){let{target:r,position:i}=t(this.moreTypes?3:0);this.moreTypes&&(r[i++]=212,r[i++]=120,r[i++]=0),n([e.source,e.flags])}},{pack(e,t){this.moreTypes?Ps(e,16,t):Fs(Ss?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let n=e.constructor;n!==ws&&this.moreTypes?Ps(e,us.indexOf(n.name),t):Fs(e,t)}},{pack(e,t){this.moreTypes?Ps(e,17,t):Fs(Ss?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let{target:n,position:r}=t(1);n[r]=193}}];function Ps(e,t,n,r){let i=e.byteLength;if(i+1<256){var{target:a,position:o}=n(4+i);a[o++]=199,a[o++]=i+1}else if(i+1<65536){var{target:a,position:o}=n(5+i);a[o++]=200,a[o++]=i+1>>8,a[o++]=i+1&255}else{var{target:a,position:o,targetView:s}=n(7+i);a[o++]=201,s.setUint32(o,i+1),o+=4}a[o++]=116,a[o++]=t,e.buffer||(e=new Uint8Array(e)),a.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),o)}function Fs(e,t){let n=e.byteLength;var r,i;if(n<256){var{target:r,position:i}=t(n+2);r[i++]=196,r[i++]=n}else if(n<65536){var{target:r,position:i}=t(n+3);r[i++]=197,r[i++]=n>>8,r[i++]=n&255}else{var{target:r,position:i,targetView:a}=t(n+5);r[i++]=198,a.setUint32(i,n),i+=4}r.set(e,i)}function Is(e,t,n,r){let i=e.length;switch(i){case 1:t[n++]=212;break;case 2:t[n++]=213;break;case 4:t[n++]=214;break;case 8:t[n++]=215;break;case 16:t[n++]=216;break;default:i<256?(t[n++]=199,t[n++]=i):i<65536?(t[n++]=200,t[n++]=i>>8,t[n++]=i&255):(t[n++]=201,t[n++]=i>>24,t[n++]=i>>16&255,t[n++]=i>>8&255,t[n++]=i&255)}return t[n++]=r,t.set(e,n),n+=i,n}function Ls(e,t){let n,r=t.length*6,i=e.length-r;for(;n=t.pop();){let t=n.offset,a=n.id;e.copyWithin(t+r,t,i),r-=6;let o=t+r;e[o++]=214,e[o++]=105,e[o++]=a>>24,e[o++]=a>>16&255,e[o++]=a>>8&255,e[o++]=a&255,i=t}return e}function Rs(e,t,n){if(ks.length>0){Ds.setUint32(ks.position+e,W+n-ks.position-e),ks.stringsPosition=W-e;let r=ks;ks=null,t(r[0]),t(r[1])}}function zs(e,t){return e.isCompatible=e=>{let n=!e||(t.lastNamedStructuresLength||0)===e.length;return n||t._mergeStructures(e),n},e}Ns.SUPPORTS_STRUCT_HOOKS=!0;var Bs=new Ns({useRecords:!1}),Vs=Bs.pack;Bs.pack;var{NEVER:Hs,ALWAYS:Us,DECIMAL_ROUND:Ws,DECIMAL_FIT:Gs}=vs,Ks=2;function qs({link:e,keyMaterial:t}){let n=e.deriveSharedAesGcmKey(t);return{async encryptFrame(e){let{nonce:t,ciphertext:r}=await bi({dataToEncrypt:e,aesGcmKey:await n});return Vs([t,r])},async decryptFrame(e){if(typeof e==`string`)throw Error(`[ws-crypto] expected an encrypted binary frame, received text`);let t=_s(e instanceof ArrayBuffer?new Uint8Array(e):e);if(!Array.isArray(t)||t.length!==Ks)throw Error(`[ws-crypto] malformed encrypted frame envelope`);let[r,i]=t;if(!(r instanceof Uint8Array)||!(i instanceof Uint8Array))throw Error(`[ws-crypto] malformed encrypted frame fields`);return await Ur({dataToDecrypt:{nonce:r,ciphertext:i},aesGcmKey:await n})}}}var Js={invalid:0,realm:1,devtools:2};function Ys(e){let t;if(e instanceof Uint8Array)t=e.length>0?e[0]:void 0;else if(e instanceof ArrayBuffer)t=e.byteLength>0?new Uint8Array(e,0,1)[0]:void 0;else return;if(!(t==null||t>15))return t}function Xs(e,t){if(e<=0||e>15)throw Error(`encodeProtocolFrame: prefix 0x${e.toString(16)} outside reserved range`);let n=new Uint8Array(t.length+1);return n[0]=e,n.set(t,1),n}function Zs(e){return`proto:${e}`}function Qs(e){let t=new Set;for(let n of e??[])n.startsWith(`proto:`)&&t.add(n.slice(6));return t}function $s(e){return typeof e==`string`?new TextEncoder().encode(e):e instanceof ArrayBuffer?new Uint8Array(e):e}function ec(e){let{write:t,isOpen:n,crypto:r,label:i=`link`}=e,a=Promise.resolve();return{send:(e,o)=>{if(n!=null&&!n())return;if(r==null){t(e,o);return}let s=$s(e);a=a.then(()=>r).then(e=>e.encryptFrame(s)).then(e=>{(n==null||n())&&t(e,o)}).catch(e=>console.error(`[${i}] failed to encrypt/send frame`,e))},decryptIncoming:async e=>{if(r==null)return e;try{return await(await r).decryptFrame(e)}catch(e){console.error(`[${i}] failed to decrypt incoming frame`,e);return}}}}function tc(e,t){return n=>{e(n.linkId==null?{...n,linkId:t}:n)}}function nc(e,t,n){return{exchange:async(r,i)=>{t({dir:`out`,bytes:ic(r),lane:`http`,linkId:n});let a=await e.exchange(r,i);return t({dir:`in`,bytes:ic(a),lane:`http`,linkId:n}),a},get label(){return e.label}}}var rc;function ic(e){return typeof e==`string`?(rc??=new TextEncoder,rc.encode(e).byteLength):e instanceof Uint8Array||e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:0}var ac=e=>{if(e==null)return;let t=[];for(let n of e)if(Number.isSafeInteger(n)&&n>=1&&n<=65535&&t.push(n),t.length===2)break;return t.length>0?t:void 0};function oc(e,t){if(t.id===`identity_pin_mismatch`)return Sr.fromId(`identity_pin_mismatch`,{reason:t.reason});if(t.id===`protocol_version_mismatch`){let e=ac(t.observedProtocolVersion==null?void 0:[t.observedProtocolVersion])?.[0];return Sr.fromId(`protocol_version_mismatch`,{reason:t.reason,observedProtocolVersion:e,localSupportedProtocolVersions:[...Xa],remoteSupportedProtocolVersions:ac(t.supportedProtocolVersions)})}return Sr.fromId(`handshake_rejected`,{stage:e,reason:t.reason})}var sc=15e3,cc=`link-handshake`;function lc(e,t,n){return Sr.fromId(`endpoint_answered_non_protocol`,{stage:cc,expected:t,url:e.label,receivedKind:`hs/${n}`})}var uc=`ping`,dc=`pong`;function fc(e,t,n){let r=Date.now(),i,a,o=!1,s=e=>{a=setTimeout(c,e),qa(a)},c=()=>{if(o||!e.isOpen())return;if(i!=null){e.close();return}let a=Date.now()-r;if(a>=t.idleMs){i=Date.now();try{e.send(uc),n?.({dir:`out`,bytes:4,lane:`keepalive`})}catch{}s(t.pongTimeoutMs)}else s(t.idleMs-a)};return s(t.idleMs),{noteInbound:()=>{r=Date.now(),i=void 0},stop:()=>{o=!0,a!=null&&clearTimeout(a)}}}function pc(e){let t=!1,n,r=()=>{t||(t=!0,n?.())};return{ready:e.ready,isOpen:()=>e.isOpen(),send:t=>e.send(t),attach:t=>{n=t.onClose,e.attach({onMessage:t.onMessage,onClose:r,onError:r})},close:()=>{e.close(),queueMicrotask(r)},get label(){return e.label}}}function mc(e){let t=pc(e.channel),n=[],r=e.tap,i=gc(t,void 0,r),a=_c(t,i),o=e.mux,s=e.heartbeat==null?void 0:fc(t,e.heartbeat,r);return s!=null&&n.push(s.stop),t.attach({onMessage:t=>{if(s?.noteInbound(),t===dc){r?.({dir:`in`,bytes:4,lane:`keepalive`});return}bc(i,t,o,e.lane,a,r)},onClose:()=>xc(n,e.lane),onError:()=>xc(n,e.lane)}),o!=null&&(o.setRemoteProtocolIds(Qs(o.localCaps())),o.attach(r==null?e=>i.send(e):e=>i.send(e,o.protocolIdFor(e)??`protocol`)),n.push(()=>o.detach())),vc(t,i,n,void 0)}async function hc(e){let t=pc(e.channel),n=[],r=e.tap,i={},a=!1,o=[],s=[],c=[],l,u,d=e.mux;t.attach({onMessage:t=>{if(u?.noteInbound(),t===dc){r?.({dir:`in`,bytes:4,lane:`keepalive`});return}if(a&&i.pipe!=null&&i.port!=null){bc(i.pipe,t,d,e.lane,i.port,r);return}if(typeof t==`string`){let e=fo(t);if(e!=null){r?.({dir:`in`,bytes:ic(t),lane:`handshake`});let n=s.shift();n==null?o.push(e):n(e);return}l??=t}c.push(t)},onClose:()=>xc(n,e.lane),onError:()=>xc(n,e.lane)});let f=()=>{let e=o.shift();return e==null?new Promise((e,n)=>{let r=setTimeout(()=>n(l==null?Error(`[${cc}] timed out waiting for peer reply`):Sr.fromId(`endpoint_answered_non_protocol`,{stage:cc,expected:`a handshake frame`,url:t.label,bodyPreview:Nr(l)})),sc);s.push(t=>{clearTimeout(r),e(t)})}):Promise.resolve(e)},{crypto:p,remoteCaps:m}=await yc({...e,channel:t},f),h=gc(t,p,r),g=_c(t,h);i.pipe=h,i.port=g,d!=null&&(d.setRemoteProtocolIds(Qs(m)),d.attach(r==null?e=>h.send(e):e=>h.send(e,d.protocolIdFor(e)??`protocol`)),n.push(()=>d.detach())),e.lane.onAttach?.(g,{remoteCaps:m??[]}),a=!0;for(let t of c)await bc(h,t,d,e.lane,g,r);return c.length=0,e.heartbeat!=null&&(u=fc(t,e.heartbeat,r),n.push(u.stop)),vc(t,h,n,m)}function gc(e,t,n){return ec({write:n==null?t=>e.send(t):(t,r)=>{n({dir:`out`,bytes:ic(t),lane:r??`action`}),e.send(t)},isOpen:()=>e.isOpen(),crypto:t})}function _c(e,t){return{send:e=>t.send(e),isOpen:()=>e.isOpen()}}function vc(e,t,n,r){return{send:e=>t.send(e),isOpen:()=>e.isOpen(),close:()=>{try{e.close()}catch{}},addOnDisconnectListener:e=>{n.push(e)},remoteCaps:r}}async function yc(e,t){let n=e.secure,r=t=>{e.channel.send(t),e.tap?.({dir:`out`,bytes:ic(t),lane:`handshake`})};await n.link.initialize();let i=e.lane.handshakeConfig(),a=I({link:n.link,localCoordinate:n.localCoordinate,expectedPeer:n.expectedPeer,dictionaryVersion:i.dictionaryVersion,securityLevel:n.securityLevel,channelTags:i.channels,extraCaps:[...e.lane.caps?.()??[],...e.mux?.localCaps()??[]]});r(uo(await a.createHello()));let o=await t();if(o.t===io.reject)throw oc(cc,o);if(o.t!==io.welcome)throw lc(e.channel,`a welcome frame`,o.t);r(uo(await a.onWelcome(o)));let s=await t();if(s.t===io.reject)throw oc(cc,s);if(s.t!==io.accept)throw lc(e.channel,`an accept frame`,s.t);let c=await a.onAccept(s);return{crypto:c.securityLevel===ro.encrypted&&c.encryptionKeyMaterial!=null?qs({link:n.link,keyMaterial:c.encryptionKeyMaterial}):void 0,remoteCaps:c.remoteCaps}}async function bc(e,t,n,r,i,a){let o=a==null?0:ic(t),s=await e.decryptIncoming(t);if(s!==void 0){if(n?.dispatchIncoming(s)){a?.({dir:`in`,bytes:o,lane:n.protocolIdFor(s)??`protocol`});return}a?.({dir:`in`,bytes:o,lane:`action`}),await r.onLaneFrame(s,i)}}function xc(e,t){for(let t of e)t();t.onDetach?.()}var Sc=0,Cc=class{def;transOrd=Sc++;type;initialized;definition;constructor(e){this.def=e,this.type=e.type,this.initialized=e.initialize()}getRouteInfo(e){return this.definition?.getRouteInfo(e)}_needsAsyncBringUp(e){return!1}_awaitCarrierReady(e){return Promise.resolve()}_finalizeReady(e){return this._finalizeTransportMethods(e)}_getCacheKey(e){let t=this.initialized.getCacheKey?.(e);return t==null?null:t.join(`\0`)}getCacheKey(e){let t=this._getCacheKey(e);return t==null?null:`${this.transOrd}:${t}`}isAvailable(e){return this.initialized.isAvailable?.(e)??!0}getTransport(e){return this._processTransportStatus(e)}_processTransportStatus(e){let t=wc(this.initialized.getTransport(e));if(t.status===xr.ready)return this._needsAsyncBringUp(t.readyData)?{status:xr.initializing,timeStarted:Date.now(),initializationPromise:this._bringUp(t.readyData)}:{status:xr.ready,readyData:this._finalizeTransportMethods(t.readyData)};if(t.status===xr.initializing){let e=t.initializationPromise.then(e=>e.status===xr.ready?this._bringUp(e.readyData):e);return{status:xr.initializing,timeStarted:t.timeStarted,initializationPromise:e}}return t}async _bringUp(e){return await this._awaitCarrierReady(e),{status:xr.ready,readyData:await this._finalizeReady(e)}}};function wc(e){return e.status===xr.ready?{status:xr.ready,readyData:e.readyData}:e.status===xr.initializing?{status:xr.initializing,initializationPromise:e.initializationPromise,timeStarted:Date.now()}:e.status===xr.failed?{status:xr.failed,error:e.error,timeFailed:Date.now()}:e.status===xr.unsupported?{status:xr.unsupported}:{status:xr.uninitialized}}var Tc=class{_byPrefix=new Map;_send;_remoteProtocolIds=new Set;_attached=!1;registerProtocol(e){if(this._attached&&console.warn(`[wire] registerProtocol("${e.id}"): the connection is already attached — this protocol missed the handshake's caps advertisement and will not be resumed after a host wake. Register it before connecting.`),e.prefixByte<=Js.invalid||e.prefixByte>15)throw Error(`registerProtocol("${e.id}"): prefix 0x${e.prefixByte.toString(16)} outside the reserved range`);if(this._byPrefix.has(e.prefixByte))throw Error(`registerProtocol("${e.id}"): prefix 0x${e.prefixByte.toString(16)} already registered`);let t={send:t=>{if(!this._canSpeak(e))throw Error(`protocol "${e.id}": connection not attached or peer did not advertise "${Zs(e.id)}"`);this._send?.(Xs(e.prefixByte,t))},isOpen:()=>this._canSpeak(e)};return this._byPrefix.set(e.prefixByte,{protocol:e,port:t}),this._attached&&this._canSpeak(e)&&e.onAttach?.(t),t}localCaps(){return[...this._byPrefix.values()].map(({protocol:e})=>Zs(e.id))}setRemoteProtocolIds(e){this._remoteProtocolIds=e}attach(e){this._send=e,this._attached=!0;for(let{protocol:e,port:t}of this._byPrefix.values())this._canSpeak(e)&&e.onAttach?.(t)}detach(){if(this._attached){this._attached=!1,this._send=void 0;for(let{protocol:e}of this._byPrefix.values())e.onDetach?.()}}protocolIdFor(e){let t=Ys(e);if(t!=null)return this._byPrefix.get(t)?.protocol.id}dispatchIncoming(e){let t=Ys(e);if(t==null)return!1;let n=this._byPrefix.get(t);if(t===Js.invalid||n==null)return!0;let r=e instanceof Uint8Array?e:new Uint8Array(e);return n.protocol.onFrame(r.subarray(1),n.port),!0}_canSpeak(e){return this._attached&&this._remoteProtocolIds.has(e.id)}},Ec=15e3,Dc=5e3,Oc=new Set;function kc(e,t,n){if(n.durable===!0||t.perId==null)return;let r=`${t.envId}::${t.perId}`;Oc.has(r)||(Oc.add(r),console.warn(`${e}: the runtime coordinate [${r}] carries a persistent id, which keys the peer's trust-on-first-use verify-key pin — but the \`storage\` passed here is not known to be durable, so this client's crypto identity may regenerate on reload. The peer will pin the first key it sees and reject every reconnect after the first reload (identity_pin_mismatch). Back the connection with a durable adapter (e.g. createWebLocalStorageAdapter) that persists at least as long as the persistent id, or set \`ephemeralIdentity: true\` if the id is minted fresh per session. Memory adapters are for tests.`))}function Ac(e){let t=e.mux??new Tc;if(e.reconnect!=null&&e.keepLinkAlive!=null)throw Sr.fromId(`conflicting_connect_options`,{detail:`${e.callerName}: pass only \`reconnect\`; \`keepLinkAlive\` is deprecated`});if(e.heartbeat!=null&&e.linkKeepalive!=null)throw Sr.fromId(`conflicting_connect_options`,{detail:`${e.callerName}: pass only \`heartbeat\`; \`linkKeepalive\` is deprecated`});let n=e.reconnect??e.keepLinkAlive,r=e.heartbeat??e.linkKeepalive;for(let n of e.protocols??[])t.registerProtocol(n);let i=e.link;if(e.anySecure&&i==null){if(e.storage==null&&e.ephemeralIdentity!==!0)throw Error(`${e.callerName}: a secure transport requires \`storage\` (or \`link\`) for the crypto identity. Pass it, declare a per-session identity with \`ephemeralIdentity: true\`, or set \`secure: false\` on the carrier for a plain connection.`);e.storage!=null&&e.ephemeralIdentity!==!0&&kc(e.callerName,e.identity,e.storage),i=new Ua(e.storage==null?{}:{storageAdapter:e.storage})}let a=()=>{if(r===!1)return;let e=r;if(e!=null||n===!0||n!==!1&&t.localCaps().length>0)return{idleMs:e?.idleMs??Ec,pongTimeoutMs:e?.pongTimeoutMs??Dc}},o=e.wireTap==null?void 0:tc(e.wireTap,e.peer.stringId);return{mux:t,link:i,resolveHeartbeat:a,wireTap:o}}function jc(e){return JSON.stringify(e)}function Mc(e){let t=Nc(e);return Pc(t)?t:void 0}function Nc(e){try{return JSON.parse(e)}catch{return}}function Pc(e){return Fc(e)&&(e.k===`hs`||e.k===`act`||e.k===`err`)}function Fc(e){return typeof e==`object`&&!!e&&`k`in e}var Ic=new TextEncoder,Lc=new TextDecoder;function Rc(e){return Bc(e,{})}async function zc(e){let t=await Uc(e.carrier,e.secure,e.lane);return Bc(e.carrier,t)}function Bc(e,t){let n=async(n,r)=>{let i=await Vc(t,n);return e.exchange(jc(i),{signal:r?.signal})};return{send:async(e,t)=>{await n(e,t)},exchange:async(e,r)=>{let i=Mc(Jc(await n(e,r)));if(i==null)return{ok:!1,reason:`malformed_reply`};if(i.k===`err`)return{ok:!1,reason:`peer_error`,message:i.message};let a=await Hc(t,i);return a===void 0?{ok:!1,reason:`malformed_reply`}:{ok:!0,wire:a}}}}async function Vc(e,t){if(e.crypto!=null){let n=await e.crypto.encryptFrame(Ic.encode(JSON.stringify(t)));return{k:`act`,t:e.token,c:Di(n)}}return{k:`act`,t:e.token,w:t}}async function Hc(e,t){if(t.k===`act`){if(`c`in t){if(e.crypto==null)return;let n=await e.crypto.decryptFrame(Oi(t.c));return JSON.parse(Lc.decode(n))}return t.w}}async function Uc(e,t,n){await t.link.initialize();let r=I({link:t.link,localCoordinate:t.localCoordinate,expectedPeer:t.expectedPeer,dictionaryVersion:n.dictionaryVersion,securityLevel:t.securityLevel,channelTags:n.channels}),i=await Gc(e,{k:`hs`,m:uo(await r.createHello())},`a welcome frame`),a=fo(i.m);if(a==null)throw Kc(e,`a welcome frame`,`hs (undecodable)`);if(a.t===io.reject)throw oc(Wc,a);if(a.t!==io.welcome)throw Kc(e,`a welcome frame`,`hs/${a.t}`);if(i.hsc==null)throw Error(`[${Wc}] welcome missing handshake continuation token${qc(e)}`);let o=await Gc(e,{k:`hs`,m:uo(await r.onWelcome(a)),hsc:i.hsc},`an accept frame`),s=fo(o.m);if(s==null)throw Kc(e,`an accept frame`,`hs (undecodable)`);if(s.t===io.reject)throw oc(Wc,s);if(s.t!==io.accept)throw Kc(e,`an accept frame`,`hs/${s.t}`);if(o.t==null)throw Error(`[${Wc}] accept missing session token${qc(e)}`);let c=await r.onAccept(s),l=c.securityLevel===ro.encrypted&&c.encryptionKeyMaterial!=null?qs({link:t.link,keyMaterial:c.encryptionKeyMaterial}):void 0;return{token:o.t,crypto:l}}var Wc=`exchange-handshake`;async function Gc(e,t,n){let r=Jc(await e.exchange(jc(t))),i=Mc(r);if(i==null)throw Sr.fromId(`endpoint_answered_non_protocol`,{stage:Wc,expected:n,url:e.label,bodyPreview:Nr(r)});if(i.k===`err`)throw Sr.fromId(`handshake_rejected`,{stage:Wc,reason:i.message});if(i.k!==`hs`)throw Kc(e,n,i.k);return i}function Kc(e,t,n){return Sr.fromId(`endpoint_answered_non_protocol`,{stage:Wc,expected:t,url:e.label,receivedKind:n})}function qc(e){return e.label==null?``:` (endpoint: ${e.label})`}function Jc(e){return typeof e==`string`?e:Lc.decode(e instanceof ArrayBuffer?new Uint8Array(e):e)}ro.none,ro.authenticated,ro.encrypted,new TextEncoder,new TextDecoder;function Yc(e){if(e.length===0)return!1;let t=e[0];return t>=128&&t<=143||t===222||t===223}function Xc(e){return typeof e!=`object`||!e||Array.isArray(e)||!(`$c`in e&&`domain`in e&&`id`in e)||typeof e.domain!=`string`||typeof e.id!=`string`||`k`in e&&e.k!=null&&typeof e.k!=`string`?!1:e.$c===`rack`?`ack`in e&&typeof e.ack==`number`:e.$c===`rsync`?!0:e.$c===`rskip`?`seq`in e&&typeof e.seq==`number`:e.$c===`rclose`}function Zc(e){return Vs(e)}function Qc(e){let t;if(e instanceof ArrayBuffer)t=new Uint8Array(e);else if(e instanceof Uint8Array)t=e;else return;if(Yc(t))try{let e=_s(t);return Xc(e)?e:void 0}catch{return}}function $c(e,t,n,r){let i=`${e.stringId}::${t}:${n}`;return r==null?i:`${i}#${r}`}var el=new Set;function tl(e,t){let n=`${e}:${t}`;el.has(n)||(el.add(n),console.warn(`[reliable] "${n}" is .reliable() but this transport has no binary codec, so its reliability metadata can't be sent — the frame is delivered best-effort (no ordering/dedup/resend). Reliable delivery requires the binary wire codec (use a channel-based transport).`))}var nl=new Set;function rl(e,t){let n=`${e}:${t}`;nl.has(n)||(nl.add(n),console.warn(`[reliable] "${n}" is .reliable() but the connected peer did not advertise reliable support (an older server) — the frame is sent best-effort (no ordering/dedup/resend). Upgrade the peer to enable reliable delivery.`))}var il=new Set;function al(e,t){let n=`${e}:${t}`;il.has(n)||(il.add(n),console.warn(`[reliable] "${n}" was sent with a streamKey but the connected peer did not advertise streamkey support (an older peer) — a keyed reliable frame it can't interpret is dropped, not delivered. Upgrade the peer, or drop the streamKey to use the single default stream.`))}var ol=new Set;function sl(e,t){let n=`${e}:${t}`;ol.has(n)||(ol.add(n),console.warn(`[reliable] a reply-less "${n}" frame was abandoned — not acknowledged within the delivery deadline. The stream skips past it and continues; the frame may not have been delivered. (Reply-less reliable sends report success on send; this warning is where a bounded non-delivery surfaces.)`))}var cl=class{form;_domain;id;domain;allDomains;schema;constructor(e,t,n){this.form=e,this._domain=t,this.id=n,this.domain=t.domain,this.allDomains=t.allDomains,this.schema=t.actionSchema[n]}toJsonObject(){return{form:this.form,domain:this.domain,allDomains:this.allDomains,id:this.id}}toJsonString(){return JSON.stringify(this.toJsonObject())}},ll=function(e){return e.core=`core`,e.context=`context`,e.data=`data`,e}({}),ul=class extends cl{_domain;form=ll.context;_routing;timeCreated;cuid;originClient;reliability;_receiverMetadata;constructor(e,t,n){super(ll.context,e,t),this._domain=e,this.timeCreated=n.timeCreated,this.cuid=n.cuid,this._routing=n.routing,this.originClient=n.originClient,this.reliability=void 0}_setReceiverMetadata(e){Object.defineProperty(this,"_receiverMetadata",{configurable:!0,enumerable:!1,value:e,writable:!0}),Object.defineProperty(this,"reliability",{configurable:!0,enumerable:!1,value:e.reliability})}_getReceiverMetadata(){return this._receiverMetadata}_setOriginClient(e){this.originClient=e}toJsonString(){return JSON.stringify(this.toJsonObject())}toContextDataJsonObject(){return{timeCreated:this.timeCreated,cuid:this.cuid,routing:this.routing.map(e=>({runtime:e.runtime.toJsonObject(),handler:e.handler,time:e.time})),originClient:this.originClient.toJsonObject()}}toJsonObject(){return{...super.toJsonObject(),...this.toContextDataJsonObject()}}get routing(){return this._routing}addRouteItem(e){this._routing.push(e)}deserializeInput(e){return this.schema.deserializeInput(e)}serializeInput(e){return this.schema.serializeInput(e)}validateInput(e){return this.schema.validateInput(e,{domain:this.domain,actionId:this.id})}validateOutput(e){return this.schema.validateOutput(e,{domain:this.domain,actionId:this.id})}},dl=class extends cl{form=ll.data;type;context;time;constructor(e,t,n){super(ll.data,e._domain,e.id),this.context=e,this.type=t,this.time=n.time}toBaseJsonObject(){return{...super.toJsonObject(),type:this.type,context:this.context.toContextDataJsonObject(),time:this.time}}};function fl(e){return e==null?String(e):typeof e==`object`?Array.isArray(e)?`[${e.map(fl).join(`,`)}]`:`{`+Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${fl(e[t])}`).join(`,`)+`}`:JSON.stringify(e)??`undefined`}function pl(e){let t=2166136261;for(let n=0;n<e.length;n++)t=(t^e.charCodeAt(n))*16777619>>>0;return t.toString(16).padStart(8,`0`)}function ml(e){return pl(fl(e))}var G=function(e){return e.request=`request`,e.progress=`progress`,e.result=`result`,e.stream=`stream`,e.push=`push`,e}({}),hl=class extends dl{progress;constructor(e,t,n){super(e.context,G.progress,n),this.progress=t}toJsonObject(){return{...this.toBaseJsonObject(),progress:this.progress}}toJsonString(){return JSON.stringify(this.toJsonObject())}toHttpResponse(){return new Response(this.toJsonString(),{status:200,headers:{"Content-Type":`application/json`}})}},gl=class extends dl{result;outputHash;constructor(e,t,n){if(super(e.context,G.result,n),t.ok)this.result=t,this.outputHash=ml(this.context.schema.serializeOutput(t.output));else{let e=this.context.schema.isExpectedError(t.error);this.result=e?{ok:!1,expected:!0,error:t.error}:{ok:!1,expected:!1,error:t.error},this.outputHash=ml(t.error.message)}}toJsonObject(){let e=this.result.ok?{ok:!0,output:this.context.schema.serializeOutput(this.result.output)}:{ok:!1,expected:this.result.expected,error:this.result.error.toJsonObject()};return{...this.toBaseJsonObject(),result:e,outputHash:this.outputHash}}toJsonString(){return JSON.stringify(this.toJsonObject())}toHttpResponse({useErrorStatus:e=!0}={}){return new Response(this.toJsonString(),{status:this.result.ok?200:e?this.result.error.httpStatusCode:500,headers:{"Content-Type":`application/json`}})}},_l=class extends dl{input;inputHash;_callSite;constructor(e,t,n){super(e.context,G.request,n),this.input=t,this.inputHash=ml(this.context.schema.serializeInput(t))}successResult(...e){let t=e[0],n=this.context.schema.validateOutput(t,{domain:this.domain,actionId:this.id});return new gl(this,{ok:!0,output:n},{time:Date.now()})}errorResult(e){return new gl(this,{ok:!1,error:e},{time:Date.now()})}progress(e){return new hl(this,e,{time:Date.now()})}toJsonObject(){return{...super.toBaseJsonObject(),input:this.context.schema.serializeInput(this.input),inputHash:this.inputHash}}toJsonString(){return JSON.stringify(this.toJsonObject())}async runToOutput(e){let t=await(await this.run(e)).waitForResultPayload();if(t.result.ok)return t.result.output;throw t.result.error}async runToResultPayload(e){return(await this.run(e)).waitForResultPayload()}async runToResult(e){return(await this.runToResultPayload(e)).result}async run(e){return this._domain.runAction(this,e)}},vl=class extends cl{_domain;form=ll.core;constructor(e,t){super(ll.core,e,t),this._domain=e}is(e){return e instanceof dl&&e.domain===this.domain&&e.id===this.id}isExpectedError(e){return e instanceof ie&&this.schema.isExpectedError(e)}toJsonObject(){return{id:this.id,form:this.form,domain:this.domain,allDomains:this.allDomains}}request(...e){let t=e[0],n=this.schema.validateInput(t,{actionId:this.id,domain:this.domain});return new _l({context:new ul(this._domain,this.id,{cuid:Ya(),timeCreated:Date.now(),routing:[],originClient:$a.unknown})},n,{time:Date.now()})}deserializeInput(e){return this.schema.deserializeInput(e)}serializeInput(e){return this.schema.serializeInput(e)}validateInput(e){return this.schema.validateInput(e,{domain:this.domain,actionId:this.id})}validateOutput(e){return this.schema.validateOutput(e,{domain:this.domain,actionId:this.id})}},yl=function(e){return e.started=`started`,e.progress=`progress`,e.finished=`finished`,e.reliability=`reliability`,e}({}),bl=function(e){return e.aborted=`aborted`,e.failed=`failed`,e.success=`success`,e}({}),xl=class{_state;reliability;context;cuid;id;_domain;domain;allDomains;parentCuid;callSite;_resultPayloadPromise;_resolveResult;_rejectResult;_isAborted=!1;_updates=[];_updateListeners=[];_ackOutcome;_ackPromise;_resolveAck;_rejectAck;constructor(e){this.context=e.context,this.cuid=e.context.cuid,this.id=e.context.id,this.domain=e.context.domain,this.allDomains=e.context.allDomains,this._domain=e.context._domain,this.parentCuid=e.parentCuid,this.callSite=e.callSite,this._resultPayloadPromise=new Promise((e,t)=>{this._resolveResult=e,this._rejectResult=t}),this._resultPayloadPromise.catch(()=>{}),this._state={request:e.request,progress:e.progress??[],result:e.result},this._sendUpdate({type:yl.started,runningAction:this,time:Date.now()})}get state(){return this._state}get isSettled(){return this._state.result!=null||this._isAborted}get isAborted(){return this._isAborted}_setReliability(e){this.reliability=e}waitForAck(){if(this._ackPromise==null){this._ackPromise=new Promise((e,t)=>{this._resolveAck=e,this._rejectAck=t}),this._ackPromise.catch(()=>{});let e=this._ackOutcome;e!=null&&(e.ok?this._resolveAck?.():this._rejectAck?.(e.reason))}return this._ackPromise}_settleAck(e){return this._ackOutcome==null?(this._ackOutcome=e,e.ok?this._resolveAck?.():this._rejectAck?.(e.reason),!0):!1}_notifyAcked(){this.reliability!=null&&this.reliability.acked!==!0&&(this.reliability.acked=!0,this._sendUpdate({type:yl.reliability,runningAction:this,time:Date.now()})),this._settleAck({ok:!0})}_notifyAckAbandoned(e){this._settleAck({ok:!1,reason:e})}abort(e){this._abort(e)}addUpdateListeners(e){this._updateListeners.push(...e);for(let t of this._updates)for(let n of e)n(t);return()=>{for(let t of e){let e=this._updateListeners.indexOf(t);e!==-1&&this._updateListeners.splice(e,1)}}}async*iterateUpdates(){let e=[],t=null,n=this.addUpdateListeners([n=>{e.push(n),t&&=(t(),null)}]);try{for(;;){e.length===0&&await new Promise(e=>{t=e});let n=e.shift();if(yield n,n.type===yl.finished)break}}finally{n()}}_sendUpdate(e){this._updates.push(e);for(let t of this._updateListeners)t(e)}_completeWithResult(e){return this._state.result!=null||this._isAborted?!1:(this._state={request:this._state.request,progress:this._state.progress,result:e},this._resolveResult(e),this._sendUpdate({type:yl.finished,finishType:bl.success,runningAction:this,time:Date.now(),response:e}),this.reliability??this._settleAck({ok:!0}),!0)}_abort(e){return this._state.result!=null||this._isAborted?!1:(this._isAborted=!0,this._rejectResult(e),this._sendUpdate({type:yl.finished,finishType:bl.aborted,runningAction:this,time:Date.now(),reason:e}),this.reliability??this._settleAck({ok:!1,reason:e}),!0)}_failWithError(e){return this._state.result!=null||this._isAborted?!1:(this._isAborted=!0,this._rejectResult(e),this._sendUpdate({type:yl.finished,finishType:bl.failed,runningAction:this,time:Date.now(),error:e}),this.reliability??this._settleAck({ok:!1,reason:e}),!0)}_updateProgress(e){this._state.result!=null||this._isAborted||(this._state.progress.push(e),this._sendUpdate({type:yl.progress,runningAction:this,time:Date.now(),progress:e.progress}))}waitForResultPayload(){return this._resultPayloadPromise}_resolveFromJson(e){if(this._state.result!=null||this._isAborted)return!1;let t=this._domain.hydrateResultPayload(e);return this._completeWithResult(t)}},K=function(e){return e.not_implemented=`not_implemented`,e.action_id_not_in_domain=`action_id_not_in_domain`,e.domain_already_exists_in_hierarchy=`domain_already_exists_in_hierarchy`,e.domain_name_collision=`domain_name_collision`,e.domain_no_handler=`domain_no_handler`,e.hydration_domain_mismatch=`hydration_domain_mismatch`,e.hydration_action_state_mismatch=`hydration_action_state_mismatch`,e.hydration_action_id_not_found=`hydration_action_id_not_found`,e.no_action_execution_handler=`no_action_execution_handler`,e.wire_action_not_payload=`wire_action_not_payload`,e.wire_not_action_data=`wire_not_action_data`,e.runtime_reset=`runtime_reset`,e.runtime_disposed=`runtime_disposed`,e.ambiguous_action_runtime=`ambiguous_action_runtime`,e.invalid_server_runtime_scope=`invalid_server_runtime_scope`,e.conflicting_server_options=`conflicting_server_options`,e.conflicting_connect_options=`conflicting_connect_options`,e.duplicate_action_executor=`duplicate_action_executor`,e.peer_handler_already_bound=`peer_handler_already_bound`,e.no_client_runtimes_registered=`no_client_runtimes_registered`,e.action_input_validation_failed=`action_input_validation_failed`,e.action_input_validation_promise=`action_input_validation_promise`,e.action_output_validation_failed=`action_output_validation_failed`,e.action_output_validation_promise=`action_output_validation_promise`,e.connection_required=`connection_required`,e}({}),q=ue.createChildDomain({domain:`err_nice_action`,defaultHttpStatusCode:500,schema:{not_implemented:k({message:({label:e})=>`The "${e}" functionality is not implemented yet.`}),action_id_not_in_domain:k({message:({actionId:e,domain:t})=>`Action with id "${e}" does not exist in domain "${t}".`}),domain_already_exists_in_hierarchy:k({message:({domain:e,allParentDomains:t,parentDomain:n})=>`Domain "${e}" already exists in the hierarchy under the parent "${n}". All parent domains ["${t.join(`, `)}"]`}),domain_name_collision:k({message:({domain:e,existingParentDomains:t,incomingParentDomains:n})=>`Two different domain definitions named "${e}" were registered on one runtime router (existing under [${t.join(` > `)}], incoming under [${n.join(` > `)}]). Wire routing is by name only, so the later registration would silently shadow the earlier one — give the domains distinct names, or register the same instance.`}),domain_no_handler:k({message:({domain:e})=>`Domain "${e}" has no action handler registered.`}),hydration_domain_mismatch:k({message:({expected:e,received:t})=>`Cannot hydrate action: domain mismatch. Expected "${e}", got "${t}".`}),hydration_action_state_mismatch:k({message:({expected:e,received:t})=>`Cannot hydrate action: action state type mismatch. Expected "${e}", got "${t}".`}),hydration_action_id_not_found:k({message:({domain:e,actionId:t})=>`Cannot hydrate action: id "${t}" does not exist in domain "${e}".`}),no_action_execution_handler:k({message:({domain:e,actionId:t,specifiedClient:n})=>`${n?` The targeted client runtime [${n.stringId}] has no`:`No`} action handler registered for "${t}" in domain "${e}".`}),wire_action_not_payload:k({message:({domain:e,actionId:t,actionState:n})=>`Cannot handle wire for action "${t}" in domain "${e}": expected action form of "${ll.data}" and type of "${G.request}", "${G.progress}" or "${G.result}", got "${n}".`}),wire_not_action_data:k({message:()=>`Cannot handle wire for action: expected an object with a "domain" property of type string, a "form" property of "${ll.data}" and a "type" property of "${G.request}", "${G.progress}" or "${G.result}".`}),connection_required:k({message:({operation:e})=>`Cannot ${e}: this action did not arrive on a live duplex connection.`}),runtime_reset:k({message:()=>`Runtime has been reset.`}),runtime_disposed:k({message:({runtime:e})=>`Action runtime [${e}] has been disposed and cannot be reused.`}),ambiguous_action_runtime:k({message:({domain:e,actionId:t,runtimes:n})=>`Several runtimes can execute "${e}:${t}" (${n.join(`, `)}). Target one explicitly with runtime.run(request) or request.run({ targetLocalRuntime: runtime }).`}),invalid_server_runtime_scope:k({message:({runtime:e,actualScope:t})=>`Server runtime [${e}] has scope "${t}". Server hosts require new ActionRuntime(identity, { scope: "instance" }) so isolate-local instances never enter global dispatch.`}),conflicting_server_options:k({message:({detail:e})=>`Invalid server construction options: ${e}`}),conflicting_connect_options:k({message:({detail:e})=>`Invalid connection options: ${e}`}),duplicate_action_executor:k({message:({route:e})=>`More than one local executor was registered for the same route priority (${e}). Keep one executor at that exact route; an action-specific executor may still override a domain fallback.`}),peer_handler_already_bound:k({message:()=>`A stateful peer handler is already bound to another runtime. Create one connector or acceptor per runtime.`}),no_client_runtimes_registered:k({message:({context:e})=>`No runtimes registered${e?.domain?` on domain "${e.domain}"`:``}. Add handlers to a runtime via runtime.addHandlers([handler]) before executing actions.`}),action_input_validation_failed:k({message:({domain:e,actionId:t,validationMessage:n})=>`Input validation failed for action "${t}" in domain "${e}":\n${n}`,httpStatusCode:400}),action_input_validation_promise:k({message:({domain:e,actionId:t})=>`Input validation for action "${t}" in domain "${e}" returned a promise, which is not supported.`,httpStatusCode:400}),action_output_validation_failed:k({message:({domain:e,actionId:t,validationMessage:n})=>`Output validation failed for action "${t}" in domain "${e}":\n${n}`,httpStatusCode:500}),action_output_validation_promise:k({message:({domain:e,actionId:t})=>`Output validation for action "${t}" in domain "${e}" returned a promise, which is not supported.`,httpStatusCode:500})}}),Sl=e=>typeof e==`object`&&!!e&&typeof e.domain==`string`&&typeof e.id==`string`&&typeof e.form==`string`,Cl=e=>Sl(e)&&e.result!=null&&e.form===ll.data&&e.type===G.result,wl;(function(e){e[e.CONTINUE=100]=`CONTINUE`,e[e.SWITCHING_PROTOCOLS=101]=`SWITCHING_PROTOCOLS`,e[e.PROCESSING=102]=`PROCESSING`,e[e.EARLY_HINTS=103]=`EARLY_HINTS`,e[e.OK=200]=`OK`,e[e.CREATED=201]=`CREATED`,e[e.ACCEPTED=202]=`ACCEPTED`,e[e.NON_AUTHORITATIVE_INFORMATION=203]=`NON_AUTHORITATIVE_INFORMATION`,e[e.NO_CONTENT=204]=`NO_CONTENT`,e[e.RESET_CONTENT=205]=`RESET_CONTENT`,e[e.PARTIAL_CONTENT=206]=`PARTIAL_CONTENT`,e[e.MULTI_STATUS=207]=`MULTI_STATUS`,e[e.MULTIPLE_CHOICES=300]=`MULTIPLE_CHOICES`,e[e.MOVED_PERMANENTLY=301]=`MOVED_PERMANENTLY`,e[e.MOVED_TEMPORARILY=302]=`MOVED_TEMPORARILY`,e[e.SEE_OTHER=303]=`SEE_OTHER`,e[e.NOT_MODIFIED=304]=`NOT_MODIFIED`,e[e.USE_PROXY=305]=`USE_PROXY`,e[e.TEMPORARY_REDIRECT=307]=`TEMPORARY_REDIRECT`,e[e.PERMANENT_REDIRECT=308]=`PERMANENT_REDIRECT`,e[e.BAD_REQUEST=400]=`BAD_REQUEST`,e[e.UNAUTHORIZED=401]=`UNAUTHORIZED`,e[e.PAYMENT_REQUIRED=402]=`PAYMENT_REQUIRED`,e[e.FORBIDDEN=403]=`FORBIDDEN`,e[e.NOT_FOUND=404]=`NOT_FOUND`,e[e.METHOD_NOT_ALLOWED=405]=`METHOD_NOT_ALLOWED`,e[e.NOT_ACCEPTABLE=406]=`NOT_ACCEPTABLE`,e[e.PROXY_AUTHENTICATION_REQUIRED=407]=`PROXY_AUTHENTICATION_REQUIRED`,e[e.REQUEST_TIMEOUT=408]=`REQUEST_TIMEOUT`,e[e.CONFLICT=409]=`CONFLICT`,e[e.GONE=410]=`GONE`,e[e.LENGTH_REQUIRED=411]=`LENGTH_REQUIRED`,e[e.PRECONDITION_FAILED=412]=`PRECONDITION_FAILED`,e[e.REQUEST_TOO_LONG=413]=`REQUEST_TOO_LONG`,e[e.REQUEST_URI_TOO_LONG=414]=`REQUEST_URI_TOO_LONG`,e[e.UNSUPPORTED_MEDIA_TYPE=415]=`UNSUPPORTED_MEDIA_TYPE`,e[e.REQUESTED_RANGE_NOT_SATISFIABLE=416]=`REQUESTED_RANGE_NOT_SATISFIABLE`,e[e.EXPECTATION_FAILED=417]=`EXPECTATION_FAILED`,e[e.IM_A_TEAPOT=418]=`IM_A_TEAPOT`,e[e.INSUFFICIENT_SPACE_ON_RESOURCE=419]=`INSUFFICIENT_SPACE_ON_RESOURCE`,e[e.METHOD_FAILURE=420]=`METHOD_FAILURE`,e[e.MISDIRECTED_REQUEST=421]=`MISDIRECTED_REQUEST`,e[e.UNPROCESSABLE_ENTITY=422]=`UNPROCESSABLE_ENTITY`,e[e.LOCKED=423]=`LOCKED`,e[e.FAILED_DEPENDENCY=424]=`FAILED_DEPENDENCY`,e[e.UPGRADE_REQUIRED=426]=`UPGRADE_REQUIRED`,e[e.PRECONDITION_REQUIRED=428]=`PRECONDITION_REQUIRED`,e[e.TOO_MANY_REQUESTS=429]=`TOO_MANY_REQUESTS`,e[e.REQUEST_HEADER_FIELDS_TOO_LARGE=431]=`REQUEST_HEADER_FIELDS_TOO_LARGE`,e[e.UNAVAILABLE_FOR_LEGAL_REASONS=451]=`UNAVAILABLE_FOR_LEGAL_REASONS`,e[e.INTERNAL_SERVER_ERROR=500]=`INTERNAL_SERVER_ERROR`,e[e.NOT_IMPLEMENTED=501]=`NOT_IMPLEMENTED`,e[e.BAD_GATEWAY=502]=`BAD_GATEWAY`,e[e.SERVICE_UNAVAILABLE=503]=`SERVICE_UNAVAILABLE`,e[e.GATEWAY_TIMEOUT=504]=`GATEWAY_TIMEOUT`,e[e.HTTP_VERSION_NOT_SUPPORTED=505]=`HTTP_VERSION_NOT_SUPPORTED`,e[e.INSUFFICIENT_STORAGE=507]=`INSUFFICIENT_STORAGE`,e[e.NETWORK_AUTHENTICATION_REQUIRED=511]=`NETWORK_AUTHENTICATION_REQUIRED`})(wl||={});function Tl(e){let t=``;for(let n of e)typeof n==`object`?n.key!=null&&(typeof n.key==`number`?t+=`[${String(n.key)}]`:typeof n.key==`symbol`?t+=`[SYMBOL:${String(n.key)}]`:t+=`.${String(n.key)}`):t+=`.${String(n)}`;return t.slice(1)}var El=e=>{let t=`Data validation failed:
19
- `,n=0;for(let r of e.issues)n++,r.path==null||r.path.length===0?t+=` (issue ${n}) ${r.message}\n`:t+=` (issue ${n}) [${Tl(r.path)}]: ${r.message}\n`;return t};ue.createChildDomain({domain:`err_validation`,defaultHttpStatusCode:wl.BAD_REQUEST,schema:{standard_schema:k({message:({issues:e})=>El({issues:e})})}});var Dl=function(e){return e.payload=`payload`,e.ack=`ack`,e.none=`none`,e}({}),Ol=function(e){return e.none=`none`,e.session=`session`,e.persisted=`persisted`,e}({}),kl=class{_errorDeclarations=[];inputOptions;outputOptions;_responseMode;_reliabilityTier=`none`;get inputSchema(){return this.inputOptions?.schema}get outputSchema(){return this.outputOptions?.schema}get responseMode(){return this._responseMode==null?this.outputOptions==null?`ack`:`payload`:this._responseMode}ack(){return this._responseMode=`ack`,this}fireAndForget(){return this._responseMode=`none`,this}get reliabilityTier(){return this._reliabilityTier}reliable(e){return this._reliabilityTier=e?.persist===!0?`persisted`:`session`,this}input(e){return this.inputOptions=e,this}output(e){return this.outputOptions=e,this}throws(e,t){return this._errorDeclarations.push({_domain:e,_ids:t}),this}isExpectedError(e){return this._errorDeclarations.some(t=>t._domain.isExact(e)&&(t._ids==null||t._ids.some(t=>e.hasId(t))))}serializeInput(e){return this.inputOptions?.serialization?this.inputOptions.serialization.serialize(e):e}deserializeInput(e){return this.inputOptions?.serialization?this.inputOptions.serialization.deserialize(e):e}validateInput(e,t){if(this.inputOptions?.schema==null)return e;let n=this.inputOptions.schema[`~standard`].validate(e);if(n instanceof Promise)throw q.fromId(K.action_input_validation_promise,{domain:t.domain,actionId:t.actionId});if(n.issues!=null)throw q.fromId(K.action_input_validation_failed,{domain:t.domain,actionId:t.actionId,validationMessage:El(n)});return n.value}validateOutput(e,t){if(this.outputOptions?.schema==null)return e;let n=this.outputOptions.schema[`~standard`].validate(e);if(n instanceof Promise)throw q.fromId(K.action_output_validation_promise,{domain:t.domain,actionId:t.actionId});if(n.issues!=null)throw q.fromId(K.action_output_validation_failed,{domain:t.domain,actionId:t.actionId,validationMessage:El(n)});return n.value}serializeOutput(e){return this.outputOptions?.serialization?this.outputOptions.serialization.serialize(e):e}deserializeOutput(e){return this.outputOptions?.serialization?this.outputOptions.serialization.deserialize(e):e}},Al=()=>new kl;function jl(){return Error().stack}var Ml={},Nl=globalThis.process||{env:Ml},Pl=Nl!==void 0&&Nl.env&&Nl.env.NODE_ENV||void 0,Fl=[[`claude`,[`CLAUDECODE`,`CLAUDE_CODE`]],[`replit`,[`REPL_ID`]],[`gemini`,[`GEMINI_CLI`]],[`codex`,[`CODEX_SANDBOX`,`CODEX_THREAD_ID`]],[`opencode`,[`OPENCODE`]],[`pi`,[Il(`PATH`,/\.pi[\\/]agent/)]],[`auggie`,[`AUGMENT_AGENT`]],[`goose`,[`GOOSE_PROVIDER`]],[`devin`,[Il(`EDITOR`,/devin/)]],[`cursor`,[`CURSOR_AGENT`]],[`kiro`,[Il(`TERM_PROGRAM`,/kiro/)]]];function Il(e,t){return()=>{let n=Ml[e];return n?t.test(n):!1}}function J(){let e=Ml.AI_AGENT;if(e)return{name:e.toLowerCase()};for(let[e,t]of Fl)for(let n of t)if(typeof n==`string`?Ml[n]:n())return{name:e};return{}}var Ll=J();Ll.name,Ll.name;var Y=[[`APPVEYOR`],[`AWS_AMPLIFY`,`AWS_APP_ID`,{ci:!0}],[`AZURE_PIPELINES`,`SYSTEM_TEAMFOUNDATIONCOLLECTIONURI`],[`AZURE_STATIC`,`INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN`],[`APPCIRCLE`,`AC_APPCIRCLE`],[`BAMBOO`,`bamboo_planKey`],[`BITBUCKET`,`BITBUCKET_COMMIT`],[`BITRISE`,`BITRISE_IO`],[`BUDDY`,`BUDDY_WORKSPACE_ID`],[`BUILDKITE`],[`CIRCLE`,`CIRCLECI`],[`CIRRUS`,`CIRRUS_CI`],[`CLOUDFLARE_PAGES`,`CF_PAGES`,{ci:!0}],[`CLOUDFLARE_WORKERS`,`WORKERS_CI`,{ci:!0}],[`GOOGLE_CLOUDRUN`,`K_SERVICE`],[`GOOGLE_CLOUDRUN_JOB`,`CLOUD_RUN_JOB`],[`CODEBUILD`,`CODEBUILD_BUILD_ARN`],[`CODEFRESH`,`CF_BUILD_ID`],[`DRONE`],[`DRONE`,`DRONE_BUILD_EVENT`],[`DSARI`],[`GITHUB_ACTIONS`],[`GITLAB`,`GITLAB_CI`],[`GITLAB`,`CI_MERGE_REQUEST_ID`],[`GOCD`,`GO_PIPELINE_LABEL`],[`LAYERCI`],[`JENKINS`,`JENKINS_URL`],[`HUDSON`,`HUDSON_URL`],[`MAGNUM`],[`NETLIFY`],[`NETLIFY`,`NETLIFY_LOCAL`,{ci:!1}],[`NEVERCODE`],[`RENDER`],[`SAIL`,`SAILCI`],[`SEMAPHORE`],[`SCREWDRIVER`],[`SHIPPABLE`],[`SOLANO`,`TDDIUM`],[`STRIDER`],[`TEAMCITY`,`TEAMCITY_VERSION`],[`TRAVIS`],[`VERCEL`,`NOW_BUILDER`],[`VERCEL`,`VERCEL`,{ci:!1}],[`VERCEL`,`VERCEL_ENV`,{ci:!1}],[`APPCENTER`,`APPCENTER_BUILD_ID`],[`CODESANDBOX`,`CODESANDBOX_SSE`,{ci:!1}],[`CODESANDBOX`,`CODESANDBOX_HOST`,{ci:!1}],[`STACKBLITZ`],[`STORMKIT`],[`CLEAVR`],[`ZEABUR`],[`CODESPHERE`,`CODESPHERE_APP_ID`,{ci:!0}],[`RAILWAY`,`RAILWAY_PROJECT_ID`],[`RAILWAY`,`RAILWAY_SERVICE_ID`],[`DENO-DEPLOY`,`DENO_DEPLOY`],[`DENO-DEPLOY`,`DENO_DEPLOYMENT_ID`],[`FIREBASE_APP_HOSTING`,`FIREBASE_APP_HOSTING`,{ci:!0}],[`EDGEONE_PAGES`,`EO_PAGES_CI`,{ci:!0}]];function X(){for(let e of Y)if(Ml[e[1]||e[0]])return{name:e[0].toLowerCase(),...e[2]};return Ml.SHELL===`/bin/jsh`&&Nl.versions?.webcontainer?{name:`stackblitz`,ci:!1}:{name:``,ci:!1}}var Rl=X();Rl.name;var zl=Nl.platform||``;Ml.CI||Rl.ci;var Bl=!!Nl.stdout?.isTTY;Ml.DEBUG,Pl===`test`||Ml.TEST,Pl===`production`||Ml.MODE,Pl===`dev`||Pl===`development`||Ml.MODE,Ml.MINIMAL;var Vl=/^win/i.test(zl);/^linux/i.test(zl),/^darwin/i.test(zl),!Ml.NO_COLOR&&(Ml.FORCE_COLOR||(Bl||Vl)&&Ml.TERM);var Hl=(Nl.versions?.node||``).replace(/^v/,``)||null;Number(Hl?.split(`.`)[0]);var Ul=!!Nl?.versions?.node,Wl=`Bun`in globalThis,Gl=`Deno`in globalThis,Kl=`fastly`in globalThis,ql=`Netlify`in globalThis,Jl=`EdgeRuntime`in globalThis,Yl=globalThis.navigator?.userAgent===`Cloudflare-Workers`,Xl=[[ql,`netlify`],[Jl,`edge-light`],[Yl,`workerd`],[Kl,`fastly`],[Gl,`deno`],[Wl,`bun`],[Ul,`node`]];function Zl(){let e=Xl.find(e=>e[0]);if(e)return{name:e[1]}}var Ql=Zl()?.name||``,$l=()=>({assumed:!0,runtimeName:Ql}),eu=e=>Sl(e)&&`progress`in e&&e.form===ll.data&&e.type===G.progress,tu=e=>Sl(e)&&e.form===ll.data&&e.type===G.request;function nu(e){return tu(e)||Cl(e)||eu(e)}var ru=function(e){return e.peer=`peer`,e.local=`local`,e}({}),iu=[];function au(e){iu.push(e)}function ou(){iu.pop()}function su(){return iu[iu.length-1]}var cu=q.createChildDomain({domain:`err_nice_external_client`,schema:{}}),lu=function(e){return e.timeout=`timeout`,e.not_found=`not_found`,e.unsupported=`unsupported`,e.initialization_failed=`initialization_failed`,e.send_failed=`send_failed`,e.invalid_action_response=`invalid_action_response`,e.reliable_outbox_overflow=`reliable_outbox_overflow`,e.reliable_delivery_abandoned=`reliable_delivery_abandoned`,e.reliable_stream_closed=`reliable_stream_closed`,e}({}),uu=cu.createChildDomain({domain:`err_nice_transport`,schema:{timeout:k({message:({timeout:e})=>`ActionConnect transport timed out after ${e}ms.`}),not_found:k({message:({actionId:e})=>`No connected transport found for action "${e}".`}),unsupported:k({message:({transportShapes:e})=>`${e.length} Transport(s) [${e.join(`, `)}] found but returned "unsupported" status.`}),initialization_failed:k({message:({actionId:e,cause:t,endpoint:n})=>{let r=`Could not connect any transport for action "${e}"${n==null?``:` against ${n}`}`;return t==null?`${r} (all transports failed to initialize).`:`${r}: ${t}${t.endsWith(`.`)?``:`.`}`}}),send_failed:k({message:({actionId:e,httpStatusCode:t,message:n})=>`Failed to send action "${e}" [${t??`Unknown status`}]: ${n??`Unknown error`}.`,httpStatusCode:({httpStatusCode:e})=>e??500}),invalid_action_response:k({message:({actionId:e})=>`Invalid action response JSON structure for action "${e}"`}),reliable_outbox_overflow:k({message:({actionId:e,maxUnacked:t})=>`Reliable outbox for action "${e}" exceeded its unacked window (${t}) — the peer is not acknowledging. Send rejected to bound memory.`}),reliable_delivery_abandoned:k({message:({actionId:e,timeout:t})=>`Reliable action "${e}" was abandoned: not acknowledged within its ${t}ms delivery deadline (or swept with an aborted earlier frame on its stream). The stream skips past it and continues.`}),reliable_stream_closed:k({message:({actionId:e,streamId:t})=>`Reliable action "${e}" was abandoned because its stream ("${t}") was closed (closeReliableStream) while the send was still unacknowledged.`})}}),du=class extends Lr{constructor(e){super(e,{unsupported:e=>uu.fromId(lu.unsupported,{transportShapes:e}),notFound:e=>uu.fromId(lu.not_found,{actionId:e.action==null?`connect()`:e.action.id}),initializationFailed:(e,t)=>uu.fromId(lu.initialization_failed,{actionId:e.action==null?`connect()`:e.action.id,cause:t.cause,endpoint:t.endpoint,kind:t.kind}).withOriginError(t.origin)})}},fu=class{_domains=new Map;assertCanAddDomain(e){let t=this._domains.get(e.domain);if(!(t===e||t==null)&&t!=null)throw q.fromId(K.domain_name_collision,{domain:e.domain,existingParentDomains:t.allDomains,incomingParentDomains:e.allDomains})}addDomain(e){this.assertCanAddDomain(e),this._domains.set(e.domain,e)}removeDomain(e){this._domains.get(e.domain)===e&&this._domains.delete(e.domain)}getDomains(){return[...this._domains.values()]}verifyIsActionJson(e){if(typeof e.domain!=`string`||typeof e.id!=`string`)throw q.fromId(K.wire_not_action_data)}getActionDomain(e){this.verifyIsActionJson(e);let t=this._domains.get(e.domain);if(t)return t}getActionDomainOrThrow(e){this.verifyIsActionJson(e);let t=this._domains.get(e.domain);if(!t)throw q.fromId(K.domain_no_handler,{domain:e.domain});return t}hydrateActionPayload(e){return this.getActionDomainOrThrow(e).hydrateAnyAction(e)}},pu=function(e){return e.runtime_to_handler=`runtime_to_handler`,e.handler_route=`handler_route`,e}({}),mu=class{domainManager=new fu;actionRouteData=new Map;_context;constructor(e){this._context=e}mergeRouter(e){for(let t of e.getDomains())this.domainManager.addDomain(t);for(let[t,n]of e.actionRouteData.entries())this.actionRouteData.set(t,[...n])}addDomainsFromOther(e){for(let t of e.getDomains())this.domainManager.assertCanAddDomain(t);for(let t of e.getDomains())this.domainManager.addDomain(t)}getRouteDataEntriesForAction(e){let t=`dom[${e.domain}]id[${e.id}]`,n=`dom[${e.domain}]id[_]`;return[...this.actionRouteData.get(t)??[],...this.actionRouteData.get(n)??[]]}getRouteDataForAction(e){return this.getRouteDataEntriesForAction(e)[0]}throwNoHandlerForAction(e,t){throw this._context.contextType===pu.handler_route?q.fromId(K.no_action_execution_handler,{domain:e.domain,actionId:e.id,specifiedClient:t.targetLocalRuntime?.coordinate}):this._context.contextType===pu.runtime_to_handler?q.fromId(K.no_action_execution_handler,{domain:e.domain,actionId:e.id,specifiedClient:this._context.runtime.coordinate}):q.fromId(K.no_action_execution_handler,{domain:e.domain,actionId:e.id})}getRouteDataEntriesForActionOrThrow(e,t){let n=this.getRouteDataEntriesForAction(e);return n.length===0&&this.throwNoHandlerForAction(e,t),n}getRouteDataForActionOrThrow(e,t){let n=this.getRouteDataForAction(e);return n||this.throwNoHandlerForAction(e,t),n}getForKey(e){return this.actionRouteData.get(e)??[]}getRegisteredKeys(){return[...this.actionRouteData.keys()]}getDomains(){return this.domainManager.getDomains()}forDomain(e,t){return this.domainManager.addDomain(e),this.actionRouteData.set(`dom[${e.domain}]id[_]`,[t]),this}forAction(e,t){return this.forActionId(e._domain,e.id,t)}forActionId(e,t,n){return this.domainManager.addDomain(e),this.actionRouteData.set(`dom[${e.domain}]id[${t}]`,[n]),this}forActionIds(e,t,n){this.domainManager.addDomain(e);for(let r of t)this.forActionId(e,r,n);return this}forDomainActionCases(e,t){this.domainManager.addDomain(e);for(let n of Object.keys(t)){let r=t[n];r!=null&&this.actionRouteData.set(`dom[${e.domain}]id[${n}]`,[r])}return this}addForDomain(e,t){return this.domainManager.addDomain(e),this._push(`dom[${e.domain}]id[_]`,t),this}addForAction(e,t,n){return this.domainManager.addDomain(e),this._push(`dom[${e.domain}]id[${t}]`,n),this}addForActionIds(e,t,n){this.domainManager.addDomain(e);for(let r of t)this.addForAction(e,r,n);return this}addForDomainActionCases(e,t){this.domainManager.addDomain(e);for(let n of Object.keys(t)){let r=t[n];r!=null&&this._push(`dom[${e.domain}]id[${n}]`,r)}return this}addForKey(e,t){return this._push(e,t),this}removeRouteData(e){for(let[t,n]of this.actionRouteData){let r=n.filter(t=>t!==e);r.length===0?this.actionRouteData.delete(t):r.length!==n.length&&this.actionRouteData.set(t,r)}let t=[...this.actionRouteData.keys()];for(let e of this.domainManager.getDomains()){let n=`dom[${e.domain}]id[`;t.some(e=>e.startsWith(n))||this.domainManager.removeDomain(e)}}_push(e,t){let n=this.actionRouteData.get(e);n==null?this.actionRouteData.set(e,[t]):n.push(t)}},hu=class{_cuid;get cuid(){return this._cuid??=Ya(),this._cuid}getActionRouter(){return this.actionRouter}},gu=class extends hu{peer;handlerType=ru.peer;actionRouter=new mu({contextType:pu.handler_route,handler:this});_incomingRuntime;_incomingActionDataListener;constructor(e){super(),this.peer=e}get peerClient(){return this.peer}forDomain(e){return this.actionRouter.forDomain(e,!0),this}forAction(e){return this.actionRouter.forAction(e,!0),this}forActionIds(e,t){return this.actionRouter.forActionIds(e,t,!0),this}_setIncomingActionDataListener(e,t){if(this._incomingRuntime!=null&&this._incomingRuntime!==e)throw q.fromId(K.peer_handler_already_bound);return this._incomingRuntime=e,this._incomingActionDataListener=t,()=>{this._incomingRuntime!==e||this._incomingActionDataListener!==t||(this._incomingRuntime=void 0,this._incomingActionDataListener=void 0)}}_emitIncoming(e,t){this._incomingActionDataListener?.(e,t)}ownsLiveConnectionFor(e){return!1}clearTransportCache(){}},_u=1024,vu=class{_streams=new Map;_overflowed=new Set;_maxUnacked;_onOverflow;constructor(e){this._maxUnacked=e?.maxUnackedPerStream??_u,this._onOverflow=e?.onOverflow}get maxUnackedPerStream(){return this._maxUnacked}_stream(e){let t=this._streams.get(e);return t??(t={nextSeq:0,ackedSeq:-1,unacked:new Map},this._streams.set(e,t)),t}prepare(e,t,n,r){let i=this._stream(e);if(i.unacked.size>=this._maxUnacked)return this._overflowed.has(e)||(this._overflowed.add(e),this._onOverflow?.(e)),null;let a=i.nextSeq++,o=n==null?{streamId:e,seq:a}:{streamId:e,seq:a,streamKey:n};return i.unacked.set(a,{seq:a,preparedAt:Date.now(),reliability:o,dispatch:t,onDrop:r?.onDrop,onAck:r?.onAck}),{reliability:o}}ack(e,t){let n=this._streams.get(e);if(n==null||t<=n.ackedSeq)return[];n.ackedSeq=t;let r=[];for(let e of n.unacked.values())e.seq<=t&&r.push(e);for(let e of r)n.unacked.delete(e.seq);n.unacked.size<this._maxUnacked&&this._overflowed.delete(e);for(let e of r)e.onAck?.();return r}dropThrough(e,t,n){let r=this._streams.get(e);if(r==null)return[];let i=[];for(let e of r.unacked.values())e.seq<=t&&i.push(e);for(let e of i)r.unacked.delete(e.seq);t>r.ackedSeq&&(r.ackedSeq=t),r.unacked.size<this._maxUnacked&&this._overflowed.delete(e);for(let e of i)e.onDrop?.(n);return i}pending(e){return[...this._streams.get(e)?.unacked.values()??[]]}pendingCount(e){return this._streams.get(e)?.unacked.size??0}oldestPreparedAt(e){let t=this._streams.get(e);if(t!=null)for(let e of t.unacked.values())return e.preparedAt}highestSeq(e){let t=this._streams.get(e);if(!(t==null||t.nextSeq===0))return t.nextSeq-1}allPending(){let e=[];for(let t of this._streams.values())e.push(...t.unacked.values());return e}resendAll(){for(let e of this.allPending())e.dispatch()}resync(e){let t=this._streams.get(e);if(t==null||t.unacked.size===0)return;let n=[...t.unacked.values()],r=new Map;n.forEach((e,t)=>{e.seq=t,e.reliability.seq=t,r.set(t,e)}),t.unacked=r,t.ackedSeq=-1,t.nextSeq=n.length;for(let e of r.values())e.dispatch()}get size(){let e=0;for(let t of this._streams.values())e+=t.unacked.size;return e}},yu=6e4,bu=1e3,xu=class extends gu{_connectionIdentity;_defaultTimeout;_reliableTimeout;_wire;get canPush(){return this._wire.canPush}get localCoordinate(){return this._wire.localCoordinate}get securityLevel(){return this._wire.securityLevel}get wireMux(){return this._wire.wireMux}get requestReconnect(){return this._wire.requestReconnect}get debug(){return this._wire.debug}_outbox=new vu;_resendHooked=new WeakSet;_deliveryDeadlines=new WeakMap;_streamSkips=new Map;_streamCloses=new Map;_controlMethods;_reliableEventListeners=new Set;constructor({peer:e,runtimeCoordinate:t,transports:n,defaultTimeout:r,reliableActionTimeout:i,wireMux:a,localCoordinate:o,connectionIdentity:s,securityLevel:c,reconnect:l,keepLinkAlive:u}){super(e??t),this._connectionIdentity=s,this._defaultTimeout=r??1e4,this._reliableTimeout=i??yu,this._wire=new So({createManager:e=>new du(e),mux:a,peer:this.peer,localCoordinate:s??o,securityLevel:c,canPush:n.some(e=>e.type===br.duplex),reconnect:l??u,buildConnectInput:e=>e,defaultLocalCoordinate:()=>Su.getDefault().coordinate});for(let e of n){let t=e._createConnection({resolvers:{onIncomingActionDataJson:(e,t)=>{t?.ack!=null&&this._applyAck($c(this.peer,e.domain,e.id,t.streamKey),t.ack),this._emitIncoming(e)},onControlMessage:e=>{let t=$c(this.peer,e.domain,e.id,e.k);e.$c===`rack`?this._applyAck(t,e.ack):e.$c===`rsync`&&(this._streamSkips.delete(t),this._outbox.resync(t))}}});t.definition=e,this._wire.addTransport(t)}}async connect(e){await this._wire.connect({localCoordinate:this._connectionIdentity??e?.targetLocalRuntime?.coordinate})}reconnectLink(){return this._wire.reconnectLink()}dispose(){this._wire.dispose()}async handleActionRequest(e,t){let n=t?.targetLocalRuntime??Su.getDefault(),r=this._connectionIdentity??n.coordinate;this._connectionIdentity!=null&&e.context._setOriginClient(this._connectionIdentity);let i=t?.timeout??this._defaultTimeout,a=su(),o=n._captureActionCallSite(e,t?.captureCallSites),s={action:e,localClient:r,externalClient:this.peer},c=this._wire.getPreferredTransport(),l=c==null?void 0:{runtime:r,handler:this.toHandlerRouteItem(c,s),time:Date.now()};l!=null&&e.context.addRouteItem(l);let u=new xl({context:e.context,request:e,parentCuid:a,callSite:o});if(n.registerRunningAction(u),e.schema.reliabilityTier!==Ol.none){let n=t?.streamKey,r=$c(this.peer,e.domain,e.id,n),a=this._outbox.prepare(r,()=>{u.isAborted||this._dispatchWhenTransportReady(u,s,l,i)},n,{onDrop:e=>{u._notifyAckAbandoned(e),u._abort(e)},onAck:()=>u._notifyAcked()});if(a==null)return this._emitReliableEvent(n==null?{type:`overflow`,domain:e.domain,actionId:e.id}:{type:`overflow`,domain:e.domain,actionId:e.id,streamKey:n}),u._abort(uu.fromId(lu.reliable_outbox_overflow,{actionId:e.id,streamId:r,maxUnacked:this._outbox.maxUnackedPerStream})),u;s.reliability=a.reliability,u._setReliability({tier:e.schema.reliabilityTier,seq:a.reliability.seq,streamKey:n}),this._armDeliveryDeadline(r,a.reliability,u);let o=u.addUpdateListeners([t=>{t.type===yl.finished&&(o(),u.isAborted&&this._abandonReliableThrough(r,a.reliability,e.domain,e.id,n))}])}return this._dispatchWhenTransportReady(u,s,l,i),u}async _dispatchWhenTransportReady(e,t,n,r){let i=t.action;try{let{methods:a,transport:o}=await this._wire.getReadyTransport(t);a.addOnDisconnectListener!=null&&!this._resendHooked.has(a)&&(this._resendHooked.add(a),a.addOnDisconnectListener(()=>{this._outbox.size>0&&setTimeout(()=>this._outbox.resendAll(),0)}),a.sendControlData!=null&&(this._controlMethods=a),this._outbox.size>0&&setTimeout(()=>this._outbox.resendAll(),0));let s=this.toHandlerRouteItem(o,t);n==null?i.context.addRouteItem({runtime:t.localClient,handler:s,time:Date.now()}):(n.handler=s,n.time=Date.now());let c={...t,runningAction:e,timeout:r};i.type===G.request&&a.updateRunConfig!=null&&(c.timeout=a.updateRunConfig(c)?.timeout??r),a.sendActionData(c),this._streamSkips.size>0&&this._flushStreamSkips(),i.type===G.request&&i.schema.responseMode===Dl.none&&e._completeWithResult(i.successResult(void 0))}catch(a){if(i.type===G.request&&t.reliability!=null){e.isAborted||setTimeout(()=>{e.isAborted||this._dispatchWhenTransportReady(e,t,n,r)},bu);return}e._abort(a)}}_applyAck(e,t){for(let n of this._outbox.ack(e,t)){let e=this._deliveryDeadlines.get(n.reliability);e!=null&&(clearTimeout(e),this._deliveryDeadlines.delete(n.reliability))}let n=this._streamSkips.get(e);n!=null&&t>=n.seq&&this._streamSkips.delete(e)}_armDeliveryDeadline(e,t,n){let r=setTimeout(()=>{if(!n._abort(uu.fromId(lu.reliable_delivery_abandoned,{actionId:n.state.request.id,streamId:e,timeout:this._reliableTimeout}))){let r=n.state.request;sl(r.domain,r.id),this._abandonReliableThrough(e,t,r.domain,r.id,t.streamKey)}},this._reliableTimeout);this._deliveryDeadlines.set(t,r)}_abandonReliableThrough(e,t,n,r,i,a){let o=t.seq;if(o==null)return;let s=a??uu.fromId(lu.reliable_delivery_abandoned,{actionId:r,streamId:e,timeout:this._reliableTimeout}),c=this._outbox.dropThrough(e,o,s);for(let e of c){let t=this._deliveryDeadlines.get(e.reliability);t!=null&&(clearTimeout(t),this._deliveryDeadlines.delete(e.reliability))}if(c.length>0&&this._emitReliableEvent({type:`abandoned`,domain:n,actionId:r,...i==null?{}:{streamKey:i},fromSeq:c[0].seq,toSeq:o,reason:s}),c.length===0&&(this._streamSkips.get(e)?.seq??-1)>=o)return;let l=this._streamSkips.get(e);(l==null||o>l.seq)&&this._streamSkips.set(e,i==null?{$c:`rskip`,domain:n,id:r,seq:o}:{$c:`rskip`,domain:n,id:r,seq:o,k:i}),this._flushStreamSkips()}_flushStreamSkips(){let e=this._controlMethods;if(e?.sendControlData!=null){for(let t of this._streamSkips.values())e.sendControlData(t);for(let[t,n]of this._streamCloses)e.sendControlData(n),this._streamCloses.delete(t)}}addReliableEventListener(e){return this._reliableEventListeners.add(e),()=>{this._reliableEventListeners.delete(e)}}_emitReliableEvent(e){for(let t of this._reliableEventListeners)try{t(e)}catch(e){console.error(`[reliable] onReliableEvent listener threw`,e)}}addLinkEventListener(e){return this._wire.addLinkEventListener(e)}closeReliableStream(e,t){let n=$c(this.peer,e.domain,e.id,t),r=this._outbox.highestSeq(n);if(r==null)return;let i=uu.fromId(lu.reliable_stream_closed,{actionId:e.id,streamId:n});this._abandonReliableThrough(n,{streamId:n,seq:r,streamKey:t},e.domain,e.id,t,i),this._streamCloses.set(n,t==null?{$c:`rclose`,domain:e.domain,id:e.id}:{$c:`rclose`,domain:e.domain,id:e.id,k:t}),this._flushStreamSkips()}reliablePending(e,t){if(e==null)return this._outbox.size;let n=$c(this.peer,e.domain,e.id,t),r=this._outbox.oldestPreparedAt(n);return{unackedCount:this._outbox.pendingCount(n),oldestUnackedAgeMs:r==null?void 0:Date.now()-r,maxUnackedPerStream:this._outbox.maxUnackedPerStream}}async sendReturnPayload(e,t){let n=this._connectionIdentity??t.targetLocalRuntime.coordinate;try{let{methods:t}=await this._wire.getReadyTransport({action:e,localClient:n,externalClient:this.peer});return t.sendReturnData==null?!1:(t.sendReturnData(e,{localClient:n,externalClient:this.peer}),!0)}catch{return!1}}toJsonObject(){return{type:this.handlerType,client:this.peer}}toHandlerRouteItem(e,t){return{type:this.handlerType,client:this.peer,transOrd:e.transOrd,transShape:e.type,transInfo:e.getRouteInfo(t)}}releaseLink(){this._wire.releaseLink()}clearTransportCache(){this._wire.clearTransportCache()}},Su=class{_coordinate;timeCreated;runtimeInfo=$l();actionRouter;_pendingRunningActions=new Map;_registeredPeerHandlers=[];_registeredRoots=new Set;_handlerOwnership=new Map;_disposed=!1;captureCallSites;scope;static getDefault(){return Tu()}constructor(e,t={}){this._coordinate=e,this.captureCallSites=t.captureCallSites??!1,this.scope=t.scope??`global`,this.timeCreated=Date.now(),this.actionRouter=new mu({contextType:pu.runtime_to_handler,runtime:this})}get coordinate(){return this._coordinate.insId??(this._coordinate=this._coordinate.specify({insId:Ya(14)})),this._coordinate}get disposed(){return this._disposed}_assertActive(){if(this._disposed)throw q.fromId(K.runtime_disposed,{runtime:this.coordinate.stringId})}_captureActionCallSite(e,t){return e._callSite==null&&(t??this.captureCallSites)&&(e._callSite=jl()),e._callSite}specifyRuntimeCoordinate(e){if(this._assertActive(),e.envId!=null&&this._coordinate.envId!==e.envId)throw q.fromId(K.not_implemented,{label:`updating RuntimeCoordinate with a different "envId" ("${this._coordinate.envId}" → "${e.envId}")`});this._coordinate=this._coordinate.specify(e)}registerRunningAction(e){this._assertActive(),this._pendingRunningActions.set(e.cuid,e),e.addUpdateListeners([t=>{t.type===yl.finished&&this._pendingRunningActions.delete(e.cuid)}])}resolveIncomingActionPayload(e,t){if(!this._disposed){if(e.type===G.request){this._handleActionPayloadWireFromReceiver(e,t).catch(t=>{console.error(`[ActionRuntime] Incoming action [${e.domain}:${e.id}:${e.form}:${e.type}] unhandled:`,t)});return}this._pendingRunningActions.get(e.context.cuid)?._resolveFromJson(e)}}async _handleActionPayloadWireFromReceiver(e,t){let n=this._hydrateActionPayloadWire(e);return t!=null&&n.context._setReceiverMetadata(t),this.handleActionPayload(n)}_hydrateActionPayloadWire(e){if(nu(e))return this.actionRouter.domainManager.getActionDomainOrThrow(e).hydrateAnyAction(e);throw q.fromId(K.wire_not_action_data)}async handleActionPayloadWire(e){return this._assertActive(),this.handleActionPayload(this._hydrateActionPayloadWire(e))}responseModeForWire(e){try{return this.actionRouter.domainManager.getActionDomainOrThrow(e).actionSchema[e.id]?.responseMode}catch{return}}reliabilityTierForWire(e){return this.reliabilityTierForRoute(e.domain,e.id)}reliabilityTierForRoute(e,t){try{return this.actionRouter.domainManager.getActionDomainOrThrow({domain:e,id:t}).actionSchema[t]?.reliabilityTier}catch{return}}async handleActionPayload(e,t){if(this._assertActive(),e.type===G.request){let n=e.context._domain._collectActionObservers(),r;try{r=this.getHandlerForActionOrThrow(e,t)}catch(t){let r=new xl({context:e.context,request:e});return r.addUpdateListeners(n),r._completeWithResult(e.errorResult(ve(t))),r}let i;try{i=new _l({context:e.context},e.context.validateInput(e.input),{time:e.time}),i._callSite=e._callSite}catch(t){let r=new xl({context:e.context,request:e});return r.addUpdateListeners(n),r._completeWithResult(e.errorResult(ve(t))),this._trySetupReturnDispatch(r),r}let a=await r.handleActionRequest(i,{...t,targetLocalRuntime:this});return a.addUpdateListeners(n),this._trySetupReturnDispatch(a),a}throw q.fromId(K.not_implemented,{label:`Handling incoming action payloads of type "${e.type}"`})}_getHandlerForAction(e,t){let n=this.actionRouter.getRouteDataEntriesForAction(e).filter(t=>t.handlerType===ru.peer||t.handlerType===ru.local&&e.type===G.request);if(n.length===0)return;let r=-1,i;for(let e of n){if(e.handlerType===ru.local)return e;if(e.handlerType===ru.peer){let t=$a.unknown.similarityLevel(e.peer);t>r&&(r=t,i=e)}}return i}getHandlerForActionOrThrow(e,t){let n=this._getHandlerForAction(e,t);if(n==null)throw q.fromId(K.no_action_execution_handler,{actionId:e.id,domain:e.domain});return n}addHandlers(e){return this._addHandlers(e,{persistent:!0,register:!0}),this}_installHandlers(e,t={}){this._assertActive();let n=Symbol(`action-runtime-handler-installation`);try{this._addHandlers(e,{persistent:!1,register:t.register??!1,lease:n})}catch(e){throw this._releaseHandlerLease(n),e}let r=!1;return()=>{r||(r=!0,this._releaseHandlerLease(n))}}_addHandlers(e,t){this._assertActive(),this._assertNoDuplicateLocalExecutors(e);for(let n of e){let e=this._handlerOwnership.get(n);if(e==null){let t=n.getActionRouter();e={persistent:!1,leases:new Set};try{this.actionRouter.addDomainsFromOther(t),n.handlerType===ru.peer&&(e.unbind=n._setIncomingActionDataListener(this,(e,t)=>this.resolveIncomingActionPayload(e,t)),this._registeredPeerHandlers.push(n));for(let e of t.getRegisteredKeys())this.actionRouter.addForKey(e,n)}catch(t){e.unbind?.(),this.actionRouter.removeRouteData(n);let r=this._registeredPeerHandlers.indexOf(n);throw r>=0&&this._registeredPeerHandlers.splice(r,1),t}this._handlerOwnership.set(n,e)}t.persistent&&(e.persistent=!0),t.lease!=null&&e.leases.add(t.lease)}t.register&&this._registerWithRoutedRoots()}_assertNoDuplicateLocalExecutors(e){for(let t of e)for(let e of t.getActionRouter().getDomains())this.actionRouter.domainManager.assertCanAddDomain(e);let t=new Map;for(let n of e)if(!(n.handlerType!==ru.local||this._handlerOwnership.has(n)))for(let e of n.getActionRouter().getRegisteredKeys()){let r=this.actionRouter.getForKey(e).find(e=>e.handlerType===ru.local)??t.get(e);if(r!=null&&r!==n)throw q.fromId(K.duplicate_action_executor,{route:e});t.set(e,n)}}_releaseHandlerLease(e){for(let[t,n]of this._handlerOwnership){if(n.leases.delete(e),n.persistent||n.leases.size>0)continue;n.unbind?.(),this.actionRouter.removeRouteData(t);let r=this._registeredPeerHandlers.indexOf(t);r>=0&&this._registeredPeerHandlers.splice(r,1),this._handlerOwnership.delete(t)}}connectTo(e,t){let n=new xu({peer:e,transports:t.transports,defaultTimeout:t.defaultTimeout,reliableActionTimeout:t.reliableActionTimeout,wireMux:t.wireMux,localCoordinate:this.coordinate,connectionIdentity:t.connectionIdentity,securityLevel:t.securityLevel,reconnect:t.reconnect??t.keepLinkAlive});for(let e of t.domains??[])n.forDomain(e);for(let e of t.actions??[])n.forAction(e);return this.addHandlers([n,...t.localHandlers??[]]),n}applyRuntimeForDomain(e){let t=e.rootDomain;t._hasRuntime(this)||(t._registerRuntime(this),this._registeredRoots.add(t))}_registerWithRoutedRoots(){if(this.scope!==`instance`)for(let e of this.actionRouter.getDomains())this.applyRuntimeForDomain(e)}apply(){return this._assertActive(),this._registerWithRoutedRoots(),this}async run(e,t){return this._assertActive(),e.run({...t,targetLocalRuntime:this})}getReturnHandlerForOrigin(e){if(e.envId===`_unset_`)return;let t=-1,n,r=-1,i;for(let a of this._registeredPeerHandlers){if(!a.canPush)continue;let o=e.similarityLevel(a.peer);o>t&&(t=o,n=a),a.ownsLiveConnectionFor(e)&&o>r&&(r=o,i=a)}return i??(t>0?n:void 0)}resetRuntime(){this._assertActive();for(let e of this._pendingRunningActions.values())e._abort(q.fromId(K.runtime_reset));for(let e of this._registeredPeerHandlers)e.clearTransportCache()}dispose(){if(!this._disposed){this._disposed=!0;for(let e of this._registeredRoots)e._unregisterRuntime(this);if(this._registeredRoots.clear(),this._pendingRunningActions.size>0){let e=q.fromId(K.runtime_disposed,{runtime:this.coordinate.stringId});for(let t of this._pendingRunningActions.values())t._abort(e)}this._pendingRunningActions.clear();for(let e of this._registeredPeerHandlers){let t=e;typeof t.dispose==`function`?t.dispose():e.clearTransportCache()}for(let[e,t]of this._handlerOwnership)t.unbind?.(),this.actionRouter.removeRouteData(e);this._handlerOwnership.clear(),this._registeredPeerHandlers.length=0}}_trySetupReturnDispatch(e){if(e.context.schema.responseMode===Dl.none)return;let t=e.context.originClient;if(t.envId===`_unset_`||t.isSameFor(this._coordinate).id)return;let n=e.context._getReceiverMetadata();e.addUpdateListeners([e=>{if(e.type===yl.finished&&e.finishType===bl.success){if(this._disposed)return;let r=n?.receiver instanceof gu?this._registeredPeerHandlers.includes(n.receiver)&&n.receiver.canPush?n.receiver:void 0:this.getReturnHandlerForOrigin(t);if(r==null||!Cu(n,r))return;r.sendReturnPayload(e.response,{targetLocalRuntime:this}).catch(()=>{})}}])}};function Cu(e,t){return e==null||e.receiver===t?!0:e.securityLevel!=null&&e.securityLevel!==ro.none}var wu={defaultLocalRuntime:void 0,assumedRuntimeInfo:void 0};function Tu(){return wu.assumedRuntimeInfo??=$l(),wu.defaultLocalRuntime??=new Su($a.unknown.specify({perId:`${wu.assumedRuntimeInfo?.runtimeName??`unknown`}-runtime`})),wu.defaultLocalRuntime}var Eu=class extends hu{handlerType=ru.local;actionRouter=new mu({contextType:pu.handler_route,handler:this});constructor(){super()}forDomain(e,t){return this.actionRouter.forDomain(e,t),this}forAction(e,t){return this.actionRouter.forAction(e,t),this}forActionIds(e,t,n){return this.actionRouter.forActionIds(e,t,n),this}forDomainActionCases(e,t){return this.actionRouter.forDomainActionCases(e,t),this}async handleActionRequest(e,t){let n=t?.targetLocalRuntime??Su.getDefault(),r=this.actionRouter.getRouteDataForActionOrThrow(e,{targetLocalRuntime:n});e.context.addRouteItem({runtime:n.coordinate,handler:this.toHandlerRouteItem(),time:Date.now()});let i=new xl({context:e.context,request:e,parentCuid:su(),callSite:n._captureActionCallSite(e,t?.captureCallSites)});return this._handleRunningAction(r,i,n),i}async _handleRunningAction(e,t,n){let r=t.state;if(r.result==null){await Promise.resolve(),au(t.cuid);try{let i=await ye(async()=>{let t=r.request.context._getReceiverMetadata()?.securityLevel,i={runtime:n,origin:r.request.context.originClient,authenticatedOrigin:t!=null&&t!==ro.none?r.request.context.originClient:void 0,securityLevel:t,reliability:r.request.context.reliability,run:(e,t)=>n.run(e,t)},a=await e(r.request,i);return a instanceof gl?a:a!=null&&Cl(a)?this.actionRouter.domainManager.getActionDomainOrThrow(r.request).hydrateResultPayload(a):r.request.successResult(a)}),a=i.ok?i.output:r.request.errorResult(i.error);t._completeWithResult(a)}finally{ou()}}}async handlePayloadWireOrThrow(e,t){let n=this.actionRouter.domainManager.hydrateActionPayload(e);if(!(n instanceof _l))throw q.fromId(K.wire_action_not_payload,{domain:n.domain,actionId:n.id,actionState:n.type??n.form});return await this.handleActionRequest(n,t)}toJsonObject(){return{type:this.handlerType}}toHandlerRouteItem(){return{type:this.handlerType}}},Du=e=>Sl(e)&&e.form===ll.context,Ou=e=>Sl(e)&&e.form===ll.core;function ku(e){return nu(e)||Du(e)||Ou(e)}function Au(e){if(!ku(e))throw q.fromId(K.wire_not_action_data)}function ju(e){return e instanceof vl||e instanceof dl||e instanceof ul}var Mu=class{domain;allDomains;actionSchema;_listeners=[];constructor(e){this.domain=e.domain,this.allDomains=e.allDomains,this.actionSchema=e.actionSchema}addActionListener(e){return this._listeners.push(e),()=>{this._listeners=this._listeners.filter(t=>t!==e)}}_getActionObservers(){return this._listeners}},Nu=class{_runtimes=new Set;_context;constructor(e){this._context=e??{}}registerRuntime(e){e._assertActive(),this._runtimes.add(e)}unregisterRuntime(e){this._runtimes.delete(e)}getRuntimeAndHandlerForAction(e,t,n){let r=t?.targetLocalRuntime;if(r!=null){r._assertActive();let i=r._getHandlerForAction(e,t);if(i!=null)return{handler:i,runtime:r};if(n)throw q.fromId(K.no_action_execution_handler,{domain:e.domain,actionId:e.id,specifiedClient:r.coordinate});return}let i,a;for(let t of this._runtimes){if(t.disposed)continue;let n=t._getHandlerForAction(e);n!=null&&(i==null?i={handler:n,runtime:t}:(a??=[i.runtime.coordinate.stringId],a.push(t.coordinate.stringId)))}if(a!=null)throw q.fromId(K.ambiguous_action_runtime,{domain:e.domain,actionId:e.id,runtimes:a});if(i!=null)return i;if(n&&this._runtimes.size===0)throw q.fromId(K.no_client_runtimes_registered,{context:this._context});if(n)throw q.fromId(K.no_action_execution_handler,{domain:e.domain,actionId:e.id})}getRuntimeAndHandlerForActionOrThrow(e,t){return this.getRuntimeAndHandlerForAction(e,t,!0)}hasRuntime(e){return this._runtimes.has(e)}},Pu=class extends Mu{domainDefinition;_actionRuntimeManager;constructor(e){let t=e.domain;super({domain:t,allDomains:[t],actionSchema:{}}),this.domainDefinition=e,this._actionRuntimeManager=new Nu({domain:t})}createChildDomain(e){if(this.allDomains.includes(e.domain))throw q.fromId(K.domain_already_exists_in_hierarchy,{domain:e.domain,allParentDomains:this.allDomains,parentDomain:this.domain});return new Fu({allDomains:[...this.allDomains,e.domain],domain:e.domain,actionSchema:e.actions},{rootDomain:this})}_registerRuntime(e){this._actionRuntimeManager.registerRuntime(e)}_unregisterRuntime(e){this._actionRuntimeManager.unregisterRuntime(e)}_hasRuntime(e){return this._actionRuntimeManager.hasRuntime(e)}async _runAction(e,t){let n=[...this._listeners,...t?.listeners??[]],r;try{r=this._actionRuntimeManager.getRuntimeAndHandlerForActionOrThrow(e,t)}catch(t){let r=new xl({context:e.context,request:e,callSite:e._callSite});throw r.addUpdateListeners(n),r._failWithError(t),t}let{handler:i,runtime:a}=r;a._captureActionCallSite(e,t?.captureCallSites),e.context._setOriginClient(a.coordinate);let o=await i.handleActionRequest(e,{targetLocalRuntime:a,timeout:t?.timeout,streamKey:t?.streamKey,captureCallSites:t?.captureCallSites});return o.addUpdateListeners(n),o}},Fu=class e extends Mu{_rootDomain;_actionMap;constructor(e,{rootDomain:t}){super(e),this._rootDomain=t,this._actionMap=this.createActionMap()}get rootDomain(){return this._rootDomain}_collectActionObservers(){return[...this._rootDomain._getActionObservers(),...this._getActionObservers()]}_registerRuntime(e){this._rootDomain._registerRuntime(e)}createChildDomain(t){if(this.allDomains.includes(t.domain))throw q.fromId(K.domain_already_exists_in_hierarchy,{domain:t.domain,allParentDomains:this.allDomains,parentDomain:this.domain});return new e({allDomains:[...this.allDomains,t.domain],domain:t.domain,actionSchema:t.actions},{rootDomain:this._rootDomain})}get action(){return this._actionMap}actionsMap(){return this._actionMap}actionForId(e){if(!this.actionSchema[e])throw q.fromId(K.action_id_not_in_domain,{domain:this.domain,actionId:e});return new vl(this,e)}wrapAsPartialLocalHandler(e){let t=new Eu,n=e;for(let r in e)this.actionSchema[r]&&t.forAction(this.actionForId(r),(e,t)=>n[e.id](e.input,t));return t}wrapAsLocalHandler(e){let t=new Eu,n=e;return t.forDomain(this,(e,t)=>n[e.id](e.input,t))}hydrateContext(e,t){return new ul(this,e,{timeCreated:t.timeCreated,cuid:t.cuid,routing:t.routing.map(e=>({runtime:new $a(e.runtime),handler:e.handler,time:e.time})),originClient:t.originClient?new $a(t.originClient):$a.unknown})}isDomainAction(e){return ju(e)&&e.domain===this.domain}hydrateRequestPayload(e){if(e.type!==G.request)throw q.fromId(K.hydration_action_state_mismatch,{expected:G.request,received:e.type});if(e.domain!==this.domain)throw q.fromId(K.hydration_domain_mismatch,{expected:this.domain,received:e.domain});let t=e.id;if(!this.actionSchema[t])throw q.fromId(K.hydration_action_id_not_found,{domain:this.domain,actionId:e.id});let n=this.hydrateContext(t,e.context);return new _l({context:n},n.deserializeInput(e.input),{time:e.time})}hydrateResultPayload(e){if(e.type!==G.result)throw q.fromId(K.hydration_action_state_mismatch,{expected:G.result,received:e.type});if(e.domain!==this.domain)throw q.fromId(K.hydration_domain_mismatch,{expected:this.domain,received:e.domain});let t=e.id;if(!this.actionSchema[t])throw q.fromId(K.hydration_action_id_not_found,{domain:this.domain,actionId:e.id});let n=this.hydrateContext(t,e.context),r=e.result.ok?{ok:!0,output:n.schema.deserializeOutput(e.result.output)}:{ok:!1,error:ve(e.result.error)};return new gl({context:n},r,{time:e.time})}hydrateAnyAction(e){if(Au(e),e.form===ll.data){if(e.type===G.request)return this.hydrateRequestPayload(e);if(e.type===G.result)return this.hydrateResultPayload(e)}return this.actionForId(e.id)}async runAction(e,t){let n=[...t?.listeners??[],...this._listeners];return this._rootDomain._runAction(e,{...t,listeners:n})}createActionMap(){let e={};for(let t in this.actionSchema)e[t]=new vl(this,t);return e}},Iu=e=>new Pu(e);function Lu(e,t){let n=t?.incoming?.(e)??(typeof e==`string`?Ru(e):void 0);return n!=null&&nu(n)?n:void 0}function Ru(e){try{let t=JSON.parse(e);return nu(t)?t:void 0}catch{return}}ro.none,ro.authenticated,ro.encrypted;function zu(e){return{localClient:e.localClient,externalClient:e.externalClient,dialContext:e}}function Bu(e){return`shape`in e&&e.shape===`exchange`}function Vu(e,t){return e==null?void 0:(t===G.request?e.seq:e.ack)??void 0}function Hu(e,t){let n=t===G.request?0:-1;if(!(typeof e!=`number`||!Number.isInteger(e)||e<n))return t===G.request?{seq:e}:{ack:e}}var Uu={[G.request]:0,[G.result]:1,[G.progress]:2},Wu=[G.request,G.result,G.progress];function Gu(e){let t=new Map,n=[];for(let r of e)for(let e of Object.keys(r.actionSchema)){let i=`${r.domain}:${e}`;t.has(i)||(t.set(i,n.length),n.push({domain:r.domain,id:e,allDomains:r.allDomains}))}return{routeToInt:t,intToRoute:n}}function Ku(e){if(e.type===G.request)return e.input;if(e.type===G.result)return e.result;if(e.type===G.progress)return e.progress}function qu(e,t,n,r,i){let a={form:ll.data,domain:e.domain,id:e.id,allDomains:e.allDomains,time:n,context:r};return t===G.request?{...a,type:G.request,input:i,inputHash:``}:t===G.result?{...a,type:G.result,result:i,outputHash:``}:{...a,type:G.progress,progress:i}}var Ju={route:0,type:1,corr:2,time:3,originClient:4,payload:5,reliability:6,streamKey:7},Yu=6,Xu=7,Zu=8,Qu=5*6e4;function $u(e){return e!=null&&e.envId!==`_unset_`}function ed(e,t,n){for(let[r,i]of e){if(t-i.time<=n)break;e.delete(r)}}function td(e,t){let{routeToInt:n,intToRoute:r}=Gu(e),i=$a.unknown.toJsonObject(),a=t?.correlationTtlMs??Qu;return()=>{let e=0,t=new Map,o=new Map,s,c;return{outgoing:r=>{let i=r.action.toJsonObject(),c=`${i.domain}:${i.id}`,l=n.get(c);if(l==null)throw Error(`[binary-wire] Cannot pack unregistered action route: ${c}`);let u=Date.now();ed(t,u,a),ed(o,u,a);let d,f;i.type===G.request?(d=e++,t.set(d,{value:i.context.cuid,time:u}),s==null&&$u(i.context.originClient)&&(s=i.context.originClient,f=i.context.originClient)):(d=o.get(i.context.cuid)?.value??-1,i.type===G.result&&o.delete(i.context.cuid));let p=Vu(r.reliability,i.type),m=r.reliability?.streamKey,h=Array(m==null?p==null?Yu:Xu:Zu);return h[Ju.route]=l,h[Ju.type]=Uu[i.type],h[Ju.corr]=d,h[Ju.time]=i.time,h[Ju.originClient]=f,h[Ju.payload]=Ku(i),p!=null&&(h[Ju.reliability]=p),m!=null&&(h[Ju.streamKey]=m),Vs(h)},incoming:e=>{let n;if(e instanceof ArrayBuffer)n=new Uint8Array(e);else if(e instanceof Uint8Array)n=e;else return;try{let e=_s(n);if(!nd(e))return;let l=r[e[Ju.route]],u=Wu[e[Ju.type]];if(l==null||u==null)return;let d=Date.now();ed(t,d,a),ed(o,d,a);let f=e[Ju.corr],p=e[Ju.time],m=e[Ju.originClient],h,g;return u===G.request?(h=Ya(),o.set(h,{value:f,time:d}),$u(m)&&(c=m),g=c??i):(h=t.get(f)?.value??Ya(),u===G.result&&t.delete(f),g=s??i),qu(l,u,p,{cuid:h,timeCreated:p,routing:[],originClient:g},e[Ju.payload])}catch(e){console.error(`[binary-wire] Failed to unpack binary action session frame`,e);return}},incomingReliability:e=>{let t;if(e instanceof ArrayBuffer)t=new Uint8Array(e);else if(e instanceof Uint8Array)t=e;else return;try{let e=_s(t);if(!nd(e)||e.length!==Xu&&e.length!==Zu)return;let n=Wu[e[Ju.type]];if(n==null)return;let r=Hu(e[Ju.reliability],n);if(r==null)return;if(e.length===Zu){let t=e[Ju.streamKey];if(typeof t!=`string`)return;r.streamKey=t}return r}catch{return}}}}}function nd(e){return Array.isArray(e)&&(e.length===Yu||e.length===Xu||e.length===Zu)}var rd=class{};function id(e){return od(e,Rc(e.carrier))}async function ad(e){return od(e,await zc({carrier:e.carrier,secure:e.secure,lane:{dictionaryVersion:e.secure.dictionaryVersion,channels:e.secure.channelTags}}))}function od(e,t){return{sendActionData:e=>{sd(t,e).catch(t=>e.runningAction._abort(t))},updateRunConfig:e.updateRunConfig}}async function sd(e,t){let{action:n,runningAction:r,timeout:i}=t,a=new AbortController,o=!1,s=setTimeout(()=>{o=!0,a.abort()},i),c=r.addUpdateListeners([e=>{e.type===yl.finished&&(clearTimeout(s),a.abort())}]);try{if(n.type!==G.request){await e.send(n.toJsonObject(),{signal:a.signal});return}let t=await e.exchange(n.toJsonObject(),{signal:a.signal});if(!t.ok&&t.reason===`peer_error`)throw uu.fromId(lu.send_failed,{actionState:n.type,actionId:n.id,message:t.message});if(!t.ok||!Cl(t.wire))throw uu.fromId(lu.invalid_action_response,{actionId:n.id});r._completeWithResult(n._domain.hydrateResultPayload(t.wire))}catch(e){throw o?uu.fromId(lu.timeout,{timeout:i}):e}finally{clearTimeout(s),c()}}var cd=class extends Cc{},ld=class extends cd{constructor(e){super({...e,type:br.exchange})}_getCacheKey(e){return this.initialized.getCacheKey?.(e).join(`\0`)??``}_needsAsyncBringUp(e){return e.secureChannel!=null&&e.secureChannel.securityLevel!==ro.none}_finalizeReady(e){let t=e.secureChannel;return t!=null&&t.securityLevel!==ro.none?ad({...this._sessionContext(e),secure:t}):this._finalizeTransportMethods(e)}_finalizeTransportMethods(e){return id(this._sessionContext(e))}_sessionContext(e){return{carrier:e.carrier,updateRunConfig:e.updateRunConfig,secure:e.secureChannel}}},ud=class e extends rd{options;type=br.exchange;constructor(e){super(),this.options=e}static create(t){return new e(t)}_createConnection(e){let t=this.options;return new ld({initialize:()=>({getCacheKey:t.getCacheKey,isAvailable:t.available,getTransport:e=>{dd(t);let n=t.openCarrier(e);return{status:xr.ready,readyData:{carrier:t.wireTap==null?n:nc(n,t.wireTap),secureChannel:t.security,updateRunConfig:t.updateRunConfig}}}})})}getRouteInfo(e){return this.options.getRouteInfo==null?{carrierLabel:this.options.label??`exchange`,summary:this.options.label??`exchange`}:this.options.getRouteInfo(e)}};function dd(e){if(!(e.exchangeOnlyConnection!==!0||e.mux==null))for(let t of Qs(e.mux.localCaps()))throw Sr.fromId(`protocol_on_exchange_only`,{protocolId:t})}var fd=e=>({onIncomingActionDataJson:t=>{console.warn(`Received incoming action JSON [${t.domain}:${t.id}] on Transport [${e}] but no incoming data listener has been set.`)}});function pd(e,t){return{id:`action`,onLaneFrame:t=>_d(e,t),onDetach:()=>vd(e,t)}}function md(e){let t=new Set;return gd(e,mc({channel:e.channel,lane:pd(e,t),heartbeat:e.heartbeat,tap:e.wireTap}),t)}async function hd(e){let t=new Set,n={...pd(e,t),handshakeConfig:()=>({dictionaryVersion:e.secure.dictionaryVersion,channels:e.secure.channelTags})},r=await hc({channel:e.channel,secure:e.secure,lane:n,mux:e.secure.mux,heartbeat:e.heartbeat,tap:e.wireTap});return gd(e,r,t,r.remoteCaps?.includes(`reliable`)??!1,r.remoteCaps?.includes(`reliable-streamkey`)??!1)}function gd(e,t,n,r,i){return{sendActionData:a=>{let{action:o,runningAction:s,timeout:c}=a,l=o.type===G.request&&o.schema?.reliabilityTier!=null&&o.schema.reliabilityTier!==Ol.none;if(!t.isOpen()){o.type===G.request&&!l&&s._abort(e.makeDisconnectError(o.id));return}if(o.type===G.request&&!l){n.add(s);let e=setTimeout(()=>{s._abort(uu.fromId(lu.timeout,{timeout:c}))},c);s.addUpdateListeners([t=>{t.type===yl.finished&&(clearTimeout(e),n.delete(s))}])}let u=a;a.reliability!=null&&(e.formatMessage==null?tl(o.domain,o.id):r===!1?(rl(o.domain,o.id),u={...a,reliability:void 0}):a.reliability.streamKey!=null&&i===!1&&al(o.domain,o.id)),t.send(e.formatMessage?.outgoing(u)??JSON.stringify(u.action.toJsonObject()))},sendControlData:e=>{t.isOpen()&&t.send(Zc(e))},updateRunConfig:e.updateRunConfig,addOnDisconnectListener:e=>t.addOnDisconnectListener(e),disconnect:()=>t.close(),sendReturnData:(n,r)=>{let i=r==null?void 0:e.formatMessage?.outgoing({action:n,...r});t.send(i??JSON.stringify(n.toJsonObject()))}}}function _d(e,t){let n=Qc(t);if(n!=null){e.resolvers.onControlMessage?.(n);return}let r=Lu(t,e.formatMessage);if(r!=null){let n=e.formatMessage?.incomingReliability?.(t);n==null?e.resolvers.onIncomingActionDataJson(r):e.resolvers.onIncomingActionDataJson(r,n)}}function vd(e,t){let n=e.makeDisconnectError(`—`);for(let e of[...t])e._abort(n)}function yd(e){return uu.fromId(lu.send_failed,{actionId:e,actionState:`request`,message:`link channel disconnected`})}var bd=class extends cd{resolvers;constructor(e,t){super({...e,type:br.duplex}),this.resolvers=t??fd(`link`)}_getCacheKey(e){return this.initialized.getCacheKey?.(e).join(`\0`)??``}_needsAsyncBringUp(){return!0}_awaitCarrierReady(e){return e.channel.ready}_finalizeReady(e){let t=e.secureChannel;return t!=null&&t.securityLevel!==ro.none?hd({...this._sessionContext(e),secure:t}):this._finalizeTransportMethods(e)}_sessionContext(e){return{channel:e.channel,resolvers:this.resolvers,formatMessage:e.formatMessage,updateRunConfig:e.updateRunConfig,makeDisconnectError:yd,heartbeat:e.heartbeat,wireTap:e.wireTap}}_finalizeTransportMethods(e){return md(this._sessionContext(e))}},Z=class e extends rd{options;type=br.duplex;constructor(e){super(),this.options=e}static create(t){return new e(t)}_createConnection(e){let t=this.options;return new bd({initialize:()=>({getCacheKey:t.getCacheKey,isAvailable:t.available,getTransport:e=>({status:xr.ready,readyData:{channel:t.openChannel(e),formatMessage:t.createFormatMessage?.()??t.formatMessage,updateRunConfig:t.updateRunConfig,secureChannel:t.security,heartbeat:t.heartbeat?.(),wireTap:t.wireTap}})})},e.resolvers)}getRouteInfo(e){return this.options.getRouteInfo==null?{carrierLabel:this.options.label??`link`,summary:this.options.label??`link`}:this.options.getRouteInfo(e)}};function xd(e){let{carrier:t,channel:n,available:r,label:i}=e,a=i??t.carrierLabel,o=t.getCacheKey,s=t.getRouteInfo,c;if(e.secure){let t=e.link??(e.storage==null?void 0:new Ua({storageAdapter:e.storage}));if(t==null)throw Error("transport: a secure transport requires `link` or `storage` for the crypto identity.");c={securityLevel:e.securityLevel??ro.authenticated,link:t,localCoordinate:(e.identity??e.runtime.coordinate).toJsonObject(),expectedPeer:e.expectedPeer?.toJsonObject(),dictionaryVersion:n.dictionaryVersion,channelTags:n.tags,mux:e.mux}}return Bu(t)?ud.create({openCarrier:e=>t.open(zu(e)),getCacheKey:o==null?void 0:e=>o(zu(e)),available:r??t.available,getRouteInfo:s==null?void 0:e=>s(zu(e)),label:a,security:c,mux:e.mux,exchangeOnlyConnection:e.exchangeOnlyConnection,wireTap:e.wireTap}):Z.create({openChannel:e=>t.open(zu(e)),createFormatMessage:n.createCodec,getCacheKey:o==null?void 0:e=>o(zu(e)),available:r??t.available,getRouteInfo:s==null?void 0:e=>s(zu(e)),label:a,security:c,heartbeat:e.heartbeat,wireTap:e.wireTap})}function Sd(e){return e.map(e=>e.domain).join(`+`)}function Cd(e){let{intToRoute:t}=Gu(e),n=t.map(e=>`${e.domain}:${e.id}`).join(`,`),r=2166136261;for(let e=0;e<n.length;e++)r^=n.charCodeAt(e),r=Math.imul(r,16777619);return`auto:${(r>>>0).toString(16).padStart(8,`0`)}`}function wd(e={}){let t=e.toAcceptor??[],n=e.toConnector??[],r=[...t,...n],i=e.tag??Sd(r);return{toAcceptorDomains:t,toConnectorDomains:n,dictionaryVersion:e.dictionaryVersion??Cd(r),createCodec:td(r,e.sessionOptions),tag:i,tags:[i]}}var Td=new WeakMap;function Ed(e,t,n){let r=Td.get(e);r??(r=new Map,Td.set(e,r));let i=r.get(t.stringId)??new Set;if(r.set(t.stringId,i),i.has(n.stringId)){console.warn(`connectChannel: this runtime already has a connection to [${t.stringId}] dialling as [${n.stringId}]. The peer binds each connection by that identity, so it cannot tell the two apart: every reply and push for both goes back over whichever connected first, and the other link's traffic hangs until it times out. Give each connection its own \`connectionId\` (e.g. \`connectChannel(runtime, jobsChannel, { connectionId: "jobs", … })\`) — or, if they carry the same routes over one link, use \`connectChannels\`.`);return}i.add(n.stringId)}function Dd(e,t,n){if(n.carriers==null==(n.transports==null))throw q.fromId(K.conflicting_connect_options,{detail:"connectChannel requires exactly one of `carriers` or deprecated `transports`"});let r=n.carriers?.map(e=>({carrier:e,secure:e.secure,securityLevel:e.securityLevel,available:e.available,label:e.label}))??n.transports,i=n.securityLevel??ro.authenticated,a=r.some(e=>e.secure??!0),o=n.connectionId==null?void 0:e.coordinate.withConnectionId(n.connectionId);r.some(e=>!Bu(e.carrier))&&Ed(e,n.peer,o??e.coordinate);let{mux:s,link:c,resolveHeartbeat:l,wireTap:u}=Ac({callerName:`connectChannel`,peer:n.peer,identity:o??e.coordinate,mux:n.wireMux,protocols:n.protocols,anySecure:a,storage:n.storage,link:n.link,ephemeralIdentity:n.ephemeralIdentity,reconnect:n.reconnect,heartbeat:n.heartbeat,keepLinkAlive:n.keepLinkAlive,linkKeepalive:n.linkKeepalive,wireTap:n.wireTap}),d=r.every(e=>Bu(e.carrier)),f=r.map(r=>xd({carrier:r.carrier,channel:t,runtime:e,identity:o,expectedPeer:n.peer,secure:r.secure??!0,link:c,securityLevel:r.securityLevel??i,available:r.available,label:r.label,mux:s,exchangeOnlyConnection:d,heartbeat:l,wireTap:u})),p=n.onPush==null?[]:t.toConnectorDomains.map(e=>e.wrapAsPartialLocalHandler(n.onPush)),m=r.filter(e=>!Bu(e.carrier)).map(e=>e.secure??!0?e.securityLevel??i:ro.none),h=m.length===0?ro.none:m.reduce((e,t)=>yo(t,e)?e:t),g=e.connectTo(n.peer,{transports:f,domains:[...t.toAcceptorDomains],localHandlers:p,defaultTimeout:n.defaultTimeout,reliableActionTimeout:n.reliableActionTimeout,wireMux:s,securityLevel:h,reconnect:n.reconnect??n.keepLinkAlive,connectionIdentity:o});return n.onReliableEvent!=null&&g.addReliableEventListener(n.onReliableEvent),n.onLinkEvent!=null&&g.addLinkEventListener(n.onLinkEvent),g}ro.none,ro.authenticated,ro.encrypted,uu.createChildDomain({domain:`err_nice_transport_ws`,schema:{ws_disconnected:k({message:()=>`WebSocket transport disconnected.`}),ws_create_failed:k({message:({originalError:e})=>`Failed to create WebSocket transport.${e?` Original error: ${e.message}`:``}`}),ws_error:k({message:({originalError:e})=>`WebSocket transport error.${e?` Original error: ${e.message}`:``}`})}});function Od(e,t={}){if(t.getCacheKey!=null&&t.getTransportCacheKey!=null)throw q.fromId(K.conflicting_connect_options,{detail:"wsCarrier: pass only `getCacheKey`; `getTransportCacheKey` is deprecated"});let n=t.getCacheKey??t.getTransportCacheKey,r=t.getRouteInfo;return{...Ar(typeof e==`string`?e:t=>e(t.dialContext),{secure:t.secure,getCacheKey:n==null?void 0:e=>n(e.dialContext),getRouteInfo:r==null?void 0:e=>r(e.dialContext),createWebSocket:t.createWebSocket}),available:t.available,label:t.label}}var{getOwnPropertyNames:kd,getOwnPropertySymbols:Ad}=Object,{hasOwnProperty:jd}=Object.prototype;function Md(e,t){return function(n,r,i){return e(n,r,i)&&t(n,r,i)}}function Nd(e){return function(t,n,r){if(!t||!n||typeof t!=`object`||typeof n!=`object`)return e(t,n,r);let{cache:i}=r,a=i.get(t),o=i.get(n);if(a&&o)return a===n&&o===t;i.set(t,n),i.set(n,t);let s=e(t,n,r);return i.delete(t),i.delete(n),s}}function Pd(e){return kd(e).concat(Ad(e))}var Fd=Object.hasOwn||((e,t)=>jd.call(e,t)),Id=`__v`,Ld=`__o`,Rd=`_owner`,{getOwnPropertyDescriptor:zd,keys:Bd}=Object,Vd=Object.is||function(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t};function Hd(e,t){return e===t}function Ud(e,t){return e.byteLength===t.byteLength&&ef(new Uint8Array(e),new Uint8Array(t))}function Wd(e,t,n){let r=e.length;if(t.length!==r)return!1;for(;r-->0;)if(!n.equals(e[r],t[r],r,r,e,t,n))return!1;return!0}function Gd(e,t){return e.byteLength===t.byteLength&&ef(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function Kd(e,t){return Vd(e.getTime(),t.getTime())}function qd(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function Jd(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.entries(),o,s,c=0;for(;(o=a.next())&&!o.done;){let r=t.entries(),a=!1,l=0;for(;(s=r.next())&&!s.done;){if(i[l]){l++;continue}let r=o.value,u=s.value;if(n.equals(r[0],u[0],c,l,e,t,n)&&n.equals(r[1],u[1],r[0],u[0],e,t,n)){a=i[l]=!0;break}l++}if(!a)return!1;c++}return!0}function Yd(e,t,n){let r=Bd(e),i=r.length;if(Bd(t).length!==i)return!1;for(;i-->0;)if(!nf(e,t,n,r[i]))return!1;return!0}function Xd(e,t,n){let r=Pd(e),i=r.length;if(Pd(t).length!==i)return!1;let a,o,s;for(;i-->0;)if(a=r[i],!nf(e,t,n,a)||(o=zd(e,a),s=zd(t,a),(o||s)&&(!o||!s||o.configurable!==s.configurable||o.enumerable!==s.enumerable||o.writable!==s.writable)))return!1;return!0}function Zd(e,t){return Vd(e.valueOf(),t.valueOf())}function Qd(e,t){return e.source===t.source&&e.flags===t.flags}function $d(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.values(),o,s;for(;(o=a.next())&&!o.done;){let r=t.values(),a=!1,c=0;for(;(s=r.next())&&!s.done;){if(!i[c]&&n.equals(o.value,s.value,o.value,s.value,e,t,n)){a=i[c]=!0;break}c++}if(!a)return!1}return!0}function ef(e,t){let n=e.byteLength;if(t.byteLength!==n||e.byteOffset!==t.byteOffset)return!1;for(;n-->0;)if(e[n]!==t[n])return!1;return!0}function tf(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function nf(e,t,n,r){return(r===Rd||r===Ld||r===Id)&&(e.$$typeof||t.$$typeof)?!0:Fd(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}var rf=Object.prototype.toString;function af(e){let t=lf(e),{areArraysEqual:n,areDatesEqual:r,areFunctionsEqual:i,areMapsEqual:a,areNumbersEqual:o,areObjectsEqual:s,areRegExpsEqual:c,areSetsEqual:l,getUnsupportedCustomComparator:u}=e;return function(e,d,f){if(e===d)return!0;if(e==null||d==null)return!1;let p=typeof e;if(p!==typeof d)return!1;if(p!==`object`)return p===`number`||p===`bigint`?o(e,d,f):p===`function`?i(e,d,f):!1;let m=e.constructor;if(m!==d.constructor)return!1;if(m===Object)return s(e,d,f);if(m===Array)return n(e,d,f);if(m===Date)return r(e,d,f);if(m===RegExp)return c(e,d,f);if(m===Map)return a(e,d,f);if(m===Set)return l(e,d,f);if(m===Promise)return!1;if(Array.isArray(e))return n(e,d,f);let h=rf.call(e),g=t[h];if(g)return g(e,d,f);let _=u&&u(e,d,f,h);return _?_(e,d,f):!1}}function of({circular:e,createCustomConfig:t,strict:n}){let r={areArrayBuffersEqual:Ud,areArraysEqual:n?Xd:Wd,areDataViewsEqual:Gd,areDatesEqual:Kd,areErrorsEqual:qd,areFunctionsEqual:Hd,areMapsEqual:n?Md(Jd,Xd):Jd,areNumbersEqual:Vd,areObjectsEqual:n?Xd:Yd,arePrimitiveWrappersEqual:Zd,areRegExpsEqual:Qd,areSetsEqual:n?Md($d,Xd):$d,areTypedArraysEqual:n?Md(ef,Xd):ef,areUrlsEqual:tf,getUnsupportedCustomComparator:void 0};if(t&&(r=Object.assign({},r,t(r))),e){let e=Nd(r.areArraysEqual),t=Nd(r.areMapsEqual),n=Nd(r.areObjectsEqual),i=Nd(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:e,areMapsEqual:t,areObjectsEqual:n,areSetsEqual:i})}return r}function sf(e){return function(t,n,r,i,a,o,s){return e(t,n,s)}}function cf({circular:e,comparator:t,createState:n,equals:r,strict:i}){if(n)return function(a,o){let{cache:s=e?new WeakMap:void 0,meta:c}=n();return t(a,o,{cache:s,equals:r,meta:c,strict:i})};if(e)return function(e,n){return t(e,n,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};let a={cache:void 0,equals:r,meta:void 0,strict:i};return function(e,n){return t(e,n,a)}}function lf({areArrayBuffersEqual:e,areArraysEqual:t,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:a,areMapsEqual:o,areNumbersEqual:s,areObjectsEqual:c,arePrimitiveWrappersEqual:l,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:p}){return{"[object Arguments]":c,"[object Array]":t,"[object ArrayBuffer]":e,"[object AsyncGeneratorFunction]":a,"[object BigInt]":s,"[object BigInt64Array]":f,"[object BigUint64Array]":f,"[object Boolean]":l,"[object DataView]":n,"[object Date]":r,"[object Error]":i,"[object Float16Array]":f,"[object Float32Array]":f,"[object Float64Array]":f,"[object Function]":a,"[object GeneratorFunction]":a,"[object Int8Array]":f,"[object Int16Array]":f,"[object Int32Array]":f,"[object Map]":o,"[object Number]":l,"[object Object]":(e,t,n)=>typeof e.then!=`function`&&typeof t.then!=`function`&&c(e,t,n),"[object RegExp]":u,"[object Set]":d,"[object String]":l,"[object URL]":p,"[object Uint8Array]":f,"[object Uint8ClampedArray]":f,"[object Uint16Array]":f,"[object Uint32Array]":f}}var uf=df();df({strict:!0}),df({circular:!0}),df({circular:!0,strict:!0}),df({createInternalComparator:()=>Vd}),df({strict:!0,createInternalComparator:()=>Vd}),df({circular:!0,createInternalComparator:()=>Vd}),df({circular:!0,createInternalComparator:()=>Vd,strict:!0});function df(e={}){let{circular:t=!1,createInternalComparator:n,createState:r,strict:i=!1}=e,a=af(of(e));return cf({circular:t,comparator:a,createState:r,equals:n?n(a):sf(a),strict:i})}var ff=Symbol.for(`immer-nothing`),pf=Symbol.for(`immer-draftable`),mf=Symbol.for(`immer-state`);function hf(e,...t){throw Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var gf=Object,_f=gf.getPrototypeOf,vf=`constructor`,yf=`prototype`,bf=`configurable`,xf=`enumerable`,Sf=`writable`,Cf=`value`,wf=e=>!!e&&!!e[mf];function Tf(e){return e?Of(e)||Ff(e)||!!e[pf]||!!e[vf]?.[pf]||If(e)||Lf(e):!1}var Ef=gf[yf][vf].toString(),Df=new WeakMap;function Of(e){if(!e||!Rf(e))return!1;let t=_f(e);if(t===null||t===gf[yf])return!0;let n=gf.hasOwnProperty.call(t,vf)&&t[vf];if(n===Object)return!0;if(!zf(n))return!1;let r=Df.get(n);return r===void 0&&(r=Function.toString.call(n),Df.set(n,r)),r===Ef}function kf(e,t,n=!0){Af(e)===0?(n?Reflect.ownKeys(e):gf.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function Af(e){let t=e[mf];return t?t.type_:Ff(e)?1:If(e)?2:Lf(e)?3:0}var jf=(e,t,n=Af(e))=>n===2?e.has(t):gf[yf].hasOwnProperty.call(e,t),Mf=(e,t,n=Af(e))=>n===2?e.get(t):e[t],Nf=(e,t,n,r=Af(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function Pf(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t}var Ff=Array.isArray,If=e=>e instanceof Map,Lf=e=>e instanceof Set,Rf=e=>typeof e==`object`,zf=e=>typeof e==`function`,Bf=e=>typeof e==`boolean`;function Vf(e){let t=+e;return Number.isInteger(t)&&String(t)===e}var Hf=e=>Rf(e)?e?.[mf]:null,Uf=e=>e.copy_||e.base_,Wf=e=>e.modified_?e.copy_:e.base_;function Gf(e,t){if(If(e))return new Map(e);if(Lf(e))return new Set(e);if(Ff(e))return Array[yf].slice.call(e);let n=Of(e);if(t===!0||t===`class_only`&&!n){let t=gf.getOwnPropertyDescriptors(e);delete t[mf];let n=Reflect.ownKeys(t);for(let r=0;r<n.length;r++){let i=n[r],a=t[i];a[Sf]===!1&&(a[Sf]=!0,a[bf]=!0),(a.get||a.set)&&(t[i]={[bf]:!0,[Sf]:!0,[xf]:a[xf],[Cf]:e[i]})}return gf.create(_f(e),t)}else{let t=_f(e);if(t!==null&&n)return{...e};let r=gf.create(t);return gf.assign(r,e)}}function Kf(e,t=!1){return Yf(e)||wf(e)||!Tf(e)?e:(Af(e)>1&&gf.defineProperties(e,{set:Jf,add:Jf,clear:Jf,delete:Jf}),gf.freeze(e),t&&kf(e,(e,t)=>{Kf(t,!0)},!1),e)}function qf(){hf(2)}var Jf={[Cf]:qf};function Yf(e){return e===null||!Rf(e)?!0:gf.isFrozen(e)}var Xf=`MapSet`,Zf=`Patches`,Qf=`ArrayMethods`,$f={};function ep(e){let t=$f[e];return t||hf(0,e),t}var tp=e=>!!$f[e];function np(e,t){$f[e]||($f[e]=t)}var rp,ip=()=>rp,ap=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:tp(Xf)?ep(Xf):void 0,arrayMethodsPlugin_:tp(Qf)?ep(Qf):void 0});function op(e,t){t&&(e.patchPlugin_=ep(Zf),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function sp(e){cp(e),e.drafts_.forEach(up),e.drafts_=null}function cp(e){e===rp&&(rp=e.parent_)}var lp=e=>rp=ap(rp,e);function up(e){let t=e[mf];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function dp(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];if(e!==void 0&&e!==n){n[mf].modified_&&(sp(t),hf(4)),Tf(e)&&(e=fp(t,e));let{patchPlugin_:r}=t;r&&r.generateReplacementPatches_(n[mf].base_,e,t)}else e=fp(t,n);return pp(t,e,!0),sp(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e===ff?void 0:e}function fp(e,t){if(Yf(t))return t;let n=t[mf];if(!n)return xp(t,e.handledSet_,e);if(!hp(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){let{callbacks_:t}=n;if(t)for(;t.length>0;)t.pop()(e);yp(n,e)}return n.copy_}function pp(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Kf(t,n)}function mp(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var hp=(e,t)=>e.scope_===t,gp=[];function _p(e,t,n,r){let i=Uf(e),a=e.type_;if(r!==void 0&&Mf(i,r,a)===t){Nf(i,r,n,a);return}if(!e.draftLocations_){let t=e.draftLocations_=new Map;kf(i,(e,n)=>{if(wf(n)){let r=t.get(n)||[];r.push(e),t.set(n,r)}})}let o=e.draftLocations_.get(t)??gp;for(let e of o)Nf(i,e,n,a)}function vp(e,t,n){e.callbacks_.push(function(r){let i=t;if(!i||!hp(i,r))return;r.mapSetPlugin_?.fixSetContents(i);let a=Wf(i);_p(e,i.draft_??i,a,n),yp(i,r)})}function yp(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){let{patchPlugin_:n}=t;if(n){let r=n.getPath(e);r&&n.generatePatches_(e,r,t)}mp(e)}}function bp(e,t,n){let{scope_:r}=e;if(wf(n)){let i=n[mf];hp(i,r)&&i.callbacks_.push(function(){kp(e),_p(e,n,Wf(i),t)})}else Tf(n)&&e.callbacks_.push(function(){let i=Uf(e);e.type_===3?i.has(n)&&xp(n,r.handledSet_,r):Mf(i,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&xp(Mf(e.copy_,t,e.type_),r.handledSet_,r)})}function xp(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||wf(e)||t.has(e)||!Tf(e)||Yf(e)?e:(t.add(e),kf(e,(r,i)=>{if(wf(i)){let t=i[mf];hp(t,n)&&(Nf(e,r,Wf(t),e.type_),mp(t))}else Tf(i)&&xp(i,t,n)}),e)}function Sp(e,t){let n=Ff(e),r={type_:+!!n,scope_:t?t.scope_:ip(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0},i=r,a=Cp;n&&(i=[r],a=wp);let{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var Cp={get(e,t){if(t===mf)return e;if(t===`constructor`||t===`__proto__`){let n=Uf(e)[t];return new Proxy(n||{},{get:(e,t)=>t===`__proto__`||t===`prototype`?Object.freeze(Object.create(null)):Reflect.get(e,t),set:()=>!0,apply:(e,t,n)=>Reflect.apply(e,t,n)})}let n=e.scope_.arrayMethodsPlugin_,r=e.type_===1&&typeof t==`string`;if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);let i=Uf(e);if(!jf(i,t,e.type_))return Ep(e,i,t);let a=i[t];if(e.finalized_||!Tf(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&Vf(t))return a;if(a===Tp(e.base_,t)){kp(e);let n=e.type_===1?+t:t,r=jp(e.scope_,a,e,n);return e.copy_[n]=r}return a},has(e,t){return t===`constructor`||t===`__proto__`||t===`prototype`?!1:t in Uf(e)},ownKeys(e){return Reflect.ownKeys(Uf(e))},set(e,t,n){if(t===`constructor`||t===`__proto__`||t===`prototype`)return!0;let r=Dp(Uf(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){let r=Tp(Uf(e),t),i=r?.[mf];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(Pf(n,r)&&(n!==void 0||jf(e.base_,t,e.type_)))return!0;kp(e),Op(e)}return e.copy_[t]===n&&(n!==void 0||jf(e.copy_,t,e.type_))||Number.isNaN(n)&&Number.isNaN(e.copy_[t])?!0:(e.copy_[t]=n,e.assigned_.set(t,!0),bp(e,t,n),!0)},deleteProperty(e,t){return kp(e),Tp(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),Op(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=Uf(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[Sf]:!0,[bf]:e.type_!==1||t!==`length`,[xf]:r[xf],[Cf]:n[t]}},defineProperty(){hf(11)},getPrototypeOf(e){return _f(e.base_)},setPrototypeOf(){hf(12)}},wp={};for(let e in Cp){let t=Cp[e];wp[e]=function(){let e=arguments;return e[0]=e[0][0],t.apply(this,e)}}wp.deleteProperty=function(e,t){return wp.set.call(this,e,t,void 0)},wp.set=function(e,t,n){return Cp.set.call(this,e[0],t,n,e[0])};function Tp(e,t){let n=e[mf];return(n?Uf(n):e)[t]}function Ep(e,t,n){let r=Dp(t,n);return r?Cf in r?r[Cf]:r.get?.call(e.draft_):void 0}function Dp(e,t){if(!(t in e))return;let n=_f(e);for(;n;){let e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=_f(n)}}function Op(e){e.modified_||(e.modified_=!0,e.parent_&&Op(e.parent_))}function kp(e){e.copy_||=(e.assigned_=new Map,Gf(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Ap=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,t,n)=>{if(zf(e)&&!zf(t)){let n=t;t=e;let r=this;return function(e=n,...i){return r.produce(e,e=>t.call(this,e,...i))}}zf(t)||hf(6),n!==void 0&&!zf(n)&&hf(7);let r;if(Tf(e)){let i=lp(this),a=jp(i,e,void 0),o=!0;try{r=t(a),o=!1}finally{o?sp(i):cp(i)}return op(i,n),dp(r,i)}else if(!e||!Rf(e)){if(r=t(e),r===void 0&&(r=e),r===ff&&(r=void 0),this.autoFreeze_&&Kf(r,!0),n){let t=[],i=[];ep(Zf).generateReplacementPatches_(e,r,{patches_:t,inversePatches_:i}),n(t,i)}return r}else hf(1,e)},this.produceWithPatches=(e,t)=>{if(zf(e))return(t,...n)=>this.produceWithPatches(t,t=>e(t,...n));let n,r;return[this.produce(e,t,(e,t)=>{n=e,r=t}),n,r]},Bf(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Bf(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Bf(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Tf(e)||hf(8),wf(e)&&(e=Mp(e));let t=lp(this),n=jp(t,e,void 0);return n[mf].isManual_=!0,cp(t),n}finishDraft(e,t){let n=e&&e[mf];(!n||!n.isManual_)&&hf(9);let{scope_:r}=n;return op(r,t),dp(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){let r=t[n];if(r.path.length===0&&r.op===`replace`){e=r.value;break}}n>-1&&(t=t.slice(n+1));let r=ep(Zf).applyPatches_;return wf(e)?r(e,t):this.produce(e,e=>r(e,t))}};function jp(e,t,n,r){let[i,a]=If(t)?ep(Xf).proxyMap_(t,n):Lf(t)?ep(Xf).proxySet_(t,n):Sp(t,n);return(n?.scope_??ip()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?vp(n,a,r):a.callbacks_.push(function(e){e.mapSetPlugin_?.fixSetContents(a);let{patchPlugin_:t}=e;a.modified_&&t&&t.generatePatches_(a,[],e)}),i}function Mp(e){return wf(e)||hf(10,e),Np(e)}function Np(e){if(!Tf(e)||Yf(e))return e;let t=e[mf],n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Gf(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Gf(e,!0);return kf(n,(e,t)=>{Nf(n,e,Np(t))},r),t&&(t.finalized_=!1),n}function Pp(){function e(n,r=[]){if(n.key_!==void 0){let e=n.parent_.copy_??n.parent_.base_,t=Hf(Mf(e,n.key_)),i=Mf(e,n.key_);if(i===void 0||i!==n.draft_&&i!==n.base_&&i!==n.copy_||t!=null&&t.base_!==n.base_)return null;let a=n.parent_.type_===3,o;if(a){let e=n.parent_;o=Array.from(e.drafts_.keys()).indexOf(n.key_)}else o=n.key_;if(!(a&&e.size>o||jf(e,o)))return null;r.push(o)}if(n.parent_)return e(n.parent_,r);r.reverse();try{t(n.copy_,r)}catch{return null}return r}function t(e,t){let n=e;for(let e=0;e<t.length-1;e++){let r=t[e];if(n=Mf(n,r),!Rf(n)||n===null)throw Error(`Cannot resolve path at '${t.join(`/`)}'`)}return n}let n=`replace`,r=`remove`;function i(e,t,n){if(e.scope_.processedForPatches_.has(e))return;e.scope_.processedForPatches_.add(e);let{patches_:r,inversePatches_:i}=n;switch(e.type_){case 0:case 2:return o(e,t,r,i);case 1:return a(e,t,r,i);case 3:return s(e,t,r,i)}}function a(e,t,i,a){let{base_:o,assigned_:s}=e,c=e.copy_;c.length<o.length&&([o,c]=[c,o],[i,a]=[a,i]);let l=e.allIndicesReassigned_===!0;for(let e=0;e<o.length;e++){let r=c[e],u=o[e];if((l||s?.get(e.toString()))&&r!==u){let o=r?.[mf];if(o&&o.modified_)continue;let s=t.concat([e]);i.push({op:n,path:s,value:d(r)}),a.push({op:n,path:s,value:d(u)})}}for(let e=o.length;e<c.length;e++){let n=t.concat([e]);i.push({op:`add`,path:n,value:d(c[e])})}for(let e=c.length-1;o.length<=e;--e){let n=t.concat([e]);a.push({op:r,path:n})}}function o(e,t,i,a){let{base_:o,copy_:s,type_:c}=e;kf(e.assigned_,(e,l)=>{let u=Mf(o,e,c),f=Mf(s,e,c),p=l?jf(o,e)?n:`add`:r;if(u===f&&p===n)return;let m=t.concat(e);i.push(p===r?{op:p,path:m}:{op:p,path:m,value:d(f)}),a.push(p===`add`?{op:r,path:m}:p===r?{op:`add`,path:m,value:d(u)}:{op:n,path:m,value:d(u)})})}function s(e,t,n,i){let{base_:a,copy_:o}=e,s=0;a.forEach(e=>{if(!o.has(e)){let a=t.concat([s]);n.push({op:r,path:a,value:e}),i.unshift({op:`add`,path:a,value:e})}s++}),s=0,o.forEach(e=>{if(!a.has(e)){let a=t.concat([s]);n.push({op:`add`,path:a,value:e}),i.unshift({op:r,path:a,value:e})}s++})}function c(e,t,r){let{patches_:i,inversePatches_:a}=r;i.push({op:n,path:[],value:t===ff?void 0:t}),a.push({op:n,path:[],value:e})}function l(e,t){return t.forEach(t=>{let{path:i,op:a}=t,o=e;for(let e=0;e<i.length-1;e++){let t=Af(o),n=i[e];typeof n!=`string`&&typeof n!=`number`&&(n=``+n),(t===0||t===1)&&(n===`__proto__`||n===vf)&&hf(19),zf(o)&&n===yf&&hf(19),o=Mf(o,n),Rf(o)||hf(18,i.join(`/`))}let s=Af(o),c=u(t.value),l=i[i.length-1];switch(a){case n:switch(s){case 2:return o.set(l,c);case 3:hf(16);default:return o[l]=c}case`add`:switch(s){case 1:return l===`-`?o.push(c):o.splice(l,0,c);case 2:return o.set(l,c);case 3:return o.add(c);default:return o[l]=c}case r:switch(s){case 1:return o.splice(l,1);case 2:return o.delete(l);case 3:return o.delete(t.value);default:return delete o[l]}default:hf(17,a)}}),e}function u(e){if(!Tf(e))return e;if(Ff(e))return e.map(u);if(If(e))return new Map(Array.from(e.entries()).map(([e,t])=>[e,u(t)]));if(Lf(e))return new Set(Array.from(e).map(u));let t=Object.create(_f(e));for(let n in e)t[n]=u(e[n]);return jf(e,pf)&&(t[pf]=e[pf]),t}function d(e){return wf(e)?u(e):e}np(Zf,{applyPatches_:l,generatePatches_:i,generateReplacementPatches_:c,getPath:e})}var Fp=new Ap,Ip=Fp.produce,Lp=Fp.produceWithPatches.bind(Fp),Rp=Fp.applyPatches.bind(Fp);Pp();function zp(e,t,n){let r=t(e.state);return()=>{let i=e.state,a=t(i);if(a===r)return;if(uf(a,r)){r=a;return}let o=r;r=a,n(a,i,o)}}function Bp(e,t){return n=>{let r=e(n.state);return(i=!1)=>{let a=n.state,o=e(a);if(!i){if(o===r)return;if(uf(o,r)){r=o;return}}let s=r;if(r=o,n._hasPatchListeners()){let[e,r,i]=Lp(a,e=>{t(o,e,a,s)});n._updateStateWithoutReaction(e),r.length>0&&n._emitPatches(r,i)}else{let e=Ip(a,e=>{t(o,e,a,s)});n._updateStateWithoutReaction(e)}}}}var Vp=class{currentState;createInitialState;ssr=!1;listeners=new Set;reactionCreators=[];reactions=[];clientSubscriptions=[];_patchListeners=[];constructor(e){e instanceof Function?(this.createInitialState=e,this.currentState=e()):(this.createInitialState=()=>e,this.currentState=e)}get state(){return Object.freeze(this.currentState)}_setInternalOptions({ssr:e,reactionCreators:t=[]}){this.ssr=e,this.reactionCreators=t,this.reactions=t.map(e=>e(this))}_getReactionCreators(){return this.reactionCreators}_instantiateReactions(){this.reactions=this.reactionCreators.map(e=>e(this))}_getInitialState(){return this.createInitialState()}_hasPatchListeners(){return this._patchListeners.length>0}_emitPatches(e,t){for(let n of this._patchListeners)n(e,t)}_updateStateWithoutReaction(e){this.currentState=e}_updateState(e){this.currentState=e;for(let e of this.reactions)e();if(!this.ssr){for(let e of this.clientSubscriptions)e();for(let e of this.listeners)e()}}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}watch(e,t){if(this.ssr)return()=>{console.warn(`@nice-code/state: Subscriptions made on the server side are not registered, so this unsubscribe call does nothing.`)};let n=zp(this,e,t);return this.clientSubscriptions.push(n),()=>{this.clientSubscriptions=this.clientSubscriptions.filter(e=>e!==n)}}createReaction(e,t,{runNow:n=!1,runNowWithSideEffects:r=!1}={}){let i=Bp(e,t);this.reactionCreators.push(i);let a=i(this);return this.reactions.push(a),(n||r)&&(a(!0),r&&!this.ssr&&this._updateState(this.currentState)),()=>{this.reactions=this.reactions.filter(e=>e!==a),this.reactionCreators=this.reactionCreators.filter(e=>e!==i)}}listenToPatches(e){return this._patchListeners.push(e),()=>{this._patchListeners=this._patchListeners.filter(t=>t!==e)}}update(e,t){Kp(this,e,t)}replace(e){e!==this.currentState&&(this._hasPatchListeners()&&this._emitPatches([{op:`replace`,path:[],value:e}],[{op:`replace`,path:[],value:this.currentState}]),this._updateState(e))}replaceFromCurrent(e){this.replace(e(this.currentState))}applyPatches(e){Hp(this,e)}};function Hp(e,t){let n=e.state,r=Rp(n,t);r!==n&&e._updateState(r)}function Up(e,t,n){if(!n&&!t&&typeof e==`object`&&e)throw Error(`@nice-code/state: an update function returned a value without modifying its draft. Update functions are mutate-only — a returned state is ignored (unlike immer's produce). To reset or swap the state wholesale, use store.replace(next); to change part of it, mutate the draft.`)}function Wp(e,t){if(typeof t==`function`){let n,r=!1,[i,a,o]=Lp(e,i=>{n=t(i,e),r=n===i});return Up(n,i!==e,r),[i,a,o]}let n=e,r=[],i=[];for(let e of t){let t,a=!1,[o,s,c]=Lp(n,r=>{t=e(r,n),a=t===r});Up(t,o!==n,a),n=o,r.push(...s),i.push(...c)}return[n,r,i]}function Gp(e,t){if(typeof t==`function`){let n,r=!1,i=Ip(e,i=>{n=t(i,e),r=n===i});return Up(n,i!==e,r),i}return t.reduce((e,t)=>{let n,r=!1,i=Ip(e,i=>{n=t(i,e),r=n===i});return Up(n,i!==e,r),i},e)}function Kp(e,t,n){let r=e.state,i;if(e._hasPatchListeners()||n!=null){let[a,o,s]=Wp(r,t);o.length>0&&(n?.(o,s),e._emitPatches(o,s)),i=a}else i=Gp(r,t);i!==r&&e._updateState(i)}var qp=ue.createChildDomain({domain:`err_nice_realm`,schema:{schema_mismatch:k({message:({realmId:e,clientHash:t,serverHash:n})=>`Realm "${e}" schema mismatch — avatar ${t.slice(0,12)}… vs server ${n.slice(0,12)}…. The client and server were built from different realm definitions; refusing to attach (silent token skew would corrupt state).`,context:{required:!0}}),realm_unknown:k({message:({realmId:e})=>`This server hosts no realm with id "${e}".`,context:{required:!0}}),unauthorized_avatar_type:k({message:({avatarType:e,expected:t})=>`Client type "${e}" is not permitted here (expected: ${t.join(`, `)}).`,context:{required:!0}}),avatar_unresolved:k({message:({realmId:e})=>`This connection's identity could not be resolved to an avatar of realm "${e}" — the server's resolveAvatar returned undefined (or the attachment carries no coordinate).`,context:{required:!0}}),insufficient_security:k({message:({realmId:e,required:t,actual:n})=>`Realm "${e}" requires a "${t}" connection but this one negotiated "${n}". Connect with at least the required security level — the realm refuses to move avatar data below it.`,context:{required:!0}}),unauthorized_coordinate:k({message:({path:e})=>`This avatar's coordinates may not write "${e}".`,context:{required:!0}}),value_invalid:k({message:({path:e,expected:t})=>`The value written to "${e}" does not match the schema (expected ${t}).`,context:{required:!0}}),limits_exceeded:k({message:({limit:e})=>`Ingress limit exceeded: ${e}.`,context:{required:!0}}),intent_unknown:k({message:({intent:e})=>`Unknown intent "${e}".`,context:{required:!0}}),version_gap_unrecoverable:k({message:({lastKnownVersion:e,oldestReplayable:t})=>`Version ${e} is behind the replayable window (oldest ${t}) — full rehydration required.`,context:{required:!0}}),write_before_hydrate:k({message:({realmId:e})=>`A write on "${e}" was queued for the first hydrate, which never arrived (the realm detached, or the pending expiry passed first) — nothing was sent.`,context:{required:!0}}),frame_too_stale:k({message:({basisVersion:e})=>`The optimistic frame (basis ${e}) expired before it could be confirmed — outcome unknown (it may have committed; re-read state rather than re-issuing a non-idempotent intent).`,context:{required:!0}}),durable_backlog_overflow:k({message:({pendingFrames:e})=>`The durable-write backlog is full (${e} unconfirmed reassert frames) — this write was rejected. Re-sync from your source of truth after reconnecting.`,context:{required:!0}}),frame_invalid:k({message:({reason:e})=>`Malformed realm frame: ${e}.`,context:{required:!0}}),write_target_missing:k({message:({path:e})=>`The write to "${e}" could not be applied — its parent no longer exists (a pruned entry or a transient region reset since the write's basis). Re-read state instead of re-issuing.`,context:{required:!0}})}});function Jp(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&!(e instanceof Uint8Array)}function Yp(e,t){switch(e.kind){case`string`:return typeof t==`string`?e.maxLength!=null&&t.length>e.maxLength?{path:[],expected:`a string of at most ${e.maxLength} characters`}:void 0:{path:[],expected:`string`};case`number`:return typeof t==`number`?(e.min!=null||e.max!=null||e.integer===!0)&&!Number.isFinite(t)?{path:[],expected:`a finite number`}:e.integer===!0&&!Number.isInteger(t)?{path:[],expected:`an integer`}:e.min!=null&&t<e.min?{path:[],expected:`a number >= ${e.min}`}:e.max!=null&&t>e.max?{path:[],expected:`a number <= ${e.max}`}:void 0:{path:[],expected:`number`};case`boolean`:return typeof t==`boolean`?void 0:{path:[],expected:`boolean`};case`literal`:return t===e.value?void 0:{path:[],expected:`literal ${JSON.stringify(e.value)}`};case`optional`:return t===void 0?void 0:Yp(e.inner,t);case`union`:for(let n of e.options)if(Yp(n,t)==null)return;return{path:[],expected:`one of the union options`};case`object`:if(!Jp(t))return{path:[],expected:`object`};for(let n of Object.keys(t))if(e.entries[n]==null)return{path:[n],expected:`no such key in the schema`};for(let[n,r]of Object.entries(e.entries)){let e=t[n];if(e===void 0){if(r.kind!==`optional`)return{path:[n],expected:r.kind};continue}let i=Yp(r,e);if(i!=null)return{path:[n,...i.path],expected:i.expected}}return;case`record`:if(!Jp(t))return{path:[],expected:`record`};if(e.maxKeys!=null&&Object.keys(t).length>e.maxKeys)return{path:[],expected:`a record with at most ${e.maxKeys} entries`};for(let[n,r]of Object.entries(t)){let t=Yp(e.value,r);if(t!=null)return{path:[n,...t.path],expected:t.expected}}return;case`array`:if(!Array.isArray(t))return{path:[],expected:`array`};if(e.maxItems!=null&&t.length>e.maxItems)return{path:[],expected:`an array of at most ${e.maxItems} items`};for(let n=0;n<t.length;n++){let r=Yp(e.item,t[n]);if(r!=null)return{path:[n,...r.path],expected:r.expected}}return;case`standard`:{let n=e.schema[`~standard`].validate(t);return n instanceof Promise?{path:[],expected:`a synchronous standard-schema validator`}:n.issues==null?void 0:{path:[],expected:n.issues[0]?.message??`standard-schema pass`}}}}var Xp=class{_toId=new Map;_toKey=[];intern(e){let t=this._toId.get(e);return t??(t=this._toKey.length,this._toId.set(e,t),this._toKey.push(e)),t}idOf(e){return this._toId.get(e)}keyOf(e){return this._toKey[e]}load(e){for(let[t,n]of e)this._toId.set(t,n),this._toKey[n]=t}get size(){return this._toId.size}clear(){this._toId.clear(),this._toKey.length=0}},Zp={hello:0,hydrate:1,patches:2,write:3,intent:4,ack:5,reject:6,keyDict:7,detach:8,clientCaps:9,batch:10},Qp=Object.fromEntries(Object.entries(Zp).map(([e,t])=>[t,e])),$p={batch:`b1`},em={replace:0,add:1,remove:2};function Q(e){throw qp.fromId(`frame_invalid`,{reason:e})}function tm(e,t){return(typeof e!=`number`||!Number.isInteger(e))&&Q(`${t} must be an int`),e}function nm(e,t){return typeof e!=`string`&&Q(`${t} must be a string`),e}function rm(e){let t=tm(e,`slot`);return(t<0||t>255)&&Q(`slot ${t} out of range`),t}function im(e){(!Array.isArray(e)||e.length===0)&&Q(`op path must be a non-empty array`);for(let t of e)typeof t==`number`?(!Number.isInteger(t)||t<0)&&Q(`invalid path token ${t}`):typeof t!=`string`&&Q(`path segments must be ints or strings`);return e}function am(e){Array.isArray(e)||Q(`ops must be an array`);for(let t of e){(!Array.isArray(t)||t.length<2||t.length>3)&&Q(`malformed op`);let e=tm(t[0],`op kind`);e!==em.replace&&e!==em.add&&e!==em.remove&&Q(`unknown op kind ${e}`),im(t[1]),e===em.remove&&t.length!==2&&Q(`remove op carries no value`),e!==em.remove&&t.length!==3&&Q(`replace/add op requires a value`)}return e}function om(e){return(!Array.isArray(e)||e.length!==3)&&Q(`hydrate limits must be 3 ints`),tm(e[0],`limits.maxPatchesPerFrame`),tm(e[1],`limits.maxFrameBytes`),tm(e[2],`limits.writeRatePerSecond`),e}function sm(e){return(!Array.isArray(e)||e.length!==3)&&Q(`hydrate avatar must be 3 strings`),nm(e[0],`avatar.type`),nm(e[1],`avatar.persistentId`),nm(e[2],`avatar.instanceId`),e}var cm=16,lm=32;function um(e){Array.isArray(e)||Q(`clientCaps features must be an array`),e.length>cm&&Q(`clientCaps features list too long`);for(let t of e)nm(t,`clientCaps feature`).length>lm&&Q(`clientCaps feature too long`);return e}function dm(e){Array.isArray(e)||Q(`keyDict entries must be an array`);for(let t of e)(!Array.isArray(t)||t.length!==2)&&Q(`malformed keyDict entry`),nm(t[0],`keyDict key`),tm(t[1],`keyDict id`)<0&&Q(`keyDict id must be >= 0`);return e}function fm(e){return Vs([Zp.hello,e.slot,e.realmId,e.schemaHash,e.lastKnownVersion,e.epoch??null])}function pm(e){return Vs([Zp.write,e.slot,e.clientSeq,e.basisVersion,e.ops])}function mm(e){return Vs([Zp.intent,e.slot,e.clientSeq,e.intentToken,e.input])}function hm(e){return Vs([Zp.detach,e.slot,e.reason??null])}function gm(e){return Vs([Zp.clientCaps,e.slot,e.features])}function _m(e){let t;try{t=_s(e)}catch{Q(`not msgpack`)}(!Array.isArray(t)||t.length<2)&&Q(`frame must be a [kind, slot, …] array`);let n=tm(t[0],`kind`),r=rm(t[1]);switch(n){case Zp.hello:return t.length!==6&&Q(`hello must have 6 elements`),t[5]!=null&&typeof t[5]!=`string`&&Q(`hello epoch must be a string`),{kind:n,slot:r,realmId:nm(t[2],`realmId`),schemaHash:nm(t[3],`schemaHash`),lastKnownVersion:tm(t[4],`lastKnownVersion`),epoch:t[5]??void 0};case Zp.hydrate:return t.length!==9&&Q(`hydrate must have 9 elements`),t[3]instanceof Uint8Array||Q(`hydrate stateBlob must be bytes`),typeof t[5]!=`boolean`&&Q(`hydrate more must be a boolean`),{kind:n,slot:r,version:tm(t[2],`version`),stateBlob:t[3],keyDictSeed:dm(t[4]),more:t[5],epoch:nm(t[6],`hydrate epoch`),limits:om(t[7]),avatar:sm(t[8])};case Zp.patches:return t.length!==5&&Q(`patches must have 5 elements`),{kind:n,slot:r,fromVersion:tm(t[2],`fromVersion`),toVersion:tm(t[3],`toVersion`),ops:am(t[4])};case Zp.write:return t.length!==5&&Q(`write must have 5 elements`),{kind:n,slot:r,clientSeq:tm(t[2],`clientSeq`),basisVersion:tm(t[3],`basisVersion`),ops:am(t[4])};case Zp.intent:return t.length!==5&&Q(`intent must have 5 elements`),{kind:n,slot:r,clientSeq:tm(t[2],`clientSeq`),intentToken:tm(t[3],`intentToken`),input:t[4]};case Zp.ack:return t.length!==4&&Q(`ack must have 4 elements`),{kind:n,slot:r,clientSeq:tm(t[2],`clientSeq`),version:tm(t[3],`version`)};case Zp.reject:return t.length!==4&&Q(`reject must have 4 elements`),(typeof t[3]!=`object`||t[3]==null||Array.isArray(t[3]))&&Q(`reject error must be a map`),{kind:n,slot:r,clientSeq:tm(t[2],`clientSeq`),error:t[3]};case Zp.keyDict:return t.length!==3&&Q(`keyDict must have 3 elements`),{kind:n,slot:r,entries:dm(t[2])};case Zp.detach:return t.length!==3&&Q(`detach must have 3 elements`),t[2]!=null&&typeof t[2]!=`string`&&Q(`detach reason must be a string`),{kind:n,slot:r,reason:t[2]??void 0};case Zp.clientCaps:return t.length!==3&&Q(`clientCaps must have 3 elements`),{kind:n,slot:r,features:um(t[2])};case Zp.batch:{t.length!==3&&Q(`batch must have 3 elements`),Array.isArray(t[2])||Q(`batch payloads must be an array`);let e=[];for(let n of t[2]){n instanceof Uint8Array||Q(`batch payload must be bytes`);let t=_m(n);t.kind===Zp.batch&&Q(`batch may not nest`),e.push(t)}return{kind:n,slot:r,frames:e}}default:Q(`unknown frame kind ${n}`)}}var vm=new Set([`__proto__`,`constructor`,`prototype`]);function ym(e){return typeof e==`string`&&vm.has(e)}function bm(e){return e.some(ym)}var xm={replace:em.replace,add:em.add,remove:em.remove},Sm={[em.replace]:`replace`,[em.add]:`add`,[em.remove]:`remove`};function Cm(e){return e.kind===`optional`?Cm(e.inner):e}function wm(e,t){let n,r=e;for(let e of t){if(r!=null)n=typeof e==`string`?r[e]:void 0,r=void 0;else if(n!=null){let t=Cm(n);if(t.kind===`object`)n=t.entries[e];else if(t.kind===`record`)n=t.value;else return}if(n==null)return}return n}function Tm(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n)return;n=n[e]}return n}function Em(e,t){for(let n=1;n<t.length;n++){let r=wm(e,t.slice(0,n));if(r!=null&&Cm(r).kind===`array`)return n}}function Dm(e,t,n){let r=[],i=new Set;for(let a of e){let e=Em(n,a.path);if(e==null||e===a.path.length){r.push(a);continue}let o=a.path.slice(0,e),s=o.join(`\0`);i.has(s)||(i.add(s),r.push({op:`replace`,path:o,value:Tm(t,o)}))}return r}function Om(e,t,n){return e.map(e=>{let r=t.tokenizePath(e.path,n);return e.op===`remove`?[em.remove,r]:[xm[e.op],r,e.value]})}function km(e,t,n){return e.map(e=>{let r=t.detokenizePath(e[1],n);return e[0]===em.remove?{op:`remove`,path:r}:{op:Sm[e[0]],path:r,value:e[2]}})}function Am(e){return e===`encrypted`?ro.encrypted:ro.authenticated}function jm(e,t){return t==null?e:e===`encrypted`||t===`encrypted`?`encrypted`:`authenticated`}function Mm(e,t,n){let r=e.securityLevel;if(r==null)return;let i=Am(jm(t.security,n));if(!yo(r,i))return qp.fromId(`insufficient_security`,{realmId:t.id,required:i,actual:r})}function Nm(e,t,n=[]){if(e===t)return[];if(!Pm(e)||!Pm(t))return[{op:`replace`,path:[...n],value:t}];let r=[];for(let i of Object.keys(t))i in e?r.push(...Nm(e[i],t[i],[...n,i])):r.push({op:`add`,path:[...n,i],value:t[i]});for(let i of Object.keys(e))i in t||r.push({op:`remove`,path:[...n,i]});return r}function Pm(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Fm(e,t,n){if(typeof e==`function`)return e(t);switch(e.kind){case`serverOnly`:return`serverOnly`;case`serverChecked`:return n==null?!0:e.fn({...t,...n});case`all`:for(let r of e.conds){let e=Fm(r,t,n);if(e!==!0)return e}return!0}}function Im(e){return e.kind===`optional`?Im(e.inner):e}function Lm(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n)return;n=n[e]}return n}var Rm=class extends Error{constructor(e){super(`subtree write expands past the ${e}-leaf limit`)}};function zm(e){let t=wm(e.schemaRoot,e.path);if(t==null)throw Error(`expandWriteToLeaves: path leaves the schema (${e.path.join(`.`)})`);let n=[],r=t=>{if(n.length>=e.maxLeaves)throw new Rm(e.maxLeaves);n.push(t)},i=(e,t,n,a)=>{let o=Im(e);if(o.kind===`object`){for(let[e,r]of Object.entries(o.entries))i(r,[...t,e],n?.[e],a?.[e]);return}if(o.kind===`record`){let e=new Set;if(typeof n==`object`&&n)for(let t of Object.keys(n))e.add(t);if(typeof a==`object`&&a)for(let t of Object.keys(a))e.add(t);for(let r of e)i(o.value,[...t,r],n?.[r],a?.[r]);return}r(t)},a=Lm(e.state,e.path);return i(t,[...e.path],e.op===`remove`?void 0:e.value,a),n}function Bm(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n)return;n=n[e]}return n}function Vm(e){let{realm:t,avatar:n,state:r,basisVersion:i}=e;for(let a of e.patches){let e=a.path,o=wm(t.stateDef,e);if(o==null)return qp.fromId(`value_invalid`,{path:e.join(`.`),expected:`a schema path`});if(a.op!==`remove`){let n=Yp(o,a.value);if(n!=null)return qp.fromId(`value_invalid`,{path:[...e,...n.path].join(`.`),expected:n.expected});for(let n=1;n<e.length;n++){let i=wm(t.stateDef,e.slice(0,n));for(;i?.kind===`optional`;)i=i.inner;if(i?.kind!==`record`||i.maxKeys==null)continue;let a=Bm(r,e.slice(0,n));if(!(typeof a!=`object`||!a||Array.isArray(a))&&!(e[n]in a)&&Object.keys(a).length>=i.maxKeys)return qp.fromId(`value_invalid`,{path:e.slice(0,n).join(`.`),expected:`a record with at most ${i.maxKeys} entries`})}}let s=zm({schemaRoot:t.stateDef,path:e,op:a.op,value:a.value,state:r,maxLeaves:1/0});for(let o of s){let s=t.ruleTrie.match(o);if(s==null)return qp.fromId(`unauthorized_coordinate`,{path:o.join(`.`)});let c=o.slice(e.length),l=Fm(s.rule.alter,{avatar:n,params:s.params,prev:Hm(r,o),next:a.op===`remove`?void 0:Hm(a.value,c),state:r,basisVersion:i},void 0);if(l===`serverOnly`)return qp.fromId(`unauthorized_coordinate`,{path:o.join(`.`)});if(l!==!0)return l}}return!0}function Hm(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n)return;n=n[e]}return n}function Um(e,t,n){let r;for(let i=0;i<t.length;i++){let a=t[i];if(a.op!==`remove`&&a.path.length>1)for(let o=1;o<a.path.length;o++){let s=a.path.slice(0,o);if(Wm(e,r??t.slice(0,i),s))continue;let c=o===1?void 0:wm(n,s.slice(0,-1));if(c!=null&&Gm(c).kind===`record`)break;let l=wm(n,s);if(l==null)break;let u=Gm(l).kind;if(u!==`object`&&u!==`record`)break;r??=t.slice(0,i),r.push({op:`add`,path:s,value:{}})}r?.push(a)}return r??t}function Wm(e,t,n){for(let e=t.length-1;e>=0;e--){let r=t[e];if(!(r.path.length>n.length)&&r.path.every((e,t)=>String(e)===String(n[t])))return r.op===`remove`?!1:Km(r.value,n.slice(r.path.length))!==void 0}return Km(e,n)!==void 0}function Gm(e){return e.kind===`optional`?Gm(e.inner):e}function Km(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n)return;n=n[e]}return n}function qm(){let e=`pending`,t,n,r,i,a,o=()=>(r??=e===`confirmed`&&t!=null?Promise.resolve(t):e===`rejected`?Promise.reject(n):new Promise((e,t)=>{i=e,a=t}),r);return{handle:{get status(){return e},get error(){return n},then:(e,t)=>o().then(e,t)},confirm(n){e===`pending`&&(e=`confirmed`,t=n,i?.(n))},reject(t){e===`pending`&&(e=`rejected`,n=t,a?.(t))}}}Pp();var Jm=256,Ym=-2,Xm=3,Zm=1e3;function Qm(e){return e.kind===Zp.batch?e.frames.some(Qm):e.kind!==Zp.reject}var $m=1e4,eh=25e3,th=1e4;function nh(e,t){let n=t.connection.coordinate,r=t.avatar.persistentId??n?.perId;if(r==null)throw Error(`connectRealm: no avatar identity — the connection carries no persistent id. Give it one where you open the connection (identity: coord.withPersistentId(id)), or pass avatar.persistentId explicitly.`);let i={type:t.avatar.type,persistentId:r,instanceId:t.avatar.instanceId??n?.insId??`default`},a=t.pendingExpiryMs??$m,o=t.connection.slot,s=t.devtools,c=t.coalesce??(t.coalesceMs==null?void 0:{ms:t.coalesceMs}),l=c!=null&&c.ms>0?c.ms:0,u=c?.leading===!0&&l>0,d=new Vp({}),f=new Xp,p=new Set,m={},h=-1,g,_,v=!1,y=`connecting`,b,x=()=>g==null?`[realm:${e.id}]`:`[realm:${e.id}#${g.slice(0,8)}]`,ee=new Set,S=!1,C=e=>{if(y!==e){y=e,e===`live`&&(S=!0);for(let t of[...ee])t(e,{hasBeenLive:S});s?.onStatus?.(e,{hasBeenLive:S}),e===`detached`&&it()}},w=[],T=[],te=0,ne=!1,re=!1,E,ie=Date.now(),ae=0,oe,D=!1,O=0,se=new Set,k=new Set,ce=e=>{s?.onDiagnostic?.(e);for(let t of[...k])t(e);if(t.onDiagnostic!=null){t.onDiagnostic(e);return}k.size>0||se.has(e.type)||(se.add(e.type),console.warn(`${x()} sync-health event "${e.type}"`,e))},le=!1,ue=e=>{if(t.onMutationRejected!=null){t.onMutationRejected(e);return}e.rolledBackPaths.length>0&&!le&&(le=!0,console.warn(`${x()} an optimistic ${e.kind} rolled back on [${e.rolledBackPaths.join(`, `)}] (${e.error.getIds().join(`, `)}) with no onMutationRejected handler — the change silently reverted. Wire onMutationRejected on connectRealm. Note: frame_too_stale is an UNKNOWN outcome (may have committed), not a definite reject.`))},A=t.staleProbeAfterMs??eh,de=t.probeReplyTimeoutMs??th,fe=()=>{de<=0||(oe!=null&&clearTimeout(oe),oe=setTimeout(()=>{oe=void 0,y===`live`&&(ie>=ae||(ce({type:`probe_escalated`}),C(`connecting`),t.connection.requestReconnect?.()))},de),qa(oe))},pe=()=>w.some(e=>e.isSystemAssert),me=.2,he=null,ge=null,_e=0,ye=e=>{e<0||(_e+=1,he==null||ge==null?(he=e,ge=0):(ge+=me*(Math.abs(e-he)-ge),he+=me*(e-he)),s?.onStats?.({rttMs:he,jitterMs:ge,samples:_e}))},be=(e,t)=>{y!==`detached`&&(ce({type:`resync`,reason:e,...t}),!(D&&Date.now()-O<1e4)&&E?.isOpen()===!0&&_t({probe:!0}))},xe=new Map,Se=new Set,Ce=e=>{let t=m;for(let n of e){if(typeof t!=`object`||!t)return!1;t=t[n]}return t!=null},we=()=>{if(xe.size!==0&&!pe())for(let[e,t]of[...xe]){if(Ce(t)){xe.delete(e),Se.delete(e);continue}ce({type:`reown_missing`,path:t.join(`.`)}),Se.has(e)?(xe.delete(e),Se.delete(e)):E?.isOpen()===!0&&y!==`detached`&&(Se.add(e),_t({probe:!0,forceFullHydrate:!0}))}},Te=0,Ee,De=()=>{Ee!=null&&(clearTimeout(Ee),Ee=void 0)},Oe=()=>{if(D=!1,Ee!=null)return;let e=Math.min(250*2**Te,5e3);Te+=1;let t=setTimeout(()=>{Ee=void 0,be(`frame_error`)},e);qa(t),Ee=t},ke=()=>{for(let e of p)e()},Ae=new Set,je={},Me=!1,Ne=!1,Pe=!0,Fe=!1,Ie=e=>e?.fullReplace===!0?`hydrate`:e?.confirmed==null?e?.cause??`rebase`:`confirm`,Le=e=>e==null?!1:e.fullReplace===!0||e.confirmed!=null?!0:e.authoritative===!0,Re=e=>{if(Me){Ne=!0,Ie(e)!==`confirm`&&(Pe=!1),Le(e)&&(Fe=!0);return}let t=m,n=[];for(let e of w)try{t=Rp(t,e.patches)}catch{n.push(e)}if(n.length>0){w=w.filter(e=>!n.includes(e));for(let e of n)Be(e,qp.fromId(`frame_too_stale`,{basisVersion:e.basisVersion}))}re=!0;try{d.replace(t)}finally{re=!1}if(t!==je){let n=Ie(e),r=Le(e);if(s?.onFlush?.({cause:n,authoritative:r,confirmedVersion:h}),Ae.size>0){let i=e?.fullReplace===!0?[{op:`replace`,path:[],value:t}]:e?.confirmed??Nm(je,t);if(i.length>0){let e={cause:n,authoritative:r,confirmedVersion:h};for(let t of[...Ae])t(i,e)}}}je=t,ke()},ze=t=>{let n=t.filter(e=>{if(e.op!==`remove`)return!0;let t=m;for(let n of e.path.slice(0,-1)){if(typeof t!=`object`||!t)return!1;t=t[n]}return typeof t==`object`&&!!t&&String(e.path[e.path.length-1])in t}),r=Um(m,n,e.stateDef);return m=Rp(m,r),r},Be=(e,t)=>{e.expiryTimer!=null&&clearTimeout(e.expiryTimer);for(let n of e.handles)n.reject(t);s?.onMutation?.({type:`rejected`,clientSeq:e.clientSeq,kind:e.kind,intentName:e.intentName,durability:e.durability,systemAssert:e.isSystemAssert,errorIds:t.getIds(),rolledBackPaths:e.patches.map(e=>e.path.join(`.`))}),!(e.isSystemAssert&&t.getIds().includes(`frame_too_stale`))&&ue({error:t,kind:e.kind,intentName:e.intentName,rolledBackPaths:e.patches.map(e=>e.path.join(`.`))})},j=(e,t)=>{e.expiryTimer!=null&&clearTimeout(e.expiryTimer),e.sentAt!=null&&ye(Date.now()-e.sentAt);for(let n of e.handles)n.confirm({version:t});s?.onMutation?.({type:`confirmed`,clientSeq:e.clientSeq,kind:e.kind,intentName:e.intentName,durability:e.durability,systemAssert:e.isSystemAssert,version:t})},Ve=e=>{e.durability!==`reassert`&&(e.expiryTimer=setTimeout(()=>{w.includes(e)&&(w=w.filter(t=>t!==e),Be(e,qp.fromId(`frame_too_stale`,{basisVersion:e.basisVersion})),Re())},a),qa(e.expiryTimer))},He=e=>{if(E==null||!E.isOpen())return;e.sentAt=Date.now();let t=e.buildFrame(e.clientSeq,e.basisVersion);s?.onFrame?.(`out`,e.kind,t.byteLength),E.send(t)},Ue,We=()=>Ue??_?.maxPatchesPerFrame??1/0,Ge=(t,n,r,i,a,s)=>{let c={clientSeq:t,kind:`write`,patches:n,basisVersion:r,handles:i,buildFrame:(t,n)=>pm({slot:o,clientSeq:t,basisVersion:n,ops:Om(rh(c.patches),e.tokens)}),expiryTimer:void 0,openForMerge:!1,retries:a,durability:s};return c},Ke=(e,t,n)=>{e.expiryTimer!=null&&clearTimeout(e.expiryTimer);let r=[];for(let i=0;i<t.length;i+=n){let a=t.slice(i,i+n),o=i+n>=t.length;r.push(Ge(r.length===0?e.clientSeq:te++,a,e.basisVersion,o?e.handles:[],e.retries,e.durability))}let i=w.indexOf(e);i>=0&&w.splice(i,1,...r);for(let e of r)Ve(e);return r},qe=e=>{if(e.kind!==`write`){He(e);return}let t=rh(e.patches),n=We();if(t.length<=n){He(e);return}for(let r of Ke(e,t,n))He(r)},Je=()=>{ne=!1;for(let e of[...w])e.openForMerge&&(e.openForMerge=!1,!D&&qe(e))},Ye,Xe=()=>{let e=setTimeout(()=>{Ye=void 0,w.some(e=>e.openForMerge)&&(Je(),Xe())},l);qa(e),Ye=e},Ze=()=>{ne||(ne=!0,!(u&&Ye!=null)&&(l>0?qa(setTimeout(Je,l)):queueMicrotask(Je)))},Qe=(e,t,n,r)=>(e.reject(n),ue({error:n,kind:t,intentName:r,rolledBackPaths:[]}),s?.onMutation?.({type:`rejected`,clientSeq:-1,kind:t,intentName:r,errorIds:n.getIds(),rolledBackPaths:[]}),e.handle),M=(e,t,n)=>Qe(qm(),e,t,n),$e=()=>b??qp.fromId(`write_before_hydrate`,{realmId:e.id}),et=(e,t)=>{e.expiryTimer!=null&&clearTimeout(e.expiryTimer),Qe(e.controller,e.kind,t,e.intentName)},tt=()=>h===-1||T.length>0,nt=(e,t)=>{let n=qm();if(y===`detached`)return Qe(n,e.kind,$e(),e.intentName);let r={...e,controller:n,expiryTimer:void 0};return t!==`reassert`&&(r.expiryTimer=setTimeout(()=>{let e=T.indexOf(r);e<0||(T.splice(e,1),et(r,$e()),ke())},a),qa(r.expiryTimer)),T.push(r),ke(),n.handle},rt=()=>{for(let e=T.shift();e!=null;e=T.shift()){e.expiryTimer!=null&&clearTimeout(e.expiryTimer);let{controller:t}=e,n;try{n=e.run()}catch(t){console.error(`${x()} a write queued before the first hydrate threw`,t),et(e,ve(t));continue}let r=n;r.then(t.confirm,()=>{r.error!=null&&t.reject(r.error)})}},it=()=>{for(let e of T.splice(0))et(e,$e())},at=(t,n)=>{let r=n?.durability,i=n?.flush===`immediate`;if(r===`reassert`){let e=w.filter(e=>e.durability===`reassert`).length;if(e>=Jm)return M(`write`,qp.fromId(`durable_backlog_overflow`,{pendingFrames:e}))}let a=qm();i&&Je();let c=i?void 0:w.find(e=>e.kind===`write`&&e.openForMerge&&e.durability===r);if(c!=null)return c.patches.push(...t),c.handles.push(a),Re({cause:`optimistic`}),Ze(),a.handle;let l={clientSeq:te++,kind:`write`,patches:t,basisVersion:h,handles:[a],buildFrame:(t,n)=>pm({slot:o,clientSeq:t,basisVersion:n,ops:Om(rh(l.patches),e.tokens)}),expiryTimer:void 0,openForMerge:!0,retries:0,durability:r};return w.push(l),s?.onMutation?.({type:`created`,clientSeq:l.clientSeq,kind:`write`,durability:r}),Ve(l),Re({cause:`optimistic`}),i?(l.openForMerge=!1,D||qe(l)):u&&Ye==null?(Je(),Xe()):Ze(),a.handle},ot=(t,n)=>{let r=d.state,a,[o,s]=Lp(r,e=>{a=t(e)});if(s.length===0){if(typeof a==`object`&&a)throw Error(`[realm:${e.id}] realm.update(fn): the update function returned a value without modifying its draft. Updates are mutate-only — a returned state is ignored (unlike immer's produce). Mutate the draft instead.`);let t=qm();return t.confirm({version:h}),t.handle}let c=Dm(s,o,e.stateDef),l=Vm({realm:e,patches:c,avatar:i,state:r,basisVersion:h});return l===!0?at(c,n):M(`write`,l)},st=(e,t)=>tt()?nt({kind:`write`,run:()=>ot(e,t)},t?.durability):ot(e,t),ct=(e,t)=>tt()?nt({kind:`intent`,intentName:e,run:()=>lt(e,t)}):lt(e,t),lt=(t,n)=>{let r=e.intents[t];if(r==null)return M(`intent`,qp.fromId(`intent_unknown`,{intent:t}),t);let a=Yp(r.input,n);if(a!=null)return M(`intent`,qp.fromId(`value_invalid`,{path:[t,...a.path].join(`.`),expected:a.expected}),t);Je();let c=[];if(r.optimistic!=null)try{let t=d.state,[a,o]=Lp(t,e=>{r.optimistic?.({view:e,avatar:i,input:n})});c=Dm(o,a,e.stateDef)}catch{c=[]}let l=qm(),u=e.intentNames.indexOf(t),f={clientSeq:te++,kind:`intent`,intentName:t,patches:c,basisVersion:h,handles:[l],buildFrame:e=>mm({slot:o,clientSeq:e,intentToken:u,input:n}),expiryTimer:void 0,openForMerge:!1,retries:0};return w.push(f),s?.onMutation?.({type:`created`,clientSeq:f.clientSeq,kind:`intent`,intentName:t}),Ve(f),c.length>0?Re({cause:`optimistic`}):ke(),D||He(f),l.handle},ut=(e,t)=>{if(e.kind!==`write`||!t.getIds().includes(`limits_exceeded`)||e.retries>=Xm)return!1;let n=t.getContext(`limits_exceeded`),r=typeof n==`object`&&n&&`limit`in n?String(n.limit):``;if(r===`writeRatePerSecond`)return e.retries+=1,qa(setTimeout(()=>{w.includes(e)&&!D&&He(e)},Zm)),!0;if(r===`maxPatchesPerFrame`||r===`maxFrameBytes`){e.retries+=1;let t=rh(e.patches);if(t.length<=1)return!1;Ue=Math.max(1,Math.floor(Math.min(We(),t.length)/2));for(let n of Ke(e,t,Ue))He(n);return!0}return!1},dt=()=>{let t=[],n=m;for(let e of w)if(e.isSystemAssert)try{n=Rp(n,e.patches)}catch{}for(let r of w){if(r.isSystemAssert){t.push(r);continue}let a=r.kind===`intent`?!0:Vm({realm:e,patches:r.patches,avatar:i,state:m,basisVersion:h});if(a!==!0){Be(r,a);continue}if(r.kind===`write`){let e;try{e=Rp(n,r.patches)}catch{Be(r,qp.fromId(`frame_too_stale`,{basisVersion:r.basisVersion}));continue}n=e}r.basisVersion=h,t.push(r)}w=t;for(let e of[...t])e.openForMerge||He(e)},ft=[],pt=n=>{switch(n.kind){case Zp.batch:{let e=Me;Me=!0,e||(Pe=!0,Fe=!1);let t=!1,r;try{for(let e of n.frames)try{pt(e)}catch(e){t||(t=!0,r=e)}}finally{Me=e}if(!Me&&Ne&&(Ne=!1,Re({cause:Pe?`confirm`:`rebase`,authoritative:Fe})),t)throw r;return}case Zp.hydrate:{if(f.load(n.keyDictSeed),ft.push(n.stateBlob),n.more)return;let r=ih(ft);ft=[];let i=h<0;m=_s(r),h=n.version,g=n.epoch,_={maxPatchesPerFrame:n.limits[0],maxFrameBytes:n.limits[1],writeRatePerSecond:n.limits[2]},Ue=void 0,ht(n.avatar),C(`live`),D&&ye(Date.now()-O),D=!1,!i&&e.transient.length>0&&t.assertOnAttach!=null&&!pe()&&gt(m),dt(),Re({fullReplace:!0}),t.assertOnAttach!=null&&!pe()&&ot(t.assertOnAttach),rt(),we();return}case Zp.keyDict:f.load(n.entries);return;case Zp.patches:{let t=n.fromVersion===h,r=n.toVersion===h;if(!t&&!r){D?ce({type:`gap_dropped`,fromVersion:n.fromVersion,toVersion:n.toVersion,confirmedVersion:h}):be(`version_gap`,{fromVersion:n.fromVersion,toVersion:n.toVersion,confirmedVersion:h});return}let i=D;D=!1,i&&ye(Date.now()-O);let a=km(n.ops,e.tokens,e=>f.keyOf(e)).filter(e=>!bm(e.path)),o=w.length===0&&je===m,s=ze(a);h=n.toVersion,i&&(pe()||gt(m),dt()),y===`connecting`&&C(`live`),Re(o&&w.length===0?{confirmed:s}:{authoritative:!0}),we();return}case Zp.ack:{let e=w.findIndex(e=>e.clientSeq===n.clientSeq);if(e<0)return;let[t]=w.splice(e,1);j(t,n.version),Re(),t.isSystemAssert&&we();return}case Zp.reject:{let e=ve(n.error);if(n.clientSeq===-1){b=e,D=!1,C(`detached`);return}let t=w.findIndex(e=>e.clientSeq===n.clientSeq);if(t<0){ce({type:`late_reject`,clientSeq:n.clientSeq,errorIds:e.getIds()});return}if(ut(w[t],e))return;let[r]=w.splice(t,1);if(Be(r,e),Re(),e.getIds().includes(`write_target_missing`)){for(let e of r.patches)if(e.path.length>1){let t=e.path.slice(0,-1);xe.set(JSON.stringify(t),t)}be(`write_target_missing`)}r.isSystemAssert&&we();return}case Zp.detach:if(n.reason===`rehello`){y===`live`&&_t({probe:!0});return}D=!1,C(`detached`);return;default:return}},mt=(e,t)=>{s?.onFrame?.(`in`,Qp[e.kind]??String(e.kind),t??0);try{pt(e)}catch(e){ce({type:`frame_error`,error:e}),ft=[],Oe();return}Qm(e)&&(ie=Date.now(),Te=0,De(),oe!=null&&(clearTimeout(oe),oe=void 0))},ht=e=>{let[t,n,r]=e;t===i.type&&n===i.persistentId&&r===i.instanceId||v||(v=!0,console.warn(`${x()} identity mismatch — this client predicts as ${i.type}/${i.persistentId}/${i.instanceId} but the server resolved it as ${t}/${n}/${r}. Prediction and view slicing run against DIFFERENT identities: owner-gated writes will pass locally and reject on the server. Fix the server's resolveAvatar/avatarType, or the avatar passed to connectRealm.`))},gt=n=>{if(t.assertOnAttach==null||e.transient.length===0||h<0||E==null||!E.isOpen())return;let[r,i]=Lp(n,e=>{t.assertOnAttach?.(e)});if(i.length===0)return;let a=Dm(i,r,e.stateDef);if(a.length===0)return;w.some(e=>e.isSystemAssert)&&(w=w.filter(e=>!e.isSystemAssert));let s={clientSeq:Ym,kind:`write`,patches:a,basisVersion:h,handles:[],buildFrame:(t,n)=>pm({slot:o,clientSeq:t,basisVersion:n,ops:Om(rh(a),e.tokens)}),expiryTimer:void 0,openForMerge:!1,retries:0,isSystemAssert:!0};w.unshift(s),Re({cause:`optimistic`})},_t=t=>{t?.probe===!0?(ae=Date.now(),fe()):(C(`connecting`),b=void 0,f.clear()),D=!0,O=Date.now(),ft=[],gt(d.state);let n=fm({slot:o,realmId:e.id,schemaHash:e.schemaHash,lastKnownVersion:t?.forceFullHydrate===!0?-1:h,epoch:g});s?.onFrame?.(`out`,`hello`,n.byteLength),E?.send(n);let r=gm({slot:o,features:[$p.batch]});s?.onFrame?.(`out`,`clientCaps`,r.byteLength),E?.send(r)},vt,yt=Mm(t.connection,e,t.security);yt==null?(E=t.connection.register({onFrame:mt,onAttach:()=>_t(),onDetach:()=>{y!==`detached`&&C(`connecting`)}}),E.isOpen()&&_t(),vt=t.connection.subscribeLinkEvents?.(e=>{e.type===`link_up`&&e.downForMs!=null&&ce({type:`link_redialed`,downForMs:e.downForMs})})):(b=yt,C(`detached`),t.connection.release());let bt;if(yt==null&&A>0&&(bt=setInterval(()=>{if(y!==`live`||E?.isOpen()!==!0)return;let e=Date.now();e-ie<A||e-ae<A||_t({probe:!0})},Math.max(1e3,Math.floor(A/2))),qa(bt)),t.experimental_writeThroughStore===!0)d.listenToPatches(t=>{if(re)return;let n=t.filter(e=>e.path.length>0);n.length!==0&&queueMicrotask(()=>{let t=Dm(n,d.state,e.stateDef);if(t.length===0)return;let r=Vm({realm:e,patches:t,avatar:i,state:d.state,basisVersion:h});if(r!==!0){ue({error:r,kind:`write`,rolledBackPaths:t.map(e=>e.path.join(`.`))}),Re();return}at(t)})});else{let e=!1;d.listenToPatches(()=>{re||e||(e=!0,console.warn(`${x()} realm.store was written directly. The store is a read projection — this change was never sent to the server and will vanish on the next incoming flush. Did you mean realm.update()? (Raw store write-through requires the experimental_writeThroughStore option.)`))})}let xt={store:d,avatar:i,update:st,intents:Object.fromEntries(e.intentNames.map(e=>[e,t=>ct(e,t)])),pending:{get count(){return w.reduce((e,t)=>t.isSystemAssert?e:e+1,0)+T.length},has(e){return w.some(t=>!t.isSystemAssert&&t.patches.some(t=>t.path.join(`.`).startsWith(e)))},subscribe(e){return p.add(e),()=>p.delete(e)}},get status(){return y},get hasBeenLive(){return S},get version(){return h},get attachError(){return b},whenLive(e){return y===`live`?Promise.resolve():b==null?y===`detached`?Promise.reject(Error(`whenLive: the realm is detached`)):new Promise((t,n)=>{let r=e?.timeoutMs??1e4,i=()=>{clearTimeout(a),ee.delete(o)},a=setTimeout(()=>{i(),n(Error(`whenLive: the realm did not hydrate within ${r}ms`))},r),o=()=>{y===`live`?(i(),t()):(b!=null||y===`detached`)&&(i(),n(b??Error(`whenLive: the realm detached before going live`)))};ee.add(o)}):Promise.reject(b)},subscribeStatus(e){return ee.add(e),()=>ee.delete(e)},subscribeDiagnostics(e){return k.add(e),()=>k.delete(e)},listenToPatches(e){return Ae.add(e),()=>Ae.delete(e)},get stats(){return{rttMs:he,jitterMs:ge,samples:_e}},detach(){if(bt!=null&&clearInterval(bt),oe!=null&&clearTimeout(oe),Ye!=null&&(clearTimeout(Ye),Ye=void 0),vt?.(),De(),xe.clear(),Se.clear(),E?.isOpen()===!0)try{let e=hm({slot:o,reason:void 0});s?.onFrame?.(`out`,`detach`,e.byteLength),E.send(e)}catch{}D=!1,C(`detached`),t.connection.release();for(let e of w.splice(0))Be(e,qp.fromId(`frame_too_stale`,{basisVersion:e.basisVersion}));Re()}};return s?.handleReady?.({handle:xt,realmId:e.id,slot:o,avatar:i,peer:(t.connection.peer??t.connection.peerCoordinate)?.envId}),xt}function rh(e){let t=new Map;for(let n of e)t.set(n.path.join(` `),n);return[...t.values()]}function ih(e){if(e.length===1)return e[0];let t=e.reduce((e,t)=>e+t.byteLength,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;return n}Pp();var ah=new WeakMap,oh=5e3;function sh(e){let t=ah.get(e);if(t!=null)return t;let n=new Map,r=(e,t,n)=>{try{e.onFrame(t,n)}catch(e){console.error(`[realm] a realm slot handler threw while dispatching an inbound frame`,e)}},i=(e,t)=>{if(e.slot===255){for(let i of n.values())r(i,e,t);return}let i=n.get(e.slot);i!=null&&r(i,e,t)};return t={nextSlot:0,freeSlots:[],slots:n,port:e.registerProtocol({id:`realm`,prefixByte:Js.realm,onFrame:e=>{let t;try{t=_m(e)}catch{return}if(t.kind===Zp.batch){let a=new Map;for(let e of t.frames){if(e.slot===255){i(e);continue}let t=a.get(e.slot);t==null?a.set(e.slot,[e]):t.push(e)}for(let[t,i]of a){let o=n.get(t);o!=null&&r(o,i.length===1?i[0]:{kind:Zp.batch,slot:t,frames:i},a.size===1?e.byteLength:void 0)}return}i(t,e.byteLength)},onAttach:()=>{for(let e of n.values())e.onAttach()},onDetach:()=>{for(let e of n.values())e.onDetach()}})},ah.set(e,t),t}function ch(e){let t=e instanceof Tc,n=t?e:e.wireMux;if(n==null)throw Error(`realmConnection: this link has no frame-protocol mux — connect it via connectChannel (which creates one per connection) or pass a WireProtocolMux directly.`);let r=t?void 0:e.localCoordinate,i=t?void 0:`peer`in e?e.peer:e.peerClient,a=t?void 0:e.securityLevel,o=t?void 0:e.requestReconnect,s=t?void 0:e.addLinkEventListener?.bind(e),c=sh(n),l=c.freeSlots.pop();if(l==null&&c.nextSlot>=255)throw Error(`realmConnection: slot space exhausted (max 254)`);let u=l??c.nextSlot++,d=!1;return{slot:u,coordinate:r,peer:i,peerCoordinate:i,securityLevel:a,requestReconnect:o,subscribeLinkEvents:s,register(e){return c.slots.set(u,e),{send:e=>c.port.send(e),isOpen:()=>c.port.isOpen()}},release(){d||(d=!0,c.slots.delete(u),qa(setTimeout(()=>c.freeSlots.push(u),oh)))}}}function lh(){return{define:e=>e}}function uh(){return{path(e){return{view:t=>({alter:n=>({pattern:e,view:t,alter:n})})}},everyone:{kind:`everyone`},serverOnly:{kind:`serverOnly`},avatarTypes:(...e)=>({kind:`avatarTypes`,types:e}),serverChecked:e=>({kind:`serverChecked`,fn:e}),all:(...e)=>({kind:`all`,conds:e})}}function dh(e){if(e.length===0)throw Error(`rule pattern may not be empty`);let t=e.split(`.`),n=[[]];return t.forEach((r,i)=>{let a=i===t.length-1;if(r.startsWith(`{`)&&r.endsWith(`}`)){let t=r.slice(1,-1).split(`,`).map(e=>e.trim());if(t.some(e=>e.length===0))throw Error(`rule pattern "${e}": empty name in brace group "${r}"`);n=n.flatMap(e=>t.map(t=>[...e,t]));return}if((r===`*`||r===`**`)&&!a)throw Error(`rule pattern "${e}": "${r}" is only valid as the final segment`);n=n.map(e=>[...e,r])}),n.map(t=>({source:e,segments:t.map(t=>{if(t===`*`)return{kind:`star`};if(t===`**`)return{kind:`deep`};if(t.startsWith(`$`)){let n=t.slice(1);if(n.length===0)throw Error(`rule pattern "${e}": bare "$" segment`);return{kind:`var`,name:n}}if(t.includes(`{`)||t.includes(`}`)||t.includes(`$`))throw Error(`rule pattern "${e}": malformed segment "${t}"`);return{kind:`lit`,name:t}})}))}function fh(e,t){for(let n of t)for(let t of dh(n)){let r=gh({kind:`object`,entries:e},t.segments,0);if(r!=null)throw Error(`rule pattern "${n}" can never match: ${r}`)}}function ph(e,t){let n=[];for(let r of t){let t=r.split(`.`);for(let e of t)if(e.length===0||/[$*{}]/.test(e))throw Error(`transient path "${r}" must be a concrete, wildcard-free path (no $var, *, ** or {a,b}); offending segment "${e}". Wildcard transient regions are not supported in v1.`);if(mh({kind:`object`,entries:e},t,0)==null)throw Error(`transient path "${r}" does not resolve to any node in the realm schema.`);n.push(t)}return n}function mh(e,t,n){if(n>=t.length)return e;let r=hh(e);if(r.kind===`object`){let e=r.entries[t[n]];return e==null?void 0:mh(e,t,n+1)}if(r.kind===`record`)return mh(r.value,t,n+1)}function hh(e){return e.kind===`optional`?hh(e.inner):e}function gh(e,t,n){if(n>=t.length)return;let r=hh(e),i=t[n],a=_h(t,n);if(r.kind===`object`){if(i.kind===`lit`){let e=r.entries[i.name];return e==null?`"${i.name}" is not a key of the object at ${a}`:gh(e,t,n+1)}if(i.kind===`var`){let e=Object.values(r.entries);return e.length===0?`the object at ${a} has no keys`:e.some(e=>gh(e,t,n+1)==null)?void 0:`no key of the object at ${a} admits the rest of the pattern`}return}if(r.kind===`record`)return i.kind===`lit`||i.kind===`var`?gh(r.value,t,n+1):void 0;let o=r.kind===`array`?` (t.array is leaf-replace-only on the wire — rule it with the exact path, e.g. "${_h(t,n,!0)}")`:``;return`it descends into the ${r.kind} wire-leaf at ${a}${o}`}function _h(e,t,n=!1){let r=e.slice(0,t).map(e=>e.kind===`lit`?e.name:e.kind===`var`?`$${e.name}`:e.kind===`star`?`*`:`**`).join(`.`);return r.length===0?`the state root`:n?r:`"${r}"`}var vh=class{_root={};_patterns=[];constructor(e){for(let t of e){for(let e of dh(t.pattern))this._insert(e,t);this._patterns.push(t.pattern)}}get patterns(){return this._patterns}_insert(e,t){let n=[],r=this._root;for(let i=0;i<e.segments.length;i++){let a=e.segments[i];if(a.kind===`star`){if(r.star!=null)throw Error(`duplicate rule pattern at "${e.source}"`);r.star={rule:t,varNames:n};return}if(a.kind===`deep`){if(r.deep!=null)throw Error(`duplicate rule pattern at "${e.source}"`);r.deep={rule:t,varNames:n};return}if(a.kind===`var`){if(n[i]=a.name,r.var==null)r.var={name:a.name,node:{}};else if(r.var.name!==a.name)throw Error(`conflicting $var names at the same trie position: "$${r.var.name}" vs "$${a.name}" (${e.source})`);r=r.var.node;continue}r.lit??=new Map;let o=r.lit.get(a.name);o??(o={},r.lit.set(a.name,o)),r=o}if(r.exact!=null)throw Error(`duplicate rule pattern at "${e.source}"`);r.exact={rule:t,varNames:n}}match(e){let t=this._match(this._root,e,0);if(t==null)return;let n={};return t.varNames.forEach((t,r)=>{t!=null&&(n[t]=e[r])}),{rule:t.rule,params:n}}_match(e,t,n){if(n===t.length)return e.exact;let r=t[n],i=n===t.length-1,a=e.lit?.get(r);if(a!=null){let e=this._match(a,t,n+1);if(e!=null)return e}if(e.var!=null){let r=this._match(e.var.node,t,n+1);if(r!=null)return r}if(i&&e.star!=null)return e.star;if(e.deep!=null)return e.deep}};function yh(e){switch(e.kind){case`string`:return e.maxLength==null?e.kind:{k:`string`,max:e.maxLength};case`number`:return e.min==null&&e.max==null&&e.integer!==!0?e.kind:{k:`number`,...e.min==null?{}:{min:e.min},...e.max==null?{}:{max:e.max},...e.integer===!0?{int:!0}:{}};case`boolean`:return e.kind;case`literal`:return{k:`lit`,v:e.value};case`union`:return{k:`u`,o:e.options.map(e=>JSON.stringify(yh(e))).sort()};case`optional`:return{k:`opt`,i:yh(e.inner)};case`object`:return{k:`obj`,e:Object.keys(e.entries).sort().map(t=>[t,yh(e.entries[t])])};case`record`:{let t={k:`rec`,id:e.keyVar,v:yh(e.value)};return e.maxKeys==null?t:{...t,max:e.maxKeys}}case`array`:{let t={k:`arr`,i:yh(e.item)};return e.maxItems==null?t:{...t,max:e.maxItems}}case`standard`:return e.hashTag==null?{k:`std`}:{k:`std`,tag:e.hashTag}}}function bh(e){let t=Object.keys(e.state).sort();return JSON.stringify({id:e.id,state:t.map(t=>[t,yh(e.state[t])]),clients:[...e.avatarTypes].sort(),intents:[...e.intents].sort((e,t)=>e[0]<t[0]?-1:1).map(([e,t])=>[e,yh(t)]),rules:[...e.rulePatterns].sort()})}function xh(e){return Mi(bh(e))}function Sh(e){return e.kind===`optional`?Sh(e.inner):e}function Ch(e){let t=Sh(e);return t.kind===`object`?wh(t.entries):t.kind===`record`?{toToken:new Map,toName:[],children:new Map,recordChild:Ch(t.value)}:`leaf`}function wh(e){let t=Object.keys(e).sort(),n={toToken:new Map,toName:[],children:new Map};return t.forEach((t,r)=>{n.toToken.set(t,r),n.toName.push(t),n.children.set(t,Ch(e[t]))}),n}var Th=class{_root;constructor(e){this._root=wh(e)}tokenizePath(e,t){let n=[],r=this._root;for(let i of e){if(r===`leaf`||r==null)throw Error(`tokenizePath: path descends past a leaf at "${i}" (${e.join(`.`)})`);if(r===`record`)throw Error(`tokenizePath: internal record level error at "${i}"`);if(r.recordChild!=null){n.push(t?.(i)??i),r=r.recordChild;continue}let a=r.toToken.get(i);if(a==null)throw Error(`tokenizePath: unknown key "${i}" in path ${e.join(`.`)}`);n.push(a),r=r.children.get(i)??`leaf`}return n}detokenizePath(e,t){let n=[],r=this._root;for(let i of e){if(r===`leaf`||r===`record`||r==null)throw Error(`detokenizePath: path descends past a leaf (${e.join(`.`)})`);if(r.recordChild!=null){if(typeof i==`number`){let e=t?.(i);if(e==null)throw Error(`detokenizePath: unknown interned key id ${i}`);n.push(e)}else n.push(i);r=r.recordChild;continue}if(typeof i!=`number`||i<0||i>=r.toName.length)throw Error(`detokenizePath: invalid token "${i}" (${e.join(`.`)})`);let a=r.toName[i];n.push(a),r=r.children.get(a)??`leaf`}return n}rootTokenNames(){return this._root.toName}};function Eh(e){let t=e.rules(uh());fh(e.state,t.map(e=>e.pattern));let n=new vh(t),r=ph(e.state,e.transient??[]),i=e.intents?.(lh())??{},a=Object.keys(i).sort(),o=Object.keys(e.avatars).sort(),s=new Th(e.state),c=xh({id:e.id,state:e.state,avatarTypes:o,intents:a.map(e=>[e,i[e].input]),rulePatterns:t.map(e=>e.pattern)});return{id:e.id,security:e.security??`authenticated`,avatarTypes:o,stateDef:e.state,rules:t,ruleTrie:n,intents:i,intentNames:a,tokens:s,transient:r,schemaHash:c}}function Dh(e,t){if(t!=null){if(!Number.isSafeInteger(t)||t<0)throw Error(`t: ${e} must be a non-negative safe integer, got ${t}`);return t}}function Oh(e){let{min:t,max:n,integer:r}=e;if(t!=null&&!Number.isFinite(t))throw Error(`t: number min must be finite, got ${t}`);if(n!=null&&!Number.isFinite(n))throw Error(`t: number max must be finite, got ${n}`);if(t!=null&&n!=null&&t>n)throw Error(`t: number min (${t}) must be <= max (${n})`);if(r!=null&&typeof r!=`boolean`)throw Error(`t: number integer must be a boolean`);return{...t==null?{}:{min:t},...n==null?{}:{max:n},...r===!0?{integer:!0}:{}}}function kh(...e){let t=e.flatMap(e=>Array.isArray(e)?e:[e]);if(t.length<2)throw Error(`t.union needs at least 2 options, got ${t.length}`);return{kind:`union`,options:t}}var $={string(e={}){let t=Dh(`string maxLength`,e.maxLength);return{kind:`string`,...t==null?{}:{maxLength:t}}},number(e={}){return{kind:`number`,...Oh(e)}},boolean(){return{kind:`boolean`}},literal(e){return{kind:`literal`,value:e}},union:kh,optional(e){return{kind:`optional`,inner:e}},object(e){return{kind:`object`,entries:e}},id(e){return{kind:`id`,varName:e}},record(e,t,n={}){let r=Dh(`record maxKeys`,n.maxKeys);return{kind:`record`,keyVar:e.varName,value:t,...r==null?{}:{maxKeys:r}}},array(e,t={}){let n=Dh(`array maxItems`,t.maxItems);return{kind:`array`,item:e,...n==null?{}:{maxItems:n}}},schema(e,t={}){if(t.hashTag!=null&&(typeof t.hashTag!=`string`||t.hashTag===``))throw Error(`t.schema: hashTag must be a non-empty string`);return{kind:`standard`,schema:e,...t.hashTag==null?{}:{hashTag:t.hashTag}}},serverContext(){return{kind:`serverContext`}}};Pp();var Ah=`/wire`,jh=`/logs`,Mh=`/bootstrap`,Nh=`/ticket`,Ph=`commander-auth.`,Fh=9e5;function Ih(e){return{"~standard":{version:1,vendor:`nice-commander`,validate:t=>{let n=e(t);return typeof n==`string`?{issues:[{message:n}]}:{value:n}}}}}function Lh(e){if(!Array.isArray(e))return null;let t=[];for(let n of e){if(typeof n!=`string`||n===``)return null;t.push(n)}return t}function Rh(e){return typeof e!=`object`||!e||Array.isArray(e)?null:{...e}}function zh(e){let t=Rh(e);if(t==null)return`expected an object`;let n=Lh(t.ids);if(n==null)return`ids: expected an array of process ids`;let r=t.wait;if(r!=null&&typeof r!=`boolean`)return`wait: expected a boolean`;let i=t.staggerMs;if(i!=null&&(typeof i!=`number`||i<0))return`staggerMs: expected a non-negative number`;let a={ids:n};return r!=null&&(a.wait=r),i!=null&&(a.staggerMs=i),a}function Bh(e){let t=Rh(e);if(t==null)return`expected an object`;let n=Rh(t.processes);if(n==null)return`processes: expected an object keyed by process id`;let r={};for(let[e,t]of Object.entries(n)){let n=Rh(t);if(n==null)return`processes[${JSON.stringify(e)}]: expected an object`;let i={};for(let[t,r]of Object.entries(n)){if(r!==null&&typeof r!=`string`)return`processes[${JSON.stringify(e)}][${JSON.stringify(t)}]: expected string | null`;i[t]=r}r[e]=i}let i=t.clear;if(i==null)return{processes:r};let a=Lh(i);return a==null?`clear: expected an array of process ids`:{processes:r,clear:a}}function Vh(e){let t=Rh(e);if(t==null||t.ok!==!0)return`expected { ok: true }`;let n=t.warnings;return!Array.isArray(n)||!n.every(e=>typeof e==`string`)?`warnings: expected an array of strings`:{ok:!0,warnings:n}}function Hh(e){let t=Rh(e);if(t==null)return`expected an object`;let n=Lh(t.ids);if(n==null)return`ids: expected an array of process ids`;let r=t.withDependencies;return r!=null&&typeof r!=`boolean`?`withDependencies: expected a boolean`:r===!0?{ids:n,withDependencies:r}:{ids:n}}function Uh(e){let t=Rh(e);if(t==null)return`expected an object`;let n={},r=t.suite;if(r!=null){if(typeof r!=`string`||r===``)return`suite: expected a suite name`;n.suite=r}if(t.ids!=null){let e=Lh(t.ids);if(e==null)return`ids: expected an array of process ids`;n.ids=e}if(n.suite==null==(n.ids==null))return`expected exactly one of suite | ids`;let i=t.parallel;if(i!=null){if(typeof i!=`number`||!Number.isInteger(i)||i<1)return`parallel: expected an integer ≥ 1`;n.parallel=i}let a=t.failFast;if(a!=null){if(typeof a!=`boolean`)return`failFast: expected a boolean`;n.failFast=a}if(t.filter!=null){let e=sn(t.filter);if(typeof e==`string`)return`filter.${e}`;n.filter=e}return n}function Wh(e){let t=Rh(e);if(t==null||typeof t.accepted!=`boolean`)return`expected { accepted }`;let{runKey:n,reason:r}=t;return{accepted:t.accepted,...typeof n==`string`?{runKey:n}:{},...typeof r==`string`?{reason:r}:{}}}function Gh(e){let t=Rh(e);if(t==null)return`expected an object`;let n=sn(t.filter);if(typeof n==`string`)return`filter.${n}`;let r=t.name;return typeof r==`string`?{filter:n,name:r}:`name: expected a string`}function Kh(e){let t=Rh(e)?.id;return typeof t==`string`&&t!==``?{id:t}:`id: expected a saved filter id`}function qh(e){return Rh(e)?.ok===!0?{ok:!0}:`expected { ok: true }`}function Jh(e){return Rh(e)==null?`expected an object`:{}}function Yh(e){let t=Rh(e);if(t==null)return`expected an object`;let n=t.errors;return t.ok===!0?typeof t.applied==`boolean`?typeof t.configRevisionHash==`string`?!Array.isArray(n)||!n.every(e=>typeof e==`string`)?`errors: expected an array of strings`:{ok:!0,applied:t.applied,configRevisionHash:t.configRevisionHash,errors:n}:`configRevisionHash: expected a string`:`applied: expected a boolean`:`expected { ok: true }`}var Xh=new Set([`ready`,`spawned`,`already-running`,`blocked`,`failed`,`succeeded`,`stopped`,`already-stopped`]);function Zh(e){return typeof e==`string`&&Xh.has(e)}function Qh(e){let t=Rh(e);if(t==null)return`expected an object`;let{results:n,warnings:r}=t;if(!Array.isArray(n)||!Array.isArray(r))return`expected { results, warnings }`;let i=[];for(let e of n){let t=Rh(e);if(t==null)return`results: expected objects`;let{id:n,outcome:r,reason:a}=t;if(typeof n!=`string`||!Zh(r))return`results: malformed entry`;if(a!=null&&typeof a!=`string`)return`results: reason must be a string`;i.push(a==null?{id:n,outcome:r}:{id:n,outcome:r,reason:a})}let a=[];for(let e of r){if(typeof e!=`string`)return`warnings: expected strings`;a.push(e)}return{results:i,warnings:a}}function $h(e){let t=Qh(e);return typeof t==`string`?null:t}var eg=Iu({domain:`commander`}).createChildDomain({domain:`control`,actions:{ports:Al().input({schema:Ih(vr)}).output({schema:Ih(yr)}),start:Al().input({schema:Ih(zh)}).output({schema:Ih(Qh)}),stop:Al().input({schema:Ih(Hh)}).output({schema:Ih(Qh)}),restart:Al().input({schema:Ih(zh)}).output({schema:Ih(Qh)}),runSuite:Al().input({schema:Ih(Uh)}).output({schema:Ih(Wh)}),saveFilter:Al().input({schema:Ih(Gh)}).output({schema:Ih(qh)}),removeFilter:Al().input({schema:Ih(Kh)}).output({schema:Ih(qh)}),setEnv:Al().input({schema:Ih(Bh)}).output({schema:Ih(Vh)}),reloadConfig:Al().input({schema:Ih(Jh)}).output({schema:Ih(Yh)}),shutdown:Al().input({schema:Ih(Jh)}).output({schema:Ih(qh)})}}),tg=wd({toAcceptor:[eg],toConnector:[]}),ng=Eh({id:`commander_status`,avatars:{viewer:{persistentId:$.string()}},state:{generation:$.number(),configName:$.string(),configRevisionHash:$.string(),configError:$.array($.string()),processes:$.record($.id(`processId`),$.object({kind:$.string(),state:$.string(),pid:$.optional($.number()),startedAt:$.optional($.number()),sawOutputAt:$.optional($.number()),lastTask:$.optional($.object({outcome:$.string(),reason:$.optional($.string()),timedOut:$.boolean(),endedAt:$.number(),durationMs:$.optional($.number())})),recentRuns:$.array($.object({startedAt:$.number(),endedAt:$.optional($.number()),outcome:$.optional($.union($.literal(`succeeded`),$.literal(`failed`),$.literal(`stopped`),$.literal(`crashed`),$.literal(`timedOut`)))})),restarts:$.number(),lastExit:$.optional($.object({code:$.optional($.number()),signal:$.optional($.string()),expected:$.boolean()})),stale:$.boolean(),removed:$.boolean(),envDrift:$.boolean(),blockedBy:$.optional($.string()),degradedBy:$.array($.string()),unreadyReason:$.optional($.string()),capability:$.optional($.object({treeMechanism:$.string(),degraded:$.boolean(),notes:$.array($.string())})),tags:$.record($.id(`tag`),$.array($.string())),optIn:$.boolean(),detail:$.object({command:$.string(),cwd:$.string(),dependsOn:$.array($.string()),ready:$.optional($.string()),timeoutMs:$.optional($.number()),endpoints:$.array($.object({name:$.string(),protocol:$.string(),host:$.string(),port:$.number(),ownership:$.string(),url:$.optional($.string())})),envVars:$.array($.object({name:$.string(),description:$.optional($.string()),secret:$.boolean(),required:$.boolean(),values:$.optional($.array($.string())),source:$.string(),value:$.optional($.string())}))})})),suites:$.record($.id(`suiteName`),$.object({description:$.optional($.string()),members:$.array($.string()),parallel:$.number(),failFast:$.boolean()})),runs:$.record($.id(`runKey`),$.object({suite:$.optional($.string()),filterId:$.optional($.string()),startedAt:$.number(),endedAt:$.optional($.number()),outcome:$.optional($.union($.literal(`passed`),$.literal(`failed`))),previousDurationMs:$.optional($.number()),members:$.record($.id(`processId`),$.union($.literal(`pending`),$.literal(`running`),$.literal(`pass`),$.literal(`fail`),$.literal(`blocked`),$.literal(`skipped`)))})),savedFilters:$.array($.object({id:$.string(),name:$.optional($.string()),mode:$.union($.literal(`all`),$.literal(`any`)),terms:$.array($.string()),bucket:$.optional($.array($.string())),pinned:$.boolean(),lastRunAt:$.optional($.number())}))},rules:e=>[e.path(`**`).view(e.everyone).alter(e.serverOnly)]});async function rg(e,t,n){let r;e.connect().catch(e=>{r=e});try{await t.whenLive({timeoutMs:n})}catch(e){throw t.attachError??r??e}}var ig=3*6e4,ag=null,og=null;function sg(){return`tab-${crypto.randomUUID()}`}async function cg(){let e=ag;if(e!=null&&Date.now()-e.mintedAt<ig)return e.token;if(og==null){let e=lg();og=e;let t=()=>{og===e&&(og=null)};e.then(t,t)}return og}async function lg(){let e=await fetch(Mh,{credentials:`omit`,cache:`no-store`});if(!e.ok)throw Error(`bootstrap failed (${e.status})`);let t=(await e.json()).capability;if(typeof t!=`string`||t===``)throw Error(`bootstrap returned no capability`);return ag={token:t,mintedAt:Date.now()},t}function ug(e){let t=e,n=!1,r=()=>{t!=null||n||(n=!0,dg().then(e=>{t=e,n=!1},()=>{n=!1}))};return{peek:()=>(r(),t),take:()=>{let e=t;return t=null,r(),e}}}async function dg(){let e=await fg(await cg());if(e!=null)return e;ag=null;let t=await fg(await cg());if(t==null)throw Error(`ticket refused (401) even with a fresh capability`);return t}async function fg(e){let t=await fetch(Nh,{method:`POST`,credentials:`omit`,cache:`no-store`,headers:{authorization:`Bearer ${e}`}});if(t.status===401)return null;if(!t.ok)throw Error(`ticket refused (${t.status})`);let n=(await t.json()).ticket;if(typeof n!=`string`||n===``)throw Error(`no ticket issued`);return n}function pg(e){return`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}${e}`}async function mg(){let e=ug(await dg()),t=new Su($a.env(`commander_web`).withPersistentId(sg())),n=Dd(t,tg,{peer:$a.env(`commander_daemon`),storage:new Ga({methods:Ka(new Map)}),ephemeralIdentity:!0,securityLevel:ro.authenticated,defaultTimeout:Fh,reconnect:!0,carriers:[Od(()=>e.peek()==null?null:{url:pg(Ah)},{createWebSocket:t=>new WebSocket(t,[`${Ph}${e.take()}`])})]}),r=nh(ng,{onDiagnostic:()=>{},avatar:{type:`viewer`},connection:ch(n),assertOnAttach:()=>{}});try{await rg(n,r,15e3)}catch(e){throw r.detach(),n.dispose(),e}return{realm:r,control:async(e,n,r)=>{let i={ids:[...n]},a=e===`start`?eg.actionForId(`start`).request({...i,wait:!1}):e===`stop`?eg.actionForId(`stop`).request(r?.withDependencies===!0?{...i,withDependencies:!0}:i):eg.actionForId(`restart`).request(i),o=await(await t.handleActionPayload(a)).waitForResultPayload();if(!o.result.ok)throw Error(`"${e}" was refused by the daemon`);let s=$h(o.result.output);if(s==null)throw Error(`"${e}" answered in a shape this build cannot read`);return s},ports:async e=>{let n=eg.actionForId(`ports`).request(e),r=await(await t.handleActionPayload(n)).waitForResultPayload();if(!r.result.ok)throw Error(`the daemon refused port inspection`);let i=yr(r.result.output);if(typeof i==`string`)throw Error(i);return i},setEnv:async(e,n)=>{let r=eg.actionForId(`setEnv`).request({processes:{[e]:n}}),i=await(await t.handleActionPayload(r)).waitForResultPayload();if(!i.result.ok)throw Error(`the daemon refused the env change`);let a=i.result.output.warnings;return Array.isArray(a)?a.filter(e=>typeof e==`string`):[]},runSuite:async e=>{let n=eg.actionForId(`runSuite`).request(e),r=await(await t.handleActionPayload(n)).waitForResultPayload();if(!r.result.ok)throw Error(`the daemon refused the run`);return r.result.output},saveFilter:async(e,n)=>{let r=eg.actionForId(`saveFilter`).request({filter:e,name:n});if(!(await(await t.handleActionPayload(r)).waitForResultPayload()).result.ok)throw Error(`the daemon refused the pin`)},removeFilter:async e=>{let n=eg.actionForId(`removeFilter`).request({id:e});if(!(await(await t.handleActionPayload(n)).waitForResultPayload()).result.ok)throw Error(`the daemon refused the removal`)},shutdown:async()=>{let e=eg.actionForId(`shutdown`).request({}),n=await(await t.handleActionPayload(e)).waitForResultPayload();if(!n.result.ok)throw Error(`the daemon refused shutdown`);let r=n.result.output;if(typeof r!=`object`||!r||!(`ok`in r)||r.ok!==!0)throw Error(`shutdown answered in a shape this build cannot read`)},dispose:()=>{r.detach(),n.dispose()}}}async function hg(){let e=await dg();return new WebSocket(pg(jh),[`${Ph}${e}`])}var gg=18,_g=500,vg=250,yg=[];function bg({view:e,runningIds:t,clearSignal:n,onSelectProc:r}){let i=ur(e),[a,o]=(0,d.useState)({key:i,rows:yg}),[s,c]=(0,d.useState)(`connecting`),[l,u]=(0,d.useState)(!0),[f,p]=(0,d.useState)(``),[m,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(!1),[v,y]=(0,d.useState)(!1),b=Rn(location.hostname),x=(0,d.useRef)(null),ee=(0,d.useRef)(0),S=(0,d.useRef)({socket:null,view:e,key:i,cursor:{},awaitingResnap:!0}),C=(0,d.useRef)(yg),w=(0,d.useCallback)(e=>{C.current=e,o({key:S.current.key,rows:e})},[]),T=a.key===i?a.rows:yg,te=(0,d.useCallback)(e=>{let t=e.socket;t==null||t.readyState!==t.OPEN||(e.awaitingResnap=e.cursor.seq==null&&e.cursor.s==null,t.send(fr(e.view,e.cursor)))},[]),ne=(0,d.useCallback)((e,t)=>{if(t.k===`search-result`){h(e=>e==null||e.id!==t.id?e:{...e,rows:t.entries.map(dr),complete:t.complete,scanned:t.scanned,running:!1});return}if(e.awaitingResnap){if(!mr(e.view,t))return;e.awaitingResnap=!1}let n=lr(e.view,C.current,e.cursor,t);n!=null&&(e.cursor=n.cursor,w(n.rows))},[w]);(0,d.useEffect)(()=>{let e=S.current,t=null,n=!1,r=r=>{n||(e.socket=null,c(r),t=setTimeout(i,_g))},i=()=>{hg().then(t=>{if(n){t.close();return}e.socket=t,t.addEventListener(`open`,()=>{c(`live`),te(e)}),t.addEventListener(`message`,t=>{let n=qn(String(t.data));n!=null&&ne(e,n)}),t.addEventListener(`close`,()=>r(`reconnecting`))},()=>r(`reconnecting`))};return i(),()=>{n=!0,t!=null&&clearTimeout(t),e.socket?.close(),e.socket=null}},[ne,te]),(0,d.useEffect)(()=>{let t=S.current,n=t.view;if(t.view=e,t.key===i)return;t.key=i,t.cursor={},t.awaitingResnap=!0,w(yg),u(!0);let r=t.socket;r==null||r.readyState!==r.OPEN||(r.send(pr(n)),te(t))},[e,i,w,te]);let re=(0,d.useRef)(null);re.current=m,(0,d.useEffect)(()=>{let e=f.trim();if(e===``){h(null);return}if(s!==`live`)return;let t=setTimeout(()=>{let t=S.current,n=t.socket;if(n==null||n.readyState!==n.OPEN)return;ee.current+=1;let r=`s${ee.current}`,i=re.current;i!=null&&n.send(JSON.stringify({k:`search-cancel`,id:i.id})),h({id:r,key:t.key,rows:yg,complete:!0,scanned:0,running:!0}),n.send(JSON.stringify({k:`search`,id:r,query:e,...t.view.kind===`proc`?{procs:[t.view.id]}:t.view.procs==null?{}:{procs:t.view.procs}}))},vg);return()=>clearTimeout(t)},[f,s,i]);let E=m!=null&&m.key===i?m:null,ie=E==null?T:E.rows,ae=Yt({count:ie.length,getScrollElement:()=>x.current,estimateSize:()=>gg,overscan:20}),oe=(0,d.useRef)(t);oe.current=t;let D=(0,d.useCallback)(()=>{let e=S.current;w(_r(e.view,C.current,{keepProcs:oe.current,now:Date.now()}).rows)},[w]),O=(0,d.useRef)(0);(0,d.useEffect)(()=>{n<=O.current||(O.current=n,D())},[n,D]),(0,d.useEffect)(()=>{ae.measure()},[v,ae]),(0,d.useEffect)(()=>{E==null&&l&&ie.length>0&&ae.scrollToIndex(ie.length-1)},[ie.length,l,E,ae]);let se=ae.getVirtualItems(),k=(0,d.useMemo)(()=>se.map(e=>({item:e,row:ie[e.index]})),[se,ie]);return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:`nc-chrome`,style:{alignItems:`center`,borderBottom:`1px solid ${N.border}`,display:`flex`,flexWrap:`wrap`,gap:10,padding:`8px 14px`},children:[(0,M.jsx)(`span`,{style:{color:N.textEmphasis,fontSize:13,minWidth:0,overflowWrap:`anywhere`},children:e.kind===`proc`?e.id:`merged timeline`}),(0,M.jsx)(`span`,{style:{color:N.textMuted,fontSize:11},children:E==null?`${T.length} lines`:Sg(E)}),s!==`live`&&(0,M.jsx)(`span`,{role:`status`,style:{color:N.warning,fontSize:11},children:s===`connecting`?`opening the log lane…`:`log lane dropped — retrying…`}),(0,M.jsx)(`input`,{value:f,onChange:e=>p(e.target.value),placeholder:`search history…`,"aria-label":`search log history`,style:{background:N.surfaceHeader,border:`1px solid ${N.border}`,borderRadius:6,color:N.text,fontSize:12,padding:`3px 8px`}}),(0,M.jsx)(`span`,{style:{flex:1}}),(0,M.jsx)(`button`,{type:`button`,"aria-pressed":g,title:`prefix every line with its timestamp`,onClick:()=>_(e=>!e),style:Cg(g),children:`ts`}),(0,M.jsx)(`button`,{type:`button`,"aria-pressed":v,title:`wrap long lines`,onClick:()=>y(e=>!e),style:Cg(v),children:`wrap`}),(0,M.jsx)(`button`,{type:`button`,title:`clear the pane — keeps the last lines of what is still running; history stays searchable (c)`,onClick:D,style:Cg(!1),children:`clear`}),(0,M.jsxs)(`label`,{style:{color:N.textMeta,fontSize:12},children:[(0,M.jsx)(`input`,{type:`checkbox`,checked:l,disabled:E!=null,onChange:e=>u(e.target.checked)}),` `,`follow`]})]}),(0,M.jsxs)(`div`,{ref:x,onScroll:e=>{let t=e.currentTarget,n=t.scrollHeight-t.scrollTop-t.clientHeight<gg*2;u(n)},style:{flex:1,fontFamily:`ui-monospace, SFMono-Regular, Menlo, monospace`,fontSize:12,overflow:`auto`,padding:`6px 0`},children:[ie.length===0&&(0,M.jsx)(`div`,{style:{color:N.textMuted,fontSize:12,padding:`2px 12px`},children:xg(s,e,E)}),(0,M.jsx)(`div`,{style:{height:ae.getTotalSize(),position:`relative`,width:`100%`},children:k.map(({item:e,row:t})=>t==null?null:(0,M.jsxs)(`div`,{"data-index":e.index,ref:v?ae.measureElement:void 0,style:{...v?{}:{height:gg},left:0,position:`absolute`,top:0,transform:`translateY(${e.start}px)`,whiteSpace:v?`pre-wrap`:`pre`,width:`100%`,paddingLeft:12,color:t.gap?N.warning:void 0},children:[g&&t.ts!=null&&(0,M.jsxs)(`span`,{style:{color:N.textMuted},children:[wg(t.ts),` `]}),t.prefix!=null&&(0,M.jsxs)(`button`,{type:`button`,"aria-label":`show only ${t.prefix} in the log`,title:`show only ${t.prefix}`,onClick:()=>r(t.prefix??``),style:{background:`transparent`,border:`none`,color:fn(t.prefix),cursor:`pointer`,font:`inherit`,padding:0},children:[t.prefix,` │`,` `]}),t.gap?t.text:or(tr(t.text),{allowLoopback:b}).map((e,t)=>e.kind===`link`?(0,M.jsx)(`a`,{className:`nc-log-link`,href:e.href,target:`_blank`,rel:`noreferrer`,children:e.pieces.map((e,t)=>(0,M.jsx)(`span`,{style:e.style,children:e.text},t))},t):(0,M.jsx)(`span`,{style:e.style,children:e.text},t))]},t.key))})]})]})}function xg(e,t,n){return e===`connecting`?`opening the log lane…`:e===`reconnecting`?`the log lane dropped — retrying, then the tail resumes`:n==null?t.kind===`proc`?`${t.id} has printed nothing yet`:t.procs!=null&&t.procs.length===0?`nothing matches the current filter`:`no output yet`:n.running?`searching the history…`:`no matches in the daemon's history`}function Sg(e){let t=`${e.rows.length} match${e.rows.length===1?``:`es`}`;return e.running?`${t} · searching…`:e.complete?t:`${t} · stopped after ${e.scanned} lines`}function Cg(e){return{background:e?N.surfaceHeader:`transparent`,border:`1px solid ${N.border}`,borderRadius:5,color:e?N.textEmphasis:N.textMeta,cursor:`pointer`,fontSize:11,padding:`1px 7px`}}function wg(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}var Tg=`nice-commander:scheme`;function Eg(){try{let e=localStorage.getItem(Tg);return e===`dark`||e===`light`||e===`system`?e:null}catch{return null}}function Dg(e){try{localStorage.setItem(Tg,e)}catch{}}var Og=`nice-commander:rail-width`;function kg(e){return Math.min(780,Math.max(300,Math.round(e)))}function Ag(){try{let e=localStorage.getItem(Og),t=e==null?NaN:Number(e);return Number.isFinite(t)?kg(t):440}catch{return 440}}function jg(e){try{localStorage.setItem(Og,String(e))}catch{}}var Mg=`nice-commander:collapsed-tag-groups`;function Ng(){try{let e=JSON.parse(localStorage.getItem(Mg)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function Pg(e){try{localStorage.setItem(Mg,JSON.stringify(e.slice(-64)))}catch{}}var Fg=30*6e4,Ig={succeeded:N.success,stopped:N.textMuted,failed:N.error,crashed:N.error,timedOut:N.error};function Lg(e,t,n,r){let i=e.endedAt??n;if(i<t||e.startedAt>n)return null;let a=Math.max(e.startedAt,t),o=Math.min(i,n);return{left:(a-t)/r,width:Math.max(0,o-a)/r,live:e.endedAt==null,...e.outcome==null?{}:{outcome:e.outcome},startedAt:e.startedAt,...e.endedAt==null?{}:{endedAt:e.endedAt}}}function Rg(e,t,n=Fg){let r=t-n,i=[];for(let[a,o]of Object.entries(e)){let e=o.recentRuns.map(e=>Lg(e,r,t,n)).filter(e=>e!=null);if(e.length===0)continue;let s=e.some(e=>e.live),c=0;for(let t of e)c=Math.max(c,t.endedAt??t.startedAt);i.push({id:a,live:s,activityAt:c,segments:e})}return i.sort((e,t)=>e.live===t.live?t.activityAt-e.activityAt:e.live?-1:1)}function zg(e){let t=e.filter(e=>e.live).length,n=e.reduce((e,t)=>e+t.segments.length,0);return`${t} live · ${n} run${n===1?``:`s`} in window`}var Bg=6e4;function Vg(e,t){let n=new Date(e.startedAt),r=String(n.getHours()).padStart(2,`0`),i=String(n.getMinutes()).padStart(2,`0`),a=(e.endedAt??t)-e.startedAt,o=[`started ${r}:${i}`,Hg(a)];return e.live?o.push(`running`):e.outcome!=null&&o.push(e.outcome),o.join(` · `)}function Hg(e){if(e<Bg)return`${Math.max(1,Math.round(e/1e3))}s`;let t=Math.floor(e/Bg),n=Math.round(e%Bg/1e3);return t<60?n===0?`${t}m`:`${t}m ${n}s`:`${Math.floor(t/60)}h ${t%60}m`}var Ug=1e3,Wg=[30,20,10],Gg=.4;function Kg({processes:e,origins:t,selected:n,onToggle:r}){let[i,a]=(0,d.useState)(()=>Date.now()),[o,s]=(0,d.useState)(!1),[c,l]=(0,d.useState)(new Set);(0,d.useEffect)(()=>{let e=setInterval(()=>a(Date.now()),Ug);return()=>clearInterval(e)},[]);let u=(0,d.useMemo)(()=>Rg(e,i),[e,i]),f=(0,d.useMemo)(()=>u.filter(e=>e.live||!c.has(e.id)),[u,c]),p=u.length-u.filter(e=>e.live).length;return(0,M.jsxs)(`section`,{"aria-label":`run timeline, last 30 minutes`,className:`nc-chrome nc-timeline-float`,children:[(0,M.jsxs)(`div`,{style:{alignItems:`baseline`,display:`flex`,gap:8},children:[(0,M.jsx)(`span`,{className:`nc-section-title`,style:{marginBottom:0},children:`timeline`}),(0,M.jsx)(`span`,{style:{color:N.textMuted,fontSize:11},children:u.length===0?`no runs in the last 30 min`:zg(u)}),(0,M.jsx)(`span`,{style:{flex:1}}),p>0&&!o&&(0,M.jsx)(`button`,{type:`button`,title:`dismiss every ended run from the strip`,onClick:()=>l(e=>{let t=new Set(e);for(let e of u)e.live||t.add(e.id);return t}),style:Yg,children:`clear ended`}),(0,M.jsx)(`button`,{type:`button`,"aria-expanded":!o,title:o?`expand the timeline`:`collapse the timeline`,onClick:()=>s(e=>!e),style:Yg,children:o?`▸`:`▾`})]}),!o&&u.length>0&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{"aria-hidden":`true`,style:{display:`flex`,color:N.textMuted,fontSize:9,marginBottom:2},children:[(0,M.jsx)(`span`,{style:{flex:`0 0 148px`}}),(0,M.jsxs)(`span`,{style:{flex:1,display:`flex`,justifyContent:`space-between`},children:[Wg.map(e=>(0,M.jsxs)(`span`,{children:[`−`,e,`m`]},e)),(0,M.jsx)(`span`,{children:`now`})]})]}),(0,M.jsx)(`div`,{style:{maxHeight:176,overflowY:`auto`},children:f.map(e=>(0,M.jsx)(qg,{row:e,now:i,origin:t.get(e.id),selected:n.has(e.id),onToggle:r,onDismiss:e=>l(t=>{let n=new Set(t);return n.add(e),n})},e.id))})]})]})}function qg({row:e,now:t,origin:n,selected:r,onToggle:i,onDismiss:a}){return(0,M.jsxs)(`div`,{"data-timeline-row":e.id,style:{alignItems:`center`,borderRadius:4,display:`flex`,gap:6,height:20,...r?{background:dn(N.system,10),outline:`1px solid ${dn(N.system,45)}`}:{}},children:[(0,M.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),title:r?`${e.id} — selected; click to release`:e.id,"aria-pressed":r,style:{background:`transparent`,border:`none`,color:r?N.textEmphasis:fn(e.id),cursor:`pointer`,flex:`0 0 140px`,fontSize:11,fontWeight:r?600:400,minWidth:0,overflow:`hidden`,padding:0,textAlign:`left`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:[r?`› `:``,n!=null&&(0,M.jsxs)(`span`,{"aria-hidden":`true`,title:`started by the ${n} run`,className:`nc-origin`,children:[`▸`,` `]}),e.id]}),(0,M.jsx)(`div`,{style:{background:N.surfaceHeader,border:`1px solid ${N.border}`,borderRadius:4,flex:1,height:12,minWidth:0,position:`relative`},children:e.segments.map(n=>(0,M.jsx)(Jg,{id:e.id,segment:n,now:t,selected:r,onToggle:i},n.startedAt))}),!e.live&&(0,M.jsx)(`button`,{type:`button`,"aria-label":`remove ${e.id} from the timeline`,title:`dismiss this finished process from the strip (a fresh run brings it back)`,onClick:()=>a(e.id),style:Yg,children:`×`})]})}function Jg({id:e,segment:t,now:n,selected:r,onToggle:i}){let a=Math.max(t.width*100,Gg);return(0,M.jsx)(rt,{config:{title:e,content:Vg(t,n),align:`edge`},children:(0,M.jsx)(`span`,{className:t.live?`nc-run-live`:void 0,"data-run-of":e,"data-run-outcome":t.live?`live`:t.outcome??`unknown`,onClick:()=>i(e),style:{background:t.live?void 0:Ig[t.outcome??`stopped`],borderRadius:3,bottom:1,cursor:`pointer`,display:`block`,left:`${t.left*100}%`,opacity:t.live?.95:r?1:.75,outline:r?`1px solid ${dn(N.system,60)}`:void 0,overflow:`hidden`,position:`absolute`,top:1,width:`${a}%`}})})}var Yg={background:`transparent`,border:`none`,color:N.textMuted,cursor:`pointer`,fontSize:11,padding:`0 4px`};function Xg({node:e,compact:t=!1}){let n=yn(e);return(0,M.jsxs)(`span`,{"aria-hidden":`true`,title:n.label,"data-process-indicator":n.indicator,className:`nc-process-indicator nc-indicator-${n.indicator}${t?` nc-indicator-compact`:``}`,style:{color:vn[n.tone],...n.indicator===`running`?{background:vn[n.tone]}:{}},children:[n.indicator===`success`&&(0,M.jsx)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,children:(0,M.jsx)(`path`,{d:`m4 8 2.5 2.5L12 5`})}),n.indicator===`failure`&&(0,M.jsx)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,children:(0,M.jsx)(`path`,{d:`m5 5 6 6m0-6-6 6`})}),n.indicator===`warning`&&(0,M.jsx)(`span`,{children:`!`}),n.indicator===`idle`&&n.label===`stopped`&&(0,M.jsx)(`span`,{children:`−`})]})}function Zg({members:e,processes:t}){return(0,M.jsx)(`span`,{"aria-hidden":`true`,className:`nc-member-dots`,children:e.map(e=>{let n=t[e];return(0,M.jsx)(`span`,{style:{display:`inline-flex`,flexShrink:0},title:`${e}: ${n?.state??`not-started`}`,children:n!=null&&(0,M.jsx)(Xg,{node:n,compact:!0})},e)})})}function Qg({filters:e,rows:t,processes:n,activeId:r,onOpen:i,onPin:a,onRemove:o}){return e.length===0?(0,M.jsx)(M.Fragment,{}):(0,M.jsxs)(`section`,{"aria-label":`saved tag groups`,style:{marginBottom:10},children:[(0,M.jsx)(`div`,{className:`nc-section-title`,children:`saved`}),(0,M.jsx)(`div`,{className:`nc-saved`,children:e.map(e=>{let s=Fn(e,t).map(e=>e.id),c=s.length===0;return(0,M.jsxs)(`span`,{className:`nc-saved-chip`,"data-saved-filter":In(e),"data-active":e.id===r,"data-pinned":e.pinned,children:[(0,M.jsxs)(`button`,{type:`button`,disabled:c,onClick:()=>i(e),title:c?`${e.terms.join(` `)} — matches nothing in the current config`:`${e.mode}: ${e.terms.join(` `)}${e.pinned?``:` — recent run`}`,className:`nc-saved-open`,children:[(0,M.jsxs)(`span`,{style:{color:e.pinned?N.text:N.textMuted,textDecoration:c?`line-through`:`none`},children:[e.pinned?`★`:`↺`,` `,In(e)]}),!c&&(0,M.jsx)(Zg,{members:s,processes:n})]}),!e.pinned&&(0,M.jsx)(`button`,{type:`button`,"aria-label":`pin ${In(e)}`,title:`pin — keep for later sessions`,onClick:()=>a(e),className:`nc-saved-action`,children:`☆`}),(0,M.jsx)(`button`,{type:`button`,"aria-label":`remove ${In(e)}`,title:`remove`,onClick:()=>o(e),className:`nc-saved-action`,children:`×`})]},e.id)})})]})}function $g(e){return e<6e4?`${Math.round(e/1e3)}s`:e<36e5?`${Math.round(e/6e4)}m`:`${(e/36e5).toFixed(1)}h`}var e_={stopped:N.textMuted,partial:N.warning,starting:N.system,ready:N.success,failed:N.error};function t_({members:e,processes:t}){let n=Bn(e,t);if(n==null){let n=zn(e,t);return(0,M.jsx)(`span`,{style:{color:e_[n],fontSize:11,whiteSpace:`nowrap`},children:n})}let r=e=>n.filter(t=>t.verdict===e).length,[i,a,o,s]=[r(`fail`),r(`pass`),r(`blocked`),r(`stopped`)],c=r(`running`)>0,l=e.find(e=>bn(t[e]?.state??``));return(0,M.jsx)(`span`,{style:{color:i>0?N.error:o>0?N.warning:c||a===n.length?N.success:N.textMuted,fontSize:11,minWidth:0,overflowWrap:`anywhere`},children:i>0?`${i} failed`:c?`${a}/${n.length} · ${l??`running`}…`:o>0?`${o} blocked`:s>0?`${a}/${n.length} passed · ${s} stopped`:a===0?`pending`:`${a}/${n.length} passed`})}var n_={pass:N.success,fail:N.error,blocked:N.warning,running:N.system,skipped:N.textMuted,pending:N.border};function r_({state:e,selected:t,onSelect:n,bulk:r,now:i}){let a=Object.entries(e.suites);return a.length===0?(0,M.jsx)(M.Fragment,{}):(0,M.jsxs)(`section`,{"aria-label":`suites`,style:{marginBottom:10},children:[(0,M.jsx)(`div`,{className:`nc-section-title`,children:`suites`}),(0,M.jsx)(`div`,{className:`nc-suites`,children:a.map(([a,o])=>(0,M.jsx)(a_,{name:a,suite:o,run:e.runs[a],state:e,selected:a===t,onSelect:n,bulk:r,now:i},a))})]})}function i_(e,t,n){let r=e.members.map(e=>{let r=n.processes[e],i=t?.members[e];if(i!=null&&(t?.endedAt==null||r==null))return{id:e,verdict:i};let a=r==null?`idle`:yn(r).indicator;return{id:e,verdict:a===`success`||a===`running`?`pass`:a===`failure`?`fail`:a===`warning`?`blocked`:a===`transition`?`running`:`pending`}});return t?.endedAt==null?r:[...r].sort((e,t)=>Number(t.verdict===`fail`)-Number(e.verdict===`fail`))}function a_({name:e,suite:t,run:n,state:r,selected:i,onSelect:a,bulk:o,now:s}){let c=n!=null&&n.endedAt==null,l=t.members.every(e=>r.processes[e]?.kind===`task`),u=Mn(t.members,r.processes),d=n?.outcome===`failed`?Object.entries(n.members).filter(([,e])=>e===`fail`||e===`blocked`).map(([e])=>e):[],f=c?N.system:n?.outcome===`failed`?N.error:N.border;return(0,M.jsxs)(`div`,{"data-suite-card":e,className:`nc-suite-card`,"data-selected":i,style:{background:i?N.surfaceSelected:dn(N.system,7),border:`1px solid ${i?N.system:f}`},children:[(0,M.jsxs)(`div`,{style:{alignItems:`center`,display:`flex`,gap:8,minWidth:0},children:[(0,M.jsx)(`button`,{type:`button`,disabled:o.busy||c,"aria-label":`run suite ${e}`,title:c?`running…`:`run ${e} — ${t.members.length} members, ${t.parallel} at a time${t.failFast?`, stops at the first failure`:``}`,onClick:()=>o.run({suite:e}),className:`nc-suite-play`,children:c?`◼`:`▶`}),(0,M.jsxs)(`button`,{type:`button`,"aria-pressed":i,onClick:()=>a(e),title:t.description??`${e} — show members below`,className:`nc-suite-identity`,children:[(0,M.jsx)(`span`,{style:{color:N.textEmphasis,fontSize:13,fontWeight:600},children:e}),(0,M.jsxs)(`span`,{style:{color:N.textMuted,fontSize:11},children:[`(`,t.members.length,`)`]}),(0,M.jsx)(`span`,{style:{flex:1}}),(0,M.jsx)(t_,{members:t.members,processes:r.processes})]}),!l&&u.stops.length>0&&(0,M.jsx)(`button`,{type:`button`,disabled:o.busy,title:`stop ${u.stops.length}: ${u.stops.join(`, `)}`+(u.kept.length>0?` · leaves ${u.kept.join(`, `)} (still needed elsewhere)`:``),onClick:()=>void o.act(`stop`,t.members,{withDependencies:!0}),className:`nc-quiet-button`,children:`down`})]}),(0,M.jsx)(`div`,{className:`nc-suite-progress`,"aria-hidden":`true`,children:i_(t,n,r).map(e=>(0,M.jsx)(`span`,{title:`${e.id}: ${e.verdict}`,className:e.verdict===`running`?`nc-run-live`:void 0,style:{background:n_[e.verdict]??N.border}},e.id))}),n!=null&&(0,M.jsxs)(`div`,{className:`nc-suite-meta`,children:[(0,M.jsxs)(`span`,{children:[c?`running ${$g(s-n.startedAt)}`:`${n.outcome??`ended`} in ${$g((n.endedAt??s)-n.startedAt)}`,n.previousDurationMs!=null&&` · last ${$g(n.previousDurationMs)}`]}),d.length>0&&(0,M.jsxs)(`button`,{type:`button`,disabled:o.busy,onClick:()=>o.run({ids:d}),className:`nc-quiet-button`,children:[`rerun `,d.length,` failed`]})]})]})}function o_(e,t){let n=[],r=new Set([e]),i=(e,a)=>{for(let o of t[e]?.detail.dependsOn??[])r.has(o)||(r.add(o),n.push({id:o,depth:a,missing:t[o]==null}),i(o,a+1))};i(e,1);let a=[],o=new Set([e]),s=(e,n)=>{for(let[r,i]of Object.entries(t))!i.detail.dependsOn.includes(e)||o.has(r)||(o.add(r),a.push({id:r,depth:n,missing:!1}),s(r,n+1))};return s(e,1),n.length===0&&a.length===0?null:{needs:n,neededBy:a}}var s_={background:`transparent`,border:`1px solid ${N.border}`,borderRadius:5,color:N.textMeta,cursor:`pointer`,fontSize:11,padding:`3px 8px`};function c_({id:e,ports:t,retry:n}){let[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)(null);async function f(n,r){c(!0),u(null),o(null);try{i(await t({ids:[e],...n?{token:n,force:r}:{}}))}catch(e){u(e.message)}finally{c(!1)}}return(0,M.jsxs)(`div`,{style:{marginTop:6,fontSize:12},children:[(0,M.jsx)(`button`,{style:s_,type:`button`,disabled:s,onClick:()=>void f(),children:s?`checking ports…`:`inspect ports`}),l&&(0,M.jsx)(`div`,{role:`alert`,style:{color:N.error},children:l}),r&&(0,M.jsxs)(`section`,{"aria-label":`port owners for ${e}`,style:{overflowWrap:`anywhere`},children:[r.warnings.map(e=>(0,M.jsx)(`div`,{role:`alert`,style:{color:N.warning},children:e},e)),r.listeners.length===0&&(0,M.jsxs)(`div`,{children:[`No visible listeners found.`,` `,(0,M.jsx)(`button`,{style:s_,type:`button`,disabled:s,onClick:()=>void n(),children:`retry start`})]}),r.listeners.map(e=>(0,M.jsxs)(`div`,{style:{borderTop:`1px solid ${N.border}`,paddingTop:6,marginTop:6},children:[(0,M.jsxs)(`div`,{children:[e.endpoint,` · `,e.host,`:`,e.port,` · PID `,e.pid]}),(0,M.jsxs)(`div`,{children:[e.command,` · parent PID `,e.ppid??`unknown`]}),(0,M.jsxs)(`div`,{children:[`cwd: `,e.cwd??`unavailable`]}),(0,M.jsxs)(`div`,{children:[`identity: `,e.startStamp??`unavailable`]}),e.refusal?(0,M.jsx)(`div`,{children:e.refusal}):(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`button`,{style:s_,type:`button`,disabled:s,onClick:()=>o({listener:e,force:!1}),children:[`stop PID `,e.pid]}),` `,(0,M.jsxs)(`button`,{style:s_,type:`button`,disabled:s,onClick:()=>o({listener:e,force:!0}),children:[`force kill PID `,e.pid]})]})]},`${e.endpoint}:${e.pid}`))]}),a&&(0,M.jsxs)(`div`,{role:`alertdialog`,"aria-label":`Confirm listener termination`,style:{marginTop:8,color:N.warning,overflowWrap:`anywhere`},children:[(0,M.jsxs)(`p`,{children:[a.force?`Force kill`:`Stop`,` PID `,a.listener.pid,` (`,a.listener.command,`) holding `,a.listener.host,`:`,a.listener.port,`? This may affect other applications using this process.`,a.force?` Force kill does not allow cleanup.`:` Sends SIGTERM.`]}),(0,M.jsxs)(`button`,{style:s_,type:`button`,onClick:()=>void f(a.listener.token,a.force),children:[`confirm `,a.force?`force kill`:`stop`]}),` `,(0,M.jsx)(`button`,{style:s_,type:`button`,onClick:()=>o(null),children:`cancel`})]})]})}function l_({rows:e,processes:t,selected:n,onSelect:r,act:i,setEnv:a,ports:o,muted:s=!1,origins:c,roleOf:l,onHover:u}){return(0,M.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6},children:e.map(e=>(0,M.jsx)(u_,{row:e,processes:t,selected:n.has(e.id),onSelect:r,act:i,setEnv:a,ports:o,muted:s,origin:c.get(e.id),role:l(e.id),onHover:u},e.id))})}function u_({row:e,processes:t,selected:n,onSelect:r,act:i,setEnv:a,ports:o,muted:s,origin:c,role:l,onHover:u}){let[f,p]=(0,d.useState)(!1),{node:m}=e,h=m.startedAt!=null&&bn(m.state)?$g(Date.now()-m.startedAt):null,g=!bn(m.state)&&m.lastTask!=null?m.lastTask:null,_=o_(e.id,t),v=m.kind===`service`&&[`running`,`ready`,`unready`].includes(m.state);return(0,M.jsxs)(`div`,{"data-process-card":e.id,className:`nc-row`,"data-selected":n,"data-outcome":yn(m).indicator,"data-dep-role":l,"data-muted":s||void 0,onMouseEnter:()=>u(e.id),onMouseLeave:()=>u(null),onFocus:()=>u(e.id),onBlur:()=>u(null),style:{background:n?N.surfaceSelected:N.surface,border:`1px solid ${n?N.system:N.border}`,borderRadius:8,padding:`7px 12px`,position:`relative`},children:[(0,M.jsxs)(`div`,{style:{alignItems:`flex-start`,display:`flex`,gap:8,minWidth:0},children:[(0,M.jsxs)(`div`,{style:{alignItems:`center`,display:`flex`,flex:1,flexWrap:`wrap`,gap:8,minWidth:0},children:[(0,M.jsx)(d_,{id:e.id,deps:_,processes:t,row:e,selected:n,onSelect:r}),c!=null&&(0,M.jsxs)(`span`,{className:`nc-origin`,title:`started by the ${c} run`,children:[`▸ `,c]}),m.optIn&&(0,M.jsx)(`span`,{className:`nc-origin`,title:"opt-in — never started by a tag group, a suite's tag query, or `all`",children:`manual`}),e.chips.length>0&&(0,M.jsxs)(`span`,{title:e.chips.join(`
20
- `),style:{background:dn(N.warning,12),border:`1px solid ${dn(N.warning,35)}`,borderRadius:4,color:N.warning,cursor:`default`,flex:`0 0 auto`,fontSize:10,padding:`0 5px`},children:[`⚠ `,e.chips.length]}),e.stickyOverrides.length>0&&(0,M.jsx)(`span`,{title:`sticky: ${e.stickyOverrides.join(`, `)} — applies to every start until cleared`,style:{background:dn(N.warning,12),border:`1px solid ${dn(N.warning,35)}`,borderRadius:4,color:N.warning,flex:`0 0 auto`,fontSize:10,padding:`0 5px`},children:e.stickyOverrides.length===1?`1 sticky env override`:`${e.stickyOverrides.length} sticky env overrides`})]}),(0,M.jsx)(p_,{id:e.id,live:bn(m.state),processes:t,act:i,open:f,onToggleOpen:()=>p(e=>!e)})]}),v&&(0,M.jsx)(v_,{row:e}),(h!=null||g!=null||m.detail.dependsOn.length>0)&&(0,M.jsxs)(`div`,{style:{alignItems:`center`,color:N.textMuted,display:`flex`,fontSize:11,gap:8,marginTop:2,whiteSpace:`nowrap`},children:[(0,M.jsx)(h_,{id:e.id,processes:t,onSelect:r}),h!=null&&(0,M.jsxs)(`span`,{children:[`up `,h]}),g!=null&&(0,M.jsxs)(`span`,{children:[g.outcome,g.durationMs==null?``:` in ${$g(g.durationMs)}`,` · ${$g(Date.now()-g.endedAt)} ago`]})]}),e.stickyOverrides.length>0&&(0,M.jsx)(`div`,{style:{marginTop:4},children:(0,M.jsx)(`button`,{type:`button`,title:`clear ${e.stickyOverrides.join(`, `)} — back to the config's values`,onClick:()=>void a(e.id,Object.fromEntries(e.stickyOverrides.map(e=>[e,null]))),style:{...S_,color:N.warning,fontSize:10,padding:`1px 6px`},children:`clear all`})}),(0,M.jsx)(__,{row:e}),m.blockedBy!=null&&(0,M.jsx)(g_,{reason:m.blockedBy,processes:t,onSelect:r}),(f||!bn(m.state))&&m.detail.endpoints.some(e=>e.ownership===`exclusive`)&&(0,M.jsx)(c_,{id:e.id,ports:o,retry:()=>i(`start`,[e.id])}),f&&(0,M.jsxs)(M.Fragment,{children:[e.chips.length>0&&(0,M.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:4,marginTop:6},children:e.chips.map(e=>(0,M.jsx)(`span`,{style:{background:dn(N.warning,12),border:`1px solid ${dn(N.warning,35)}`,borderRadius:4,color:N.warning,fontSize:11,padding:`1px 6px`},children:e},e))}),!v&&(0,M.jsx)(v_,{row:e}),(0,M.jsx)(y_,{row:e,setEnv:a})]})]})}function d_({id:e,deps:t,processes:n,row:r,selected:i,onSelect:a}){let o=(0,M.jsxs)(`button`,{type:`button`,"aria-pressed":i,onClick:()=>a(e),style:{alignItems:`center`,background:`transparent`,border:`none`,color:`inherit`,cursor:`pointer`,display:`flex`,flex:`0 1 auto`,gap:8,minWidth:0,overflow:`hidden`,padding:0,textAlign:`left`},children:[(0,M.jsx)(Xg,{node:r.node}),(0,M.jsx)(`span`,{style:{color:N.textEmphasis,fontWeight:600,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e}),t!=null&&(0,M.jsx)(`span`,{"aria-hidden":`true`,style:{color:N.textMuted,fontSize:10},title:`has a dependency tree — hover to see it`,children:`⬦`}),(0,M.jsx)(`span`,{style:{color:N.textMeta,fontSize:12},children:yn(r.node).label}),(0,M.jsx)(`span`,{style:{color:N.textMuted,fontSize:11},children:r.node.kind})]});return t==null?o:(0,M.jsx)(rt,{config:{title:`${e} — dependency tree`,content:(0,M.jsx)(f_,{deps:t,processes:n,onSelect:a}),align:`edge`,maxWidth:320},children:o})}function f_({deps:e,processes:t,onSelect:n}){let r=e=>e.map(e=>(0,M.jsx)(`div`,{style:{paddingLeft:(e.depth-1)*12},children:e.missing?(0,M.jsxs)(`span`,{style:{color:N.textMuted,fontSize:11},children:[e.id,` (not in config)`]}):(0,M.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),title:`select ${e.id}`,style:{alignItems:`center`,background:`transparent`,border:`none`,color:N.text,cursor:`pointer`,display:`flex`,fontSize:11,gap:6,padding:`1px 0`},children:[t[e.id]&&(0,M.jsx)(Xg,{node:t[e.id],compact:!0}),e.id]})},e.id));return(0,M.jsxs)(`div`,{children:[e.needs.length>0&&(0,M.jsxs)(`div`,{style:{marginBottom:e.neededBy.length>0?6:0},children:[(0,M.jsx)(`div`,{style:{color:N.textMuted,fontSize:10,marginBottom:2},children:`needs`}),r(e.needs)]}),e.neededBy.length>0&&(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`div`,{style:{color:N.textMuted,fontSize:10,marginBottom:2},children:`needed by`}),r(e.neededBy)]})]})}function p_({id:e,live:t,processes:n,act:r,open:i,onToggleOpen:a}){let o=t?Mn([e],n):null,s=o?.stops.filter(t=>t!==e)??[];return(0,M.jsxs)(`span`,{className:`nc-row-actions`,children:[!t&&(0,M.jsx)(`button`,{type:`button`,"aria-label":`start`,title:`start`,onClick:()=>void r(`start`,[e]),children:`▶`}),t&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`button`,{type:`button`,"aria-label":`restart`,title:`restart — a ready dependency is left alone`,onClick:()=>void r(`restart`,[e]),children:`↻`}),(0,M.jsx)(`button`,{type:`button`,"aria-label":`stop`,title:`stop`,onClick:()=>void r(`stop`,[e]),children:`■`})]}),s.length>0&&(0,M.jsxs)(`button`,{type:`button`,"aria-label":`stop with dependencies`,"data-stop-with-dependencies":!0,title:`stop with dependencies — also stops ${s.join(`, `)}`+(o!=null&&o.kept.length>0?` · leaves ${o.kept.join(`, `)} (still needed elsewhere)`:``),onClick:()=>void r(`stop`,[e],{withDependencies:!0}),children:[`■`,(0,M.jsx)(`span`,{"aria-hidden":`true`,children:`↳`})]}),(0,M.jsx)(`button`,{type:`button`,"aria-label":i?`less`:`detail`,"aria-expanded":i,title:i?`hide detail`:`detail — command, endpoints, env`,onClick:a,children:i?`▴`:`▾`})]})}var m_=3;function h_({id:e,processes:t,onSelect:n}){let r=t[e]?.detail.dependsOn??[];return r.length===0?(0,M.jsx)(M.Fragment,{}):(0,M.jsxs)(`span`,{className:`nc-dep-dots`,"data-dependency-dots":e,children:[(0,M.jsx)(`span`,{"aria-hidden":`true`,children:`↳`}),r.slice(0,m_).map(e=>{let r=t[e];return(0,M.jsx)(`button`,{type:`button`,"aria-label":`dependency ${e}: ${r?.state??`not in config`}`,title:`needs ${e} — ${r?.state??`not in config`}`,onClick:()=>n(e),children:r==null?`?`:(0,M.jsx)(Xg,{node:r,compact:!0})},e)}),r.length>m_&&(0,M.jsxs)(`span`,{title:r.slice(m_).join(`, `),children:[`+`,r.length-m_]})]})}function g_({reason:e,processes:t,onSelect:n}){let r=/"([^"]+)"/.exec(e)?.[1];return r==null||t[r]==null?(0,M.jsx)(M.Fragment,{}):(0,M.jsxs)(`button`,{type:`button`,onClick:()=>n(r),title:e,style:{...S_,color:N.warning,fontSize:10,marginTop:4,padding:`1px 6px`},children:[`blocked by `,r,` →`]})}function __({row:e}){let t=e.node.detail.timeoutMs,n=e.node.startedAt;if(e.node.kind!==`task`||t==null||n==null||!bn(e.node.state))return(0,M.jsx)(M.Fragment,{});let r=Math.min(1,(Date.now()-n)/t);return(0,M.jsx)(`div`,{role:`progressbar`,"aria-label":`elapsed ${$g(Date.now()-n)} of ${$g(t)} cap`,"aria-valuenow":Math.round(r*100),"aria-valuemin":0,"aria-valuemax":100,style:{background:N.surfaceHeader,borderRadius:2,height:3,marginTop:5,overflow:`hidden`},children:(0,M.jsx)(`div`,{style:{background:r>.8?N.warning:N.system,height:`100%`,width:`${r*100}%`}})})}function v_({row:e}){let t=Rn(location.hostname),n=Ln(e.node,t);return n.length===0?(0,M.jsx)(M.Fragment,{}):(0,M.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:6,marginTop:6},children:n.map(e=>e.href==null?(0,M.jsxs)(`span`,{style:w_,title:e.remote?`bound on the daemon's machine — forward the port to reach it from here`:void 0,children:[e.label,e.remote?` (remote)`:``]},e.name):(0,M.jsxs)(`a`,{href:e.href,title:`${e.name} — ${e.href} (opens in a new tab)`,target:`_blank`,rel:`noreferrer`,style:{...w_,color:N.system},children:[e.label,` ↗`]},e.name))})}function y_({row:e,setEnv:t}){let{detail:n}=e.node;return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`dl`,{style:{display:`grid`,fontSize:11,gap:`2px 8px`,gridTemplateColumns:`auto minmax(0, 1fr)`,margin:`8px 0 0`},children:[e.node.pid!=null&&(0,M.jsx)(x_,{label:`pid`,value:String(e.node.pid)}),(0,M.jsx)(x_,{label:`run`,value:n.command}),(0,M.jsx)(x_,{label:`cwd`,value:n.cwd}),n.ready!=null&&(0,M.jsx)(x_,{label:`ready`,value:n.ready}),n.dependsOn.length>0&&(0,M.jsx)(x_,{label:`needs`,value:n.dependsOn.join(`, `)})]}),n.envVars.length>0&&(0,M.jsx)(b_,{row:e,setEnv:t})]})}function b_({row:e,setEnv:t}){let[n,r]=(0,d.useState)({}),[i,a]=(0,d.useState)(!1),o=e.node.detail.envVars,s=Object.keys(n).length>0,c=async()=>{a(!0);try{await t(e.id,n),r({})}finally{a(!1)}};return(0,M.jsxs)(`div`,{style:{borderTop:`1px solid ${N.border}`,marginTop:8,paddingTop:8},children:[(0,M.jsx)(`div`,{style:{color:N.textMuted,fontSize:11,marginBottom:6},children:`env`}),(0,M.jsx)(`div`,{style:{display:`grid`,gap:6},children:o.map(i=>(0,M.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6},children:[(0,M.jsxs)(`label`,{htmlFor:`env-${e.id}-${i.name}`,style:{color:N.textMeta,flex:`0 0 40%`,fontSize:11},title:i.description,children:[i.name,i.required&&(0,M.jsx)(`span`,{style:{color:N.error},children:` *`}),i.source===`override`&&(0,M.jsx)(`span`,{title:`sticky override — applies to every start until cleared`,style:{background:dn(N.warning,12),border:`1px solid ${dn(N.warning,35)}`,borderRadius:4,color:N.warning,fontSize:10,marginLeft:6,padding:`0px 5px`},children:`sticky`})]}),i.values==null?(0,M.jsx)(`input`,{id:`env-${e.id}-${i.name}`,type:i.secret?`password`:`text`,value:n[i.name]??(i.secret?``:i.value??``),placeholder:i.secret&&i.source!==`unset`?`•••• set`:i.source,onChange:e=>r(t=>({...t,[i.name]:e.target.value})),style:C_}):(0,M.jsx)(`select`,{id:`env-${e.id}-${i.name}`,value:n[i.name]??i.value??``,onChange:e=>r(t=>({...t,[i.name]:e.target.value})),style:C_,children:i.values.map(e=>(0,M.jsx)(`option`,{value:e,children:e},e))}),(0,M.jsx)(`button`,{type:`button`,disabled:i.source!==`override`,title:`drop the override, back to the config's value`,onClick:()=>void t(e.id,{[i.name]:null}),style:{...S_,opacity:i.source===`override`?1:.35},children:`clear`})]},i.name))}),(0,M.jsxs)(`div`,{style:{alignItems:`center`,display:`flex`,gap:8,marginTop:8},children:[(0,M.jsx)(`button`,{type:`button`,disabled:!s||i,onClick:()=>void c(),style:S_,children:i?`saving…`:`save`}),(0,M.jsx)(`span`,{style:{color:N.textMuted,fontSize:10},children:`sticky — applies to every start until cleared`})]})]})}function x_({label:e,value:t}){return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`dt`,{style:{color:N.textMuted},children:e}),(0,M.jsx)(`dd`,{style:{color:N.textMeta,margin:0,overflowWrap:`anywhere`},children:t})]})}var S_={background:`transparent`,border:`1px solid ${N.border}`,borderRadius:5,color:N.textMeta,cursor:`pointer`,fontSize:11,padding:`1px 8px`},C_={background:N.surfaceSection,border:`1px solid ${N.border}`,borderRadius:4,color:N.textEmphasis,flex:1,fontSize:11,minWidth:0,padding:`2px 5px`},w_={background:N.surfaceSection,border:`1px solid ${N.borderStrong}`,borderRadius:4,color:N.textMeta,fontSize:11,padding:`1px 6px`,textDecoration:`none`,maxWidth:`100%`,overflowWrap:`anywhere`},T_=3,E_=e=>e.join(`,`);function D_({groups:e,processes:t,runs:n,savedFilters:r,filterFor:i,focused:a,onFocus:o,collapsed:s,onCollapse:c,selected:l,onSelect:u,bulk:f,onPin:p,setEnv:m,ports:h}){let[g,_]=(0,d.useState)(null),v=(0,d.useMemo)(()=>{let e=g==null?null:o_(g,t);return g==null||e==null?null:{self:g,upstream:new Set(e.needs.map(e=>e.id)),downstream:new Set(e.neededBy.map(e=>e.id))}},[g,t]),y=e=>{if(v!=null)return e===v.self?`self`:v.upstream.has(e)?`upstream`:v.downstream.has(e)?`downstream`:`unrelated`},b=(0,d.useMemo)(()=>Pn(n),[n]);return e.length===0?(0,M.jsx)(`div`,{style:{color:N.textMuted,padding:8},children:`no processes match this filter`}):(0,M.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:10},children:e.map((n,d)=>{let g=E_(n.signature),v=s.get(g)??(n.signature.length>0&&d>=T_),x=i(n.signature),ee=(e,n)=>(0,M.jsx)(l_,{rows:e,processes:t,selected:l,onSelect:u,act:f.act,setEnv:m,ports:h,muted:n,origins:b,roleOf:y,onHover:_});return(0,M.jsxs)(`section`,{"data-tag-group":g,"aria-label":`tag group ${g||`all`}`,children:[(n.signature.length>0||e.length>1)&&(0,M.jsx)(O_,{group:n,processes:t,filter:x,pinned:x!=null&&r.some(e=>e.pinned&&e.mode===x.mode&&rn(e.terms,x.terms)&&rn(e.bucket??[],x.bucket??[])),focused:a!=null&&rn(a,n.signature),onFocus:()=>o(n.signature),collapsed:v,onCollapse:()=>c(g,!v),bulk:f,onPin:p}),!v&&(0,M.jsxs)(M.Fragment,{children:[ee(n.members,!1),n.optIn.length>0&&(0,M.jsx)(`div`,{style:{marginTop:6},children:ee(n.optIn,!0)})]})]},g)})})}function O_({group:e,processes:t,filter:n,pinned:r,focused:i,onFocus:a,collapsed:o,onCollapse:s,bulk:c,onPin:l}){let u=e.members.map(e=>e.id),d=u.length>0&&e.members.every(e=>e.node.kind===`task`),f=e.members.some(e=>bn(e.node.state)),p=jn(u,t),m=Nn(u,t),h=[`start ${p.starts.length}`,...p.alreadyRunning.length>0?[`already running ${p.alreadyRunning.length} (skipped)`]:[],...p.dependencies.length>0?[`+${p.dependencies.length} dependencies: ${p.dependencies.join(`, `)}`]:[]].join(` · `),g=e.signature.map(e=>e.slice(e.indexOf(`=`)+1));return(0,M.jsxs)(`div`,{className:`nc-tag-group-heading`,"data-focused":i,children:[(0,M.jsxs)(`div`,{style:{alignItems:`center`,display:`flex`,gap:6,minWidth:0},children:[(0,M.jsx)(`button`,{type:`button`,"aria-expanded":!o,"aria-label":o?`expand`:`collapse`,onClick:s,className:`nc-caret`,children:o?`▸`:`▾`}),(0,M.jsxs)(`button`,{type:`button`,"aria-pressed":i,onClick:a,title:`scope the log pane to this tag group`,className:`nc-tag-group-identity`,children:[e.signature.length===0?(0,M.jsx)(`span`,{style:{color:N.textMuted,fontSize:11},children:`untagged`}):e.signature.map(e=>(0,M.jsx)(`span`,{className:`nc-signature-chip`,title:e,children:e.slice(e.indexOf(`=`)+1)},e)),(0,M.jsxs)(`span`,{style:{color:N.textMuted,fontSize:11,flexShrink:0},children:[u.length,e.optIn.length>0&&` · +${e.optIn.length} manual`]})]}),(0,M.jsx)(`span`,{style:{flex:1}}),(0,M.jsx)(t_,{members:u,processes:t}),u.length>0&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`button`,{type:`button`,disabled:c.busy,title:h,"data-tag-group-run":!0,onClick:()=>c.run({ids:u,...n==null?{}:{filter:n}}),className:`nc-quiet-button`,children:d?`▶ run`:`▲ up`}),!d&&f&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`button`,{type:`button`,disabled:c.busy,title:`restart these — a ready dependency outside the group is left alone`,onClick:()=>void c.act(`restart`,u),className:`nc-quiet-button`,children:`↻`}),(0,M.jsx)(`button`,{type:`button`,disabled:c.busy,title:m.length>0?`stop — leaves live dependents degraded: ${m.join(`, `)}`:`stop these`,"data-warn":m.length>0||void 0,onClick:()=>void c.act(`stop`,u),className:`nc-quiet-button`,children:`▼`})]})]}),n!=null&&(0,M.jsx)(`button`,{type:`button`,"aria-label":r?`pinned`:`pin this tag group`,title:r?`pinned`:`pin — keep this tag group for later sessions`,disabled:r,onClick:()=>l(n,g.join(` · `)),className:`nc-quiet-button`,children:r?`★`:`☆`})]}),!o&&(0,M.jsxs)(`div`,{className:`nc-tag-group-sub`,children:[(0,M.jsx)(Zg,{members:u,processes:t}),p.dependencies.length>0&&(0,M.jsxs)(`span`,{title:`started first, because members depend on them`,children:[`also starts: `,p.dependencies.join(`, `)]})]})]})}function k_({rows:e,tags:t,mode:n,onMode:r,onToggle:i,onClear:a}){let o=(0,d.useMemo)(()=>En(e),[e]),s=(0,d.useMemo)(()=>kn(e,t,n),[e,t,n]);return o.length===0?(0,M.jsx)(M.Fragment,{}):(0,M.jsxs)(`section`,{"aria-label":`tags`,style:{marginBottom:10},children:[(0,M.jsxs)(`div`,{style:{alignItems:`baseline`,display:`flex`,gap:8,marginBottom:4},children:[(0,M.jsx)(`span`,{className:`nc-section-title`,children:`tags`}),(0,M.jsx)(`span`,{className:`nc-segmented`,"data-match-mode":n,children:[`any`,`all`].map(e=>(0,M.jsx)(`button`,{type:`button`,"aria-pressed":n===e,title:e===`any`?`any — every partial match, strict matches on top`:`all — only processes carrying every selected tag`,onClick:()=>r(e),children:e},e))}),(0,M.jsx)(`span`,{style:{flex:1}}),t.length>0&&(0,M.jsxs)(`button`,{type:`button`,onClick:a,title:`clear ${t.join(`, `)}`,style:{background:`transparent`,border:`none`,color:N.textMuted,cursor:`pointer`,fontSize:11,padding:0},children:[`× clear `,t.length]})]}),(0,M.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,maxHeight:160,overflowY:`auto`},children:o.map(e=>(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`div`,{style:{color:N.textMuted,fontSize:10,letterSpacing:.4,marginBottom:3,overflow:`hidden`,textOverflow:`ellipsis`,textTransform:`uppercase`,whiteSpace:`nowrap`},title:e.key,children:e.key}),(0,M.jsx)(`span`,{style:{display:`flex`,flexWrap:`wrap`,gap:4},children:e.values.map(n=>{let r=`${e.key}=${n}`,a=t.includes(r),o=s.get(r)??0;return(0,M.jsxs)(`button`,{type:`button`,"aria-pressed":a,title:`${r} — ${o} process${o===1?``:`es`}`,"data-tag-chip":r,onClick:()=>i(r),style:{background:a?N.system:N.surfaceHeader,border:`1px solid ${N.border}`,borderRadius:999,color:a?N.void:N.textMeta,cursor:`pointer`,fontSize:11,opacity:o===0&&!a?.45:1,padding:`1px 9px`,maxWidth:`100%`,minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:[n,(0,M.jsx)(`span`,{style:{fontSize:10,marginLeft:5,opacity:.7},children:o})]},n)})})]},e.key))})]})}var A_=(e,t)=>{let n=e.get(t);if(n==null||n===``)return;let r=n.split(`,`).filter(Boolean);return r.length>0?r:void 0};function j_(e){let t=new URLSearchParams(e.startsWith(`#`)?e.slice(1):e),n={},r=A_(t,`sel`);r!=null&&(n.selected=r);let i=A_(t,`tags`);i!=null&&(n.tags=i);let a=A_(t,`bucket`);a!=null&&(n.bucket=a);for(let e of[`suite`,`q`,`by`]){let r=t.get(e);r!=null&&r!==``&&(n[e]=r)}return t.get(`mode`)===`all`&&(n.mode=`all`),n}function M_(e){let t=new URLSearchParams;e.selected!=null&&e.selected.length>0&&t.set(`sel`,e.selected.join(`,`)),e.suite!=null&&e.suite!==``&&t.set(`suite`,e.suite),e.q!=null&&e.q!==``&&t.set(`q`,e.q),e.tags!=null&&e.tags.length>0&&t.set(`tags`,e.tags.join(`,`)),e.mode===`all`&&t.set(`mode`,`all`),e.bucket!=null&&e.bucket.length>0&&t.set(`bucket`,e.bucket.join(`,`)),e.by!=null&&e.by!==``&&t.set(`by`,e.by);let n=t.toString();return n===``?``:`#${n}`}function N_(){let[e,t]=(0,d.useState)({kind:`connecting`}),[n,r]=(0,d.useState)(null),[i]=(0,d.useState)(()=>j_(location.hash)),[a,o]=(0,d.useState)(i.tags??[]),[s,c]=(0,d.useState)(i.q??``),[l,u]=(0,d.useState)(i.selected??[]),[f,p]=(0,d.useState)(i.mode??`any`),[m,h]=(0,d.useState)(i.by??null),[g,_]=(0,d.useState)(i.bucket??null),[v,y]=(0,d.useState)(i.suite??null),[b,x]=(0,d.useState)(()=>new Map(Ng().map(e=>[e,!0]))),[ee,S]=(0,d.useState)(!1),[C,w]=(0,d.useState)(null),[T,te]=(0,d.useState)(null),[ne,re]=(0,d.useState)(null),[E,ie]=(0,d.useState)(0),[ae,oe]=(0,d.useState)({status:`connecting`,hasBeenLive:!1}),[D,O]=(0,d.useState)(!1),[se,k]=(0,d.useState)(!1),ce=(0,d.useRef)(!1),[le,ue]=(0,d.useState)(()=>{let e=document.documentElement.getAttribute(Ce);return e===`light`||e===`system`?e:`dark`}),[A,de]=(0,d.useState)(Ag),fe=(0,d.useRef)(null);(0,d.useEffect)(()=>{fe.current?.style.setProperty(`--nc-rail-w`,`${A}px`)},[A]);let pe=(0,d.useRef)(null),me=(0,d.useRef)([]),he=(0,d.useRef)(null),ge=(0,d.useRef)([]),_e=(0,d.useRef)([]),ve=(0,d.useRef)(null),ye=(0,d.useRef)(!1),be=(0,d.useRef)(null);(0,d.useEffect)(()=>{let e=!1,n=null;return mg().then(i=>{if(e){i.dispose();return}n=i,t({kind:`live`,session:i}),r(i.realm.store.state),i.realm.store.subscribe(()=>r({...i.realm.store.state})),oe({status:i.realm.status,hasBeenLive:i.realm.hasBeenLive}),i.realm.subscribeStatus((e,t)=>oe({status:e,hasBeenLive:t.hasBeenLive}))},n=>{e||t({kind:`lost`,message:n.message})}),()=>{e=!0,n?.dispose()}},[]);let[xe,Se]=(0,d.useState)(()=>Date.now());(0,d.useEffect)(()=>{let e=setInterval(()=>Se(Date.now()),5e3);return()=>clearInterval(e)},[]),(0,d.useEffect)(()=>{let e=n?.configName;e!=null&&(document.title=`${e} · nice-commander`)},[n?.configName]);let Te=(0,d.useMemo)(()=>n==null?[]:Cn(n,xe),[n,xe]),Ee=(0,d.useMemo)(()=>{if(v==null)return Te;let e=n?.suites[v]?.members;return e==null?Te:wn(Te,e)},[Te,n,v]),De=(0,d.useMemo)(()=>An(Ee,a,f,s),[Ee,a,f,s]),Oe=(0,d.useMemo)(()=>En(Te).map(e=>e.key),[Te]),ke=(0,d.useMemo)(()=>On(De,a,f,v==null?m:null),[De,a,f,m,v]),Ae=(0,d.useMemo)(()=>g==null?void 0:ke.find(e=>rn(e.signature,g)),[ke,g]),je=(0,d.useMemo)(()=>new Set(Te.filter(e=>bn(e.node.state)).map(e=>e.id)),[Te]);(0,d.useEffect)(()=>{v!=null&&n!=null&&n.suites[v]==null&&y(null)},[n,v]);let Me=(0,d.useMemo)(()=>l.length===1?{kind:`proc`,id:l[0]}:l.length>1?{kind:`merged`,procs:[...l].sort()}:Ae==null?{kind:`merged`,procs:a.length>0||s.trim()!==``||v!=null?De.map(e=>e.id).sort():null}:{kind:`merged`,procs:Ae.members.map(e=>e.id).sort()},[l,a,s,De,v,Ae]),Ne=(0,d.useCallback)(async(t,n,r)=>{if(!(e.kind!==`live`||ce.current||n.length===0)){te(t),re(null);try{let{results:i,warnings:a}=await e.session.control(t,n,r),o=i.filter(e=>e.outcome===`failed`||e.outcome===`blocked`),s=t===`start`?i.filter(e=>e.outcome===`spawned`):[],c=[s.length>0?`${t}: ${i.length} process(es), ${s.length} running — the grid shows progress`:`${t}: ${i.length} process(es)`,...o.map(e=>`✗ ${e.id} — ${e.outcome}${e.reason==null?``:`: ${e.reason}`}`),...a.map(e=>`⚠ ${e}`)];re(c.join(`
19
+ `,n=0;for(let r of e.issues)n++,r.path==null||r.path.length===0?t+=` (issue ${n}) ${r.message}\n`:t+=` (issue ${n}) [${Tl(r.path)}]: ${r.message}\n`;return t};ue.createChildDomain({domain:`err_validation`,defaultHttpStatusCode:wl.BAD_REQUEST,schema:{standard_schema:k({message:({issues:e})=>El({issues:e})})}});var Dl=function(e){return e.payload=`payload`,e.ack=`ack`,e.none=`none`,e}({}),Ol=function(e){return e.none=`none`,e.session=`session`,e.persisted=`persisted`,e}({}),kl=class{_errorDeclarations=[];inputOptions;outputOptions;_responseMode;_reliabilityTier=`none`;get inputSchema(){return this.inputOptions?.schema}get outputSchema(){return this.outputOptions?.schema}get responseMode(){return this._responseMode==null?this.outputOptions==null?`ack`:`payload`:this._responseMode}ack(){return this._responseMode=`ack`,this}fireAndForget(){return this._responseMode=`none`,this}get reliabilityTier(){return this._reliabilityTier}reliable(e){return this._reliabilityTier=e?.persist===!0?`persisted`:`session`,this}input(e){return this.inputOptions=e,this}output(e){return this.outputOptions=e,this}throws(e,t){return this._errorDeclarations.push({_domain:e,_ids:t}),this}isExpectedError(e){return this._errorDeclarations.some(t=>t._domain.isExact(e)&&(t._ids==null||t._ids.some(t=>e.hasId(t))))}serializeInput(e){return this.inputOptions?.serialization?this.inputOptions.serialization.serialize(e):e}deserializeInput(e){return this.inputOptions?.serialization?this.inputOptions.serialization.deserialize(e):e}validateInput(e,t){if(this.inputOptions?.schema==null)return e;let n=this.inputOptions.schema[`~standard`].validate(e);if(n instanceof Promise)throw q.fromId(K.action_input_validation_promise,{domain:t.domain,actionId:t.actionId});if(n.issues!=null)throw q.fromId(K.action_input_validation_failed,{domain:t.domain,actionId:t.actionId,validationMessage:El(n)});return n.value}validateOutput(e,t){if(this.outputOptions?.schema==null)return e;let n=this.outputOptions.schema[`~standard`].validate(e);if(n instanceof Promise)throw q.fromId(K.action_output_validation_promise,{domain:t.domain,actionId:t.actionId});if(n.issues!=null)throw q.fromId(K.action_output_validation_failed,{domain:t.domain,actionId:t.actionId,validationMessage:El(n)});return n.value}serializeOutput(e){return this.outputOptions?.serialization?this.outputOptions.serialization.serialize(e):e}deserializeOutput(e){return this.outputOptions?.serialization?this.outputOptions.serialization.deserialize(e):e}},Al=()=>new kl;function jl(){return Error().stack}var Ml={},Nl=globalThis.process||{env:Ml},Pl=Nl!==void 0&&Nl.env&&Nl.env.NODE_ENV||void 0,Fl=[[`claude`,[`CLAUDECODE`,`CLAUDE_CODE`]],[`replit`,[`REPL_ID`]],[`gemini`,[`GEMINI_CLI`]],[`codex`,[`CODEX_SANDBOX`,`CODEX_THREAD_ID`]],[`opencode`,[`OPENCODE`]],[`pi`,[Il(`PATH`,/\.pi[\\/]agent/)]],[`auggie`,[`AUGMENT_AGENT`]],[`goose`,[`GOOSE_PROVIDER`]],[`devin`,[Il(`EDITOR`,/devin/)]],[`cursor`,[`CURSOR_AGENT`]],[`kiro`,[Il(`TERM_PROGRAM`,/kiro/)]]];function Il(e,t){return()=>{let n=Ml[e];return n?t.test(n):!1}}function J(){let e=Ml.AI_AGENT;if(e)return{name:e.toLowerCase()};for(let[e,t]of Fl)for(let n of t)if(typeof n==`string`?Ml[n]:n())return{name:e};return{}}var Ll=J();Ll.name,Ll.name;var Y=[[`APPVEYOR`],[`AWS_AMPLIFY`,`AWS_APP_ID`,{ci:!0}],[`AZURE_PIPELINES`,`SYSTEM_TEAMFOUNDATIONCOLLECTIONURI`],[`AZURE_STATIC`,`INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN`],[`APPCIRCLE`,`AC_APPCIRCLE`],[`BAMBOO`,`bamboo_planKey`],[`BITBUCKET`,`BITBUCKET_COMMIT`],[`BITRISE`,`BITRISE_IO`],[`BUDDY`,`BUDDY_WORKSPACE_ID`],[`BUILDKITE`],[`CIRCLE`,`CIRCLECI`],[`CIRRUS`,`CIRRUS_CI`],[`CLOUDFLARE_PAGES`,`CF_PAGES`,{ci:!0}],[`CLOUDFLARE_WORKERS`,`WORKERS_CI`,{ci:!0}],[`GOOGLE_CLOUDRUN`,`K_SERVICE`],[`GOOGLE_CLOUDRUN_JOB`,`CLOUD_RUN_JOB`],[`CODEBUILD`,`CODEBUILD_BUILD_ARN`],[`CODEFRESH`,`CF_BUILD_ID`],[`DRONE`],[`DRONE`,`DRONE_BUILD_EVENT`],[`DSARI`],[`GITHUB_ACTIONS`],[`GITLAB`,`GITLAB_CI`],[`GITLAB`,`CI_MERGE_REQUEST_ID`],[`GOCD`,`GO_PIPELINE_LABEL`],[`LAYERCI`],[`JENKINS`,`JENKINS_URL`],[`HUDSON`,`HUDSON_URL`],[`MAGNUM`],[`NETLIFY`],[`NETLIFY`,`NETLIFY_LOCAL`,{ci:!1}],[`NEVERCODE`],[`RENDER`],[`SAIL`,`SAILCI`],[`SEMAPHORE`],[`SCREWDRIVER`],[`SHIPPABLE`],[`SOLANO`,`TDDIUM`],[`STRIDER`],[`TEAMCITY`,`TEAMCITY_VERSION`],[`TRAVIS`],[`VERCEL`,`NOW_BUILDER`],[`VERCEL`,`VERCEL`,{ci:!1}],[`VERCEL`,`VERCEL_ENV`,{ci:!1}],[`APPCENTER`,`APPCENTER_BUILD_ID`],[`CODESANDBOX`,`CODESANDBOX_SSE`,{ci:!1}],[`CODESANDBOX`,`CODESANDBOX_HOST`,{ci:!1}],[`STACKBLITZ`],[`STORMKIT`],[`CLEAVR`],[`ZEABUR`],[`CODESPHERE`,`CODESPHERE_APP_ID`,{ci:!0}],[`RAILWAY`,`RAILWAY_PROJECT_ID`],[`RAILWAY`,`RAILWAY_SERVICE_ID`],[`DENO-DEPLOY`,`DENO_DEPLOY`],[`DENO-DEPLOY`,`DENO_DEPLOYMENT_ID`],[`FIREBASE_APP_HOSTING`,`FIREBASE_APP_HOSTING`,{ci:!0}],[`EDGEONE_PAGES`,`EO_PAGES_CI`,{ci:!0}]];function X(){for(let e of Y)if(Ml[e[1]||e[0]])return{name:e[0].toLowerCase(),...e[2]};return Ml.SHELL===`/bin/jsh`&&Nl.versions?.webcontainer?{name:`stackblitz`,ci:!1}:{name:``,ci:!1}}var Rl=X();Rl.name;var zl=Nl.platform||``;Ml.CI||Rl.ci;var Bl=!!Nl.stdout?.isTTY;Ml.DEBUG,Pl===`test`||Ml.TEST,Pl===`production`||Ml.MODE,Pl===`dev`||Pl===`development`||Ml.MODE,Ml.MINIMAL;var Vl=/^win/i.test(zl);/^linux/i.test(zl),/^darwin/i.test(zl),!Ml.NO_COLOR&&(Ml.FORCE_COLOR||(Bl||Vl)&&Ml.TERM);var Hl=(Nl.versions?.node||``).replace(/^v/,``)||null;Number(Hl?.split(`.`)[0]);var Ul=!!Nl?.versions?.node,Wl=`Bun`in globalThis,Gl=`Deno`in globalThis,Kl=`fastly`in globalThis,ql=`Netlify`in globalThis,Jl=`EdgeRuntime`in globalThis,Yl=globalThis.navigator?.userAgent===`Cloudflare-Workers`,Xl=[[ql,`netlify`],[Jl,`edge-light`],[Yl,`workerd`],[Kl,`fastly`],[Gl,`deno`],[Wl,`bun`],[Ul,`node`]];function Zl(){let e=Xl.find(e=>e[0]);if(e)return{name:e[1]}}var Ql=Zl()?.name||``,$l=()=>({assumed:!0,runtimeName:Ql}),eu=e=>Sl(e)&&`progress`in e&&e.form===ll.data&&e.type===G.progress,tu=e=>Sl(e)&&e.form===ll.data&&e.type===G.request;function nu(e){return tu(e)||Cl(e)||eu(e)}var ru=function(e){return e.peer=`peer`,e.local=`local`,e}({}),iu=[];function au(e){iu.push(e)}function ou(){iu.pop()}function su(){return iu[iu.length-1]}var cu=q.createChildDomain({domain:`err_nice_external_client`,schema:{}}),lu=function(e){return e.timeout=`timeout`,e.not_found=`not_found`,e.unsupported=`unsupported`,e.initialization_failed=`initialization_failed`,e.send_failed=`send_failed`,e.invalid_action_response=`invalid_action_response`,e.reliable_outbox_overflow=`reliable_outbox_overflow`,e.reliable_delivery_abandoned=`reliable_delivery_abandoned`,e.reliable_stream_closed=`reliable_stream_closed`,e}({}),uu=cu.createChildDomain({domain:`err_nice_transport`,schema:{timeout:k({message:({timeout:e})=>`ActionConnect transport timed out after ${e}ms.`}),not_found:k({message:({actionId:e})=>`No connected transport found for action "${e}".`}),unsupported:k({message:({transportShapes:e})=>`${e.length} Transport(s) [${e.join(`, `)}] found but returned "unsupported" status.`}),initialization_failed:k({message:({actionId:e,cause:t,endpoint:n})=>{let r=`Could not connect any transport for action "${e}"${n==null?``:` against ${n}`}`;return t==null?`${r} (all transports failed to initialize).`:`${r}: ${t}${t.endsWith(`.`)?``:`.`}`}}),send_failed:k({message:({actionId:e,httpStatusCode:t,message:n})=>`Failed to send action "${e}" [${t??`Unknown status`}]: ${n??`Unknown error`}.`,httpStatusCode:({httpStatusCode:e})=>e??500}),invalid_action_response:k({message:({actionId:e})=>`Invalid action response JSON structure for action "${e}"`}),reliable_outbox_overflow:k({message:({actionId:e,maxUnacked:t})=>`Reliable outbox for action "${e}" exceeded its unacked window (${t}) — the peer is not acknowledging. Send rejected to bound memory.`}),reliable_delivery_abandoned:k({message:({actionId:e,timeout:t})=>`Reliable action "${e}" was abandoned: not acknowledged within its ${t}ms delivery deadline (or swept with an aborted earlier frame on its stream). The stream skips past it and continues.`}),reliable_stream_closed:k({message:({actionId:e,streamId:t})=>`Reliable action "${e}" was abandoned because its stream ("${t}") was closed (closeReliableStream) while the send was still unacknowledged.`})}}),du=class extends Lr{constructor(e){super(e,{unsupported:e=>uu.fromId(lu.unsupported,{transportShapes:e}),notFound:e=>uu.fromId(lu.not_found,{actionId:e.action==null?`connect()`:e.action.id}),initializationFailed:(e,t)=>uu.fromId(lu.initialization_failed,{actionId:e.action==null?`connect()`:e.action.id,cause:t.cause,endpoint:t.endpoint,kind:t.kind}).withOriginError(t.origin)})}},fu=class{_domains=new Map;assertCanAddDomain(e){let t=this._domains.get(e.domain);if(!(t===e||t==null)&&t!=null)throw q.fromId(K.domain_name_collision,{domain:e.domain,existingParentDomains:t.allDomains,incomingParentDomains:e.allDomains})}addDomain(e){this.assertCanAddDomain(e),this._domains.set(e.domain,e)}removeDomain(e){this._domains.get(e.domain)===e&&this._domains.delete(e.domain)}getDomains(){return[...this._domains.values()]}verifyIsActionJson(e){if(typeof e.domain!=`string`||typeof e.id!=`string`)throw q.fromId(K.wire_not_action_data)}getActionDomain(e){this.verifyIsActionJson(e);let t=this._domains.get(e.domain);if(t)return t}getActionDomainOrThrow(e){this.verifyIsActionJson(e);let t=this._domains.get(e.domain);if(!t)throw q.fromId(K.domain_no_handler,{domain:e.domain});return t}hydrateActionPayload(e){return this.getActionDomainOrThrow(e).hydrateAnyAction(e)}},pu=function(e){return e.runtime_to_handler=`runtime_to_handler`,e.handler_route=`handler_route`,e}({}),mu=class{domainManager=new fu;actionRouteData=new Map;_context;constructor(e){this._context=e}mergeRouter(e){for(let t of e.getDomains())this.domainManager.addDomain(t);for(let[t,n]of e.actionRouteData.entries())this.actionRouteData.set(t,[...n])}addDomainsFromOther(e){for(let t of e.getDomains())this.domainManager.assertCanAddDomain(t);for(let t of e.getDomains())this.domainManager.addDomain(t)}getRouteDataEntriesForAction(e){let t=`dom[${e.domain}]id[${e.id}]`,n=`dom[${e.domain}]id[_]`;return[...this.actionRouteData.get(t)??[],...this.actionRouteData.get(n)??[]]}getRouteDataForAction(e){return this.getRouteDataEntriesForAction(e)[0]}throwNoHandlerForAction(e,t){throw this._context.contextType===pu.handler_route?q.fromId(K.no_action_execution_handler,{domain:e.domain,actionId:e.id,specifiedClient:t.targetLocalRuntime?.coordinate}):this._context.contextType===pu.runtime_to_handler?q.fromId(K.no_action_execution_handler,{domain:e.domain,actionId:e.id,specifiedClient:this._context.runtime.coordinate}):q.fromId(K.no_action_execution_handler,{domain:e.domain,actionId:e.id})}getRouteDataEntriesForActionOrThrow(e,t){let n=this.getRouteDataEntriesForAction(e);return n.length===0&&this.throwNoHandlerForAction(e,t),n}getRouteDataForActionOrThrow(e,t){let n=this.getRouteDataForAction(e);return n||this.throwNoHandlerForAction(e,t),n}getForKey(e){return this.actionRouteData.get(e)??[]}getRegisteredKeys(){return[...this.actionRouteData.keys()]}getDomains(){return this.domainManager.getDomains()}forDomain(e,t){return this.domainManager.addDomain(e),this.actionRouteData.set(`dom[${e.domain}]id[_]`,[t]),this}forAction(e,t){return this.forActionId(e._domain,e.id,t)}forActionId(e,t,n){return this.domainManager.addDomain(e),this.actionRouteData.set(`dom[${e.domain}]id[${t}]`,[n]),this}forActionIds(e,t,n){this.domainManager.addDomain(e);for(let r of t)this.forActionId(e,r,n);return this}forDomainActionCases(e,t){this.domainManager.addDomain(e);for(let n of Object.keys(t)){let r=t[n];r!=null&&this.actionRouteData.set(`dom[${e.domain}]id[${n}]`,[r])}return this}addForDomain(e,t){return this.domainManager.addDomain(e),this._push(`dom[${e.domain}]id[_]`,t),this}addForAction(e,t,n){return this.domainManager.addDomain(e),this._push(`dom[${e.domain}]id[${t}]`,n),this}addForActionIds(e,t,n){this.domainManager.addDomain(e);for(let r of t)this.addForAction(e,r,n);return this}addForDomainActionCases(e,t){this.domainManager.addDomain(e);for(let n of Object.keys(t)){let r=t[n];r!=null&&this._push(`dom[${e.domain}]id[${n}]`,r)}return this}addForKey(e,t){return this._push(e,t),this}removeRouteData(e){for(let[t,n]of this.actionRouteData){let r=n.filter(t=>t!==e);r.length===0?this.actionRouteData.delete(t):r.length!==n.length&&this.actionRouteData.set(t,r)}let t=[...this.actionRouteData.keys()];for(let e of this.domainManager.getDomains()){let n=`dom[${e.domain}]id[`;t.some(e=>e.startsWith(n))||this.domainManager.removeDomain(e)}}_push(e,t){let n=this.actionRouteData.get(e);n==null?this.actionRouteData.set(e,[t]):n.push(t)}},hu=class{_cuid;get cuid(){return this._cuid??=Ya(),this._cuid}getActionRouter(){return this.actionRouter}},gu=class extends hu{peer;handlerType=ru.peer;actionRouter=new mu({contextType:pu.handler_route,handler:this});_incomingRuntime;_incomingActionDataListener;constructor(e){super(),this.peer=e}get peerClient(){return this.peer}forDomain(e){return this.actionRouter.forDomain(e,!0),this}forAction(e){return this.actionRouter.forAction(e,!0),this}forActionIds(e,t){return this.actionRouter.forActionIds(e,t,!0),this}_setIncomingActionDataListener(e,t){if(this._incomingRuntime!=null&&this._incomingRuntime!==e)throw q.fromId(K.peer_handler_already_bound);return this._incomingRuntime=e,this._incomingActionDataListener=t,()=>{this._incomingRuntime!==e||this._incomingActionDataListener!==t||(this._incomingRuntime=void 0,this._incomingActionDataListener=void 0)}}_emitIncoming(e,t){this._incomingActionDataListener?.(e,t)}ownsLiveConnectionFor(e){return!1}clearTransportCache(){}},_u=1024,vu=class{_streams=new Map;_overflowed=new Set;_maxUnacked;_onOverflow;constructor(e){this._maxUnacked=e?.maxUnackedPerStream??_u,this._onOverflow=e?.onOverflow}get maxUnackedPerStream(){return this._maxUnacked}_stream(e){let t=this._streams.get(e);return t??(t={nextSeq:0,ackedSeq:-1,unacked:new Map},this._streams.set(e,t)),t}prepare(e,t,n,r){let i=this._stream(e);if(i.unacked.size>=this._maxUnacked)return this._overflowed.has(e)||(this._overflowed.add(e),this._onOverflow?.(e)),null;let a=i.nextSeq++,o=n==null?{streamId:e,seq:a}:{streamId:e,seq:a,streamKey:n};return i.unacked.set(a,{seq:a,preparedAt:Date.now(),reliability:o,dispatch:t,onDrop:r?.onDrop,onAck:r?.onAck}),{reliability:o}}ack(e,t){let n=this._streams.get(e);if(n==null||t<=n.ackedSeq)return[];n.ackedSeq=t;let r=[];for(let e of n.unacked.values())e.seq<=t&&r.push(e);for(let e of r)n.unacked.delete(e.seq);n.unacked.size<this._maxUnacked&&this._overflowed.delete(e);for(let e of r)e.onAck?.();return r}dropThrough(e,t,n){let r=this._streams.get(e);if(r==null)return[];let i=[];for(let e of r.unacked.values())e.seq<=t&&i.push(e);for(let e of i)r.unacked.delete(e.seq);t>r.ackedSeq&&(r.ackedSeq=t),r.unacked.size<this._maxUnacked&&this._overflowed.delete(e);for(let e of i)e.onDrop?.(n);return i}pending(e){return[...this._streams.get(e)?.unacked.values()??[]]}pendingCount(e){return this._streams.get(e)?.unacked.size??0}oldestPreparedAt(e){let t=this._streams.get(e);if(t!=null)for(let e of t.unacked.values())return e.preparedAt}highestSeq(e){let t=this._streams.get(e);if(!(t==null||t.nextSeq===0))return t.nextSeq-1}allPending(){let e=[];for(let t of this._streams.values())e.push(...t.unacked.values());return e}resendAll(){for(let e of this.allPending())e.dispatch()}resync(e){let t=this._streams.get(e);if(t==null||t.unacked.size===0)return;let n=[...t.unacked.values()],r=new Map;n.forEach((e,t)=>{e.seq=t,e.reliability.seq=t,r.set(t,e)}),t.unacked=r,t.ackedSeq=-1,t.nextSeq=n.length;for(let e of r.values())e.dispatch()}get size(){let e=0;for(let t of this._streams.values())e+=t.unacked.size;return e}},yu=6e4,bu=1e3,xu=class extends gu{_connectionIdentity;_defaultTimeout;_reliableTimeout;_wire;get canPush(){return this._wire.canPush}get localCoordinate(){return this._wire.localCoordinate}get securityLevel(){return this._wire.securityLevel}get wireMux(){return this._wire.wireMux}get requestReconnect(){return this._wire.requestReconnect}get debug(){return this._wire.debug}_outbox=new vu;_resendHooked=new WeakSet;_deliveryDeadlines=new WeakMap;_streamSkips=new Map;_streamCloses=new Map;_controlMethods;_reliableEventListeners=new Set;constructor({peer:e,runtimeCoordinate:t,transports:n,defaultTimeout:r,reliableActionTimeout:i,wireMux:a,localCoordinate:o,connectionIdentity:s,securityLevel:c,reconnect:l,keepLinkAlive:u}){super(e??t),this._connectionIdentity=s,this._defaultTimeout=r??1e4,this._reliableTimeout=i??yu,this._wire=new So({createManager:e=>new du(e),mux:a,peer:this.peer,localCoordinate:s??o,securityLevel:c,canPush:n.some(e=>e.type===br.duplex),reconnect:l??u,buildConnectInput:e=>e,defaultLocalCoordinate:()=>Su.getDefault().coordinate});for(let e of n){let t=e._createConnection({resolvers:{onIncomingActionDataJson:(e,t)=>{t?.ack!=null&&this._applyAck($c(this.peer,e.domain,e.id,t.streamKey),t.ack),this._emitIncoming(e)},onControlMessage:e=>{let t=$c(this.peer,e.domain,e.id,e.k);e.$c===`rack`?this._applyAck(t,e.ack):e.$c===`rsync`&&(this._streamSkips.delete(t),this._outbox.resync(t))}}});t.definition=e,this._wire.addTransport(t)}}async connect(e){await this._wire.connect({localCoordinate:this._connectionIdentity??e?.targetLocalRuntime?.coordinate})}reconnectLink(){return this._wire.reconnectLink()}dispose(){this._wire.dispose()}async handleActionRequest(e,t){let n=t?.targetLocalRuntime??Su.getDefault(),r=this._connectionIdentity??n.coordinate;this._connectionIdentity!=null&&e.context._setOriginClient(this._connectionIdentity);let i=t?.timeout??this._defaultTimeout,a=su(),o=n._captureActionCallSite(e,t?.captureCallSites),s={action:e,localClient:r,externalClient:this.peer},c=this._wire.getPreferredTransport(),l=c==null?void 0:{runtime:r,handler:this.toHandlerRouteItem(c,s),time:Date.now()};l!=null&&e.context.addRouteItem(l);let u=new xl({context:e.context,request:e,parentCuid:a,callSite:o});if(n.registerRunningAction(u),e.schema.reliabilityTier!==Ol.none){let n=t?.streamKey,r=$c(this.peer,e.domain,e.id,n),a=this._outbox.prepare(r,()=>{u.isAborted||this._dispatchWhenTransportReady(u,s,l,i)},n,{onDrop:e=>{u._notifyAckAbandoned(e),u._abort(e)},onAck:()=>u._notifyAcked()});if(a==null)return this._emitReliableEvent(n==null?{type:`overflow`,domain:e.domain,actionId:e.id}:{type:`overflow`,domain:e.domain,actionId:e.id,streamKey:n}),u._abort(uu.fromId(lu.reliable_outbox_overflow,{actionId:e.id,streamId:r,maxUnacked:this._outbox.maxUnackedPerStream})),u;s.reliability=a.reliability,u._setReliability({tier:e.schema.reliabilityTier,seq:a.reliability.seq,streamKey:n}),this._armDeliveryDeadline(r,a.reliability,u);let o=u.addUpdateListeners([t=>{t.type===yl.finished&&(o(),u.isAborted&&this._abandonReliableThrough(r,a.reliability,e.domain,e.id,n))}])}return this._dispatchWhenTransportReady(u,s,l,i),u}async _dispatchWhenTransportReady(e,t,n,r){let i=t.action;try{let{methods:a,transport:o}=await this._wire.getReadyTransport(t);a.addOnDisconnectListener!=null&&!this._resendHooked.has(a)&&(this._resendHooked.add(a),a.addOnDisconnectListener(()=>{this._outbox.size>0&&setTimeout(()=>this._outbox.resendAll(),0)}),a.sendControlData!=null&&(this._controlMethods=a),this._outbox.size>0&&setTimeout(()=>this._outbox.resendAll(),0));let s=this.toHandlerRouteItem(o,t);n==null?i.context.addRouteItem({runtime:t.localClient,handler:s,time:Date.now()}):(n.handler=s,n.time=Date.now());let c={...t,runningAction:e,timeout:r};i.type===G.request&&a.updateRunConfig!=null&&(c.timeout=a.updateRunConfig(c)?.timeout??r),a.sendActionData(c),this._streamSkips.size>0&&this._flushStreamSkips(),i.type===G.request&&i.schema.responseMode===Dl.none&&e._completeWithResult(i.successResult(void 0))}catch(a){if(i.type===G.request&&t.reliability!=null){e.isAborted||setTimeout(()=>{e.isAborted||this._dispatchWhenTransportReady(e,t,n,r)},bu);return}e._abort(a)}}_applyAck(e,t){for(let n of this._outbox.ack(e,t)){let e=this._deliveryDeadlines.get(n.reliability);e!=null&&(clearTimeout(e),this._deliveryDeadlines.delete(n.reliability))}let n=this._streamSkips.get(e);n!=null&&t>=n.seq&&this._streamSkips.delete(e)}_armDeliveryDeadline(e,t,n){let r=setTimeout(()=>{if(!n._abort(uu.fromId(lu.reliable_delivery_abandoned,{actionId:n.state.request.id,streamId:e,timeout:this._reliableTimeout}))){let r=n.state.request;sl(r.domain,r.id),this._abandonReliableThrough(e,t,r.domain,r.id,t.streamKey)}},this._reliableTimeout);this._deliveryDeadlines.set(t,r)}_abandonReliableThrough(e,t,n,r,i,a){let o=t.seq;if(o==null)return;let s=a??uu.fromId(lu.reliable_delivery_abandoned,{actionId:r,streamId:e,timeout:this._reliableTimeout}),c=this._outbox.dropThrough(e,o,s);for(let e of c){let t=this._deliveryDeadlines.get(e.reliability);t!=null&&(clearTimeout(t),this._deliveryDeadlines.delete(e.reliability))}if(c.length>0&&this._emitReliableEvent({type:`abandoned`,domain:n,actionId:r,...i==null?{}:{streamKey:i},fromSeq:c[0].seq,toSeq:o,reason:s}),c.length===0&&(this._streamSkips.get(e)?.seq??-1)>=o)return;let l=this._streamSkips.get(e);(l==null||o>l.seq)&&this._streamSkips.set(e,i==null?{$c:`rskip`,domain:n,id:r,seq:o}:{$c:`rskip`,domain:n,id:r,seq:o,k:i}),this._flushStreamSkips()}_flushStreamSkips(){let e=this._controlMethods;if(e?.sendControlData!=null){for(let t of this._streamSkips.values())e.sendControlData(t);for(let[t,n]of this._streamCloses)e.sendControlData(n),this._streamCloses.delete(t)}}addReliableEventListener(e){return this._reliableEventListeners.add(e),()=>{this._reliableEventListeners.delete(e)}}_emitReliableEvent(e){for(let t of this._reliableEventListeners)try{t(e)}catch(e){console.error(`[reliable] onReliableEvent listener threw`,e)}}addLinkEventListener(e){return this._wire.addLinkEventListener(e)}closeReliableStream(e,t){let n=$c(this.peer,e.domain,e.id,t),r=this._outbox.highestSeq(n);if(r==null)return;let i=uu.fromId(lu.reliable_stream_closed,{actionId:e.id,streamId:n});this._abandonReliableThrough(n,{streamId:n,seq:r,streamKey:t},e.domain,e.id,t,i),this._streamCloses.set(n,t==null?{$c:`rclose`,domain:e.domain,id:e.id}:{$c:`rclose`,domain:e.domain,id:e.id,k:t}),this._flushStreamSkips()}reliablePending(e,t){if(e==null)return this._outbox.size;let n=$c(this.peer,e.domain,e.id,t),r=this._outbox.oldestPreparedAt(n);return{unackedCount:this._outbox.pendingCount(n),oldestUnackedAgeMs:r==null?void 0:Date.now()-r,maxUnackedPerStream:this._outbox.maxUnackedPerStream}}async sendReturnPayload(e,t){let n=this._connectionIdentity??t.targetLocalRuntime.coordinate;try{let{methods:t}=await this._wire.getReadyTransport({action:e,localClient:n,externalClient:this.peer});return t.sendReturnData==null?!1:(t.sendReturnData(e,{localClient:n,externalClient:this.peer}),!0)}catch{return!1}}toJsonObject(){return{type:this.handlerType,client:this.peer}}toHandlerRouteItem(e,t){return{type:this.handlerType,client:this.peer,transOrd:e.transOrd,transShape:e.type,transInfo:e.getRouteInfo(t)}}releaseLink(){this._wire.releaseLink()}clearTransportCache(){this._wire.clearTransportCache()}},Su=class{_coordinate;timeCreated;runtimeInfo=$l();actionRouter;_pendingRunningActions=new Map;_registeredPeerHandlers=[];_registeredRoots=new Set;_handlerOwnership=new Map;_disposed=!1;captureCallSites;scope;static getDefault(){return Tu()}constructor(e,t={}){this._coordinate=e,this.captureCallSites=t.captureCallSites??!1,this.scope=t.scope??`global`,this.timeCreated=Date.now(),this.actionRouter=new mu({contextType:pu.runtime_to_handler,runtime:this})}get coordinate(){return this._coordinate.insId??(this._coordinate=this._coordinate.specify({insId:Ya(14)})),this._coordinate}get disposed(){return this._disposed}_assertActive(){if(this._disposed)throw q.fromId(K.runtime_disposed,{runtime:this.coordinate.stringId})}_captureActionCallSite(e,t){return e._callSite==null&&(t??this.captureCallSites)&&(e._callSite=jl()),e._callSite}specifyRuntimeCoordinate(e){if(this._assertActive(),e.envId!=null&&this._coordinate.envId!==e.envId)throw q.fromId(K.not_implemented,{label:`updating RuntimeCoordinate with a different "envId" ("${this._coordinate.envId}" → "${e.envId}")`});this._coordinate=this._coordinate.specify(e)}registerRunningAction(e){this._assertActive(),this._pendingRunningActions.set(e.cuid,e),e.addUpdateListeners([t=>{t.type===yl.finished&&this._pendingRunningActions.delete(e.cuid)}])}resolveIncomingActionPayload(e,t){if(!this._disposed){if(e.type===G.request){this._handleActionPayloadWireFromReceiver(e,t).catch(t=>{console.error(`[ActionRuntime] Incoming action [${e.domain}:${e.id}:${e.form}:${e.type}] unhandled:`,t)});return}this._pendingRunningActions.get(e.context.cuid)?._resolveFromJson(e)}}async _handleActionPayloadWireFromReceiver(e,t){let n=this._hydrateActionPayloadWire(e);return t!=null&&n.context._setReceiverMetadata(t),this.handleActionPayload(n)}_hydrateActionPayloadWire(e){if(nu(e))return this.actionRouter.domainManager.getActionDomainOrThrow(e).hydrateAnyAction(e);throw q.fromId(K.wire_not_action_data)}async handleActionPayloadWire(e){return this._assertActive(),this.handleActionPayload(this._hydrateActionPayloadWire(e))}responseModeForWire(e){try{return this.actionRouter.domainManager.getActionDomainOrThrow(e).actionSchema[e.id]?.responseMode}catch{return}}reliabilityTierForWire(e){return this.reliabilityTierForRoute(e.domain,e.id)}reliabilityTierForRoute(e,t){try{return this.actionRouter.domainManager.getActionDomainOrThrow({domain:e,id:t}).actionSchema[t]?.reliabilityTier}catch{return}}async handleActionPayload(e,t){if(this._assertActive(),e.type===G.request){let n=e.context._domain._collectActionObservers(),r;try{r=this.getHandlerForActionOrThrow(e,t)}catch(t){let r=new xl({context:e.context,request:e});return r.addUpdateListeners(n),r._completeWithResult(e.errorResult(ve(t))),r}let i;try{i=new _l({context:e.context},e.context.validateInput(e.input),{time:e.time}),i._callSite=e._callSite}catch(t){let r=new xl({context:e.context,request:e});return r.addUpdateListeners(n),r._completeWithResult(e.errorResult(ve(t))),this._trySetupReturnDispatch(r),r}let a=await r.handleActionRequest(i,{...t,targetLocalRuntime:this});return a.addUpdateListeners(n),this._trySetupReturnDispatch(a),a}throw q.fromId(K.not_implemented,{label:`Handling incoming action payloads of type "${e.type}"`})}_getHandlerForAction(e,t){let n=this.actionRouter.getRouteDataEntriesForAction(e).filter(t=>t.handlerType===ru.peer||t.handlerType===ru.local&&e.type===G.request);if(n.length===0)return;let r=-1,i;for(let e of n){if(e.handlerType===ru.local)return e;if(e.handlerType===ru.peer){let t=$a.unknown.similarityLevel(e.peer);t>r&&(r=t,i=e)}}return i}getHandlerForActionOrThrow(e,t){let n=this._getHandlerForAction(e,t);if(n==null)throw q.fromId(K.no_action_execution_handler,{actionId:e.id,domain:e.domain});return n}addHandlers(e){return this._addHandlers(e,{persistent:!0,register:!0}),this}_installHandlers(e,t={}){this._assertActive();let n=Symbol(`action-runtime-handler-installation`);try{this._addHandlers(e,{persistent:!1,register:t.register??!1,lease:n})}catch(e){throw this._releaseHandlerLease(n),e}let r=!1;return()=>{r||(r=!0,this._releaseHandlerLease(n))}}_addHandlers(e,t){this._assertActive(),this._assertNoDuplicateLocalExecutors(e);for(let n of e){let e=this._handlerOwnership.get(n);if(e==null){let t=n.getActionRouter();e={persistent:!1,leases:new Set};try{this.actionRouter.addDomainsFromOther(t),n.handlerType===ru.peer&&(e.unbind=n._setIncomingActionDataListener(this,(e,t)=>this.resolveIncomingActionPayload(e,t)),this._registeredPeerHandlers.push(n));for(let e of t.getRegisteredKeys())this.actionRouter.addForKey(e,n)}catch(t){e.unbind?.(),this.actionRouter.removeRouteData(n);let r=this._registeredPeerHandlers.indexOf(n);throw r>=0&&this._registeredPeerHandlers.splice(r,1),t}this._handlerOwnership.set(n,e)}t.persistent&&(e.persistent=!0),t.lease!=null&&e.leases.add(t.lease)}t.register&&this._registerWithRoutedRoots()}_assertNoDuplicateLocalExecutors(e){for(let t of e)for(let e of t.getActionRouter().getDomains())this.actionRouter.domainManager.assertCanAddDomain(e);let t=new Map;for(let n of e)if(!(n.handlerType!==ru.local||this._handlerOwnership.has(n)))for(let e of n.getActionRouter().getRegisteredKeys()){let r=this.actionRouter.getForKey(e).find(e=>e.handlerType===ru.local)??t.get(e);if(r!=null&&r!==n)throw q.fromId(K.duplicate_action_executor,{route:e});t.set(e,n)}}_releaseHandlerLease(e){for(let[t,n]of this._handlerOwnership){if(n.leases.delete(e),n.persistent||n.leases.size>0)continue;n.unbind?.(),this.actionRouter.removeRouteData(t);let r=this._registeredPeerHandlers.indexOf(t);r>=0&&this._registeredPeerHandlers.splice(r,1),this._handlerOwnership.delete(t)}}connectTo(e,t){let n=new xu({peer:e,transports:t.transports,defaultTimeout:t.defaultTimeout,reliableActionTimeout:t.reliableActionTimeout,wireMux:t.wireMux,localCoordinate:this.coordinate,connectionIdentity:t.connectionIdentity,securityLevel:t.securityLevel,reconnect:t.reconnect??t.keepLinkAlive});for(let e of t.domains??[])n.forDomain(e);for(let e of t.actions??[])n.forAction(e);return this.addHandlers([n,...t.localHandlers??[]]),n}applyRuntimeForDomain(e){let t=e.rootDomain;t._hasRuntime(this)||(t._registerRuntime(this),this._registeredRoots.add(t))}_registerWithRoutedRoots(){if(this.scope!==`instance`)for(let e of this.actionRouter.getDomains())this.applyRuntimeForDomain(e)}apply(){return this._assertActive(),this._registerWithRoutedRoots(),this}async run(e,t){return this._assertActive(),e.run({...t,targetLocalRuntime:this})}getReturnHandlerForOrigin(e){if(e.envId===`_unset_`)return;let t=-1,n,r=-1,i;for(let a of this._registeredPeerHandlers){if(!a.canPush)continue;let o=e.similarityLevel(a.peer);o>t&&(t=o,n=a),a.ownsLiveConnectionFor(e)&&o>r&&(r=o,i=a)}return i??(t>0?n:void 0)}resetRuntime(){this._assertActive();for(let e of this._pendingRunningActions.values())e._abort(q.fromId(K.runtime_reset));for(let e of this._registeredPeerHandlers)e.clearTransportCache()}dispose(){if(!this._disposed){this._disposed=!0;for(let e of this._registeredRoots)e._unregisterRuntime(this);if(this._registeredRoots.clear(),this._pendingRunningActions.size>0){let e=q.fromId(K.runtime_disposed,{runtime:this.coordinate.stringId});for(let t of this._pendingRunningActions.values())t._abort(e)}this._pendingRunningActions.clear();for(let e of this._registeredPeerHandlers){let t=e;typeof t.dispose==`function`?t.dispose():e.clearTransportCache()}for(let[e,t]of this._handlerOwnership)t.unbind?.(),this.actionRouter.removeRouteData(e);this._handlerOwnership.clear(),this._registeredPeerHandlers.length=0}}_trySetupReturnDispatch(e){if(e.context.schema.responseMode===Dl.none)return;let t=e.context.originClient;if(t.envId===`_unset_`||t.isSameFor(this._coordinate).id)return;let n=e.context._getReceiverMetadata();e.addUpdateListeners([e=>{if(e.type===yl.finished&&e.finishType===bl.success){if(this._disposed)return;let r=n?.receiver instanceof gu?this._registeredPeerHandlers.includes(n.receiver)&&n.receiver.canPush?n.receiver:void 0:this.getReturnHandlerForOrigin(t);if(r==null||!Cu(n,r))return;r.sendReturnPayload(e.response,{targetLocalRuntime:this}).catch(()=>{})}}])}};function Cu(e,t){return e==null||e.receiver===t?!0:e.securityLevel!=null&&e.securityLevel!==ro.none}var wu={defaultLocalRuntime:void 0,assumedRuntimeInfo:void 0};function Tu(){return wu.assumedRuntimeInfo??=$l(),wu.defaultLocalRuntime??=new Su($a.unknown.specify({perId:`${wu.assumedRuntimeInfo?.runtimeName??`unknown`}-runtime`})),wu.defaultLocalRuntime}var Eu=class extends hu{handlerType=ru.local;actionRouter=new mu({contextType:pu.handler_route,handler:this});constructor(){super()}forDomain(e,t){return this.actionRouter.forDomain(e,t),this}forAction(e,t){return this.actionRouter.forAction(e,t),this}forActionIds(e,t,n){return this.actionRouter.forActionIds(e,t,n),this}forDomainActionCases(e,t){return this.actionRouter.forDomainActionCases(e,t),this}async handleActionRequest(e,t){let n=t?.targetLocalRuntime??Su.getDefault(),r=this.actionRouter.getRouteDataForActionOrThrow(e,{targetLocalRuntime:n});e.context.addRouteItem({runtime:n.coordinate,handler:this.toHandlerRouteItem(),time:Date.now()});let i=new xl({context:e.context,request:e,parentCuid:su(),callSite:n._captureActionCallSite(e,t?.captureCallSites)});return this._handleRunningAction(r,i,n),i}async _handleRunningAction(e,t,n){let r=t.state;if(r.result==null){await Promise.resolve(),au(t.cuid);try{let i=await ye(async()=>{let t=r.request.context._getReceiverMetadata()?.securityLevel,i={runtime:n,origin:r.request.context.originClient,authenticatedOrigin:t!=null&&t!==ro.none?r.request.context.originClient:void 0,securityLevel:t,reliability:r.request.context.reliability,run:(e,t)=>n.run(e,t)},a=await e(r.request,i);return a instanceof gl?a:a!=null&&Cl(a)?this.actionRouter.domainManager.getActionDomainOrThrow(r.request).hydrateResultPayload(a):r.request.successResult(a)}),a=i.ok?i.output:r.request.errorResult(i.error);t._completeWithResult(a)}finally{ou()}}}async handlePayloadWireOrThrow(e,t){let n=this.actionRouter.domainManager.hydrateActionPayload(e);if(!(n instanceof _l))throw q.fromId(K.wire_action_not_payload,{domain:n.domain,actionId:n.id,actionState:n.type??n.form});return await this.handleActionRequest(n,t)}toJsonObject(){return{type:this.handlerType}}toHandlerRouteItem(){return{type:this.handlerType}}},Du=e=>Sl(e)&&e.form===ll.context,Ou=e=>Sl(e)&&e.form===ll.core;function ku(e){return nu(e)||Du(e)||Ou(e)}function Au(e){if(!ku(e))throw q.fromId(K.wire_not_action_data)}function ju(e){return e instanceof vl||e instanceof dl||e instanceof ul}var Mu=class{domain;allDomains;actionSchema;_listeners=[];constructor(e){this.domain=e.domain,this.allDomains=e.allDomains,this.actionSchema=e.actionSchema}addActionListener(e){return this._listeners.push(e),()=>{this._listeners=this._listeners.filter(t=>t!==e)}}_getActionObservers(){return this._listeners}},Nu=class{_runtimes=new Set;_context;constructor(e){this._context=e??{}}registerRuntime(e){e._assertActive(),this._runtimes.add(e)}unregisterRuntime(e){this._runtimes.delete(e)}getRuntimeAndHandlerForAction(e,t,n){let r=t?.targetLocalRuntime;if(r!=null){r._assertActive();let i=r._getHandlerForAction(e,t);if(i!=null)return{handler:i,runtime:r};if(n)throw q.fromId(K.no_action_execution_handler,{domain:e.domain,actionId:e.id,specifiedClient:r.coordinate});return}let i,a;for(let t of this._runtimes){if(t.disposed)continue;let n=t._getHandlerForAction(e);n!=null&&(i==null?i={handler:n,runtime:t}:(a??=[i.runtime.coordinate.stringId],a.push(t.coordinate.stringId)))}if(a!=null)throw q.fromId(K.ambiguous_action_runtime,{domain:e.domain,actionId:e.id,runtimes:a});if(i!=null)return i;if(n&&this._runtimes.size===0)throw q.fromId(K.no_client_runtimes_registered,{context:this._context});if(n)throw q.fromId(K.no_action_execution_handler,{domain:e.domain,actionId:e.id})}getRuntimeAndHandlerForActionOrThrow(e,t){return this.getRuntimeAndHandlerForAction(e,t,!0)}hasRuntime(e){return this._runtimes.has(e)}},Pu=class extends Mu{domainDefinition;_actionRuntimeManager;constructor(e){let t=e.domain;super({domain:t,allDomains:[t],actionSchema:{}}),this.domainDefinition=e,this._actionRuntimeManager=new Nu({domain:t})}createChildDomain(e){if(this.allDomains.includes(e.domain))throw q.fromId(K.domain_already_exists_in_hierarchy,{domain:e.domain,allParentDomains:this.allDomains,parentDomain:this.domain});return new Fu({allDomains:[...this.allDomains,e.domain],domain:e.domain,actionSchema:e.actions},{rootDomain:this})}_registerRuntime(e){this._actionRuntimeManager.registerRuntime(e)}_unregisterRuntime(e){this._actionRuntimeManager.unregisterRuntime(e)}_hasRuntime(e){return this._actionRuntimeManager.hasRuntime(e)}async _runAction(e,t){let n=[...this._listeners,...t?.listeners??[]],r;try{r=this._actionRuntimeManager.getRuntimeAndHandlerForActionOrThrow(e,t)}catch(t){let r=new xl({context:e.context,request:e,callSite:e._callSite});throw r.addUpdateListeners(n),r._failWithError(t),t}let{handler:i,runtime:a}=r;a._captureActionCallSite(e,t?.captureCallSites),e.context._setOriginClient(a.coordinate);let o=await i.handleActionRequest(e,{targetLocalRuntime:a,timeout:t?.timeout,streamKey:t?.streamKey,captureCallSites:t?.captureCallSites});return o.addUpdateListeners(n),o}},Fu=class e extends Mu{_rootDomain;_actionMap;constructor(e,{rootDomain:t}){super(e),this._rootDomain=t,this._actionMap=this.createActionMap()}get rootDomain(){return this._rootDomain}_collectActionObservers(){return[...this._rootDomain._getActionObservers(),...this._getActionObservers()]}_registerRuntime(e){this._rootDomain._registerRuntime(e)}createChildDomain(t){if(this.allDomains.includes(t.domain))throw q.fromId(K.domain_already_exists_in_hierarchy,{domain:t.domain,allParentDomains:this.allDomains,parentDomain:this.domain});return new e({allDomains:[...this.allDomains,t.domain],domain:t.domain,actionSchema:t.actions},{rootDomain:this._rootDomain})}get action(){return this._actionMap}actionsMap(){return this._actionMap}actionForId(e){if(!this.actionSchema[e])throw q.fromId(K.action_id_not_in_domain,{domain:this.domain,actionId:e});return new vl(this,e)}wrapAsPartialLocalHandler(e){let t=new Eu,n=e;for(let r in e)this.actionSchema[r]&&t.forAction(this.actionForId(r),(e,t)=>n[e.id](e.input,t));return t}wrapAsLocalHandler(e){let t=new Eu,n=e;return t.forDomain(this,(e,t)=>n[e.id](e.input,t))}hydrateContext(e,t){return new ul(this,e,{timeCreated:t.timeCreated,cuid:t.cuid,routing:t.routing.map(e=>({runtime:new $a(e.runtime),handler:e.handler,time:e.time})),originClient:t.originClient?new $a(t.originClient):$a.unknown})}isDomainAction(e){return ju(e)&&e.domain===this.domain}hydrateRequestPayload(e){if(e.type!==G.request)throw q.fromId(K.hydration_action_state_mismatch,{expected:G.request,received:e.type});if(e.domain!==this.domain)throw q.fromId(K.hydration_domain_mismatch,{expected:this.domain,received:e.domain});let t=e.id;if(!this.actionSchema[t])throw q.fromId(K.hydration_action_id_not_found,{domain:this.domain,actionId:e.id});let n=this.hydrateContext(t,e.context);return new _l({context:n},n.deserializeInput(e.input),{time:e.time})}hydrateResultPayload(e){if(e.type!==G.result)throw q.fromId(K.hydration_action_state_mismatch,{expected:G.result,received:e.type});if(e.domain!==this.domain)throw q.fromId(K.hydration_domain_mismatch,{expected:this.domain,received:e.domain});let t=e.id;if(!this.actionSchema[t])throw q.fromId(K.hydration_action_id_not_found,{domain:this.domain,actionId:e.id});let n=this.hydrateContext(t,e.context),r=e.result.ok?{ok:!0,output:n.schema.deserializeOutput(e.result.output)}:{ok:!1,error:ve(e.result.error)};return new gl({context:n},r,{time:e.time})}hydrateAnyAction(e){if(Au(e),e.form===ll.data){if(e.type===G.request)return this.hydrateRequestPayload(e);if(e.type===G.result)return this.hydrateResultPayload(e)}return this.actionForId(e.id)}async runAction(e,t){let n=[...t?.listeners??[],...this._listeners];return this._rootDomain._runAction(e,{...t,listeners:n})}createActionMap(){let e={};for(let t in this.actionSchema)e[t]=new vl(this,t);return e}},Iu=e=>new Pu(e);function Lu(e,t){let n=t?.incoming?.(e)??(typeof e==`string`?Ru(e):void 0);return n!=null&&nu(n)?n:void 0}function Ru(e){try{let t=JSON.parse(e);return nu(t)?t:void 0}catch{return}}ro.none,ro.authenticated,ro.encrypted;function zu(e){return{localClient:e.localClient,externalClient:e.externalClient,dialContext:e}}function Bu(e){return`shape`in e&&e.shape===`exchange`}function Vu(e,t){return e==null?void 0:(t===G.request?e.seq:e.ack)??void 0}function Hu(e,t){let n=t===G.request?0:-1;if(!(typeof e!=`number`||!Number.isInteger(e)||e<n))return t===G.request?{seq:e}:{ack:e}}var Uu={[G.request]:0,[G.result]:1,[G.progress]:2},Wu=[G.request,G.result,G.progress];function Gu(e){let t=new Map,n=[];for(let r of e)for(let e of Object.keys(r.actionSchema)){let i=`${r.domain}:${e}`;t.has(i)||(t.set(i,n.length),n.push({domain:r.domain,id:e,allDomains:r.allDomains}))}return{routeToInt:t,intToRoute:n}}function Ku(e){if(e.type===G.request)return e.input;if(e.type===G.result)return e.result;if(e.type===G.progress)return e.progress}function qu(e,t,n,r,i){let a={form:ll.data,domain:e.domain,id:e.id,allDomains:e.allDomains,time:n,context:r};return t===G.request?{...a,type:G.request,input:i,inputHash:``}:t===G.result?{...a,type:G.result,result:i,outputHash:``}:{...a,type:G.progress,progress:i}}var Ju={route:0,type:1,corr:2,time:3,originClient:4,payload:5,reliability:6,streamKey:7},Yu=6,Xu=7,Zu=8,Qu=5*6e4;function $u(e){return e!=null&&e.envId!==`_unset_`}function ed(e,t,n){for(let[r,i]of e){if(t-i.time<=n)break;e.delete(r)}}function td(e,t){let{routeToInt:n,intToRoute:r}=Gu(e),i=$a.unknown.toJsonObject(),a=t?.correlationTtlMs??Qu;return()=>{let e=0,t=new Map,o=new Map,s,c;return{outgoing:r=>{let i=r.action.toJsonObject(),c=`${i.domain}:${i.id}`,l=n.get(c);if(l==null)throw Error(`[binary-wire] Cannot pack unregistered action route: ${c}`);let u=Date.now();ed(t,u,a),ed(o,u,a);let d,f;i.type===G.request?(d=e++,t.set(d,{value:i.context.cuid,time:u}),s==null&&$u(i.context.originClient)&&(s=i.context.originClient,f=i.context.originClient)):(d=o.get(i.context.cuid)?.value??-1,i.type===G.result&&o.delete(i.context.cuid));let p=Vu(r.reliability,i.type),m=r.reliability?.streamKey,h=Array(m==null?p==null?Yu:Xu:Zu);return h[Ju.route]=l,h[Ju.type]=Uu[i.type],h[Ju.corr]=d,h[Ju.time]=i.time,h[Ju.originClient]=f,h[Ju.payload]=Ku(i),p!=null&&(h[Ju.reliability]=p),m!=null&&(h[Ju.streamKey]=m),Vs(h)},incoming:e=>{let n;if(e instanceof ArrayBuffer)n=new Uint8Array(e);else if(e instanceof Uint8Array)n=e;else return;try{let e=_s(n);if(!nd(e))return;let l=r[e[Ju.route]],u=Wu[e[Ju.type]];if(l==null||u==null)return;let d=Date.now();ed(t,d,a),ed(o,d,a);let f=e[Ju.corr],p=e[Ju.time],m=e[Ju.originClient],h,g;return u===G.request?(h=Ya(),o.set(h,{value:f,time:d}),$u(m)&&(c=m),g=c??i):(h=t.get(f)?.value??Ya(),u===G.result&&t.delete(f),g=s??i),qu(l,u,p,{cuid:h,timeCreated:p,routing:[],originClient:g},e[Ju.payload])}catch(e){console.error(`[binary-wire] Failed to unpack binary action session frame`,e);return}},incomingReliability:e=>{let t;if(e instanceof ArrayBuffer)t=new Uint8Array(e);else if(e instanceof Uint8Array)t=e;else return;try{let e=_s(t);if(!nd(e)||e.length!==Xu&&e.length!==Zu)return;let n=Wu[e[Ju.type]];if(n==null)return;let r=Hu(e[Ju.reliability],n);if(r==null)return;if(e.length===Zu){let t=e[Ju.streamKey];if(typeof t!=`string`)return;r.streamKey=t}return r}catch{return}}}}}function nd(e){return Array.isArray(e)&&(e.length===Yu||e.length===Xu||e.length===Zu)}var rd=class{};function id(e){return od(e,Rc(e.carrier))}async function ad(e){return od(e,await zc({carrier:e.carrier,secure:e.secure,lane:{dictionaryVersion:e.secure.dictionaryVersion,channels:e.secure.channelTags}}))}function od(e,t){return{sendActionData:e=>{sd(t,e).catch(t=>e.runningAction._abort(t))},updateRunConfig:e.updateRunConfig}}async function sd(e,t){let{action:n,runningAction:r,timeout:i}=t,a=new AbortController,o=!1,s=setTimeout(()=>{o=!0,a.abort()},i),c=r.addUpdateListeners([e=>{e.type===yl.finished&&(clearTimeout(s),a.abort())}]);try{if(n.type!==G.request){await e.send(n.toJsonObject(),{signal:a.signal});return}let t=await e.exchange(n.toJsonObject(),{signal:a.signal});if(!t.ok&&t.reason===`peer_error`)throw uu.fromId(lu.send_failed,{actionState:n.type,actionId:n.id,message:t.message});if(!t.ok||!Cl(t.wire))throw uu.fromId(lu.invalid_action_response,{actionId:n.id});r._completeWithResult(n._domain.hydrateResultPayload(t.wire))}catch(e){throw o?uu.fromId(lu.timeout,{timeout:i}):e}finally{clearTimeout(s),c()}}var cd=class extends Cc{},ld=class extends cd{constructor(e){super({...e,type:br.exchange})}_getCacheKey(e){return this.initialized.getCacheKey?.(e).join(`\0`)??``}_needsAsyncBringUp(e){return e.secureChannel!=null&&e.secureChannel.securityLevel!==ro.none}_finalizeReady(e){let t=e.secureChannel;return t!=null&&t.securityLevel!==ro.none?ad({...this._sessionContext(e),secure:t}):this._finalizeTransportMethods(e)}_finalizeTransportMethods(e){return id(this._sessionContext(e))}_sessionContext(e){return{carrier:e.carrier,updateRunConfig:e.updateRunConfig,secure:e.secureChannel}}},ud=class e extends rd{options;type=br.exchange;constructor(e){super(),this.options=e}static create(t){return new e(t)}_createConnection(e){let t=this.options;return new ld({initialize:()=>({getCacheKey:t.getCacheKey,isAvailable:t.available,getTransport:e=>{dd(t);let n=t.openCarrier(e);return{status:xr.ready,readyData:{carrier:t.wireTap==null?n:nc(n,t.wireTap),secureChannel:t.security,updateRunConfig:t.updateRunConfig}}}})})}getRouteInfo(e){return this.options.getRouteInfo==null?{carrierLabel:this.options.label??`exchange`,summary:this.options.label??`exchange`}:this.options.getRouteInfo(e)}};function dd(e){if(!(e.exchangeOnlyConnection!==!0||e.mux==null))for(let t of Qs(e.mux.localCaps()))throw Sr.fromId(`protocol_on_exchange_only`,{protocolId:t})}var fd=e=>({onIncomingActionDataJson:t=>{console.warn(`Received incoming action JSON [${t.domain}:${t.id}] on Transport [${e}] but no incoming data listener has been set.`)}});function pd(e,t){return{id:`action`,onLaneFrame:t=>_d(e,t),onDetach:()=>vd(e,t)}}function md(e){let t=new Set;return gd(e,mc({channel:e.channel,lane:pd(e,t),heartbeat:e.heartbeat,tap:e.wireTap}),t)}async function hd(e){let t=new Set,n={...pd(e,t),handshakeConfig:()=>({dictionaryVersion:e.secure.dictionaryVersion,channels:e.secure.channelTags})},r=await hc({channel:e.channel,secure:e.secure,lane:n,mux:e.secure.mux,heartbeat:e.heartbeat,tap:e.wireTap});return gd(e,r,t,r.remoteCaps?.includes(`reliable`)??!1,r.remoteCaps?.includes(`reliable-streamkey`)??!1)}function gd(e,t,n,r,i){return{sendActionData:a=>{let{action:o,runningAction:s,timeout:c}=a,l=o.type===G.request&&o.schema?.reliabilityTier!=null&&o.schema.reliabilityTier!==Ol.none;if(!t.isOpen()){o.type===G.request&&!l&&s._abort(e.makeDisconnectError(o.id));return}if(o.type===G.request&&!l){n.add(s);let e=setTimeout(()=>{s._abort(uu.fromId(lu.timeout,{timeout:c}))},c);s.addUpdateListeners([t=>{t.type===yl.finished&&(clearTimeout(e),n.delete(s))}])}let u=a;a.reliability!=null&&(e.formatMessage==null?tl(o.domain,o.id):r===!1?(rl(o.domain,o.id),u={...a,reliability:void 0}):a.reliability.streamKey!=null&&i===!1&&al(o.domain,o.id)),t.send(e.formatMessage?.outgoing(u)??JSON.stringify(u.action.toJsonObject()))},sendControlData:e=>{t.isOpen()&&t.send(Zc(e))},updateRunConfig:e.updateRunConfig,addOnDisconnectListener:e=>t.addOnDisconnectListener(e),disconnect:()=>t.close(),sendReturnData:(n,r)=>{let i=r==null?void 0:e.formatMessage?.outgoing({action:n,...r});t.send(i??JSON.stringify(n.toJsonObject()))}}}function _d(e,t){let n=Qc(t);if(n!=null){e.resolvers.onControlMessage?.(n);return}let r=Lu(t,e.formatMessage);if(r!=null){let n=e.formatMessage?.incomingReliability?.(t);n==null?e.resolvers.onIncomingActionDataJson(r):e.resolvers.onIncomingActionDataJson(r,n)}}function vd(e,t){let n=e.makeDisconnectError(`—`);for(let e of[...t])e._abort(n)}function yd(e){return uu.fromId(lu.send_failed,{actionId:e,actionState:`request`,message:`link channel disconnected`})}var bd=class extends cd{resolvers;constructor(e,t){super({...e,type:br.duplex}),this.resolvers=t??fd(`link`)}_getCacheKey(e){return this.initialized.getCacheKey?.(e).join(`\0`)??``}_needsAsyncBringUp(){return!0}_awaitCarrierReady(e){return e.channel.ready}_finalizeReady(e){let t=e.secureChannel;return t!=null&&t.securityLevel!==ro.none?hd({...this._sessionContext(e),secure:t}):this._finalizeTransportMethods(e)}_sessionContext(e){return{channel:e.channel,resolvers:this.resolvers,formatMessage:e.formatMessage,updateRunConfig:e.updateRunConfig,makeDisconnectError:yd,heartbeat:e.heartbeat,wireTap:e.wireTap}}_finalizeTransportMethods(e){return md(this._sessionContext(e))}},Z=class e extends rd{options;type=br.duplex;constructor(e){super(),this.options=e}static create(t){return new e(t)}_createConnection(e){let t=this.options;return new bd({initialize:()=>({getCacheKey:t.getCacheKey,isAvailable:t.available,getTransport:e=>({status:xr.ready,readyData:{channel:t.openChannel(e),formatMessage:t.createFormatMessage?.()??t.formatMessage,updateRunConfig:t.updateRunConfig,secureChannel:t.security,heartbeat:t.heartbeat?.(),wireTap:t.wireTap}})})},e.resolvers)}getRouteInfo(e){return this.options.getRouteInfo==null?{carrierLabel:this.options.label??`link`,summary:this.options.label??`link`}:this.options.getRouteInfo(e)}};function xd(e){let{carrier:t,channel:n,available:r,label:i}=e,a=i??t.carrierLabel,o=t.getCacheKey,s=t.getRouteInfo,c;if(e.secure){let t=e.link??(e.storage==null?void 0:new Ua({storageAdapter:e.storage}));if(t==null)throw Error("transport: a secure transport requires `link` or `storage` for the crypto identity.");c={securityLevel:e.securityLevel??ro.authenticated,link:t,localCoordinate:(e.identity??e.runtime.coordinate).toJsonObject(),expectedPeer:e.expectedPeer?.toJsonObject(),dictionaryVersion:n.dictionaryVersion,channelTags:n.tags,mux:e.mux}}return Bu(t)?ud.create({openCarrier:e=>t.open(zu(e)),getCacheKey:o==null?void 0:e=>o(zu(e)),available:r??t.available,getRouteInfo:s==null?void 0:e=>s(zu(e)),label:a,security:c,mux:e.mux,exchangeOnlyConnection:e.exchangeOnlyConnection,wireTap:e.wireTap}):Z.create({openChannel:e=>t.open(zu(e)),createFormatMessage:n.createCodec,getCacheKey:o==null?void 0:e=>o(zu(e)),available:r??t.available,getRouteInfo:s==null?void 0:e=>s(zu(e)),label:a,security:c,heartbeat:e.heartbeat,wireTap:e.wireTap})}function Sd(e){return e.map(e=>e.domain).join(`+`)}function Cd(e){let{intToRoute:t}=Gu(e),n=t.map(e=>`${e.domain}:${e.id}`).join(`,`),r=2166136261;for(let e=0;e<n.length;e++)r^=n.charCodeAt(e),r=Math.imul(r,16777619);return`auto:${(r>>>0).toString(16).padStart(8,`0`)}`}function wd(e={}){let t=e.toAcceptor??[],n=e.toConnector??[],r=[...t,...n],i=e.tag??Sd(r);return{toAcceptorDomains:t,toConnectorDomains:n,dictionaryVersion:e.dictionaryVersion??Cd(r),createCodec:td(r,e.sessionOptions),tag:i,tags:[i]}}var Td=new WeakMap;function Ed(e,t,n){let r=Td.get(e);r??(r=new Map,Td.set(e,r));let i=r.get(t.stringId)??new Set;if(r.set(t.stringId,i),i.has(n.stringId)){console.warn(`connectChannel: this runtime already has a connection to [${t.stringId}] dialling as [${n.stringId}]. The peer binds each connection by that identity, so it cannot tell the two apart: every reply and push for both goes back over whichever connected first, and the other link's traffic hangs until it times out. Give each connection its own \`connectionId\` (e.g. \`connectChannel(runtime, jobsChannel, { connectionId: "jobs", … })\`) — or, if they carry the same routes over one link, use \`connectChannels\`.`);return}i.add(n.stringId)}function Dd(e,t,n){if(n.carriers==null==(n.transports==null))throw q.fromId(K.conflicting_connect_options,{detail:"connectChannel requires exactly one of `carriers` or deprecated `transports`"});let r=n.carriers?.map(e=>({carrier:e,secure:e.secure,securityLevel:e.securityLevel,available:e.available,label:e.label}))??n.transports,i=n.securityLevel??ro.authenticated,a=r.some(e=>e.secure??!0),o=n.connectionId==null?void 0:e.coordinate.withConnectionId(n.connectionId);r.some(e=>!Bu(e.carrier))&&Ed(e,n.peer,o??e.coordinate);let{mux:s,link:c,resolveHeartbeat:l,wireTap:u}=Ac({callerName:`connectChannel`,peer:n.peer,identity:o??e.coordinate,mux:n.wireMux,protocols:n.protocols,anySecure:a,storage:n.storage,link:n.link,ephemeralIdentity:n.ephemeralIdentity,reconnect:n.reconnect,heartbeat:n.heartbeat,keepLinkAlive:n.keepLinkAlive,linkKeepalive:n.linkKeepalive,wireTap:n.wireTap}),d=r.every(e=>Bu(e.carrier)),f=r.map(r=>xd({carrier:r.carrier,channel:t,runtime:e,identity:o,expectedPeer:n.peer,secure:r.secure??!0,link:c,securityLevel:r.securityLevel??i,available:r.available,label:r.label,mux:s,exchangeOnlyConnection:d,heartbeat:l,wireTap:u})),p=n.onPush==null?[]:t.toConnectorDomains.map(e=>e.wrapAsPartialLocalHandler(n.onPush)),m=r.filter(e=>!Bu(e.carrier)).map(e=>e.secure??!0?e.securityLevel??i:ro.none),h=m.length===0?ro.none:m.reduce((e,t)=>yo(t,e)?e:t),g=e.connectTo(n.peer,{transports:f,domains:[...t.toAcceptorDomains],localHandlers:p,defaultTimeout:n.defaultTimeout,reliableActionTimeout:n.reliableActionTimeout,wireMux:s,securityLevel:h,reconnect:n.reconnect??n.keepLinkAlive,connectionIdentity:o});return n.onReliableEvent!=null&&g.addReliableEventListener(n.onReliableEvent),n.onLinkEvent!=null&&g.addLinkEventListener(n.onLinkEvent),g}ro.none,ro.authenticated,ro.encrypted,uu.createChildDomain({domain:`err_nice_transport_ws`,schema:{ws_disconnected:k({message:()=>`WebSocket transport disconnected.`}),ws_create_failed:k({message:({originalError:e})=>`Failed to create WebSocket transport.${e?` Original error: ${e.message}`:``}`}),ws_error:k({message:({originalError:e})=>`WebSocket transport error.${e?` Original error: ${e.message}`:``}`})}});function Od(e,t={}){if(t.getCacheKey!=null&&t.getTransportCacheKey!=null)throw q.fromId(K.conflicting_connect_options,{detail:"wsCarrier: pass only `getCacheKey`; `getTransportCacheKey` is deprecated"});let n=t.getCacheKey??t.getTransportCacheKey,r=t.getRouteInfo;return{...Ar(typeof e==`string`?e:t=>e(t.dialContext),{secure:t.secure,getCacheKey:n==null?void 0:e=>n(e.dialContext),getRouteInfo:r==null?void 0:e=>r(e.dialContext),createWebSocket:t.createWebSocket}),available:t.available,label:t.label}}var{getOwnPropertyNames:kd,getOwnPropertySymbols:Ad}=Object,{hasOwnProperty:jd}=Object.prototype;function Md(e,t){return function(n,r,i){return e(n,r,i)&&t(n,r,i)}}function Nd(e){return function(t,n,r){if(!t||!n||typeof t!=`object`||typeof n!=`object`)return e(t,n,r);let{cache:i}=r,a=i.get(t),o=i.get(n);if(a&&o)return a===n&&o===t;i.set(t,n),i.set(n,t);let s=e(t,n,r);return i.delete(t),i.delete(n),s}}function Pd(e){return kd(e).concat(Ad(e))}var Fd=Object.hasOwn||((e,t)=>jd.call(e,t)),Id=`__v`,Ld=`__o`,Rd=`_owner`,{getOwnPropertyDescriptor:zd,keys:Bd}=Object,Vd=Object.is||function(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t};function Hd(e,t){return e===t}function Ud(e,t){return e.byteLength===t.byteLength&&ef(new Uint8Array(e),new Uint8Array(t))}function Wd(e,t,n){let r=e.length;if(t.length!==r)return!1;for(;r-->0;)if(!n.equals(e[r],t[r],r,r,e,t,n))return!1;return!0}function Gd(e,t){return e.byteLength===t.byteLength&&ef(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function Kd(e,t){return Vd(e.getTime(),t.getTime())}function qd(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function Jd(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.entries(),o,s,c=0;for(;(o=a.next())&&!o.done;){let r=t.entries(),a=!1,l=0;for(;(s=r.next())&&!s.done;){if(i[l]){l++;continue}let r=o.value,u=s.value;if(n.equals(r[0],u[0],c,l,e,t,n)&&n.equals(r[1],u[1],r[0],u[0],e,t,n)){a=i[l]=!0;break}l++}if(!a)return!1;c++}return!0}function Yd(e,t,n){let r=Bd(e),i=r.length;if(Bd(t).length!==i)return!1;for(;i-->0;)if(!nf(e,t,n,r[i]))return!1;return!0}function Xd(e,t,n){let r=Pd(e),i=r.length;if(Pd(t).length!==i)return!1;let a,o,s;for(;i-->0;)if(a=r[i],!nf(e,t,n,a)||(o=zd(e,a),s=zd(t,a),(o||s)&&(!o||!s||o.configurable!==s.configurable||o.enumerable!==s.enumerable||o.writable!==s.writable)))return!1;return!0}function Zd(e,t){return Vd(e.valueOf(),t.valueOf())}function Qd(e,t){return e.source===t.source&&e.flags===t.flags}function $d(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.values(),o,s;for(;(o=a.next())&&!o.done;){let r=t.values(),a=!1,c=0;for(;(s=r.next())&&!s.done;){if(!i[c]&&n.equals(o.value,s.value,o.value,s.value,e,t,n)){a=i[c]=!0;break}c++}if(!a)return!1}return!0}function ef(e,t){let n=e.byteLength;if(t.byteLength!==n||e.byteOffset!==t.byteOffset)return!1;for(;n-->0;)if(e[n]!==t[n])return!1;return!0}function tf(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function nf(e,t,n,r){return(r===Rd||r===Ld||r===Id)&&(e.$$typeof||t.$$typeof)?!0:Fd(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}var rf=Object.prototype.toString;function af(e){let t=lf(e),{areArraysEqual:n,areDatesEqual:r,areFunctionsEqual:i,areMapsEqual:a,areNumbersEqual:o,areObjectsEqual:s,areRegExpsEqual:c,areSetsEqual:l,getUnsupportedCustomComparator:u}=e;return function(e,d,f){if(e===d)return!0;if(e==null||d==null)return!1;let p=typeof e;if(p!==typeof d)return!1;if(p!==`object`)return p===`number`||p===`bigint`?o(e,d,f):p===`function`?i(e,d,f):!1;let m=e.constructor;if(m!==d.constructor)return!1;if(m===Object)return s(e,d,f);if(m===Array)return n(e,d,f);if(m===Date)return r(e,d,f);if(m===RegExp)return c(e,d,f);if(m===Map)return a(e,d,f);if(m===Set)return l(e,d,f);if(m===Promise)return!1;if(Array.isArray(e))return n(e,d,f);let h=rf.call(e),g=t[h];if(g)return g(e,d,f);let _=u&&u(e,d,f,h);return _?_(e,d,f):!1}}function of({circular:e,createCustomConfig:t,strict:n}){let r={areArrayBuffersEqual:Ud,areArraysEqual:n?Xd:Wd,areDataViewsEqual:Gd,areDatesEqual:Kd,areErrorsEqual:qd,areFunctionsEqual:Hd,areMapsEqual:n?Md(Jd,Xd):Jd,areNumbersEqual:Vd,areObjectsEqual:n?Xd:Yd,arePrimitiveWrappersEqual:Zd,areRegExpsEqual:Qd,areSetsEqual:n?Md($d,Xd):$d,areTypedArraysEqual:n?Md(ef,Xd):ef,areUrlsEqual:tf,getUnsupportedCustomComparator:void 0};if(t&&(r=Object.assign({},r,t(r))),e){let e=Nd(r.areArraysEqual),t=Nd(r.areMapsEqual),n=Nd(r.areObjectsEqual),i=Nd(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:e,areMapsEqual:t,areObjectsEqual:n,areSetsEqual:i})}return r}function sf(e){return function(t,n,r,i,a,o,s){return e(t,n,s)}}function cf({circular:e,comparator:t,createState:n,equals:r,strict:i}){if(n)return function(a,o){let{cache:s=e?new WeakMap:void 0,meta:c}=n();return t(a,o,{cache:s,equals:r,meta:c,strict:i})};if(e)return function(e,n){return t(e,n,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};let a={cache:void 0,equals:r,meta:void 0,strict:i};return function(e,n){return t(e,n,a)}}function lf({areArrayBuffersEqual:e,areArraysEqual:t,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:a,areMapsEqual:o,areNumbersEqual:s,areObjectsEqual:c,arePrimitiveWrappersEqual:l,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:p}){return{"[object Arguments]":c,"[object Array]":t,"[object ArrayBuffer]":e,"[object AsyncGeneratorFunction]":a,"[object BigInt]":s,"[object BigInt64Array]":f,"[object BigUint64Array]":f,"[object Boolean]":l,"[object DataView]":n,"[object Date]":r,"[object Error]":i,"[object Float16Array]":f,"[object Float32Array]":f,"[object Float64Array]":f,"[object Function]":a,"[object GeneratorFunction]":a,"[object Int8Array]":f,"[object Int16Array]":f,"[object Int32Array]":f,"[object Map]":o,"[object Number]":l,"[object Object]":(e,t,n)=>typeof e.then!=`function`&&typeof t.then!=`function`&&c(e,t,n),"[object RegExp]":u,"[object Set]":d,"[object String]":l,"[object URL]":p,"[object Uint8Array]":f,"[object Uint8ClampedArray]":f,"[object Uint16Array]":f,"[object Uint32Array]":f}}var uf=df();df({strict:!0}),df({circular:!0}),df({circular:!0,strict:!0}),df({createInternalComparator:()=>Vd}),df({strict:!0,createInternalComparator:()=>Vd}),df({circular:!0,createInternalComparator:()=>Vd}),df({circular:!0,createInternalComparator:()=>Vd,strict:!0});function df(e={}){let{circular:t=!1,createInternalComparator:n,createState:r,strict:i=!1}=e,a=af(of(e));return cf({circular:t,comparator:a,createState:r,equals:n?n(a):sf(a),strict:i})}var ff=Symbol.for(`immer-nothing`),pf=Symbol.for(`immer-draftable`),mf=Symbol.for(`immer-state`);function hf(e,...t){throw Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var gf=Object,_f=gf.getPrototypeOf,vf=`constructor`,yf=`prototype`,bf=`configurable`,xf=`enumerable`,Sf=`writable`,Cf=`value`,wf=e=>!!e&&!!e[mf];function Tf(e){return e?Of(e)||Ff(e)||!!e[pf]||!!e[vf]?.[pf]||If(e)||Lf(e):!1}var Ef=gf[yf][vf].toString(),Df=new WeakMap;function Of(e){if(!e||!Rf(e))return!1;let t=_f(e);if(t===null||t===gf[yf])return!0;let n=gf.hasOwnProperty.call(t,vf)&&t[vf];if(n===Object)return!0;if(!zf(n))return!1;let r=Df.get(n);return r===void 0&&(r=Function.toString.call(n),Df.set(n,r)),r===Ef}function kf(e,t,n=!0){Af(e)===0?(n?Reflect.ownKeys(e):gf.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function Af(e){let t=e[mf];return t?t.type_:Ff(e)?1:If(e)?2:Lf(e)?3:0}var jf=(e,t,n=Af(e))=>n===2?e.has(t):gf[yf].hasOwnProperty.call(e,t),Mf=(e,t,n=Af(e))=>n===2?e.get(t):e[t],Nf=(e,t,n,r=Af(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function Pf(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t}var Ff=Array.isArray,If=e=>e instanceof Map,Lf=e=>e instanceof Set,Rf=e=>typeof e==`object`,zf=e=>typeof e==`function`,Bf=e=>typeof e==`boolean`;function Vf(e){let t=+e;return Number.isInteger(t)&&String(t)===e}var Hf=e=>Rf(e)?e?.[mf]:null,Uf=e=>e.copy_||e.base_,Wf=e=>e.modified_?e.copy_:e.base_;function Gf(e,t){if(If(e))return new Map(e);if(Lf(e))return new Set(e);if(Ff(e))return Array[yf].slice.call(e);let n=Of(e);if(t===!0||t===`class_only`&&!n){let t=gf.getOwnPropertyDescriptors(e);delete t[mf];let n=Reflect.ownKeys(t);for(let r=0;r<n.length;r++){let i=n[r],a=t[i];a[Sf]===!1&&(a[Sf]=!0,a[bf]=!0),(a.get||a.set)&&(t[i]={[bf]:!0,[Sf]:!0,[xf]:a[xf],[Cf]:e[i]})}return gf.create(_f(e),t)}else{let t=_f(e);if(t!==null&&n)return{...e};let r=gf.create(t);return gf.assign(r,e)}}function Kf(e,t=!1){return Yf(e)||wf(e)||!Tf(e)?e:(Af(e)>1&&gf.defineProperties(e,{set:Jf,add:Jf,clear:Jf,delete:Jf}),gf.freeze(e),t&&kf(e,(e,t)=>{Kf(t,!0)},!1),e)}function qf(){hf(2)}var Jf={[Cf]:qf};function Yf(e){return e===null||!Rf(e)?!0:gf.isFrozen(e)}var Xf=`MapSet`,Zf=`Patches`,Qf=`ArrayMethods`,$f={};function ep(e){let t=$f[e];return t||hf(0,e),t}var tp=e=>!!$f[e];function np(e,t){$f[e]||($f[e]=t)}var rp,ip=()=>rp,ap=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:tp(Xf)?ep(Xf):void 0,arrayMethodsPlugin_:tp(Qf)?ep(Qf):void 0});function op(e,t){t&&(e.patchPlugin_=ep(Zf),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function sp(e){cp(e),e.drafts_.forEach(up),e.drafts_=null}function cp(e){e===rp&&(rp=e.parent_)}var lp=e=>rp=ap(rp,e);function up(e){let t=e[mf];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function dp(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];if(e!==void 0&&e!==n){n[mf].modified_&&(sp(t),hf(4)),Tf(e)&&(e=fp(t,e));let{patchPlugin_:r}=t;r&&r.generateReplacementPatches_(n[mf].base_,e,t)}else e=fp(t,n);return pp(t,e,!0),sp(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e===ff?void 0:e}function fp(e,t){if(Yf(t))return t;let n=t[mf];if(!n)return xp(t,e.handledSet_,e);if(!hp(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){let{callbacks_:t}=n;if(t)for(;t.length>0;)t.pop()(e);yp(n,e)}return n.copy_}function pp(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Kf(t,n)}function mp(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var hp=(e,t)=>e.scope_===t,gp=[];function _p(e,t,n,r){let i=Uf(e),a=e.type_;if(r!==void 0&&Mf(i,r,a)===t){Nf(i,r,n,a);return}if(!e.draftLocations_){let t=e.draftLocations_=new Map;kf(i,(e,n)=>{if(wf(n)){let r=t.get(n)||[];r.push(e),t.set(n,r)}})}let o=e.draftLocations_.get(t)??gp;for(let e of o)Nf(i,e,n,a)}function vp(e,t,n){e.callbacks_.push(function(r){let i=t;if(!i||!hp(i,r))return;r.mapSetPlugin_?.fixSetContents(i);let a=Wf(i);_p(e,i.draft_??i,a,n),yp(i,r)})}function yp(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){let{patchPlugin_:n}=t;if(n){let r=n.getPath(e);r&&n.generatePatches_(e,r,t)}mp(e)}}function bp(e,t,n){let{scope_:r}=e;if(wf(n)){let i=n[mf];hp(i,r)&&i.callbacks_.push(function(){kp(e),_p(e,n,Wf(i),t)})}else Tf(n)&&e.callbacks_.push(function(){let i=Uf(e);e.type_===3?i.has(n)&&xp(n,r.handledSet_,r):Mf(i,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&xp(Mf(e.copy_,t,e.type_),r.handledSet_,r)})}function xp(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||wf(e)||t.has(e)||!Tf(e)||Yf(e)?e:(t.add(e),kf(e,(r,i)=>{if(wf(i)){let t=i[mf];hp(t,n)&&(Nf(e,r,Wf(t),e.type_),mp(t))}else Tf(i)&&xp(i,t,n)}),e)}function Sp(e,t){let n=Ff(e),r={type_:+!!n,scope_:t?t.scope_:ip(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0},i=r,a=Cp;n&&(i=[r],a=wp);let{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var Cp={get(e,t){if(t===mf)return e;if(t===`constructor`||t===`__proto__`){let n=Uf(e)[t];return new Proxy(n||{},{get:(e,t)=>t===`__proto__`||t===`prototype`?Object.freeze(Object.create(null)):Reflect.get(e,t),set:()=>!0,apply:(e,t,n)=>Reflect.apply(e,t,n)})}let n=e.scope_.arrayMethodsPlugin_,r=e.type_===1&&typeof t==`string`;if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);let i=Uf(e);if(!jf(i,t,e.type_))return Ep(e,i,t);let a=i[t];if(e.finalized_||!Tf(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&Vf(t))return a;if(a===Tp(e.base_,t)){kp(e);let n=e.type_===1?+t:t,r=jp(e.scope_,a,e,n);return e.copy_[n]=r}return a},has(e,t){return t===`constructor`||t===`__proto__`||t===`prototype`?!1:t in Uf(e)},ownKeys(e){return Reflect.ownKeys(Uf(e))},set(e,t,n){if(t===`constructor`||t===`__proto__`||t===`prototype`)return!0;let r=Dp(Uf(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){let r=Tp(Uf(e),t),i=r?.[mf];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(Pf(n,r)&&(n!==void 0||jf(e.base_,t,e.type_)))return!0;kp(e),Op(e)}return e.copy_[t]===n&&(n!==void 0||jf(e.copy_,t,e.type_))||Number.isNaN(n)&&Number.isNaN(e.copy_[t])?!0:(e.copy_[t]=n,e.assigned_.set(t,!0),bp(e,t,n),!0)},deleteProperty(e,t){return kp(e),Tp(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),Op(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=Uf(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[Sf]:!0,[bf]:e.type_!==1||t!==`length`,[xf]:r[xf],[Cf]:n[t]}},defineProperty(){hf(11)},getPrototypeOf(e){return _f(e.base_)},setPrototypeOf(){hf(12)}},wp={};for(let e in Cp){let t=Cp[e];wp[e]=function(){let e=arguments;return e[0]=e[0][0],t.apply(this,e)}}wp.deleteProperty=function(e,t){return wp.set.call(this,e,t,void 0)},wp.set=function(e,t,n){return Cp.set.call(this,e[0],t,n,e[0])};function Tp(e,t){let n=e[mf];return(n?Uf(n):e)[t]}function Ep(e,t,n){let r=Dp(t,n);return r?Cf in r?r[Cf]:r.get?.call(e.draft_):void 0}function Dp(e,t){if(!(t in e))return;let n=_f(e);for(;n;){let e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=_f(n)}}function Op(e){e.modified_||(e.modified_=!0,e.parent_&&Op(e.parent_))}function kp(e){e.copy_||=(e.assigned_=new Map,Gf(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Ap=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,t,n)=>{if(zf(e)&&!zf(t)){let n=t;t=e;let r=this;return function(e=n,...i){return r.produce(e,e=>t.call(this,e,...i))}}zf(t)||hf(6),n!==void 0&&!zf(n)&&hf(7);let r;if(Tf(e)){let i=lp(this),a=jp(i,e,void 0),o=!0;try{r=t(a),o=!1}finally{o?sp(i):cp(i)}return op(i,n),dp(r,i)}else if(!e||!Rf(e)){if(r=t(e),r===void 0&&(r=e),r===ff&&(r=void 0),this.autoFreeze_&&Kf(r,!0),n){let t=[],i=[];ep(Zf).generateReplacementPatches_(e,r,{patches_:t,inversePatches_:i}),n(t,i)}return r}else hf(1,e)},this.produceWithPatches=(e,t)=>{if(zf(e))return(t,...n)=>this.produceWithPatches(t,t=>e(t,...n));let n,r;return[this.produce(e,t,(e,t)=>{n=e,r=t}),n,r]},Bf(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Bf(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Bf(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Tf(e)||hf(8),wf(e)&&(e=Mp(e));let t=lp(this),n=jp(t,e,void 0);return n[mf].isManual_=!0,cp(t),n}finishDraft(e,t){let n=e&&e[mf];(!n||!n.isManual_)&&hf(9);let{scope_:r}=n;return op(r,t),dp(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){let r=t[n];if(r.path.length===0&&r.op===`replace`){e=r.value;break}}n>-1&&(t=t.slice(n+1));let r=ep(Zf).applyPatches_;return wf(e)?r(e,t):this.produce(e,e=>r(e,t))}};function jp(e,t,n,r){let[i,a]=If(t)?ep(Xf).proxyMap_(t,n):Lf(t)?ep(Xf).proxySet_(t,n):Sp(t,n);return(n?.scope_??ip()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?vp(n,a,r):a.callbacks_.push(function(e){e.mapSetPlugin_?.fixSetContents(a);let{patchPlugin_:t}=e;a.modified_&&t&&t.generatePatches_(a,[],e)}),i}function Mp(e){return wf(e)||hf(10,e),Np(e)}function Np(e){if(!Tf(e)||Yf(e))return e;let t=e[mf],n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Gf(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Gf(e,!0);return kf(n,(e,t)=>{Nf(n,e,Np(t))},r),t&&(t.finalized_=!1),n}function Pp(){function e(n,r=[]){if(n.key_!==void 0){let e=n.parent_.copy_??n.parent_.base_,t=Hf(Mf(e,n.key_)),i=Mf(e,n.key_);if(i===void 0||i!==n.draft_&&i!==n.base_&&i!==n.copy_||t!=null&&t.base_!==n.base_)return null;let a=n.parent_.type_===3,o;if(a){let e=n.parent_;o=Array.from(e.drafts_.keys()).indexOf(n.key_)}else o=n.key_;if(!(a&&e.size>o||jf(e,o)))return null;r.push(o)}if(n.parent_)return e(n.parent_,r);r.reverse();try{t(n.copy_,r)}catch{return null}return r}function t(e,t){let n=e;for(let e=0;e<t.length-1;e++){let r=t[e];if(n=Mf(n,r),!Rf(n)||n===null)throw Error(`Cannot resolve path at '${t.join(`/`)}'`)}return n}let n=`replace`,r=`remove`;function i(e,t,n){if(e.scope_.processedForPatches_.has(e))return;e.scope_.processedForPatches_.add(e);let{patches_:r,inversePatches_:i}=n;switch(e.type_){case 0:case 2:return o(e,t,r,i);case 1:return a(e,t,r,i);case 3:return s(e,t,r,i)}}function a(e,t,i,a){let{base_:o,assigned_:s}=e,c=e.copy_;c.length<o.length&&([o,c]=[c,o],[i,a]=[a,i]);let l=e.allIndicesReassigned_===!0;for(let e=0;e<o.length;e++){let r=c[e],u=o[e];if((l||s?.get(e.toString()))&&r!==u){let o=r?.[mf];if(o&&o.modified_)continue;let s=t.concat([e]);i.push({op:n,path:s,value:d(r)}),a.push({op:n,path:s,value:d(u)})}}for(let e=o.length;e<c.length;e++){let n=t.concat([e]);i.push({op:`add`,path:n,value:d(c[e])})}for(let e=c.length-1;o.length<=e;--e){let n=t.concat([e]);a.push({op:r,path:n})}}function o(e,t,i,a){let{base_:o,copy_:s,type_:c}=e;kf(e.assigned_,(e,l)=>{let u=Mf(o,e,c),f=Mf(s,e,c),p=l?jf(o,e)?n:`add`:r;if(u===f&&p===n)return;let m=t.concat(e);i.push(p===r?{op:p,path:m}:{op:p,path:m,value:d(f)}),a.push(p===`add`?{op:r,path:m}:p===r?{op:`add`,path:m,value:d(u)}:{op:n,path:m,value:d(u)})})}function s(e,t,n,i){let{base_:a,copy_:o}=e,s=0;a.forEach(e=>{if(!o.has(e)){let a=t.concat([s]);n.push({op:r,path:a,value:e}),i.unshift({op:`add`,path:a,value:e})}s++}),s=0,o.forEach(e=>{if(!a.has(e)){let a=t.concat([s]);n.push({op:`add`,path:a,value:e}),i.unshift({op:r,path:a,value:e})}s++})}function c(e,t,r){let{patches_:i,inversePatches_:a}=r;i.push({op:n,path:[],value:t===ff?void 0:t}),a.push({op:n,path:[],value:e})}function l(e,t){return t.forEach(t=>{let{path:i,op:a}=t,o=e;for(let e=0;e<i.length-1;e++){let t=Af(o),n=i[e];typeof n!=`string`&&typeof n!=`number`&&(n=``+n),(t===0||t===1)&&(n===`__proto__`||n===vf)&&hf(19),zf(o)&&n===yf&&hf(19),o=Mf(o,n),Rf(o)||hf(18,i.join(`/`))}let s=Af(o),c=u(t.value),l=i[i.length-1];switch(a){case n:switch(s){case 2:return o.set(l,c);case 3:hf(16);default:return o[l]=c}case`add`:switch(s){case 1:return l===`-`?o.push(c):o.splice(l,0,c);case 2:return o.set(l,c);case 3:return o.add(c);default:return o[l]=c}case r:switch(s){case 1:return o.splice(l,1);case 2:return o.delete(l);case 3:return o.delete(t.value);default:return delete o[l]}default:hf(17,a)}}),e}function u(e){if(!Tf(e))return e;if(Ff(e))return e.map(u);if(If(e))return new Map(Array.from(e.entries()).map(([e,t])=>[e,u(t)]));if(Lf(e))return new Set(Array.from(e).map(u));let t=Object.create(_f(e));for(let n in e)t[n]=u(e[n]);return jf(e,pf)&&(t[pf]=e[pf]),t}function d(e){return wf(e)?u(e):e}np(Zf,{applyPatches_:l,generatePatches_:i,generateReplacementPatches_:c,getPath:e})}var Fp=new Ap,Ip=Fp.produce,Lp=Fp.produceWithPatches.bind(Fp),Rp=Fp.applyPatches.bind(Fp);Pp();function zp(e,t,n){let r=t(e.state);return()=>{let i=e.state,a=t(i);if(a===r)return;if(uf(a,r)){r=a;return}let o=r;r=a,n(a,i,o)}}function Bp(e,t){return n=>{let r=e(n.state);return(i=!1)=>{let a=n.state,o=e(a);if(!i){if(o===r)return;if(uf(o,r)){r=o;return}}let s=r;if(r=o,n._hasPatchListeners()){let[e,r,i]=Lp(a,e=>{t(o,e,a,s)});n._updateStateWithoutReaction(e),r.length>0&&n._emitPatches(r,i)}else{let e=Ip(a,e=>{t(o,e,a,s)});n._updateStateWithoutReaction(e)}}}}var Vp=class{currentState;createInitialState;ssr=!1;listeners=new Set;reactionCreators=[];reactions=[];clientSubscriptions=[];_patchListeners=[];constructor(e){e instanceof Function?(this.createInitialState=e,this.currentState=e()):(this.createInitialState=()=>e,this.currentState=e)}get state(){return Object.freeze(this.currentState)}_setInternalOptions({ssr:e,reactionCreators:t=[]}){this.ssr=e,this.reactionCreators=t,this.reactions=t.map(e=>e(this))}_getReactionCreators(){return this.reactionCreators}_instantiateReactions(){this.reactions=this.reactionCreators.map(e=>e(this))}_getInitialState(){return this.createInitialState()}_hasPatchListeners(){return this._patchListeners.length>0}_emitPatches(e,t){for(let n of this._patchListeners)n(e,t)}_updateStateWithoutReaction(e){this.currentState=e}_updateState(e){this.currentState=e;for(let e of this.reactions)e();if(!this.ssr){for(let e of this.clientSubscriptions)e();for(let e of this.listeners)e()}}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}watch(e,t){if(this.ssr)return()=>{console.warn(`@nice-code/state: Subscriptions made on the server side are not registered, so this unsubscribe call does nothing.`)};let n=zp(this,e,t);return this.clientSubscriptions.push(n),()=>{this.clientSubscriptions=this.clientSubscriptions.filter(e=>e!==n)}}createReaction(e,t,{runNow:n=!1,runNowWithSideEffects:r=!1}={}){let i=Bp(e,t);this.reactionCreators.push(i);let a=i(this);return this.reactions.push(a),(n||r)&&(a(!0),r&&!this.ssr&&this._updateState(this.currentState)),()=>{this.reactions=this.reactions.filter(e=>e!==a),this.reactionCreators=this.reactionCreators.filter(e=>e!==i)}}listenToPatches(e){return this._patchListeners.push(e),()=>{this._patchListeners=this._patchListeners.filter(t=>t!==e)}}update(e,t){Kp(this,e,t)}replace(e){e!==this.currentState&&(this._hasPatchListeners()&&this._emitPatches([{op:`replace`,path:[],value:e}],[{op:`replace`,path:[],value:this.currentState}]),this._updateState(e))}replaceFromCurrent(e){this.replace(e(this.currentState))}applyPatches(e){Hp(this,e)}};function Hp(e,t){let n=e.state,r=Rp(n,t);r!==n&&e._updateState(r)}function Up(e,t,n){if(!n&&!t&&typeof e==`object`&&e)throw Error(`@nice-code/state: an update function returned a value without modifying its draft. Update functions are mutate-only — a returned state is ignored (unlike immer's produce). To reset or swap the state wholesale, use store.replace(next); to change part of it, mutate the draft.`)}function Wp(e,t){if(typeof t==`function`){let n,r=!1,[i,a,o]=Lp(e,i=>{n=t(i,e),r=n===i});return Up(n,i!==e,r),[i,a,o]}let n=e,r=[],i=[];for(let e of t){let t,a=!1,[o,s,c]=Lp(n,r=>{t=e(r,n),a=t===r});Up(t,o!==n,a),n=o,r.push(...s),i.push(...c)}return[n,r,i]}function Gp(e,t){if(typeof t==`function`){let n,r=!1,i=Ip(e,i=>{n=t(i,e),r=n===i});return Up(n,i!==e,r),i}return t.reduce((e,t)=>{let n,r=!1,i=Ip(e,i=>{n=t(i,e),r=n===i});return Up(n,i!==e,r),i},e)}function Kp(e,t,n){let r=e.state,i;if(e._hasPatchListeners()||n!=null){let[a,o,s]=Wp(r,t);o.length>0&&(n?.(o,s),e._emitPatches(o,s)),i=a}else i=Gp(r,t);i!==r&&e._updateState(i)}var qp=ue.createChildDomain({domain:`err_nice_realm`,schema:{schema_mismatch:k({message:({realmId:e,clientHash:t,serverHash:n})=>`Realm "${e}" schema mismatch — avatar ${t.slice(0,12)}… vs server ${n.slice(0,12)}…. The client and server were built from different realm definitions; refusing to attach (silent token skew would corrupt state).`,context:{required:!0}}),realm_unknown:k({message:({realmId:e})=>`This server hosts no realm with id "${e}".`,context:{required:!0}}),unauthorized_avatar_type:k({message:({avatarType:e,expected:t})=>`Client type "${e}" is not permitted here (expected: ${t.join(`, `)}).`,context:{required:!0}}),avatar_unresolved:k({message:({realmId:e})=>`This connection's identity could not be resolved to an avatar of realm "${e}" — the server's resolveAvatar returned undefined (or the attachment carries no coordinate).`,context:{required:!0}}),insufficient_security:k({message:({realmId:e,required:t,actual:n})=>`Realm "${e}" requires a "${t}" connection but this one negotiated "${n}". Connect with at least the required security level — the realm refuses to move avatar data below it.`,context:{required:!0}}),unauthorized_coordinate:k({message:({path:e})=>`This avatar's coordinates may not write "${e}".`,context:{required:!0}}),value_invalid:k({message:({path:e,expected:t})=>`The value written to "${e}" does not match the schema (expected ${t}).`,context:{required:!0}}),limits_exceeded:k({message:({limit:e})=>`Ingress limit exceeded: ${e}.`,context:{required:!0}}),intent_unknown:k({message:({intent:e})=>`Unknown intent "${e}".`,context:{required:!0}}),version_gap_unrecoverable:k({message:({lastKnownVersion:e,oldestReplayable:t})=>`Version ${e} is behind the replayable window (oldest ${t}) — full rehydration required.`,context:{required:!0}}),write_before_hydrate:k({message:({realmId:e})=>`A write on "${e}" was queued for the first hydrate, which never arrived (the realm detached, or the pending expiry passed first) — nothing was sent.`,context:{required:!0}}),frame_too_stale:k({message:({basisVersion:e})=>`The optimistic frame (basis ${e}) expired before it could be confirmed — outcome unknown (it may have committed; re-read state rather than re-issuing a non-idempotent intent).`,context:{required:!0}}),durable_backlog_overflow:k({message:({pendingFrames:e})=>`The durable-write backlog is full (${e} unconfirmed reassert frames) — this write was rejected. Re-sync from your source of truth after reconnecting.`,context:{required:!0}}),frame_invalid:k({message:({reason:e})=>`Malformed realm frame: ${e}.`,context:{required:!0}}),write_target_missing:k({message:({path:e})=>`The write to "${e}" could not be applied — its parent no longer exists (a pruned entry or a transient region reset since the write's basis). Re-read state instead of re-issuing.`,context:{required:!0}})}});function Jp(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&!(e instanceof Uint8Array)}function Yp(e,t){switch(e.kind){case`string`:return typeof t==`string`?e.maxLength!=null&&t.length>e.maxLength?{path:[],expected:`a string of at most ${e.maxLength} characters`}:void 0:{path:[],expected:`string`};case`number`:return typeof t==`number`?(e.min!=null||e.max!=null||e.integer===!0)&&!Number.isFinite(t)?{path:[],expected:`a finite number`}:e.integer===!0&&!Number.isInteger(t)?{path:[],expected:`an integer`}:e.min!=null&&t<e.min?{path:[],expected:`a number >= ${e.min}`}:e.max!=null&&t>e.max?{path:[],expected:`a number <= ${e.max}`}:void 0:{path:[],expected:`number`};case`boolean`:return typeof t==`boolean`?void 0:{path:[],expected:`boolean`};case`literal`:return t===e.value?void 0:{path:[],expected:`literal ${JSON.stringify(e.value)}`};case`optional`:return t===void 0?void 0:Yp(e.inner,t);case`union`:for(let n of e.options)if(Yp(n,t)==null)return;return{path:[],expected:`one of the union options`};case`object`:if(!Jp(t))return{path:[],expected:`object`};for(let n of Object.keys(t))if(e.entries[n]==null)return{path:[n],expected:`no such key in the schema`};for(let[n,r]of Object.entries(e.entries)){let e=t[n];if(e===void 0){if(r.kind!==`optional`)return{path:[n],expected:r.kind};continue}let i=Yp(r,e);if(i!=null)return{path:[n,...i.path],expected:i.expected}}return;case`record`:if(!Jp(t))return{path:[],expected:`record`};if(e.maxKeys!=null&&Object.keys(t).length>e.maxKeys)return{path:[],expected:`a record with at most ${e.maxKeys} entries`};for(let[n,r]of Object.entries(t)){let t=Yp(e.value,r);if(t!=null)return{path:[n,...t.path],expected:t.expected}}return;case`array`:if(!Array.isArray(t))return{path:[],expected:`array`};if(e.maxItems!=null&&t.length>e.maxItems)return{path:[],expected:`an array of at most ${e.maxItems} items`};for(let n=0;n<t.length;n++){let r=Yp(e.item,t[n]);if(r!=null)return{path:[n,...r.path],expected:r.expected}}return;case`standard`:{let n=e.schema[`~standard`].validate(t);return n instanceof Promise?{path:[],expected:`a synchronous standard-schema validator`}:n.issues==null?void 0:{path:[],expected:n.issues[0]?.message??`standard-schema pass`}}}}var Xp=class{_toId=new Map;_toKey=[];intern(e){let t=this._toId.get(e);return t??(t=this._toKey.length,this._toId.set(e,t),this._toKey.push(e)),t}idOf(e){return this._toId.get(e)}keyOf(e){return this._toKey[e]}load(e){for(let[t,n]of e)this._toId.set(t,n),this._toKey[n]=t}get size(){return this._toId.size}clear(){this._toId.clear(),this._toKey.length=0}},Zp={hello:0,hydrate:1,patches:2,write:3,intent:4,ack:5,reject:6,keyDict:7,detach:8,clientCaps:9,batch:10},Qp=Object.fromEntries(Object.entries(Zp).map(([e,t])=>[t,e])),$p={batch:`b1`},em={replace:0,add:1,remove:2};function Q(e){throw qp.fromId(`frame_invalid`,{reason:e})}function tm(e,t){return(typeof e!=`number`||!Number.isInteger(e))&&Q(`${t} must be an int`),e}function nm(e,t){return typeof e!=`string`&&Q(`${t} must be a string`),e}function rm(e){let t=tm(e,`slot`);return(t<0||t>255)&&Q(`slot ${t} out of range`),t}function im(e){(!Array.isArray(e)||e.length===0)&&Q(`op path must be a non-empty array`);for(let t of e)typeof t==`number`?(!Number.isInteger(t)||t<0)&&Q(`invalid path token ${t}`):typeof t!=`string`&&Q(`path segments must be ints or strings`);return e}function am(e){Array.isArray(e)||Q(`ops must be an array`);for(let t of e){(!Array.isArray(t)||t.length<2||t.length>3)&&Q(`malformed op`);let e=tm(t[0],`op kind`);e!==em.replace&&e!==em.add&&e!==em.remove&&Q(`unknown op kind ${e}`),im(t[1]),e===em.remove&&t.length!==2&&Q(`remove op carries no value`),e!==em.remove&&t.length!==3&&Q(`replace/add op requires a value`)}return e}function om(e){return(!Array.isArray(e)||e.length!==3)&&Q(`hydrate limits must be 3 ints`),tm(e[0],`limits.maxPatchesPerFrame`),tm(e[1],`limits.maxFrameBytes`),tm(e[2],`limits.writeRatePerSecond`),e}function sm(e){return(!Array.isArray(e)||e.length!==3)&&Q(`hydrate avatar must be 3 strings`),nm(e[0],`avatar.type`),nm(e[1],`avatar.persistentId`),nm(e[2],`avatar.instanceId`),e}var cm=16,lm=32;function um(e){Array.isArray(e)||Q(`clientCaps features must be an array`),e.length>cm&&Q(`clientCaps features list too long`);for(let t of e)nm(t,`clientCaps feature`).length>lm&&Q(`clientCaps feature too long`);return e}function dm(e){Array.isArray(e)||Q(`keyDict entries must be an array`);for(let t of e)(!Array.isArray(t)||t.length!==2)&&Q(`malformed keyDict entry`),nm(t[0],`keyDict key`),tm(t[1],`keyDict id`)<0&&Q(`keyDict id must be >= 0`);return e}function fm(e){return Vs([Zp.hello,e.slot,e.realmId,e.schemaHash,e.lastKnownVersion,e.epoch??null])}function pm(e){return Vs([Zp.write,e.slot,e.clientSeq,e.basisVersion,e.ops])}function mm(e){return Vs([Zp.intent,e.slot,e.clientSeq,e.intentToken,e.input])}function hm(e){return Vs([Zp.detach,e.slot,e.reason??null])}function gm(e){return Vs([Zp.clientCaps,e.slot,e.features])}function _m(e){let t;try{t=_s(e)}catch{Q(`not msgpack`)}(!Array.isArray(t)||t.length<2)&&Q(`frame must be a [kind, slot, …] array`);let n=tm(t[0],`kind`),r=rm(t[1]);switch(n){case Zp.hello:return t.length!==6&&Q(`hello must have 6 elements`),t[5]!=null&&typeof t[5]!=`string`&&Q(`hello epoch must be a string`),{kind:n,slot:r,realmId:nm(t[2],`realmId`),schemaHash:nm(t[3],`schemaHash`),lastKnownVersion:tm(t[4],`lastKnownVersion`),epoch:t[5]??void 0};case Zp.hydrate:return t.length!==9&&Q(`hydrate must have 9 elements`),t[3]instanceof Uint8Array||Q(`hydrate stateBlob must be bytes`),typeof t[5]!=`boolean`&&Q(`hydrate more must be a boolean`),{kind:n,slot:r,version:tm(t[2],`version`),stateBlob:t[3],keyDictSeed:dm(t[4]),more:t[5],epoch:nm(t[6],`hydrate epoch`),limits:om(t[7]),avatar:sm(t[8])};case Zp.patches:return t.length!==5&&Q(`patches must have 5 elements`),{kind:n,slot:r,fromVersion:tm(t[2],`fromVersion`),toVersion:tm(t[3],`toVersion`),ops:am(t[4])};case Zp.write:return t.length!==5&&Q(`write must have 5 elements`),{kind:n,slot:r,clientSeq:tm(t[2],`clientSeq`),basisVersion:tm(t[3],`basisVersion`),ops:am(t[4])};case Zp.intent:return t.length!==5&&Q(`intent must have 5 elements`),{kind:n,slot:r,clientSeq:tm(t[2],`clientSeq`),intentToken:tm(t[3],`intentToken`),input:t[4]};case Zp.ack:return t.length!==4&&Q(`ack must have 4 elements`),{kind:n,slot:r,clientSeq:tm(t[2],`clientSeq`),version:tm(t[3],`version`)};case Zp.reject:return t.length!==4&&Q(`reject must have 4 elements`),(typeof t[3]!=`object`||t[3]==null||Array.isArray(t[3]))&&Q(`reject error must be a map`),{kind:n,slot:r,clientSeq:tm(t[2],`clientSeq`),error:t[3]};case Zp.keyDict:return t.length!==3&&Q(`keyDict must have 3 elements`),{kind:n,slot:r,entries:dm(t[2])};case Zp.detach:return t.length!==3&&Q(`detach must have 3 elements`),t[2]!=null&&typeof t[2]!=`string`&&Q(`detach reason must be a string`),{kind:n,slot:r,reason:t[2]??void 0};case Zp.clientCaps:return t.length!==3&&Q(`clientCaps must have 3 elements`),{kind:n,slot:r,features:um(t[2])};case Zp.batch:{t.length!==3&&Q(`batch must have 3 elements`),Array.isArray(t[2])||Q(`batch payloads must be an array`);let e=[];for(let n of t[2]){n instanceof Uint8Array||Q(`batch payload must be bytes`);let t=_m(n);t.kind===Zp.batch&&Q(`batch may not nest`),e.push(t)}return{kind:n,slot:r,frames:e}}default:Q(`unknown frame kind ${n}`)}}var vm=new Set([`__proto__`,`constructor`,`prototype`]);function ym(e){return typeof e==`string`&&vm.has(e)}function bm(e){return e.some(ym)}var xm={replace:em.replace,add:em.add,remove:em.remove},Sm={[em.replace]:`replace`,[em.add]:`add`,[em.remove]:`remove`};function Cm(e){return e.kind===`optional`?Cm(e.inner):e}function wm(e,t){let n,r=e;for(let e of t){if(r!=null)n=typeof e==`string`?r[e]:void 0,r=void 0;else if(n!=null){let t=Cm(n);if(t.kind===`object`)n=t.entries[e];else if(t.kind===`record`)n=t.value;else return}if(n==null)return}return n}function Tm(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n)return;n=n[e]}return n}function Em(e,t){for(let n=1;n<t.length;n++){let r=wm(e,t.slice(0,n));if(r!=null&&Cm(r).kind===`array`)return n}}function Dm(e,t,n){let r=[],i=new Set;for(let a of e){let e=Em(n,a.path);if(e==null||e===a.path.length){r.push(a);continue}let o=a.path.slice(0,e),s=o.join(`\0`);i.has(s)||(i.add(s),r.push({op:`replace`,path:o,value:Tm(t,o)}))}return r}function Om(e,t,n){return e.map(e=>{let r=t.tokenizePath(e.path,n);return e.op===`remove`?[em.remove,r]:[xm[e.op],r,e.value]})}function km(e,t,n){return e.map(e=>{let r=t.detokenizePath(e[1],n);return e[0]===em.remove?{op:`remove`,path:r}:{op:Sm[e[0]],path:r,value:e[2]}})}function Am(e){return e===`encrypted`?ro.encrypted:ro.authenticated}function jm(e,t){return t==null?e:e===`encrypted`||t===`encrypted`?`encrypted`:`authenticated`}function Mm(e,t,n){let r=e.securityLevel;if(r==null)return;let i=Am(jm(t.security,n));if(!yo(r,i))return qp.fromId(`insufficient_security`,{realmId:t.id,required:i,actual:r})}function Nm(e,t,n=[]){if(e===t)return[];if(!Pm(e)||!Pm(t))return[{op:`replace`,path:[...n],value:t}];let r=[];for(let i of Object.keys(t))i in e?r.push(...Nm(e[i],t[i],[...n,i])):r.push({op:`add`,path:[...n,i],value:t[i]});for(let i of Object.keys(e))i in t||r.push({op:`remove`,path:[...n,i]});return r}function Pm(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Fm(e,t,n){if(typeof e==`function`)return e(t);switch(e.kind){case`serverOnly`:return`serverOnly`;case`serverChecked`:return n==null?!0:e.fn({...t,...n});case`all`:for(let r of e.conds){let e=Fm(r,t,n);if(e!==!0)return e}return!0}}function Im(e){return e.kind===`optional`?Im(e.inner):e}function Lm(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n)return;n=n[e]}return n}var Rm=class extends Error{constructor(e){super(`subtree write expands past the ${e}-leaf limit`)}};function zm(e){let t=wm(e.schemaRoot,e.path);if(t==null)throw Error(`expandWriteToLeaves: path leaves the schema (${e.path.join(`.`)})`);let n=[],r=t=>{if(n.length>=e.maxLeaves)throw new Rm(e.maxLeaves);n.push(t)},i=(e,t,n,a)=>{let o=Im(e);if(o.kind===`object`){for(let[e,r]of Object.entries(o.entries))i(r,[...t,e],n?.[e],a?.[e]);return}if(o.kind===`record`){let e=new Set;if(typeof n==`object`&&n)for(let t of Object.keys(n))e.add(t);if(typeof a==`object`&&a)for(let t of Object.keys(a))e.add(t);for(let r of e)i(o.value,[...t,r],n?.[r],a?.[r]);return}r(t)},a=Lm(e.state,e.path);return i(t,[...e.path],e.op===`remove`?void 0:e.value,a),n}function Bm(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n)return;n=n[e]}return n}function Vm(e){let{realm:t,avatar:n,state:r,basisVersion:i}=e;for(let a of e.patches){let e=a.path,o=wm(t.stateDef,e);if(o==null)return qp.fromId(`value_invalid`,{path:e.join(`.`),expected:`a schema path`});if(a.op!==`remove`){let n=Yp(o,a.value);if(n!=null)return qp.fromId(`value_invalid`,{path:[...e,...n.path].join(`.`),expected:n.expected});for(let n=1;n<e.length;n++){let i=wm(t.stateDef,e.slice(0,n));for(;i?.kind===`optional`;)i=i.inner;if(i?.kind!==`record`||i.maxKeys==null)continue;let a=Bm(r,e.slice(0,n));if(!(typeof a!=`object`||!a||Array.isArray(a))&&!(e[n]in a)&&Object.keys(a).length>=i.maxKeys)return qp.fromId(`value_invalid`,{path:e.slice(0,n).join(`.`),expected:`a record with at most ${i.maxKeys} entries`})}}let s=zm({schemaRoot:t.stateDef,path:e,op:a.op,value:a.value,state:r,maxLeaves:1/0});for(let o of s){let s=t.ruleTrie.match(o);if(s==null)return qp.fromId(`unauthorized_coordinate`,{path:o.join(`.`)});let c=o.slice(e.length),l=Fm(s.rule.alter,{avatar:n,params:s.params,prev:Hm(r,o),next:a.op===`remove`?void 0:Hm(a.value,c),state:r,basisVersion:i},void 0);if(l===`serverOnly`)return qp.fromId(`unauthorized_coordinate`,{path:o.join(`.`)});if(l!==!0)return l}}return!0}function Hm(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n)return;n=n[e]}return n}function Um(e,t,n){let r;for(let i=0;i<t.length;i++){let a=t[i];if(a.op!==`remove`&&a.path.length>1)for(let o=1;o<a.path.length;o++){let s=a.path.slice(0,o);if(Wm(e,r??t.slice(0,i),s))continue;let c=o===1?void 0:wm(n,s.slice(0,-1));if(c!=null&&Gm(c).kind===`record`)break;let l=wm(n,s);if(l==null)break;let u=Gm(l).kind;if(u!==`object`&&u!==`record`)break;r??=t.slice(0,i),r.push({op:`add`,path:s,value:{}})}r?.push(a)}return r??t}function Wm(e,t,n){for(let e=t.length-1;e>=0;e--){let r=t[e];if(!(r.path.length>n.length)&&r.path.every((e,t)=>String(e)===String(n[t])))return r.op===`remove`?!1:Km(r.value,n.slice(r.path.length))!==void 0}return Km(e,n)!==void 0}function Gm(e){return e.kind===`optional`?Gm(e.inner):e}function Km(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n)return;n=n[e]}return n}function qm(){let e=`pending`,t,n,r,i,a,o=()=>(r??=e===`confirmed`&&t!=null?Promise.resolve(t):e===`rejected`?Promise.reject(n):new Promise((e,t)=>{i=e,a=t}),r);return{handle:{get status(){return e},get error(){return n},then:(e,t)=>o().then(e,t)},confirm(n){e===`pending`&&(e=`confirmed`,t=n,i?.(n))},reject(t){e===`pending`&&(e=`rejected`,n=t,a?.(t))}}}Pp();var Jm=256,Ym=-2,Xm=3,Zm=1e3;function Qm(e){return e.kind===Zp.batch?e.frames.some(Qm):e.kind!==Zp.reject}var $m=1e4,eh=25e3,th=1e4;function nh(e,t){let n=t.connection.coordinate,r=t.avatar.persistentId??n?.perId;if(r==null)throw Error(`connectRealm: no avatar identity — the connection carries no persistent id. Give it one where you open the connection (identity: coord.withPersistentId(id)), or pass avatar.persistentId explicitly.`);let i={type:t.avatar.type,persistentId:r,instanceId:t.avatar.instanceId??n?.insId??`default`},a=t.pendingExpiryMs??$m,o=t.connection.slot,s=t.devtools,c=t.coalesce??(t.coalesceMs==null?void 0:{ms:t.coalesceMs}),l=c!=null&&c.ms>0?c.ms:0,u=c?.leading===!0&&l>0,d=new Vp({}),f=new Xp,p=new Set,m={},h=-1,g,_,v=!1,y=`connecting`,b,x=()=>g==null?`[realm:${e.id}]`:`[realm:${e.id}#${g.slice(0,8)}]`,ee=new Set,S=!1,C=e=>{if(y!==e){y=e,e===`live`&&(S=!0);for(let t of[...ee])t(e,{hasBeenLive:S});s?.onStatus?.(e,{hasBeenLive:S}),e===`detached`&&it()}},w=[],T=[],te=0,ne=!1,re=!1,E,ie=Date.now(),ae=0,oe,D=!1,O=0,se=new Set,k=new Set,ce=e=>{s?.onDiagnostic?.(e);for(let t of[...k])t(e);if(t.onDiagnostic!=null){t.onDiagnostic(e);return}k.size>0||se.has(e.type)||(se.add(e.type),console.warn(`${x()} sync-health event "${e.type}"`,e))},le=!1,ue=e=>{if(t.onMutationRejected!=null){t.onMutationRejected(e);return}e.rolledBackPaths.length>0&&!le&&(le=!0,console.warn(`${x()} an optimistic ${e.kind} rolled back on [${e.rolledBackPaths.join(`, `)}] (${e.error.getIds().join(`, `)}) with no onMutationRejected handler — the change silently reverted. Wire onMutationRejected on connectRealm. Note: frame_too_stale is an UNKNOWN outcome (may have committed), not a definite reject.`))},A=t.staleProbeAfterMs??eh,de=t.probeReplyTimeoutMs??th,fe=()=>{de<=0||(oe!=null&&clearTimeout(oe),oe=setTimeout(()=>{oe=void 0,y===`live`&&(ie>=ae||(ce({type:`probe_escalated`}),C(`connecting`),t.connection.requestReconnect?.()))},de),qa(oe))},pe=()=>w.some(e=>e.isSystemAssert),me=.2,he=null,ge=null,_e=0,ye=e=>{e<0||(_e+=1,he==null||ge==null?(he=e,ge=0):(ge+=me*(Math.abs(e-he)-ge),he+=me*(e-he)),s?.onStats?.({rttMs:he,jitterMs:ge,samples:_e}))},be=(e,t)=>{y!==`detached`&&(ce({type:`resync`,reason:e,...t}),!(D&&Date.now()-O<1e4)&&E?.isOpen()===!0&&_t({probe:!0}))},xe=new Map,Se=new Set,Ce=e=>{let t=m;for(let n of e){if(typeof t!=`object`||!t)return!1;t=t[n]}return t!=null},we=()=>{if(xe.size!==0&&!pe())for(let[e,t]of[...xe]){if(Ce(t)){xe.delete(e),Se.delete(e);continue}ce({type:`reown_missing`,path:t.join(`.`)}),Se.has(e)?(xe.delete(e),Se.delete(e)):E?.isOpen()===!0&&y!==`detached`&&(Se.add(e),_t({probe:!0,forceFullHydrate:!0}))}},Te=0,Ee,De=()=>{Ee!=null&&(clearTimeout(Ee),Ee=void 0)},Oe=()=>{if(D=!1,Ee!=null)return;let e=Math.min(250*2**Te,5e3);Te+=1;let t=setTimeout(()=>{Ee=void 0,be(`frame_error`)},e);qa(t),Ee=t},ke=()=>{for(let e of p)e()},Ae=new Set,je={},Me=!1,Ne=!1,Pe=!0,Fe=!1,Ie=e=>e?.fullReplace===!0?`hydrate`:e?.confirmed==null?e?.cause??`rebase`:`confirm`,Le=e=>e==null?!1:e.fullReplace===!0||e.confirmed!=null?!0:e.authoritative===!0,Re=e=>{if(Me){Ne=!0,Ie(e)!==`confirm`&&(Pe=!1),Le(e)&&(Fe=!0);return}let t=m,n=[];for(let e of w)try{t=Rp(t,e.patches)}catch{n.push(e)}if(n.length>0){w=w.filter(e=>!n.includes(e));for(let e of n)Be(e,qp.fromId(`frame_too_stale`,{basisVersion:e.basisVersion}))}re=!0;try{d.replace(t)}finally{re=!1}if(t!==je){let n=Ie(e),r=Le(e);if(s?.onFlush?.({cause:n,authoritative:r,confirmedVersion:h}),Ae.size>0){let i=e?.fullReplace===!0?[{op:`replace`,path:[],value:t}]:e?.confirmed??Nm(je,t);if(i.length>0){let e={cause:n,authoritative:r,confirmedVersion:h};for(let t of[...Ae])t(i,e)}}}je=t,ke()},ze=t=>{let n=t.filter(e=>{if(e.op!==`remove`)return!0;let t=m;for(let n of e.path.slice(0,-1)){if(typeof t!=`object`||!t)return!1;t=t[n]}return typeof t==`object`&&!!t&&String(e.path[e.path.length-1])in t}),r=Um(m,n,e.stateDef);return m=Rp(m,r),r},Be=(e,t)=>{e.expiryTimer!=null&&clearTimeout(e.expiryTimer);for(let n of e.handles)n.reject(t);s?.onMutation?.({type:`rejected`,clientSeq:e.clientSeq,kind:e.kind,intentName:e.intentName,durability:e.durability,systemAssert:e.isSystemAssert,errorIds:t.getIds(),rolledBackPaths:e.patches.map(e=>e.path.join(`.`))}),!(e.isSystemAssert&&t.getIds().includes(`frame_too_stale`))&&ue({error:t,kind:e.kind,intentName:e.intentName,rolledBackPaths:e.patches.map(e=>e.path.join(`.`))})},j=(e,t)=>{e.expiryTimer!=null&&clearTimeout(e.expiryTimer),e.sentAt!=null&&ye(Date.now()-e.sentAt);for(let n of e.handles)n.confirm({version:t});s?.onMutation?.({type:`confirmed`,clientSeq:e.clientSeq,kind:e.kind,intentName:e.intentName,durability:e.durability,systemAssert:e.isSystemAssert,version:t})},Ve=e=>{e.durability!==`reassert`&&(e.expiryTimer=setTimeout(()=>{w.includes(e)&&(w=w.filter(t=>t!==e),Be(e,qp.fromId(`frame_too_stale`,{basisVersion:e.basisVersion})),Re())},a),qa(e.expiryTimer))},He=e=>{if(E==null||!E.isOpen())return;e.sentAt=Date.now();let t=e.buildFrame(e.clientSeq,e.basisVersion);s?.onFrame?.(`out`,e.kind,t.byteLength),E.send(t)},Ue,We=()=>Ue??_?.maxPatchesPerFrame??1/0,Ge=(t,n,r,i,a,s)=>{let c={clientSeq:t,kind:`write`,patches:n,basisVersion:r,handles:i,buildFrame:(t,n)=>pm({slot:o,clientSeq:t,basisVersion:n,ops:Om(rh(c.patches),e.tokens)}),expiryTimer:void 0,openForMerge:!1,retries:a,durability:s};return c},Ke=(e,t,n)=>{e.expiryTimer!=null&&clearTimeout(e.expiryTimer);let r=[];for(let i=0;i<t.length;i+=n){let a=t.slice(i,i+n),o=i+n>=t.length;r.push(Ge(r.length===0?e.clientSeq:te++,a,e.basisVersion,o?e.handles:[],e.retries,e.durability))}let i=w.indexOf(e);i>=0&&w.splice(i,1,...r);for(let e of r)Ve(e);return r},qe=e=>{if(e.kind!==`write`){He(e);return}let t=rh(e.patches),n=We();if(t.length<=n){He(e);return}for(let r of Ke(e,t,n))He(r)},Je=()=>{ne=!1;for(let e of[...w])e.openForMerge&&(e.openForMerge=!1,!D&&qe(e))},Ye,Xe=()=>{let e=setTimeout(()=>{Ye=void 0,w.some(e=>e.openForMerge)&&(Je(),Xe())},l);qa(e),Ye=e},Ze=()=>{ne||(ne=!0,!(u&&Ye!=null)&&(l>0?qa(setTimeout(Je,l)):queueMicrotask(Je)))},Qe=(e,t,n,r)=>(e.reject(n),ue({error:n,kind:t,intentName:r,rolledBackPaths:[]}),s?.onMutation?.({type:`rejected`,clientSeq:-1,kind:t,intentName:r,errorIds:n.getIds(),rolledBackPaths:[]}),e.handle),M=(e,t,n)=>Qe(qm(),e,t,n),$e=()=>b??qp.fromId(`write_before_hydrate`,{realmId:e.id}),et=(e,t)=>{e.expiryTimer!=null&&clearTimeout(e.expiryTimer),Qe(e.controller,e.kind,t,e.intentName)},tt=()=>h===-1||T.length>0,nt=(e,t)=>{let n=qm();if(y===`detached`)return Qe(n,e.kind,$e(),e.intentName);let r={...e,controller:n,expiryTimer:void 0};return t!==`reassert`&&(r.expiryTimer=setTimeout(()=>{let e=T.indexOf(r);e<0||(T.splice(e,1),et(r,$e()),ke())},a),qa(r.expiryTimer)),T.push(r),ke(),n.handle},rt=()=>{for(let e=T.shift();e!=null;e=T.shift()){e.expiryTimer!=null&&clearTimeout(e.expiryTimer);let{controller:t}=e,n;try{n=e.run()}catch(t){console.error(`${x()} a write queued before the first hydrate threw`,t),et(e,ve(t));continue}let r=n;r.then(t.confirm,()=>{r.error!=null&&t.reject(r.error)})}},it=()=>{for(let e of T.splice(0))et(e,$e())},at=(t,n)=>{let r=n?.durability,i=n?.flush===`immediate`;if(r===`reassert`){let e=w.filter(e=>e.durability===`reassert`).length;if(e>=Jm)return M(`write`,qp.fromId(`durable_backlog_overflow`,{pendingFrames:e}))}let a=qm();i&&Je();let c=i?void 0:w.find(e=>e.kind===`write`&&e.openForMerge&&e.durability===r);if(c!=null)return c.patches.push(...t),c.handles.push(a),Re({cause:`optimistic`}),Ze(),a.handle;let l={clientSeq:te++,kind:`write`,patches:t,basisVersion:h,handles:[a],buildFrame:(t,n)=>pm({slot:o,clientSeq:t,basisVersion:n,ops:Om(rh(l.patches),e.tokens)}),expiryTimer:void 0,openForMerge:!0,retries:0,durability:r};return w.push(l),s?.onMutation?.({type:`created`,clientSeq:l.clientSeq,kind:`write`,durability:r}),Ve(l),Re({cause:`optimistic`}),i?(l.openForMerge=!1,D||qe(l)):u&&Ye==null?(Je(),Xe()):Ze(),a.handle},ot=(t,n)=>{let r=d.state,a,[o,s]=Lp(r,e=>{a=t(e)});if(s.length===0){if(typeof a==`object`&&a)throw Error(`[realm:${e.id}] realm.update(fn): the update function returned a value without modifying its draft. Updates are mutate-only — a returned state is ignored (unlike immer's produce). Mutate the draft instead.`);let t=qm();return t.confirm({version:h}),t.handle}let c=Dm(s,o,e.stateDef),l=Vm({realm:e,patches:c,avatar:i,state:r,basisVersion:h});return l===!0?at(c,n):M(`write`,l)},st=(e,t)=>tt()?nt({kind:`write`,run:()=>ot(e,t)},t?.durability):ot(e,t),ct=(e,t)=>tt()?nt({kind:`intent`,intentName:e,run:()=>lt(e,t)}):lt(e,t),lt=(t,n)=>{let r=e.intents[t];if(r==null)return M(`intent`,qp.fromId(`intent_unknown`,{intent:t}),t);let a=Yp(r.input,n);if(a!=null)return M(`intent`,qp.fromId(`value_invalid`,{path:[t,...a.path].join(`.`),expected:a.expected}),t);Je();let c=[];if(r.optimistic!=null)try{let t=d.state,[a,o]=Lp(t,e=>{r.optimistic?.({view:e,avatar:i,input:n})});c=Dm(o,a,e.stateDef)}catch{c=[]}let l=qm(),u=e.intentNames.indexOf(t),f={clientSeq:te++,kind:`intent`,intentName:t,patches:c,basisVersion:h,handles:[l],buildFrame:e=>mm({slot:o,clientSeq:e,intentToken:u,input:n}),expiryTimer:void 0,openForMerge:!1,retries:0};return w.push(f),s?.onMutation?.({type:`created`,clientSeq:f.clientSeq,kind:`intent`,intentName:t}),Ve(f),c.length>0?Re({cause:`optimistic`}):ke(),D||He(f),l.handle},ut=(e,t)=>{if(e.kind!==`write`||!t.getIds().includes(`limits_exceeded`)||e.retries>=Xm)return!1;let n=t.getContext(`limits_exceeded`),r=typeof n==`object`&&n&&`limit`in n?String(n.limit):``;if(r===`writeRatePerSecond`)return e.retries+=1,qa(setTimeout(()=>{w.includes(e)&&!D&&He(e)},Zm)),!0;if(r===`maxPatchesPerFrame`||r===`maxFrameBytes`){e.retries+=1;let t=rh(e.patches);if(t.length<=1)return!1;Ue=Math.max(1,Math.floor(Math.min(We(),t.length)/2));for(let n of Ke(e,t,Ue))He(n);return!0}return!1},dt=()=>{let t=[],n=m;for(let e of w)if(e.isSystemAssert)try{n=Rp(n,e.patches)}catch{}for(let r of w){if(r.isSystemAssert){t.push(r);continue}let a=r.kind===`intent`?!0:Vm({realm:e,patches:r.patches,avatar:i,state:m,basisVersion:h});if(a!==!0){Be(r,a);continue}if(r.kind===`write`){let e;try{e=Rp(n,r.patches)}catch{Be(r,qp.fromId(`frame_too_stale`,{basisVersion:r.basisVersion}));continue}n=e}r.basisVersion=h,t.push(r)}w=t;for(let e of[...t])e.openForMerge||He(e)},ft=[],pt=n=>{switch(n.kind){case Zp.batch:{let e=Me;Me=!0,e||(Pe=!0,Fe=!1);let t=!1,r;try{for(let e of n.frames)try{pt(e)}catch(e){t||(t=!0,r=e)}}finally{Me=e}if(!Me&&Ne&&(Ne=!1,Re({cause:Pe?`confirm`:`rebase`,authoritative:Fe})),t)throw r;return}case Zp.hydrate:{if(f.load(n.keyDictSeed),ft.push(n.stateBlob),n.more)return;let r=ih(ft);ft=[];let i=h<0;m=_s(r),h=n.version,g=n.epoch,_={maxPatchesPerFrame:n.limits[0],maxFrameBytes:n.limits[1],writeRatePerSecond:n.limits[2]},Ue=void 0,ht(n.avatar),C(`live`),D&&ye(Date.now()-O),D=!1,!i&&e.transient.length>0&&t.assertOnAttach!=null&&!pe()&&gt(m),dt(),Re({fullReplace:!0}),t.assertOnAttach!=null&&!pe()&&ot(t.assertOnAttach),rt(),we();return}case Zp.keyDict:f.load(n.entries);return;case Zp.patches:{let t=n.fromVersion===h,r=n.toVersion===h;if(!t&&!r){D?ce({type:`gap_dropped`,fromVersion:n.fromVersion,toVersion:n.toVersion,confirmedVersion:h}):be(`version_gap`,{fromVersion:n.fromVersion,toVersion:n.toVersion,confirmedVersion:h});return}let i=D;D=!1,i&&ye(Date.now()-O);let a=km(n.ops,e.tokens,e=>f.keyOf(e)).filter(e=>!bm(e.path)),o=w.length===0&&je===m,s=ze(a);h=n.toVersion,i&&(pe()||gt(m),dt()),y===`connecting`&&C(`live`),Re(o&&w.length===0?{confirmed:s}:{authoritative:!0}),we();return}case Zp.ack:{let e=w.findIndex(e=>e.clientSeq===n.clientSeq);if(e<0)return;let[t]=w.splice(e,1);j(t,n.version),Re(),t.isSystemAssert&&we();return}case Zp.reject:{let e=ve(n.error);if(n.clientSeq===-1){b=e,D=!1,C(`detached`);return}let t=w.findIndex(e=>e.clientSeq===n.clientSeq);if(t<0){ce({type:`late_reject`,clientSeq:n.clientSeq,errorIds:e.getIds()});return}if(ut(w[t],e))return;let[r]=w.splice(t,1);if(Be(r,e),Re(),e.getIds().includes(`write_target_missing`)){for(let e of r.patches)if(e.path.length>1){let t=e.path.slice(0,-1);xe.set(JSON.stringify(t),t)}be(`write_target_missing`)}r.isSystemAssert&&we();return}case Zp.detach:if(n.reason===`rehello`){y===`live`&&_t({probe:!0});return}D=!1,C(`detached`);return;default:return}},mt=(e,t)=>{s?.onFrame?.(`in`,Qp[e.kind]??String(e.kind),t??0);try{pt(e)}catch(e){ce({type:`frame_error`,error:e}),ft=[],Oe();return}Qm(e)&&(ie=Date.now(),Te=0,De(),oe!=null&&(clearTimeout(oe),oe=void 0))},ht=e=>{let[t,n,r]=e;t===i.type&&n===i.persistentId&&r===i.instanceId||v||(v=!0,console.warn(`${x()} identity mismatch — this client predicts as ${i.type}/${i.persistentId}/${i.instanceId} but the server resolved it as ${t}/${n}/${r}. Prediction and view slicing run against DIFFERENT identities: owner-gated writes will pass locally and reject on the server. Fix the server's resolveAvatar/avatarType, or the avatar passed to connectRealm.`))},gt=n=>{if(t.assertOnAttach==null||e.transient.length===0||h<0||E==null||!E.isOpen())return;let[r,i]=Lp(n,e=>{t.assertOnAttach?.(e)});if(i.length===0)return;let a=Dm(i,r,e.stateDef);if(a.length===0)return;w.some(e=>e.isSystemAssert)&&(w=w.filter(e=>!e.isSystemAssert));let s={clientSeq:Ym,kind:`write`,patches:a,basisVersion:h,handles:[],buildFrame:(t,n)=>pm({slot:o,clientSeq:t,basisVersion:n,ops:Om(rh(a),e.tokens)}),expiryTimer:void 0,openForMerge:!1,retries:0,isSystemAssert:!0};w.unshift(s),Re({cause:`optimistic`})},_t=t=>{t?.probe===!0?(ae=Date.now(),fe()):(C(`connecting`),b=void 0,f.clear()),D=!0,O=Date.now(),ft=[],gt(d.state);let n=fm({slot:o,realmId:e.id,schemaHash:e.schemaHash,lastKnownVersion:t?.forceFullHydrate===!0?-1:h,epoch:g});s?.onFrame?.(`out`,`hello`,n.byteLength),E?.send(n);let r=gm({slot:o,features:[$p.batch]});s?.onFrame?.(`out`,`clientCaps`,r.byteLength),E?.send(r)},vt,yt=Mm(t.connection,e,t.security);yt==null?(E=t.connection.register({onFrame:mt,onAttach:()=>_t(),onDetach:()=>{y!==`detached`&&C(`connecting`)}}),E.isOpen()&&_t(),vt=t.connection.subscribeLinkEvents?.(e=>{e.type===`link_up`&&e.downForMs!=null&&ce({type:`link_redialed`,downForMs:e.downForMs})})):(b=yt,C(`detached`),t.connection.release());let bt;if(yt==null&&A>0&&(bt=setInterval(()=>{if(y!==`live`||E?.isOpen()!==!0)return;let e=Date.now();e-ie<A||e-ae<A||_t({probe:!0})},Math.max(1e3,Math.floor(A/2))),qa(bt)),t.experimental_writeThroughStore===!0)d.listenToPatches(t=>{if(re)return;let n=t.filter(e=>e.path.length>0);n.length!==0&&queueMicrotask(()=>{let t=Dm(n,d.state,e.stateDef);if(t.length===0)return;let r=Vm({realm:e,patches:t,avatar:i,state:d.state,basisVersion:h});if(r!==!0){ue({error:r,kind:`write`,rolledBackPaths:t.map(e=>e.path.join(`.`))}),Re();return}at(t)})});else{let e=!1;d.listenToPatches(()=>{re||e||(e=!0,console.warn(`${x()} realm.store was written directly. The store is a read projection — this change was never sent to the server and will vanish on the next incoming flush. Did you mean realm.update()? (Raw store write-through requires the experimental_writeThroughStore option.)`))})}let xt={store:d,avatar:i,update:st,intents:Object.fromEntries(e.intentNames.map(e=>[e,t=>ct(e,t)])),pending:{get count(){return w.reduce((e,t)=>t.isSystemAssert?e:e+1,0)+T.length},has(e){return w.some(t=>!t.isSystemAssert&&t.patches.some(t=>t.path.join(`.`).startsWith(e)))},subscribe(e){return p.add(e),()=>p.delete(e)}},get status(){return y},get hasBeenLive(){return S},get version(){return h},get attachError(){return b},whenLive(e){return y===`live`?Promise.resolve():b==null?y===`detached`?Promise.reject(Error(`whenLive: the realm is detached`)):new Promise((t,n)=>{let r=e?.timeoutMs??1e4,i=()=>{clearTimeout(a),ee.delete(o)},a=setTimeout(()=>{i(),n(Error(`whenLive: the realm did not hydrate within ${r}ms`))},r),o=()=>{y===`live`?(i(),t()):(b!=null||y===`detached`)&&(i(),n(b??Error(`whenLive: the realm detached before going live`)))};ee.add(o)}):Promise.reject(b)},subscribeStatus(e){return ee.add(e),()=>ee.delete(e)},subscribeDiagnostics(e){return k.add(e),()=>k.delete(e)},listenToPatches(e){return Ae.add(e),()=>Ae.delete(e)},get stats(){return{rttMs:he,jitterMs:ge,samples:_e}},detach(){if(bt!=null&&clearInterval(bt),oe!=null&&clearTimeout(oe),Ye!=null&&(clearTimeout(Ye),Ye=void 0),vt?.(),De(),xe.clear(),Se.clear(),E?.isOpen()===!0)try{let e=hm({slot:o,reason:void 0});s?.onFrame?.(`out`,`detach`,e.byteLength),E.send(e)}catch{}D=!1,C(`detached`),t.connection.release();for(let e of w.splice(0))Be(e,qp.fromId(`frame_too_stale`,{basisVersion:e.basisVersion}));Re()}};return s?.handleReady?.({handle:xt,realmId:e.id,slot:o,avatar:i,peer:(t.connection.peer??t.connection.peerCoordinate)?.envId}),xt}function rh(e){let t=new Map;for(let n of e)t.set(n.path.join(` `),n);return[...t.values()]}function ih(e){if(e.length===1)return e[0];let t=e.reduce((e,t)=>e+t.byteLength,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;return n}Pp();var ah=new WeakMap,oh=5e3;function sh(e){let t=ah.get(e);if(t!=null)return t;let n=new Map,r=(e,t,n)=>{try{e.onFrame(t,n)}catch(e){console.error(`[realm] a realm slot handler threw while dispatching an inbound frame`,e)}},i=(e,t)=>{if(e.slot===255){for(let i of n.values())r(i,e,t);return}let i=n.get(e.slot);i!=null&&r(i,e,t)};return t={nextSlot:0,freeSlots:[],slots:n,port:e.registerProtocol({id:`realm`,prefixByte:Js.realm,onFrame:e=>{let t;try{t=_m(e)}catch{return}if(t.kind===Zp.batch){let a=new Map;for(let e of t.frames){if(e.slot===255){i(e);continue}let t=a.get(e.slot);t==null?a.set(e.slot,[e]):t.push(e)}for(let[t,i]of a){let o=n.get(t);o!=null&&r(o,i.length===1?i[0]:{kind:Zp.batch,slot:t,frames:i},a.size===1?e.byteLength:void 0)}return}i(t,e.byteLength)},onAttach:()=>{for(let e of n.values())e.onAttach()},onDetach:()=>{for(let e of n.values())e.onDetach()}})},ah.set(e,t),t}function ch(e){let t=e instanceof Tc,n=t?e:e.wireMux;if(n==null)throw Error(`realmConnection: this link has no frame-protocol mux — connect it via connectChannel (which creates one per connection) or pass a WireProtocolMux directly.`);let r=t?void 0:e.localCoordinate,i=t?void 0:`peer`in e?e.peer:e.peerClient,a=t?void 0:e.securityLevel,o=t?void 0:e.requestReconnect,s=t?void 0:e.addLinkEventListener?.bind(e),c=sh(n),l=c.freeSlots.pop();if(l==null&&c.nextSlot>=255)throw Error(`realmConnection: slot space exhausted (max 254)`);let u=l??c.nextSlot++,d=!1;return{slot:u,coordinate:r,peer:i,peerCoordinate:i,securityLevel:a,requestReconnect:o,subscribeLinkEvents:s,register(e){return c.slots.set(u,e),{send:e=>c.port.send(e),isOpen:()=>c.port.isOpen()}},release(){d||(d=!0,c.slots.delete(u),qa(setTimeout(()=>c.freeSlots.push(u),oh)))}}}function lh(){return{define:e=>e}}function uh(){return{path(e){return{view:t=>({alter:n=>({pattern:e,view:t,alter:n})})}},everyone:{kind:`everyone`},serverOnly:{kind:`serverOnly`},avatarTypes:(...e)=>({kind:`avatarTypes`,types:e}),serverChecked:e=>({kind:`serverChecked`,fn:e}),all:(...e)=>({kind:`all`,conds:e})}}function dh(e){if(e.length===0)throw Error(`rule pattern may not be empty`);let t=e.split(`.`),n=[[]];return t.forEach((r,i)=>{let a=i===t.length-1;if(r.startsWith(`{`)&&r.endsWith(`}`)){let t=r.slice(1,-1).split(`,`).map(e=>e.trim());if(t.some(e=>e.length===0))throw Error(`rule pattern "${e}": empty name in brace group "${r}"`);n=n.flatMap(e=>t.map(t=>[...e,t]));return}if((r===`*`||r===`**`)&&!a)throw Error(`rule pattern "${e}": "${r}" is only valid as the final segment`);n=n.map(e=>[...e,r])}),n.map(t=>({source:e,segments:t.map(t=>{if(t===`*`)return{kind:`star`};if(t===`**`)return{kind:`deep`};if(t.startsWith(`$`)){let n=t.slice(1);if(n.length===0)throw Error(`rule pattern "${e}": bare "$" segment`);return{kind:`var`,name:n}}if(t.includes(`{`)||t.includes(`}`)||t.includes(`$`))throw Error(`rule pattern "${e}": malformed segment "${t}"`);return{kind:`lit`,name:t}})}))}function fh(e,t){for(let n of t)for(let t of dh(n)){let r=gh({kind:`object`,entries:e},t.segments,0);if(r!=null)throw Error(`rule pattern "${n}" can never match: ${r}`)}}function ph(e,t){let n=[];for(let r of t){let t=r.split(`.`);for(let e of t)if(e.length===0||/[$*{}]/.test(e))throw Error(`transient path "${r}" must be a concrete, wildcard-free path (no $var, *, ** or {a,b}); offending segment "${e}". Wildcard transient regions are not supported in v1.`);if(mh({kind:`object`,entries:e},t,0)==null)throw Error(`transient path "${r}" does not resolve to any node in the realm schema.`);n.push(t)}return n}function mh(e,t,n){if(n>=t.length)return e;let r=hh(e);if(r.kind===`object`){let e=r.entries[t[n]];return e==null?void 0:mh(e,t,n+1)}if(r.kind===`record`)return mh(r.value,t,n+1)}function hh(e){return e.kind===`optional`?hh(e.inner):e}function gh(e,t,n){if(n>=t.length)return;let r=hh(e),i=t[n],a=_h(t,n);if(r.kind===`object`){if(i.kind===`lit`){let e=r.entries[i.name];return e==null?`"${i.name}" is not a key of the object at ${a}`:gh(e,t,n+1)}if(i.kind===`var`){let e=Object.values(r.entries);return e.length===0?`the object at ${a} has no keys`:e.some(e=>gh(e,t,n+1)==null)?void 0:`no key of the object at ${a} admits the rest of the pattern`}return}if(r.kind===`record`)return i.kind===`lit`||i.kind===`var`?gh(r.value,t,n+1):void 0;let o=r.kind===`array`?` (t.array is leaf-replace-only on the wire — rule it with the exact path, e.g. "${_h(t,n,!0)}")`:``;return`it descends into the ${r.kind} wire-leaf at ${a}${o}`}function _h(e,t,n=!1){let r=e.slice(0,t).map(e=>e.kind===`lit`?e.name:e.kind===`var`?`$${e.name}`:e.kind===`star`?`*`:`**`).join(`.`);return r.length===0?`the state root`:n?r:`"${r}"`}var vh=class{_root={};_patterns=[];constructor(e){for(let t of e){for(let e of dh(t.pattern))this._insert(e,t);this._patterns.push(t.pattern)}}get patterns(){return this._patterns}_insert(e,t){let n=[],r=this._root;for(let i=0;i<e.segments.length;i++){let a=e.segments[i];if(a.kind===`star`){if(r.star!=null)throw Error(`duplicate rule pattern at "${e.source}"`);r.star={rule:t,varNames:n};return}if(a.kind===`deep`){if(r.deep!=null)throw Error(`duplicate rule pattern at "${e.source}"`);r.deep={rule:t,varNames:n};return}if(a.kind===`var`){if(n[i]=a.name,r.var==null)r.var={name:a.name,node:{}};else if(r.var.name!==a.name)throw Error(`conflicting $var names at the same trie position: "$${r.var.name}" vs "$${a.name}" (${e.source})`);r=r.var.node;continue}r.lit??=new Map;let o=r.lit.get(a.name);o??(o={},r.lit.set(a.name,o)),r=o}if(r.exact!=null)throw Error(`duplicate rule pattern at "${e.source}"`);r.exact={rule:t,varNames:n}}match(e){let t=this._match(this._root,e,0);if(t==null)return;let n={};return t.varNames.forEach((t,r)=>{t!=null&&(n[t]=e[r])}),{rule:t.rule,params:n}}_match(e,t,n){if(n===t.length)return e.exact;let r=t[n],i=n===t.length-1,a=e.lit?.get(r);if(a!=null){let e=this._match(a,t,n+1);if(e!=null)return e}if(e.var!=null){let r=this._match(e.var.node,t,n+1);if(r!=null)return r}if(i&&e.star!=null)return e.star;if(e.deep!=null)return e.deep}};function yh(e){switch(e.kind){case`string`:return e.maxLength==null?e.kind:{k:`string`,max:e.maxLength};case`number`:return e.min==null&&e.max==null&&e.integer!==!0?e.kind:{k:`number`,...e.min==null?{}:{min:e.min},...e.max==null?{}:{max:e.max},...e.integer===!0?{int:!0}:{}};case`boolean`:return e.kind;case`literal`:return{k:`lit`,v:e.value};case`union`:return{k:`u`,o:e.options.map(e=>JSON.stringify(yh(e))).sort()};case`optional`:return{k:`opt`,i:yh(e.inner)};case`object`:return{k:`obj`,e:Object.keys(e.entries).sort().map(t=>[t,yh(e.entries[t])])};case`record`:{let t={k:`rec`,id:e.keyVar,v:yh(e.value)};return e.maxKeys==null?t:{...t,max:e.maxKeys}}case`array`:{let t={k:`arr`,i:yh(e.item)};return e.maxItems==null?t:{...t,max:e.maxItems}}case`standard`:return e.hashTag==null?{k:`std`}:{k:`std`,tag:e.hashTag}}}function bh(e){let t=Object.keys(e.state).sort();return JSON.stringify({id:e.id,state:t.map(t=>[t,yh(e.state[t])]),clients:[...e.avatarTypes].sort(),intents:[...e.intents].sort((e,t)=>e[0]<t[0]?-1:1).map(([e,t])=>[e,yh(t)]),rules:[...e.rulePatterns].sort()})}function xh(e){return Mi(bh(e))}function Sh(e){return e.kind===`optional`?Sh(e.inner):e}function Ch(e){let t=Sh(e);return t.kind===`object`?wh(t.entries):t.kind===`record`?{toToken:new Map,toName:[],children:new Map,recordChild:Ch(t.value)}:`leaf`}function wh(e){let t=Object.keys(e).sort(),n={toToken:new Map,toName:[],children:new Map};return t.forEach((t,r)=>{n.toToken.set(t,r),n.toName.push(t),n.children.set(t,Ch(e[t]))}),n}var Th=class{_root;constructor(e){this._root=wh(e)}tokenizePath(e,t){let n=[],r=this._root;for(let i of e){if(r===`leaf`||r==null)throw Error(`tokenizePath: path descends past a leaf at "${i}" (${e.join(`.`)})`);if(r===`record`)throw Error(`tokenizePath: internal record level error at "${i}"`);if(r.recordChild!=null){n.push(t?.(i)??i),r=r.recordChild;continue}let a=r.toToken.get(i);if(a==null)throw Error(`tokenizePath: unknown key "${i}" in path ${e.join(`.`)}`);n.push(a),r=r.children.get(i)??`leaf`}return n}detokenizePath(e,t){let n=[],r=this._root;for(let i of e){if(r===`leaf`||r===`record`||r==null)throw Error(`detokenizePath: path descends past a leaf (${e.join(`.`)})`);if(r.recordChild!=null){if(typeof i==`number`){let e=t?.(i);if(e==null)throw Error(`detokenizePath: unknown interned key id ${i}`);n.push(e)}else n.push(i);r=r.recordChild;continue}if(typeof i!=`number`||i<0||i>=r.toName.length)throw Error(`detokenizePath: invalid token "${i}" (${e.join(`.`)})`);let a=r.toName[i];n.push(a),r=r.children.get(a)??`leaf`}return n}rootTokenNames(){return this._root.toName}};function Eh(e){let t=e.rules(uh());fh(e.state,t.map(e=>e.pattern));let n=new vh(t),r=ph(e.state,e.transient??[]),i=e.intents?.(lh())??{},a=Object.keys(i).sort(),o=Object.keys(e.avatars).sort(),s=new Th(e.state),c=xh({id:e.id,state:e.state,avatarTypes:o,intents:a.map(e=>[e,i[e].input]),rulePatterns:t.map(e=>e.pattern)});return{id:e.id,security:e.security??`authenticated`,avatarTypes:o,stateDef:e.state,rules:t,ruleTrie:n,intents:i,intentNames:a,tokens:s,transient:r,schemaHash:c}}function Dh(e,t){if(t!=null){if(!Number.isSafeInteger(t)||t<0)throw Error(`t: ${e} must be a non-negative safe integer, got ${t}`);return t}}function Oh(e){let{min:t,max:n,integer:r}=e;if(t!=null&&!Number.isFinite(t))throw Error(`t: number min must be finite, got ${t}`);if(n!=null&&!Number.isFinite(n))throw Error(`t: number max must be finite, got ${n}`);if(t!=null&&n!=null&&t>n)throw Error(`t: number min (${t}) must be <= max (${n})`);if(r!=null&&typeof r!=`boolean`)throw Error(`t: number integer must be a boolean`);return{...t==null?{}:{min:t},...n==null?{}:{max:n},...r===!0?{integer:!0}:{}}}function kh(...e){let t=e.flatMap(e=>Array.isArray(e)?e:[e]);if(t.length<2)throw Error(`t.union needs at least 2 options, got ${t.length}`);return{kind:`union`,options:t}}var $={string(e={}){let t=Dh(`string maxLength`,e.maxLength);return{kind:`string`,...t==null?{}:{maxLength:t}}},number(e={}){return{kind:`number`,...Oh(e)}},boolean(){return{kind:`boolean`}},literal(e){return{kind:`literal`,value:e}},union:kh,optional(e){return{kind:`optional`,inner:e}},object(e){return{kind:`object`,entries:e}},id(e){return{kind:`id`,varName:e}},record(e,t,n={}){let r=Dh(`record maxKeys`,n.maxKeys);return{kind:`record`,keyVar:e.varName,value:t,...r==null?{}:{maxKeys:r}}},array(e,t={}){let n=Dh(`array maxItems`,t.maxItems);return{kind:`array`,item:e,...n==null?{}:{maxItems:n}}},schema(e,t={}){if(t.hashTag!=null&&(typeof t.hashTag!=`string`||t.hashTag===``))throw Error(`t.schema: hashTag must be a non-empty string`);return{kind:`standard`,schema:e,...t.hashTag==null?{}:{hashTag:t.hashTag}}},serverContext(){return{kind:`serverContext`}}};Pp();var Ah=`/wire`,jh=`/logs`,Mh=`/bootstrap`,Nh=`/ticket`,Ph=`commander-auth.`,Fh=9e5;function Ih(e){return{"~standard":{version:1,vendor:`nice-commander`,validate:t=>{let n=e(t);return typeof n==`string`?{issues:[{message:n}]}:{value:n}}}}}function Lh(e){if(!Array.isArray(e))return null;let t=[];for(let n of e){if(typeof n!=`string`||n===``)return null;t.push(n)}return t}function Rh(e){return typeof e!=`object`||!e||Array.isArray(e)?null:{...e}}function zh(e){let t=Rh(e);if(t==null)return`expected an object`;let n=Lh(t.ids);if(n==null)return`ids: expected an array of process ids`;let r=t.wait;if(r!=null&&typeof r!=`boolean`)return`wait: expected a boolean`;let i=t.staggerMs;if(i!=null&&(typeof i!=`number`||i<0))return`staggerMs: expected a non-negative number`;let a=t.replaceSame;if(a!=null&&typeof a!=`boolean`)return`replaceSame: expected a boolean`;let o={ids:n};return r!=null&&(o.wait=r),i!=null&&(o.staggerMs=i),a!=null&&(o.replaceSame=a),o}function Bh(e){let t=Rh(e);if(t==null)return`expected an object`;let n=Rh(t.processes);if(n==null)return`processes: expected an object keyed by process id`;let r={};for(let[e,t]of Object.entries(n)){let n=Rh(t);if(n==null)return`processes[${JSON.stringify(e)}]: expected an object`;let i={};for(let[t,r]of Object.entries(n)){if(r!==null&&typeof r!=`string`)return`processes[${JSON.stringify(e)}][${JSON.stringify(t)}]: expected string | null`;i[t]=r}r[e]=i}let i=t.clear;if(i==null)return{processes:r};let a=Lh(i);return a==null?`clear: expected an array of process ids`:{processes:r,clear:a}}function Vh(e){let t=Rh(e);if(t==null||t.ok!==!0)return`expected { ok: true }`;let n=t.warnings;return!Array.isArray(n)||!n.every(e=>typeof e==`string`)?`warnings: expected an array of strings`:{ok:!0,warnings:n}}function Hh(e){let t=Rh(e);if(t==null)return`expected an object`;let n=Lh(t.ids);if(n==null)return`ids: expected an array of process ids`;let r=t.withDependencies;return r!=null&&typeof r!=`boolean`?`withDependencies: expected a boolean`:r===!0?{ids:n,withDependencies:r}:{ids:n}}function Uh(e){let t=Rh(e);if(t==null)return`expected an object`;let n={},r=t.suite;if(r!=null){if(typeof r!=`string`||r===``)return`suite: expected a suite name`;n.suite=r}if(t.ids!=null){let e=Lh(t.ids);if(e==null)return`ids: expected an array of process ids`;n.ids=e}if(n.suite==null==(n.ids==null))return`expected exactly one of suite | ids`;let i=t.parallel;if(i!=null){if(typeof i!=`number`||!Number.isInteger(i)||i<1)return`parallel: expected an integer ≥ 1`;n.parallel=i}let a=t.failFast;if(a!=null){if(typeof a!=`boolean`)return`failFast: expected a boolean`;n.failFast=a}if(t.filter!=null){let e=sn(t.filter);if(typeof e==`string`)return`filter.${e}`;n.filter=e}return n}function Wh(e){let t=Rh(e);if(t==null||typeof t.accepted!=`boolean`)return`expected { accepted }`;let{runKey:n,reason:r}=t;return{accepted:t.accepted,...typeof n==`string`?{runKey:n}:{},...typeof r==`string`?{reason:r}:{}}}function Gh(e){let t=Rh(e);if(t==null)return`expected an object`;let n=sn(t.filter);if(typeof n==`string`)return`filter.${n}`;let r=t.name;return typeof r==`string`?{filter:n,name:r}:`name: expected a string`}function Kh(e){let t=Rh(e)?.id;return typeof t==`string`&&t!==``?{id:t}:`id: expected a saved filter id`}function qh(e){return Rh(e)?.ok===!0?{ok:!0}:`expected { ok: true }`}function Jh(e){return Rh(e)==null?`expected an object`:{}}function Yh(e){let t=Rh(e);if(t==null)return`expected an object`;let n=t.errors;return t.ok===!0?typeof t.applied==`boolean`?typeof t.configRevisionHash==`string`?!Array.isArray(n)||!n.every(e=>typeof e==`string`)?`errors: expected an array of strings`:{ok:!0,applied:t.applied,configRevisionHash:t.configRevisionHash,errors:n}:`configRevisionHash: expected a string`:`applied: expected a boolean`:`expected { ok: true }`}var Xh=new Set([`ready`,`spawned`,`already-running`,`blocked`,`failed`,`succeeded`,`stopped`,`already-stopped`]);function Zh(e){return typeof e==`string`&&Xh.has(e)}function Qh(e){let t=Rh(e);if(t==null)return`expected an object`;let{results:n,warnings:r}=t;if(!Array.isArray(n)||!Array.isArray(r))return`expected { results, warnings }`;let i=[];for(let e of n){let t=Rh(e);if(t==null)return`results: expected objects`;let{id:n,outcome:r,reason:a}=t;if(typeof n!=`string`||!Zh(r))return`results: malformed entry`;if(a!=null&&typeof a!=`string`)return`results: reason must be a string`;i.push(a==null?{id:n,outcome:r}:{id:n,outcome:r,reason:a})}let a=[];for(let e of r){if(typeof e!=`string`)return`warnings: expected strings`;a.push(e)}return{results:i,warnings:a}}function $h(e){let t=Qh(e);return typeof t==`string`?null:t}var eg=Iu({domain:`commander`}).createChildDomain({domain:`control`,actions:{ports:Al().input({schema:Ih(vr)}).output({schema:Ih(yr)}),start:Al().input({schema:Ih(zh)}).output({schema:Ih(Qh)}),stop:Al().input({schema:Ih(Hh)}).output({schema:Ih(Qh)}),restart:Al().input({schema:Ih(zh)}).output({schema:Ih(Qh)}),runSuite:Al().input({schema:Ih(Uh)}).output({schema:Ih(Wh)}),saveFilter:Al().input({schema:Ih(Gh)}).output({schema:Ih(qh)}),removeFilter:Al().input({schema:Ih(Kh)}).output({schema:Ih(qh)}),setEnv:Al().input({schema:Ih(Bh)}).output({schema:Ih(Vh)}),reloadConfig:Al().input({schema:Ih(Jh)}).output({schema:Ih(Yh)}),shutdown:Al().input({schema:Ih(Jh)}).output({schema:Ih(qh)})}}),tg=wd({toAcceptor:[eg],toConnector:[]}),ng=Eh({id:`commander_status`,avatars:{viewer:{persistentId:$.string()}},state:{generation:$.number(),configName:$.string(),configRevisionHash:$.string(),configError:$.array($.string()),processes:$.record($.id(`processId`),$.object({kind:$.string(),state:$.string(),pid:$.optional($.number()),startedAt:$.optional($.number()),sawOutputAt:$.optional($.number()),lastTask:$.optional($.object({outcome:$.string(),reason:$.optional($.string()),timedOut:$.boolean(),endedAt:$.number(),durationMs:$.optional($.number())})),recentRuns:$.array($.object({startedAt:$.number(),endedAt:$.optional($.number()),outcome:$.optional($.union($.literal(`succeeded`),$.literal(`failed`),$.literal(`stopped`),$.literal(`crashed`),$.literal(`timedOut`)))})),restarts:$.number(),lastExit:$.optional($.object({code:$.optional($.number()),signal:$.optional($.string()),expected:$.boolean()})),stale:$.boolean(),removed:$.boolean(),envDrift:$.boolean(),blockedBy:$.optional($.string()),startError:$.optional($.string()),degradedBy:$.array($.string()),unreadyReason:$.optional($.string()),capability:$.optional($.object({treeMechanism:$.string(),degraded:$.boolean(),notes:$.array($.string())})),tags:$.record($.id(`tag`),$.array($.string())),optIn:$.boolean(),detail:$.object({command:$.string(),cwd:$.string(),dependsOn:$.array($.string()),url:$.optional($.string()),ready:$.optional($.string()),timeoutMs:$.optional($.number()),endpoints:$.array($.object({name:$.string(),protocol:$.string(),host:$.string(),port:$.number(),ownership:$.string(),url:$.optional($.string())})),envVars:$.array($.object({name:$.string(),description:$.optional($.string()),secret:$.boolean(),required:$.boolean(),values:$.optional($.array($.string())),source:$.string(),value:$.optional($.string())}))})})),suites:$.record($.id(`suiteName`),$.object({description:$.optional($.string()),members:$.array($.string()),parallel:$.number(),failFast:$.boolean()})),runs:$.record($.id(`runKey`),$.object({suite:$.optional($.string()),filterId:$.optional($.string()),startedAt:$.number(),endedAt:$.optional($.number()),outcome:$.optional($.union($.literal(`passed`),$.literal(`failed`))),previousDurationMs:$.optional($.number()),members:$.record($.id(`processId`),$.union($.literal(`pending`),$.literal(`running`),$.literal(`pass`),$.literal(`fail`),$.literal(`blocked`),$.literal(`skipped`)))})),savedFilters:$.array($.object({id:$.string(),name:$.optional($.string()),mode:$.union($.literal(`all`),$.literal(`any`)),terms:$.array($.string()),bucket:$.optional($.array($.string())),pinned:$.boolean(),lastRunAt:$.optional($.number())}))},rules:e=>[e.path(`**`).view(e.everyone).alter(e.serverOnly)]});async function rg(e,t,n){let r;e.connect().catch(e=>{r=e});try{await t.whenLive({timeoutMs:n})}catch(e){throw t.attachError??r??e}}var ig=3*6e4,ag=null,og=null;function sg(){return`tab-${crypto.randomUUID()}`}async function cg(){let e=ag;if(e!=null&&Date.now()-e.mintedAt<ig)return e.token;if(og==null){let e=lg();og=e;let t=()=>{og===e&&(og=null)};e.then(t,t)}return og}async function lg(){let e=await fetch(Mh,{credentials:`omit`,cache:`no-store`});if(!e.ok)throw Error(`bootstrap failed (${e.status})`);let t=(await e.json()).capability;if(typeof t!=`string`||t===``)throw Error(`bootstrap returned no capability`);return ag={token:t,mintedAt:Date.now()},t}function ug(e){let t=e,n=!1,r=()=>{t!=null||n||(n=!0,dg().then(e=>{t=e,n=!1},()=>{n=!1}))};return{peek:()=>(r(),t),take:()=>{let e=t;return t=null,r(),e}}}async function dg(){let e=await fg(await cg());if(e!=null)return e;ag=null;let t=await fg(await cg());if(t==null)throw Error(`ticket refused (401) even with a fresh capability`);return t}async function fg(e){let t=await fetch(Nh,{method:`POST`,credentials:`omit`,cache:`no-store`,headers:{authorization:`Bearer ${e}`}});if(t.status===401)return null;if(!t.ok)throw Error(`ticket refused (${t.status})`);let n=(await t.json()).ticket;if(typeof n!=`string`||n===``)throw Error(`no ticket issued`);return n}function pg(e){return`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}${e}`}async function mg(){let e=ug(await dg()),t=new Su($a.env(`commander_web`).withPersistentId(sg())),n=Dd(t,tg,{peer:$a.env(`commander_daemon`),storage:new Ga({methods:Ka(new Map)}),ephemeralIdentity:!0,securityLevel:ro.authenticated,defaultTimeout:Fh,reconnect:!0,carriers:[Od(()=>e.peek()==null?null:{url:pg(Ah)},{createWebSocket:t=>new WebSocket(t,[`${Ph}${e.take()}`])})]}),r=nh(ng,{onDiagnostic:()=>{},avatar:{type:`viewer`},connection:ch(n),assertOnAttach:()=>{}});try{await rg(n,r,15e3)}catch(e){throw r.detach(),n.dispose(),e}return{realm:r,control:async(e,n,r)=>{let i={ids:[...n]},a=e===`start`?eg.actionForId(`start`).request(r?.replaceSame===!0?{...i,wait:!1,replaceSame:!0}:{...i,wait:!1}):e===`stop`?eg.actionForId(`stop`).request(r?.withDependencies===!0?{...i,withDependencies:!0}:i):eg.actionForId(`restart`).request(i),o=await(await t.handleActionPayload(a)).waitForResultPayload();if(!o.result.ok)throw Error(`"${e}" was refused by the daemon`);let s=$h(o.result.output);if(s==null)throw Error(`"${e}" answered in a shape this build cannot read`);return s},ports:async e=>{let n=eg.actionForId(`ports`).request(e),r=await(await t.handleActionPayload(n)).waitForResultPayload();if(!r.result.ok)throw Error(`the daemon refused port inspection`);let i=yr(r.result.output);if(typeof i==`string`)throw Error(i);return i},setEnv:async(e,n)=>{let r=eg.actionForId(`setEnv`).request({processes:{[e]:n}}),i=await(await t.handleActionPayload(r)).waitForResultPayload();if(!i.result.ok)throw Error(`the daemon refused the env change`);let a=i.result.output.warnings;return Array.isArray(a)?a.filter(e=>typeof e==`string`):[]},runSuite:async e=>{let n=eg.actionForId(`runSuite`).request(e),r=await(await t.handleActionPayload(n)).waitForResultPayload();if(!r.result.ok)throw Error(`the daemon refused the run`);return r.result.output},saveFilter:async(e,n)=>{let r=eg.actionForId(`saveFilter`).request({filter:e,name:n});if(!(await(await t.handleActionPayload(r)).waitForResultPayload()).result.ok)throw Error(`the daemon refused the pin`)},removeFilter:async e=>{let n=eg.actionForId(`removeFilter`).request({id:e});if(!(await(await t.handleActionPayload(n)).waitForResultPayload()).result.ok)throw Error(`the daemon refused the removal`)},shutdown:async()=>{let e=eg.actionForId(`shutdown`).request({}),n=await(await t.handleActionPayload(e)).waitForResultPayload();if(!n.result.ok)throw Error(`the daemon refused shutdown`);let r=n.result.output;if(typeof r!=`object`||!r||!(`ok`in r)||r.ok!==!0)throw Error(`shutdown answered in a shape this build cannot read`)},dispose:()=>{r.detach(),n.dispose()}}}async function hg(){let e=await dg();return new WebSocket(pg(jh),[`${Ph}${e}`])}var gg=18,_g=500,vg=250,yg=[];function bg({view:e,runningIds:t,clearSignal:n,onSelectProc:r}){let i=ur(e),[a,o]=(0,d.useState)({key:i,rows:yg}),[s,c]=(0,d.useState)(`connecting`),[l,u]=(0,d.useState)(!0),[f,p]=(0,d.useState)(``),[m,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(!1),[v,y]=(0,d.useState)(!1),b=Rn(location.hostname),x=(0,d.useRef)(null),ee=(0,d.useRef)(0),S=(0,d.useRef)({socket:null,view:e,key:i,cursor:{},awaitingResnap:!0}),C=(0,d.useRef)(yg),w=(0,d.useCallback)(e=>{C.current=e,o({key:S.current.key,rows:e})},[]),T=a.key===i?a.rows:yg,te=(0,d.useCallback)(e=>{let t=e.socket;t==null||t.readyState!==t.OPEN||(e.awaitingResnap=e.cursor.seq==null&&e.cursor.s==null,t.send(fr(e.view,e.cursor)))},[]),ne=(0,d.useCallback)((e,t)=>{if(t.k===`search-result`){h(e=>e==null||e.id!==t.id?e:{...e,rows:t.entries.map(dr),complete:t.complete,scanned:t.scanned,running:!1});return}if(e.awaitingResnap){if(!mr(e.view,t))return;e.awaitingResnap=!1}let n=lr(e.view,C.current,e.cursor,t);n!=null&&(e.cursor=n.cursor,w(n.rows))},[w]);(0,d.useEffect)(()=>{let e=S.current,t=null,n=!1,r=r=>{n||(e.socket=null,c(r),t=setTimeout(i,_g))},i=()=>{hg().then(t=>{if(n){t.close();return}e.socket=t,t.addEventListener(`open`,()=>{c(`live`),te(e)}),t.addEventListener(`message`,t=>{let n=qn(String(t.data));n!=null&&ne(e,n)}),t.addEventListener(`close`,()=>r(`reconnecting`))},()=>r(`reconnecting`))};return i(),()=>{n=!0,t!=null&&clearTimeout(t),e.socket?.close(),e.socket=null}},[ne,te]),(0,d.useEffect)(()=>{let t=S.current,n=t.view;if(t.view=e,t.key===i)return;t.key=i,t.cursor={},t.awaitingResnap=!0,w(yg),u(!0);let r=t.socket;r==null||r.readyState!==r.OPEN||(r.send(pr(n)),te(t))},[e,i,w,te]);let re=(0,d.useRef)(null);re.current=m,(0,d.useEffect)(()=>{let e=f.trim();if(e===``){h(null);return}if(s!==`live`)return;let t=setTimeout(()=>{let t=S.current,n=t.socket;if(n==null||n.readyState!==n.OPEN)return;ee.current+=1;let r=`s${ee.current}`,i=re.current;i!=null&&n.send(JSON.stringify({k:`search-cancel`,id:i.id})),h({id:r,key:t.key,rows:yg,complete:!0,scanned:0,running:!0}),n.send(JSON.stringify({k:`search`,id:r,query:e,...t.view.kind===`proc`?{procs:[t.view.id]}:t.view.procs==null?{}:{procs:t.view.procs}}))},vg);return()=>clearTimeout(t)},[f,s,i]);let E=m!=null&&m.key===i?m:null,ie=E==null?T:E.rows,ae=Yt({count:ie.length,getScrollElement:()=>x.current,estimateSize:()=>gg,overscan:20}),oe=(0,d.useRef)(t);oe.current=t;let D=(0,d.useCallback)(()=>{let e=S.current;w(_r(e.view,C.current,{keepProcs:oe.current,now:Date.now()}).rows)},[w]),O=(0,d.useRef)(0);(0,d.useEffect)(()=>{n<=O.current||(O.current=n,D())},[n,D]),(0,d.useEffect)(()=>{ae.measure()},[v,ae]),(0,d.useEffect)(()=>{E==null&&l&&ie.length>0&&ae.scrollToIndex(ie.length-1)},[ie.length,l,E,ae]);let se=ae.getVirtualItems(),k=(0,d.useMemo)(()=>se.map(e=>({item:e,row:ie[e.index]})),[se,ie]);return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:`nc-chrome`,style:{alignItems:`center`,borderBottom:`1px solid ${N.border}`,display:`flex`,flexWrap:`wrap`,gap:10,padding:`8px 14px`},children:[(0,M.jsx)(`span`,{style:{color:N.textEmphasis,fontSize:13,minWidth:0,overflowWrap:`anywhere`},children:e.kind===`proc`?e.id:`merged timeline`}),(0,M.jsx)(`span`,{style:{color:N.textMuted,fontSize:11},children:E==null?`${T.length} lines`:Sg(E)}),s!==`live`&&(0,M.jsx)(`span`,{role:`status`,style:{color:N.warning,fontSize:11},children:s===`connecting`?`opening the log lane…`:`log lane dropped — retrying…`}),(0,M.jsx)(`input`,{value:f,onChange:e=>p(e.target.value),placeholder:`search history…`,"aria-label":`search log history`,style:{background:N.surfaceHeader,border:`1px solid ${N.border}`,borderRadius:6,color:N.text,fontSize:12,padding:`3px 8px`}}),(0,M.jsx)(`span`,{style:{flex:1}}),(0,M.jsx)(`button`,{type:`button`,"aria-pressed":g,title:`prefix every line with its timestamp`,onClick:()=>_(e=>!e),style:Cg(g),children:`ts`}),(0,M.jsx)(`button`,{type:`button`,"aria-pressed":v,title:`wrap long lines`,onClick:()=>y(e=>!e),style:Cg(v),children:`wrap`}),(0,M.jsx)(`button`,{type:`button`,title:`clear the pane — keeps the last lines of what is still running; history stays searchable (c)`,onClick:D,style:Cg(!1),children:`clear`}),(0,M.jsxs)(`label`,{style:{color:N.textMeta,fontSize:12},children:[(0,M.jsx)(`input`,{type:`checkbox`,checked:l,disabled:E!=null,onChange:e=>u(e.target.checked)}),` `,`follow`]})]}),(0,M.jsxs)(`div`,{ref:x,onScroll:e=>{let t=e.currentTarget,n=t.scrollHeight-t.scrollTop-t.clientHeight<gg*2;u(n)},style:{flex:1,fontFamily:`ui-monospace, SFMono-Regular, Menlo, monospace`,fontSize:12,overflow:`auto`,padding:`6px 0`},children:[ie.length===0&&(0,M.jsx)(`div`,{style:{color:N.textMuted,fontSize:12,padding:`2px 12px`},children:xg(s,e,E)}),(0,M.jsx)(`div`,{style:{height:ae.getTotalSize(),position:`relative`,width:`100%`},children:k.map(({item:e,row:t})=>t==null?null:(0,M.jsxs)(`div`,{"data-index":e.index,ref:v?ae.measureElement:void 0,style:{...v?{}:{height:gg},left:0,position:`absolute`,top:0,transform:`translateY(${e.start}px)`,whiteSpace:v?`pre-wrap`:`pre`,width:`100%`,paddingLeft:12,color:t.gap?N.warning:void 0},children:[g&&t.ts!=null&&(0,M.jsxs)(`span`,{style:{color:N.textMuted},children:[wg(t.ts),` `]}),t.prefix!=null&&(0,M.jsxs)(`button`,{type:`button`,"aria-label":`show only ${t.prefix} in the log`,title:`show only ${t.prefix}`,onClick:()=>r(t.prefix??``),style:{background:`transparent`,border:`none`,color:fn(t.prefix),cursor:`pointer`,font:`inherit`,padding:0},children:[t.prefix,` │`,` `]}),t.gap?t.text:or(tr(t.text),{allowLoopback:b}).map((e,t)=>e.kind===`link`?(0,M.jsx)(`a`,{className:`nc-log-link`,href:e.href,target:`_blank`,rel:`noreferrer`,children:e.pieces.map((e,t)=>(0,M.jsx)(`span`,{style:e.style,children:e.text},t))},t):(0,M.jsx)(`span`,{style:e.style,children:e.text},t))]},t.key))})]})]})}function xg(e,t,n){return e===`connecting`?`opening the log lane…`:e===`reconnecting`?`the log lane dropped — retrying, then the tail resumes`:n==null?t.kind===`proc`?`${t.id} has printed nothing yet`:t.procs!=null&&t.procs.length===0?`nothing matches the current filter`:`no output yet`:n.running?`searching the history…`:`no matches in the daemon's history`}function Sg(e){let t=`${e.rows.length} match${e.rows.length===1?``:`es`}`;return e.running?`${t} · searching…`:e.complete?t:`${t} · stopped after ${e.scanned} lines`}function Cg(e){return{background:e?N.surfaceHeader:`transparent`,border:`1px solid ${N.border}`,borderRadius:5,color:e?N.textEmphasis:N.textMeta,cursor:`pointer`,fontSize:11,padding:`1px 7px`}}function wg(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}var Tg=`nice-commander:scheme`;function Eg(){try{let e=localStorage.getItem(Tg);return e===`dark`||e===`light`||e===`system`?e:null}catch{return null}}function Dg(e){try{localStorage.setItem(Tg,e)}catch{}}var Og=`nice-commander:rail-width`;function kg(e){return Math.min(780,Math.max(300,Math.round(e)))}function Ag(){try{let e=localStorage.getItem(Og),t=e==null?NaN:Number(e);return Number.isFinite(t)?kg(t):440}catch{return 440}}function jg(e){try{localStorage.setItem(Og,String(e))}catch{}}var Mg=`nice-commander:collapsed-tag-groups`;function Ng(){try{let e=JSON.parse(localStorage.getItem(Mg)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function Pg(e){try{localStorage.setItem(Mg,JSON.stringify(e.slice(-64)))}catch{}}var Fg=30*6e4,Ig={succeeded:N.success,stopped:N.textMuted,failed:N.error,crashed:N.error,timedOut:N.error};function Lg(e,t,n,r){let i=e.endedAt??n;if(i<t||e.startedAt>n)return null;let a=Math.max(e.startedAt,t),o=Math.min(i,n);return{left:(a-t)/r,width:Math.max(0,o-a)/r,live:e.endedAt==null,...e.outcome==null?{}:{outcome:e.outcome},startedAt:e.startedAt,...e.endedAt==null?{}:{endedAt:e.endedAt}}}function Rg(e,t,n=Fg){let r=t-n,i=[];for(let[a,o]of Object.entries(e)){let e=o.recentRuns.map(e=>Lg(e,r,t,n)).filter(e=>e!=null);if(e.length===0)continue;let s=e.some(e=>e.live),c=0;for(let t of e)c=Math.max(c,t.endedAt??t.startedAt);i.push({id:a,live:s,activityAt:c,segments:e})}return i.sort((e,t)=>e.live===t.live?t.activityAt-e.activityAt:e.live?-1:1)}function zg(e){let t=e.filter(e=>e.live).length,n=e.reduce((e,t)=>e+t.segments.length,0);return`${t} live · ${n} run${n===1?``:`s`} in window`}var Bg=6e4;function Vg(e,t){let n=new Date(e.startedAt),r=String(n.getHours()).padStart(2,`0`),i=String(n.getMinutes()).padStart(2,`0`),a=(e.endedAt??t)-e.startedAt,o=[`started ${r}:${i}`,Hg(a)];return e.live?o.push(`running`):e.outcome!=null&&o.push(e.outcome),o.join(` · `)}function Hg(e){if(e<Bg)return`${Math.max(1,Math.round(e/1e3))}s`;let t=Math.floor(e/Bg),n=Math.round(e%Bg/1e3);return t<60?n===0?`${t}m`:`${t}m ${n}s`:`${Math.floor(t/60)}h ${t%60}m`}var Ug=1e3,Wg=[30,20,10],Gg=.4;function Kg({processes:e,origins:t,selected:n,onToggle:r}){let[i,a]=(0,d.useState)(()=>Date.now()),[o,s]=(0,d.useState)(!1),[c,l]=(0,d.useState)(new Set);(0,d.useEffect)(()=>{let e=setInterval(()=>a(Date.now()),Ug);return()=>clearInterval(e)},[]);let u=(0,d.useMemo)(()=>Rg(e,i),[e,i]),f=(0,d.useMemo)(()=>u.filter(e=>e.live||!c.has(e.id)),[u,c]),p=u.length-u.filter(e=>e.live).length;return(0,M.jsxs)(`section`,{"aria-label":`run timeline, last 30 minutes`,className:`nc-chrome nc-timeline-float`,children:[(0,M.jsxs)(`div`,{style:{alignItems:`baseline`,display:`flex`,gap:8},children:[(0,M.jsx)(`span`,{className:`nc-section-title`,style:{marginBottom:0},children:`timeline`}),(0,M.jsx)(`span`,{style:{color:N.textMuted,fontSize:11},children:u.length===0?`no runs in the last 30 min`:zg(u)}),(0,M.jsx)(`span`,{style:{flex:1}}),p>0&&!o&&(0,M.jsx)(`button`,{type:`button`,title:`dismiss every ended run from the strip`,onClick:()=>l(e=>{let t=new Set(e);for(let e of u)e.live||t.add(e.id);return t}),style:Yg,children:`clear ended`}),(0,M.jsx)(`button`,{type:`button`,"aria-expanded":!o,title:o?`expand the timeline`:`collapse the timeline`,onClick:()=>s(e=>!e),style:Yg,children:o?`▸`:`▾`})]}),!o&&u.length>0&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{"aria-hidden":`true`,style:{display:`flex`,color:N.textMuted,fontSize:9,marginBottom:2},children:[(0,M.jsx)(`span`,{style:{flex:`0 0 148px`}}),(0,M.jsxs)(`span`,{style:{flex:1,display:`flex`,justifyContent:`space-between`},children:[Wg.map(e=>(0,M.jsxs)(`span`,{children:[`−`,e,`m`]},e)),(0,M.jsx)(`span`,{children:`now`})]})]}),(0,M.jsx)(`div`,{style:{maxHeight:176,overflowY:`auto`},children:f.map(e=>(0,M.jsx)(qg,{row:e,now:i,origin:t.get(e.id),selected:n.has(e.id),onToggle:r,onDismiss:e=>l(t=>{let n=new Set(t);return n.add(e),n})},e.id))})]})]})}function qg({row:e,now:t,origin:n,selected:r,onToggle:i,onDismiss:a}){return(0,M.jsxs)(`div`,{"data-timeline-row":e.id,style:{alignItems:`center`,borderRadius:4,display:`flex`,gap:6,height:20,...r?{background:dn(N.system,10),outline:`1px solid ${dn(N.system,45)}`}:{}},children:[(0,M.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),title:r?`${e.id} — selected; click to release`:e.id,"aria-pressed":r,style:{background:`transparent`,border:`none`,color:r?N.textEmphasis:fn(e.id),cursor:`pointer`,flex:`0 0 140px`,fontSize:11,fontWeight:r?600:400,minWidth:0,overflow:`hidden`,padding:0,textAlign:`left`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:[r?`› `:``,n!=null&&(0,M.jsxs)(`span`,{"aria-hidden":`true`,title:`started by the ${n} run`,className:`nc-origin`,children:[`▸`,` `]}),e.id]}),(0,M.jsx)(`div`,{style:{background:N.surfaceHeader,border:`1px solid ${N.border}`,borderRadius:4,flex:1,height:12,minWidth:0,position:`relative`},children:e.segments.map(n=>(0,M.jsx)(Jg,{id:e.id,segment:n,now:t,selected:r,onToggle:i},n.startedAt))}),!e.live&&(0,M.jsx)(`button`,{type:`button`,"aria-label":`remove ${e.id} from the timeline`,title:`dismiss this finished process from the strip (a fresh run brings it back)`,onClick:()=>a(e.id),style:Yg,children:`×`})]})}function Jg({id:e,segment:t,now:n,selected:r,onToggle:i}){let a=Math.max(t.width*100,Gg);return(0,M.jsx)(rt,{config:{title:e,content:Vg(t,n),align:`edge`},children:(0,M.jsx)(`span`,{className:t.live?`nc-run-live`:void 0,"data-run-of":e,"data-run-outcome":t.live?`live`:t.outcome??`unknown`,onClick:()=>i(e),style:{background:t.live?void 0:Ig[t.outcome??`stopped`],borderRadius:3,bottom:1,cursor:`pointer`,display:`block`,left:`${t.left*100}%`,opacity:t.live?.95:r?1:.75,outline:r?`1px solid ${dn(N.system,60)}`:void 0,overflow:`hidden`,position:`absolute`,top:1,width:`${a}%`}})})}var Yg={background:`transparent`,border:`none`,color:N.textMuted,cursor:`pointer`,fontSize:11,padding:`0 4px`};function Xg({node:e,compact:t=!1}){let n=yn(e);return(0,M.jsxs)(`span`,{"aria-hidden":`true`,title:n.label,"data-process-indicator":n.indicator,className:`nc-process-indicator nc-indicator-${n.indicator}${t?` nc-indicator-compact`:``}`,style:{color:vn[n.tone],...n.indicator===`running`?{background:vn[n.tone]}:{}},children:[n.indicator===`success`&&(0,M.jsx)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,children:(0,M.jsx)(`path`,{d:`m4 8 2.5 2.5L12 5`})}),n.indicator===`failure`&&(0,M.jsx)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,children:(0,M.jsx)(`path`,{d:`m5 5 6 6m0-6-6 6`})}),n.indicator===`warning`&&(0,M.jsx)(`span`,{children:`!`}),n.indicator===`idle`&&n.label===`stopped`&&(0,M.jsx)(`span`,{children:`−`})]})}function Zg({members:e,processes:t}){return(0,M.jsx)(`span`,{"aria-hidden":`true`,className:`nc-member-dots`,children:e.map(e=>{let n=t[e];return(0,M.jsx)(`span`,{style:{display:`inline-flex`,flexShrink:0},title:`${e}: ${n?.state??`not-started`}`,children:n!=null&&(0,M.jsx)(Xg,{node:n,compact:!0})},e)})})}function Qg({filters:e,rows:t,processes:n,activeId:r,onOpen:i,onPin:a,onRemove:o}){return e.length===0?(0,M.jsx)(M.Fragment,{}):(0,M.jsxs)(`section`,{"aria-label":`saved tag groups`,style:{marginBottom:10},children:[(0,M.jsx)(`div`,{className:`nc-section-title`,children:`saved`}),(0,M.jsx)(`div`,{className:`nc-saved`,children:e.map(e=>{let s=Fn(e,t).map(e=>e.id),c=s.length===0;return(0,M.jsxs)(`span`,{className:`nc-saved-chip`,"data-saved-filter":In(e),"data-active":e.id===r,"data-pinned":e.pinned,children:[(0,M.jsxs)(`button`,{type:`button`,disabled:c,onClick:()=>i(e),title:c?`${e.terms.join(` `)} — matches nothing in the current config`:`${e.mode}: ${e.terms.join(` `)}${e.pinned?``:` — recent run`}`,className:`nc-saved-open`,children:[(0,M.jsxs)(`span`,{style:{color:e.pinned?N.text:N.textMuted,textDecoration:c?`line-through`:`none`},children:[e.pinned?`★`:`↺`,` `,In(e)]}),!c&&(0,M.jsx)(Zg,{members:s,processes:n})]}),!e.pinned&&(0,M.jsx)(`button`,{type:`button`,"aria-label":`pin ${In(e)}`,title:`pin — keep for later sessions`,onClick:()=>a(e),className:`nc-saved-action`,children:`☆`}),(0,M.jsx)(`button`,{type:`button`,"aria-label":`remove ${In(e)}`,title:`remove`,onClick:()=>o(e),className:`nc-saved-action`,children:`×`})]},e.id)})})]})}function $g(e){return e<6e4?`${Math.round(e/1e3)}s`:e<36e5?`${Math.round(e/6e4)}m`:`${(e/36e5).toFixed(1)}h`}var e_={stopped:N.textMuted,partial:N.warning,starting:N.system,ready:N.success,failed:N.error};function t_({members:e,processes:t}){let n=Bn(e,t);if(n==null){let n=zn(e,t);return(0,M.jsx)(`span`,{style:{color:e_[n],fontSize:11,whiteSpace:`nowrap`},children:n})}let r=e=>n.filter(t=>t.verdict===e).length,[i,a,o,s]=[r(`fail`),r(`pass`),r(`blocked`),r(`stopped`)],c=r(`running`)>0,l=e.find(e=>bn(t[e]?.state??``));return(0,M.jsx)(`span`,{style:{color:i>0?N.error:o>0?N.warning:c||a===n.length?N.success:N.textMuted,fontSize:11,minWidth:0,overflowWrap:`anywhere`},children:i>0?`${i} failed`:c?`${a}/${n.length} · ${l??`running`}…`:o>0?`${o} blocked`:s>0?`${a}/${n.length} passed · ${s} stopped`:a===0?`pending`:`${a}/${n.length} passed`})}var n_={pass:N.success,fail:N.error,blocked:N.warning,running:N.system,skipped:N.textMuted,pending:N.border};function r_({state:e,selected:t,onSelect:n,bulk:r,now:i}){let a=Object.entries(e.suites);return a.length===0?(0,M.jsx)(M.Fragment,{}):(0,M.jsxs)(`section`,{"aria-label":`suites`,style:{marginBottom:10},children:[(0,M.jsx)(`div`,{className:`nc-section-title`,children:`suites`}),(0,M.jsx)(`div`,{className:`nc-suites`,children:a.map(([a,o])=>(0,M.jsx)(a_,{name:a,suite:o,run:e.runs[a],state:e,selected:a===t,onSelect:n,bulk:r,now:i},a))})]})}function i_(e,t,n){let r=e.members.map(e=>{let r=n.processes[e],i=t?.members[e];if(i!=null&&(t?.endedAt==null||r==null))return{id:e,verdict:i};let a=r==null?`idle`:yn(r).indicator;return{id:e,verdict:a===`success`||a===`running`?`pass`:a===`failure`?`fail`:a===`warning`?`blocked`:a===`transition`?`running`:`pending`}});return t?.endedAt==null?r:[...r].sort((e,t)=>Number(t.verdict===`fail`)-Number(e.verdict===`fail`))}function a_({name:e,suite:t,run:n,state:r,selected:i,onSelect:a,bulk:o,now:s}){let c=n!=null&&n.endedAt==null,l=t.members.every(e=>r.processes[e]?.kind===`task`),u=Mn(t.members,r.processes),d=n?.outcome===`failed`?Object.entries(n.members).filter(([,e])=>e===`fail`||e===`blocked`).map(([e])=>e):[],f=c?N.system:n?.outcome===`failed`?N.error:N.border;return(0,M.jsxs)(`div`,{"data-suite-card":e,className:`nc-suite-card`,"data-selected":i,style:{background:i?N.surfaceSelected:dn(N.system,7),border:`1px solid ${i?N.system:f}`},children:[(0,M.jsxs)(`div`,{style:{alignItems:`center`,display:`flex`,gap:8,minWidth:0},children:[(0,M.jsx)(`button`,{type:`button`,disabled:o.busy||c,"aria-label":`run suite ${e}`,title:c?`running…`:`run ${e} — ${t.members.length} members, ${t.parallel} at a time${t.failFast?`, stops at the first failure`:``}`,onClick:()=>o.run({suite:e}),className:`nc-suite-play`,children:c?`◼`:`▶`}),(0,M.jsxs)(`button`,{type:`button`,"aria-pressed":i,onClick:()=>a(e),title:t.description??`${e} — show members below`,className:`nc-suite-identity`,children:[(0,M.jsx)(`span`,{style:{color:N.textEmphasis,fontSize:13,fontWeight:600},children:e}),(0,M.jsxs)(`span`,{style:{color:N.textMuted,fontSize:11},children:[`(`,t.members.length,`)`]}),(0,M.jsx)(`span`,{style:{flex:1}}),(0,M.jsx)(t_,{members:t.members,processes:r.processes})]}),!l&&u.stops.length>0&&(0,M.jsx)(`button`,{type:`button`,disabled:o.busy,title:`stop ${u.stops.length}: ${u.stops.join(`, `)}`+(u.kept.length>0?` · leaves ${u.kept.join(`, `)} (still needed elsewhere)`:``),onClick:()=>void o.act(`stop`,t.members,{withDependencies:!0}),className:`nc-quiet-button`,children:`down`})]}),(0,M.jsx)(`div`,{className:`nc-suite-progress`,"aria-hidden":`true`,children:i_(t,n,r).map(e=>(0,M.jsx)(`span`,{title:`${e.id}: ${e.verdict}`,className:e.verdict===`running`?`nc-run-live`:void 0,style:{background:n_[e.verdict]??N.border}},e.id))}),n!=null&&(0,M.jsxs)(`div`,{className:`nc-suite-meta`,children:[(0,M.jsxs)(`span`,{children:[c?`running ${$g(s-n.startedAt)}`:`${n.outcome??`ended`} in ${$g((n.endedAt??s)-n.startedAt)}`,n.previousDurationMs!=null&&` · last ${$g(n.previousDurationMs)}`]}),d.length>0&&(0,M.jsxs)(`button`,{type:`button`,disabled:o.busy,onClick:()=>o.run({ids:d}),className:`nc-quiet-button`,children:[`rerun `,d.length,` failed`]})]})]})}function o_(e,t){let n=[],r=new Set([e]),i=(e,a)=>{for(let o of t[e]?.detail.dependsOn??[])r.has(o)||(r.add(o),n.push({id:o,depth:a,missing:t[o]==null}),i(o,a+1))};i(e,1);let a=[],o=new Set([e]),s=(e,n)=>{for(let[r,i]of Object.entries(t))!i.detail.dependsOn.includes(e)||o.has(r)||(o.add(r),a.push({id:r,depth:n,missing:!1}),s(r,n+1))};return s(e,1),n.length===0&&a.length===0?null:{needs:n,neededBy:a}}var s_={background:`transparent`,border:`1px solid ${N.border}`,borderRadius:5,color:N.textMeta,cursor:`pointer`,fontSize:11,padding:`3px 8px`};function c_({id:e,ports:t,retry:n,replace:r}){let[i,a]=(0,d.useState)(null),[o,s]=(0,d.useState)(null),[c,l]=(0,d.useState)(!1),[u,f]=(0,d.useState)(null);async function p(n,r){l(!0),f(null),s(null);try{a(await t({ids:[e],...n?{token:n,force:r}:{}}))}catch(e){f(e.message)}finally{l(!1)}}return(0,M.jsxs)(`div`,{style:{marginTop:6,fontSize:12},children:[(0,M.jsx)(`button`,{style:s_,type:`button`,disabled:c,onClick:()=>void p(),children:c?`checking ports…`:`inspect ports`}),u&&(0,M.jsx)(`div`,{role:`alert`,style:{color:N.error},children:u}),i&&(0,M.jsxs)(`section`,{"aria-label":`port owners for ${e}`,style:{overflowWrap:`anywhere`},children:[i.warnings.map(e=>(0,M.jsx)(`div`,{role:`alert`,style:{color:N.warning},children:e},e)),i.listeners.length===0&&(0,M.jsxs)(`div`,{children:[`No visible listeners found.`,` `,(0,M.jsx)(`button`,{style:s_,type:`button`,disabled:c,onClick:()=>void n(),children:`retry start`})]}),i.listeners.map(e=>(0,M.jsxs)(`div`,{style:{borderTop:`1px solid ${N.border}`,paddingTop:6,marginTop:6},children:[(0,M.jsxs)(`div`,{children:[e.endpoint,` · `,e.host,`:`,e.port,` · PID `,e.pid]}),(0,M.jsxs)(`div`,{children:[e.command,` · parent PID `,e.ppid??`unknown`]}),(0,M.jsxs)(`div`,{children:[`cwd: `,e.cwd??`unavailable`]}),(0,M.jsxs)(`div`,{children:[`identity: `,e.startStamp??`unavailable`]}),(0,M.jsx)(`div`,{children:e.stray?`stray: this definition's own command, started outside the daemon — stopping ends its tree${e.strayRoot!=null&&e.strayRoot!==e.pid?` (root PID ${e.strayRoot})`:``}`:`not this definition's command — stop only if you know what it is`}),e.stray&&e.refusal==null&&(0,M.jsx)(`div`,{children:(0,M.jsx)(`button`,{style:s_,type:`button`,disabled:c,onClick:()=>{a(null),r()},children:`replace stray and start`})}),e.refusal?(0,M.jsx)(`div`,{children:e.refusal}):(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`button`,{style:s_,type:`button`,disabled:c,onClick:()=>s({listener:e,force:!1}),children:[`stop PID `,e.pid]}),` `,(0,M.jsxs)(`button`,{style:s_,type:`button`,disabled:c,onClick:()=>s({listener:e,force:!0}),children:[`force kill PID `,e.pid]})]})]},`${e.endpoint}:${e.pid}`))]}),o&&(0,M.jsxs)(`div`,{role:`alertdialog`,"aria-label":`Confirm listener termination`,style:{marginTop:8,color:N.warning,overflowWrap:`anywhere`},children:[(0,M.jsxs)(`p`,{children:[o.force?`Force kill`:`Stop`,` PID `,o.listener.pid,` (`,o.listener.command,`) holding `,o.listener.host,`:`,o.listener.port,`? This may affect other applications using this process.`,o.force?` Force kill does not allow cleanup.`:` Sends SIGTERM.`]}),(0,M.jsxs)(`button`,{style:s_,type:`button`,onClick:()=>void p(o.listener.token,o.force),children:[`confirm `,o.force?`force kill`:`stop`]}),` `,(0,M.jsx)(`button`,{style:s_,type:`button`,onClick:()=>s(null),children:`cancel`})]})]})}function l_({rows:e,processes:t,selected:n,onSelect:r,act:i,setEnv:a,ports:o,muted:s=!1,origins:c,roleOf:l,onHover:u}){return(0,M.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6},children:e.map(e=>(0,M.jsx)(u_,{row:e,processes:t,selected:n.has(e.id),onSelect:r,act:i,setEnv:a,ports:o,muted:s,origin:c.get(e.id),role:l(e.id),onHover:u},e.id))})}function u_({row:e,processes:t,selected:n,onSelect:r,act:i,setEnv:a,ports:o,muted:s,origin:c,role:l,onHover:u}){let[f,p]=(0,d.useState)(!1),{node:m}=e,h=m.startedAt!=null&&bn(m.state)?$g(Date.now()-m.startedAt):null,g=!bn(m.state)&&m.lastTask!=null?m.lastTask:null,_=o_(e.id,t),v=m.kind===`service`&&[`running`,`ready`,`unready`].includes(m.state);return(0,M.jsxs)(`div`,{"data-process-card":e.id,className:`nc-row`,"data-selected":n,"data-outcome":yn(m).indicator,"data-dep-role":l,"data-muted":s||void 0,onMouseEnter:()=>u(e.id),onMouseLeave:()=>u(null),onFocus:()=>u(e.id),onBlur:()=>u(null),style:{background:n?N.surfaceSelected:N.surface,border:`1px solid ${n?N.system:N.border}`,borderRadius:8,padding:`7px 12px`,position:`relative`},children:[(0,M.jsxs)(`div`,{style:{alignItems:`flex-start`,display:`flex`,gap:8,minWidth:0},children:[(0,M.jsxs)(`div`,{style:{alignItems:`center`,display:`flex`,flex:1,flexWrap:`wrap`,gap:8,minWidth:0},children:[(0,M.jsx)(d_,{id:e.id,deps:_,processes:t,row:e,selected:n,onSelect:r}),c!=null&&(0,M.jsxs)(`span`,{className:`nc-origin`,title:`started by the ${c} run`,children:[`▸ `,c]}),m.optIn&&(0,M.jsx)(`span`,{className:`nc-origin`,title:"opt-in — never started by a tag group, a suite's tag query, or `all`",children:`manual`}),e.chips.length>0&&(0,M.jsxs)(`span`,{title:e.chips.join(`
20
+ `),style:{background:dn(N.warning,12),border:`1px solid ${dn(N.warning,35)}`,borderRadius:4,color:N.warning,cursor:`default`,flex:`0 0 auto`,fontSize:10,padding:`0 5px`},children:[`⚠ `,e.chips.length]}),e.stickyOverrides.length>0&&(0,M.jsx)(`span`,{title:`sticky: ${e.stickyOverrides.join(`, `)} — applies to every start until cleared`,style:{background:dn(N.warning,12),border:`1px solid ${dn(N.warning,35)}`,borderRadius:4,color:N.warning,flex:`0 0 auto`,fontSize:10,padding:`0 5px`},children:e.stickyOverrides.length===1?`1 sticky env override`:`${e.stickyOverrides.length} sticky env overrides`})]}),(0,M.jsx)(p_,{id:e.id,live:bn(m.state),processes:t,act:i,open:f,onToggleOpen:()=>p(e=>!e)})]}),v&&(0,M.jsx)(v_,{row:e}),(h!=null||g!=null||m.detail.dependsOn.length>0)&&(0,M.jsxs)(`div`,{style:{alignItems:`center`,color:N.textMuted,display:`flex`,fontSize:11,gap:8,marginTop:2,whiteSpace:`nowrap`},children:[(0,M.jsx)(h_,{id:e.id,processes:t,onSelect:r}),h!=null&&(0,M.jsxs)(`span`,{children:[`up `,h]}),g!=null&&(0,M.jsxs)(`span`,{children:[g.outcome,g.durationMs==null?``:` in ${$g(g.durationMs)}`,` · ${$g(Date.now()-g.endedAt)} ago`]})]}),e.stickyOverrides.length>0&&(0,M.jsx)(`div`,{style:{marginTop:4},children:(0,M.jsx)(`button`,{type:`button`,title:`clear ${e.stickyOverrides.join(`, `)} — back to the config's values`,onClick:()=>void a(e.id,Object.fromEntries(e.stickyOverrides.map(e=>[e,null]))),style:{...S_,color:N.warning,fontSize:10,padding:`1px 6px`},children:`clear all`})}),(0,M.jsx)(__,{row:e}),m.blockedBy!=null&&(0,M.jsx)(g_,{reason:m.blockedBy,processes:t,onSelect:r}),(f||!bn(m.state))&&m.detail.endpoints.some(e=>e.ownership===`exclusive`)&&(0,M.jsx)(c_,{id:e.id,ports:o,retry:()=>i(`start`,[e.id]),replace:()=>i(`start`,[e.id],{replaceSame:!0})}),f&&(0,M.jsxs)(M.Fragment,{children:[e.chips.length>0&&(0,M.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:4,marginTop:6},children:e.chips.map(e=>(0,M.jsx)(`span`,{style:{background:dn(N.warning,12),border:`1px solid ${dn(N.warning,35)}`,borderRadius:4,color:N.warning,fontSize:11,padding:`1px 6px`},children:e},e))}),!v&&(0,M.jsx)(v_,{row:e}),(0,M.jsx)(y_,{row:e,setEnv:a})]})]})}function d_({id:e,deps:t,processes:n,row:r,selected:i,onSelect:a}){let o=(0,M.jsxs)(`button`,{type:`button`,"aria-pressed":i,onClick:()=>a(e),style:{alignItems:`center`,background:`transparent`,border:`none`,color:`inherit`,cursor:`pointer`,display:`flex`,flex:`0 1 auto`,gap:8,minWidth:0,overflow:`hidden`,padding:0,textAlign:`left`},children:[(0,M.jsx)(Xg,{node:r.node}),(0,M.jsx)(`span`,{style:{color:N.textEmphasis,fontWeight:600,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e}),t!=null&&(0,M.jsx)(`span`,{"aria-hidden":`true`,style:{color:N.textMuted,fontSize:10},title:`has a dependency tree — hover to see it`,children:`⬦`}),(0,M.jsx)(`span`,{style:{color:N.textMeta,fontSize:12},children:yn(r.node).label}),(0,M.jsx)(`span`,{style:{color:N.textMuted,fontSize:11},children:r.node.kind})]});return t==null?o:(0,M.jsx)(rt,{config:{title:`${e} — dependency tree`,content:(0,M.jsx)(f_,{deps:t,processes:n,onSelect:a}),align:`edge`,maxWidth:320},children:o})}function f_({deps:e,processes:t,onSelect:n}){let r=e=>e.map(e=>(0,M.jsx)(`div`,{style:{paddingLeft:(e.depth-1)*12},children:e.missing?(0,M.jsxs)(`span`,{style:{color:N.textMuted,fontSize:11},children:[e.id,` (not in config)`]}):(0,M.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),title:`select ${e.id}`,style:{alignItems:`center`,background:`transparent`,border:`none`,color:N.text,cursor:`pointer`,display:`flex`,fontSize:11,gap:6,padding:`1px 0`},children:[t[e.id]&&(0,M.jsx)(Xg,{node:t[e.id],compact:!0}),e.id]})},e.id));return(0,M.jsxs)(`div`,{children:[e.needs.length>0&&(0,M.jsxs)(`div`,{style:{marginBottom:e.neededBy.length>0?6:0},children:[(0,M.jsx)(`div`,{style:{color:N.textMuted,fontSize:10,marginBottom:2},children:`needs`}),r(e.needs)]}),e.neededBy.length>0&&(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`div`,{style:{color:N.textMuted,fontSize:10,marginBottom:2},children:`needed by`}),r(e.neededBy)]})]})}function p_({id:e,live:t,processes:n,act:r,open:i,onToggleOpen:a}){let o=t?Mn([e],n):null,s=o?.stops.filter(t=>t!==e)??[];return(0,M.jsxs)(`span`,{className:`nc-row-actions`,children:[!t&&(0,M.jsx)(`button`,{type:`button`,"aria-label":`start`,title:`start`,onClick:()=>void r(`start`,[e]),children:`▶`}),t&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`button`,{type:`button`,"aria-label":`restart`,title:`restart — a ready dependency is left alone`,onClick:()=>void r(`restart`,[e]),children:`↻`}),(0,M.jsx)(`button`,{type:`button`,"aria-label":`stop`,title:`stop`,onClick:()=>void r(`stop`,[e]),children:`■`})]}),s.length>0&&(0,M.jsxs)(`button`,{type:`button`,"aria-label":`stop with dependencies`,"data-stop-with-dependencies":!0,title:`stop with dependencies — also stops ${s.join(`, `)}`+(o!=null&&o.kept.length>0?` · leaves ${o.kept.join(`, `)} (still needed elsewhere)`:``),onClick:()=>void r(`stop`,[e],{withDependencies:!0}),children:[`■`,(0,M.jsx)(`span`,{"aria-hidden":`true`,children:`↳`})]}),(0,M.jsx)(`button`,{type:`button`,"aria-label":i?`less`:`detail`,"aria-expanded":i,title:i?`hide detail`:`detail — command, endpoints, env`,onClick:a,children:i?`▴`:`▾`})]})}var m_=3;function h_({id:e,processes:t,onSelect:n}){let r=t[e]?.detail.dependsOn??[];return r.length===0?(0,M.jsx)(M.Fragment,{}):(0,M.jsxs)(`span`,{className:`nc-dep-dots`,"data-dependency-dots":e,children:[(0,M.jsx)(`span`,{"aria-hidden":`true`,children:`↳`}),r.slice(0,m_).map(e=>{let r=t[e];return(0,M.jsx)(`button`,{type:`button`,"aria-label":`dependency ${e}: ${r?.state??`not in config`}`,title:`needs ${e} — ${r?.state??`not in config`}`,onClick:()=>n(e),children:r==null?`?`:(0,M.jsx)(Xg,{node:r,compact:!0})},e)}),r.length>m_&&(0,M.jsxs)(`span`,{title:r.slice(m_).join(`, `),children:[`+`,r.length-m_]})]})}function g_({reason:e,processes:t,onSelect:n}){let r=/"([^"]+)"/.exec(e)?.[1];return r==null||t[r]==null?(0,M.jsx)(M.Fragment,{}):(0,M.jsxs)(`button`,{type:`button`,onClick:()=>n(r),title:e,style:{...S_,color:N.warning,fontSize:10,marginTop:4,padding:`1px 6px`},children:[`blocked by `,r,` →`]})}function __({row:e}){let t=e.node.detail.timeoutMs,n=e.node.startedAt;if(e.node.kind!==`task`||t==null||n==null||!bn(e.node.state))return(0,M.jsx)(M.Fragment,{});let r=Math.min(1,(Date.now()-n)/t);return(0,M.jsx)(`div`,{role:`progressbar`,"aria-label":`elapsed ${$g(Date.now()-n)} of ${$g(t)} cap`,"aria-valuenow":Math.round(r*100),"aria-valuemin":0,"aria-valuemax":100,style:{background:N.surfaceHeader,borderRadius:2,height:3,marginTop:5,overflow:`hidden`},children:(0,M.jsx)(`div`,{style:{background:r>.8?N.warning:N.system,height:`100%`,width:`${r*100}%`}})})}function v_({row:e}){let t=Rn(location.hostname),n=Ln(e.node,t);return n.length===0?(0,M.jsx)(M.Fragment,{}):(0,M.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:6,marginTop:6},children:n.map(e=>e.href==null?(0,M.jsxs)(`span`,{style:w_,title:e.remote?`bound on the daemon's machine — forward the port to reach it from here`:void 0,children:[e.label,e.remote?` (remote)`:``]},e.name):(0,M.jsxs)(`a`,{href:e.href,title:`${e.name} — ${e.href} (opens in a new tab)`,target:`_blank`,rel:`noreferrer`,style:{...w_,color:N.system},children:[e.label,` ↗`]},e.name))})}function y_({row:e,setEnv:t}){let{detail:n}=e.node;return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`dl`,{style:{display:`grid`,fontSize:11,gap:`2px 8px`,gridTemplateColumns:`auto minmax(0, 1fr)`,margin:`8px 0 0`},children:[e.node.pid!=null&&(0,M.jsx)(x_,{label:`pid`,value:String(e.node.pid)}),(0,M.jsx)(x_,{label:`run`,value:n.command}),(0,M.jsx)(x_,{label:`cwd`,value:n.cwd}),n.ready!=null&&(0,M.jsx)(x_,{label:`ready`,value:n.ready}),n.dependsOn.length>0&&(0,M.jsx)(x_,{label:`needs`,value:n.dependsOn.join(`, `)})]}),n.envVars.length>0&&(0,M.jsx)(b_,{row:e,setEnv:t})]})}function b_({row:e,setEnv:t}){let[n,r]=(0,d.useState)({}),[i,a]=(0,d.useState)(!1),o=e.node.detail.envVars,s=Object.keys(n).length>0,c=async()=>{a(!0);try{await t(e.id,n),r({})}finally{a(!1)}};return(0,M.jsxs)(`div`,{style:{borderTop:`1px solid ${N.border}`,marginTop:8,paddingTop:8},children:[(0,M.jsx)(`div`,{style:{color:N.textMuted,fontSize:11,marginBottom:6},children:`env`}),(0,M.jsx)(`div`,{style:{display:`grid`,gap:6},children:o.map(i=>(0,M.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6},children:[(0,M.jsxs)(`label`,{htmlFor:`env-${e.id}-${i.name}`,style:{color:N.textMeta,flex:`0 0 40%`,fontSize:11},title:i.description,children:[i.name,i.required&&(0,M.jsx)(`span`,{style:{color:N.error},children:` *`}),i.source===`override`&&(0,M.jsx)(`span`,{title:`sticky override — applies to every start until cleared`,style:{background:dn(N.warning,12),border:`1px solid ${dn(N.warning,35)}`,borderRadius:4,color:N.warning,fontSize:10,marginLeft:6,padding:`0px 5px`},children:`sticky`})]}),i.values==null?(0,M.jsx)(`input`,{id:`env-${e.id}-${i.name}`,type:i.secret?`password`:`text`,value:n[i.name]??(i.secret?``:i.value??``),placeholder:i.secret&&i.source!==`unset`?`•••• set`:i.source,onChange:e=>r(t=>({...t,[i.name]:e.target.value})),style:C_}):(0,M.jsx)(`select`,{id:`env-${e.id}-${i.name}`,value:n[i.name]??i.value??``,onChange:e=>r(t=>({...t,[i.name]:e.target.value})),style:C_,children:i.values.map(e=>(0,M.jsx)(`option`,{value:e,children:e},e))}),(0,M.jsx)(`button`,{type:`button`,disabled:i.source!==`override`,title:`drop the override, back to the config's value`,onClick:()=>void t(e.id,{[i.name]:null}),style:{...S_,opacity:i.source===`override`?1:.35},children:`clear`})]},i.name))}),(0,M.jsxs)(`div`,{style:{alignItems:`center`,display:`flex`,gap:8,marginTop:8},children:[(0,M.jsx)(`button`,{type:`button`,disabled:!s||i,onClick:()=>void c(),style:S_,children:i?`saving…`:`save`}),(0,M.jsx)(`span`,{style:{color:N.textMuted,fontSize:10},children:`sticky — applies to every start until cleared`})]})]})}function x_({label:e,value:t}){return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`dt`,{style:{color:N.textMuted},children:e}),(0,M.jsx)(`dd`,{style:{color:N.textMeta,margin:0,overflowWrap:`anywhere`},children:t})]})}var S_={background:`transparent`,border:`1px solid ${N.border}`,borderRadius:5,color:N.textMeta,cursor:`pointer`,fontSize:11,padding:`1px 8px`},C_={background:N.surfaceSection,border:`1px solid ${N.border}`,borderRadius:4,color:N.textEmphasis,flex:1,fontSize:11,minWidth:0,padding:`2px 5px`},w_={background:N.surfaceSection,border:`1px solid ${N.borderStrong}`,borderRadius:4,color:N.textMeta,fontSize:11,padding:`1px 6px`,textDecoration:`none`,maxWidth:`100%`,overflowWrap:`anywhere`},T_=3,E_=e=>e.join(`,`);function D_({groups:e,processes:t,runs:n,savedFilters:r,filterFor:i,focused:a,onFocus:o,collapsed:s,onCollapse:c,selected:l,onSelect:u,bulk:f,onPin:p,setEnv:m,ports:h}){let[g,_]=(0,d.useState)(null),v=(0,d.useMemo)(()=>{let e=g==null?null:o_(g,t);return g==null||e==null?null:{self:g,upstream:new Set(e.needs.map(e=>e.id)),downstream:new Set(e.neededBy.map(e=>e.id))}},[g,t]),y=e=>{if(v!=null)return e===v.self?`self`:v.upstream.has(e)?`upstream`:v.downstream.has(e)?`downstream`:`unrelated`},b=(0,d.useMemo)(()=>Pn(n),[n]);return e.length===0?(0,M.jsx)(`div`,{style:{color:N.textMuted,padding:8},children:`no processes match this filter`}):(0,M.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:10},children:e.map((n,d)=>{let g=E_(n.signature),v=s.get(g)??(n.signature.length>0&&d>=T_),x=i(n.signature),ee=(e,n)=>(0,M.jsx)(l_,{rows:e,processes:t,selected:l,onSelect:u,act:f.act,setEnv:m,ports:h,muted:n,origins:b,roleOf:y,onHover:_});return(0,M.jsxs)(`section`,{"data-tag-group":g,"aria-label":`tag group ${g||`all`}`,children:[(n.signature.length>0||e.length>1)&&(0,M.jsx)(O_,{group:n,processes:t,filter:x,pinned:x!=null&&r.some(e=>e.pinned&&e.mode===x.mode&&rn(e.terms,x.terms)&&rn(e.bucket??[],x.bucket??[])),focused:a!=null&&rn(a,n.signature),onFocus:()=>o(n.signature),collapsed:v,onCollapse:()=>c(g,!v),bulk:f,onPin:p}),!v&&(0,M.jsxs)(M.Fragment,{children:[ee(n.members,!1),n.optIn.length>0&&(0,M.jsx)(`div`,{style:{marginTop:6},children:ee(n.optIn,!0)})]})]},g)})})}function O_({group:e,processes:t,filter:n,pinned:r,focused:i,onFocus:a,collapsed:o,onCollapse:s,bulk:c,onPin:l}){let u=e.members.map(e=>e.id),d=u.length>0&&e.members.every(e=>e.node.kind===`task`),f=e.members.some(e=>bn(e.node.state)),p=jn(u,t),m=Nn(u,t),h=[`start ${p.starts.length}`,...p.alreadyRunning.length>0?[`already running ${p.alreadyRunning.length} (skipped)`]:[],...p.dependencies.length>0?[`+${p.dependencies.length} dependencies: ${p.dependencies.join(`, `)}`]:[]].join(` · `),g=e.signature.map(e=>e.slice(e.indexOf(`=`)+1));return(0,M.jsxs)(`div`,{className:`nc-tag-group-heading`,"data-focused":i,children:[(0,M.jsxs)(`div`,{style:{alignItems:`center`,display:`flex`,gap:6,minWidth:0},children:[(0,M.jsx)(`button`,{type:`button`,"aria-expanded":!o,"aria-label":o?`expand`:`collapse`,onClick:s,className:`nc-caret`,children:o?`▸`:`▾`}),(0,M.jsxs)(`button`,{type:`button`,"aria-pressed":i,onClick:a,title:`scope the log pane to this tag group`,className:`nc-tag-group-identity`,children:[e.signature.length===0?(0,M.jsx)(`span`,{style:{color:N.textMuted,fontSize:11},children:`untagged`}):e.signature.map(e=>(0,M.jsx)(`span`,{className:`nc-signature-chip`,title:e,children:e.slice(e.indexOf(`=`)+1)},e)),(0,M.jsxs)(`span`,{style:{color:N.textMuted,fontSize:11,flexShrink:0},children:[u.length,e.optIn.length>0&&` · +${e.optIn.length} manual`]})]}),(0,M.jsx)(`span`,{style:{flex:1}}),(0,M.jsx)(t_,{members:u,processes:t}),u.length>0&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`button`,{type:`button`,disabled:c.busy,title:h,"data-tag-group-run":!0,onClick:()=>c.run({ids:u,...n==null?{}:{filter:n}}),className:`nc-quiet-button`,children:d?`▶ run`:`▲ up`}),!d&&f&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`button`,{type:`button`,disabled:c.busy,title:`restart these — a ready dependency outside the group is left alone`,onClick:()=>void c.act(`restart`,u),className:`nc-quiet-button`,children:`↻`}),(0,M.jsx)(`button`,{type:`button`,disabled:c.busy,title:m.length>0?`stop — leaves live dependents degraded: ${m.join(`, `)}`:`stop these`,"data-warn":m.length>0||void 0,onClick:()=>void c.act(`stop`,u),className:`nc-quiet-button`,children:`▼`})]})]}),n!=null&&(0,M.jsx)(`button`,{type:`button`,"aria-label":r?`pinned`:`pin this tag group`,title:r?`pinned`:`pin — keep this tag group for later sessions`,disabled:r,onClick:()=>l(n,g.join(` · `)),className:`nc-quiet-button`,children:r?`★`:`☆`})]}),!o&&(0,M.jsxs)(`div`,{className:`nc-tag-group-sub`,children:[(0,M.jsx)(Zg,{members:u,processes:t}),p.dependencies.length>0&&(0,M.jsxs)(`span`,{title:`started first, because members depend on them`,children:[`also starts: `,p.dependencies.join(`, `)]})]})]})}function k_({rows:e,tags:t,mode:n,onMode:r,onToggle:i,onClear:a}){let o=(0,d.useMemo)(()=>En(e),[e]),s=(0,d.useMemo)(()=>kn(e,t,n),[e,t,n]);return o.length===0?(0,M.jsx)(M.Fragment,{}):(0,M.jsxs)(`section`,{"aria-label":`tags`,style:{marginBottom:10},children:[(0,M.jsxs)(`div`,{style:{alignItems:`baseline`,display:`flex`,gap:8,marginBottom:4},children:[(0,M.jsx)(`span`,{className:`nc-section-title`,children:`tags`}),(0,M.jsx)(`span`,{className:`nc-segmented`,"data-match-mode":n,children:[`any`,`all`].map(e=>(0,M.jsx)(`button`,{type:`button`,"aria-pressed":n===e,title:e===`any`?`any — every partial match, strict matches on top`:`all — only processes carrying every selected tag`,onClick:()=>r(e),children:e},e))}),(0,M.jsx)(`span`,{style:{flex:1}}),t.length>0&&(0,M.jsxs)(`button`,{type:`button`,onClick:a,title:`clear ${t.join(`, `)}`,style:{background:`transparent`,border:`none`,color:N.textMuted,cursor:`pointer`,fontSize:11,padding:0},children:[`× clear `,t.length]})]}),(0,M.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,maxHeight:160,overflowY:`auto`},children:o.map(e=>(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`div`,{style:{color:N.textMuted,fontSize:10,letterSpacing:.4,marginBottom:3,overflow:`hidden`,textOverflow:`ellipsis`,textTransform:`uppercase`,whiteSpace:`nowrap`},title:e.key,children:e.key}),(0,M.jsx)(`span`,{style:{display:`flex`,flexWrap:`wrap`,gap:4},children:e.values.map(n=>{let r=`${e.key}=${n}`,a=t.includes(r),o=s.get(r)??0;return(0,M.jsxs)(`button`,{type:`button`,"aria-pressed":a,title:`${r} — ${o} process${o===1?``:`es`}`,"data-tag-chip":r,onClick:()=>i(r),style:{background:a?N.system:N.surfaceHeader,border:`1px solid ${N.border}`,borderRadius:999,color:a?N.void:N.textMeta,cursor:`pointer`,fontSize:11,opacity:o===0&&!a?.45:1,padding:`1px 9px`,maxWidth:`100%`,minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:[n,(0,M.jsx)(`span`,{style:{fontSize:10,marginLeft:5,opacity:.7},children:o})]},n)})})]},e.key))})]})}var A_=(e,t)=>{let n=e.get(t);if(n==null||n===``)return;let r=n.split(`,`).filter(Boolean);return r.length>0?r:void 0};function j_(e){let t=new URLSearchParams(e.startsWith(`#`)?e.slice(1):e),n={},r=A_(t,`sel`);r!=null&&(n.selected=r);let i=A_(t,`tags`);i!=null&&(n.tags=i);let a=A_(t,`bucket`);a!=null&&(n.bucket=a);for(let e of[`suite`,`q`,`by`]){let r=t.get(e);r!=null&&r!==``&&(n[e]=r)}return t.get(`mode`)===`all`&&(n.mode=`all`),n}function M_(e){let t=new URLSearchParams;e.selected!=null&&e.selected.length>0&&t.set(`sel`,e.selected.join(`,`)),e.suite!=null&&e.suite!==``&&t.set(`suite`,e.suite),e.q!=null&&e.q!==``&&t.set(`q`,e.q),e.tags!=null&&e.tags.length>0&&t.set(`tags`,e.tags.join(`,`)),e.mode===`all`&&t.set(`mode`,`all`),e.bucket!=null&&e.bucket.length>0&&t.set(`bucket`,e.bucket.join(`,`)),e.by!=null&&e.by!==``&&t.set(`by`,e.by);let n=t.toString();return n===``?``:`#${n}`}function N_(){let[e,t]=(0,d.useState)({kind:`connecting`}),[n,r]=(0,d.useState)(null),[i]=(0,d.useState)(()=>j_(location.hash)),[a,o]=(0,d.useState)(i.tags??[]),[s,c]=(0,d.useState)(i.q??``),[l,u]=(0,d.useState)(i.selected??[]),[f,p]=(0,d.useState)(i.mode??`any`),[m,h]=(0,d.useState)(i.by??null),[g,_]=(0,d.useState)(i.bucket??null),[v,y]=(0,d.useState)(i.suite??null),[b,x]=(0,d.useState)(()=>new Map(Ng().map(e=>[e,!0]))),[ee,S]=(0,d.useState)(!1),[C,w]=(0,d.useState)(null),[T,te]=(0,d.useState)(null),[ne,re]=(0,d.useState)(null),[E,ie]=(0,d.useState)(0),[ae,oe]=(0,d.useState)({status:`connecting`,hasBeenLive:!1}),[D,O]=(0,d.useState)(!1),[se,k]=(0,d.useState)(!1),ce=(0,d.useRef)(!1),[le,ue]=(0,d.useState)(()=>{let e=document.documentElement.getAttribute(Ce);return e===`light`||e===`system`?e:`dark`}),[A,de]=(0,d.useState)(Ag),fe=(0,d.useRef)(null);(0,d.useEffect)(()=>{fe.current?.style.setProperty(`--nc-rail-w`,`${A}px`)},[A]);let pe=(0,d.useRef)(null),me=(0,d.useRef)([]),he=(0,d.useRef)(null),ge=(0,d.useRef)([]),_e=(0,d.useRef)([]),ve=(0,d.useRef)(null),ye=(0,d.useRef)(!1),be=(0,d.useRef)(null);(0,d.useEffect)(()=>{let e=!1,n=null;return mg().then(i=>{if(e){i.dispose();return}n=i,t({kind:`live`,session:i}),r(i.realm.store.state),i.realm.store.subscribe(()=>r({...i.realm.store.state})),oe({status:i.realm.status,hasBeenLive:i.realm.hasBeenLive}),i.realm.subscribeStatus((e,t)=>oe({status:e,hasBeenLive:t.hasBeenLive}))},n=>{e||t({kind:`lost`,message:n.message})}),()=>{e=!0,n?.dispose()}},[]);let[xe,Se]=(0,d.useState)(()=>Date.now());(0,d.useEffect)(()=>{let e=setInterval(()=>Se(Date.now()),5e3);return()=>clearInterval(e)},[]),(0,d.useEffect)(()=>{let e=n?.configName;e!=null&&(document.title=`${e} · nice-commander`)},[n?.configName]);let Te=(0,d.useMemo)(()=>n==null?[]:Cn(n,xe),[n,xe]),Ee=(0,d.useMemo)(()=>{if(v==null)return Te;let e=n?.suites[v]?.members;return e==null?Te:wn(Te,e)},[Te,n,v]),De=(0,d.useMemo)(()=>An(Ee,a,f,s),[Ee,a,f,s]),Oe=(0,d.useMemo)(()=>En(Te).map(e=>e.key),[Te]),ke=(0,d.useMemo)(()=>On(De,a,f,v==null?m:null),[De,a,f,m,v]),Ae=(0,d.useMemo)(()=>g==null?void 0:ke.find(e=>rn(e.signature,g)),[ke,g]),je=(0,d.useMemo)(()=>new Set(Te.filter(e=>bn(e.node.state)).map(e=>e.id)),[Te]);(0,d.useEffect)(()=>{v!=null&&n!=null&&n.suites[v]==null&&y(null)},[n,v]);let Me=(0,d.useMemo)(()=>l.length===1?{kind:`proc`,id:l[0]}:l.length>1?{kind:`merged`,procs:[...l].sort()}:Ae==null?{kind:`merged`,procs:a.length>0||s.trim()!==``||v!=null?De.map(e=>e.id).sort():null}:{kind:`merged`,procs:Ae.members.map(e=>e.id).sort()},[l,a,s,De,v,Ae]),Ne=(0,d.useCallback)(async(t,n,r)=>{if(!(e.kind!==`live`||ce.current||n.length===0)){te(t),re(null);try{let{results:i,warnings:a}=await e.session.control(t,n,r),o=i.filter(e=>e.outcome===`failed`||e.outcome===`blocked`),s=t===`start`?i.filter(e=>e.outcome===`spawned`):[],c=[s.length>0?`${t}: ${i.length} process(es), ${s.length} running — the grid shows progress`:`${t}: ${i.length} process(es)`,...o.map(e=>`✗ ${e.id} — ${e.outcome}${e.reason==null?``:`: ${e.reason}`}`),...a.map(e=>`⚠ ${e}`)];re(c.join(`
21
21
  `))}catch(e){re(`${t} failed: ${e.message}`)}finally{te(null)}}},[e]),Pe=(0,d.useMemo)(()=>({busy:T!=null,act:Ne,run:t=>{if(e.kind!==`live`||ce.current)return;te(`run`),re(null);let n=`suite`in t?{suite:t.suite}:{ids:[...t.ids],...t.filter==null?{}:{filter:t.filter}};e.session.runSuite(n).then(e=>{e.accepted||re(`run refused: ${e.reason??`unknown reason`}`)},e=>re(`run failed: ${e.message}`)).finally(()=>te(null))}}),[Ne,T,e]),Fe=(0,d.useCallback)(e=>{if(y(null),c(``),o(e.terms),p(e.mode),_(e.bucket??null),e.bucket!=null){let t=E_(Dn(e.bucket));x(e=>new Map(e).set(t,!1))}},[]),Ie=async()=>{if(!(e.kind!==`live`||ce.current)){ce.current=!0,te(`shutdown`),re(null);try{await e.session.shutdown(),k(!1),t({kind:`shutdown`}),e.session.dispose()}catch(e){k(!1),re(`shutdown failed: ${e.message}`),ce.current=!1}finally{te(null)}}},Le=(0,d.useCallback)(async(t,n)=>{if(!(e.kind!==`live`||ce.current)){re(null);try{let r=await e.session.setEnv(t,n);re(r.length>0?r.map(e=>`⚠ ${e}`).join(`
22
22
  `):`${t}: saved — sticky until cleared, and it applies on the next start`)}catch(e){re(`env change failed: ${e.message}`)}}},[e]);me.current=l,he.current=v,ge.current=ke.map(e=>e.signature);let Re=(0,d.useMemo)(()=>new Set(l),[l]),ze=(0,d.useCallback)(e=>u(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),[]);_e.current=ke.flatMap(e=>e.members.map(e=>e.id)),ve.current=n,ye.current=D||se||ee||C!=null,be.current=Ne,(0,d.useEffect)(()=>{let e=M_({...l.length>0?{selected:l}:{},...v==null?{}:{suite:v},...s.trim()===``?{}:{q:s},...a.length>0?{tags:a}:{},mode:f,...g==null?{}:{bucket:g},...m==null?{}:{by:m}});history.replaceState(null,``,e===``?location.pathname:e)},[l,v,s,a,f,g,m]),(0,d.useEffect)(()=>{let e=e=>{if(ce.current||ye.current)return;let t=e.target,n=t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLElement&&t.isContentEditable;if(e.key===`Escape`){if(n)t.blur();else if(ye.current)return;else me.current.length>0?u([]):(y(null),_(null));return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`){e.preventDefault(),S(!0);return}if(!(n||e.metaKey||e.ctrlKey||e.altKey)){if(e.key===`a`){p(e=>e===`any`?`all`:`any`);return}if(e.key===`[`||e.key===`]`){let t=ge.current;if(t.length===0)return;_(n=>{let r=n==null?-1:t.findIndex(e=>rn(e,n)),i=e.key===`]`?r+1:r<0?t.length-1:r-1;return i<0||i>=t.length?null:t[i]??null});return}if(e.key===`/`){e.preventDefault(),pe.current?.focus();return}if(e.key===`?`){O(!0);return}if(e.key===`c`){ie(e=>e+1);return}if(e.key===`g`){let e=Object.keys(ve.current?.suites??{});if(e.length===0)return;let t=he.current,n=(t==null?-1:e.indexOf(t))+1;y(n>=e.length?null:e[n]??null);return}if(e.key>=`1`&&e.key<=`9`){let t=_e.current[Number(e.key)-1];t!=null&&ze(t);return}me.current.length!==0&&(e.key===`r`&&be.current?.(`restart`,[...me.current]),e.key===`s`&&be.current?.(`stop`,[...me.current]),e.key===`u`&&be.current?.(`start`,[...me.current]))}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[ze]);let Be=(0,d.useMemo)(()=>n==null?[]:[...Object.keys(n.suites).flatMap(e=>[{label:e,hint:`suite — show`,run:()=>y(e)},{label:`run ${e}`,hint:`suite — run`,run:()=>Pe.run({suite:e})}]),...n.savedFilters.map(e=>({label:In(e),hint:e.pinned?`pin`:`recent run`,run:()=>Fe(e)})),...En(Te).flatMap(({key:e,values:t})=>t.map(t=>({label:`${e}=${t}`,hint:`tag — filter`,run:()=>{y(null),_(null),o([`${e}=${t}`])}}))),...Te.map(e=>({label:e.id,hint:`${e.node.kind} — ${e.node.state}`,run:()=>u([e.id])}))],[n,Te,Pe,Fe]);if(e.kind===`shutdown`)return(0,M.jsx)(R_,{children:(0,M.jsxs)(`div`,{role:`status`,style:{textAlign:`center`,padding:24},children:[(0,M.jsx)(`strong`,{children:`Shutdown accepted`}),(0,M.jsx)(`p`,{children:`The daemon is stopping all managed processes and will exit when cleanup finishes.`}),(0,M.jsxs)(`p`,{children:[`You can close this tab. Run `,(0,M.jsx)(`code`,{children:`nice-commander ui`}),` to start it again.`]})]})});if(e.kind===`connecting`)return(0,M.jsx)(R_,{children:`connecting…`});if(e.kind===`lost`)return(0,M.jsxs)(R_,{children:[`could not reach the daemon — `,e.message]});if(n==null)return(0,M.jsx)(R_,{children:`waiting for the status realm…`});let j=Te.filter(e=>e.node.stale&&!e.node.removed).map(e=>e.id);return(0,M.jsxs)(`div`,{className:`nc-shell`,style:{display:`flex`,flexDirection:`column`,height:`100%`},children:[(0,M.jsxs)(`header`,{className:`nc-chrome nc-header`,style:{display:`flex`,alignItems:`center`,gap:12,padding:`10px 16px`,borderBottom:`1px solid ${N.border}`,flexWrap:`wrap`},children:[(0,M.jsx)(`strong`,{style:{color:N.textEmphasis},children:n?.configName??`nice-commander`}),(0,M.jsxs)(`span`,{style:{color:N.textMuted,fontSize:12},children:[`generation `,n.generation,` · revision `,n.configRevisionHash.slice(0,8)]}),(0,M.jsx)(`input`,{ref:pe,value:s,onChange:e=>c(e.target.value),placeholder:`filter ids… (/)`,"aria-label":`filter ids`,style:{background:N.surfaceHeader,border:`1px solid ${N.border}`,borderRadius:6,color:N.text,padding:`4px 8px`}}),(0,M.jsx)(`span`,{style:{flex:1}}),(0,M.jsx)(F_,{link:ae}),(0,M.jsxs)(`button`,{type:`button`,title:`colour scheme: dark → light → system (persisted for this browser)`,onClick:()=>{let e=le===`dark`?`light`:le===`light`?`system`:`dark`;ue(e),document.documentElement.setAttribute(Ce,e),document.documentElement.setAttribute(we,`persisted`),Dg(e)},style:I_,children:[`theme: `,le]}),(0,M.jsx)(`button`,{type:`button`,title:`keyboard shortcuts`,onClick:()=>O(!0),style:I_,children:`keys`}),(0,M.jsx)(`button`,{type:`button`,title:`go to a process, tag, suite or pin (⌘K / Ctrl+K)`,onClick:()=>S(!0),style:I_,children:`go to… ⌘K`}),(0,M.jsx)(`button`,{type:`button`,disabled:T!=null||ae.status!==`live`,onClick:()=>k(!0),title:`Shut down this daemon and all its managed processes, including hidden tasks`,style:{...I_,color:N.error},children:`shutdown daemon`})]}),n.configError.length>0&&(0,M.jsxs)(z_,{tone:N.error,children:[`config reload failed — the last good config is still live:`,n.configError.map(e=>(0,M.jsxs)(`div`,{children:[`· `,e]},e))]}),ne!=null&&(0,M.jsx)(z_,{tone:N.warning,children:(0,M.jsxs)(`div`,{style:{alignItems:`flex-start`,display:`flex`,gap:10},children:[(0,M.jsx)(`span`,{style:{flex:1},children:ne}),(0,M.jsx)(`button`,{type:`button`,"aria-label":`dismiss`,onClick:()=>re(null),style:{...I_,padding:`0 7px`},children:`×`})]})}),j.length>0&&(0,M.jsx)(z_,{tone:N.warning,children:(0,M.jsxs)(`div`,{style:{alignItems:`center`,display:`flex`,gap:10},children:[(0,M.jsxs)(`span`,{children:[j.length,` process`,j.length===1?``:`es`,` running an old config revision: `,j.join(`, `)]}),(0,M.jsx)(`span`,{style:{flex:1}}),(0,M.jsxs)(`button`,{type:`button`,disabled:T!=null,onClick:()=>void Ne(`restart`,j),style:I_,children:[`restart `,j.length,` stale`]})]})}),(0,M.jsxs)(`div`,{className:`nc-main`,children:[(0,M.jsxs)(`div`,{className:`nc-rail`,ref:fe,children:[(0,M.jsx)(Vn,{rows:De}),(0,M.jsx)(r_,{state:n,selected:v,onSelect:e=>y(t=>t===e?null:e),bulk:Pe,now:xe}),(0,M.jsx)(Qg,{filters:n.savedFilters,rows:Te,processes:n.processes,activeId:n.savedFilters.find(e=>e.mode===f&&rn(e.terms,a)&&rn(e.bucket??[],g??[]))?.id??null,onOpen:Fe,onPin:e=>w({filter:e,name:In(e)}),onRemove:t=>{e.kind===`live`&&e.session.removeFilter(t.id).catch(e=>re(`remove failed: ${e.message}`))}}),(0,M.jsx)(k_,{rows:Te,tags:a,mode:f,onMode:p,onToggle:e=>{_(null),o(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},onClear:()=>{_(null),o([])}}),(0,M.jsxs)(`div`,{className:`nc-procs-heading`,children:[(0,M.jsx)(`span`,{className:`nc-section-title`,children:`processes`}),(0,M.jsx)(`span`,{style:{color:N.textMuted,fontSize:11},children:De.length}),(0,M.jsx)(`span`,{style:{flex:1}}),a.length===0&&v==null&&(0,M.jsxs)(`label`,{style:{color:N.textMuted,fontSize:11},children:[`group by`,` `,(0,M.jsxs)(`select`,{value:m??``,"aria-label":`group processes by tag key`,onChange:e=>h(e.target.value===``?null:e.target.value),className:`nc-select`,children:[(0,M.jsx)(`option`,{value:``,children:`none`}),Oe.map(e=>(0,M.jsx)(`option`,{value:e,children:e},e))]})]})]}),(0,M.jsxs)(`div`,{className:`nc-procs`,children:[v!=null&&(0,M.jsxs)(`div`,{style:{alignItems:`center`,color:N.textMeta,display:`flex`,fontSize:11,gap:6,marginBottom:6},children:[(0,M.jsxs)(`span`,{style:{minWidth:0,overflowWrap:`anywhere`},children:[`suite: `,v,` (`,De.length,`) — dependency order`]}),(0,M.jsx)(`button`,{type:`button`,"aria-label":`clear suite ${v}`,onClick:()=>y(null),style:{background:`transparent`,border:`none`,color:N.textMuted,cursor:`pointer`,fontSize:11,padding:`0 2px`},children:`×`})]}),(0,M.jsx)(D_,{groups:ke,processes:n.processes,runs:n.runs,savedFilters:n.savedFilters,filterFor:e=>e.length===0?null:a.length>0?{mode:f,terms:Dn(a),bucket:[...e]}:{mode:`any`,terms:[...e]},focused:g,onFocus:e=>_(t=>t!=null&&rn(t,e)?null:[...e]),collapsed:b,onCollapse:(e,t)=>x(n=>{let r=new Map(n).set(e,t);return Pg([...r].filter(([,e])=>e).map(([e])=>e)),r}),selected:Re,onSelect:ze,bulk:Pe,onPin:(e,t)=>w({filter:e,name:t}),setEnv:Le,ports:async t=>{if(e.kind!==`live`)throw Error(`Daemon is not connected`);return e.session.ports(t)}})]})]}),(0,M.jsx)(L_,{width:A,onChange:de,onCommit:e=>jg(e)}),(0,M.jsxs)(`div`,{className:`nc-logs`,children:[(0,M.jsx)(Kg,{processes:n.processes,origins:Pn(n.runs),selected:Re,onToggle:ze}),(0,M.jsx)(bg,{view:Me,runningIds:je,clearSignal:E,onSelectProc:e=>u([e])})]})]}),(0,M.jsxs)(gt,{open:se,onClose:()=>{ce.current||k(!1)},title:`Shut down ${n.configName}?`,description:`This stops all tasks and services managed by this daemon, including processes hidden by filters or suites, then exits the daemon.`,children:[(0,M.jsxs)(`p`,{children:[je.size,` active process(es). This dashboard will disconnect.`]}),(0,M.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8},children:[(0,M.jsx)(`button`,{type:`button`,disabled:T===`shutdown`,onClick:()=>k(!1),style:I_,children:`cancel`}),(0,M.jsx)(`button`,{type:`button`,disabled:T===`shutdown`,onClick:()=>void Ie(),style:{...I_,color:N.error},children:T===`shutdown`?`shutting down…`:`shut down daemon and all tasks`})]})]}),(0,M.jsx)(Wn,{open:ee,onClose:()=>S(!1),entries:Be}),(0,M.jsx)(gt,{open:C!=null,onClose:()=>w(null),title:`pin this tag group`,description:"Saved with this daemon's state, so every tab and later session has it. `nice-commander up @name` selects it from the CLI.",children:(0,M.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),!(C==null||e.kind!==`live`)&&(e.session.saveFilter(C.filter,C.name).catch(e=>re(`pin failed: ${e.message}`)),w(null))},style:{display:`flex`,gap:8},children:[(0,M.jsx)(`input`,{value:C?.name??``,"aria-label":`pin name`,maxLength:48,onChange:e=>w(t=>t==null?null:{...t,name:e.target.value}),className:`nc-palette-input`}),(0,M.jsx)(`button`,{type:`submit`,style:I_,children:`pin`})]})}),(0,M.jsx)(gt,{open:D,onClose:()=>O(!1),title:`keyboard shortcuts`,description:`All keys are plain presses and never fire while typing in a field.`,children:(0,M.jsx)(`table`,{style:{borderCollapse:`collapse`,fontSize:12,width:`100%`},children:(0,M.jsx)(`tbody`,{children:P_.map(([e,t])=>(0,M.jsxs)(`tr`,{children:[(0,M.jsx)(`td`,{style:{color:N.textEmphasis,padding:`3px 12px 3px 0`,whiteSpace:`nowrap`},children:(0,M.jsx)(`code`,{children:e})}),(0,M.jsx)(`td`,{style:{color:N.textMeta,padding:`3px 0`},children:t})]},e))})})})]})}var P_=[[`/`,`focus the id filter`],[`⌘K / Ctrl+K`,`go to a process, tag, suite or pin`],[`1–9`,`toggle the nth visible process in the selection`],[`a`,`flip the tag filter between any and all`],[`[ / ]`,`move the focus across tag groups (scopes the log pane)`],[`g`,`cycle suite selection (then release)`],[`c`,`clear the log pane (keeps the last lines of running processes)`],[`r / s / u`,`restart / stop / start the whole selection`],[`Esc`,`close dialogs, then clear the selection, then the suite and focus`]];function F_({link:e}){let t=e.status===`live`?`live`:e.status===`detached`?`detached`:e.hasBeenLive?`reconnecting…`:`connecting…`,n=e.status===`live`?N.success:e.status===`detached`?N.error:e.hasBeenLive?N.warning:N.textMuted;return(0,M.jsxs)(`span`,{role:`status`,title:`the live link to the daemon`,style:{alignItems:`center`,color:n,display:`inline-flex`,fontSize:11,gap:5},children:[(0,M.jsx)(`span`,{"aria-hidden":`true`,style:{background:n,borderRadius:999,height:7,width:7}}),t]})}var I_={background:N.surfaceHeader,border:`1px solid ${N.border}`,borderRadius:6,color:N.text,cursor:`pointer`,fontSize:12,padding:`4px 10px`};function L_({width:e,onChange:t,onCommit:n}){let r=(0,d.useRef)(null),[i,a]=(0,d.useState)(!1),o=()=>{r.current!=null&&(r.current=null,a(!1),document.body.style.userSelect=``,n(e))};return(0,M.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`resize the process rail`,"aria-valuenow":e,"aria-valuemin":300,"aria-valuemax":780,tabIndex:0,className:`nc-gutter`,"data-dragging":i||void 0,title:`drag to resize · arrows nudge · double-click resets`,onPointerDown:t=>{t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),r.current={startX:t.clientX,startWidth:e},a(!0),document.body.style.userSelect=`none`},onPointerMove:e=>{let n=r.current;n!=null&&t(kg(n.startWidth+e.clientX-n.startX))},onPointerUp:o,onPointerCancel:o,onLostPointerCapture:o,onDoubleClick:()=>{t(440),n(440)},onKeyDown:r=>{let i=r.key===`ArrowLeft`?-16:r.key===`ArrowRight`?16:null;if(i!=null){r.preventDefault();let a=kg(e+i);t(a),n(a)}else r.key===`Home`&&(r.preventDefault(),t(440),n(440))}})}function R_({children:e}){return(0,M.jsx)(`div`,{style:{alignItems:`center`,display:`flex`,height:`100%`,justifyContent:`center`,color:N.textMeta},children:e})}function z_({tone:e,children:t}){return(0,M.jsx)(`div`,{style:{background:N.surfaceHeader,borderBottom:`1px solid ${N.border}`,borderLeft:`3px solid ${e}`,color:N.text,fontSize:13,padding:`8px 14px`,whiteSpace:`pre-wrap`},children:t})}var B_=Eg();St(Be,{document}),document.documentElement.setAttribute(Ce,B_??Be.defaultScheme),document.documentElement.setAttribute(we,B_==null?`default`:`persisted`);var V_=document.getElementById(`root`);V_!=null&&(0,$t.createRoot)(V_).render((0,M.jsx)(d.StrictMode,{children:(0,M.jsx)(N_,{})}));
23
- //# sourceMappingURL=index-XAXsvgf4.js.map
23
+ //# sourceMappingURL=index-CP-c9YFT.js.map